github-issue-tower-defence-management 2.201.4 → 2.201.5

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.
@@ -13,7 +13,7 @@ Error generating stack: `+e.message+`
13
13
 
14
14
  `),Ee=`In Tmux by human`,De=`Awaiting Workspace`,Oe=[`In Tmux by human`,`Todo by human`,De],ke=e=>e===`todo-by-human`,Ae=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===De.toLowerCase());if(n===void 0)return null;let r=I(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`})})},je={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`]}},Me=({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`,Ne=({size:e=12,...t})=>{let n=Me(t),r=je[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))})},Pe=({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)(Ne,{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:ie(e.createdAt),children:ne(e.createdAt,n)})]}),e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-item-status-badge`,style:ge(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]})})]})}),Fe=({story:e,count:t,colorEnum:n})=>{let r=I(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})]})},Ie=({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)(Fe,{story:e.story,count:e.count,colorEnum:ve(t,e.storyOptionId??e.story)})},`group:${e.groupKey}`);let a=c?.[e.item.projectItemId]??null;return(0,x.jsxs)(`li`,{className:`console-list-row`,children:[(0,x.jsx)(Pe,{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)(Ae,{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]}),Le=({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))]})})},Re=e=>({...ge(e),fontSize:`12px`,whiteSpace:`nowrap`,flexShrink:0}),ze=({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)(Ne,{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:Re(a?.color??null),children:e.status}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:Re(o?.color??null),children:e.agent})]}),(0,x.jsx)(`span`,{className:`console-queued-item-actions`})]})},Be=({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)(Fe,{story:e.story,count:e.count,colorEnum:ve(t,e.storyOptionId??e.story)})},`group:${e.groupKey}`):(0,x.jsx)(`li`,{className:`console-list-row`,children:(0,x.jsx)(ze,{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]}),Ve=e=>e.isClosed===!0||e.status===`Done`,He=`console-story-selected-statuses`,Ue=`console-story-selected-statuses-format`,We=`2`,Ge=()=>{if(typeof localStorage>`u`)return null;let e=localStorage.getItem(He);if(e===null)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):null}catch{return null}},Ke=`Done`,qe=e=>e.filter(e=>e!==Ke),Je=(e,t)=>e??qe(t),Ye=e=>e===null?!1:e.length===0||e.includes(Ke),Xe=e=>{typeof localStorage<`u`&&(localStorage.setItem(He,JSON.stringify(e)),localStorage.setItem(Ue,We))},Ze=()=>typeof localStorage<`u`&&localStorage.getItem(`console-story-selected-statuses-format`)===We,Qe=()=>typeof localStorage<`u`&&!Ze()&&localStorage.getItem(`console-story-selected-statuses`)!==null,$e=()=>{typeof localStorage>`u`||Ze()||(localStorage.getItem(`console-story-selected-statuses`)===`[]`&&localStorage.removeItem(He),localStorage.setItem(Ue,We))},et=(e,t)=>{if(e===null)return[];let n=e.filter(e=>t.includes(e));return Array.from(new Set(n))},tt=(e,t)=>e===null||e.length===0||t.length===0?e:et(e,t).length===0?null:e,nt=(e,t)=>t.length===0?e:e.flatMap(e=>{let n=(e.items??[]).filter(e=>{let n=Ve(e)?`Done`:e.status;return n!==null&&t.includes(n)});return n.length>0?[{...e,items:n}]:[]}),rt=`status`,it=e=>{let t=new URLSearchParams(e);t.delete(rt);let n=t.toString();return n.length>0?`?${n}`:``},at=e=>{let t=new URLSearchParams(e);if(!t.has(rt))return null;let n=t.getAll(rt);return Array.from(new Set(n.filter(e=>e.length>0)))},ot=(e,t)=>{let n=new URLSearchParams(e);n.delete(rt),t.length===0&&n.append(rt,``);for(let e of Array.from(new Set(t)))n.append(rt,e);let r=n.toString();return r.length>0?`?${r}`:``},st=e=>e.dependedIssueUrls.length>0||e.nextActionDate!==null||e.nextActionHour!==null,ct=(e,t,n,r,i)=>r?n.length:i?t.filter(e=>!Ve(e)&&!st(e)).length:e.openItemCount,lt=({stories:e,effectiveStatusSelection:t,showDone:n,hideTriggered:r,hideEmptyStories:i})=>{let a=t.length>0;return nt(e,t).flatMap(e=>{let t=e.items??[],o=a?t:t.filter(e=>n||!Ve(e)),s=r?o.filter(e=>!st(e)):o,c=ct(e,t,s,a,r);return i&&c===0?[]:[{entry:e,visibleItems:s,badgeCount:c}]})},ut=(e,t,n)=>e.map(e=>{let r=e.items??[];return r.some(e=>e.projectItemId===t)?{...e,items:r.map(e=>e.projectItemId===t?{...e,...n}:e)}:e}),dt=e=>e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),ft=({className:e,ariaLabel:t,placeholder:n,currentOption:r,options:i,onSelect:a,disabled:o=!1})=>{let s=(0,y.useRef)({ready:!1,currentOptionId:r?.id??null});return(0,y.useLayoutEffect)(()=>{s.current.ready=!0,s.current.currentOptionId=r?.id??null}),(0,x.jsxs)(`select`,{className:e,defaultValue:r?.id??``,disabled:o,onChange:e=>{if(!s.current.ready||e.target.value===(s.current.currentOptionId??``))return;let t=i.find(t=>t.id===e.target.value);t!==void 0&&a(t)},"aria-label":t,children:[(0,x.jsx)(`option`,{value:``,children:n}),i.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})},pt=({agentOptions:e,currentAgentName:t,currentAgentOptionId:n,onSetAgent:r,disabled:i=!1})=>{if(e.length===0)return null;let a=n==null?t===null?null:e.find(e=>e.name===t)??null:e.find(e=>e.id===n)??null;return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(ft,{className:`console-agent-select`,ariaLabel:`Set agent`,placeholder:`— agent —`,currentOption:a,options:e,onSelect:r,disabled:i},a?.id??`none`)})},mt=({storyOptions:e,currentStoryName:t,currentStoryOptionId:n,onSetStory:r,disabled:i=!1})=>{if(e.length===0)return null;let a=n===null?t===null?null:e.find(e=>e.name===t)??null:e.find(e=>e.id===n)??null;return(0,x.jsx)(`div`,{className:`console-op-group`,children:(0,x.jsx)(ft,{className:`console-story-select`,ariaLabel:`Set story`,placeholder:`— story —`,currentOption:a,options:e,onSelect:r,disabled:i},a?.id??`none`)})},ht=Object.keys(F),gt=({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:ht.map(e=>{let t=F[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`})})]})]})},_t=({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`);else{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`})]})]})]})]})},vt=({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(),disabled:t,children:t?`Deleting…`:`Keep child tasks`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:i,disabled:t,children:`Cancel`})]})]})]})),yt=({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`})]})]})]})]})},bt=({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`);else{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`})]})]})]})]})},xt=[`story`,`status`,`dependedIssueUrl`,`nextActionDate`,`nextActionHour`,`agent`],St=[`story`,`status`],Ct=`shownStoryField`,wt=`hiddenStoryField`,Tt=(e,t)=>e.length===t.length&&e.every(e=>t.includes(e)),Et=e=>{let t=new URLSearchParams(e);if(!t.has(Ct))return[...St];let n=t.getAll(Ct);return xt.filter(e=>n.includes(e))},Dt=(e,t)=>{let n=new URLSearchParams(e);if(n.delete(Ct),n.delete(wt),!Tt(t,St)){t.length===0&&n.append(Ct,``);for(let e of xt)t.includes(e)&&n.append(Ct,e)}let r=n.toString();return r.length>0?`?${r}`:``},Ot=e=>xt.filter(t=>!e.includes(t)),kt=(e,t)=>e.includes(t)?e.filter(e=>e!==t):[...e,t],At={dependedIssueUrl:`Depended Issue URL`,nextActionDate:`Next Action Date`,nextActionHour:`Next Action Hour`,agent:`Agent`,story:`Story`,status:`Status`},jt=({hiddenFields:e,onToggle:t})=>(0,x.jsxs)(`fieldset`,{className:`console-story-row-field-toggles`,style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:12,border:`none`,margin:0,padding:0},children:[(0,x.jsx)(`legend`,{children:`Display items`}),xt.map(n=>(0,x.jsxs)(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:!e.includes(n),onChange:()=>t(n)}),At[n]]},n))]}),Mt=({statusNames:e,selectedStatuses:t,onToggleStatus:n,onClearStatuses:r})=>(0,x.jsxs)(`fieldset`,{className:`console-story-status-filter`,style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:12,border:`none`,margin:0,padding:0},children:[(0,x.jsx)(`legend`,{children:`Status`}),e.map(e=>(0,x.jsxs)(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:()=>n(e)}),e]},e)),(0,x.jsx)(`button`,{type:`button`,onClick:r,disabled:t.length===0,children:`Clear`})]}),Nt=({storyName:e,onSubmit:t,onClose:n,onEdit:r})=>{let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(!1),f=(0,y.useRef)(null);(0,y.useEffect)(()=>{f.current?.focus()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]);let p=async()=>{let r=i.trim();if(r.length===0)l(`Title is required`);else{s(!0),l(null);try{await t(e,r),n()}catch(e){l(e instanceof Error?e.message:String(e)),d(!0)}finally{s(!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(),p()},children:[(0,x.jsx)(`input`,{ref:f,type:`text`,className:`console-modal-input`,placeholder:`Issue title`,value:i,onChange:e=>a(e.target.value),disabled:o}),c!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:c}),(0,x.jsxs)(`div`,{className:`console-modal-actions`,children:[(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:o,children:o?`Creating…`:`Create`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:n,disabled:o,children:`Cancel`}),u&&r!==void 0&&(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>{r(e,i),n()},disabled:o,children:`Edit`})]})]})]})]})},Pt=Array.from({length:24},(e,t)=>t),Ft=(e,t)=>!e.includes(t),It=e=>e===null?``:e.slice(0,10),Lt=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!Number.isNaN(Date.parse(e)),Rt=e=>e instanceof Error?e.message:String(e),zt=({label:e,checked:t,onChange:n})=>(0,x.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,x.jsx)(`span`,{style:{fontSize:`0.875rem`,color:`#c9d1d9`},children:e}),(0,x.jsx)(S,{checked:t,ariaLabel:e,onChange:()=>n()})]}),Bt=({item:e,storyOptions:t,currentStoryOptionId:n,agentOptions:r,statusOptions:i,hiddenRowFields:a,onOpenItem:o,actions:s})=>{let[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(0),m=e=>{l(!0),d(null),e().then(()=>l(!1),e=>{l(!1),d(Rt(e)),p(e=>e+1)})},h=e.dependedIssueUrls.join(`, `),g=i.find(t=>t.name===e.status)??null,_=t=>{let n=dt(t);n.join(`, `)!==h&&m(()=>s.onSetDependedIssueUrl(e,n.join(`, `)))},v=It(e.nextActionDate),b=Ft(a,`dependedIssueUrl`),S=Ft(a,`nextActionDate`),C=Ft(a,`nextActionHour`),w=t=>{let n=t.value;n!==v&&(Lt(n)?m(()=>s.onSetNextActionDate(e,n)):t.value=v)};return(0,x.jsxs)(`li`,{className:`console-story-task-row`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-story-task-title`,onClick:()=>o(e),children:e.title}),(0,x.jsxs)(`div`,{className:`console-story-task-ops`,children:[(b||S||C)&&(0,x.jsxs)(`div`,{className:`console-op-group console-story-task-trigger`,children:[b&&(0,x.jsx)(`input`,{type:`text`,className:`console-story-task-depended-input`,"aria-label":`Set depended issue URL`,placeholder:`Depended issue URL`,defaultValue:h,disabled:c,onBlur:e=>_(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}},`depended-${h}-${f}`),S&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`input`,{type:`date`,className:`console-story-task-date-input`,"aria-label":`Set next action date`,defaultValue:v,disabled:c,onBlur:e=>w(e.currentTarget),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}},`date-${v}-${f}`),e.nextActionDate!==null&&(0,x.jsx)(`button`,{type:`button`,className:`console-story-task-date-clear`,"aria-label":`Clear next action date`,disabled:c,onClick:()=>m(()=>s.onSetNextActionDate(e,``)),children:`Clear`})]}),C&&(0,x.jsxs)(`select`,{className:`console-story-task-hour-select`,"aria-label":`Set next action hour`,value:e.nextActionHour===null?``:String(e.nextActionHour),disabled:c,onChange:t=>{let n=t.target.value;n!==(e.nextActionHour===null?``:String(e.nextActionHour))&&m(()=>s.onSetNextActionHour(e,n===``?null:Number(n)))},children:[(0,x.jsx)(`option`,{value:``,children:`— hour —`}),Pt.map(e=>(0,x.jsxs)(`option`,{value:String(e),children:[String(e).padStart(2,`0`),`:00`]},e))]})]}),Ft(a,`agent`)&&(0,x.jsx)(`div`,{className:`console-story-task-field`,children:(0,x.jsx)(pt,{agentOptions:r,currentAgentName:e.agent,currentAgentOptionId:e.agentOptionId??null,onSetAgent:t=>m(()=>s.onSetAgent(e,t)),disabled:c})},`agent-${f}`),Ft(a,`story`)&&(0,x.jsx)(mt,{storyOptions:t,currentStoryName:null,currentStoryOptionId:n,onSetStory:t=>m(()=>s.onSetStory(e,t)),disabled:c},`story-${f}`),Ft(a,`status`)&&(0,x.jsx)(`div`,{className:`console-op-group console-story-task-field`,children:(0,x.jsx)(ft,{className:`console-story-task-status-select`,ariaLabel:`Set status`,placeholder:`— status —`,currentOption:g,options:i,onSelect:t=>m(()=>s.onSetStatus(e,t)),disabled:c})},`status-${f}`)]}),u!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error console-story-task-error`,children:u})]})},Vt=({items:e,storyOptions:t,currentStoryOptionId:n,agentOptions:r,statusOptions:i,hiddenRowFields:a,onOpenItem:o,actions:s})=>(0,x.jsx)(`ul`,{className:`console-story-task-list`,children:e.map(e=>(0,x.jsx)(Bt,{item:e,storyOptions:t,currentStoryOptionId:n,agentOptions:r,statusOptions:i,hiddenRowFields:a,onOpenItem:o,actions:s},e.url))}),Ht=({stories:e,isLoading:t,error:n,showArchived:r,showDone:i,onCreateIssue:a,onAddStory:o,onSelectColor:s,onToggleArchived:c,hideTriggered:l,hideEmptyStories:u,onToggleHideTriggered:d,onToggleHideEmptyStories:f,onReorderStory:p,onDeleteStory:m,onRenameStory:h,onUpdateDescription:g,onStoryTaskCreateEdit:_,optimisticColors:v,colorChangeInFlight:b,colorErrors:S,onOpenItem:C,selectedStatuses:w=[],statusOptionNames:T=[],isStatusSelectionDefault:ee=!1,onToggleStatus:E,onClearStatuses:D,agentOptions:O,statusFieldOptions:te,hiddenRowFields:k,onToggleRowField:ne,taskActions:re})=>{let[ie,A]=(0,y.useState)(null),[j,ae]=(0,y.useState)(!1),[oe,se]=(0,y.useState)(null),[ce,le]=(0,y.useState)(null),[M,ue]=(0,y.useState)(null),[N,P]=(0,y.useState)({}),[de,fe]=(0,y.useState)(null),[pe,me]=(0,y.useState)(null),[he,F]=(0,y.useState)({}),[ge,L]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(ge===null)return;let e=e=>{let t=e.target;!t.closest(`.console-story-overflow-menu`)&&!t.closest(`.console-story-overflow-btn`)&&L(null)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[ge]);let _e=e=>he[e]??{inProgress:!1,error:null},ve=async(e,t)=>{F(t=>({...t,[e]:{inProgress:!0,error:null}}));try{await p(e,t),F(t=>({...t,[e]:{inProgress:!1,error:null}}))}catch(t){F(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 ye=async(e,t)=>{P(t=>({...t,[e]:{isDeleting:!0,error:null}}));try{await m(e,t),ue(null),P(t=>({...t,[e]:{isDeleting:!1,error:null}}))}catch(t){P(n=>({...n,[e]:{isDeleting:!1,error:t instanceof Error?t.message:String(t)}}))}},be=ee?[]:et(w,T),R=be.length>0,z=R?`Clear the status filter to reorder stories`:void 0,xe=e.filter(e=>r||e.color!==`GRAY`),Se=lt({stories:xe,effectiveStatusSelection:be,showDone:i,hideTriggered:l,hideEmptyStories:u}),Ce=ie===null?null:e.find(e=>e.storyOptionId===ie)??null,we=oe===null?null:e.find(e=>e.storyOptionId===oe)??null,Te=M===null?null:e.find(e=>e.storyOptionId===M)??null,Ee=M===null?{isDeleting:!1,error:null}:N[M]??{isDeleting:!1,error:null},De=de===null?null:e.find(e=>e.storyOptionId===de)??null,Oe=pe===null?null:e.find(e=>e.storyOptionId===pe)??null,ke=xe.map(e=>({id:e.storyOptionId,name:e.storyName,color:e.color}));return(0,x.jsxs)(`div`,{className:`console-story-list-container`,children:[(0,x.jsxs)(`div`,{className:`console-story-filter-bar`,children:[T.length>0&&E!==void 0&&D!==void 0&&(0,x.jsx)(Mt,{statusNames:T,selectedStatuses:w,onToggleStatus:E,onClearStatuses:D}),(0,x.jsx)(jt,{hiddenFields:k,onToggle:ne})]}),(0,x.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,alignItems:`center`,flexWrap:`wrap`,gap:16,rowGap:8},children:[(0,x.jsx)(zt,{label:`Archived`,checked:r,onChange:c}),(0,x.jsx)(zt,{label:`Hide triggered`,checked:l,onChange:d}),(0,x.jsx)(zt,{label:`Hide empty`,checked:u,onChange:f})]}),Se.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No active stories`}):(0,x.jsx)(`ul`,{className:`console-story-list`,children:Se.map(({entry:e,visibleItems:t,badgeCount:n},r)=>{let i=I(v[e.storyOptionId]??e.color),a=b===e.storyOptionId,o=S[e.storyOptionId]??null,{inProgress:s,error:c}=_e(e.storyOptionId),l=r===0,u=r===Se.length-1,d=ce===e.storyOptionId,f=ge===e.storyOptionId,p=e.description??``;return(0,x.jsxs)(`li`,{className:`console-story-list-row`,children:[(0,x.jsxs)(`div`,{className:`console-story-list-row-main`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-story-name-toggle`,style:{cursor:`pointer`},onClick:()=>le(d?null:e.storyOptionId),children:(0,x.jsxs)(`span`,{className:`console-storytag`,style:{color:i.fg,borderColor:i.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:i.dot}}),e.storyName]})}),(0,x.jsx)(`span`,{className:`console-story-count`,children:n}),(0,x.jsx)(`button`,{type:`button`,className:`console-story-chevron`,"aria-label":d?`Hide tasks`:`Show tasks`,onClick:()=>le(d?null:e.storyOptionId),children:d?`▼`:`▶`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>A(ie===e.storyOptionId?null:e.storyOptionId),children:`+ Add task`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move up`,disabled:l||s||R,title:z,onClick:()=>void ve(e.storyOptionId,`up`),children:`↑`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move down`,disabled:u||s||R,title:z,onClick:()=>void ve(e.storyOptionId,`down`),children:`↓`}),(0,x.jsxs)(`div`,{className:`console-story-overflow-container`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-story-overflow-btn`,"aria-label":`More options`,"aria-haspopup":`menu`,"aria-expanded":f,onClick:()=>L(f?null:e.storyOptionId),children:`⋯`}),f&&(0,x.jsxs)(`div`,{role:`menu`,className:`console-story-overflow-menu`,children:[(0,x.jsx)(`button`,{type:`button`,role:`menuitem`,className:`console-story-overflow-option`,disabled:a,onClick:()=>{L(null),se(e.storyOptionId)},children:`Change color`}),(0,x.jsx)(`button`,{type:`button`,role:`menuitem`,className:`console-story-overflow-option`,onClick:()=>{L(null),fe(e.storyOptionId)},children:`Rename`}),(0,x.jsx)(`button`,{type:`button`,role:`menuitem`,className:`console-story-overflow-option`,onClick:()=>{L(null),me(e.storyOptionId)},children:`Edit description`}),(0,x.jsx)(`hr`,{className:`console-story-overflow-separator`}),(0,x.jsx)(`button`,{type:`button`,role:`menuitem`,className:`console-story-overflow-option console-story-overflow-option--danger`,onClick:()=>{L(null),ue(e.storyOptionId)},children:`Delete story`})]})]})]}),p!==``&&(0,x.jsx)(`p`,{className:`console-story-description`,children:p}),d&&(0,x.jsx)(Vt,{items:t,storyOptions:ke,currentStoryOptionId:e.storyOptionId,agentOptions:O,statusOptions:te,hiddenRowFields:k,onOpenItem:C,actions:re}),c!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:c}),o!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:o})]},e.storyOptionId)})}),(0,x.jsx)(`div`,{className:`console-add-story-section`,children:(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>ae(!j),children:`Add story`})}),Ce!==null&&(0,x.jsx)(Nt,{storyName:Ce.storyName,onSubmit:(e,t)=>a(e,t),onClose:()=>A(null),onEdit:_===void 0?void 0:(e,t)=>{A(null),_(e,t)}}),j&&(0,x.jsx)(_t,{onSubmit:e=>o(e),onClose:()=>ae(!1)}),we!==null&&(0,x.jsx)(gt,{storyName:we.storyName,storyOptionId:we.storyOptionId,onSelectColor:(e,t)=>{se(null),s(e,t)},onClose:()=>se(null),disabled:b===we.storyOptionId}),Te!==null&&(0,x.jsx)(vt,{storyName:Te.storyName,isDeleting:Ee.isDeleting,deleteError:Ee.error,onConfirm:()=>void ye(Te.storyOptionId,!1),onCancel:()=>{ue(null),P({})}}),De!==null&&(0,x.jsx)(bt,{currentName:De.storyName,onSubmit:e=>h(De.storyOptionId,e),onClose:()=>fe(null)}),Oe!==null&&(0,x.jsx)(yt,{currentDescription:Oe.description??``,onSubmit:e=>g(Oe.storyOptionId,e),onClose:()=>me(null)})]})},Ut=5e3,Wt=(e,t,n)=>n?`PR ${e}#${t}`:`${e}#${t}`,B=e=>Wt(e.nameWithOwner,e.number,e.isPr),Gt=(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`:ke(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`ok_and_close`:return`ok → Closed`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},Kt=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`ok_and_close`:case`close`:return`red`;case`delete_all_comments`:return`red`}},qt=(e,t)=>e.type===`next_action_date`?ke(t):e.type!==`delete_all_comments`,Jt=(e,t,n)=>`${Gt(e,n)} — ${B(t)}`,Yt=(e,t)=>{let n=[...e].sort((e,t)=>e.createdAt-t.createdAt);if(n.length<=t)return{visibleEntries:n,collapsedEntries:[],collapsedCount:0};let r=n.length-t;return{visibleEntries:n.slice(r),collapsedEntries:n.slice(0,r),collapsedCount:r}},Xt=({message:e,color:t,remainingSeconds:n,progress:r,onUndo:i,onDismiss:a})=>(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`]}),a!==void 0&&(0,x.jsx)(`button`,{type:`button`,className:`console-undo-toast-dismiss`,onClick:a,children:`✕`}),(0,x.jsx)(`span`,{className:`console-undo-toast-bar`,"aria-hidden":`true`,style:{width:`${Math.max(0,Math.min(100,r*100))}%`}})]}),Zt=({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`})]})]}),Qt=e=>Math.max(0,Math.ceil((Ut-e)/1e3)),$t=e=>Math.max(0,1-e/Ut),en=12,tn=8,nn=`console-action-toast-stack-toggle`,rn=({pendingEntries:e,errorEntries:t,displayLimit:n,onUndo:r,onDismiss:i,onDismissError:a})=>{let[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(()=>Date.now()),u=e.length>0;(0,y.useEffect)(()=>{if(!u)return;let e=setInterval(()=>l(Date.now()),100);return()=>clearInterval(e)},[u]);let d=[...e.map(e=>({kind:`pending`,id:e.id,createdAt:e.createdAt,entry:e})),...t.map(e=>({kind:`error`,id:e.id,createdAt:e.createdAt,entry:e}))],{visibleEntries:f,collapsedEntries:p,collapsedCount:m}=Yt(d,n),h=[...[...f].reverse().map(e=>e.id),...o?[...p].reverse().map(e=>e.id):[],...m>0?[nn]:[]],g=(0,y.useRef)(null),_=(0,y.useRef)(new Map);if((0,y.useLayoutEffect)(()=>{let e=en;for(let t of h){let n=t===nn?g.current:_.current.get(t)?.firstElementChild??null;n instanceof HTMLElement&&(n.style.bottom=`${e}px`,e+=n.getBoundingClientRect().height+tn)}}),d.length===0)return null;let v=e=>e.kind===`pending`?(0,x.jsx)(Xt,{message:e.entry.message,color:e.entry.color,remainingSeconds:Qt(c-e.entry.createdAt),progress:$t(c-e.entry.createdAt),onUndo:()=>r(e.id),onDismiss:()=>i(e.id)},e.id):(0,x.jsx)(Zt,{title:e.entry.message,message:`Operation failed: ${e.entry.reason}`,onDismiss:()=>a(e.id),onRetry:e.entry.retry===void 0?void 0:()=>{a(e.id),e.entry.retry?.()}},e.id),b=e=>(0,x.jsx)(`div`,{className:`console-action-toast-stack-entry`,ref:t=>{t?_.current.set(e.id,t):_.current.delete(e.id)},children:v(e)},e.id);return(0,x.jsxs)(`div`,{className:`console-action-toast-stack`,children:[m>0&&(0,x.jsx)(`button`,{type:`button`,ref:g,className:`console-action-toast-stack-toggle`,onClick:()=>s(e=>!e),children:o?`Show less`:`+${m} more`}),o&&p.map(b),f.map(b)]})},an=e=>Wt(e.nameWithOwner,e.itemNumber,e.isPr),on=e=>e===null?`loading…`:e,sn=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(` · `)},cn=e=>e.fetchError?`${an(e)} — failed to load current state`:e.currentTitle===null?`${an(e)} — loading current state…`:`${an(e)} — ${e.currentTitle} (${on(e.currentState)})`,ln=({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:cn(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:sn(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))]}),un=(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}},dn=`tdpm-airplane-v1`,fn=`/airplane-snapshot-data`,pn=`tdpm_airplane_mode_on`,mn=()=>typeof localStorage>`u`?!1:localStorage.getItem(pn)===`1`,hn=e=>{typeof localStorage<`u`&&(e?localStorage.setItem(pn,`1`):localStorage.removeItem(pn))},gn=async e=>{if(typeof caches>`u`)throw Error(`Cache API unavailable`);try{await(await caches.open(dn)).put(fn,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}},_n=async()=>{if(typeof caches>`u`)return null;let e=await(await caches.open(dn)).match(fn);return e===void 0?null:e.json()},vn=async()=>{typeof caches<`u`&&await caches.delete(dn)},V=e=>typeof e==`object`&&!!e&&!Array.isArray(e),H=e=>typeof e==`string`?e:``,yn=e=>typeof e==`number`?e:0,bn=e=>e===!0,xn=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Sn=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,Cn=e=>V(e)?{number:yn(e.number),title:H(e.title),url:H(e.url),repo:H(e.repo),nameWithOwner:H(e.nameWithOwner),projectItemId:H(e.projectItemId),itemId:H(e.itemId),isPr:bn(e.isPr),story:H(e.story),storyOptionId:typeof e.storyOptionId==`string`?e.storyOptionId:null,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:xn(e.dependedIssueUrls),labels:xn(e.labels),createdAt:H(e.createdAt),relatedOpenPullRequestUrls:xn(e.relatedOpenPullRequestUrls),agent:typeof e.agent==`string`?e.agent:null}:null,wn=e=>{if(!V(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(Cn).filter(e=>e!==null):[],n=Array.isArray(e.statusOptions)?e.statusOptions.filter(V):[],r=Array.isArray(e.agentOptions)?e.agentOptions.filter(V):[],i=Array.isArray(e.storyOptions)?e.storyOptions.filter(V):[],a=Array.isArray(e.stories)?e.stories.filter(V):[],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:V(e.storyColors)?e.storyColors:{},stories:a,defaultNameWithOwner:typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,fromCache:!1,storyOrder:o,timerEndsAt:null,timerTotalSeconds:null}},Tn=e=>V(e)?{id:yn(e.id),author:H(e.author),body:H(e.body),createdAt:H(e.createdAt)}:null,En=e=>V(e)?{path:H(e.path),additions:yn(e.additions),deletions:yn(e.deletions),status:H(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null}:null,Dn=e=>V(e)?{sha:H(e.sha),message:H(e.message),author:H(e.author),authoredAt:H(e.authoredAt)}:null,On=e=>V(e)?{found:bn(e.found),isConflicted:bn(e.isConflicted),mergeableStatus:Sn(e.mergeableStatus),isPassedAllCiJob:bn(e.isPassedAllCiJob),isCiStateSuccess:bn(e.isCiStateSuccess),isBranchOutOfDate:bn(e.isBranchOutOfDate),missingRequiredCheckNames:xn(e.missingRequiredCheckNames)}:{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},kn=e=>{if(e===`AVAILABLE`||e===`UNAVAILABLE`)return e;throw Error(`ciStatusAvailability must be 'AVAILABLE' or 'UNAVAILABLE', received ${JSON.stringify(e)}`)},An=e=>{if(!V(e))return null;let t=V(e.summary)?{title:H(e.summary.title),body:H(e.summary.body),additions:yn(e.summary.additions),deletions:yn(e.summary.deletions),changedFiles:yn(e.summary.changedFiles)}:null;return{url:H(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:H(e.createdAt),isDraft:bn(e.isDraft),isConflicted:bn(e.isConflicted),mergeableStatus:Sn(e.mergeableStatus),isPassedAllCiJob:bn(e.isPassedAllCiJob),isCiStateSuccess:bn(e.isCiStateSuccess),isResolvedAllReviewComments:bn(e.isResolvedAllReviewComments),isBranchOutOfDate:bn(e.isBranchOutOfDate),missingRequiredCheckNames:xn(e.missingRequiredCheckNames),ciStatusAvailability:kn(e.ciStatusAvailability),summary:t}},jn=e=>{if(!V(e))return{body:``,comments:[],state:{state:`open`,merged:!1,isPullRequest:!1,title:``,stateReason:``},files:null,commits:null,prStatus:null,relatedPrs:null};let t=V(e.state)?e.state:{},n={state:H(t.state)||`open`,merged:bn(t.merged),isPullRequest:bn(t.isPullRequest),title:H(t.title),stateReason:H(t.stateReason)},r=e.files===null?null:Array.isArray(e.files)?e.files.map(En).filter(e=>e!==null):null,i=e.commits===null?null:Array.isArray(e.commits)?e.commits.map(Dn).filter(e=>e!==null):null,a=e.prStatus===null?null:On(e.prStatus),o=e.relatedPrs===null?null:Array.isArray(e.relatedPrs)?e.relatedPrs.map(An).filter(e=>e!==null):null;return{body:H(e.body),comments:Array.isArray(e.comments)?e.comments.map(Tn).filter(e=>e!==null):[],state:n,files:r,commits:i,prStatus:a,relatedPrs:o}},Mn=e=>{if(!V(e))return null;let t=typeof e.capturedAt==`string`?e.capturedAt:``,n=xn(e.failures),r={};if(V(e.tabs))for(let[t,n]of Object.entries(e.tabs)){if(!V(n))continue;let e={};for(let[t,r]of Object.entries(n))e[t]=wn(r);r[t]=e}let i={};if(V(e.items))for(let[t,n]of Object.entries(e.items))i[t]=jn(n);return{capturedAt:t,tabs:r,items:i,failures:n}},Nn=`/api/airplanesync`,Pn=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}},Fn=()=>{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,l]=(0,y.useState)([]),u=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!mn())return;let e=!1;return _n().then(n=>{e||n===null||(a(n),t(`on`))}).catch(()=>{hn(!1)}),()=>{e=!0}},[]);let d=(0,y.useCallback)(async(e,n,i)=>{let o=e.getReader(),c=new TextDecoder,u=``;for(;;){let{done:e,value:d}=await o.read();if(e)break;u+=c.decode(d,{stream:!0});let f=u.split(`
15
15
 
16
- `);u=f.pop()??``;for(let e of f){if(!e.startsWith(`data: `))continue;let o=Pn(e.slice(6));if(o!==null){if(o.type===`progress`)r({fetched:typeof o.fetched==`number`?o.fetched:0,total:typeof o.total==`number`?o.total:0});else if(o.type===`done`){let e=Mn(o.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]),l(i);return}let r=un(n,e);if(r.status===`error`){s(r.failures),t(`error`),l(r.failures);return}let c=Mn(r.snapshot);if(c===null){t(`error`),s([`Failed to merge snapshot`]),l(i);return}await gn(c),hn(!0),a(c),t(`on`),s(c.failures),l(c.failures)}}}}},[]),f=(0,y.useCallback)(()=>{u.current!==null&&u.current.abort();let e=new AbortController;u.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),l([]),fetch(Nn,{signal:e.signal}).then(async e=>{!e.ok||e.body===null?(t(`error`),s([`HTTP ${e.status}`]),l([])):await d(e.body,null,[])}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]),l([]))})},[d]),p=(0,y.useCallback)(()=>{u.current!==null&&(u.current.abort(),u.current=null),t(`off`),a(null),r(null),s([]),l([]),hn(!1),vn().catch(()=>{})},[]),m=(0,y.useCallback)((e,n)=>{if(n.length===0)return;u.current!==null&&u.current.abort();let i=new AbortController;u.current=i,t(`syncing`),r({fetched:0,total:n.length}),s([]),l([]),fetch(Nn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targetUrls:n}),signal:i.signal}).then(async r=>{!r.ok||r.body===null?(t(`error`),s([`HTTP ${r.status}`]),l(n)):await d(r.body,e,n)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]),l(n))})},[d]);return{status:e,progress:n,snapshot:i,failures:o,retryTargetUrls:c,startSync:f,turnOff:p,retryFailed:()=>m(i,c)}},In=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ln=e=>typeof e==`string`?e:``,Rn=e=>typeof e==`number`?e:0,zn=e=>e===!0,Bn=`console-api-v1`,Vn=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();In(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(Bn).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(Bn)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},Hn=e=>!In(e)||!Array.isArray(e.comments)?[]:e.comments.filter(In).map(e=>({id:Rn(e.id),author:Ln(e.author),body:Ln(e.body),createdAt:Ln(e.createdAt)})),Un=e=>!In(e)||!Array.isArray(e.files)?[]:e.files.filter(In).map(e=>({path:Ln(e.path)||Ln(e.filename),additions:Rn(e.additions),deletions:Rn(e.deletions),status:Ln(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Wn=e=>!In(e)||!Array.isArray(e.commits)?[]:e.commits.filter(In).map(e=>({sha:Ln(e.sha),message:Ln(e.message),author:Ln(e.author),authoredAt:Ln(e.authoredAt)})),Gn=e=>In(e)?{title:Ln(e.title),body:Ln(e.body),additions:Rn(e.additions),deletions:Rn(e.deletions),changedFiles:Rn(e.changedFiles)}:null,Kn=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],qn=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,Jn=e=>{if(e===`AVAILABLE`||e===`UNAVAILABLE`)return e;throw Error(`ciStatusAvailability must be 'AVAILABLE' or 'UNAVAILABLE', received ${JSON.stringify(e)}`)},Yn=e=>!In(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(In).map(e=>({url:Ln(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:Ln(e.createdAt),isDraft:zn(e.isDraft),isConflicted:zn(e.isConflicted),mergeableStatus:qn(e.mergeableStatus),isPassedAllCiJob:zn(e.isPassedAllCiJob),isCiStateSuccess:zn(e.isCiStateSuccess),isResolvedAllReviewComments:zn(e.isResolvedAllReviewComments),isBranchOutOfDate:zn(e.isBranchOutOfDate),missingRequiredCheckNames:Kn(e.missingRequiredCheckNames),ciStatusAvailability:Jn(e.ciStatusAvailability),summary:Gn(e.summary)})),Xn=e=>{if(!In(e)||!In(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:zn(t.isConflicted),mergeableStatus:qn(t.mergeableStatus),isPassedAllCiJob:zn(t.isPassedAllCiJob),isCiStateSuccess:zn(t.isCiStateSuccess),isBranchOutOfDate:zn(t.isBranchOutOfDate),missingRequiredCheckNames:Kn(t.missingRequiredCheckNames)}},Zn=e=>In(e)?{state:Ln(e.state)||`open`,merged:zn(e.merged),isPullRequest:zn(e.isPullRequest),title:Ln(e.title),stateReason:Ln(e.stateReason)}:{state:`open`,merged:!1,isPullRequest:!1,title:``,stateReason:``},Qn=()=>({fetchItemBody:async e=>{let t=await Vn(`/api/itembody`,e);return In(t)?Ln(t.body):``},fetchComments:async e=>Hn(await Vn(`/api/comments`,e)),fetchPrFiles:async e=>Un(await Vn(`/api/prfiles`,e)),fetchPrCommits:async e=>Wn(await Vn(`/api/prcommits`,e)),fetchRelatedPrs:async e=>Yn(await Vn(`/api/relatedprs`,e)),fetchIssueState:async e=>Zn(await Vn(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Xn(await Vn(`/api/pullrequeststatus`,e))}),$n=async e=>{let t=typeof e.text==`function`?await e.text().catch(()=>``):typeof e.json==`function`?JSON.stringify(await e.json().catch(()=>({}))):``;if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(In(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},er=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 $n(n));return await n.json()},tr=`/api/comment`,nr=e=>({id:Rn(e.id),author:Ln(e.author),body:Ln(e.body),createdAt:Ln(e.createdAt)}),rr=async e=>{let t=await fetch(tr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await $n(t),rateLimitResetAt:null};let n=await t.json();return In(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:In(n.comment)?{posted:!0,comment:nr(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},ir=`/api/upload`,ar=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},or=async e=>{let t=await fetch(ir,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t));let n=await t.json();if(!In(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},sr=`/api/addstory`,cr=async e=>{let t=await fetch(sr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t));let n=await t.json();return!In(n)||!Array.isArray(n.stories)?[]:n.stories.filter(In).map(e=>({id:Ln(e.id),name:Ln(e.name),color:Ln(e.color)}))},lr=`/api/reviewcomment`,ur=async e=>{let t=await fetch(lr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},dr=`/api/createissue`,fr=`/api/storycolor`,pr=async e=>{let t=await fetch(fr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},mr=async e=>{let t=await fetch(dr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(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},hr=`/api/reorderstory`,gr=async e=>{let t=await fetch(hr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},_r=`/api/deleteallcomments`,vr=async e=>{let t=await fetch(_r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},yr=`/api/deletestory`,br=async e=>{let t=await fetch(yr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},xr=`/api/renamestory`,Sr=async e=>{let t=await fetch(xr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Cr=`/api/storydescription`,wr=async e=>{let t=await fetch(Cr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Tr=e=>typeof e!=`object`||!e||Array.isArray(e)?null:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`)),Er=e=>In(e)?Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`number`)):null,Dr=e=>{if(!In(e))return null;let t=Er(e.todoByHumanCounts),n=Er(e.awaitingOwnerCounts);return t===null||n===null?null:{todoByHumanCounts:t,awaitingOwnerCounts:n}},Or=e=>Array.isArray(e)?e.filter(In):null,kr=e=>Array.isArray(e)?e.filter(In):null,Ar=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,disabledPjcodes:[],workflowStoryEntries:null,workflowAgentOptions:null,actionableCounts:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:Tr(n.projectUrls),fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null,nameWithOwnerByPjcode:Tr(n.nameWithOwnerByPjcode),disabledPjcodes:Array.isArray(n.disabledPjcodes)?n.disabledPjcodes.filter(e=>typeof e==`string`):[],workflowStoryEntries:Or(n.workflowStoryEntries),workflowAgentOptions:kr(n.workflowAgentOptions),actionableCounts:Dr(n.actionableCounts)}},jr=`/api/projectreadmeconfig`,Mr=async e=>{let t=`${jr}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await $n(n));let r=await n.json();return{maximumPreparingIssuesCount:In(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},Nr=`/api/renameissue`,Pr=async e=>{let t=await fetch(Nr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Fr=`/api/issuebody`,Ir=async e=>{let t=await fetch(Fr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Lr=`/api/issuecommentbody`,Rr=async e=>{let t=await fetch(Lr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},zr=`/api/setdependedissueurl`,Br=async e=>{let t=await fetch(zr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Vr=`/api/projectsettings`,Hr=async e=>{let t=await fetch(Vr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Ur=`console-comment-expanded:`,Wr=e=>{try{let t=localStorage.getItem(Ur+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}},Gr=(e,t)=>{try{localStorage.setItem(Ur+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Kr=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(Ur)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},qr=e=>`pv_overlay_${e}`,Jr=e=>e.projectItemId===``?e.itemId:e.projectItemId,Yr=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,Xr=(e,t,n)=>e.filter(e=>!Yr(t[Jr(e)],n)).length,Zr=(e,t,n)=>e.filter(e=>!Yr(t[Jr(e)],n)),Qr=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[Jr(t)];return i===void 0||i.ts<r?null:i.status??null},$r=(e,t,n,r,i)=>{let{closed:a,...o}=n,s={...e[t]??{},...o,...a===!0?{closedAtMs:i}:{},ts:i,mode:r};return{...e,[t]:s}},ei=(e,t,n)=>{let r=e[t];return r===void 0||!Number.isFinite(r.closedAtMs)?e:{...e,[t]:{...r,closedAtMs:n}}},ti=(e,t)=>{let{pjcode:n,projectItemId:r}=e;if(typeof n!=`string`||n===``||typeof r!=`string`||r===``||typeof t!=`object`||!t)return null;let{closedAtMs:i}=t;return typeof i!=`number`||!Number.isFinite(i)?null:{pjcode:n,key:r,closedAtMs:i}},ni=(e,t)=>{let n={...e};return delete n[t],n},ri=(e,t)=>{let n={};for(let[r,i]of Object.entries(e)){if(i.done!==!0){n[r]=i;continue}let e=t[i.mode];if(e==null){n[r]=i;continue}let a=Date.parse(e.generatedAt);Number.isNaN(a)||i.ts>=a?n[r]=i:e.items.some(e=>Jr(e)===r)||(n[r]=i)}return n},ii=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,ai=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(qr(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))ii(t)&&(r[e]=t);return r},oi=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(qr(e),JSON.stringify(t))},si=new Set,ci=(e,t)=>{let n=ti(e,t);if(n===null)return;let r=ai(n.pjcode),i=ei(r,n.key,n.closedAtMs);i!==r&&oi(n.pjcode,i);for(let e of si)e(n)},li=e=>{let[t,n]=(0,y.useState)(()=>({pjcode:e,overlay:ai(e)})),r=t.pjcode===e?t.overlay:ai(e);(0,y.useEffect)(()=>{n(t=>t.pjcode===e?t:{pjcode:e,overlay:ai(e)})},[e]);let i=(0,y.useCallback)((t,r)=>{n(n=>{let i=n.pjcode===e?n.overlay:ai(e),a=t(i);return(r||a!==i)&&oi(e,a),{pjcode:e,overlay:a}})},[e]),a=(0,y.useCallback)((e,t,n)=>{i(r=>$r(r,e,t,n,Date.now()),!0)},[i]),o=(0,y.useCallback)(e=>{i(t=>ni(t,e),!0)},[i]);return(0,y.useEffect)(()=>{let t=t=>{t.pjcode===e&&i(e=>ei(e,t.key,t.closedAtMs),!1)};return si.add(t),()=>{si.delete(t)}},[e,i]),{overlay:r,patchOverlay:a,revertOverlayEntry:o}},ui=`console-action-delivery-queue`,di=new Set,fi=()=>{try{let e=localStorage.getItem(ui);if(e!==null){let t=JSON.parse(e);return Array.isArray(t)?t:[]}return[]}catch{return[]}},pi=e=>{localStorage.setItem(ui,JSON.stringify(e))},mi=e=>{pi([...fi(),e])},hi=e=>{pi(fi().filter(t=>t.id!==e))},gi=async(e,t=!1)=>{let n=await fetch(e.apiPath,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e.requestBody,actionId:e.id}),...t?{keepalive:!0}:{}}),r=typeof n.json==`function`?await n.json().catch(async()=>typeof n.text==`function`?n.text():{}):typeof n.text==`function`?await n.text():{};if(!n.ok){let e=typeof r==`object`&&r&&`error`in r?String(r.error):typeof r==`string`&&r.length>0?r:`HTTP ${n.status}`;throw Error(e)}if(typeof r==`object`&&r&&`ok`in r&&r.ok===!1)throw Error(`error`in r?String(r.error):`Action failed`);return ci(e.requestBody,r),r},_i=async(e,t=!1)=>{if(!di.has(e.id)){di.add(e.id);try{let n=await gi(e,t);return hi(e.id),n}catch(t){throw di.delete(e.id),t}}},vi=`console-offline-action-queue`,yi=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.nameWithOwner==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},bi=e=>typeof e.pjcode==`string`&&typeof e.url==`string`&&typeof e.body==`string`,xi=()=>{try{let e=localStorage.getItem(vi);if(e===null)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=new Set(fi().map(e=>e.id));return t.filter(e=>yi(e)&&!n.has(e.id))}catch{return[]}},Si=e=>{localStorage.setItem(vi,JSON.stringify(e))},Ci=e=>{try{let t=localStorage.getItem(vi),n=t===null?[]:JSON.parse(t);Si((Array.isArray(n)?n:[]).filter(t=>typeof t!=`object`||!t||t.id!==e))}catch{Si([])}},wi=()=>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)}`,Ti=e=>e instanceof TypeError,Ei=class extends Error{sentStepCount;constructor(e,t){super(t instanceof Error?t.message:String(t)),this.name=`ConsoleActionPartiallySentError`,this.sentStepCount=e,this.cause=t}},Di=async(e,t=0)=>{for(let n=t;n<e.length;n+=1)try{await e[n]()}catch(e){throw n===0?e:new Ei(n,e)}},Oi=`Airplane mode`,ki=`This action requires a network connection. Turn off airplane mode and try again.`,Ai=e=>e instanceof Error&&e.message.length>0?e.message:String(e),ji=100,Mi=(e={isAirplaneModeOn:!1})=>{let t=(0,y.useRef)(e.isAirplaneModeOn);t.current=e.isAirplaneModeOn;let n=(0,y.useRef)(e.projectCode),r=(0,y.useRef)(new Set),i=(0,y.useRef)((()=>{let e=xi();return e.length===1?e.filter(e=>e.actionId===void 0&&e.apiPath!==`/api/comment`):[]})()),[a,o]=(0,y.useState)([]),[s,c]=(0,y.useState)([]),[l,u]=(0,y.useState)(xi),d=(0,y.useRef)(l);d.current=l;let f=(0,y.useRef)(new Map),p=(0,y.useRef)(()=>{}),m=(0,y.useRef)(0),[h,g]=(0,y.useState)({status:`idle`,attempt:0}),[_,v]=(0,y.useState)(0),b=(0,y.useCallback)(e=>{c(t=>[...t,{id:wi(),createdAt:Date.now(),...e}])},[]),x=(0,y.useCallback)(({payloads:e,message:t,color:n})=>{let r=Date.now(),i=e.map(e=>{let i={...e};return delete i.actionId,{id:wi(),message:t,color:n,enqueuedAt:r,...i}});Si([...xi(),...i]),u(e=>{let t=[...e,...i];return Si(t),t})},[]),S=(0,y.useCallback)((e,n,r)=>{let i=m.current+1;m.current=i;let a=r??wi(),o=e=>{c(t=>{let n=t.findIndex(e=>e.id===a);return n===-1?[...t,{id:a,createdAt:Date.now(),...e}]:t.map((t,r)=>r===n?{...t,...e}:t)})},s=e.offline??[],l=t=>{for(let e of s)e.id!==void 0&&(hi(e.id),Ci(e.id));x({payloads:t,message:e.message,color:e.color}),g({status:`offline`,attempt:i})};if(t.current){let t=s.slice(n);t.length>0?l(t):(e.revertAdvance?.(),e.revertOptimistic?.(),o({message:Oi,reason:ki}),g({status:`failed`,attempt:i}))}else g({status:`unconfirmed`,attempt:i}),(e.commitWithActionId===void 0?e.commit(n):e.commitWithActionId(n,String(s[0]?.id??``))).then(()=>{for(let e of s){let t=e.id??``;hi(t),Ci(t)}g({status:`succeeded`,attempt:i})}).catch(t=>{let r=t instanceof Ei,c=r?t.sentStepCount:n,u=s.slice(c),d=r?t.cause:t;if(Ti(d)&&u.length>0)l(u);else{for(let e of s)e.id!==void 0&&(hi(e.id),Ci(e.id));o({message:e.message,reason:Ai(d),retry:()=>p.current(e,c,a)}),g({status:`failed`,attempt:i})}})},[x]);p.current=S,(0,y.useEffect)(()=>{if(n.current===void 0||n.current===e.projectCode){n.current=e.projectCode;return}n.current=e.projectCode;let t=Array.from(f.current.values());for(let e of t)e.timer!==null&&clearInterval(e.timer),f.current.delete(e.id),o(t=>t.filter(t=>t.id!==e.id)),S(e.action,0)},[e.projectCode,S]);let C=(0,y.useCallback)(e=>{let t=f.current.get(e);t!==void 0&&(t.timer!==null&&clearInterval(t.timer),f.current.delete(e),o(t=>t.filter(t=>t.id!==e)),Kr(),S(t.action,0))},[S]),w=(0,y.useCallback)(e=>{let t=f.current.get(e);if(t!==void 0){t.timer!==null&&clearInterval(t.timer),f.current.delete(e),o(t=>t.filter(t=>t.id!==e));for(let e of t.action.offline??[]){let t=e.id??``;hi(t),Ci(t)}t.action.revertAdvance?.(),t.action.revertOptimistic?.()}},[]),T=(0,y.useCallback)(e=>{C(e)},[C]),ee=(0,y.useCallback)(e=>{c(t=>t.filter(t=>t.id!==e))},[]),E=(0,y.useCallback)((e,t)=>{b({message:e,reason:t})},[b]),D=(0,y.useCallback)(e=>{u(t=>{let n=t.filter(t=>t.id!==e);return Si(n),n})},[]),O=(0,y.useCallback)(async e=>{let t=d.current.find(t=>t.id===e);if(t!==void 0)try{if(t.apiPath===`/api/comment`&&bi(t.requestBody)){let n=await rr(t.requestBody);if(n.posted){D(e);return}let r=n.rateLimitResetAt===null?``:` Rate limit resets at ${n.rateLimitResetAt}.`;b({message:t.message,reason:`${n.error}.${r}`,retry:()=>void O(e)});return}let n=await er(t.apiPath,t.requestBody);ci(t.requestBody,n),D(e)}catch(n){Ti(n)?b({message:t.message,reason:`Still offline — action is still held in the queue`}):(b({message:t.message,reason:Ai(n)}),D(e))}},[b,D]),te=(0,y.useCallback)(e=>{v(e=>e+1);let t=wi(),n=Date.now(),r={id:t,createdAt:n,action:e,startedAt:n,timer:null},i=(e.offline??[]).map(t=>{let r=typeof t.requestBody.actionId==`string`?t.requestBody.actionId:wi(),i={id:r,actionId:r,message:e.message,color:e.color,enqueuedAt:n,...t};return mi(i),i}),a=i.length>0?{...e,offline:i}:e;i.length>0&&Si([...xi(),...i]);let s={...r,action:a};f.current.set(t,s),o(r=>[...r,{id:t,createdAt:n,message:e.message,color:e.color}]),e.advance(),e.optimistic?.(),r.timer=setInterval(()=>{Date.now()-r.startedAt>=5e3&&C(t)},ji)},[C]);return(0,y.useLayoutEffect)(()=>{let e=()=>{let t=fi(),n=t.length===0&&i.current.length===1?i.current:t;for(let t of n)r.current.has(t.id)||(r.current.add(t.id),_i(t).then(()=>Ci(t.id)).catch(n=>{b({message:t.message,reason:Ai(n),retry:()=>void e()})}))},t=()=>{let e=Array.from(f.current.values());for(let t of e){t.timer!==null&&clearInterval(t.timer),f.current.delete(t.id),o(e=>e.filter(e=>e.id!==t.id));let e=t.action.offline??[];e.length===0&&t.action.commit(0).catch(e=>b({message:t.action.message,reason:Ai(e)}));for(let n of e){let e=fi().find(e=>e.id===n.id);if(e!==void 0){if(r.current.has(e.id))continue;r.current.add(e.id),_i(e,!0).then(()=>Ci(e.id)).catch(e=>b({message:t.action.message,reason:Ai(e)}))}}}};e();let n=()=>{document.visibilityState===`hidden`&&t()};return window.addEventListener(`pagehide`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`pagehide`,t),document.removeEventListener(`visibilitychange`,n),t()}},[b]),{pending:a,error:s,offlineActions:l,writeState:h,enqueueSequence:_,enqueue:te,offlineActionsCreate:x,showError:E,undo:w,dismiss:T,dismissError:ee,confirmOfflineAction:O,discardOfflineAction:D}},Ni=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},Pi=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},Fi=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)=>{let _=(0,y.useRef)(0),v=(0,y.useRef)(null),b=(0,y.useRef)(0),x=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e||i===null){_.current=0,v.current=null,x.current=null;return}let y=f!==b.current;y&&(b.current=f);let S=a.filter(e=>(o[e]??15)>0),C=x.current,w=C!==null&&C.pjcode===i&&S.some(e=>!C.pjcodesWithMinutes.includes(e));x.current={pjcode:i,pjcodesWithMinutes:S};let T=ce({actionNewlyEnqueued:y,timerElapsed:t(o[i]??15),remainingCountIsZero:n===0&&r===0,snapshotsReady:s&&c&&!l&&!u,explicitlySelectedPjcodeMatchesCurrent:d!==null&&i===d,taskOpen:p!==null,dialogOpen:m,aProjectGainedRemainingMinutesSinceTheCurrentProjectWasLastEvaluated:w,pjcode:i,pjcodes:a,projectMinutes:o,skipCount:_.current,evaluatedPjcode:v.current,projectTodoByHumanCounts:h,projectAwaitingOwnerCounts:g});_.current=T.nextSkipCount,v.current=T.nextEvaluatedPjcode,T.targetPjcode!==null&&Ni(`/projects/${T.targetPjcode}/todo-by-human`)},[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g])},Ii=`tdpm-awaiting-owner-list-visibility-settings`,Li=()=>({showExecutiveSummaryAndActionButton:!0}),Ri=()=>{if(typeof localStorage>`u`)return Li();let e=localStorage.getItem(Ii);if(e===null)return Li();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return Li();let n=t;return{showExecutiveSummaryAndActionButton:typeof n.showExecutiveSummaryAndActionButton!=`boolean`||n.showExecutiveSummaryAndActionButton}}catch{return Li()}},zi=e=>{typeof localStorage<`u`&&localStorage.setItem(Ii,JSON.stringify(e))},Bi=e=>{let[t,n]=(0,y.useState)(()=>Ri().showExecutiveSummaryAndActionButton),[r,i]=(0,y.useState)(t);return(0,y.useEffect)(()=>{e&&i(t)},[e,t]),{showExecutiveSummaryAndActionButton:t,draftShowExecutiveSummaryAndActionButton:r,toggleDraft:(0,y.useCallback)(e=>{i(e)},[]),save:(0,y.useCallback)(()=>{i(e=>(zi({showExecutiveSummaryAndActionButton:e}),n(e),e))},[])}},Vi=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Hi=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ui=e=>Array.isArray(e)?e.filter(Vi).map(e=>({...e,relatedOpenPullRequestUrls:Hi(e.relatedOpenPullRequestUrls)})):[],Wi=e=>!Vi(e)||!Array.isArray(e.items)?[]:Ui(e.items),Gi=e=>Array.isArray(e)?e.filter(Vi):[],Ki=e=>Array.isArray(e)?e.filter(Vi).map(e=>({...e,items:Ui(e.items)})):[],qi=e=>({items:Wi(e),generatedAt:Vi(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Vi(e)?Gi(e.statusOptions):[],agentOptions:Vi(e)?Gi(e.agentOptions):[],storyOptions:Vi(e)?Gi(e.storyOptions):[],storyColors:Vi(e)&&Vi(e.storyColors)?e.storyColors:{},stories:Vi(e)?Ki(e.stories):[],defaultNameWithOwner:Vi(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Vi(e)?Hi(e.storyOrder):[],timerEndsAt:Vi(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Vi(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Ji=()=>{let e={};for(let t of A)e[t.name]=null;return e},Yi=(e,t)=>`/projects/${e}/${t}/list.json`,Xi=6e4,Zi=`console-list-v1`,Qi=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(Zi).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)}},$i=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(Zi)).match(e);return t===void 0?null:{...qi(await t.json()),fromCache:!0}}catch{return null}},ea=async e=>{let t=await Promise.all(A.map(async t=>({tabName:t.name,snapshot:await $i(Yi(e,t.name))}))),n=Ji();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},ta=async(e,t)=>{let n=Yi(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Qi(n,t),{snapshot:{...qi(t),fromCache:!1},error:null}}catch(e){let t=await $i(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},U=async e=>{await Promise.all(A.map(async t=>{let n=Yi(e,t.name);try{let e=await fetch(n);if(!e.ok)return;Qi(n,await e.json())}catch{}}))},na=async e=>{let t=await Promise.all(A.map(async t=>{let{snapshot:n,error:r}=await ta(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Ji(),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}},ra=(e,t=null)=>{let n=(0,y.useRef)(new Map),[r,i]=(0,y.useState)(Ji),[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??Ji()),t!==null&&o(!1)}return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Ji();for(let t of A){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(Ji()),o(!1),c(`No project specified in the URL path.`),()=>{r=!0};let s=n.current.has(e);ea(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(Ji()))});let l=()=>{na(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,Xi);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 ta(e,t);r!==null&&i(i=>{let a={...i,[t]:r};return n.current.set(e,a),a})},[e])}},ia=(e,t,n,r,i)=>{(0,y.useEffect)(()=>{if(!i||r)return;let a=n.filter(n=>n!==e&&n!==t);if(a.length!==0)for(let e of a)U(e).catch(()=>{})},[i,r,e,t,n]),(0,y.useEffect)(()=>{if(!i||r)return;let t=n.filter(t=>t!==e);if(t.length===0)return;let a=setInterval(()=>{for(let e of t)U(e).catch(()=>{})},Xi);return()=>{clearInterval(a)}},[i,r,e,n])},aa=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)}},oa=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},sa=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=oa(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)}},ca=(e=null)=>(0,y.useMemo)(()=>{let t=Qn(),n={client:t,body:new aa(t.fetchItemBody),comments:new aa(t.fetchComments),files:new aa(t.fetchPrFiles),commits:new aa(t.fetchPrCommits),relatedPrs:new aa(t.fetchRelatedPrs),state:new aa(t.fetchIssueState),prStatus:new aa(t.fetchPullRequestStatus)};return e!==null&&sa(n,e),n},[e]),la=0,ua=500,da=2e3,fa=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:da});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},pa=(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)},ma=(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+la);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=fa(()=>{for(let t of i)pa(e,t)})},ua);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},ha=e=>{let[t,n]=(0,y.useState)(null);return(0,y.useEffect)(()=>{t!==null&&e!==t&&n(null)},[e,t]),{explicitlySelectedPjcode:t,notifyExplicitSelection:(0,y.useCallback)(e=>{n(e)},[])}},ga=`/api/features`,_a=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(ga).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},va=(e,t)=>{let n=A.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<A.length;e+=1){let n=A[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},ya=e=>{let t=A.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},ba=new Set(A.map(e=>e.name)),xa=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return ba.has(n)?n:null},Sa=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Ca=`#settings`,wa=(e,t,n=new Set,r)=>{let i=(0,y.useCallback)(()=>{let e=ya(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:xa(window.location.pathname)??e,selectedItemKey:Sa(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=xa(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=ya(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=>{typeof window>`u`||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}},Ta=`/api/review`,Ea=`/api/triage`,Da=`/api/intmux`,Oa=(e,t,n,r,i,a)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId,expectedStatusName:t.status,...a===void 0?{}:{actionId:a}};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:Te(i),expectedStatusName:t.status,...a===void 0?{}:{actionId:a},...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:Se,expectedStatusName:t.status,...a===void 0?{}:{actionId:a}}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:Ce,issueCommentBody:we(n),expectedStatusName:t.status,...a===void 0?{}:{actionId:a}}},ka=(e,t,n,r)=>{let{actionId:i,...a}=r??{};return{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,expectedStatusName:t.status,...a,...i===void 0?{}:{actionId:i}}},Aa=(e,t,n)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId,expectedStatusName:t.status,...n===void 0?{}:{actionId:n}}),ja=(e,t,n,r)=>({pjcode:e,url:t.url,body:n,...r===void 0?{}:{actionId:r}}),Ma=(e,t)=>({issueUrl:e.url,...t===void 0?{}:{actionId:t}}),Na=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,Pa=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fa=()=>Error(`No project specified in the URL path.`),Ia=(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.useRef)(new Set),a=(0,y.useCallback)(async(t,n,i,a=[],o)=>{if(e===null)throw Fa();await er(Ta,Oa(e,t,n,i,a,o)),r(t)},[e,r]),o=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,actionId:i??Na()}),r(t)},[e,r]),s=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,{pjcode:e,action:`set_agent`,issueUrl:t.url,projectItemId:t.projectItemId,agentOptionId:n.id,actionId:i??Na()}),r(t)},[e,r]),c=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();let a=await er(Ea,{pjcode:e,action:`set_story`,issueUrl:t.url,projectItemId:t.projectItemId,storyOptionId:n.id,actionId:i??Na()});return r(t),a},[e,r]),l=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,ka(e,t,`set_status`,{statusName:n.name,actionId:i??Na()})),r(t)},[e,r]),u=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,ka(e,t,`set_next_action_date`,{nextActionDate:n,actionId:i??Na()})),r(t)},[e,r]),d=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,ka(e,t,`set_next_action_hour`,{nextActionHour:n,actionId:i??Na()})),r(t)},[e,r]),f=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Da,Aa(e,t,i??Na())),r(t)},[e,r]),p=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();let a={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,actionId:i??Na()};ci(a,await er(Ea,a)),r(t)},[e,r]),m=(0,y.useCallback)(async(e,t)=>{try{await l(e,t)}catch(e){throw new Ei(1,e)}await n?.()},[l,n]),h=(0,y.useCallback)(async(t,i,a=0,o)=>{if(e===null)throw Fa();let s=o??Na();if(a>0){await m(t,i);return}let c=await er(Ea,ka(e,t,`set_status`,{statusName:i.name,commentBody:`ok`,actionId:s,setStatusWhenCommentFails:!0}));if(r(t),Pa(c)&&c.commentPosted===!1&&c.ok===!1)throw Error(`Comment not posted — ${String(c.error??`Comment was not posted`)}. Status was changed. Re-post: ok`);await n?.()},[e,r,n,m]),g=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();let a=await rr(ja(e,t,n,i));if(!a.posted){let e=a.rateLimitResetAt===null?``:` Rate limit resets at ${a.rateLimitResetAt}.`;throw Error(`${a.error}.${e}`)}return r(t),a.comment},[e,r]),_=(0,y.useCallback)(async(t,a,o,s)=>{if(e===null)throw Fa();let c=s??Na(),l=i.current.has(c);i.current.add(c);let u=await er(Ea,ka(e,t,`set_status`,{statusName:o.name,commentBody:a,actionId:c}));if(!l&&Pa(u)&&Object.keys(u).length===0){let n=await rr(ja(e,t,a));if(!n.posted)throw Error(n.error);return await m(t,o),n.comment}if(!Pa(u)||u.ok!==!0||u.commentPosted===!1)throw Error(String(Pa(u)?u.error??`Comment was not posted`:`Comment was not posted`));return r(t),await n?.(),{id:0,author:``,body:a,createdAt:new Date().toISOString()}},[e,r,m,n]),v=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=ar(new Uint8Array(await n.arrayBuffer()));return or({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),b=(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw Fa();await ur({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),x=(0,y.useCallback)(async(e,t)=>{await Pr({issueUrl:e.url,newTitle:t})},[]),S=(0,y.useCallback)(async(e,t)=>{try{await Ir({issueUrl:e.url,body:t})}finally{r(e)}},[r]),C=(0,y.useCallback)(async(e,t,n)=>{try{await Rr({issueUrl:e.url,commentId:t,body:n})}finally{r(e)}},[r]),w=(0,y.useCallback)(async(e,t)=>{await vr(Ma(e,t)),r(e)},[r]),T=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fa();await Br({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e]),ee=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fa();await Br({pjcode:e,issueUrl:t.url,dependedIssueUrl:n,projectItemId:t.projectItemId,replaceExisting:!0})},[e]);return(0,y.useMemo)(()=>({reviewPullRequest:a,setNextActionDate:o,setStory:c,setAgent:s,setStatus:l,setNextActionDateValue:u,setNextActionHourValue:d,setInTmuxByHuman:f,closeIssue:p,okAndMoveToAwaitingWorkspace:h,addComment:g,addCommentAndMoveToAwaitingWorkspace:_,uploadAttachment:v,addInlineReviewComment:b,issueRename:x,issueBodyUpdate:S,issueCommentBodyUpdate:C,deleteAllComments:w,setDependedIssueUrl:T,replaceDependedIssueUrl:ee,onAfterMoveToAwaitingWorkspace:n}),[a,o,c,s,l,u,d,f,p,h,g,_,v,b,x,S,C,w,T,ee,n])},La=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},Ra=()=>{let[e,t]=(0,y.useState)(()=>La(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(La(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},za=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ba=(e,t)=>{let[n,r]=(0,y.useState)([]),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)([]),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!0),[x,S]=(0,y.useState)(null),C=(0,y.useRef)({pjcodes:n,projectUrls:i,fleetTaskCreateUrl:o,nameWithOwnerByPjcode:c,disabledPjcodes:u,workflowStoryEntries:f,workflowAgentOptions:m,actionableCounts:g});return(0,y.useEffect)(()=>{let e=!1;return b(!0),S(null),Ar().then(t=>{e||(C.current={pjcodes:t.pjcodes,projectUrls:t.projectUrls,fleetTaskCreateUrl:t.fleetTaskCreateUrl,nameWithOwnerByPjcode:t.nameWithOwnerByPjcode,disabledPjcodes:t.disabledPjcodes,workflowStoryEntries:t.workflowStoryEntries,workflowAgentOptions:t.workflowAgentOptions,actionableCounts:t.actionableCounts},r(t.pjcodes),a(t.projectUrls),s(t.fleetTaskCreateUrl),l(t.nameWithOwnerByPjcode),d(t.disabledPjcodes),p(t.workflowStoryEntries),h(t.workflowAgentOptions),_(t.actionableCounts),b(!1))}).catch(t=>{e||(S(t instanceof Error?t:Error(String(t))),b(!1))}),()=>{e=!0}},[]),(0,y.useEffect)(()=>{if(!e||t)return;let n=!1,i=e=>{let t=C.current;za(t.pjcodes,e.pjcodes)||(C.current={...C.current,pjcodes:e.pjcodes},r(e.pjcodes)),za(t.projectUrls,e.projectUrls)||(C.current={...C.current,projectUrls:e.projectUrls},a(e.projectUrls)),za(t.fleetTaskCreateUrl,e.fleetTaskCreateUrl)||(C.current={...C.current,fleetTaskCreateUrl:e.fleetTaskCreateUrl},s(e.fleetTaskCreateUrl)),za(t.nameWithOwnerByPjcode,e.nameWithOwnerByPjcode)||(C.current={...C.current,nameWithOwnerByPjcode:e.nameWithOwnerByPjcode},l(e.nameWithOwnerByPjcode)),za(t.disabledPjcodes,e.disabledPjcodes)||(C.current={...C.current,disabledPjcodes:e.disabledPjcodes},d(e.disabledPjcodes)),za(t.workflowStoryEntries,e.workflowStoryEntries)||(C.current={...C.current,workflowStoryEntries:e.workflowStoryEntries},p(e.workflowStoryEntries)),za(t.workflowAgentOptions,e.workflowAgentOptions)||(C.current={...C.current,workflowAgentOptions:e.workflowAgentOptions},h(e.workflowAgentOptions)),za(t.actionableCounts,e.actionableCounts)||(C.current={...C.current,actionableCounts:e.actionableCounts},_(e.actionableCounts))},o=setInterval(()=>{Ar().then(e=>{n||i(e)}).catch(e=>{n||S(e instanceof Error?e:Error(String(e)))})},Xi);return()=>{n=!0,clearInterval(o)}},[e,t]),{pjcodes:n,projectUrls:i,fleetTaskCreateUrl:o,nameWithOwnerByPjcode:c,disabledPjcodes:u,workflowStoryEntries:f,workflowAgentOptions:m,actionableCounts:g,isLoading:v,error:x}},Va=e=>(0,y.useCallback)(t=>{Kr(),e(t)},[e]),Ha=()=>typeof window<`u`&&window.location.hash===`#settings`,Ua=e=>{let[t,n]=(0,y.useState)(Ha),[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=>Mr(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===Ca;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({},``,Ca)),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])=>Hr({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}},Wa=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,[])}},Ga=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,Ka=/^From:\s+:robot:/m,qa=/^##\s/m,Ja=e=>{let t=Ga.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=Ka.exec(n),i=qa.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},Ya=e=>{if(e.length===0)return null;let t=e[e.length-1],n=Ja(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},Xa=e=>`${e.repo}#${e.number}`,Za=(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=Xa(n),a=t.peek(e);if(a!==void 0){let e=Ya(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e})}else t.load(e,n.url).then(e=>{if(r)return;let t=Ya(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},Qa=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},$a=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},eo=(e,t,n,r)=>e===`previous`?t<=0:t>=n-r,to=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)return{scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth};t=t.parentElement}return null},no=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=null,o=e=>{if(e.touches.length!==1){i=!1;return}a=to(e.target);let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},s=e=>{if(!i)return;let t=e.touches[0];$a(t.clientX-n,t.clientY-r)&&(i=!1)},c=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let o=e.changedTouches[0],s=Qa(o.clientX-n,o.clientY-r);s!==null&&(a===null||eo(s,a.scrollLeft,a.scrollWidth,a.clientWidth))&&t.current(s)};return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`touchend`,c,{passive:!0}),()=>{e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`touchend`,c)}},[]),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},ro=e=>(0,y.useCallback)(t=>{Kr(),e(t)},[e]),io=(e,t,n,r,i)=>{let a=(0,y.useRef)(void 0),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{e?(a.current!==t&&(a.current=t,o.current=t!==null),o.current&&r===null&&n.length!==0&&(o.current=!1,i(n[0].projectItemId))):(a.current=t,o.current=!1)},[e,t,n,r,i])},ao=()=>{let[e,t]=(0,y.useState)(ue),[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=>(N(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}},oo=`console-comment-drafts`,so=()=>{try{let e=localStorage.getItem(oo);if(e===null)return new Map;let t=JSON.parse(e);return Array.isArray(t)?new Map(t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`string`)):new Map}catch(e){return console.error(`Failed to load comment drafts from storage:`,e),new Map}},co=e=>{try{localStorage.setItem(oo,JSON.stringify([...e]))}catch(e){console.error(`Failed to save comment drafts to storage:`,e)}},lo=(e,t,n)=>{let r=n===null?null:Date.parse(n);return e.map(e=>{let n=e.openItemCount,i=(e.items??[]).map(e=>{let i=t[Jr(e)]?.closedAtMs;return!(typeof i==`number`&&Number.isFinite(i)&&(r===null||!Number.isNaN(r)&&r<i))||e.isClosed===!0?{...e,isClosed:e.isClosed}:(n=Math.max(0,n-1),{...e,isClosed:!0})});return{...e,items:i,openItemCount:n}})},uo=e=>e.isClosed===void 0?e.status!==`Done`:!e.isClosed,fo=(e,t,n)=>{let r=e.find(e=>(e.items??[]).some(e=>e.projectItemId===t)),i=(r?.items??[]).find(e=>e.projectItemId===t);if(r===void 0||i===void 0||r.storyOptionId===n.id)return e;let a=+!!uo(i);return e.map(e=>e.storyOptionId===r.storyOptionId?{...e,items:(e.items??[]).filter(e=>e.projectItemId!==t),openItemCount:Math.max(0,e.openItemCount-a)}:e.storyOptionId===n.id?{...e,items:[...e.items??[],{...i,story:n.name}],openItemCount:e.openItemCount+a}:e)},po=e=>{if(typeof e!=`object`||!e)return;let{storySetAtMs:t}=e;if(typeof t==`number`&&Number.isFinite(t))return t},mo=(e,t)=>{if(t===null)return!0;let n=Date.parse(t);return!Number.isNaN(n)&&n<e.storySetAtMs},ho=(e,t)=>e.filter(e=>mo(e,t)),go=(e,t,n)=>ho(t,n).reduce((e,t)=>fo(e,t.projectItemId,t.target),e),_o=(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},vo=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},yo=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},bo=(e,t,n)=>e===null?null:t===`loaded-live`?n?e:null:e,xo=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
16
+ `);u=f.pop()??``;for(let e of f){if(!e.startsWith(`data: `))continue;let o=Pn(e.slice(6));if(o!==null){if(o.type===`progress`)r({fetched:typeof o.fetched==`number`?o.fetched:0,total:typeof o.total==`number`?o.total:0});else if(o.type===`done`){let e=Mn(o.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]),l(i);return}let r=un(n,e);if(r.status===`error`){s(r.failures),t(`error`),l(r.failures);return}let c=Mn(r.snapshot);if(c===null){t(`error`),s([`Failed to merge snapshot`]),l(i);return}await gn(c),hn(!0),a(c),t(`on`),s(c.failures),l(c.failures)}}}}},[]),f=(0,y.useCallback)(()=>{u.current!==null&&u.current.abort();let e=new AbortController;u.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),l([]),fetch(Nn,{signal:e.signal}).then(async e=>{!e.ok||e.body===null?(t(`error`),s([`HTTP ${e.status}`]),l([])):await d(e.body,null,[])}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]),l([]))})},[d]),p=(0,y.useCallback)(()=>{u.current!==null&&(u.current.abort(),u.current=null),t(`off`),a(null),r(null),s([]),l([]),hn(!1),vn().catch(()=>{})},[]),m=(0,y.useCallback)((e,n)=>{if(n.length===0)return;u.current!==null&&u.current.abort();let i=new AbortController;u.current=i,t(`syncing`),r({fetched:0,total:n.length}),s([]),l([]),fetch(Nn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targetUrls:n}),signal:i.signal}).then(async r=>{!r.ok||r.body===null?(t(`error`),s([`HTTP ${r.status}`]),l(n)):await d(r.body,e,n)}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]),l(n))})},[d]);return{status:e,progress:n,snapshot:i,failures:o,retryTargetUrls:c,startSync:f,turnOff:p,retryFailed:()=>m(i,c)}},In=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Ln=e=>typeof e==`string`?e:``,Rn=e=>typeof e==`number`?e:0,zn=e=>e===!0,Bn=`console-api-v1`,Vn=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();In(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(Bn).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(Bn)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},Hn=e=>!In(e)||!Array.isArray(e.comments)?[]:e.comments.filter(In).map(e=>({id:Rn(e.id),author:Ln(e.author),body:Ln(e.body),createdAt:Ln(e.createdAt)})),Un=e=>!In(e)||!Array.isArray(e.files)?[]:e.files.filter(In).map(e=>({path:Ln(e.path)||Ln(e.filename),additions:Rn(e.additions),deletions:Rn(e.deletions),status:Ln(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Wn=e=>!In(e)||!Array.isArray(e.commits)?[]:e.commits.filter(In).map(e=>({sha:Ln(e.sha),message:Ln(e.message),author:Ln(e.author),authoredAt:Ln(e.authoredAt)})),Gn=e=>In(e)?{title:Ln(e.title),body:Ln(e.body),additions:Rn(e.additions),deletions:Rn(e.deletions),changedFiles:Rn(e.changedFiles)}:null,Kn=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],qn=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,Jn=e=>{if(e===`AVAILABLE`||e===`UNAVAILABLE`)return e;throw Error(`ciStatusAvailability must be 'AVAILABLE' or 'UNAVAILABLE', received ${JSON.stringify(e)}`)},Yn=e=>!In(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(In).map(e=>({url:Ln(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:Ln(e.createdAt),isDraft:zn(e.isDraft),isConflicted:zn(e.isConflicted),mergeableStatus:qn(e.mergeableStatus),isPassedAllCiJob:zn(e.isPassedAllCiJob),isCiStateSuccess:zn(e.isCiStateSuccess),isResolvedAllReviewComments:zn(e.isResolvedAllReviewComments),isBranchOutOfDate:zn(e.isBranchOutOfDate),missingRequiredCheckNames:Kn(e.missingRequiredCheckNames),ciStatusAvailability:Jn(e.ciStatusAvailability),summary:Gn(e.summary)})),Xn=e=>{if(!In(e)||!In(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:zn(t.isConflicted),mergeableStatus:qn(t.mergeableStatus),isPassedAllCiJob:zn(t.isPassedAllCiJob),isCiStateSuccess:zn(t.isCiStateSuccess),isBranchOutOfDate:zn(t.isBranchOutOfDate),missingRequiredCheckNames:Kn(t.missingRequiredCheckNames)}},Zn=e=>In(e)?{state:Ln(e.state)||`open`,merged:zn(e.merged),isPullRequest:zn(e.isPullRequest),title:Ln(e.title),stateReason:Ln(e.stateReason)}:{state:`open`,merged:!1,isPullRequest:!1,title:``,stateReason:``},Qn=()=>({fetchItemBody:async e=>{let t=await Vn(`/api/itembody`,e);return In(t)?Ln(t.body):``},fetchComments:async e=>Hn(await Vn(`/api/comments`,e)),fetchPrFiles:async e=>Un(await Vn(`/api/prfiles`,e)),fetchPrCommits:async e=>Wn(await Vn(`/api/prcommits`,e)),fetchRelatedPrs:async e=>Yn(await Vn(`/api/relatedprs`,e)),fetchIssueState:async e=>Zn(await Vn(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>Xn(await Vn(`/api/pullrequeststatus`,e))}),$n=async e=>{let t=typeof e.text==`function`?await e.text().catch(()=>``):typeof e.json==`function`?JSON.stringify(await e.json().catch(()=>({}))):``;if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(In(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},er=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 $n(n));return await n.json()},tr=`/api/comment`,nr=e=>({id:Rn(e.id),author:Ln(e.author),body:Ln(e.body),createdAt:Ln(e.createdAt)}),rr=async e=>{let t=await fetch(tr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await $n(t),rateLimitResetAt:null};let n=await t.json();return In(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:In(n.comment)?{posted:!0,comment:nr(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},ir=`/api/upload`,ar=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},or=async e=>{let t=await fetch(ir,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t));let n=await t.json();if(!In(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},sr=`/api/addstory`,cr=async e=>{let t=await fetch(sr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t));let n=await t.json();return!In(n)||!Array.isArray(n.stories)?[]:n.stories.filter(In).map(e=>({id:Ln(e.id),name:Ln(e.name),color:Ln(e.color)}))},lr=`/api/reviewcomment`,ur=async e=>{let t=await fetch(lr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},dr=`/api/createissue`,fr=`/api/storycolor`,pr=async e=>{let t=await fetch(fr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},mr=async e=>{let t=await fetch(dr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(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},hr=`/api/reorderstory`,gr=async e=>{let t=await fetch(hr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},_r=`/api/deleteallcomments`,vr=async e=>{let t=await fetch(_r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},yr=`/api/deletestory`,br=async e=>{let t=await fetch(yr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},xr=`/api/renamestory`,Sr=async e=>{let t=await fetch(xr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Cr=`/api/storydescription`,wr=async e=>{let t=await fetch(Cr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Tr=e=>typeof e!=`object`||!e||Array.isArray(e)?null:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`)),Er=e=>In(e)?Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`number`)):null,Dr=e=>{if(!In(e))return null;let t=Er(e.todoByHumanCounts),n=Er(e.awaitingOwnerCounts);return t===null||n===null?null:{todoByHumanCounts:t,awaitingOwnerCounts:n}},Or=e=>Array.isArray(e)?e.filter(In):null,kr=e=>Array.isArray(e)?e.filter(In):null,Ar=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,disabledPjcodes:[],workflowStoryEntries:null,workflowAgentOptions:null,actionableCounts:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:Tr(n.projectUrls),fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null,nameWithOwnerByPjcode:Tr(n.nameWithOwnerByPjcode),disabledPjcodes:Array.isArray(n.disabledPjcodes)?n.disabledPjcodes.filter(e=>typeof e==`string`):[],workflowStoryEntries:Or(n.workflowStoryEntries),workflowAgentOptions:kr(n.workflowAgentOptions),actionableCounts:Dr(n.actionableCounts)}},jr=`/api/projectreadmeconfig`,Mr=async e=>{let t=`${jr}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await $n(n));let r=await n.json();return{maximumPreparingIssuesCount:In(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},Nr=`/api/renameissue`,Pr=async e=>{let t=await fetch(Nr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Fr=`/api/issuebody`,Ir=async e=>{let t=await fetch(Fr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Lr=`/api/issuecommentbody`,Rr=async e=>{let t=await fetch(Lr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},zr=`/api/setdependedissueurl`,Br=async e=>{let t=await fetch(zr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Vr=`/api/projectsettings`,Hr=async e=>{let t=await fetch(Vr,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await $n(t))},Ur=`console-comment-expanded:`,Wr=e=>{try{let t=localStorage.getItem(Ur+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}},Gr=(e,t)=>{try{localStorage.setItem(Ur+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Kr=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(Ur)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},qr=e=>`pv_overlay_${e}`,Jr=e=>e.projectItemId===``?e.itemId:e.projectItemId,Yr=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,Xr=(e,t,n)=>e.filter(e=>!Yr(t[Jr(e)],n)).length,Zr=(e,t,n)=>e.filter(e=>!Yr(t[Jr(e)],n)),Qr=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[Jr(t)];return i===void 0||i.ts<r?null:i.status??null},$r=(e,t,n,r,i)=>{let{closed:a,...o}=n,s={...e[t]??{},...o,...a===!0?{closedAtMs:i}:{},ts:i,mode:r};return{...e,[t]:s}},ei=(e,t,n)=>{let r=e[t];return r===void 0||!Number.isFinite(r.closedAtMs)?e:{...e,[t]:{...r,closedAtMs:n}}},ti=(e,t)=>{let{pjcode:n,projectItemId:r}=e;if(typeof n!=`string`||n===``||typeof r!=`string`||r===``||typeof t!=`object`||!t)return null;let{closedAtMs:i}=t;return typeof i!=`number`||!Number.isFinite(i)?null:{pjcode:n,key:r,closedAtMs:i}},ni=(e,t)=>{let n={...e};return delete n[t],n},ri=(e,t)=>{let n={};for(let[r,i]of Object.entries(e)){if(i.done!==!0){n[r]=i;continue}let e=t[i.mode];if(e==null){n[r]=i;continue}let a=Date.parse(e.generatedAt);Number.isNaN(a)||i.ts>=a?n[r]=i:e.items.some(e=>Jr(e)===r)||(n[r]=i)}return n},ii=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,ai=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(qr(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))ii(t)&&(r[e]=t);return r},oi=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(qr(e),JSON.stringify(t))},si=new Set,ci=(e,t)=>{let n=ti(e,t);if(n===null)return;let r=ai(n.pjcode),i=ei(r,n.key,n.closedAtMs);i!==r&&oi(n.pjcode,i);for(let e of si)e(n)},li=e=>{let[t,n]=(0,y.useState)(()=>({pjcode:e,overlay:ai(e)})),r=t.pjcode===e?t.overlay:ai(e);(0,y.useEffect)(()=>{n(t=>t.pjcode===e?t:{pjcode:e,overlay:ai(e)})},[e]);let i=(0,y.useCallback)((t,r)=>{n(n=>{let i=n.pjcode===e?n.overlay:ai(e),a=t(i);return(r||a!==i)&&oi(e,a),{pjcode:e,overlay:a}})},[e]),a=(0,y.useCallback)((e,t,n)=>{i(r=>$r(r,e,t,n,Date.now()),!0)},[i]),o=(0,y.useCallback)(e=>{i(t=>ni(t,e),!0)},[i]);return(0,y.useEffect)(()=>{let t=t=>{t.pjcode===e&&i(e=>ei(e,t.key,t.closedAtMs),!1)};return si.add(t),()=>{si.delete(t)}},[e,i]),{overlay:r,patchOverlay:a,revertOverlayEntry:o}},ui=`console-action-delivery-queue`,di=new Set,fi=()=>{try{let e=localStorage.getItem(ui);if(e!==null){let t=JSON.parse(e);return Array.isArray(t)?t:[]}return[]}catch{return[]}},pi=e=>{localStorage.setItem(ui,JSON.stringify(e))},mi=e=>{pi([...fi(),e])},hi=e=>{pi(fi().filter(t=>t.id!==e))},gi=async(e,t=!1)=>{let n=await fetch(e.apiPath,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e.requestBody,actionId:e.id}),...t?{keepalive:!0}:{}}),r=typeof n.json==`function`?await n.json().catch(async()=>typeof n.text==`function`?n.text():{}):typeof n.text==`function`?await n.text():{};if(!n.ok){let e=typeof r==`object`&&r&&`error`in r?String(r.error):typeof r==`string`&&r.length>0?r:`HTTP ${n.status}`;throw Error(e)}if(typeof r==`object`&&r&&`ok`in r&&r.ok===!1)throw Error(`error`in r?String(r.error):`Action failed`);return ci(e.requestBody,r),r},_i=async(e,t=!1)=>{if(!di.has(e.id)){di.add(e.id);try{let n=await gi(e,t);return hi(e.id),n}catch(t){throw di.delete(e.id),t}}},vi=`console-offline-action-queue`,yi=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.nameWithOwner==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},bi=e=>typeof e.pjcode==`string`&&typeof e.url==`string`&&typeof e.body==`string`,xi=()=>{try{let e=localStorage.getItem(vi);if(e===null)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=new Set(fi().map(e=>e.id));return t.filter(e=>yi(e)&&!n.has(e.id))}catch{return[]}},Si=e=>{localStorage.setItem(vi,JSON.stringify(e))},Ci=e=>{try{let t=localStorage.getItem(vi),n=t===null?[]:JSON.parse(t);Si((Array.isArray(n)?n:[]).filter(t=>typeof t!=`object`||!t||t.id!==e))}catch{Si([])}},wi=()=>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)}`,Ti=e=>e instanceof TypeError,Ei=class extends Error{sentStepCount;constructor(e,t){super(t instanceof Error?t.message:String(t)),this.name=`ConsoleActionPartiallySentError`,this.sentStepCount=e,this.cause=t}},Di=async(e,t=0)=>{for(let n=t;n<e.length;n+=1)try{await e[n]()}catch(e){throw n===0?e:new Ei(n,e)}},Oi=`Airplane mode`,ki=`This action requires a network connection. Turn off airplane mode and try again.`,Ai=e=>e instanceof Error&&e.message.length>0?e.message:String(e),ji=100,Mi=(e={isAirplaneModeOn:!1})=>{let t=(0,y.useRef)(e.isAirplaneModeOn);t.current=e.isAirplaneModeOn;let n=(0,y.useRef)(e.projectCode),r=(0,y.useRef)(new Set),i=(0,y.useRef)((()=>{let e=xi();return e.length===1?e.filter(e=>e.actionId===void 0&&e.apiPath!==`/api/comment`):[]})()),[a,o]=(0,y.useState)([]),[s,c]=(0,y.useState)([]),[l,u]=(0,y.useState)(xi),d=(0,y.useRef)(l);d.current=l;let f=(0,y.useRef)(new Map),p=(0,y.useRef)(()=>{}),m=(0,y.useRef)(0),[h,g]=(0,y.useState)({status:`idle`,attempt:0}),[_,v]=(0,y.useState)(0),b=(0,y.useCallback)(e=>{c(t=>[...t,{id:wi(),createdAt:Date.now(),...e}])},[]),x=(0,y.useCallback)(({payloads:e,message:t,color:n})=>{let r=Date.now(),i=e.map(e=>{let i={...e};return delete i.actionId,{id:wi(),message:t,color:n,enqueuedAt:r,...i}});Si([...xi(),...i]),u(e=>{let t=[...e,...i];return Si(t),t})},[]),S=(0,y.useCallback)((e,n,r)=>{let i=m.current+1;m.current=i;let a=r??wi(),o=e=>{c(t=>{let n=t.findIndex(e=>e.id===a);return n===-1?[...t,{id:a,createdAt:Date.now(),...e}]:t.map((t,r)=>r===n?{...t,...e}:t)})},s=e.offline??[],l=t=>{for(let e of s)e.id!==void 0&&(hi(e.id),Ci(e.id));x({payloads:t,message:e.message,color:e.color}),g({status:`offline`,attempt:i})};if(t.current){let t=s.slice(n);t.length>0?l(t):(e.revertAdvance?.(),e.revertOptimistic?.(),o({message:Oi,reason:ki}),g({status:`failed`,attempt:i}))}else g({status:`unconfirmed`,attempt:i}),(e.commitWithActionId===void 0?e.commit(n):e.commitWithActionId(n,String(s[0]?.id??``))).then(()=>{for(let e of s){let t=e.id??``;hi(t),Ci(t)}g({status:`succeeded`,attempt:i})}).catch(t=>{let r=t instanceof Ei,c=r?t.sentStepCount:n,u=s.slice(c),d=r?t.cause:t;if(Ti(d)&&u.length>0)l(u);else{for(let e of s)e.id!==void 0&&(hi(e.id),Ci(e.id));o({message:e.message,reason:Ai(d),retry:()=>p.current(e,c,a)}),g({status:`failed`,attempt:i})}})},[x]);p.current=S,(0,y.useEffect)(()=>{if(n.current===void 0||n.current===e.projectCode){n.current=e.projectCode;return}n.current=e.projectCode;let t=Array.from(f.current.values());for(let e of t)e.timer!==null&&clearInterval(e.timer),f.current.delete(e.id),o(t=>t.filter(t=>t.id!==e.id)),S(e.action,0)},[e.projectCode,S]);let C=(0,y.useCallback)(e=>{let t=f.current.get(e);t!==void 0&&(t.timer!==null&&clearInterval(t.timer),f.current.delete(e),o(t=>t.filter(t=>t.id!==e)),Kr(),S(t.action,0))},[S]),w=(0,y.useCallback)(e=>{let t=f.current.get(e);if(t!==void 0){t.timer!==null&&clearInterval(t.timer),f.current.delete(e),o(t=>t.filter(t=>t.id!==e));for(let e of t.action.offline??[]){let t=e.id??``;hi(t),Ci(t)}t.action.revertAdvance?.(),t.action.revertOptimistic?.()}},[]),T=(0,y.useCallback)(e=>{C(e)},[C]),ee=(0,y.useCallback)(e=>{c(t=>t.filter(t=>t.id!==e))},[]),E=(0,y.useCallback)((e,t)=>{b({message:e,reason:t})},[b]),D=(0,y.useCallback)(e=>{u(t=>{let n=t.filter(t=>t.id!==e);return Si(n),n})},[]),O=(0,y.useCallback)(async e=>{let t=d.current.find(t=>t.id===e);if(t!==void 0)try{if(t.apiPath===`/api/comment`&&bi(t.requestBody)){let n=await rr(t.requestBody);if(n.posted){D(e);return}let r=n.rateLimitResetAt===null?``:` Rate limit resets at ${n.rateLimitResetAt}.`;b({message:t.message,reason:`${n.error}.${r}`,retry:()=>void O(e)});return}let n=await er(t.apiPath,t.requestBody);ci(t.requestBody,n),D(e)}catch(n){Ti(n)?b({message:t.message,reason:`Still offline — action is still held in the queue`}):(b({message:t.message,reason:Ai(n)}),D(e))}},[b,D]),te=(0,y.useCallback)(e=>{v(e=>e+1);let t=wi(),n=Date.now(),r={id:t,createdAt:n,action:e,startedAt:n,timer:null},i=(e.offline??[]).map(t=>{let r=typeof t.requestBody.actionId==`string`?t.requestBody.actionId:wi(),i={id:r,actionId:r,message:e.message,color:e.color,enqueuedAt:n,...t};return mi(i),i}),a=i.length>0?{...e,offline:i}:e;i.length>0&&Si([...xi(),...i]);let s={...r,action:a};f.current.set(t,s),o(r=>[...r,{id:t,createdAt:n,message:e.message,color:e.color}]),e.advance(),e.optimistic?.(),r.timer=setInterval(()=>{Date.now()-r.startedAt>=5e3&&C(t)},ji)},[C]);return(0,y.useLayoutEffect)(()=>{let e=()=>{let t=fi(),n=t.length===0&&i.current.length===1?i.current:t;for(let t of n)r.current.has(t.id)||(r.current.add(t.id),_i(t).then(()=>Ci(t.id)).catch(n=>{b({message:t.message,reason:Ai(n),retry:()=>void e()})}))},t=()=>{let e=Array.from(f.current.values());for(let t of e){t.timer!==null&&clearInterval(t.timer),f.current.delete(t.id),o(e=>e.filter(e=>e.id!==t.id));let e=t.action.offline??[];e.length===0&&t.action.commit(0).catch(e=>b({message:t.action.message,reason:Ai(e)}));for(let n of e){let e=fi().find(e=>e.id===n.id);if(e!==void 0){if(r.current.has(e.id))continue;r.current.add(e.id),_i(e,!0).then(()=>Ci(e.id)).catch(e=>b({message:t.action.message,reason:Ai(e)}))}}}};e();let n=()=>{document.visibilityState===`hidden`&&t()};return window.addEventListener(`pagehide`,t),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`pagehide`,t),document.removeEventListener(`visibilitychange`,n),t()}},[b]),{pending:a,error:s,offlineActions:l,writeState:h,enqueueSequence:_,enqueue:te,offlineActionsCreate:x,showError:E,undo:w,dismiss:T,dismissError:ee,confirmOfflineAction:O,discardOfflineAction:D}},Ni=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},Pi=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},Fi=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)=>{let _=(0,y.useRef)(0),v=(0,y.useRef)(null),b=(0,y.useRef)(0),x=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!e||i===null){_.current=0,v.current=null,x.current=null;return}let y=f!==b.current;y&&(b.current=f);let S=a.filter(e=>(o[e]??15)>0),C=x.current,w=C!==null&&C.pjcode===i&&S.some(e=>!C.pjcodesWithMinutes.includes(e));x.current={pjcode:i,pjcodesWithMinutes:S};let T=ce({actionNewlyEnqueued:y,timerElapsed:t(o[i]??15),remainingCountIsZero:n===0&&r===0,snapshotsReady:s&&c&&!l&&!u,explicitlySelectedPjcodeMatchesCurrent:d!==null&&i===d,taskOpen:p!==null,dialogOpen:m,aProjectGainedRemainingMinutesSinceTheCurrentProjectWasLastEvaluated:w,pjcode:i,pjcodes:a,projectMinutes:o,skipCount:_.current,evaluatedPjcode:v.current,projectTodoByHumanCounts:h,projectAwaitingOwnerCounts:g});_.current=T.nextSkipCount,v.current=T.nextEvaluatedPjcode,T.targetPjcode!==null&&Ni(`/projects/${T.targetPjcode}/todo-by-human`)},[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g])},Ii=`tdpm-awaiting-owner-list-visibility-settings`,Li=()=>({showExecutiveSummaryAndActionButton:!0}),Ri=()=>{if(typeof localStorage>`u`)return Li();let e=localStorage.getItem(Ii);if(e===null)return Li();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return Li();let n=t;return{showExecutiveSummaryAndActionButton:typeof n.showExecutiveSummaryAndActionButton!=`boolean`||n.showExecutiveSummaryAndActionButton}}catch{return Li()}},zi=e=>{typeof localStorage<`u`&&localStorage.setItem(Ii,JSON.stringify(e))},Bi=e=>{let[t,n]=(0,y.useState)(()=>Ri().showExecutiveSummaryAndActionButton),[r,i]=(0,y.useState)(t);return(0,y.useEffect)(()=>{e&&i(t)},[e,t]),{showExecutiveSummaryAndActionButton:t,draftShowExecutiveSummaryAndActionButton:r,toggleDraft:(0,y.useCallback)(e=>{i(e)},[]),save:(0,y.useCallback)(()=>{i(e=>(zi({showExecutiveSummaryAndActionButton:e}),n(e),e))},[])}},Vi=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Hi=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ui=e=>Array.isArray(e)?e.filter(Vi).map(e=>({...e,relatedOpenPullRequestUrls:Hi(e.relatedOpenPullRequestUrls)})):[],Wi=e=>!Vi(e)||!Array.isArray(e.items)?[]:Ui(e.items),Gi=e=>Array.isArray(e)?e.filter(Vi):[],Ki=e=>Array.isArray(e)?e.filter(Vi).map(e=>({...e,items:Ui(e.items)})):[],qi=e=>({items:Wi(e),generatedAt:Vi(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Vi(e)?Gi(e.statusOptions):[],agentOptions:Vi(e)?Gi(e.agentOptions):[],storyOptions:Vi(e)?Gi(e.storyOptions):[],storyColors:Vi(e)&&Vi(e.storyColors)?e.storyColors:{},stories:Vi(e)?Ki(e.stories):[],defaultNameWithOwner:Vi(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Vi(e)?Hi(e.storyOrder):[],timerEndsAt:Vi(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Vi(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),Ji=()=>{let e={};for(let t of A)e[t.name]=null;return e},Yi=(e,t)=>`/projects/${e}/${t}/list.json`,Xi=6e4,Zi=`console-list-v1`,Qi=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(Zi).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)}},$i=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(Zi)).match(e);return t===void 0?null:{...qi(await t.json()),fromCache:!0}}catch{return null}},ea=async e=>{let t=await Promise.all(A.map(async t=>({tabName:t.name,snapshot:await $i(Yi(e,t.name))}))),n=Ji();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},ta=async(e,t)=>{let n=Yi(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return Qi(n,t),{snapshot:{...qi(t),fromCache:!1},error:null}}catch(e){let t=await $i(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},U=async e=>{await Promise.all(A.map(async t=>{let n=Yi(e,t.name);try{let e=await fetch(n);if(!e.ok)return;Qi(n,await e.json())}catch{}}))},na=async e=>{let t=await Promise.all(A.map(async t=>{let{snapshot:n,error:r}=await ta(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=Ji(),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}},ra=(e,t=null)=>{let n=(0,y.useRef)(new Map),[r,i]=(0,y.useState)(Ji),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(e),d=(0,y.useRef)(e);if((0,y.useLayoutEffect)(()=>{d.current=e},[e]),l!==e){u(e);let t=e===null?null:n.current.get(e)??null;i(t??Ji()),t!==null&&o(!1)}return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=Ji();for(let t of A){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(Ji()),o(!1),c(`No project specified in the URL path.`),()=>{r=!0};let s=n.current.has(e);ea(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(Ji()))});let l=()=>{na(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,Xi);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 ta(e,t);if(r===null)return;if(d.current===e){i(i=>{let a={...i,[t]:r};return n.current.set(e,a),a});return}let a=n.current.get(e)??Ji();n.current.set(e,{...a,[t]:r})},[e])}},ia=(e,t,n,r,i)=>{(0,y.useEffect)(()=>{if(!i||r)return;let a=n.filter(n=>n!==e&&n!==t);if(a.length!==0)for(let e of a)U(e).catch(()=>{})},[i,r,e,t,n]),(0,y.useEffect)(()=>{if(!i||r)return;let t=n.filter(t=>t!==e);if(t.length===0)return;let a=setInterval(()=>{for(let e of t)U(e).catch(()=>{})},Xi);return()=>{clearInterval(a)}},[i,r,e,n])},aa=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)}},oa=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},sa=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=oa(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)}},ca=(e=null)=>(0,y.useMemo)(()=>{let t=Qn(),n={client:t,body:new aa(t.fetchItemBody),comments:new aa(t.fetchComments),files:new aa(t.fetchPrFiles),commits:new aa(t.fetchPrCommits),relatedPrs:new aa(t.fetchRelatedPrs),state:new aa(t.fetchIssueState),prStatus:new aa(t.fetchPullRequestStatus)};return e!==null&&sa(n,e),n},[e]),la=0,ua=500,da=2e3,fa=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:da});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},pa=(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)},ma=(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+la);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=fa(()=>{for(let t of i)pa(e,t)})},ua);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},ha=e=>{let[t,n]=(0,y.useState)(null);return(0,y.useEffect)(()=>{t!==null&&e!==t&&n(null)},[e,t]),{explicitlySelectedPjcode:t,notifyExplicitSelection:(0,y.useCallback)(e=>{n(e)},[])}},ga=`/api/features`,_a=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(ga).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},va=(e,t)=>{let n=A.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<A.length;e+=1){let n=A[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},ya=e=>{let t=A.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},ba=new Set(A.map(e=>e.name)),xa=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return ba.has(n)?n:null},Sa=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},Ca=`#settings`,wa=(e,t,n=new Set,r)=>{let i=(0,y.useCallback)(()=>{let e=ya(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:xa(window.location.pathname)??e,selectedItemKey:Sa(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=xa(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=ya(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=>{typeof window>`u`||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}},Ta=`/api/review`,Ea=`/api/triage`,Da=`/api/intmux`,Oa=(e,t,n,r,i,a)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId,expectedStatusName:t.status,...a===void 0?{}:{actionId:a}};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:Te(i),expectedStatusName:t.status,...a===void 0?{}:{actionId:a},...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:Se,expectedStatusName:t.status,...a===void 0?{}:{actionId:a}}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:Ce,issueCommentBody:we(n),expectedStatusName:t.status,...a===void 0?{}:{actionId:a}}},ka=(e,t,n,r)=>{let{actionId:i,...a}=r??{};return{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,expectedStatusName:t.status,...a,...i===void 0?{}:{actionId:i}}},Aa=(e,t,n)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId,expectedStatusName:t.status,...n===void 0?{}:{actionId:n}}),ja=(e,t,n,r)=>({pjcode:e,url:t.url,body:n,...r===void 0?{}:{actionId:r}}),Ma=(e,t)=>({issueUrl:e.url,...t===void 0?{}:{actionId:t}}),Na=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,Pa=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Fa=()=>Error(`No project specified in the URL path.`),Ia=(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.useRef)(new Set),a=(0,y.useCallback)(async(t,n,i,a=[],o)=>{if(e===null)throw Fa();await er(Ta,Oa(e,t,n,i,a,o)),r(t)},[e,r]),o=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,{pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,actionId:i??Na()}),r(t)},[e,r]),s=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,{pjcode:e,action:`set_agent`,issueUrl:t.url,projectItemId:t.projectItemId,agentOptionId:n.id,actionId:i??Na()}),r(t)},[e,r]),c=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();let a=await er(Ea,{pjcode:e,action:`set_story`,issueUrl:t.url,projectItemId:t.projectItemId,storyOptionId:n.id,actionId:i??Na()});return r(t),a},[e,r]),l=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,ka(e,t,`set_status`,{statusName:n.name,actionId:i??Na()})),r(t)},[e,r]),u=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,ka(e,t,`set_next_action_date`,{nextActionDate:n,actionId:i??Na()})),r(t)},[e,r]),d=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Ea,ka(e,t,`set_next_action_hour`,{nextActionHour:n,actionId:i??Na()})),r(t)},[e,r]),f=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();await er(Da,Aa(e,t,i??Na())),r(t)},[e,r]),p=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();let a={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,actionId:i??Na()};ci(a,await er(Ea,a)),r(t)},[e,r]),m=(0,y.useCallback)(async(e,t)=>{try{await l(e,t)}catch(e){throw new Ei(1,e)}await n?.()},[l,n]),h=(0,y.useCallback)(async(t,i,a=0,o)=>{if(e===null)throw Fa();let s=o??Na();if(a>0){await m(t,i);return}let c=await er(Ea,ka(e,t,`set_status`,{statusName:i.name,commentBody:`ok`,actionId:s,setStatusWhenCommentFails:!0}));if(r(t),Pa(c)&&c.commentPosted===!1&&c.ok===!1)throw Error(`Comment not posted — ${String(c.error??`Comment was not posted`)}. Status was changed. Re-post: ok`);await n?.()},[e,r,n,m]),g=(0,y.useCallback)(async(t,n,i)=>{if(e===null)throw Fa();let a=await rr(ja(e,t,n,i));if(!a.posted){let e=a.rateLimitResetAt===null?``:` Rate limit resets at ${a.rateLimitResetAt}.`;throw Error(`${a.error}.${e}`)}return r(t),a.comment},[e,r]),_=(0,y.useCallback)(async(t,a,o,s)=>{if(e===null)throw Fa();let c=s??Na(),l=i.current.has(c);i.current.add(c);let u=await er(Ea,ka(e,t,`set_status`,{statusName:o.name,commentBody:a,actionId:c}));if(!l&&Pa(u)&&Object.keys(u).length===0){let n=await rr(ja(e,t,a));if(!n.posted)throw Error(n.error);return await m(t,o),n.comment}if(!Pa(u)||u.ok!==!0||u.commentPosted===!1)throw Error(String(Pa(u)?u.error??`Comment was not posted`:`Comment was not posted`));return r(t),await n?.(),{id:0,author:``,body:a,createdAt:new Date().toISOString()}},[e,r,m,n]),v=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=ar(new Uint8Array(await n.arrayBuffer()));return or({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),b=(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw Fa();await ur({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),x=(0,y.useCallback)(async(e,t)=>{await Pr({issueUrl:e.url,newTitle:t})},[]),S=(0,y.useCallback)(async(e,t)=>{try{await Ir({issueUrl:e.url,body:t})}finally{r(e)}},[r]),C=(0,y.useCallback)(async(e,t,n)=>{try{await Rr({issueUrl:e.url,commentId:t,body:n})}finally{r(e)}},[r]),w=(0,y.useCallback)(async(e,t)=>{await vr(Ma(e,t)),r(e)},[r]),T=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fa();await Br({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e]),ee=(0,y.useCallback)(async(t,n)=>{if(e===null)throw Fa();await Br({pjcode:e,issueUrl:t.url,dependedIssueUrl:n,projectItemId:t.projectItemId,replaceExisting:!0})},[e]);return(0,y.useMemo)(()=>({reviewPullRequest:a,setNextActionDate:o,setStory:c,setAgent:s,setStatus:l,setNextActionDateValue:u,setNextActionHourValue:d,setInTmuxByHuman:f,closeIssue:p,okAndMoveToAwaitingWorkspace:h,addComment:g,addCommentAndMoveToAwaitingWorkspace:_,uploadAttachment:v,addInlineReviewComment:b,issueRename:x,issueBodyUpdate:S,issueCommentBodyUpdate:C,deleteAllComments:w,setDependedIssueUrl:T,replaceDependedIssueUrl:ee,onAfterMoveToAwaitingWorkspace:n}),[a,o,c,s,l,u,d,f,p,h,g,_,v,b,x,S,C,w,T,ee,n])},La=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},Ra=()=>{let[e,t]=(0,y.useState)(()=>La(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(La(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},za=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ba=(e,t)=>{let[n,r]=(0,y.useState)([]),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)([]),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!0),[x,S]=(0,y.useState)(null),C=(0,y.useRef)({pjcodes:n,projectUrls:i,fleetTaskCreateUrl:o,nameWithOwnerByPjcode:c,disabledPjcodes:u,workflowStoryEntries:f,workflowAgentOptions:m,actionableCounts:g});return(0,y.useEffect)(()=>{let e=!1;return b(!0),S(null),Ar().then(t=>{e||(C.current={pjcodes:t.pjcodes,projectUrls:t.projectUrls,fleetTaskCreateUrl:t.fleetTaskCreateUrl,nameWithOwnerByPjcode:t.nameWithOwnerByPjcode,disabledPjcodes:t.disabledPjcodes,workflowStoryEntries:t.workflowStoryEntries,workflowAgentOptions:t.workflowAgentOptions,actionableCounts:t.actionableCounts},r(t.pjcodes),a(t.projectUrls),s(t.fleetTaskCreateUrl),l(t.nameWithOwnerByPjcode),d(t.disabledPjcodes),p(t.workflowStoryEntries),h(t.workflowAgentOptions),_(t.actionableCounts),b(!1))}).catch(t=>{e||(S(t instanceof Error?t:Error(String(t))),b(!1))}),()=>{e=!0}},[]),(0,y.useEffect)(()=>{if(!e||t)return;let n=!1,i=e=>{let t=C.current;za(t.pjcodes,e.pjcodes)||(C.current={...C.current,pjcodes:e.pjcodes},r(e.pjcodes)),za(t.projectUrls,e.projectUrls)||(C.current={...C.current,projectUrls:e.projectUrls},a(e.projectUrls)),za(t.fleetTaskCreateUrl,e.fleetTaskCreateUrl)||(C.current={...C.current,fleetTaskCreateUrl:e.fleetTaskCreateUrl},s(e.fleetTaskCreateUrl)),za(t.nameWithOwnerByPjcode,e.nameWithOwnerByPjcode)||(C.current={...C.current,nameWithOwnerByPjcode:e.nameWithOwnerByPjcode},l(e.nameWithOwnerByPjcode)),za(t.disabledPjcodes,e.disabledPjcodes)||(C.current={...C.current,disabledPjcodes:e.disabledPjcodes},d(e.disabledPjcodes)),za(t.workflowStoryEntries,e.workflowStoryEntries)||(C.current={...C.current,workflowStoryEntries:e.workflowStoryEntries},p(e.workflowStoryEntries)),za(t.workflowAgentOptions,e.workflowAgentOptions)||(C.current={...C.current,workflowAgentOptions:e.workflowAgentOptions},h(e.workflowAgentOptions)),za(t.actionableCounts,e.actionableCounts)||(C.current={...C.current,actionableCounts:e.actionableCounts},_(e.actionableCounts))},o=setInterval(()=>{Ar().then(e=>{n||i(e)}).catch(e=>{n||S(e instanceof Error?e:Error(String(e)))})},Xi);return()=>{n=!0,clearInterval(o)}},[e,t]),{pjcodes:n,projectUrls:i,fleetTaskCreateUrl:o,nameWithOwnerByPjcode:c,disabledPjcodes:u,workflowStoryEntries:f,workflowAgentOptions:m,actionableCounts:g,isLoading:v,error:x}},Va=e=>(0,y.useCallback)(t=>{Kr(),e(t)},[e]),Ha=()=>typeof window<`u`&&window.location.hash===`#settings`,Ua=e=>{let[t,n]=(0,y.useState)(Ha),[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=>Mr(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===Ca;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({},``,Ca)),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])=>Hr({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}},Wa=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,[])}},Ga=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,Ka=/^From:\s+:robot:/m,qa=/^##\s/m,Ja=e=>{let t=Ga.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=Ka.exec(n),i=qa.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},Ya=e=>{if(e.length===0)return null;let t=e[e.length-1],n=Ja(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},Xa=e=>`${e.repo}#${e.number}`,Za=(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=Xa(n),a=t.peek(e);if(a!==void 0){let e=Ya(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e})}else t.load(e,n.url).then(e=>{if(r)return;let t=Ya(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},Qa=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},$a=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},eo=(e,t,n,r)=>e===`previous`?t<=0:t>=n-r,to=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)return{scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth};t=t.parentElement}return null},no=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=null,o=e=>{if(e.touches.length!==1){i=!1;return}a=to(e.target);let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},s=e=>{if(!i)return;let t=e.touches[0];$a(t.clientX-n,t.clientY-r)&&(i=!1)},c=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let o=e.changedTouches[0],s=Qa(o.clientX-n,o.clientY-r);s!==null&&(a===null||eo(s,a.scrollLeft,a.scrollWidth,a.clientWidth))&&t.current(s)};return e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),e.addEventListener(`touchend`,c,{passive:!0}),()=>{e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s),e.removeEventListener(`touchend`,c)}},[]),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},ro=e=>(0,y.useCallback)(t=>{Kr(),e(t)},[e]),io=(e,t,n,r,i)=>{let a=(0,y.useRef)(void 0),o=(0,y.useRef)(!1);(0,y.useEffect)(()=>{e?(a.current!==t&&(a.current=t,o.current=t!==null),o.current&&r===null&&n.length!==0&&(o.current=!1,i(n[0].projectItemId))):(a.current=t,o.current=!1)},[e,t,n,r,i])},ao=()=>{let[e,t]=(0,y.useState)(ue),[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=>(N(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}},oo=`console-comment-drafts`,so=()=>{try{let e=localStorage.getItem(oo);if(e===null)return new Map;let t=JSON.parse(e);return Array.isArray(t)?new Map(t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&typeof e[1]==`string`)):new Map}catch(e){return console.error(`Failed to load comment drafts from storage:`,e),new Map}},co=e=>{try{localStorage.setItem(oo,JSON.stringify([...e]))}catch(e){console.error(`Failed to save comment drafts to storage:`,e)}},lo=(e,t,n)=>{let r=n===null?null:Date.parse(n);return e.map(e=>{let n=e.openItemCount,i=(e.items??[]).map(e=>{let i=t[Jr(e)]?.closedAtMs;return!(typeof i==`number`&&Number.isFinite(i)&&(r===null||!Number.isNaN(r)&&r<i))||e.isClosed===!0?{...e,isClosed:e.isClosed}:(n=Math.max(0,n-1),{...e,isClosed:!0})});return{...e,items:i,openItemCount:n}})},uo=e=>e.isClosed===void 0?e.status!==`Done`:!e.isClosed,fo=(e,t,n)=>{let r=e.find(e=>(e.items??[]).some(e=>e.projectItemId===t)),i=(r?.items??[]).find(e=>e.projectItemId===t);if(r===void 0||i===void 0||r.storyOptionId===n.id)return e;let a=+!!uo(i);return e.map(e=>e.storyOptionId===r.storyOptionId?{...e,items:(e.items??[]).filter(e=>e.projectItemId!==t),openItemCount:Math.max(0,e.openItemCount-a)}:e.storyOptionId===n.id?{...e,items:[...e.items??[],{...i,story:n.name}],openItemCount:e.openItemCount+a}:e)},po=e=>{if(typeof e!=`object`||!e)return;let{storySetAtMs:t}=e;if(typeof t==`number`&&Number.isFinite(t))return t},mo=(e,t)=>{if(t===null)return!0;let n=Date.parse(t);return!Number.isNaN(n)&&n<e.storySetAtMs},ho=(e,t)=>e.filter(e=>mo(e,t)),go=(e,t,n)=>ho(t,n).reduce((e,t)=>fo(e,t.projectItemId,t.target),e),_o=(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},vo=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},yo=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},bo=(e,t,n)=>e===null?null:t===`loaded-live`?n?e:null:e,xo=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
17
17
  `)?`${e}${t}\n`:`${e}\n${t}\n`,So=(e,t)=>{let n=`![uploading ${t}]()`;return`${e.length===0?``:e.replace(/\n*$/,`
18
18
  `)}\n\n\n${n}\n`},Co=(e,t,n)=>{let r=`![uploading ${t}]()`,i=e.indexOf(r);return i===-1?xo(e,n):e.slice(0,i)+n+e.slice(i+r.length)},wo=(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]===`
19
19
  `;)i--,a++;let o=+(e[r+n.length]===`
@@ -6,7 +6,7 @@
6
6
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
7
7
  <link rel="manifest" href="/manifest.webmanifest" />
8
8
  <title>TDPM Console</title>
9
- <script type="module" crossorigin src="/assets/index-CBQvsEl5.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-Dj4P8bP5.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-CncefgjK.css">
11
11
  </head>
12
12
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "github-issue-tower-defence-management",
3
- "version": "2.201.4",
3
+ "version": "2.201.5",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {