@ipul-labs/forge 1.35.0 → 1.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +13 -6
  2. package/dist/assets/{index-BmEuPeOG.js → index-BITzz5sg.js} +2 -2
  3. package/dist/assets/{index-CSH1OQYQ.css → index-UKkHh18Z.css} +1 -1
  4. package/dist/index.html +2 -2
  5. package/lib/server/app.d.ts.map +1 -1
  6. package/lib/server/app.js +3 -0
  7. package/lib/server/app.js.map +1 -1
  8. package/lib/server/forge/auth/createAuth.d.ts +1 -0
  9. package/lib/server/forge/auth/createAuth.d.ts.map +1 -1
  10. package/lib/server/forge/auth/testHarness.d.ts +1 -0
  11. package/lib/server/forge/auth/testHarness.d.ts.map +1 -1
  12. package/lib/server/forge/auth/users.d.ts +2 -0
  13. package/lib/server/forge/auth/users.d.ts.map +1 -1
  14. package/lib/server/forge/auth/users.js +4 -0
  15. package/lib/server/forge/auth/users.js.map +1 -1
  16. package/lib/server/forge/core/claudeAuth.d.ts +32 -0
  17. package/lib/server/forge/core/claudeAuth.d.ts.map +1 -0
  18. package/lib/server/forge/core/claudeAuth.js +28 -0
  19. package/lib/server/forge/core/claudeAuth.js.map +1 -0
  20. package/lib/server/forge/core/claudeClient.d.ts +16 -7
  21. package/lib/server/forge/core/claudeClient.d.ts.map +1 -1
  22. package/lib/server/forge/core/claudeClient.js +28 -10
  23. package/lib/server/forge/core/claudeClient.js.map +1 -1
  24. package/lib/server/forge/core/configStore.d.ts +2 -3
  25. package/lib/server/forge/core/configStore.d.ts.map +1 -1
  26. package/lib/server/forge/core/configStore.js +7 -8
  27. package/lib/server/forge/core/configStore.js.map +1 -1
  28. package/lib/server/forge/routes.d.ts.map +1 -1
  29. package/lib/server/forge/routes.js +17 -7
  30. package/lib/server/forge/routes.js.map +1 -1
  31. package/package.json +3 -5
@@ -13,7 +13,7 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
13
13
  `),a=r.length>150?r.slice(-150).join(`
14
14
  `):t.trace;return`--- Job ${e[n]} (${i}) ---\n${a}`}).join(`
15
15
 
16
- `),f=n?.trim()?`${d}\n\n--- User instructions ---\n${n.trim()}`:d;Re(`ci-fix`);let m=P||`default`,v=u.iid;if(g){Me(!0),w(null),p([]);try{let{jobId:e}=await R(`/issues/${u.iid}/refine`,{method:`POST`,body:JSON.stringify({ciContext:f,previousChanges:g.changes,repo:P,secondaryRepos:pt,agent:wt})});Wr(m,v,`ci-fix`,{jobId:e,meta:{isRefine:!0,ordinal:A}}),I.current.add(e),An(e,{repoKey:m,issueIid:v,isRefine:!0})}catch(e){w(e.message),Me(!1)}return}let{jobId:y}=await R(`/issues/${u.iid}/ci-fix`,{method:`POST`,body:JSON.stringify({ciContext:f,model:bt,repo:P,secondaryRepos:pt,agent:wt})});p([]),h([]),_(null),w(null),t(`analyzing`),Wr(m,v,`ci-fix`,{jobId:y,meta:{isRefine:!1}}),I.current.add(y),An(y,{repoKey:m,issueIid:v,isRefine:!1})},Mn=async()=>{if(u){Oe(!0),Ae(null);try{let e=await R(`/issues/${u.iid}/resolution-check`,{method:`POST`,body:JSON.stringify({repo:P,secondaryRepos:pt,agent:wt})});Ee(e),e.cost??e.inputTokens}catch(e){Ae(e.message)}finally{Oe(!1)}}},Nn=()=>{ce&&(j({applications:[{repo:P,branchName:ce.branchName,mr:{iid:ce.iid,web_url:ce.web_url,title:ce.title},pipelineUrl:null}]}),t(`monitoring`))},Pn=async()=>{u&&(await R(`/issues/${u.iid}/close`,{method:`POST`,body:JSON.stringify({repo:P})}),r(e=>e.filter(e=>e.iid!==u.iid)),Ln())},Fn=async()=>{u&&(await R(`/issues/${u.iid}?repo=${encodeURIComponent(P)}`,{method:`DELETE`}),r(e=>e.filter(e=>e.iid!==u.iid)),Ln())},In=()=>{F.current?.close(),F.current=null,et.current?.close(),et.current=null,tt.current=null,I.current.clear(),Ye(!1),Me(!1),Pe([]),te(null),$e(Zr),Ze(null),t(`selected`)},Ln=()=>{At.current+=1,Ot.current?.abort(),F.current?.close(),F.current=null,I.current.clear(),d(null),le(null),ue(!1),fe([]),me([]),ge(!1),Ee(null),Ae(null),_(null),k([]),te(null),j(null),p([]),h([]),w(null),ae(null),Me(!1),Pe([]),$e(Zr),Ze(null),t(`idle`)};return{phase:e,setPhase:t,issues:n,issuesLoading:i,issuesError:c,selectedIssue:u,progressSteps:f,analysisLogs:m,analysisResult:g,analysisError:C,applying:ne,applyResult:ie,applyError:M,pipelineRefreshKey:oe,refining:je,analysisMode:Le,analysisPrompt:ze,setAnalysisPrompt:Be,existingMr:ce,existingMrLoading:N,mergedMrs:de,issueEnvironments:pe,issueEnvironmentsLoading:he,openMRs:_e,openMRsLoading:ye,openMRsError:Ce,storedAnalyses:O,currentOrdinal:A,handleRestoreAnalysis:vn,restoreAnalysisByOrdinal:yn,handleDiscardStoredAnalysis:bn,handleClearIssueCache:xn,handleDestroyAllAnalyses:Sn,handleUndoRefine:Cn,formatAnalysisDate:kr,reloadStatus:It,loadIssues:zt,loadOpenMRs:Bt,handleSelectMR:Jt,handleCreateIssue:Yt,handleUpdateIssue:Xt,handleSelectIssue:Qt,handleBeginAnalysis:en,handleFreshReanalyze:tn,handleCancelAnalysis:nn,handleApprove:fn,handleDeployBranch:pn,handlePromoteBranch:mn,handleCommitToBranch:hn,handleReject:_n,handleRefine:On,handleRefinePipelineFailure:jn,handleCheckResolution:Mn,resolutionCheck:Te,resolutionChecking:De,resolutionError:ke,handleViewExistingMr:Nn,handleCloseIssue:Pn,handleDeleteIssue:Fn,handleBackToIssue:In,handleReset:Ln,availableRepos:st,selectedRepo:P,setSelectedRepo:ut,selectedSecondaryRepos:pt,setSelectedSecondaryRepos:ht,testDeployUrlTemplate:dt,availableModels:gt,selectedModel:bt,setSelectedModel:Et,availableAgents:St,selectedAgent:wt,setSelectedAgent:Dt,validating:Je,validationError:Xe,validation:Qe,handleValidate:ln,handleFixValidation:kn,autoPushOnValidatePass:rt,setAutoPushOnValidatePass:ot,refineThread:v,refineQueue:Ne,thinkingLogs:Fe,backendError:T,statusLoaded:vt,issuesLoaded:o,openMRsLoaded:xe,backendRetrying:ee,retryBackend:Lt,remoteActiveIids:Vt,remoteJobId:Ut,ciFixAttempts:Ve,ciFixLoopWarning:Ge,ciFixMaxAttempts:qe.current,dismissCiFixLoopWarning:()=>{Ke(null),He(0),We(null)}}}var si=`setPhase.setAnalysisPrompt.setAutoPushOnValidatePass.setSelectedModel.setSelectedAgent.setSelectedRepo.setSelectedSecondaryRepos.reloadStatus.handleSelectMR.handleCreateIssue.handleUpdateIssue.handleSelectIssue.handleBeginAnalysis.handleFreshReanalyze.handleCancelAnalysis.handleApprove.handleDeployBranch.handlePromoteBranch.handleCommitToBranch.handleReject.handleRefine.handleUndoRefine.handleRefinePipelineFailure.handleCheckResolution.handleRestoreAnalysis.restoreAnalysisByOrdinal.handleDiscardStoredAnalysis.handleClearIssueCache.handleDestroyAllAnalyses.handleViewExistingMr.handleCloseIssue.handleDeleteIssue.handleBackToIssue.handleReset.handleValidate.handleFixValidation.loadIssues.loadOpenMRs.formatAnalysisDate.retryBackend.dismissCiFixLoopWarning`.split(`.`),ci=(0,x.createContext)(null),li=(0,x.createContext)(null),ui=(0,x.createContext)(null),di=new Set(si);function fi(e){let t={},n={};for(let[r,i]of Object.entries(e))di.has(r)?n[r]=i:t[r]=i;return{state:t,actions:n}}function pi({children:e}){let{state:t,actions:n}=fi(oi()),[r,i]=(0,x.useState)(`issue`),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(!1);return(0,L.jsx)(ci.Provider,{value:t,children:(0,L.jsx)(li.Provider,{value:n,children:(0,L.jsx)(ui.Provider,{value:{activeDetailTab:r,setActiveDetailTab:i,mrMerged:a,setMrMerged:o,taskModalOpen:s,setTaskModalOpen:c},children:e})})})}function mi(e,t){let n=(0,x.useContext)(e);if(!n)throw Error(`${t} must be used inside <ForgeProvider>`);return n}var V=()=>mi(ci,`useForgeState`),H=()=>mi(li,`useForgeActions`),hi=()=>mi(ui,`useForgeUI`);function gi(){let{availableRepos:e,selectedRepo:t,statusLoaded:n}=V(),{setSelectedRepo:r}=H(),i=e.find(e=>e.id===t)?.label??(n?`No repository`:``);return e.length<2?(0,L.jsx)(`div`,{className:`h-4 truncate text-[12px] leading-4 text-fg-subtle ${n?``:`w-16 animate-pulse rounded bg-surface-hover`}`,children:i},`single`):(0,L.jsxs)(`div`,{className:`relative flex h-4 min-w-0 items-center gap-1 text-[12px] leading-4 text-fg-muted hover:text-fg`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:i}),(0,L.jsx)(B,{name:`chevronDown`,size:12,className:`shrink-0`}),(0,L.jsx)(`select`,{"aria-label":`Repository`,value:t,onChange:e=>r(e.target.value),className:`absolute inset-0 cursor-pointer opacity-0`,children:e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]},`multi`)}var _i=[`viewer`,`operator`,`approver`,`admin`],vi={viewer:`Viewer`,operator:`Operator`,approver:`Approver`,admin:`Admin`},yi={viewer:`Read issues, merge requests, pipelines and runs.`,operator:`Analyze issues, refine fixes, validate and open merge requests.`,approver:`Everything an operator can do, plus merge and close merge requests.`,admin:`Full access, including connections, repositories, members and the audit log.`},bi=(e,t)=>_i.indexOf(e)>=_i.indexOf(t);function xi(){let[e,t]=(0,x.useState)(!1),{user:n,signOut:r}=Ui(),i=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!e)return;let n=e=>{i.current&&!i.current.contains(e.target)&&t(!1)},r=e=>e.key===`Escape`&&t(!1);return document.addEventListener(`mousedown`,n),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`keydown`,r)}},[e]),(0,L.jsxs)(`div`,{ref:i,className:`relative`,children:[e&&(0,L.jsxs)(`div`,{role:`menu`,className:`absolute bottom-full left-0 right-0 mb-1.5 overflow-hidden rounded-lg bg-surface-raised p-1 shadow-overlay animate-pop-in`,children:[(0,L.jsxs)(`div`,{className:`px-2.5 py-2`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm text-fg`,children:n.email}),(0,L.jsx)(`div`,{className:`text-[11px] text-fg-subtle`,children:vi[n.role]})]}),(0,L.jsx)(`div`,{className:`my-1 h-px bg-line`}),(0,L.jsxs)(`button`,{role:`menuitem`,onClick:()=>{t(!1),r()},className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,L.jsx)(B,{name:`logout`,size:14}),` Sign out`]})]}),(0,L.jsxs)(`button`,{onClick:()=>t(e=>!e),className:`flex h-10 w-full items-center gap-2.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,"aria-expanded":e,"aria-haspopup":`menu`,children:[(0,L.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-violet-500 to-indigo-600 text-[11px] font-semibold text-on-accent`,children:n.name.slice(0,1).toUpperCase()}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 text-left leading-tight`,children:[(0,L.jsx)(`span`,{className:`block truncate text-fg`,children:n.name}),(0,L.jsx)(`span`,{className:`block text-[11px] text-fg-subtle`,children:vi[n.role]})]}),(0,L.jsx)(B,{name:`more`,size:14,className:`text-fg-subtle`})]}),(0,L.jsxs)(`p`,{className:`mt-1 text-center text-[10px] tabular-nums text-fg-subtle opacity-60`,children:[`v`,`1.35.0`]})]})}function Si({count:e,active:t}){let n=!e;return(0,L.jsx)(`span`,{"data-testid":`count-badge`,"aria-hidden":n||void 0,className:Gn(`min-w-6 rounded-md px-1.5 text-center text-[11px] font-medium tabular-nums leading-5`,t?`bg-surface text-fg`:`bg-surface-hover text-fg-subtle`,n&&`invisible`),children:e??0})}function Ci({label:e,icon:t,active:n,onClick:r,badgeCount:i,showBadge:a=!0}){return(0,L.jsxs)(`button`,{type:`button`,onClick:r,"aria-current":n?`page`:void 0,className:Gn(`flex h-8 w-full items-center gap-2.5 rounded-lg px-2.5 text-sm transition-colors`,n?`bg-surface-hover font-medium text-fg`:`text-fg-muted hover:bg-surface-hover/60 hover:text-fg`),children:[(0,L.jsx)(B,{name:t,className:n?`text-accent-fg`:`text-fg-subtle`}),(0,L.jsx)(`span`,{className:`flex-1 text-left`,children:e}),a&&(0,L.jsx)(Si,{count:i,active:n})]})}var wi=(0,x.createContext)(null);function Ti({basePath:e=``,children:t}){let n=ct(),r=at(),i=e.replace(/\/+$/,``),a=(0,x.useCallback)((e,t)=>{n(`${i}${e}`,t)},[n,i]),o=(0,x.useMemo)(()=>{let e=r.pathname;return i&&e.startsWith(i)?e.slice(i.length)||`/`:e},[r.pathname,i]),s=(0,x.useMemo)(()=>({navigate:a,pathname:o,search:r.search,basePath:i}),[a,o,r.search,i]);return(0,L.jsx)(wi.Provider,{value:s,children:t})}function Ei(){let e=(0,x.useContext)(wi);if(!e)throw Error(`useForgeRouter must be used inside <ForgeRouterProvider>`);return e}var Di=[{path:`/issues`,label:`Issues`,icon:`issues`,section:`primary`,adminOnly:!1,preloadMRs:!1,keywords:[]},{path:`/mrs`,label:`Merge requests`,icon:`mergeRequest`,section:`primary`,adminOnly:!1,preloadMRs:!0,keywords:[`mr`,`pull`]},{path:`/pipelines`,label:`Pipelines`,icon:`pipeline`,section:`primary`,adminOnly:!1,preloadMRs:!0,keywords:[`ci`]},{path:`/settings`,label:`Settings`,icon:`settings`,section:`workspace`,adminOnly:!1,preloadMRs:!1,keywords:[`config`,`tokens`,`repos`]},{path:`/members`,label:`Members`,icon:`users`,section:`workspace`,adminOnly:!0,preloadMRs:!1,keywords:[`users`,`roles`,`team`]},{path:`/audit`,label:`Audit log`,icon:`shield`,section:`workspace`,adminOnly:!0,preloadMRs:!1,keywords:[`activity`,`security`]}];function Oi(e,t){return e===t||e.startsWith(`${t}/`)}function ki(e){return Di.find(t=>Oi(e,t.path))}function Ai(){let{can:e}=Ui(),t=e(`admin`);return Di.filter(e=>t||!e.adminOnly)}function U(){let{issues:e,issuesLoaded:t,openMRs:n,openMRsLoading:r}=V(),{loadOpenMRs:i}=H(),{navigate:a,pathname:o}=Ei(),s=Ai(),c={"/issues":t?e.length:void 0,"/mrs":n.length,"/pipelines":n.filter(e=>e.pipeline).length};return s.map(e=>({...e,active:Oi(o,e.path),badgeCount:c[e.path],go:()=>{a(e.path,{replace:!0}),e.preloadMRs&&n.length===0&&!r&&i()}}))}function ji(){let e=U();return(0,L.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col gap-0.5`,children:e.map((t,n)=>(0,L.jsxs)(x.Fragment,{children:[t.section===`workspace`&&e[n-1]?.section!==`workspace`&&(0,L.jsx)(`div`,{className:`px-2.5 pb-1 pt-5 text-xs font-medium text-fg-subtle`,children:`Workspace`}),(0,L.jsx)(Ci,{label:t.label,icon:t.icon,active:t.active,onClick:t.go,badgeCount:t.badgeCount,showBadge:t.section===`primary`})]},t.path))})}function Mi({size:e=28}){return(0,L.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-violet-500 to-indigo-600 text-on-accent shadow-sm`,style:{width:e,height:e},"aria-hidden":!0,children:(0,L.jsx)(`svg`,{width:e*.55,height:e*.55,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M4 20h16M7 16h10l-1.5-5h-7L7 16Zm1.5-5L10 4h4l1.5 7`})})})}function Ni({open:e,onClose:t}){let{setTaskModalOpen:n}=hi(),{preference:r,setPreference:i}=ir(),{can:a}=Ui();return(0,x.useEffect)(()=>{if(!e)return;let n=e=>e.key===`Escape`&&t();return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`fixed inset-0 z-40 bg-black/40 lg:hidden`,onClick:t}),(0,L.jsxs)(`aside`,{className:Gn(`w-60 shrink-0 flex-col border-r border-line bg-surface lg:static lg:flex`,e?`fixed inset-y-0 left-0 z-50 flex shadow-overlay animate-[forge-slide-in_280ms_cubic-bezier(0.32,0.72,0,1)] pt-[env(safe-area-inset-top)]`:`hidden`),children:[(0,L.jsxs)(`div`,{className:`flex h-14 items-center gap-2.5 px-4`,children:[(0,L.jsx)(Mi,{}),(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold tracking-tight text-fg`,children:`Forge`}),(0,L.jsx)(gi,{})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 overflow-y-auto px-3 pb-3 pt-2`,children:[(0,L.jsxs)(z,{variant:`primary`,className:`w-full`,disabled:!a(`operator`),title:a(`operator`)?void 0:`Requires the operator role`,onClick:()=>n(!0),children:[(0,L.jsx)(B,{name:`plus`,size:15}),` New task`]}),(0,L.jsx)(ji,{})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[(0,L.jsx)(or,{value:r,onChange:i}),(0,L.jsx)(xi,{})]})]})]})}function Pi({title:e,subtitle:t,children:n}){return(0,L.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-4 py-12`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,L.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-4 text-center`,children:[(0,L.jsx)(Mi,{size:40}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t})]})]}),(0,L.jsx)(`div`,{className:`rounded-2xl border border-line bg-surface-raised p-6 shadow-sm`,children:n})]})})}var Fi=`h-10 w-full rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`;function Ii({message:e}){return(0,L.jsx)(`p`,{role:e?`alert`:void 0,className:e?`rounded-lg bg-red-950/50 px-3 py-2 text-sm text-red-300 ring-1 ring-inset ring-red-800/60`:`hidden`,children:e})}function Li({sso:e,onSignedIn:t}){let[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(!1);return(0,L.jsx)(Pi,{title:`Sign in to Forge`,subtitle:`Use your work account to continue.`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(z,{variant:`secondary`,className:`h-10 w-full`,onClick:()=>{window.location.assign(Wn.ssoStartUrl(window.location.pathname+window.location.search))},children:[`Continue with `,e.name]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`h-px flex-1 bg-line`}),`or use a password`,(0,L.jsx)(`span`,{className:`h-px flex-1 bg-line`})]})]}),(0,L.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),l(!0),s(null);try{await Wn.login(n,i),t()}catch(e){s(e.message)}finally{l(!1)}},className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Email`,(0,L.jsx)(`input`,{type:`email`,autoComplete:`username`,required:!0,value:n,onChange:e=>r(e.target.value),className:Fi})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Password`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`current-password`,required:!0,value:i,onChange:e=>a(e.target.value),className:Fi})]}),(0,L.jsx)(Ii,{message:o}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,className:`h-10 w-full`,disabled:c,children:c?`Signing in…`:`Sign in`})]})]})})}function Ri({requiresToken:e,onDone:t}){let[n,r]=(0,x.useState)({name:``,email:``,password:``,setupToken:``}),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),c=e=>t=>r(n=>({...n,[e]:t.target.value}));return(0,L.jsx)(Pi,{title:`Set up Forge`,subtitle:`Create the first admin account for this workspace.`,children:(0,L.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),s(!0),a(null);try{await Wn.setup(e?n:{...n,setupToken:void 0}),t()}catch(e){a(e.message)}finally{s(!1)}},className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Your name`,(0,L.jsx)(`input`,{autoComplete:`name`,required:!0,value:n.name,onChange:c(`name`),className:Fi})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Work email`,(0,L.jsx)(`input`,{type:`email`,autoComplete:`username`,required:!0,value:n.email,onChange:c(`email`),className:Fi})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Password`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,required:!0,minLength:12,value:n.password,onChange:c(`password`),className:Fi}),(0,L.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:`At least 12 characters.`})]}),e&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Setup code`,(0,L.jsx)(`input`,{autoComplete:`off`,required:!0,"aria-describedby":`setup-code-hint`,value:n.setupToken,onChange:c(`setupToken`),className:`h-10 w-full rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`})]}),(0,L.jsx)(`span`,{id:`setup-code-hint`,className:`text-xs text-fg-subtle`,children:`Printed in the server log on first start (or your FORGE_TOKEN, if set). It proves you operate this install.`})]}),(0,L.jsx)(Ii,{message:i}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,className:`h-10 w-full`,disabled:o,children:o?`Creating…`:`Create admin account`})]})})}var zi=(0,x.createContext)(null),Bi=700;function Vi(){let e=window.__forgeBootT??0;return Math.round((performance.now()-e)%Bi)}function Hi({children:e}){let[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(null),a=(0,x.useRef)(null),o=()=>a.current??=Wn.me().then(e=>{n(e),i(null)}).catch(e=>i(e.message)).finally(()=>{a.current=null});if((0,x.useEffect)(()=>{o();let e=()=>o();return window.addEventListener(Hn,e),()=>window.removeEventListener(Hn,e)},[]),r&&!t)return(0,L.jsxs)(`div`,{role:`alert`,className:`flex min-h-screen flex-col items-center justify-center gap-3 bg-canvas px-4 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:`Forge couldn't load your session.`}),(0,L.jsx)(`p`,{className:`max-w-sm text-sm text-fg-muted`,children:r}),(0,L.jsx)(`button`,{onClick:o,className:`text-sm text-accent-fg hover:underline`,children:`Try again`})]});if(!t)return(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-canvas`,"aria-busy":`true`,children:(0,L.jsx)(`div`,{className:`size-5 animate-spin rounded-full border-2 border-line-strong border-t-violet-500`,style:{animationDelay:`-${Vi()}ms`}})});if(t.needsSetup)return(0,L.jsx)(Ri,{requiresToken:t.setupRequiresToken??!0,onDone:o});if(!t.user)return(0,L.jsx)(Li,{sso:t.sso,onSignedIn:o});let s=t.user,c={user:s,can:e=>bi(s.role,e),signOut:async()=>{await Wn.logout().catch(()=>void 0),await o()}};return(0,L.jsx)(zi.Provider,{value:c,children:e})}function Ui(){let e=(0,x.useContext)(zi);if(!e)throw Error(`useSession must be used inside <AuthGate>`);return e}var Wi={neutral:`bg-surface-hover/70 text-fg ring-line-strong/60`,accent:`bg-violet-950/60 text-violet-300 ring-violet-800/60`,success:`bg-emerald-950/60 text-emerald-300 ring-emerald-800/60`,warning:`bg-amber-950/60 text-amber-300 ring-amber-800/60`,danger:`bg-red-950/60 text-red-300 ring-red-800/60`,info:`bg-sky-950/60 text-sky-300 ring-sky-800/60`};function Gi({tone:e=`neutral`,dot:t,className:n,children:r}){return(0,L.jsxs)(`span`,{className:Gn(`inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-[11px] font-medium ring-1 ring-inset whitespace-nowrap`,Wi[e],n),children:[t&&(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`,"aria-hidden":!0}),r]})}function Ki({icon:e,title:t,description:n,action:r}){return(0,L.jsxs)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-line px-6 py-12 text-center`,children:[(0,L.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-2xl bg-surface-hover text-fg-muted ring-1 ring-line`,children:(0,L.jsx)(B,{name:e,size:20})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:n})]}),r]})}function qi({title:e,description:t,actions:n}){return(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t})]}),n&&(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:n})]})}var Ji=(e,t,n)=>R(t,{method:e,body:n===void 0?void 0:JSON.stringify(n)}),Yi={listMembers:()=>R(`/admin/users`),addMember:e=>Ji(`POST`,`/admin/users`,e),updateMember:(e,t)=>Ji(`PATCH`,`/admin/users/${e}`,t),listAudit:e=>{let t=new URLSearchParams;return e.action&&t.set(`action`,e.action),e.before&&t.set(`before`,String(e.before)),R(`/admin/audit?${t}`)},listTokens:()=>R(`/auth/tokens`),createToken:e=>Ji(`POST`,`/auth/tokens`,{name:e}),revokeToken:e=>Ji(`DELETE`,`/auth/tokens/${e}`)},Xi=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),Zi=e=>e?Xi.format(new Date(e)):`—`,Qi={"auth.setup":`Set up Forge`,"auth.login":`Signed in`,"auth.sso_login":`Signed in with SSO`,"auth.logout":`Signed out`,"user.create":`Added member`,"user.update":`Updated member`,"token.create":`Created API token`,"token.revoke":`Revoked API token`,"PUT /config":`Changed workspace settings`,"DELETE /workspaces":`Deleted local workspace`,"POST /workspaces/purge":`Purged local workspaces`,"POST /issues":`Created issue`,"PUT /issues/:iid":`Edited issue`,"POST /issues/:iid/close":`Closed issue`,"DELETE /issues/:iid":`Deleted issue`,"POST /issues/:iid/analyze":`Started analysis`,"POST /issues/:iid/refine":`Refined fix`,"POST /issues/:iid/ci-fix":`Asked AI to fix CI`,"POST /issues/:iid/resolution-check":`Checked resolution`,"POST /validate":`Ran validation`,"POST /apply":`Opened merge request`,"POST /commit-to-branch":`Committed to branch`,"POST /promote-branch":`Promoted branch`,"POST /deploy-branch":`Deployed branch`,"POST /jobs/:jobId/cancel":`Cancelled job`,"POST /mr/:mrIid/merge":`Merged merge request`,"POST /mr/:mrIid/auto-merge":`Enabled auto-merge`,"POST /mr/:mrIid/cancel-auto-merge":`Cancelled auto-merge`,"POST /mr/:mrIid/close":`Closed merge request`,"POST /mr/:mrIid/reopen":`Reopened merge request`,"POST /mr/:mrIid/rebase":`Rebased merge request`,"POST /mr/:mrIid/draft":`Changed draft status`};function $i(e){return Qi[e]??e}var ea={success:{label:`Success`,tone:`success`},failure:{label:`Failed`,tone:`danger`},denied:{label:`Denied`,tone:`warning`}},ta=[{value:``,label:`All activity`},{value:`auth.login`,label:`Sign-ins`},{value:`auth.sso_login`,label:`SSO sign-ins`},{value:`POST /mr/:mrIid/merge`,label:`Merges`},{value:`POST /apply`,label:`Merge requests opened`},{value:`PUT /config`,label:`Settings changes`},{value:`user.update`,label:`Member changes`}];function na(){let[e,t]=(0,x.useState)(``),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null);return(0,x.useEffect)(()=>{r(null),Yi.listAudit({action:e}).then(e=>{r(e.events),a(e.nextCursor)}).catch(e=>s(e.message))},[e]),(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6`,children:[(0,L.jsx)(qi,{title:`Audit log`,description:`Every sign-in and every change made through Forge. Entries can't be edited or deleted.`,actions:(0,L.jsx)(`select`,{"aria-label":`Filter activity`,value:e,onChange:e=>t(e.target.value),className:`h-8 rounded-lg border border-line bg-surface-raised px-2.5 text-xs text-fg focus:border-accent-hover focus:outline-none`,children:ta.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),o&&(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-red-400`,children:o}),n&&n.length===0?(0,L.jsx)(Ki,{icon:`inbox`,title:`No activity yet`,description:`Sign-ins and changes will appear here as they happen.`}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface-raised`,children:(0,L.jsxs)(`table`,{"aria-label":`Audit log`,className:`w-full min-w-[860px] table-fixed text-left text-sm`,children:[(0,L.jsxs)(`colgroup`,{children:[(0,L.jsx)(`col`,{className:`w-36`}),(0,L.jsx)(`col`,{className:`w-52`}),(0,L.jsx)(`col`,{}),(0,L.jsx)(`col`,{className:`w-44`}),(0,L.jsx)(`col`,{className:`w-28`})]}),(0,L.jsx)(`thead`,{className:`border-b border-line text-xs font-medium text-fg-subtle`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-4 pr-3 font-medium`,children:`When`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Who`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`What`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Where`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-3 pr-4 text-right font-medium`,children:`Result`})]})}),(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[(n??[]).map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`py-3 pl-4 pr-3 tabular-nums text-fg-muted`,children:Zi(e.at)}),(0,L.jsx)(`td`,{className:`truncate px-3 py-3 text-fg`,title:e.ip??void 0,children:e.actorLabel}),(0,L.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:$i(e.action)}),e.target&&(0,L.jsx)(`span`,{className:`ml-2 font-mono text-xs text-fg-subtle`,children:e.target})]}),(0,L.jsx)(`td`,{className:`truncate px-3 py-3 font-mono text-xs text-fg-subtle`,children:e.repo?.replace(/^[a-z]+:/,``)??`—`}),(0,L.jsx)(`td`,{className:`py-3 pl-3 pr-4 text-right`,children:(0,L.jsx)(Gi,{tone:ea[e.outcome].tone,children:ea[e.outcome].label})})]},e.id)),!n&&Array.from({length:5}).map((e,t)=>(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:5,className:`h-[45px] px-4`,children:(0,L.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse rounded bg-surface-hover`})})},t))]})]})}),i&&(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(z,{size:`sm`,onClick:async()=>{if(!i)return;let t=await Yi.listAudit({action:e,before:i});r(e=>[...e??[],...t.events]),a(t.nextCursor)},children:`Load older activity`})})]})}var ra=`h-9 w-full rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`,ia=`h-8 rounded-lg border border-line bg-surface-raised px-2 text-xs text-fg focus:border-accent-hover focus:outline-none disabled:opacity-50`;function aa({onAdded:e,onCancel:t}){let[n,r]=(0,x.useState)({name:``,email:``,role:`operator`,password:``}),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1);return(0,L.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),s(!0),a(null);try{e((await Yi.addMember(n)).user)}catch(e){a(e.message)}finally{s(!1)}},"aria-label":`Add member`,className:`grid gap-4 rounded-xl border border-line bg-surface-raised p-5 shadow-sm sm:grid-cols-2`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Name`,(0,L.jsx)(`input`,{required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value}),className:ra})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Email`,(0,L.jsx)(`input`,{type:`email`,required:!0,value:n.email,onChange:e=>r({...n,email:e.target.value}),className:ra})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Role`,(0,L.jsx)(`select`,{value:n.role,onChange:e=>r({...n,role:e.target.value}),className:ra,children:_i.map(e=>(0,L.jsx)(`option`,{value:e,children:vi[e]},e))}),(0,L.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:yi[n.role]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Temporary password`,(0,L.jsx)(`input`,{type:`password`,required:!0,minLength:12,autoComplete:`new-password`,value:n.password,onChange:e=>r({...n,password:e.target.value}),className:ra}),(0,L.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:`Share it privately. SSO users can leave Forge's password unused.`})]}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-red-400 sm:col-span-2`,children:i}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2 sm:col-span-2`,children:[(0,L.jsx)(z,{variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,size:`sm`,disabled:o,children:`Add`})]})]})}function oa(){let{user:e}=Ui(),[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(!1);(0,x.useEffect)(()=>{Yi.listMembers().then(e=>n(e.users)).catch(e=>i(e.message))},[]);let s=async(e,t)=>{i(null);try{let{user:r}=await Yi.updateMember(e.id,t);n(e=>e?.map(e=>e.id===r.id?r:e)??null)}catch(e){i(e.message)}};return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6`,children:[(0,L.jsx)(qi,{title:`Members`,description:`Who can use this Forge workspace, and what they're allowed to do.`,actions:(0,L.jsxs)(z,{size:`sm`,variant:`primary`,onClick:()=>o(!0),children:[(0,L.jsx)(B,{name:`plus`,size:14}),` Add member`]})}),a&&(0,L.jsx)(aa,{onCancel:()=>o(!1),onAdded:e=>{n(t=>[...t??[],e]),o(!1)}}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`rounded-lg bg-red-950/50 px-3 py-2 text-sm text-red-300 ring-1 ring-inset ring-red-800/60`,children:r}),(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface-raised`,children:(0,L.jsxs)(`table`,{"aria-label":`Members`,className:`w-full min-w-[760px] table-fixed text-left text-sm`,children:[(0,L.jsxs)(`colgroup`,{children:[(0,L.jsx)(`col`,{}),(0,L.jsx)(`col`,{className:`w-40`}),(0,L.jsx)(`col`,{className:`w-28`}),(0,L.jsx)(`col`,{className:`w-40`}),(0,L.jsx)(`col`,{className:`w-32`})]}),(0,L.jsx)(`thead`,{className:`border-b border-line text-xs font-medium text-fg-subtle`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-4 pr-3 font-medium`,children:`Member`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Role`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Sign-in`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Last active`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-3 pr-4 text-right font-medium`,children:`Access`})]})}),(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[(t??[]).map(t=>(0,L.jsxs)(`tr`,{className:t.disabled?`opacity-60`:void 0,children:[(0,L.jsx)(`td`,{className:`py-3 pl-4 pr-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg-muted ring-1 ring-line`,children:t.name.slice(0,1).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`truncate font-medium text-fg`,children:[t.name,` `,t.id===e.id&&(0,L.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:`(you)`})]}),(0,L.jsx)(`div`,{className:`truncate text-xs text-fg-subtle`,children:t.email})]})]})}),(0,L.jsx)(`td`,{className:`px-3 py-3`,children:(0,L.jsx)(`select`,{"aria-label":`Role for ${t.name}`,value:t.role,onChange:e=>s(t,{role:e.target.value}),title:yi[t.role],className:ia,children:_i.map(e=>(0,L.jsx)(`option`,{value:e,children:vi[e]},e))})}),(0,L.jsx)(`td`,{className:`px-3 py-3`,children:(0,L.jsx)(Gi,{tone:t.authProvider===`oidc`?`info`:`neutral`,children:t.authProvider===`oidc`?`SSO`:`Password`})}),(0,L.jsx)(`td`,{className:`px-3 py-3 tabular-nums text-fg-muted`,children:Zi(t.lastLoginAt)}),(0,L.jsx)(`td`,{className:`py-3 pl-3 pr-4 text-right`,children:(0,L.jsx)(z,{size:`sm`,variant:`ghost`,disabled:t.id===e.id,onClick:()=>s(t,{disabled:!t.disabled}),children:t.disabled?`Enable`:`Disable`})})]},t.id)),!t&&Array.from({length:3}).map((e,t)=>(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:5,className:`h-[57px] px-4`,children:(0,L.jsx)(`div`,{className:`h-3 w-1/3 animate-pulse rounded bg-surface-hover`})})},t))]})]})})]})}var sa=/\b(error|failed|failure|exception|panic|traceback|cannot|could not|refused|denied|timed? out|abort|unexpected)\b/i,ca=/\b(warn|warning|skipped|skipping|deprecated|retry|retrying|fallback|truncated|missing)\b/i,la=/\b(ok|success|passed|completed|done|ready|merged|applied|resolved)\b/i,ua=/^(reasoning|scanning|analysis started|ci fix started|identified|loaded)\b/i;function da(e){return sa.test(e)?`error`:ca.test(e)?`warn`:la.test(e)?`success`:ua.test(e)?`debug`:`info`}function fa(e){try{let t=new Date(e);return Number.isNaN(t.getTime())?``:`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}catch{return`--:--:--.---`}}var pa={info:{icon:`ℹ`,text:`text-fg`,iconColor:`text-sky-400`},warn:{icon:`⚠`,text:`text-amber-300`,iconColor:`text-amber-400`},error:{icon:`✖`,text:`text-red-300`,iconColor:`text-red-400`},debug:{icon:`›`,text:`text-fg-subtle`,iconColor:`text-fg-subtle`},success:{icon:`✓`,text:`text-emerald-300`,iconColor:`text-emerald-400`}};function ma({entries:e,autoScroll:t=!0,variant:n=`panel`,heightClass:r=`min-h-[12rem] max-h-[60vh]`,label:i,badge:a,headerAccessory:o,empty:s=`No output yet.`}){let c=(0,x.useRef)(null);(0,x.useEffect)(()=>{t&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[e.length,t]);let l=e.map(e=>typeof e==`string`?{ts:new Date().toISOString(),message:e}:e),u=(0,L.jsx)(`div`,{ref:c,className:`font-mono text-[11px] leading-5 ${r} overflow-y-auto bg-canvas`,children:l.length===0?(0,L.jsx)(`div`,{className:`px-4 py-3 text-fg-subtle italic`,children:s}):(0,L.jsx)(`div`,{children:l.map((e,t)=>{let n=e.level??da(e.message),r=pa[n];return(0,L.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-[2px] hover:bg-fg/[0.02] border-l-2 border-transparent`,style:{borderLeftColor:n===`error`?`rgba(248, 113, 113, 0.5)`:n===`warn`?`rgba(251, 191, 36, 0.4)`:n===`success`?`rgba(52, 211, 153, 0.4)`:`transparent`},children:[(0,L.jsx)(`span`,{className:`text-fg-subtle select-none shrink-0 tabular-nums`,children:fa(e.ts)}),(0,L.jsx)(`span`,{className:`${r.iconColor} shrink-0 select-none`,children:r.icon}),(0,L.jsx)(`span`,{className:`${r.text} whitespace-pre-wrap break-words`,children:e.message})]},t)})})});return n===`embedded`?u:(0,L.jsxs)(`div`,{className:`border border-line rounded-lg overflow-hidden bg-canvas shadow-inner`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-raised/80 border-b border-line px-3 py-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-fg-subtle font-mono`,children:[(0,L.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-red-500/60`}),(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-amber-500/60`}),(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-emerald-500/60`})]}),i&&(0,L.jsx)(`span`,{className:`pl-1`,children:i}),a&&(0,L.jsx)(`span`,{className:`ml-1 px-1.5 py-0.5 rounded bg-surface-raised text-[10px] text-fg-muted tracking-normal normal-case`,children:a})]}),o&&(0,L.jsx)(`div`,{className:`flex items-center`,children:o})]}),u]})}function ha(e,t=Date.now()){return e.replace(/\x1b\[[0-9;]*[a-zA-Z]/g,``).split(`
16
+ `),f=n?.trim()?`${d}\n\n--- User instructions ---\n${n.trim()}`:d;Re(`ci-fix`);let m=P||`default`,v=u.iid;if(g){Me(!0),w(null),p([]);try{let{jobId:e}=await R(`/issues/${u.iid}/refine`,{method:`POST`,body:JSON.stringify({ciContext:f,previousChanges:g.changes,repo:P,secondaryRepos:pt,agent:wt})});Wr(m,v,`ci-fix`,{jobId:e,meta:{isRefine:!0,ordinal:A}}),I.current.add(e),An(e,{repoKey:m,issueIid:v,isRefine:!0})}catch(e){w(e.message),Me(!1)}return}let{jobId:y}=await R(`/issues/${u.iid}/ci-fix`,{method:`POST`,body:JSON.stringify({ciContext:f,model:bt,repo:P,secondaryRepos:pt,agent:wt})});p([]),h([]),_(null),w(null),t(`analyzing`),Wr(m,v,`ci-fix`,{jobId:y,meta:{isRefine:!1}}),I.current.add(y),An(y,{repoKey:m,issueIid:v,isRefine:!1})},Mn=async()=>{if(u){Oe(!0),Ae(null);try{let e=await R(`/issues/${u.iid}/resolution-check`,{method:`POST`,body:JSON.stringify({repo:P,secondaryRepos:pt,agent:wt})});Ee(e),e.cost??e.inputTokens}catch(e){Ae(e.message)}finally{Oe(!1)}}},Nn=()=>{ce&&(j({applications:[{repo:P,branchName:ce.branchName,mr:{iid:ce.iid,web_url:ce.web_url,title:ce.title},pipelineUrl:null}]}),t(`monitoring`))},Pn=async()=>{u&&(await R(`/issues/${u.iid}/close`,{method:`POST`,body:JSON.stringify({repo:P})}),r(e=>e.filter(e=>e.iid!==u.iid)),Ln())},Fn=async()=>{u&&(await R(`/issues/${u.iid}?repo=${encodeURIComponent(P)}`,{method:`DELETE`}),r(e=>e.filter(e=>e.iid!==u.iid)),Ln())},In=()=>{F.current?.close(),F.current=null,et.current?.close(),et.current=null,tt.current=null,I.current.clear(),Ye(!1),Me(!1),Pe([]),te(null),$e(Zr),Ze(null),t(`selected`)},Ln=()=>{At.current+=1,Ot.current?.abort(),F.current?.close(),F.current=null,I.current.clear(),d(null),le(null),ue(!1),fe([]),me([]),ge(!1),Ee(null),Ae(null),_(null),k([]),te(null),j(null),p([]),h([]),w(null),ae(null),Me(!1),Pe([]),$e(Zr),Ze(null),t(`idle`)};return{phase:e,setPhase:t,issues:n,issuesLoading:i,issuesError:c,selectedIssue:u,progressSteps:f,analysisLogs:m,analysisResult:g,analysisError:C,applying:ne,applyResult:ie,applyError:M,pipelineRefreshKey:oe,refining:je,analysisMode:Le,analysisPrompt:ze,setAnalysisPrompt:Be,existingMr:ce,existingMrLoading:N,mergedMrs:de,issueEnvironments:pe,issueEnvironmentsLoading:he,openMRs:_e,openMRsLoading:ye,openMRsError:Ce,storedAnalyses:O,currentOrdinal:A,handleRestoreAnalysis:vn,restoreAnalysisByOrdinal:yn,handleDiscardStoredAnalysis:bn,handleClearIssueCache:xn,handleDestroyAllAnalyses:Sn,handleUndoRefine:Cn,formatAnalysisDate:kr,reloadStatus:It,loadIssues:zt,loadOpenMRs:Bt,handleSelectMR:Jt,handleCreateIssue:Yt,handleUpdateIssue:Xt,handleSelectIssue:Qt,handleBeginAnalysis:en,handleFreshReanalyze:tn,handleCancelAnalysis:nn,handleApprove:fn,handleDeployBranch:pn,handlePromoteBranch:mn,handleCommitToBranch:hn,handleReject:_n,handleRefine:On,handleRefinePipelineFailure:jn,handleCheckResolution:Mn,resolutionCheck:Te,resolutionChecking:De,resolutionError:ke,handleViewExistingMr:Nn,handleCloseIssue:Pn,handleDeleteIssue:Fn,handleBackToIssue:In,handleReset:Ln,availableRepos:st,selectedRepo:P,setSelectedRepo:ut,selectedSecondaryRepos:pt,setSelectedSecondaryRepos:ht,testDeployUrlTemplate:dt,availableModels:gt,selectedModel:bt,setSelectedModel:Et,availableAgents:St,selectedAgent:wt,setSelectedAgent:Dt,validating:Je,validationError:Xe,validation:Qe,handleValidate:ln,handleFixValidation:kn,autoPushOnValidatePass:rt,setAutoPushOnValidatePass:ot,refineThread:v,refineQueue:Ne,thinkingLogs:Fe,backendError:T,statusLoaded:vt,issuesLoaded:o,openMRsLoaded:xe,backendRetrying:ee,retryBackend:Lt,remoteActiveIids:Vt,remoteJobId:Ut,ciFixAttempts:Ve,ciFixLoopWarning:Ge,ciFixMaxAttempts:qe.current,dismissCiFixLoopWarning:()=>{Ke(null),He(0),We(null)}}}var si=`setPhase.setAnalysisPrompt.setAutoPushOnValidatePass.setSelectedModel.setSelectedAgent.setSelectedRepo.setSelectedSecondaryRepos.reloadStatus.handleSelectMR.handleCreateIssue.handleUpdateIssue.handleSelectIssue.handleBeginAnalysis.handleFreshReanalyze.handleCancelAnalysis.handleApprove.handleDeployBranch.handlePromoteBranch.handleCommitToBranch.handleReject.handleRefine.handleUndoRefine.handleRefinePipelineFailure.handleCheckResolution.handleRestoreAnalysis.restoreAnalysisByOrdinal.handleDiscardStoredAnalysis.handleClearIssueCache.handleDestroyAllAnalyses.handleViewExistingMr.handleCloseIssue.handleDeleteIssue.handleBackToIssue.handleReset.handleValidate.handleFixValidation.loadIssues.loadOpenMRs.formatAnalysisDate.retryBackend.dismissCiFixLoopWarning`.split(`.`),ci=(0,x.createContext)(null),li=(0,x.createContext)(null),ui=(0,x.createContext)(null),di=new Set(si);function fi(e){let t={},n={};for(let[r,i]of Object.entries(e))di.has(r)?n[r]=i:t[r]=i;return{state:t,actions:n}}function pi({children:e}){let{state:t,actions:n}=fi(oi()),[r,i]=(0,x.useState)(`issue`),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(!1);return(0,L.jsx)(ci.Provider,{value:t,children:(0,L.jsx)(li.Provider,{value:n,children:(0,L.jsx)(ui.Provider,{value:{activeDetailTab:r,setActiveDetailTab:i,mrMerged:a,setMrMerged:o,taskModalOpen:s,setTaskModalOpen:c},children:e})})})}function mi(e,t){let n=(0,x.useContext)(e);if(!n)throw Error(`${t} must be used inside <ForgeProvider>`);return n}var V=()=>mi(ci,`useForgeState`),H=()=>mi(li,`useForgeActions`),hi=()=>mi(ui,`useForgeUI`);function gi(){let{availableRepos:e,selectedRepo:t,statusLoaded:n}=V(),{setSelectedRepo:r}=H(),i=e.find(e=>e.id===t)?.label??(n?`No repository`:``);return e.length<2?(0,L.jsx)(`div`,{className:`h-4 truncate text-[12px] leading-4 text-fg-subtle ${n?``:`w-16 animate-pulse rounded bg-surface-hover`}`,children:i},`single`):(0,L.jsxs)(`div`,{className:`relative flex h-4 min-w-0 items-center gap-1 text-[12px] leading-4 text-fg-muted hover:text-fg`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:i}),(0,L.jsx)(B,{name:`chevronDown`,size:12,className:`shrink-0`}),(0,L.jsx)(`select`,{"aria-label":`Repository`,value:t,onChange:e=>r(e.target.value),className:`absolute inset-0 cursor-pointer opacity-0`,children:e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]},`multi`)}var _i=[`viewer`,`operator`,`approver`,`admin`],vi={viewer:`Viewer`,operator:`Operator`,approver:`Approver`,admin:`Admin`},yi={viewer:`Read issues, merge requests, pipelines and runs.`,operator:`Analyze issues, refine fixes, validate and open merge requests.`,approver:`Everything an operator can do, plus merge and close merge requests.`,admin:`Full access, including connections, repositories, members and the audit log.`},bi=(e,t)=>_i.indexOf(e)>=_i.indexOf(t);function xi(){let[e,t]=(0,x.useState)(!1),{user:n,signOut:r}=Ui(),i=(0,x.useRef)(null);return(0,x.useEffect)(()=>{if(!e)return;let n=e=>{i.current&&!i.current.contains(e.target)&&t(!1)},r=e=>e.key===`Escape`&&t(!1);return document.addEventListener(`mousedown`,n),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`keydown`,r)}},[e]),(0,L.jsxs)(`div`,{ref:i,className:`relative`,children:[e&&(0,L.jsxs)(`div`,{role:`menu`,className:`absolute bottom-full left-0 right-0 mb-1.5 overflow-hidden rounded-lg bg-surface-raised p-1 shadow-overlay animate-pop-in`,children:[(0,L.jsxs)(`div`,{className:`px-2.5 py-2`,children:[(0,L.jsx)(`div`,{className:`truncate text-sm text-fg`,children:n.email}),(0,L.jsx)(`div`,{className:`text-[11px] text-fg-subtle`,children:vi[n.role]})]}),(0,L.jsx)(`div`,{className:`my-1 h-px bg-line`}),(0,L.jsxs)(`button`,{role:`menuitem`,onClick:()=>{t(!1),r()},className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,L.jsx)(B,{name:`logout`,size:14}),` Sign out`]})]}),(0,L.jsxs)(`button`,{onClick:()=>t(e=>!e),className:`flex h-10 w-full items-center gap-2.5 rounded-lg px-2 text-sm text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,"aria-expanded":e,"aria-haspopup":`menu`,children:[(0,L.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-violet-500 to-indigo-600 text-[11px] font-semibold text-on-accent`,children:n.name.slice(0,1).toUpperCase()}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 text-left leading-tight`,children:[(0,L.jsx)(`span`,{className:`block truncate text-fg`,children:n.name}),(0,L.jsx)(`span`,{className:`block text-[11px] text-fg-subtle`,children:vi[n.role]})]}),(0,L.jsx)(B,{name:`more`,size:14,className:`text-fg-subtle`})]}),(0,L.jsxs)(`p`,{className:`mt-1 text-center text-[10px] tabular-nums text-fg-subtle opacity-60`,children:[`v`,`1.35.2`]})]})}function Si({count:e,active:t}){let n=!e;return(0,L.jsx)(`span`,{"data-testid":`count-badge`,"aria-hidden":n||void 0,className:Gn(`min-w-6 rounded-md px-1.5 text-center text-[11px] font-medium tabular-nums leading-5`,t?`bg-surface text-fg`:`bg-surface-hover text-fg-subtle`,n&&`invisible`),children:e??0})}function Ci({label:e,icon:t,active:n,onClick:r,badgeCount:i,showBadge:a=!0}){return(0,L.jsxs)(`button`,{type:`button`,onClick:r,"aria-current":n?`page`:void 0,className:Gn(`flex h-8 w-full items-center gap-2.5 rounded-lg px-2.5 text-sm transition-colors`,n?`bg-surface-hover font-medium text-fg`:`text-fg-muted hover:bg-surface-hover/60 hover:text-fg`),children:[(0,L.jsx)(B,{name:t,className:n?`text-accent-fg`:`text-fg-subtle`}),(0,L.jsx)(`span`,{className:`flex-1 text-left`,children:e}),a&&(0,L.jsx)(Si,{count:i,active:n})]})}var wi=(0,x.createContext)(null);function Ti({basePath:e=``,children:t}){let n=ct(),r=at(),i=e.replace(/\/+$/,``),a=(0,x.useCallback)((e,t)=>{n(`${i}${e}`,t)},[n,i]),o=(0,x.useMemo)(()=>{let e=r.pathname;return i&&e.startsWith(i)?e.slice(i.length)||`/`:e},[r.pathname,i]),s=(0,x.useMemo)(()=>({navigate:a,pathname:o,search:r.search,basePath:i}),[a,o,r.search,i]);return(0,L.jsx)(wi.Provider,{value:s,children:t})}function Ei(){let e=(0,x.useContext)(wi);if(!e)throw Error(`useForgeRouter must be used inside <ForgeRouterProvider>`);return e}var Di=[{path:`/issues`,label:`Issues`,icon:`issues`,section:`primary`,adminOnly:!1,preloadMRs:!1,keywords:[]},{path:`/mrs`,label:`Merge requests`,icon:`mergeRequest`,section:`primary`,adminOnly:!1,preloadMRs:!0,keywords:[`mr`,`pull`]},{path:`/pipelines`,label:`Pipelines`,icon:`pipeline`,section:`primary`,adminOnly:!1,preloadMRs:!0,keywords:[`ci`]},{path:`/settings`,label:`Settings`,icon:`settings`,section:`workspace`,adminOnly:!1,preloadMRs:!1,keywords:[`config`,`tokens`,`repos`]},{path:`/members`,label:`Members`,icon:`users`,section:`workspace`,adminOnly:!0,preloadMRs:!1,keywords:[`users`,`roles`,`team`]},{path:`/audit`,label:`Audit log`,icon:`shield`,section:`workspace`,adminOnly:!0,preloadMRs:!1,keywords:[`activity`,`security`]}];function Oi(e,t){return e===t||e.startsWith(`${t}/`)}function ki(e){return Di.find(t=>Oi(e,t.path))}function Ai(){let{can:e}=Ui(),t=e(`admin`);return Di.filter(e=>t||!e.adminOnly)}function U(){let{issues:e,issuesLoaded:t,openMRs:n,openMRsLoading:r}=V(),{loadOpenMRs:i}=H(),{navigate:a,pathname:o}=Ei(),s=Ai(),c={"/issues":t?e.length:void 0,"/mrs":n.length,"/pipelines":n.filter(e=>e.pipeline).length};return s.map(e=>({...e,active:Oi(o,e.path),badgeCount:c[e.path],go:()=>{a(e.path,{replace:!0}),e.preloadMRs&&n.length===0&&!r&&i()}}))}function ji(){let e=U();return(0,L.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col gap-0.5`,children:e.map((t,n)=>(0,L.jsxs)(x.Fragment,{children:[t.section===`workspace`&&e[n-1]?.section!==`workspace`&&(0,L.jsx)(`div`,{className:`px-2.5 pb-1 pt-5 text-xs font-medium text-fg-subtle`,children:`Workspace`}),(0,L.jsx)(Ci,{label:t.label,icon:t.icon,active:t.active,onClick:t.go,badgeCount:t.badgeCount,showBadge:t.section===`primary`})]},t.path))})}function Mi({size:e=28}){return(0,L.jsx)(`span`,{className:`flex shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-violet-500 to-indigo-600 text-on-accent shadow-sm`,style:{width:e,height:e},"aria-hidden":!0,children:(0,L.jsx)(`svg`,{width:e*.55,height:e*.55,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.2,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,L.jsx)(`path`,{d:`M4 20h16M7 16h10l-1.5-5h-7L7 16Zm1.5-5L10 4h4l1.5 7`})})})}function Ni({open:e,onClose:t}){let{setTaskModalOpen:n}=hi(),{preference:r,setPreference:i}=ir(),{can:a}=Ui();return(0,x.useEffect)(()=>{if(!e)return;let n=e=>e.key===`Escape`&&t();return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`fixed inset-0 z-40 bg-black/40 lg:hidden`,onClick:t}),(0,L.jsxs)(`aside`,{className:Gn(`w-60 shrink-0 flex-col border-r border-line bg-surface lg:static lg:flex`,e?`fixed inset-y-0 left-0 z-50 flex shadow-overlay animate-[forge-slide-in_280ms_cubic-bezier(0.32,0.72,0,1)] pt-[env(safe-area-inset-top)]`:`hidden`),children:[(0,L.jsxs)(`div`,{className:`flex h-14 items-center gap-2.5 px-4`,children:[(0,L.jsx)(Mi,{}),(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsx)(`div`,{className:`text-sm font-semibold tracking-tight text-fg`,children:`Forge`}),(0,L.jsx)(gi,{})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 overflow-y-auto px-3 pb-3 pt-2`,children:[(0,L.jsxs)(z,{variant:`primary`,className:`w-full`,disabled:!a(`operator`),title:a(`operator`)?void 0:`Requires the operator role`,onClick:()=>n(!0),children:[(0,L.jsx)(B,{name:`plus`,size:15}),` New task`]}),(0,L.jsx)(ji,{})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[(0,L.jsx)(or,{value:r,onChange:i}),(0,L.jsx)(xi,{})]})]})]})}function Pi({title:e,subtitle:t,children:n}){return(0,L.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-canvas px-4 py-12`,children:(0,L.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,L.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-4 text-center`,children:[(0,L.jsx)(Mi,{size:40}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:e}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t})]})]}),(0,L.jsx)(`div`,{className:`rounded-2xl border border-line bg-surface-raised p-6 shadow-sm`,children:n})]})})}var Fi=`h-10 w-full rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`;function Ii({message:e}){return(0,L.jsx)(`p`,{role:e?`alert`:void 0,className:e?`rounded-lg bg-red-950/50 px-3 py-2 text-sm text-red-300 ring-1 ring-inset ring-red-800/60`:`hidden`,children:e})}function Li({sso:e,onSignedIn:t}){let[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(!1);return(0,L.jsx)(Pi,{title:`Sign in to Forge`,subtitle:`Use your work account to continue.`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(z,{variant:`secondary`,className:`h-10 w-full`,onClick:()=>{window.location.assign(Wn.ssoStartUrl(window.location.pathname+window.location.search))},children:[`Continue with `,e.name]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`h-px flex-1 bg-line`}),`or use a password`,(0,L.jsx)(`span`,{className:`h-px flex-1 bg-line`})]})]}),(0,L.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),l(!0),s(null);try{await Wn.login(n,i),t()}catch(e){s(e.message)}finally{l(!1)}},className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Email`,(0,L.jsx)(`input`,{type:`email`,autoComplete:`username`,required:!0,value:n,onChange:e=>r(e.target.value),className:Fi})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Password`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`current-password`,required:!0,value:i,onChange:e=>a(e.target.value),className:Fi})]}),(0,L.jsx)(Ii,{message:o}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,className:`h-10 w-full`,disabled:c,children:c?`Signing in…`:`Sign in`})]})]})})}function Ri({requiresToken:e,onDone:t}){let[n,r]=(0,x.useState)({name:``,email:``,password:``,setupToken:``}),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),c=e=>t=>r(n=>({...n,[e]:t.target.value}));return(0,L.jsx)(Pi,{title:`Set up Forge`,subtitle:`Create the first admin account for this workspace.`,children:(0,L.jsxs)(`form`,{onSubmit:async r=>{r.preventDefault(),s(!0),a(null);try{await Wn.setup(e?n:{...n,setupToken:void 0}),t()}catch(e){a(e.message)}finally{s(!1)}},className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Your name`,(0,L.jsx)(`input`,{autoComplete:`name`,required:!0,value:n.name,onChange:c(`name`),className:Fi})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Work email`,(0,L.jsx)(`input`,{type:`email`,autoComplete:`username`,required:!0,value:n.email,onChange:c(`email`),className:Fi})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Password`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,required:!0,minLength:12,value:n.password,onChange:c(`password`),className:Fi}),(0,L.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:`At least 12 characters.`})]}),e&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Setup code`,(0,L.jsx)(`input`,{autoComplete:`off`,required:!0,"aria-describedby":`setup-code-hint`,value:n.setupToken,onChange:c(`setupToken`),className:`h-10 w-full rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`})]}),(0,L.jsx)(`span`,{id:`setup-code-hint`,className:`text-xs text-fg-subtle`,children:`Printed in the server log on first start (or your FORGE_TOKEN, if set). It proves you operate this install.`})]}),(0,L.jsx)(Ii,{message:i}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,className:`h-10 w-full`,disabled:o,children:o?`Creating…`:`Create admin account`})]})})}var zi=(0,x.createContext)(null),Bi=700;function Vi(){let e=window.__forgeBootT??0;return Math.round((performance.now()-e)%Bi)}function Hi({children:e}){let[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(null),a=(0,x.useRef)(null),o=()=>a.current??=Wn.me().then(e=>{n(e),i(null)}).catch(e=>i(e.message)).finally(()=>{a.current=null});if((0,x.useEffect)(()=>{o();let e=()=>o();return window.addEventListener(Hn,e),()=>window.removeEventListener(Hn,e)},[]),r&&!t)return(0,L.jsxs)(`div`,{role:`alert`,className:`flex min-h-screen flex-col items-center justify-center gap-3 bg-canvas px-4 text-center`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:`Forge couldn't load your session.`}),(0,L.jsx)(`p`,{className:`max-w-sm text-sm text-fg-muted`,children:r}),(0,L.jsx)(`button`,{onClick:o,className:`text-sm text-accent-fg hover:underline`,children:`Try again`})]});if(!t)return(0,L.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-canvas`,"aria-busy":`true`,children:(0,L.jsx)(`div`,{className:`size-5 animate-spin rounded-full border-2 border-line-strong border-t-violet-500`,style:{animationDelay:`-${Vi()}ms`}})});if(t.needsSetup)return(0,L.jsx)(Ri,{requiresToken:t.setupRequiresToken??!0,onDone:o});if(!t.user)return(0,L.jsx)(Li,{sso:t.sso,onSignedIn:o});let s=t.user,c={user:s,can:e=>bi(s.role,e),signOut:async()=>{await Wn.logout().catch(()=>void 0),await o()}};return(0,L.jsx)(zi.Provider,{value:c,children:e})}function Ui(){let e=(0,x.useContext)(zi);if(!e)throw Error(`useSession must be used inside <AuthGate>`);return e}var Wi={neutral:`bg-surface-hover/70 text-fg ring-line-strong/60`,accent:`bg-violet-950/60 text-violet-300 ring-violet-800/60`,success:`bg-emerald-950/60 text-emerald-300 ring-emerald-800/60`,warning:`bg-amber-950/60 text-amber-300 ring-amber-800/60`,danger:`bg-red-950/60 text-red-300 ring-red-800/60`,info:`bg-sky-950/60 text-sky-300 ring-sky-800/60`};function Gi({tone:e=`neutral`,dot:t,className:n,children:r}){return(0,L.jsxs)(`span`,{className:Gn(`inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-[11px] font-medium ring-1 ring-inset whitespace-nowrap`,Wi[e],n),children:[t&&(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-current`,"aria-hidden":!0}),r]})}function Ki({icon:e,title:t,description:n,action:r}){return(0,L.jsxs)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center gap-3 rounded-xl border border-dashed border-line px-6 py-12 text-center`,children:[(0,L.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-2xl bg-surface-hover text-fg-muted ring-1 ring-line`,children:(0,L.jsx)(B,{name:e,size:20})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t}),n&&(0,L.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:n})]}),r]})}function qi({title:e,description:t,actions:n}){return(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:e}),t&&(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t})]}),n&&(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:n})]})}var Ji=(e,t,n)=>R(t,{method:e,body:n===void 0?void 0:JSON.stringify(n)}),Yi={listMembers:()=>R(`/admin/users`),addMember:e=>Ji(`POST`,`/admin/users`,e),updateMember:(e,t)=>Ji(`PATCH`,`/admin/users/${e}`,t),listAudit:e=>{let t=new URLSearchParams;return e.action&&t.set(`action`,e.action),e.before&&t.set(`before`,String(e.before)),R(`/admin/audit?${t}`)},listTokens:()=>R(`/auth/tokens`),createToken:e=>Ji(`POST`,`/auth/tokens`,{name:e}),revokeToken:e=>Ji(`DELETE`,`/auth/tokens/${e}`)},Xi=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),Zi=e=>e?Xi.format(new Date(e)):`—`,Qi={"auth.setup":`Set up Forge`,"auth.login":`Signed in`,"auth.sso_login":`Signed in with SSO`,"auth.logout":`Signed out`,"user.create":`Added member`,"user.update":`Updated member`,"token.create":`Created API token`,"token.revoke":`Revoked API token`,"PUT /config":`Changed workspace settings`,"DELETE /workspaces":`Deleted local workspace`,"POST /workspaces/purge":`Purged local workspaces`,"POST /issues":`Created issue`,"PUT /issues/:iid":`Edited issue`,"POST /issues/:iid/close":`Closed issue`,"DELETE /issues/:iid":`Deleted issue`,"POST /issues/:iid/analyze":`Started analysis`,"POST /issues/:iid/refine":`Refined fix`,"POST /issues/:iid/ci-fix":`Asked AI to fix CI`,"POST /issues/:iid/resolution-check":`Checked resolution`,"POST /validate":`Ran validation`,"POST /apply":`Opened merge request`,"POST /commit-to-branch":`Committed to branch`,"POST /promote-branch":`Promoted branch`,"POST /deploy-branch":`Deployed branch`,"POST /jobs/:jobId/cancel":`Cancelled job`,"POST /mr/:mrIid/merge":`Merged merge request`,"POST /mr/:mrIid/auto-merge":`Enabled auto-merge`,"POST /mr/:mrIid/cancel-auto-merge":`Cancelled auto-merge`,"POST /mr/:mrIid/close":`Closed merge request`,"POST /mr/:mrIid/reopen":`Reopened merge request`,"POST /mr/:mrIid/rebase":`Rebased merge request`,"POST /mr/:mrIid/draft":`Changed draft status`};function $i(e){return Qi[e]??e}var ea={success:{label:`Success`,tone:`success`},failure:{label:`Failed`,tone:`danger`},denied:{label:`Denied`,tone:`warning`}},ta=[{value:``,label:`All activity`},{value:`auth.login`,label:`Sign-ins`},{value:`auth.sso_login`,label:`SSO sign-ins`},{value:`POST /mr/:mrIid/merge`,label:`Merges`},{value:`POST /apply`,label:`Merge requests opened`},{value:`PUT /config`,label:`Settings changes`},{value:`user.update`,label:`Member changes`}];function na(){let[e,t]=(0,x.useState)(``),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(null);return(0,x.useEffect)(()=>{r(null),Yi.listAudit({action:e}).then(e=>{r(e.events),a(e.nextCursor)}).catch(e=>s(e.message))},[e]),(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6`,children:[(0,L.jsx)(qi,{title:`Audit log`,description:`Every sign-in and every change made through Forge. Entries can't be edited or deleted.`,actions:(0,L.jsx)(`select`,{"aria-label":`Filter activity`,value:e,onChange:e=>t(e.target.value),className:`h-8 rounded-lg border border-line bg-surface-raised px-2.5 text-xs text-fg focus:border-accent-hover focus:outline-none`,children:ta.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),o&&(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-red-400`,children:o}),n&&n.length===0?(0,L.jsx)(Ki,{icon:`inbox`,title:`No activity yet`,description:`Sign-ins and changes will appear here as they happen.`}):(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface-raised`,children:(0,L.jsxs)(`table`,{"aria-label":`Audit log`,className:`w-full min-w-[860px] table-fixed text-left text-sm`,children:[(0,L.jsxs)(`colgroup`,{children:[(0,L.jsx)(`col`,{className:`w-36`}),(0,L.jsx)(`col`,{className:`w-52`}),(0,L.jsx)(`col`,{}),(0,L.jsx)(`col`,{className:`w-44`}),(0,L.jsx)(`col`,{className:`w-28`})]}),(0,L.jsx)(`thead`,{className:`border-b border-line text-xs font-medium text-fg-subtle`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-4 pr-3 font-medium`,children:`When`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Who`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`What`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Where`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-3 pr-4 text-right font-medium`,children:`Result`})]})}),(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[(n??[]).map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`py-3 pl-4 pr-3 tabular-nums text-fg-muted`,children:Zi(e.at)}),(0,L.jsx)(`td`,{className:`truncate px-3 py-3 text-fg`,title:e.ip??void 0,children:e.actorLabel}),(0,L.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:$i(e.action)}),e.target&&(0,L.jsx)(`span`,{className:`ml-2 font-mono text-xs text-fg-subtle`,children:e.target})]}),(0,L.jsx)(`td`,{className:`truncate px-3 py-3 font-mono text-xs text-fg-subtle`,children:e.repo?.replace(/^[a-z]+:/,``)??`—`}),(0,L.jsx)(`td`,{className:`py-3 pl-3 pr-4 text-right`,children:(0,L.jsx)(Gi,{tone:ea[e.outcome].tone,children:ea[e.outcome].label})})]},e.id)),!n&&Array.from({length:5}).map((e,t)=>(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:5,className:`h-[45px] px-4`,children:(0,L.jsx)(`div`,{className:`h-3 w-1/2 animate-pulse rounded bg-surface-hover`})})},t))]})]})}),i&&(0,L.jsx)(`div`,{className:`flex justify-center`,children:(0,L.jsx)(z,{size:`sm`,onClick:async()=>{if(!i)return;let t=await Yi.listAudit({action:e,before:i});r(e=>[...e??[],...t.events]),a(t.nextCursor)},children:`Load older activity`})})]})}var ra=`h-9 w-full rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`,ia=`h-8 rounded-lg border border-line bg-surface-raised px-2 text-xs text-fg focus:border-accent-hover focus:outline-none disabled:opacity-50`;function aa({onAdded:e,onCancel:t}){let[n,r]=(0,x.useState)({name:``,email:``,role:`operator`,password:``}),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1);return(0,L.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),s(!0),a(null);try{e((await Yi.addMember(n)).user)}catch(e){a(e.message)}finally{s(!1)}},"aria-label":`Add member`,className:`grid gap-4 rounded-xl border border-line bg-surface-raised p-5 shadow-sm sm:grid-cols-2`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Name`,(0,L.jsx)(`input`,{required:!0,value:n.name,onChange:e=>r({...n,name:e.target.value}),className:ra})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Email`,(0,L.jsx)(`input`,{type:`email`,required:!0,value:n.email,onChange:e=>r({...n,email:e.target.value}),className:ra})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Role`,(0,L.jsx)(`select`,{value:n.role,onChange:e=>r({...n,role:e.target.value}),className:ra,children:_i.map(e=>(0,L.jsx)(`option`,{value:e,children:vi[e]},e))}),(0,L.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:yi[n.role]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Temporary password`,(0,L.jsx)(`input`,{type:`password`,required:!0,minLength:12,autoComplete:`new-password`,value:n.password,onChange:e=>r({...n,password:e.target.value}),className:ra}),(0,L.jsx)(`span`,{className:`text-xs font-normal text-fg-subtle`,children:`Share it privately. SSO users can leave Forge's password unused.`})]}),i&&(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-red-400 sm:col-span-2`,children:i}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2 sm:col-span-2`,children:[(0,L.jsx)(z,{variant:`ghost`,size:`sm`,onClick:t,children:`Cancel`}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,size:`sm`,disabled:o,children:`Add`})]})]})}function oa(){let{user:e}=Ui(),[t,n]=(0,x.useState)(null),[r,i]=(0,x.useState)(null),[a,o]=(0,x.useState)(!1);(0,x.useEffect)(()=>{Yi.listMembers().then(e=>n(e.users)).catch(e=>i(e.message))},[]);let s=async(e,t)=>{i(null);try{let{user:r}=await Yi.updateMember(e.id,t);n(e=>e?.map(e=>e.id===r.id?r:e)??null)}catch(e){i(e.message)}};return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6`,children:[(0,L.jsx)(qi,{title:`Members`,description:`Who can use this Forge workspace, and what they're allowed to do.`,actions:(0,L.jsxs)(z,{size:`sm`,variant:`primary`,onClick:()=>o(!0),children:[(0,L.jsx)(B,{name:`plus`,size:14}),` Add member`]})}),a&&(0,L.jsx)(aa,{onCancel:()=>o(!1),onAdded:e=>{n(t=>[...t??[],e]),o(!1)}}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`rounded-lg bg-red-950/50 px-3 py-2 text-sm text-red-300 ring-1 ring-inset ring-red-800/60`,children:r}),(0,L.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface-raised`,children:(0,L.jsxs)(`table`,{"aria-label":`Members`,className:`w-full min-w-[760px] table-fixed text-left text-sm`,children:[(0,L.jsxs)(`colgroup`,{children:[(0,L.jsx)(`col`,{}),(0,L.jsx)(`col`,{className:`w-40`}),(0,L.jsx)(`col`,{className:`w-28`}),(0,L.jsx)(`col`,{className:`w-40`}),(0,L.jsx)(`col`,{className:`w-32`})]}),(0,L.jsx)(`thead`,{className:`border-b border-line text-xs font-medium text-fg-subtle`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-4 pr-3 font-medium`,children:`Member`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Role`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Sign-in`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Last active`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-3 pr-4 text-right font-medium`,children:`Access`})]})}),(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[(t??[]).map(t=>(0,L.jsxs)(`tr`,{className:t.disabled?`opacity-60`:void 0,children:[(0,L.jsx)(`td`,{className:`py-3 pl-4 pr-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg-muted ring-1 ring-line`,children:t.name.slice(0,1).toUpperCase()}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`truncate font-medium text-fg`,children:[t.name,` `,t.id===e.id&&(0,L.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:`(you)`})]}),(0,L.jsx)(`div`,{className:`truncate text-xs text-fg-subtle`,children:t.email})]})]})}),(0,L.jsx)(`td`,{className:`px-3 py-3`,children:(0,L.jsx)(`select`,{"aria-label":`Role for ${t.name}`,value:t.role,onChange:e=>s(t,{role:e.target.value}),title:yi[t.role],className:ia,children:_i.map(e=>(0,L.jsx)(`option`,{value:e,children:vi[e]},e))})}),(0,L.jsx)(`td`,{className:`px-3 py-3`,children:(0,L.jsx)(Gi,{tone:t.authProvider===`oidc`?`info`:`neutral`,children:t.authProvider===`oidc`?`SSO`:`Password`})}),(0,L.jsx)(`td`,{className:`px-3 py-3 tabular-nums text-fg-muted`,children:Zi(t.lastLoginAt)}),(0,L.jsx)(`td`,{className:`py-3 pl-3 pr-4 text-right`,children:(0,L.jsx)(z,{size:`sm`,variant:`ghost`,disabled:t.id===e.id,onClick:()=>s(t,{disabled:!t.disabled}),children:t.disabled?`Enable`:`Disable`})})]},t.id)),!t&&Array.from({length:3}).map((e,t)=>(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:5,className:`h-[57px] px-4`,children:(0,L.jsx)(`div`,{className:`h-3 w-1/3 animate-pulse rounded bg-surface-hover`})})},t))]})]})})]})}var sa=/\b(error|failed|failure|exception|panic|traceback|cannot|could not|refused|denied|timed? out|abort|unexpected)\b/i,ca=/\b(warn|warning|skipped|skipping|deprecated|retry|retrying|fallback|truncated|missing)\b/i,la=/\b(ok|success|passed|completed|done|ready|merged|applied|resolved)\b/i,ua=/^(reasoning|scanning|analysis started|ci fix started|identified|loaded)\b/i;function da(e){return sa.test(e)?`error`:ca.test(e)?`warn`:la.test(e)?`success`:ua.test(e)?`debug`:`info`}function fa(e){try{let t=new Date(e);return Number.isNaN(t.getTime())?``:`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}.${String(t.getMilliseconds()).padStart(3,`0`)}`}catch{return`--:--:--.---`}}var pa={info:{icon:`ℹ`,text:`text-fg`,iconColor:`text-sky-400`},warn:{icon:`⚠`,text:`text-amber-300`,iconColor:`text-amber-400`},error:{icon:`✖`,text:`text-red-300`,iconColor:`text-red-400`},debug:{icon:`›`,text:`text-fg-subtle`,iconColor:`text-fg-subtle`},success:{icon:`✓`,text:`text-emerald-300`,iconColor:`text-emerald-400`}};function ma({entries:e,autoScroll:t=!0,variant:n=`panel`,heightClass:r=`min-h-[12rem] max-h-[60vh]`,label:i,badge:a,headerAccessory:o,empty:s=`No output yet.`}){let c=(0,x.useRef)(null);(0,x.useEffect)(()=>{t&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[e.length,t]);let l=e.map(e=>typeof e==`string`?{ts:new Date().toISOString(),message:e}:e),u=(0,L.jsx)(`div`,{ref:c,className:`font-mono text-[11px] leading-5 ${r} overflow-y-auto bg-canvas`,children:l.length===0?(0,L.jsx)(`div`,{className:`px-4 py-3 text-fg-subtle italic`,children:s}):(0,L.jsx)(`div`,{children:l.map((e,t)=>{let n=e.level??da(e.message),r=pa[n];return(0,L.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-[2px] hover:bg-fg/[0.02] border-l-2 border-transparent`,style:{borderLeftColor:n===`error`?`rgba(248, 113, 113, 0.5)`:n===`warn`?`rgba(251, 191, 36, 0.4)`:n===`success`?`rgba(52, 211, 153, 0.4)`:`transparent`},children:[(0,L.jsx)(`span`,{className:`text-fg-subtle select-none shrink-0 tabular-nums`,children:fa(e.ts)}),(0,L.jsx)(`span`,{className:`${r.iconColor} shrink-0 select-none`,children:r.icon}),(0,L.jsx)(`span`,{className:`${r.text} whitespace-pre-wrap break-words`,children:e.message})]},t)})})});return n===`embedded`?u:(0,L.jsxs)(`div`,{className:`border border-line rounded-lg overflow-hidden bg-canvas shadow-inner`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-raised/80 border-b border-line px-3 py-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-fg-subtle font-mono`,children:[(0,L.jsxs)(`span`,{className:`flex gap-1.5`,children:[(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-red-500/60`}),(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-amber-500/60`}),(0,L.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full bg-emerald-500/60`})]}),i&&(0,L.jsx)(`span`,{className:`pl-1`,children:i}),a&&(0,L.jsx)(`span`,{className:`ml-1 px-1.5 py-0.5 rounded bg-surface-raised text-[10px] text-fg-muted tracking-normal normal-case`,children:a})]}),o&&(0,L.jsx)(`div`,{className:`flex items-center`,children:o})]}),u]})}function ha(e,t=Date.now()){return e.replace(/\x1b\[[0-9;]*[a-zA-Z]/g,``).split(`
17
17
  `).map((e,n)=>({ts:new Date(t+n).toISOString(),message:e.length?e:` `}))}var ga=[`fetch_issue`,`scan_repo`,`identify_files`,`fetch_files`,`generate_fix`],_a={fetch_issue:`fetch_issue`,scan_repo:`scan_repos`,identify_files:`identify_files`,fetch_files:`fetch_files`,generate_fix:`generate_fix`};function va({steps:e,logs:t,issueTitle:n,mode:r=`analyze`}){let i=new Set(e.map(e=>e.step)),a=e[e.length-1],o=r===`ci-fix`?`ci-fix`:`analyze`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`border border-line rounded-lg overflow-hidden bg-canvas`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-raised/80 border-b border-line px-4 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs font-mono text-fg-muted`,children:[(0,L.jsx)(`span`,{className:`text-emerald-400`,children:`●`}),(0,L.jsxs)(`span`,{className:`text-fg-subtle`,children:[`forge / `,o]}),(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`›`}),(0,L.jsx)(`span`,{className:`text-fg truncate max-w-md`,children:n})]}),r===`ci-fix`&&(0,L.jsx)(`span`,{className:`text-[11px] font-mono px-2 py-0.5 rounded bg-amber-950/60 text-amber-300 border border-amber-900`,children:`CI FAILURE`})]}),(0,L.jsx)(`div`,{className:`px-4 py-4`,children:(0,L.jsx)(`div`,{className:`flex flex-col gap-1`,children:ga.map((t,n)=>{let r=i.has(t),o=a?.step===t,s=e.find(e=>e.step===t)?.message??``,c=_a[t]??t,l,u=`text-fg-subtle`;return r&&!o?(l=(0,L.jsx)(`span`,{className:`text-emerald-400 text-sm`,children:`✓`}),u=`text-fg-muted`):o?(l=(0,L.jsx)(`span`,{className:`w-3.5 h-3.5 rounded-full border-2 border-violet-400 border-t-transparent animate-spin inline-block`}),u=`text-fg`):l=(0,L.jsx)(`span`,{className:`text-fg-subtle text-sm`,children:`○`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 font-mono text-xs`,children:[(0,L.jsx)(`span`,{className:`text-fg-subtle tabular-nums select-none w-6 text-right`,children:String(n+1).padStart(2,`0`)}),(0,L.jsx)(`span`,{className:`w-5 flex items-center justify-center shrink-0`,children:l}),(0,L.jsx)(`span`,{className:`${u} w-36 shrink-0`,children:c}),(0,L.jsx)(`span`,{className:`text-fg-subtle truncate`,children:s||`—`})]},t)})})})]}),t.length>0&&(0,L.jsx)(ma,{entries:t,label:`forge ${o}`,badge:`${t.length} entr${t.length===1?`y`:`ies`}`,heightClass:`min-h-[40vh] max-h-[65vh]`})]})}function ya(){let{selectedIssue:e,progressSteps:t,analysisLogs:n,analysisResult:r,analysisMode:i}=V(),{handleCancelAnalysis:a}=H();return e?(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(va,{steps:t,logs:n,issueTitle:e.title,mode:i}),(0,L.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,L.jsx)(`button`,{onClick:a,className:`w-full md:w-auto min-h-[50px] md:min-h-0 text-[17px] md:text-xs text-red-400 md:text-fg-muted hover:text-red-300 border border-line-strong hover:border-red-800/60 px-3 py-1.5 rounded-xl md:rounded-lg transition-colors`,title:`Stop the running analysis and return to the issue view. The Claude CLI is killed on the server.`,children:`Cancel analysis`})}),r&&r.changes.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:[`Proposed changes (`,r.changes.length,` file`,r.changes.length===1?``:`s`,`)`]}),r.changes.map(e=>(0,L.jsxs)(`div`,{className:`flex items-start gap-3 bg-surface-raised border border-line-strong rounded-lg px-4 py-3`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium mt-0.5 shrink-0 ${e.action===`create`?`text-green-400`:e.action===`delete`?`text-red-400`:`text-yellow-400`}`,children:e.action}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,L.jsx)(`span`,{className:`text-sm font-mono text-fg truncate`,children:e.file}),e.summary&&(0,L.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.summary})]})]},e.file))]})]}):null}var ba={success:`bg-green-400`,failed:`bg-red-400`,running:`bg-yellow-400 animate-pulse`,pending:`bg-yellow-600`,canceled:`bg-fg-subtle`,skipped:`bg-fg-subtle`,created:`bg-fg-subtle`},xa={success:`passed`,failed:`failed`,running:`running`,pending:`pending`,canceled:`canceled`},Sa={open:`No open Forge merge requests.`,merged:`No merged Forge merge requests.`,closed:`No closed Forge merge requests.`};function Ca({mrs:e,loading:t,refreshing:n=!1,error:r,state:i=`open`,onSelect:a,onRefresh:o}){return t?(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:Array.from({length:3}).map((e,t)=>(0,L.jsx)(`div`,{className:`h-16 bg-surface-raised rounded-lg animate-pulse`},t))}):r?(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-red-950/40 border border-red-800 rounded-lg px-4 py-3`,children:[(0,L.jsx)(`p`,{className:`text-sm text-red-300`,children:r}),(0,L.jsx)(`button`,{onClick:o,className:`text-xs text-red-400 hover:text-red-200 transition-colors ml-4 shrink-0`,children:`Retry`})]}):e.length===0?(0,L.jsx)(`div`,{className:`text-center py-12 text-fg-subtle text-sm`,children:Sa[i]}):(0,L.jsx)(`div`,{"aria-busy":n||void 0,className:`flex flex-col gap-2 transition-opacity ${n?`opacity-60`:``}`,children:e.map(e=>{let t=e.pipeline?ba[e.pipeline.status]??`bg-fg-subtle`:`bg-fg-subtle`,n=e.pipeline?xa[e.pipeline.status]??e.pipeline.status:`no pipeline`,r=e.source_branch.match(/^forge\/issue-(\d+)-/),i=r?r[1]:null;return(0,L.jsx)(`button`,{onClick:()=>a(e),className:`w-full text-left bg-surface-raised ring-1 ring-inset ring-line-strong hover:bg-surface-hover active:bg-surface-hover border border-line-strong hover:border-violet-500 rounded-xl md:rounded-lg px-4 py-3 transition-colors group`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`flex flex-col items-center gap-1 pt-0.5 shrink-0`,children:(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full ${t}`,title:n})}),(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle font-mono`,children:[`!`,e.iid]}),i&&(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle font-mono`,children:[`#`,i]}),e.has_conflicts&&(0,L.jsx)(`span`,{className:`text-xs bg-amber-900/50 text-amber-400 border border-amber-700/50 px-1.5 py-0.5 rounded`,children:`conflicts`}),e.pipeline&&(0,L.jsx)(`span`,{className:`text-xs ${e.pipeline.status===`failed`?`text-red-400`:e.pipeline.status===`success`?`text-green-400`:e.pipeline.status===`running`?`text-yellow-400`:`text-fg-subtle`}`,children:n})]}),(0,L.jsx)(`p`,{className:`text-[16px] md:text-sm leading-snug text-fg font-semibold md:font-medium line-clamp-2 md:line-clamp-none md:truncate`,children:e.title}),(0,L.jsx)(`p`,{className:`text-xs font-mono text-fg-subtle mt-0.5 truncate`,children:e.source_branch})]}),(0,L.jsxs)(`div`,{className:`shrink-0 flex flex-col items-end gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:new Date(e.created_at).toLocaleDateString()}),(0,L.jsx)(`span`,{className:`hidden md:inline text-violet-400 opacity-0 group-hover:opacity-100 transition-opacity text-xs`,children:`View →`}),(0,L.jsx)(B,{name:`chevronRight`,className:`md:hidden mt-2 text-fg-subtle`})]})]})},e.iid)})})}var wa={success:`success`,failed:`danger`,running:`info`,pending:`warning`,created:`neutral`,manual:`accent`,canceled:`neutral`,skipped:`neutral`},Ta=/^refs\/merge-requests\/(\d+)\/head$/,Ea=`h-14`;function Da(e){let t=Ta.exec(e);return t?`!${t[1]}`:e}function Oa(e,t){let n=new URLSearchParams;return e&&n.set(`repo`,e),n.set(`page`,String(t)),`/pipelines?${n}`}function ka({repo:e,reloadKey:t}){let[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null);return(0,x.useEffect)(()=>{let t=!1;return l(null),R(Oa(e,1)).then(e=>{t||(r(e.pipelines),a(e.nextPage))}).catch(e=>{t||l(e.message)}),()=>{t=!0}},[e,t]),c&&n===null?(0,L.jsx)(`div`,{className:`rounded-lg border border-red-800 bg-red-950/40 px-4 py-3 text-sm text-red-300`,children:c}):n===null?(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:Array.from({length:6}).map((e,t)=>(0,L.jsx)(`div`,{"data-testid":`pipeline-skeleton`,className:`${Ea} animate-pulse rounded-lg bg-surface-raised`},t))}):n.length===0?(0,L.jsx)(Ki,{icon:`pipeline`,title:`No pipelines yet`,description:`CI runs for this repo will show up here.`}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`ul`,{className:`flex flex-col gap-2`,children:n.map(e=>{let t=Da(e.ref);return(0,L.jsxs)(`li`,{className:`${Ea} flex items-center gap-4 rounded-lg border border-line-strong/50 bg-surface-raised/50 px-4`,children:[(0,L.jsx)(Gi,{tone:wa[e.status]??`neutral`,dot:!0,className:`w-20 justify-center`,children:e.status}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`truncate font-mono text-sm text-fg`,title:e.ref,children:t}),e.ref.startsWith(`forge/`)&&(0,L.jsx)(Gi,{tone:`accent`,children:`Forge`})]}),(0,L.jsxs)(`span`,{className:`font-mono text-[11px] text-fg-subtle`,children:[e.sha.slice(0,8),` · `,e.source.replace(/_/g,` `)]})]}),(0,L.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:kr(e.created_at)}),(0,L.jsxs)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`shrink-0 text-xs tabular-nums text-fg-subtle transition-colors hover:text-fg`,children:[`#`,e.id,` ↗`]})]},e.id)})}),c&&(0,L.jsx)(`p`,{className:`text-xs text-red-400`,children:c}),i!==null&&(0,L.jsx)(z,{size:`sm`,className:`self-center`,onClick:()=>{i!==null&&(s(!0),R(Oa(e,i)).then(e=>{r(t=>{let n=new Set(t?.map(e=>e.id));return[...t??[],...e.pipelines.filter(e=>!n.has(e.id))]}),a(e.nextPage)}).catch(e=>l(e.message)).finally(()=>s(!1)))},disabled:o,children:o?`Loading…`:`Load more`})]})}var Aa=new Map;function ja(e){let t=Aa.get(e);return t||(t=R(`/labels?repo=${encodeURIComponent(e)}`).then(({labels:e})=>e.map(e=>e.name)).catch(()=>(Aa.delete(e),[])),Aa.set(e,t)),t}function Ma(e){let[t,n]=(0,x.useState)([]);return(0,x.useEffect)(()=>{if(!e)return;let t=!0;return ja(e).then(e=>t&&n(e)),()=>{t=!1}},[e]),t}var Na=[`critical`,`high`,`medium`,`low`],Pa={priority:Na,status:[`triage`,`ready`,`in-progress`,`in-review`,`blocked`]},Fa=/^(type|priority|status|area)::(.+)$/;function Ia(e){let t={type:null,priority:null,status:null,areas:[],other:[]};for(let n of e){let e=n.match(Fa);if(!e){t.other.push(n);continue}let[,r,i]=e;r===`area`?t.areas.push(i):t[r]=i}return t}function La({issues:e,query:t,type:n,priority:r}){let i=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{let t=Ia(e.labels);if(n!==`all`&&t.type!==n||r!==`all`&&t.priority!==r)return!1;if(!i.length)return!0;let a=`#${e.iid} ${e.title} ${e.labels.join(` `)}`.toLowerCase();return i.every(t=>t.startsWith(`#`)?`#${e.iid}`===t:a.includes(t))})}function Ra(e,t,n){let r=e.filter(e=>!e.startsWith(`${t}::`));return n?[...r,`${t}::${n}`]:r}function za(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Ba({available:e,scope:t,current:n}){let r=`${t}::`,i=new Set(e.filter(e=>e.startsWith(r)).map(e=>e.slice(r.length)));n&&i.add(n);let a=t===`area`?void 0:Pa[t],o=e=>a?.includes(e)?a.indexOf(e):2**53-1;return[...i].sort((e,t)=>o(e)-o(t)||e.localeCompare(t))}var Va=[{scope:`type`,label:`Type`},{scope:`priority`,label:`Priority`},{scope:`status`,label:`Status`}],Ha=`h-8 w-full rounded-lg border border-line bg-canvas px-2.5 text-xs text-fg focus:border-accent-hover focus:outline-none`,Ua=`inline-flex h-6 items-center gap-1 rounded-md px-2 text-xs transition-colors`;function Wa({labels:e,available:t,onChange:n}){let r=Ia(e),i=Ba({available:t,scope:`area`,current:null});for(let e of r.areas)i.includes(e)||i.push(e);let a=t.filter(t=>!t.includes(`::`)&&!e.includes(t)),[o,s]=(0,x.useState)(``),c=(0,x.useId)(),l=()=>{let t=o.trim();!t||t.includes(`,`)||(e.includes(t)||n([...e,t]),s(``))};return(0,L.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Labels`}),(0,L.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:Va.map(({scope:i,label:a})=>(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg-subtle`,children:[a,(0,L.jsxs)(`select`,{"aria-label":a,value:r[i]??``,onChange:t=>n(Ra(e,i,t.target.value||null)),className:Gn(Ha,`normal-case tracking-normal`),children:[(0,L.jsx)(`option`,{value:``,children:`None`}),Ba({available:t,scope:i,current:r[i]}).map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]})]},i))}),i.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:`Areas`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(t=>{let i=r.areas.includes(t);return(0,L.jsx)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>n(za(e,`area::${t}`)),className:Gn(Ua,i?`bg-accent text-on-accent`:`bg-surface-raised text-fg-muted ring-1 ring-inset ring-line hover:text-fg`),children:t},t)})})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:`Other labels`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r.other.map(t=>(0,L.jsxs)(`span`,{className:Gn(Ua,`bg-surface-raised text-fg-muted ring-1 ring-inset ring-line`),children:[t,(0,L.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t}`,onClick:()=>n(e.filter(e=>e!==t)),className:`text-fg-subtle hover:text-fg`,children:`×`})]},t)),(0,L.jsx)(`input`,{type:`text`,role:`combobox`,"aria-label":`Add label`,"aria-expanded":!1,list:c,placeholder:`Add label…`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),l())},onBlur:l,className:Gn(Ha,`h-6 w-36`)}),(0,L.jsx)(`datalist`,{id:c,children:a.map(e=>(0,L.jsx)(`option`,{value:e},e))})]})]})]})}var Ga=`w-full rounded-lg border border-line bg-canvas px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`;function Ka({onCreate:e,availableLabels:t,onCancel:n}){let[r,i]=(0,x.useState)(``),[a,o]=(0,x.useState)(``),[s,c]=(0,x.useState)([]),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(null);return(0,L.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),r.trim()){u(!0),f(null);try{await e(r.trim(),a.trim(),s),n()}catch(e){f(e.message)}finally{u(!1)}}},"aria-label":`New issue`,className:`flex flex-col gap-3 rounded-xl border border-line bg-surface-raised p-4 shadow-sm`,children:[(0,L.jsx)(`input`,{type:`text`,"aria-label":`Issue title`,placeholder:`Issue title`,value:r,onChange:e=>i(e.target.value),className:Ga}),(0,L.jsx)(`textarea`,{"aria-label":`Description`,placeholder:`Description (optional)`,value:a,onChange:e=>o(e.target.value),rows:3,className:`${Ga} resize-none`}),(0,L.jsx)(Wa,{labels:s,available:t,onChange:c}),d&&(0,L.jsx)(`p`,{className:`text-xs text-red-400`,children:d}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(z,{variant:`ghost`,size:`sm`,onClick:n,children:`Cancel`}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,size:`sm`,disabled:l||!r.trim(),children:l?`Creating…`:`Create issue`})]})]})}var qa={analyze:`analyzing`,refine:`refining`,"ci-fix":`fixing CI`,validate:`validating`};function Ja({types:e}){if(!e.length)return null;let t=e.find(e=>e===`analyze`)??e.find(e=>e===`ci-fix`)??e.find(e=>e===`refine`)??e[0];return(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-violet-300 bg-violet-950/50 border border-violet-800/60 px-2 py-0.5 rounded-full shrink-0`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full border border-violet-300 border-t-transparent animate-spin inline-block shrink-0`}),qa[t],e.length>1&&(0,L.jsxs)(`span`,{className:`text-violet-400/70`,children:[`+`,e.length-1]})]})}var Ya=new Set([`running`,`pending`,`created`,`preparing`,`waiting_for_resource`,`scheduled`]);function Xa({pipeline:e}){if(!e)return null;let t=Ya.has(e.status),n=e.status===`failed`;if(!t&&!n)return null;let r=t?`text-amber-300 bg-amber-950/40 border-amber-800/60 hover:bg-amber-900/50`:`text-red-300 bg-red-950/40 border-red-800/60 hover:bg-red-900/50`,i=t?`pipeline running`:`pipeline failed`;return(0,L.jsxs)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`flex items-center gap-1.5 text-[11px] px-2 py-0.5 rounded-full shrink-0 border transition-colors ${r}`,title:`CI pipeline is ${e.status}`,children:[t?(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full border border-amber-300 border-t-transparent animate-spin inline-block shrink-0`}):(0,L.jsx)(`span`,{"aria-hidden":!0,children:`✗`}),i]})}function Za({issue:e,activeJobs:t=[],pipeline:n,openMr:r}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Ja,{types:t}),(0,L.jsx)(Xa,{pipeline:n}),!e.likelyFixedByMr&&r&&(0,L.jsxs)(`a`,{href:r.web_url,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[11px] text-sky-300 bg-sky-950/50 border border-sky-800/60 px-2 py-0.5 rounded-full shrink-0 hover:bg-sky-900/60 transition-colors`,title:`MR !${r.iid} is open — not yet merged.`,children:[`MR open !`,r.iid]}),e.likelyFixedByMr&&(0,L.jsxs)(`a`,{href:e.likelyFixedByMr.webUrl,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[11px] text-emerald-300 bg-emerald-950/50 border border-emerald-800/60 px-2 py-0.5 rounded-full shrink-0 hover:bg-emerald-900/60 transition-colors`,title:`Merged via !${e.likelyFixedByMr.iid}. Verify the fix and close the issue on GitLab if resolved.`,children:[`✓ merged !`,e.likelyFixedByMr.iid]}),e.forgeBranch&&e.branchAhead===0&&(0,L.jsx)(`span`,{className:`text-[11px] text-amber-300 bg-amber-950/40 border border-amber-800/60 px-2 py-0.5 rounded-full shrink-0`,title:`Branch has no commits ahead of main — nothing to promote.`,children:`stale branch`})]})}var Qa={bug:`danger`,security:`danger`,feature:`accent`,enhancement:`info`},$a={critical:`danger`,high:`warning`,medium:`info`,low:`neutral`},eo=e=>e.charAt(0).toUpperCase()+e.slice(1),to=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`});function no({issues:e,onSelect:t,renderStatus:n}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`ul`,{"aria-label":`Issues`,className:`divide-y divide-line overflow-hidden rounded-xl border border-line bg-surface-raised md:hidden`,children:e.map(e=>{let r=Ia(e.labels);return(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:`flex w-full items-center gap-3 px-4 py-3.5 text-left active:bg-surface-hover`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`line-clamp-2 font-medium text-fg`,children:e.title}),(0,L.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[(0,L.jsxs)(`span`,{children:[`#`,e.iid]}),r.type&&(0,L.jsx)(Gi,{tone:Qa[r.type]??`neutral`,children:eo(r.type)}),r.priority&&(0,L.jsx)(Gi,{tone:$a[r.priority]??`neutral`,dot:!0,children:eo(r.priority)}),n?.(e)]})]}),(0,L.jsx)(B,{name:`chevronRight`,size:16,className:`shrink-0 text-fg-subtle`})]})},e.iid)})}),(0,L.jsx)(`div`,{className:`hidden overflow-x-auto rounded-xl border border-line bg-surface-raised md:block`,children:(0,L.jsxs)(`table`,{"aria-label":`Issues`,className:`w-full min-w-[880px] table-fixed text-left text-sm`,children:[(0,L.jsxs)(`colgroup`,{children:[(0,L.jsx)(`col`,{}),(0,L.jsx)(`col`,{className:`w-28`}),(0,L.jsx)(`col`,{className:`w-28`}),(0,L.jsx)(`col`,{className:`w-48`}),(0,L.jsx)(`col`,{className:`w-36`}),(0,L.jsx)(`col`,{className:`w-24`})]}),(0,L.jsx)(`thead`,{className:`border-b border-line text-xs font-medium text-fg-subtle`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-4 pr-3 font-medium`,children:`Issue`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Type`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Priority`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Status`}),(0,L.jsx)(`th`,{scope:`col`,className:`px-3 py-2.5 font-medium`,children:`Author`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2.5 pl-3 pr-4 text-right font-medium`,children:`Opened`})]})}),(0,L.jsx)(`tbody`,{className:`divide-y divide-line`,children:e.map(e=>{let r=Ia(e.labels);return(0,L.jsxs)(`tr`,{onClick:()=>t(e),className:`group cursor-pointer transition-colors hover:bg-surface-hover`,children:[(0,L.jsxs)(`td`,{className:`py-3 pl-4 pr-3 align-top`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-fg-subtle`,children:[`#`,e.iid]}),(0,L.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(e)},className:`truncate text-left font-medium text-fg group-hover:text-accent-fg`,children:e.title})]}),(0,L.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-2 text-xs text-fg-subtle`,children:[e.forgeBranch&&(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 font-mono`,title:e.forgeBranch,children:[(0,L.jsx)(B,{name:`branch`,size:12,className:`shrink-0`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.forgeBranch})]}),r.areas.map(e=>(0,L.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-px`,children:e},e))]})]}),(0,L.jsx)(`td`,{className:`px-3 py-3 align-top`,children:r.type?(0,L.jsx)(Gi,{tone:Qa[r.type]??`neutral`,children:eo(r.type)}):(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-3 py-3 align-top`,children:r.priority?(0,L.jsx)(Gi,{tone:$a[r.priority]??`neutral`,dot:!0,children:eo(r.priority)}):(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`—`})}),(0,L.jsx)(`td`,{className:`px-3 py-3 align-top`,children:(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n?.(e)})}),(0,L.jsx)(`td`,{className:`truncate px-3 py-3 align-top text-fg-muted`,children:e.author.name}),(0,L.jsx)(`td`,{className:`whitespace-nowrap py-3 pl-3 pr-4 text-right align-top tabular-nums text-fg-subtle`,children:to.format(new Date(e.created_at))})]},e.iid)})})]})})]})}var ro=`h-8 rounded-lg border border-line bg-surface-raised px-2.5 text-xs text-fg focus:border-accent-hover focus:outline-none`;function io(e,t){let n=new Set;for(let r of e){let e=Ia(r.labels)[t];e&&n.add(e)}let r=[...n];return t===`priority`?r.sort((e,t)=>Na.indexOf(e)-Na.indexOf(t)):r.sort()}function ao({issues:e,loading:t,refreshing:n=!1,error:r,onSelect:i,onCreate:a,availableLabels:o,activeJobsByIid:s,pipelinesByIid:c,openMrByIid:l,creating:u,onCreatingChange:d}){let[f,p]=(0,x.useState)(``),[m,h]=(0,x.useState)(`all`),[g,_]=(0,x.useState)(`all`),v=La({issues:e,query:f,type:m,priority:g}),y=v.length===e.length?`${e.length} ${e.length===1?`issue`:`issues`}`:`${v.length} of ${e.length} issues`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u&&(0,L.jsx)(Ka,{onCreate:a,availableLabels:o,onCancel:()=>d(!1)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 items-center gap-2 sm:flex sm:flex-wrap`,children:[(0,L.jsxs)(`div`,{className:`relative col-span-2 min-w-[220px] flex-1 sm:max-w-xs`,children:[(0,L.jsx)(B,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-subtle`}),(0,L.jsx)(`input`,{type:`search`,"aria-label":`Filter issues`,placeholder:`Filter by title, #number or label`,value:f,onChange:e=>p(e.target.value),className:`h-8 w-full rounded-lg border border-line bg-surface-raised pl-8 pr-2.5 text-xs text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`})]}),(0,L.jsxs)(`select`,{"aria-label":`Type`,value:m,onChange:e=>h(e.target.value),className:ro,children:[(0,L.jsx)(`option`,{value:`all`,children:`All types`}),io(e,`type`).map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]}),(0,L.jsxs)(`select`,{"aria-label":`Priority`,value:g,onChange:e=>_(e.target.value),className:ro,children:[(0,L.jsx)(`option`,{value:`all`,children:`All priorities`}),io(e,`priority`).map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]}),(0,L.jsx)(`span`,{className:`col-span-2 min-w-28 text-xs tabular-nums text-fg-subtle sm:ml-auto`,"aria-live":`polite`,children:t?`Loading…`:y})]}),r&&(0,L.jsx)(`div`,{className:`max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-xl border border-red-800/60 bg-red-950/40 px-4 py-3 text-sm leading-snug text-red-300 [overflow-wrap:anywhere]`,children:r}),t?(0,L.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface-raised`,"aria-busy":`true`,children:Array.from({length:6}).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex h-[61px] items-center gap-4 border-b border-line px-4 last:border-0`,children:[(0,L.jsx)(`div`,{className:`h-3 w-8 animate-pulse rounded bg-surface-hover`}),(0,L.jsx)(`div`,{className:`h-3 flex-1 animate-pulse rounded bg-surface-hover`}),(0,L.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-surface-hover`}),(0,L.jsx)(`div`,{className:`h-3 w-16 animate-pulse rounded bg-surface-hover`})]},t))}):e.length===0?(0,L.jsx)(Ki,{icon:`inbox`,title:`No open issues`,description:`Create an issue and Forge can analyze it, propose a fix and open the merge request.`,action:(0,L.jsxs)(z,{size:`sm`,variant:`primary`,onClick:()=>d(!0),children:[(0,L.jsx)(B,{name:`plus`,size:14}),` New issue`]})}):v.length===0?(0,L.jsx)(Ki,{icon:`search`,title:`No matching issues`,description:`Try a different search or clear the filters.`}):(0,L.jsx)(`div`,{"aria-busy":n||void 0,className:Gn(`transition-opacity`,n&&`opacity-60`),children:(0,L.jsx)(no,{issues:v,onSelect:i,renderStatus:e=>(0,L.jsx)(Za,{issue:e,activeJobs:s[e.iid],pipeline:c[e.iid],openMr:l[e.iid]})})})]})}var oo=new Set([`running`,`pending`,`created`,`preparing`,`waiting_for_resource`,`scheduled`]),so=15e3;function co(e){if(!e)return null;let t=e.match(/^forge\/issue-(\d+)(?:-|$)/);return t?Number(t[1]):null}function W(e){return e===`/mrs`||e.startsWith(`/mrs/`)?`mrs`:e===`/pipelines`||e.startsWith(`/pipelines/`)?`pipelines`:`issues`}var G=[`open`,`merged`,`closed`];function lo(){let{pathname:e}=Ei(),{issues:t,issuesLoading:n,issuesLoaded:r,issuesError:i,openMRs:a,openMRsLoading:o,openMRsLoaded:s,openMRsError:c,selectedRepo:l,availableRepos:u,remoteActiveIids:d}=V(),[f,p]=(0,x.useState)(!1),[m,h]=(0,x.useState)(0),g=qr(),_=(0,x.useMemo)(()=>{let e=l||`default`,n={};for(let r of t){let t=Xr(g,e,r.iid);t.length?n[r.iid]=t:d.has(r.iid)&&!n[r.iid]?.length&&(n[r.iid]=[`analyze`])}return n},[g,t,l,d]),v=(0,x.useMemo)(()=>{let e={};for(let t of a){if(!t.pipeline)continue;let n=co(t.source_branch);n!=null&&(e[n]={status:t.pipeline.status,web_url:t.pipeline.web_url})}return e},[a]),y=(0,x.useMemo)(()=>{let e={};for(let t of a){let n=co(t.source_branch);n!=null&&(e[n]={iid:t.iid,web_url:t.web_url})}return e},[a]),{handleSelectIssue:b,handleCreateIssue:S,handleSelectMR:C,loadIssues:w,loadOpenMRs:T}=H(),E=W(e),ee=Ma(l),D=(0,x.useMemo)(()=>Object.values(v).some(e=>oo.has(e.status)),[v]);(0,x.useEffect)(()=>{if(E!==`issues`||!D)return;let e=setInterval(()=>T(),so);return()=>clearInterval(e)},[E,D,T]);let[O,k]=(0,x.useState)(`open`);(0,x.useEffect)(()=>{E!==`mrs`&&O!==`open`&&(k(`open`),T(`open`))},[E]);let A=e=>{e!==O&&(k(e),T(e))},te=()=>{E===`issues`?w():T(E===`mrs`?O:`open`)},ne=u.find(e=>e.id===l)?.label??l,re=(0,L.jsxs)(z,{size:`sm`,onClick:te,children:[(0,L.jsx)(B,{name:`refresh`,size:14}),` Refresh`]});return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6`,children:[E===`issues`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(qi,{title:`Issues`,description:(0,L.jsxs)(`span`,{"aria-hidden":!ne||void 0,className:ne?void 0:`animate-pulse rounded bg-surface-hover text-transparent [box-decoration-break:clone]`,children:[`Open issues in `,ne||`repository`,`. Pick one to have Forge analyze and fix it.`]},ne?`ready`:`loading`),actions:(0,L.jsxs)(L.Fragment,{children:[re,(0,L.jsxs)(z,{size:`sm`,variant:`primary`,onClick:()=>p(!0),children:[(0,L.jsx)(B,{name:`plus`,size:14}),` New issue`]})]})}),(0,L.jsx)(ao,{issues:t,loading:!r||!s,refreshing:n&&r,error:i,onSelect:b,onCreate:S,availableLabels:ee,activeJobsByIid:_,pipelinesByIid:v,openMrByIid:y,creating:f,onCreatingChange:p})]}),E===`mrs`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(qi,{title:`Merge requests`,description:`Forge-authored and team merge requests, with their pipelines.`,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{role:`tablist`,"aria-label":`Merge request state`,className:`flex rounded-lg border border-line bg-surface p-0.5`,children:G.map(e=>(0,L.jsx)(`button`,{role:`tab`,"aria-selected":O===e,onClick:()=>A(e),className:`h-6 rounded-md px-3 text-xs capitalize transition-colors ${O===e?`bg-surface-raised text-fg shadow-sm ring-1 ring-line`:`text-fg-subtle hover:text-fg`}`,children:e},e))}),re]})}),(0,L.jsx)(Ca,{mrs:a,loading:!s&&!c,refreshing:o&&s,error:c,state:O,onSelect:C,onRefresh:()=>T(O)})]}),E===`pipelines`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(qi,{title:`Pipelines`,description:`CI history: main, merge requests and branches.`,actions:(0,L.jsxs)(z,{size:`sm`,onClick:()=>h(e=>e+1),children:[(0,L.jsx)(B,{name:`refresh`,size:14}),` Refresh`]})}),(0,L.jsx)(ka,{repo:l||void 0,reloadKey:m})]})]})}function uo(){let{issueEnvironments:e}=V();return e.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-[15px] font-semibold text-fg`,children:`Environments`}),(0,L.jsx)(`span`,{className:`text-[10px] text-fg-subtle`,children:`Ephemeral review apps`})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 bg-surface-raised/50 border border-line-strong rounded-lg px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`font-medium ${e.state===`available`?`text-emerald-400`:e.state===`stopping`?`text-amber-400`:e.state===`stopped`?`text-fg-subtle`:`text-fg-muted`}`,children:e.state}),(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`·`}),(0,L.jsx)(`span`,{className:`text-fg-muted font-mono truncate`,title:e.name,children:e.name})]}),(0,L.jsxs)(`span`,{className:`text-[11px] font-mono text-fg-subtle truncate`,title:e.branchName,children:[`⎇ `,e.branchName]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[e.external_url?(0,L.jsx)(`a`,{href:e.external_url,target:`_blank`,rel:`noreferrer`,className:`text-sm text-violet-400 hover:underline`,children:`Open preview ↗`}):(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle italic`,children:`no URL yet`}),e.web_url&&(0,L.jsx)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`text-xs text-fg-subtle hover:text-fg transition-colors`,title:`View environment in GitLab`,children:`details ↗`})]})]},e.id))})]})}function fo({label:e,trigger:t,items:n,triggerClassName:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useRef)(null),l=(0,x.useRef)([]);l.current.length=n.length,(0,x.useEffect)(()=>{if(!i)return;l.current[0]?.focus();let e=e=>{s.current?.contains(e.target)||a(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i]);let u=()=>{a(!1),c.current?.focus()};return(0,L.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,L.jsx)(`button`,{ref:c,type:`button`,"aria-label":e,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":i?o:void 0,onClick:()=>a(e=>!e),className:r,children:t}),i&&(0,L.jsx)(`div`,{id:o,role:`menu`,"aria-label":e,onKeyDown:e=>{let t=l.current.filter(e=>e!==null),n=t.indexOf(document.activeElement),r=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus()};e.key===`ArrowDown`?r(n+1):e.key===`ArrowUp`?r(n-1):e.key===`Home`?r(0):e.key===`End`?r(t.length-1):e.key===`Escape`?(e.preventDefault(),u()):e.key===`Tab`&&a(!1)},className:`absolute right-0 top-full mt-2 z-40 w-60 p-1.5 flex flex-col rounded-xl border border-line-strong bg-surface-raised shadow-2xl animate-[forge-fade_120ms_ease-out]`,children:n.map((e,t)=>(0,L.jsxs)(`div`,{className:`contents`,children:[e.separated&&(0,L.jsx)(`div`,{role:`separator`,className:`my-1.5 mx-1 h-px bg-line`}),(0,L.jsxs)(`button`,{ref:e=>{l.current[t]=e},type:`button`,role:`menuitem`,tabIndex:-1,onClick:()=>{a(!1),e.onSelect()},className:Gn(`flex items-center gap-2.5 min-h-11 md:min-h-9 px-2.5 rounded-lg text-[15px] md:text-sm text-left outline-none transition-colors`,`hover:bg-surface-hover focus-visible:bg-surface-hover`,e.tone===`danger`?`text-red-400`:`text-fg`),children:[e.icon,e.label]})]},e.id))})]})}function po(e,t){let n=(0,x.useRef)(t);n.current=t,(0,x.useEffect)(()=>{if(!e)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e=>{e.key===`Escape`&&n.current()};window.addEventListener(`keydown`,r);let i=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,r),document.body.style.overflow=i,t?.isConnected&&t.focus()}},[e])}function mo({open:e,onClose:t,title:n,description:r,icon:i,footer:a,children:o}){let s=(0,x.useId)(),c=(0,x.useId)();return po(e,t),e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end md:items-center justify-center bg-black/60 md:p-4 animate-[forge-fade_160ms_ease-out]`,onClick:t,children:(0,L.jsxs)(`section`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":s,"aria-describedby":r?c:void 0,onClick:e=>e.stopPropagation(),className:`w-full md:max-w-[480px] max-h-[92dvh] flex flex-col bg-surface-raised border-t md:border border-line-strong rounded-t-[20px] md:rounded-2xl shadow-2xl animate-[forge-sheet-up_320ms_cubic-bezier(0.32,0.72,0,1)] md:animate-none`,children:[(0,L.jsx)(`div`,{className:`md:hidden flex justify-center pt-2`,children:(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`w-9 h-[5px] rounded-full bg-line-strong`})}),(0,L.jsxs)(`header`,{className:`flex items-start gap-3.5 px-4 md:px-6 pt-3 md:pt-6`,children:[i&&(0,L.jsx)(`span`,{className:`hidden md:inline-flex shrink-0`,children:i}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,L.jsx)(`h2`,{id:s,className:`text-xl md:text-[17px] font-bold md:font-semibold text-fg`,children:n}),r&&(0,L.jsx)(`p`,{id:c,className:`text-sm md:text-[13px] text-fg-muted truncate`,children:r})]})]}),o&&(0,L.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-4 md:px-6 py-4 md:py-5 flex flex-col gap-4`,children:o}),(0,L.jsx)(`footer`,{className:Gn(`flex flex-col-reverse md:flex-row md:justify-end gap-2 px-4 md:px-6 pt-3 md:py-4 pb-[max(1.25rem,env(safe-area-inset-bottom))] md:border-t md:border-line`,!o&&`mt-4`),children:a})]})}):null}var ho={close:{title:`Close issue`,confirm:`Close issue`,pending:`Closing…`,issueRow:`The issue`,issueEffect:`closed, can be reopened`},delete:{title:`Delete issue`,confirm:`Delete issue`,pending:`Deleting…`,issueRow:`The issue and its comments`,issueEffect:`deleted`}};function go({action:e,onClose:t,onSwitch:n}){let{selectedIssue:r,selectedRepo:i}=V(),{handleCloseIssue:a,handleDeleteIssue:o}=H(),[s,c]=(0,x.useState)({status:`loading`}),[l,u]=(0,x.useState)(``),[d,f]=(0,x.useState)(!1),[p,m]=(0,x.useState)(null),h=r?.iid,g=e!==null&&h!==void 0;if((0,x.useEffect)(()=>{if(!g)return;let e=!1;return c({status:`loading`}),R(`/issues/${h}/footprint?repo=${encodeURIComponent(i)}`).then(t=>!e&&c({status:`ready`,footprint:t})).catch(()=>!e&&c({status:`unknown`})),()=>{e=!0}},[g,h,i]),(0,x.useEffect)(()=>{u(``),m(null),f(!1)},[e,h]),!g||!r||!e)return null;let _=ho[e],v=e===`delete`,y=s.status===`ready`?s.footprint.openMr:null,b=l.trim()===String(r.iid),S=s.status!==`loading`&&!y&&(!v||b)&&!d,C=async()=>{f(!0),m(null);try{await(v?o():a()),t()}catch(e){m(e.message),f(!1)}},w=e=>s.status===`ready`?String(e(s.footprint)):s.status===`unknown`?`—`:null;return(0,L.jsxs)(mo,{open:!0,onClose:d?()=>{}:t,title:`${_.title} #${r.iid}?`,description:r.title,icon:(0,L.jsx)(`span`,{"aria-hidden":`true`,className:Gn(`inline-flex items-center justify-center size-10 rounded-[10px]`,v?`bg-red-950 text-red-400`:`bg-surface-hover text-fg-muted`),children:(0,L.jsx)(B,{name:v?`trash`:`archive`,size:18})}),footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z,{variant:`secondary`,onClick:t,disabled:d,className:`h-12 md:h-10 px-4 text-[15px] md:text-sm`,children:`Cancel`}),(0,L.jsx)(z,{variant:v?`danger`:`primary`,onClick:C,disabled:!S,className:`h-12 md:h-10 px-4 text-[15px] md:text-sm font-semibold`,children:(0,L.jsxs)(`span`,{className:`grid`,children:[(0,L.jsx)(`span`,{className:Gn(`[grid-area:1/1]`,d&&`invisible`),children:_.confirm}),(0,L.jsx)(`span`,{"aria-hidden":!d,className:Gn(`[grid-area:1/1]`,!d&&`invisible`),children:_.pending})]})})]}),children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`span`,{className:`text-sm md:text-[13px] text-fg`,children:v?`This permanently removes:`:`This will:`}),(0,L.jsxs)(`ul`,{className:`rounded-xl md:rounded-[10px] border border-line bg-surface`,children:[(0,L.jsx)(_o,{label:_.issueRow,value:_.issueEffect}),(0,L.jsx)(_o,{label:`Forge branches`,value:w(e=>e.branches),effect:`deleted`}),(0,L.jsx)(_o,{label:`Review environments`,value:w(e=>e.environments),effect:`stopped`})]})]}),(0,L.jsx)(`div`,{className:`min-h-[76px] flex flex-col justify-center`,children:y?(0,L.jsxs)(`p`,{role:`alert`,className:`rounded-[10px] border border-amber-800/60 bg-amber-950/40 px-3.5 py-3 text-sm md:text-[13px] text-amber-200`,children:[`MR`,` `,(0,L.jsxs)(`a`,{href:y.web_url,target:`_blank`,rel:`noreferrer`,className:`font-mono underline`,children:[`!`,y.iid]}),` `,`is still open. Merge or close it first.`]}):v?(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`span`,{className:`text-sm md:text-[13px] text-fg`,children:[`Type `,(0,L.jsx)(`strong`,{className:`font-mono`,children:r.iid}),` to confirm`]}),(0,L.jsx)(`input`,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S&&C()},inputMode:`numeric`,autoComplete:`off`,"aria-label":`Type ${r.iid} to confirm`,className:Gn(`h-12 md:h-10 px-3 rounded-xl md:rounded-lg border bg-canvas font-mono text-fg outline-none`,b?`border-red-500`:`border-line-strong focus:border-accent`)})]}):(0,L.jsx)(`p`,{className:`text-sm md:text-[13px] text-fg-muted`,children:`You can reopen it later.`})}),v&&(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl md:rounded-[10px] bg-surface-hover px-3.5 py-3`,children:[(0,L.jsx)(`span`,{className:`flex-1 text-sm md:text-[13px] text-fg`,children:`Just want it off the list? Closing is reversible.`}),(0,L.jsx)(z,{variant:`secondary`,size:`sm`,onClick:()=>n(`close`),disabled:d||!!y,className:`h-9`,children:`Close instead`})]}),p&&(0,L.jsx)(`p`,{role:`alert`,className:`rounded-[10px] border border-red-800 bg-red-950/40 px-3.5 py-3 text-sm md:text-[13px] text-red-300`,children:p})]})}function _o({label:e,value:t,effect:n}){return(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-3 min-h-11 md:min-h-10 px-3.5 text-sm md:text-[13px] border-t border-line first:border-t-0`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:e}),(0,L.jsx)(`span`,{className:`text-fg-muted tabular-nums`,children:t===null?(0,L.jsx)(`span`,{"aria-label":`Loading`,className:`inline-block align-middle h-3 w-16 rounded bg-surface-hover animate-pulse`}):n?`${t} ${n}`:t})]})}function vo({onEdit:e}){let{selectedIssue:t}=V(),{can:n}=Ui(),[r,i]=(0,x.useState)(null);if(!t)return null;let a=[...e?[{id:`edit`,label:`Edit title & labels`,icon:(0,L.jsx)(B,{name:`pencil`}),onSelect:e}]:[],{id:`open`,label:`Open in GitLab`,icon:(0,L.jsx)(B,{name:`external`}),onSelect:()=>window.open(t.web_url,`_blank`,`noopener,noreferrer`)},...n(`approver`)?[{id:`delete`,label:`Delete issue…`,icon:(0,L.jsx)(B,{name:`trash`}),tone:`danger`,separated:!0,onSelect:()=>i(`delete`)}]:[]];return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(`operator`)&&(0,L.jsx)(z,{variant:`secondary`,onClick:()=>i(`close`),className:`h-11 md:h-10 px-3.5`,children:`Close issue`}),(0,L.jsx)(fo,{label:`More actions`,trigger:(0,L.jsx)(B,{name:`more`,size:18}),items:a,triggerClassName:`inline-flex items-center justify-center size-11 md:size-10 rounded-lg border border-line-strong text-fg hover:bg-surface-hover aria-expanded:bg-surface-hover transition-colors`}),(0,L.jsx)(go,{action:r,onClose:()=>i(null),onSwitch:i})]})}var yo={success:`bg-green-400`,failed:`bg-red-400`,running:`bg-yellow-400 animate-pulse`,pending:`bg-yellow-600`,canceled:`bg-fg-subtle`,skipped:`bg-fg-subtle`,created:`bg-fg-subtle`},bo={success:`passed`,failed:`failed`,running:`running`,pending:`pending`,canceled:`canceled`,skipped:`skipped`,created:`created`},xo={success:`text-green-400`,failed:`text-red-400`,running:`text-yellow-400`,pending:`text-yellow-500`,canceled:`text-fg-subtle`,skipped:`text-fg-subtle`,created:`text-fg-subtle`};function So({mrs:e}){return e.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-[15px] font-semibold text-fg`,children:`Merged changes`}),(0,L.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>{let t=e.pipeline?.status,n=t?yo[t]??`bg-fg-subtle`:`bg-fg-subtle`,r=t?bo[t]??t:`no pipeline`,i=t?xo[t]??`text-fg-subtle`:`text-fg-subtle`;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-raised border border-line rounded px-3 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,L.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${n}`,title:`post-merge pipeline: ${r}`}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,L.jsxs)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`text-sm text-fg hover:text-fg transition-colors truncate`,children:[`!`,e.iid,` `,e.title]}),(0,L.jsx)(`span`,{className:`text-xs font-mono text-fg-subtle truncate`,children:e.branchName})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 ml-3`,children:[e.pipeline?(0,L.jsx)(`a`,{href:e.pipeline.web_url,target:`_blank`,rel:`noreferrer`,className:`text-xs hover:underline ${i}`,title:`View post-merge pipeline in GitLab`,children:r}):(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle italic`,children:`no pipeline`}),(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:new Date(e.merged_at).toLocaleDateString()})]})]},e.iid)})})]})}function Co(){let{selectedIssue:e,analysisPrompt:t,refining:n,mergedMrs:r}=V(),{setAnalysisPrompt:i,handleBeginAnalysis:a}=H();return e?(0,L.jsxs)(`div`,{className:`flex flex-col gap-6 w-full`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,L.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.iid]}),e.labels.map(e=>(0,L.jsx)(`span`,{className:`bg-surface-raised text-fg-muted ring-1 ring-inset ring-line px-1.5 py-0.5 rounded`,children:e},e))]}),(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:e.title}),(0,L.jsx)(vo,{})]}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[`by `,e.author.name,` ·`,` `,(0,L.jsx)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`hover:text-fg transition-colors`,children:`view on GitLab ↗`})]})]}),e.description&&(0,L.jsx)(`div`,{className:`bg-surface-raised border border-line-strong rounded-lg px-4 py-4 text-sm text-fg whitespace-pre-wrap leading-relaxed w-full max-h-[50vh] overflow-y-auto`,children:e.description}),(0,L.jsx)(uo,{}),!n&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`textarea`,{value:t,onChange:e=>i(e.target.value),placeholder:`Optional instructions for the analysis…`,rows:2,className:`w-full bg-surface-raised/60 border border-line-strong rounded-lg px-3 py-2 text-sm text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 resize-none`}),(0,L.jsx)(`div`,{className:`flex items-center justify-between gap-6 border-t border-line/60 pt-3`,children:(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsx)(`button`,{onClick:a,className:`bg-surface-raised ring-1 ring-inset ring-line-strong hover:bg-surface-hover text-fg text-sm font-medium px-4 py-2 rounded-lg transition-colors`,children:`Analyze & Update MR`})})})]}),(0,L.jsx)(So,{mrs:r})]}):null}var wo=(0,x.createContext)(null);function To({children:e,placeholder:t=null,className:n}){let[r,i]=(0,x.useState)({}),[a,o]=(0,x.useState)(!1),[s,c]=(0,x.useState)(!1),l=(0,x.useCallback)((e,t)=>{i(n=>n[e]===!t?n:{...n,[e]:!t})},[]);(0,x.useEffect)(()=>o(!0),[]);let u=a&&Object.values(r).every(e=>!e);return(0,x.useEffect)(()=>{u&&c(!0)},[u]),(0,L.jsxs)(wo.Provider,{value:l,children:[!s&&t,(0,L.jsx)(`div`,{hidden:!s,className:s?n:void 0,children:e})]})}function Eo(e){let t=(0,x.useContext)(wo),n=(0,x.useId)();(0,x.useEffect)(()=>{t?.(n,e)},[t,n,e]),(0,x.useEffect)(()=>()=>t?.(n,!0),[t,n])}function Do({ready:e}){return Eo(e),null}async function Oo(e,t){let n=await e.text().catch(()=>``);try{let e=JSON.parse(n);if(e.error)return e.error}catch{}return n||t}function ko({state:e,label:t,detail:n}){return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`w-4 text-center font-mono ${e===`ok`?`text-emerald-400`:e===`fail`?`text-red-400`:e===`pending`?`text-yellow-400`:`text-fg-subtle`}`,children:e===`ok`?`✓`:e===`fail`?`✗`:e===`pending`?`○`:`–`}),(0,L.jsx)(`span`,{className:`text-fg`,children:t}),n&&(0,L.jsxs)(`span`,{className:`text-fg-subtle`,children:[`— `,n]})]})}function Ao(e){let t=[],n=null;for(let r of e.split(`
18
18
  `))r.startsWith(`@@`)?(n={header:r,lines:[]},t.push(n)):n&&(r.startsWith(`+`)?n.lines.push({type:`add`,content:r.slice(1)}):r.startsWith(`-`)?n.lines.push({type:`remove`,content:r.slice(1)}):r.startsWith(`\\`)||n.lines.push({type:`context`,content:r.slice(1)}));return t}function jo({d:e}){let[t,n]=(0,x.useState)(!0),r=Ao(e.diff),i=e.new_file?`A`:e.deleted_file?`D`:e.renamed_file?`R`:`M`;return(0,L.jsxs)(`div`,{className:`border border-line-strong rounded-lg overflow-hidden`,children:[(0,L.jsxs)(`button`,{onClick:()=>n(e=>!e),className:`w-full flex items-center gap-2 bg-surface-raised px-3 py-2 text-left hover:bg-surface-hover transition-colors`,children:[(0,L.jsx)(`span`,{className:`text-xs font-mono font-bold ${i===`A`?`text-green-400`:i===`D`?`text-red-400`:i===`R`?`text-blue-400`:`text-fg-muted`}`,children:i}),(0,L.jsx)(`span`,{className:`text-xs font-mono text-fg flex-1 truncate`,children:e.new_path!==e.old_path&&e.old_path!==`/dev/null`?`${e.old_path} → ${e.new_path}`:e.new_path}),(0,L.jsx)(`span`,{className:`text-fg-subtle text-xs`,children:t?`▲`:`▼`})]}),t&&(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:r.length===0?(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle px-3 py-2`,children:`Binary or empty diff`}):r.map((e,t)=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`bg-surface-raised px-3 py-0.5 text-xs font-mono text-fg-subtle`,children:e.header}),e.lines.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex font-mono text-xs leading-5 ${e.type===`add`?`bg-green-950/40 text-green-300`:e.type===`remove`?`bg-red-950/40 text-red-300`:`text-fg-muted`}`,children:[(0,L.jsx)(`span`,{className:`select-none w-4 shrink-0 text-center ${e.type===`add`?`text-green-500`:e.type===`remove`?`text-red-500`:`text-fg-subtle`}`,children:e.type===`add`?`+`:e.type===`remove`?`−`:` `}),(0,L.jsx)(`span`,{className:`pl-2 whitespace-pre`,children:e.content})]},t))]},t))})]})}function Mo({mrIid:e,repo:t,pipelineStatus:n,onMerged:r}){let[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!0),[c,l]=(0,x.useState)(null),[u,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(!1),[g,_]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),{can:b}=Ui(),[S,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1),[E,ee]=(0,x.useState)(!1),[D,O]=(0,x.useState)(null),[k,A]=(0,x.useState)(!1),[te,ne]=(0,x.useState)(null),[re,ie]=(0,x.useState)(!1),j=(0,x.useRef)(null),M=(0,x.useRef)(!1),ae=(0,x.useRef)(!1);Eo(!o);let oe=t?`?repo=${encodeURIComponent(t)}`:``,se=(0,x.useCallback)(async()=>{try{let t=await window.fetch(`/api/forge/mr/${e}/detail${oe}`,{headers:Vn});if(!t.ok)throw t.status===404?(M.current=!0,j.current&&=(clearInterval(j.current),null),Error(`MR not found — it may have been deleted or belongs to a different project`)):Error(`MR API ${t.status}`);let n=await t.json();if(M.current)return;if(a(n),l(null),s(!1),n.state===`merged`&&!ae.current){ae.current=!0,j.current&&clearInterval(j.current),j.current=null,r?.();return}!n.rebase_in_progress&&j.current&&(clearInterval(j.current),j.current=null)}catch(e){if(M.current)return;l(e.message),s(!1)}},[e,oe]);(0,x.useEffect)(()=>(M.current=!1,se(),()=>{M.current=!0,j.current&&clearInterval(j.current)}),[se]);let ce=async()=>{d(!0),p(null);try{let t=await window.fetch(`/api/forge/mr/${e}/rebase${oe}`,{method:`POST`,headers:Vn});if(!t.ok)throw Error(await Oo(t,`Rebase API ${t.status}`));a(e=>e&&{...e,rebase_in_progress:!0}),j.current&&clearInterval(j.current),j.current=setInterval(se,3e3)}catch(e){p(e.message)}finally{d(!1)}},le=async()=>{h(!0),_(null);let t=i?.merge_when_pipeline_succeeds;try{let n=t?`/api/forge/mr/${e}/cancel-auto-merge${oe}`:`/api/forge/mr/${e}/auto-merge${oe}`,r=await window.fetch(n,{method:`POST`,headers:Vn});if(!r.ok)throw Error(await Oo(r,`Auto-merge API ${r.status}`));a(e=>e&&{...e,merge_when_pipeline_succeeds:!t})}catch(e){_(e.message)}finally{h(!1)}},N=async(t,n,r)=>{y(t),C(null);try{let t=await window.fetch(`/api/forge/mr/${e}/${n}${oe}`,{method:`POST`,headers:{...Vn,...r?{"Content-Type":`application/json`}:{}},body:r?JSON.stringify(r):void 0});if(!t.ok)throw Error(await Oo(t,`${n} API ${t.status}`));await se()}catch(e){C(e.message)}finally{y(null)}},ue=async()=>{A(!0),ne(null);try{let t=await window.fetch(`/api/forge/mr/${e}/diffs${oe}`,{headers:Vn});if(!t.ok)throw Error(`Diffs API ${t.status}`);O((await t.json()).diffs??[])}catch(e){ne(e.message)}finally{A(!1)}},de=()=>{!re&&D===null&&ue(),ie(e=>!e)};if(o)return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-subtle py-1`,children:[(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-fg-subtle border-t-transparent animate-spin inline-block shrink-0`}),`Loading MR status…`]});if(c||!i)return(0,L.jsxs)(`div`,{className:`text-sm text-fg-subtle py-1`,children:[`Could not load MR status`,c?` — ${c}`:``,`.`]});let fe=i.has_conflicts||i.detailed_merge_status===`need_rebase`||i.merge_status===`cannot_be_merged`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[i.rebase_in_progress&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 bg-surface-raised border border-line-strong rounded-lg px-4 py-3`,children:[(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-yellow-400 border-t-transparent animate-spin inline-block shrink-0`}),(0,L.jsx)(`span`,{className:`text-sm text-yellow-300`,children:`Rebase in progress…`})]}),!i.rebase_in_progress&&fe&&(0,L.jsxs)(`div`,{className:`bg-amber-950/40 border border-amber-700 rounded-lg px-4 py-3 flex items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-amber-300`,children:i.has_conflicts?`Merge conflicts detected`:`Rebase required`}),(0,L.jsx)(`p`,{className:`text-xs text-amber-400/70 mt-0.5`,children:i.has_conflicts?`This branch has conflicts with the target branch.`:`The target branch has moved ahead of this MR branch.`}),f&&(0,L.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:f})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[b(`operator`)&&(0,L.jsx)(`button`,{onClick:ce,disabled:u,className:`bg-amber-600 hover:bg-amber-500 disabled:opacity-50 text-on-accent text-xs font-medium px-3 py-1.5 rounded-lg transition-colors`,children:u?`Rebasing…`:`Rebase`}),i.has_conflicts&&(0,L.jsx)(`a`,{href:`${i.web_url}/conflicts`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-amber-400 hover:text-amber-200 transition-colors`,children:`Resolve in GitLab ↗`})]})]}),i.state===`opened`&&!i.rebase_in_progress&&(()=>{let e=n===`failed`||n===`canceled`,t=n===`success`?`ok`:e?`fail`:n===`running`||n===`pending`||n===`created`?`pending`:`neutral`,r=i.draft?`Marked as draft`:i.has_conflicts?`Has merge conflicts`:fe?`Needs rebase`:e?`CI pipeline failed`:null,a=!r;return(0,L.jsxs)(`div`,{className:`bg-surface-raised/50 border border-line-strong rounded-lg overflow-hidden`,children:[(0,L.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-line-strong flex items-center justify-between`,children:[(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:i.draft?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium bg-surface-raised text-fg-muted ring-1 ring-inset ring-line px-2 py-0.5 rounded`,children:[(0,L.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-fg-muted`}),`Draft`]}):(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium bg-emerald-900/40 text-emerald-300 px-2 py-0.5 rounded`,children:[(0,L.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-400`}),`Open`]})}),b(`approver`)&&(0,L.jsx)(`button`,{onClick:le,disabled:m||!a,className:i.merge_when_pipeline_succeeds?`text-xs text-fg-subtle hover:text-fg disabled:opacity-40 transition-colors`:`text-xs text-violet-400 hover:text-violet-200 disabled:opacity-40 transition-colors`,title:i.merge_when_pipeline_succeeds?`Cancel the pending auto-merge`:`Queue this MR to merge automatically when the pipeline passes`,children:m?`…`:i.merge_when_pipeline_succeeds?`Cancel auto-merge`:`Set auto-merge`})]}),(0,L.jsxs)(`div`,{className:`px-4 py-3 border-b border-line-strong flex flex-col gap-1`,children:[(0,L.jsx)(ko,{state:t,label:`CI pipeline`,detail:n??`no pipeline`}),(0,L.jsx)(ko,{state:i.has_conflicts?`fail`:`ok`,label:i.has_conflicts?`Merge conflicts`:`No merge conflicts`}),(0,L.jsx)(ko,{state:fe?`fail`:`ok`,label:fe?`Rebase required`:`Branch up to date`}),i.draft&&(0,L.jsx)(ko,{state:`fail`,label:`Marked as draft`,detail:`mark ready to enable merge`}),i.merge_when_pipeline_succeeds&&(0,L.jsx)(ko,{state:`pending`,label:`Auto-merge queued`,detail:`will merge when pipeline passes`}),g&&(0,L.jsx)(`p`,{className:`text-xs text-red-400 pt-1`,children:g})]}),(0,L.jsxs)(`div`,{className:`px-4 py-3 bg-surface-raised/40 flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[b(`operator`)&&(0,L.jsx)(`button`,{onClick:()=>N(`draft`,`draft`,{draft:!i.draft}),disabled:v!==null,className:`text-fg-subtle hover:text-fg disabled:opacity-50 transition-colors`,title:i.draft?`Mark this MR as ready for review`:`Mark this MR as a draft`,children:v===`draft`?`…`:i.draft?`Mark ready`:`Mark as draft`}),b(`operator`)&&b(`approver`)&&(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`•`}),b(`approver`)&&(E?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-red-300`,children:`Close MR?`}),(0,L.jsx)(`button`,{onClick:()=>{ee(!1),N(`close`,`close`)},disabled:v!==null,className:`font-medium text-red-300 hover:text-red-200 disabled:opacity-50 transition-colors`,children:v===`close`?`Closing…`:`Confirm`}),(0,L.jsx)(`button`,{onClick:()=>ee(!1),className:`text-fg-subtle hover:text-fg transition-colors`,children:`Cancel`})]}):(0,L.jsx)(`button`,{onClick:()=>{C(null),T(!1),ee(!0)},disabled:v!==null,className:`text-fg-subtle hover:text-red-300 disabled:opacity-50 transition-colors`,children:`Close MR`}))]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:a?b(`approver`)?w?(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(`button`,{onClick:()=>T(!1),className:`text-xs text-fg-muted hover:text-fg transition-colors`,children:`Cancel`}),(0,L.jsx)(`button`,{onClick:()=>{T(!1),N(`merge`,`merge`)},disabled:v!==null,className:`text-sm font-medium text-on-accent bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 rounded-lg px-4 py-1.5 transition-colors`,children:v===`merge`?`Merging…`:`Confirm merge`})]}):(0,L.jsx)(`button`,{onClick:()=>{C(null),ee(!1),T(!0)},disabled:v!==null,className:`text-sm font-medium text-on-accent bg-emerald-600 hover:bg-emerald-500 disabled:opacity-50 rounded-lg px-4 py-1.5 transition-colors`,children:`Merge now`}):(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Ready to merge — an approver merges it`}):(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[`Can't merge — `,r]})})]})]})})(),i.state!==`opened`&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium px-2 py-0.5 rounded ${i.state===`merged`?`bg-violet-900/40 text-violet-300`:`bg-red-900/30 text-red-300`}`,children:[(0,L.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${i.state===`merged`?`bg-violet-400`:`bg-red-400`}`}),i.state===`merged`?`Merged`:`Closed`]}),i.state===`closed`&&b(`approver`)&&(0,L.jsx)(`button`,{onClick:()=>N(`reopen`,`reopen`),disabled:v!==null,className:`text-xs text-violet-400 hover:text-violet-200 disabled:opacity-50 transition-colors`,children:v===`reopen`?`Reopening…`:`Reopen`})]}),S&&(0,L.jsx)(`p`,{className:`text-xs text-red-400`,children:S}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{onClick:de,className:`text-xs text-fg-subtle hover:text-fg transition-colors flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`transition-transform ${re?`rotate-90`:``} inline-block`,children:`›`}),re?`Hide diff`:`Show current diff`,D!==null&&` (${D.length} file${D.length===1?``:`s`})`]}),re&&(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[k&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-fg-subtle border-t-transparent animate-spin inline-block shrink-0`}),`Loading diff…`]}),te&&(0,L.jsx)(`p`,{className:`text-xs text-red-400`,children:te}),D&&D.length===0&&(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:`No changes in this MR.`}),D&&D.map((e,t)=>(0,L.jsx)(jo,{d:e},t))]})]})]})}var No={success:`text-green-400`,failed:`text-red-400`,running:`text-yellow-400`,pending:`text-yellow-400`,canceled:`text-fg-subtle`,skipped:`text-fg-subtle`,created:`text-fg-muted`,waiting_for_resource:`text-fg-muted`,preparing:`text-fg-muted`,scheduled:`text-fg-muted`,manual:`text-blue-400`},Po={success:`✓`,failed:`✗`,running:`◎`,pending:`○`,canceled:`⊘`,skipped:`→`,created:`○`,manual:`⊡`},Fo=new Set([`success`,`failed`,`canceled`]);function Io(e){return No[e]??`text-fg-muted`}function Lo(e){return Po[e]??`○`}function Ro(e){let t=new Map;return e.forEach(e=>{t.has(e.stage)||t.set(e.stage,[]),t.get(e.stage).push(e)}),t}function zo({endpoint:e,repo:t,refreshKey:n,onRefinePipelineFailure:r,onStatusChange:i,ciFixAttempts:a,ciFixMaxAttempts:o,ciFixLoopWarning:s,onDismissCiFixWarning:c}){let[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)([]),[p,m]=(0,x.useState)(!0),[h,g]=(0,x.useState)(null),[_,v]=(0,x.useState)(``),[y,b]=(0,x.useState)({}),[S,C]=(0,x.useState)({}),[w,T]=(0,x.useState)(0);Eo(!p&&w===0);let E=(0,x.useRef)(!1),ee=(0,x.useRef)(null),D=(0,x.useRef)(!1),O=(0,x.useRef)(null),k=(0,x.useRef)(i);(0,x.useEffect)(()=>{k.current=i},[i]);let A=async()=>{let n=new AbortController,r=setTimeout(()=>n.abort(),12e3);try{let i=e.includes(`?`)?`&`:`?`,a=t?`${i}repo=${encodeURIComponent(t)}`:``,o=await window.fetch(`/api/forge/${e}${a}`,{headers:Vn,signal:n.signal});if(clearTimeout(r),!o.ok)throw Error(`Pipeline API ${o.status}`);let s=await o.json();if(E.current)return;u(s.pipeline??null),f(s.jobs??[]),g(null),m(!1);let c=s.pipeline?.status??null;if(c!==O.current&&(O.current=c,k.current?.(c)),s.pipeline&&Fo.has(s.pipeline.status)&&(E.current=!0,ee.current&&clearInterval(ee.current),s.pipeline.status===`failed`&&!D.current)){D.current=!0;let e=(s.jobs??[]).filter(e=>e.status===`failed`);T(e.length),e.forEach(e=>{window.fetch(`/api/forge/jobs/${e.id}/trace`,{headers:Vn}).then(e=>e.json()).then(t=>b(n=>({...n,[e.id]:t.trace??`(empty)`}))).catch(()=>b(t=>({...t,[e.id]:`(failed to load trace)`}))).finally(()=>T(e=>Math.max(0,e-1)))})}}catch(e){if(clearTimeout(r),E.current)return;g(e.name===`AbortError`?`Request timed out`:e.message),m(!1)}};(0,x.useEffect)(()=>(E.current=!1,D.current=!1,O.current=null,u(null),f([]),m(!0),g(null),b({}),T(0),A(),ee.current=setInterval(A,1e4),()=>{E.current=!0,ee.current&&clearInterval(ee.current)}),[e,n]);let te=async e=>{if(y[e]!==void 0){b(t=>{let n={...t};return delete n[e],n});return}C(t=>({...t,[e]:!0}));try{let t=await(await window.fetch(`/api/forge/jobs/${e}/trace`,{headers:Vn})).json();b(n=>({...n,[e]:t.trace??`(empty)`}))}catch{b(t=>({...t,[e]:`(failed to load trace)`}))}finally{C(t=>({...t,[e]:!1}))}},ne=d.filter(e=>e.status===`failed`);if(p)return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-fg-subtle border-t-transparent animate-spin inline-block shrink-0`}),`Waiting for pipeline...`]});if(h)return(0,L.jsxs)(`div`,{className:`flex items-center justify-between py-3 px-4 bg-surface-raised border border-line-strong rounded-lg`,children:[(0,L.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load pipeline — `,h]}),(0,L.jsx)(`button`,{onClick:()=>{m(!0),g(null),A()},className:`text-xs text-fg-muted hover:text-fg transition-colors ml-4 shrink-0`,children:`Retry`})]});if(!l)return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-line-strong border-t-transparent animate-spin inline-block shrink-0`}),`Waiting for pipeline to start...`]});let re=Ro(d),ie=l.status===`failed`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-sm ${Io(l.status)}`,children:l.status===`running`?(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-yellow-400 border-t-transparent animate-spin inline-block`}):Lo(l.status)}),(0,L.jsx)(`span`,{className:`text-sm font-medium capitalize ${Io(l.status)}`,children:l.status}),(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[`#`,l.id]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{onClick:()=>{m(!0),A()},className:`text-xs text-fg-subtle hover:text-fg-muted transition-colors`,children:`↻`}),(0,L.jsx)(`a`,{href:l.web_url,target:`_blank`,rel:`noreferrer`,className:`text-xs text-fg-muted hover:text-fg transition-colors`,children:`View in GitLab →`})]})]}),ie&&r&&ne.length>0&&(0,L.jsxs)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-red-300`,children:`Pipeline failed`}),(0,L.jsxs)(`p`,{className:`text-xs text-red-400/70 mt-0.5`,children:[ne.length,` job`,ne.length===1?``:`s`,` `,`failed: `,ne.map(e=>e.name).join(`, `)]})]}),a!=null&&a>0&&(0,L.jsxs)(`span`,{className:`text-xs font-mono shrink-0 ${o&&a>=o?`text-amber-400`:`text-fg-subtle`}`,children:[`attempt `,a,`/`,o??3]})]}),s?(0,L.jsxs)(`div`,{className:`bg-amber-950/40 border border-amber-800/50 rounded-lg px-3 py-2 flex flex-col gap-2`,children:[(0,L.jsx)(`p`,{className:`text-xs text-amber-300 font-medium`,children:`CI fix loop detected`}),(0,L.jsx)(`p`,{className:`text-xs text-amber-400/80 whitespace-pre-wrap`,children:s}),(0,L.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,L.jsx)(`button`,{onClick:c,className:`text-xs text-amber-400 hover:text-amber-300 underline transition-colors`,children:`Dismiss and retry`})})]}):(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),r(ne.map(e=>e.id),_,t))},placeholder:`Add context or instructions for the AI fix (optional)`,className:`flex-1 bg-surface-raised border border-red-800/50 rounded-lg px-3 py-1.5 text-xs text-fg placeholder-fg-subtle focus:outline-none focus:border-red-600`}),(0,L.jsx)(`button`,{onClick:()=>r(ne.map(e=>e.id),_,t),className:`shrink-0 bg-violet-600 hover:bg-violet-500 text-on-accent text-xs font-medium px-4 py-2 rounded-lg transition-colors`,children:`Fix with AI`})]})]}),Array.from(re.entries()).map(([e,t])=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle mb-2`,children:e}),(0,L.jsx)(`div`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 bg-surface-raised rounded px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-sm w-4 ${Io(e.status)}`,children:e.status===`running`?(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-yellow-400 border-t-transparent animate-spin inline-block`}):Lo(e.status)}),(0,L.jsx)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`text-sm text-fg hover:text-fg transition-colors flex-1`,children:e.name}),e.duration!=null&&(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[Math.round(e.duration),`s`]}),Fo.has(e.status)&&(0,L.jsx)(`button`,{onClick:()=>te(e.id),className:`text-xs text-fg-subtle hover:text-fg transition-colors shrink-0`,children:S[e.id]?(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-fg-subtle border-t-transparent animate-spin inline-block`}):y[e.id]===void 0?`View logs`:`Hide logs`})]}),y[e.id]!==void 0&&(0,L.jsx)(`div`,{className:`border border-line border-t-0 rounded-b overflow-hidden`,children:(0,L.jsx)(ma,{variant:`embedded`,autoScroll:!1,heightClass:`max-h-64`,entries:ha(y[e.id].split(`
19
19
  `).slice(-200).join(`
@@ -24,4 +24,4 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
24
24
  `).map(e=>({type:`remove`,text:e})):[],i=e.action===`create`?`text-green-400`:e.action===`delete`?`text-red-400`:`text-yellow-400`,a=r.filter(e=>e.type===`add`).length,o=r.filter(e=>e.type===`remove`).length;return(0,L.jsxs)(`div`,{className:`border border-line-strong rounded-lg overflow-hidden`,children:[(0,L.jsxs)(`button`,{onClick:()=>n(e=>!e),className:`w-full flex items-center gap-3 px-4 py-2.5 bg-surface-raised hover:bg-surface-hover text-left`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium ${i}`,children:e.action}),(0,L.jsx)(`span`,{className:`text-sm text-fg font-mono flex-1 truncate`,children:e.file}),(0,L.jsxs)(`span`,{className:`text-xs text-green-400`,children:[`+`,a]}),(0,L.jsxs)(`span`,{className:`text-xs text-red-400 ml-1`,children:[`-`,o]}),(0,L.jsx)(`span`,{className:`text-fg-subtle text-xs ml-2`,children:t?`▲`:`▼`})]}),(0,L.jsx)(`div`,{className:`px-4 py-1.5 bg-surface-raised border-t border-line-strong text-xs text-fg-muted`,children:e.summary}),t&&(0,L.jsx)(`div`,{className:`overflow-x-auto`,children:(0,L.jsx)(`table`,{className:`w-full text-xs font-mono border-collapse`,children:(0,L.jsx)(`tbody`,{children:r.map((e,t)=>(0,L.jsxs)(`tr`,{className:e.type===`add`?`bg-green-950/40`:e.type===`remove`?`bg-red-950/40`:``,children:[(0,L.jsx)(`td`,{className:`w-6 px-2 py-px text-fg-subtle select-none border-r border-line text-right`,children:e.type===`add`?`+`:e.type===`remove`?`-`:` `}),(0,L.jsx)(`td`,{className:`px-3 py-px whitespace-pre ${e.type===`add`?`text-green-300`:e.type===`remove`?`text-red-300`:e.text===`...`?`text-fg-subtle`:`text-fg`}`,children:e.text})]},t))})})})]})}function $o(e,t){return t?.find(t=>t.id===e)?.label??e.split(`/`).pop()??e}function es(e,t,n){let r=new Map;for(let t of e){let e=t.repo||`(unknown)`,n=r.get(e)??[];n.push(t),r.set(e,n)}return Array.from(r.entries()).map(([e,r])=>{let i=0,a=0;for(let e of r)if(e.action===`create`&&e.proposed)i+=e.proposed.split(`
25
25
  `).length;else if(e.action===`delete`&&e.original)a+=e.original.split(`
26
26
  `).length;else if(e.action===`modify`&&e.original){let t=Xo(e.original,e.proposed);for(let e of t)e.type===`add`?i++:e.type===`remove`&&a++}let o=n?.find(t=>t.repo===e);return{repo:e,label:$o(e,t),changes:r,adds:i,removes:a,existingBranch:o?.branchName}})}function ts({explanation:e,changes:t,removals:n=[],existingApplications:r,availableRepos:i,onApprove:a,onDeployBranch:o,onCommitToBranch:s,checks:c,onRefine:l,onUndoRefine:u,refineThread:d=[],refineQueue:f=[],thinkingLogs:p=[],applying:m,refining:h,validationStatus:g=`idle`}){let[_,v]=(0,x.useState)(``),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(new Set),w=(0,x.useMemo)(()=>es(t,i,r),[t,i,r]),T=m||h,E=w.length>1,ee=w.every(e=>e.existingBranch),D=w.some(e=>e.existingBranch),O=g!==`passed`&&!y,k=T||O;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:`Proposed changes`}),(0,L.jsx)(`p`,{className:`text-[15px] leading-relaxed text-fg-muted whitespace-pre-wrap`,children:e})]}),n.length>0&&(0,L.jsxs)(`div`,{className:`bg-amber-950/40 border border-amber-700/60 rounded-lg px-4 py-3`,children:[(0,L.jsxs)(`p`,{className:`text-sm font-medium text-amber-400 mb-2`,children:[`⚠ `,n.length,` existing code removal`,n.length===1?``:`s`,` declared`]}),(0,L.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:n.map((e,t)=>(0,L.jsxs)(`li`,{className:`text-sm text-amber-200/80`,children:[(0,L.jsx)(`span`,{className:`font-mono text-amber-300/90`,children:e.file}),` — `,(0,L.jsx)(`span`,{children:e.what}),(0,L.jsxs)(`span`,{className:`text-amber-200/50`,children:[` (`,e.why,`)`]})]},t))})]}),E&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle font-mono`,children:[(0,L.jsx)(`span`,{className:`text-violet-400`,children:`⚡ full-stack`}),(0,L.jsx)(`span`,{children:`•`}),(0,L.jsxs)(`span`,{children:[w.length,` repos`]}),(0,L.jsx)(`span`,{children:`•`}),(0,L.jsxs)(`span`,{children:[t.length,` file`,t.length===1?``:`s`]})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-6`,children:w.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[E&&(0,L.jsxs)(`div`,{className:`flex items-center gap-3 px-1`,children:[(0,L.jsxs)(`span`,{className:`text-xs font-mono font-semibold text-violet-300`,children:[`[`,e.label,`]`]}),(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle font-mono truncate`,children:e.repo}),(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-fg-subtle flex items-center gap-2`,children:[(0,L.jsxs)(`span`,{children:[e.changes.length,` file`,e.changes.length===1?``:`s`]}),(0,L.jsxs)(`span`,{className:`text-green-400`,children:[`+`,e.adds]}),(0,L.jsxs)(`span`,{className:`text-red-400`,children:[`-`,e.removes]}),e.existingBranch&&(0,L.jsx)(`span`,{className:`ml-2 text-[11px] bg-violet-900/40 text-violet-300 px-1.5 py-0.5 rounded font-mono`,children:`branch open`})]})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.changes.map(t=>(0,L.jsx)(Qo,{change:t},`${e.repo}:${t.file}`))})]},e.repo))}),c,(0,L.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-2xl bg-surface-raised px-4 py-4 ring-1 ring-inset ring-line`,children:[(0,L.jsx)(`label`,{htmlFor:`diff-refine`,className:`text-[15px] font-semibold text-fg`,children:`Ask or refine`}),d.length>0&&(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:d.map((e,t)=>{let n=e.kind===`answer`,r=e.kind===`canceled`,i=e.kind===`failed`,a=e.kind===`refine`,o=i?`border-red-800/60 bg-red-950/30`:r?`border-amber-800/60 bg-amber-950/30`:n?`border-sky-800/60 bg-sky-950/30`:`border-line-strong bg-surface-raised`,s=S.has(t),c=e.feedback.length>240,d=()=>{C(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},f=a&&!!e.prevResult&&!!u&&!T,m=(r||i)&&!T;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`div`,{className:`text-xs text-fg-subtle`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-violet-400/80 font-medium shrink-0`,children:`You:`}),(0,L.jsx)(`span`,{className:`italic flex-1 whitespace-pre-wrap break-words [overflow-wrap:anywhere] ${c&&!s?`max-h-12 overflow-hidden line-clamp-2`:`max-h-40 overflow-y-auto`}`,children:c&&!s?e.feedback.slice(0,240)+`…`:e.feedback})]}),c&&(0,L.jsx)(`button`,{onClick:d,className:`ml-10 mt-0.5 text-[11px] text-fg-subtle hover:text-fg transition-colors`,children:s?`Show less`:`Show more`})]}),e.explanation===void 0?(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-fg-subtle border-t-transparent animate-spin inline-block`}),`Thinking…`]}),p.length>0&&(0,L.jsx)(`div`,{className:`ml-5 flex flex-col gap-0.5 font-mono text-[11px] text-fg-subtle/80 leading-tight`,children:p.slice(-3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},`${p.length-3+t}-${e}`))})]}):(0,L.jsxs)(`div`,{className:`text-sm text-fg border rounded px-3 py-2 leading-relaxed whitespace-pre-wrap ${o}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1.5`,children:[(0,L.jsx)(`span`,{className:`text-[11px] font-mono ${i?`text-red-300`:r?`text-amber-300`:n?`text-sky-300`:`text-emerald-300`}`,children:i?`Failed`:r?`Canceled`:n?`Answer — no code changed`:`Refined — code updated`}),f&&(0,L.jsx)(`button`,{onClick:()=>u?.(t),className:`text-[11px] text-fg-muted hover:text-fg border border-line-strong hover:border-fg-subtle rounded px-2 py-0.5 transition-colors`,title:`Revert the code back to the state before this refinement`,children:`Undo`}),m&&(0,L.jsx)(`button`,{onClick:()=>l(e.feedback),className:`text-[11px] text-amber-300 hover:text-amber-200 border border-amber-800/60 hover:border-amber-600 rounded px-2 py-0.5 transition-colors`,title:`Re-run refinement with the same feedback`,children:`Retry`})]}),e.explanation]})]},t)})}),f.length>0&&(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:f.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`div`,{className:`text-xs text-fg-subtle flex items-start gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-violet-400/80 font-medium shrink-0`,children:`You:`}),(0,L.jsx)(`span`,{className:`italic flex-1 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e})]}),(0,L.jsx)(`div`,{className:`text-[11px] font-mono text-fg-subtle border border-line bg-surface-raised/60 rounded px-2 py-1 w-fit`,children:`Queued — runs after the current turn`})]},`queued-${t}`))}),(0,L.jsx)(`textarea`,{id:`diff-refine`,value:_,onChange:e=>v(e.target.value),disabled:m,placeholder:h?`Stack another prompt — it'll run after the current turn.`:`Ask a question (e.g. “are the lint issues fixed?”) or give direction (e.g. “use the existing log utility”)`,rows:2,className:`w-full rounded-xl border border-line bg-surface px-3 py-2.5 text-[15px] text-fg placeholder-fg-subtle resize-none focus:border-accent-hover focus:outline-none disabled:opacity-40`}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[h&&(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:f.length>0?`${f.length} queued`:`New prompts will queue`}),(0,L.jsx)(`button`,{onClick:()=>{_.trim()&&(l(_.trim()),v(``))},disabled:m||!_.trim(),className:`rounded-full bg-surface px-4 py-1.5 text-sm font-medium text-accent-fg ring-1 ring-inset ring-line transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-40`,children:h?`Queue →`:`Refine →`})]})]}),(0,L.jsxs)(`div`,{className:`sticky bottom-0 z-10 -mx-4 mt-1 flex flex-col gap-2.5 border-t border-line/70 bg-canvas/85 px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-3 backdrop-blur-xl sm:mx-0 sm:rounded-2xl sm:border sm:px-4`,children:[g===`idle`&&(0,L.jsxs)(`p`,{className:`text-xs text-amber-300`,children:[`Run the checks before pushing.`,` `,(0,L.jsx)(`button`,{onClick:()=>b(e=>!e),className:`underline decoration-dotted hover:text-amber-200 transition-colors`,children:y?`Cancel override`:`Skip checks`}),y&&` — override active, CI may still fail.`]}),g===`running`&&(0,L.jsx)(`p`,{className:`text-xs text-violet-300`,children:`Validation in progress — hold on before pushing.`}),g===`failed`&&(0,L.jsxs)(`p`,{className:`text-xs text-red-300`,children:[`Validation failed.`,` `,(0,L.jsx)(`button`,{onClick:()=>b(e=>!e),className:`underline decoration-dotted hover:text-red-200 transition-colors`,children:y?`Cancel override`:`Push anyway`}),y&&` — override active, CI may still fail.`]}),(0,L.jsxs)(`div`,{className:Yo,children:[ee&&s?(0,L.jsx)(`button`,{onClick:s,disabled:k,className:`${Jo} md:flex-1 bg-violet-600 hover:bg-violet-500 disabled:opacity-40 disabled:cursor-not-allowed text-on-accent py-2.5 transition-colors`,children:m?`Pushing...`:g===`running`?`Waiting for checks…`:O?g===`failed`?`Checks failed`:`Validate first`:E?`Push to ${w.length} existing branches`:`Push to ${w[0]?.existingBranch??`branch`}`}):(0,L.jsx)(`button`,{onClick:a,disabled:k,className:`${Jo} md:flex-1 bg-violet-600 hover:bg-violet-500 disabled:opacity-40 disabled:cursor-not-allowed text-on-accent py-2.5 transition-colors`,children:m?`Pushing...`:g===`running`?`Waiting for checks…`:O?g===`failed`?`Checks failed`:`Validate first`:E?`Approve & Create ${w.length} MRs`:`Approve & Create MR`}),!D&&(0,L.jsx)(`button`,{onClick:o,disabled:k,title:`Push branch only — deploys to test namespace without opening an MR`,className:`w-full md:w-auto min-h-[50px] md:min-h-0 rounded-xl md:rounded-lg text-[17px] md:text-sm font-semibold md:font-medium px-4 bg-surface-raised ring-1 ring-inset ring-line-strong hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed text-fg py-2.5 transition-colors border border-line-strong`,children:`Deploy to Test`})]})]})]})}function ns({checked:e,onChange:t,className:n=``}){return(0,L.jsxs)(`span`,{className:`relative inline-flex shrink-0 ${n}`,children:[(0,L.jsx)(`input`,{type:`checkbox`,role:`switch`,checked:e,onChange:e=>t(e.target.checked),className:`peer sr-only`}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`w-[51px] h-[31px] md:w-9 md:h-5 rounded-full bg-line-strong transition-colors duration-200 peer-checked:bg-accent peer-focus-visible:ring-2 peer-focus-visible:ring-accent-hover peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-canvas`}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-[2px] left-[2px] w-[27px] h-[27px] md:w-4 md:h-4 rounded-full bg-on-accent shadow-md transition-transform duration-200 peer-checked:translate-x-5 md:peer-checked:translate-x-4`})]})}var rs=[`clone`,`install`,`overlay`,`format`,`lint`,`typecheck`,`test`],is=[`lint`,`typecheck`,`test`],as={clone:`Clone`,install:`Install`,overlay:`Apply`,format:`Format`,lint:`Lint`,typecheck:`Types`,tdd_precheck:`Test first`,test:`Tests`,fmt:`Format`,vet:`Vet`,build:`Build`};function os(e){switch(e){case`running`:return(0,L.jsx)(`span`,{className:`w-3.5 h-3.5 rounded-full border-2 border-violet-400 border-t-transparent animate-spin inline-block`});case`passed`:return(0,L.jsx)(`span`,{className:`text-emerald-400 text-sm`,children:`✓`});case`failed`:return(0,L.jsx)(`span`,{className:`text-red-400 text-sm`,children:`✗`});case`skipped`:return(0,L.jsx)(`span`,{className:`text-fg-subtle text-sm`,children:`—`});case`interrupted`:return(0,L.jsx)(`span`,{className:`text-amber-300 text-sm`,children:`!`});default:return(0,L.jsx)(`span`,{className:`text-fg-subtle text-sm`,children:`○`})}}function ss(e,t){let n=e?Date.parse(e):NaN;if(Number.isNaN(n))return`running…`;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?`running · ${r}s`:`running · ${Math.floor(r/60)}m ${r%60}s`}function cs(e,t){switch(e.status){case`running`:return ss(e.startedAt,t);case`interrupted`:return`interrupted`;case`passed`:return e.durationMs==null?`passed`:`passed in ${(e.durationMs/1e3).toFixed(1)}s`;case`failed`:return e.exitCode==null?`failed`:`failed (exit ${e.exitCode})`;case`idle`:return`pending`;case`skipped`:return`skipped`;default:return``}}function ls({step:e,state:t,stale:n,onFix:r,fixing:i,fixable:a}){let[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(()=>Date.now()),u=t.status===`running`;(0,x.useEffect)(()=>{if(!u)return;let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[u]);let d=t.logs.length>0||!!t.tail,f=r&&a&&t.status===`failed`;return(0,L.jsxs)(`div`,{className:n?`opacity-70`:void 0,children:[(0,L.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,L.jsxs)(`button`,{disabled:!d,onClick:()=>s(e=>!e),className:`flex-1 flex min-h-11 items-center gap-3 px-3.5 py-2 text-left ${d?`hover:bg-surface-hover/60 cursor-pointer`:`cursor-default`}`,children:[(0,L.jsx)(`span`,{className:`w-4 flex items-center justify-center shrink-0`,children:os(t.status)}),(0,L.jsx)(`span`,{className:`text-sm text-fg w-24 shrink-0`,children:as[e]??e}),(0,L.jsx)(`span`,{className:`text-xs ${t.status===`failed`?`text-red-300`:t.status===`passed`?`text-fg-muted`:t.status===`running`?`text-violet-300`:t.status===`interrupted`?`text-amber-300`:`text-fg-subtle`} flex-1 truncate`,children:cs(t,c)}),d&&(0,L.jsx)(`span`,{className:`text-fg-subtle shrink-0 transition-transform ${o?`rotate-90`:``}`,children:`›`})]}),f&&(0,L.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r()},disabled:i,title:`Send this ${e} failure to Claude to refine the proposed changes.`,className:`shrink-0 px-3.5 text-sm font-medium text-accent-fg hover:bg-accent-soft disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:i?`Fixing…`:`Fix with AI`})]}),o&&d&&(0,L.jsx)(ma,{entries:t.logs.length>0?t.logs:fs(t.tail),variant:`embedded`,heightClass:`max-h-56`,autoScroll:t.status===`running`})]})}function us({repo:e,stale:t,onFixStep:n,fixingStep:r,showName:i}){let a=e.stepOrder??rs,o=new Set,s=[];for(let t of a)e.steps[t]&&(s.push(t),o.add(t));for(let t of Object.keys(e.steps))o.has(t)||s.push(t);if(s.length===0&&!e.skipped)return null;if(e.skipped)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs text-amber-300 truncate`,children:e.repo}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle font-mono shrink-0`,children:`skipped`})]}),(0,L.jsx)(`div`,{className:`text-xs text-amber-300/80 bg-amber-950/20 border border-amber-900/40 rounded-md px-3 py-2`,children:e.skipReason===`misattributed`?`No proposed file exists in this repo — the change was likely misrouted here. Refine and tell the model the correct repo, or leave it for the other block to validate.`:`Skipped (${e.skipReason??`unknown`})`})]});let c=new Set(e.fixableSteps??is),l=e.result?.allPassed?`text-emerald-300`:s.some(t=>e.steps[t]?.status===`failed`)?`text-red-300`:s.some(t=>e.steps[t]?.status===`running`)?`text-violet-300`:`text-fg-muted`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[i&&(0,L.jsx)(`span`,{className:`px-1 text-xs ${l} truncate`,children:e.repo.replace(/^[a-z]+:/,``)}),(0,L.jsx)(`div`,{className:`divide-y divide-line overflow-hidden rounded-xl bg-surface ring-1 ring-inset ring-line`,children:s.map(i=>{let a=e.steps[i];return(0,L.jsx)(ls,{step:i,state:a,stale:t,onFix:n?()=>n(i,a.tail):void 0,fixing:r===i,fixable:c.has(i)},i)})})]})}function ds({state:e,validating:t,error:n,onValidate:r,onFixStep:i,fixingStep:a=null,autoPushOnPass:o=!1,onToggleAutoPush:s,children:c}){let{result:l,byRepo:u={},repoOrder:d=[],aggregateLogs:f=[],stale:p}=e,m=d.map(e=>u[e]).filter(Boolean),h=m.some(e=>Object.values(e.steps).some(e=>e&&e.status!==`idle`))||f.length>0,g=!t&&m.some(e=>Object.values(e.steps).some(e=>e?.status===`interrupted`)),_=h?t?`text-violet-300`:g||p?`text-amber-300`:l?.allPassed?`text-emerald-300`:`text-red-300`:`text-fg-subtle`,v=h?t?`Running pre-flight checks…`:g?`Checks were interrupted. Run them again.`:p?`Results outdated — proposal changed since last run`:l?.allPassed?`All checks passed`:`Some checks failed`:`Lint, types and tests run before anything is pushed.`,y=!t&&!p&&!!l?.allPassed,b=m.reduce((e,t)=>e+Object.keys(t.steps).length,0),x=(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[f.length>0&&(0,L.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg bg-surface px-3 py-2 font-mono text-[11px] leading-relaxed text-fg-subtle [overflow-wrap:anywhere]`,children:f.slice(-30).map((e,t)=>(0,L.jsx)(`div`,{children:e.message},t))}),m.map(e=>(0,L.jsx)(us,{repo:e,stale:p,onFixStep:i,fixingStep:a,showName:m.length>1},e.repo))]});return(0,L.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-2xl bg-surface-raised p-4 ring-1 ring-inset ring-line [overflow-anchor:none]`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-semibold text-fg`,children:`Checks`}),(0,L.jsx)(`span`,{className:`text-sm ${_}`,children:v})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[s&&(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] md:text-[11px] text-fg-muted cursor-pointer select-none`,title:`When checked, any validation that passes automatically commits — pushes to the existing branch if one exists, or opens a new MR otherwise. Pairs with Fix with AI to close the loop.`,children:[(0,L.jsx)(ns,{checked:o,onChange:s}),`Auto-push on green`]}),(0,L.jsx)(`button`,{onClick:r,disabled:t,className:`min-h-11 md:min-h-0 rounded-full bg-surface px-4 py-1.5 text-[15px] md:text-sm font-medium text-accent-fg ring-1 ring-inset ring-line transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,children:t?`Validating…`:p||h?`Re-validate`:`Validate`})]})]}),n&&(0,L.jsx)(`div`,{className:`text-xs text-red-400 bg-red-950/40 border border-red-900 rounded px-3 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere] max-h-32 overflow-y-auto font-mono`,children:n}),h&&(y?(0,L.jsxs)(`details`,{className:`group`,children:[(0,L.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1 text-xs text-fg-subtle select-none hover:text-fg`,children:[(0,L.jsx)(`span`,{className:`inline-block transition-transform group-open:rotate-90`,children:`›`}),`Show `,b,` checks`]}),(0,L.jsx)(`div`,{className:`mt-3`,children:x})]}):x),c]})}function fs(e){return(e??``).split(`
27
- `).map(e=>({ts:``,message:e}))}function ps(){let{analysisLogs:e,analysisResult:t,analysisError:n,applyResult:r,applyError:i,applying:a,refining:o,validation:s,validating:c,validationError:l,autoPushOnValidatePass:u,availableRepos:d,refineThread:f,refineQueue:p,thinkingLogs:m}=V(),{handleApprove:h,handleDeployBranch:g,handleCommitToBranch:_,handleRefine:v,handleUndoRefine:y,handleValidate:b,handleFixValidation:S,setAutoPushOnValidatePass:C}=H(),[w,T]=(0,x.useState)(null);(0,x.useEffect)(()=>{o||T(null)},[o]);let E=(e,t)=>{T(e),S(e,t)},ee=c?`running`:s.stale||!s.result?`idle`:s.result.allPassed?`passed`:`failed`;return(0,L.jsxs)(`div`,{className:`max-w-3xl mx-auto w-full flex flex-col gap-6`,children:[n&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 text-sm text-red-300 whitespace-pre-wrap break-words [overflow-wrap:anywhere] max-h-48 overflow-y-auto font-mono leading-snug`,children:n}),i&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 text-sm text-red-300 whitespace-pre-wrap break-words [overflow-wrap:anywhere] max-h-48 overflow-y-auto font-mono leading-snug`,children:i}),e.length>0&&(0,L.jsxs)(`details`,{className:`group order-last`,children:[(0,L.jsxs)(`summary`,{className:`cursor-pointer text-xs text-fg-subtle hover:text-fg transition-colors select-none list-none flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`group-open:rotate-90 transition-transform inline-block`,children:`›`}),`Analysis log (`,e.length,` lines)`]}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(ma,{entries:e,label:`forge analysis`,badge:`${e.length} entr${e.length===1?`y`:`ies`}`,heightClass:`max-h-56`})})]}),t?(0,L.jsx)(ts,{explanation:t.explanation,changes:t.changes,removals:t.removals,existingApplications:r?.applications??[],availableRepos:d,onApprove:h,onDeployBranch:g,onCommitToBranch:_,checks:(0,L.jsx)(ds,{state:s,validating:c,error:l,onValidate:b,onFixStep:E,fixingStep:w,autoPushOnPass:u,onToggleAutoPush:C}),onRefine:v,onUndoRefine:y,refineThread:f,refineQueue:p,thinkingLogs:m,applying:a,refining:o,validationStatus:ee}):(0,L.jsx)(`div`,{className:`text-center py-12 text-fg-subtle text-sm`,children:`No changes were proposed.`})]})}function ms({className:e}){return(0,L.jsx)(`div`,{className:Gn(`animate-pulse rounded bg-surface-hover`,e)})}function hs(){return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-10`,role:`status`,"aria-label":`Loading settings`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(ms,{className:`h-6 w-28`}),(0,L.jsx)(ms,{className:`h-3 w-2/3`})]}),[0,1,2].map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(ms,{className:`h-4 w-32`}),(0,L.jsx)(ms,{className:`h-3 w-1/2`}),(0,L.jsx)(ms,{className:`h-28 w-full rounded-xl`})]},e))]})}function gs(){return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4`,role:`status`,"aria-label":`Loading issue`,children:[(0,L.jsx)(ms,{className:`h-7 w-2/3`}),(0,L.jsx)(ms,{className:`h-3 w-1/3`}),(0,L.jsx)(ms,{className:`h-8 w-40 rounded-lg`}),(0,L.jsx)(ms,{className:`h-24 w-full rounded-xl`}),(0,L.jsx)(ms,{className:`h-24 w-full rounded-xl`})]})}var _s=`h-9 w-full rounded-lg border border-line bg-surface px-2.5 text-sm text-fg focus:border-accent-hover focus:outline-none sm:w-auto`;function vs(){let{availableRepos:e,selectedRepo:t,selectedSecondaryRepos:n,availableAgents:r,selectedAgent:i,availableModels:a,selectedModel:o}=V(),{setSelectedSecondaryRepos:s,setSelectedAgent:c,setSelectedModel:l}=H(),u=e.filter(e=>e.id!==t),d=i!==`openclaw`&&a.length>0,f=u.filter(e=>n.includes(e.id)),p=[d?a.find(e=>e.id===o)?.label:r.find(e=>e.id===i)?.label,f.length?`+ ${f.map(e=>e.label).join(`, `)}`:null].filter(Boolean).join(` · `);if(!d&&r.length<2&&u.length===0)return null;let m=e=>s(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,L.jsxs)(`details`,{className:`group text-sm`,children:[(0,L.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 text-fg-muted select-none hover:text-fg`,children:[(0,L.jsx)(`span`,{className:`inline-block transition-transform group-open:rotate-90`,children:`›`}),`Options`,p&&(0,L.jsxs)(`span`,{className:`truncate text-fg-subtle`,children:[`· `,p]})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 rounded-xl bg-surface-raised p-4 sm:flex-row sm:flex-wrap sm:items-end sm:gap-5`,children:[r.length>1&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs text-fg-subtle`,children:[`Agent`,(0,L.jsx)(`select`,{"aria-label":`Agent`,value:i,onChange:e=>c(e.target.value),className:_s,children:r.map(e=>(0,L.jsxs)(`option`,{value:e.id,disabled:!e.configured,children:[e.label,e.configured?``:` (not configured)`]},e.id))})]}),d&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs text-fg-subtle`,children:[`Model`,(0,L.jsx)(`select`,{"aria-label":`Model`,value:o,onChange:e=>l(e.target.value),className:_s,children:a.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),u.length>0&&(0,L.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5 text-xs text-fg-subtle`,children:[(0,L.jsx)(`legend`,{className:`mb-1.5`,children:`Also change`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.map(e=>{let t=n.includes(e.id);return(0,L.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(e.id),className:`h-9 rounded-full px-3.5 text-sm transition-colors ${t?`bg-accent-soft text-accent-fg`:`bg-surface text-fg-muted ring-1 ring-inset ring-line hover:text-fg`}`,children:e.label},e.id)})})]})]})]})}function ys(){let{applyResult:e}=V(),{handleRefinePipelineFailure:t}=H(),n=e?.applications.filter(e=>!e.mr)??[];return n.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-[15px] font-semibold text-fg`,children:`Activity`}),(0,L.jsx)(`span`,{className:`text-[10px] text-fg-subtle`,children:`Deploy-to-Test · no MR yet`})]}),n.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 bg-surface-raised/50 border border-line-strong rounded-lg p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:`Branch`}),(0,L.jsxs)(`span`,{className:`text-sm font-mono text-violet-300 truncate`,title:e.branchName,children:[`⎇ `,e.branchName]})]}),e.pipelineUrl&&(0,L.jsx)(`a`,{href:e.pipelineUrl,target:`_blank`,rel:`noreferrer`,className:`text-xs text-violet-400 hover:underline shrink-0`,children:`Open in GitLab ↗`})]}),(0,L.jsx)(zo,{endpoint:`branch-pipeline?branch=${encodeURIComponent(e.branchName)}`,repo:e.repo,onRefinePipelineFailure:t})]},`${e.repo}:${e.branchName}`))]})}function bs(){let{storedAnalyses:e}=V(),{handleRestoreAnalysis:t,handleDiscardStoredAnalysis:n,handleClearIssueCache:r,formatAnalysisDate:i}=H();return e.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-muted font-medium`,children:[`Previous analyses (`,e.length,`)`]}),(0,L.jsx)(`button`,{onClick:()=>{window.confirm(`Delete all ${e.length} analyses for this issue? They're removed for everyone and can't be restored.`)&&r()},className:`text-xs text-fg-subtle hover:text-red-300 transition-colors`,title:`Delete every analysis for this issue`,children:`Clear all`})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`bg-surface-raised/60 border border-line-strong rounded-lg px-4 py-2.5 flex items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle min-w-0`,children:[(0,L.jsx)(`span`,{children:i(e.analyzedAt)}),(0,L.jsx)(`span`,{children:`·`}),(0,L.jsxs)(`span`,{children:[e.result.changes.length,` file`,e.result.changes.length===1?``:`s`]}),e.model&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`·`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.model.split(`-`).slice(1,3).join(` `)})]}),(0,L.jsx)(`span`,{children:`·`}),e.mrIid?(0,L.jsxs)(`span`,{className:`text-violet-400`,children:[`MR !`,e.mrIid]}):(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`no MR`})]}),e.prompt&&(0,L.jsxs)(`div`,{className:`text-xs text-fg-muted italic truncate`,title:e.prompt,children:[`“`,e.prompt,`”`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,L.jsx)(`button`,{onClick:()=>t(e.id),className:`bg-violet-600 hover:bg-violet-500 text-on-accent text-xs font-medium px-3 py-1 rounded transition-colors`,children:`Restore`}),(0,L.jsx)(`button`,{onClick:()=>n(e.id),className:`text-xs text-fg-subtle hover:text-fg-muted transition-colors`,title:`Discard`,children:`✕`})]})]},e.id))})]})}var xs={updateMr:`Analyze & Update MR`,newAnalysis:`New Analysis`,tryAgain:`Try Again`,begin:`Begin Analysis`};function Ss({editing:e,editDescription:t,setEditDescription:n,editLabels:r,setEditLabels:i,availableLabels:a,saving:o,onSave:s,onCancelEdit:c,editTitle:l}){let{selectedIssue:u,analysisPrompt:d,existingMr:f,existingMrLoading:p,storedAnalyses:m,mergedMrs:h,resolutionCheck:g,issueEnvironmentsLoading:_}=V(),{setAnalysisPrompt:v,handleBeginAnalysis:y,handleFreshReanalyze:b}=H();if(!u)return null;let x=h.length>0&&!f&&!p,S=p?null:f?xs.updateMr:m.length>0?xs.newAnalysis:h.length>0&&g&&!g.resolved?xs.tryAgain:xs.begin,C=!p&&!_;return(0,L.jsxs)(L.Fragment,{children:[e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`textarea`,{"aria-label":`Description`,value:t,onChange:e=>n(e.target.value),rows:8,className:`bg-surface-raised border border-line-strong focus:border-violet-500 rounded-lg px-4 py-3 text-sm text-fg outline-none w-full resize-y leading-relaxed`}),(0,L.jsx)(Wa,{labels:r,available:a,onChange:i})]}):u.description&&(0,L.jsx)(`div`,{className:`bg-surface-raised border border-line-strong rounded-lg px-4 py-4 text-sm text-fg whitespace-pre-wrap leading-relaxed w-full max-h-[50vh] overflow-y-auto`,children:u.description}),!e&&(0,L.jsx)(bs,{}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!e&&(0,L.jsx)(`textarea`,{value:d,onChange:e=>v(e.target.value),placeholder:`Optional instructions for the analysis…`,rows:2,className:`w-full bg-surface-raised/60 border border-line-strong rounded-lg px-3 py-2 text-sm text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 resize-none`}),!e&&(0,L.jsx)(vs,{}),e?(0,L.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center gap-1 md:gap-3`,children:[(0,L.jsx)(`button`,{onClick:s,disabled:o||!l.trim(),className:`${Jo} bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent px-5 py-2 transition-colors ${p?`animate-pulse`:``}`,children:o?`Saving…`:`Save`}),(0,L.jsx)(`button`,{onClick:c,className:`min-h-11 md:min-h-0 text-[17px] md:text-sm text-fg-subtle hover:text-fg transition-colors`,children:`Cancel`})]}):(0,L.jsx)(`div`,{className:`flex flex-col md:flex-row md:flex-wrap md:items-center justify-between gap-3 md:gap-x-6 md:gap-y-3 border-t border-line/60 pt-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center gap-1 md:gap-3`,children:[(0,L.jsx)(`button`,{onClick:y,disabled:p,className:`grid ${Jo} bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent px-5 py-2 transition-colors ${p?`animate-pulse`:``}`,children:Object.values(xs).map(e=>(0,L.jsx)(`span`,{"aria-hidden":e!==S||void 0,className:`[grid-area:1/1] ${e===S?``:`invisible`}`,children:e},e))}),m.length>0&&(0,L.jsx)(`button`,{onClick:b,className:`min-h-11 md:min-h-0 text-[17px] md:text-sm text-amber-400/90 md:text-fg-muted hover:text-amber-400 transition-colors`,children:`Discard & Reanalyze`})]})})]}),!e&&(0,L.jsxs)(To,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(Do,{ready:C}),x&&(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,L.jsx)(Wo,{})}),(0,L.jsx)(uo,{}),(0,L.jsx)(ys,{}),(0,L.jsx)(So,{mrs:h})]},u.iid)]})}function Cs(){return(0,L.jsxs)(`div`,{"aria-hidden":`true`,className:`flex flex-col gap-3 animate-pulse`,children:[(0,L.jsx)(`div`,{className:`h-20 bg-surface-raised border border-line-strong rounded-lg`}),(0,L.jsx)(`div`,{className:`h-32 bg-surface-raised border border-line-strong rounded-lg`})]})}function ws(){let{existingMr:e,existingMrLoading:t,applyResult:n,selectedRepo:r,applying:i,applyError:a,testDeployUrlTemplate:o}=V(),{handleRefinePipelineFailure:s,handlePromoteBranch:c}=H(),{setMrMerged:l}=hi(),[u,d]=(0,x.useState)({}),[f,p]=(0,x.useState)(null);if(t)return(0,L.jsx)(Cs,{});if(e)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-raised border border-line-strong rounded-lg px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:`Merge request`}),(0,L.jsxs)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`text-sm text-violet-400 hover:underline`,children:[`!`,e.iid,` `,e.title]}),(0,L.jsx)(`span`,{className:`text-xs font-mono text-fg-subtle`,children:e.branchName})]}),(0,L.jsx)(Ho,{mrIid:e.iid,repo:r||void 0})]}),(0,L.jsxs)(To,{placeholder:(0,L.jsx)(Cs,{}),className:`flex flex-col gap-6`,children:[(0,L.jsx)(Mo,{mrIid:e.iid,repo:r||void 0,pipelineStatus:f,onMerged:()=>l(!0)}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-semibold text-fg`,children:`Pipeline`}),(0,L.jsx)(zo,{endpoint:`mr/${e.iid}/pipeline`,repo:r||void 0,onRefinePipelineFailure:s,onStatusChange:p})]})]},e.iid)]});let m=n?.applications.filter(e=>!e.mr)??[];return m.length>0?(0,L.jsx)(To,{placeholder:(0,L.jsx)(Cs,{}),className:`flex flex-col gap-6`,children:m.map(e=>{let t=`${e.repo}:${e.branchName}`,n=u[t]===`success`,r=n?Uo(o,e.branchName):null;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`div`,{className:`bg-surface-raised border border-line-strong rounded-lg px-4 py-4 flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:`Test deploy — branch only, no MR`}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 truncate`,children:[`Branch: `,(0,L.jsx)(`span`,{className:`font-mono`,children:e.branchName})]})]}),(0,L.jsx)(Ho,{branchName:e.branchName,repo:e.repo,fallbackUrl:r}),n&&(0,L.jsx)(`button`,{onClick:()=>c(e),disabled:i,className:`shrink-0 ml-4 bg-violet-600 hover:bg-violet-500 disabled:opacity-40 disabled:cursor-not-allowed text-on-accent text-sm font-medium px-4 py-2 rounded-lg transition-colors`,title:`Pipeline is green — promote this branch to a merge request`,children:i?`Creating MR…`:`Approve & Create MR`})]}),a&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-2 text-xs text-red-300`,children:a}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-semibold text-fg`,children:`Test deploy pipeline`}),(0,L.jsx)(zo,{endpoint:`branch-pipeline?branch=${encodeURIComponent(e.branchName)}`,repo:e.repo,onRefinePipelineFailure:s,onStatusChange:e=>d(n=>({...n,[t]:e??``}))})]})]},t)})}):(0,L.jsx)(`div`,{className:`text-center py-12 text-fg-subtle text-sm`,children:`No open MR found for this issue.`})}function Ts({editing:e,editTitle:t,setEditTitle:n,onStartEdit:r}){let{selectedIssue:i}=V();if(!i)return null;let a=Ia(i.labels),o=/^(type|priority|area)::/,s=i.labels.find(e=>e.startsWith(`status::`))?.slice(8),c=i.labels.filter(e=>!o.test(e)&&!e.startsWith(`status::`));return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[e?(0,L.jsx)(`input`,{"aria-label":`Title`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-line-strong bg-surface-raised px-3 py-1.5 text-xl font-semibold text-fg outline-none focus:border-violet-500`}):(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg sm:text-2xl`,children:i.title}),!e&&(0,L.jsx)(vo,{onEdit:r})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 text-sm text-fg-subtle`,children:[(0,L.jsxs)(`span`,{children:[`#`,i.iid]}),a.type&&(0,L.jsx)(Gi,{tone:Qa[a.type]??`neutral`,children:eo(a.type)}),a.priority&&(0,L.jsx)(Gi,{tone:$a[a.priority]??`neutral`,dot:!0,children:eo(a.priority)}),s&&(0,L.jsx)(Gi,{tone:`neutral`,children:eo(s.replace(/-/g,` `))}),[...a.areas,...c].map(e=>(0,L.jsx)(`span`,{className:`rounded-full bg-surface-raised px-2 py-0.5 text-xs text-fg-muted`,children:e},e))]}),(0,L.jsxs)(`p`,{className:`text-[13px] text-fg-subtle`,children:[`Opened by `,i.author.name,` ·`,` `,(0,L.jsx)(`a`,{href:i.web_url,target:`_blank`,rel:`noreferrer`,className:`hover:text-fg`,children:`View on GitLab ↗`})]})]})}function Es(){let{selectedIssue:e,existingMr:t,existingMrLoading:n,applyResult:r,selectedRepo:i}=V(),{handleUpdateIssue:a}=H(),{activeDetailTab:o,setActiveDetailTab:s}=hi(),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(``),[m,h]=(0,x.useState)([]),g=Ma(i),[_,v]=(0,x.useState)(!1),{navigate:y}=Ei();if(!e)return(0,L.jsx)(gs,{});let b=()=>{d(e.title??``),p(e.description??``),h(e.labels),l(!0)},S=()=>l(!1),C=async()=>{v(!0);try{await a(u,f,m),l(!1)}finally{v(!1)}},w=t=>{let n=t===`mr`?`mr`:`issue`;s(n),y(n===`mr`?`/issues/${e.iid}/mr`:`/issues/${e.iid}`,{replace:!0})},T=(r?.applications??[]).filter(e=>!e.mr).length,E=t?`MR`:T>0?`Branch`:`MR`,ee=t?(0,L.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${o===`mr`?`bg-surface-raised text-fg`:`bg-violet-600/40 text-violet-300`}`,children:[`!`,t.iid]}):T>0?(0,L.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${o===`mr`?`bg-surface-raised text-fg`:`bg-amber-600/40 text-amber-300`}`,title:`${T} deploy-to-test branch${T>1?`es`:``} without an MR`,children:T}):(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`—`});return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6 w-full`,children:[(0,L.jsx)(Ts,{editing:c,editTitle:u,setEditTitle:d,onStartEdit:b}),(0,L.jsx)(Ko,{tabs:[{id:`issue`,label:`Issue`},{id:`mr`,label:E,loading:n,badge:n?void 0:ee}],active:o,onSelect:w}),o===`issue`&&(0,L.jsx)(Ss,{editing:c,editDescription:f,setEditDescription:p,editLabels:m,setEditLabels:h,availableLabels:g,saving:_,onSave:C,onCancelEdit:S,editTitle:u}),o===`mr`&&(0,L.jsx)(ws,{})]})}function Ds(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),o=(0,x.useCallback)(async()=>{r(!0),a(null);try{t(await R(`/config`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},[]),s=(0,x.useCallback)(async e=>{let n=await R(`/config`,{method:`PUT`,body:JSON.stringify(e)});return t(n),n},[]);return(0,x.useEffect)(()=>{o()},[o]),{config:e,loading:n,error:i,reload:o,patch:s}}function Os(){let[e,t]=(0,x.useState)([]),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(null);(0,x.useEffect)(()=>{Yi.listTokens().then(e=>t(e.tokens)).catch(e=>l(e.message))},[]);let u=async e=>{e.preventDefault(),l(null);try{let{token:e,record:n}=await Yi.createToken(i);t(e=>[n,...e]),s(e),r(!1),a(``)}catch(e){l(e.message)}},d=async e=>{await Yi.revokeToken(e),t(t=>t.filter(t=>t.id!==e))};return(0,L.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-end justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`API tokens`}),(0,L.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`Personal tokens for the `,(0,L.jsx)(`code`,{className:`font-mono`,children:`forge`}),` CLI and automation. They act with your role.`]})]}),!n&&(0,L.jsx)(z,{size:`sm`,onClick:()=>r(!0),children:`New token`})]}),o&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-emerald-800/60 bg-emerald-950/40 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-emerald-300`,children:`Copy this token now. You won't see it again.`}),(0,L.jsx)(`code`,{className:`break-all rounded-lg bg-canvas px-3 py-2 font-mono text-xs text-fg ring-1 ring-line`,children:o}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Use it as `,(0,L.jsx)(`code`,{className:`font-mono`,children:`FORGE_API_TOKEN`}),` in the CLI's environment.`]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(z,{size:`sm`,variant:`secondary`,onClick:()=>navigator.clipboard?.writeText(o),children:`Copy`}),(0,L.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>s(null),children:`Done`})]})]}),n&&(0,L.jsxs)(`form`,{onSubmit:u,className:`flex items-end gap-2 rounded-xl border border-line bg-surface-raised p-4`,children:[(0,L.jsxs)(`label`,{className:`flex flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Token name`,(0,L.jsx)(`input`,{required:!0,placeholder:`e.g. laptop CLI`,value:i,onChange:e=>a(e.target.value),className:`h-9 rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`})]}),(0,L.jsx)(z,{variant:`ghost`,size:`md`,onClick:()=>r(!1),children:`Cancel`}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,size:`md`,children:`Create token`})]}),c&&(0,L.jsx)(`p`,{className:`text-xs text-red-400`,children:c}),(0,L.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface-raised`,children:(0,L.jsx)(`table`,{"aria-label":`API tokens`,className:`w-full text-left text-sm`,children:(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(`td`,{className:`py-3 pl-4 pr-3`,children:[(0,L.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,L.jsxs)(`div`,{className:`font-mono text-xs text-fg-subtle`,children:[e.prefix,`…`]})]}),(0,L.jsxs)(`td`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`Created `,Zi(e.createdAt)]}),(0,L.jsxs)(`td`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`Last used `,Zi(e.lastUsedAt)]}),(0,L.jsx)(`td`,{className:`py-3 pl-3 pr-4 text-right`,children:(0,L.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>d(e.id),children:`Revoke`})})]},e.id)),e.length===0&&(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{className:`px-4 py-6 text-center text-sm text-fg-subtle`,children:`No tokens yet.`})})]})})})]})}var ks={gitlab:`GitLab`,github:`GitHub`,azuredevops:`Azure DevOps`,anthropic:`Anthropic`},As={gitlab:`GitLab token`,github:`GitHub token`,azuredevops:`Azure DevOps token`,anthropic:`Anthropic API key`},js={gitlab:`Clear stored token (revert to env var if set)`,github:`Clear stored token (revert to env var if set)`,azuredevops:`Clear stored token (revert to env var if set)`,anthropic:`Clear stored key (Claude goes back to the Claude Code subscription)`};function Ms(e,t){return e===`anthropic`&&t===`none`?(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:`subscription`}):t===`config`?(0,L.jsx)(`span`,{className:`text-[11px] text-violet-400`,children:`config`}):t===`env`?(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:`env`}):(0,L.jsx)(`span`,{className:`text-[11px] text-red-400/80`,children:`missing`})}function Ns({provider:e,connection:t,newToken:n,setNewToken:r,clearToken:i,setClearToken:a,baseUrl:o,setBaseUrl:s}){let[c,l]=(0,x.useState)(!1);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 bg-surface-raised border border-line rounded-lg px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:ks[e]}),Ms(e,t.tokenSource)]}),s&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`API base URL`}),(0,L.jsx)(`input`,{value:o??``,onChange:e=>s(e.target.value),placeholder:`https://gitlab.com/api/v4`,className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs font-mono text-fg focus:outline-none focus:border-violet-500`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[e===`anthropic`?`API key`:`Token`,t.hasToken&&(0,L.jsx)(`span`,{className:`ml-2 font-mono text-fg-subtle`,children:t.tokenHint})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`input`,{type:c?`text`:`password`,"aria-label":As[e],value:n,onChange:e=>r(e.target.value),placeholder:t.hasToken?`Leave blank to keep current`:e===`anthropic`?`Paste API key`:`Paste token`,disabled:i,className:`flex-1 bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs font-mono text-fg focus:outline-none focus:border-violet-500 disabled:opacity-40`}),(0,L.jsx)(`button`,{onClick:()=>l(e=>!e),disabled:!n,className:`text-xs text-fg-subtle hover:text-fg disabled:opacity-30`,children:c?`Hide`:`Show`})]}),t.tokenSource===`config`&&(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] md:text-xs text-fg-subtle`,children:[(0,L.jsx)(ns,{checked:i,onChange:a}),js[e]]})]})]})}var Ps={gitlab:``,github:``,azuredevops:``,anthropic:``},Fs={gitlab:!1,github:!1,azuredevops:!1,anthropic:!1};function Is({connections:e,onSave:t}){let[n,r]=(0,x.useState)(e.gitlab.baseUrl),[i,a]=(0,x.useState)(Ps),[o,s]=(0,x.useState)(Fs),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null);(0,x.useEffect)(()=>{r(e.gitlab.baseUrl)},[e.gitlab.baseUrl]);let f=n!==e.gitlab.baseUrl,p=Object.values(i).some(Boolean)||Object.values(o).some(Boolean),m=f||p,h=()=>{let e={},t={};return f&&(t.baseUrl=n),o.gitlab?t.token=``:i.gitlab&&(t.token=i.gitlab),Object.keys(t).length>0&&(e.gitlab=t),o.github?e.github={token:``}:i.github&&(e.github={token:i.github}),o.azuredevops?e.azuredevops={token:``}:i.azuredevops&&(e.azuredevops={token:i.azuredevops}),o.anthropic?e.anthropic={token:``}:i.anthropic&&(e.anthropic={token:i.anthropic}),e};return(0,L.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Connections`}),(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle mt-0.5`,children:`SCM hosts and tokens. Config values override env vars; empty config values fall back to env.`})]}),m&&(0,L.jsx)(`button`,{onClick:async()=>{l(!0),d(null);try{await t(h()),a(Ps),s(Fs)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},disabled:c,className:`bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-1.5 rounded-lg transition-colors`,children:c?`Saving…`:`Save`})]}),u&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-3 py-2 text-sm text-red-300`,children:u}),(0,L.jsx)(Ns,{provider:`gitlab`,connection:e.gitlab,baseUrl:n,setBaseUrl:r,newToken:i.gitlab,setNewToken:e=>a(t=>({...t,gitlab:e})),clearToken:o.gitlab,setClearToken:e=>s(t=>({...t,gitlab:e}))}),(0,L.jsx)(Ns,{provider:`github`,connection:e.github,newToken:i.github,setNewToken:e=>a(t=>({...t,github:e})),clearToken:o.github,setClearToken:e=>s(t=>({...t,github:e}))}),(0,L.jsx)(Ns,{provider:`azuredevops`,connection:e.azuredevops,newToken:i.azuredevops,setNewToken:e=>a(t=>({...t,azuredevops:e})),clearToken:o.azuredevops,setClearToken:e=>s(t=>({...t,azuredevops:e}))}),(0,L.jsx)(Ns,{provider:`anthropic`,connection:e.anthropic,newToken:i.anthropic,setNewToken:e=>a(t=>({...t,anthropic:e})),clearToken:o.anthropic,setClearToken:e=>s(t=>({...t,anthropic:e}))})]})}function Ls({defaults:e,onSave:t}){let{availableModels:n,availableAgents:r}=V(),[i,a]=(0,x.useState)(e),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null),u=(0,x.useId)();(0,x.useEffect)(()=>{a(e)},[e]);let d=JSON.stringify(i)!==JSON.stringify(e);return(0,L.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Defaults`}),(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle mt-0.5`,children:`Preselect the model and agent on load. Leaves selection free per-request.`})]}),(0,L.jsx)(`button`,{onClick:async()=>{s(!0),l(null);try{await t(i)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}},disabled:!d||o,"aria-hidden":!d||void 0,tabIndex:d?void 0:-1,className:`bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-1.5 rounded-lg transition-colors ${d?``:`invisible`}`,children:o?`Saving…`:`Save`})]}),c&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-3 py-2 text-sm text-red-300`,children:c}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Default model`}),(0,L.jsxs)(`select`,{value:i.model??``,onChange:e=>a({...i,model:e.target.value===``?null:e.target.value}),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:[(0,L.jsx)(`option`,{value:``,children:`— none —`}),n.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Default agent`}),(0,L.jsxs)(`select`,{value:i.agent??``,onChange:e=>a({...i,agent:e.target.value===``?null:e.target.value}),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:[(0,L.jsx)(`option`,{value:``,children:`— none —`}),r.map(e=>(0,L.jsxs)(`option`,{value:e.id,disabled:!e.configured,children:[e.label,e.configured?``:` (not configured)`]},e.id))]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`label`,{htmlFor:u,className:`text-xs text-fg-subtle`,children:`Agent mode`}),(0,L.jsxs)(`select`,{id:u,"aria-describedby":`${u}-help`,value:i.agentMode??`structured`,onChange:e=>a({...i,agentMode:e.target.value}),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:[(0,L.jsx)(`option`,{value:`structured`,children:`Structured — single-pass JSON, no tools`}),(0,L.jsx)(`option`,{value:`agentic`,children:`Agentic — works in a checkout with tools`})]}),(0,L.jsxs)(`span`,{id:`${u}-help`,className:`text-[11px] text-fg-subtle leading-relaxed`,children:[`Agentic runs Claude inside a clone of the repo (GitLab, single repo) with its `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`CLAUDE.md`}),`, so it can run tests and Playwright and attach a write-up and screenshots to the MR. Other cases fall back to structured. `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`FORGE_AGENT_MODE`}),`, if set, overrides this.`]})]}),(0,L.jsxs)(`label`,{className:`flex items-center gap-3 md:gap-2`,children:[(0,L.jsx)(ns,{checked:i.autoPushOnValidatePass,onChange:e=>a({...i,autoPushOnValidatePass:e})}),(0,L.jsx)(`span`,{className:`text-[15px] md:text-xs text-fg`,children:`Auto-push on successful validation`})]}),(0,L.jsxs)(`label`,{className:`flex items-start gap-3 md:gap-2`,children:[(0,L.jsx)(ns,{checked:i.refineRepoAccess,onChange:e=>a({...i,refineRepoAccess:e}),className:`mt-0.5`}),(0,L.jsxs)(`span`,{className:`flex flex-col`,children:[(0,L.jsx)(`span`,{className:`text-[15px] md:text-xs text-fg`,children:`Refine repo access`}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-subtle leading-relaxed`,children:[`When on, Refine spawns Claude with `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`Read/Glob/Grep`}),` over a local clone of the primary repo (GitLab only). Off uses a lighter "file tree + attached files" prompt. `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`FORGE_REFINE_REPO_ACCESS`}),`, if set, overrides this.`]})]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Prompt rules`}),(0,L.jsx)(`textarea`,{value:i.promptRules??``,onChange:e=>a({...i,promptRules:e.target.value}),placeholder:`e.g. "Never restructure the NavBar — only add entries"`,rows:3,className:`bg-surface-raised border border-line-strong rounded px-2 py-1.5 text-xs text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 font-mono resize-y`}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle leading-relaxed`,children:`Custom instructions injected into every analysis and refine prompt, in both modes. Use this to steer the model towards your preferred patterns, or to ask for evidence (e.g. "run the e2e tests and screenshot every changed page") — that needs agentic mode.`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Test deploy URL`}),(0,L.jsx)(`input`,{type:`url`,value:i.testDeployUrlTemplate??``,onChange:e=>a({...i,testDeployUrlTemplate:e.target.value}),placeholder:`https://test.example.com or https://{slug}.test.example.com`,className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 font-mono`}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-subtle leading-relaxed`,children:[`Shown next to "Approve & Create MR" once the branch pipeline is green. Supports `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`{branch}`}),` (full branch) and`,` `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`{slug}`}),` (subdomain-safe) placeholders for ephemeral per-branch envs. Leave blank to hide the link.`]})]})]})]})}var Rs=[`gitlab`,`github`,`azuredevops`],zs=[{value:`auto`,label:`auto-detect`},{value:`node`,label:`Node (npm)`},{value:`go`,label:`Go`}];function Bs(e){let t=e.replace(/^(gitlab|github|azuredevops):/,``);return t.split(`/`).pop()??t}function Vs({repos:e,onSave:t}){let[n,r]=(0,x.useState)(e),[i,a]=(0,x.useState)(`gitlab`),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{r(e)},[e]);let g=JSON.stringify(n)!==JSON.stringify(e),_=()=>{let e=o.trim();if(!e)return;let t=e.includes(`:`)?e:`${i}:${e}`;if(n.some(e=>e.id===t)){d(`Already in list: ${t}`);return}d(null),r([...n,{id:t,label:Bs(t),projectType:`auto`}]),s(``)},v=e=>{r(n.filter(t=>t.id!==e))},y=(e,t)=>{r(n.map(n=>n.id===e?{...n,label:t}:n))},b=(e,t)=>{r(n.map(n=>n.id===e?{...n,projectType:t}:n))},S=(e,t)=>{e!==t&&r(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})};return(0,L.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Repositories`}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle mt-0.5`,children:[`Override the `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`FORGE_REPOS`}),` env var. Empty list falls back to env.`]})]}),g&&(0,L.jsx)(`button`,{onClick:async()=>{l(!0),d(null);try{await t(n)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},disabled:c,className:`bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-1.5 rounded-lg transition-colors`,children:c?`Saving…`:`Save`})]}),u&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-3 py-2 text-sm text-red-300`,children:u}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n.length===0&&(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle italic`,children:`No repos configured — using env vars.`}),n.map((e,t)=>{let n=f===t,r=m===t&&f!==null&&f!==t;return(0,L.jsxs)(`div`,{onDragOver:e=>{f!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m!==t&&h(t))},onDragLeave:()=>{m===t&&h(null)},onDrop:e=>{e.preventDefault(),f!==null&&S(f,t),p(null),h(null)},className:`flex flex-wrap md:flex-nowrap items-center gap-2 md:gap-3 bg-surface-raised border rounded-xl md:rounded-lg px-3 py-2.5 md:py-2 transition-colors ${n?`opacity-40 border-line`:`border-line`} ${r&&f>t?`!border-t-violet-500`:``} ${r&&f<t?`!border-b-violet-500`:``}`,children:[(0,L.jsx)(`span`,{draggable:!0,onDragStart:n=>{p(t),n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,e.id)},onDragEnd:()=>{p(null),h(null)},className:`hidden md:inline shrink-0 cursor-grab active:cursor-grabbing text-fg-subtle hover:text-fg-muted select-none leading-none px-1`,title:`Drag to reorder`,"aria-label":`Drag to reorder`,children:`⋮⋮`}),(0,L.jsx)(`span`,{className:`order-first md:order-none basis-[calc(100%-2.5rem)] md:basis-auto text-xs font-mono text-fg-subtle truncate md:shrink-0`,children:e.id}),(0,L.jsx)(`input`,{value:e.label,onChange:t=>y(e.id,t.target.value),className:`flex-1 min-w-0 bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`}),(0,L.jsx)(`select`,{value:e.projectType??`auto`,onChange:t=>b(e.id,t.target.value),title:`Validator toolchain — picks npm scripts or go fmt/vet/build/test`,className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:zs.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,L.jsx)(`button`,{onClick:()=>v(e.id),className:`order-first md:order-none ml-auto md:ml-0 h-8 w-8 md:h-auto md:w-auto text-xs text-fg-subtle hover:text-red-400 transition-colors`,title:`Remove`,"aria-label":`Remove ${e.id}`,children:`✕`})]},e.id)})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap md:flex-nowrap items-center gap-2 border-t border-line pt-4`,children:[(0,L.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:Rs.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))}),(0,L.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`group/repo or owner/repo`,className:`basis-full md:basis-auto order-first md:order-none flex-1 min-w-0 bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`}),(0,L.jsx)(`button`,{onClick:_,className:`bg-surface-raised ring-1 ring-inset ring-line-strong hover:bg-surface-hover border border-line-strong hover:border-line-strong text-fg text-xs px-3 py-1 rounded transition-colors`,children:`+ Add`})]})]})}var Hs=3,Us={base:`Base clone`,legacy:`Old-layout clone`,orphan:`Stray folder`};function Ws(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Gs({removed:e,skipped:t,freedBytes:n}){let r=[`Removed ${e.length}`,`freed ${Ws(n)}`];return t.length&&r.push(`${t.length} in use, kept`),r.join(` · `)}function Ks(e){return e.lastUsedAt?`used ${Zi(Date.parse(e.lastUsedAt))}`:`never used`}function qs({ws:e}){let t=e.kind===`worktree`||e.kind===`base`?e.repo:e.id;return(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:e.kind===`worktree`?(0,L.jsxs)(L.Fragment,{children:[e.issueIid!==null&&(0,L.jsxs)(`span`,{className:`shrink-0 font-medium text-fg`,children:[`#`,e.issueIid]}),(0,L.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-muted`,children:e.branch??`detached`})]}):(0,L.jsx)(`span`,{className:`font-medium text-fg`,children:Us[e.kind]})}),(0,L.jsxs)(`div`,{className:`truncate text-[11px] text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`font-mono`,children:t}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,Ws(e.sizeBytes),` · `,Ks(e)]})]})]})}function Js(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(null),m=()=>R(`/workspaces`).then(e=>t(e.workspaces)).catch(e=>r(e.message));(0,x.useEffect)(()=>{m()},[]);let h=async e=>{d(!0),r(null);try{await R(`/workspaces?id=${encodeURIComponent(e)}`,{method:`DELETE`}),p(null),await m()}catch(e){r(e.message)}finally{d(!1),a(null)}},g=async()=>{d(!0),r(null);try{p(Gs(await R(`/workspaces/purge`,{method:`POST`,body:JSON.stringify({includeBases:c})}))),await m()}catch(e){r(e.message)}finally{d(!1),s(!1)}},_=e?.reduce((e,t)=>e+t.sizeBytes,0)??0,v=e?.filter(e=>!e.inUse&&(c||e.kind!==`base`))??[],y=v.reduce((e,t)=>e+t.sizeBytes,0);return(0,L.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-x-4 gap-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workspaces`}),(0,L.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`Checkouts Forge works in, under `,(0,L.jsx)(`code`,{className:`font-mono`,children:`~/.forge/cache`}),`: one worktree per issue off a base clone per repo.`,` `,(0,L.jsxs)(`span`,{className:Gn(`tabular-nums`,!e&&`invisible`),children:[Ws(_),` total.`]})]})]}),(0,L.jsx)(`div`,{className:`flex h-7 items-center gap-2`,children:o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums`,children:[`Remove `,v.length,` (`,Ws(y),`)?`]}),(0,L.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>s(!1),children:`Cancel`}),(0,L.jsx)(z,{size:`sm`,variant:`danger`,disabled:u,onClick:g,children:`Confirm purge`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z,{size:`sm`,variant:`ghost`,disabled:u,onClick:()=>m(),children:`Refresh`}),(0,L.jsx)(z,{size:`sm`,disabled:u||!e,onClick:()=>s(!0),children:`Purge idle`})]})})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`rounded border-line-strong bg-surface-raised text-violet-600 focus:ring-violet-500`}),`Include base clones`]}),(0,L.jsx)(`p`,{"aria-live":`polite`,className:Gn(`min-h-4 text-xs`,n?`text-red-400`:`text-fg-muted`),children:n??f})]}),(0,L.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface-raised`,children:(0,L.jsx)(`table`,{"aria-label":`Workspaces`,"aria-busy":!e||void 0,className:`w-full table-fixed text-left text-sm`,children:(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[!e&&Array.from({length:Hs},(e,t)=>(0,L.jsx)(`tr`,{"aria-hidden":`true`,className:`h-14`,children:(0,L.jsx)(`td`,{colSpan:2,className:`px-4`,children:(0,L.jsx)(`div`,{className:`h-4 w-2/3 animate-pulse rounded bg-surface-hover`})})},t)),e?.map(e=>(0,L.jsxs)(`tr`,{className:`h-14`,children:[(0,L.jsx)(`td`,{className:`py-2 pl-4 pr-2`,children:(0,L.jsx)(qs,{ws:e})}),(0,L.jsx)(`td`,{className:`w-40 py-2 pl-2 pr-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[e.inUse&&(0,L.jsx)(`span`,{className:`rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] text-amber-300`,children:`In use`}),i===e.id?(0,L.jsx)(z,{size:`sm`,variant:`danger`,disabled:u,onClick:()=>h(e.id),onBlur:()=>a(null),children:`Confirm delete`}):(0,L.jsx)(z,{size:`sm`,variant:`ghost`,disabled:u||e.inUse,title:e.inUse?`A running job is using this workspace`:void 0,onClick:()=>a(e.id),children:`Delete`})]})})]},e.id)),e?.length===0&&(0,L.jsx)(`tr`,{className:`h-14`,children:(0,L.jsx)(`td`,{colSpan:2,className:`px-4 text-center text-sm text-fg-subtle`,children:`No workspaces yet. Forge creates one per issue when a job needs a checkout.`})})]})})})]})}function Ys(){let{config:e,loading:t,error:n,patch:r}=Ds(),{can:i}=Ui(),a=i(`admin`),{selectedRepo:o,availableRepos:s,selectedSecondaryRepos:c}=V(),{handleDestroyAllAnalyses:l,reloadStatus:u}=H(),[d,f]=(0,x.useState)(null),p=()=>{if(!window.confirm(`Destroy every cached analysis across every issue and repo? This cannot be undone.`))return;let e=l();f(e===0?`No cached analyses to remove.`:`Removed ${e} cached analysis entr${e===1?`y`:`ies`}.`)},m=s.find(e=>e.id===o)?.label??o,h=c.map(e=>s.find(t=>t.id===e)?.label??e);return t&&!e?(0,L.jsx)(hs,{}):n&&!e?(0,L.jsx)(`div`,{className:`max-w-3xl mx-auto w-full bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 text-sm text-red-300`,children:n}):e?(0,L.jsxs)(`div`,{className:`max-w-3xl mx-auto w-full flex flex-col gap-10`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:`Settings`}),m&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`Current repo`}),(0,L.jsx)(`span`,{className:`bg-violet-600/15 border border-violet-600/40 text-violet-200 px-2 py-0.5 rounded`,children:m}),h.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`+`}),h.map(e=>(0,L.jsx)(`span`,{className:`bg-surface-raised border border-line-strong text-fg px-2 py-0.5 rounded`,children:e},e))]})]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[`Persisted to `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`~/.forge/config.json`}),`. Env vars apply when config is empty.`]})]}),(0,L.jsx)(Os,{}),!a&&(0,L.jsx)(`p`,{className:`rounded-xl border border-line bg-surface px-4 py-3 text-sm text-fg-muted`,children:`Workspace connections, repositories and defaults are managed by admins.`}),a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Is,{connections:e.connections,onSave:e=>r({connections:e}).then(()=>void 0)}),(0,L.jsx)(Vs,{repos:e.repos,onSave:e=>r({repos:e}).then(()=>u())}),(0,L.jsx)(Ls,{defaults:e.defaults,onSave:e=>r({defaults:e}).then(()=>u())}),(0,L.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Local cache`}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[`Forge caches previous analyses in `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`localStorage`}),` so you can restore them without re-running Claude. Destroy the cache if it grows too large or if an analysis schema change has left stale entries that won't render.`]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{onClick:p,className:`text-xs text-red-300 hover:text-red-200 border border-red-900/60 hover:border-red-800 bg-red-950/30 hover:bg-red-950/50 px-3 py-1.5 rounded-lg transition-colors`,children:`Destroy all cached analyses`}),d&&(0,L.jsx)(`span`,{className:`text-xs text-fg-muted`,children:d})]})]}),(0,L.jsx)(Js,{})]})]}):null}function Xs(){let{phase:e,selectedIssue:t,currentOrdinal:n,storedAnalyses:r,selectedRepo:i,availableRepos:a}=V(),{setPhase:o,handleReset:s,handleSelectIssue:c,restoreAnalysisByOrdinal:l,setSelectedRepo:u}=H(),{setActiveDetailTab:d}=hi(),{navigate:f,pathname:p,search:m}=Ei(),h=new URLSearchParams(m).get(`repo`),g=(0,x.useRef)(!1),_=(0,x.useRef)(i);_.current=i;let v=(0,x.useRef)(i);(0,x.useEffect)(()=>{let e=v.current;v.current=i,!(!e||e===i||!g.current)&&/^\/issues\/\d+/.test(p)&&h!==i&&(s(),f(`/issues`,{replace:!0}))},[i]),(0,x.useEffect)(()=>{!t||!i||h||v.current===i&&p.startsWith(`/issues/${t.iid}`)&&f(`${p}?repo=${encodeURIComponent(i)}`,{replace:!0})},[t?.iid,i,p,h]),(0,x.useEffect)(()=>{d(p.endsWith(`/mr`)?`mr`:`issue`)},[p,d]),(0,x.useEffect)(()=>{if(!t||e===`idle`||e===`applying`)return;let r=`/issues/${t.iid}`;if(e===`reviewing`){let e=`${r}/analysis/${n??1}`;p!==e&&f(e)}else if(e===`monitoring`){let e=`${r}/mr`;p!==e&&f(e)}else p.startsWith(r)||f(r)},[e,t?.iid,n]);let y=(0,x.useRef)(t?.iid);return(0,x.useEffect)(()=>{let e=y.current;y.current=t?.iid,e!==void 0&&!t&&p.startsWith(`/issues/${e}`)&&f(`/issues`,{replace:!0})},[t?.iid]),(0,x.useEffect)(()=>{if(!t||e===`idle`)return;let i=`/issues/${t.iid}`;if(!p.startsWith(i)){s();return}let a=p.match(RegExp(`^${i}/analysis/(\\d+)$`));if(p===`${i}/review`){let e=r[0];f(e?`${i}/analysis/${e.ordinal}`:i,{replace:!0});return}if(a){let t=Number(a[1]);if(e===`reviewing`&&n===t)return;l(t)||f(i,{replace:!0})}else e===`reviewing`&&o(`selected`)},[p]),(0,x.useEffect)(()=>{if(g.current||!i)return;if(h&&h!==i){if(!a.length)return;if(a.some(e=>e.id===h)){u(h);return}}if(g.current=!0,e!==`idle`&&e!==`selected`)return;let t=p.match(/^\/issues\/(\d+)/);if(!t)return;let n=p.match(/^\/issues\/\d+\/analysis\/(\d+)$/),r=p.endsWith(`/review`),o=i;R(`/issues/${t[1]}?repo=${encodeURIComponent(o)}`).then(async({issue:e})=>{if(_.current!==o||(c(e),!n&&!r))return;let t=await xr(i,e.iid);if(n)l(Number(n[1]),e.iid)||f(`/issues/${e.iid}`,{replace:!0});else{let n=t[0];n&&l(n.ordinal,e.iid)?f(`/issues/${e.iid}/analysis/${n.ordinal}`,{replace:!0}):f(`/issues/${e.iid}`,{replace:!0})}}).catch(()=>f(`/issues`,{replace:!0}))},[e,i,a.length]),null}function Zs({open:e,onClose:t,title:n,leading:r,trailing:i,closeLabel:a=`Cancel`,children:o}){return po(e,t),e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end md:items-start justify-center bg-black/50 backdrop-blur-sm md:pt-24 md:px-4 animate-[forge-fade_200ms_ease-out]`,onClick:t,children:(0,L.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":n,onClick:e=>e.stopPropagation(),className:`w-full md:max-w-xl max-h-[92dvh] flex flex-col bg-surface-raised border-t md:border border-line md:border-line-strong rounded-t-[14px] md:rounded-xl shadow-2xl animate-[forge-sheet-up_320ms_cubic-bezier(0.32,0.72,0,1)] md:animate-none`,children:[(0,L.jsx)(`div`,{className:`md:hidden flex justify-center pt-2`,children:(0,L.jsx)(`span`,{className:`w-9 h-[5px] rounded-full bg-line-strong`})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-2 px-4 md:px-5 h-12 md:h-auto md:pt-4 md:pb-1 shrink-0`,children:[(0,L.jsx)(`div`,{className:`justify-self-start`,children:r??(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`text-[17px] md:text-sm text-accent-fg md:text-fg-muted hover:text-accent-hover md:hover:text-fg -ml-1 px-1 py-2 md:py-0`,children:a})}),(0,L.jsx)(`h2`,{className:`text-[17px] md:text-sm font-semibold text-fg truncate`,children:n}),(0,L.jsx)(`div`,{className:`justify-self-end`,children:i})]}),(0,L.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-4 md:px-5 pt-2 pb-[max(1.25rem,env(safe-area-inset-bottom))]`,children:o})]})}):null}var Qs=`forge-new-task`;function $s(){let{taskModalOpen:e,setTaskModalOpen:t}=hi(),{handleCreateIssue:n,handleSelectIssue:r}=H(),{navigate:i}=Ei(),{selectedRepo:a}=V(),o=Ma(a),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(``),[d,f]=(0,x.useState)([]),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{e||(c(``),u(``),f([]),g(null),m(!1))},[e]);let _=()=>t(!1);return(0,L.jsx)(Zs,{open:e,onClose:_,title:`New Task`,trailing:(0,L.jsx)(`button`,{type:`submit`,form:Qs,disabled:!(!p&&s.trim()),className:`text-[17px] md:text-xs font-semibold md:font-medium text-accent-fg md:text-on-accent md:bg-violet-600 md:hover:bg-violet-500 disabled:opacity-40 disabled:cursor-not-allowed md:px-4 md:py-1.5 md:rounded px-1 py-2 transition-colors`,children:p?`Creating…`:`Create task`}),children:(0,L.jsxs)(`form`,{id:Qs,onSubmit:async e=>{if(e.preventDefault(),s.trim()){m(!0),g(null);try{let e=await n(s.trim(),l.trim(),d);r(e),i(`/issues/${e.iid}`,{replace:!1}),_()}catch(e){g(e.message),m(!1)}}},className:`flex flex-col gap-3`,children:[(0,L.jsx)(`input`,{type:`text`,placeholder:`Task title`,value:s,onChange:e=>c(e.target.value),autoFocus:!0,enterKeyHint:`next`,className:`w-full bg-surface-raised border border-line-strong rounded-[10px] md:rounded px-3 py-2.5 md:py-2 text-[17px] md:text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:border-violet-500`}),(0,L.jsx)(`textarea`,{placeholder:`Describe what you want done. The more detail, the better the analysis.`,value:l,onChange:e=>u(e.target.value),rows:6,className:`w-full bg-surface-raised border border-line-strong rounded-[10px] md:rounded px-3 py-2.5 md:py-2 text-[17px] md:text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:border-violet-500 resize-y`}),(0,L.jsx)(Wa,{labels:d,available:o,onChange:f}),h&&(0,L.jsx)(`p`,{className:`text-[13px] md:text-xs text-red-400`,children:h}),(0,L.jsx)(`p`,{className:`text-[13px] md:text-[11px] text-fg-subtle`,children:`Creates an issue in the selected repo and opens it — then choose “Begin Analysis”.`})]})})}function ec({children:e}){return(0,L.jsx)(`kbd`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded border border-line bg-surface px-1 font-sans text-[10px] font-medium text-fg-subtle`,children:e})}function tc({commands:e,query:t}){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return e;let r=[];return e.forEach((e,t)=>{let i=e.hint?.toLowerCase()??``,a=[e.label,i,...e.keywords??[]].join(` `).toLowerCase(),o=0;for(let t of n)if(t.startsWith(`#`))if(i===t)o+=3;else if(i.startsWith(t))o+=1;else return;else if(e.label.toLowerCase().startsWith(t))o+=2;else if(a.includes(t))o+=1;else return;r.push({command:e,score:o,index:t})}),r.sort((e,t)=>t.score-e.score||e.index-t.index).map(e=>e.command)}function nc({open:e,commands:t,onClose:n}){return e?(0,L.jsx)(rc,{commands:t,onClose:n}):null}function rc({commands:e,onClose:t}){let[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(0),o=(0,x.useId)(),s=(0,x.useRef)(null),c=tc({commands:e,query:n}),l=c[Math.min(i,c.length-1)];(0,x.useEffect)(()=>{s.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[i,n]);let u=e=>{e&&(t(),e.run())},d=e=>{e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,c.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Enter`?(e.preventDefault(),u(l)):e.key===`Escape`&&(e.preventDefault(),t())},f=``;return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center px-4 pt-[12vh]`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-[2px] animate-fade-in`,onClick:t,"aria-hidden":!0}),(0,L.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`relative w-full max-w-xl overflow-hidden rounded-xl bg-surface-raised shadow-overlay animate-pop-in`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-line px-4`,children:[(0,L.jsx)(B,{name:`search`,className:`text-fg-subtle shrink-0`}),(0,L.jsx)(`input`,{ref:e=>e?.focus(),role:`combobox`,"aria-expanded":`true`,"aria-controls":o,"aria-activedescendant":l?`${o}-${l.id}`:void 0,"aria-autocomplete":`list`,value:n,onChange:e=>{r(e.target.value),a(0)},onKeyDown:d,placeholder:`Search issues, pages and actions…`,className:`h-12 flex-1 bg-transparent text-sm text-fg placeholder:text-fg-subtle focus:outline-none`}),(0,L.jsx)(ec,{children:`Esc`})]}),(0,L.jsxs)(`div`,{ref:s,id:o,role:`listbox`,"aria-label":`Results`,className:`max-h-[50vh] overflow-y-auto p-1.5`,children:[c.length===0&&(0,L.jsxs)(`p`,{className:`px-3 py-10 text-center text-sm text-fg-subtle`,children:[`No results for “`,n,`”`]}),c.map((e,t)=>{let n=e.group!==f;f=e.group;let r=e===l;return(0,L.jsxs)(`div`,{children:[n&&(0,L.jsx)(`div`,{className:`px-3 pb-1 pt-2.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:e.group}),(0,L.jsxs)(`div`,{id:`${o}-${e.id}`,role:`option`,"aria-selected":r,onMouseMove:()=>a(t),onClick:()=>u(e),className:Gn(`flex cursor-pointer items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm`,r?`bg-surface-hover text-fg`:`text-fg-muted`),children:[(0,L.jsx)(`span`,{className:`truncate`,children:e.label}),e.hint&&(0,L.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-fg-subtle`,children:e.hint})]})]},e.id)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 border-t border-line px-4 py-2 text-[11px] text-fg-subtle`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(ec,{children:`↑`}),(0,L.jsx)(ec,{children:`↓`}),` navigate`]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(ec,{children:`↵`}),` open`]})]})]})]})}function ic({open:e,onOpenChange:t}){let{issues:n,phase:r,openMRs:i,openMRsLoading:a}=V(),{handleSelectIssue:o,handleReset:s,loadIssues:c,loadOpenMRs:l}=H(),{setTaskModalOpen:u}=hi(),{navigate:d}=Ei(),{setPreference:f}=ir(),{can:p,signOut:m}=Ui(),h=Ai();(0,x.useEffect)(()=>{let n=n=>{(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===`k`&&(n.preventDefault(),t(!e))};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let g=(e,t)=>{r!==`idle`&&s(),d(e,{replace:!0}),t&&i.length===0&&!a&&l()};return(0,L.jsx)(nc,{open:e,commands:[...h.map(e=>({id:`go-${e.path.slice(1)}`,group:`Navigate`,label:`Go to ${e.label}`,keywords:[...e.keywords],run:()=>g(e.path,e.preloadMRs)})),...p(`operator`)?[{id:`new-task`,group:`Actions`,label:`New task`,keywords:[`create`],run:()=>u(!0)}]:[],{id:`refresh`,group:`Actions`,label:`Refresh issues and merge requests`,keywords:[`reload`],run:()=>{c(),l()}},{id:`theme-light`,group:`Actions`,label:`Switch to light theme`,keywords:[`appearance`],run:()=>f(`light`)},{id:`theme-dark`,group:`Actions`,label:`Switch to dark theme`,keywords:[`appearance`],run:()=>f(`dark`)},{id:`theme-system`,group:`Actions`,label:`Use system theme`,keywords:[`appearance`],run:()=>f(`system`)},{id:`sign-out`,group:`Actions`,label:`Sign out`,keywords:[`logout`],run:()=>void m()},...n.map(e=>({id:`issue-${e.iid}`,group:`Issues`,label:e.title,hint:`#${e.iid}`,keywords:e.labels,run:()=>{r!==`idle`&&s(),o(e)}}))],onClose:()=>t(!1)})}function ac(){let e=U().filter(e=>!e.adminOnly);return(0,L.jsx)(`nav`,{"aria-label":`Tabs`,className:`fixed inset-x-0 bottom-0 z-30 border-t border-line/70 bg-canvas/80 pb-[env(safe-area-inset-bottom)] backdrop-blur-xl backdrop-saturate-150 md:hidden`,children:(0,L.jsx)(`ul`,{className:`grid h-[50px]`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(e=>{let t=e.badgeCount!==void 0&&e.badgeCount>0;return(0,L.jsx)(`li`,{className:`flex`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:e.go,"aria-current":e.active?`page`:void 0,className:Gn(`flex flex-1 flex-col items-center justify-center gap-0.5 pt-1 transition-colors`,e.active?`text-accent-fg`:`text-fg-subtle active:text-fg-muted`),children:[(0,L.jsxs)(`span`,{className:`relative`,children:[(0,L.jsx)(B,{name:e.icon,size:24}),t&&(0,L.jsx)(`span`,{className:`absolute -right-2.5 -top-1 h-[18px] min-w-[18px] rounded-full bg-red-500 px-1 text-center text-[11px] font-semibold leading-[18px] text-on-accent tabular-nums`,children:e.badgeCount})]}),(0,L.jsx)(`span`,{className:`text-[10px] font-medium leading-none tracking-tight`,children:e.label})]})},e.path)})})})}var oc=[`/issues`,`/mrs`,`/pipelines`];function sc(e){return oc.includes(e)}var cc=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function lc({popoutUrl:e,onOpenPalette:t,onOpenNav:n}){let{phase:r,selectedIssue:i,applyResult:a}=V(),{handleReset:o,handleBackToIssue:s}=H(),{setMrMerged:c,setTaskModalOpen:l}=hi(),{navigate:u,pathname:d}=Ei(),{can:f}=Ui(),p=(0,x.useRef)(`/issues`);(0,x.useEffect)(()=>{r===`idle`&&sc(d)&&(p.current=d)},[d,r]);let m=r!==`idle`,h=a?.applications[0]?.mr,g=ki(m?p.current:d)?.label??`Issues`;return(0,L.jsxs)(`header`,{className:`box-content flex h-14 shrink-0 pt-[env(safe-area-inset-top)] items-center justify-between gap-2 border-b border-line/70 bg-canvas/80 px-3 backdrop-blur-xl sm:gap-4 sm:px-6`,children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,onClick:n,className:`-ml-1 flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg lg:hidden`,children:(0,L.jsx)(B,{name:`menu`,size:18})}),(0,L.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`mr-auto flex min-w-0 items-center gap-1 text-sm`,children:[m?(0,L.jsxs)(`button`,{onClick:()=>{c(!1),o(),u(p.current,{replace:!0})},"aria-label":`Back to ${g}`,className:`-ml-1.5 flex shrink-0 items-center rounded-lg py-1 pl-0.5 pr-2 text-accent-fg transition-colors hover:bg-surface-hover`,children:[(0,L.jsx)(B,{name:`chevronLeft`,size:18}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:g})]}):null,i&&m&&(0,L.jsxs)(`button`,{type:`button`,onClick:s,disabled:r!==`analyzing`&&r!==`reviewing`,title:r===`analyzing`||r===`reviewing`?`Back to the ticket; the analysis stays`:void 0,"aria-current":`page`,className:`min-w-0 truncate rounded-lg px-1.5 py-1 text-left font-medium text-fg enabled:hover:bg-surface-hover`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-fg-subtle`,children:[`#`,i.iid]}),` `,i.title]}),!i&&h&&m&&a&&(0,L.jsxs)(`span`,{className:`truncate px-1.5 font-medium text-fg`,"aria-current":`page`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-fg-subtle`,children:[`!`,h.iid]}),` `,h.title,a.applications.length>1&&(0,L.jsxs)(`span`,{className:`ml-2 text-xs text-accent-fg`,children:[`+`,a.applications.length-1,` more`]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[!m&&f(`operator`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(!0),"aria-label":`New task`,className:`flex size-8 items-center justify-center rounded-lg text-accent-fg transition-colors hover:bg-surface-hover md:hidden`,children:(0,L.jsx)(B,{name:`plus`,size:18})}),(0,L.jsxs)(`button`,{type:`button`,onClick:t,"aria-label":`Search or jump to`,className:`flex h-8 w-8 items-center justify-center gap-2 rounded-lg sm:w-64 sm:justify-start border border-line bg-surface px-2.5 text-xs text-fg-subtle transition-colors hover:border-line-strong hover:text-fg-muted`,children:[(0,L.jsx)(B,{name:`search`,size:14}),(0,L.jsx)(`span`,{className:`hidden flex-1 text-left sm:inline`,children:`Search or jump to…`}),(0,L.jsxs)(`span`,{className:`hidden items-center gap-1 sm:flex`,children:[(0,L.jsx)(ec,{children:cc?`⌘`:`Ctrl`}),(0,L.jsx)(ec,{children:`K`})]})]}),e&&(0,L.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`flex size-8 items-center justify-center rounded-lg text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,title:`Open in new tab`,"aria-label":`Open in new tab`,children:(0,L.jsx)(B,{name:`external`,size:14})})]})]})}function uc({popoutUrl:e,children:t}){let{phase:n}=V(),[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(!1),{pathname:s}=Ei();(0,x.useEffect)(()=>o(!1),[s]);let c=n===`idle`;return(0,L.jsxs)(`div`,{className:`flex h-[100dvh] bg-canvas text-fg`,children:[(0,L.jsx)(Ni,{open:a,onClose:()=>o(!1)}),(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(lc,{popoutUrl:e,onOpenPalette:()=>i(!0),onOpenNav:()=>o(!0)}),(0,L.jsx)(`main`,{className:Gn(`min-h-0 w-full flex-1 overflow-y-auto overscroll-contain px-4 pt-6 sm:px-6 sm:pt-8 md:pb-8 lg:px-10`,c?`pb-[calc(50px+env(safe-area-inset-bottom)+1.5rem)]`:`pb-[max(1.5rem,env(safe-area-inset-bottom))]`),children:t})]}),c&&(0,L.jsx)(ac,{}),(0,L.jsx)($s,{}),(0,L.jsx)(ic,{open:r,onOpenChange:i})]})}function dc({popoutUrl:e,basePath:t}={}){return(0,L.jsx)(Ti,{basePath:t,children:(0,L.jsxs)(pi,{children:[(0,L.jsx)(Xs,{}),(0,L.jsx)(fc,{popoutUrl:e})]})})}function fc({popoutUrl:e}){let{backendError:t,backendRetrying:n}=V(),{retryBackend:r}=H();return t?(0,L.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-canvas px-4`,children:(0,L.jsxs)(`div`,{className:`max-w-md w-full bg-red-950/40 border border-red-800 rounded-lg p-6 text-center`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium text-red-200 mb-2`,children:`Forge backend unreachable`}),(0,L.jsx)(`p`,{className:`text-sm text-red-300/80 mb-4 break-words`,children:t}),(0,L.jsx)(`button`,{onClick:r,disabled:n,className:`bg-red-800 hover:bg-red-700 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-2 rounded-lg transition-colors`,children:n?`Retrying…`:`Retry`})]})}):(0,L.jsx)(uc,{popoutUrl:e,children:(0,L.jsx)(pc,{})})}function pc(){let{phase:e}=V(),{pathname:t}=Ei();if(e===`idle`){if(t.startsWith(`/settings`))return(0,L.jsx)(Ys,{});if(t.startsWith(`/members`))return(0,L.jsx)(oa,{});if(t.startsWith(`/audit`))return(0,L.jsx)(na,{})}switch(e){case`idle`:return(0,L.jsx)(lo,{});case`selected`:return(0,L.jsx)(Es,{});case`analyzing`:return(0,L.jsx)(ya,{});case`reviewing`:case`applying`:return(0,L.jsx)(ps,{});case`monitoring`:return(0,L.jsx)(qo,{});default:return null}}(0,zn.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(x.StrictMode,{children:(0,L.jsx)(Bn,{children:(0,L.jsx)(rr,{children:(0,L.jsx)(gn,{children:(0,L.jsx)(`div`,{className:`min-h-screen bg-canvas`,children:(0,L.jsx)(Hi,{children:(0,L.jsx)(dc,{})})})})})})}));
27
+ `).map(e=>({ts:``,message:e}))}function ps(){let{analysisLogs:e,analysisResult:t,analysisError:n,applyResult:r,applyError:i,applying:a,refining:o,validation:s,validating:c,validationError:l,autoPushOnValidatePass:u,availableRepos:d,refineThread:f,refineQueue:p,thinkingLogs:m}=V(),{handleApprove:h,handleDeployBranch:g,handleCommitToBranch:_,handleRefine:v,handleUndoRefine:y,handleValidate:b,handleFixValidation:S,setAutoPushOnValidatePass:C}=H(),[w,T]=(0,x.useState)(null);(0,x.useEffect)(()=>{o||T(null)},[o]);let E=(e,t)=>{T(e),S(e,t)},ee=c?`running`:s.stale||!s.result?`idle`:s.result.allPassed?`passed`:`failed`;return(0,L.jsxs)(`div`,{className:`max-w-3xl mx-auto w-full flex flex-col gap-6`,children:[n&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 text-sm text-red-300 whitespace-pre-wrap break-words [overflow-wrap:anywhere] max-h-48 overflow-y-auto font-mono leading-snug`,children:n}),i&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 text-sm text-red-300 whitespace-pre-wrap break-words [overflow-wrap:anywhere] max-h-48 overflow-y-auto font-mono leading-snug`,children:i}),e.length>0&&(0,L.jsxs)(`details`,{className:`group order-last`,children:[(0,L.jsxs)(`summary`,{className:`cursor-pointer text-xs text-fg-subtle hover:text-fg transition-colors select-none list-none flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`group-open:rotate-90 transition-transform inline-block`,children:`›`}),`Analysis log (`,e.length,` lines)`]}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(ma,{entries:e,label:`forge analysis`,badge:`${e.length} entr${e.length===1?`y`:`ies`}`,heightClass:`max-h-56`})})]}),t?(0,L.jsx)(ts,{explanation:t.explanation,changes:t.changes,removals:t.removals,existingApplications:r?.applications??[],availableRepos:d,onApprove:h,onDeployBranch:g,onCommitToBranch:_,checks:(0,L.jsx)(ds,{state:s,validating:c,error:l,onValidate:b,onFixStep:E,fixingStep:w,autoPushOnPass:u,onToggleAutoPush:C}),onRefine:v,onUndoRefine:y,refineThread:f,refineQueue:p,thinkingLogs:m,applying:a,refining:o,validationStatus:ee}):(0,L.jsx)(`div`,{className:`text-center py-12 text-fg-subtle text-sm`,children:`No changes were proposed.`})]})}function ms({className:e}){return(0,L.jsx)(`div`,{className:Gn(`animate-pulse rounded bg-surface-hover`,e)})}function hs(){return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-10`,role:`status`,"aria-label":`Loading settings`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(ms,{className:`h-6 w-28`}),(0,L.jsx)(ms,{className:`h-3 w-2/3`})]}),[0,1,2].map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(ms,{className:`h-4 w-32`}),(0,L.jsx)(ms,{className:`h-3 w-1/2`}),(0,L.jsx)(ms,{className:`h-28 w-full rounded-xl`})]},e))]})}function gs(){return(0,L.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-4`,role:`status`,"aria-label":`Loading issue`,children:[(0,L.jsx)(ms,{className:`h-7 w-2/3`}),(0,L.jsx)(ms,{className:`h-3 w-1/3`}),(0,L.jsx)(ms,{className:`h-8 w-40 rounded-lg`}),(0,L.jsx)(ms,{className:`h-24 w-full rounded-xl`}),(0,L.jsx)(ms,{className:`h-24 w-full rounded-xl`})]})}var _s=`h-9 w-full rounded-lg border border-line bg-surface px-2.5 text-sm text-fg focus:border-accent-hover focus:outline-none sm:w-auto`;function vs(){let{availableRepos:e,selectedRepo:t,selectedSecondaryRepos:n,availableAgents:r,selectedAgent:i,availableModels:a,selectedModel:o}=V(),{setSelectedSecondaryRepos:s,setSelectedAgent:c,setSelectedModel:l}=H(),u=e.filter(e=>e.id!==t),d=i!==`openclaw`&&a.length>0,f=u.filter(e=>n.includes(e.id)),p=[d?a.find(e=>e.id===o)?.label:r.find(e=>e.id===i)?.label,f.length?`+ ${f.map(e=>e.label).join(`, `)}`:null].filter(Boolean).join(` · `);if(!d&&r.length<2&&u.length===0)return null;let m=e=>s(n.includes(e)?n.filter(t=>t!==e):[...n,e]);return(0,L.jsxs)(`details`,{className:`group text-sm`,children:[(0,L.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 text-fg-muted select-none hover:text-fg`,children:[(0,L.jsx)(`span`,{className:`inline-block transition-transform group-open:rotate-90`,children:`›`}),`Options`,p&&(0,L.jsxs)(`span`,{className:`truncate text-fg-subtle`,children:[`· `,p]})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 rounded-xl bg-surface-raised p-4 sm:flex-row sm:flex-wrap sm:items-end sm:gap-5`,children:[r.length>1&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs text-fg-subtle`,children:[`Agent`,(0,L.jsx)(`select`,{"aria-label":`Agent`,value:i,onChange:e=>c(e.target.value),className:_s,children:r.map(e=>(0,L.jsxs)(`option`,{value:e.id,disabled:!e.configured,children:[e.label,e.configured?``:` (not configured)`]},e.id))})]}),d&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-xs text-fg-subtle`,children:[`Model`,(0,L.jsx)(`select`,{"aria-label":`Model`,value:o,onChange:e=>l(e.target.value),className:_s,children:a.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),u.length>0&&(0,L.jsxs)(`fieldset`,{className:`flex flex-col gap-1.5 text-xs text-fg-subtle`,children:[(0,L.jsx)(`legend`,{className:`mb-1.5`,children:`Also change`}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:u.map(e=>{let t=n.includes(e.id);return(0,L.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>m(e.id),className:`h-9 rounded-full px-3.5 text-sm transition-colors ${t?`bg-accent-soft text-accent-fg`:`bg-surface text-fg-muted ring-1 ring-inset ring-line hover:text-fg`}`,children:e.label},e.id)})})]})]})]})}function ys(){let{applyResult:e}=V(),{handleRefinePipelineFailure:t}=H(),n=e?.applications.filter(e=>!e.mr)??[];return n.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`text-[15px] font-semibold text-fg`,children:`Activity`}),(0,L.jsx)(`span`,{className:`text-[10px] text-fg-subtle`,children:`Deploy-to-Test · no MR yet`})]}),n.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 bg-surface-raised/50 border border-line-strong rounded-lg p-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:`Branch`}),(0,L.jsxs)(`span`,{className:`text-sm font-mono text-violet-300 truncate`,title:e.branchName,children:[`⎇ `,e.branchName]})]}),e.pipelineUrl&&(0,L.jsx)(`a`,{href:e.pipelineUrl,target:`_blank`,rel:`noreferrer`,className:`text-xs text-violet-400 hover:underline shrink-0`,children:`Open in GitLab ↗`})]}),(0,L.jsx)(zo,{endpoint:`branch-pipeline?branch=${encodeURIComponent(e.branchName)}`,repo:e.repo,onRefinePipelineFailure:t})]},`${e.repo}:${e.branchName}`))]})}function bs(){let{storedAnalyses:e}=V(),{handleRestoreAnalysis:t,handleDiscardStoredAnalysis:n,handleClearIssueCache:r,formatAnalysisDate:i}=H();return e.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-muted font-medium`,children:[`Previous analyses (`,e.length,`)`]}),(0,L.jsx)(`button`,{onClick:()=>{window.confirm(`Delete all ${e.length} analyses for this issue? They're removed for everyone and can't be restored.`)&&r()},className:`text-xs text-fg-subtle hover:text-red-300 transition-colors`,title:`Delete every analysis for this issue`,children:`Clear all`})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`bg-surface-raised/60 border border-line-strong rounded-lg px-4 py-2.5 flex items-start justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-subtle min-w-0`,children:[(0,L.jsx)(`span`,{children:i(e.analyzedAt)}),(0,L.jsx)(`span`,{children:`·`}),(0,L.jsxs)(`span`,{children:[e.result.changes.length,` file`,e.result.changes.length===1?``:`s`]}),e.model&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`·`}),(0,L.jsx)(`span`,{className:`truncate`,children:e.model.split(`-`).slice(1,3).join(` `)})]}),(0,L.jsx)(`span`,{children:`·`}),e.mrIid?(0,L.jsxs)(`span`,{className:`text-violet-400`,children:[`MR !`,e.mrIid]}):(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`no MR`})]}),e.prompt&&(0,L.jsxs)(`div`,{className:`text-xs text-fg-muted italic truncate`,title:e.prompt,children:[`“`,e.prompt,`”`]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,L.jsx)(`button`,{onClick:()=>t(e.id),className:`bg-violet-600 hover:bg-violet-500 text-on-accent text-xs font-medium px-3 py-1 rounded transition-colors`,children:`Restore`}),(0,L.jsx)(`button`,{onClick:()=>n(e.id),className:`text-xs text-fg-subtle hover:text-fg-muted transition-colors`,title:`Discard`,children:`✕`})]})]},e.id))})]})}var xs={updateMr:`Analyze & Update MR`,newAnalysis:`New Analysis`,tryAgain:`Try Again`,begin:`Begin Analysis`};function Ss({editing:e,editDescription:t,setEditDescription:n,editLabels:r,setEditLabels:i,availableLabels:a,saving:o,onSave:s,onCancelEdit:c,editTitle:l}){let{selectedIssue:u,analysisPrompt:d,existingMr:f,existingMrLoading:p,storedAnalyses:m,mergedMrs:h,resolutionCheck:g,issueEnvironmentsLoading:_}=V(),{setAnalysisPrompt:v,handleBeginAnalysis:y,handleFreshReanalyze:b}=H();if(!u)return null;let x=h.length>0&&!f&&!p,S=p?null:f?xs.updateMr:m.length>0?xs.newAnalysis:h.length>0&&g&&!g.resolved?xs.tryAgain:xs.begin,C=!p&&!_;return(0,L.jsxs)(L.Fragment,{children:[e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`textarea`,{"aria-label":`Description`,value:t,onChange:e=>n(e.target.value),rows:8,className:`bg-surface-raised border border-line-strong focus:border-violet-500 rounded-lg px-4 py-3 text-sm text-fg outline-none w-full resize-y leading-relaxed`}),(0,L.jsx)(Wa,{labels:r,available:a,onChange:i})]}):u.description&&(0,L.jsx)(`div`,{className:`bg-surface-raised border border-line-strong rounded-lg px-4 py-4 text-sm text-fg whitespace-pre-wrap leading-relaxed w-full max-h-[50vh] overflow-y-auto`,children:u.description}),!e&&(0,L.jsx)(bs,{}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!e&&(0,L.jsx)(`textarea`,{value:d,onChange:e=>v(e.target.value),placeholder:`Optional instructions for the analysis…`,rows:2,className:`w-full bg-surface-raised/60 border border-line-strong rounded-lg px-3 py-2 text-sm text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 resize-none`}),!e&&(0,L.jsx)(vs,{}),e?(0,L.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center gap-1 md:gap-3`,children:[(0,L.jsx)(`button`,{onClick:s,disabled:o||!l.trim(),className:`${Jo} bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent px-5 py-2 transition-colors ${p?`animate-pulse`:``}`,children:o?`Saving…`:`Save`}),(0,L.jsx)(`button`,{onClick:c,className:`min-h-11 md:min-h-0 text-[17px] md:text-sm text-fg-subtle hover:text-fg transition-colors`,children:`Cancel`})]}):(0,L.jsx)(`div`,{className:`flex flex-col md:flex-row md:flex-wrap md:items-center justify-between gap-3 md:gap-x-6 md:gap-y-3 border-t border-line/60 pt-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center gap-1 md:gap-3`,children:[(0,L.jsx)(`button`,{onClick:y,disabled:p,className:`grid ${Jo} bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent px-5 py-2 transition-colors ${p?`animate-pulse`:``}`,children:Object.values(xs).map(e=>(0,L.jsx)(`span`,{"aria-hidden":e!==S||void 0,className:`[grid-area:1/1] ${e===S?``:`invisible`}`,children:e},e))}),m.length>0&&(0,L.jsx)(`button`,{onClick:b,className:`min-h-11 md:min-h-0 text-[17px] md:text-sm text-amber-400/90 md:text-fg-muted hover:text-amber-400 transition-colors`,children:`Discard & Reanalyze`})]})})]}),!e&&(0,L.jsxs)(To,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(Do,{ready:C}),x&&(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,L.jsx)(Wo,{})}),(0,L.jsx)(uo,{}),(0,L.jsx)(ys,{}),(0,L.jsx)(So,{mrs:h})]},u.iid)]})}function Cs(){return(0,L.jsxs)(`div`,{"aria-hidden":`true`,className:`flex flex-col gap-3 animate-pulse`,children:[(0,L.jsx)(`div`,{className:`h-20 bg-surface-raised border border-line-strong rounded-lg`}),(0,L.jsx)(`div`,{className:`h-32 bg-surface-raised border border-line-strong rounded-lg`})]})}function ws(){let{existingMr:e,existingMrLoading:t,applyResult:n,selectedRepo:r,applying:i,applyError:a,testDeployUrlTemplate:o}=V(),{handleRefinePipelineFailure:s,handlePromoteBranch:c}=H(),{setMrMerged:l}=hi(),[u,d]=(0,x.useState)({}),[f,p]=(0,x.useState)(null);if(t)return(0,L.jsx)(Cs,{});if(e)return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-raised border border-line-strong rounded-lg px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:`Merge request`}),(0,L.jsxs)(`a`,{href:e.web_url,target:`_blank`,rel:`noreferrer`,className:`text-sm text-violet-400 hover:underline`,children:[`!`,e.iid,` `,e.title]}),(0,L.jsx)(`span`,{className:`text-xs font-mono text-fg-subtle`,children:e.branchName})]}),(0,L.jsx)(Ho,{mrIid:e.iid,repo:r||void 0})]}),(0,L.jsxs)(To,{placeholder:(0,L.jsx)(Cs,{}),className:`flex flex-col gap-6`,children:[(0,L.jsx)(Mo,{mrIid:e.iid,repo:r||void 0,pipelineStatus:f,onMerged:()=>l(!0)}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-semibold text-fg`,children:`Pipeline`}),(0,L.jsx)(zo,{endpoint:`mr/${e.iid}/pipeline`,repo:r||void 0,onRefinePipelineFailure:s,onStatusChange:p})]})]},e.iid)]});let m=n?.applications.filter(e=>!e.mr)??[];return m.length>0?(0,L.jsx)(To,{placeholder:(0,L.jsx)(Cs,{}),className:`flex flex-col gap-6`,children:m.map(e=>{let t=`${e.repo}:${e.branchName}`,n=u[t]===`success`,r=n?Uo(o,e.branchName):null;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`div`,{className:`bg-surface-raised border border-line-strong rounded-lg px-4 py-4 flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:`Test deploy — branch only, no MR`}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-muted mt-0.5 truncate`,children:[`Branch: `,(0,L.jsx)(`span`,{className:`font-mono`,children:e.branchName})]})]}),(0,L.jsx)(Ho,{branchName:e.branchName,repo:e.repo,fallbackUrl:r}),n&&(0,L.jsx)(`button`,{onClick:()=>c(e),disabled:i,className:`shrink-0 ml-4 bg-violet-600 hover:bg-violet-500 disabled:opacity-40 disabled:cursor-not-allowed text-on-accent text-sm font-medium px-4 py-2 rounded-lg transition-colors`,title:`Pipeline is green — promote this branch to a merge request`,children:i?`Creating MR…`:`Approve & Create MR`})]}),a&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-4 py-2 text-xs text-red-300`,children:a}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-semibold text-fg`,children:`Test deploy pipeline`}),(0,L.jsx)(zo,{endpoint:`branch-pipeline?branch=${encodeURIComponent(e.branchName)}`,repo:e.repo,onRefinePipelineFailure:s,onStatusChange:e=>d(n=>({...n,[t]:e??``}))})]})]},t)})}):(0,L.jsx)(`div`,{className:`text-center py-12 text-fg-subtle text-sm`,children:`No open MR found for this issue.`})}function Ts({editing:e,editTitle:t,setEditTitle:n,onStartEdit:r}){let{selectedIssue:i}=V();if(!i)return null;let a=Ia(i.labels),o=/^(type|priority|area)::/,s=i.labels.find(e=>e.startsWith(`status::`))?.slice(8),c=i.labels.filter(e=>!o.test(e)&&!e.startsWith(`status::`));return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[e?(0,L.jsx)(`input`,{"aria-label":`Title`,value:t,onChange:e=>n(e.target.value),className:`w-full rounded-lg border border-line-strong bg-surface-raised px-3 py-1.5 text-xl font-semibold text-fg outline-none focus:border-violet-500`}):(0,L.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg sm:text-2xl`,children:i.title}),!e&&(0,L.jsx)(vo,{onEdit:r})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1.5 text-sm text-fg-subtle`,children:[(0,L.jsxs)(`span`,{children:[`#`,i.iid]}),a.type&&(0,L.jsx)(Gi,{tone:Qa[a.type]??`neutral`,children:eo(a.type)}),a.priority&&(0,L.jsx)(Gi,{tone:$a[a.priority]??`neutral`,dot:!0,children:eo(a.priority)}),s&&(0,L.jsx)(Gi,{tone:`neutral`,children:eo(s.replace(/-/g,` `))}),[...a.areas,...c].map(e=>(0,L.jsx)(`span`,{className:`rounded-full bg-surface-raised px-2 py-0.5 text-xs text-fg-muted`,children:e},e))]}),(0,L.jsxs)(`p`,{className:`text-[13px] text-fg-subtle`,children:[`Opened by `,i.author.name,` ·`,` `,(0,L.jsx)(`a`,{href:i.web_url,target:`_blank`,rel:`noreferrer`,className:`hover:text-fg`,children:`View on GitLab ↗`})]})]})}function Es(){let{selectedIssue:e,existingMr:t,existingMrLoading:n,applyResult:r,selectedRepo:i}=V(),{handleUpdateIssue:a}=H(),{activeDetailTab:o,setActiveDetailTab:s}=hi(),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(``),[f,p]=(0,x.useState)(``),[m,h]=(0,x.useState)([]),g=Ma(i),[_,v]=(0,x.useState)(!1),{navigate:y}=Ei();if(!e)return(0,L.jsx)(gs,{});let b=()=>{d(e.title??``),p(e.description??``),h(e.labels),l(!0)},S=()=>l(!1),C=async()=>{v(!0);try{await a(u,f,m),l(!1)}finally{v(!1)}},w=t=>{let n=t===`mr`?`mr`:`issue`;s(n),y(n===`mr`?`/issues/${e.iid}/mr`:`/issues/${e.iid}`,{replace:!0})},T=(r?.applications??[]).filter(e=>!e.mr).length,E=t?`MR`:T>0?`Branch`:`MR`,ee=t?(0,L.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${o===`mr`?`bg-surface-raised text-fg`:`bg-violet-600/40 text-violet-300`}`,children:[`!`,t.iid]}):T>0?(0,L.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${o===`mr`?`bg-surface-raised text-fg`:`bg-amber-600/40 text-amber-300`}`,title:`${T} deploy-to-test branch${T>1?`es`:``} without an MR`,children:T}):(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`—`});return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6 w-full`,children:[(0,L.jsx)(Ts,{editing:c,editTitle:u,setEditTitle:d,onStartEdit:b}),(0,L.jsx)(Ko,{tabs:[{id:`issue`,label:`Issue`},{id:`mr`,label:E,loading:n,badge:n?void 0:ee}],active:o,onSelect:w}),o===`issue`&&(0,L.jsx)(Ss,{editing:c,editDescription:f,setEditDescription:p,editLabels:m,setEditLabels:h,availableLabels:g,saving:_,onSave:C,onCancelEdit:S,editTitle:u}),o===`mr`&&(0,L.jsx)(ws,{})]})}function Ds(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(null),o=(0,x.useCallback)(async()=>{r(!0),a(null);try{t(await R(`/config`))}catch(e){a(e instanceof Error?e.message:String(e))}finally{r(!1)}},[]),s=(0,x.useCallback)(async e=>{let n=await R(`/config`,{method:`PUT`,body:JSON.stringify(e)});return t(n),n},[]);return(0,x.useEffect)(()=>{o()},[o]),{config:e,loading:n,error:i,reload:o,patch:s}}function Os(){let[e,t]=(0,x.useState)([]),[n,r]=(0,x.useState)(!1),[i,a]=(0,x.useState)(``),[o,s]=(0,x.useState)(null),[c,l]=(0,x.useState)(null);(0,x.useEffect)(()=>{Yi.listTokens().then(e=>t(e.tokens)).catch(e=>l(e.message))},[]);let u=async e=>{e.preventDefault(),l(null);try{let{token:e,record:n}=await Yi.createToken(i);t(e=>[n,...e]),s(e),r(!1),a(``)}catch(e){l(e.message)}},d=async e=>{await Yi.revokeToken(e),t(t=>t.filter(t=>t.id!==e))};return(0,L.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-end justify-between gap-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`API tokens`}),(0,L.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`Personal tokens for the `,(0,L.jsx)(`code`,{className:`font-mono`,children:`forge`}),` CLI and automation. They act with your role.`]})]}),!n&&(0,L.jsx)(z,{size:`sm`,onClick:()=>r(!0),children:`New token`})]}),o&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-emerald-800/60 bg-emerald-950/40 p-4`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-emerald-300`,children:`Copy this token now. You won't see it again.`}),(0,L.jsx)(`code`,{className:`break-all rounded-lg bg-canvas px-3 py-2 font-mono text-xs text-fg ring-1 ring-line`,children:o}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Use it as `,(0,L.jsx)(`code`,{className:`font-mono`,children:`FORGE_API_TOKEN`}),` in the CLI's environment.`]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(z,{size:`sm`,variant:`secondary`,onClick:()=>navigator.clipboard?.writeText(o),children:`Copy`}),(0,L.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>s(null),children:`Done`})]})]}),n&&(0,L.jsxs)(`form`,{onSubmit:u,className:`flex items-end gap-2 rounded-xl border border-line bg-surface-raised p-4`,children:[(0,L.jsxs)(`label`,{className:`flex flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[`Token name`,(0,L.jsx)(`input`,{required:!0,placeholder:`e.g. laptop CLI`,value:i,onChange:e=>a(e.target.value),className:`h-9 rounded-lg border border-line bg-canvas px-3 text-sm text-fg placeholder:text-fg-subtle focus:border-accent-hover focus:outline-none`})]}),(0,L.jsx)(z,{variant:`ghost`,size:`md`,onClick:()=>r(!1),children:`Cancel`}),(0,L.jsx)(z,{type:`submit`,variant:`primary`,size:`md`,children:`Create token`})]}),c&&(0,L.jsx)(`p`,{className:`text-xs text-red-400`,children:c}),(0,L.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface-raised`,children:(0,L.jsx)(`table`,{"aria-label":`API tokens`,className:`w-full text-left text-sm`,children:(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsxs)(`td`,{className:`py-3 pl-4 pr-3`,children:[(0,L.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,L.jsxs)(`div`,{className:`font-mono text-xs text-fg-subtle`,children:[e.prefix,`…`]})]}),(0,L.jsxs)(`td`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`Created `,Zi(e.createdAt)]}),(0,L.jsxs)(`td`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[`Last used `,Zi(e.lastUsedAt)]}),(0,L.jsx)(`td`,{className:`py-3 pl-3 pr-4 text-right`,children:(0,L.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>d(e.id),children:`Revoke`})})]},e.id)),e.length===0&&(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{className:`px-4 py-6 text-center text-sm text-fg-subtle`,children:`No tokens yet.`})})]})})})]})}function ks({mode:e,activeMembers:t}){return e===`api-key`?`Claude runs on this key.`:e===`blocked`?`Forge has ${t} members, so Claude needs an API key and won't run until one is added. A Claude subscription covers one person's own use.`:`Without a key, Claude runs on your own Claude Code sign-in, which covers one person. Add a key before you invite anyone.`}function As({status:e}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2 text-[13px] md:text-xs text-fg-subtle`,children:[(0,L.jsx)(`p`,{children:ks(e)}),e.mode!==`api-key`&&(0,L.jsxs)(`a`,{href:`https://useafk.dev/steward`,target:`_blank`,rel:`noopener noreferrer`,className:`self-start text-violet-400 hover:text-violet-300`,children:[`Prefer your own subscription? Steward runs Claude Code hands-off on your Mac`,(0,L.jsx)(B,{name:`chevronRight`,size:14,className:`ml-1 inline-block align-[-2px]`})]})]})}var js={gitlab:`GitLab`,github:`GitHub`,azuredevops:`Azure DevOps`,anthropic:`Anthropic`},Ms={gitlab:`GitLab token`,github:`GitHub token`,azuredevops:`Azure DevOps token`,anthropic:`Anthropic API key`},Ns={gitlab:`Clear stored token (revert to env var if set)`,github:`Clear stored token (revert to env var if set)`,azuredevops:`Clear stored token (revert to env var if set)`,anthropic:`Clear stored key (a one-member Forge goes back to your Claude Code sign-in)`};function Ps(e,t,n){return e===`anthropic`&&t===`none`?n?.mode===`blocked`?(0,L.jsx)(`span`,{className:`text-[11px] text-red-400/80`,children:`Key required`}):(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:`Your Claude sign-in`}):t===`config`?(0,L.jsx)(`span`,{className:`text-[11px] text-violet-400`,children:`config`}):t===`env`?(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:`env`}):(0,L.jsx)(`span`,{className:`text-[11px] text-red-400/80`,children:`missing`})}function Fs({provider:e,connection:t,newToken:n,setNewToken:r,clearToken:i,setClearToken:a,baseUrl:o,setBaseUrl:s,claudeAuth:c}){let[l,u]=(0,x.useState)(!1);return(0,L.jsxs)(`div`,{"data-testid":`connection-${e}`,className:`flex flex-col gap-3 bg-surface-raised border border-line rounded-lg px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:js[e]}),Ps(e,t.tokenSource,c)]}),s&&(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`API base URL`}),(0,L.jsx)(`input`,{value:o??``,onChange:e=>s(e.target.value),placeholder:`https://gitlab.com/api/v4`,className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs font-mono text-fg focus:outline-none focus:border-violet-500`})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[e===`anthropic`?`API key`:`Token`,t.hasToken&&(0,L.jsx)(`span`,{className:`ml-2 font-mono text-fg-subtle`,children:t.tokenHint})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`input`,{type:l?`text`:`password`,"aria-label":Ms[e],value:n,onChange:e=>r(e.target.value),placeholder:t.hasToken?`Leave blank to keep current`:e===`anthropic`?`Paste API key`:`Paste token`,disabled:i,className:`flex-1 bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs font-mono text-fg focus:outline-none focus:border-violet-500 disabled:opacity-40`}),(0,L.jsx)(`button`,{onClick:()=>u(e=>!e),disabled:!n,className:`text-xs text-fg-subtle hover:text-fg disabled:opacity-30`,children:l?`Hide`:`Show`})]}),t.tokenSource===`config`&&(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px] md:text-xs text-fg-subtle`,children:[(0,L.jsx)(ns,{checked:i,onChange:a}),Ns[e]]})]}),c&&(0,L.jsx)(As,{status:c})]})}var Is={gitlab:``,github:``,azuredevops:``,anthropic:``},Ls={gitlab:!1,github:!1,azuredevops:!1,anthropic:!1};function Rs({connections:e,claudeAuth:t,onSave:n}){let[r,i]=(0,x.useState)(e.gitlab.baseUrl),[a,o]=(0,x.useState)(Is),[s,c]=(0,x.useState)(Ls),[l,u]=(0,x.useState)(!1),[d,f]=(0,x.useState)(null);(0,x.useEffect)(()=>{i(e.gitlab.baseUrl)},[e.gitlab.baseUrl]);let p=r!==e.gitlab.baseUrl,m=Object.values(a).some(Boolean)||Object.values(s).some(Boolean),h=p||m,g=()=>{let e={},t={};return p&&(t.baseUrl=r),s.gitlab?t.token=``:a.gitlab&&(t.token=a.gitlab),Object.keys(t).length>0&&(e.gitlab=t),s.github?e.github={token:``}:a.github&&(e.github={token:a.github}),s.azuredevops?e.azuredevops={token:``}:a.azuredevops&&(e.azuredevops={token:a.azuredevops}),s.anthropic?e.anthropic={token:``}:a.anthropic&&(e.anthropic={token:a.anthropic}),e};return(0,L.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Connections`}),(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle mt-0.5`,children:`SCM hosts and tokens. Config values override env vars; empty config values fall back to env.`})]}),h&&(0,L.jsx)(`button`,{onClick:async()=>{u(!0),f(null);try{await n(g()),o(Is),c(Ls)}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},disabled:l,className:`bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-1.5 rounded-lg transition-colors`,children:l?`Saving…`:`Save`})]}),d&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-3 py-2 text-sm text-red-300`,children:d}),(0,L.jsx)(Fs,{provider:`gitlab`,connection:e.gitlab,baseUrl:r,setBaseUrl:i,newToken:a.gitlab,setNewToken:e=>o(t=>({...t,gitlab:e})),clearToken:s.gitlab,setClearToken:e=>c(t=>({...t,gitlab:e}))}),(0,L.jsx)(Fs,{provider:`github`,connection:e.github,newToken:a.github,setNewToken:e=>o(t=>({...t,github:e})),clearToken:s.github,setClearToken:e=>c(t=>({...t,github:e}))}),(0,L.jsx)(Fs,{provider:`azuredevops`,connection:e.azuredevops,newToken:a.azuredevops,setNewToken:e=>o(t=>({...t,azuredevops:e})),clearToken:s.azuredevops,setClearToken:e=>c(t=>({...t,azuredevops:e}))}),(0,L.jsx)(Fs,{provider:`anthropic`,connection:e.anthropic,claudeAuth:t,newToken:a.anthropic,setNewToken:e=>o(t=>({...t,anthropic:e})),clearToken:s.anthropic,setClearToken:e=>c(t=>({...t,anthropic:e}))})]})}function zs({defaults:e,onSave:t}){let{availableModels:n,availableAgents:r}=V(),[i,a]=(0,x.useState)(e),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null),u=(0,x.useId)();(0,x.useEffect)(()=>{a(e)},[e]);let d=JSON.stringify(i)!==JSON.stringify(e);return(0,L.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Defaults`}),(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle mt-0.5`,children:`Preselect the model and agent on load. Leaves selection free per-request.`})]}),(0,L.jsx)(`button`,{onClick:async()=>{s(!0),l(null);try{await t(i)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}},disabled:!d||o,"aria-hidden":!d||void 0,tabIndex:d?void 0:-1,className:`bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-1.5 rounded-lg transition-colors ${d?``:`invisible`}`,children:o?`Saving…`:`Save`})]}),c&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-3 py-2 text-sm text-red-300`,children:c}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Default model`}),(0,L.jsxs)(`select`,{value:i.model??``,onChange:e=>a({...i,model:e.target.value===``?null:e.target.value}),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:[(0,L.jsx)(`option`,{value:``,children:`— none —`}),n.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Default agent`}),(0,L.jsxs)(`select`,{value:i.agent??``,onChange:e=>a({...i,agent:e.target.value===``?null:e.target.value}),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:[(0,L.jsx)(`option`,{value:``,children:`— none —`}),r.map(e=>(0,L.jsxs)(`option`,{value:e.id,disabled:!e.configured,children:[e.label,e.configured?``:` (not configured)`]},e.id))]})]}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`label`,{htmlFor:u,className:`text-xs text-fg-subtle`,children:`Agent mode`}),(0,L.jsxs)(`select`,{id:u,"aria-describedby":`${u}-help`,value:i.agentMode??`structured`,onChange:e=>a({...i,agentMode:e.target.value}),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:[(0,L.jsx)(`option`,{value:`structured`,children:`Structured — single-pass JSON, no tools`}),(0,L.jsx)(`option`,{value:`agentic`,children:`Agentic — works in a checkout with tools`})]}),(0,L.jsxs)(`span`,{id:`${u}-help`,className:`text-[11px] text-fg-subtle leading-relaxed`,children:[`Agentic runs Claude inside a clone of the repo (GitLab, single repo) with its `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`CLAUDE.md`}),`, so it can run tests and Playwright and attach a write-up and screenshots to the MR. Other cases fall back to structured. `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`FORGE_AGENT_MODE`}),`, if set, overrides this.`]})]}),(0,L.jsxs)(`label`,{className:`flex items-center gap-3 md:gap-2`,children:[(0,L.jsx)(ns,{checked:i.autoPushOnValidatePass,onChange:e=>a({...i,autoPushOnValidatePass:e})}),(0,L.jsx)(`span`,{className:`text-[15px] md:text-xs text-fg`,children:`Auto-push on successful validation`})]}),(0,L.jsxs)(`label`,{className:`flex items-start gap-3 md:gap-2`,children:[(0,L.jsx)(ns,{checked:i.refineRepoAccess,onChange:e=>a({...i,refineRepoAccess:e}),className:`mt-0.5`}),(0,L.jsxs)(`span`,{className:`flex flex-col`,children:[(0,L.jsx)(`span`,{className:`text-[15px] md:text-xs text-fg`,children:`Refine repo access`}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-subtle leading-relaxed`,children:[`When on, Refine spawns Claude with `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`Read/Glob/Grep`}),` over a local clone of the primary repo (GitLab only). Off uses a lighter "file tree + attached files" prompt. `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`FORGE_REFINE_REPO_ACCESS`}),`, if set, overrides this.`]})]})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Prompt rules`}),(0,L.jsx)(`textarea`,{value:i.promptRules??``,onChange:e=>a({...i,promptRules:e.target.value}),placeholder:`e.g. "Never restructure the NavBar — only add entries"`,rows:3,className:`bg-surface-raised border border-line-strong rounded px-2 py-1.5 text-xs text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 font-mono resize-y`}),(0,L.jsx)(`span`,{className:`text-[11px] text-fg-subtle leading-relaxed`,children:`Custom instructions injected into every analysis and refine prompt, in both modes. Use this to steer the model towards your preferred patterns, or to ask for evidence (e.g. "run the e2e tests and screenshot every changed page") — that needs agentic mode.`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,L.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:`Test deploy URL`}),(0,L.jsx)(`input`,{type:`url`,value:i.testDeployUrlTemplate??``,onChange:e=>a({...i,testDeployUrlTemplate:e.target.value}),placeholder:`https://test.example.com or https://{slug}.test.example.com`,className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg placeholder-fg-subtle focus:outline-none focus:border-violet-500 font-mono`}),(0,L.jsxs)(`span`,{className:`text-[11px] text-fg-subtle leading-relaxed`,children:[`Shown next to "Approve & Create MR" once the branch pipeline is green. Supports `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`{branch}`}),` (full branch) and`,` `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`{slug}`}),` (subdomain-safe) placeholders for ephemeral per-branch envs. Leave blank to hide the link.`]})]})]})]})}var Bs=[`gitlab`,`github`,`azuredevops`],Vs=[{value:`auto`,label:`auto-detect`},{value:`node`,label:`Node (npm)`},{value:`go`,label:`Go`}];function Hs(e){let t=e.replace(/^(gitlab|github|azuredevops):/,``);return t.split(`/`).pop()??t}function Us({repos:e,onSave:t}){let[n,r]=(0,x.useState)(e),[i,a]=(0,x.useState)(`gitlab`),[o,s]=(0,x.useState)(``),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{r(e)},[e]);let g=JSON.stringify(n)!==JSON.stringify(e),_=()=>{let e=o.trim();if(!e)return;let t=e.includes(`:`)?e:`${i}:${e}`;if(n.some(e=>e.id===t)){d(`Already in list: ${t}`);return}d(null),r([...n,{id:t,label:Hs(t),projectType:`auto`}]),s(``)},v=e=>{r(n.filter(t=>t.id!==e))},y=(e,t)=>{r(n.map(n=>n.id===e?{...n,label:t}:n))},b=(e,t)=>{r(n.map(n=>n.id===e?{...n,projectType:t}:n))},S=(e,t)=>{e!==t&&r(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})};return(0,L.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,L.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Repositories`}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle mt-0.5`,children:[`Override the `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`FORGE_REPOS`}),` env var. Empty list falls back to env.`]})]}),g&&(0,L.jsx)(`button`,{onClick:async()=>{l(!0),d(null);try{await t(n)}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},disabled:c,className:`bg-violet-600 hover:bg-violet-500 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-1.5 rounded-lg transition-colors`,children:c?`Saving…`:`Save`})]}),u&&(0,L.jsx)(`div`,{className:`bg-red-950/40 border border-red-800 rounded-lg px-3 py-2 text-sm text-red-300`,children:u}),(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n.length===0&&(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle italic`,children:`No repos configured — using env vars.`}),n.map((e,t)=>{let n=f===t,r=m===t&&f!==null&&f!==t;return(0,L.jsxs)(`div`,{onDragOver:e=>{f!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,m!==t&&h(t))},onDragLeave:()=>{m===t&&h(null)},onDrop:e=>{e.preventDefault(),f!==null&&S(f,t),p(null),h(null)},className:`flex flex-wrap md:flex-nowrap items-center gap-2 md:gap-3 bg-surface-raised border rounded-xl md:rounded-lg px-3 py-2.5 md:py-2 transition-colors ${n?`opacity-40 border-line`:`border-line`} ${r&&f>t?`!border-t-violet-500`:``} ${r&&f<t?`!border-b-violet-500`:``}`,children:[(0,L.jsx)(`span`,{draggable:!0,onDragStart:n=>{p(t),n.dataTransfer.effectAllowed=`move`,n.dataTransfer.setData(`text/plain`,e.id)},onDragEnd:()=>{p(null),h(null)},className:`hidden md:inline shrink-0 cursor-grab active:cursor-grabbing text-fg-subtle hover:text-fg-muted select-none leading-none px-1`,title:`Drag to reorder`,"aria-label":`Drag to reorder`,children:`⋮⋮`}),(0,L.jsx)(`span`,{className:`order-first md:order-none basis-[calc(100%-2.5rem)] md:basis-auto text-xs font-mono text-fg-subtle truncate md:shrink-0`,children:e.id}),(0,L.jsx)(`input`,{value:e.label,onChange:t=>y(e.id,t.target.value),className:`flex-1 min-w-0 bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`}),(0,L.jsx)(`select`,{value:e.projectType??`auto`,onChange:t=>b(e.id,t.target.value),title:`Validator toolchain — picks npm scripts or go fmt/vet/build/test`,className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:Vs.map(e=>(0,L.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,L.jsx)(`button`,{onClick:()=>v(e.id),className:`order-first md:order-none ml-auto md:ml-0 h-8 w-8 md:h-auto md:w-auto text-xs text-fg-subtle hover:text-red-400 transition-colors`,title:`Remove`,"aria-label":`Remove ${e.id}`,children:`✕`})]},e.id)})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap md:flex-nowrap items-center gap-2 border-t border-line pt-4`,children:[(0,L.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`,children:Bs.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))}),(0,L.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_()},placeholder:`group/repo or owner/repo`,className:`basis-full md:basis-auto order-first md:order-none flex-1 min-w-0 bg-surface-raised border border-line-strong rounded px-2 py-1 text-xs text-fg focus:outline-none focus:border-violet-500`}),(0,L.jsx)(`button`,{onClick:_,className:`bg-surface-raised ring-1 ring-inset ring-line-strong hover:bg-surface-hover border border-line-strong hover:border-line-strong text-fg text-xs px-3 py-1 rounded transition-colors`,children:`+ Add`})]})]})}var Ws=3,Gs={base:`Base clone`,legacy:`Old-layout clone`,orphan:`Stray folder`};function Ks(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function qs({removed:e,skipped:t,freedBytes:n}){let r=[`Removed ${e.length}`,`freed ${Ks(n)}`];return t.length&&r.push(`${t.length} in use, kept`),r.join(` · `)}function Js(e){return e.lastUsedAt?`used ${Zi(Date.parse(e.lastUsedAt))}`:`never used`}function Ys({ws:e}){let t=e.kind===`worktree`||e.kind===`base`?e.repo:e.id;return(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:e.kind===`worktree`?(0,L.jsxs)(L.Fragment,{children:[e.issueIid!==null&&(0,L.jsxs)(`span`,{className:`shrink-0 font-medium text-fg`,children:[`#`,e.issueIid]}),(0,L.jsx)(`span`,{className:`truncate font-mono text-xs text-fg-muted`,children:e.branch??`detached`})]}):(0,L.jsx)(`span`,{className:`font-medium text-fg`,children:Gs[e.kind]})}),(0,L.jsxs)(`div`,{className:`truncate text-[11px] text-fg-subtle`,children:[(0,L.jsx)(`span`,{className:`font-mono`,children:t}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,Ks(e.sizeBytes),` · `,Js(e)]})]})]})}function Xs(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(null),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(!1),[f,p]=(0,x.useState)(null),m=()=>R(`/workspaces`).then(e=>t(e.workspaces)).catch(e=>r(e.message));(0,x.useEffect)(()=>{m()},[]);let h=async e=>{d(!0),r(null);try{await R(`/workspaces?id=${encodeURIComponent(e)}`,{method:`DELETE`}),p(null),await m()}catch(e){r(e.message)}finally{d(!1),a(null)}},g=async()=>{d(!0),r(null);try{p(qs(await R(`/workspaces/purge`,{method:`POST`,body:JSON.stringify({includeBases:c})}))),await m()}catch(e){r(e.message)}finally{d(!1),s(!1)}},_=e?.reduce((e,t)=>e+t.sizeBytes,0)??0,v=e?.filter(e=>!e.inUse&&(c||e.kind!==`base`))??[],y=v.reduce((e,t)=>e+t.sizeBytes,0);return(0,L.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-x-4 gap-y-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workspaces`}),(0,L.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[`Checkouts Forge works in, under `,(0,L.jsx)(`code`,{className:`font-mono`,children:`~/.forge/cache`}),`: one worktree per issue off a base clone per repo.`,` `,(0,L.jsxs)(`span`,{className:Gn(`tabular-nums`,!e&&`invisible`),children:[Ks(_),` total.`]})]})]}),(0,L.jsx)(`div`,{className:`flex h-7 items-center gap-2`,children:o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`text-xs text-fg-muted tabular-nums`,children:[`Remove `,v.length,` (`,Ks(y),`)?`]}),(0,L.jsx)(z,{size:`sm`,variant:`ghost`,onClick:()=>s(!1),children:`Cancel`}),(0,L.jsx)(z,{size:`sm`,variant:`danger`,disabled:u,onClick:g,children:`Confirm purge`})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z,{size:`sm`,variant:`ghost`,disabled:u,onClick:()=>m(),children:`Refresh`}),(0,L.jsx)(z,{size:`sm`,disabled:u||!e,onClick:()=>s(!0),children:`Purge idle`})]})})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1`,children:[(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`rounded border-line-strong bg-surface-raised text-violet-600 focus:ring-violet-500`}),`Include base clones`]}),(0,L.jsx)(`p`,{"aria-live":`polite`,className:Gn(`min-h-4 text-xs`,n?`text-red-400`:`text-fg-muted`),children:n??f})]}),(0,L.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-line bg-surface-raised`,children:(0,L.jsx)(`table`,{"aria-label":`Workspaces`,"aria-busy":!e||void 0,className:`w-full table-fixed text-left text-sm`,children:(0,L.jsxs)(`tbody`,{className:`divide-y divide-line`,children:[!e&&Array.from({length:Ws},(e,t)=>(0,L.jsx)(`tr`,{"aria-hidden":`true`,className:`h-14`,children:(0,L.jsx)(`td`,{colSpan:2,className:`px-4`,children:(0,L.jsx)(`div`,{className:`h-4 w-2/3 animate-pulse rounded bg-surface-hover`})})},t)),e?.map(e=>(0,L.jsxs)(`tr`,{className:`h-14`,children:[(0,L.jsx)(`td`,{className:`py-2 pl-4 pr-2`,children:(0,L.jsx)(Ys,{ws:e})}),(0,L.jsx)(`td`,{className:`w-40 py-2 pl-2 pr-4`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[e.inUse&&(0,L.jsx)(`span`,{className:`rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] text-amber-300`,children:`In use`}),i===e.id?(0,L.jsx)(z,{size:`sm`,variant:`danger`,disabled:u,onClick:()=>h(e.id),onBlur:()=>a(null),children:`Confirm delete`}):(0,L.jsx)(z,{size:`sm`,variant:`ghost`,disabled:u||e.inUse,title:e.inUse?`A running job is using this workspace`:void 0,onClick:()=>a(e.id),children:`Delete`})]})})]},e.id)),e?.length===0&&(0,L.jsx)(`tr`,{className:`h-14`,children:(0,L.jsx)(`td`,{colSpan:2,className:`px-4 text-center text-sm text-fg-subtle`,children:`No workspaces yet. Forge creates one per issue when a job needs a checkout.`})})]})})})]})}function Zs(){let{config:e,loading:t,error:n,patch:r}=Ds(),{can:i}=Ui(),a=i(`admin`),{selectedRepo:o,availableRepos:s,selectedSecondaryRepos:c}=V(),{handleDestroyAllAnalyses:l,reloadStatus:u}=H(),[d,f]=(0,x.useState)(null),p=()=>{if(!window.confirm(`Destroy every cached analysis across every issue and repo? This cannot be undone.`))return;let e=l();f(e===0?`No cached analyses to remove.`:`Removed ${e} cached analysis entr${e===1?`y`:`ies`}.`)},m=s.find(e=>e.id===o)?.label??o,h=c.map(e=>s.find(t=>t.id===e)?.label??e);return t&&!e?(0,L.jsx)(hs,{}):n&&!e?(0,L.jsx)(`div`,{className:`max-w-3xl mx-auto w-full bg-red-950/40 border border-red-800 rounded-lg px-4 py-3 text-sm text-red-300`,children:n}):e?(0,L.jsxs)(`div`,{className:`max-w-3xl mx-auto w-full flex flex-col gap-10`,children:[(0,L.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:`Settings`}),m&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-mono`,children:[(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`Current repo`}),(0,L.jsx)(`span`,{className:`bg-violet-600/15 border border-violet-600/40 text-violet-200 px-2 py-0.5 rounded`,children:m}),h.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-fg-subtle`,children:`+`}),h.map(e=>(0,L.jsx)(`span`,{className:`bg-surface-raised border border-line-strong text-fg px-2 py-0.5 rounded`,children:e},e))]})]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[`Persisted to `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`~/.forge/config.json`}),`. Env vars apply when config is empty.`]})]}),(0,L.jsx)(Os,{}),!a&&(0,L.jsx)(`p`,{className:`rounded-xl border border-line bg-surface px-4 py-3 text-sm text-fg-muted`,children:`Workspace connections, repositories and defaults are managed by admins.`}),a&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Rs,{connections:e.connections,claudeAuth:e.claudeAuth,onSave:e=>r({connections:e}).then(()=>void 0)}),(0,L.jsx)(Us,{repos:e.repos,onSave:e=>r({repos:e}).then(()=>u())}),(0,L.jsx)(zs,{defaults:e.defaults,onSave:e=>r({defaults:e}).then(()=>u())}),(0,L.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Local cache`}),(0,L.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[`Forge caches previous analyses in `,(0,L.jsx)(`code`,{className:`text-fg-muted`,children:`localStorage`}),` so you can restore them without re-running Claude. Destroy the cache if it grows too large or if an analysis schema change has left stale entries that won't render.`]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`button`,{onClick:p,className:`text-xs text-red-300 hover:text-red-200 border border-red-900/60 hover:border-red-800 bg-red-950/30 hover:bg-red-950/50 px-3 py-1.5 rounded-lg transition-colors`,children:`Destroy all cached analyses`}),d&&(0,L.jsx)(`span`,{className:`text-xs text-fg-muted`,children:d})]})]}),(0,L.jsx)(Xs,{})]})]}):null}function Qs(){let{phase:e,selectedIssue:t,currentOrdinal:n,storedAnalyses:r,selectedRepo:i,availableRepos:a}=V(),{setPhase:o,handleReset:s,handleSelectIssue:c,restoreAnalysisByOrdinal:l,setSelectedRepo:u}=H(),{setActiveDetailTab:d}=hi(),{navigate:f,pathname:p,search:m}=Ei(),h=new URLSearchParams(m).get(`repo`),g=(0,x.useRef)(!1),_=(0,x.useRef)(i);_.current=i;let v=(0,x.useRef)(i);(0,x.useEffect)(()=>{let e=v.current;v.current=i,!(!e||e===i||!g.current)&&/^\/issues\/\d+/.test(p)&&h!==i&&(s(),f(`/issues`,{replace:!0}))},[i]),(0,x.useEffect)(()=>{!t||!i||h||v.current===i&&p.startsWith(`/issues/${t.iid}`)&&f(`${p}?repo=${encodeURIComponent(i)}`,{replace:!0})},[t?.iid,i,p,h]),(0,x.useEffect)(()=>{d(p.endsWith(`/mr`)?`mr`:`issue`)},[p,d]),(0,x.useEffect)(()=>{if(!t||e===`idle`||e===`applying`)return;let r=`/issues/${t.iid}`;if(e===`reviewing`){let e=`${r}/analysis/${n??1}`;p!==e&&f(e)}else if(e===`monitoring`){let e=`${r}/mr`;p!==e&&f(e)}else p.startsWith(r)||f(r)},[e,t?.iid,n]);let y=(0,x.useRef)(t?.iid);return(0,x.useEffect)(()=>{let e=y.current;y.current=t?.iid,e!==void 0&&!t&&p.startsWith(`/issues/${e}`)&&f(`/issues`,{replace:!0})},[t?.iid]),(0,x.useEffect)(()=>{if(!t||e===`idle`)return;let i=`/issues/${t.iid}`;if(!p.startsWith(i)){s();return}let a=p.match(RegExp(`^${i}/analysis/(\\d+)$`));if(p===`${i}/review`){let e=r[0];f(e?`${i}/analysis/${e.ordinal}`:i,{replace:!0});return}if(a){let t=Number(a[1]);if(e===`reviewing`&&n===t)return;l(t)||f(i,{replace:!0})}else e===`reviewing`&&o(`selected`)},[p]),(0,x.useEffect)(()=>{if(g.current||!i)return;if(h&&h!==i){if(!a.length)return;if(a.some(e=>e.id===h)){u(h);return}}if(g.current=!0,e!==`idle`&&e!==`selected`)return;let t=p.match(/^\/issues\/(\d+)/);if(!t)return;let n=p.match(/^\/issues\/\d+\/analysis\/(\d+)$/),r=p.endsWith(`/review`),o=i;R(`/issues/${t[1]}?repo=${encodeURIComponent(o)}`).then(async({issue:e})=>{if(_.current!==o||(c(e),!n&&!r))return;let t=await xr(i,e.iid);if(n)l(Number(n[1]),e.iid)||f(`/issues/${e.iid}`,{replace:!0});else{let n=t[0];n&&l(n.ordinal,e.iid)?f(`/issues/${e.iid}/analysis/${n.ordinal}`,{replace:!0}):f(`/issues/${e.iid}`,{replace:!0})}}).catch(()=>f(`/issues`,{replace:!0}))},[e,i,a.length]),null}function $s({open:e,onClose:t,title:n,leading:r,trailing:i,closeLabel:a=`Cancel`,children:o}){return po(e,t),e?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-end md:items-start justify-center bg-black/50 backdrop-blur-sm md:pt-24 md:px-4 animate-[forge-fade_200ms_ease-out]`,onClick:t,children:(0,L.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":n,onClick:e=>e.stopPropagation(),className:`w-full md:max-w-xl max-h-[92dvh] flex flex-col bg-surface-raised border-t md:border border-line md:border-line-strong rounded-t-[14px] md:rounded-xl shadow-2xl animate-[forge-sheet-up_320ms_cubic-bezier(0.32,0.72,0,1)] md:animate-none`,children:[(0,L.jsx)(`div`,{className:`md:hidden flex justify-center pt-2`,children:(0,L.jsx)(`span`,{className:`w-9 h-[5px] rounded-full bg-line-strong`})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-center gap-2 px-4 md:px-5 h-12 md:h-auto md:pt-4 md:pb-1 shrink-0`,children:[(0,L.jsx)(`div`,{className:`justify-self-start`,children:r??(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`text-[17px] md:text-sm text-accent-fg md:text-fg-muted hover:text-accent-hover md:hover:text-fg -ml-1 px-1 py-2 md:py-0`,children:a})}),(0,L.jsx)(`h2`,{className:`text-[17px] md:text-sm font-semibold text-fg truncate`,children:n}),(0,L.jsx)(`div`,{className:`justify-self-end`,children:i})]}),(0,L.jsx)(`div`,{className:`overflow-y-auto overscroll-contain px-4 md:px-5 pt-2 pb-[max(1.25rem,env(safe-area-inset-bottom))]`,children:o})]})}):null}var ec=`forge-new-task`;function tc(){let{taskModalOpen:e,setTaskModalOpen:t}=hi(),{handleCreateIssue:n,handleSelectIssue:r}=H(),{navigate:i}=Ei(),{selectedRepo:a}=V(),o=Ma(a),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(``),[d,f]=(0,x.useState)([]),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null);(0,x.useEffect)(()=>{e||(c(``),u(``),f([]),g(null),m(!1))},[e]);let _=()=>t(!1);return(0,L.jsx)($s,{open:e,onClose:_,title:`New Task`,trailing:(0,L.jsx)(`button`,{type:`submit`,form:ec,disabled:!(!p&&s.trim()),className:`text-[17px] md:text-xs font-semibold md:font-medium text-accent-fg md:text-on-accent md:bg-violet-600 md:hover:bg-violet-500 disabled:opacity-40 disabled:cursor-not-allowed md:px-4 md:py-1.5 md:rounded px-1 py-2 transition-colors`,children:p?`Creating…`:`Create task`}),children:(0,L.jsxs)(`form`,{id:ec,onSubmit:async e=>{if(e.preventDefault(),s.trim()){m(!0),g(null);try{let e=await n(s.trim(),l.trim(),d);r(e),i(`/issues/${e.iid}`,{replace:!1}),_()}catch(e){g(e.message),m(!1)}}},className:`flex flex-col gap-3`,children:[(0,L.jsx)(`input`,{type:`text`,placeholder:`Task title`,value:s,onChange:e=>c(e.target.value),autoFocus:!0,enterKeyHint:`next`,className:`w-full bg-surface-raised border border-line-strong rounded-[10px] md:rounded px-3 py-2.5 md:py-2 text-[17px] md:text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:border-violet-500`}),(0,L.jsx)(`textarea`,{placeholder:`Describe what you want done. The more detail, the better the analysis.`,value:l,onChange:e=>u(e.target.value),rows:6,className:`w-full bg-surface-raised border border-line-strong rounded-[10px] md:rounded px-3 py-2.5 md:py-2 text-[17px] md:text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:border-violet-500 resize-y`}),(0,L.jsx)(Wa,{labels:d,available:o,onChange:f}),h&&(0,L.jsx)(`p`,{className:`text-[13px] md:text-xs text-red-400`,children:h}),(0,L.jsx)(`p`,{className:`text-[13px] md:text-[11px] text-fg-subtle`,children:`Creates an issue in the selected repo and opens it — then choose “Begin Analysis”.`})]})})}function nc({children:e}){return(0,L.jsx)(`kbd`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded border border-line bg-surface px-1 font-sans text-[10px] font-medium text-fg-subtle`,children:e})}function rc({commands:e,query:t}){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return e;let r=[];return e.forEach((e,t)=>{let i=e.hint?.toLowerCase()??``,a=[e.label,i,...e.keywords??[]].join(` `).toLowerCase(),o=0;for(let t of n)if(t.startsWith(`#`))if(i===t)o+=3;else if(i.startsWith(t))o+=1;else return;else if(e.label.toLowerCase().startsWith(t))o+=2;else if(a.includes(t))o+=1;else return;r.push({command:e,score:o,index:t})}),r.sort((e,t)=>t.score-e.score||e.index-t.index).map(e=>e.command)}function ic({open:e,commands:t,onClose:n}){return e?(0,L.jsx)(ac,{commands:t,onClose:n}):null}function ac({commands:e,onClose:t}){let[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(0),o=(0,x.useId)(),s=(0,x.useRef)(null),c=rc({commands:e,query:n}),l=c[Math.min(i,c.length-1)];(0,x.useEffect)(()=>{s.current?.querySelector(`[aria-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[i,n]);let u=e=>{e&&(t(),e.run())},d=e=>{e.key===`ArrowDown`?(e.preventDefault(),a(e=>Math.min(e+1,c.length-1))):e.key===`ArrowUp`?(e.preventDefault(),a(e=>Math.max(e-1,0))):e.key===`Enter`?(e.preventDefault(),u(l)):e.key===`Escape`&&(e.preventDefault(),t())},f=``;return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center px-4 pt-[12vh]`,children:[(0,L.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-[2px] animate-fade-in`,onClick:t,"aria-hidden":!0}),(0,L.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`relative w-full max-w-xl overflow-hidden rounded-xl bg-surface-raised shadow-overlay animate-pop-in`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-line px-4`,children:[(0,L.jsx)(B,{name:`search`,className:`text-fg-subtle shrink-0`}),(0,L.jsx)(`input`,{ref:e=>e?.focus(),role:`combobox`,"aria-expanded":`true`,"aria-controls":o,"aria-activedescendant":l?`${o}-${l.id}`:void 0,"aria-autocomplete":`list`,value:n,onChange:e=>{r(e.target.value),a(0)},onKeyDown:d,placeholder:`Search issues, pages and actions…`,className:`h-12 flex-1 bg-transparent text-sm text-fg placeholder:text-fg-subtle focus:outline-none`}),(0,L.jsx)(nc,{children:`Esc`})]}),(0,L.jsxs)(`div`,{ref:s,id:o,role:`listbox`,"aria-label":`Results`,className:`max-h-[50vh] overflow-y-auto p-1.5`,children:[c.length===0&&(0,L.jsxs)(`p`,{className:`px-3 py-10 text-center text-sm text-fg-subtle`,children:[`No results for “`,n,`”`]}),c.map((e,t)=>{let n=e.group!==f;f=e.group;let r=e===l;return(0,L.jsxs)(`div`,{children:[n&&(0,L.jsx)(`div`,{className:`px-3 pb-1 pt-2.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:e.group}),(0,L.jsxs)(`div`,{id:`${o}-${e.id}`,role:`option`,"aria-selected":r,onMouseMove:()=>a(t),onClick:()=>u(e),className:Gn(`flex cursor-pointer items-center justify-between gap-3 rounded-lg px-3 py-2 text-sm`,r?`bg-surface-hover text-fg`:`text-fg-muted`),children:[(0,L.jsx)(`span`,{className:`truncate`,children:e.label}),e.hint&&(0,L.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-fg-subtle`,children:e.hint})]})]},e.id)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-4 border-t border-line px-4 py-2 text-[11px] text-fg-subtle`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(nc,{children:`↑`}),(0,L.jsx)(nc,{children:`↓`}),` navigate`]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(nc,{children:`↵`}),` open`]})]})]})]})}function oc({open:e,onOpenChange:t}){let{issues:n,phase:r,openMRs:i,openMRsLoading:a}=V(),{handleSelectIssue:o,handleReset:s,loadIssues:c,loadOpenMRs:l}=H(),{setTaskModalOpen:u}=hi(),{navigate:d}=Ei(),{setPreference:f}=ir(),{can:p,signOut:m}=Ui(),h=Ai();(0,x.useEffect)(()=>{let n=n=>{(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===`k`&&(n.preventDefault(),t(!e))};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let g=(e,t)=>{r!==`idle`&&s(),d(e,{replace:!0}),t&&i.length===0&&!a&&l()};return(0,L.jsx)(ic,{open:e,commands:[...h.map(e=>({id:`go-${e.path.slice(1)}`,group:`Navigate`,label:`Go to ${e.label}`,keywords:[...e.keywords],run:()=>g(e.path,e.preloadMRs)})),...p(`operator`)?[{id:`new-task`,group:`Actions`,label:`New task`,keywords:[`create`],run:()=>u(!0)}]:[],{id:`refresh`,group:`Actions`,label:`Refresh issues and merge requests`,keywords:[`reload`],run:()=>{c(),l()}},{id:`theme-light`,group:`Actions`,label:`Switch to light theme`,keywords:[`appearance`],run:()=>f(`light`)},{id:`theme-dark`,group:`Actions`,label:`Switch to dark theme`,keywords:[`appearance`],run:()=>f(`dark`)},{id:`theme-system`,group:`Actions`,label:`Use system theme`,keywords:[`appearance`],run:()=>f(`system`)},{id:`sign-out`,group:`Actions`,label:`Sign out`,keywords:[`logout`],run:()=>void m()},...n.map(e=>({id:`issue-${e.iid}`,group:`Issues`,label:e.title,hint:`#${e.iid}`,keywords:e.labels,run:()=>{r!==`idle`&&s(),o(e)}}))],onClose:()=>t(!1)})}function sc(){let e=U().filter(e=>!e.adminOnly);return(0,L.jsx)(`nav`,{"aria-label":`Tabs`,className:`fixed inset-x-0 bottom-0 z-30 border-t border-line/70 bg-canvas/80 pb-[env(safe-area-inset-bottom)] backdrop-blur-xl backdrop-saturate-150 md:hidden`,children:(0,L.jsx)(`ul`,{className:`grid h-[50px]`,style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(e=>{let t=e.badgeCount!==void 0&&e.badgeCount>0;return(0,L.jsx)(`li`,{className:`flex`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:e.go,"aria-current":e.active?`page`:void 0,className:Gn(`flex flex-1 flex-col items-center justify-center gap-0.5 pt-1 transition-colors`,e.active?`text-accent-fg`:`text-fg-subtle active:text-fg-muted`),children:[(0,L.jsxs)(`span`,{className:`relative`,children:[(0,L.jsx)(B,{name:e.icon,size:24}),t&&(0,L.jsx)(`span`,{className:`absolute -right-2.5 -top-1 h-[18px] min-w-[18px] rounded-full bg-red-500 px-1 text-center text-[11px] font-semibold leading-[18px] text-on-accent tabular-nums`,children:e.badgeCount})]}),(0,L.jsx)(`span`,{className:`text-[10px] font-medium leading-none tracking-tight`,children:e.label})]})},e.path)})})})}var cc=[`/issues`,`/mrs`,`/pipelines`];function lc(e){return cc.includes(e)}var uc=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform);function dc({popoutUrl:e,onOpenPalette:t,onOpenNav:n}){let{phase:r,selectedIssue:i,applyResult:a}=V(),{handleReset:o,handleBackToIssue:s}=H(),{setMrMerged:c,setTaskModalOpen:l}=hi(),{navigate:u,pathname:d}=Ei(),{can:f}=Ui(),p=(0,x.useRef)(`/issues`);(0,x.useEffect)(()=>{r===`idle`&&lc(d)&&(p.current=d)},[d,r]);let m=r!==`idle`,h=a?.applications[0]?.mr,g=ki(m?p.current:d)?.label??`Issues`;return(0,L.jsxs)(`header`,{className:`box-content flex h-14 shrink-0 pt-[env(safe-area-inset-top)] items-center justify-between gap-2 border-b border-line/70 bg-canvas/80 px-3 backdrop-blur-xl sm:gap-4 sm:px-6`,children:[(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,onClick:n,className:`-ml-1 flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg lg:hidden`,children:(0,L.jsx)(B,{name:`menu`,size:18})}),(0,L.jsxs)(`nav`,{"aria-label":`Breadcrumb`,className:`mr-auto flex min-w-0 items-center gap-1 text-sm`,children:[m?(0,L.jsxs)(`button`,{onClick:()=>{c(!1),o(),u(p.current,{replace:!0})},"aria-label":`Back to ${g}`,className:`-ml-1.5 flex shrink-0 items-center rounded-lg py-1 pl-0.5 pr-2 text-accent-fg transition-colors hover:bg-surface-hover`,children:[(0,L.jsx)(B,{name:`chevronLeft`,size:18}),(0,L.jsx)(`span`,{className:`hidden sm:inline`,children:g})]}):null,i&&m&&(0,L.jsxs)(`button`,{type:`button`,onClick:s,disabled:r!==`analyzing`&&r!==`reviewing`,title:r===`analyzing`||r===`reviewing`?`Back to the ticket; the analysis stays`:void 0,"aria-current":`page`,className:`min-w-0 truncate rounded-lg px-1.5 py-1 text-left font-medium text-fg enabled:hover:bg-surface-hover`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-fg-subtle`,children:[`#`,i.iid]}),` `,i.title]}),!i&&h&&m&&a&&(0,L.jsxs)(`span`,{className:`truncate px-1.5 font-medium text-fg`,"aria-current":`page`,children:[(0,L.jsxs)(`span`,{className:`font-normal text-fg-subtle`,children:[`!`,h.iid]}),` `,h.title,a.applications.length>1&&(0,L.jsxs)(`span`,{className:`ml-2 text-xs text-accent-fg`,children:[`+`,a.applications.length-1,` more`]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[!m&&f(`operator`)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(!0),"aria-label":`New task`,className:`flex size-8 items-center justify-center rounded-lg text-accent-fg transition-colors hover:bg-surface-hover md:hidden`,children:(0,L.jsx)(B,{name:`plus`,size:18})}),(0,L.jsxs)(`button`,{type:`button`,onClick:t,"aria-label":`Search or jump to`,className:`flex h-8 w-8 items-center justify-center gap-2 rounded-lg sm:w-64 sm:justify-start border border-line bg-surface px-2.5 text-xs text-fg-subtle transition-colors hover:border-line-strong hover:text-fg-muted`,children:[(0,L.jsx)(B,{name:`search`,size:14}),(0,L.jsx)(`span`,{className:`hidden flex-1 text-left sm:inline`,children:`Search or jump to…`}),(0,L.jsxs)(`span`,{className:`hidden items-center gap-1 sm:flex`,children:[(0,L.jsx)(nc,{children:uc?`⌘`:`Ctrl`}),(0,L.jsx)(nc,{children:`K`})]})]}),e&&(0,L.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`flex size-8 items-center justify-center rounded-lg text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg`,title:`Open in new tab`,"aria-label":`Open in new tab`,children:(0,L.jsx)(B,{name:`external`,size:14})})]})]})}function fc({popoutUrl:e,children:t}){let{phase:n}=V(),[r,i]=(0,x.useState)(!1),[a,o]=(0,x.useState)(!1),{pathname:s}=Ei();(0,x.useEffect)(()=>o(!1),[s]);let c=n===`idle`;return(0,L.jsxs)(`div`,{className:`flex h-[100dvh] bg-canvas text-fg`,children:[(0,L.jsx)(Ni,{open:a,onClose:()=>o(!1)}),(0,L.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,L.jsx)(dc,{popoutUrl:e,onOpenPalette:()=>i(!0),onOpenNav:()=>o(!0)}),(0,L.jsx)(`main`,{className:Gn(`min-h-0 w-full flex-1 overflow-y-auto overscroll-contain px-4 pt-6 sm:px-6 sm:pt-8 md:pb-8 lg:px-10`,c?`pb-[calc(50px+env(safe-area-inset-bottom)+1.5rem)]`:`pb-[max(1.5rem,env(safe-area-inset-bottom))]`),children:t})]}),c&&(0,L.jsx)(sc,{}),(0,L.jsx)(tc,{}),(0,L.jsx)(oc,{open:r,onOpenChange:i})]})}function pc({popoutUrl:e,basePath:t}={}){return(0,L.jsx)(Ti,{basePath:t,children:(0,L.jsxs)(pi,{children:[(0,L.jsx)(Qs,{}),(0,L.jsx)(mc,{popoutUrl:e})]})})}function mc({popoutUrl:e}){let{backendError:t,backendRetrying:n}=V(),{retryBackend:r}=H();return t?(0,L.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-canvas px-4`,children:(0,L.jsxs)(`div`,{className:`max-w-md w-full bg-red-950/40 border border-red-800 rounded-lg p-6 text-center`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium text-red-200 mb-2`,children:`Forge backend unreachable`}),(0,L.jsx)(`p`,{className:`text-sm text-red-300/80 mb-4 break-words`,children:t}),(0,L.jsx)(`button`,{onClick:r,disabled:n,className:`bg-red-800 hover:bg-red-700 disabled:opacity-50 text-on-accent text-sm font-medium px-4 py-2 rounded-lg transition-colors`,children:n?`Retrying…`:`Retry`})]})}):(0,L.jsx)(fc,{popoutUrl:e,children:(0,L.jsx)(hc,{})})}function hc(){let{phase:e}=V(),{pathname:t}=Ei();if(e===`idle`){if(t.startsWith(`/settings`))return(0,L.jsx)(Zs,{});if(t.startsWith(`/members`))return(0,L.jsx)(oa,{});if(t.startsWith(`/audit`))return(0,L.jsx)(na,{})}switch(e){case`idle`:return(0,L.jsx)(lo,{});case`selected`:return(0,L.jsx)(Es,{});case`analyzing`:return(0,L.jsx)(ya,{});case`reviewing`:case`applying`:return(0,L.jsx)(ps,{});case`monitoring`:return(0,L.jsx)(qo,{});default:return null}}(0,zn.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(x.StrictMode,{children:(0,L.jsx)(Bn,{children:(0,L.jsx)(rr,{children:(0,L.jsx)(gn,{children:(0,L.jsx)(`div`,{className:`min-h-screen bg-canvas`,children:(0,L.jsx)(Hi,{children:(0,L.jsx)(pc,{})})})})})})}));