github-issue-tower-defence-management 2.107.1 → 2.107.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/adapter/entry-points/console/ui-dist/assets/{index-BL4Or0Cn.js → index-D9wVV6wh.js}
RENAMED
|
@@ -10,7 +10,7 @@ Error generating stack: `+e.message+`
|
|
|
10
10
|
|
|
11
11
|
`),_e=`In Tmux by human`,ve=`Awaiting Workspace`,ye=[`In Tmux by human`,`Todo by human`,ve],be=e=>e===`todo-by-human`||e===`todo-by-agent`,xe=({statusOptions:e,onOkAndAwaitingWorkspace:t})=>{let n=e.find(e=>e.name.toLowerCase()===ve.toLowerCase());if(n===void 0)return null;let r=j(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`})})},Se={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`]}},Ce=({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`,we=({size:e=12,...t})=>{let n=Ce(t),r=Se[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))})},Te=({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)(we,{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:O(e.createdAt),children:ie(e.createdAt,n)})]}),e.status!==null&&e.status!==``&&(0,x.jsx)(`span`,{className:`console-item-status-badge`,style:ce(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]})})]})}),Ee=({story:e,count:t,colorEnum:n})=>{let r=j(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})]})},De=({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)(Ee,{story:e.story,count:e.count,colorEnum:F(t,e.story)})},`group:${e.story}`);let a=c?.[e.item.projectItemId]??null;return(0,x.jsxs)(`li`,{className:`console-list-row`,children:[(0,x.jsx)(Te,{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)(xe,{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]}),Oe=({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))]})})},ke=e=>({...ce(e),fontSize:`12px`,whiteSpace:`nowrap`,flexShrink:0}),Ae=({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)(we,{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:ke(a?.color??null),children:e.status}),e.agent!==null&&e.agent!==``&&(0,x.jsx)(`span`,{className:`console-queued-item-badge`,style:ke(o?.color??null),children:e.agent})]}),(0,x.jsx)(`span`,{className:`console-queued-item-actions`})]})},je=({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)(Ee,{story:e.story,count:e.count,colorEnum:F(t,e.story)})},`group:${e.story}`):(0,x.jsx)(`li`,{className:`console-list-row`,children:(0,x.jsx)(Ae,{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]}),Me=Object.keys(se),Ne=({placeholder:e,emptyValueError:t,onSubmit:n,onCancel:r,initialValue:i=``,submitLabel:a=`Create`,selectAllOnFocus:o=!1,multiline:s=!1})=>{let[c,l]=(0,y.useState)(i),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),m=(0,y.useRef)(null),h=(0,y.useRef)(null),g=(0,y.useRef)(o);(0,y.useEffect)(()=>{s?(h.current?.focus(),g.current&&h.current?.select()):(m.current?.focus(),g.current&&m.current?.select())},[s]);let _=async()=>{let e=c.trim();if(e.length===0&&t!==``){p(t);return}d(!0),p(null);try{await n(e)}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}};return(0,x.jsxs)(`form`,{className:`console-inline-input-form`,onSubmit:e=>{e.preventDefault(),_()},children:[s?(0,x.jsx)(`textarea`,{ref:h,className:`console-inline-input-form-textarea`,placeholder:e,value:c,onChange:e=>l(e.target.value),disabled:u,rows:3}):(0,x.jsx)(`input`,{ref:m,type:`text`,className:`console-inline-input-form-input`,placeholder:e,value:c,onChange:e=>l(e.target.value),disabled:u}),(0,x.jsx)(`button`,{type:`submit`,className:`console-op-button`,disabled:u,children:u?`${a.replace(/e$/,``)}ing…`:a}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:r,disabled:u,children:`Cancel`}),f!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:f})]})},Pe=({storyName:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Ne,{placeholder:`Issue title`,emptyValueError:`Title is required`,onSubmit:n=>t(e,n),onCancel:n}),Fe=({currentName:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Ne,{placeholder:`Story name`,emptyValueError:`Story name is required`,initialValue:e,submitLabel:`Rename`,selectAllOnFocus:!0,onSubmit:t,onCancel:n}),Ie=({currentDescription:e,onSubmit:t,onCancel:n})=>(0,x.jsx)(Ne,{placeholder:`Story description`,emptyValueError:``,initialValue:e,submitLabel:`Save`,selectAllOnFocus:!0,multiline:!0,onSubmit:t,onCancel:n}),Le=({onSelectColor:e,disabled:t})=>(0,x.jsx)(`div`,{className:`console-story-color-palette`,children:Me.map(n=>{let r=se[n];return(0,x.jsx)(`button`,{type:`button`,className:`console-story-color-swatch`,"aria-label":n===`GRAY`?`${n} (disable)`:n,style:{backgroundColor:r.dot},onClick:()=>e(n),disabled:t,children:n===`GRAY`&&(0,x.jsx)(`span`,{className:`console-story-color-swatch-label`,children:`disable`})},n)})}),Re=({storyName:e,isDeleting:t,deleteError:n,onConfirm:r,onCancel:i})=>(0,x.jsxs)(`div`,{className:`console-story-delete-confirm`,role:`dialog`,"aria-modal":`true`,"aria-label":`Confirm story deletion`,children:[(0,x.jsxs)(`p`,{className:`console-story-delete-confirm-message`,children:[`Delete story option "`,e,`" from the GitHub custom field? Tasks assigned to this story will not be deleted.`]}),n!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:n}),(0,x.jsxs)(`div`,{className:`console-story-delete-confirm-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,onClick:r,disabled:t,children:t?`Deleting…`:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:i,disabled:t,children:`Cancel`})]})]}),ze=({items:e})=>(0,x.jsx)(`ul`,{className:`console-story-task-list`,children:e.map(e=>(0,x.jsxs)(`li`,{className:`console-story-task-row`,children:[(0,x.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`console-story-task-title`,children:e.title}),(0,x.jsx)(`span`,{className:`console-story-task-status`,children:e.status??`—`}),(0,x.jsx)(`span`,{className:`console-story-task-agent`,children:e.agent??`—`}),(0,x.jsx)(`span`,{className:`console-story-task-depended-urls`,children:e.dependedIssueUrls.length>0?e.dependedIssueUrls.join(`, `):`—`}),(0,x.jsx)(`span`,{className:`console-story-task-next-action-date`,children:e.nextActionDate===null?`—`:e.nextActionDate.slice(0,10)}),(0,x.jsx)(`span`,{className:`console-story-task-next-action-hour`,children:e.nextActionHour===null?`—`:String(e.nextActionHour)})]},e.url))}),Be=({stories:e,isLoading:t,error:n,showGray:r,onCreateIssue:i,onAddStory:a,onSelectColor:o,onToggleGray:s,onReorderStory:c,onDeleteStory:l,onRenameStory:u,onUpdateDescription:d,optimisticColors:f,colorChangeInFlight:p,colorErrors:m})=>{let[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),[b,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(null),[T,ee]=(0,y.useState)({}),[te,E]=(0,y.useState)(null),[ne,re]=(0,y.useState)({}),[ie,D]=(0,y.useState)(null),[O,ae]=(0,y.useState)(null),oe=e=>T[e]??{inProgress:!1,error:null},k=async(e,t)=>{ee(t=>({...t,[e]:{inProgress:!0,error:null}}));try{await c(e,t),ee(t=>({...t,[e]:{inProgress:!1,error:null}}))}catch(t){ee(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 A=e=>{g(h===e?null:e)},se=async(e,t)=>{await i(e,t),g(null)},ce=e=>{w(C===e?null:e)},le=(e,t)=>{w(null),o(e,t)},M=e=>{E(e)},N=async e=>{re(t=>({...t,[e]:{isDeleting:!0,error:null}}));try{await l(e),E(null),re(t=>({...t,[e]:{isDeleting:!1,error:null}}))}catch(t){re(n=>({...n,[e]:{isDeleting:!1,error:t instanceof Error?t.message:String(t)}}))}},ue=()=>{E(null),re({})},P=e=>{D(ie===e?null:e)},F=async(e,t)=>{await u(e,t),D(null)},de=e=>{ae(O===e?null:e)},fe=async(e,t)=>{await d(e,t),ae(null)},I=r?e:e.filter(e=>e.color!==`GRAY`),pe=e.some(e=>e.color===`GRAY`);return(0,x.jsxs)(`div`,{className:`console-story-list-container`,children:[I.length===0?(0,x.jsx)(`p`,{className:`console-list-empty`,children:`No active stories`}):(0,x.jsx)(`ul`,{className:`console-story-list`,children:I.map((e,t)=>{let n=j(f[e.storyOptionId]??e.color),r=h===e.storyOptionId,i=C===e.storyOptionId,a=p===e.storyOptionId,o=m[e.storyOptionId]??null,{inProgress:s,error:c}=oe(e.storyOptionId),l=t===0,u=t===I.length-1,d=te===e.storyOptionId,y=ne[e.storyOptionId]??{isDeleting:!1,error:null},b=ie===e.storyOptionId,S=O===e.storyOptionId,w=_===e.storyOptionId,T=e.description??``;return(0,x.jsxs)(`li`,{className:`console-story-list-row`,children:[(0,x.jsxs)(`div`,{className:`console-story-list-row-main`,children:[e.storyViewUrl?(0,x.jsxs)(`a`,{href:e.storyViewUrl,target:`_blank`,rel:`noopener noreferrer`,className:`console-storytag`,style:{color:n.fg,borderColor:n.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:n.dot}}),e.storyName]}):(0,x.jsxs)(`span`,{className:`console-storytag`,style:{color:n.fg,borderColor:n.border},children:[(0,x.jsx)(`span`,{className:`console-story-dot`,style:{backgroundColor:n.dot}}),e.storyName]}),(0,x.jsx)(`span`,{className:`console-story-count`,children:e.openItemCount}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>A(e.storyOptionId),children:`Add task`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>ce(e.storyOptionId),disabled:a,children:`Change color`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move up`,disabled:l||s,onClick:()=>void k(e.storyOptionId,`up`),children:`↑`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Move down`,disabled:u||s,onClick:()=>void k(e.storyOptionId,`down`),children:`↓`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button console-op-button-danger`,"aria-label":`Delete story`,onClick:()=>M(e.storyOptionId),children:`Delete`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Rename story`,onClick:()=>P(e.storyOptionId),children:`Rename`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,"aria-label":`Edit description`,onClick:()=>de(e.storyOptionId),children:`Edit description`}),(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>v(w?null:e.storyOptionId),children:w?`Hide tasks`:`Show tasks`})]}),T!==``&&(0,x.jsx)(`p`,{className:`console-story-description`,children:T}),w&&(0,x.jsx)(ze,{items:e.items}),c!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:c}),i&&(0,x.jsx)(Le,{onSelectColor:t=>le(e.storyOptionId,t),disabled:a}),o!==null&&(0,x.jsx)(`p`,{role:`alert`,className:`console-list-error`,children:o}),r&&(0,x.jsx)(Pe,{storyName:e.storyName,onSubmit:se,onCancel:()=>g(null)}),d&&(0,x.jsx)(Re,{storyName:e.storyName,isDeleting:y.isDeleting,deleteError:y.error,onConfirm:()=>void N(e.storyOptionId),onCancel:ue}),b&&(0,x.jsx)(Fe,{currentName:e.storyName,onSubmit:t=>F(e.storyOptionId,t),onCancel:()=>D(null)}),S&&(0,x.jsx)(Ie,{currentDescription:T,onSubmit:t=>fe(e.storyOptionId,t),onCancel:()=>ae(null)})]},e.storyOptionId)})}),pe&&(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:s,children:r?`Hide archived`:`Show archived`}),(0,x.jsxs)(`div`,{className:`console-add-story-section`,children:[(0,x.jsx)(`button`,{type:`button`,className:`console-op-button`,onClick:()=>S(!b),children:`Add story`}),b&&(0,x.jsx)(Ne,{placeholder:`Story name`,emptyValueError:`Story name is required`,onSubmit:async e=>{await a(e),S(!1)},onCancel:()=>S(!1)})]})]})},Ve=e=>`${e.isPr?`PR`:`Issue`} #${e.itemNumber}`,He=e=>e===null?`loading…`:e,Ue=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(` · `)},We=e=>e.fetchError?`${Ve(e)} — failed to load current state`:e.currentTitle===null?`${Ve(e)} — loading current state…`:`${Ve(e)} — ${e.currentTitle} (${He(e.currentState)})`,Ge=({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:We(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:Ue(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))]}),Ke=({message:e,color:t,remainingSeconds:n,progress:r,onUndo:i})=>(0,x.jsxs)(`div`,{className:`console-undo-toast console-undo-toast-${t}`,role:`status`,"aria-live":`polite`,children:[(0,x.jsx)(`span`,{className:`console-undo-toast-message`,children:e}),(0,x.jsx)(`button`,{type:`button`,className:`console-undo-toast-undo`,onClick:i,children:`Undo`}),(0,x.jsxs)(`span`,{className:`console-undo-toast-countdown`,"aria-hidden":`true`,children:[n,`s`]}),(0,x.jsx)(`span`,{className:`console-undo-toast-bar`,"aria-hidden":`true`,style:{width:`${Math.max(0,Math.min(100,r*100))}%`}})]}),qe=({title:e,message:t,onDismiss:n})=>(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.jsx)(`button`,{type:`button`,className:`console-error-toast-dismiss`,onClick:n,children:`Dismiss`})]}),Je=`tdpm-airplane-v1`,Ye=`/airplane-snapshot-data`,Xe=`tdpm_airplane_mode_on`,Ze=()=>typeof localStorage>`u`?!1:localStorage.getItem(Xe)===`1`,Qe=e=>{typeof localStorage>`u`||(e?localStorage.setItem(Xe,`1`):localStorage.removeItem(Xe))},$e=async e=>{if(typeof caches>`u`)throw Error(`Cache API unavailable`);try{await(await caches.open(Je)).put(Ye,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}},et=async()=>{if(typeof caches>`u`)return null;let e=await(await caches.open(Je)).match(Ye);return e===void 0?null:e.json()},tt=async()=>{typeof caches>`u`||await caches.delete(Je)},nt=e=>typeof e==`object`&&!!e&&!Array.isArray(e),rt=e=>typeof e==`string`?e:``,it=e=>typeof e==`number`?e:0,at=e=>e===!0,ot=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],st=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,ct=e=>nt(e)?{number:it(e.number),title:rt(e.title),url:rt(e.url),repo:rt(e.repo),nameWithOwner:rt(e.nameWithOwner),projectItemId:rt(e.projectItemId),itemId:rt(e.itemId),isPr:at(e.isPr),story:rt(e.story),status:typeof e.status==`string`?e.status:null,nextActionDate:typeof e.nextActionDate==`string`?e.nextActionDate:null,nextActionHour:typeof e.nextActionHour==`number`?e.nextActionHour:null,dependedIssueUrls:ot(e.dependedIssueUrls),labels:ot(e.labels),createdAt:rt(e.createdAt),relatedOpenPullRequestUrls:ot(e.relatedOpenPullRequestUrls),agent:typeof e.agent==`string`?e.agent:null}:null,L=e=>{if(!nt(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(ct).filter(e=>e!==null):[],n=Array.isArray(e.statusOptions)?e.statusOptions.filter(nt):[],r=Array.isArray(e.agentOptions)?e.agentOptions.filter(nt):[],i=Array.isArray(e.storyOptions)?e.storyOptions.filter(nt):[],a=Array.isArray(e.stories)?e.stories.filter(nt):[],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:nt(e.storyColors)?e.storyColors:{},stories:a,defaultNameWithOwner:typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,fromCache:!1,storyOrder:o,timerEndsAt:null,timerTotalSeconds:null}},lt=e=>nt(e)?{author:rt(e.author),body:rt(e.body),createdAt:rt(e.createdAt),url:typeof e.url==`string`?e.url:null}:null,ut=e=>nt(e)?{path:rt(e.path),additions:it(e.additions),deletions:it(e.deletions),status:rt(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null}:null,dt=e=>nt(e)?{sha:rt(e.sha),message:rt(e.message),author:rt(e.author),authoredAt:rt(e.authoredAt)}:null,ft=e=>nt(e)?{found:at(e.found),isConflicted:at(e.isConflicted),mergeableStatus:st(e.mergeableStatus),isPassedAllCiJob:at(e.isPassedAllCiJob),isCiStateSuccess:at(e.isCiStateSuccess),isBranchOutOfDate:at(e.isBranchOutOfDate),missingRequiredCheckNames:ot(e.missingRequiredCheckNames)}:{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]},pt=e=>{if(!nt(e))return null;let t=nt(e.summary)?{title:rt(e.summary.title),body:rt(e.summary.body),additions:it(e.summary.additions),deletions:it(e.summary.deletions),changedFiles:it(e.summary.changedFiles)}:null;return{url:rt(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:rt(e.createdAt),isDraft:at(e.isDraft),isConflicted:at(e.isConflicted),mergeableStatus:st(e.mergeableStatus),isPassedAllCiJob:at(e.isPassedAllCiJob),isCiStateSuccess:at(e.isCiStateSuccess),isResolvedAllReviewComments:at(e.isResolvedAllReviewComments),isBranchOutOfDate:at(e.isBranchOutOfDate),missingRequiredCheckNames:ot(e.missingRequiredCheckNames),summary:t}},mt=e=>{if(!nt(e))return{body:``,comments:[],state:{state:`open`,merged:!1,isPullRequest:!1,title:``},files:null,commits:null,prStatus:null,relatedPrs:null};let t=nt(e.state)?e.state:{},n={state:rt(t.state)||`open`,merged:at(t.merged),isPullRequest:at(t.isPullRequest),title:rt(t.title)},r=e.files===null?null:Array.isArray(e.files)?e.files.map(ut).filter(e=>e!==null):null,i=e.commits===null?null:Array.isArray(e.commits)?e.commits.map(dt).filter(e=>e!==null):null,a=e.prStatus===null?null:ft(e.prStatus),o=e.relatedPrs===null?null:Array.isArray(e.relatedPrs)?e.relatedPrs.map(pt).filter(e=>e!==null):null;return{body:rt(e.body),comments:Array.isArray(e.comments)?e.comments.map(lt).filter(e=>e!==null):[],state:n,files:r,commits:i,prStatus:a,relatedPrs:o}},ht=e=>{if(!nt(e))return null;let t=typeof e.capturedAt==`string`?e.capturedAt:``,n=ot(e.failures),r={};if(nt(e.tabs))for(let[t,n]of Object.entries(e.tabs)){if(!nt(n))continue;let e={};for(let[t,r]of Object.entries(n))e[t]=L(r);r[t]=e}let i={};if(nt(e.items))for(let[t,n]of Object.entries(e.items))i[t]=mt(n);return{capturedAt:t,tabs:r,items:i,failures:n}},gt=`/api/airplanesync`,_t=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}},vt=()=>{let[e,t]=(0,y.useState)(`off`),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),c=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!Ze())return;let e=!1;return et().then(n=>{e||n===null||(a(n),t(`on`))}).catch(()=>{Qe(!1)}),()=>{e=!0}},[]),{status:e,progress:n,snapshot:i,failures:o,startSync:(0,y.useCallback)(()=>{c.current!==null&&c.current.abort();let e=new AbortController;c.current=e,t(`syncing`),r({fetched:0,total:0}),s([]),fetch(gt,{signal:e.signal}).then(async e=>{if(!e.ok||e.body===null){t(`error`),s([`HTTP ${e.status}`]);return}let n=e.body.pipeThrough(new TextDecoderStream).getReader(),i=``;for(;;){let{done:e,value:o}=await n.read();if(e)break;i+=o;let c=i.split(`
|
|
12
12
|
|
|
13
|
-
`);i=c.pop()??``;for(let e of c){if(!e.startsWith(`data: `))continue;let n=_t(e.slice(6));if(n!==null){if(n.type===`progress`)r({fetched:typeof n.fetched==`number`?n.fetched:0,total:typeof n.total==`number`?n.total:0});else if(n.type===`done`){let e=ht(n.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}if(e.failures.length>0){s(e.failures),t(`error`);return}await $e(e),Qe(!0),a(e),t(`on`),s([])}}}}}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[]),turnOff:(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),Qe(!1),tt().catch(()=>{})},[])}},R=e=>typeof e==`object`&&!!e&&!Array.isArray(e),z=e=>typeof e==`string`?e:``,yt=e=>typeof e==`number`?e:0,bt=e=>e===!0,xt=`console-api-v1`,St=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();R(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(xt).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(xt)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},Ct=e=>!R(e)||!Array.isArray(e.comments)?[]:e.comments.filter(R).map(e=>({author:z(e.author),body:z(e.body),createdAt:z(e.createdAt),url:typeof e.url==`string`?e.url:null})),wt=e=>!R(e)||!Array.isArray(e.files)?[]:e.files.filter(R).map(e=>({path:z(e.path)||z(e.filename),additions:yt(e.additions),deletions:yt(e.deletions),status:z(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Tt=e=>!R(e)||!Array.isArray(e.commits)?[]:e.commits.filter(R).map(e=>({sha:z(e.sha),message:z(e.message),author:z(e.author),authoredAt:z(e.authoredAt)})),Et=e=>R(e)?{title:z(e.title),body:z(e.body),additions:yt(e.additions),deletions:yt(e.deletions),changedFiles:yt(e.changedFiles)}:null,Dt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ot=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,kt=e=>!R(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(R).map(e=>({url:z(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:z(e.createdAt),isDraft:bt(e.isDraft),isConflicted:bt(e.isConflicted),mergeableStatus:Ot(e.mergeableStatus),isPassedAllCiJob:bt(e.isPassedAllCiJob),isCiStateSuccess:bt(e.isCiStateSuccess),isResolvedAllReviewComments:bt(e.isResolvedAllReviewComments),isBranchOutOfDate:bt(e.isBranchOutOfDate),missingRequiredCheckNames:Dt(e.missingRequiredCheckNames),summary:Et(e.summary)})),At=e=>{if(!R(e)||!R(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:bt(t.isConflicted),mergeableStatus:Ot(t.mergeableStatus),isPassedAllCiJob:bt(t.isPassedAllCiJob),isCiStateSuccess:bt(t.isCiStateSuccess),isBranchOutOfDate:bt(t.isBranchOutOfDate),missingRequiredCheckNames:Dt(t.missingRequiredCheckNames)}},jt=e=>R(e)?{state:z(e.state)||`open`,merged:bt(e.merged),isPullRequest:bt(e.isPullRequest),title:z(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},Mt=()=>({fetchItemBody:async e=>{let t=await St(`/api/itembody`,e);return R(t)?z(t.body):``},fetchComments:async e=>Ct(await St(`/api/comments`,e)),fetchPrFiles:async e=>wt(await St(`/api/prfiles`,e)),fetchPrCommits:async e=>Tt(await St(`/api/prcommits`,e)),fetchRelatedPrs:async e=>kt(await St(`/api/relatedprs`,e)),fetchIssueState:async e=>jt(await St(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>At(await St(`/api/pullrequeststatus`,e))}),Nt=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(R(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Pt=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 Nt(n))},Ft=`/api/comment`,It=e=>({author:z(e.author),body:z(e.body),createdAt:z(e.createdAt),url:typeof e.url==`string`?e.url:null}),Lt=async e=>{let t=await fetch(Ft,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await Nt(t),rateLimitResetAt:null};let n=await t.json();return R(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:R(n.comment)?{posted:!0,comment:It(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},Rt=`/api/upload`,zt=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Bt=async e=>{let t=await fetch(Rt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t));let n=await t.json();if(!R(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},Vt=`/api/addstory`,Ht=async e=>{let t=await fetch(Vt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Ut=`/api/reviewcomment`,Wt=async e=>{let t=await fetch(Ut,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Gt=`/api/createissue`,Kt=`/api/storycolor`,qt=async e=>{let t=await fetch(Kt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Jt=async e=>{let t=await fetch(Gt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(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},Yt=`/api/reorderstory`,Xt=async e=>{let t=await fetch(Yt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Zt=`/api/deleteallcomments`,Qt=async e=>{let t=await fetch(Zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},$t=`/api/deletestory`,en=async e=>{let t=await fetch($t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},tn=`/api/renamestory`,nn=async e=>{let t=await fetch(tn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},rn=`/api/storydescription`,an=async e=>{let t=await fetch(rn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},on=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,workflowImprovementIssueUrl:null,fleetTaskCreateUrl:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:n.projectUrls!==null&&typeof n.projectUrls==`object`&&!Array.isArray(n.projectUrls)?Object.fromEntries(Object.entries(n.projectUrls).filter(e=>typeof e[1]==`string`)):null,workflowImprovementIssueUrl:typeof n.workflowImprovementIssueUrl==`string`?n.workflowImprovementIssueUrl:null,fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null}},sn=`/api/projectreadmeconfig`,cn=async e=>{let t=`${sn}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await Nt(n));let r=await n.json();return{maximumPreparingIssuesCount:R(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},ln=`/api/setdependedissueurl`,un=async e=>{let t=await fetch(ln,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},dn=`/api/projectsettings`,fn=async e=>{let t=await fetch(dn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},pn=5e3,mn=e=>`${e.isPr?`PR #`:`#`}${e.number}`,hn=(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 +1 hour`:e.action===`snooze_3hours`?`Next Action Hour +3 hours`:e.action===`snooze_6hours`?`Next Action Hour +6 hours`:e.action===`snooze_1day`?`Next Action Date +1 day`:e.action===`snooze_2days`?`Next Action Date +2 days`:e.action===`snooze_3days`?`Next Action Date +3 days`:e.action===`snooze_5days`?`Next Action Date +5 days`:e.action===`snooze_1month`?`Next Action Date +1 month`:be(t)?`Next Action Date +1 week and skip`:`Next Action Date +1 week`;case`set_story`:return`Story → ${e.optionName}`;case`set_agent`:return`Agent → ${e.optionName}`;case`set_status`:return`Status → ${e.optionName}`;case`set_in_tmux_by_human`:return`Added to In Tmux by human`;case`ok_and_awaiting_workspace`:return`ok → Awaiting Workspace`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},gn=e=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`green`:e.action===`request_changes`?`amber`:e.action===`totally_wrong`?`red`:`gray`;case`next_action_date`:return`amber`;case`set_story`:case`set_agent`:case`set_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},_n=(e,t)=>e.type===`next_action_date`?be(t):e.type!==`delete_all_comments`,vn=(e,t,n)=>`${hn(e,n)} — ${mn(t)}`,yn=`console-offline-action-queue`,bn=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.message==`string`&&typeof t.color==`string`&&typeof t.enqueuedAt==`number`&&typeof t.itemUrl==`string`&&typeof t.projectItemId==`string`&&typeof t.itemNumber==`number`&&typeof t.repo==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},xn=()=>{try{let e=localStorage.getItem(yn);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(bn):[]}catch{return[]}},Sn=e=>{localStorage.setItem(yn,JSON.stringify(e))},Cn=()=>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)}`,wn=e=>e instanceof TypeError,Tn=e=>e instanceof Error&&e.message.length>0?e.message:String(e),En=100,Dn=e=>Math.max(0,Math.ceil((pn-e)/1e3)),On=e=>Math.max(0,1-e/pn),kn=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(xn),o=(0,y.useRef)(i);o.current=i;let s=(0,y.useRef)(null),c=(0,y.useRef)(0),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),f=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:Cn(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return Sn(n),n})},[]),p=(0,y.useCallback)(e=>{e.commit().catch(t=>{wn(t)&&e.offline!==void 0?f(e):r({message:e.message,reason:Tn(t)})})},[f]),m=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,p(e))},[d,p]),h=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.()},[d]),g=(0,y.useCallback)(()=>{r(null)},[]),_=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),v=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return Sn(n),n})},[]),b=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Pt(t.apiPath,t.requestBody),v(e)}catch(n){wn(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:Tn(n)}),v(e))}},[v]),x=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;d(),u.current=!0,p(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Dn(0),progress:On(0)}),e.advance(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){m();return}t({message:e.message,color:e.color,remainingSeconds:Dn(n),progress:On(n)})},En)},[d,m,p]);return(0,y.useEffect)(()=>d,[d]),{pending:e,error:n,offlineActions:i,enqueue:x,showError:_,undo:h,dismissError:g,confirmOfflineAction:b,discardOfflineAction:v}},An=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},jn=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},Mn=`tdpm-timer-settings`,Nn=()=>({timerMode:!1,projectMinutes:{}}),Pn=()=>{if(typeof localStorage>`u`)return Nn();let e=localStorage.getItem(Mn);if(e===null)return Nn();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return Nn();let n=t,r=typeof n.timerMode==`boolean`&&n.timerMode,i=n.projectMinutes;return{timerMode:r,projectMinutes:typeof i==`object`&&i&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(([,e])=>typeof e==`number`).map(([e,t])=>[e,t])):{}}}catch{return Nn()}},Fn=e=>{typeof localStorage<`u`&&localStorage.setItem(Mn,JSON.stringify(e))},In=(e,t,n)=>{if(e.length===0)return null;let r=t===null?-1:e.indexOf(t),i=r===-1?0:(r+1)%e.length,a=r===-1?e.length:e.length-1;for(let t=0;t<a;t++){let r=e[(i+t)%e.length];if((n[r]??0)>0)return r}return null},Ln=(e,t,n,r,i)=>{let a=(0,y.useRef)(t),o=(0,y.useRef)(n);(0,y.useEffect)(()=>{let s=a.current,c=o.current;if(a.current=t,o.current=n,e){if(c!==n){a.current=0;return}if(s>0&&t===0){let e=In(r,n,i);e!==null&&An(`/projects/${e}`)}}},[e,t,n,r,i])},Rn=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)}},zn=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},Bn=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=zn(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)}},Vn=(e=null)=>(0,y.useMemo)(()=>{let t=Mt(),n={client:t,body:new Rn(t.fetchItemBody),comments:new Rn(t.fetchComments),files:new Rn(t.fetchPrFiles),commits:new Rn(t.fetchPrCommits),relatedPrs:new Rn(t.fetchRelatedPrs),state:new Rn(t.fetchIssueState),prStatus:new Rn(t.fetchPullRequestStatus)};return e!==null&&Bn(n,e),n},[e]),Hn=0,Un=500,Wn=2e3,Gn=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:Wn});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},Kn=(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)},qn=(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+Hn);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=Gn(()=>{for(let t of i)Kn(e,t)})},Un);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},Jn=`/api/features`,Yn=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(Jn).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},Xn=(e,t)=>{let n=ae.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<ae.length;e+=1){let n=ae[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},Zn=e=>{let t=ae.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},Qn=new Set(ae.map(e=>e.name)),$n=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return Qn.has(n)?n:null},er=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},tr=`#settings`,nr=(e,t)=>{let n=(0,y.useCallback)(()=>{let e=Zn(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:$n(window.location.pathname)??e,selectedItemKey:er(window.location.hash)}},[t]),[r,i]=(0,y.useState)(n);(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{i(n())};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[n]),(0,y.useEffect)(()=>{if(typeof window>`u`||$n(window.location.pathname)!==null)return;let e=Zn(t);i(t=>t.activeTab===e?t:{...t,activeTab:e})},[t]);let a=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),o=(0,y.useCallback)(e=>{if(typeof window>`u`){i({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,a(e)),i({activeTab:e,selectedItemKey:null})},[a]),s=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),i(t=>({...t,selectedItemKey:e}))},[]),c=(0,y.useCallback)(()=>{if(typeof window<`u`&&window.location.hash!==``){let e=`${window.location.pathname}${window.location.search}`;window.history.pushState({},``,e)}i(e=>({...e,selectedItemKey:null}))},[]);return{activeTab:r.activeTab,selectedItemKey:r.selectedItemKey,tabHref:a,selectTab:o,openItem:s,closeItem:c}},rr=e=>`pv_overlay_${e}`,ir=e=>e.projectItemId===``?e.itemId:e.projectItemId,ar=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,or=(e,t,n)=>e.filter(e=>!ar(t[ir(e)],n)).length,sr=(e,t,n)=>e.filter(e=>!ar(t[ir(e)],n)),cr=(e,t)=>{let n=Date.parse(t);if(Number.isNaN(n))return{};let r={};for(let[t,i]of Object.entries(e))i.ts>=n&&(r[t]=i);return r},lr=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[ir(t)];return i===void 0||i.ts<r?null:i.status??null},ur=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},dr=`/api/review`,fr=`/api/triage`,pr=`/api/intmux`,mr=(e,t,n,r,i)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:ge(i),...r===void 0?{}:{changedFilePath:r.path,line:r.line,side:r.side}}}return r===`totally_wrong`?{pjcode:e,action:`close`,prUrl:n,issueUrl:t.url,projectItemId:t.projectItemId,commentBody:pe}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:me,issueCommentBody:he(n)}},hr=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),gr=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),_r=()=>Error(`No project specified in the URL path.`),vr=`ok`,yr=(e,t,n,r,i)=>{let{patchOverlay:a}=n,o=(0,y.useCallback)(e=>{if(r===void 0)return;let t=`${e.repo}#${e.number}`;r.body.invalidate(t),r.comments.invalidate(t)},[r]),s=(0,y.useCallback)(e=>{a(ir(e),{done:!0},t)},[a,t]),c=(0,y.useCallback)(async(t,n,r,i=[])=>{if(e===null)throw _r();await Pt(dr,mr(e,t,n,r,i)),s(t),o(t)},[e,s,o]),l=(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Pt(fr,r),o(t)},[e,s,o]),u=(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_agent`,issueUrl:n.url,projectItemId:n.projectItemId,agentOptionId:r.id};a(ir(n),{done:!0},t),await Pt(fr,i),o(n)},[e,o,a,t]);return{reviewPullRequest:c,setNextActionDate:l,setStory:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_story`,issueUrl:n.url,projectItemId:n.projectItemId,storyOptionId:r.id};a(ir(n),{done:!0,story:{name:r.name,color:r.color}},t),await Pt(fr,i),o(n)},[e,o,a,t]),setAgent:u,setStatus:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name};a(ir(n),{done:!0,status:{name:r.name,color:r.color}},t),await Pt(fr,i),o(n)},[e,o,a,t]),setInTmuxByHuman:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_intmux`,issueUrl:n.url,projectItemId:n.projectItemId};a(ir(n),{done:!0,status:{name:r.name,color:r.color}},t),await Pt(pr,i),o(n)},[e,o,a,t]),closeIssue:(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Pt(fr,r),o(t)},[e,s,o]),okAndMoveToAwaitingWorkspace:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();a(ir(n),{done:!0,status:{name:r.name,color:r.color}},t);let s=await Lt({pjcode:e,url:n.url,body:vr});if(await Pt(fr,{pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name}),o(n),await i?.(),!s.posted){let e=s.rateLimitResetAt===null?``:` Rate limit resets at ${s.rateLimitResetAt}.`;throw Error(`Comment not posted — ${s.error}.${e} Status was changed. Re-post: ${vr}`)}},[e,o,a,t,i]),addComment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();let r=await Lt({pjcode:e,url:t.url,body:n});if(!r.posted){let e=r.rateLimitResetAt===null?``:` Rate limit resets at ${r.rateLimitResetAt}.`;throw Error(`${r.error}.${e}`)}return o(t),r.comment},[e,o]),uploadAttachment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=zt(new Uint8Array(await n.arrayBuffer()));return Bt({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw _r();await Wt({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),deleteAllComments:(0,y.useCallback)(async e=>{await Qt({issueUrl:e.url}),o(e)},[o]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();await un({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e])}},br=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,xr=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(rr(e));if(t===null)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{};let r={};for(let[e,t]of Object.entries(n))br(t)&&(r[e]=t);return r},Sr=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(rr(e),JSON.stringify(t))},Cr=e=>{let[t,n]=(0,y.useState)(()=>xr(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=ur(n,t,r,i,Date.now());return Sr(e,a),a})},[e])}},wr=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},Tr=()=>{let[e,t]=(0,y.useState)(()=>wr(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(wr(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},Er=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return l(!0),d(null),on().then(n=>{e||(t(n.pjcodes),r(n.projectUrls),a(n.workflowImprovementIssueUrl),s(n.fleetTaskCreateUrl),l(!1))}).catch(t=>{e||(d(t instanceof Error?t:Error(String(t))),l(!1))}),()=>{e=!0}},[]),{pjcodes:e,projectUrls:n,workflowImprovementIssueUrl:i,fleetTaskCreateUrl:o,isLoading:c,error:u}},Dr=`console-comment-expanded:`,Or=e=>{try{let t=localStorage.getItem(Dr+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}},kr=(e,t)=>{try{localStorage.setItem(Dr+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Ar=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(Dr)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},jr=e=>(0,y.useCallback)(t=>{Ar(),e(t)},[e]),Mr=()=>typeof window<`u`&&window.location.hash===`#settings`,Nr=e=>{let[t,n]=(0,y.useState)(Mr),[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=>cn(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===tr;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({},``,tr)),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])=>fn({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}},Pr=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,[])}},Fr=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,Ir=/^From:\s+:robot:/m,Lr=/^##\s/m,Rr=e=>{let t=Fr.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=Ir.exec(n),i=Lr.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},zr=e=>{if(e.length===0)return null;let t=e[e.length-1],n=Rr(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},Br=e=>`${e.repo}#${e.number}`,Vr=(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=Br(n),a=t.peek(e);if(a!==void 0){let e=zr(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e});continue}t.load(e,n.url).then(e=>{if(r)return;let t=zr(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},Hr=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},Ur=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},Wr=e=>{let t=e instanceof Element?e:null;for(;t!==null&&t!==document.body;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth&&t.scrollLeft>0)return!0;t=t.parentElement}return!1},Gr=e=>{let t=(0,y.useRef)(e);t.current=e;let n=(0,y.useRef)(null),r=(0,y.useCallback)(e=>{let n=0,r=0,i=!1,a=e=>{if(e.touches.length!==1){i=!1;return}if(Wr(e.target)){i=!1;return}let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},o=e=>{if(!i)return;let t=e.touches[0];Ur(t.clientX-n,t.clientY-r)&&(i=!1)},s=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let a=e.changedTouches[0],o=Hr(a.clientX-n,a.clientY-r);o!==null&&t.current(o)};return e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),()=>{e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s)}},[]),i=(0,y.useCallback)(e=>{n.current!==null&&(n.current(),n.current=null),e!==null&&(n.current=r(e))},[r]);return(0,y.useEffect)(()=>()=>{n.current!==null&&(n.current(),n.current=null)},[]),i},Kr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),qr=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Jr=e=>Array.isArray(e)?e.filter(Kr).map(e=>({...e,relatedOpenPullRequestUrls:qr(e.relatedOpenPullRequestUrls)})):[],Yr=e=>!Kr(e)||!Array.isArray(e.items)?[]:Jr(e.items),Xr=e=>Array.isArray(e)?e.filter(Kr):[],Zr=e=>Array.isArray(e)?e.filter(Kr).map(e=>({...e,items:Jr(e.items)})):[],Qr=e=>({items:Yr(e),generatedAt:Kr(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Kr(e)?Xr(e.statusOptions):[],agentOptions:Kr(e)?Xr(e.agentOptions):[],storyOptions:Kr(e)?Xr(e.storyOptions):[],storyColors:Kr(e)&&Kr(e.storyColors)?e.storyColors:{},stories:Kr(e)?Zr(e.stories):[],defaultNameWithOwner:Kr(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Kr(e)?qr(e.storyOrder):[],timerEndsAt:Kr(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Kr(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),$r=()=>{let e={};for(let t of ae)e[t.name]=null;return e},ei=(e,t)=>`/projects/${e}/${t}/list.json`,ti=6e4,ni=`console-list-v1`,ri=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(ni).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)}},ii=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(ni)).match(e);return t===void 0?null:{...Qr(await t.json()),fromCache:!0}}catch{return null}},ai=async e=>{let t=await Promise.all(ae.map(async t=>({tabName:t.name,snapshot:await ii(ei(e,t.name))}))),n=$r();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},oi=async(e,t)=>{let n=ei(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return ri(n,t),{snapshot:{...Qr(t),fromCache:!1},error:null}}catch(e){let t=await ii(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},si=async e=>{let t=await Promise.all(ae.map(async t=>{let{snapshot:n,error:r}=await oi(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=$r(),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}},ci=(e,t=null)=>{let[n,r]=(0,y.useState)($r),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=$r();for(let t of ae){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}r(e),a(!1),s(null);return}}let n=!1,i=!1;if(s(null),e===null)return r($r()),a(!1),s(`No project specified in the URL path.`),()=>{n=!0};ai(e).then(e=>{if(n)return;let t=Object.values(e).some(e=>e!==null);t&&!i?(r(e),a(!1)):!t&&!i&&(a(!0),r($r()))});let o=()=>{si(e).then(({snapshots:e,firstError:t})=>{n||(i=!0,r(e),s(t===null?null:t.message),a(!1))}).catch(e=>{n||(i=!0,s(e instanceof Error?e.message:String(e)),a(!1))})};o();let c=setInterval(o,ti);return()=>{n=!0,clearInterval(c)}},[e,t]),{snapshots:n,isLoading:i,error:o,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:n}=await oi(e,t);n!==null&&r(e=>({...e,[t]:n}))},[e])}},li=e=>(0,y.useCallback)(t=>{Ar(),e(t)},[e]),ui=()=>{let[e,t]=(0,y.useState)(Pn),[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=>(Fn(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}},di=(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},fi=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},pi=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},mi=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
|
|
13
|
+
`);i=c.pop()??``;for(let e of c){if(!e.startsWith(`data: `))continue;let n=_t(e.slice(6));if(n!==null){if(n.type===`progress`)r({fetched:typeof n.fetched==`number`?n.fetched:0,total:typeof n.total==`number`?n.total:0});else if(n.type===`done`){let e=ht(n.snapshot);if(e===null){t(`error`),s([`Failed to parse snapshot`]);return}if(e.failures.length>0){s(e.failures),t(`error`);return}await $e(e),Qe(!0),a(e),t(`on`),s([])}}}}}).catch(e=>{e instanceof Error&&e.name===`AbortError`||(t(`error`),s([e instanceof Error?e.message:String(e)]))})},[]),turnOff:(0,y.useCallback)(()=>{c.current!==null&&(c.current.abort(),c.current=null),t(`off`),a(null),r(null),s([]),Qe(!1),tt().catch(()=>{})},[])}},R=e=>typeof e==`object`&&!!e&&!Array.isArray(e),z=e=>typeof e==`string`?e:``,yt=e=>typeof e==`number`?e:0,bt=e=>e===!0,xt=`console-api-v1`,St=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();R(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(xt).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(xt)).match(n);if(e!==void 0)return e.json()}}catch{}throw e}},Ct=e=>!R(e)||!Array.isArray(e.comments)?[]:e.comments.filter(R).map(e=>({author:z(e.author),body:z(e.body),createdAt:z(e.createdAt),url:typeof e.url==`string`?e.url:null})),wt=e=>!R(e)||!Array.isArray(e.files)?[]:e.files.filter(R).map(e=>({path:z(e.path)||z(e.filename),additions:yt(e.additions),deletions:yt(e.deletions),status:z(e.status),patch:typeof e.patch==`string`?e.patch:null,rawUrl:typeof e.rawUrl==`string`?e.rawUrl:null})),Tt=e=>!R(e)||!Array.isArray(e.commits)?[]:e.commits.filter(R).map(e=>({sha:z(e.sha),message:z(e.message),author:z(e.author),authoredAt:z(e.authoredAt)})),Et=e=>R(e)?{title:z(e.title),body:z(e.body),additions:yt(e.additions),deletions:yt(e.deletions),changedFiles:yt(e.changedFiles)}:null,Dt=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Ot=e=>e===`MERGEABLE`?`MERGEABLE`:e===`CONFLICTING`?`CONFLICTING`:`UNKNOWN`,kt=e=>!R(e)||!Array.isArray(e.relatedPullRequests)?[]:e.relatedPullRequests.filter(R).map(e=>({url:z(e.url),branchName:typeof e.branchName==`string`?e.branchName:null,createdAt:z(e.createdAt),isDraft:bt(e.isDraft),isConflicted:bt(e.isConflicted),mergeableStatus:Ot(e.mergeableStatus),isPassedAllCiJob:bt(e.isPassedAllCiJob),isCiStateSuccess:bt(e.isCiStateSuccess),isResolvedAllReviewComments:bt(e.isResolvedAllReviewComments),isBranchOutOfDate:bt(e.isBranchOutOfDate),missingRequiredCheckNames:Dt(e.missingRequiredCheckNames),summary:Et(e.summary)})),At=e=>{if(!R(e)||!R(e.status))return{found:!1,isConflicted:!1,mergeableStatus:`UNKNOWN`,isPassedAllCiJob:!1,isCiStateSuccess:!1,isBranchOutOfDate:!1,missingRequiredCheckNames:[]};let t=e.status;return{found:!0,isConflicted:bt(t.isConflicted),mergeableStatus:Ot(t.mergeableStatus),isPassedAllCiJob:bt(t.isPassedAllCiJob),isCiStateSuccess:bt(t.isCiStateSuccess),isBranchOutOfDate:bt(t.isBranchOutOfDate),missingRequiredCheckNames:Dt(t.missingRequiredCheckNames)}},jt=e=>R(e)?{state:z(e.state)||`open`,merged:bt(e.merged),isPullRequest:bt(e.isPullRequest),title:z(e.title)}:{state:`open`,merged:!1,isPullRequest:!1,title:``},Mt=()=>({fetchItemBody:async e=>{let t=await St(`/api/itembody`,e);return R(t)?z(t.body):``},fetchComments:async e=>Ct(await St(`/api/comments`,e)),fetchPrFiles:async e=>wt(await St(`/api/prfiles`,e)),fetchPrCommits:async e=>Tt(await St(`/api/prcommits`,e)),fetchRelatedPrs:async e=>kt(await St(`/api/relatedprs`,e)),fetchIssueState:async e=>jt(await St(`/api/issuetitle`,e)),fetchPullRequestStatus:async e=>At(await St(`/api/pullrequeststatus`,e))}),Nt=async e=>{let t=await e.text().catch(()=>``);if(t.length===0)return`HTTP ${e.status}`;try{let e=JSON.parse(t);if(R(e)&&typeof e.error==`string`)return e.error}catch{return t}return t},Pt=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 Nt(n))},Ft=`/api/comment`,It=e=>({author:z(e.author),body:z(e.body),createdAt:z(e.createdAt),url:typeof e.url==`string`?e.url:null}),Lt=async e=>{let t=await fetch(Ft,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)return{posted:!1,error:await Nt(t),rateLimitResetAt:null};let n=await t.json();return R(n)?n.ok===!1?{posted:!1,error:typeof n.error==`string`?n.error:`upstream error`,rateLimitResetAt:typeof n.rateLimitResetAt==`string`?n.rateLimitResetAt:null}:R(n.comment)?{posted:!0,comment:It(n.comment)}:{posted:!1,error:`comment was not returned`,rateLimitResetAt:null}:{posted:!1,error:`unexpected response shape`,rateLimitResetAt:null}},Rt=`/api/upload`,zt=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)},Bt=async e=>{let t=await fetch(Rt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t));let n=await t.json();if(!R(n)||typeof n.markdown!=`string`)throw Error(`markdown was not returned`);return n.markdown},Vt=`/api/addstory`,Ht=async e=>{let t=await fetch(Vt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Ut=`/api/reviewcomment`,Wt=async e=>{let t=await fetch(Ut,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Gt=`/api/createissue`,Kt=`/api/storycolor`,qt=async e=>{let t=await fetch(Kt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Jt=async e=>{let t=await fetch(Gt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(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},Yt=`/api/reorderstory`,Xt=async e=>{let t=await fetch(Yt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},Zt=`/api/deleteallcomments`,Qt=async e=>{let t=await fetch(Zt,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},$t=`/api/deletestory`,en=async e=>{let t=await fetch($t,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},tn=`/api/renamestory`,nn=async e=>{let t=await fetch(tn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},rn=`/api/storydescription`,an=async e=>{let t=await fetch(rn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},on=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,workflowImprovementIssueUrl:null,fleetTaskCreateUrl:null};let n=t;return{pjcodes:Array.isArray(n.pjcodes)?n.pjcodes.filter(e=>typeof e==`string`):[],projectUrls:n.projectUrls!==null&&typeof n.projectUrls==`object`&&!Array.isArray(n.projectUrls)?Object.fromEntries(Object.entries(n.projectUrls).filter(e=>typeof e[1]==`string`)):null,workflowImprovementIssueUrl:typeof n.workflowImprovementIssueUrl==`string`?n.workflowImprovementIssueUrl:null,fleetTaskCreateUrl:typeof n.fleetTaskCreateUrl==`string`?n.fleetTaskCreateUrl:null}},sn=`/api/projectreadmeconfig`,cn=async e=>{let t=`${sn}?pjcode=${encodeURIComponent(e)}`,n=await fetch(t);if(!n.ok)throw Error(await Nt(n));let r=await n.json();return{maximumPreparingIssuesCount:R(r)&&typeof r.maximumPreparingIssuesCount==`number`?r.maximumPreparingIssuesCount:null}},ln=`/api/setdependedissueurl`,un=async e=>{let t=await fetch(ln,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},dn=`/api/projectsettings`,fn=async e=>{let t=await fetch(dn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Nt(t))},pn=5e3,mn=e=>`${e.isPr?`PR #`:`#`}${e.number}`,hn=(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 +1 hour`:e.action===`snooze_3hours`?`Next Action Hour +3 hours`:e.action===`snooze_6hours`?`Next Action Hour +6 hours`:e.action===`snooze_1day`?`Next Action Date +1 day`:e.action===`snooze_2days`?`Next Action Date +2 days`:e.action===`snooze_3days`?`Next Action Date +3 days`:e.action===`snooze_5days`?`Next Action Date +5 days`:e.action===`snooze_1month`?`Next Action Date +1 month`:be(t)?`Next Action Date +1 week and skip`:`Next Action Date +1 week`;case`set_story`:return`Story → ${e.optionName}`;case`set_agent`:return`Agent → ${e.optionName}`;case`set_status`:return`Status → ${e.optionName}`;case`set_in_tmux_by_human`:return`Added to In Tmux by human`;case`ok_and_awaiting_workspace`:return`ok → Awaiting Workspace`;case`close`:return e.action===`close`?`Closed`:`Closed as not planned`;case`delete_all_comments`:return`Deleted all comments`}},gn=e=>{switch(e.type){case`review`:return e.action===`approve_and_merge`?`green`:e.action===`request_changes`?`amber`:e.action===`totally_wrong`?`red`:`gray`;case`next_action_date`:return`amber`;case`set_story`:case`set_agent`:case`set_status`:case`set_in_tmux_by_human`:case`ok_and_awaiting_workspace`:return`blue`;case`close`:return`red`;case`delete_all_comments`:return`red`}},_n=(e,t)=>e.type===`next_action_date`?be(t):e.type!==`delete_all_comments`,vn=(e,t,n)=>`${hn(e,n)} — ${mn(t)}`,yn=`console-offline-action-queue`,bn=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.id==`string`&&typeof t.message==`string`&&typeof t.color==`string`&&typeof t.enqueuedAt==`number`&&typeof t.itemUrl==`string`&&typeof t.projectItemId==`string`&&typeof t.itemNumber==`number`&&typeof t.repo==`string`&&typeof t.isPr==`boolean`&&typeof t.apiPath==`string`&&typeof t.requestBody==`object`&&t.requestBody!==null},xn=()=>{try{let e=localStorage.getItem(yn);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(bn):[]}catch{return[]}},Sn=e=>{localStorage.setItem(yn,JSON.stringify(e))},Cn=()=>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)}`,wn=e=>e instanceof TypeError,Tn=e=>e instanceof Error&&e.message.length>0?e.message:String(e),En=100,Dn=e=>Math.max(0,Math.ceil((pn-e)/1e3)),On=e=>Math.max(0,1-e/pn),kn=()=>{let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(xn),o=(0,y.useRef)(i);o.current=i;let s=(0,y.useRef)(null),c=(0,y.useRef)(0),l=(0,y.useRef)(null),u=(0,y.useRef)(!1),d=(0,y.useCallback)(()=>{l.current!==null&&(clearInterval(l.current),l.current=null)},[]),f=(0,y.useCallback)(e=>{if(e.offline===void 0)return;let t={id:Cn(),message:e.message,color:e.color,enqueuedAt:Date.now(),...e.offline};a(e=>{let n=[...e,t];return Sn(n),n})},[]),p=(0,y.useCallback)(e=>{e.commit().catch(t=>{wn(t)&&e.offline!==void 0?f(e):r({message:e.message,reason:Tn(t)})})},[f]),m=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,t(null),e!==null&&!u.current&&(u.current=!0,p(e))},[d,p]),h=(0,y.useCallback)(()=>{let e=s.current;d(),s.current=null,u.current=!0,t(null),e?.revertAdvance?.()},[d]),g=(0,y.useCallback)(()=>{r(null)},[]),_=(0,y.useCallback)((e,t)=>{r({message:e,reason:t})},[]),v=(0,y.useCallback)(e=>{a(t=>{let n=t.filter(t=>t.id!==e);return Sn(n),n})},[]),b=(0,y.useCallback)(async e=>{let t=o.current.find(t=>t.id===e);if(t!==void 0)try{await Pt(t.apiPath,t.requestBody),v(e)}catch(n){wn(n)?r({message:t.message,reason:`Still offline — action is still held in the queue`}):(r({message:t.message,reason:Tn(n)}),v(e))}},[v]),x=(0,y.useCallback)(e=>{if(s.current!==null&&!u.current){let e=s.current;d(),u.current=!0,p(e)}u.current=!1,s.current=e,c.current=Date.now(),t({message:e.message,color:e.color,remainingSeconds:Dn(0),progress:On(0)}),e.advance(),l.current=setInterval(()=>{let n=Date.now()-c.current;if(n>=5e3){m();return}t({message:e.message,color:e.color,remainingSeconds:Dn(n),progress:On(n)})},En)},[d,m,p]);return(0,y.useEffect)(()=>d,[d]),{pending:e,error:n,offlineActions:i,enqueue:x,showError:_,undo:h,dismissError:g,confirmOfflineAction:b,discardOfflineAction:v}},An=e=>{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},jn=e=>{window.history.replaceState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`))},Mn=`tdpm-timer-settings`,Nn=()=>({timerMode:!1,projectMinutes:{}}),Pn=()=>{if(typeof localStorage>`u`)return Nn();let e=localStorage.getItem(Mn);if(e===null)return Nn();try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return Nn();let n=t,r=typeof n.timerMode==`boolean`&&n.timerMode,i=n.projectMinutes;return{timerMode:r,projectMinutes:typeof i==`object`&&i&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(([,e])=>typeof e==`number`).map(([e,t])=>[e,t])):{}}}catch{return Nn()}},Fn=e=>{typeof localStorage<`u`&&localStorage.setItem(Mn,JSON.stringify(e))},In=(e,t,n)=>{if(e.length===0)return null;let r=t===null?-1:e.indexOf(t),i=r===-1?0:(r+1)%e.length,a=r===-1?e.length:e.length-1;for(let t=0;t<a;t++){let r=e[(i+t)%e.length];if((n[r]??0)>0)return r}return null},Ln=(e,t,n,r,i)=>{let a=(0,y.useRef)(t),o=(0,y.useRef)(n);(0,y.useEffect)(()=>{let s=a.current,c=o.current;if(a.current=t,o.current=n,e){if(c!==n){a.current=0;return}if(s>0&&t===0){let e=In(r,n,i);e!==null&&An(`/projects/${e}`)}}},[e,t,n,r,i])},Rn=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)}},zn=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},Bn=(e,t)=>{for(let[n,r]of Object.entries(t.items)){let t=zn(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)}},Vn=(e=null)=>(0,y.useMemo)(()=>{let t=Mt(),n={client:t,body:new Rn(t.fetchItemBody),comments:new Rn(t.fetchComments),files:new Rn(t.fetchPrFiles),commits:new Rn(t.fetchPrCommits),relatedPrs:new Rn(t.fetchRelatedPrs),state:new Rn(t.fetchIssueState),prStatus:new Rn(t.fetchPullRequestStatus)};return e!==null&&Bn(n,e),n},[e]),Hn=0,Un=500,Wn=2e3,Gn=e=>{let t=window;if(typeof t.requestIdleCallback==`function`&&typeof t.cancelIdleCallback==`function`){let n=t.requestIdleCallback(e,{timeout:Wn});return{cancel:()=>t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,0);return{cancel:()=>window.clearTimeout(n)}},Kn=(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)},qn=(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+Hn);if(i.length===0)return;let a=null,o=window.setTimeout(()=>{a=Gn(()=>{for(let t of i)Kn(e,t)})},Un);return()=>{window.clearTimeout(o),a?.cancel()}},[e,t,n])},Jn=`/api/features`,Yn=()=>{let[e,t]=(0,y.useState)({airplaneMode:!1});return(0,y.useEffect)(()=>{fetch(Jn).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},Xn=(e,t)=>{let n=ae.findIndex(t=>t.name===e);if(n===-1)return null;for(let e=n+1;e<ae.length;e+=1){let n=ae[e];if(n.isNavigable!==!1&&(t[n.name]??0)>0)return n.name}return null},Zn=e=>{let t=ae.filter(e=>e.isNavigable!==!1);for(let n of t)if((e[n.name]??0)>0)return n.name;return t[0].name},Qn=new Set(ae.map(e=>e.name)),$n=e=>{let t=e.split(`/`).filter(e=>e.length>0);if(t.length<3||t[0]!==`projects`)return null;let n=t[2];return Qn.has(n)?n:null},er=e=>{if(!e.startsWith(`#item/`))return null;let t=e.slice(6);return t.length===0?null:decodeURIComponent(t)},tr=`#settings`,nr=(e,t)=>{let n=(0,y.useCallback)(()=>{let e=Zn(t);return typeof window>`u`?{activeTab:e,selectedItemKey:null}:{activeTab:$n(window.location.pathname)??e,selectedItemKey:er(window.location.hash)}},[t]),[r,i]=(0,y.useState)(n),a=(0,y.useRef)(null);a.current=e,(0,y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>{i(n())};return window.addEventListener(`popstate`,e),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`hashchange`,e)}},[n]),(0,y.useEffect)(()=>{if(typeof window>`u`||$n(window.location.pathname)!==null)return;let e=Zn(t);Object.values(t).some(e=>e>0)&&a.current!==null&&window.history.replaceState({},``,`/projects/${a.current}/${e}${window.location.search}`),i(t=>t.activeTab===e?t:{...t,activeTab:e})},[t]);let o=(0,y.useCallback)(t=>e===null?`#${t}`:`/projects/${e}/${t}`,[e]),s=(0,y.useCallback)(e=>{if(typeof window>`u`){i({activeTab:e,selectedItemKey:null});return}window.history.pushState({},``,o(e)),i({activeTab:e,selectedItemKey:null})},[o]),c=(0,y.useCallback)(e=>{typeof window<`u`&&(window.location.hash=`#item/${encodeURIComponent(e)}`),i(t=>({...t,selectedItemKey:e}))},[]),l=(0,y.useCallback)(()=>{if(typeof window<`u`&&window.location.hash!==``){let e=`${window.location.pathname}${window.location.search}`;window.history.pushState({},``,e)}i(e=>({...e,selectedItemKey:null}))},[]);return{activeTab:r.activeTab,selectedItemKey:r.selectedItemKey,tabHref:o,selectTab:s,openItem:c,closeItem:l}},rr=e=>`pv_overlay_${e}`,ir=e=>e.projectItemId===``?e.itemId:e.projectItemId,ar=(e,t)=>e!==void 0&&e.done===!0&&e.mode===t,or=(e,t,n)=>e.filter(e=>!ar(t[ir(e)],n)).length,sr=(e,t,n)=>e.filter(e=>!ar(t[ir(e)],n)),cr=(e,t)=>{let n=Date.parse(t);if(Number.isNaN(n))return{};let r={};for(let[t,i]of Object.entries(e))i.ts>=n&&(r[t]=i);return r},lr=(e,t,n)=>{if(n===null)return null;let r=Date.parse(n);if(Number.isNaN(r))return null;let i=e[ir(t)];return i===void 0||i.ts<r?null:i.status??null},ur=(e,t,n,r,i)=>{let a={...e[t]??{},...n,ts:i,mode:r};return{...e,[t]:a}},dr=`/api/review`,fr=`/api/triage`,pr=`/api/intmux`,mr=(e,t,n,r,i)=>{if(r===`approve_and_merge`)return{pjcode:e,action:`approve_and_merge`,prUrl:n,projectItemId:t.projectItemId};if(r===`request_changes`){let r=i[0];return{pjcode:e,action:`request_changes`,prUrl:n,projectItemId:t.projectItemId,commentBody:ge(i),...r===void 0?{}:{changedFilePath:r.path,line:r.line,side:r.side}}}return r===`totally_wrong`?{pjcode:e,action:`close`,prUrl:n,issueUrl:t.url,projectItemId:t.projectItemId,commentBody:pe}:{pjcode:e,action:`unnecessary`,prUrl:n,projectItemId:t.projectItemId,issueUrl:t.url,commentBody:me,issueCommentBody:he(n)}},hr=(e,t,n,r)=>({pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId,...r??{}}),gr=(e,t)=>({pjcode:e,action:`set_intmux`,issueUrl:t.url,projectItemId:t.projectItemId}),_r=()=>Error(`No project specified in the URL path.`),vr=`ok`,yr=(e,t,n,r,i)=>{let{patchOverlay:a}=n,o=(0,y.useCallback)(e=>{if(r===void 0)return;let t=`${e.repo}#${e.number}`;r.body.invalidate(t),r.comments.invalidate(t)},[r]),s=(0,y.useCallback)(e=>{a(ir(e),{done:!0},t)},[a,t]),c=(0,y.useCallback)(async(t,n,r,i=[])=>{if(e===null)throw _r();await Pt(dr,mr(e,t,n,r,i)),s(t),o(t)},[e,s,o]),l=(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Pt(fr,r),o(t)},[e,s,o]),u=(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_agent`,issueUrl:n.url,projectItemId:n.projectItemId,agentOptionId:r.id};a(ir(n),{done:!0},t),await Pt(fr,i),o(n)},[e,o,a,t]);return{reviewPullRequest:c,setNextActionDate:l,setStory:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_story`,issueUrl:n.url,projectItemId:n.projectItemId,storyOptionId:r.id};a(ir(n),{done:!0,story:{name:r.name,color:r.color}},t),await Pt(fr,i),o(n)},[e,o,a,t]),setAgent:u,setStatus:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name};a(ir(n),{done:!0,status:{name:r.name,color:r.color}},t),await Pt(fr,i),o(n)},[e,o,a,t]),setInTmuxByHuman:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();let i={pjcode:e,action:`set_intmux`,issueUrl:n.url,projectItemId:n.projectItemId};a(ir(n),{done:!0,status:{name:r.name,color:r.color}},t),await Pt(pr,i),o(n)},[e,o,a,t]),closeIssue:(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();let r={pjcode:e,action:n,issueUrl:t.url,projectItemId:t.projectItemId};s(t),await Pt(fr,r),o(t)},[e,s,o]),okAndMoveToAwaitingWorkspace:(0,y.useCallback)(async(n,r)=>{if(e===null)throw _r();a(ir(n),{done:!0,status:{name:r.name,color:r.color}},t);let s=await Lt({pjcode:e,url:n.url,body:vr});if(await Pt(fr,{pjcode:e,action:`set_status`,issueUrl:n.url,projectItemId:n.projectItemId,statusName:r.name}),o(n),await i?.(),!s.posted){let e=s.rateLimitResetAt===null?``:` Rate limit resets at ${s.rateLimitResetAt}.`;throw Error(`Comment not posted — ${s.error}.${e} Status was changed. Re-post: ${vr}`)}},[e,o,a,t,i]),addComment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();let r=await Lt({pjcode:e,url:t.url,body:n});if(!r.posted){let e=r.rateLimitResetAt===null?``:` Rate limit resets at ${r.rateLimitResetAt}.`;throw Error(`${r.error}.${e}`)}return o(t),r.comment},[e,o]),uploadAttachment:(0,y.useCallback)(async(t,n)=>{if(e===null)throw Error(`no project in the URL path`);let r=zt(new Uint8Array(await n.arrayBuffer()));return Bt({pjcode:e,url:t.url,fileName:n.name,contentBase64:r})},[e]),addInlineReviewComment:(0,y.useCallback)(async(t,n,r,i,a)=>{if(e===null)throw _r();await Wt({pjcode:e,url:t,path:n,line:r,side:i,body:a})},[e]),deleteAllComments:(0,y.useCallback)(async e=>{await Qt({issueUrl:e.url}),o(e)},[o]),setDependedIssueUrl:(0,y.useCallback)(async(t,n)=>{if(e===null)throw _r();await un({pjcode:e,issueUrl:t.url,dependedIssueUrl:n})},[e])}},br=e=>typeof e==`object`&&!!e&&typeof e.ts==`number`,xr=e=>{if(typeof localStorage>`u`)return{};let t=localStorage.getItem(rr(e));if(t===null)return{};let n=JSON.parse(t);if(typeof n!=`object`||!n)return{};let r={};for(let[e,t]of Object.entries(n))br(t)&&(r[e]=t);return r},Sr=(e,t)=>{typeof localStorage<`u`&&localStorage.setItem(rr(e),JSON.stringify(t))},Cr=e=>{let[t,n]=(0,y.useState)(()=>xr(e));return{overlay:t,patchOverlay:(0,y.useCallback)((t,r,i)=>{n(n=>{let a=ur(n,t,r,i,Date.now());return Sr(e,a),a})},[e])}},wr=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},Tr=()=>{let[e,t]=(0,y.useState)(()=>wr(typeof window>`u`?``:window.location.pathname));return(0,y.useEffect)(()=>{let e=()=>{t(wr(window.location.pathname))};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},[]),e},Er=()=>{let[e,t]=(0,y.useState)([]),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{let e=!1;return l(!0),d(null),on().then(n=>{e||(t(n.pjcodes),r(n.projectUrls),a(n.workflowImprovementIssueUrl),s(n.fleetTaskCreateUrl),l(!1))}).catch(t=>{e||(d(t instanceof Error?t:Error(String(t))),l(!1))}),()=>{e=!0}},[]),{pjcodes:e,projectUrls:n,workflowImprovementIssueUrl:i,fleetTaskCreateUrl:o,isLoading:c,error:u}},Dr=`console-comment-expanded:`,Or=e=>{try{let t=localStorage.getItem(Dr+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}},kr=(e,t)=>{try{localStorage.setItem(Dr+e,JSON.stringify([...t]))}catch(e){console.error(`Failed to save comment expanded state to storage:`,e)}},Ar=()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(Dr)&&e.push(n)}for(let t of e)localStorage.removeItem(t)},jr=e=>(0,y.useCallback)(t=>{Ar(),e(t)},[e]),Mr=()=>typeof window<`u`&&window.location.hash===`#settings`,Nr=e=>{let[t,n]=(0,y.useState)(Mr),[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=>cn(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===tr;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({},``,tr)),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])=>fn({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}},Pr=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,[])}},Fr=/##\s+(?:エグゼクティブサマリ(?:\s*\/\s*Executive\s+Summary)?|Executive\s+Summary)\s*\n/i,Ir=/^From:\s+:robot:/m,Lr=/^##\s/m,Rr=e=>{let t=Fr.exec(e);if(t===null)return null;let n=e.slice(t.index+t[0].length),r=Ir.exec(n),i=Lr.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},zr=e=>{if(e.length===0)return null;let t=e[e.length-1],n=Rr(t.body);if(n!==null)return n;let r=t.body.trim();return r.length>0?r:null},Br=e=>`${e.repo}#${e.number}`,Vr=(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=Br(n),a=t.peek(e);if(a!==void 0){let e=zr(a);r||i(t=>t[n.projectItemId]===e?t:{...t,[n.projectItemId]:e});continue}t.load(e,n.url).then(e=>{if(r)return;let t=zr(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},Hr=(e,t)=>{let n=Math.abs(e);return n<60||n<=Math.abs(t)*1.5?null:e<0?`next`:`previous`},Ur=(e,t)=>{let n=Math.abs(e),r=Math.abs(t);return r>n*1.5&&r>20},Wr=e=>{let t=e instanceof Element?e:null;for(;t!==null&&t!==document.body;){let e=window.getComputedStyle(t).overflowX;if((e===`auto`||e===`scroll`)&&t.scrollWidth>t.clientWidth&&t.scrollLeft>0)return!0;t=t.parentElement}return!1},Gr=e=>{let t=(0,y.useRef)(e);t.current=e;let n=(0,y.useRef)(null),r=(0,y.useCallback)(e=>{let n=0,r=0,i=!1,a=e=>{if(e.touches.length!==1){i=!1;return}if(Wr(e.target)){i=!1;return}let t=e.touches[0];n=t.clientX,r=t.clientY,i=!0},o=e=>{if(!i)return;let t=e.touches[0];Ur(t.clientX-n,t.clientY-r)&&(i=!1)},s=e=>{if(!i||(i=!1,e.changedTouches.length!==1))return;let a=e.changedTouches[0],o=Hr(a.clientX-n,a.clientY-r);o!==null&&t.current(o)};return e.addEventListener(`touchstart`,a,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`touchend`,s,{passive:!0}),()=>{e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s)}},[]),i=(0,y.useCallback)(e=>{n.current!==null&&(n.current(),n.current=null),e!==null&&(n.current=r(e))},[r]);return(0,y.useEffect)(()=>()=>{n.current!==null&&(n.current(),n.current=null)},[]),i},Kr=e=>typeof e==`object`&&!!e&&!Array.isArray(e),qr=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],Jr=e=>Array.isArray(e)?e.filter(Kr).map(e=>({...e,relatedOpenPullRequestUrls:qr(e.relatedOpenPullRequestUrls)})):[],Yr=e=>!Kr(e)||!Array.isArray(e.items)?[]:Jr(e.items),Xr=e=>Array.isArray(e)?e.filter(Kr):[],Zr=e=>Array.isArray(e)?e.filter(Kr).map(e=>({...e,items:Jr(e.items)})):[],Qr=e=>({items:Yr(e),generatedAt:Kr(e)&&typeof e.generatedAt==`string`?e.generatedAt:``,statusOptions:Kr(e)?Xr(e.statusOptions):[],agentOptions:Kr(e)?Xr(e.agentOptions):[],storyOptions:Kr(e)?Xr(e.storyOptions):[],storyColors:Kr(e)&&Kr(e.storyColors)?e.storyColors:{},stories:Kr(e)?Zr(e.stories):[],defaultNameWithOwner:Kr(e)&&typeof e.defaultNameWithOwner==`string`?e.defaultNameWithOwner:null,storyOrder:Kr(e)?qr(e.storyOrder):[],timerEndsAt:Kr(e)&&typeof e.timerEndsAt==`string`?e.timerEndsAt:null,timerTotalSeconds:Kr(e)&&typeof e.timerTotalSeconds==`number`&&e.timerTotalSeconds>0?e.timerTotalSeconds:null}),$r=()=>{let e={};for(let t of ae)e[t.name]=null;return e},ei=(e,t)=>`/projects/${e}/${t}/list.json`,ti=6e4,ni=`console-list-v1`,ri=(e,t)=>{try{if(!(`caches`in globalThis))return;globalThis.caches.open(ni).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)}},ii=async e=>{if(!(`caches`in globalThis))return null;try{let t=await(await globalThis.caches.open(ni)).match(e);return t===void 0?null:{...Qr(await t.json()),fromCache:!0}}catch{return null}},ai=async e=>{let t=await Promise.all(ae.map(async t=>({tabName:t.name,snapshot:await ii(ei(e,t.name))}))),n=$r();for(let{tabName:e,snapshot:r}of t)n[e]=r;return n},oi=async(e,t)=>{let n=ei(e,t);try{let e=await fetch(n);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();return ri(n,t),{snapshot:{...Qr(t),fromCache:!1},error:null}}catch(e){let t=await ii(n);return t===null?{snapshot:null,error:e instanceof Error?e:Error(String(e))}:{snapshot:t,error:null}}},si=async e=>{let t=await Promise.all(ae.map(async t=>{let{snapshot:n,error:r}=await oi(e,t.name);return{tabName:t.name,snapshot:n,error:r}})),n=$r(),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}},ci=(e,t=null)=>{let[n,r]=(0,y.useState)($r),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(null);return(0,y.useEffect)(()=>{if(t!==null&&e!==null){let n=t.tabs[e];if(n!==void 0){let e=$r();for(let t of ae){let r=n[t.name];r!==void 0&&(e[t.name]={...r})}r(e),a(!1),s(null);return}}let n=!1,i=!1;if(s(null),e===null)return r($r()),a(!1),s(`No project specified in the URL path.`),()=>{n=!0};ai(e).then(e=>{if(n)return;let t=Object.values(e).some(e=>e!==null);t&&!i?(r(e),a(!1)):!t&&!i&&(a(!0),r($r()))});let o=()=>{si(e).then(({snapshots:e,firstError:t})=>{n||(i=!0,r(e),s(t===null?null:t.message),a(!1))}).catch(e=>{n||(i=!0,s(e instanceof Error?e.message:String(e)),a(!1))})};o();let c=setInterval(o,ti);return()=>{n=!0,clearInterval(c)}},[e,t]),{snapshots:n,isLoading:i,error:o,refreshSingleTab:(0,y.useCallback)(async t=>{if(e===null)return;let{snapshot:n}=await oi(e,t);n!==null&&r(e=>({...e,[t]:n}))},[e])}},li=e=>(0,y.useCallback)(t=>{Ar(),e(t)},[e]),ui=()=>{let[e,t]=(0,y.useState)(Pn),[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=>(Fn(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}},di=(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},fi=(e,t)=>{let n=e.indexOf(t);return n<0||n>=e.length-1?null:e[n+1]},pi=(e,t)=>{let n=e.indexOf(t);return n<=0?null:e[n-1]},mi=(e,t)=>e.length===0?`${t}\n`:e.endsWith(`
|
|
14
14
|
`)?`${e}${t}\n`:`${e}\n${t}\n`,hi=(e,t)=>{let n=`![uploading ${t}]()`;return`${e.length===0?``:e.replace(/\n*$/,`
|
|
15
15
|
`)}\n\n\n${n}\n`},gi=(e,t,n)=>{let r=`![uploading ${t}]()`,i=e.indexOf(r);return i===-1?mi(e,n):e.slice(0,i)+n+e.slice(i+r.length)},_i=(e,t)=>{let n=`![uploading ${t}]()`,r=e.indexOf(n);if(r===-1)return e;let i=r,a=0;for(;a<3&&i>0&&e[i-1]===`
|
|
16
16
|
`;)i--,a++;let o=+(e[r+n.length]===`
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>TDPM Console</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-D9wVV6wh.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-BlQJRUQT.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|