github-issue-tower-defence-management 2.12.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/bin/adapter/entry-points/console/ui-dist/assets/{index-CvJgSVoN.js → index-D6QOQvoN.js} +1 -1
- package/bin/adapter/entry-points/console/ui-dist/index.html +1 -1
- package/package.json +1 -1
- package/src/adapter/entry-points/console/ui/src/features/console/components/operations/ConsoleOkAndAwaitingWorkspaceActions.test.tsx +12 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/operations/ConsoleOkAndAwaitingWorkspaceActions.tsx +1 -9
- package/src/adapter/entry-points/console/ui-dist/assets/{index-CvJgSVoN.js → index-D6QOQvoN.js} +1 -1
- package/src/adapter/entry-points/console/ui-dist/index.html +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.12.1](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v2.12.0...v2.12.1) (2026-08-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **console:** apply green approve style to ok & Awaiting Workspace button ([#1876](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/issues/1876)) ([248b997](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/commit/248b997a613e16f5c6990aec67885a1d4ebfa79e)), closes [HiromiShikata/umino-corporait-operation#31087](https://github.com/HiromiShikata/umino-corporait-operation/issues/31087)
|
|
7
|
+
|
|
1
8
|
# [2.12.0](https://github.com/HiromiShikata/npm-cli-github-issue-tower-defence-management/compare/v2.11.0...v2.12.0) (2026-08-30)
|
|
2
9
|
|
|
3
10
|
|
package/bin/adapter/entry-points/console/ui-dist/assets/{index-CvJgSVoN.js → index-D6QOQvoN.js}
RENAMED
|
@@ -85,4 +85,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
85
85
|
`)}),o+=1,r=[])};for(let e of t){if(a){r.push(e),Yc(e)&&(a=!1);continue}if(i===null&&qc(e)){s(),i=[];continue}if(i!==null){if(Yc(e)){n.push({kind:`mermaid`,key:`mermaid:${o}`,code:i.join(`
|
|
86
86
|
`)}),o+=1,i=null;continue}i.push(e);continue}if(Jc(e)){r.push(e),a=!0;continue}r.push(e)}return i!==null&&r.push("```mermaid",...i),s(),n},Zc=({code:e,label:t=`Copy code`})=>(0,S.jsx)(vn,{value:e,idleText:t,idleAriaLabel:t,copiedAriaLabel:`Code copied to clipboard`,className:`console-copy-code-button`}),Qc=`https://cdn.jsdelivr.net/npm/mermaid@10.9.6/dist/mermaid.min.js`,$c=null,el=0,tl=e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#0d1117`,primaryColor:`#161b22`,primaryTextColor:`#e6edf3`,primaryBorderColor:`#30363d`,lineColor:`#8b949e`,fontSize:`14px`}}),e),nl=()=>$c===null?window.mermaid===void 0?($c=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=Qc,n.async=!0,n.onload=()=>{if(window.mermaid===void 0){t(Error(`mermaid failed to load`));return}e(tl(window.mermaid))},n.onerror=()=>t(Error(`mermaid script failed to load`)),document.head.appendChild(n)}),$c):($c=Promise.resolve(tl(window.mermaid)),$c):$c,rl=async e=>{let t=await nl();el+=1;let n=`console-mermaid-${el}`,{svg:r}=await t.render(n,e);return Yo.sanitize(r,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`foreignObject`]})},il=.5,al=e=>Number.isNaN(e)||e<1?1:e>6?6:e,ol=e=>al(al(e)+il),sl=e=>al(al(e)-il),cl=e=>al(e)<=1,ll=e=>al(e)>=6,ul=e=>`${Math.round(al(e)*100)}%`,dl=e=>`${al(e)*100}%`,fl=({svg:e,onClose:t})=>{let[n,r]=(0,_.useState)(1),i=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=i.current;if(t===null)return;t.innerHTML=e;let n=t.querySelector(`svg`);n!==null&&(n.style.removeProperty(`max-width`),n.style.setProperty(`width`,`100%`),n.style.setProperty(`height`,`auto`))},[e]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[t]),(0,S.jsxs)(`div`,{className:`console-mermaid-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Enlarged diagram`,children:[(0,S.jsxs)(`div`,{className:`console-mermaid-modal-bar`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom out`,disabled:cl(n),onClick:()=>r(sl(n)),children:`−`}),(0,S.jsx)(`span`,{className:`console-mermaid-modal-scale`,children:ul(n)}),(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom in`,disabled:ll(n),onClick:()=>r(ol(n)),children:`+`}),(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-close`,"aria-label":`Close enlarged diagram`,onClick:t,children:`✕`})]}),(0,S.jsx)(`div`,{className:`console-mermaid-modal-viewport`,children:(0,S.jsx)(`div`,{ref:i,className:`console-mermaid-modal-canvas`,style:{width:dl(n)}})})]})},pl=({code:e})=>{let[t,n]=(0,_.useState)({status:`loading`}),[r,i]=(0,_.useState)(!1),a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=!1;return n({status:`loading`}),rl(e).then(e=>{t||n({status:`ready`,svg:e})}).catch(e=>{t||n({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{let e=a.current;e!==null&&(e.innerHTML=t.status===`ready`?t.svg:``)},[t]),t.status===`loading`?(0,S.jsx)(`div`,{className:`console-mermaid-loading`,children:`Rendering diagram...`}):t.status===`error`?(0,S.jsxs)(`div`,{className:`console-mermaid`,children:[(0,S.jsxs)(`div`,{className:`console-mermaid-error`,children:[`Mermaid render error: `,t.message]}),(0,S.jsx)(`pre`,{className:`console-mermaid-source`,children:(0,S.jsx)(`code`,{children:e})})]}):(0,S.jsxs)(`div`,{className:`console-mermaid`,children:[(0,S.jsx)(`div`,{ref:a,className:`console-mermaid-rendered`}),(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-enlarge`,onClick:()=>i(!0),children:`Enlarge diagram`}),r&&(0,S.jsx)(fl,{svg:t.svg,onClose:()=>i(!1)})]})},ml=e=>{let t=e.querySelectorAll(`a[href]`),n=[];return t.forEach((e,t)=>{let r=e.getAttribute(`href`)??``;if(ya(r)===null)return;let i=e.textContent??r,a=document.createElement(`span`);a.className=`console-markdown-reference-host`,e.replaceWith(a),n.push({key:`${t}:${r}`,host:a,href:r,fallbackText:i})}),n},hl=e=>{let t=e.querySelectorAll(`pre > code`),n=[];return t.forEach((e,t)=>{let r=e.parentElement;if(r===null)return;let i=e.textContent??``,a=document.createElement(`div`);a.className=`console-markdown-code-block`;let o=document.createElement(`div`);o.className=`console-markdown-code-copy-host`,r.replaceWith(a),a.append(o,r),n.push({key:`code:${t}`,host:o,code:i})}),n},gl=({source:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,_.useMemo)(()=>{let n=Kc(e,r);return t===void 0?n:Ta(n,t)},[e,t,r]),a=(0,_.useRef)(null),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)([]);return(0,_.useEffect)(()=>{let e=a.current;e!==null&&(e.innerHTML=i,l(hl(e)),s(n===void 0?[]:ml(e)))},[i,n]),(0,S.jsxs)(`div`,{ref:a,className:`console-markdown`,children:[c.map(e=>(0,v.createPortal)((0,S.jsx)(Zc,{code:e.code}),e.host,e.key)),n!==void 0&&o.map(e=>(0,v.createPortal)(n(e.href,e.fallbackText),e.host,e.key))]})},_l=({body:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,_.useMemo)(()=>Xc(e),[e]);return e.trim()===``?(0,S.jsx)(`p`,{className:`console-markdown-empty`,children:`No description provided.`}):(0,S.jsx)(`div`,{className:`console-markdown-view`,children:i.map(e=>e.kind===`mermaid`?(0,S.jsx)(pl,{code:e.code},e.key):(0,S.jsx)(gl,{source:e.source,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r},e.key))})},vl=({title:e,count:t=null,defaultCollapsed:n=!1,headerAction:r,children:i})=>{let[a,o]=(0,_.useState)(n),s=t===null?e:`${e} (${t})`;return(0,S.jsxs)(`section`,{className:`console-panel`,children:[(0,S.jsxs)(`header`,{className:`console-panel-header`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`console-panel-toggle`,"aria-expanded":!a,onClick:()=>o(e=>!e),children:[(0,S.jsx)(`span`,{className:`console-panel-caret`,children:a?`▸`:`▾`}),(0,S.jsx)(`span`,{className:`console-panel-title`,children:s})]}),r!==void 0&&(0,S.jsx)(`div`,{className:`console-panel-action`,children:r})]}),!a&&(0,S.jsx)(`div`,{className:`console-panel-body`,children:i})]})},yl=e=>{switch(e){case`added`:return{label:`A`,color:`#3fb950`};case`modified`:return{label:`M`,color:`#d29922`};case`removed`:return{label:`D`,color:`#f85149`};case`renamed`:return{label:`R`,color:`#a371f7`};case`changed`:return{label:`M`,color:`#d29922`};default:return{label:`?`,color:`#8b949e`}}},bl=()=>({directories:new Map,files:[]}),xl=e=>e.split(`/`).filter(e=>e!==``),Sl=(e,t)=>e.name.localeCompare(t.name),Cl=(e,t)=>{let n=[];e.directories.forEach((e,r)=>{let i=t===``?r:`${t}/${r}`;n.push({kind:`directory`,name:r,path:i,children:Cl(e,i)})}),n.sort(Sl);let r=e.files.map(e=>({kind:`file`,name:xl(e.path).at(-1)??e.path,path:e.path,file:e}));return r.sort(Sl),[...n,...r]},wl=e=>{let t=bl();for(let n of e){let e=xl(n.path);if(e.length===0){t.files.push(n);continue}let r=e.slice(0,-1),i=t;for(let e of r){let t=i.directories.get(e);if(t===void 0){let t=bl();i.directories.set(e,t),i=t;continue}i=t}i.files.push(n)}return Cl(t,``)},Tl=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,El=e=>{let t=[],n=0,r=0;for(let i of e.split(`
|
|
87
87
|
`)){if(i.startsWith(`@@`)){let e=i.match(Tl);e!==null&&(n=Number(e[1]),r=Number(e[2])),t.push({kind:`hunk`,oldLineNumber:null,newLineNumber:null,content:i});continue}if(i.startsWith(`+`)){t.push({kind:`add`,oldLineNumber:null,newLineNumber:r,content:i}),r+=1;continue}if(i.startsWith(`-`)){t.push({kind:`del`,oldLineNumber:n,newLineNumber:null,content:i}),n+=1;continue}t.push({kind:`ctx`,oldLineNumber:n,newLineNumber:r,content:i}),n+=1,r+=1}return t},Dl=[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.avif`,`.bmp`,`.ico`],Ol=e=>{let t=e.toLowerCase();return Dl.some(e=>t.endsWith(e))},kl=e=>e.kind===`add`||e.kind===`ctx`?e.newLineNumber===null?null:{line:e.newLineNumber,side:`RIGHT`}:e.kind===`del`?e.oldLineNumber===null?null:{line:e.oldLineNumber,side:`LEFT`}:null,Al=e=>`${e.kind}:${e.oldLineNumber??`x`}:${e.newLineNumber??`x`}:${e.content}`,jl=({target:e,onSubmit:t,onClose:n})=>{let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)({kind:`idle`}),s=async()=>{let n=r.trim();if(n.length!==0&&a.kind!==`posting`){o({kind:`posting`});try{await t(e.path,e.line,e.side,n),i(``),o({kind:`posted`})}catch(e){o({kind:`error`,message:e instanceof Error?e.message:`failed to post`})}}};return(0,S.jsxs)(`div`,{className:`console-diff-composer`,children:[(0,S.jsxs)(`div`,{className:`console-diff-composer-anchor`,children:[`commenting on line `,e.line,` (`,e.side,`)`]}),a.kind===`posted`?(0,S.jsx)(`p`,{className:`console-diff-composer-posted`,children:`Comment saved.`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`textarea`,{className:`console-diff-composer-input`,rows:3,placeholder:`Leave a review comment on this line…`,value:r,onChange:e=>i(e.target.value)}),(0,S.jsxs)(`div`,{className:`console-diff-composer-controls`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-diff-composer-submit`,disabled:a.kind===`posting`,onClick:()=>{s()},children:`Comment`}),(0,S.jsx)(`button`,{type:`button`,className:`console-diff-composer-cancel`,onClick:n,children:`Cancel`}),a.kind===`posting`&&(0,S.jsx)(`span`,{className:`console-diff-composer-status`,children:`Posting…`}),a.kind===`error`&&(0,S.jsxs)(`span`,{role:`alert`,className:`console-diff-composer-status console-diff-composer-error`,children:[`Failed: `,a.message]})]})]})]})},Ml=({patch:e,path:t,rawUrl:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,_.useState)(null);if(e===null||e===``){if(t!==void 0&&n!=null){if(n.startsWith(`data:image/`))return(0,S.jsx)(`div`,{className:`console-file-diff-image`,children:(0,S.jsx)(`img`,{className:`console-file-diff-image-content`,src:n,alt:t})});if(Ol(t)&&r!==void 0)return(0,S.jsx)(`div`,{className:`console-file-diff-image`,children:(0,S.jsx)(`img`,{className:`console-file-diff-image-content`,src:r(n),alt:t})})}return(0,S.jsx)(`p`,{className:`console-file-diff-empty`,children:`(no diff / binary or too large)`})}let s=El(e),c=i!==void 0&&t!==void 0&&t.length>0,l=c?4:3;return(0,S.jsx)(`table`,{className:`console-file-diff`,children:(0,S.jsx)(`tbody`,{children:s.map(e=>{let n=Al(e),r=c?kl(e):null,s=a!==null&&r!==null&&a.line===r.line&&a.side===r.side;return(0,S.jsxs)(_.Fragment,{children:[(0,S.jsxs)(`tr`,{className:`console-diff-row console-diff-${e.kind}`,children:[c&&(0,S.jsx)(`td`,{className:`console-diff-comment-cell`,children:r!==null&&t!==void 0&&(0,S.jsx)(`button`,{type:`button`,className:`console-diff-comment-button`,"aria-label":`Comment on line ${r.line} (${r.side})`,"aria-expanded":s,onClick:()=>o(s?null:{path:t,line:r.line,side:r.side}),children:`+`})}),(0,S.jsx)(`td`,{className:`console-diff-ln`,children:e.oldLineNumber??``}),(0,S.jsx)(`td`,{className:`console-diff-ln`,children:e.newLineNumber??``}),(0,S.jsx)(`td`,{className:`console-diff-code`,children:e.content})]}),s&&i!==void 0&&a!==null&&(0,S.jsx)(`tr`,{className:`console-diff-composer-row`,children:(0,S.jsx)(`td`,{colSpan:l,children:(0,S.jsx)(jl,{target:a,onSubmit:i,onClose:()=>o(null)})})})]},n)})})})},Nl=e=>({paddingLeft:`${e*16}px`}),Pl=({file:e,depth:t,name:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,_.useState)(!1),s=yl(e.status);return(0,S.jsxs)(`li`,{className:`console-file`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`console-file-row`,style:Nl(t),"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,S.jsx)(`span`,{className:`console-file-caret`,children:a?`▾`:`▸`}),(0,S.jsx)(`span`,{className:`console-file-badge`,style:{color:s.color,borderColor:s.color},children:s.label}),(0,S.jsx)(`span`,{className:`console-file-path`,children:n}),(0,S.jsxs)(`span`,{className:`console-file-stat console-file-add`,children:[`+`,e.additions]}),(0,S.jsxs)(`span`,{className:`console-file-stat console-file-del`,children:[`-`,e.deletions]})]}),a&&(0,S.jsx)(Ml,{patch:e.patch,path:e.path,rawUrl:e.rawUrl,buildImageProxyUrl:r,onAddInlineComment:i})]})},Fl=({node:e,depth:t,buildImageProxyUrl:n,onAddInlineComment:r})=>e.kind===`file`?(0,S.jsx)(Pl,{file:e.file,depth:t,name:e.name,buildImageProxyUrl:n,onAddInlineComment:r}):(0,S.jsxs)(`li`,{className:`console-file-tree-dir`,children:[(0,S.jsxs)(`div`,{className:`console-file-tree-dir-name`,style:Nl(t),children:[(0,S.jsx)(`span`,{className:`console-file-tree-dir-icon`,"aria-hidden":`true`,children:`📁`}),e.name]}),(0,S.jsx)(`ul`,{className:`console-file-tree-children`,children:e.children.map(e=>(0,S.jsx)(Fl,{node:e,depth:t+1,buildImageProxyUrl:n,onAddInlineComment:r},e.path))})]}),Y=({files:e,isLoading:t,error:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{if(n!==null)return(0,S.jsx)(`p`,{className:`console-files-notloaded`,children:`Not loaded.`});if(t)return(0,S.jsx)(`p`,{className:`console-files-loading`,children:`Loading changed files...`});if(e.length===0)return(0,S.jsx)(`p`,{className:`console-files-empty`,children:`No changed files.`});let a=wl(e);return(0,S.jsx)(`ul`,{className:`console-files console-file-tree`,children:a.map(e=>(0,S.jsx)(Fl,{node:e,depth:0,buildImageProxyUrl:r,onAddInlineComment:i},e.path))})},Il=({comments:e,isLoading:t,error:n,now:r,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})=>{let[s,c]=(0,_.useState)(!1);if(n!==null)return(0,S.jsx)(`p`,{className:`console-comment-notloaded`,children:`Not loaded.`});if(t)return(0,S.jsx)(`p`,{className:`console-comment-loading`,children:`Loading comments...`});if(e.length===0)return(0,S.jsx)(`p`,{className:`console-comment-empty`,children:`No comments.`});let l=s?e:e.slice(-1);return(0,S.jsxs)(`div`,{className:`console-comment-list`,children:[!s&&e.length>1&&(0,S.jsxs)(`button`,{type:`button`,className:`console-comment-show-all`,onClick:()=>c(!0),children:[`Show all `,e.length]}),l.map(e=>(0,S.jsxs)(`article`,{className:`console-comment`,children:[(0,S.jsxs)(`header`,{className:`console-comment-header`,children:[(0,S.jsx)(`span`,{className:`console-comment-author`,children:e.author}),(0,S.jsx)(`span`,{className:`console-comment-time`,children:M(e.createdAt,r)})]}),(0,S.jsx)(_l,{body:e.body,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})]},`${e.author}:${e.createdAt}:${e.body}`))]})},X=e=>e.slice(0,7),Z=e=>e.split(`
|
|
88
|
-
`)[0],Q=({commits:e,isLoading:t,error:n,now:r})=>n===null?t?(0,S.jsx)(`p`,{className:`console-commits-loading`,children:`Loading commits...`}):e.length===0?(0,S.jsx)(`p`,{className:`console-commits-empty`,children:`No commits.`}):(0,S.jsx)(`ul`,{className:`console-commits`,children:e.map(e=>(0,S.jsxs)(`li`,{className:`console-commit`,children:[(0,S.jsx)(`span`,{className:`console-commit-message`,children:Z(e.message)}),(0,S.jsx)(`span`,{className:`console-commit-sha`,children:X(e.sha)}),(0,S.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,S.jsx)(`span`,{className:`console-commit-time`,children:M(e.authoredAt,r)})]},e.sha))}):(0,S.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Ll=({url:e,label:t=`Copy URL`})=>(0,S.jsx)(vn,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),Rl=e=>{let t=new Map;for(let n of e){let e=t.get(n.message);if(e===void 0){t.set(n.message,[n.section]);continue}e.push(n.section)}return Array.from(t,([e,t])=>({message:e,sections:t}))},zl=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,Bl=({failures:e})=>e.length===0?null:(0,S.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:Rl(e).map(e=>(0,S.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,zl(e.sections),`:`,` `,e.message]},e.message))}),Vl={MERGEABLE:{color:`GREEN`,label:`No conflict`,title:`This pull request has no merge conflicts`,modifier:`console-detail-mergeable-chip-ok`},CONFLICTING:{color:`RED`,label:`Conflict`,title:`This pull request has merge conflicts`,modifier:`console-detail-mergeable-chip-conflict`},UNKNOWN:{color:`GRAY`,label:`Checking merge status`,title:`GitHub has not finished computing the merge status yet`,modifier:`console-detail-mergeable-chip-unknown`}},Hl=({mergeableStatus:e})=>{let t=Vl[e],n=k(t.color);return(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-mergeable-chip ${t.modifier}`,style:{color:n.fg,borderColor:n.border,backgroundColor:n.bg},title:t.title,children:t.label})},Ul=e=>{let t=k(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},Wl=({isPassedAllCiJob:e,isCiStateSuccess:t,isBranchOutOfDate:n,missingRequiredCheckNames:r})=>{let i=e&&t,a=i?`GREEN`:`RED`,o=i?`CI passing`:`CI failing`,s=!i&&r.length>0?`missing: ${r.join(`, `)}`:null;return(0,S.jsxs)(`span`,{className:`console-detail-pr-status`,children:[(0,S.jsxs)(`span`,{className:`console-detail-status-chip console-detail-ci-chip`,style:Ul(a),title:s??o,children:[o,s!==null&&(0,S.jsxs)(`span`,{className:`console-detail-ci-missing`,children:[` `,`(`,s,`)`]})]}),n&&(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-outofdate-chip`,style:Ul(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},Gl=({pullRequest:e,body:t,bodyIsLoading:n,files:r,filesAreLoading:i,filesError:a,commits:o,commitsAreLoading:s,commitsError:c,now:l,buildImageProxyUrl:u,renderReferenceLink:d,onAddInlineComment:f})=>{let p=e.summary,m=ya(e.url),h=m===null?void 0:{owner:m.owner,repo:m.repo},g=i||a!==null?null:r.length,_=s||c!==null?null:o.length;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`console-pr-header`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-pr-section-title`,target:`_blank`,rel:`noopener noreferrer`,children:p?.title??e.url}),e.isDraft&&(0,S.jsx)(`span`,{className:`console-pr-section-state`,children:`draft`}),(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.isPassedAllCiJob,isCiStateSuccess:e.isCiStateSuccess,isBranchOutOfDate:e.isBranchOutOfDate,missingRequiredCheckNames:e.missingRequiredCheckNames}),(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),(0,S.jsx)(Ll,{url:e.url,label:`Copy PR URL`}),(0,S.jsxs)(`div`,{className:`console-pr-statbar`,children:[m!==null&&(0,S.jsxs)(`span`,{className:`console-pr-repo`,children:[m.owner,`/`,m.repo]}),e.branchName!==null&&(0,S.jsx)(`span`,{className:`console-pr-branch`,children:e.branchName}),p!==null&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`console-pr-add`,children:[`+`,p.additions]}),(0,S.jsxs)(`span`,{className:`console-pr-del`,children:[`-`,p.deletions]}),(0,S.jsxs)(`span`,{className:`console-pr-files-count`,children:[p.changedFiles,` files`]})]})]})]}),(0,S.jsx)(vl,{title:`Description`,children:n?(0,S.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,S.jsx)(vl,{title:`Changed files`,count:g,children:(0,S.jsx)(Y,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,S.jsx)(vl,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:o,isLoading:s,error:c,now:l})})]})},Kl=({item:e,storyName:t,storyColorEnum:n,overlayStatus:r,statusOptions:i,state:a,body:o,bodyIsLoading:s,bodyError:c,comments:l,commentsAreLoading:u,commentsError:d,files:f,filesAreLoading:p,filesError:m,commits:h,commitsAreLoading:g,commitsError:_,stateError:v,pullRequestStatus:y,pullRequestStatusError:b,relatedPullRequests:x,relatedPullRequestsError:C,now:w,commentComposer:T,operationBar:ee,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne})=>{let D=a?.state??`open`,re=a?.merged??!1,O=!e.isPr&&D===`closed`?`Closed`:null,ie=ba(e.nameWithOwner)??void 0,ae=k(n),A=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,j=A===null?null:k(A.color),oe=p||m!==null?null:f.length,N=u||d!==null?null:l.length,P=g||_!==null?null:h.length,ce=e=>{let t=ya(e);return t===null?e:`PR #${t.number}`},I=[{section:`item state`,message:v},{section:`pull request status`,message:e.isPr?b:null},{section:`description`,message:c},{section:`comments`,message:d},{section:`changed files`,message:e.isPr?m:null},{section:`commits`,message:e.isPr?_:null},{section:`related pull requests`,message:e.isPr?null:C},...x.flatMap(e=>[{section:`changed files of ${ce(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${ce(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),le=e.isPr&&y?.found?[{url:e.url,mergeableStatus:y.mergeableStatus}]:[];return(0,S.jsxs)(`article`,{className:`console-detail`,children:[(0,S.jsxs)(`h2`,{className:`console-detail-title`,children:[(0,S.jsx)(F,{isPr:e.isPr,state:D,merged:re,isDraft:!1,stateReason:``}),(0,S.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}),(0,S.jsx)(`span`,{className:`console-detail-number`,children:e.isPr?`PR #${e.number}`:`#${e.number}`})]}),(0,S.jsxs)(`div`,{className:`console-detail-topline`,children:[A!==null&&j!==null&&(0,S.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:j.fg,borderColor:j.border,backgroundColor:j.bg},children:A.name}),e.agent!==null&&e.agent!==``&&(0,S.jsx)(`span`,{className:`console-detail-agent-chip`,children:e.agent}),t!==null&&(0,S.jsxs)(`span`,{className:`console-storytag`,children:[(0,S.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:ae.dot}}),t]}),e.isPr&&y?.found&&(0,S.jsx)(Wl,{isPassedAllCiJob:y.isPassedAllCiJob,isCiStateSuccess:y.isCiStateSuccess,isBranchOutOfDate:y.isBranchOutOfDate,missingRequiredCheckNames:y.missingRequiredCheckNames}),!e.isPr&&x.map(e=>(0,S.jsxs)(`span`,{className:`console-related-pr-group`,children:[x.length>1&&(0,S.jsx)(`span`,{className:`console-related-pr-label`,children:ce(e.pullRequest.url)}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,S.jsx)(Hl,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),le.map(e=>(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus},e.url)),O!==null&&(0,S.jsx)(`span`,{className:`console-detail-closed-label`,children:O})]}),(0,S.jsx)(Bl,{failures:I}),(0,S.jsxs)(`div`,{className:`console-detail-subbar`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-detail-link`,target:`_blank`,rel:`noopener noreferrer`,children:e.isPr?`PR #${e.number}`:`Issue #${e.number}`}),(0,S.jsx)(`span`,{className:`console-detail-repo`,children:e.repo}),(0,S.jsx)(`span`,{className:`console-detail-pill`,children:e.isPr?`PR`:`Issue`}),(0,S.jsx)(Ll,{url:e.url})]}),e.labels.length>0&&(0,S.jsx)(`div`,{className:`console-detail-labels`,children:e.labels.map(e=>(0,S.jsx)(`span`,{className:`console-label-chip`,children:e},e))}),(0,S.jsxs)(`div`,{className:`console-detail-createdat`,title:se(e.createdAt),children:[`opened `,M(e.createdAt,w)]}),(0,S.jsx)(vl,{title:`Description`,headerAction:(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),children:c===null?s?(0,S.jsx)(`p`,{className:`console-detail-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:o,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie}):(0,S.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})}),e.isPr&&(0,S.jsx)(vl,{title:`Changed files`,count:oe,children:(0,S.jsx)(Y,{files:f,isLoading:p,error:m,onAddInlineComment:ne})}),(0,S.jsx)(vl,{title:`Comments`,count:N,defaultCollapsed:e.isPr,children:(0,S.jsx)(Il,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie})}),e.isPr&&(0,S.jsx)(vl,{title:`Commits`,count:P,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&x.map(e=>(0,S.jsx)(Gl,{pullRequest:e.pullRequest,body:e.pullRequest.summary?.body??``,bodyIsLoading:!1,files:e.files,filesAreLoading:e.filesAreLoading,filesError:e.filesError,commits:e.commits,commitsAreLoading:e.commitsAreLoading,commitsError:e.commitsError,now:w,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne},e.pullRequest.url)),(0,S.jsxs)(`div`,{className:`console-detail-dock`,children:[(0,S.jsx)(`div`,{className:`console-detail-dock-composer`,children:T}),(0,S.jsx)(`div`,{className:`console-actionbar`,children:ee})]})]})},ql=({onClose:e})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close_not_planned`),children:`Close as not planned`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close`),children:`Close`})]}),Jl=({isManualTriage:e,onSetNextActionDate:t})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1hour`),children:`+1 hour`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3hours`),children:`+3 hours`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1day`),children:`+1 day`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1week`),children:e?`+1 week and skip`:`+1 week`})]}),Yl=`awaiting workspace`,Xl=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===Yl);if(n===void 0)return null;let r=k(n.color);return(0,S.jsx)(`div`,{className:`console-op-group`,children:(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:r.fg,borderColor:r.border,backgroundColor:r.bg},onClick:()=>t(n),children:`ok & Awaiting Workspace`})})},Zl=[{action:`unnecessary`,label:`Unnecessary`,variant:`unneeded`},{action:`totally_wrong`,label:`Totally wrong`,variant:`wrong`},{action:`request_changes`,label:`Reject`,variant:`reject`},{action:`approve_and_merge`,label:`Approve & Merge`,variant:`approve`}],Ql=`Reject needs an inline comment on the diff.`,$l=({onReview:e,rejectEnabled:t})=>(0,S.jsxs)(`div`,{className:`console-op-group console-op-group-review`,children:[!t&&(0,S.jsx)(`p`,{className:`console-op-requirement`,children:Ql}),Zl.map(n=>{let r=n.action===`request_changes`&&!t;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-${n.variant}`,disabled:r,onClick:()=>e(n.action),children:n.label},n.action)})]}),eu=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},tu=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=ir.map(t=>({name:t,option:eu(e,t)})).filter(e=>e.option!==null);return r.length===0?null:(0,S.jsx)(`div`,{className:`console-op-group`,children:r.map(({name:e,option:r})=>{let i=k(r.color),a=e===rr;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:i.fg,borderColor:i.border,backgroundColor:i.bg},onClick:()=>a?n(r):t(r),children:r.name},r.id)})})},nu=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,handlers:i})=>(0,S.jsxs)(`div`,{className:`console-operation-bar`,children:[(0,S.jsx)(Xl,{statusOptions:r,onOkAndAwaitingWorkspace:i.onOkAndAwaitingWorkspace}),t&&(0,S.jsx)($l,{onReview:i.onReview,rejectEnabled:n}),(0,S.jsx)(Jl,{isManualTriage:ar(e),onSetNextActionDate:i.onSetNextActionDate}),(0,S.jsx)(tu,{statusOptions:r,onSetStatus:i.onSetStatus,onSetInTmuxByHuman:i.onSetInTmuxByHuman}),(0,S.jsx)(ql,{onClose:i.onClose})]}),ru=(e,t,n,r)=>{let i=t===null?void 0:e.peek(t),[a,o]=(0,_.useState)(i??r),[s,c]=(0,_.useState)(t!==null&&i===void 0),[l,u]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(t===null||n===null)return;let r=e.peek(t);if(r!==void 0){o(r),c(!1),u(null);return}let i=!1;return c(!0),u(null),e.load(t,n).then(e=>{i||(o(e),c(!1))}).catch(e=>{i||(u(e instanceof Error?e.message:String(e)),c(!1))}),()=>{i=!0}},[e,t,n]),{data:a,isLoading:s,error:l}},iu=[],au=[],ou=[],su=[],cu={state:`open`,merged:!1,isPullRequest:!1,title:``},lu={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},uu=(e,t)=>{let n=t===null?null:`${t.repo}#${t.number}`,r=t===null?null:t.url,i=t?.isPr??!1,a=ru(e.body,n,r,``),o=ru(e.state,n,r,cu),s=ru(e.comments,n,r,iu),c=ru(e.files,i?n:null,i?r:null,au),l=ru(e.commits,i?n:null,i?r:null,ou),u=ru(e.prStatus,i?n:null,i?r:null,lu),d=!i&&(t?.relatedOpenPullRequestUrls.length??0)>0,f=ru(e.relatedPrs,d?n:null,d?r:null,su),[p,m]=(0,_.useState)([]);return(0,_.useEffect)(()=>{if(i||f.data.length===0){m([]);return}let t=!1,n=f.data.map(e=>({pullRequest:e,files:au,filesAreLoading:!0,filesError:null,commits:ou,commitsAreLoading:!0,commitsError:null}));m(n);let r=(e,n)=>{t||m(t=>t.map(t=>t.pullRequest.url===e?{...t,...n}:t))};for(let t of f.data){let n=t.url;e.files.load(n,t.url).then(e=>r(t.url,{files:e,filesAreLoading:!1})).catch(e=>r(t.url,{filesAreLoading:!1,filesError:e instanceof Error?e.message:String(e)})),e.commits.load(n,t.url).then(e=>r(t.url,{commits:e,commitsAreLoading:!1})).catch(e=>r(t.url,{commitsAreLoading:!1,commitsError:e instanceof Error?e.message:String(e)}))}return()=>{t=!0}},[e,i,f.data]),{state:o.data,body:a.data,bodyIsLoading:a.isLoading,bodyError:a.error,comments:s.data,commentsAreLoading:s.isLoading,commentsError:s.error,files:c.data,filesAreLoading:c.isLoading,filesError:c.error,commits:l.data,commitsAreLoading:l.isLoading,commitsError:l.error,stateError:o.error,pullRequestStatus:i?u.data:null,pullRequestStatusError:i?u.error:null,relatedPullRequests:p,relatedPullRequestsError:i?null:f.error}},du=e=>JSON.stringify([e.author,e.createdAt,e.body]),fu=(e,t)=>{let n=new Set(e.map(du));return[...e,...t.filter(e=>!n.has(du(e)))]},pu=({href:e,fallbackText:t,state:n})=>n===null||n.title.trim()===``?(0,S.jsx)(`a`,{className:`console-markdown-reference console-markdown-reference-plain`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,S.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,S.jsx)(F,{...xa(n)}),(0,S.jsx)(`span`,{className:`console-markdown-reference-title`,children:n.title})]}),mu=(e,t)=>{let[n,r]=(0,_.useState)(()=>e.peek(t)??null);return(0,_.useEffect)(()=>{let n=e.peek(t);if(n!==void 0){r(n);return}let i=!1;return r(null),e.load(t,t).then(e=>{i||r(e)}).catch(()=>{i||r(null)}),()=>{i=!0}},[e,t]),n},hu=({cache:e,href:t,fallbackText:n})=>{let r=mu(e,t);return(0,S.jsx)(pu,{href:t,fallbackText:n,state:r})},gu=({tab:e,item:t,caches:n,operations:r,statusOptions:i,storyColors:a,storyName:o,overlayStatus:s,now:c,initialCommentDraft:l,onCommentDraftChange:u,onQueueAction:d})=>{let f=uu(n,t),p=(0,_.useCallback)(e=>wa(e,t.url),[t.url]),m=(0,_.useCallback)((e,t)=>(0,S.jsx)(hu,{cache:n.state,href:e,fallbackText:t}),[n.state]),h=t.isPr||t.relatedOpenPullRequestUrls.length>0||f.relatedPullRequests.length>0,[g,v]=(0,_.useState)([]),y=(0,_.useCallback)(async(e,t,n,r)=>{v(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[b,x]=(0,_.useState)([]),C=(0,_.useCallback)(async e=>{let n=await r.addComment(t,e);return x(e=>[...e,n]),n},[t,r]),w={onReview:e=>{let n=t.isPr?t.url:f.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,i=e===`request_changes`?g:[];d({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,i)})},onSetNextActionDate:e=>{d({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e)})},onSetStory:e=>{d({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e)})},onSetStatus:e=>{d({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e)})},onSetInTmuxByHuman:e=>{d({kind:{type:`set_in_tmux_by_human`,optionName:e.name},item:t,commit:()=>r.setInTmuxByHuman(t,e)})},onClose:e=>{d({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e)})},onOkAndAwaitingWorkspace:e=>{d({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e)})}},T=i.find(e=>e.name===`Awaiting Workspace`)??null,ee=T===null?void 0:async e=>{let t=await C(e);return w.onSetStatus(T),t},te=o??(t.story.trim()===``?null:t.story),ne=te===null?null:E(a,te);return(0,S.jsx)(Kl,{item:t,storyName:te,storyColorEnum:ne,overlayStatus:s,statusOptions:i,state:f.state,stateError:f.stateError,body:f.body,bodyIsLoading:f.bodyIsLoading,bodyError:f.bodyError,comments:fu(f.comments,b),commentsAreLoading:f.commentsAreLoading,commentsError:f.commentsError,files:f.files,filesAreLoading:f.filesAreLoading,filesError:f.filesError,commits:f.commits,commitsAreLoading:f.commitsAreLoading,commitsError:f.commitsError,pullRequestStatus:f.pullRequestStatus,pullRequestStatusError:f.pullRequestStatusError,relatedPullRequests:f.relatedPullRequests,relatedPullRequestsError:f.relatedPullRequestsError,now:c,buildImageProxyUrl:p,renderReferenceLink:m,onAddInlineComment:y,commentComposer:(0,S.jsx)(_a,{initiallyOpen:!0,initialDraft:l,onSubmit:C,onDraftChange:u,onSubmitAndMoveToAwaitingWorkspace:ee,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,S.jsx)(nu,{tab:e,item:t,hasPullRequest:h,rejectEnabled:g.length>0,statusOptions:i,handlers:w})})},_u=()=>{let e={};for(let t of b)e[t.name]=0;return e},vu=`console`,yu=()=>{let e=Pi(),t=li(),n=Qn(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o}=ta(e,r),{timerMode:s,projectMinutes:c,isOpen:l,draftTimerMode:u,draftProjectMinutes:d,openSettings:f,closeSettings:p,saveSettings:m,toggleDraftTimerMode:h,changeDraftMinutes:g}=sa(),{pjcodes:v,isLoading:y}=Fi(),{isTimerExpired:x}=Ii(e),C=Mi(e??vu),w=(0,_.useMemo)(()=>{let e=_u();for(let t of b){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=yi(n.items,xi(C.overlay,n.generatedAt),t.name))}return e},[i,C.overlay]),te=hi(e,w),{activeTab:E,selectedItemKey:D,openItem:O,closeItem:k,selectTab:ie}=te,ae=(0,_.useRef)(new Map),A=(0,_.useCallback)(e=>{D!==null&&(e?ae.current.set(D,e):ae.current.delete(D))},[D]),j=ti(r),oe=ki(e,E,C,j),M=gr(),se=Date.now(),N=i[E],P=(0,_.useMemo)(()=>N===null?[]:bi(N.items,xi(C.overlay,N.generatedAt),E),[N,C.overlay,E]),F=(0,_.useMemo)(()=>P.map(e=>_i(e)),[P]),ce=N?.storyOrder??[],I=(0,_.useMemo)(()=>re(P,C.overlay,ce,N?.generatedAt??null),[P,C.overlay,ce,N]),ue=N?.storyColors??{},de=N?.statusOptions??[],fe=N?.agentOptions??[],R=N?.generatedAt??null,pe=N?.fromCache??!1,[me,he]=(0,_.useState)(null),ge=(0,_.useMemo)(()=>D===null||N===null?null:N.items.find(e=>e.projectItemId===D)??null,[D,N]);si(j,ge,P),(0,_.useEffect)(()=>{D!==null&&window.scrollTo({top:0})},[D]),(0,_.useEffect)(()=>{if(e===null&&s&&v.length>0){let e=oa(v,null,c);e!==null&&ca(`/projects/${e}`)}},[e,s,v,c]);let _e=w[E],ve=(0,_.useRef)({tab:E,count:_e});(0,_.useEffect)(()=>{let e=ve.current;if(ve.current={tab:E,count:_e},e.tab===E&&e.count>0&&_e===0){let e=ui(E,w);e!==null&&(ie(e),k())}},[E,_e,w,ie,k]);let ye=ge===null?null:Si(C.overlay,ge,i[E]?.generatedAt??null),be=ge===null?null:ne(ge,C.overlay,i[E]?.generatedAt??null),xe=(0,_.useCallback)(e=>{let t=ua(F,e);t===null?k():O(t)},[F,O,k]),Se=(0,_.useCallback)(t=>{if(n.status===`on`){M.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=_i(t.item);M.enqueue({message:dr(t.kind,t.item,E),color:lr(t.kind),commit:t.commit,advance:()=>{if(ur(t.kind,E)){if(s&&x(c[e??``]??0)){let t=oa(v,e,c);t!==null&&la(`/projects/${t}`)}else xe(r)}}})},[M,E,xe,n.status,s,x,c,e,v]),Ce=Bi((0,_.useCallback)(e=>{if(D===null||e===null)return;let t=e===`next`?da(F,D):fa(F,D);t!==null&&O(t)},[D,F,O])),[we,Te]=(0,_.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),Ee=(0,_.useCallback)(()=>{Te(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),De=i.stories,Oe=De?.stories??[],ke=me!==null&&me.generatedAt===De?.generatedAt?me.stories:Oe,Ae=De?.defaultNameWithOwner??null,je=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(Ae===null)throw Error(`No repository configured for this project.`);await Jr({pjcode:e,title:n,storyOptionId:t,nameWithOwner:Ae})},[e,Ae]),Me=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Xr({pjcode:e,storyOptionId:t,direction:n});let r=ke.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<ke.length){let t=[...ke],n=t[r];t[r]=t[e],t[e]=n,he({generatedAt:De?.generatedAt,stories:t})}}},[e,ke,De?.generatedAt]),Ne=(0,_.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Hr({pjcode:e,storyName:t})},[e]),[Pe,Fe]=(0,_.useState)({}),[Ie,Le]=(0,_.useState)(null),[Re,ze]=(0,_.useState)({}),Be=(0,_.useCallback)((t,n)=>{let r=ke.find(e=>e.storyOptionId===t)?.color;if(Le(t),Fe(e=>({...e,[t]:n})),ze(e=>{let n={...e};return delete n[t],n}),e===null||Ae===null){Fe(e=>r===void 0?e:{...e,[t]:r}),ze(e=>({...e,[t]:`No project or repository configured.`})),Le(e=>e===t?null:e);return}qr({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:Ae}).catch(e=>{Fe(e=>r===void 0?e:{...e,[t]:r}),ze(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{Le(e=>e===t?null:e)})},[e,Ae,ke]);return(0,S.jsxs)(`main`,{className:`console-app`,children:[M.pending!==null&&(0,S.jsx)(Tn,{message:M.pending.message,color:M.pending.color,remainingSeconds:M.pending.remainingSeconds,progress:M.pending.progress,onUndo:M.undo}),M.error!==null&&(0,S.jsx)(En,{title:M.error.message,message:`Operation failed: ${M.error.reason}`,onDismiss:M.dismissError}),(0,S.jsx)(T,{activeTab:E,counts:w,pjcode:e,pjcodes:v,generatedAt:R,fromCache:pe,tabHref:te.tabHref,onSelectTab:te.selectTab,onSelectProject:e=>la(`/projects/${e}`),settingsButton:(0,S.jsx)(ee,{isOpen:l,timerMode:u,projectMinutes:d,pjcodes:v,isLoadingPjcodes:y,onOpen:f,onToggleTimerMode:h,onChangeMinutes:g,onSave:m,onClose:p}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff}),E===`stories`?(0,S.jsx)(wn,{stories:ke,isLoading:a,error:o,showGray:we,onCreateIssue:je,onAddStory:Ne,onSelectColor:Be,onToggleGray:Ee,onReorderStory:Me,optimisticColors:Pe,colorChangeInFlight:Ie,colorErrors:Re}):ge===null?E===`queued`?(0,S.jsx)(L,{rows:I,storyColors:ue,statusOptions:de,agentOptions:fe,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(le,{rows:I,storyColors:ue,statusOptions:de,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(`div`,{className:`console-detail-screen`,ref:Ce,children:(0,S.jsx)(gu,{tab:E,item:ge,caches:j,operations:oe,statusOptions:de,storyColors:ue,storyName:be,overlayStatus:ye,now:se,initialCommentDraft:ae.current.get(ge.projectItemId)??``,onCommentDraftChange:A,onQueueAction:Se},ge.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var bu=document.getElementById(`root`);if(bu===null)throw Error(`Root container #root not found`);(0,y.createRoot)(bu).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(yu,{})}));
|
|
88
|
+
`)[0],Q=({commits:e,isLoading:t,error:n,now:r})=>n===null?t?(0,S.jsx)(`p`,{className:`console-commits-loading`,children:`Loading commits...`}):e.length===0?(0,S.jsx)(`p`,{className:`console-commits-empty`,children:`No commits.`}):(0,S.jsx)(`ul`,{className:`console-commits`,children:e.map(e=>(0,S.jsxs)(`li`,{className:`console-commit`,children:[(0,S.jsx)(`span`,{className:`console-commit-message`,children:Z(e.message)}),(0,S.jsx)(`span`,{className:`console-commit-sha`,children:X(e.sha)}),(0,S.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,S.jsx)(`span`,{className:`console-commit-time`,children:M(e.authoredAt,r)})]},e.sha))}):(0,S.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Ll=({url:e,label:t=`Copy URL`})=>(0,S.jsx)(vn,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),Rl=e=>{let t=new Map;for(let n of e){let e=t.get(n.message);if(e===void 0){t.set(n.message,[n.section]);continue}e.push(n.section)}return Array.from(t,([e,t])=>({message:e,sections:t}))},zl=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,Bl=({failures:e})=>e.length===0?null:(0,S.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:Rl(e).map(e=>(0,S.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,zl(e.sections),`:`,` `,e.message]},e.message))}),Vl={MERGEABLE:{color:`GREEN`,label:`No conflict`,title:`This pull request has no merge conflicts`,modifier:`console-detail-mergeable-chip-ok`},CONFLICTING:{color:`RED`,label:`Conflict`,title:`This pull request has merge conflicts`,modifier:`console-detail-mergeable-chip-conflict`},UNKNOWN:{color:`GRAY`,label:`Checking merge status`,title:`GitHub has not finished computing the merge status yet`,modifier:`console-detail-mergeable-chip-unknown`}},Hl=({mergeableStatus:e})=>{let t=Vl[e],n=k(t.color);return(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-mergeable-chip ${t.modifier}`,style:{color:n.fg,borderColor:n.border,backgroundColor:n.bg},title:t.title,children:t.label})},Ul=e=>{let t=k(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},Wl=({isPassedAllCiJob:e,isCiStateSuccess:t,isBranchOutOfDate:n,missingRequiredCheckNames:r})=>{let i=e&&t,a=i?`GREEN`:`RED`,o=i?`CI passing`:`CI failing`,s=!i&&r.length>0?`missing: ${r.join(`, `)}`:null;return(0,S.jsxs)(`span`,{className:`console-detail-pr-status`,children:[(0,S.jsxs)(`span`,{className:`console-detail-status-chip console-detail-ci-chip`,style:Ul(a),title:s??o,children:[o,s!==null&&(0,S.jsxs)(`span`,{className:`console-detail-ci-missing`,children:[` `,`(`,s,`)`]})]}),n&&(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-outofdate-chip`,style:Ul(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},Gl=({pullRequest:e,body:t,bodyIsLoading:n,files:r,filesAreLoading:i,filesError:a,commits:o,commitsAreLoading:s,commitsError:c,now:l,buildImageProxyUrl:u,renderReferenceLink:d,onAddInlineComment:f})=>{let p=e.summary,m=ya(e.url),h=m===null?void 0:{owner:m.owner,repo:m.repo},g=i||a!==null?null:r.length,_=s||c!==null?null:o.length;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`console-pr-header`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-pr-section-title`,target:`_blank`,rel:`noopener noreferrer`,children:p?.title??e.url}),e.isDraft&&(0,S.jsx)(`span`,{className:`console-pr-section-state`,children:`draft`}),(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.isPassedAllCiJob,isCiStateSuccess:e.isCiStateSuccess,isBranchOutOfDate:e.isBranchOutOfDate,missingRequiredCheckNames:e.missingRequiredCheckNames}),(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),(0,S.jsx)(Ll,{url:e.url,label:`Copy PR URL`}),(0,S.jsxs)(`div`,{className:`console-pr-statbar`,children:[m!==null&&(0,S.jsxs)(`span`,{className:`console-pr-repo`,children:[m.owner,`/`,m.repo]}),e.branchName!==null&&(0,S.jsx)(`span`,{className:`console-pr-branch`,children:e.branchName}),p!==null&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`console-pr-add`,children:[`+`,p.additions]}),(0,S.jsxs)(`span`,{className:`console-pr-del`,children:[`-`,p.deletions]}),(0,S.jsxs)(`span`,{className:`console-pr-files-count`,children:[p.changedFiles,` files`]})]})]})]}),(0,S.jsx)(vl,{title:`Description`,children:n?(0,S.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,S.jsx)(vl,{title:`Changed files`,count:g,children:(0,S.jsx)(Y,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,S.jsx)(vl,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:o,isLoading:s,error:c,now:l})})]})},Kl=({item:e,storyName:t,storyColorEnum:n,overlayStatus:r,statusOptions:i,state:a,body:o,bodyIsLoading:s,bodyError:c,comments:l,commentsAreLoading:u,commentsError:d,files:f,filesAreLoading:p,filesError:m,commits:h,commitsAreLoading:g,commitsError:_,stateError:v,pullRequestStatus:y,pullRequestStatusError:b,relatedPullRequests:x,relatedPullRequestsError:C,now:w,commentComposer:T,operationBar:ee,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne})=>{let D=a?.state??`open`,re=a?.merged??!1,O=!e.isPr&&D===`closed`?`Closed`:null,ie=ba(e.nameWithOwner)??void 0,ae=k(n),A=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,j=A===null?null:k(A.color),oe=p||m!==null?null:f.length,N=u||d!==null?null:l.length,P=g||_!==null?null:h.length,ce=e=>{let t=ya(e);return t===null?e:`PR #${t.number}`},I=[{section:`item state`,message:v},{section:`pull request status`,message:e.isPr?b:null},{section:`description`,message:c},{section:`comments`,message:d},{section:`changed files`,message:e.isPr?m:null},{section:`commits`,message:e.isPr?_:null},{section:`related pull requests`,message:e.isPr?null:C},...x.flatMap(e=>[{section:`changed files of ${ce(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${ce(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),le=e.isPr&&y?.found?[{url:e.url,mergeableStatus:y.mergeableStatus}]:[];return(0,S.jsxs)(`article`,{className:`console-detail`,children:[(0,S.jsxs)(`h2`,{className:`console-detail-title`,children:[(0,S.jsx)(F,{isPr:e.isPr,state:D,merged:re,isDraft:!1,stateReason:``}),(0,S.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}),(0,S.jsx)(`span`,{className:`console-detail-number`,children:e.isPr?`PR #${e.number}`:`#${e.number}`})]}),(0,S.jsxs)(`div`,{className:`console-detail-topline`,children:[A!==null&&j!==null&&(0,S.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:j.fg,borderColor:j.border,backgroundColor:j.bg},children:A.name}),e.agent!==null&&e.agent!==``&&(0,S.jsx)(`span`,{className:`console-detail-agent-chip`,children:e.agent}),t!==null&&(0,S.jsxs)(`span`,{className:`console-storytag`,children:[(0,S.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:ae.dot}}),t]}),e.isPr&&y?.found&&(0,S.jsx)(Wl,{isPassedAllCiJob:y.isPassedAllCiJob,isCiStateSuccess:y.isCiStateSuccess,isBranchOutOfDate:y.isBranchOutOfDate,missingRequiredCheckNames:y.missingRequiredCheckNames}),!e.isPr&&x.map(e=>(0,S.jsxs)(`span`,{className:`console-related-pr-group`,children:[x.length>1&&(0,S.jsx)(`span`,{className:`console-related-pr-label`,children:ce(e.pullRequest.url)}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,S.jsx)(Hl,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),le.map(e=>(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus},e.url)),O!==null&&(0,S.jsx)(`span`,{className:`console-detail-closed-label`,children:O})]}),(0,S.jsx)(Bl,{failures:I}),(0,S.jsxs)(`div`,{className:`console-detail-subbar`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-detail-link`,target:`_blank`,rel:`noopener noreferrer`,children:e.isPr?`PR #${e.number}`:`Issue #${e.number}`}),(0,S.jsx)(`span`,{className:`console-detail-repo`,children:e.repo}),(0,S.jsx)(`span`,{className:`console-detail-pill`,children:e.isPr?`PR`:`Issue`}),(0,S.jsx)(Ll,{url:e.url})]}),e.labels.length>0&&(0,S.jsx)(`div`,{className:`console-detail-labels`,children:e.labels.map(e=>(0,S.jsx)(`span`,{className:`console-label-chip`,children:e},e))}),(0,S.jsxs)(`div`,{className:`console-detail-createdat`,title:se(e.createdAt),children:[`opened `,M(e.createdAt,w)]}),(0,S.jsx)(vl,{title:`Description`,headerAction:(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),children:c===null?s?(0,S.jsx)(`p`,{className:`console-detail-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:o,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie}):(0,S.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})}),e.isPr&&(0,S.jsx)(vl,{title:`Changed files`,count:oe,children:(0,S.jsx)(Y,{files:f,isLoading:p,error:m,onAddInlineComment:ne})}),(0,S.jsx)(vl,{title:`Comments`,count:N,defaultCollapsed:e.isPr,children:(0,S.jsx)(Il,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie})}),e.isPr&&(0,S.jsx)(vl,{title:`Commits`,count:P,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&x.map(e=>(0,S.jsx)(Gl,{pullRequest:e.pullRequest,body:e.pullRequest.summary?.body??``,bodyIsLoading:!1,files:e.files,filesAreLoading:e.filesAreLoading,filesError:e.filesError,commits:e.commits,commitsAreLoading:e.commitsAreLoading,commitsError:e.commitsError,now:w,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne},e.pullRequest.url)),(0,S.jsxs)(`div`,{className:`console-detail-dock`,children:[(0,S.jsx)(`div`,{className:`console-detail-dock-composer`,children:T}),(0,S.jsx)(`div`,{className:`console-actionbar`,children:ee})]})]})},ql=({onClose:e})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close_not_planned`),children:`Close as not planned`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close`),children:`Close`})]}),Jl=({isManualTriage:e,onSetNextActionDate:t})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1hour`),children:`+1 hour`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3hours`),children:`+3 hours`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1day`),children:`+1 day`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1week`),children:e?`+1 week and skip`:`+1 week`})]}),Yl=`awaiting workspace`,Xl=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===Yl);return n===void 0?null:(0,S.jsx)(`div`,{className:`console-op-group`,children:(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-approve`,onClick:()=>t(n),children:`ok & Awaiting Workspace`})})},Zl=[{action:`unnecessary`,label:`Unnecessary`,variant:`unneeded`},{action:`totally_wrong`,label:`Totally wrong`,variant:`wrong`},{action:`request_changes`,label:`Reject`,variant:`reject`},{action:`approve_and_merge`,label:`Approve & Merge`,variant:`approve`}],Ql=`Reject needs an inline comment on the diff.`,$l=({onReview:e,rejectEnabled:t})=>(0,S.jsxs)(`div`,{className:`console-op-group console-op-group-review`,children:[!t&&(0,S.jsx)(`p`,{className:`console-op-requirement`,children:Ql}),Zl.map(n=>{let r=n.action===`request_changes`&&!t;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-${n.variant}`,disabled:r,onClick:()=>e(n.action),children:n.label},n.action)})]}),eu=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},tu=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=ir.map(t=>({name:t,option:eu(e,t)})).filter(e=>e.option!==null);return r.length===0?null:(0,S.jsx)(`div`,{className:`console-op-group`,children:r.map(({name:e,option:r})=>{let i=k(r.color),a=e===rr;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:i.fg,borderColor:i.border,backgroundColor:i.bg},onClick:()=>a?n(r):t(r),children:r.name},r.id)})})},nu=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,handlers:i})=>(0,S.jsxs)(`div`,{className:`console-operation-bar`,children:[(0,S.jsx)(Xl,{statusOptions:r,onOkAndAwaitingWorkspace:i.onOkAndAwaitingWorkspace}),t&&(0,S.jsx)($l,{onReview:i.onReview,rejectEnabled:n}),(0,S.jsx)(Jl,{isManualTriage:ar(e),onSetNextActionDate:i.onSetNextActionDate}),(0,S.jsx)(tu,{statusOptions:r,onSetStatus:i.onSetStatus,onSetInTmuxByHuman:i.onSetInTmuxByHuman}),(0,S.jsx)(ql,{onClose:i.onClose})]}),ru=(e,t,n,r)=>{let i=t===null?void 0:e.peek(t),[a,o]=(0,_.useState)(i??r),[s,c]=(0,_.useState)(t!==null&&i===void 0),[l,u]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(t===null||n===null)return;let r=e.peek(t);if(r!==void 0){o(r),c(!1),u(null);return}let i=!1;return c(!0),u(null),e.load(t,n).then(e=>{i||(o(e),c(!1))}).catch(e=>{i||(u(e instanceof Error?e.message:String(e)),c(!1))}),()=>{i=!0}},[e,t,n]),{data:a,isLoading:s,error:l}},iu=[],au=[],ou=[],su=[],cu={state:`open`,merged:!1,isPullRequest:!1,title:``},lu={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},uu=(e,t)=>{let n=t===null?null:`${t.repo}#${t.number}`,r=t===null?null:t.url,i=t?.isPr??!1,a=ru(e.body,n,r,``),o=ru(e.state,n,r,cu),s=ru(e.comments,n,r,iu),c=ru(e.files,i?n:null,i?r:null,au),l=ru(e.commits,i?n:null,i?r:null,ou),u=ru(e.prStatus,i?n:null,i?r:null,lu),d=!i&&(t?.relatedOpenPullRequestUrls.length??0)>0,f=ru(e.relatedPrs,d?n:null,d?r:null,su),[p,m]=(0,_.useState)([]);return(0,_.useEffect)(()=>{if(i||f.data.length===0){m([]);return}let t=!1,n=f.data.map(e=>({pullRequest:e,files:au,filesAreLoading:!0,filesError:null,commits:ou,commitsAreLoading:!0,commitsError:null}));m(n);let r=(e,n)=>{t||m(t=>t.map(t=>t.pullRequest.url===e?{...t,...n}:t))};for(let t of f.data){let n=t.url;e.files.load(n,t.url).then(e=>r(t.url,{files:e,filesAreLoading:!1})).catch(e=>r(t.url,{filesAreLoading:!1,filesError:e instanceof Error?e.message:String(e)})),e.commits.load(n,t.url).then(e=>r(t.url,{commits:e,commitsAreLoading:!1})).catch(e=>r(t.url,{commitsAreLoading:!1,commitsError:e instanceof Error?e.message:String(e)}))}return()=>{t=!0}},[e,i,f.data]),{state:o.data,body:a.data,bodyIsLoading:a.isLoading,bodyError:a.error,comments:s.data,commentsAreLoading:s.isLoading,commentsError:s.error,files:c.data,filesAreLoading:c.isLoading,filesError:c.error,commits:l.data,commitsAreLoading:l.isLoading,commitsError:l.error,stateError:o.error,pullRequestStatus:i?u.data:null,pullRequestStatusError:i?u.error:null,relatedPullRequests:p,relatedPullRequestsError:i?null:f.error}},du=e=>JSON.stringify([e.author,e.createdAt,e.body]),fu=(e,t)=>{let n=new Set(e.map(du));return[...e,...t.filter(e=>!n.has(du(e)))]},pu=({href:e,fallbackText:t,state:n})=>n===null||n.title.trim()===``?(0,S.jsx)(`a`,{className:`console-markdown-reference console-markdown-reference-plain`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,S.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,S.jsx)(F,{...xa(n)}),(0,S.jsx)(`span`,{className:`console-markdown-reference-title`,children:n.title})]}),mu=(e,t)=>{let[n,r]=(0,_.useState)(()=>e.peek(t)??null);return(0,_.useEffect)(()=>{let n=e.peek(t);if(n!==void 0){r(n);return}let i=!1;return r(null),e.load(t,t).then(e=>{i||r(e)}).catch(()=>{i||r(null)}),()=>{i=!0}},[e,t]),n},hu=({cache:e,href:t,fallbackText:n})=>{let r=mu(e,t);return(0,S.jsx)(pu,{href:t,fallbackText:n,state:r})},gu=({tab:e,item:t,caches:n,operations:r,statusOptions:i,storyColors:a,storyName:o,overlayStatus:s,now:c,initialCommentDraft:l,onCommentDraftChange:u,onQueueAction:d})=>{let f=uu(n,t),p=(0,_.useCallback)(e=>wa(e,t.url),[t.url]),m=(0,_.useCallback)((e,t)=>(0,S.jsx)(hu,{cache:n.state,href:e,fallbackText:t}),[n.state]),h=t.isPr||t.relatedOpenPullRequestUrls.length>0||f.relatedPullRequests.length>0,[g,v]=(0,_.useState)([]),y=(0,_.useCallback)(async(e,t,n,r)=>{v(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[b,x]=(0,_.useState)([]),C=(0,_.useCallback)(async e=>{let n=await r.addComment(t,e);return x(e=>[...e,n]),n},[t,r]),w={onReview:e=>{let n=t.isPr?t.url:f.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,i=e===`request_changes`?g:[];d({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,i)})},onSetNextActionDate:e=>{d({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e)})},onSetStory:e=>{d({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e)})},onSetStatus:e=>{d({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e)})},onSetInTmuxByHuman:e=>{d({kind:{type:`set_in_tmux_by_human`,optionName:e.name},item:t,commit:()=>r.setInTmuxByHuman(t,e)})},onClose:e=>{d({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e)})},onOkAndAwaitingWorkspace:e=>{d({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e)})}},T=i.find(e=>e.name===`Awaiting Workspace`)??null,ee=T===null?void 0:async e=>{let t=await C(e);return w.onSetStatus(T),t},te=o??(t.story.trim()===``?null:t.story),ne=te===null?null:E(a,te);return(0,S.jsx)(Kl,{item:t,storyName:te,storyColorEnum:ne,overlayStatus:s,statusOptions:i,state:f.state,stateError:f.stateError,body:f.body,bodyIsLoading:f.bodyIsLoading,bodyError:f.bodyError,comments:fu(f.comments,b),commentsAreLoading:f.commentsAreLoading,commentsError:f.commentsError,files:f.files,filesAreLoading:f.filesAreLoading,filesError:f.filesError,commits:f.commits,commitsAreLoading:f.commitsAreLoading,commitsError:f.commitsError,pullRequestStatus:f.pullRequestStatus,pullRequestStatusError:f.pullRequestStatusError,relatedPullRequests:f.relatedPullRequests,relatedPullRequestsError:f.relatedPullRequestsError,now:c,buildImageProxyUrl:p,renderReferenceLink:m,onAddInlineComment:y,commentComposer:(0,S.jsx)(_a,{initiallyOpen:!0,initialDraft:l,onSubmit:C,onDraftChange:u,onSubmitAndMoveToAwaitingWorkspace:ee,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,S.jsx)(nu,{tab:e,item:t,hasPullRequest:h,rejectEnabled:g.length>0,statusOptions:i,handlers:w})})},_u=()=>{let e={};for(let t of b)e[t.name]=0;return e},vu=`console`,yu=()=>{let e=Pi(),t=li(),n=Qn(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o}=ta(e,r),{timerMode:s,projectMinutes:c,isOpen:l,draftTimerMode:u,draftProjectMinutes:d,openSettings:f,closeSettings:p,saveSettings:m,toggleDraftTimerMode:h,changeDraftMinutes:g}=sa(),{pjcodes:v,isLoading:y}=Fi(),{isTimerExpired:x}=Ii(e),C=Mi(e??vu),w=(0,_.useMemo)(()=>{let e=_u();for(let t of b){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=yi(n.items,xi(C.overlay,n.generatedAt),t.name))}return e},[i,C.overlay]),te=hi(e,w),{activeTab:E,selectedItemKey:D,openItem:O,closeItem:k,selectTab:ie}=te,ae=(0,_.useRef)(new Map),A=(0,_.useCallback)(e=>{D!==null&&(e?ae.current.set(D,e):ae.current.delete(D))},[D]),j=ti(r),oe=ki(e,E,C,j),M=gr(),se=Date.now(),N=i[E],P=(0,_.useMemo)(()=>N===null?[]:bi(N.items,xi(C.overlay,N.generatedAt),E),[N,C.overlay,E]),F=(0,_.useMemo)(()=>P.map(e=>_i(e)),[P]),ce=N?.storyOrder??[],I=(0,_.useMemo)(()=>re(P,C.overlay,ce,N?.generatedAt??null),[P,C.overlay,ce,N]),ue=N?.storyColors??{},de=N?.statusOptions??[],fe=N?.agentOptions??[],R=N?.generatedAt??null,pe=N?.fromCache??!1,[me,he]=(0,_.useState)(null),ge=(0,_.useMemo)(()=>D===null||N===null?null:N.items.find(e=>e.projectItemId===D)??null,[D,N]);si(j,ge,P),(0,_.useEffect)(()=>{D!==null&&window.scrollTo({top:0})},[D]),(0,_.useEffect)(()=>{if(e===null&&s&&v.length>0){let e=oa(v,null,c);e!==null&&ca(`/projects/${e}`)}},[e,s,v,c]);let _e=w[E],ve=(0,_.useRef)({tab:E,count:_e});(0,_.useEffect)(()=>{let e=ve.current;if(ve.current={tab:E,count:_e},e.tab===E&&e.count>0&&_e===0){let e=ui(E,w);e!==null&&(ie(e),k())}},[E,_e,w,ie,k]);let ye=ge===null?null:Si(C.overlay,ge,i[E]?.generatedAt??null),be=ge===null?null:ne(ge,C.overlay,i[E]?.generatedAt??null),xe=(0,_.useCallback)(e=>{let t=ua(F,e);t===null?k():O(t)},[F,O,k]),Se=(0,_.useCallback)(t=>{if(n.status===`on`){M.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=_i(t.item);M.enqueue({message:dr(t.kind,t.item,E),color:lr(t.kind),commit:t.commit,advance:()=>{if(ur(t.kind,E)){if(s&&x(c[e??``]??0)){let t=oa(v,e,c);t!==null&&la(`/projects/${t}`)}else xe(r)}}})},[M,E,xe,n.status,s,x,c,e,v]),Ce=Bi((0,_.useCallback)(e=>{if(D===null||e===null)return;let t=e===`next`?da(F,D):fa(F,D);t!==null&&O(t)},[D,F,O])),[we,Te]=(0,_.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),Ee=(0,_.useCallback)(()=>{Te(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),De=i.stories,Oe=De?.stories??[],ke=me!==null&&me.generatedAt===De?.generatedAt?me.stories:Oe,Ae=De?.defaultNameWithOwner??null,je=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(Ae===null)throw Error(`No repository configured for this project.`);await Jr({pjcode:e,title:n,storyOptionId:t,nameWithOwner:Ae})},[e,Ae]),Me=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Xr({pjcode:e,storyOptionId:t,direction:n});let r=ke.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<ke.length){let t=[...ke],n=t[r];t[r]=t[e],t[e]=n,he({generatedAt:De?.generatedAt,stories:t})}}},[e,ke,De?.generatedAt]),Ne=(0,_.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Hr({pjcode:e,storyName:t})},[e]),[Pe,Fe]=(0,_.useState)({}),[Ie,Le]=(0,_.useState)(null),[Re,ze]=(0,_.useState)({}),Be=(0,_.useCallback)((t,n)=>{let r=ke.find(e=>e.storyOptionId===t)?.color;if(Le(t),Fe(e=>({...e,[t]:n})),ze(e=>{let n={...e};return delete n[t],n}),e===null||Ae===null){Fe(e=>r===void 0?e:{...e,[t]:r}),ze(e=>({...e,[t]:`No project or repository configured.`})),Le(e=>e===t?null:e);return}qr({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:Ae}).catch(e=>{Fe(e=>r===void 0?e:{...e,[t]:r}),ze(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{Le(e=>e===t?null:e)})},[e,Ae,ke]);return(0,S.jsxs)(`main`,{className:`console-app`,children:[M.pending!==null&&(0,S.jsx)(Tn,{message:M.pending.message,color:M.pending.color,remainingSeconds:M.pending.remainingSeconds,progress:M.pending.progress,onUndo:M.undo}),M.error!==null&&(0,S.jsx)(En,{title:M.error.message,message:`Operation failed: ${M.error.reason}`,onDismiss:M.dismissError}),(0,S.jsx)(T,{activeTab:E,counts:w,pjcode:e,pjcodes:v,generatedAt:R,fromCache:pe,tabHref:te.tabHref,onSelectTab:te.selectTab,onSelectProject:e=>la(`/projects/${e}`),settingsButton:(0,S.jsx)(ee,{isOpen:l,timerMode:u,projectMinutes:d,pjcodes:v,isLoadingPjcodes:y,onOpen:f,onToggleTimerMode:h,onChangeMinutes:g,onSave:m,onClose:p}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff}),E===`stories`?(0,S.jsx)(wn,{stories:ke,isLoading:a,error:o,showGray:we,onCreateIssue:je,onAddStory:Ne,onSelectColor:Be,onToggleGray:Ee,onReorderStory:Me,optimisticColors:Pe,colorChangeInFlight:Ie,colorErrors:Re}):ge===null?E===`queued`?(0,S.jsx)(L,{rows:I,storyColors:ue,statusOptions:de,agentOptions:fe,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(le,{rows:I,storyColors:ue,statusOptions:de,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(`div`,{className:`console-detail-screen`,ref:Ce,children:(0,S.jsx)(gu,{tab:E,item:ge,caches:j,operations:oe,statusOptions:de,storyColors:ue,storyName:be,overlayStatus:ye,now:se,initialCommentDraft:ae.current.get(ge.projectItemId)??``,onCommentDraftChange:A,onQueueAction:Se},ge.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var bu=document.getElementById(`root`);if(bu===null)throw Error(`Root container #root not found`);(0,y.createRoot)(bu).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(yu,{})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>TDPM Console</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-D6QOQvoN.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-CLHvrafO.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -34,6 +34,18 @@ describe('ConsoleOkAndAwaitingWorkspaceActions', () => {
|
|
|
34
34
|
expect(container.firstChild).toBeNull();
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
it('applies the approve green style class regardless of the status option color', () => {
|
|
38
|
+
const { getByRole } = render(
|
|
39
|
+
<ConsoleOkAndAwaitingWorkspaceActions
|
|
40
|
+
statusOptions={consoleStatusOptionsFixture}
|
|
41
|
+
onOkAndAwaitingWorkspace={() => {}}
|
|
42
|
+
/>,
|
|
43
|
+
);
|
|
44
|
+
expect(
|
|
45
|
+
getByRole('button', { name: 'ok & Awaiting Workspace' }),
|
|
46
|
+
).toHaveClass('console-op-button-approve');
|
|
47
|
+
});
|
|
48
|
+
|
|
37
49
|
it('calls the callback with the awaiting workspace option on click', () => {
|
|
38
50
|
const onOkAndAwaitingWorkspace = jest.fn();
|
|
39
51
|
const { getByRole } = render(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { colorFromEnum } from '../../logic/colors';
|
|
2
1
|
import type { ConsoleFieldOption } from '../../logic/types';
|
|
3
2
|
|
|
4
3
|
export type ConsoleOkAndAwaitingWorkspaceActionsProps = {
|
|
@@ -20,18 +19,11 @@ export const ConsoleOkAndAwaitingWorkspaceActions = ({
|
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
const palette = colorFromEnum(option.color);
|
|
24
|
-
|
|
25
22
|
return (
|
|
26
23
|
<div className="console-op-group">
|
|
27
24
|
<button
|
|
28
25
|
type="button"
|
|
29
|
-
className="console-op-button"
|
|
30
|
-
style={{
|
|
31
|
-
color: palette.fg,
|
|
32
|
-
borderColor: palette.border,
|
|
33
|
-
backgroundColor: palette.bg,
|
|
34
|
-
}}
|
|
26
|
+
className="console-op-button console-op-button-approve"
|
|
35
27
|
onClick={() => onOkAndAwaitingWorkspace(option)}
|
|
36
28
|
>
|
|
37
29
|
ok & Awaiting Workspace
|
package/src/adapter/entry-points/console/ui-dist/assets/{index-CvJgSVoN.js → index-D6QOQvoN.js}
RENAMED
|
@@ -85,4 +85,4 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
85
85
|
`)}),o+=1,r=[])};for(let e of t){if(a){r.push(e),Yc(e)&&(a=!1);continue}if(i===null&&qc(e)){s(),i=[];continue}if(i!==null){if(Yc(e)){n.push({kind:`mermaid`,key:`mermaid:${o}`,code:i.join(`
|
|
86
86
|
`)}),o+=1,i=null;continue}i.push(e);continue}if(Jc(e)){r.push(e),a=!0;continue}r.push(e)}return i!==null&&r.push("```mermaid",...i),s(),n},Zc=({code:e,label:t=`Copy code`})=>(0,S.jsx)(vn,{value:e,idleText:t,idleAriaLabel:t,copiedAriaLabel:`Code copied to clipboard`,className:`console-copy-code-button`}),Qc=`https://cdn.jsdelivr.net/npm/mermaid@10.9.6/dist/mermaid.min.js`,$c=null,el=0,tl=e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#0d1117`,primaryColor:`#161b22`,primaryTextColor:`#e6edf3`,primaryBorderColor:`#30363d`,lineColor:`#8b949e`,fontSize:`14px`}}),e),nl=()=>$c===null?window.mermaid===void 0?($c=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=Qc,n.async=!0,n.onload=()=>{if(window.mermaid===void 0){t(Error(`mermaid failed to load`));return}e(tl(window.mermaid))},n.onerror=()=>t(Error(`mermaid script failed to load`)),document.head.appendChild(n)}),$c):($c=Promise.resolve(tl(window.mermaid)),$c):$c,rl=async e=>{let t=await nl();el+=1;let n=`console-mermaid-${el}`,{svg:r}=await t.render(n,e);return Yo.sanitize(r,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:[`foreignObject`]})},il=.5,al=e=>Number.isNaN(e)||e<1?1:e>6?6:e,ol=e=>al(al(e)+il),sl=e=>al(al(e)-il),cl=e=>al(e)<=1,ll=e=>al(e)>=6,ul=e=>`${Math.round(al(e)*100)}%`,dl=e=>`${al(e)*100}%`,fl=({svg:e,onClose:t})=>{let[n,r]=(0,_.useState)(1),i=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=i.current;if(t===null)return;t.innerHTML=e;let n=t.querySelector(`svg`);n!==null&&(n.style.removeProperty(`max-width`),n.style.setProperty(`width`,`100%`),n.style.setProperty(`height`,`auto`))},[e]),(0,_.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[t]),(0,S.jsxs)(`div`,{className:`console-mermaid-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":`Enlarged diagram`,children:[(0,S.jsxs)(`div`,{className:`console-mermaid-modal-bar`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom out`,disabled:cl(n),onClick:()=>r(sl(n)),children:`−`}),(0,S.jsx)(`span`,{className:`console-mermaid-modal-scale`,children:ul(n)}),(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-button`,"aria-label":`Zoom in`,disabled:ll(n),onClick:()=>r(ol(n)),children:`+`}),(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-modal-close`,"aria-label":`Close enlarged diagram`,onClick:t,children:`✕`})]}),(0,S.jsx)(`div`,{className:`console-mermaid-modal-viewport`,children:(0,S.jsx)(`div`,{ref:i,className:`console-mermaid-modal-canvas`,style:{width:dl(n)}})})]})},pl=({code:e})=>{let[t,n]=(0,_.useState)({status:`loading`}),[r,i]=(0,_.useState)(!1),a=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let t=!1;return n({status:`loading`}),rl(e).then(e=>{t||n({status:`ready`,svg:e})}).catch(e=>{t||n({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{let e=a.current;e!==null&&(e.innerHTML=t.status===`ready`?t.svg:``)},[t]),t.status===`loading`?(0,S.jsx)(`div`,{className:`console-mermaid-loading`,children:`Rendering diagram...`}):t.status===`error`?(0,S.jsxs)(`div`,{className:`console-mermaid`,children:[(0,S.jsxs)(`div`,{className:`console-mermaid-error`,children:[`Mermaid render error: `,t.message]}),(0,S.jsx)(`pre`,{className:`console-mermaid-source`,children:(0,S.jsx)(`code`,{children:e})})]}):(0,S.jsxs)(`div`,{className:`console-mermaid`,children:[(0,S.jsx)(`div`,{ref:a,className:`console-mermaid-rendered`}),(0,S.jsx)(`button`,{type:`button`,className:`console-mermaid-enlarge`,onClick:()=>i(!0),children:`Enlarge diagram`}),r&&(0,S.jsx)(fl,{svg:t.svg,onClose:()=>i(!1)})]})},ml=e=>{let t=e.querySelectorAll(`a[href]`),n=[];return t.forEach((e,t)=>{let r=e.getAttribute(`href`)??``;if(ya(r)===null)return;let i=e.textContent??r,a=document.createElement(`span`);a.className=`console-markdown-reference-host`,e.replaceWith(a),n.push({key:`${t}:${r}`,host:a,href:r,fallbackText:i})}),n},hl=e=>{let t=e.querySelectorAll(`pre > code`),n=[];return t.forEach((e,t)=>{let r=e.parentElement;if(r===null)return;let i=e.textContent??``,a=document.createElement(`div`);a.className=`console-markdown-code-block`;let o=document.createElement(`div`);o.className=`console-markdown-code-copy-host`,r.replaceWith(a),a.append(o,r),n.push({key:`code:${t}`,host:o,code:i})}),n},gl=({source:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,_.useMemo)(()=>{let n=Kc(e,r);return t===void 0?n:Ta(n,t)},[e,t,r]),a=(0,_.useRef)(null),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)([]);return(0,_.useEffect)(()=>{let e=a.current;e!==null&&(e.innerHTML=i,l(hl(e)),s(n===void 0?[]:ml(e)))},[i,n]),(0,S.jsxs)(`div`,{ref:a,className:`console-markdown`,children:[c.map(e=>(0,v.createPortal)((0,S.jsx)(Zc,{code:e.code}),e.host,e.key)),n!==void 0&&o.map(e=>(0,v.createPortal)(n(e.href,e.fallbackText),e.host,e.key))]})},_l=({body:e,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r})=>{let i=(0,_.useMemo)(()=>Xc(e),[e]);return e.trim()===``?(0,S.jsx)(`p`,{className:`console-markdown-empty`,children:`No description provided.`}):(0,S.jsx)(`div`,{className:`console-markdown-view`,children:i.map(e=>e.kind===`mermaid`?(0,S.jsx)(pl,{code:e.code},e.key):(0,S.jsx)(gl,{source:e.source,buildImageProxyUrl:t,renderReferenceLink:n,repoContext:r},e.key))})},vl=({title:e,count:t=null,defaultCollapsed:n=!1,headerAction:r,children:i})=>{let[a,o]=(0,_.useState)(n),s=t===null?e:`${e} (${t})`;return(0,S.jsxs)(`section`,{className:`console-panel`,children:[(0,S.jsxs)(`header`,{className:`console-panel-header`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`console-panel-toggle`,"aria-expanded":!a,onClick:()=>o(e=>!e),children:[(0,S.jsx)(`span`,{className:`console-panel-caret`,children:a?`▸`:`▾`}),(0,S.jsx)(`span`,{className:`console-panel-title`,children:s})]}),r!==void 0&&(0,S.jsx)(`div`,{className:`console-panel-action`,children:r})]}),!a&&(0,S.jsx)(`div`,{className:`console-panel-body`,children:i})]})},yl=e=>{switch(e){case`added`:return{label:`A`,color:`#3fb950`};case`modified`:return{label:`M`,color:`#d29922`};case`removed`:return{label:`D`,color:`#f85149`};case`renamed`:return{label:`R`,color:`#a371f7`};case`changed`:return{label:`M`,color:`#d29922`};default:return{label:`?`,color:`#8b949e`}}},bl=()=>({directories:new Map,files:[]}),xl=e=>e.split(`/`).filter(e=>e!==``),Sl=(e,t)=>e.name.localeCompare(t.name),Cl=(e,t)=>{let n=[];e.directories.forEach((e,r)=>{let i=t===``?r:`${t}/${r}`;n.push({kind:`directory`,name:r,path:i,children:Cl(e,i)})}),n.sort(Sl);let r=e.files.map(e=>({kind:`file`,name:xl(e.path).at(-1)??e.path,path:e.path,file:e}));return r.sort(Sl),[...n,...r]},wl=e=>{let t=bl();for(let n of e){let e=xl(n.path);if(e.length===0){t.files.push(n);continue}let r=e.slice(0,-1),i=t;for(let e of r){let t=i.directories.get(e);if(t===void 0){let t=bl();i.directories.set(e,t),i=t;continue}i=t}i.files.push(n)}return Cl(t,``)},Tl=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,El=e=>{let t=[],n=0,r=0;for(let i of e.split(`
|
|
87
87
|
`)){if(i.startsWith(`@@`)){let e=i.match(Tl);e!==null&&(n=Number(e[1]),r=Number(e[2])),t.push({kind:`hunk`,oldLineNumber:null,newLineNumber:null,content:i});continue}if(i.startsWith(`+`)){t.push({kind:`add`,oldLineNumber:null,newLineNumber:r,content:i}),r+=1;continue}if(i.startsWith(`-`)){t.push({kind:`del`,oldLineNumber:n,newLineNumber:null,content:i}),n+=1;continue}t.push({kind:`ctx`,oldLineNumber:n,newLineNumber:r,content:i}),n+=1,r+=1}return t},Dl=[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.svg`,`.avif`,`.bmp`,`.ico`],Ol=e=>{let t=e.toLowerCase();return Dl.some(e=>t.endsWith(e))},kl=e=>e.kind===`add`||e.kind===`ctx`?e.newLineNumber===null?null:{line:e.newLineNumber,side:`RIGHT`}:e.kind===`del`?e.oldLineNumber===null?null:{line:e.oldLineNumber,side:`LEFT`}:null,Al=e=>`${e.kind}:${e.oldLineNumber??`x`}:${e.newLineNumber??`x`}:${e.content}`,jl=({target:e,onSubmit:t,onClose:n})=>{let[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)({kind:`idle`}),s=async()=>{let n=r.trim();if(n.length!==0&&a.kind!==`posting`){o({kind:`posting`});try{await t(e.path,e.line,e.side,n),i(``),o({kind:`posted`})}catch(e){o({kind:`error`,message:e instanceof Error?e.message:`failed to post`})}}};return(0,S.jsxs)(`div`,{className:`console-diff-composer`,children:[(0,S.jsxs)(`div`,{className:`console-diff-composer-anchor`,children:[`commenting on line `,e.line,` (`,e.side,`)`]}),a.kind===`posted`?(0,S.jsx)(`p`,{className:`console-diff-composer-posted`,children:`Comment saved.`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`textarea`,{className:`console-diff-composer-input`,rows:3,placeholder:`Leave a review comment on this line…`,value:r,onChange:e=>i(e.target.value)}),(0,S.jsxs)(`div`,{className:`console-diff-composer-controls`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-diff-composer-submit`,disabled:a.kind===`posting`,onClick:()=>{s()},children:`Comment`}),(0,S.jsx)(`button`,{type:`button`,className:`console-diff-composer-cancel`,onClick:n,children:`Cancel`}),a.kind===`posting`&&(0,S.jsx)(`span`,{className:`console-diff-composer-status`,children:`Posting…`}),a.kind===`error`&&(0,S.jsxs)(`span`,{role:`alert`,className:`console-diff-composer-status console-diff-composer-error`,children:[`Failed: `,a.message]})]})]})]})},Ml=({patch:e,path:t,rawUrl:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,_.useState)(null);if(e===null||e===``){if(t!==void 0&&n!=null){if(n.startsWith(`data:image/`))return(0,S.jsx)(`div`,{className:`console-file-diff-image`,children:(0,S.jsx)(`img`,{className:`console-file-diff-image-content`,src:n,alt:t})});if(Ol(t)&&r!==void 0)return(0,S.jsx)(`div`,{className:`console-file-diff-image`,children:(0,S.jsx)(`img`,{className:`console-file-diff-image-content`,src:r(n),alt:t})})}return(0,S.jsx)(`p`,{className:`console-file-diff-empty`,children:`(no diff / binary or too large)`})}let s=El(e),c=i!==void 0&&t!==void 0&&t.length>0,l=c?4:3;return(0,S.jsx)(`table`,{className:`console-file-diff`,children:(0,S.jsx)(`tbody`,{children:s.map(e=>{let n=Al(e),r=c?kl(e):null,s=a!==null&&r!==null&&a.line===r.line&&a.side===r.side;return(0,S.jsxs)(_.Fragment,{children:[(0,S.jsxs)(`tr`,{className:`console-diff-row console-diff-${e.kind}`,children:[c&&(0,S.jsx)(`td`,{className:`console-diff-comment-cell`,children:r!==null&&t!==void 0&&(0,S.jsx)(`button`,{type:`button`,className:`console-diff-comment-button`,"aria-label":`Comment on line ${r.line} (${r.side})`,"aria-expanded":s,onClick:()=>o(s?null:{path:t,line:r.line,side:r.side}),children:`+`})}),(0,S.jsx)(`td`,{className:`console-diff-ln`,children:e.oldLineNumber??``}),(0,S.jsx)(`td`,{className:`console-diff-ln`,children:e.newLineNumber??``}),(0,S.jsx)(`td`,{className:`console-diff-code`,children:e.content})]}),s&&i!==void 0&&a!==null&&(0,S.jsx)(`tr`,{className:`console-diff-composer-row`,children:(0,S.jsx)(`td`,{colSpan:l,children:(0,S.jsx)(jl,{target:a,onSubmit:i,onClose:()=>o(null)})})})]},n)})})})},Nl=e=>({paddingLeft:`${e*16}px`}),Pl=({file:e,depth:t,name:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{let[a,o]=(0,_.useState)(!1),s=yl(e.status);return(0,S.jsxs)(`li`,{className:`console-file`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`console-file-row`,style:Nl(t),"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,S.jsx)(`span`,{className:`console-file-caret`,children:a?`▾`:`▸`}),(0,S.jsx)(`span`,{className:`console-file-badge`,style:{color:s.color,borderColor:s.color},children:s.label}),(0,S.jsx)(`span`,{className:`console-file-path`,children:n}),(0,S.jsxs)(`span`,{className:`console-file-stat console-file-add`,children:[`+`,e.additions]}),(0,S.jsxs)(`span`,{className:`console-file-stat console-file-del`,children:[`-`,e.deletions]})]}),a&&(0,S.jsx)(Ml,{patch:e.patch,path:e.path,rawUrl:e.rawUrl,buildImageProxyUrl:r,onAddInlineComment:i})]})},Fl=({node:e,depth:t,buildImageProxyUrl:n,onAddInlineComment:r})=>e.kind===`file`?(0,S.jsx)(Pl,{file:e.file,depth:t,name:e.name,buildImageProxyUrl:n,onAddInlineComment:r}):(0,S.jsxs)(`li`,{className:`console-file-tree-dir`,children:[(0,S.jsxs)(`div`,{className:`console-file-tree-dir-name`,style:Nl(t),children:[(0,S.jsx)(`span`,{className:`console-file-tree-dir-icon`,"aria-hidden":`true`,children:`📁`}),e.name]}),(0,S.jsx)(`ul`,{className:`console-file-tree-children`,children:e.children.map(e=>(0,S.jsx)(Fl,{node:e,depth:t+1,buildImageProxyUrl:n,onAddInlineComment:r},e.path))})]}),Y=({files:e,isLoading:t,error:n,buildImageProxyUrl:r,onAddInlineComment:i})=>{if(n!==null)return(0,S.jsx)(`p`,{className:`console-files-notloaded`,children:`Not loaded.`});if(t)return(0,S.jsx)(`p`,{className:`console-files-loading`,children:`Loading changed files...`});if(e.length===0)return(0,S.jsx)(`p`,{className:`console-files-empty`,children:`No changed files.`});let a=wl(e);return(0,S.jsx)(`ul`,{className:`console-files console-file-tree`,children:a.map(e=>(0,S.jsx)(Fl,{node:e,depth:0,buildImageProxyUrl:r,onAddInlineComment:i},e.path))})},Il=({comments:e,isLoading:t,error:n,now:r,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})=>{let[s,c]=(0,_.useState)(!1);if(n!==null)return(0,S.jsx)(`p`,{className:`console-comment-notloaded`,children:`Not loaded.`});if(t)return(0,S.jsx)(`p`,{className:`console-comment-loading`,children:`Loading comments...`});if(e.length===0)return(0,S.jsx)(`p`,{className:`console-comment-empty`,children:`No comments.`});let l=s?e:e.slice(-1);return(0,S.jsxs)(`div`,{className:`console-comment-list`,children:[!s&&e.length>1&&(0,S.jsxs)(`button`,{type:`button`,className:`console-comment-show-all`,onClick:()=>c(!0),children:[`Show all `,e.length]}),l.map(e=>(0,S.jsxs)(`article`,{className:`console-comment`,children:[(0,S.jsxs)(`header`,{className:`console-comment-header`,children:[(0,S.jsx)(`span`,{className:`console-comment-author`,children:e.author}),(0,S.jsx)(`span`,{className:`console-comment-time`,children:M(e.createdAt,r)})]}),(0,S.jsx)(_l,{body:e.body,buildImageProxyUrl:i,renderReferenceLink:a,repoContext:o})]},`${e.author}:${e.createdAt}:${e.body}`))]})},X=e=>e.slice(0,7),Z=e=>e.split(`
|
|
88
|
-
`)[0],Q=({commits:e,isLoading:t,error:n,now:r})=>n===null?t?(0,S.jsx)(`p`,{className:`console-commits-loading`,children:`Loading commits...`}):e.length===0?(0,S.jsx)(`p`,{className:`console-commits-empty`,children:`No commits.`}):(0,S.jsx)(`ul`,{className:`console-commits`,children:e.map(e=>(0,S.jsxs)(`li`,{className:`console-commit`,children:[(0,S.jsx)(`span`,{className:`console-commit-message`,children:Z(e.message)}),(0,S.jsx)(`span`,{className:`console-commit-sha`,children:X(e.sha)}),(0,S.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,S.jsx)(`span`,{className:`console-commit-time`,children:M(e.authoredAt,r)})]},e.sha))}):(0,S.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Ll=({url:e,label:t=`Copy URL`})=>(0,S.jsx)(vn,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),Rl=e=>{let t=new Map;for(let n of e){let e=t.get(n.message);if(e===void 0){t.set(n.message,[n.section]);continue}e.push(n.section)}return Array.from(t,([e,t])=>({message:e,sections:t}))},zl=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,Bl=({failures:e})=>e.length===0?null:(0,S.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:Rl(e).map(e=>(0,S.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,zl(e.sections),`:`,` `,e.message]},e.message))}),Vl={MERGEABLE:{color:`GREEN`,label:`No conflict`,title:`This pull request has no merge conflicts`,modifier:`console-detail-mergeable-chip-ok`},CONFLICTING:{color:`RED`,label:`Conflict`,title:`This pull request has merge conflicts`,modifier:`console-detail-mergeable-chip-conflict`},UNKNOWN:{color:`GRAY`,label:`Checking merge status`,title:`GitHub has not finished computing the merge status yet`,modifier:`console-detail-mergeable-chip-unknown`}},Hl=({mergeableStatus:e})=>{let t=Vl[e],n=k(t.color);return(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-mergeable-chip ${t.modifier}`,style:{color:n.fg,borderColor:n.border,backgroundColor:n.bg},title:t.title,children:t.label})},Ul=e=>{let t=k(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},Wl=({isPassedAllCiJob:e,isCiStateSuccess:t,isBranchOutOfDate:n,missingRequiredCheckNames:r})=>{let i=e&&t,a=i?`GREEN`:`RED`,o=i?`CI passing`:`CI failing`,s=!i&&r.length>0?`missing: ${r.join(`, `)}`:null;return(0,S.jsxs)(`span`,{className:`console-detail-pr-status`,children:[(0,S.jsxs)(`span`,{className:`console-detail-status-chip console-detail-ci-chip`,style:Ul(a),title:s??o,children:[o,s!==null&&(0,S.jsxs)(`span`,{className:`console-detail-ci-missing`,children:[` `,`(`,s,`)`]})]}),n&&(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-outofdate-chip`,style:Ul(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},Gl=({pullRequest:e,body:t,bodyIsLoading:n,files:r,filesAreLoading:i,filesError:a,commits:o,commitsAreLoading:s,commitsError:c,now:l,buildImageProxyUrl:u,renderReferenceLink:d,onAddInlineComment:f})=>{let p=e.summary,m=ya(e.url),h=m===null?void 0:{owner:m.owner,repo:m.repo},g=i||a!==null?null:r.length,_=s||c!==null?null:o.length;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`console-pr-header`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-pr-section-title`,target:`_blank`,rel:`noopener noreferrer`,children:p?.title??e.url}),e.isDraft&&(0,S.jsx)(`span`,{className:`console-pr-section-state`,children:`draft`}),(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.isPassedAllCiJob,isCiStateSuccess:e.isCiStateSuccess,isBranchOutOfDate:e.isBranchOutOfDate,missingRequiredCheckNames:e.missingRequiredCheckNames}),(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),(0,S.jsx)(Ll,{url:e.url,label:`Copy PR URL`}),(0,S.jsxs)(`div`,{className:`console-pr-statbar`,children:[m!==null&&(0,S.jsxs)(`span`,{className:`console-pr-repo`,children:[m.owner,`/`,m.repo]}),e.branchName!==null&&(0,S.jsx)(`span`,{className:`console-pr-branch`,children:e.branchName}),p!==null&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`console-pr-add`,children:[`+`,p.additions]}),(0,S.jsxs)(`span`,{className:`console-pr-del`,children:[`-`,p.deletions]}),(0,S.jsxs)(`span`,{className:`console-pr-files-count`,children:[p.changedFiles,` files`]})]})]})]}),(0,S.jsx)(vl,{title:`Description`,children:n?(0,S.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,S.jsx)(vl,{title:`Changed files`,count:g,children:(0,S.jsx)(Y,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,S.jsx)(vl,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:o,isLoading:s,error:c,now:l})})]})},Kl=({item:e,storyName:t,storyColorEnum:n,overlayStatus:r,statusOptions:i,state:a,body:o,bodyIsLoading:s,bodyError:c,comments:l,commentsAreLoading:u,commentsError:d,files:f,filesAreLoading:p,filesError:m,commits:h,commitsAreLoading:g,commitsError:_,stateError:v,pullRequestStatus:y,pullRequestStatusError:b,relatedPullRequests:x,relatedPullRequestsError:C,now:w,commentComposer:T,operationBar:ee,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne})=>{let D=a?.state??`open`,re=a?.merged??!1,O=!e.isPr&&D===`closed`?`Closed`:null,ie=ba(e.nameWithOwner)??void 0,ae=k(n),A=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,j=A===null?null:k(A.color),oe=p||m!==null?null:f.length,N=u||d!==null?null:l.length,P=g||_!==null?null:h.length,ce=e=>{let t=ya(e);return t===null?e:`PR #${t.number}`},I=[{section:`item state`,message:v},{section:`pull request status`,message:e.isPr?b:null},{section:`description`,message:c},{section:`comments`,message:d},{section:`changed files`,message:e.isPr?m:null},{section:`commits`,message:e.isPr?_:null},{section:`related pull requests`,message:e.isPr?null:C},...x.flatMap(e=>[{section:`changed files of ${ce(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${ce(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),le=e.isPr&&y?.found?[{url:e.url,mergeableStatus:y.mergeableStatus}]:[];return(0,S.jsxs)(`article`,{className:`console-detail`,children:[(0,S.jsxs)(`h2`,{className:`console-detail-title`,children:[(0,S.jsx)(F,{isPr:e.isPr,state:D,merged:re,isDraft:!1,stateReason:``}),(0,S.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}),(0,S.jsx)(`span`,{className:`console-detail-number`,children:e.isPr?`PR #${e.number}`:`#${e.number}`})]}),(0,S.jsxs)(`div`,{className:`console-detail-topline`,children:[A!==null&&j!==null&&(0,S.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:j.fg,borderColor:j.border,backgroundColor:j.bg},children:A.name}),e.agent!==null&&e.agent!==``&&(0,S.jsx)(`span`,{className:`console-detail-agent-chip`,children:e.agent}),t!==null&&(0,S.jsxs)(`span`,{className:`console-storytag`,children:[(0,S.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:ae.dot}}),t]}),e.isPr&&y?.found&&(0,S.jsx)(Wl,{isPassedAllCiJob:y.isPassedAllCiJob,isCiStateSuccess:y.isCiStateSuccess,isBranchOutOfDate:y.isBranchOutOfDate,missingRequiredCheckNames:y.missingRequiredCheckNames}),!e.isPr&&x.map(e=>(0,S.jsxs)(`span`,{className:`console-related-pr-group`,children:[x.length>1&&(0,S.jsx)(`span`,{className:`console-related-pr-label`,children:ce(e.pullRequest.url)}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,S.jsx)(Hl,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),le.map(e=>(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus},e.url)),O!==null&&(0,S.jsx)(`span`,{className:`console-detail-closed-label`,children:O})]}),(0,S.jsx)(Bl,{failures:I}),(0,S.jsxs)(`div`,{className:`console-detail-subbar`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-detail-link`,target:`_blank`,rel:`noopener noreferrer`,children:e.isPr?`PR #${e.number}`:`Issue #${e.number}`}),(0,S.jsx)(`span`,{className:`console-detail-repo`,children:e.repo}),(0,S.jsx)(`span`,{className:`console-detail-pill`,children:e.isPr?`PR`:`Issue`}),(0,S.jsx)(Ll,{url:e.url})]}),e.labels.length>0&&(0,S.jsx)(`div`,{className:`console-detail-labels`,children:e.labels.map(e=>(0,S.jsx)(`span`,{className:`console-label-chip`,children:e},e))}),(0,S.jsxs)(`div`,{className:`console-detail-createdat`,title:se(e.createdAt),children:[`opened `,M(e.createdAt,w)]}),(0,S.jsx)(vl,{title:`Description`,headerAction:(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),children:c===null?s?(0,S.jsx)(`p`,{className:`console-detail-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:o,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie}):(0,S.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})}),e.isPr&&(0,S.jsx)(vl,{title:`Changed files`,count:oe,children:(0,S.jsx)(Y,{files:f,isLoading:p,error:m,onAddInlineComment:ne})}),(0,S.jsx)(vl,{title:`Comments`,count:N,defaultCollapsed:e.isPr,children:(0,S.jsx)(Il,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie})}),e.isPr&&(0,S.jsx)(vl,{title:`Commits`,count:P,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&x.map(e=>(0,S.jsx)(Gl,{pullRequest:e.pullRequest,body:e.pullRequest.summary?.body??``,bodyIsLoading:!1,files:e.files,filesAreLoading:e.filesAreLoading,filesError:e.filesError,commits:e.commits,commitsAreLoading:e.commitsAreLoading,commitsError:e.commitsError,now:w,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne},e.pullRequest.url)),(0,S.jsxs)(`div`,{className:`console-detail-dock`,children:[(0,S.jsx)(`div`,{className:`console-detail-dock-composer`,children:T}),(0,S.jsx)(`div`,{className:`console-actionbar`,children:ee})]})]})},ql=({onClose:e})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close_not_planned`),children:`Close as not planned`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close`),children:`Close`})]}),Jl=({isManualTriage:e,onSetNextActionDate:t})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1hour`),children:`+1 hour`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3hours`),children:`+3 hours`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1day`),children:`+1 day`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1week`),children:e?`+1 week and skip`:`+1 week`})]}),Yl=`awaiting workspace`,Xl=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===Yl);if(n===void 0)return null;let r=k(n.color);return(0,S.jsx)(`div`,{className:`console-op-group`,children:(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:r.fg,borderColor:r.border,backgroundColor:r.bg},onClick:()=>t(n),children:`ok & Awaiting Workspace`})})},Zl=[{action:`unnecessary`,label:`Unnecessary`,variant:`unneeded`},{action:`totally_wrong`,label:`Totally wrong`,variant:`wrong`},{action:`request_changes`,label:`Reject`,variant:`reject`},{action:`approve_and_merge`,label:`Approve & Merge`,variant:`approve`}],Ql=`Reject needs an inline comment on the diff.`,$l=({onReview:e,rejectEnabled:t})=>(0,S.jsxs)(`div`,{className:`console-op-group console-op-group-review`,children:[!t&&(0,S.jsx)(`p`,{className:`console-op-requirement`,children:Ql}),Zl.map(n=>{let r=n.action===`request_changes`&&!t;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-${n.variant}`,disabled:r,onClick:()=>e(n.action),children:n.label},n.action)})]}),eu=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},tu=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=ir.map(t=>({name:t,option:eu(e,t)})).filter(e=>e.option!==null);return r.length===0?null:(0,S.jsx)(`div`,{className:`console-op-group`,children:r.map(({name:e,option:r})=>{let i=k(r.color),a=e===rr;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:i.fg,borderColor:i.border,backgroundColor:i.bg},onClick:()=>a?n(r):t(r),children:r.name},r.id)})})},nu=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,handlers:i})=>(0,S.jsxs)(`div`,{className:`console-operation-bar`,children:[(0,S.jsx)(Xl,{statusOptions:r,onOkAndAwaitingWorkspace:i.onOkAndAwaitingWorkspace}),t&&(0,S.jsx)($l,{onReview:i.onReview,rejectEnabled:n}),(0,S.jsx)(Jl,{isManualTriage:ar(e),onSetNextActionDate:i.onSetNextActionDate}),(0,S.jsx)(tu,{statusOptions:r,onSetStatus:i.onSetStatus,onSetInTmuxByHuman:i.onSetInTmuxByHuman}),(0,S.jsx)(ql,{onClose:i.onClose})]}),ru=(e,t,n,r)=>{let i=t===null?void 0:e.peek(t),[a,o]=(0,_.useState)(i??r),[s,c]=(0,_.useState)(t!==null&&i===void 0),[l,u]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(t===null||n===null)return;let r=e.peek(t);if(r!==void 0){o(r),c(!1),u(null);return}let i=!1;return c(!0),u(null),e.load(t,n).then(e=>{i||(o(e),c(!1))}).catch(e=>{i||(u(e instanceof Error?e.message:String(e)),c(!1))}),()=>{i=!0}},[e,t,n]),{data:a,isLoading:s,error:l}},iu=[],au=[],ou=[],su=[],cu={state:`open`,merged:!1,isPullRequest:!1,title:``},lu={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},uu=(e,t)=>{let n=t===null?null:`${t.repo}#${t.number}`,r=t===null?null:t.url,i=t?.isPr??!1,a=ru(e.body,n,r,``),o=ru(e.state,n,r,cu),s=ru(e.comments,n,r,iu),c=ru(e.files,i?n:null,i?r:null,au),l=ru(e.commits,i?n:null,i?r:null,ou),u=ru(e.prStatus,i?n:null,i?r:null,lu),d=!i&&(t?.relatedOpenPullRequestUrls.length??0)>0,f=ru(e.relatedPrs,d?n:null,d?r:null,su),[p,m]=(0,_.useState)([]);return(0,_.useEffect)(()=>{if(i||f.data.length===0){m([]);return}let t=!1,n=f.data.map(e=>({pullRequest:e,files:au,filesAreLoading:!0,filesError:null,commits:ou,commitsAreLoading:!0,commitsError:null}));m(n);let r=(e,n)=>{t||m(t=>t.map(t=>t.pullRequest.url===e?{...t,...n}:t))};for(let t of f.data){let n=t.url;e.files.load(n,t.url).then(e=>r(t.url,{files:e,filesAreLoading:!1})).catch(e=>r(t.url,{filesAreLoading:!1,filesError:e instanceof Error?e.message:String(e)})),e.commits.load(n,t.url).then(e=>r(t.url,{commits:e,commitsAreLoading:!1})).catch(e=>r(t.url,{commitsAreLoading:!1,commitsError:e instanceof Error?e.message:String(e)}))}return()=>{t=!0}},[e,i,f.data]),{state:o.data,body:a.data,bodyIsLoading:a.isLoading,bodyError:a.error,comments:s.data,commentsAreLoading:s.isLoading,commentsError:s.error,files:c.data,filesAreLoading:c.isLoading,filesError:c.error,commits:l.data,commitsAreLoading:l.isLoading,commitsError:l.error,stateError:o.error,pullRequestStatus:i?u.data:null,pullRequestStatusError:i?u.error:null,relatedPullRequests:p,relatedPullRequestsError:i?null:f.error}},du=e=>JSON.stringify([e.author,e.createdAt,e.body]),fu=(e,t)=>{let n=new Set(e.map(du));return[...e,...t.filter(e=>!n.has(du(e)))]},pu=({href:e,fallbackText:t,state:n})=>n===null||n.title.trim()===``?(0,S.jsx)(`a`,{className:`console-markdown-reference console-markdown-reference-plain`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,S.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,S.jsx)(F,{...xa(n)}),(0,S.jsx)(`span`,{className:`console-markdown-reference-title`,children:n.title})]}),mu=(e,t)=>{let[n,r]=(0,_.useState)(()=>e.peek(t)??null);return(0,_.useEffect)(()=>{let n=e.peek(t);if(n!==void 0){r(n);return}let i=!1;return r(null),e.load(t,t).then(e=>{i||r(e)}).catch(()=>{i||r(null)}),()=>{i=!0}},[e,t]),n},hu=({cache:e,href:t,fallbackText:n})=>{let r=mu(e,t);return(0,S.jsx)(pu,{href:t,fallbackText:n,state:r})},gu=({tab:e,item:t,caches:n,operations:r,statusOptions:i,storyColors:a,storyName:o,overlayStatus:s,now:c,initialCommentDraft:l,onCommentDraftChange:u,onQueueAction:d})=>{let f=uu(n,t),p=(0,_.useCallback)(e=>wa(e,t.url),[t.url]),m=(0,_.useCallback)((e,t)=>(0,S.jsx)(hu,{cache:n.state,href:e,fallbackText:t}),[n.state]),h=t.isPr||t.relatedOpenPullRequestUrls.length>0||f.relatedPullRequests.length>0,[g,v]=(0,_.useState)([]),y=(0,_.useCallback)(async(e,t,n,r)=>{v(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[b,x]=(0,_.useState)([]),C=(0,_.useCallback)(async e=>{let n=await r.addComment(t,e);return x(e=>[...e,n]),n},[t,r]),w={onReview:e=>{let n=t.isPr?t.url:f.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,i=e===`request_changes`?g:[];d({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,i)})},onSetNextActionDate:e=>{d({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e)})},onSetStory:e=>{d({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e)})},onSetStatus:e=>{d({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e)})},onSetInTmuxByHuman:e=>{d({kind:{type:`set_in_tmux_by_human`,optionName:e.name},item:t,commit:()=>r.setInTmuxByHuman(t,e)})},onClose:e=>{d({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e)})},onOkAndAwaitingWorkspace:e=>{d({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e)})}},T=i.find(e=>e.name===`Awaiting Workspace`)??null,ee=T===null?void 0:async e=>{let t=await C(e);return w.onSetStatus(T),t},te=o??(t.story.trim()===``?null:t.story),ne=te===null?null:E(a,te);return(0,S.jsx)(Kl,{item:t,storyName:te,storyColorEnum:ne,overlayStatus:s,statusOptions:i,state:f.state,stateError:f.stateError,body:f.body,bodyIsLoading:f.bodyIsLoading,bodyError:f.bodyError,comments:fu(f.comments,b),commentsAreLoading:f.commentsAreLoading,commentsError:f.commentsError,files:f.files,filesAreLoading:f.filesAreLoading,filesError:f.filesError,commits:f.commits,commitsAreLoading:f.commitsAreLoading,commitsError:f.commitsError,pullRequestStatus:f.pullRequestStatus,pullRequestStatusError:f.pullRequestStatusError,relatedPullRequests:f.relatedPullRequests,relatedPullRequestsError:f.relatedPullRequestsError,now:c,buildImageProxyUrl:p,renderReferenceLink:m,onAddInlineComment:y,commentComposer:(0,S.jsx)(_a,{initiallyOpen:!0,initialDraft:l,onSubmit:C,onDraftChange:u,onSubmitAndMoveToAwaitingWorkspace:ee,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,S.jsx)(nu,{tab:e,item:t,hasPullRequest:h,rejectEnabled:g.length>0,statusOptions:i,handlers:w})})},_u=()=>{let e={};for(let t of b)e[t.name]=0;return e},vu=`console`,yu=()=>{let e=Pi(),t=li(),n=Qn(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o}=ta(e,r),{timerMode:s,projectMinutes:c,isOpen:l,draftTimerMode:u,draftProjectMinutes:d,openSettings:f,closeSettings:p,saveSettings:m,toggleDraftTimerMode:h,changeDraftMinutes:g}=sa(),{pjcodes:v,isLoading:y}=Fi(),{isTimerExpired:x}=Ii(e),C=Mi(e??vu),w=(0,_.useMemo)(()=>{let e=_u();for(let t of b){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=yi(n.items,xi(C.overlay,n.generatedAt),t.name))}return e},[i,C.overlay]),te=hi(e,w),{activeTab:E,selectedItemKey:D,openItem:O,closeItem:k,selectTab:ie}=te,ae=(0,_.useRef)(new Map),A=(0,_.useCallback)(e=>{D!==null&&(e?ae.current.set(D,e):ae.current.delete(D))},[D]),j=ti(r),oe=ki(e,E,C,j),M=gr(),se=Date.now(),N=i[E],P=(0,_.useMemo)(()=>N===null?[]:bi(N.items,xi(C.overlay,N.generatedAt),E),[N,C.overlay,E]),F=(0,_.useMemo)(()=>P.map(e=>_i(e)),[P]),ce=N?.storyOrder??[],I=(0,_.useMemo)(()=>re(P,C.overlay,ce,N?.generatedAt??null),[P,C.overlay,ce,N]),ue=N?.storyColors??{},de=N?.statusOptions??[],fe=N?.agentOptions??[],R=N?.generatedAt??null,pe=N?.fromCache??!1,[me,he]=(0,_.useState)(null),ge=(0,_.useMemo)(()=>D===null||N===null?null:N.items.find(e=>e.projectItemId===D)??null,[D,N]);si(j,ge,P),(0,_.useEffect)(()=>{D!==null&&window.scrollTo({top:0})},[D]),(0,_.useEffect)(()=>{if(e===null&&s&&v.length>0){let e=oa(v,null,c);e!==null&&ca(`/projects/${e}`)}},[e,s,v,c]);let _e=w[E],ve=(0,_.useRef)({tab:E,count:_e});(0,_.useEffect)(()=>{let e=ve.current;if(ve.current={tab:E,count:_e},e.tab===E&&e.count>0&&_e===0){let e=ui(E,w);e!==null&&(ie(e),k())}},[E,_e,w,ie,k]);let ye=ge===null?null:Si(C.overlay,ge,i[E]?.generatedAt??null),be=ge===null?null:ne(ge,C.overlay,i[E]?.generatedAt??null),xe=(0,_.useCallback)(e=>{let t=ua(F,e);t===null?k():O(t)},[F,O,k]),Se=(0,_.useCallback)(t=>{if(n.status===`on`){M.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=_i(t.item);M.enqueue({message:dr(t.kind,t.item,E),color:lr(t.kind),commit:t.commit,advance:()=>{if(ur(t.kind,E)){if(s&&x(c[e??``]??0)){let t=oa(v,e,c);t!==null&&la(`/projects/${t}`)}else xe(r)}}})},[M,E,xe,n.status,s,x,c,e,v]),Ce=Bi((0,_.useCallback)(e=>{if(D===null||e===null)return;let t=e===`next`?da(F,D):fa(F,D);t!==null&&O(t)},[D,F,O])),[we,Te]=(0,_.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),Ee=(0,_.useCallback)(()=>{Te(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),De=i.stories,Oe=De?.stories??[],ke=me!==null&&me.generatedAt===De?.generatedAt?me.stories:Oe,Ae=De?.defaultNameWithOwner??null,je=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(Ae===null)throw Error(`No repository configured for this project.`);await Jr({pjcode:e,title:n,storyOptionId:t,nameWithOwner:Ae})},[e,Ae]),Me=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Xr({pjcode:e,storyOptionId:t,direction:n});let r=ke.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<ke.length){let t=[...ke],n=t[r];t[r]=t[e],t[e]=n,he({generatedAt:De?.generatedAt,stories:t})}}},[e,ke,De?.generatedAt]),Ne=(0,_.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Hr({pjcode:e,storyName:t})},[e]),[Pe,Fe]=(0,_.useState)({}),[Ie,Le]=(0,_.useState)(null),[Re,ze]=(0,_.useState)({}),Be=(0,_.useCallback)((t,n)=>{let r=ke.find(e=>e.storyOptionId===t)?.color;if(Le(t),Fe(e=>({...e,[t]:n})),ze(e=>{let n={...e};return delete n[t],n}),e===null||Ae===null){Fe(e=>r===void 0?e:{...e,[t]:r}),ze(e=>({...e,[t]:`No project or repository configured.`})),Le(e=>e===t?null:e);return}qr({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:Ae}).catch(e=>{Fe(e=>r===void 0?e:{...e,[t]:r}),ze(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{Le(e=>e===t?null:e)})},[e,Ae,ke]);return(0,S.jsxs)(`main`,{className:`console-app`,children:[M.pending!==null&&(0,S.jsx)(Tn,{message:M.pending.message,color:M.pending.color,remainingSeconds:M.pending.remainingSeconds,progress:M.pending.progress,onUndo:M.undo}),M.error!==null&&(0,S.jsx)(En,{title:M.error.message,message:`Operation failed: ${M.error.reason}`,onDismiss:M.dismissError}),(0,S.jsx)(T,{activeTab:E,counts:w,pjcode:e,pjcodes:v,generatedAt:R,fromCache:pe,tabHref:te.tabHref,onSelectTab:te.selectTab,onSelectProject:e=>la(`/projects/${e}`),settingsButton:(0,S.jsx)(ee,{isOpen:l,timerMode:u,projectMinutes:d,pjcodes:v,isLoadingPjcodes:y,onOpen:f,onToggleTimerMode:h,onChangeMinutes:g,onSave:m,onClose:p}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff}),E===`stories`?(0,S.jsx)(wn,{stories:ke,isLoading:a,error:o,showGray:we,onCreateIssue:je,onAddStory:Ne,onSelectColor:Be,onToggleGray:Ee,onReorderStory:Me,optimisticColors:Pe,colorChangeInFlight:Ie,colorErrors:Re}):ge===null?E===`queued`?(0,S.jsx)(L,{rows:I,storyColors:ue,statusOptions:de,agentOptions:fe,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(le,{rows:I,storyColors:ue,statusOptions:de,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(`div`,{className:`console-detail-screen`,ref:Ce,children:(0,S.jsx)(gu,{tab:E,item:ge,caches:j,operations:oe,statusOptions:de,storyColors:ue,storyName:be,overlayStatus:ye,now:se,initialCommentDraft:ae.current.get(ge.projectItemId)??``,onCommentDraftChange:A,onQueueAction:Se},ge.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var bu=document.getElementById(`root`);if(bu===null)throw Error(`Root container #root not found`);(0,y.createRoot)(bu).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(yu,{})}));
|
|
88
|
+
`)[0],Q=({commits:e,isLoading:t,error:n,now:r})=>n===null?t?(0,S.jsx)(`p`,{className:`console-commits-loading`,children:`Loading commits...`}):e.length===0?(0,S.jsx)(`p`,{className:`console-commits-empty`,children:`No commits.`}):(0,S.jsx)(`ul`,{className:`console-commits`,children:e.map(e=>(0,S.jsxs)(`li`,{className:`console-commit`,children:[(0,S.jsx)(`span`,{className:`console-commit-message`,children:Z(e.message)}),(0,S.jsx)(`span`,{className:`console-commit-sha`,children:X(e.sha)}),(0,S.jsx)(`span`,{className:`console-commit-author`,children:e.author}),(0,S.jsx)(`span`,{className:`console-commit-time`,children:M(e.authoredAt,r)})]},e.sha))}):(0,S.jsx)(`p`,{className:`console-commits-notloaded`,children:`Not loaded.`}),Ll=({url:e,label:t=`Copy URL`})=>(0,S.jsx)(vn,{value:e,idleText:`Copy URL`,idleAriaLabel:t,copiedAriaLabel:`URL copied to clipboard`,className:`console-copy-url-button`}),Rl=e=>{let t=new Map;for(let n of e){let e=t.get(n.message);if(e===void 0){t.set(n.message,[n.section]);continue}e.push(n.section)}return Array.from(t,([e,t])=>({message:e,sections:t}))},zl=e=>e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`,Bl=({failures:e})=>e.length===0?null:(0,S.jsx)(`div`,{role:`alert`,className:`console-detail-fetch-error`,children:Rl(e).map(e=>(0,S.jsxs)(`p`,{className:`console-detail-fetch-error-line`,children:[`Failed to load `,zl(e.sections),`:`,` `,e.message]},e.message))}),Vl={MERGEABLE:{color:`GREEN`,label:`No conflict`,title:`This pull request has no merge conflicts`,modifier:`console-detail-mergeable-chip-ok`},CONFLICTING:{color:`RED`,label:`Conflict`,title:`This pull request has merge conflicts`,modifier:`console-detail-mergeable-chip-conflict`},UNKNOWN:{color:`GRAY`,label:`Checking merge status`,title:`GitHub has not finished computing the merge status yet`,modifier:`console-detail-mergeable-chip-unknown`}},Hl=({mergeableStatus:e})=>{let t=Vl[e],n=k(t.color);return(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-mergeable-chip ${t.modifier}`,style:{color:n.fg,borderColor:n.border,backgroundColor:n.bg},title:t.title,children:t.label})},Ul=e=>{let t=k(e);return{color:t.fg,borderColor:t.border,backgroundColor:t.bg}},Wl=({isPassedAllCiJob:e,isCiStateSuccess:t,isBranchOutOfDate:n,missingRequiredCheckNames:r})=>{let i=e&&t,a=i?`GREEN`:`RED`,o=i?`CI passing`:`CI failing`,s=!i&&r.length>0?`missing: ${r.join(`, `)}`:null;return(0,S.jsxs)(`span`,{className:`console-detail-pr-status`,children:[(0,S.jsxs)(`span`,{className:`console-detail-status-chip console-detail-ci-chip`,style:Ul(a),title:s??o,children:[o,s!==null&&(0,S.jsxs)(`span`,{className:`console-detail-ci-missing`,children:[` `,`(`,s,`)`]})]}),n&&(0,S.jsx)(`span`,{className:`console-detail-status-chip console-detail-outofdate-chip`,style:Ul(`YELLOW`),title:`This branch is out of date with the base branch`,children:`Out of date`})]})},Gl=({pullRequest:e,body:t,bodyIsLoading:n,files:r,filesAreLoading:i,filesError:a,commits:o,commitsAreLoading:s,commitsError:c,now:l,buildImageProxyUrl:u,renderReferenceLink:d,onAddInlineComment:f})=>{let p=e.summary,m=ya(e.url),h=m===null?void 0:{owner:m.owner,repo:m.repo},g=i||a!==null?null:r.length,_=s||c!==null?null:o.length;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`console-pr-header`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-pr-section-title`,target:`_blank`,rel:`noopener noreferrer`,children:p?.title??e.url}),e.isDraft&&(0,S.jsx)(`span`,{className:`console-pr-section-state`,children:`draft`}),(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.isPassedAllCiJob,isCiStateSuccess:e.isCiStateSuccess,isBranchOutOfDate:e.isBranchOutOfDate,missingRequiredCheckNames:e.missingRequiredCheckNames}),(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),(0,S.jsx)(Ll,{url:e.url,label:`Copy PR URL`}),(0,S.jsxs)(`div`,{className:`console-pr-statbar`,children:[m!==null&&(0,S.jsxs)(`span`,{className:`console-pr-repo`,children:[m.owner,`/`,m.repo]}),e.branchName!==null&&(0,S.jsx)(`span`,{className:`console-pr-branch`,children:e.branchName}),p!==null&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`console-pr-add`,children:[`+`,p.additions]}),(0,S.jsxs)(`span`,{className:`console-pr-del`,children:[`-`,p.deletions]}),(0,S.jsxs)(`span`,{className:`console-pr-files-count`,children:[p.changedFiles,` files`]})]})]})]}),(0,S.jsx)(vl,{title:`Description`,children:n?(0,S.jsx)(`p`,{className:`console-pr-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:p?.body??t,buildImageProxyUrl:u,renderReferenceLink:d,repoContext:h})}),(0,S.jsx)(vl,{title:`Changed files`,count:g,children:(0,S.jsx)(Y,{files:r,isLoading:i,error:a,buildImageProxyUrl:u,onAddInlineComment:f})}),(0,S.jsx)(vl,{title:`Commits`,count:_,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:o,isLoading:s,error:c,now:l})})]})},Kl=({item:e,storyName:t,storyColorEnum:n,overlayStatus:r,statusOptions:i,state:a,body:o,bodyIsLoading:s,bodyError:c,comments:l,commentsAreLoading:u,commentsError:d,files:f,filesAreLoading:p,filesError:m,commits:h,commitsAreLoading:g,commitsError:_,stateError:v,pullRequestStatus:y,pullRequestStatusError:b,relatedPullRequests:x,relatedPullRequestsError:C,now:w,commentComposer:T,operationBar:ee,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne})=>{let D=a?.state??`open`,re=a?.merged??!1,O=!e.isPr&&D===`closed`?`Closed`:null,ie=ba(e.nameWithOwner)??void 0,ae=k(n),A=r===null?e.status===null?null:{name:e.status,color:i.find(t=>t.name===e.status)?.color??`GRAY`}:r,j=A===null?null:k(A.color),oe=p||m!==null?null:f.length,N=u||d!==null?null:l.length,P=g||_!==null?null:h.length,ce=e=>{let t=ya(e);return t===null?e:`PR #${t.number}`},I=[{section:`item state`,message:v},{section:`pull request status`,message:e.isPr?b:null},{section:`description`,message:c},{section:`comments`,message:d},{section:`changed files`,message:e.isPr?m:null},{section:`commits`,message:e.isPr?_:null},{section:`related pull requests`,message:e.isPr?null:C},...x.flatMap(e=>[{section:`changed files of ${ce(e.pullRequest.url)}`,message:e.filesError},{section:`commits of ${ce(e.pullRequest.url)}`,message:e.commitsError}])].flatMap(e=>e.message===null?[]:[{section:e.section,message:e.message}]),le=e.isPr&&y?.found?[{url:e.url,mergeableStatus:y.mergeableStatus}]:[];return(0,S.jsxs)(`article`,{className:`console-detail`,children:[(0,S.jsxs)(`h2`,{className:`console-detail-title`,children:[(0,S.jsx)(F,{isPr:e.isPr,state:D,merged:re,isDraft:!1,stateReason:``}),(0,S.jsx)(`span`,{className:`console-detail-title-text`,children:e.title}),(0,S.jsx)(`span`,{className:`console-detail-number`,children:e.isPr?`PR #${e.number}`:`#${e.number}`})]}),(0,S.jsxs)(`div`,{className:`console-detail-topline`,children:[A!==null&&j!==null&&(0,S.jsx)(`span`,{className:`console-detail-status-chip`,style:{color:j.fg,borderColor:j.border,backgroundColor:j.bg},children:A.name}),e.agent!==null&&e.agent!==``&&(0,S.jsx)(`span`,{className:`console-detail-agent-chip`,children:e.agent}),t!==null&&(0,S.jsxs)(`span`,{className:`console-storytag`,children:[(0,S.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:ae.dot}}),t]}),e.isPr&&y?.found&&(0,S.jsx)(Wl,{isPassedAllCiJob:y.isPassedAllCiJob,isCiStateSuccess:y.isCiStateSuccess,isBranchOutOfDate:y.isBranchOutOfDate,missingRequiredCheckNames:y.missingRequiredCheckNames}),!e.isPr&&x.map(e=>(0,S.jsxs)(`span`,{className:`console-related-pr-group`,children:[x.length>1&&(0,S.jsx)(`span`,{className:`console-related-pr-label`,children:ce(e.pullRequest.url)}),(0,S.jsx)(Wl,{isPassedAllCiJob:e.pullRequest.isPassedAllCiJob,isCiStateSuccess:e.pullRequest.isCiStateSuccess,isBranchOutOfDate:e.pullRequest.isBranchOutOfDate,missingRequiredCheckNames:e.pullRequest.missingRequiredCheckNames}),(0,S.jsx)(Hl,{mergeableStatus:e.pullRequest.mergeableStatus})]},e.pullRequest.url)),le.map(e=>(0,S.jsx)(Hl,{mergeableStatus:e.mergeableStatus},e.url)),O!==null&&(0,S.jsx)(`span`,{className:`console-detail-closed-label`,children:O})]}),(0,S.jsx)(Bl,{failures:I}),(0,S.jsxs)(`div`,{className:`console-detail-subbar`,children:[(0,S.jsx)(`a`,{href:e.url,className:`console-detail-link`,target:`_blank`,rel:`noopener noreferrer`,children:e.isPr?`PR #${e.number}`:`Issue #${e.number}`}),(0,S.jsx)(`span`,{className:`console-detail-repo`,children:e.repo}),(0,S.jsx)(`span`,{className:`console-detail-pill`,children:e.isPr?`PR`:`Issue`}),(0,S.jsx)(Ll,{url:e.url})]}),e.labels.length>0&&(0,S.jsx)(`div`,{className:`console-detail-labels`,children:e.labels.map(e=>(0,S.jsx)(`span`,{className:`console-label-chip`,children:e},e))}),(0,S.jsxs)(`div`,{className:`console-detail-createdat`,title:se(e.createdAt),children:[`opened `,M(e.createdAt,w)]}),(0,S.jsx)(vl,{title:`Description`,headerAction:(0,S.jsx)(`a`,{href:e.url,className:`console-panel-open-link`,target:`_blank`,rel:`noopener noreferrer`,children:`open`}),children:c===null?s?(0,S.jsx)(`p`,{className:`console-detail-body-loading`,children:`Loading description...`}):(0,S.jsx)(_l,{body:o,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie}):(0,S.jsx)(`p`,{className:`console-detail-body-notloaded`,children:`Not loaded.`})}),e.isPr&&(0,S.jsx)(vl,{title:`Changed files`,count:oe,children:(0,S.jsx)(Y,{files:f,isLoading:p,error:m,onAddInlineComment:ne})}),(0,S.jsx)(vl,{title:`Comments`,count:N,defaultCollapsed:e.isPr,children:(0,S.jsx)(Il,{comments:l,isLoading:u,error:d,now:w,buildImageProxyUrl:te,renderReferenceLink:E,repoContext:ie})}),e.isPr&&(0,S.jsx)(vl,{title:`Commits`,count:P,defaultCollapsed:!0,children:(0,S.jsx)(Q,{commits:h,isLoading:g,error:_,now:w})}),!e.isPr&&x.map(e=>(0,S.jsx)(Gl,{pullRequest:e.pullRequest,body:e.pullRequest.summary?.body??``,bodyIsLoading:!1,files:e.files,filesAreLoading:e.filesAreLoading,filesError:e.filesError,commits:e.commits,commitsAreLoading:e.commitsAreLoading,commitsError:e.commitsError,now:w,buildImageProxyUrl:te,renderReferenceLink:E,onAddInlineComment:ne},e.pullRequest.url)),(0,S.jsxs)(`div`,{className:`console-detail-dock`,children:[(0,S.jsx)(`div`,{className:`console-detail-dock-composer`,children:T}),(0,S.jsx)(`div`,{className:`console-actionbar`,children:ee})]})]})},ql=({onClose:e})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close_not_planned`),children:`Close as not planned`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>e(`close`),children:`Close`})]}),Jl=({isManualTriage:e,onSetNextActionDate:t})=>(0,S.jsxs)(`div`,{className:`console-op-group`,children:[(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1hour`),children:`+1 hour`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_3hours`),children:`+3 hours`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1day`),children:`+1 day`}),(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-snooze`,onClick:()=>t(`snooze_1week`),children:e?`+1 week and skip`:`+1 week`})]}),Yl=`awaiting workspace`,Xl=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===Yl);return n===void 0?null:(0,S.jsx)(`div`,{className:`console-op-group`,children:(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-approve`,onClick:()=>t(n),children:`ok & Awaiting Workspace`})})},Zl=[{action:`unnecessary`,label:`Unnecessary`,variant:`unneeded`},{action:`totally_wrong`,label:`Totally wrong`,variant:`wrong`},{action:`request_changes`,label:`Reject`,variant:`reject`},{action:`approve_and_merge`,label:`Approve & Merge`,variant:`approve`}],Ql=`Reject needs an inline comment on the diff.`,$l=({onReview:e,rejectEnabled:t})=>(0,S.jsxs)(`div`,{className:`console-op-group console-op-group-review`,children:[!t&&(0,S.jsx)(`p`,{className:`console-op-requirement`,children:Ql}),Zl.map(n=>{let r=n.action===`request_changes`&&!t;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-${n.variant}`,disabled:r,onClick:()=>e(n.action),children:n.label},n.action)})]}),eu=(e,t)=>{let n=t.toLowerCase();return e.find(e=>e.name.toLowerCase()===n)??null},tu=({statusOptions:e,onSetStatus:t,onSetInTmuxByHuman:n})=>{let r=ir.map(t=>({name:t,option:eu(e,t)})).filter(e=>e.option!==null);return r.length===0?null:(0,S.jsx)(`div`,{className:`console-op-group`,children:r.map(({name:e,option:r})=>{let i=k(r.color),a=e===rr;return(0,S.jsx)(`button`,{type:`button`,className:`console-op-button`,style:{color:i.fg,borderColor:i.border,backgroundColor:i.bg},onClick:()=>a?n(r):t(r),children:r.name},r.id)})})},nu=({tab:e,hasPullRequest:t,rejectEnabled:n,statusOptions:r,handlers:i})=>(0,S.jsxs)(`div`,{className:`console-operation-bar`,children:[(0,S.jsx)(Xl,{statusOptions:r,onOkAndAwaitingWorkspace:i.onOkAndAwaitingWorkspace}),t&&(0,S.jsx)($l,{onReview:i.onReview,rejectEnabled:n}),(0,S.jsx)(Jl,{isManualTriage:ar(e),onSetNextActionDate:i.onSetNextActionDate}),(0,S.jsx)(tu,{statusOptions:r,onSetStatus:i.onSetStatus,onSetInTmuxByHuman:i.onSetInTmuxByHuman}),(0,S.jsx)(ql,{onClose:i.onClose})]}),ru=(e,t,n,r)=>{let i=t===null?void 0:e.peek(t),[a,o]=(0,_.useState)(i??r),[s,c]=(0,_.useState)(t!==null&&i===void 0),[l,u]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(t===null||n===null)return;let r=e.peek(t);if(r!==void 0){o(r),c(!1),u(null);return}let i=!1;return c(!0),u(null),e.load(t,n).then(e=>{i||(o(e),c(!1))}).catch(e=>{i||(u(e instanceof Error?e.message:String(e)),c(!1))}),()=>{i=!0}},[e,t,n]),{data:a,isLoading:s,error:l}},iu=[],au=[],ou=[],su=[],cu={state:`open`,merged:!1,isPullRequest:!1,title:``},lu={found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},uu=(e,t)=>{let n=t===null?null:`${t.repo}#${t.number}`,r=t===null?null:t.url,i=t?.isPr??!1,a=ru(e.body,n,r,``),o=ru(e.state,n,r,cu),s=ru(e.comments,n,r,iu),c=ru(e.files,i?n:null,i?r:null,au),l=ru(e.commits,i?n:null,i?r:null,ou),u=ru(e.prStatus,i?n:null,i?r:null,lu),d=!i&&(t?.relatedOpenPullRequestUrls.length??0)>0,f=ru(e.relatedPrs,d?n:null,d?r:null,su),[p,m]=(0,_.useState)([]);return(0,_.useEffect)(()=>{if(i||f.data.length===0){m([]);return}let t=!1,n=f.data.map(e=>({pullRequest:e,files:au,filesAreLoading:!0,filesError:null,commits:ou,commitsAreLoading:!0,commitsError:null}));m(n);let r=(e,n)=>{t||m(t=>t.map(t=>t.pullRequest.url===e?{...t,...n}:t))};for(let t of f.data){let n=t.url;e.files.load(n,t.url).then(e=>r(t.url,{files:e,filesAreLoading:!1})).catch(e=>r(t.url,{filesAreLoading:!1,filesError:e instanceof Error?e.message:String(e)})),e.commits.load(n,t.url).then(e=>r(t.url,{commits:e,commitsAreLoading:!1})).catch(e=>r(t.url,{commitsAreLoading:!1,commitsError:e instanceof Error?e.message:String(e)}))}return()=>{t=!0}},[e,i,f.data]),{state:o.data,body:a.data,bodyIsLoading:a.isLoading,bodyError:a.error,comments:s.data,commentsAreLoading:s.isLoading,commentsError:s.error,files:c.data,filesAreLoading:c.isLoading,filesError:c.error,commits:l.data,commitsAreLoading:l.isLoading,commitsError:l.error,stateError:o.error,pullRequestStatus:i?u.data:null,pullRequestStatusError:i?u.error:null,relatedPullRequests:p,relatedPullRequestsError:i?null:f.error}},du=e=>JSON.stringify([e.author,e.createdAt,e.body]),fu=(e,t)=>{let n=new Set(e.map(du));return[...e,...t.filter(e=>!n.has(du(e)))]},pu=({href:e,fallbackText:t,state:n})=>n===null||n.title.trim()===``?(0,S.jsx)(`a`,{className:`console-markdown-reference console-markdown-reference-plain`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,S.jsxs)(`a`,{className:`console-markdown-reference`,href:e,target:`_blank`,rel:`noopener noreferrer`,children:[(0,S.jsx)(F,{...xa(n)}),(0,S.jsx)(`span`,{className:`console-markdown-reference-title`,children:n.title})]}),mu=(e,t)=>{let[n,r]=(0,_.useState)(()=>e.peek(t)??null);return(0,_.useEffect)(()=>{let n=e.peek(t);if(n!==void 0){r(n);return}let i=!1;return r(null),e.load(t,t).then(e=>{i||r(e)}).catch(()=>{i||r(null)}),()=>{i=!0}},[e,t]),n},hu=({cache:e,href:t,fallbackText:n})=>{let r=mu(e,t);return(0,S.jsx)(pu,{href:t,fallbackText:n,state:r})},gu=({tab:e,item:t,caches:n,operations:r,statusOptions:i,storyColors:a,storyName:o,overlayStatus:s,now:c,initialCommentDraft:l,onCommentDraftChange:u,onQueueAction:d})=>{let f=uu(n,t),p=(0,_.useCallback)(e=>wa(e,t.url),[t.url]),m=(0,_.useCallback)((e,t)=>(0,S.jsx)(hu,{cache:n.state,href:e,fallbackText:t}),[n.state]),h=t.isPr||t.relatedOpenPullRequestUrls.length>0||f.relatedPullRequests.length>0,[g,v]=(0,_.useState)([]),y=(0,_.useCallback)(async(e,t,n,r)=>{v(i=>[...i,{path:e,line:t,side:n,body:r}])},[]),[b,x]=(0,_.useState)([]),C=(0,_.useCallback)(async e=>{let n=await r.addComment(t,e);return x(e=>[...e,n]),n},[t,r]),w={onReview:e=>{let n=t.isPr?t.url:f.relatedPullRequests[0]?.pullRequest.url??t.relatedOpenPullRequestUrls[0]??t.url,i=e===`request_changes`?g:[];d({kind:{type:`review`,action:e},item:t,commit:()=>r.reviewPullRequest(t,n,e,i)})},onSetNextActionDate:e=>{d({kind:{type:`next_action_date`,action:e},item:t,commit:()=>r.setNextActionDate(t,e)})},onSetStory:e=>{d({kind:{type:`set_story`,optionName:e.name},item:t,commit:()=>r.setStory(t,e)})},onSetStatus:e=>{d({kind:{type:`set_status`,optionName:e.name},item:t,commit:()=>r.setStatus(t,e)})},onSetInTmuxByHuman:e=>{d({kind:{type:`set_in_tmux_by_human`,optionName:e.name},item:t,commit:()=>r.setInTmuxByHuman(t,e)})},onClose:e=>{d({kind:{type:`close`,action:e},item:t,commit:()=>r.closeIssue(t,e)})},onOkAndAwaitingWorkspace:e=>{d({kind:{type:`ok_and_awaiting_workspace`},item:t,commit:()=>r.okAndMoveToAwaitingWorkspace(t,e)})}},T=i.find(e=>e.name===`Awaiting Workspace`)??null,ee=T===null?void 0:async e=>{let t=await C(e);return w.onSetStatus(T),t},te=o??(t.story.trim()===``?null:t.story),ne=te===null?null:E(a,te);return(0,S.jsx)(Kl,{item:t,storyName:te,storyColorEnum:ne,overlayStatus:s,statusOptions:i,state:f.state,stateError:f.stateError,body:f.body,bodyIsLoading:f.bodyIsLoading,bodyError:f.bodyError,comments:fu(f.comments,b),commentsAreLoading:f.commentsAreLoading,commentsError:f.commentsError,files:f.files,filesAreLoading:f.filesAreLoading,filesError:f.filesError,commits:f.commits,commitsAreLoading:f.commitsAreLoading,commitsError:f.commitsError,pullRequestStatus:f.pullRequestStatus,pullRequestStatusError:f.pullRequestStatusError,relatedPullRequests:f.relatedPullRequests,relatedPullRequestsError:f.relatedPullRequestsError,now:c,buildImageProxyUrl:p,renderReferenceLink:m,onAddInlineComment:y,commentComposer:(0,S.jsx)(_a,{initiallyOpen:!0,initialDraft:l,onSubmit:C,onDraftChange:u,onSubmitAndMoveToAwaitingWorkspace:ee,onUploadFile:e=>r.uploadAttachment(t,e)}),operationBar:(0,S.jsx)(nu,{tab:e,item:t,hasPullRequest:h,rejectEnabled:g.length>0,statusOptions:i,handlers:w})})},_u=()=>{let e={};for(let t of b)e[t.name]=0;return e},vu=`console`,yu=()=>{let e=Pi(),t=li(),n=Qn(),r=n.status===`on`?n.snapshot:null,{snapshots:i,isLoading:a,error:o}=ta(e,r),{timerMode:s,projectMinutes:c,isOpen:l,draftTimerMode:u,draftProjectMinutes:d,openSettings:f,closeSettings:p,saveSettings:m,toggleDraftTimerMode:h,changeDraftMinutes:g}=sa(),{pjcodes:v,isLoading:y}=Fi(),{isTimerExpired:x}=Ii(e),C=Mi(e??vu),w=(0,_.useMemo)(()=>{let e=_u();for(let t of b){let n=i[t.name];n!==null&&(t.name===`stories`?e[t.name]=n.stories.filter(e=>e.color!==`GRAY`).length:e[t.name]=yi(n.items,xi(C.overlay,n.generatedAt),t.name))}return e},[i,C.overlay]),te=hi(e,w),{activeTab:E,selectedItemKey:D,openItem:O,closeItem:k,selectTab:ie}=te,ae=(0,_.useRef)(new Map),A=(0,_.useCallback)(e=>{D!==null&&(e?ae.current.set(D,e):ae.current.delete(D))},[D]),j=ti(r),oe=ki(e,E,C,j),M=gr(),se=Date.now(),N=i[E],P=(0,_.useMemo)(()=>N===null?[]:bi(N.items,xi(C.overlay,N.generatedAt),E),[N,C.overlay,E]),F=(0,_.useMemo)(()=>P.map(e=>_i(e)),[P]),ce=N?.storyOrder??[],I=(0,_.useMemo)(()=>re(P,C.overlay,ce,N?.generatedAt??null),[P,C.overlay,ce,N]),ue=N?.storyColors??{},de=N?.statusOptions??[],fe=N?.agentOptions??[],R=N?.generatedAt??null,pe=N?.fromCache??!1,[me,he]=(0,_.useState)(null),ge=(0,_.useMemo)(()=>D===null||N===null?null:N.items.find(e=>e.projectItemId===D)??null,[D,N]);si(j,ge,P),(0,_.useEffect)(()=>{D!==null&&window.scrollTo({top:0})},[D]),(0,_.useEffect)(()=>{if(e===null&&s&&v.length>0){let e=oa(v,null,c);e!==null&&ca(`/projects/${e}`)}},[e,s,v,c]);let _e=w[E],ve=(0,_.useRef)({tab:E,count:_e});(0,_.useEffect)(()=>{let e=ve.current;if(ve.current={tab:E,count:_e},e.tab===E&&e.count>0&&_e===0){let e=ui(E,w);e!==null&&(ie(e),k())}},[E,_e,w,ie,k]);let ye=ge===null?null:Si(C.overlay,ge,i[E]?.generatedAt??null),be=ge===null?null:ne(ge,C.overlay,i[E]?.generatedAt??null),xe=(0,_.useCallback)(e=>{let t=ua(F,e);t===null?k():O(t)},[F,O,k]),Se=(0,_.useCallback)(t=>{if(n.status===`on`){M.showError(`Airplane mode`,`This action requires a network connection. Turn off airplane mode and try again.`);return}let r=_i(t.item);M.enqueue({message:dr(t.kind,t.item,E),color:lr(t.kind),commit:t.commit,advance:()=>{if(ur(t.kind,E)){if(s&&x(c[e??``]??0)){let t=oa(v,e,c);t!==null&&la(`/projects/${t}`)}else xe(r)}}})},[M,E,xe,n.status,s,x,c,e,v]),Ce=Bi((0,_.useCallback)(e=>{if(D===null||e===null)return;let t=e===`next`?da(F,D):fa(F,D);t!==null&&O(t)},[D,F,O])),[we,Te]=(0,_.useState)(()=>localStorage.getItem(`console-story-show-gray`)===`true`),Ee=(0,_.useCallback)(()=>{Te(e=>{let t=!e;return localStorage.setItem(`console-story-show-gray`,String(t)),t})},[]),De=i.stories,Oe=De?.stories??[],ke=me!==null&&me.generatedAt===De?.generatedAt?me.stories:Oe,Ae=De?.defaultNameWithOwner??null,je=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);if(Ae===null)throw Error(`No repository configured for this project.`);await Jr({pjcode:e,title:n,storyOptionId:t,nameWithOwner:Ae})},[e,Ae]),Me=(0,_.useCallback)(async(t,n)=>{if(e===null)throw Error(`No project specified in the URL path.`);await Xr({pjcode:e,storyOptionId:t,direction:n});let r=ke.findIndex(e=>e.storyOptionId===t);if(r!==-1){let e=r+(n===`up`?-1:1);if(e>=0&&e<ke.length){let t=[...ke],n=t[r];t[r]=t[e],t[e]=n,he({generatedAt:De?.generatedAt,stories:t})}}},[e,ke,De?.generatedAt]),Ne=(0,_.useCallback)(async t=>{if(e===null)throw Error(`No project specified in the URL path.`);await Hr({pjcode:e,storyName:t})},[e]),[Pe,Fe]=(0,_.useState)({}),[Ie,Le]=(0,_.useState)(null),[Re,ze]=(0,_.useState)({}),Be=(0,_.useCallback)((t,n)=>{let r=ke.find(e=>e.storyOptionId===t)?.color;if(Le(t),Fe(e=>({...e,[t]:n})),ze(e=>{let n={...e};return delete n[t],n}),e===null||Ae===null){Fe(e=>r===void 0?e:{...e,[t]:r}),ze(e=>({...e,[t]:`No project or repository configured.`})),Le(e=>e===t?null:e);return}qr({pjcode:e,storyOptionId:t,newColor:n,nameWithOwner:Ae}).catch(e=>{Fe(e=>r===void 0?e:{...e,[t]:r}),ze(n=>({...n,[t]:e instanceof Error?e.message:String(e)}))}).finally(()=>{Le(e=>e===t?null:e)})},[e,Ae,ke]);return(0,S.jsxs)(`main`,{className:`console-app`,children:[M.pending!==null&&(0,S.jsx)(Tn,{message:M.pending.message,color:M.pending.color,remainingSeconds:M.pending.remainingSeconds,progress:M.pending.progress,onUndo:M.undo}),M.error!==null&&(0,S.jsx)(En,{title:M.error.message,message:`Operation failed: ${M.error.reason}`,onDismiss:M.dismissError}),(0,S.jsx)(T,{activeTab:E,counts:w,pjcode:e,pjcodes:v,generatedAt:R,fromCache:pe,tabHref:te.tabHref,onSelectTab:te.selectTab,onSelectProject:e=>la(`/projects/${e}`),settingsButton:(0,S.jsx)(ee,{isOpen:l,timerMode:u,projectMinutes:d,pjcodes:v,isLoadingPjcodes:y,onOpen:f,onToggleTimerMode:h,onChangeMinutes:g,onSave:m,onClose:p}),airplaneModeEnabled:t.airplaneMode,airplaneModeStatus:n.status,airplaneModeProgress:n.progress,airplaneModeCapturedAt:r?.capturedAt??null,airplaneModeFailures:n.failures,onAirplaneModeStartSync:n.startSync,onAirplaneModeTurnOff:n.turnOff}),E===`stories`?(0,S.jsx)(wn,{stories:ke,isLoading:a,error:o,showGray:we,onCreateIssue:je,onAddStory:Ne,onSelectColor:Be,onToggleGray:Ee,onReorderStory:Me,optimisticColors:Pe,colorChangeInFlight:Ie,colorErrors:Re}):ge===null?E===`queued`?(0,S.jsx)(L,{rows:I,storyColors:ue,statusOptions:de,agentOptions:fe,activeItemId:null,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(le,{rows:I,storyColors:ue,statusOptions:de,activeItemId:null,now:se,isLoading:a,error:o,onSelectItem:e=>te.openItem(e.projectItemId)}):(0,S.jsx)(`div`,{className:`console-detail-screen`,ref:Ce,children:(0,S.jsx)(gu,{tab:E,item:ge,caches:j,operations:oe,statusOptions:de,storyColors:ue,storyName:be,overlayStatus:ye,now:se,initialCommentDraft:ae.current.get(ge.projectItemId)??``,onCommentDraftChange:A,onQueueAction:Se},ge.projectItemId)})]})};`serviceWorker`in navigator&&navigator.serviceWorker.register(`/sw.js`).catch(e=>{console.warn(`Service worker registration failed:`,e)});var bu=document.getElementById(`root`);if(bu===null)throw Error(`Root container #root not found`);(0,y.createRoot)(bu).render((0,S.jsx)(_.StrictMode,{children:(0,S.jsx)(yu,{})}));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>TDPM Console</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-D6QOQvoN.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-CLHvrafO.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|