github-issue-tower-defence-management 2.135.5 → 2.135.6
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/bin/adapter/entry-points/console/ui-dist/assets/{index-DTYdb_sn.js → index-B-DtPr8b.js}
RENAMED
|
@@ -10,7 +10,7 @@ Error generating stack: `+e.message+`
|
|
|
10
10
|
|
|
11
11
|
`),xe=`In Tmux by human`,Se=`Awaiting Workspace`,Ce=[`In Tmux by human`,`Todo by human`,Se],we=e=>e===`todo-by-human`||e===`todo-by-agent`,Te=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===Se.toLowerCase());if(n===void 0)return null;let r=P(n.color);return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.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`})})},Ee={issueOpen:{color:`#3fb950`,paths:[`M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z`,`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z`]},issueClosed:{color:`#a371f7`,paths:[`M11.28 6.78a.75.75 0 0 0-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0l3.5-3.5Z`,`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 1 0-13 0 6.5 6.5 0 0 0 13 0Z`]},issueClosedNotPlanned:{color:`#848d97`,paths:[`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`]},prOpen:{color:`#3fb950`,paths:[`M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z`]},prMerged:{color:`#a371f7`,paths:[`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`]},prClosed:{color:`#f85149`,paths:[`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 5.5a.75.75 0 0 1 .75.75v3.378a2.251 2.251 0 1 1-1.5 0V7.25a.75.75 0 0 1 .75-.75Zm-2.03-5.273a.75.75 0 0 1 1.06 0l.97.97.97-.97a.748.748 0 0 1 1.265.332.75.75 0 0 1-.205.729l-.97.97.97.97a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-.97-.97-.97.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l.97-.97-.97-.97a.75.75 0 0 1 0-1.06ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z`]},prDraft:{color:`#8b949e`,paths:[`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`]}},De=({isPr:e,state:t,merged:n,isDraft:r,stateReason:i})=>e?r?`prDraft`:n?`prMerged`:t===`closed`?`prClosed`:`prOpen`:t===`closed`?i===`not_planned`?`issueClosedNotPlanned`:`issueClosed`:`issueOpen`,Oe=({size:e=12,...t})=>{let n=De(t),r=Ee[n];return(0,x.jsx)(`svg`,{className:`console-item-icon`,viewBox:`0 0 16 16`,width:e,height:e,fill:r.color,role:`img`,"aria-label":n,children:r.paths.map(e=>(0,x.jsx)(`path`,{d:e},e))})},ke=({item:e,isActive:t,now:n,statusOptions:r=[],onSelect:i})=>(0,x.jsx)(`button`,{type:`button`,className:`console-item-row`,"aria-current":t?`true`:void 0,"data-active":t?`true`:void 0,onClick:()=>i(e),children:(0,x.jsxs)(`span`,{className:`console-item-meta`,children:[(0,x.jsxs)(`span`,{className:`console-item-title`,children:[(0,x.jsx)(Oe,{isPr:e.isPr,state:`open`,merged:!1,isDraft:!1,stateReason:``}),e.title]}),(0,x.jsxs)(`span`,{className:`console-item-sub`,children:[(0,x.jsxs)(`span`,{className:`console-item-pill`,children:[`#`,e.number]}),e.repo!==``&&(0,x.jsx)(`span`,{className:`console-item-pill`,children:e.repo}),(0,x.jsx)(`span`,{className:`console-item-pill`,children:e.isPr?`PR`:`Issue`}),e.createdAt!==``&&(0,x.jsxs)(`span`,{className:`console-item-opened`,children:[` · opened `,(0,x.jsx)(`span`,{className:`console-item-createdat`,title:ne(e.createdAt),children:k(e.createdAt,n)})]}),e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-item-status-badge`,style:pe(r.find(t=>t.name===e.status)?.color??null),children:e.status})]}),(e.nextActionDate!==null||e.nextActionHour!==null||e.dependedIssueUrls.length>0)&&(0,x.jsxs)(`span`,{className:`console-item-fields`,children:[e.nextActionDate!==null&&(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Next Action Date`}),e.nextActionDate.slice(0,10)]}),e.nextActionHour!==null&&(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Next Action Hour`}),e.nextActionHour]}),e.dependedIssueUrls.length>0&&(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Depended Issue URL`}),e.dependedIssueUrls.join(`, `)]})]}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-item-status-agent`,children:(0,x.jsxs)(`span`,{className:`console-item-field`,children:[(0,x.jsx)(`span`,{className:`console-item-field-label`,children:`Agent`}),e.agent]})})]})}),Ae=({story:e,count:t,colorEnum:n})=>{let r=P(n);return(0,x.jsxs)(`div`,{className:`console-group-header`,children:[(0,x.jsxs)(`span`,{className:`console-storytag`,children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:r.dot}}),e]}),(0,x.jsx)(`span`,{className:`console-group-count`,children:t})]})},je=({rows:e,storyColors:t,statusOptions:n=[],activeItemId:r,now:i,isLoading:a,error:o,onSelectItem:s,executiveSummaries:c,onOkAndAwaitingWorkspace:l})=>o===null?a?(0,x.jsx)(`p`,{className:`console-list-message`,children:`Loading list...`}):e.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No items`}):(0,x.jsx)(`ul`,{className:`console-list`,children:e.map(e=>{if(e.kind===`group-header`)return(0,x.jsx)(`li`,{className:`console-list-group`,children:(0,x.jsx)(Ae,{story:e.story,count:e.count,colorEnum:I(t,e.story)})},`group:${e.story}`);let a=c?.[e.item.projectItemId]??null;return(0,x.jsxs)(`li`,{className:`console-list-row`,children:[(0,x.jsx)(ke,{item:e.item,isActive:e.item.itemId===r,now:i,statusOptions:n,onSelect:s}),a!==null&&a!==``&&(0,x.jsx)(`span`,{className:`console-item-executive-summary`,children:a}),l!==void 0&&(0,x.jsx)(Te,{statusOptions:n,onOkAndAwaitingWorkspace:t=>l(e.item,t)})]},e.item.itemId)})}):(0,x.jsxs)(`p`,{role:`alert`,className:`console-list-message console-list-error`,children:[`Failed to load list: `,o]}),Me=({agentOptions:e,agentCounts:t,selectedAgent:n,onAgentChange:r})=>{let i=e.filter(e=>(t[e.name]??0)>0);return i.length===0?null:(0,x.jsx)(`div`,{className:`console-prs-agent-filter`,children:(0,x.jsxs)(`select`,{value:n??``,onChange:e=>r(e.target.value===``?null:e.target.value),"aria-label":`Filter by agent`,children:[(0,x.jsx)(`option`,{value:``,children:`All agents`}),i.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.name,` (`,t[e.name],`)`]},e.id))]})})},Ne=e=>({...pe(e),fontSize:`12px`,whiteSpace:`nowrap`,flexShrink:0}),Pe=({item:e,isActive:t,statusOptions:n,agentOptions:r,onSelect:i})=>{let a=n.find(t=>t.name===e.status),o=r.find(t=>t.name===e.agent);return(0,x.jsxs)(`button`,{type:`button`,className:`console-item-row console-queued-item-row`,"aria-current":t?`true`:void 0,"data-active":t?`true`:void 0,onClick:()=>i(e),children:[(0,x.jsx)(Oe,{isPr:e.isPr,state:`open`,merged:!1,isDraft:!1,stateReason:``}),(0,x.jsx)(`span`,{className:`console-queued-item-title`,children:e.title}),(0,x.jsxs)(`span`,{className:`console-queued-item-badges`,children:[e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:Ne(a?.color??null),children:e.status}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:Ne(o?.color??null),children:e.agent})]}),(0,x.jsx)(`span`,{className:`console-queued-item-actions`})]})},Fe=({rows:e,storyColors:t,statusOptions:n,agentOptions:r,activeItemId:i,isLoading:a,error:o,onSelectItem:s})=>o===null?a?(0,x.jsx)(`p`,{className:`console-list-message`,children:`Loading list...`}):e.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No items`}):(0,x.jsx)(`ul`,{className:`console-list`,children:e.map(e=>e.kind===`group-header`?(0,x.jsx)(`li`,{className:`console-list-group`,children:(0,x.jsx)(Ae,{story:e.story,count:e.count,colorEnum:I(t,e.story)})},`group:${e.story}`):(0,x.jsx)(`li`,{className:`console-list-row`,children:(0,x.jsx)(Pe,{item:e.item,isActive:e.item.itemId===i,statusOptions:n,agentOptions:r,onSelect:s})},e.item.itemId))}):(0,x.jsxs)(`p`,{role:`alert`,className:`console-list-message console-list-error`,children:[`Failed to load list: `,o]}),Ie=Object.keys(fe),Le=({storyName:e,storyOptionId:t,onSelectColor:n,onClose:r,disabled:i})=>{(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]);let a=e=>{n(t,e),r()};return(0,x.jsxs)(`div`,{className:`console-modal-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Change color for ${e}`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-modal-backdrop`,"aria-label":`Close dialog`,onClick:r}),(0,x.jsxs)(`div`,{className:`console-modal-inner`,children:[(0,x.jsxs)(`h2`,{className:`console-modal-title`,children:[`Change color for `,e]}),(0,x.jsx)(`div`,{className:`console-story-color-palette`,children:Ie.map(e=>{let t=fe[e];return(0,x.jsx)(`button`,{type:`button`,className:`console-story-color-swatch`,"aria-label":e===`GRAY`?`${e} (disable)`:e,style:{backgroundColor:t.dot},onClick:()=>a(e),disabled:i,children:e===`GRAY`&&(0,x.jsx)(`span`,{className:`console-story-color-swatch-label`,children:`disable`})},e)})}),(0,x.jsx)(`div`,{className:`console-modal-actions`,children:(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:r,children:`Cancel`})})]})]})},Re=({onSubmit:e,onClose:t})=>{let[n,r]=(0,y.useState)(``),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),c=(0,y.useRef)(null);(0,y.useEffect)(()=>{c.current?.focus()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]);let l=async()=>{let r=n.trim();if(r.length===0){s(`Story name is required`);return}a(!0),s(null);try{await e(r),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}};return(0,x.jsxs)(`div`,{className:`console-modal-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add story`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-modal-backdrop`,"aria-label":`Close dialog`,onClick:t}),(0,x.jsxs)(`div`,{className:`console-modal-inner`,children:[(0,x.jsx)(`h2`,{className:`console-modal-title`,children:`Add story`}),(0,x.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),l()},children:[(0,x.jsx)(`input`,{ref:c,type:`text`,className:`console-modal-input`,placeholder:`Story name`,value:n,onChange:e=>r(e.target.value),disabled:i}),o!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:o}),(0,x.jsxs)(`div`,{className:`console-modal-actions`,children:[(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:i,children:i?`Creating…`:`Create`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:t,disabled:i,children:`Cancel`})]})]})]})]})},ze=({storyName:e,isDeleting:t,deleteError:n,onConfirm:r,onCancel:i})=>((0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),(0,x.jsxs)(`div`,{className:`console-modal-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Confirm story deletion`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-modal-backdrop`,"aria-label":`Close dialog`,onClick:i}),(0,x.jsxs)(`div`,{className:`console-modal-inner`,children:[(0,x.jsx)(`h2`,{className:`console-modal-title`,children:`Delete story`}),(0,x.jsxs)(`p`,{className:`console-story-delete-confirm-message`,children:[`Delete story option "`,e,`" from the GitHub custom field?`]}),n!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:n}),(0,x.jsxs)(`div`,{className:`console-modal-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>r(!0),disabled:t,children:t?`Deleting…`:`Delete with child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:()=>r(!1),disabled:t,children:t?`Deleting…`:`Keep child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:i,disabled:t,children:`Cancel`})]})]})]})),Be=({currentDescription:e,onSubmit:t,onClose:n})=>{let[r,i]=(0,y.useState)(e),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),l=(0,y.useRef)(null);(0,y.useEffect)(()=>{l.current?.focus(),l.current?.select()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let u=async()=>{o(!0),c(null);try{await t(r.trim()),n()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,x.jsxs)(`div`,{className:`console-modal-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Edit story description`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-modal-backdrop`,"aria-label":`Close dialog`,onClick:n}),(0,x.jsxs)(`div`,{className:`console-modal-inner`,children:[(0,x.jsx)(`h2`,{className:`console-modal-title`,children:`Edit story description`}),(0,x.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u()},children:[(0,x.jsx)(`textarea`,{ref:l,className:`console-modal-input`,placeholder:`Story description`,value:r,onChange:e=>i(e.target.value),disabled:a,rows:4}),s!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:s}),(0,x.jsxs)(`div`,{className:`console-modal-actions`,children:[(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:a,children:a?`Saving…`:`Save`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:n,disabled:a,children:`Cancel`})]})]})]})]})},Ve=({currentName:e,onSubmit:t,onClose:n})=>{let[r,i]=(0,y.useState)(e),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),l=(0,y.useRef)(null);(0,y.useEffect)(()=>{l.current?.focus(),l.current?.select()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let u=async()=>{let e=r.trim();if(e.length===0){c(`Story name is required`);return}o(!0),c(null);try{await t(e),n()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,x.jsxs)(`div`,{className:`console-modal-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Rename story`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-modal-backdrop`,"aria-label":`Close dialog`,onClick:n}),(0,x.jsxs)(`div`,{className:`console-modal-inner`,children:[(0,x.jsx)(`h2`,{className:`console-modal-title`,children:`Rename story`}),(0,x.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u()},children:[(0,x.jsx)(`input`,{ref:l,type:`text`,className:`console-modal-input`,placeholder:`Story name`,value:r,onChange:e=>i(e.target.value),disabled:a}),s!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:s}),(0,x.jsxs)(`div`,{className:`console-modal-actions`,children:[(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:a,children:a?`Renaming…`:`Rename`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:n,disabled:a,children:`Cancel`})]})]})]})]})},He=({storyName:e,onSubmit:t,onClose:n})=>{let[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),l=(0,y.useRef)(null);(0,y.useEffect)(()=>{l.current?.focus()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let u=async()=>{let i=r.trim();if(i.length===0){c(`Title is required`);return}o(!0),c(null);try{await t(e,i),n()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,x.jsxs)(`div`,{className:`console-modal-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add task to ${e}`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-modal-backdrop`,"aria-label":`Close dialog`,onClick:n}),(0,x.jsxs)(`div`,{className:`console-modal-inner`,children:[(0,x.jsxs)(`h2`,{className:`console-modal-title`,children:[`Add task to `,e]}),(0,x.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u()},children:[(0,x.jsx)(`input`,{ref:l,type:`text`,className:`console-modal-input`,placeholder:`Issue title`,value:r,onChange:e=>i(e.target.value),disabled:a}),s!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:s}),(0,x.jsxs)(`div`,{className:`console-modal-actions`,children:[(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:a,children:a?`Creating…`:`Create`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:n,disabled:a,children:`Cancel`})]})]})]})]})},Ue=({items:e})=>(0,x.jsx)(`ul`,{className:`console-story-task-list`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`console-story-task-row`,children:[(0,x.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`console-story-task-title`,children:e.title}),(0,x.jsx)(`span`,{className:`console-story-task-status`,children:e.status??`—`}),(0,x.jsx)(`span`,{className:`console-story-task-agent`,children:e.agent??`—`}),(0,x.jsx)(`span`,{className:`console-story-task-depended-urls`,children:e.dependedIssueUrls.length>0?e.dependedIssueUrls.join(`, `):`—`}),(0,x.jsx)(`span`,{className:`console-story-task-next-action-date`,children:e.nextActionDate===null?`—`:e.nextActionDate.slice(0,10)}),(0,x.jsx)(`span`,{className:`console-story-task-next-action-hour`,children:e.nextActionHour===null?`—`:String(e.nextActionHour)})]},e.url))}),We=({stories:e,isLoading:t,error:n,showGray:r,onCreateIssue:i,onAddStory:a,onSelectColor:o,onToggleGray:s,onReorderStory:c,onDeleteStory:l,onRenameStory:u,onUpdateDescription:d,optimisticColors:f,colorChangeInFlight:p,colorErrors:m})=>{let[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(null),[T,ee]=(0,y.useState)(null),[E,D]=(0,y.useState)({}),[O,te]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),[ne,j]=(0,y.useState)({}),re=e=>ne[e]??{inProgress:!1,error:null},M=async(e,t)=>{j(t=>({...t,[e]:{inProgress:!0,error:null}}));try{await c(e,t),j(t=>({...t,[e]:{inProgress:!1,error:null}}))}catch(t){j(n=>({...n,[e]:{inProgress:!1,error:t instanceof Error?t.message:String(t)}}))}};if(n!==null)return(0,x.jsxs)(`p`,{role:`alert`,className:`console-list-message console-list-error`,children:[`Failed to load stories: `,n]});if(t)return(0,x.jsx)(`p`,{className:`console-list-message`,children:`Loading stories...`});let ie=async(e,t)=>{D(t=>({...t,[e]:{isDeleting:!0,error:null}}));try{await l(e,t),ee(null),D(t=>({...t,[e]:{isDeleting:!1,error:null}}))}catch(t){D(n=>({...n,[e]:{isDeleting:!1,error:t instanceof Error?t.message:String(t)}}))}},ae=r?e:e.filter(e=>e.color!==`GRAY`),oe=e.some(e=>e.color===`GRAY`),N=h===null?null:e.find(e=>e.storyOptionId===h)??null,se=b===null?null:e.find(e=>e.storyOptionId===b)??null,ce=T===null?null:e.find(e=>e.storyOptionId===T)??null,le=T===null?{isDeleting:!1,error:null}:E[T]??{isDeleting:!1,error:null},ue=O===null?null:e.find(e=>e.storyOptionId===O)??null,de=k===null?null:e.find(e=>e.storyOptionId===k)??null;return(0,x.jsxs)(`div`,{className:`console-story-list-container`,children:[ae.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No active stories`}):(0,x.jsx)(`ul`,{className:`console-story-list`,children:ae.map((e,t)=>{let n=P(f[e.storyOptionId]??e.color),r=p===e.storyOptionId,i=m[e.storyOptionId]??null,{inProgress:a,error:o}=re(e.storyOptionId),s=t===0,c=t===ae.length-1,l=C===e.storyOptionId,u=e.description??``;return(0,x.jsxs)(`li`,{className:`console-story-list-row`,children:[(0,x.jsxs)(`div`,{className:`console-story-list-row-main`,children:[e.storyViewUrl?(0,x.jsxs)(`a`,{href:e.storyViewUrl,target:`_blank`,rel:`noopener noreferrer`,className:`console-storytag`,style:{color:n.fg,borderColor:n.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:n.dot}}),e.storyName]}):(0,x.jsxs)(`span`,{className:`console-storytag`,style:{color:n.fg,borderColor:n.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:n.dot}}),e.storyName]}),(0,x.jsx)(`span`,{className:`console-story-count`,children:e.openItemCount}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>g(h===e.storyOptionId?null:e.storyOptionId),children:`Add task`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>S(b===e.storyOptionId?null:e.storyOptionId),disabled:r,children:`Change color`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move up`,disabled:s||a,onClick:()=>void M(e.storyOptionId,`up`),children:`↑`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move down`,disabled:c||a,onClick:()=>void M(e.storyOptionId,`down`),children:`↓`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,"aria-label":`Delete story`,onClick:()=>ee(e.storyOptionId),children:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Rename story`,onClick:()=>te(O===e.storyOptionId?null:e.storyOptionId),children:`Rename`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Edit description`,onClick:()=>A(k===e.storyOptionId?null:e.storyOptionId),children:`Edit description`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>w(l?null:e.storyOptionId),children:l?`Hide tasks`:`Show tasks`})]}),u!==``&&(0,x.jsx)(`p`,{className:`console-story-description`,children:u}),l&&(0,x.jsx)(Ue,{items:e.items}),o!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:o}),i!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:i})]},e.storyOptionId)})}),oe&&(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:s,children:r?`Hide archived`:`Show archived`}),(0,x.jsx)(`div`,{className:`console-add-story-section`,children:(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>v(!_),children:`Add story`})}),N!==null&&(0,x.jsx)(He,{storyName:N.storyName,onSubmit:(e,t)=>i(e,t),onClose:()=>g(null)}),_&&(0,x.jsx)(Re,{onSubmit:e=>a(e),onClose:()=>v(!1)}),se!==null&&(0,x.jsx)(Le,{storyName:se.storyName,storyOptionId:se.storyOptionId,onSelectColor:(e,t)=>{S(null),o(e,t)},onClose:()=>S(null),disabled:p===se.storyOptionId}),ce!==null&&(0,x.jsx)(ze,{storyName:ce.storyName,isDeleting:le.isDeleting,deleteError:le.error,onConfirm:e=>void ie(ce.storyOptionId,e),onCancel:()=>{ee(null),D({})}}),ue!==null&&(0,x.jsx)(Ve,{currentName:ue.storyName,onSubmit:e=>u(ue.storyOptionId,e),onClose:()=>te(null)}),de!==null&&(0,x.jsx)(Be,{currentDescription:de.description??``,onSubmit:e=>d(de.storyOptionId,e),onClose:()=>A(null)})]})},Ge=e=>`${e.isPr?`PR`:`Issue`} #${e.itemNumber}`,Ke=e=>e===null?`loading…`:e,qe=e=>{let t=[];return t.push(`CI: ${e.isCiStateSuccess?`pass`:`fail`}`),t.push(`Merge: ${e.mergeableStatus.toLowerCase()}`),e.isBranchOutOfDate&&t.push(`branch out of date`),t.join(` · `)},Je=e=>e.fetchError?`${Ge(e)} — failed to load current state`:e.currentTitle===null?`${Ge(e)} — loading current state…`:`${Ge(e)} — ${e.currentTitle} (${Ke(e.currentState)})`,Ye=({actions:e,isOnline:t,isConfirming:n,onConfirm:r,onDiscard:i})=>e.length===0?null:(0,x.jsxs)(`section`,{className:`console-offline-panel`,"aria-label":`Offline actions queue`,children:[(0,x.jsxs)(`div`,{className:`console-offline-panel-header`,children:[e.length,` action`,e.length===1?``:`s`,` held`,t?` — confirm each before sending`:` — awaiting connectivity`]}),e.map(e=>(0,x.jsxs)(`div`,{className:`console-offline-panel-item console-offline-panel-item-${e.color}`,children:[(0,x.jsx)(`div`,{className:`console-offline-panel-item-message`,children:e.message}),(0,x.jsx)(`div`,{className:`console-offline-panel-item-target`,children:Je(e)}),e.fetchError&&(0,x.jsx)(`div`,{className:`console-offline-panel-item-fetch-error`,children:`Failed to load current state — sending will act on the last known state`}),t&&e.isPr&&e.currentPrStatus!==null&&!e.fetchError&&(0,x.jsx)(`div`,{className:`console-offline-panel-item-pr-status`,children:qe(e.currentPrStatus)}),(0,x.jsxs)(`div`,{className:`console-offline-panel-item-controls`,children:[t&&(0,x.jsx)(`button`,{type:`button`,className:`console-offline-panel-confirm`,disabled:n||e.currentTitle===null&&!e.fetchError,onClick:()=>r(e.id),children:`Send`}),(0,x.jsx)(`button`,{type:`button`,className:`console-offline-panel-discard`,onClick:()=>i(e.id),children:`Discard`})]})]},e.id))]}),Xe=({message:e,color:t,remainingSeconds:n,progress:r,onUndo:i})=>(0,x.jsxs)(`div`,{className:`console-undo-toast console-undo-toast-${t}`,role:`status`,"aria-live":`polite`,children:[(0,x.jsx)(`span`,{className:`console-undo-toast-message`,children:e}),(0,x.jsx)(`button`,{type:`button`,className:`console-undo-toast-undo`,onClick:i,children:`Undo`}),(0,x.jsxs)(`span`,{className:`console-undo-toast-countdown`,"aria-hidden":`true`,children:[n,`s`]}),(0,x.jsx)(`span`,{className:`console-undo-toast-bar`,"aria-hidden":`true`,style:{width:`${Math.max(0,Math.min(100,r*100))}%`}})]}),Ze=({title:e,message:t,onDismiss:n,onRetry:r})=>(0,x.jsxs)(`div`,{className:`console-undo-toast-error console-error-toast`,role:`alert`,"aria-live":`assertive`,children:[e!==void 0&&(0,x.jsx)(`span`,{className:`console-error-toast-title`,children:e}),(0,x.jsx)(`span`,{className:`console-error-toast-message`,children:t}),(0,x.jsxs)(`div`,{className:`console-error-toast-actions`,children:[r!==void 0&&(0,x.jsx)(`button`,{type:`button`,className:`console-error-toast-retry`,onClick:r,children:`Retry`}),(0,x.jsx)(`button`,{type:`button`,className:`console-error-toast-dismiss`,onClick:n,children:`Dismiss`})]})]}),Qe=(e,t)=>Object.keys(t.items).length===0&&t.failures.length>0?{status:`error`,failures:t.failures}:{status:`on`,snapshot:{capturedAt:t.capturedAt,tabs:e===null?t.tabs:{...e.tabs,...t.tabs},items:e===null?t.items:{...e.items,...t.items},failures:t.failures}},$e=`tdpm-airplane-v1`,et=`/airplane-snapshot-data`,tt=`tdpm_airplane_mode_on`,nt=()=>typeof localStorage>`u`?!1:localStorage.getItem(tt)===`1`,rt=e=>{typeof localStorage>`u`||(e?localStorage.setItem(tt,`1`):localStorage.removeItem(tt))},it=async e=>{if(typeof caches>`u`)throw Error(`Cache API unavailable`);try{await(await caches.open($e)).put(et,new Response(JSON.stringify(e),{headers:{"Content-Type":`application/json`}}))}catch(e){throw e instanceof Error&&e.name===`QuotaExceededError`?Error(`Not enough browser storage to save the offline snapshot. Free up storage and retry.`):e}},at=async()=>{if(typeof caches>`u`)return null;let e=await(await caches.open($e)).match(et);return e===void 0?null:e.json()},ot=async()=>{typeof caches>`u`||await caches.delete($e)},st=e=>typeof e==`object`&&!!e&&!Array.isArray(e),R=e=>typeof e==`string`?e:``,ct=e=>typeof e==`number`?e:0,lt=e=>e===!0,ut=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],dt=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,ft=e=>st(e)?{number:ct(e.number),title:R(e.title),url:R(e.url),repo:R(e.repo),nameWithOwner:R(e.nameWithOwner),projectItemId:R(e.projectItemId),itemId:R(e.itemId),isPr:lt(e.isPr),story:R(e.story),status:typeof e.status==`string`?e.status:null,nextActionDate:typeof e.nextActionDate==`string`?e.nextActionDate:null,nextActionHour:typeof e.nextActionHour==`number`?e.nextActionHour:null,dependedIssueUrls:ut(e.dependedIssueUrls),labels:ut(e.labels),createdAt:R(e.createdAt),relatedOpenPullRequestUrls:ut(e.relatedOpenPullRequestUrls),agent:typeof e.agent==`string`?e.agent:null}:null,pt=e=>{if(!st(e))return{items:[],generatedAt:``,statusOptions:[],agentOptions:[],storyOptions:[],storyColors:{},stories:[],defaultNameWithOwner:null,fromCache:!1,storyOrder:[],timerEndsAt:null,timerTotalSeconds:null};let t=Array.isArray(e.items)?e.items.map(ft).filter(e=>e!==null):[],n=Array.isArray(e.statusOptions)?e.statusOptions.filter(st):[],r=Array.isArray(e.agentOptions)?e.agentOptions.filter(st):[],i=Array.isArray(e.storyOptions)?e.storyOptions.filter(st):[],a=Array.isArray(e.stories)?e.stories.filter(st):[],o=Array.isArray(e.storyOrder)?e.storyOrder.filter(e=>typeof e==`string`):[];return{items:t,generatedAt:typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:n,agentOptions:r,storyOptions:i,storyColors:st(e.storyColors)?e.storyColors:{},stories:a,defaultNameWithOwner:typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,fromCache:!1,storyOrder:o,timerEndsAt:null,timerTotalSeconds:null}},mt=e=>st(e)?{author:R(e.author),body:R(e.body),createdAt:R(e.createdAt)}:null,ht=e=>st(e)?{path:R(e.path),additions:ct(e.additions),deletions:ct(e.deletions),status:R(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null}:null,gt=e=>st(e)?{sha:R(e.sha),message:R(e.message),author:R(e.author),authoredAt:R(e.authoredAt)}:null,_t=e=>st(e)?{found:lt(e.found),isConflicted:lt(e.isConflicted),mergeableStatus:dt(e.mergeableStatus),isPassedAllCiJob:lt(e.isPassedAllCiJob),isCiStateSuccess:lt(e.isCiStateSuccess),isBranchOutOfDate:lt(e.isBranchOutOfDate),missingRequiredCheckNames:ut(e.missingRequiredCheckNames)}:{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},vt=e=>{if(!st(e))return null;let t=st(e.summary)?{title:R(e.summary.title),body:R(e.summary.body),additions:ct(e.summary.additions),deletions:ct(e.summary.deletions),changedFiles:ct(e.summary.changedFiles)}:null;return{url:R(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:R(e.createdAt),isDraft:lt(e.isDraft),isConflicted:lt(e.isConflicted),mergeableStatus:dt(e.mergeableStatus),isPassedAllCiJob:lt(e.isPassedAllCiJob),isCiStateSuccess:lt(e.isCiStateSuccess),isResolvedAllReviewComments:lt(e.isResolvedAllReviewComments),isBranchOutOfDate:lt(e.isBranchOutOfDate),missingRequiredCheckNames:ut(e.missingRequiredCheckNames),summary:t}},yt=e=>{if(!st(e))return{body:``,comments:[],state:{state:`open`,merged:!1,isPullRequest:!1,title:``},files:null,commits:null,prStatus:null,relatedPrs:null};let t=st(e.state)?e.state:{},n={state:R(t.state)||`open`,merged:lt(t.merged),isPullRequest:lt(t.isPullRequest),title:R(t.title)},r=e.files===null?null:Array.isArray(e.files)?e.files.map(ht).filter(e=>e!==null):null,i=e.commits===null?null:Array.isArray(e.commits)?e.commits.map(gt).filter(e=>e!==null):null,a=e.prStatus===null?null:_t(e.prStatus),o=e.relatedPrs===null?null:Array.isArray(e.relatedPrs)?e.relatedPrs.map(vt).filter(e=>e!==null):null;return{body:R(e.body),comments:Array.isArray(e.comments)?e.comments.map(mt).filter(e=>e!==null):[],state:n,files:r,commits:i,prStatus:a,relatedPrs:o}},bt=e=>{if(!st(e))return null;let t=typeof e.capturedAt==`string`?e.capturedAt:``,n=ut(e.failures),r={};if(st(e.tabs))for(let[t,n]of Object.entries(e.tabs)){if(!st(n))continue;let e={};for(let[t,r]of Object.entries(n))e[t]=pt(r);r[t]=e}let i={};if(st(e.items))for(let[t,n]of Object.entries(e.items))i[t]=yt(n);return{capturedAt:t,tabs:r,items:i,failures:n}},xt=`/api/airplanesync`,St=e=>{try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)&&`type`in t&&typeof t.type==`string`?t:null}catch{return null}},Ct=()=>{let[e,t]=(0,y.useState)(`off`),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),c=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!nt())return;let e=!1;return at().then(n=>{e||n===null||(a(n),t(`on`))}).catch(()=>{rt(!1)}),()=>{e=!0}},[]);let l=(0,y.useCallback)(async(e,n)=>{let i=e.getReader(),o=new TextDecoder,c=``;for(;;){let{done:e,value:l}=await i.read();if(e)break;c+=o.decode(l,{stream:!0});let u=c.split(`
|
|
12
12
|
|
|
13
|
-
`);c=u.pop()??``;for(let e of u){if(!e.startsWith(`data: `))continue;let i=St(e.slice(6));if(i!==null){if(i.type===`progress`)r({fetched:typeof i.fetched==`number`?i.fetched:0,total:typeof i.total==`number`?i.total:0});else if(i.type===`done`){let e=bt(i.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}let r=Qe(n,e);if(r.status===`error`){s(r.failures),t(`error`);return}let o=bt(r.snapshot);if(o===null){t(`error`),s([`Failed to merge snapshot`]);return}await it(o),rt(!0),a(o),t(`on`),s(o.failures)}}}}},[]),u=(0,y.useCallback)(()=>{c.current!==null&&c.current.abort();let e=new AbortController;c.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),fetch(xt,{signal:e.signal}).then(async e=>{if(!e.ok||e.body===null){t(`error`),s([`HTTP ${e.status}`]);return}await l(e.body,null)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]),d=(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),rt(!1),ot().catch(()=>{})},[]),f=(0,y.useCallback)((e,n)=>{if(n.length===0)return;c.current!==null&&c.current.abort();let i=new AbortController;c.current=i,t(`syncing`),r({fetched:0,total:n.length}),s([]),fetch(xt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targetUrls:n}),signal:i.signal}).then(async n=>{if(!n.ok||n.body===null){t(`error`),s([`HTTP ${n.status}`]);return}await l(n.body,e)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]);return{status:e,progress:n,snapshot:i,failures:o,startSync:u,turnOff:d,retryFailed:()=>f(i,o)}},wt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Tt=e=>typeof e==`string`?e:``,Et=e=>typeof e==`number`?e:0,Dt=e=>e===!0,Ot=`console-api-v1`,kt=async(e,t)=>{let n=`${e}?url=${encodeURIComponent(t)}`;try{let e=await fetch(n);if(!e.ok){let t=`HTTP ${e.status}`;try{let n=await e.json();wt(n)&&typeof n.error==`string`&&n.error.length>0&&(t=n.error)}catch(e){console.warn(`Failed to parse error body from non-ok response:`,e)}throw Error(t)}let t=await e.json();try{`caches`in globalThis&&globalThis.caches.open(Ot).then(e=>e.put(n,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist API response to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}return t}catch(e){try{if(`caches`in globalThis){let e=await(await globalThis.caches.open(Ot)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},At=e=>!wt(e)||!Array.isArray(e.comments)?[]:e.comments.filter(wt).map(e=>({author:Tt(e.author),body:Tt(e.body),createdAt:Tt(e.createdAt)})),jt=e=>!wt(e)||!Array.isArray(e.files)?[]:e.files.filter(wt).map(e=>({path:Tt(e.path)||Tt(e.filename),additions:Et(e.additions),deletions:Et(e.deletions),status:Tt(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Mt=e=>!wt(e)||!Array.isArray(e.commits)?[]:e.commits.filter(wt).map(e=>({sha:Tt(e.sha),message:Tt(e.message),author:Tt(e.author),authoredAt:Tt(e.authoredAt)})),Nt=e=>wt(e)?{title:Tt(e.title),body:Tt(e.body),additions:Et(e.additions),deletions:Et(e.deletions),changedFiles:Et(e.changedFiles)}:null,Pt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ft=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,It=e=>!wt(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(wt).map(e=>({url:Tt(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:Tt(e.createdAt),isDraft:Dt(e.isDraft),isConflicted:Dt(e.isConflicted),mergeableStatus:Ft(e.mergeableStatus),isPassedAllCiJob:Dt(e.isPassedAllCiJob),isCiStateSuccess:Dt(e.isCiStateSuccess),isResolvedAllReviewComments:Dt(e.isResolvedAllReviewComments),isBranchOutOfDate:Dt(e.isBranchOutOfDate),missingRequiredCheckNames:Pt(e.missingRequiredCheckNames),summary:Nt(e.summary)})),Lt=e=>{if(!wt(e)||!wt(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:Dt(t.isConflicted),mergeableStatus:Ft(t.mergeableStatus),isPassedAllCiJob:Dt(t.isPassedAllCiJob),isCiStateSuccess:Dt(t.isCiStateSuccess),isBranchOutOfDate:Dt(t.isBranchOutOfDate),missingRequiredCheckNames:Pt(t.missingRequiredCheckNames)}},Rt=e=>wt(e)?{state:Tt(e.state)||`open`,merged:Dt(e.merged),isPullRequest:Dt(e.isPullRequest),title:Tt(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},zt=()=>({fetchItemBody:async e=>{let t=await kt(`/api/itembody`,e);return wt(t)?Tt(t.body):``},fetchComments:async e=>At(await kt(`/api/comments`,e)),fetchPrFiles:async e=>jt(await kt(`/api/prfiles`,e)),fetchPrCommits:async e=>Mt(await kt(`/api/prcommits`,e)),fetchRelatedPrs:async e=>It(await kt(`/api/relatedprs`,e)),fetchIssueState:async e=>Rt(await kt(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Lt(await kt(`/api/pullrequeststatus`,e))}),Bt=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(wt(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Vt=async(e,t)=>{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(await Bt(n))},Ht=`/api/comment`,Ut=e=>({author:Tt(e.author),body:Tt(e.body),createdAt:Tt(e.createdAt)}),Wt=async e=>{let t=await fetch(Ht,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await Bt(t),rateLimitResetAt:null};let n=await t.json();return wt(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:wt(n.comment)?{posted:!0,comment:Ut(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},Gt=`/api/upload`,z=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Kt=async e=>{let t=await fetch(Gt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t));let n=await t.json();if(!wt(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},qt=`/api/addstory`,Jt=async e=>{let t=await fetch(qt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},Yt=`/api/reviewcomment`,Xt=async e=>{let t=await fetch(Yt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},Zt=`/api/createissue`,Qt=`/api/storycolor`,$t=async e=>{let t=await fetch(Qt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},en=async e=>{let t=await fetch(Zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t));let n=await t.json();if(!(e=>typeof e==`object`&&!!e&&!Array.isArray(e))(n)||typeof n.issueUrl!=`string`)throw Error(`issueUrl was not returned`);return n.issueUrl},tn=`/api/createworkflowissue`,nn=async e=>{let t=await fetch(tn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t));let n=await t.json();if(!(e=>typeof e==`object`&&!!e&&!Array.isArray(e))(n)||typeof n.issueUrl!=`string`)throw Error(`issueUrl was not returned`);return n.issueUrl},rn=`/api/reorderstory`,an=async e=>{let t=await fetch(rn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},on=`/api/deleteallcomments`,sn=async e=>{let t=await fetch(on,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},cn=`/api/deletestory`,ln=async e=>{let t=await fetch(cn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},un=`/api/renamestory`,dn=async e=>{let t=await fetch(un,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},fn=`/api/storydescription`,pn=async e=>{let t=await fetch(fn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},mn=e=>typeof e!=`object`||!e||Array.isArray(e)?null:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`)),hn=async()=>{let e=await fetch(`/api/projects`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if(typeof t!=`object`||!t||Array.isArray(t))return{pjcodes:[],projectUrls:null,fleetTaskCreateUrl:null,nameWithOwnerByPjcode:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:mn(n.projectUrls),fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null,nameWithOwnerByPjcode:mn(n.nameWithOwnerByPjcode)}},gn=`/api/projectreadmeconfig`,_n=async e=>{let t=`${gn}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await Bt(n));let r=await n.json();return{maximumPreparingIssuesCount:wt(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},vn=`/api/renameissue`,yn=async e=>{let t=await fetch(vn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},bn=`/api/setdependedissueurl`,xn=async e=>{let t=await fetch(bn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},Sn=`/api/projectsettings`,Cn=async e=>{let t=await fetch(Sn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},wn=5e3,Tn=e=>`${e.isPr?`PR #`:`#`}${e.number}`,En=(e,t)=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`Approved & Merged`:e.action===`request_changes`?`Rejected`:e.action===`totally_wrong`?`Marked totally wrong`:`Marked unnecessary`;case`next_action_date`:return e.action===`snooze_1hour`?`Next Action Hour +1h`:e.action===`snooze_3hours`?`Next Action Hour +3h`:e.action===`snooze_6hours`?`Next Action Hour +6h`:e.action===`snooze_1day`?`Next Action Date +1d`:e.action===`snooze_2days`?`Next Action Date +2d`:e.action===`snooze_3days`?`Next Action Date +3d`:e.action===`snooze_5days`?`Next Action Date +5d`:e.action===`snooze_1month`?`Next Action Date +1mo`:we(t)?`Next Action Date +1w skip`:`Next Action Date +1w`;case`set_story`:return`Story → ${e.optionName}`;case`set_agent`:return`Agent → ${e.optionName}`;case`set_status`:return`Status → ${e.optionName}`;case`set_in_tmux_by_human`:return`Added to In Tmux by human`;case`ok_and_awaiting_workspace`:return`ok → Awaiting Workspace`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},Dn=e=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`green`:e.action===`request_changes`?`amber`:e.action===`totally_wrong`?`red`:`gray`;case`next_action_date`:return`amber`;case`set_story`:case`set_agent`:case`set_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},On=(e,t)=>e.type===`next_action_date`?we(t):e.type!==`delete_all_comments`,kn=(e,t,n)=>`${En(e,n)} — ${Tn(t)}`,An=`console-comment-expanded:`,jn=e=>{try{let t=localStorage.getItem(An+e);if(t===null)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch(e){return console.error(`Failed to load comment expanded state from storage:`,e),new Set}},Mn=(e,t)=>{try{localStorage.setItem(An+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Nn=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(An)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},Pn=`console-offline-action-queue`,Fn=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.message==`string`&&typeof t.color==`string`&&typeof t.enqueuedAt==`number`&&typeof t.itemUrl==`string`&&typeof t.projectItemId==`string`&&typeof t.itemNumber==`number`&&typeof t.repo==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},In=()=>{try{let e=localStorage.getItem(Pn);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(Fn):[]}catch{return[]}},Ln=e=>{localStorage.setItem(Pn,JSON.stringify(e))},Rn=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`,zn=e=>e instanceof TypeError,Bn=e=>e instanceof Error&&e.message.length>0?e.message:String(e),Vn=100,Hn=e=>Math.max(0,Math.ceil((wn-e)/1e3)),Un=e=>Math.max(0,1-e/wn),Wn=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(In),o=(0,y.useRef)(i);o.current=i;let s=(0,y.useRef)(null),c=(0,y.useRef)(0),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useRef)(()=>{}),f=(0,y.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),p=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:Rn(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return Ln(n),n})},[]),m=(0,y.useCallback)(e=>{e.commit().catch(t=>{zn(t)&&e.offline!==void 0?p(e):r({message:e.message,reason:Bn(t),retry:()=>d.current(e)})})},[p]);d.current=m;let h=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,Nn(),m(e))},[f,m]),g=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.(),e?.revertOptimistic?.()},[f]),_=(0,y.useCallback)(()=>{r(null)},[]),v=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),b=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return Ln(n),n})},[]),x=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Vt(t.apiPath,t.requestBody),b(e)}catch(n){zn(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:Bn(n)}),b(e))}},[b]),S=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;f(),u.current=!0,Nn(),m(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Hn(0),progress:Un(0)}),e.advance(),e.optimistic?.(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){h();return}t({message:e.message,color:e.color,remainingSeconds:Hn(n),progress:Un(n)})},Vn)},[f,h,m]);return(0,y.useEffect)(()=>h,[h]),{pending:e,error:n,offlineActions:i,enqueue:S,showError:v,undo:g,dismissError:_,confirmOfflineAction:x,discardOfflineAction:b}},Gn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Kn=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],qn=e=>Array.isArray(e)?e.filter(Gn).map(e=>({...e,relatedOpenPullRequestUrls:Kn(e.relatedOpenPullRequestUrls)})):[],Jn=e=>!Gn(e)||!Array.isArray(e.items)?[]:qn(e.items),Yn=e=>Array.isArray(e)?e.filter(Gn):[],Xn=e=>Array.isArray(e)?e.filter(Gn).map(e=>({...e,items:qn(e.items)})):[],Zn=e=>({items:Jn(e),generatedAt:Gn(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Gn(e)?Yn(e.statusOptions):[],agentOptions:Gn(e)?Yn(e.agentOptions):[],storyOptions:Gn(e)?Yn(e.storyOptions):[],storyColors:Gn(e)&&Gn(e.storyColors)?e.storyColors:{},stories:Gn(e)?Xn(e.stories):[],defaultNameWithOwner:Gn(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Gn(e)?Kn(e.storyOrder):[],timerEndsAt:Gn(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Gn(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Qn=()=>{let e={};for(let t of j)e[t.name]=null;return e},$n=(e,t)=>`/projects/${e}/${t}/list.json`,er=6e4,tr=`console-list-v1`,nr=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(tr).then(n=>n.put(e,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist tab snapshot to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}},rr=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(tr)).match(e);return t===void 0?null:{...Zn(await t.json()),fromCache:!0}}catch{return null}},ir=async e=>{let t=await Promise.all(j.map(async t=>({tabName:t.name,snapshot:await rr($n(e,t.name))}))),n=Qn();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},ar=async(e,t)=>{let n=$n(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return nr(n,t),{snapshot:{...Zn(t),fromCache:!1},error:null}}catch(e){let t=await rr(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},or=async e=>{await Promise.all(j.map(async t=>{let n=$n(e,t.name);try{let e=await fetch(n);if(!e.ok)return;nr(n,await e.json())}catch{}}))},sr=async e=>{let t=await Promise.all(j.map(async t=>{let{snapshot:n,error:r}=await ar(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Qn(),r=null;for(let{tabName:e,snapshot:i,error:a}of t)n[e]=i,a!==null&&r===null&&(r=a);return{snapshots:n,firstError:Object.values(n).every(e=>e===null)?r:null}},cr=(e,t=null)=>{let n=(0,y.useRef)(new Map),[r,i]=(0,y.useState)(Qn),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(e);if(l!==e){u(e);let t=e===null?null:n.current.get(e)??null;i(t??Qn()),t!==null&&o(!1)}return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Qn();for(let t of j){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}i(e),o(!1),c(null);return}}let r=!1,a=!1;if(c(null),e===null)return i(Qn()),o(!1),c(`No project specified in the URL path.`),()=>{r=!0};let s=n.current.has(e);ir(e).then(t=>{if(r)return;let c=Object.values(t).some(e=>e!==null);c&&!a?(n.current.set(e,t),i(t),o(!1)):!c&&!a&&!s&&(o(!0),i(Qn()))});let l=()=>{sr(e).then(({snapshots:t,firstError:s})=>{r||(a=!0,n.current.set(e,t),i(t),c(s===null?null:s.message),o(!1))}).catch(e=>{r||(a=!0,c(e instanceof Error?e.message:String(e)),o(!1))})};l();let u=setInterval(l,er);return()=>{r=!0,clearInterval(u)}},[e,t]),{snapshots:r,isLoading:a,error:s,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:r}=await ar(e,t);r!==null&&i(i=>{let a={...i,[t]:r};return n.current.set(e,a),a})},[e])}},lr=(e,t,n)=>{(0,y.useEffect)(()=>{if(!n)return;let r=t.filter(t=>t!==e);if(r.length===0)return;let i=()=>{for(let e of r)or(e).catch(()=>{})};i();let a=setInterval(i,er);return()=>{clearInterval(a)}},[n,e,t])},ur=class{fetcher;cache=new Map;inFlight=new Map;prefetchInFlight=new Set;constructor(e){this.fetcher=e}peek=e=>this.cache.get(e);has=e=>this.cache.has(e);load=(e,t)=>{let n=this.cache.get(e);if(n!==void 0)return Promise.resolve(n);let r=this.inFlight.get(e);if(r!==void 0)return r;let i=this.fetcher(t).then(t=>(this.cache.set(e,t),t)).finally(()=>{this.inFlight.delete(e)});return this.inFlight.set(e,i),i};prefetch=(e,t)=>{this.cache.has(e)||this.inFlight.has(e)||this.prefetchInFlight.has(e)||(this.prefetchInFlight.add(e),this.fetcher(t).then(t=>{this.cache.set(e,t)}).catch(()=>{}).finally(()=>{this.prefetchInFlight.delete(e)}))};seed(e,t){this.cache.set(e,t)}invalidate=e=>{this.cache.delete(e)}},dr=e=>{try{let t=new URL(e).pathname.split(`/`).filter(Boolean);if(t.length>=4)return`${t[0]}/${t[1]}#${t[3]}`}catch{}return e},fr=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=dr(n);e.body.seed(t,r.body),e.comments.seed(t,r.comments),e.state.seed(t,r.state),r.files!==null&&e.files.seed(t,r.files),r.commits!==null&&e.commits.seed(t,r.commits),r.prStatus!==null&&e.prStatus.seed(t,r.prStatus),r.relatedPrs!==null&&e.relatedPrs.seed(t,r.relatedPrs)}},pr=(e=null)=>(0,y.useMemo)(()=>{let t=zt(),n={client:t,body:new ur(t.fetchItemBody),comments:new ur(t.fetchComments),files:new ur(t.fetchPrFiles),commits:new ur(t.fetchPrCommits),relatedPrs:new ur(t.fetchRelatedPrs),state:new ur(t.fetchIssueState),prStatus:new ur(t.fetchPullRequestStatus)};return e!==null&&fr(n,e),n},[e]),mr=0,hr=500,gr=2e3,_r=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:gr});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},vr=(e,t)=>{let n=`${t.repo}#${t.number}`;e.body.prefetch(n,t.url),e.state.prefetch(n,t.url),e.comments.prefetch(n,t.url),t.isPr?(e.files.prefetch(n,t.url),e.commits.prefetch(n,t.url),e.prStatus.prefetch(n,t.url)):e.relatedPrs.prefetch(n,t.url)},yr=(e,t,n)=>{(0,y.useEffect)(()=>{if(t===null)return;let r=n.findIndex(e=>e.projectItemId===t.projectItemId);if(r===-1)return;let i=n.slice(r+1,r+1+mr);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=_r(()=>{for(let t of i)vr(e,t)})},hr);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},br=`/api/features`,xr=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(br).then(async e=>{if(!e.ok)return;let n=await e.json();typeof n==`object`&&n&&!Array.isArray(n)&&`airplaneMode`in n&&typeof n.airplaneMode==`boolean`&&t({airplaneMode:n.airplaneMode})}).catch(e=>{console.warn(`Failed to fetch /api/features`,e)})},[]),e},Sr=(e,t)=>{let n=j.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<j.length;e+=1){let n=j[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},Cr=e=>{let t=j.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},wr=new Set(j.map(e=>e.name)),Tr=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return wr.has(n)?n:null},Er=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Dr=`#settings`,Or=(e,t,n=new Set,r)=>{let i=(0,y.useCallback)(()=>{let e=Cr(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:Tr(window.location.pathname)??e,selectedItemKey:Er(window.location.hash)}},[t]),[a,o]=(0,y.useState)(i),s=(0,y.useRef)(null);s.current=e,(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{o(i())};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[i]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=Tr(window.location.pathname),i=Object.values(t).some(e=>e>0),a=r??t;if(e!==null){if(t[e]>0||a[e]>0){o(t=>t.activeTab===e?t:{...t,activeTab:e});return}if(!n.has(e))return}let c=Cr(t);i&&s.current!==null&&window.history.replaceState({},``,`/projects/${s.current}/${c}${window.location.search}`),o(e=>e.activeTab===c?e:{...e,activeTab:c})},[t,n,r]);let c=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),l=(0,y.useCallback)(e=>{if(typeof window>`u`){o({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,c(e)),o({activeTab:e,selectedItemKey:null})},[c]),u=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),o(t=>({...t,selectedItemKey:e}))},[]),d=(0,y.useCallback)(()=>{if(typeof window<`u`&&window.location.hash!==``){let e=`${window.location.pathname}${window.location.search}`;window.history.pushState({},``,e)}o(e=>({...e,selectedItemKey:null}))},[]);return{activeTab:a.activeTab,selectedItemKey:a.selectedItemKey,tabHref:c,selectTab:l,openItem:u,closeItem:d}},kr=`/api/review`,Ar=`/api/triage`,jr=`/api/intmux`,Mr=(e,t,n,r,i)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:be(i),...r===void 0?{}:{changedFilePath:r.path,line:r.line,side:r.side}}}return r===`totally_wrong`?{pjcode:e,action:`close`,prUrl:n,issueUrl:t.url,projectItemId:t.projectItemId,commentBody:_e}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:ve,issueCommentBody:ye(n)}},Nr=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),Pr=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),Fr=()=>Error(`No project specified in the URL path.`),Ir=`ok`,Lr=(e,t,n)=>{let r=(0,y.useCallback)(e=>{if(t===void 0)return;let n=`${e.repo}#${e.number}`;t.body.invalidate(n),t.comments.invalidate(n)},[t]),i=(0,y.useCallback)(async(t,n,i,a=[])=>{if(e===null)throw Fr();await Vt(kr,Mr(e,t,n,i,a)),r(t)},[e,r]),a=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId}),r(t)},[e,r]),o=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:`set_agent`,issueUrl:t.url,projectItemId:t.projectItemId,agentOptionId:n.id}),r(t)},[e,r]);return{reviewPullRequest:i,setNextActionDate:a,setStory:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:`set_story`,issueUrl:t.url,projectItemId:t.projectItemId,storyOptionId:n.id}),r(t)},[e,r]),setAgent:o,setStatus:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:`set_status`,issueUrl:t.url,projectItemId:t.projectItemId,statusName:n.name}),r(t)},[e,r]),setInTmuxByHuman:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(jr,{pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),r(t)},[e,r]),closeIssue:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId}),r(t)},[e,r]),okAndMoveToAwaitingWorkspace:(0,y.useCallback)(async(t,i)=>{if(e===null)throw Fr();let a=await Wt({pjcode:e,url:t.url,body:Ir});if(await Vt(Ar,{pjcode:e,action:`set_status`,issueUrl:t.url,projectItemId:t.projectItemId,statusName:i.name}),r(t),await n?.(),!a.posted){let e=a.rateLimitResetAt===null?``:` Rate limit resets at ${a.rateLimitResetAt}.`;throw Error(`Comment not posted — ${a.error}.${e} Status was changed. Re-post: ${Ir}`)}},[e,r,n]),addComment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();let i=await Wt({pjcode:e,url:t.url,body:n});if(!i.posted){let e=i.rateLimitResetAt===null?``:` Rate limit resets at ${i.rateLimitResetAt}.`;throw Error(`${i.error}.${e}`)}return r(t),i.comment},[e,r]),uploadAttachment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=z(new Uint8Array(await n.arrayBuffer()));return Kt({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw Fr();await Xt({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),issueRename:(0,y.useCallback)(async(e,t)=>{await yn({issueUrl:e.url,newTitle:t})},[]),deleteAllComments:(0,y.useCallback)(async e=>{await sn({issueUrl:e.url}),r(e)},[r]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await xn({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e])}},Rr=e=>`pv_overlay_${e}`,zr=e=>e.projectItemId===``?e.itemId:e.projectItemId,Br=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,Vr=(e,t,n)=>e.filter(e=>!Br(t[zr(e)],n)).length,Hr=(e,t,n)=>e.filter(e=>!Br(t[zr(e)],n)),Ur=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[zr(t)];return i===void 0||i.ts<r?null:i.status??null},Wr=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},Gr=(e,t)=>{let n={...e};return delete n[t],n},Kr=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,qr=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(Rr(e));if(t===null)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{};let r={};for(let[e,t]of Object.entries(n))Kr(t)&&(r[e]=t);return r},Jr=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(Rr(e),JSON.stringify(t))},Yr=e=>{let[t,n]=(0,y.useState)(()=>qr(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=Wr(n,t,r,i,Date.now());return Jr(e,a),a})},[e]),revertOverlayEntry:(0,y.useCallback)(t=>{n(n=>{let r=Gr(n,t);return Jr(e,r),r})},[e])}},Xr=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<2||t[0]!==`projects`)return null;let n=t[1];return n.length===0?null:n},Zr=()=>{let[e,t]=(0,y.useState)(()=>Xr(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(Xr(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},Qr=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return l(!0),d(null),hn().then(n=>{e||(t(n.pjcodes),r(n.projectUrls),a(n.fleetTaskCreateUrl),s(n.nameWithOwnerByPjcode),l(!1))}).catch(t=>{e||(d(t instanceof Error?t:Error(String(t))),l(!1))}),()=>{e=!0}},[]),{pjcodes:e,projectUrls:n,fleetTaskCreateUrl:i,nameWithOwnerByPjcode:o,isLoading:c,error:u}},$r=e=>(0,y.useCallback)(t=>{Nn(),e(t)},[e]),ei=()=>typeof window<`u`&&window.location.hash===`#settings`,ti=e=>{let[t,n]=(0,y.useState)(ei),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)({}),d=(0,y.useRef)(``),f=(0,y.useRef)(e);f.current=e,(0,y.useEffect)(()=>{if(!t)return;let e=!1;return u({}),i(!0),c(null),Promise.all(f.current.map(e=>_n(e).then(t=>({pjcode:e,value:t.maximumPreparingIssuesCount===null?``:String(t.maximumPreparingIssuesCount)})))).then(t=>{if(!e){let e={};for(let{pjcode:n,value:r}of t)e[n]=r;u(e)}}).catch(t=>{e||c(t instanceof Error?t.message:`Failed to load settings`)}).finally(()=>{e||i(!1)}),()=>{e=!0}},[t]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.location.hash===Dr;e||c(null),n(e)};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]);let p=(0,y.useCallback)(()=>{typeof window<`u`&&(d.current=window.location.hash,window.history.pushState({},``,Dr)),n(!0)},[]),m=(0,y.useCallback)(()=>{if(typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1),c(null)},[]),h=(0,y.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),g=(0,y.useCallback)(async()=>{o(!0),c(null);try{if(await Promise.all(Object.entries(l).filter(([,e])=>{let t=parseInt(e,10);return!Number.isNaN(t)&&t>=0}).map(([e,t])=>Cn({pjcode:e,maximumPreparingIssuesCount:parseInt(t,10)}))),typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1)}catch(e){c(e instanceof Error?e.message:`Failed to save settings`)}finally{o(!1)}},[l]);return(0,y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&m()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,m]),{isOpen:t,isLoading:r,isSaving:a,error:s,inputValues:l,open:p,close:m,changeInput:h,save:g}},ni=e=>{let t=(0,y.useRef)(e),n=(0,y.useRef)(Date.now());return t.current!==e&&(t.current=e,n.current=Date.now()),{isTimerExpired:(0,y.useCallback)(e=>e<=0?!1:Date.now()-n.current>=e*60*1e3,[])}},ri=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,ii=/^From:\s+:robot:/m,ai=/^##\s/m,oi=e=>{let t=ri.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=ii.exec(n),i=ai.exec(n),a=n.length;r!==null&&(a=Math.min(a,r.index)),i!==null&&(a=Math.min(a,i.index));let o=n.slice(0,a).trim();return o.length>0?o:null},si=e=>{if(e.length===0)return null;let t=e[e.length-1],n=oi(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},ci=e=>`${e.repo}#${e.number}`,li=(e,t,n)=>{let[r,i]=(0,y.useState)({});return(0,y.useEffect)(()=>{if(!n)return;let r=!1;for(let n of e){let e=ci(n),a=t.peek(e);if(a!==void 0){let e=si(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e});continue}t.load(e,n.url).then(e=>{if(r)return;let t=si(e);i(e=>e[n.projectItemId]===t?e:{...e,[n.projectItemId]:t})}).catch(()=>{r||i(e=>e[n.projectItemId]===null?e:{...e,[n.projectItemId]:null})})}return()=>{r=!0}},[e,t,n]),r},ui=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},di=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},fi=e=>{let t=e instanceof Element?e:null;for(;t!==null&&t!==document.body;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth&&t.scrollLeft>0)return!0;t=t.parentElement}return!1},pi=e=>{let t=(0,y.useRef)(e);t.current=e;let n=(0,y.useRef)(null),r=(0,y.useCallback)(e=>{let n=0,r=0,i=!1,a=e=>{if(e.touches.length!==1){i=!1;return}if(fi(e.target)){i=!1;return}let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},o=e=>{if(!i)return;let t=e.touches[0];di(t.clientX-n,t.clientY-r)&&(i=!1)},s=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let a=e.changedTouches[0],o=ui(a.clientX-n,a.clientY-r);o!==null&&t.current(o)};return e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),()=>{e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s)}},[]),i=(0,y.useCallback)(e=>{n.current!==null&&(n.current(),n.current=null),e!==null&&(n.current=r(e))},[r]);return(0,y.useEffect)(()=>()=>{n.current!==null&&(n.current(),n.current=null)},[]),i},mi=e=>(0,y.useCallback)(t=>{Nn(),e(t)},[e]),hi=(e,t,n,r,i)=>{let a=(0,y.useRef)(void 0),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(!e){a.current=t,o.current=!1;return}a.current!==t&&(a.current=t,o.current=t!==null),o.current&&r===null&&n.length!==0&&(o.current=!1,i(n[0].projectItemId))},[e,t,n,r,i])},gi=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},_i=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},vi=(e,t,n,r,i,a,o,s,c,l)=>{let u=(0,y.useRef)(0),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e||r===null){u.current=0,d.current=null;return}if(!o||!s||c||l||d.current===r)return;if(t>0||n>0){u.current=0;return}if(i.length===0)return;let f=i.filter(e=>(a[e]??15)>0);if(u.current>=f.length-1){d.current=r,u.current=0;return}d.current=r,u.current+=1;let p=ce(i,r,a);p===null?u.current=0:gi(`/projects/${p}/todo-by-human`)},[e,t,n,r,i,a,o,s,c,l])},yi=()=>{let[e,t]=(0,y.useState)(N),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(e),o=(0,y.useCallback)(()=>{t(e=>(a(e),e)),r(!0)},[]),s=(0,y.useCallback)(()=>{r(!1)},[]),c=(0,y.useCallback)(()=>{a(e=>(se(e),t(e),e)),r(!1)},[]),l=(0,y.useCallback)(e=>{a(t=>({...t,timerMode:e}))},[]),u=(0,y.useCallback)((e,t)=>{a(n=>({...n,projectMinutes:{...n.projectMinutes,[e]:t}}))},[]);return{timerMode:e.timerMode,projectMinutes:e.projectMinutes,isOpen:n,draftTimerMode:i.timerMode,draftProjectMinutes:i.projectMinutes,openSettings:o,closeSettings:s,saveSettings:c,toggleDraftTimerMode:l,changeDraftMinutes:u}},bi=(e,t)=>{let n=e.indexOf(t);if(n<0)return e.length>0?e[0]:null;let r=n+1;return r<e.length?e[r]:null},xi=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},Si=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},Ci=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
|
|
13
|
+
`);c=u.pop()??``;for(let e of u){if(!e.startsWith(`data: `))continue;let i=St(e.slice(6));if(i!==null){if(i.type===`progress`)r({fetched:typeof i.fetched==`number`?i.fetched:0,total:typeof i.total==`number`?i.total:0});else if(i.type===`done`){let e=bt(i.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}let r=Qe(n,e);if(r.status===`error`){s(r.failures),t(`error`);return}let o=bt(r.snapshot);if(o===null){t(`error`),s([`Failed to merge snapshot`]);return}await it(o),rt(!0),a(o),t(`on`),s(o.failures)}}}}},[]),u=(0,y.useCallback)(()=>{c.current!==null&&c.current.abort();let e=new AbortController;c.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),fetch(xt,{signal:e.signal}).then(async e=>{if(!e.ok||e.body===null){t(`error`),s([`HTTP ${e.status}`]);return}await l(e.body,null)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]),d=(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),rt(!1),ot().catch(()=>{})},[]),f=(0,y.useCallback)((e,n)=>{if(n.length===0)return;c.current!==null&&c.current.abort();let i=new AbortController;c.current=i,t(`syncing`),r({fetched:0,total:n.length}),s([]),fetch(xt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targetUrls:n}),signal:i.signal}).then(async n=>{if(!n.ok||n.body===null){t(`error`),s([`HTTP ${n.status}`]);return}await l(n.body,e)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[l]);return{status:e,progress:n,snapshot:i,failures:o,startSync:u,turnOff:d,retryFailed:()=>f(i,o)}},wt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Tt=e=>typeof e==`string`?e:``,Et=e=>typeof e==`number`?e:0,Dt=e=>e===!0,Ot=`console-api-v1`,kt=async(e,t)=>{let n=`${e}?url=${encodeURIComponent(t)}`;try{let e=await fetch(n);if(!e.ok){let t=`HTTP ${e.status}`;try{let n=await e.json();wt(n)&&typeof n.error==`string`&&n.error.length>0&&(t=n.error)}catch(e){console.warn(`Failed to parse error body from non-ok response:`,e)}throw Error(t)}let t=await e.json();try{`caches`in globalThis&&globalThis.caches.open(Ot).then(e=>e.put(n,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist API response to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}return t}catch(e){try{if(`caches`in globalThis){let e=await(await globalThis.caches.open(Ot)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},At=e=>!wt(e)||!Array.isArray(e.comments)?[]:e.comments.filter(wt).map(e=>({author:Tt(e.author),body:Tt(e.body),createdAt:Tt(e.createdAt)})),jt=e=>!wt(e)||!Array.isArray(e.files)?[]:e.files.filter(wt).map(e=>({path:Tt(e.path)||Tt(e.filename),additions:Et(e.additions),deletions:Et(e.deletions),status:Tt(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Mt=e=>!wt(e)||!Array.isArray(e.commits)?[]:e.commits.filter(wt).map(e=>({sha:Tt(e.sha),message:Tt(e.message),author:Tt(e.author),authoredAt:Tt(e.authoredAt)})),Nt=e=>wt(e)?{title:Tt(e.title),body:Tt(e.body),additions:Et(e.additions),deletions:Et(e.deletions),changedFiles:Et(e.changedFiles)}:null,Pt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ft=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,It=e=>!wt(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(wt).map(e=>({url:Tt(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:Tt(e.createdAt),isDraft:Dt(e.isDraft),isConflicted:Dt(e.isConflicted),mergeableStatus:Ft(e.mergeableStatus),isPassedAllCiJob:Dt(e.isPassedAllCiJob),isCiStateSuccess:Dt(e.isCiStateSuccess),isResolvedAllReviewComments:Dt(e.isResolvedAllReviewComments),isBranchOutOfDate:Dt(e.isBranchOutOfDate),missingRequiredCheckNames:Pt(e.missingRequiredCheckNames),summary:Nt(e.summary)})),Lt=e=>{if(!wt(e)||!wt(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:Dt(t.isConflicted),mergeableStatus:Ft(t.mergeableStatus),isPassedAllCiJob:Dt(t.isPassedAllCiJob),isCiStateSuccess:Dt(t.isCiStateSuccess),isBranchOutOfDate:Dt(t.isBranchOutOfDate),missingRequiredCheckNames:Pt(t.missingRequiredCheckNames)}},Rt=e=>wt(e)?{state:Tt(e.state)||`open`,merged:Dt(e.merged),isPullRequest:Dt(e.isPullRequest),title:Tt(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},zt=()=>({fetchItemBody:async e=>{let t=await kt(`/api/itembody`,e);return wt(t)?Tt(t.body):``},fetchComments:async e=>At(await kt(`/api/comments`,e)),fetchPrFiles:async e=>jt(await kt(`/api/prfiles`,e)),fetchPrCommits:async e=>Mt(await kt(`/api/prcommits`,e)),fetchRelatedPrs:async e=>It(await kt(`/api/relatedprs`,e)),fetchIssueState:async e=>Rt(await kt(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Lt(await kt(`/api/pullrequeststatus`,e))}),Bt=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(wt(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Vt=async(e,t)=>{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(await Bt(n))},Ht=`/api/comment`,Ut=e=>({author:Tt(e.author),body:Tt(e.body),createdAt:Tt(e.createdAt)}),Wt=async e=>{let t=await fetch(Ht,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await Bt(t),rateLimitResetAt:null};let n=await t.json();return wt(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:wt(n.comment)?{posted:!0,comment:Ut(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},Gt=`/api/upload`,z=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Kt=async e=>{let t=await fetch(Gt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t));let n=await t.json();if(!wt(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},qt=`/api/addstory`,Jt=async e=>{let t=await fetch(qt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},Yt=`/api/reviewcomment`,Xt=async e=>{let t=await fetch(Yt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},Zt=`/api/createissue`,Qt=`/api/storycolor`,$t=async e=>{let t=await fetch(Qt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},en=async e=>{let t=await fetch(Zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t));let n=await t.json();if(!(e=>typeof e==`object`&&!!e&&!Array.isArray(e))(n)||typeof n.issueUrl!=`string`)throw Error(`issueUrl was not returned`);return n.issueUrl},tn=`/api/createworkflowissue`,nn=async e=>{let t=await fetch(tn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t));let n=await t.json();if(!(e=>typeof e==`object`&&!!e&&!Array.isArray(e))(n)||typeof n.issueUrl!=`string`)throw Error(`issueUrl was not returned`);return n.issueUrl},rn=`/api/reorderstory`,an=async e=>{let t=await fetch(rn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},on=`/api/deleteallcomments`,sn=async e=>{let t=await fetch(on,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},cn=`/api/deletestory`,ln=async e=>{let t=await fetch(cn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},un=`/api/renamestory`,dn=async e=>{let t=await fetch(un,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},fn=`/api/storydescription`,pn=async e=>{let t=await fetch(fn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},mn=e=>typeof e!=`object`||!e||Array.isArray(e)?null:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`)),hn=async()=>{let e=await fetch(`/api/projects`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();if(typeof t!=`object`||!t||Array.isArray(t))return{pjcodes:[],projectUrls:null,fleetTaskCreateUrl:null,nameWithOwnerByPjcode:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:mn(n.projectUrls),fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null,nameWithOwnerByPjcode:mn(n.nameWithOwnerByPjcode)}},gn=`/api/projectreadmeconfig`,_n=async e=>{let t=`${gn}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await Bt(n));let r=await n.json();return{maximumPreparingIssuesCount:wt(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},vn=`/api/renameissue`,yn=async e=>{let t=await fetch(vn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},bn=`/api/setdependedissueurl`,xn=async e=>{let t=await fetch(bn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},Sn=`/api/projectsettings`,Cn=async e=>{let t=await fetch(Sn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Bt(t))},wn=5e3,Tn=e=>`${e.isPr?`PR #`:`#`}${e.number}`,En=(e,t)=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`Approved & Merged`:e.action===`request_changes`?`Rejected`:e.action===`totally_wrong`?`Marked totally wrong`:`Marked unnecessary`;case`next_action_date`:return e.action===`snooze_1hour`?`Next Action Hour +1h`:e.action===`snooze_3hours`?`Next Action Hour +3h`:e.action===`snooze_6hours`?`Next Action Hour +6h`:e.action===`snooze_1day`?`Next Action Date +1d`:e.action===`snooze_2days`?`Next Action Date +2d`:e.action===`snooze_3days`?`Next Action Date +3d`:e.action===`snooze_5days`?`Next Action Date +5d`:e.action===`snooze_1month`?`Next Action Date +1mo`:we(t)?`Next Action Date +1w skip`:`Next Action Date +1w`;case`set_story`:return`Story → ${e.optionName}`;case`set_agent`:return`Agent → ${e.optionName}`;case`set_status`:return`Status → ${e.optionName}`;case`set_in_tmux_by_human`:return`Added to In Tmux by human`;case`ok_and_awaiting_workspace`:return`ok → Awaiting Workspace`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},Dn=e=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`green`:e.action===`request_changes`?`amber`:e.action===`totally_wrong`?`red`:`gray`;case`next_action_date`:return`amber`;case`set_story`:case`set_agent`:case`set_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},On=(e,t)=>e.type===`next_action_date`?we(t):e.type!==`delete_all_comments`,kn=(e,t,n)=>`${En(e,n)} — ${Tn(t)}`,An=`console-comment-expanded:`,jn=e=>{try{let t=localStorage.getItem(An+e);if(t===null)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch(e){return console.error(`Failed to load comment expanded state from storage:`,e),new Set}},Mn=(e,t)=>{try{localStorage.setItem(An+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Nn=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(An)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},Pn=`console-offline-action-queue`,Fn=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.message==`string`&&typeof t.color==`string`&&typeof t.enqueuedAt==`number`&&typeof t.itemUrl==`string`&&typeof t.projectItemId==`string`&&typeof t.itemNumber==`number`&&typeof t.repo==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},In=()=>{try{let e=localStorage.getItem(Pn);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(Fn):[]}catch{return[]}},Ln=e=>{localStorage.setItem(Pn,JSON.stringify(e))},Rn=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`,zn=e=>e instanceof TypeError,Bn=e=>e instanceof Error&&e.message.length>0?e.message:String(e),Vn=100,Hn=e=>Math.max(0,Math.ceil((wn-e)/1e3)),Un=e=>Math.max(0,1-e/wn),Wn=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(In),o=(0,y.useRef)(i);o.current=i;let s=(0,y.useRef)(null),c=(0,y.useRef)(0),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useRef)(()=>{}),f=(0,y.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),p=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:Rn(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return Ln(n),n})},[]),m=(0,y.useCallback)(e=>{e.commit().catch(t=>{zn(t)&&e.offline!==void 0?p(e):r({message:e.message,reason:Bn(t),retry:()=>d.current(e)})})},[p]);d.current=m;let h=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,Nn(),m(e))},[f,m]),g=(0,y.useCallback)(()=>{let e=s.current;f(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.(),e?.revertOptimistic?.()},[f]),_=(0,y.useCallback)(()=>{r(null)},[]),v=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),b=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return Ln(n),n})},[]),x=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Vt(t.apiPath,t.requestBody),b(e)}catch(n){zn(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:Bn(n)}),b(e))}},[b]),S=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;f(),u.current=!0,Nn(),m(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Hn(0),progress:Un(0)}),e.advance(),e.optimistic?.(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){h();return}t({message:e.message,color:e.color,remainingSeconds:Hn(n),progress:Un(n)})},Vn)},[f,h,m]);return(0,y.useEffect)(()=>h,[h]),{pending:e,error:n,offlineActions:i,enqueue:S,showError:v,undo:g,dismissError:_,confirmOfflineAction:x,discardOfflineAction:b}},Gn=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Kn=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],qn=e=>Array.isArray(e)?e.filter(Gn).map(e=>({...e,relatedOpenPullRequestUrls:Kn(e.relatedOpenPullRequestUrls)})):[],Jn=e=>!Gn(e)||!Array.isArray(e.items)?[]:qn(e.items),Yn=e=>Array.isArray(e)?e.filter(Gn):[],Xn=e=>Array.isArray(e)?e.filter(Gn).map(e=>({...e,items:qn(e.items)})):[],Zn=e=>({items:Jn(e),generatedAt:Gn(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Gn(e)?Yn(e.statusOptions):[],agentOptions:Gn(e)?Yn(e.agentOptions):[],storyOptions:Gn(e)?Yn(e.storyOptions):[],storyColors:Gn(e)&&Gn(e.storyColors)?e.storyColors:{},stories:Gn(e)?Xn(e.stories):[],defaultNameWithOwner:Gn(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Gn(e)?Kn(e.storyOrder):[],timerEndsAt:Gn(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Gn(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Qn=()=>{let e={};for(let t of j)e[t.name]=null;return e},$n=(e,t)=>`/projects/${e}/${t}/list.json`,er=6e4,tr=`console-list-v1`,nr=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(tr).then(n=>n.put(e,new Response(JSON.stringify(t),{headers:{"Content-Type":`application/json`}}))).catch(e=>{console.warn(`Failed to persist tab snapshot to cache:`,e)})}catch(e){console.warn(`Failed to access cache storage:`,e)}},rr=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(tr)).match(e);return t===void 0?null:{...Zn(await t.json()),fromCache:!0}}catch{return null}},ir=async e=>{let t=await Promise.all(j.map(async t=>({tabName:t.name,snapshot:await rr($n(e,t.name))}))),n=Qn();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},ar=async(e,t)=>{let n=$n(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return nr(n,t),{snapshot:{...Zn(t),fromCache:!1},error:null}}catch(e){let t=await rr(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},or=async e=>{await Promise.all(j.map(async t=>{let n=$n(e,t.name);try{let e=await fetch(n);if(!e.ok)return;nr(n,await e.json())}catch{}}))},sr=async e=>{let t=await Promise.all(j.map(async t=>{let{snapshot:n,error:r}=await ar(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Qn(),r=null;for(let{tabName:e,snapshot:i,error:a}of t)n[e]=i,a!==null&&r===null&&(r=a);return{snapshots:n,firstError:Object.values(n).every(e=>e===null)?r:null}},cr=(e,t=null)=>{let n=(0,y.useRef)(new Map),[r,i]=(0,y.useState)(Qn),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(e);if(l!==e){u(e);let t=e===null?null:n.current.get(e)??null;i(t??Qn()),t!==null&&o(!1)}return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Qn();for(let t of j){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}i(e),o(!1),c(null);return}}let r=!1,a=!1;if(c(null),e===null)return i(Qn()),o(!1),c(`No project specified in the URL path.`),()=>{r=!0};let s=n.current.has(e);ir(e).then(t=>{if(r)return;let c=Object.values(t).some(e=>e!==null);c&&!a?(n.current.set(e,t),i(t),o(!1)):!c&&!a&&!s&&(o(!0),i(Qn()))});let l=()=>{sr(e).then(({snapshots:t,firstError:s})=>{r||(a=!0,n.current.set(e,t),i(t),c(s===null?null:s.message),o(!1))}).catch(e=>{r||(a=!0,c(e instanceof Error?e.message:String(e)),o(!1))})};l();let u=setInterval(l,er);return()=>{r=!0,clearInterval(u)}},[e,t]),{snapshots:r,isLoading:a,error:s,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:r}=await ar(e,t);r!==null&&i(i=>{let a={...i,[t]:r};return n.current.set(e,a),a})},[e])}},lr=(e,t,n)=>{(0,y.useEffect)(()=>{if(!n)return;let r=t.filter(t=>t!==e);if(r.length===0)return;let i=()=>{for(let e of r)or(e).catch(()=>{})};i();let a=setInterval(i,er);return()=>{clearInterval(a)}},[n,e,t])},ur=class{fetcher;cache=new Map;inFlight=new Map;prefetchInFlight=new Set;constructor(e){this.fetcher=e}peek=e=>this.cache.get(e);has=e=>this.cache.has(e);load=(e,t)=>{let n=this.cache.get(e);if(n!==void 0)return Promise.resolve(n);let r=this.inFlight.get(e);if(r!==void 0)return r;let i=this.fetcher(t).then(t=>(this.cache.set(e,t),t)).finally(()=>{this.inFlight.delete(e)});return this.inFlight.set(e,i),i};prefetch=(e,t)=>{this.cache.has(e)||this.inFlight.has(e)||this.prefetchInFlight.has(e)||(this.prefetchInFlight.add(e),this.fetcher(t).then(t=>{this.cache.set(e,t)}).catch(()=>{}).finally(()=>{this.prefetchInFlight.delete(e)}))};seed(e,t){this.cache.set(e,t)}invalidate=e=>{this.cache.delete(e)}},dr=e=>{try{let t=new URL(e).pathname.split(`/`).filter(Boolean);if(t.length>=4)return`${t[0]}/${t[1]}#${t[3]}`}catch{}return e},fr=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=dr(n);e.body.seed(t,r.body),e.comments.seed(t,r.comments),e.state.seed(t,r.state),r.files!==null&&e.files.seed(t,r.files),r.commits!==null&&e.commits.seed(t,r.commits),r.prStatus!==null&&e.prStatus.seed(t,r.prStatus),r.relatedPrs!==null&&e.relatedPrs.seed(t,r.relatedPrs)}},pr=(e=null)=>(0,y.useMemo)(()=>{let t=zt(),n={client:t,body:new ur(t.fetchItemBody),comments:new ur(t.fetchComments),files:new ur(t.fetchPrFiles),commits:new ur(t.fetchPrCommits),relatedPrs:new ur(t.fetchRelatedPrs),state:new ur(t.fetchIssueState),prStatus:new ur(t.fetchPullRequestStatus)};return e!==null&&fr(n,e),n},[e]),mr=0,hr=500,gr=2e3,_r=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:gr});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},vr=(e,t)=>{let n=`${t.repo}#${t.number}`;e.body.prefetch(n,t.url),e.state.prefetch(n,t.url),e.comments.prefetch(n,t.url),t.isPr?(e.files.prefetch(n,t.url),e.commits.prefetch(n,t.url),e.prStatus.prefetch(n,t.url)):e.relatedPrs.prefetch(n,t.url)},yr=(e,t,n)=>{(0,y.useEffect)(()=>{if(t===null)return;let r=n.findIndex(e=>e.projectItemId===t.projectItemId);if(r===-1)return;let i=n.slice(r+1,r+1+mr);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=_r(()=>{for(let t of i)vr(e,t)})},hr);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},br=`/api/features`,xr=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(br).then(async e=>{if(!e.ok)return;let n=await e.json();typeof n==`object`&&n&&!Array.isArray(n)&&`airplaneMode`in n&&typeof n.airplaneMode==`boolean`&&t({airplaneMode:n.airplaneMode})}).catch(e=>{console.warn(`Failed to fetch /api/features`,e)})},[]),e},Sr=(e,t)=>{let n=j.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<j.length;e+=1){let n=j[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},Cr=e=>{let t=j.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},wr=new Set(j.map(e=>e.name)),Tr=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return wr.has(n)?n:null},Er=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Dr=`#settings`,Or=(e,t,n=new Set,r)=>{let i=(0,y.useCallback)(()=>{let e=Cr(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:Tr(window.location.pathname)??e,selectedItemKey:Er(window.location.hash)}},[t]),[a,o]=(0,y.useState)(i),s=(0,y.useRef)(null);s.current=e,(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{o(i())};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[i]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=Tr(window.location.pathname),i=Object.values(t).some(e=>e>0),a=r??t;if(e!==null){if(t[e]>0||a[e]>0){o(t=>t.activeTab===e?t:{...t,activeTab:e});return}if(!n.has(e))return}let c=Cr(t);i&&s.current!==null&&window.history.replaceState({},``,`/projects/${s.current}/${c}${window.location.search}`),o(e=>e.activeTab===c?e:{...e,activeTab:c})},[t,n,r]);let c=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),l=(0,y.useCallback)(e=>{if(typeof window>`u`){o({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,c(e)),o({activeTab:e,selectedItemKey:null})},[c]),u=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),o(t=>({...t,selectedItemKey:e}))},[]),d=(0,y.useCallback)(()=>{if(typeof window<`u`&&window.location.hash!==``){let e=`${window.location.pathname}${window.location.search}`;window.history.pushState({},``,e)}o(e=>({...e,selectedItemKey:null}))},[]);return{activeTab:a.activeTab,selectedItemKey:a.selectedItemKey,tabHref:c,selectTab:l,openItem:u,closeItem:d}},kr=`/api/review`,Ar=`/api/triage`,jr=`/api/intmux`,Mr=(e,t,n,r,i)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:be(i),...r===void 0?{}:{changedFilePath:r.path,line:r.line,side:r.side}}}return r===`totally_wrong`?{pjcode:e,action:`close`,prUrl:n,issueUrl:t.url,projectItemId:t.projectItemId,commentBody:_e}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:ve,issueCommentBody:ye(n)}},Nr=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),Pr=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),Fr=()=>Error(`No project specified in the URL path.`),Ir=`ok`,Lr=(e,t,n)=>{let r=(0,y.useCallback)(e=>{if(t===void 0)return;let n=`${e.repo}#${e.number}`;t.body.invalidate(n),t.comments.invalidate(n)},[t]),i=(0,y.useCallback)(async(t,n,i,a=[])=>{if(e===null)throw Fr();await Vt(kr,Mr(e,t,n,i,a)),r(t)},[e,r]),a=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId}),r(t)},[e,r]),o=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:`set_agent`,issueUrl:t.url,projectItemId:t.projectItemId,agentOptionId:n.id}),r(t)},[e,r]);return{reviewPullRequest:i,setNextActionDate:a,setStory:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:`set_story`,issueUrl:t.url,projectItemId:t.projectItemId,storyOptionId:n.id}),r(t)},[e,r]),setAgent:o,setStatus:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:`set_status`,issueUrl:t.url,projectItemId:t.projectItemId,statusName:n.name}),r(t)},[e,r]),setInTmuxByHuman:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(jr,{pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),r(t)},[e,r]),closeIssue:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await Vt(Ar,{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId}),r(t)},[e,r]),okAndMoveToAwaitingWorkspace:(0,y.useCallback)(async(t,i)=>{if(e===null)throw Fr();let a=await Wt({pjcode:e,url:t.url,body:Ir});if(await Vt(Ar,{pjcode:e,action:`set_status`,issueUrl:t.url,projectItemId:t.projectItemId,statusName:i.name}),r(t),await n?.(),!a.posted){let e=a.rateLimitResetAt===null?``:` Rate limit resets at ${a.rateLimitResetAt}.`;throw Error(`Comment not posted — ${a.error}.${e} Status was changed. Re-post: ${Ir}`)}},[e,r,n]),addComment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();let i=await Wt({pjcode:e,url:t.url,body:n});if(!i.posted){let e=i.rateLimitResetAt===null?``:` Rate limit resets at ${i.rateLimitResetAt}.`;throw Error(`${i.error}.${e}`)}return r(t),i.comment},[e,r]),uploadAttachment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=z(new Uint8Array(await n.arrayBuffer()));return Kt({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw Fr();await Xt({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),issueRename:(0,y.useCallback)(async(e,t)=>{await yn({issueUrl:e.url,newTitle:t})},[]),deleteAllComments:(0,y.useCallback)(async e=>{await sn({issueUrl:e.url}),r(e)},[r]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fr();await xn({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e])}},Rr=e=>`pv_overlay_${e}`,zr=e=>e.projectItemId===``?e.itemId:e.projectItemId,Br=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,Vr=(e,t,n)=>e.filter(e=>!Br(t[zr(e)],n)).length,Hr=(e,t,n)=>e.filter(e=>!Br(t[zr(e)],n)),Ur=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[zr(t)];return i===void 0||i.ts<r?null:i.status??null},Wr=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},Gr=(e,t)=>{let n={...e};return delete n[t],n},Kr=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,qr=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(Rr(e));if(t===null)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{};let r={};for(let[e,t]of Object.entries(n))Kr(t)&&(r[e]=t);return r},Jr=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(Rr(e),JSON.stringify(t))},Yr=e=>{let[t,n]=(0,y.useState)(()=>qr(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=Wr(n,t,r,i,Date.now());return Jr(e,a),a})},[e]),revertOverlayEntry:(0,y.useCallback)(t=>{n(n=>{let r=Gr(n,t);return Jr(e,r),r})},[e])}},Xr=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<2||t[0]!==`projects`)return null;let n=t[1];return n.length===0?null:n},Zr=()=>{let[e,t]=(0,y.useState)(()=>Xr(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(Xr(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},Qr=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return l(!0),d(null),hn().then(n=>{e||(t(n.pjcodes),r(n.projectUrls),a(n.fleetTaskCreateUrl),s(n.nameWithOwnerByPjcode),l(!1))}).catch(t=>{e||(d(t instanceof Error?t:Error(String(t))),l(!1))}),()=>{e=!0}},[]),{pjcodes:e,projectUrls:n,fleetTaskCreateUrl:i,nameWithOwnerByPjcode:o,isLoading:c,error:u}},$r=e=>(0,y.useCallback)(t=>{Nn(),e(t)},[e]),ei=()=>typeof window<`u`&&window.location.hash===`#settings`,ti=e=>{let[t,n]=(0,y.useState)(ei),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)({}),d=(0,y.useRef)(``),f=(0,y.useRef)(e);f.current=e,(0,y.useEffect)(()=>{if(!t)return;let e=!1;return u({}),i(!0),c(null),Promise.all(f.current.map(e=>_n(e).then(t=>({pjcode:e,value:t.maximumPreparingIssuesCount===null?``:String(t.maximumPreparingIssuesCount)})))).then(t=>{if(!e){let e={};for(let{pjcode:n,value:r}of t)e[n]=r;u(e)}}).catch(t=>{e||c(t instanceof Error?t.message:`Failed to load settings`)}).finally(()=>{e||i(!1)}),()=>{e=!0}},[t]),(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{let e=window.location.hash===Dr;e||c(null),n(e)};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[]);let p=(0,y.useCallback)(()=>{typeof window<`u`&&(d.current=window.location.hash,window.history.pushState({},``,Dr)),n(!0)},[]),m=(0,y.useCallback)(()=>{if(typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1),c(null)},[]),h=(0,y.useCallback)((e,t)=>{u(n=>({...n,[e]:t}))},[]),g=(0,y.useCallback)(async()=>{o(!0),c(null);try{if(await Promise.all(Object.entries(l).filter(([,e])=>{let t=parseInt(e,10);return!Number.isNaN(t)&&t>=0}).map(([e,t])=>Cn({pjcode:e,maximumPreparingIssuesCount:parseInt(t,10)}))),typeof window<`u`){let e=d.current,t=`${window.location.pathname}${window.location.search}${e}`;window.history.replaceState({},``,t)}n(!1)}catch(e){c(e instanceof Error?e.message:`Failed to save settings`)}finally{o(!1)}},[l]);return(0,y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&m()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,m]),{isOpen:t,isLoading:r,isSaving:a,error:s,inputValues:l,open:p,close:m,changeInput:h,save:g}},ni=e=>{let t=(0,y.useRef)(e),n=(0,y.useRef)(Date.now());return t.current!==e&&(t.current=e,n.current=Date.now()),{isTimerExpired:(0,y.useCallback)(e=>e<=0?!1:Date.now()-n.current>=e*60*1e3,[])}},ri=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,ii=/^From:\s+:robot:/m,ai=/^##\s/m,oi=e=>{let t=ri.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=ii.exec(n),i=ai.exec(n),a=n.length;r!==null&&(a=Math.min(a,r.index)),i!==null&&(a=Math.min(a,i.index));let o=n.slice(0,a).trim();return o.length>0?o:null},si=e=>{if(e.length===0)return null;let t=e[e.length-1],n=oi(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},ci=e=>`${e.repo}#${e.number}`,li=(e,t,n)=>{let[r,i]=(0,y.useState)({});return(0,y.useEffect)(()=>{if(!n)return;let r=!1;for(let n of e){let e=ci(n),a=t.peek(e);if(a!==void 0){let e=si(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e});continue}t.load(e,n.url).then(e=>{if(r)return;let t=si(e);i(e=>e[n.projectItemId]===t?e:{...e,[n.projectItemId]:t})}).catch(()=>{r||i(e=>e[n.projectItemId]===null?e:{...e,[n.projectItemId]:null})})}return()=>{r=!0}},[e,t,n]),r},ui=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},di=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},fi=e=>{let t=e instanceof Element?e:null;for(;t!==null&&t!==document.body;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth&&t.scrollLeft>0)return!0;t=t.parentElement}return!1},pi=e=>{let t=(0,y.useRef)(e);t.current=e;let n=(0,y.useRef)(null),r=(0,y.useCallback)(e=>{let n=0,r=0,i=!1,a=e=>{if(e.touches.length!==1){i=!1;return}if(fi(e.target)){i=!1;return}let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},o=e=>{if(!i)return;let t=e.touches[0];di(t.clientX-n,t.clientY-r)&&(i=!1)},s=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let a=e.changedTouches[0],o=ui(a.clientX-n,a.clientY-r);o!==null&&t.current(o)};return e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),()=>{e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s)}},[]),i=(0,y.useCallback)(e=>{n.current!==null&&(n.current(),n.current=null),e!==null&&(n.current=r(e))},[r]);return(0,y.useEffect)(()=>()=>{n.current!==null&&(n.current(),n.current=null)},[]),i},mi=e=>(0,y.useCallback)(t=>{Nn(),e(t)},[e]),hi=(e,t,n,r,i)=>{let a=(0,y.useRef)(void 0),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(!e){a.current=t,o.current=!1;return}a.current!==t&&(a.current=t,o.current=t!==null),o.current&&r===null&&n.length!==0&&(o.current=!1,i(n[0].projectItemId))},[e,t,n,r,i])},gi=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},_i=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},vi=(e,t,n,r,i,a,o,s,c,l)=>{let u=(0,y.useRef)(0),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e||r===null){u.current=0,d.current=null;return}if(!o||!s||c||l||d.current===r)return;if(t>0||n>0){u.current=0,d.current=null;return}if(i.length===0)return;let f=i.filter(e=>(a[e]??15)>0);if(u.current>=f.length-1){d.current=r,u.current=0;return}d.current=r,u.current+=1;let p=ce(i,r,a);p===null?u.current=0:gi(`/projects/${p}/todo-by-human`)},[e,t,n,r,i,a,o,s,c,l])},yi=()=>{let[e,t]=(0,y.useState)(N),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(e),o=(0,y.useCallback)(()=>{t(e=>(a(e),e)),r(!0)},[]),s=(0,y.useCallback)(()=>{r(!1)},[]),c=(0,y.useCallback)(()=>{a(e=>(se(e),t(e),e)),r(!1)},[]),l=(0,y.useCallback)(e=>{a(t=>({...t,timerMode:e}))},[]),u=(0,y.useCallback)((e,t)=>{a(n=>({...n,projectMinutes:{...n.projectMinutes,[e]:t}}))},[]);return{timerMode:e.timerMode,projectMinutes:e.projectMinutes,isOpen:n,draftTimerMode:i.timerMode,draftProjectMinutes:i.projectMinutes,openSettings:o,closeSettings:s,saveSettings:c,toggleDraftTimerMode:l,changeDraftMinutes:u}},bi=(e,t)=>{let n=e.indexOf(t);if(n<0)return e.length>0?e[0]:null;let r=n+1;return r<e.length?e[r]:null},xi=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},Si=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},Ci=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
|
|
14
14
|
`)?`${e}${t}\n`:`${e}\n${t}\n`,wi=(e,t)=>{let n=`![uploading ${t}]()`;return`${e.length===0?``:e.replace(/\n*$/,`
|
|
15
15
|
`)}\n\n\n${n}\n`},Ti=(e,t,n)=>{let r=`![uploading ${t}]()`,i=e.indexOf(r);return i===-1?Ci(e,n):e.slice(0,i)+n+e.slice(i+r.length)},Ei=(e,t)=>{let n=`![uploading ${t}]()`,r=e.indexOf(n);if(r===-1)return e;let i=r,a=0;for(;a<3&&i>0&&e[i-1]===`
|
|
16
16
|
`;)i--,a++;let o=+(e[r+n.length]===`
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
7
7
|
<title>TDPM Console</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-B-DtPr8b.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-DPKo0NnF.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|