ccdeck 3.47.0 → 3.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +28 -4
  2. package/bin/cli/commands.js +17 -9
  3. package/bin/cli/help.js +9 -4
  4. package/bin/cli/second-start.js +4 -2
  5. package/bin/cli/startup.js +3 -2
  6. package/bin/cli/tui.js +544 -0
  7. package/dist/web/assets/BrowserWatchModal-Dfsuy2cT.js +1 -0
  8. package/dist/web/assets/IntegrationModal-CcSR7YB-.js +7 -0
  9. package/dist/web/assets/{RadioPanel-DbmJJPsz.js → RadioPanel-s7WXdS6v.js} +1 -1
  10. package/dist/web/assets/{TrafficRadar-CPjAXd5e.js → TrafficRadar-C5GXMIwi.js} +1 -1
  11. package/dist/web/assets/UsageHistoryModal-CiExD9wF.js +1 -0
  12. package/dist/web/assets/app-BFaxhiED.js +321 -0
  13. package/dist/web/assets/app-DjlHxWHg.css +1 -0
  14. package/dist/web/assets/{index-Ca87aJP9.js → index-ByovgZ_7.js} +1 -1
  15. package/dist/web/index.html +3 -3
  16. package/package.json +1 -1
  17. package/release-notes.json +30 -3
  18. package/src/server/args.mjs +1 -0
  19. package/src/server/cli-lines.mjs +46 -0
  20. package/src/server/deck-prefs.mjs +23 -13
  21. package/src/server/gpu-metrics.mjs +78 -0
  22. package/src/server/integrations/jira-move.mjs +239 -0
  23. package/src/server/integrations/jira.mjs +30 -8
  24. package/src/server/integrations/proxy.mjs +3 -4
  25. package/src/server/integrations/routes.mjs +19 -5
  26. package/src/server/lan-deck.mjs +2 -1
  27. package/src/server/system-metrics.mjs +4 -0
  28. package/src/server/term.mjs +14 -5
  29. package/src/server/tui-screen.mjs +110 -0
  30. package/src/server/tui-view.mjs +1072 -0
  31. package/src/server/way-back.mjs +27 -0
  32. package/dist/web/assets/BrowserWatchModal-Bau0ttnH.js +0 -1
  33. package/dist/web/assets/IntegrationModal-8tTi25gA.js +0 -6
  34. package/dist/web/assets/UsageHistoryModal-qfmvXdWJ.js +0 -1
  35. package/dist/web/assets/app-BFFG6Wz8.js +0 -321
  36. package/dist/web/assets/app-DfcfHvcX.css +0 -1
@@ -0,0 +1,7 @@
1
+ import{r as Dr,a as Ir,w as Fr,b as i,p as As,m as Ls,j as t,u as Br,f as Or,I as Yt,c as Pr,q as Ur,R as _r,s as we,d as Ce,e as Es,i as Kr,A as nn,H as Hr,g as jt,E as xt,h as Wr,t as qr,k as Ms,T as Gr,l as Vr,n as zr,o as Jr,v as Xr,x as Qr,y as Yr,z as Zr,B as ea,C as ta,D as na,F as sa}from"./app-BFaxhiED.js";const Re={min:320,max:1600},Bt=.5;function Ts(e){return Number.isFinite(e)&&e>0&&e<1?e:Bt}function Ds(e=Bt){return`clamp(${Re.min}px, ${Ts(e)*100}%, ${Re.max}px)`}const ra=420,aa=8,oa="(max-width: 899px)",Sn=e=>`agent-dag.integrations.${e}.detail-width`;function At(e,n){const s=Math.max(Re.min,Math.min(Re.max,n-ra-aa));return Math.round(Math.min(s,Math.max(Re.min,Number.isFinite(e)?e:n*Bt)))}function Yn(e,n=Bt){return At(e*Ts(n),e)}function la(e){const n=Dr(Sn(e));if(n==null)return null;const s=Number(n);return Number.isFinite(s)&&s>=Re.min&&s<=Re.max?Math.round(s):null}function ia(e,n){n==null?Ir(Sn(e)):Fr(Sn(e),String(Math.round(n)))}function ca({width:e,workspace:n,controls:s,onCommit:r,automaticDetailShare:a}){const o=i.useRef(null),d=i.useRef(null),l=()=>{var x;return((x=n.current)==null?void 0:x.clientWidth)??window.innerWidth},c=e==null?Yn(l(),a):At(e,l()),u=x=>{var m,k;(m=n.current)==null||m.style.setProperty("--ig-detail-w",`${x}px`),(k=o.current)==null||k.setAttribute("aria-valuenow",String(x))},j=x=>{var m,k;x==null?((m=n.current)==null||m.style.setProperty("--ig-detail-w",Ds(a)),(k=o.current)==null||k.setAttribute("aria-valuenow",String(Yn(l(),a)))):u(x),r(x)},h=x=>{var m;x.button===0&&(x.preventDefault(),x.currentTarget.setPointerCapture(x.pointerId),d.current={x:x.clientX,width:c,room:l(),last:c},(m=n.current)==null||m.setAttribute("data-resizing",""))},f=x=>{const m=d.current;m&&(m.last=At(m.width+m.x-x.clientX,m.room),u(m.last))},g=()=>{var m;const x=d.current;x&&(d.current=null,(m=n.current)==null||m.removeAttribute("data-resizing"),j(x.last))},y=x=>{const m=x.shiftKey?64:16;if(x.key==="Enter"){x.preventDefault(),j(null);return}const k=x.key==="ArrowLeft"?c+m:x.key==="ArrowRight"?c-m:x.key==="Home"?Re.min:x.key==="End"?Re.max:null;k!==null&&(x.preventDefault(),j(At(k,l())))};return t.jsx("div",{ref:o,className:"ig-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Detail width","aria-controls":s,"aria-valuemin":Re.min,"aria-valuemax":At(Re.max,l()),"aria-valuenow":c,tabIndex:0,title:"Drag to resize · double-click for the automatic width",onPointerDown:h,onPointerMove:f,onPointerUp:g,onPointerCancel:g,onLostPointerCapture:g,onDoubleClick:()=>j(null),onKeyDown:y})}function Is(){return Br(oa)}function _n({list:e,detail:n,onBack:s,backLabel:r,storageKey:a,detailKey:o,automaticDetailShare:d=Bt}){const l=Is(),c=`${i.useId()}-detail`,u=i.useRef(null),j=i.useRef(null),h=i.useRef(null),f=i.useRef(null),[g,y]=i.useState(()=>la(a)),x=w=>{y(w),ia(a,w)},m=n!=null,k=i.useRef(null);m&&(k.current=n);const[p,T]=i.useState(m),[L,R]=i.useState(null);p!==m&&(T(m),R(!m&&l&&!As()?k.current:null));const v=m?n:L,S=!m&&L!=null;i.useEffect(()=>{if(!S)return;const w=window.setTimeout(()=>R(null),200);return()=>window.clearTimeout(w)},[S]),i.useLayoutEffect(()=>{h.current&&(h.current.inert=S)},[S]),i.useLayoutEffect(()=>{const w=h.current;!w||!m||(w.dataset.flip=w.dataset.flip==="a"?"b":"a")},[m,o]);const F=i.useRef(null);i.useLayoutEffect(()=>{var $,I,B,C;if(!m)return;const w=document.activeElement;w instanceof HTMLElement&&(($=j.current)!=null&&$.contains(w))&&(F.current=w);const E=w instanceof HTMLElement&&!(((I=w.checkVisibility)==null?void 0:I.call(w))??!0);l&&(!w||w===document.body||E||(B=j.current)!=null&&B.contains(w))&&((C=f.current)==null||C.focus({preventScroll:!0}))},[m,l,o]),i.useEffect(()=>{if(m)return;const w=F.current;if(!w)return;const E=requestAnimationFrame(()=>{var I;const $=document.activeElement;(!$||$===document.body)&&w.isConnected&&(((I=w.checkVisibility)==null?void 0:I.call(w))??!0)&&w.focus({preventScroll:!0})});return()=>cancelAnimationFrame(E)},[m]);const K=i.useRef(s);return K.current=s,i.useEffect(()=>{if(m)return Ls.push(()=>K.current(),0,"popover")},[m]),t.jsxs("div",{ref:u,className:"ig-split","data-detail":m||void 0,"data-drill-in":l||void 0,style:{"--ig-detail-w":g==null?Ds(d):`${g}px`},children:[t.jsx("div",{ref:j,className:"ig-list",hidden:l&&m||void 0,children:e}),m&&!l&&t.jsx(ca,{width:g,workspace:u,controls:c,onCommit:x,automaticDetailShare:d}),v!=null&&t.jsxs("section",{ref:h,className:"ig-detail",id:c,"aria-label":"Details","data-leaving":S||void 0,onAnimationEnd:w=>{S&&w.target===w.currentTarget&&R(null)},children:[l&&t.jsxs("button",{ref:f,type:"button",className:"ig-back","data-ig-back":!0,onClick:s,children:[t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:t.jsx("path",{d:"M8.6 3 4.6 7l4 4"})}),r]}),v]})]})}const Fs=e=>e.issueKeys??[e.issueKey];function da(e,n,s,r,a){if(!n.includes(s))return new Set(e);if(a==="replace")return new Set([s]);if(a==="toggle"){const c=new Set(e);return c.has(s)?c.delete(s):c.add(s),c}const o=r?n.indexOf(r):-1,d=n.indexOf(s),l=o<0?[s]:n.slice(Math.min(o,d),Math.max(o,d)+1);return new Set([...a==="add-range"?e:[],...l])}function Tt(e){return e.kind==="backlog"?{kind:"backlog"}:(e.kind==="active"||e.kind==="future")&&e.sprint&&(e.sprint.state==="active"||e.sprint.state==="future")?{kind:"sprint",sprintId:e.sprint.id}:null}function zt(e,n){return Qe({issue:e,group:n})===null}function Qe({issue:e,group:n}){return e.type.subtask?"is a subtask":e.type.epic?"is an epic":e.status.category==="done"?`is ${e.status.name}`:n.kind==="closed"?"is in a closed sprint":Tt(n)?null:"is not in an active/future sprint or the backlog"}function Jt(e){const n=e.filter(s=>Qe(s));return n.length?`${n.slice(0,2).map(s=>`${s.issue.key} ${Qe(s)}`).join("; ")}${n.length>2?`; ${n.length-2} more blocked`:""}. Remove blocked issues to move the rest.`:e.length>50?"Move up to 50 issues at a time.":""}function Cn(e,n,s){const r=Tt(n),a=e.map(o=>o.issue.key);return!e.length||e.length>50||new Set(a).size!==a.length||!r||e.some(o=>!zt(o.issue,o.group))||s&&a.includes(s.key)||e.every(o=>o.group.id===n.id)&&!s?null:{...a.length===1?{issueKey:a[0]}:{issueKeys:a},target:r,...s?s.side==="before"?{beforeIssue:s.key}:{afterIssue:s.key}:{}}}async function ua(e,n,s){var o;const r=new AbortController,a=window.setTimeout(()=>r.abort(),45e3);try{const d=await e(`board/${encodeURIComponent(n)}/move`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(s),signal:r.signal}),l=(o=d.body)==null?void 0:o.getReader(),c=()=>{l==null||l.cancel().catch(()=>{})};r.signal.addEventListener("abort",c,{once:!0});let u="";try{const g=new TextDecoder;let y=0;for(;l&&!r.signal.aborted;){const x=await l.read();if(x.done)break;if(y+=x.value.byteLength,y>16384)throw new Error("Result too large");u+=g.decode(x.value,{stream:!0})}if(u+=g.decode(),r.signal.aborted)throw new Error("Deadline exceeded")}finally{r.signal.removeEventListener("abort",c),await(l==null?void 0:l.cancel().catch(()=>{}))}if(!d.ok)throw await Or(new Response(u,{status:d.status}));if(d.status===204)return{};const j=JSON.parse(u),h=Fs(s),f=j&&typeof j=="object"&&(s.issueKeys?"issueKeys"in j&&Array.isArray(j.issueKeys)&&j.issueKeys.length===h.length&&j.issueKeys.every((g,y)=>g===h[y]):"issueKey"in j&&j.issueKey===s.issueKey);if(!j||typeof j!="object"||Array.isArray(j)||!("ok"in j)||j.ok!==!0||!f||"notice"in j&&(typeof j.notice!="string"||j.notice.length>1e3))throw new Error("Unconfirmed result");return"notice"in j?{notice:j.notice}:{}}catch(d){throw d instanceof Yt?d:new Yt("network","The move could not be confirmed. Refresh the board before trying again.")}finally{window.clearTimeout(a)}}const Nt=(e,n,s={},r)=>Pr(e,`${n}${Ur(s)}`,{signal:r}),Bs=(e,n,s,r)=>Nt(e,"boards",{startAt:n||void 0,name:s},r),ha=(e,n,s)=>Nt(e,`board/${encodeURIComponent(n)}`,{},s),fa=(e,n,s,r)=>Nt(e,`board/${encodeURIComponent(n)}/closed-sprints`,{startAt:s||void 0},r),Zn=(e,n,s,r)=>Nt(e,`board/${encodeURIComponent(n)}/issues`,{source:s.source,sprint:s.sprint,column:s.column,cursor:s.cursor||void 0,backlog:s.backlog,mine:s.mine,quick:s.quick.join(",")||void 0},r),ma=(e,n,s)=>Nt(e,`issue/${encodeURIComponent(n)}/subtasks`,{},s),pa=(e,n,s)=>Nt(e,`issue/${encodeURIComponent(n)}`,{},s);function ga(e,n,s){var l;let r;try{r=new URL(s)}catch{return null}const a=typeof((l=e.meta)==null?void 0:l.apiBase)=="string"?e.meta.apiBase:"";let o="";try{o=new URL(e.baseUrl).origin}catch{}if(a&&r.origin===o&&/^\/(rest|images)\//.test(r.pathname))try{r=new URL(`${a}${r.pathname}${r.search}`)}catch{return null}if(/\.svg$/i.test(r.pathname))return null;const d=r.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(r.hostname)&&e.allowedOrigins.includes(r.origin);return r.protocol!=="https:"&&!d?null:n(r.href)}const xn=e=>`sprint:${e.id}`;function es(e,n=[]){const s=[];if(e.hasSprints){for(const r of e.sprints.active)s.push({id:xn(r),kind:"active",title:r.name,sprint:r,defaultOpen:!0,paged:!1});for(const r of e.sprints.future)s.push({id:xn(r),kind:"future",title:r.name,sprint:r,defaultOpen:!1,paged:!1});e.hasBacklog&&s.push({id:"backlog",kind:"backlog",title:"Backlog",defaultOpen:!1,paged:!0});for(const r of n)s.push({id:xn(r),kind:"closed",title:r.name,sprint:r,defaultOpen:!1,paged:!1});return s}return s.push({id:"column:todo",kind:"column",column:"todo",title:"To Do",defaultOpen:!0,paged:!1}),s.push({id:"column:progress",kind:"column",column:"progress",title:"In Progress",defaultOpen:!0,paged:!1}),s.push({id:"column:done",kind:"column",column:"done",title:"Done in the last 14 days",defaultOpen:!1,paged:!1}),e.hasBacklog&&s.push({id:"backlog",kind:"backlog",title:"Backlog",defaultOpen:!1,paged:!0}),s}function Lt(e,n){return Object.hasOwn(n,e.id)?n[e.id]:e.defaultOpen}const Ye=e=>e.kind==="issue"?e.issue.key:e.parent.key;function ja(e,n=new Set){const s=new Map;for(const o of e)!n.has(o.key)&&!s.has(o.key)&&s.set(o.key,o);const r=[],a=new Map;for(const o of s.values()){const d=o.type.subtask&&o.parent?o.parent.key:null;if(d&&d!==o.key){let c=a.get(d);if(!c){const u=s.get(d);u&&!n.has(d)?c={kind:"issue",issue:u,matched:[]}:(c={kind:"context",parent:o.parent,matched:[]},r.push(c)),a.set(d,c)}c.matched.push(o);continue}let l=a.get(o.key);l||(l={kind:"issue",issue:o,matched:[]},a.set(o.key,l)),r.push(l)}for(const o of s.keys())n.add(o);return r}const Zt=e=>e.status.category==="done";function Kn(e){const n=e.trim().toLowerCase();return/highest|blocker|critical|urgent/.test(n)?"highest":/high|major/.test(n)?"high":/medium|normal|moderate/.test(n)?"medium":/lowest|trivial/.test(n)?"lowest":/low|minor/.test(n)?"low":null}function xa(e){return!Zt(e)&&(e.flagged||e.priority!=null&&Kn(e.priority.name)==="highest")}function ba(e){var s;const n=((s=e.resolution)==null?void 0:s.trim())??"";return n&&n.toLowerCase()!==e.status.name.trim().toLowerCase()?n:null}function ya({handedOff:e,narrow:n,focusLost:s,focusOnBack:r}){return s?e||n:n&&r}function Os(e,n){return(!n.hideDone||!Zt(e))&&(!n.attention||xa(e))}const ka=/^only my issues$/i;function wa(e){return e.filter(n=>!ka.test(n.name.trim()))}function Na(e,n){return n?e.key.toLowerCase().includes(n)||e.summary.toLowerCase().includes(n):!0}function va(e,n,s){const r=n.search.trim().toLowerCase();if(!r&&!n.hideDone&&!n.attention)return e.slice();const a=d=>Os(d,n)&&Na(d,r),o=[];for(const d of e){const l=d.matched.filter(a),c=(s==null?void 0:s(Ye(d)))??[],u=l.length>0||c.some(a);d.kind==="issue"?(a(d.issue)||u)&&o.push({...d,matched:l}):u&&o.push({...d,matched:l})}return o}function Ps(e,n,s,r){const a=new Set;return e.map(o=>{const d=n[o.id];return{def:o,data:d,rows:va(ja((d==null?void 0:d.issues)??[],a),r,s)}})}function Rn(e,n){return n[Ye(e)]??e.kind==="context"}function An(e,n,s){return(n==null?void 0:n.status)==="ready"?n.issues.filter(r=>Os(r,s)):e.matched}function Us(e,n){if(e.kind==="context")return!0;const s=e.issue.subtaskKeys;return s.length===0?!1:n||!s.every(r=>e.matched.some(a=>a.key===r))}function $a(e,n,s,r,a,o){const d=new Set;let l=!0,c=null;for(const{def:u,data:j,rows:h}of e)if(Lt(u,n)){if(!j||j.status!=="ready"&&j.status!=="error"&&j.issues.length===0){l=!1;continue}c==null&&l&&h.length>0&&(c=Ye(h[0]));for(const f of h){const g=Ye(f);if(d.add(g),!Rn(f,s))continue;const y=r[g];for(const x of An(f,y,a))d.add(x.key);(y?y.status==="loading":Us(f,o))&&(l=!1)}}return{complete:l,keys:d,first:c}}function Sa(e){return e.flatMap(n=>n.kind==="issue"?[n.issue]:n.matched)}function Ca(e,n){const s=Sa(e),r={new:0,indeterminate:0,done:0},a=new Map;let o=0,d=0,l=null,c=0,u=0;for(const h of s){const f=n==="count"?1:n==="points"?h.points??0:h.estimate??0;if(r[h.status.category]+=f,h.assignee){const g=a.get(h.assignee.id);g?g.n++:a.set(h.assignee.id,{person:h.assignee,n:1})}h.mine&&(o++,h.assignee&&(l=h.assignee.id),Zt(h)&&d++),Zt(h)||(h.flagged&&c++,h.priority&&Kn(h.priority.name)==="highest"&&u++)}const j=[...a.values()].sort((h,f)=>f.n-h.n||h.person.name.localeCompare(f.person.name)).map(h=>h.person);return{count:s.length,totals:r,assignees:j,mine:o,mineDone:d,youId:l,flagged:c,highest:u}}function pt(e,n={hoursPerDay:8,daysPerWeek:5}){if(e==null||!Number.isFinite(e))return"";let s=Math.round(e/60);if(s<=0)return"0m";const r=60,a=Math.round(n.hoursPerDay*r),o=Math.round(a*n.daysPerWeek),d=[];for(const[l,c]of[[o,"w"],[a,"d"],[r,"h"],[1,"m"]]){if(l<=0)continue;const u=Math.floor(s/l);u>0&&(d.push(`${u}${c}`),s-=u*l)}return d.join(" ")}function ts(e,n,s){return n==="time"?pt(e,s)||"0m":n==="points"?`${Number.isInteger(e)?e:e.toFixed(1)}`:String(e)}function ns(e){if(!e)return"";const n=new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleDateString(void 0,{day:"numeric",month:"short"})}function Ra(e,n){const s=pt(e.estimate,n),r=pt(e.timeSpent,n),a=e.remaining!=null&&(e.remaining!==e.estimate||r)?pt(e.remaining,n):"";return[s&&`${s} estimated`,a&&`${a} left`,r&&`${r} logged`].filter(Boolean).join(" · ")}function St(e,n=!1){if(!e)return"";const s=new Date(String(e).replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isNaN(s.getTime())?String(e):n?s.toLocaleString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Aa(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(e<10*1024?1:0)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const La=120,at=new Map,Ln=new Map,Ea=()=>({selection:null,closed:!1,listTop:0,detailTop:0,rows:{},section:null});function _s(e,...n){return[e,...n.map(s=>s??"*")].join("|")}function Dt(e){return at.get(e)??null}function ot(e,n){const s={...at.get(e)??Ea(),...n};for(at.delete(e),at.set(e,s);at.size>La;)at.delete(at.keys().next().value)}function En(e){return Ln.get(e)??""}function Ks(e,n){n?Ln.set(e,n):Ln.delete(e)}function Ma(e,n,s){if(e!=null&&e.closed)return{kind:"none",listTop:e.listTop};if((e==null?void 0:e.selection)!=null){if(n.has(e.selection))return{kind:"restore",selection:e.selection,listTop:e.listTop,detailTop:e.detailTop};if(!n.complete)return{kind:"wait"}}return s?n.first!=null?{kind:"first",selection:n.first}:{kind:"wait"}:{kind:"none",listTop:(e==null?void 0:e.selection)!=null?0:(e==null?void 0:e.listTop)??0}}function ss(e,n){const s=Dt(e);return s!=null&&s.closed?{key:e,selection:null,auto:!1,settled:!0,plan:{list:s.listTop,detail:null}}:{key:e,selection:null,auto:!1,settled:!1,plan:n?null:{list:0,detail:null}}}function Ta(e,n,s){if(e.settled||!n)return e;const r=Ma(Dt(e.key),n,s);return r.kind==="wait"?e:r.kind==="none"?{key:e.key,selection:null,auto:!1,settled:!0,plan:{list:r.listTop,detail:null}}:r.kind==="first"?(ot(e.key,{selection:r.selection,closed:!1,section:null,listTop:0,detailTop:0}),{key:e.key,selection:r.selection,auto:!0,settled:!0,plan:{list:0,detail:0}}):{key:e.key,selection:r.selection,auto:!0,settled:!0,plan:{list:r.listTop,detail:r.detailTop}}}function Da(e,n,s){const r=n==null||e.selection==null||!s(e.selection,n);return ot(e.key,{selection:n,closed:n==null,...r?{section:null,detailTop:0}:{}}),{key:e.key,selection:n,auto:!1,settled:!0,plan:null}}const Xt=typeof window>"u"?i.useEffect:i.useLayoutEffect,Ia=3e3,rs=["wheel","pointerdown","touchstart","keydown"];function Fa(e,n,s){let r=!1,a=0,o=0,d=null;const l=()=>{if(!r){r=!0,cancelAnimationFrame(a),d==null||d.disconnect();for(const u of rs)e.removeEventListener(u,l);s()}},c=()=>{if(r)return;if(!e.isConnected){l();return}if(e.clientHeight===0){!d&&typeof ResizeObserver<"u"&&(d=new ResizeObserver(()=>{e.clientHeight!==0&&(d==null||d.disconnect(),d=null,c())}),d.observe(e));return}o||(o=performance.now()+Ia);const u=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop=Math.min(n,u),u>=n||performance.now()>=o){l();return}a=requestAnimationFrame(c)};for(const u of rs)e.addEventListener(u,l,{passive:!0});return c(),l}const bn=".ig-detail";function Hs({listKey:e,drawn:n,same:s,sideBySide:r,root:a,listScroller:o}){const[d,l]=i.useState(()=>ss(e,!0));let c=d;d.key!==e&&(c=ss(e,!1),l(c));const u=i.useRef(c);u.current=c;const j=i.useRef(s);j.current=s;const h=i.useRef(!1),f=i.useRef(!1),g=c.plan;Xt(()=>{const k=a.current;if(!g||!k)return;const p=[],T=(L,R,v)=>{const S=v==null?null:k.querySelector(R);!S||v==null||(L.current=!0,p.push(Fa(S,v,()=>{L.current=!1})))};return T(h,o,g.list),T(f,bn,g.detail),()=>{for(const L of p)L()}},[g,a,o]),Xt(()=>{const k=Ta(c,n,r);k!==c&&l(k)},[c,n,r]),i.useEffect(()=>{const k=a.current;if(!k)return;const p=T=>{const L=T.target;L instanceof HTMLElement&&(L.matches(bn)?f.current||ot(u.current.key,{detailTop:L.scrollTop}):L.matches(o)&&(h.current||ot(u.current.key,{listTop:L.scrollTop})))};return k.addEventListener("scroll",p,{capture:!0,passive:!0}),()=>k.removeEventListener("scroll",p,{capture:!0})},[a,o]);const{selection:y,auto:x}=c;Xt(()=>{var p;if(x||!y||f.current)return;const k=(p=a.current)==null?void 0:p.querySelector(bn);ot(u.current.key,{detailTop:(k==null?void 0:k.scrollTop)??0})},[y,x,a]);const m=i.useCallback(k=>l(Da(u.current,k,j.current)),[]);return{selection:y,auto:x,choose:m}}const Ba=5*6e4,Oa=2*6e4,Pa=24,as={shown:!1,sprints:[],total:0,isLast:!1,loading:!1,error:null},Ua={status:"idle",issues:[],next:"",total:null,capped:!1,error:null,more:!1},Pe=new Map,Mn=new Set;function _a(e){for(const[n,s]of Pe)n.startsWith(`${e}|`)&&Pe.set(n,{...s,loadedAt:0});for(const n of Xe.keys())n.startsWith(`${e}|`)&&Xe.delete(n);for(const n of Mn)n(e)}const Ka=(e,n,s)=>`${e}|${n}|${s.mine?"mine":"all"}|${s.quick.join(",")}`;function Ha(e,n){for(Pe.delete(e),Pe.set(e,n);Pe.size>Pa;)Pe.delete(Pe.keys().next().value)}function os(e,n){for(const[s,r]of[...Pe.entries()].reverse())if(s.startsWith(`${e}|${n}|`)&&r.overview)return{overview:r.overview,groups:{},subtasks:{},closed:{...as,shown:r.closed.shown,sprints:r.closed.sprints,total:r.closed.total,isLast:r.closed.isLast},loadedAt:0};return{overview:null,groups:{},subtasks:{},closed:as,loadedAt:0}}function Ge(e){return e instanceof Yt?e:new Yt("upstream",e instanceof Error&&e.message?e.message:"Jira could not be read.")}const Tn=e=>e instanceof DOMException&&e.name==="AbortError",Wa=new Set(["auth","expired","rate-limit","tls","unreachable","incompatible","network","unavailable"]);function ls(e,n,s,r=""){const a={mine:n.mine,quick:n.quick};return e.kind==="backlog"?{...a,source:"backlog",cursor:r}:e.kind==="column"?{...a,source:"kanban",column:e.column,backlog:s.hasBacklog}:{...a,source:"sprint",sprint:e.sprint.id}}async function qa(e,n,s){let r=0;const a=Array.from({length:Math.min(n,e.length)},async()=>{for(;r<e.length;)await s(e[r++])});await Promise.all(a)}function Ga(e,n,s,r){const a=s?Ka(n,s,r):"",[o,d]=i.useState(()=>a&&Pe.get(a)||os(n,s??"")),l=i.useRef(o),[c,u]=i.useState(!1),[j,h]=i.useState(null),f=i.useRef(0),g=i.useRef(null),y=i.useRef(a),x=i.useRef(r);x.current=r;const m=i.useCallback(($,I)=>{if($!==y.current)return;const B=I(l.current);l.current=B,$&&Ha($,B),d(B)},[]),k=i.useCallback(($,I,B)=>{m($,C=>({...C,groups:{...C.groups,[I]:B(C.groups[I]??Ua)}}))},[m]),p=i.useCallback(async($,I,B,C)=>{if(s){k($,I.id,U=>({...U,status:"loading",error:null}));try{const U=await Zn(e,s,ls(I,x.current,B),C);k($,I.id,()=>({status:"ready",issues:U.issues,next:U.next,total:U.total,capped:U.capped,error:null,more:!1}))}catch(U){if(Tn(U)||C.aborted)return;const W=Ge(U);if(k($,I.id,ee=>({...ee,status:"error",error:W,more:!1})),Wa.has(W.kind))throw W}}},[s,e,k]),T=i.useCallback(async()=>{var U;if(!s)return;const $=y.current,I=++f.current;(U=g.current)==null||U.abort();const B=new AbortController;g.current=B;const{signal:C}=B;u(!0),h(null),await(async()=>{try{const W=await ha(e,s,C);if(I!==f.current)return;m($,Y=>({...Y,overview:W,subtasks:{}}));const ee=l.current.closed,se=es(W,ee.shown?ee.sprints:[]),V=se.filter(Y=>Y.kind==="active"||Y.kind==="column"&&Y.column!=="done"),J=se.filter(Y=>!V.includes(Y)&&(Y.kind!=="closed"||l.current.groups[Y.id]));await Promise.all(V.map(Y=>p($,Y,W,C))),await qa(J,3,Y=>C.aborted?Promise.resolve():p($,Y,W,C)),I===f.current&&m($,Y=>({...Y,loadedAt:Date.now()}))}catch(W){if(Tn(W)||C.aborted||I!==f.current)return;B.abort(),h(Ge(W))}finally{I===f.current&&u(!1)}})()},[s,e,p,m]);i.useEffect(()=>{var B;y.current=a;const $=a?Pe.get(a):void 0,I=$??os(n,s??"");if(l.current=I,d(I),h(null),!s){(B=g.current)==null||B.abort(),u(!1);return}(!$||Date.now()-$.loadedAt>Ba)&&T()},[a]),i.useEffect(()=>()=>{var $;($=g.current)==null||$.abort()},[]);const L=i.useCallback(($,I=!1)=>{const B=l.current.overview,C=l.current.groups[$.id];if(!B||C&&C.status!=="idle"&&!(I&&C.status==="error"))return;const U=g.current&&!g.current.signal.aborted?g.current.signal:new AbortController().signal,W=y.current;p(W,$,B,U).catch(ee=>h(Ge(ee)))},[p]),R=i.useCallback($=>{const I=l.current.overview,B=l.current.groups[$.id];if(!s||!I||!B||!B.next||B.more)return;const C=y.current;k(C,$.id,U=>({...U,more:!0,error:null})),(async()=>{try{const U=await Zn(e,s,ls($,x.current,I,B.next));k(C,$.id,W=>{const ee=new Set(W.issues.map(se=>se.key));return{...W,issues:[...W.issues,...U.issues.filter(se=>!ee.has(se.key))],next:U.next,total:U.total??W.total,capped:U.capped,more:!1}})}catch(U){const W=Ge(U);k(C,$.id,ee=>({...ee,more:!1,error:W}))}})()},[s,e,k]),v=i.useCallback($=>{if(!s)return;const I=y.current;m(I,B=>({...B,closed:{...B.closed,shown:!0,loading:!0,error:null}})),(async()=>{try{const B=await fa(e,s,$);m(I,C=>{const U=new Set(C.closed.sprints.map(ee=>ee.id)),W=$===0?B.sprints:[...C.closed.sprints,...B.sprints.filter(ee=>!U.has(ee.id))];return{...C,closed:{...C.closed,sprints:W,total:B.total,isLast:B.isLast,loading:!1,error:null}}})}catch(B){const C=Ge(B);m(I,U=>({...U,closed:{...U.closed,loading:!1,error:C}}))}})()},[s,e,m]),S=i.useCallback($=>{const I=y.current;if(!$){m(I,C=>({...C,closed:{...C.closed,shown:!1}}));return}const B=l.current.closed;B.sprints.length||B.loading?m(I,C=>({...C,closed:{...C.closed,shown:!0}})):v(0)},[v,m]),F=i.useCallback(()=>{const $=l.current.closed;$.loading||$.isLast||v($.sprints.length)},[v]),K=i.useCallback($=>{const I=l.current.subtasks[$];if(I&&I.status!=="error")return;const B=y.current,C=U=>m(B,W=>({...W,subtasks:{...W.subtasks,[$]:U}}));C({status:"loading",issues:(I==null?void 0:I.issues)??[],error:null}),ma(e,$).then(U=>C({status:"ready",issues:U.issues,error:null})).catch(U=>C({status:"error",issues:[],error:Ge(U)}))},[e,m]),w=o.closed,E=o.overview?es(o.overview,w.shown?w.sprints:[]):[];return{snap:o,groups:E,loading:c,error:j,refresh:T,ensureGroup:L,loadMore:R,showClosed:S,moreClosed:F,loadSubtasks:K}}const Xe=new Map;function Va(e,n,s){const r=s?`${n}|${s}`:"",[a,o]=i.useState(()=>{var y;return r?((y=Xe.get(r))==null?void 0:y.data)??null:null}),[d,l]=i.useState(!1),[c,u]=i.useState(null),[j,h]=i.useState(0),f=i.useRef(!1);i.useEffect(()=>{const y=x=>{x===n&&s&&(f.current=!0,h(m=>m+1))};return Mn.add(y),()=>{Mn.delete(y)}},[n,s]),i.useEffect(()=>{if(!s){o(null),u(null);return}const y=Xe.get(r);if(o((y==null?void 0:y.data)??null),u(null),y&&!f.current&&Date.now()-y.at<Oa){l(!1);return}f.current=!1;const x=new AbortController;return l(!0),pa(e,s,x.signal).then(m=>{Xe.set(r,{at:Date.now(),data:m}),Xe.size>60&&Xe.delete(Xe.keys().next().value),o(m)}).catch(m=>{!Tn(m)&&!x.signal.aborted&&u(Ge(m))}).finally(()=>{x.signal.aborted||l(!1)}),()=>x.abort()},[r,e,s,j]);const g=i.useCallback(()=>{f.current=!0,h(y=>y+1)},[]);return{data:a,loading:d,error:c,reload:g}}function za(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[t.jsx("circle",{cx:"6.1",cy:"6.1",r:"4.1"}),t.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]})}function Ws(){return t.jsxs("svg",{className:"ig-mark",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[t.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),t.jsx("path",{d:"M7 5.6v2.9"}),t.jsx("path",{d:"M7 10.3v.05"})]})}function Ja(){return t.jsxs("svg",{className:"ig-mark",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[t.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),t.jsx("path",{d:"M7 4.1v3.4"}),t.jsx("path",{d:"M7 9.8v.05"})]})}function Xa(){return t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[t.jsx("rect",{x:"4.6",y:"4.6",width:"7.4",height:"7.4",rx:"1.2"}),t.jsx("path",{d:"M9.4 4.6V2.8a.8.8 0 0 0-.8-.8H2.8a.8.8 0 0 0-.8.8v5.8a.8.8 0 0 0 .8.8h1.8"})]})}function Hn(){return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:t.jsx("path",{d:"m2.6 7.4 2.9 2.9 5.9-6.4"})})}function qs(){return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:t.jsx("path",{d:"M3.5 3.5l7 7M10.5 3.5l-7 7"})})}function Qa({loadedAt:e,loading:n,stale:s},r=Date.now()){const a=e!=null?Es(r-e):null,o=(d,l,c="",u=null)=>({tone:d,word:l,join:c,ago:u,text:`${l}${c}${u??""}`});return n?e!=null?o("updating","Updating…"):o("reading","Reading…"):e==null?o("none",""):s?o("stale","Not updated"," · last answer ",a):o("updated","Updated"," ",a)}function Ya(e,n){return e==="reading"||e==="updating"?"Updating…":n?e==="stale"?"Not updated":e==="updated"?"Updated":"":""}function Gs({loadedAt:e,loading:n,stale:s=!1,onRefresh:r,label:a,disabled:o=!1,now:d}){const[,l]=i.useState(0),c=i.useRef(n);c.current=n;const[u,j]=i.useState(!1);i.useEffect(()=>{if(e==null)return;const g=window.setInterval(()=>l(y=>y+1),3e4);return()=>window.clearInterval(g)},[e]),i.useEffect(()=>{n&&j(!0)},[n]);const h=Qa({loadedAt:e,loading:n,stale:s},d??Date.now()),f=e!=null?new Date(e):null;return t.jsxs("div",{className:"ig-freshness","data-tone":h.tone,children:[h.tone!=="none"&&t.jsxs("span",{className:"ig-fresh",children:[h.tone==="stale"&&t.jsx(Ws,{}),t.jsx("span",{className:"ig-fresh-word",children:h.word}),h.join,f&&h.ago&&t.jsx("time",{dateTime:f.toISOString(),title:f.toLocaleString(),children:h.ago})]}),t.jsx("span",{className:"vis-hidden",role:"status",children:Ya(h.tone,u)}),t.jsx("button",{type:"button",className:"glyph-btn ig-refresh","aria-label":a,title:"Refresh",...Ce(n,o),"data-loading":n||void 0,onClick:()=>{we(c.current)&&r()},children:t.jsx(_r,{})})]})}function Wn({value:e,onChange:n,label:s,placeholder:r,inputRef:a,onKeyDown:o}){const d=i.useRef(null),l=a??d,[c,u]=i.useState(!1),j=c&&e!=="",h=i.useRef(n);return h.current=n,i.useEffect(()=>{if(j)return Ls.push(()=>h.current(""),0,"popover")},[j]),t.jsxs("div",{className:"ig-search","data-filled":e!==""||void 0,children:[t.jsx(za,{}),t.jsx("input",{ref:l,type:"search",className:"ig-search-input","aria-label":s,placeholder:r,value:e,onChange:f=>n(f.target.value),onKeyDown:o,onFocus:()=>u(!0),onBlur:()=>u(!1)}),e!==""&&t.jsx("button",{type:"button",className:"glyph-btn ig-search-clear","aria-label":"Clear the search",title:"Clear",onClick:()=>{var f;n(""),(f=l.current)==null||f.focus()},children:t.jsx(qs,{})})]})}function sn({label:e,rows:n=6,variant:s="rows"}){return t.jsxs("div",{className:"ig-skeleton","data-variant":s,role:"status",children:[t.jsx("span",{className:"vis-hidden",children:e}),Array.from({length:n},(r,a)=>t.jsx("i",{"aria-hidden":!0},a))]})}const Vt=new Set;function yn(e,n,s){for(const r of[e,n])if(r&&!s.has(r))return r;return null}function Vs(e){return{width:e,height:e,"--ig-avatar-size":`${e}px`}}function Ot({src:e,direct:n,name:s,size:r=20,you:a=!1,className:o=""}){const[d,l]=i.useState(()=>yn(e,n,Vt));i.useEffect(()=>l(yn(e,n,Vt)),[e,n]);const c=Vs(r),u=a||void 0;return d?t.jsx("img",{className:`ig-avatar ${o}`.trim(),style:c,src:d,alt:"","aria-hidden":!0,referrerPolicy:"no-referrer",loading:"lazy",decoding:"async",draggable:!1,"data-you":u,onError:()=>{Vt.add(d),l(yn(e,n,Vt))}}):t.jsx("span",{className:`ig-avatar ig-avatar-initials ${o}`.trim(),"data-large":r>=28||void 0,"data-you":u,style:c,"aria-hidden":!0,children:Kr(s)})}function zs({size:e=20}){return t.jsx("span",{className:"ig-avatar ig-avatar-none",style:Vs(e),"aria-hidden":!0})}function Js({src:e,direct:n,name:s,size:r=20,you:a=!1,nameless:o=!1}){return t.jsxs("span",{className:"ig-person",title:o?s:void 0,children:[t.jsx(Ot,{src:e,direct:n,name:s,size:r,you:a}),o?t.jsx("span",{className:"vis-hidden",children:s}):t.jsx("span",{className:"ig-person-name",children:s})]})}function Za(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Xs({people:e,max:n=3,size:s=20,label:r}){if(!e.length)return null;const a=e.map(c=>c.name),o=e.length>n?e.slice(0,n):e,d=e.length-o.length,l=Za(a);return t.jsxs("span",{className:"ig-stack",role:"img","aria-label":r?`${r} ${l}`:l,title:a.join(", "),children:[o.map(c=>t.jsx(Ot,{src:c.src,direct:c.direct,name:c.name,size:s,you:c.you},c.key)),d>0&&t.jsxs("span",{className:"ig-stack-more","aria-hidden":!0,children:["+",d]})]})}function eo(e){switch(e){case"auth":case"expired":return"reconnect";case"permission":case"incompatible":return"settings";case"not-found":return"none";default:return"retry"}}function to(e){return e==="reconnect"?"Reconnect":e==="settings"?"Open connection settings":"Try again"}function Qs(e,n=Date.now()){return e<60?`in ${Math.max(1,Math.ceil(e))}s`:`after ${new Date(n+e*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`}function no(e,n,s=n,r=Date.now()){var o;const a=((o=e.message)==null?void 0:o.trim())||"";switch(e.kind){case"auth":return{title:`${n} did not accept the saved token`,body:"It may have been revoked or replaced. Reconnect with a new one."};case"expired":return{title:`The saved ${n} token has expired`,body:"Make a new token and reconnect with it."};case"permission":return{title:"The token cannot read this",body:"Check the token's scopes in the connection's settings."};case"unreachable":return{title:`${s} did not answer`,body:"Check the network or VPN, and whether the site is up."};case"tls":return{title:`${s}'s certificate is not trusted here`,body:"The deck checks every certificate and cannot skip one: add the issuing authority to this machine's trust store, then try again."};case"rate-limit":return{title:`${n} asked the deck to slow down`,body:e.retryAfter==null?"Try again in a minute.":e.retryAfter<60?"It will answer again in a moment.":`It will answer again ${Qs(e.retryAfter,r)}.`};case"incompatible":return{title:`This is not a ${n} the deck can read`,body:a||"Check the address in the connection's settings."};case"not-found":return{title:"Not there any more",body:"It was deleted or moved, or this token cannot see it."};case"network":return{title:"The deck could not be reached",body:"Check that the deck is still running, then try again."};case"unavailable":return{title:`${n} is unavailable on this deck`,body:"The deck cannot read it right now. Try again in a moment."};case"invalid":return{title:"The deck could not ask for that",body:a};default:return{title:`${n} answered with an error`,body:a}}}function so(e,n){var r;if(e.kind==="auth"||e.kind==="expired")return null;const s=(r=e.detail)==null?void 0:r.trim();return!s||n.includes(s)?null:s}function ro(e,n,s=Date.now()){return e.kind!=="rate-limit"||e.retryAfter==null?0:Math.max(0,Math.ceil(e.retryAfter-(s-n)/1e3))}function bt({error:e,provider:n,host:s,stale:r=!1,onRetry:a,onReconnect:o,title:d,body:l,children:c,now:u}){const[j,h]=i.useState(()=>u??Date.now()),[f,g]=i.useState(()=>u??Date.now());i.useEffect(()=>{const F=Date.now();h(F),g(F)},[e]);const y=u??f,x=ro(e,j,y);i.useEffect(()=>{if(x<=0)return;const F=window.setTimeout(()=>g(Date.now()),1e3);return()=>window.clearTimeout(F)},[x,f]);const m=no(e,n,s,y),k=d??m.title,p=l??m.body,T=so(e,p),L=eo(e.kind),R=L==="retry"?a:L==="none"?void 0:o,v=L==="none"?"":to(L),S=L==="reconnect";return t.jsxs("div",{className:"ig-failure","data-kind":e.kind,"data-stale":r||void 0,children:[t.jsxs("div",{className:"ig-failure-text",role:r?"status":"alert",children:[t.jsxs("p",{className:"ig-failure-title",children:[r?t.jsx(Ws,{}):t.jsx(Ja,{}),t.jsx("strong",{children:k})]}),p&&t.jsx("p",{className:"ig-failure-body",children:p}),T&&!r&&t.jsxs("p",{className:"ig-failure-said",children:[n," said: ",T]})]}),(R||c)&&t.jsxs("div",{className:"ig-failure-actions",children:[R&&t.jsx("button",{type:"button",className:S?"btn primary":"btn","aria-disabled":x>0||void 0,onClick:()=>{x<=0&&R()},children:x>0?`${v} ${Qs(x,y)}`:v}),c]})]})}const kn=new Set;function Ys({src:e,label:n,fallback:s,className:r="jr-icon"}){const[a,o]=i.useState(()=>!e||kn.has(e));return i.useEffect(()=>o(!e||kn.has(e)),[e]),!e||a?s?t.jsx(t.Fragment,{children:s}):t.jsx("span",{className:r,title:n,"aria-hidden":!0}):t.jsx("img",{className:r,src:e,alt:"",title:n,width:16,height:16,loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,onError:()=>{kn.add(e),o(!0)}})}function ao(e,n=!1){const s=e.trim().toLowerCase();return n||/^sub-?\s?task/.test(s)?"subtask":/bug|defect|incident/.test(s)?"bug":/story|feature|improvement|requirement/.test(s)?"story":/epic/.test(s)?"epic":/task|chore|spike|support|request/.test(s)?"task":"other"}const oo={bug:t.jsx("circle",{className:"jr-glyph-mark",cx:"8",cy:"8",r:"2.6"}),story:t.jsx("path",{className:"jr-glyph-mark",d:"M5.5 4h5v8L8 10.2 5.5 12z"}),task:t.jsx("path",{className:"jr-glyph-mark jr-glyph-stroke",d:"m4.8 8.2 2.2 2.2 4.2-4.6",fill:"none",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),subtask:t.jsx("path",{className:"jr-glyph-mark",d:"M4.5 4.5h4.2v4.2H4.5zM7.3 7.3h4.2v4.2H7.3z",fillRule:"evenodd"}),epic:t.jsx("path",{className:"jr-glyph-mark",d:"M9 3 5 9h2.6L7 13l4-6H8.4z"}),other:t.jsx("circle",{className:"jr-glyph-mark",cx:"8",cy:"8",r:"1.8"})};function lo({type:e,subtask:n}){const s=e.epic?"epic":ao(e.name,n??e.subtask);return t.jsxs("svg",{className:"jr-icon jr-type-glyph","data-shape":s,width:"16",height:"16",viewBox:"0 0 16 16",role:"img","aria-label":e.name,children:[t.jsx("title",{children:e.name}),t.jsx("rect",{className:"jr-glyph-tile",x:"1",y:"1",width:"14",height:"14",rx:"3"}),oo[s]]})}const io={highest:"m4 8.5 4-4 4 4M4 12l4-4 4 4",high:"m4 10 4-4 4 4",medium:"M4 6h8M4 10h8",low:"m4 6 4 4 4-4",lowest:"m4 4 4 4 4-4M4 7.5l4 4 4-4"};function co({priority:e}){const n=Kn(e.name);return n?t.jsxs("svg",{className:"jr-icon jr-priority-glyph","data-level":n,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":`Priority: ${e.name}`,children:[t.jsx("title",{children:`Priority: ${e.name}`}),t.jsx("path",{d:io[n]})]}):t.jsx("span",{className:"jr-icon",title:`Priority: ${e.name}`,"aria-hidden":!0})}const rn=({type:e,subtask:n})=>t.jsx(Ys,{src:e.icon,label:e.name,fallback:t.jsx(lo,{type:e,subtask:n})}),qn=({priority:e})=>e?t.jsx(Ys,{src:e.icon,label:`Priority: ${e.name}`,fallback:t.jsx(co,{priority:e})}):t.jsx("span",{className:"jr-icon","aria-hidden":!0});function Zs({epic:e}){return t.jsx("span",{className:"jr-epic ig-chip","data-color":e.color??void 0,title:`Epic ${e.key}: ${e.name}`,children:e.name})}function an({status:e}){return t.jsx("span",{className:"jr-status ig-chip","data-cat":e.category,title:e.name,children:e.name})}function uo({issue:e,estimation:n,time:s}){if(n==="points")return e.points==null?null:t.jsx("span",{className:"jr-estimate ig-chip",title:"Story points",children:Number.isInteger(e.points)?e.points:e.points.toFixed(1)});const r=pt(e.estimate,s),a=e.remaining!=null&&e.remaining!==e.estimate?pt(e.remaining,s):"";return!r&&!a?null:t.jsxs("span",{className:"jr-estimate ig-chip",title:`${r?`Original estimate ${r}`:"No original estimate"}${a?` · ${a} remaining`:""}`,children:[r||"–",a&&t.jsxs("span",{className:"jr-remaining",children:[" · ",a," left"]})]})}function er(){return t.jsxs("svg",{className:"jr-flag",width:"12",height:"12",viewBox:"0 0 14 14",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round","aria-hidden":!0,children:[t.jsx("path",{d:"M3.5 12.5V1.8",fill:"none",strokeLinecap:"round"}),t.jsx("path",{d:"M3.5 2.2h7l-1.6 2.9 1.6 2.9h-7z"})]})}function Dn({open:e}){return t.jsx("svg",{className:"jr-chevron","data-open":e||void 0,width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:t.jsx("path",{d:"m5.2 3 4 4-4 4"})})}function ho({items:e,groups:n,snap:s,anchorId:r,portalId:a,boundaryId:o,busy:d,onMove:l,onClose:c,error:u,initialView:j="move"}){const h=i.useId(),f=i.useRef(d);f.current=d;const g=i.useRef(!1),[y,x]=i.useState(j),[m,k]=i.useState(e[0].group.id),[p,T]=i.useState(""),L=y==="menu",R=n.filter(C=>Tt(C)),v=R.find(C=>C.id===m),S=v?s.groups[v.id]:void 0,F=new Set(e.map(C=>C.issue.key)),K=((S==null?void 0:S.issues)??[]).filter(C=>!F.has(C.key)&&!C.type.subtask&&!C.type.epic),w=p?{key:p.slice(p.indexOf(":")+1),side:p.startsWith("before:")?"before":"after"}:void 0,E=v?Cn(e,v,w):null,$=e.length===1?Qe(e[0]):null,I=$?`${e[0].issue.key} ${$}. This issue cannot be moved.`:Jt(e),B=async()=>{if(!(!E||!v||!we(f.current||g.current))){g.current=!0;try{await l(E,v)}finally{g.current=!1}}};return t.jsx(nn,{anchorId:r,portalRootId:a,boundaryId:o??a,id:`${h}-popover`,className:L?"jr-actions-pop":"jr-move-pop",role:L?"menu":"dialog",labelledBy:L?r:`${h}-title`,onClose:c,children:L?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"jr-action-item",role:"menuitem","aria-disabled":!!I||d,"aria-describedby":I?`${h}-problem`:void 0,onClick:()=>{!I&&we(f.current||g.current)&&x("move")},children:e.length===1?"Move…":`Move ${e.length} issues…`}),I&&t.jsx("p",{id:`${h}-problem`,className:"jr-action-hint",children:I})]}):t.jsxs("form",{onSubmit:C=>{C.preventDefault(),B()},children:[t.jsxs("h3",{id:`${h}-title`,children:["Move ",e.length===1?e[0].issue.key:`${e.length} issues`]}),t.jsx("label",{htmlFor:`${h}-destination`,children:"Destination"}),t.jsx("select",{id:`${h}-destination`,value:m,...Ce(d),autoFocus:!0,onChange:C=>{we(f.current||g.current)&&(k(C.target.value),T(""))},children:R.map(C=>t.jsx("option",{value:C.id,children:C.title},C.id))}),t.jsx("label",{htmlFor:`${h}-position`,children:"Position"}),t.jsxs("select",{id:`${h}-position`,value:p,...Ce(d),onChange:C=>{we(f.current||g.current)&&T(C.target.value)},children:[t.jsx("option",{value:"",children:e.every(C=>C.group.id===m)?"Choose a position":"Keep current rank"}),K.map(C=>t.jsxs("option",{value:`before:${C.key}`,children:["Before ",C.key," — ",C.summary]},C.key)),K.length>0&&t.jsxs("option",{value:`after:${K[K.length-1].key}`,children:["After ",K[K.length-1].key]})]}),t.jsxs("p",{className:"jr-move-help",children:["Saved in Jira. Status stays the same. ",S!=null&&S.next||S!=null&&S.capped||!S||S.status!=="ready"?"Positions are limited to issues already loaded.":""]}),u&&t.jsx("p",{className:"jr-move-error",role:"alert",children:u}),t.jsxs("div",{className:"jr-move-actions",children:[t.jsx("button",{type:"button",className:"btn",onClick:c,children:"Cancel"}),t.jsx("button",{type:"submit",className:"btn primary",...Ce(d,!E),children:d?"Moving…":e.length===1?"Move issue":`Move ${e.length} issues`})]})]})})}function is({item:e,portalRootId:n,children:s}){const r=e.fixVersions??[],a=o=>{var d;return(d=o.closest(".jr-board"))!=null&&d.querySelector("[data-dragging]")?!1:r.length>1?!0:Array.from(o.querySelectorAll(".jr-key, .jr-summary, .jr-version, .jr-epic")).some(l=>l.getClientRects().length===0||l.scrollWidth>l.clientWidth+1||l.classList.contains("jr-summary")&&l.scrollHeight>l.clientHeight+2)};return t.jsx(Hr,{className:"jr-row-preview",portalRootId:n,placement:"reading",focusDelay:250,shouldShow:a,detail:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"jr-preview-key",children:e.key}),t.jsx("div",{className:"jr-preview-summary",children:e.summary}),(r.length>0||e.epic)&&t.jsxs("dl",{children:[r.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("dt",{children:r.length===1?"Version":"Versions"}),t.jsx("dd",{children:r.join(", ")})]}),e.epic&&t.jsxs(t.Fragment,{children:[t.jsx("dt",{children:"Epic"}),t.jsxs("dd",{children:[e.epic.key,": ",e.epic.name]})]})]})]}),children:s})}const cs={new:"To do",indeterminate:"In progress",done:"Done"},fo=["new","indeterminate","done"],ds=e=>e<=30;function mo({def:e,totals:n,estimation:s,time:r}){if(s==="count")return null;const a=s==="points"?"story points":"estimated";if(e.kind==="column"){const d=n.new+n.indeterminate+n.done;if(d<=0)return null;const l=ts(d,s,r);return t.jsx("span",{className:"jr-totals",children:t.jsxs("span",{className:"jr-total",title:`Total: ${l} ${a}`,children:["Total ",l]})})}const o=fo.filter(d=>n[d]>0);return o.length===0?null:t.jsx("span",{className:"jr-totals",children:o.map(d=>{const l=ts(n[d],s,r);return t.jsxs("span",{className:"jr-total","data-cat":d,title:`${cs[d]}: ${l} ${a}`,children:[cs[d]," ",l]},d)})})}function po({stats:e,mine:n}){const s=[];return e.mine>0&&s.push(n?{key:"mine",text:`${e.mineDone} of ${e.mine} done`,title:`${e.mineDone} of your ${e.mine} done`}:{key:"mine",text:`${e.mine} yours`,title:`${e.mineDone} of ${e.mine} yours done`}),e.flagged>0&&s.push({key:"flagged",text:`${e.flagged} flagged`,title:"Flagged and not done"}),e.highest>0&&s.push({key:"highest",text:`${e.highest} highest`,title:"Highest priority (or Blocker, Critical) and not done"}),s.length===0?null:t.jsx("span",{className:"jr-tally",children:s.map((r,a)=>t.jsxs(i.Fragment,{children:[a>0&&t.jsx("span",{"aria-hidden":!0,children:" · "}),t.jsx("span",{title:r.title,children:r.text})]},r.key))})}function us(e,n=""){const s=e.assignee?`${e.assignee.name}${e.mine?", assigned to you":""}`:"unassigned";return`${e.key}: ${e.summary}. ${e.type.name}, ${e.status.name}, ${s}${e.priority?`, priority ${e.priority.name}`:""}${e.flagged?", flagged":""}${n}`}function hs({issue:e,estimation:n,time:s}){const r=e.status.category==="done";return t.jsxs(t.Fragment,{children:[t.jsx(rn,{type:e.type}),t.jsx(qn,{priority:e.priority}),t.jsx("span",{className:"jr-key","data-done":r||void 0,children:e.key}),t.jsx("span",{className:"jr-summary",children:e.summary}),t.jsxs("span",{className:"jr-facts",children:[t.jsxs("span",{className:"jr-meta",children:[e.flagged&&t.jsx("span",{className:"jr-flagged",title:"Flagged",children:t.jsx(er,{})}),e.fixVersions.length>0&&t.jsx("span",{className:"jr-version",title:e.fixVersions.join(", "),children:e.fixVersions.length===1?e.fixVersions[0]:`${e.fixVersions.length} versions`}),e.epic&&t.jsx(Zs,{epic:e.epic})]}),t.jsx(uo,{issue:e,estimation:n,time:s}),t.jsx("span",{className:"jr-status-cell",children:t.jsx(an,{status:e.status})})]}),t.jsx("span",{className:"jr-assignee",title:e.assignee?`${e.assignee.name}${e.mine?" (you)":""}`:"Unassigned",children:e.assignee?t.jsx(Ot,{src:e.assignee.avatar,name:e.assignee.name,size:20,you:e.mine}):t.jsx(zs,{size:20})})]})}function go(e){let n=4;const s=r=>{r.length>n&&(n=r.length)};for(const r of Object.values(e.groups))for(const a of r.issues)s(a.status.name),a.parent&&s(a.parent.status.name);for(const r of Object.values(e.subtasks))for(const a of r.issues)s(a.status.name);return Math.min(16,n)}function jo(e){var Xn;const{conn:n,overview:s,groups:r,snap:a,expanded:o,onToggleGroup:d,filter:l,mine:c,filtered:u,selected:j,onOpen:h,rowsOpen:f,onToggleRow:g,onRetryGroup:y,onMore:x,onShowClosed:m,onMoreClosed:k,loadSubtasks:p,onReconnect:T,onMove:L,moveBusy:R=!1}=e,v=i.useRef(null),S=i.useId(),F=i.useRef(null),K=i.useRef(!1),[w,E]=i.useState([]),[$,I]=i.useState(()=>new Set),[B,C]=i.useState(!1),U=i.useRef(null),W=i.useRef(0),[ee,se]=i.useState(null),[V,J]=i.useState(null),Y=i.useRef(0),[ve,me]=i.useState(""),[dt,_e]=i.useState(""),$e=i.useRef(!1),Le=i.useRef(!1);Le.current=R;const Ke=i.useRef(!1);Ke.current=a.closed.loading;const P=((Xn=s.moves)==null?void 0:Xn.enabled)===!0&&!!L,be=(b,N,_,q=!1,O="move")=>{if(!we(Le.current||$e.current))return;const X=$.has(b.key)?Se:[{issue:b,group:N}];if(O==="move"&&(X.length>50||X.some(z=>!zt(z.issue,z.group)))){me(Jt(X));return}Y.current++,me(""),J({issue:b,items:X,anchorId:_,keyboard:q,initialView:O})},tt=()=>{const b=V;$e.current&&b&&!document.getElementById(b.anchorId)||Y.current++,J(null),b!=null&&b.keyboard&&requestAnimationFrame(()=>{var _,q;document.activeElement===document.getElementById(b.anchorId)&&((q=Array.from(((_=v.current)==null?void 0:_.querySelectorAll(".jr-row-main[data-key]"))??[]).find(O=>O.dataset.key===b.issue.key))==null||q.focus())})},he=()=>{F.current=null,E([]),se(null)},Ee=async(b,N)=>{if(!L||R||$e.current)return!1;const _=Y.current,q=W.current,O=Fs(b),X=O.length===1?O[0]:`${O.length} issues`,z=document.activeElement,te=z==null?void 0:z.closest(".jr-move-pop");$e.current=!0,me(""),_e(`Moving ${X}…`);try{const de=await L(b);_e(de.notice||`${X} moved to ${N.title}.`),q===W.current&&I(new Set(O));const ye=_===Y.current&&(document.activeElement===z||!!(te!=null&&te.contains(document.activeElement))||document.activeElement===document.body&&(!(z!=null&&z.isConnected)||(te==null?void 0:te.isConnected)));return _===Y.current&&J(null),d(N,!0),ye&&requestAnimationFrame(()=>{var Fe,st;(st=Array.from(((Fe=v.current)==null?void 0:Fe.querySelectorAll(".jr-row-main[data-key]"))??[]).find(ht=>{var G;return ht.dataset.key===O[0]&&((G=ht.dataset.nav)==null?void 0:G.startsWith(`${N.id}/`))})??document.getElementById(`jr-group-${N.id.replace(/[^a-z0-9]/gi,"-")}-toggle`))==null||st.focus()}),!0}catch(de){return _e(""),me(de instanceof Error?de.message:"The move could not be confirmed. Refresh before trying again."),!1}finally{$e.current=!1}},He=(b,N)=>{!F.current||!P||R||!Tt(N)||(b.preventDefault(),b.dataTransfer.dropEffect="move",se({group:N.id}))},nt=(b,N)=>{const _=F.current;if(!_||!P||R)return;b.preventDefault();const q=Cn(_.items,N);he(),q&&Ee(q,N)},[A,re]=i.useState(()=>new Set),[pe,xe]=i.useState(()=>new Set),[Me,Te]=i.useState(null),De=s.estimation.kind,ut=s.timeTracking,ge=i.useMemo(()=>Ps(r,a.groups,b=>{var N;return(N=a.subtasks[b])==null?void 0:N.issues},l).map(b=>({...b,stats:Ca(b.rows,De)})),[r,a.groups,a.subtasks,l,De]),ze=b=>Rn(b,f),je=i.useMemo(()=>{const b=[],N=new Set,_=(q,O)=>{N.has(q.key)||(N.add(q.key),b.push({issue:q,group:O}))};for(const{def:q,rows:O}of ge)if(Lt(q,o)){for(const X of O)if(X.kind==="issue"&&_(X.issue,q),Rn(X,f))for(const z of An(X,a.subtasks[Ye(X)],l))_(z,q)}return b},[ge,o,f,a.subtasks,l]),Kt=je.map(b=>b.issue.key),Se=je.filter(b=>$.has(b.issue.key)),$t=Se.filter(b=>Qe(b)),Je=Jt(Se);i.useEffect(()=>{const b=new Set(je.map(N=>N.issue.key));I(N=>[...N].every(_=>b.has(_))?N:new Set([...N].filter(_=>b.has(_)))),U.current&&!b.has(U.current)&&(U.current=null)},[je]);const We=(b,N,_=!1)=>{const q=N.ctrlKey||N.metaKey,O=q||N.shiftKey||_,X=U.current;W.current++,I(z=>da(z,Kt,b,X,N.shiftKey?q?"add-range":"range":q||_?"toggle":"replace")),N.shiftKey||(U.current=b),C(O),O||h(b)};i.useEffect(()=>{for(const{def:b,rows:N}of ge)if(Lt(b,o))for(const _ of N){if(!ze(_))continue;const q=Ye(_);a.subtasks[q]||!Us(_,u)||p(q)}},[ge,f,o]);const gn=(b,N)=>{N&&xe(_=>new Set(_).add(b)),g(b,N)},jn=()=>{var b;return Array.from(((b=v.current)==null?void 0:b.querySelectorAll("[data-nav]"))??[])},qe=b=>{var N;b&&(b.focus(),(N=b.scrollIntoView)==null||N.call(b,{block:"nearest"}))},Ht=b=>{var X,z;const N=b.target;if(N.dataset.key&&b.key===" "&&!b.altKey){b.preventDefault(),b.repeat||We(N.dataset.key,b,!0);return}if(!N.dataset.nav||b.altKey||b.ctrlKey||b.metaKey)return;const _=jn(),q=_.indexOf(N),O=N.getAttribute("data-expanded");switch(b.key){case"ArrowDown":b.preventDefault(),qe(_[Math.min(_.length-1,q+1)]);return;case"ArrowUp":b.preventDefault(),qe(_[Math.max(0,q-1)]);return;case"Home":b.preventDefault(),qe(_[0]);return;case"End":b.preventDefault(),qe(_[_.length-1]);return;case"ArrowRight":O==="false"?(b.preventDefault(),(X=document.getElementById(N.dataset.toggle??""))==null||X.click()):O==="true"&&(b.preventDefault(),qe(_[q+1]));return;case"ArrowLeft":O==="true"?(b.preventDefault(),(z=document.getElementById(N.dataset.toggle??""))==null||z.click()):N.dataset.parent&&(b.preventDefault(),qe(_.find(te=>te.dataset.nav===N.dataset.parent)));return}},M=i.useMemo(()=>{for(const{def:b,rows:N}of ge)if(Lt(b,o)&&N.length>0)return`${b.id}/${Ye(N[0])}`;return ge.length?`g:${ge[0].def.id}`:null},[ge,o]);i.useEffect(()=>{var b;Me&&!((b=v.current)!=null&&b.querySelector(`[data-nav="${CSS.escape(Me)}"]`))&&Te(null)});const H=b=>b===(Me??M)?0:-1,ae=(b,N,_,q)=>{const O=Ye(b),X=`${N.id}/${O}`,z=ze(b),te=a.subtasks[O],de=b.kind==="issue"?b.issue.subtaskKeys.length:0,ye=de>0||b.matched.length>0||b.kind==="context",Ie=`jr-toggle-${N.id.replace(/[^a-z0-9]/gi,"-")}-${O}`,Fe=An(b,te,l),st=((te==null?void 0:te.status)==="ready"?te.issues:b.matched).filter(D=>D.mine).length,ht=b.kind==="issue"?us(b.issue,ye?`, ${de||b.matched.length} sub-tasks${st?`, ${st} yours`:""}`:""):`${b.parent.key}: ${b.parent.summary}. ${c?"Not assigned to you":"Parent not in this list"}; shown for ${b.matched.length} sub-task${b.matched.length===1?"":"s"}`,G=b.kind==="issue"?b.issue:null,le=P&&G&&zt(G,N)&&_===0,ft=`${S}-move-${N.id}-${O}`,qt=`${ft}-row`,Gt=P&&G&&_===0;return t.jsxs("li",{className:"jr-item","data-context":b.kind==="context"||void 0,children:[t.jsxs("div",{className:"jr-row ig-row","data-selected":$.has(O)||j===O||void 0,"data-picked":$.has(O)||void 0,"data-done":(G==null?void 0:G.status.category)==="done"||void 0,"data-current":j===O||void 0,"data-move-blocked":!!(G&&$.has(O)&&Qe({issue:G,group:N}))||void 0,"data-mine":(G==null?void 0:G.mine)||void 0,"data-dragging":w.includes(O)||void 0,"data-drop":(ee==null?void 0:ee.group)===N.id&&ee.key===O?ee.side:void 0,draggable:!!(le&&!R),onPointerDown:D=>{K.current=!!D.target.closest(".jr-toggle, .jr-move-button")},onDragStart:D=>{if(!le||R||!G||K.current){D.preventDefault();return}const fe=$.has(O)?Se:[{issue:G,group:N}];if(fe.length>50||fe.some(ie=>!zt(ie.issue,ie.group))){D.preventDefault(),me(Jt(fe));return}$.has(O)||(W.current++,I(new Set([O])),C(!1)),F.current={items:fe},D.dataTransfer.effectAllowed="move",D.dataTransfer.setData("text/plain",fe.map(ie=>ie.issue.key).join(`
2
+ `)),E(fe.map(ie=>ie.issue.key)),J(null)},onDragEnd:he,onDragOver:D=>{if(!F.current||!P||R||!G||G.type.subtask||!Tt(N))return;if(D.stopPropagation(),F.current.items.some(ie=>ie.issue.key===O)){se(null);return}D.preventDefault(),D.dataTransfer.dropEffect="move";const fe=D.currentTarget.getBoundingClientRect();se({group:N.id,key:O,side:D.clientY<fe.top+fe.height/2?"before":"after"})},onDrop:D=>{const fe=F.current;if(!fe||!P||R||!G||G.type.subtask)return;D.preventDefault(),D.stopPropagation();const ie=D.currentTarget.getBoundingClientRect(),Tr=D.clientY<ie.top+ie.height/2?"before":"after",Qn=Cn(fe.items,N,{key:O,side:Tr});he(),Qn&&Ee(Qn,N)},children:[ye?t.jsx("button",{type:"button",id:Ie,className:"jr-toggle",tabIndex:-1,"aria-expanded":z,"aria-label":`${z?"Hide":"Show"} sub-tasks of ${O}`,onClick:()=>gn(O,!z),children:t.jsx(Dn,{open:z})}):t.jsx("span",{className:"jr-toggle-space","aria-hidden":!0}),t.jsx(is,{item:b.kind==="issue"?b.issue:b.parent,portalRootId:S,children:t.jsx("button",{type:"button",id:qt,className:"jr-row-main","aria-haspopup":Gt?"menu":void 0,"data-nav":X,"data-key":O,"data-parent":q,"data-toggle":ye?Ie:void 0,"data-has-meta":G?!!(G.flagged||G.fixVersions.length||G.epic)||void 0:!0,"data-expanded":ye?String(z):void 0,"aria-expanded":ye?z:void 0,"aria-controls":ye&&z?`${Ie}-children`:void 0,"aria-describedby":`${S}-instructions`,tabIndex:H(X),"aria-current":j===O||void 0,onKeyDown:D=>{if(Gt&&!R&&(D.key==="ContextMenu"||D.shiftKey&&D.key==="F10")){D.preventDefault(),D.stopPropagation(),be(G,N,qt,!1,"menu");return}le&&!R&&D.altKey&&!D.ctrlKey&&!D.metaKey&&(D.code==="KeyM"||D.key.toLowerCase()==="m")&&G&&(D.preventDefault(),D.stopPropagation(),be(G,N,qt,!0))},"aria-label":`${ht}${$.has(O)?". Selected":""}`,onFocus:()=>Te(X),onClick:D=>{G?(D.preventDefault(),We(O,D)):!D.ctrlKey&&!D.metaKey&&!D.shiftKey&&(I(new Set),C(!1),h(O))},onContextMenu:D=>{G&&D.ctrlKey?(D.preventDefault(),D.currentTarget.focus(),We(O,D)):Gt&&!R&&(D.preventDefault(),D.currentTarget.focus(),be(G,N,qt,!1,"menu"))},children:G?t.jsx(hs,{issue:G,estimation:De,time:ut}):b.kind==="context"&&t.jsxs(t.Fragment,{children:[t.jsx(rn,{type:b.parent.type}),t.jsx(qn,{priority:b.parent.priority}),t.jsx("span",{className:"jr-key","data-done":b.parent.status.category==="done"||void 0,children:b.parent.key}),t.jsx("span",{className:"jr-summary",children:b.parent.summary}),t.jsxs("span",{className:"jr-facts",children:[t.jsx("span",{className:"jr-meta",children:t.jsx("span",{className:"jr-context-tag",children:c?"not assigned to you":"parent not in this list"})}),t.jsx("span",{className:"jr-status-cell",children:t.jsx(an,{status:b.parent.status})})]})]})})}),Gt&&t.jsx("button",{id:ft,type:"button",className:"jr-move-button",...Ce(R),"aria-label":`Actions for ${O}`,title:`Actions for ${O}`,"aria-haspopup":"menu","aria-expanded":(V==null?void 0:V.anchorId)===ft,tabIndex:H(X),onKeyDown:D=>{(D.key==="ArrowDown"||D.key==="ArrowUp")&&(D.preventDefault(),D.stopPropagation(),be(G,N,ft,!1,"menu"))},onClick:()=>{we(Le.current||$e.current)&&((V==null?void 0:V.anchorId)===ft?tt():be(G,N,ft,!1,"menu"))},children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"3",cy:"8",r:"1.2"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.2"}),t.jsx("circle",{cx:"13",cy:"8",r:"1.2"})]})})]}),ye&&z&&t.jsxs("ul",{id:`${Ie}-children`,className:"jr-subrows",role:"list","aria-label":`Sub-tasks of ${O}`,"data-fade":pe.has(O)&&ds(Fe.length)||void 0,children:[(te==null?void 0:te.status)==="loading"&&Fe.length===0&&t.jsx("li",{className:"jr-subnote",role:"status",children:"Reading sub-tasks…"}),(te==null?void 0:te.status)==="error"&&t.jsxs("li",{className:"jr-subnote",role:"alert",children:["Sub-tasks could not be read. ",t.jsx("button",{type:"button",className:"jr-link-btn",onClick:()=>p(O),children:"Try again"})]}),Fe.map(D=>{const fe=`${N.id}/${D.key}/${X}`;return t.jsx("li",{className:"jr-item",children:t.jsxs("div",{className:"jr-row jr-subrow ig-row","data-selected":$.has(D.key)||j===D.key||void 0,"data-picked":$.has(D.key)||void 0,"data-done":D.status.category==="done"||void 0,"data-current":j===D.key||void 0,"data-move-blocked":!!($.has(D.key)&&Qe({issue:D,group:N}))||void 0,"data-mine":D.mine||void 0,children:[t.jsx("span",{className:"jr-toggle-space","aria-hidden":!0}),t.jsx(is,{item:D,portalRootId:S,children:t.jsx("button",{type:"button",className:"jr-row-main","data-nav":fe,"data-key":D.key,"data-parent":X,tabIndex:H(fe),"data-has-meta":!!(D.flagged||D.fixVersions.length||D.epic)||void 0,"aria-current":j===D.key||void 0,"aria-label":`${us(D)}${$.has(D.key)?". Selected":""}`,"aria-describedby":`${S}-instructions`,onFocus:()=>Te(fe),onClick:ie=>{ie.preventDefault(),We(D.key,ie)},onContextMenu:ie=>{ie.ctrlKey&&(ie.preventDefault(),ie.currentTarget.focus(),We(D.key,ie))},children:t.jsx(hs,{issue:D,estimation:De,time:ut})})})]})},D.key)}),(te==null?void 0:te.status)==="ready"&&Fe.length===0&&t.jsx("li",{className:"jr-subnote",children:l.attention?"No sub-task needs attention.":l.hideDone?"Every sub-task is done.":"No sub-tasks."})]})]},O)},Wt=s.hasSprints,Lr=Wt&&s.sprints.active.length===0,oe=a.closed,Er=ge.findIndex(b=>b.def.kind==="closed"),Mr=i.useMemo(()=>go(a),[a]);return t.jsxs("div",{className:"jr-board",id:S,ref:v,onKeyDown:Ht,style:{"--jr-status-ch":Mr},children:[t.jsxs("p",{className:"vis-hidden",id:`${S}-instructions`,children:["Use Up and Down to navigate, Right to expand and Left to collapse. Enter opens the issue. Ctrl or Command click toggles selection; Shift click selects a range. Space toggles the focused issue.",P?" Drag selected issues to reorder or change sprint. Right-click or Shift+F10 opens actions. Alt+M opens Move.":""]}),B&&Se.length>0&&t.jsxs("div",{className:"jr-selection",role:"group","aria-label":"Selected issues",children:[t.jsxs("span",{role:"status",children:[Se.length," selected"]}),P&&t.jsx("button",{type:"button",className:"btn",id:`${S}-move-selected`,...Ce(R,!!Je),"aria-haspopup":"dialog","aria-expanded":(V==null?void 0:V.anchorId)===`${S}-move-selected`,onClick:()=>{Je||be(Se[0].issue,Se[0].group,`${S}-move-selected`)},children:"Move selected"}),t.jsx("button",{type:"button",className:"btn","aria-label":"Clear selection",onClick:()=>{W.current++,I(new Set),C(!0),U.current=null},children:"Clear"}),Je&&P&&t.jsx("span",{className:"jr-selection-note",id:`${S}-blocked`,children:Je}),$t.length>0&&P&&t.jsxs("button",{type:"button",className:"btn",onClick:()=>{W.current++,I(new Set(Se.filter(b=>!Qe(b)).map(b=>b.issue.key))),me("")},children:["Remove blocked (",$t.length,")"]})]}),t.jsx("p",{className:"jr-move-status",role:"status","aria-live":"polite",children:dt}),ve&&!V&&t.jsx("p",{className:"jr-move-error",role:"alert",children:ve}),Lr&&t.jsx("p",{className:"jr-board-note",children:"No sprint is active on this board. The future sprints and the backlog are below."}),ge.map(({def:b,data:N,rows:_,stats:q},O)=>{const X=Lt(b,o),z=`jr-group-${b.id.replace(/[^a-z0-9]/gi,"-")}`,te=`g:${b.id}`,de=b.sprint,ye=de&&(de.startDate||de.endDate)?`${ns(de.startDate)||"?"} – ${ns(de.completeDate??de.endDate)||"?"}`:"",Ie=(N==null?void 0:N.status)==="ready"||((N==null?void 0:N.issues.length)??0)>0,Fe=(N==null?void 0:N.total)!=null&&b.paged&&N.total>q.count&&!l.search&&!l.hideDone&&!l.attention,st=b.kind==="closed"&&(!N||N.status==="idle"),ht=Ie?Fe?`${q.count} of ${N.total}`:`${q.count}`:(N==null?void 0:N.status)==="error"?"":"…",G=q.assignees;return t.jsxs(i.Fragment,{children:[O===Er&&t.jsx("h3",{className:"jr-closed-title",children:"Closed sprints"}),t.jsxs("section",{className:"jr-group","data-kind":b.kind,"aria-labelledby":`${z}-title`,"data-drop-group":(ee==null?void 0:ee.group)===b.id&&!ee.key||void 0,onDragOver:le=>He(le,b),onDrop:le=>nt(le,b),children:[t.jsxs("div",{className:"jr-group-head",children:[t.jsx("h3",{className:"jr-group-title",id:`${z}-title`,children:t.jsxs("button",{type:"button",id:`${z}-toggle`,className:"jr-group-toggle","data-nav":te,"data-toggle":`${z}-toggle`,"data-expanded":String(X),"aria-expanded":X,"aria-controls":z,tabIndex:H(te),onFocus:()=>Te(te),onClick:()=>{X||re(le=>new Set(le).add(b.id)),d(b,!X)},children:[t.jsx(Dn,{open:X}),t.jsxs("span",{className:"jr-group-identity",children:[t.jsx("span",{className:"jr-group-name",children:b.title}),b.kind==="active"&&t.jsx("span",{className:"jr-badge",children:"Active"}),ye&&t.jsx("span",{className:"jr-group-dates",children:ye}),st?t.jsxs("span",{className:"jr-group-count",title:"Counted when you open it",children:[t.jsx("span",{"aria-hidden":!0,children:"—"}),t.jsx("span",{className:"vis-hidden",children:"issues counted when opened"})]}):t.jsxs("span",{className:"jr-group-count",children:[ht," ",Ie?q.count===1&&!Fe?"issue":"issues":t.jsx("span",{className:"vis-hidden",children:"issues, not read yet"})]})]})]})}),Ie&&t.jsxs("div",{className:"jr-group-facts",children:[t.jsx(po,{stats:q,mine:c}),t.jsx(Xs,{label:"Assigned to",people:G.map(le=>({key:le.id,name:le.name,src:le.avatar,you:le.id===q.youId}))}),t.jsx(mo,{def:b,totals:q.totals,estimation:De,time:ut})]})]}),(de==null?void 0:de.goal)&&X&&t.jsx("p",{className:"jr-goal",children:de.goal}),X&&t.jsxs("div",{id:z,className:"jr-group-body","data-empty":(N==null?void 0:N.status)==="ready"&&_.length===0&&!N.error&&!N.next&&!N.capped||void 0,"data-fade":A.has(b.id)&&ds(_.length)||void 0,children:[(N==null?void 0:N.error)&&t.jsx(bt,{error:N.error,provider:"Jira",host:jt(n),stale:N.issues.length>0,title:N.status==="ready"?"More issues could not be read":void 0,onRetry:()=>{var le;(le=document.getElementById(`${z}-toggle`))==null||le.focus(),N.status==="ready"&&N.next?x(b):y(b)},onReconnect:T}),(!N||N.status==="idle"||N.status==="loading"&&N.issues.length===0)&&t.jsx(sn,{label:`Reading ${b.title}`,rows:3}),Ie&&_.length===0&&t.jsx("p",{className:"jr-empty-group",children:((N==null?void 0:N.issues.length)??0)>0?"Nothing here matches the filters.":c?"None of your issues are here.":u?"Nothing here matches the filters.":"No issues."}),_.length>0&&t.jsx("ul",{className:"jr-rows",children:_.map(le=>ae(le,b,0))}),(N==null?void 0:N.capped)&&t.jsx("p",{className:"jr-board-note",children:"The first 600 issues are shown. Open the sprint in Jira for the rest."}),b.paged&&(N==null?void 0:N.next)&&t.jsx("button",{type:"button",className:"btn jr-more",...Ce(R||!!N.more),onClick:()=>{we(Le.current||!!N.more)&&x(b)},children:N.more?"Reading…":N.total!=null?`Show more (${N.issues.length} of ${N.total})`:"Show more"})]})]})]},b.id)}),V&&t.jsx(ho,{items:V.items,groups:r,snap:a,initialView:V.initialView,anchorId:V.anchorId,portalId:S,boundaryId:e.scrollBoundaryId,busy:R,error:ve,onMove:Ee,onClose:tt},V.anchorId),Wt&&t.jsxs("div",{className:"jr-closed-foot",children:[t.jsx("button",{id:`${S}-closed-toggle`,type:"button",className:"btn","aria-expanded":oe.shown,"aria-busy":oe.loading||void 0,onClick:()=>m(!oe.shown),children:oe.shown?"Hide closed sprints":"Show closed sprints"}),oe.shown&&t.jsxs(t.Fragment,{children:[oe.loading&&t.jsx("p",{className:"jr-subnote",role:"status",children:"Reading closed sprints…"}),oe.error&&t.jsx(bt,{error:oe.error,provider:"Jira",host:jt(n),title:"Closed sprints could not be read",stale:oe.sprints.length>0,onRetry:()=>{var b;(b=document.getElementById(`${S}-closed-toggle`))==null||b.focus(),oe.sprints.length?k():m(!0)},onReconnect:T}),!oe.error&&!oe.loading&&oe.sprints.length===0&&t.jsx("p",{className:"jr-subnote",children:"No closed sprints on this board."}),!oe.error&&!oe.isLast&&oe.sprints.length>0&&t.jsx("button",{type:"button",className:"btn",...Ce(oe.loading),onClick:()=>{we(Ke.current)&&k()},children:oe.loading?"Reading…":`Show older sprints (${oe.sprints.length} of ${oe.total})`})]})]})]})}const xo=1,bo=3,yo=48,ko=2e4,wo=new Set(["SCRIPT","STYLE","IFRAME","FRAME","FRAMESET","OBJECT","EMBED","APPLET","PARAM","NOSCRIPT","TEMPLATE","SVG","MATH","FORM","INPUT","BUTTON","SELECT","OPTION","TEXTAREA","LABEL","FIELDSET","LINK","META","TITLE","HEAD","BASE","AUDIO","VIDEO","SOURCE","TRACK","PICTURE","CANVAS","MAP","AREA","DIALOG","SLOT"]),No={P:"p",BR:"br",HR:"hr",DIV:"div",SPAN:"span",STRONG:"strong",B:"strong",EM:"em",I:"em",U:"u",S:"s",STRIKE:"s",DEL:"del",INS:"ins",SUB:"sub",SUP:"sup",SMALL:"small",MARK:"mark",ABBR:"abbr",CITE:"cite",Q:"q",FONT:"span",CODE:"code",TT:"code",KBD:"kbd",SAMP:"samp",PRE:"pre",BLOCKQUOTE:"blockquote",UL:"ul",OL:"ol",LI:"li",DL:"dl",DT:"dt",DD:"dd",H1:"h4",H2:"h5",H3:"h6",H4:"h6",H5:"h6",H6:"h6",TABLE:"table",CAPTION:"caption",THEAD:"thead",TBODY:"tbody",TFOOT:"tfoot",TR:"tr",TH:"th",TD:"td",A:"a",IMG:"img"},vo=new Set(["br","hr","img"]),$o={panel:"jr-html-panel",panelHeader:"jr-html-panel-head",panelContent:"jr-html-panel-body",code:"jr-html-code",codeContent:"jr-html-code-body",preformatted:"jr-html-pre",preformattedContent:"jr-html-pre-body",emoticon:"jr-emoticon","user-hover":"jr-mention",error:"jr-html-error"};function So(e){var r;const s=(((r=e.getAttribute)==null?void 0:r.call(e,"class"))??"").split(/\s+/).map(a=>$o[a]).filter(Boolean);return s.length?[...new Set(s)].join(" "):void 0}function fs(e,n){const s=String(e??"").trim();if(!s)return null;let r;try{r=new URL(s,`${n.replace(/\/+$/,"")}/`)}catch{return null}return r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password?null:r.href}function ms(e){const n=Number.parseInt(String(e??""),10);return Number.isFinite(n)&&n>1&&n<=100?n:void 0}function tr({href:e,alt:n,emoticon:s}){return s?t.jsx(t.Fragment,{children:n}):t.jsx("a",{className:"jr-image-link",href:e,target:"_blank",rel:"noreferrer noopener",children:n||"Image"})}function Co({src:e,href:n,alt:s,emoticon:r}){const[a,o]=i.useState(!1);return a?t.jsx(tr,{href:n,alt:s,emoticon:r}):t.jsx("img",{className:r?"jr-emoticon":"jr-image",src:e,alt:s,loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,onError:()=>o(!0)})}function Ro(e){return typeof DOMParser>"u"?null:new DOMParser().parseFromString(e,"text/html").body}function Ao(e,n,s=Ro){if(!e||!e.trim())return null;const r=s(e);if(!r)return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();let a=ko,o=3;const d=(c,u,j)=>{var k,p,T,L,R,v;if(--a<0)return null;if(c.nodeType===bo)return c.nodeValue??"";if(c.nodeType!==xo)return null;const h=String(c.nodeName).toUpperCase();if(wo.has(h))return null;const f=()=>{if(j>=yo)return[];const S=[],F=c.childNodes;for(let K=0;K<F.length;K++){const w=d(F[K],`${u}.${K}`,j+1);w!==null&&w!==""&&S.push(w)}return S};let g=No[h];const y=/^H([1-6])$/.exec(h);if(y){const S=Math.min(Number(y[1])+3,6,o+1);o=S,g=`h${S}`}if(!g){const S=f();return S.length?i.createElement(i.Fragment,{key:u},...S):null}const x=So(c);if(g==="img"){const S=fs((k=c.getAttribute)==null?void 0:k.call(c,"src"),n.baseUrl);if(!S)return null;const F=(((p=c.getAttribute)==null?void 0:p.call(c,"alt"))??((T=c.getAttribute)==null?void 0:T.call(c,"title"))??"").slice(0,200),K=n.image(S),w=x==="jr-emoticon";return K?t.jsx(Co,{src:K,href:S,alt:F,emoticon:w},u):t.jsx(tr,{href:S,alt:F,emoticon:w},u)}if(g==="a"){const S=fs((L=c.getAttribute)==null?void 0:L.call(c,"href"),n.baseUrl),F=f();return S?i.createElement("a",{key:u,href:S,target:"_blank",rel:"noreferrer noopener",className:x},...F.length?F:[S]):F.length?i.createElement(i.Fragment,{key:u},...F):null}const m={key:u};if(x&&(m.className=x),g==="td"||g==="th"){const S=ms((R=c.getAttribute)==null?void 0:R.call(c,"colspan")),F=ms((v=c.getAttribute)==null?void 0:v.call(c,"rowspan"));S&&(m.colSpan=S),F&&(m.rowSpan=F)}return g==="table"?t.jsx("div",{className:"jr-table-wrap",tabIndex:0,role:"region","aria-label":"Table",children:i.createElement("table",{className:x},...f())},u):(g==="pre"&&Object.assign(m,{tabIndex:0,role:"region","aria-label":"Code"}),vo.has(g)?i.createElement(g,m):i.createElement(g,m,...f()))},l=[];for(let c=0;c<r.childNodes.length;c++){const u=d(r.childNodes[c],String(c),0);u!==null&&u!==""&&l.push(u)}return l.length?l:null}function ps({html:e,ctx:n,className:s="jr-html",empty:r}){const a=i.useMemo(()=>Ao(e,n),[e,n]);return a?t.jsx("div",{className:s,children:a}):r?t.jsx(t.Fragment,{children:r}):null}function Lo(e){const n=/^(.*?)([#!]\d+)$/.exec(e);return n?{path:n[1],num:n[2]}:/^[A-Z][A-Z0-9_]*-\d+$/.test(e)?{path:"",num:e}:{path:e,num:""}}function nr({value:e,label:n}){const[s,r]=i.useState(!1);return i.useEffect(()=>{if(!s)return;const a=window.setTimeout(()=>r(!1),1500);return()=>window.clearTimeout(a)},[s]),t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"glyph-btn ig-copy","data-done":s||void 0,"aria-label":`Copy ${n}`,title:s?"Copied":`Copy ${n}`,onClick:a=>{a.stopPropagation(),Wr(e).then(o=>r(!!o))},children:s?t.jsx(Hn,{}):t.jsx(Xa,{})}),t.jsx("span",{className:"vis-hidden",role:"status",children:s?`${n[0].toUpperCase()}${n.slice(1)} copied`:""})]})}function Pt({reference:e,context:n,copyValue:s,copyLabel:r,href:a,openLabel:o,narrow:d,onClose:l}){const{path:c,num:u}=Lo(e);return t.jsxs("div",{className:"ig-detail-bar",children:[t.jsxs("span",{className:"ig-ref",children:[n&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"ig-ref-context",title:n,children:n}),t.jsx("span",{className:"ig-ref-separator","aria-hidden":!0,children:"/"})]}),t.jsxs("code",{className:"ig-ref-text",title:e,children:[c&&t.jsx("span",{className:"ig-ref-path",children:c}),u&&t.jsx("span",{className:"ig-ref-num",children:u})]}),t.jsx(nr,{value:s??e,label:r})]}),t.jsxs("span",{className:"ig-detail-bar-end",children:[a&&t.jsxs("a",{className:"ig-open",href:a,target:"_blank",rel:"noreferrer noopener",children:[o,t.jsx(xt,{})]}),!d&&t.jsx("button",{type:"button",className:"glyph-btn ig-detail-close","aria-label":"Close details",title:"Close",onClick:l,children:t.jsx(qs,{})})]})]})}function Be({label:e,children:n}){return n==null||n===""||Array.isArray(n)&&n.length===0?null:t.jsxs("div",{className:"jr-field",children:[t.jsx("dt",{children:e}),t.jsx("dd",{children:n})]})}function wn({person:e,fallback:n,you:s=!1}){return e?t.jsx(Js,{src:e.avatar,name:e.name,size:18,you:s}):t.jsx("span",{className:"jr-dim",children:n})}function Eo({issues:e,onOpen:n}){return t.jsx("ul",{className:"jr-detail-subtasks",children:e.map(s=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"jr-detail-sub","data-mine":s.mine||void 0,"data-done":s.status.category==="done"||void 0,onClick:()=>n(s.key),"aria-label":`${s.key}: ${s.summary}. ${s.status.name}${s.assignee?`, ${s.assignee.name}${s.mine?", assigned to you":""}`:", unassigned"}`,children:[t.jsx(rn,{type:s.type}),t.jsx("span",{className:"jr-key",children:s.key}),t.jsx("span",{className:"jr-summary",children:s.summary}),t.jsx(an,{status:s.status}),s.assignee?t.jsx(Ot,{src:s.assignee.avatar,name:s.assignee.name,size:18,you:s.mine}):t.jsx(zs,{size:18})]})},s.key))})}function Mo({conn:e,api:n,assetUrl:s,trail:r,estimation:a,time:o,onOpen:d,onTrail:l,onReconnect:c,narrow:u,auto:j=!1,onClose:h}){var K;const f=r[r.length-1]??null,{data:g,loading:y,error:x,reload:m}=Va(n,e.id,f),k=i.useMemo(()=>({baseUrl:e.baseUrl,image:w=>ga(e,s,w)}),[e,s]),p=g&&g.issue.key===f?g.issue:null,T=p?ba(p):null,L=i.useRef(!1),R=w=>{L.current=!0,w()},v=p==null?void 0:p.key;i.useEffect(()=>{var B;if(!v)return;const w=L.current;if(L.current=!1,j)return;const E=document.activeElement,$=E==null||E===document.body,I=E instanceof HTMLElement&&E.matches("[data-ig-back]");ya({handedOff:w,narrow:u,focusLost:$,focusOnBack:I})&&((B=document.getElementById("jira-detail-title"))==null||B.focus())},[u,v,j]);const S=[],F=(K=p==null?void 0:p.parent)==null?void 0:K.key;return F&&!r.slice(0,-1).includes(F)&&S.push({label:F,title:p.parent.summary,go:()=>R(()=>d(F,"replace"))}),r.slice(0,-1).forEach((w,E)=>S.push({label:w,title:`Back to ${w}`,go:()=>R(()=>l(E))})),f?t.jsxs("article",{className:"jr-detail","aria-busy":y||void 0,"aria-labelledby":"jira-detail-title",children:[t.jsx(Pt,{reference:f,context:p==null?void 0:p.project.name,copyLabel:"key",href:(p==null?void 0:p.url)??null,openLabel:"Open in Jira",narrow:u,onClose:h}),S.length>0&&t.jsx("ol",{className:"jr-crumbs",role:"list","aria-label":"Related issues",children:S.map((w,E)=>t.jsx("li",{children:w.go?t.jsx("button",{type:"button",className:"jr-crumb",title:w.title,onClick:w.go,children:w.label}):t.jsx("span",{className:"jr-crumb-text",title:w.title,children:w.label})},`${w.label}-${E}`))}),x&&t.jsx(bt,{error:x,provider:"Jira",host:jt(e),stale:!!p,onRetry:m,onReconnect:c}),!p&&y&&t.jsx(sn,{label:`Reading ${f}`,rows:4,variant:"lines"}),p&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"jr-detail-head",children:[t.jsx("h2",{id:"jira-detail-title",tabIndex:-1,className:"jr-detail-title",children:p.summary}),t.jsxs("p",{className:"jr-detail-state",children:[t.jsxs("span",{className:"jr-with-icon",children:[t.jsx(rn,{type:p.type}),p.type.name]}),t.jsx(an,{status:p.status}),T&&t.jsx("span",{className:"jr-dim",children:T}),p.priority&&t.jsxs("span",{className:"jr-with-icon",children:[t.jsx(qn,{priority:p.priority}),p.priority.name]}),p.flagged&&t.jsxs("span",{className:"jr-flagged",children:[t.jsx(er,{})," Flagged"]})]})]}),t.jsxs("dl",{className:"jr-fields",children:[t.jsx(Be,{label:"Assignee",children:t.jsx(wn,{person:p.assignee,fallback:"Unassigned",you:p.mine})}),t.jsx(Be,{label:"Reporter",children:p.reporter?t.jsx(wn,{person:p.reporter,fallback:""}):null}),t.jsx(Be,{label:"Sprint",children:p.sprint?t.jsxs(t.Fragment,{children:[p.sprint.name,p.sprint.state?t.jsxs("span",{className:"jr-dim",children:[" · ",p.sprint.state]}):null]}):null}),t.jsx(Be,{label:"Epic",children:p.epic?t.jsx(Zs,{epic:p.epic}):null}),t.jsx(Be,{label:"Fix versions",children:p.fixVersions.length?t.jsx("span",{className:"jr-chips",children:p.fixVersions.map(w=>t.jsx("span",{className:"jr-version",children:w},w))}):null}),t.jsx(Be,{label:"Labels",children:p.labels.length?t.jsx("span",{className:"jr-chips",children:p.labels.map(w=>t.jsx("span",{className:"jr-label",children:w},w))}):null}),t.jsx(Be,{label:"Components",children:p.components.join(", ")}),t.jsx(Be,{label:"Due",children:St(p.dueDate)}),a==="points"&&t.jsx(Be,{label:"Estimate",children:p.points!=null?`${p.points} ${p.points===1?"point":"points"}`:null}),t.jsx(Be,{label:"Time",children:Ra(p,o)})]}),t.jsx("p",{className:"jr-detail-dates",children:[p.created&&`Created ${St(p.created,!0)}`,p.updated&&`Updated ${St(p.updated,!0)}`].filter(Boolean).join(" · ")}),t.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-desc",children:[t.jsx("h3",{id:"jira-detail-desc",children:"Description"}),t.jsx(ps,{html:p.descriptionHtml,ctx:k,empty:t.jsx("p",{className:"jr-dim",children:"No description."})})]}),g.subtasks.length>0&&t.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-subs",children:[t.jsxs("h3",{id:"jira-detail-subs",children:["Sub-tasks ",t.jsx("span",{className:"jr-count",children:g.subtasks.length})]}),t.jsx(Eo,{issues:g.subtasks,onOpen:w=>R(()=>d(w,"push"))})]}),g.attachments.length>0&&t.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-files",children:[t.jsxs("h3",{id:"jira-detail-files",children:["Attachments ",t.jsx("span",{className:"jr-count",children:g.attachments.length})]}),t.jsx("ul",{className:"jr-files",children:g.attachments.map(w=>t.jsxs("li",{children:[w.url?t.jsxs("a",{href:w.url,target:"_blank",rel:"noreferrer noopener",title:"Opens in Jira",children:[w.filename,t.jsx(xt,{})]}):t.jsx("span",{children:w.filename}),t.jsx("span",{className:"jr-dim",children:[Aa(w.size),St(w.created)].filter(Boolean).join(" · ")})]},w.id))})]}),t.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-comments",children:[t.jsxs("h3",{id:"jira-detail-comments",children:["Comments ",t.jsx("span",{className:"jr-count",children:g.comments.total>g.comments.items.length?`${g.comments.items.length} of ${g.comments.total}`:g.comments.total})]}),g.comments.items.length===0&&t.jsx("p",{className:"jr-dim",children:"No comments."}),t.jsx("ol",{className:"jr-comments",children:g.comments.items.map(w=>t.jsxs("li",{className:"jr-comment",children:[t.jsxs("div",{className:"jr-comment-head",children:[t.jsx(wn,{person:w.author,fallback:"Someone"}),t.jsx("time",{className:"jr-dim",dateTime:w.created,children:St(w.created,!0)}),w.updated&&w.updated!==w.created&&t.jsx("span",{className:"jr-dim",children:"edited"})]}),t.jsx(ps,{html:w.html,ctx:k,empty:t.jsx("p",{className:"jr-dim",children:"(empty)"})})]},w.id))}),g.comments.total>g.comments.items.length&&t.jsx("p",{className:"jr-dim",children:t.jsxs("a",{className:"jr-more-link",href:p.url,target:"_blank",rel:"noreferrer noopener",children:["The older comments are in Jira ",t.jsx(xt,{})]})})]})]})]}):null}const To=e=>typeof e=="string"&&e.length>0&&e.length<=40,Nn=e=>typeof e=="boolean",Do=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&Object.values(e).every(n=>typeof n=="boolean"),Io=e=>!!e&&typeof e=="object"&&typeof e.board=="string"&&Array.isArray(e.ids)&&e.ids.every(n=>typeof n=="string");function Fo({api:e,current:n,layerId:s,onPick:r,onClose:a}){const[o,d]=i.useState(""),[l,c]=i.useState({boards:[],isLast:!1,total:null,loading:!0,error:null}),u=i.useRef(null),j=i.useRef(null),h=i.useRef(0),f=i.useCallback((x,m)=>{const k=++h.current;c(p=>({...p,loading:!0,error:null,...m===0?{boards:[]}:{}})),Bs(e,m,x).then(p=>{k===h.current&&c(T=>({boards:m===0?p.boards:[...T.boards,...p.boards.filter(L=>!T.boards.some(R=>R.id===L.id))],isLast:p.isLast,total:p.total,loading:!1,error:null}))}).catch(p=>{k===h.current&&c(T=>({...T,loading:!1,error:Ge(p)}))})},[e]);i.useEffect(()=>{const x=window.setTimeout(()=>f(o.trim(),0),o?250:0);return()=>window.clearTimeout(x)},[o,f]);const g=()=>{var x;return Array.from(((x=j.current)==null?void 0:x.querySelectorAll("button[data-board]"))??[])},y=x=>{var T;if(x.key!=="ArrowDown"&&x.key!=="ArrowUp")return;const m=g();if(!m.length)return;x.preventDefault();const k=m.indexOf(document.activeElement),p=x.key==="ArrowDown"?k<0?0:Math.min(m.length-1,k+1):k<=0?-1:k-1;p<0?(T=u.current)==null||T.focus():m[p].focus()};return t.jsx(nn,{anchorId:s,align:"start",portalRootId:s,id:"jira-board-picker",className:"jr-board-pop",role:"dialog",labelledBy:"jira-board-picker-title",focusRef:u,onClose:a,children:t.jsxs("div",{className:"jr-board-pop-inner",onKeyDown:y,children:[t.jsx("p",{className:"jr-board-pop-title",id:"jira-board-picker-title",children:"Boards"}),t.jsx(Wn,{value:o,onChange:d,label:"Find a board by name",placeholder:"Find a board by name",inputRef:u}),t.jsx("ul",{className:"jr-board-list",role:"list",ref:j,"aria-label":"Boards","aria-busy":l.loading||void 0,children:l.boards.map(x=>t.jsx("li",{children:t.jsxs("button",{type:"button","data-board":x.id,className:"jr-board-item","aria-current":String(x.id)===n||void 0,onClick:()=>r(x),children:[t.jsx("span",{className:"jr-board-item-name",children:x.name}),t.jsx("span",{className:"jr-board-item-meta",children:[x.type,x.projectName||x.projectKey].filter(Boolean).join(" · ")})]})},x.id))}),l.loading&&t.jsx("p",{className:"jr-board-pop-note",role:"status",children:"Reading boards…"}),!l.loading&&l.error&&t.jsx("p",{className:"jr-board-pop-note",role:"alert",children:l.error.message}),!l.loading&&!l.error&&l.boards.length===0&&t.jsx("p",{className:"jr-board-pop-note",children:o?"No board by that name.":"No boards this account can see."}),!l.loading&&!l.isLast&&l.boards.length>0&&t.jsxs("button",{type:"button",className:"btn jr-board-more",onClick:()=>f(o.trim(),l.boards.length),children:["Show more boards",l.total!=null?` (${l.boards.length} of ${l.total})`:""]})]})})}const Bo=(e,n)=>e[e.length-1]===n[n.length-1];function Oo({connection:e,api:n,assetUrl:s,prefs:r,narrow:a,onReconnect:o}){var qe,Ht;const d=i.useId(),l=`jira:${e.id}`,[c,u]=i.useState(()=>r.read("board",To)??null),[j,h]=i.useState(()=>r.read("boardName",M=>typeof M=="string")??""),[f,g]=i.useState(()=>r.read("mine",Nn)??!0),[y,x]=i.useState(()=>r.read("hideDone",Nn)??!1),[m,k]=i.useState(()=>r.read("attention",Nn)??!1),[p,T]=i.useState(()=>{const M=r.read("quick",Io);return M&&M.board===c?M.ids:[]}),[L,R]=i.useState(()=>r.read("expanded",Do)??{}),[v,S]=i.useState(()=>En(l)),F=M=>{S(M),Ks(l,M)},K=i.useRef(null),[w,E]=i.useState(!1),[$,I]=i.useState(null),[B,C]=i.useState(!1);i.useEffect(()=>{r.write("mine",f)},[r,f]),i.useEffect(()=>{r.write("hideDone",y)},[r,y]),i.useEffect(()=>{r.write("attention",m)},[r,m]),i.useEffect(()=>{c&&r.write("quick",{board:c,ids:p})},[r,c,p]),i.useEffect(()=>{r.write("expanded",L)},[r,L]);const U=i.useCallback(M=>{const H=String(M.id);u(H),h(M.name),r.write("board",H),r.write("boardName",M.name),T([])},[r]),W=i.useCallback(()=>{I(null),C(!1),Bs(n,0,"").then(M=>{M.boards[0]?U(M.boards[0]):C(!0)}).catch(M=>I(Ge(M)))},[n,U]);i.useEffect(()=>{c||W()},[c,W]);const ee=i.useMemo(()=>({mine:f,quick:p}),[f,p]),se=Ga(n,e.id,c,ee),{snap:V,groups:J,loading:Y,error:ve}=se,me=i.useRef(!1),[dt,_e]=i.useState(!1),$e=Object.values(V.groups).some(M=>M.more||M.status==="loading"),Le=i.useRef(c);Le.current=c;const Ke=async M=>{if(!c||me.current||Y||$e)throw new Error("Wait for the board to finish updating.");me.current=!0,_e(!0);try{return await ua(n,c,M)}finally{me.current=!1,_e(!1),_a(e.id),Le.current===c&&await se.refresh()}},P=V.overview&&String(V.overview.board.id)===c?V.overview:null;i.useEffect(()=>{P&&P.board.name&&P.board.name!==j&&(h(P.board.name),r.write("boardName",P.board.name))},[P,j,r]);const{ensureGroup:be}=se;i.useEffect(()=>{for(const M of J)M.kind==="closed"&&L[M.id]&&be(M)},[J,L,be]);const tt=(M,H)=>R(ae=>({...ae,[M.id]:H})),he=f||y||m||p.length>0||v.trim()!=="",Ee=()=>{var M;g(!1),x(!1),k(!1),T([]),F(""),(M=K.current)==null||M.focus()},He=i.useMemo(()=>({search:v,hideDone:y,attention:m}),[v,y,m]),nt=i.useMemo(()=>wa((P==null?void 0:P.quickFilters)??[]),[P]);i.useEffect(()=>{if(!P)return;const M=new Set(nt.map(H=>H.id));T(H=>H.every(ae=>M.has(ae))?H:H.filter(ae=>M.has(ae)))},[P,nt]);const A=_s(l,c),[re,pe]=i.useState(()=>{var M;return{key:A,open:((M=Dt(A))==null?void 0:M.rows)??{}}});let xe=re.open;re.key!==A&&(xe=((qe=Dt(A))==null?void 0:qe.rows)??{},pe({key:A,open:xe}));const Me=(M,H)=>{const ae={...xe,[M]:H};pe({key:A,open:ae}),ot(A,{rows:ae})},Te=i.useMemo(()=>P?Ps(J,V.groups,M=>{var H;return(H=V.subtasks[M])==null?void 0:H.issues},He):[],[P,J,V.groups,V.subtasks,He]),De=i.useMemo(()=>{if(!P)return null;const{complete:M,keys:H,first:ae}=$a(Te,L,xe,V.subtasks,He,he);return{complete:M,has:Wt=>H.has(Wt[0]),first:ae==null?null:[ae]}},[P,Te,L,xe,V.subtasks,He,he]),ut=i.useRef(null),ge=Hs({listKey:A,drawn:De,same:Bo,sideBySide:!a,root:ut,listScroller:".jr-list-scroll"}),{choose:ze}=ge,je=i.useMemo(()=>ge.selection??[],[ge.selection]),Kt=je.length>0,Se=M=>{ze([M]),a&&requestAnimationFrame(()=>{var H;return(H=document.getElementById("jira-detail-title")??document.querySelector(".ig-detail [data-ig-back]"))==null?void 0:H.focus()})},$t=i.useCallback(()=>{const M=je[0];ze(null),requestAnimationFrame(()=>{const H=M?document.querySelector(`.jr-row-main[data-key="${CSS.escape(M)}"]`):null;H==null||H.focus()})},[je,ze]),Je=jt(e),We=P?null:ve??$,gn=B?t.jsxs("div",{className:"jr-state",children:[t.jsx("h3",{children:"No boards here"}),t.jsxs("p",{children:["This account cannot see any board on ",Je,". A board appears here once you are given access to one in Jira."]}),t.jsx("p",{children:t.jsxs("a",{className:"ig-open",href:`${e.baseUrl}/secure/ManageRapidViews.jspa`,target:"_blank",rel:"noreferrer noopener",children:["Open boards in Jira",t.jsx(xt,{})]})})]}):We?t.jsxs("div",{className:"jr-state",children:[t.jsx(bt,{error:We,provider:"Jira",host:Je,onRetry:c?se.refresh:W,onReconnect:o}),We.kind==="not-found"&&c&&t.jsx("p",{children:t.jsx("button",{type:"button",className:"btn",onClick:()=>E(!0),children:"Choose another board"})})]}):P?t.jsxs(t.Fragment,{children:[ve&&t.jsx(bt,{error:ve,provider:"Jira",host:Je,stale:!0,onRetry:se.refresh,onReconnect:o}),t.jsx(jo,{conn:e,overview:P,groups:J,snap:V,expanded:L,onToggleGroup:tt,filter:He,mine:f,filtered:he,selected:je[je.length-1]??null,onOpen:Se,rowsOpen:xe,onToggleRow:Me,onRetryGroup:M=>se.ensureGroup(M,!0),onMore:se.loadMore,onShowClosed:se.showClosed,onMoreClosed:se.moreClosed,loadSubtasks:se.loadSubtasks,onReconnect:o,onMove:Ke,moveBusy:dt||Y||$e,scrollBoundaryId:d},c)]}):t.jsx(sn,{label:"Reading the board",rows:6}),jn=Kt&&P?t.jsx(Mo,{conn:e,api:n,assetUrl:s,trail:je,estimation:P.estimation.kind,time:P.timeTracking,onOpen:(M,H)=>ze(H==="push"?[...je.filter(ae=>ae!==M),M]:[M]),onTrail:M=>ze(je.slice(0,M+1)),onReconnect:o,narrow:a,auto:ge.auto,onClose:$t}):null;return t.jsxs("div",{ref:ut,className:"jr-panel","data-deployment":((Ht=e.meta)==null?void 0:Ht.deployment)==="cloud"?"cloud":"server",children:[t.jsxs("div",{className:"jr-toolbar",hidden:a&&Kt,children:[t.jsx("span",{id:"jira-board-layer",className:"jr-board-layer",children:t.jsxs("button",{type:"button",id:"jira-board-button",className:"btn jr-board-btn","aria-label":`Board: ${(P==null?void 0:P.board.name)||j||(c?`Board ${c}`:"Choose a board")}`,title:[...new Set([(P==null?void 0:P.board.name)||j,P==null?void 0:P.board.projectName].filter(Boolean))].join(" · "),"aria-haspopup":"dialog","aria-expanded":w,"aria-controls":w?"jira-board-picker":void 0,onClick:()=>E(M=>!M),children:[t.jsx("span",{className:"jr-board-btn-label",children:"Board"}),t.jsx("span",{className:"jr-board-btn-name",children:(P==null?void 0:P.board.name)||j||(c?`Board ${c}`:"Choose a board")}),t.jsx(Dn,{open:w})]})}),t.jsxs("div",{className:"jr-filters",role:"group","aria-label":"Filters",children:[t.jsx(Wn,{inputRef:K,value:v,onChange:F,label:"Search issues by key or summary",placeholder:"Search key or summary"}),t.jsxs("div",{className:"jr-filter-chips",children:[t.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":f,onClick:()=>g(M=>!M),children:"Only my issues"}),t.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":y,onClick:()=>x(M=>!M),children:"Hide done"}),t.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":m,title:"Flagged, or Highest, Blocker or Critical priority, and not done",onClick:()=>k(M=>!M),children:"Needs attention"}),nt.map(M=>t.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":p.includes(M.id),title:M.description||void 0,onClick:()=>T(H=>H.includes(M.id)?H.filter(ae=>ae!==M.id):[...H,M.id]),children:M.name},M.id))]}),he&&t.jsx("button",{type:"button",className:"jr-link-btn jr-clear",onClick:Ee,children:"Clear filters"})]}),t.jsx(Gs,{loadedAt:V.loadedAt||null,loading:Y,stale:!!ve,onRefresh:()=>{c?se.refresh():W()},label:"Refresh the board",disabled:!c})]}),t.jsx(_n,{storageKey:"jira",automaticDetailShare:.4,list:t.jsx("div",{className:"jr-list-scroll",id:d,children:gn}),detail:jn,onBack:$t,backLabel:"Back to the board",detailKey:je[je.length-1]}),w&&t.jsx(Fo,{api:n,current:c,layerId:"jira-board-layer",onPick:M=>{var H;U(M),E(!1),(H=document.getElementById("jira-board-button"))==null||H.focus()},onClose:()=>{var H,ae;const M=(H=document.getElementById("jira-board-picker"))==null?void 0:H.contains(document.activeElement);E(!1),M&&((ae=document.getElementById("jira-board-button"))==null||ae.focus())}})]})}const Z={github:{name:"GitHub",change:"Pull request",changes:"Pull requests",changeSigil:"#",pipeline:"Workflow run",pipelines:"Actions",repo:"Repository"},gitlab:{name:"GitLab",change:"Merge request",changes:"Merge requests",changeSigil:"!",pipeline:"Pipeline",pipelines:"Pipelines",repo:"Project"}},Po=12e4;function en(e,n={}){const s=new URLSearchParams;for(const[a,o]of Object.entries(n))o!=null&&o!==""&&s.set(a,String(o));const r=s.toString();return`${e}${r?`?${r}`:""}`}class Mt extends Error{constructor(n){super(n.message),this.info=n,this.name="ForgeReadError"}}async function Gn(e,n,s){let r;try{r=await e(n,{signal:s,headers:{accept:"application/json"}})}catch(d){throw(d==null?void 0:d.name)==="AbortError"?d:new Mt({kind:"unreachable",message:"the deck did not answer"})}let a=null;try{a=await r.json()}catch{}if(r.ok&&(a!=null&&a.ok))return a.data;const o=a==null?void 0:a.error;throw o&&typeof o=="object"&&typeof o.kind=="string"?new Mt(o):new Mt({kind:"upstream",message:typeof o=="string"?o:`the deck answered ${r.status}`,status:r.status})}const mt=new Map,Uo=200;function Et(e){return mt.get(e)??{data:null,loadedAt:null,error:null}}function In(e,n){for(mt.delete(e),mt.set(e,n);mt.size>Uo;)mt.delete(mt.keys().next().value)}function gs(e,n,s=!1){return s||e.loadedAt==null||n-e.loadedAt>=Po}function _o(e){return e.data!=null&&e.error!=null}const js={success:{mark:"passed",word:"passed",tone:"ok"},failed:{mark:"failed",word:"failed",tone:"bad"},running:{mark:"running",word:"running",tone:"busy"},pending:{mark:"pending",word:"pending",tone:"busy"},canceled:{mark:"canceled",word:"canceled",tone:"idle"},skipped:{mark:"skipped",word:"skipped",tone:"idle"},manual:{mark:"manual",word:"manual",tone:"idle"},none:{mark:"none",word:"no pipeline",tone:"idle"}};function Ne(e){return js[e??"none"]??js.none}function Ut(e){return e.state==="merged"?{mark:"merged",word:"Merged",tone:"ok"}:e.state==="closed"?{mark:"closed",word:"Closed",tone:"idle"}:e.draft?{mark:"draft",word:"Draft",tone:"idle"}:e.approved?{mark:"approved",word:"Approved",tone:"ok"}:{mark:"open",word:"Open",tone:"busy"}}function sr(e){switch(e){case"approved":return{mark:"approved",word:"approved",tone:"ok"};case"changes_requested":return{mark:"changes-requested",word:"changes requested",tone:"bad"};case"commented":return{mark:"commented",word:"commented",tone:"idle"};default:return{mark:"review-pending",word:"review pending",tone:"idle"}}}function Ko(e,n){const s=n==null?void 0:n.login.trim().toLowerCase();return!!s&&!!e&&e.login.trim().toLowerCase()===s}function tn(e){return e==null?"–":e>=1e3?"999+":String(e)}function _t(e){if(e==null||!Number.isFinite(e)||e<0)return null;const n=Math.round(e);return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n%3600/60)).padStart(2,"0")}m`}function Ho(e){const n=[],s=[];for(const r of e)(r.stale&&!r.isDefault?s:n).push(r);return{active:n,stale:s}}function Wo(e){const n=[],s=[];for(const r of e)(r.approvedByMe?s:n).push(r);return{waiting:n,approved:s}}function on(e,n){const s=n.trim().toLowerCase();if(!s)return!0;const r=[e.key,e.title,e.name,e.number!=null?String(e.number):null].filter(a=>typeof a=="string").join(`
3
+ `).toLowerCase();return s.replace(/^[#!]/,"").split(/\s+/).every(a=>r.includes(a))}function xs(e){const n=e.trim();return/^https?:\/\/\S+\/(?:-\/)?(?:merge_requests|issues|pull)\/\d+/.test(n)||/^[\w.-]+(?:\/[\w.-]+)+[#!]\d+$/.test(n)}const Ct={tab:"branches",filter:"all",state:"open",sort:"created",issueState:"open"},qo=["branches","changes","pipelines","issues"],rr="view",Go=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function bs(e){return Vo(e.read(rr,Go)??{})}function ys(e,n){e.write(rr,n)}function Vo(e){const n=(s,r,a)=>r.includes(s)?s:a;return{repo:typeof e.repo=="string"&&e.repo.length<=255?e.repo:null,tab:n(e.tab,qo,Ct.tab),filter:n(e.filter,["all","mine","review"],Ct.filter),state:n(e.state,["open","merged","closed"],Ct.state),sort:n(e.sort,["created","updated"],Ct.sort),issueState:n(e.issueState,["open","closed"],Ct.issueState),open:Array.isArray(e.open)?e.open.filter(s=>typeof s=="string").slice(0,20):[]}}function zo(e,n,s){return e?s||!n?"page":"stay":"opener"}function Jo(e,n,s){if(s<=0)return null;switch(e){case"ArrowDown":return Math.min(s-1,n+1);case"ArrowUp":return Math.max(0,n-1);case"Home":return 0;case"End":return s-1;default:return null}}function Xo(e,n,s){return e<=0?-1:n>=0&&n<e?n:s>=0&&s<e?s:0}function Qo(e,n,s=8){return n.left<e.left?n.left-e.left-s:n.right>e.right?n.right-e.right+s:0}function Yo(e,n){return n==="branches"?!1:n==="issues"?e==="gitlab":!0}function ar(e){return e instanceof Mt?e.info:{kind:"upstream",message:"the read failed"}}function Ue(e,n,s,r={},a=0){const o=s?en(s,r):null,d=o?`${n}
4
+ ${o}`:null,[l,c]=i.useState(()=>({key:d,read:rt(d?Et(d):null,!1)})),[u,j]=i.useState(0),h=i.useRef(a);i.useEffect(()=>{if(!d||!o){c({key:d,read:rt(null,!1)});return}const x=Et(d),m=u>0||a!==h.current;if(h.current=a,!gs(x,Date.now(),m)){c({key:d,read:rt(x,!1)});return}c({key:d,read:rt(x,!0)});const k=new AbortController;return Gn(e,o,k.signal).then(p=>{const T={data:p,loadedAt:Date.now(),error:null};In(d,T),k.signal.aborted||c({key:d,read:rt(T,!1)})},p=>{if(k.signal.aborted||(p==null?void 0:p.name)==="AbortError")return;const T={...Et(d),error:ar(p)};In(d,T),c({key:d,read:rt(T,!1)})}),()=>k.abort()},[e,d,o,a,u]);const f=i.useCallback(()=>j(x=>x+1),[]),g=l.key===d||!d?null:Et(d);return{...l.key===d?l.read:rt(g,g!=null&&gs(g,Date.now())),reload:f}}function rt(e,n){return{data:(e==null?void 0:e.data)??null,error:(e==null?void 0:e.error)??null,loading:n,loadedAt:(e==null?void 0:e.loadedAt)??null,stale:e?_o(e):!1}}function Ze(e,n,s,r={},a=0){var T;const o=Ue(e,n,s,r,a),d=s?en(s,r):null,l=d?`${n}
5
+ ${d}
6
+ more`:null,[c,u]=i.useState(()=>({key:l,...ks(l)})),[j,h]=i.useState(!1),[f,g]=i.useState(null),y=i.useRef(!1),x=o.loadedAt;i.useEffect(()=>{g(null);const L=ks(l);u(L.base!=null&&L.base===x?{key:l,...L}:{key:l,items:[],next:void 0,base:x})},[l,x]);const m=c.next!==void 0?c.next:((T=o.data)==null?void 0:T.next)??null,k=i.useCallback(()=>{!s||!m||!l||!we(y.current)||(y.current=!0,h(!0),g(null),Gn(e,en(s,{...r,cursor:m})).then(L=>{u(R=>{const v={key:l,items:[...R.items,...L.items],next:L.next,base:R.base??x};return In(l,{data:v,loadedAt:Date.now(),error:null}),v})},L=>g(ar(L))).finally(()=>{y.current=!1,h(!1)}))},[e,s,m,l,r,x]),p=o.data?{items:[...o.data.items,...c.key===l?c.items:[]],next:m,total:o.data.total}:null;return{...o,data:p,loadingMore:j,moreError:f,loadMore:k,reload:o.reload}}function ks(e){const n=e?Et(e).data:null;return n?{items:n.items,next:n.next,base:n.base}:{items:[],next:void 0,base:null}}const or=i.createContext(null);function Zo({value:e,children:n}){return t.jsx(or.Provider,{value:e,children:n})}function Q(){const e=i.useContext(or);if(!e)throw new Error("useForge outside a forge panel");return e}function ln(e,n){const{listKey:s,reportRows:r}=Q(),a=i.useRef(e);a.current=e;const o=e.map(lr).join(`
7
+ `);Xt(()=>{r({key:s,complete:n,items:a.current})},[r,s,n,o])}function lr(e){switch(e.type){case"change":case"issue":return`${e.type}:${e.repo}:${e.number}`;case"branch":return`branch:${e.repo}:${e.name}`;case"pipeline":return`pipeline:${e.repo}:${e.id}`}}function yt(e,n){if(!e||e.type!==n.type||e.repo!==n.repo)return!1;switch(n.type){case"change":case"issue":return e.number===n.number;case"branch":return e.name===n.name;case"pipeline":return e.id===n.id}}const Oe=t.jsx("circle",{cx:"7",cy:"7",r:"5.6"});function el(e){switch(e){case"passed":case"done":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"m4.6 7.2 1.7 1.7 3.2-3.5"})]});case"failed":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"M5 5l4 4M9 5 5 9"})]});case"running":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"M7 3.6a3.4 3.4 0 0 1 0 6.8z",fill:"currentColor",stroke:"none"})]});case"pending":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"M7 4.2V7l1.9 1.2"})]});case"canceled":case"closed":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"m3.1 10.9 7.8-7.8"})]});case"skipped":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"m4.7 5 2 2-2 2M7.5 5l2 2-2 2"})]});case"manual":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"M5.8 4.7v4.6L9.4 7z"})]});case"none":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"M4.7 7h4.6"})]});case"warning":return t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),t.jsx("path",{d:"M7 5.6v2.9M7 10.3v.05"})]});case"open":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("circle",{cx:"7",cy:"7",r:"2",fill:"currentColor",stroke:"none"})]});case"draft":return t.jsx("circle",{cx:"7",cy:"7",r:"5.6",strokeDasharray:"2.4 2"});case"merged":return t.jsx("path",{d:"M4.4 2.4v2.8c0 2.3 2.6 2.7 2.6 4.8v1.6M9.6 2.4v2.8c0 2.3-2.6 2.7-2.6 4.8"});case"approved":case"resolved":return t.jsx("path",{d:"m2.6 7.4 2.9 2.9 5.9-6.4"});case"changes-requested":return t.jsx("path",{d:"M7 2.4v5.2M4.4 5h5.2M4.4 11h5.2"});case"commented":return t.jsx("path",{d:"M2.2 2.8h9.6v6.6H6.4l-2.5 2.2V9.4H2.2z"});case"review-pending":return t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M1.4 7S3.4 3.4 7 3.4 12.6 7 12.6 7 10.6 10.6 7 10.6 1.4 7 1.4 7z"}),t.jsx("circle",{cx:"7",cy:"7",r:"1.7"})]});case"info":return t.jsxs(t.Fragment,{children:[Oe,t.jsx("path",{d:"M7 6.5v3.4M7 4.4v.05"})]});case"linked":return t.jsx("path",{d:"M2.4 5h9L9.2 2.8M11.6 9h-9l2.2 2.2"})}}function cn({name:e,size:n=12,weight:s=1.3}){return t.jsx("svg",{className:"fg-glyph","data-glyph":e,width:n,height:n,viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:el(e)})}function ir(){return t.jsx("svg",{className:"fgl-chevron",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4l2.5 2.5L7.5 4"})})}function ue({mark:e,quiet:n=!1,className:s}){return t.jsxs("span",{className:s?`fg-mark ${s}`:"fg-mark","data-tone":e.tone,title:e.word,children:[t.jsx(cn,{name:e.mark}),t.jsx("span",{className:n?"fg-sr":"fg-mark-word",children:e.word})]})}function it({mark:e}){return t.jsxs("span",{className:"fg-badge","data-tone":e.tone,children:[t.jsx(cn,{name:e.mark})," ",e.word]})}function lt({id:e,title:n,count:s,defaultOpen:r,children:a,aside:o}){const{isOpen:d,toggle:l}=Q(),c=d(e)?!r:r;return t.jsxs("section",{className:"fg-group","data-open":c||void 0,children:[t.jsxs("h3",{className:"fg-group-head",children:[t.jsxs("button",{type:"button",className:"fg-fold","data-nav":"","aria-expanded":c,onClick:()=>l(e),children:[t.jsx("span",{className:"fg-fold-chevron","aria-hidden":"true"}),n,s!=null&&t.jsx("span",{className:"fg-count",children:s.toLocaleString()})]}),o]}),c&&a]})}function ne({error:e,onRetry:n,compact:s=!1}){const{kind:r,connection:a,onReconnect:o}=Q(),d=e.kind==="permission"&&e.message?`${e.message.replace(/\.\s*$/,"")}. Check the token's scopes in the connection's settings.`:void 0;return t.jsx(bt,{error:e,provider:Z[r].name,host:tl(a.baseUrl),stale:s,onRetry:n,onReconnect:o,body:d})}function tl(e){try{return new URL(e).host||void 0}catch{return}}function et({pages:e,label:n="Load more"}){var s;return e.moreError?t.jsx(ne,{error:e.moreError,onRetry:e.loadMore,compact:!0}):(s=e.data)!=null&&s.next?t.jsx("button",{type:"button",className:"btn fg-more",onClick:e.loadMore,...Ce(e.loadingMore),children:e.loadingMore?"Loading…":n}):null}function Ae({rows:e=6,label:n}){return t.jsx(sn,{label:n,rows:e})}function Vn(){const{asset:e,connection:n}=Q();return s=>({src:s.avatarUrl?e(s.avatarUrl):null,direct:qr(n,s.avatarUrl),name:s.name||s.login,you:Ko(s,n.account)})}function vt({user:e,size:n=20,nameless:s=!1}){const r=Vn();return e?t.jsx(Js,{...r(e),size:n,nameless:s}):null}function cr({user:e,size:n=20}){const s=Vn();return t.jsx(Ot,{...s(e),size:n})}function ce({at:e}){const[,n]=i.useState(0);return i.useEffect(()=>{const s=window.setInterval(()=>n(r=>r+1),3e4);return()=>window.clearInterval(s)},[]),e==null?null:t.jsx("time",{dateTime:new Date(e).toISOString(),title:new Date(e).toLocaleString(),children:Es(Date.now()-e)})}function ct({value:e,label:n,children:s}){return t.jsxs("span",{className:"fg-copyable",children:[s??t.jsx("code",{children:e}),t.jsx(nr,{value:e,label:n})]})}function kt({href:e,children:n}){const{kind:s}=Q();return e?t.jsxs("a",{className:"ig-open",href:e,target:"_blank",rel:"noreferrer noopener",children:[n??`Open in ${Z[s].name}`,t.jsx(xt,{})]}):null}function nl(e){const n=i.useRef(null);i.useEffect(()=>{const s=e.current;if(!s)return;const r=()=>Array.from(s.querySelectorAll("[data-nav]")).filter(h=>h.getClientRects().length>0),a=h=>{const f=h.closest("li");return!f||!s.contains(f)?[]:Array.from(f.querySelectorAll("button, a[href], input, select, textarea")).filter(g=>g!==h&&!g.hasAttribute("data-nav")&&g.closest("li")===f)};let o;const d=(h,f)=>{for(const g of[h,...a(h)])f?g.removeAttribute("tabindex"):g.tabIndex!==-1&&(g.tabIndex=-1)},l=()=>{const h=r();o=h[Xo(h.length,n.current?h.indexOf(n.current):-1,h.findIndex(f=>f.getAttribute("aria-current")==="true"))];for(const f of h)d(f,f===o)},c=h=>{var g;const f=h.target;!((g=f.hasAttribute)!=null&&g.call(f,"data-nav"))||f===o||(n.current=f,o!=null&&o.isConnected&&d(o,!1),d(f,!0),o=f)},u=h=>{var p,T,L;const f=h.target;if(!((p=f.hasAttribute)!=null&&p.call(f,"data-nav"))||h.altKey||h.ctrlKey||h.metaKey||h.shiftKey)return;const g=r(),y=g.indexOf(f);if(y<0)return;const x=f.getAttribute("aria-expanded"),m=Jo(h.key,y,g.length);let k;if(m!=null)k=g[m];else if(h.key==="ArrowRight"&&x==="true")k=g[y+1];else if(h.key==="ArrowLeft"&&x==null)k=(T=f.closest(".fg-group"))==null?void 0:T.querySelector(".fg-group-head [data-nav]");else if(h.key==="ArrowRight"&&x==="false"||h.key==="ArrowLeft"&&x==="true"){h.preventDefault(),f.click();return}else return;h.preventDefault(),k&&k!==f&&(k.focus(),(L=k.scrollIntoView)==null||L.call(k,{block:"nearest"}))},j=new MutationObserver(l);return j.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-current","aria-expanded","hidden"]}),s.addEventListener("focusin",c),s.addEventListener("keydown",u),l(),()=>{j.disconnect(),s.removeEventListener("focusin",c),s.removeEventListener("keydown",u)}},[e])}function sl(e,n){i.useLayoutEffect(()=>{const s=e.current,r=s==null?void 0:s.querySelector('[aria-selected="true"]');!s||!r||s.scrollWidth<=s.clientWidth||(s.scrollLeft+=Qo(s.getBoundingClientRect(),r.getBoundingClientRect()))},[e,n])}function zn(e){const n=Z[e].repo.toLowerCase();return n.endsWith("y")?`${n.slice(0,-1)}ies`:`${n}s`}function dr(e){return`All ${zn(e)}`}function ur(e){const n=e.lastIndexOf("/");return n<0?{group:"",name:e}:{group:e.slice(0,n+1),name:e.slice(n+1)}}function hr(e,n,s){return s?n.key:`${e}${n.number}`}const rl=/^\s*(?:\[(?:draft|wip)\]|\((?:draft|wip)\)|(?:draft|wip)\s*:)\s*/i;function al(e,n){return n&&e.replace(rl,"")||e}function ol(e){return e.state==="merged"&&e.mergedAt!=null?{verb:"merged",at:e.mergedAt}:e.state==="closed"&&e.closedAt!=null?{verb:"closed",at:e.closedAt}:{verb:"updated",at:e.updatedAt}}function ll(e){return e.state!=="closed"?null:e.stateReason==="not_planned"?{mark:"closed",word:"Not planned",tone:"idle"}:e.stateReason==="duplicate"?{mark:"closed",word:"Duplicate",tone:"idle"}:null}function il(e){const n=e.findIndex(s=>s.isDefault);return n<=0?e:[e[n],...e.slice(0,n),...e.slice(n+1)]}function cl(e){return e==null||!Number.isFinite(e)||e<0?null:e.toLocaleString("en-US")}function dl(e){return typeof e=="string"&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)?e:null}function ul(e,n,s){if(e==null||n==null)return null;const r=s?`“${s}”`:"the default branch",a=o=>o>=1e3?"999+":String(o);return`${a(e)} ${e===1?"commit":"commits"} behind, ${a(n)} ahead of ${r}`}function hl(e,n){const s=n.name.split("/").map(encodeURIComponent).join("/"),r=e==="gitlab"?"/-/tree/":"/tree/";for(const a of new Set([s,n.name])){const o=`${r}${a}`;if(!n.webUrl.endsWith(o))continue;const d=n.webUrl.slice(0,-o.length);if(!/^https?:\/\/[^/]+\/\S+$/.test(d))break;return e==="gitlab"?`${d}/-/merge_requests/new?merge_request%5Bsource_branch%5D=${encodeURIComponent(n.name)}`:`${d}/compare/${s}?expand=1`}return n.webUrl}function fl(e,n){if(!n)return{workflow:null,title:null};if(e!=="github")return{workflow:null,title:n};const s=n.indexOf(" · ");return s>0&&s<n.length-3?{workflow:n.slice(0,s),title:n.slice(s+3)}:{workflow:null,title:n}}const ml={push:"push",merge_request_event:"merge request",pull_request:"pull request",pull_request_target:"pull request",merge_group:"merge queue",schedule:"schedule",workflow_dispatch:"manual",web:"manual",api:"API",trigger:"trigger",pipeline:"multi-project",parent_pipeline:"child pipeline",release:"release",external:"external",chat:"chat",ondemand_dast_scan:"DAST scan",security_orchestration_policy:"security policy"};function pl(e){return e?ml[e]??e.replace(/_/g," "):null}function dn(e,n,s){return e.data==null?e.error?"failed":"loading":n===0?"empty":s===0?"no-match":"rows"}function wt(e,n){return`No ${e} match “${n.trim()}”.`}function un(e,n){return n!=null&&n>e?`Load more · ${e.toLocaleString("en-US")} of ${n.toLocaleString("en-US")}`:"Load more"}function gl(e,n){const s=Z[e].changes.toLowerCase(),r=n.acrossRepos?"":` in this ${Z[e].repo.toLowerCase()}`;return n.filter==="mine"?`You have no ${n.state} ${s}${r}.`:n.filter==="review"?n.state==="open"?`Nothing is waiting for your review${r}.`:`No ${n.state} ${s} asked for your review${r}.`:`No ${n.state} ${s}${r}.`}function jl(e,n){const s=`${Z[e].pipeline.toLowerCase()}s`;return n?`No ${s} in your most recently active ${zn(e)}.`:`No ${s} in this ${Z[e].repo.toLowerCase()} yet.`}function xl(e,n,s){const r=Z[e].repo.toLowerCase();if(e==="github")return`This ${r} has no ${n} issues.`;const a=s?"":` in this ${r}`;return n==="open"?`No open issues are assigned to you${a}.`:`No closed issues were assigned to you${a}.`}function hn(e,n){const{loadedAt:s,loading:r,stale:a}=n;i.useEffect(()=>{e({loadedAt:s,loading:r,stale:a})},[e,s,r,a])}function bl({value:e,allowAll:n,onChange:s}){const{kind:r}=Q(),a=i.useId(),[o,d]=i.useState(!1),l=i.useRef(null),c=Z[r].repo,u=e??(n?dr(r):`Choose a ${c.toLowerCase()}`),j=e?ur(e):null,h=i.useCallback(()=>{var f;d(!1),(f=l.current)==null||f.focus({preventScroll:!0})},[]);return t.jsxs("span",{className:"fgl-repo",id:`${a}-layer`,children:[t.jsxs("button",{ref:l,id:`${a}-trigger`,type:"button",className:"btn fgl-repo-trigger","aria-label":`${c}: ${u}`,"aria-haspopup":"dialog","aria-expanded":o,title:e??void 0,onClick:()=>d(f=>!f),onKeyDown:f=>{(f.key==="ArrowDown"||f.key==="ArrowUp")&&(f.preventDefault(),d(!0))},children:[t.jsx(wl,{}),j?t.jsxs("span",{className:"fgl-repo-path",children:[t.jsx("span",{className:"fgl-repo-group",children:j.group}),t.jsx("span",{className:"fgl-repo-name",children:j.name})]}):t.jsx("span",{className:"fgl-repo-all",children:u}),t.jsx(ir,{})]}),o&&t.jsx(nn,{anchorId:`${a}-layer`,portalRootId:`${a}-layer`,id:`${a}-popup`,className:"fgl-repo-pop",role:"dialog",labelledBy:`${a}-trigger`,onClose:h,children:t.jsx(yl,{value:e,allowAll:n,onPick:f=>{s(f),h()},onEscape:h})})]})}function yl({value:e,allowAll:n,onPick:s,onEscape:r}){var w;const{kind:a,api:o,scope:d,refresh:l}=Q(),c=i.useId(),[u,j]=i.useState(""),[h,f]=i.useState(""),g=i.useRef(null),y=i.useRef(null),x=zn(a);i.useEffect(()=>{const E=window.setTimeout(()=>f(u.trim()),250);return()=>window.clearTimeout(E)},[u]);const m=Ze(o,d,"repos",{search:h||void 0},l),k=(w=m.data)==null?void 0:w.items,p=i.useMemo(()=>{const E=[];n&&!h&&E.push({value:null,repo:null}),e&&!h&&k&&!k.some($=>$.path===e)&&E.push({value:e,repo:null});for(const $ of k??[])E.push({value:$.path,repo:$});return E},[n,h,e,k]),[T,L]=i.useState(0),R=k!=null;i.useEffect(()=>{L(Math.max(0,p.findIndex(E=>E.value===e)))},[h,R]);const v=Math.min(T,p.length-1);i.useEffect(()=>{var E;(E=g.current)==null||E.focus({preventScroll:!0})},[]),i.useEffect(()=>{var E,$;($=(E=y.current)==null?void 0:E.querySelector('[data-active="true"]'))==null||$.scrollIntoView({block:"nearest"})},[v,p.length]);const S=E=>{const $=p.length;E.key==="ArrowDown"||E.key==="ArrowUp"?(E.preventDefault(),$&&L((Math.max(0,v)+(E.key==="ArrowDown"?1:-1)+$)%$)):E.key==="Home"||E.key==="End"?(E.preventDefault(),L(E.key==="Home"?0:Math.max(0,$-1))):E.key==="Enter"&&v>=0&&p[v]&&(E.preventDefault(),s(p[v].value))},F=u.trim()!==h,K=k==null?m.error?"failed":"loading":p.length?"rows":"empty";return t.jsxs("div",{className:"fgl-repo-body",onKeyDown:E=>{E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),r())},children:[t.jsxs("label",{className:"fgl-repo-search",children:[t.jsxs("span",{className:"fg-sr",children:["Search ",x]}),t.jsx(Nl,{}),t.jsx("input",{ref:g,className:"ap-manage-input",role:"combobox",placeholder:`Search ${x}…`,autoComplete:"off",spellCheck:!1,value:u,"aria-expanded":p.length>0,"aria-autocomplete":"list","aria-controls":`${c}-options`,"aria-activedescendant":K==="rows"&&v>=0?`${c}-option-${v}`:void 0,"aria-busy":F||m.loading,onChange:E=>j(E.target.value),onKeyDown:S})]}),t.jsxs("div",{ref:y,className:"fgl-repo-scroll",children:[m.error&&k&&t.jsx(ne,{error:m.error,onRetry:m.reload,compact:!0}),K==="loading"&&t.jsx(Ae,{rows:4,label:`Loading ${x}`}),K==="failed"&&m.error&&t.jsx(ne,{error:m.error,onRetry:m.reload}),K==="empty"&&t.jsx("p",{className:"fgl-repo-none",role:"status",children:h?`No ${x} match “${h}”.`:`This token can see no ${x}.`}),t.jsx("div",{id:`${c}-options`,className:"fgl-repo-options",role:"listbox","aria-label":Z[a].repo,hidden:K!=="rows",children:K==="rows"&&p.map((E,$)=>t.jsx(kl,{id:`${c}-option-${$}`,option:E,selected:E.value===e,active:$===v,onHover:()=>{$!==v&&L($)},onPick:()=>s(E.value)},E.value??"(all)"))}),m.data&&t.jsx(et,{pages:m,label:`More ${x}`})]})]})}function kl({id:e,option:n,selected:s,active:r,onHover:a,onPick:o}){var c,u;const{kind:d}=Q(),l=n.value?ur(n.value):null;return t.jsxs("button",{id:e,type:"button",role:"option",tabIndex:-1,className:"fgl-repo-option","aria-selected":s,"data-active":r,onPointerMove:a,onClick:o,children:[t.jsx("span",{className:"fgl-repo-option-text",children:l?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"fgl-repo-option-name",children:l.name}),l.group&&t.jsx("span",{className:"fgl-repo-option-group",children:l.group.slice(0,-1)})]}):t.jsx("span",{className:"fgl-repo-option-name",children:dr(d)})}),((c=n.repo)==null?void 0:c.archived)&&t.jsx("span",{className:"fg-badge",children:"archived"}),((u=n.repo)==null?void 0:u.lastActivityAt)!=null&&t.jsx("span",{className:"fgl-repo-option-when",children:t.jsx(ce,{at:n.repo.lastActivityAt})}),t.jsx("span",{className:"fgl-repo-check","aria-hidden":"true",children:s&&t.jsx(Hn,{})})]})}function wl(){return t.jsxs("svg",{className:"fgl-glyph",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M3.5 2.5h8a1 1 0 0 1 1 1v8.5h-8.5a1 1 0 0 0-1 1z"}),t.jsx("path",{d:"M3.5 13a1 1 0 0 0 1 1h8v-2"}),t.jsx("path",{d:"M6 5.5h4"})]})}function Nl(){return t.jsxs("svg",{className:"fgl-glyph",width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"7",cy:"7",r:"4.5"}),t.jsx("path",{d:"M10.5 10.5L14 14"})]})}function fr(e,n){return n.change?{type:"change",repo:e,number:n.change.number}:{type:"branch",repo:e,name:n.name}}function vl({view:e,query:n}){var k;const{kind:s,api:r,scope:a,refresh:o,reportFreshness:d,isOpen:l}=Q(),c=e.repo??"",u=Ze(r,a,c?"branches":null,{repo:c},o);hn(d,u);const j=i.useMemo(()=>{var p;return((p=u.data)==null?void 0:p.items)??[]},[u.data]),h=i.useMemo(()=>j.filter(p=>on({name:p.name},n)),[j,n]),f=i.useMemo(()=>Ho(il(h)),[h]),g=((k=j.find(p=>p.isDefault))==null?void 0:k.name)??null,y=dn(u,j.length,h.length),x=i.useMemo(()=>{if(y!=="rows")return[];const p=(T,L)=>l(T)?!L:L;return[...p("branches-active",!0)?f.active:[],...p("branches-stale",!1)?f.stale:[]].map(T=>fr(c,T))},[y,f,l,c]);ln(x,y!=="loading");const m=p=>t.jsx("ul",{className:"fg-rows",children:p.map(T=>t.jsx($l,{kind:s,repo:c,branch:T,defaultBranch:g},T.name))});return t.jsxs("div",{className:"fgl",children:[u.error&&u.data&&t.jsx(ne,{error:u.error,onRetry:u.reload,compact:!0}),y==="loading"&&t.jsx(Ae,{label:"Loading branches"}),y==="failed"&&u.error&&t.jsx(ne,{error:u.error,onRetry:u.reload}),y==="empty"&&t.jsxs("p",{className:"fg-empty",children:["This ",Z[s].repo.toLowerCase()," has no branches."]}),y==="no-match"&&t.jsx("p",{className:"fg-empty",children:wt("branches",n)}),y==="rows"&&t.jsxs(t.Fragment,{children:[t.jsx(lt,{id:"branches-active",title:"Active branches",count:f.active.length,defaultOpen:!0,children:f.active.length?m(f.active):t.jsx("p",{className:"fgl-group-empty",children:n.trim()?wt("active branches",n):"Every branch loaded so far is stale."})}),f.stale.length>0&&t.jsx(lt,{id:"branches-stale",title:"Stale branches",count:f.stale.length,defaultOpen:!1,aside:t.jsx("span",{className:"fgl-group-note",children:"No commits in 90 days"}),children:m(f.stale)})]}),u.data&&t.jsx(et,{pages:u,label:un(j.length,u.data.total)})]})}function $l({kind:e,repo:n,branch:s,defaultBranch:r}){const{selected:a,select:o}=Q(),d=Z[e],l=fr(n,s),c=yt(a,l),u=s.isDefault?null:ul(s.behind,s.ahead,r),j=s.change?`${d.changeSigil}${s.change.number}`:null,h=s.change?Ut(s.change):null;return t.jsxs("li",{className:"fgl-branch ig-row","data-selected":c||void 0,children:[t.jsx("button",{type:"button",className:"fgl-hit","data-nav":"","aria-current":c||void 0,"aria-label":s.change?`${s.name}, ${d.change.toLowerCase()} ${j}`:s.name,onClick:()=>o(l)}),t.jsxs("span",{className:"fgl-branch-name",children:[t.jsx(ct,{value:s.name,label:"branch name",children:t.jsx("code",{className:"fgl-branch-code",children:s.name})}),s.isDefault&&t.jsx("span",{className:"fg-badge",children:"default"}),s.protected&&t.jsx("span",{className:"fg-badge",children:"protected"})]}),t.jsxs("span",{className:"fg-meta fgl-commit",children:[t.jsx("code",{children:s.commit.shortSha}),t.jsx("span",{className:"fgl-dot","aria-hidden":"true",children:"·"}),t.jsx("span",{className:"fgl-commit-title",children:s.commit.title}),s.commit.committedAt!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"fgl-dot","aria-hidden":"true",children:"·"}),t.jsx(ce,{at:s.commit.committedAt})]})]}),t.jsxs("span",{className:"fgl-stats","data-empty":!u&&!s.ci||void 0,children:[t.jsx("span",{className:"fgl-diverge","data-empty":!u||void 0,title:u??void 0,children:u&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"fgl-behind","aria-hidden":"true",children:tn(s.behind)}),t.jsx("span",{className:"fgl-diverge-rule","aria-hidden":"true"}),t.jsx("span",{"aria-hidden":"true",children:tn(s.ahead)}),t.jsx("span",{className:"fg-sr",children:u})]})}),t.jsx("span",{className:"fgl-ci",children:s.ci&&t.jsx(ue,{mark:Ne(s.ci.state)})})]}),t.jsx("span",{className:"fgl-branch-change",children:h&&j?t.jsxs("span",{className:"fg-badge","data-tone":h.tone,title:`${d.change} ${j}: ${h.word}`,children:[t.jsx(cn,{name:h.mark})," ",t.jsx("code",{children:j})," ",h.word]}):!s.isDefault&&t.jsxs("a",{className:"ig-open fgl-create",href:hl(e,s),target:"_blank",rel:"noreferrer noopener",children:["Create ",d.change.toLowerCase(),t.jsx(xt,{})]})})]})}function mr(e,n,s){return`${n}${Z[e].changeSigil}${s}`}function pr(e){const n=/^refs\/(?:merge-requests|pull)\/(\d{1,12})\/(?:head|merge|train)$/.exec(e??"");return n?Number(n[1]):null}function gr(e,n){const s=pr(n);return s!=null?`${Z[e].changeSigil}${s}`:n.replace(/^refs\/(?:heads|tags)\//,"")}function Sl(e){const n=/\/(?:-\/pipelines|actions\/runs)\/(\d{1,15})(?:[/?#]|$)/.exec(e??"");return n?n[1]:null}function Cl(e,n,s,r){const a=n.replace(/\/+$/,""),o=s.split("/").map(encodeURIComponent).join("/");return e==="github"?`${a}/${o}/compare/${r.split("/").map(encodeURIComponent).join("/")}?expand=1`:`${a}/${o}/-/merge_requests/new?${new URLSearchParams({"merge_request[source_branch]":r})}`}function Rl(e,n){const s=e==="github";return[{id:"overview",label:s?"Conversation":"Overview",count:n.discussions},{id:"commits",label:"Commits",count:n.commits},{id:"pipelines",label:jr(e),count:n.pipelines},{id:"changes",label:s?"Files changed":"Changes",count:n.files}]}function jr(e){return e==="github"?"Checks":Z[e].pipelines}function Al(e){return e==null||!Number.isFinite(e)||e<=0?null:`${e.toLocaleString("en-US")} ${e===1?"commit":"commits"}`}function Ll(e){return Ut({state:e.state,draft:e.draft,approved:!1})}const Fn=/^\s*(?:\[draft\]|\(draft\)|draft:|\[wip\]|wip:)\s*/i;function El(e){return e.replace(Fn,"")||e}function Ml(e){const n=e[0];if(!n||n.t!=="text"||!Fn.test(n.text))return e;const s=n.text.replace(Fn,"");return s?[{t:"text",text:s},...e.slice(1)]:e.slice(1)}function Tl(e){return{id:`comment:${e.id}`,resolvable:!1,resolved:!1,path:null,line:null,outdated:!1,comments:[e],webUrl:e.webUrl}}const ws=e=>{var n;return((n=e.comments[0])==null?void 0:n.createdAt)??Number.MAX_SAFE_INTEGER};function Dl(e){const n=[],s=[],r=[];for(const a of e.threads)a.comments.length&&(a.resolvable?(a.resolved?s:n).push(a):r.push(a));for(const a of e.generalComments)r.push(Tl(a));return r.sort((a,o)=>ws(a)-ws(o)),{unresolved:n,resolved:s,general:r}}function xr(e){const n=e.lastIndexOf("/");return n<0?{dir:"",name:e}:{dir:e.slice(0,n+1),name:e.slice(n+1)}}function Il(e){return e.path?e.line!=null?`${e.path}:${e.line}`:e.path:null}function Fl(e){return e.name||e.login}function Bl(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Ol(e){return e.approvedBy.length?{mark:{mark:"approved",word:"approved",tone:"ok"},text:`Approved by ${Bl(e.approvedBy.map(Fl))}`}:e.approvalsLeft!=null&&e.approvalsLeft>0?{mark:{mark:"pending",word:"approval required",tone:"idle"},text:`Requires ${e.approvalsLeft} more approval${e.approvalsLeft===1?"":"s"}`}:null}function Pl(e){switch(e){case"added":return"new";case"deleted":return"deleted";case"renamed":return"renamed";default:return null}}function br(e){const n=e.lastIndexOf("::");return n>0&&n<e.length-2?{scope:e.slice(0,n),value:e.slice(n+2)}:{scope:null,value:e}}function Ul(e){return e&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)?e:null}function _l(e,n){return e==="open"?{mark:"open",word:"Open",tone:"busy"}:n==="not_planned"?{mark:"closed",word:"Closed · not planned",tone:"idle"}:n==="duplicate"?{mark:"closed",word:"Closed · duplicate",tone:"idle"}:{mark:"done",word:"Closed",tone:"idle"}}function Kl(e){return e?{push:"push",merge_request_event:"merge request",pull_request:"pull request",pull_request_target:"pull request",schedule:"schedule",workflow_dispatch:"manual run",web:"run from the web",api:"API",trigger:"trigger",pipeline:"parent pipeline",parent_pipeline:"parent pipeline",dynamic:"dynamic"}[e]??e.replace(/_/g," "):null}function Hl(e){if(!e.length)return"none";const n=e.map(s=>s.state==="failed"&&s.allowFailure?"success":s.state);return n.includes("failed")?"failed":n.includes("running")?"running":n.includes("pending")?"pending":n.every(s=>s==="skipped")?"skipped":n.every(s=>s==="manual"||s==="skipped")?"manual":n.includes("canceled")?"canceled":"success"}function Wl(e){const n=[],s=new Map;for(const r of e){const a=r.stage||null;s.has(a)||(s.set(a,[]),n.push(a)),s.get(a).push(r)}return n.map(r=>{const a=s.get(r);return{name:r,jobs:a,state:Hl(a)}})}const ql=8;function Gl(e,n){return e.state==="failed"||n<=ql}function Vl(e){return e.state==="failed"&&!e.allowFailure}function zl(e){return e.state==="failed"&&e.allowFailure?{mark:"warning",word:"failed",tone:"warn"}:Ne(e.state)}function Jl(e){return e.state==="success"&&e.jobs.some(n=>n.state==="failed"&&n.allowFailure)?{mark:"warning",word:"passed with warnings",tone:"warn"}:Ne(e.state)}function Xl(e){switch(e){case"failure":return{mark:"failed",word:"failure",tone:"bad"};case"warning":return{mark:"warning",word:"warning",tone:"warn"};default:return{mark:"info",word:"notice",tone:"idle"}}}const Bn=[80,200,500];function Ql(e){return e==null?Bn[0]:Bn.find(n=>n>e)??null}function Yl(e){return/^\s*(?:::error\b|error\b|fatal\b|ERROR:|FAILED\b|✕|×)/i.test(e)||/\bJob failed\b/.test(e)?"err":/^\s*(?:::warning\b|warning\b|warn\b)/i.test(e)?"warn":null}const Zl=[{state:"open",label:"Open"},{state:"merged",label:"Merged"},{state:"closed",label:"Closed"}],Qt=[{filter:"all",label:"All"},{filter:"mine",label:"Mine"},{filter:"review",label:"Review requests"}],ei=Ut({state:"open",draft:!0,approved:!1}),ti=Ut({state:"open",draft:!1,approved:!0});function ni({view:e,setView:n,query:s}){const{kind:r,api:a,scope:o,refresh:d,reportFreshness:l,isOpen:c}=Q(),u=Z[r],j=e.repo??void 0,h=e.repo==null,f=Ze(a,o,"changes",{repo:j,filter:e.filter,state:e.state,sort:e.sort},d),g=Ue(a,o,"change-counts",{repo:j,filter:e.filter},d);hn(l,f);const y=i.useMemo(()=>{var R;return((R=f.data)==null?void 0:R.items)??[]},[f.data]),x=i.useMemo(()=>y.filter(R=>on({key:R.key,title:R.title,name:R.sourceBranch,number:R.number},s)),[y,s]),m=dn(f,y.length,x.length),k=e.filter==="review"&&e.state==="open"?Wo(x):null,p=u.changes.toLowerCase(),T=i.useMemo(()=>{if(m!=="rows")return[];const R=(S,F)=>c(S)?!F:F;return(k?[...R("reviews-waiting",!0)?k.waiting:[],...R("reviews-approved",!1)?k.approved:[]]:x).map(S=>({type:"change",repo:S.repo,number:S.number}))},[m,k,x,c]);ln(T,m!=="loading");const L=R=>t.jsx("ul",{className:"fg-rows",children:R.map(v=>t.jsx(ai,{kind:r,change:v,acrossRepos:h},v.key))});return t.jsxs("div",{className:"fgl",children:[t.jsxs("div",{className:"fgl-controls",children:[t.jsx("div",{className:"uh-range fgl-seg",role:"group","aria-label":`${u.changes} by state`,children:Zl.map(({state:R,label:v})=>{var F;const S=cl((F=g.data)==null?void 0:F[R]);return t.jsxs("button",{type:"button",className:"uh-range-btn","aria-pressed":e.state===R,onClick:()=>n({state:R}),children:[v,S&&t.jsx("span",{className:"fgl-seg-count",children:S})]},R)})}),t.jsx("div",{className:"uh-range fgl-seg fgl-scope-seg",role:"group","aria-label":`Which ${p}`,children:Qt.map(({filter:R,label:v})=>t.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":e.filter===R,onClick:()=>n({filter:R}),children:v},R))}),t.jsx(si,{filter:e.filter,noun:p,onChange:R=>n({filter:R})}),t.jsx(ri,{sort:e.sort,onChange:R=>n({sort:R})})]}),f.error&&f.data&&t.jsx(ne,{error:f.error,onRetry:f.reload,compact:!0}),m==="loading"&&t.jsx(Ae,{label:`Loading ${p}`}),m==="failed"&&f.error&&t.jsx(ne,{error:f.error,onRetry:f.reload}),m==="empty"&&t.jsx("p",{className:"fg-empty",children:gl(r,{state:e.state,filter:e.filter,acrossRepos:h})}),m==="no-match"&&t.jsx("p",{className:"fg-empty",children:wt(p,s)}),m==="rows"&&(k?t.jsxs(t.Fragment,{children:[t.jsx(lt,{id:"reviews-waiting",title:"Waiting for my review",count:k.waiting.length,defaultOpen:!0,children:k.waiting.length?L(k.waiting):t.jsx("p",{className:"fgl-group-empty",children:s.trim()?wt(`${p} waiting for you`,s):"Nothing loaded is waiting for you; you approved every one."})}),k.approved.length>0&&t.jsx(lt,{id:"reviews-approved",title:"Approved by me",count:k.approved.length,defaultOpen:!1,children:L(k.approved)})]}):t.jsx("div",{className:"fgl-flat",children:L(x)})),f.data&&t.jsx(et,{pages:f,label:un(y.length,f.data.total)})]})}function si({filter:e,noun:n,onChange:s}){const r=i.useId(),[a,o]=i.useState(null),d=Qt.find(u=>u.filter===e)??Qt[0],l=`${r}-trigger`,c=u=>{var j;s(u),o(null),(j=document.getElementById(l))==null||j.focus({preventScroll:!0})};return t.jsxs("span",{className:"fgl-scope",id:`${r}-layer`,children:[t.jsxs("button",{id:l,type:"button",className:"btn fgl-scope-trigger","aria-label":`Which ${n}: ${d.label}`,"aria-haspopup":"menu","aria-expanded":a!=null,"aria-controls":a?`${r}-menu`:void 0,onClick:()=>o(u=>u?null:"first"),onKeyDown:u=>{u.key!=="ArrowDown"&&u.key!=="ArrowUp"||(u.preventDefault(),o(u.key==="ArrowUp"?"last":"first"))},children:[d.label,t.jsx(ir,{})]}),a&&t.jsx(nn,{anchorId:l,portalRootId:`${r}-layer`,id:`${r}-menu`,className:"ap-pop fgl-scope-pop",role:"menu",labelledBy:l,start:a,onClose:()=>o(null),children:Qt.map(u=>t.jsxs("button",{type:"button",role:"menuitem",className:"ap-menu-item fgl-scope-item","aria-current":u.filter===e||void 0,onClick:()=>c(u.filter),children:[t.jsx("span",{className:"fgl-scope-check","aria-hidden":"true",children:u.filter===e&&t.jsx(Hn,{})}),u.label]},u.filter))})]})}function ri({sort:e,onChange:n}){const s=e==="created"?"updated":"created";return t.jsxs("button",{type:"button",className:"btn fgl-sort",title:`Newest ${e} first. Sort by ${s} instead.`,"aria-label":`Sorted by ${e==="created"?"date created":"last updated"}, newest first. Sort by ${s==="created"?"date created":"last updated"} instead.`,onClick:()=>n(s),children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M2 3h8M3.5 6h5M5 9h2"})}),t.jsx("span",{className:"fgl-sort-word",children:e==="created"?"Created":"Updated"})]})}function ai({kind:e,change:n,acrossRepos:s}){const{selected:r,select:a}=Q(),o={type:"change",repo:n.repo,number:n.number},d=yt(r,o),l=ol(n),c=n.author?n.author.name||n.author.login:null;return t.jsx("li",{children:t.jsxs("button",{type:"button",className:"fg-row fgl-row ig-row","data-nav":"","data-selected":d||void 0,"aria-current":d||void 0,onClick:()=>a(o),children:[t.jsxs("span",{className:"fg-row-title fgl-title",children:[n.draft&&t.jsx(it,{mark:ei}),t.jsx("span",{className:"fgl-title-text",children:al(n.title,n.draft)}),t.jsx(kr,{labels:n.labels})]}),t.jsxs("span",{className:"fgl-side",children:[n.ci&&t.jsx(ue,{mark:Ne(n.ci.state)}),n.state==="open"&&n.approved&&t.jsx(it,{mark:ti}),t.jsx(oi,{reviewers:n.reviewers}),t.jsx(yr,{count:n.comments})]}),t.jsxs("span",{className:"fg-meta fgl-meta",children:[t.jsx("code",{children:hr(Z[e].changeSigil,n,s)}),n.createdAt!=null&&t.jsxs(t.Fragment,{children:[" · created ",t.jsx(ce,{at:n.createdAt})]}),c&&t.jsxs(t.Fragment,{children:[" by ",c]})]}),t.jsx("span",{className:"fgl-when",children:l.at!=null&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"fgl-when-verb",children:[l.verb," "]}),t.jsx(ce,{at:l.at})]})})]})})}function oi({reviewers:e}){return e.length?t.jsxs("span",{className:"fgl-people",children:[t.jsx("span",{className:"fg-sr",children:e.length===1?"Reviewer: ":"Reviewers: "}),e.slice(0,3).map((n,s)=>{const r=sr(n.state);return t.jsxs("span",{className:"fgl-reviewer","data-tone":r.tone,title:`${n.name||n.login}: ${r.word}`,children:[s>0&&t.jsx("span",{className:"fg-sr",children:"; "}),t.jsx(cr,{user:n}),t.jsx("span",{className:"fg-sr",children:n.name||n.login}),n.state!=="pending"&&t.jsx("span",{className:"fgl-reviewer-mark","aria-hidden":"true",children:t.jsx(cn,{name:r.mark,size:9,weight:1.8})}),t.jsxs("span",{className:"fg-sr",children:[", ",r.word]})]},n.login)}),t.jsx(ii,{count:e.length-3})]}):null}function li({users:e,label:n}){const s=Vn();return e.length?t.jsx(Xs,{label:n,people:e.map(r=>({key:r.login,...s(r)}))}):null}function ii({count:e}){return e<=0?null:t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"fgl-people-more","aria-hidden":"true",children:["+",e]}),t.jsxs("span",{className:"fg-sr",children:[" and ",e," more"]})]})}function yr({count:e}){return e?t.jsxs("span",{className:"fgl-comments",title:`${e} ${e===1?"comment":"comments"}`,children:[t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 3.5h11v7.5h-6l-3 2.5v-2.5h-2z"})}),e.toLocaleString("en-US"),t.jsxs("span",{className:"fg-sr",children:[" ",e===1?"comment":"comments"]})]}):null}function kr({labels:e}){return e.length?t.jsxs("span",{className:"fgl-labels",children:[e.slice(0,4).map(n=>{const s=dl(n.color),{scope:r,value:a}=br(n.name);return t.jsxs("span",{className:"fgl-label",title:n.name,children:[s&&t.jsx("i",{className:"fgl-label-dot",style:{background:s},"aria-hidden":"true"}),r&&t.jsxs("span",{className:"fgl-label-scope",children:[r,t.jsx("span",{className:"fg-sr",children:"::"})]}),t.jsx("span",{className:"fgl-label-name",children:a})]},n.name)}),e.length>4&&t.jsxs("span",{className:"fgl-label",title:e.slice(4).map(n=>n.name).join(", "),children:["+",e.length-4]})]}):null}function ci({view:e,query:n}){const{kind:s,api:r,scope:a,refresh:o,reportFreshness:d}=Q(),l=e.repo==null,c=Ze(r,a,"pipelines",{repo:e.repo??void 0},o);hn(d,c);const u=i.useMemo(()=>{var y;return((y=c.data)==null?void 0:y.items)??[]},[c.data]),j=i.useMemo(()=>u.filter(y=>on({title:y.title??"",name:y.ref,key:`${y.repo} ${y.shortSha}`},n)),[u,n]),h=dn(c,u.length,j.length),f=`${Z[s].pipeline.toLowerCase()}s`,g=i.useMemo(()=>h==="rows"?j.map(y=>({type:"pipeline",repo:y.repo,id:y.id})):[],[h,j]);return ln(g,h!=="loading"),t.jsxs("div",{className:"fgl",children:[c.error&&c.data&&t.jsx(ne,{error:c.error,onRetry:c.reload,compact:!0}),h==="loading"&&t.jsx(Ae,{label:`Loading ${f}`}),h==="failed"&&c.error&&t.jsx(ne,{error:c.error,onRetry:c.reload}),h==="empty"&&t.jsx("p",{className:"fg-empty",children:jl(s,l)}),h==="no-match"&&t.jsx("p",{className:"fg-empty",children:wt(f,n)}),h==="rows"&&t.jsx("div",{className:"fgl-flat",children:t.jsx("ul",{className:"fg-rows",children:j.map(y=>t.jsx(di,{kind:s,pipeline:y,acrossRepos:l},`${y.repo}/${y.id}`))})}),c.data&&t.jsx(et,{pages:c,label:un(u.length,c.data.total)})]})}function di({kind:e,pipeline:n,acrossRepos:s}){const{selected:r,select:a}=Q(),o={type:"pipeline",repo:n.repo,id:n.id},d=yt(r,o),{workflow:l,title:c}=fl(e,n.title),u=_t(n.durationSec),j=pl(n.source),h=n.state==="running"&&n.startedAt!=null&&n.finishedAt==null,f=n.finishedAt??n.createdAt,g=n.triggeredBy?n.triggeredBy.name||n.triggeredBy.login:null;return t.jsx("li",{children:t.jsxs("button",{type:"button",className:"fg-row fgl-row fgl-pipeline ig-row","data-nav":"","data-selected":d||void 0,"aria-current":d||void 0,onClick:()=>a(o),children:[t.jsx("span",{className:"fgl-status",children:t.jsx(ue,{mark:Ne(n.state)})}),t.jsx("span",{className:"fgl-duration",children:u?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"fg-sr",children:"ran for "}),u]}):h&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"fgl-when-verb",children:"started "}),t.jsx(ce,{at:n.startedAt})]})}),t.jsx("span",{className:"fg-row-title fgl-title",children:t.jsx("span",{className:"fgl-title-text",children:c??`${Z[e].pipeline} ${n.id}`})}),t.jsxs("span",{className:"fg-meta fgl-meta",children:[s&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"fgl-repo-ref",children:n.repo})," · "]}),t.jsx(ui,{}),t.jsx("code",{children:n.ref}),n.shortSha&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("code",{children:n.shortSha})]}),l&&t.jsxs(t.Fragment,{children:[" · ",l]}),j&&t.jsxs(t.Fragment,{children:[" · ",j]})]}),t.jsx("span",{className:"fgl-side",children:n.triggeredBy&&t.jsxs("span",{title:g??void 0,children:[t.jsx(cr,{user:n.triggeredBy}),t.jsx("span",{className:"fg-sr",children:g})]})}),t.jsx("span",{className:"fgl-when",children:f!=null&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"fgl-when-verb",children:[n.finishedAt!=null?"finished":"created"," "]}),t.jsx(ce,{at:f})]})})]})})}function ui(){return t.jsxs("svg",{className:"fgl-ref-glyph",width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"4.5",cy:"3.5",r:"1.5"}),t.jsx("circle",{cx:"4.5",cy:"12.5",r:"1.5"}),t.jsx("circle",{cx:"11.5",cy:"5.5",r:"1.5"}),t.jsx("path",{d:"M4.5 5v6M11.5 7c0 3-7 2-7 4"})]})}const hi=[{state:"open",label:"Open"},{state:"closed",label:"Closed"}];function fi({view:e,setView:n,query:s}){var m;const{kind:r,api:a,scope:o,refresh:d,reportFreshness:l,connection:c}=Q(),u=e.repo==null,j=Ze(a,o,"issues",{repo:e.repo??void 0,state:e.issueState},d);hn(l,j);const h=i.useMemo(()=>{var k;return((k=j.data)==null?void 0:k.items)??[]},[j.data]),f=i.useMemo(()=>h.filter(k=>on({key:k.key,title:k.title,number:k.number},s)),[h,s]),g=dn(j,h.length,f.length),y=i.useMemo(()=>g==="rows"?f.map(k=>({type:"issue",repo:k.repo,number:k.number})):[],[g,f]);ln(y,g!=="loading");const x=r==="gitlab"?((m=c.account)==null?void 0:m.login)??null:null;return t.jsxs("div",{className:"fgl",children:[t.jsxs("div",{className:"fgl-controls",children:[t.jsx("div",{className:"uh-range fgl-seg",role:"group","aria-label":"Issues by state",children:hi.map(({state:k,label:p})=>t.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":e.issueState===k,onClick:()=>n({issueState:k}),children:p},k))}),r==="gitlab"&&t.jsx("span",{className:"fgl-controls-note",children:"Assigned to you"})]}),j.error&&j.data&&t.jsx(ne,{error:j.error,onRetry:j.reload,compact:!0}),g==="loading"&&t.jsx(Ae,{label:"Loading issues"}),g==="failed"&&j.error&&t.jsx(ne,{error:j.error,onRetry:j.reload}),g==="empty"&&t.jsx("p",{className:"fg-empty",children:xl(r,e.issueState,u)}),g==="no-match"&&t.jsx("p",{className:"fg-empty",children:wt("issues",s)}),g==="rows"&&t.jsx("div",{className:"fgl-flat",children:t.jsx("ul",{className:"fg-rows",children:f.map(k=>t.jsx(mi,{issue:k,acrossRepos:u,me:x},k.key))})}),j.data&&t.jsx(et,{pages:j,label:un(h.length,j.data.total)})]})}function mi({issue:e,acrossRepos:n,me:s}){const{selected:r,select:a}=Q(),o={type:"issue",repo:e.repo,number:e.number},d=yt(r,o),l=e.author?e.author.name||e.author.login:null,c=s?e.assignees.filter(h=>h.login!==s):e.assignees,u=ll(e),j=e.state==="closed"&&e.closedAt!=null?e.closedAt:e.updatedAt;return t.jsx("li",{children:t.jsxs("button",{type:"button",className:"fg-row fgl-row ig-row","data-nav":"","data-selected":d||void 0,"aria-current":d||void 0,onClick:()=>a(o),children:[t.jsxs("span",{className:"fg-row-title fgl-title",children:[u&&t.jsx(it,{mark:u}),t.jsx("span",{className:"fgl-title-text",children:e.title}),t.jsx(kr,{labels:e.labels})]}),t.jsxs("span",{className:"fgl-side",children:[e.children&&e.children.total>0&&t.jsxs("span",{className:"fgl-children",title:`${e.children.completed} of ${e.children.total} child items done`,children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"2"}),t.jsx("path",{d:"M5.5 8.2l1.8 1.8 3.4-4"})]}),e.children.completed,"/",e.children.total,t.jsx("span",{className:"fg-sr",children:" child items done"})]}),t.jsx(li,{users:c,label:"Assigned to"}),t.jsx(yr,{count:e.comments})]}),t.jsxs("span",{className:"fg-meta fgl-meta",children:[t.jsx("code",{children:hr("#",e,n)}),e.createdAt!=null&&t.jsxs(t.Fragment,{children:[" · opened ",t.jsx(ce,{at:e.createdAt})]}),l&&t.jsxs(t.Fragment,{children:[" by ",l]}),e.milestone&&t.jsxs(t.Fragment,{children:[" · ",e.milestone.title]})]}),t.jsx("span",{className:"fgl-when",children:j!=null&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"fgl-when-verb",children:[e.state==="closed"&&e.closedAt!=null?"closed":"updated"," "]}),t.jsx(ce,{at:j})]})})]})})}function Ns(e){const n={};for(const[s,r]of Object.entries(e))s==="colspan"?n.colSpan=Number(r):s==="rowspan"?n.rowSpan=Number(r):s==="start"?n.start=Number(r):s==="open"?n.open=!0:s==="align"?n.style={textAlign:r.toLowerCase()}:n[s]=r;return n}function pi({node:e}){const[n,s]=i.useState(!1),r=e.alt.trim()||"image";return!e.src||n?t.jsxs("a",{className:"fh-image-link",href:e.href,target:"_blank",rel:"noreferrer noopener",children:[r," ↗"]}):t.jsx("a",{className:"fh-image",href:e.href,target:"_blank",rel:"noreferrer noopener",children:t.jsx("img",{src:e.src,alt:e.alt,width:e.width??void 0,height:e.height??void 0,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>s(!0)})})}function gt(e){return e.map((n,s)=>{switch(n.t){case"text":return n.text;case"link":return t.jsx("a",{href:n.href,title:n.title??void 0,target:"_blank",rel:"noreferrer noopener",children:gt(n.kids)},s);case"img":return t.jsx(pi,{node:n},s);case"check":return t.jsx("span",{className:"fh-check",role:"img","aria-label":n.checked?"done":"to do","data-checked":n.checked||void 0,children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"1.6",y:"1.6",width:"10.8",height:"10.8",rx:"2.4"}),n.checked&&t.jsx("path",{d:"m4.3 7.2 1.9 1.9 3.6-4"})]})},s);case"el":{const r=n.tag;return n.tag==="hr"||n.tag==="br"?t.jsx(r,{},s):n.tag==="pre"?t.jsx("pre",{tabIndex:0,...Ns(n.attrs),children:gt(n.kids)},s):t.jsx(r,{...Ns(n.attrs),children:gt(n.kids)},s)}}})}function Jn({nodes:e,className:n}){return t.jsx("div",{className:n?`forge-html ${n}`:"forge-html",children:gt(e)})}const gi=1,ji=3,xi={p:[],div:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],ul:[],ol:["start"],li:[],blockquote:[],pre:[],hr:[],br:[],table:[],caption:[],thead:[],tbody:[],tfoot:[],tr:[],th:["align","colspan","rowspan"],td:["align","colspan","rowspan"],details:["open"],summary:[],dl:[],dt:[],dd:[]},bi={code:[],em:[],strong:[],b:[],i:[],u:[],s:[],del:[],ins:[],mark:[],sup:[],sub:[],kbd:[],small:[],abbr:["title"],q:[],cite:[]},yi=new Set(["script","style","template","noscript","iframe","frame","frameset","object","embed","applet","svg","math","form","button","textarea","select","option","canvas","link","meta","base","head","title","portal","track","source"]),ki=new Set(["http:","https:","mailto:"]),vs=new Set(["http:","https:"]),wr=2048,wi=48;function vn(e,n,s){const r=(e??"").trim();if(!r||r.length>wr)return null;let a;try{a=new URL(r,new URL(n).origin+"/")}catch{return null}return s.has(a.protocol)?a.toString():null}function ke(e,n){var r;const s=(r=e.getAttribute)==null?void 0:r.call(e,n);return typeof s=="string"?s:null}function $s(e){const n=Number(e);return Number.isInteger(n)&&n>0&&n<1e4?n:null}function Ni(e,n){const s={left:n.maxNodes??5e3,cut:!1},r=On(e,n,s,0);return s.cut&&r.push({t:"text",text:" …"}),r}function On(e,n,s,r){const a=[],o=e.childNodes;for(let d=0;d<o.length;d++){if(s.left<=0){s.cut=!0;break}a.push(...vi(o[d],n,s,r))}return a}function vi(e,n,s,r){var c,u,j,h;if(s.left--,e.nodeType===ji)return e.nodeValue?[{t:"text",text:e.nodeValue}]:[];if(e.nodeType!==gi)return[];const a=e.nodeName.toLowerCase();if(yi.has(a))return[];if(r>=wi)return On(e,n,s,r);const o=()=>On(e,n,s,r+1);if(a==="a"){const f=vn(ke(e,"href"),n.baseUrl,ki);return!f||(c=ke(e,"href"))!=null&&c.trim().startsWith("#")?o():[{t:"link",href:f,title:((u=ke(e,"title"))==null?void 0:u.slice(0,300))??null,kids:o()}]}if(a==="img"){const f=vn(ke(e,"data-src")??ke(e,"src"),n.baseUrl,vs);if(!f)return[];const g=(ke(e,"alt")??"").slice(0,300);return n.inline?[{t:"text",text:g}]:[{t:"img",src:n.asset(f),href:f,alt:g,width:$s(ke(e,"width")),height:$s(ke(e,"height"))}]}if(a==="video"||a==="audio"){const f=vn(ke(e,"data-src")??ke(e,"src"),n.baseUrl,vs);return f&&!n.inline?[{t:"link",href:f,title:null,kids:[{t:"text",text:`${a} ↗`}]}]:[]}if(a==="input")return((j=ke(e,"type"))==null?void 0:j.toLowerCase())==="checkbox"&&!n.inline?[{t:"check",checked:((h=e.getAttribute)==null?void 0:h.call(e,"checked"))!=null}]:[];const d=bi[a]??(n.inline?void 0:xi[a]);if(!d)return o();const l={};for(const f of d){const g=ke(e,f);g!=null&&g.length<=wr&&(l[f]=g)}l.start!=null&&!/^\d{1,6}$/.test(l.start)&&delete l.start;for(const f of["colspan","rowspan"])l[f]!=null&&!/^\d{1,3}$/.test(l[f])&&delete l[f];return l.align!=null&&!/^(?:left|right|center)$/i.test(l.align)&&delete l.align,[{t:"el",tag:a,attrs:l,kids:o()}]}function $i(e,n){if(!e)return[];const s=new DOMParser().parseFromString(e,"text/html");return Ni(s.body,n)}function Nr({dir:e}){if(!e)return null;const n=e.split("/").slice(0,-1);return t.jsx("span",{className:"fd-path-dir",children:n.map((s,r)=>t.jsxs("span",{children:[s,"/",t.jsx("wbr",{})]},r))})}function fn({label:e,children:n}){const s=i.useRef(null);return i.useLayoutEffect(()=>{var a;const r=(a=s.current)==null?void 0:a.closest(".ig-detail");r&&(r.scrollTop=0)},[]),t.jsx("article",{ref:s,className:"fd","aria-label":e,tabIndex:-1,children:n})}function mn(){const{kind:e,narrow:n,select:s}=Q();return{openLabel:`Open in ${Z[e].name}`,narrow:n,onClose:()=>s(null)}}function pn({data:e,loading:n,error:s,onRetry:r,what:a}){return e?null:(s==null?void 0:s.kind)==="not-found"?t.jsxs("p",{className:"fg-empty",children:["This ",a," no longer exists, or this token cannot see it."]}):s?t.jsx(ne,{error:s,onRetry:r}):n?t.jsx(Ae,{rows:5,label:`Loading the ${a}`}):null}function It(e,n=!1){const{connection:s,asset:r}=Q();return i.useMemo(()=>e?$i(e,{baseUrl:s.baseUrl,asset:r,inline:n}):[],[e,n,s.baseUrl,r])}function Ve({label:e,children:n}){return t.jsxs("div",{className:"fd-fact",children:[t.jsx("dt",{children:e}),t.jsx("dd",{children:n})]})}function vr({label:e,children:n}){return t.jsx("aside",{className:"fd-side","aria-label":e,children:t.jsx("dl",{className:"fd-facts",children:n})})}function Pn({users:e,extra:n}){return e.length?t.jsx("ul",{className:"fd-people",children:e.map(s=>t.jsxs("li",{children:[t.jsx(vt,{user:s,size:20}),n==null?void 0:n(s)]},s.login))}):t.jsx("span",{className:"fd-none",children:"None"})}function Si({users:e,max:n=12}){if(!e.length)return t.jsx("span",{className:"fd-none",children:"None"});const s=e.slice(0,n);return t.jsxs("ul",{className:"fd-faces",children:[s.map(r=>t.jsx("li",{children:t.jsx(vt,{user:r,size:22,nameless:!0})},r.login)),e.length>n&&t.jsxs("li",{className:"fd-faces-more",children:["+",e.length-n]})]})}function Ci({label:e}){const n=Ul(e.color),{scope:s,value:r}=br(e.name);return t.jsxs("span",{className:"fd-label",title:e.name,children:[t.jsx("span",{className:"fd-swatch",style:n?{backgroundColor:n}:void 0,"aria-hidden":"true"}),s&&t.jsx("span",{className:"fd-label-scope",children:s}),t.jsx("span",{className:"fd-label-value",children:r})]})}function $r({labels:e}){return e.length?t.jsx("span",{className:"fd-labels",children:e.map(n=>t.jsx(Ci,{label:n},n.name))}):t.jsx("span",{className:"fd-none",children:"None"})}function Un({commit:e}){return t.jsxs("li",{className:"fd-item",children:[e.webUrl?t.jsxs("a",{className:"fd-item-title fd-out",href:e.webUrl,target:"_blank",rel:"noreferrer noopener",children:[e.title,t.jsx("span",{className:"fd-out-mark","aria-hidden":"true",children:" ↗"})]}):t.jsx("span",{className:"fd-item-title",children:e.title}),t.jsxs("span",{className:"fd-item-meta",children:[t.jsx(ct,{value:e.sha,label:"commit sha",children:t.jsx("code",{children:e.shortSha})}),e.authorName&&t.jsx("span",{children:e.authorName}),e.authoredAt!=null&&t.jsx(ce,{at:e.authoredAt})]})]})}function Ft({children:e,count:n,aside:s}){return t.jsxs("h3",{className:"fd-heading",children:[t.jsx("span",{children:e}),n!=null&&t.jsx("span",{className:"fg-count",children:n.toLocaleString()}),s]})}function Ri({title:e,count:n,startsOpen:s,aside:r,children:a}){const[o,d]=i.useState(s);return t.jsxs("section",{className:"fg-group fd-fold","data-open":o||void 0,children:[t.jsxs("h3",{className:"fg-group-head fd-fold-head",children:[t.jsxs("button",{type:"button",className:"fg-fold","aria-expanded":o,onClick:()=>d(l=>!l),children:[t.jsx("span",{className:"fg-fold-chevron","aria-hidden":"true"}),e,n!=null&&t.jsx("span",{className:"fg-count",children:n.toLocaleString()})]}),r]}),o&&a]})}function Ss(e){return`Open this comment in ${Z[e].name}`}function Sr({comment:e}){const{kind:n}=Q(),s=It(e.bodyHtml);return t.jsxs("li",{className:"fd-comment",children:[t.jsxs("div",{className:"fd-comment-head",children:[e.author?t.jsx(vt,{user:e.author,size:20}):t.jsx("span",{className:"fd-none",children:"Someone"}),e.createdAt!=null&&t.jsx("span",{className:"fd-comment-time",children:t.jsx(ce,{at:e.createdAt})}),e.webUrl&&t.jsx("a",{className:"fd-comment-link",href:e.webUrl,target:"_blank",rel:"noreferrer noopener","aria-label":Ss(n),title:Ss(n),children:t.jsx("span",{"aria-hidden":"true",children:"↗"})})]}),s.length?t.jsx(Jn,{className:"fd-comment-body",nodes:s}):t.jsx("p",{className:"fd-comment-body fd-none",children:"No text."})]})}function Ai({thread:e}){const n=e.path?xr(e.path):null;return t.jsxs("li",{className:"fd-thread",children:[n&&t.jsxs("div",{className:"fd-thread-head",children:[t.jsxs("code",{className:"fd-path",title:Il(e)??void 0,children:[t.jsx(Nr,{dir:n.dir}),t.jsxs("span",{className:"fd-path-name",children:[n.name,e.line!=null&&t.jsxs("span",{className:"fd-path-line",children:[":",e.line]})]})]}),e.outdated&&t.jsx("span",{className:"fg-badge fd-outdated",children:"outdated"})]}),t.jsx("ol",{className:"fd-comments",children:e.comments.map(s=>t.jsx(Sr,{comment:s},s.id))})]})}function $n({threads:e}){return t.jsx("ol",{className:"fd-threads",children:e.map(n=>t.jsx(Ai,{thread:n},n.id))})}const Li=["overview","commits","pipelines","changes"],Ei=e=>e!=null&&Li.includes(e);function Mi({selection:e}){const{kind:n,api:s,scope:r,refresh:a,recallSection:o,keepSection:d}=Q(),l=mn(),c=Z[n],u={repo:e.repo,number:e.number},j=Ue(s,r,"change",u,a),h=j.data,f=!!h&&(h.ci!=null||h.counts.pipelines>0),g=Ue(s,r,f?"change/pipelines":null,u,a),[y,x]=i.useState(()=>{const v=o();return Ei(v)?v:"overview"}),m=v=>{x(v),d(v)},k=(h==null?void 0:h.key)??mr(n,e.repo,e.number),p=i.useId(),T=v=>`${p}-tab-${v}`,L=v=>`${p}-panel-${v}`,R=h?Rl(n,h.counts):[];return t.jsxs(fn,{label:`${c.change} ${k}`,children:[t.jsx(Pt,{...l,reference:k,copyLabel:"reference",href:(h==null?void 0:h.webUrl)??null}),t.jsx(pn,{data:h,loading:j.loading,error:j.error,onRetry:j.reload,what:c.change.toLowerCase()}),h&&t.jsxs(t.Fragment,{children:[j.error&&t.jsx(ne,{error:j.error,onRetry:j.reload,compact:!0}),t.jsx(Ti,{change:h,pipelines:g.data}),t.jsxs("div",{className:"fd-layout",children:[t.jsx(Di,{change:h}),t.jsxs("div",{className:"fd-main",children:[t.jsx("div",{className:"uh-range fd-sections",role:"tablist","aria-label":`${c.change} sections`,onKeyDown:v=>{var F;const S=Ms(v,R.findIndex(K=>K.id===y),R.length);S.kind!=="pass"&&(v.preventDefault(),v.stopPropagation(),m(R[S.index].id),(F=v.currentTarget.querySelectorAll("[role=tab]")[S.index])==null||F.focus())},children:R.map(v=>t.jsxs("button",{id:T(v.id),type:"button",role:"tab",className:"uh-range-btn","aria-selected":y===v.id,"aria-controls":L(v.id),tabIndex:y===v.id?0:-1,onClick:()=>m(v.id),children:[t.jsx("span",{className:"fd-section-label",children:v.label}),t.jsx("span",{className:"fd-section-count",children:v.count.toLocaleString()})]},v.id))}),R.map(v=>t.jsx("div",{className:"fd-section",id:L(v.id),role:"tabpanel","aria-labelledby":T(v.id),hidden:y!==v.id,children:y!==v.id?null:v.id==="overview"?t.jsx(Ii,{change:h}):v.id==="commits"?t.jsx(Fi,{selection:e}):v.id==="pipelines"?t.jsx(Bi,{repo:e.repo,read:g}):t.jsx(Oi,{selection:e})},v.id))]})]})]})]})}function Ti({change:e,pipelines:n}){var g,y,x;const{kind:s,select:r}=Q(),a=Z[s],o=e.state==="open"&&e.draft,d=It(e.titleHtml,!0),l=d.length?gt(o?Ml(d):d):o?El(e.title):e.title,c=(n==null?void 0:n[0])??null,u=Sl((g=e.ci)==null?void 0:g.webUrl)??(c==null?void 0:c.id)??null,j=((y=e.ci)==null?void 0:y.state)??(c==null?void 0:c.state)??null,h=Ol(e),f=Al(e.counts.commits);return t.jsxs("header",{className:"fd-head",children:[t.jsx("h2",{className:"fd-title",children:l}),t.jsxs("p",{className:"fd-byline",children:[t.jsx(it,{mark:Ll(e)}),e.author&&t.jsx(vt,{user:e.author,size:18}),s==="github"?t.jsxs(t.Fragment,{children:[e.state==="merged"?t.jsx("span",{children:f?`· ${f} merged into`:"· merged into"}):t.jsx("span",{children:f?`wants to merge ${f} into`:"wants to merge into"}),t.jsx("code",{className:"fd-branch",children:e.targetBranch}),t.jsx("span",{children:"from"}),t.jsx(ct,{value:e.sourceBranch,label:"source branch",children:t.jsx("code",{className:"fd-branch",children:e.sourceBranch})})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"requested to merge"}),t.jsx(ct,{value:e.sourceBranch,label:"source branch",children:t.jsx("code",{className:"fd-branch",children:e.sourceBranch})}),t.jsx("span",{children:"into"}),t.jsx("code",{className:"fd-branch",children:e.targetBranch})]}),e.createdAt!=null&&t.jsxs("span",{className:"fd-when",children:["· created ",t.jsx(ce,{at:e.createdAt})]}),e.state==="merged"&&e.mergedAt!=null&&t.jsxs("span",{className:"fd-when",children:["· merged ",t.jsx(ce,{at:e.mergedAt})]}),e.state==="closed"&&e.closedAt!=null&&t.jsxs("span",{className:"fd-when",children:["· closed ",t.jsx(ce,{at:e.closedAt})]})]}),(j||h)&&t.jsxs("ul",{className:"fd-status",children:[j&&t.jsx("li",{children:u?t.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>r({type:"pipeline",repo:e.repo,id:u}),children:[t.jsx(ue,{mark:Ne(j)}),t.jsxs("span",{children:[a.pipeline," ",t.jsxs("code",{children:["#",u]})]}),t.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]}):t.jsxs("span",{className:"fd-status-line",children:[t.jsx(ue,{mark:Ne(j)}),t.jsx(kt,{href:((x=e.ci)==null?void 0:x.webUrl)??null,children:"Checks"})]})}),h&&t.jsxs("li",{className:"fd-status-line",children:[t.jsx(ue,{mark:h.mark,quiet:!0}),t.jsx("span",{children:h.text})]})]})]})}function Di({change:e}){return t.jsxs(vr,{label:"About this change",children:[t.jsx(Ve,{label:e.assignees.length>1?"Assignees":"Assignee",children:t.jsx(Pn,{users:e.assignees})}),t.jsx(Ve,{label:e.reviewers.length>1?"Reviewers":"Reviewer",children:t.jsx(Pn,{users:e.reviewers,extra:n=>t.jsx(ue,{className:"fd-review",mark:sr(n.state)})})}),e.labels.length>0&&t.jsx(Ve,{label:"Labels",children:t.jsx($r,{labels:e.labels})}),e.milestone&&t.jsx(Ve,{label:"Milestone",children:e.milestone.webUrl?t.jsx("a",{className:"fd-plain-link",href:e.milestone.webUrl,target:"_blank",rel:"noreferrer noopener",children:e.milestone.title}):e.milestone.title}),e.participants.length>0&&t.jsx(Ve,{label:`Participants · ${e.participants.length}`,children:t.jsx(Si,{users:e.participants})})]})}function Ii({change:e}){const n=It(e.descriptionHtml),{unresolved:s,resolved:r,general:a}=Dl(e),o=!s.length&&!r.length&&!a.length;return t.jsxs(t.Fragment,{children:[n.length?t.jsx(Jn,{className:"fd-description",nodes:n}):t.jsx("p",{className:"fd-none fd-description",children:"No description."}),t.jsxs("div",{className:"fd-discussions",children:[o&&t.jsx("p",{className:"fg-empty",children:"No discussions yet."}),s.length>0&&t.jsx(lt,{id:"change:unresolved",title:"Unresolved threads",count:s.length,defaultOpen:!0,children:t.jsx($n,{threads:s})}),!s.length&&r.length>0&&t.jsx("p",{className:"fd-status-line fd-all-resolved",children:t.jsx(ue,{mark:{mark:"resolved",word:"All threads resolved",tone:"ok"}})}),r.length>0&&t.jsx(lt,{id:"change:resolved",title:"Resolved threads",count:r.length,defaultOpen:!1,children:t.jsx($n,{threads:r})}),a.length>0&&t.jsx(lt,{id:"change:general",title:"General comments",count:a.length,defaultOpen:!1,children:t.jsx($n,{threads:a})})]})]})}function Fi({selection:e}){const{api:n,scope:s,refresh:r}=Q(),a=Ze(n,s,"change/commits",{repo:e.repo,number:e.number},r);return a.data?t.jsxs(t.Fragment,{children:[a.error&&t.jsx(ne,{error:a.error,onRetry:a.reload,compact:!0}),a.data.items.length?t.jsx("ul",{className:"fd-items",children:a.data.items.map(o=>t.jsx(Un,{commit:o},o.sha))}):t.jsx("p",{className:"fg-empty",children:"No commits."}),t.jsx(et,{pages:a,label:"Load more commits"})]}):a.error?t.jsx(ne,{error:a.error,onRetry:a.reload}):t.jsx(Ae,{rows:4,label:"Loading commits"})}function Bi({repo:e,read:n}){const{kind:s,select:r,selected:a}=Q(),o=Z[s],d=jr(s).toLowerCase();return n.data?n.data.length?t.jsxs(t.Fragment,{children:[n.error&&t.jsx(ne,{error:n.error,onRetry:n.reload,compact:!0}),t.jsx("ul",{className:"fg-rows fd-rows",children:n.data.map(l=>{const c=(a==null?void 0:a.type)==="pipeline"&&a.id===l.id,u=_t(l.durationSec);return t.jsx("li",{children:t.jsxs("button",{type:"button",className:"fg-row fd-pipe-row","aria-current":c||void 0,"data-selected":c||void 0,onClick:()=>r({type:"pipeline",repo:e,id:l.id}),children:[t.jsx(ue,{mark:Ne(l.state)}),t.jsx("span",{className:"fd-pipe-id",children:t.jsxs("code",{children:["#",l.id]})}),t.jsxs("span",{className:"fd-pipe-meta",children:[t.jsx("code",{className:"fd-branch",title:l.ref,children:gr(s,l.ref)}),t.jsx("code",{children:l.shortSha}),l.title&&t.jsx("span",{className:"fd-pipe-title",children:l.title})]}),t.jsxs("span",{className:"fd-pipe-when",children:[u&&t.jsx("span",{children:u}),l.createdAt!=null&&t.jsx(ce,{at:l.createdAt})]})]})},l.id)})})]}):t.jsxs("p",{className:"fg-empty",children:["No ",d," ran for this ",o.change.toLowerCase(),"."]}):n.error?t.jsx(ne,{error:n.error,onRetry:n.reload}):n.loading?t.jsx(Ae,{rows:3,label:`Loading ${d}`}):t.jsxs("p",{className:"fg-empty",children:["No ",d," ran for this ",o.change.toLowerCase(),"."]})}function Oi({selection:e}){const{api:n,scope:s,refresh:r}=Q(),a=Ze(n,s,"change/files",{repo:e.repo,number:e.number},r);return a.data?t.jsxs(t.Fragment,{children:[a.error&&t.jsx(ne,{error:a.error,onRetry:a.reload,compact:!0}),a.data.items.length?t.jsx("ul",{className:"fd-files",children:a.data.items.map(o=>t.jsx(Pi,{file:o},`${o.oldPath??""}>${o.path}`))}):t.jsx("p",{className:"fg-empty",children:"No changed files."}),t.jsx(et,{pages:a,label:"Load more files"})]}):a.error?t.jsx(ne,{error:a.error,onRetry:a.reload}):t.jsx(Ae,{rows:5,label:"Loading changed files"})}function Pi({file:e}){const n=Pl(e.status),{dir:s,name:r}=xr(e.path),a=t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"fd-file-path",children:[e.oldPath&&e.oldPath!==e.path&&t.jsxs("span",{className:"fd-file-old",children:[t.jsx("code",{children:e.oldPath})," ",t.jsx("span",{"aria-hidden":"true",children:"→"}),t.jsx("span",{className:"fd-sr",children:" renamed to"})," "]}),t.jsxs("code",{children:[t.jsx(Nr,{dir:s}),t.jsx("span",{className:"fd-path-name",children:r})]})]}),t.jsxs("span",{className:"fd-file-end",children:[n&&t.jsx("span",{className:"fd-file-status","data-status":e.status,children:n}),t.jsxs("span",{className:"fd-diffstat",title:`${e.additions} added, ${e.deletions} removed`,children:[t.jsxs("span",{className:"fd-add","data-zero":e.additions===0||void 0,children:["+",e.additions.toLocaleString()]}),t.jsxs("span",{className:"fd-del","data-zero":e.deletions===0||void 0,children:["−",e.deletions.toLocaleString()]})]}),e.webUrl&&t.jsx("span",{className:"fd-out-mark","aria-hidden":"true",children:"↗"})]})]});return t.jsx("li",{children:e.webUrl?t.jsx("a",{className:"fd-file",href:e.webUrl,target:"_blank",rel:"noreferrer noopener",children:a}):t.jsx("span",{className:"fd-file",children:a})})}const Cs=10;function Ui({selection:e}){const{kind:n,api:s,scope:r,refresh:a}=Q(),o=mn(),d=Ue(s,r,"branch",{repo:e.repo,name:e.name},a),l=d.data;return t.jsxs(fn,{label:`Branch ${e.name}`,children:[t.jsx(Pt,{...o,reference:e.repo,copyLabel:Z[n].repo.toLowerCase(),href:(l==null?void 0:l.branch.webUrl)??null}),t.jsx(pn,{data:l,loading:d.loading,error:d.error,onRetry:d.reload,what:"branch"}),l&&t.jsxs(t.Fragment,{children:[d.error&&t.jsx(ne,{error:d.error,onRetry:d.reload,compact:!0}),t.jsx(_i,{repo:e.repo,detail:l})]})]})}function _i({repo:e,detail:n}){var k,p;const{kind:s,api:r,scope:a,refresh:o,connection:d,select:l}=Q(),c=Z[s],u=n.branch,h=((p=(k=Ue(r,a,u.isDefault?null:"repos",{},o).data)==null?void 0:k.items.find(T=>T.path===e))==null?void 0:p.defaultBranch)??null,[f,g]=i.useState(!1),y=n.pipeline,x=y?_t(y.durationSec):null,m=f?n.commitsAhead:n.commitsAhead.slice(0,Cs);return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"fd-head",children:[t.jsx("h2",{className:"fd-title fd-title-mono",children:t.jsx(ct,{value:u.name,label:"branch name",children:t.jsx("code",{children:u.name})})}),(u.isDefault||u.protected||u.stale)&&t.jsxs("p",{className:"fd-byline",children:[u.isDefault&&t.jsx("span",{className:"fg-badge",children:"default"}),u.protected&&t.jsx("span",{className:"fg-badge",children:"protected"}),u.stale&&t.jsx("span",{className:"fg-badge",children:"stale"})]})]}),t.jsxs("dl",{className:"fd-facts fd-facts-page",children:[t.jsxs("div",{className:"fd-fact",children:[t.jsx("dt",{children:"Latest commit"}),t.jsx("dd",{children:t.jsx("ul",{className:"fd-items fd-items-bare",children:t.jsx(Un,{commit:{...u.commit,authoredAt:u.commit.committedAt}})})})]}),!u.isDefault&&t.jsxs("div",{className:"fd-fact",children:[t.jsxs("dt",{children:["Compared with ",h??"the default branch"]}),t.jsxs("dd",{className:"fd-diverge",children:[t.jsxs("span",{children:[t.jsx("strong",{children:tn(u.behind)})," behind"]}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsxs("span",{children:[t.jsx("strong",{children:tn(u.ahead)})," ahead"]})]})]}),t.jsxs("div",{className:"fd-fact",children:[t.jsx("dt",{children:c.pipeline}),t.jsx("dd",{children:y?t.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>l({type:"pipeline",repo:e,id:y.id}),children:[t.jsx(ue,{mark:Ne(y.state)}),t.jsx("span",{children:t.jsxs("code",{children:["#",y.id]})}),x&&t.jsx("span",{className:"fd-jump-meta",children:x}),y.createdAt!=null&&t.jsx("span",{className:"fd-jump-meta",children:t.jsx(ce,{at:y.createdAt})}),t.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]}):u.ci?t.jsxs("span",{className:"fd-status-line",children:[t.jsx(ue,{mark:Ne(u.ci.state)}),t.jsx(kt,{href:u.ci.webUrl})]}):t.jsx(ue,{mark:Ne("none")})})]}),!u.isDefault&&t.jsxs("div",{className:"fd-fact",children:[t.jsx("dt",{children:c.change}),t.jsx("dd",{children:u.change?t.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>l({type:"change",repo:e,number:u.change.number}),children:[t.jsx(it,{mark:Ut(u.change)}),t.jsx("span",{children:t.jsxs("code",{children:[c.changeSigil,u.change.number]})}),t.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]}):t.jsxs(kt,{href:Cl(s,d.baseUrl,e,u.name),children:["Create ",c.change.toLowerCase()]})})]})]}),!u.isDefault&&t.jsxs("section",{className:"fd-block",children:[t.jsxs(Ft,{count:u.ahead??n.commitsAhead.length,children:["Commits not in ",h??"the default branch"]}),n.commitsAhead.length?t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"fd-items",children:m.map(T=>t.jsx(Un,{commit:T},T.sha))}),!f&&n.commitsAhead.length>Cs&&t.jsxs("button",{type:"button",className:"btn fg-more",onClick:()=>g(!0),children:["Show all ",n.commitsAhead.length.toLocaleString()]})]}):t.jsx("p",{className:"fg-empty",children:u.ahead===0?`Every commit here is already in ${h??"the default branch"}.`:"The forge listed none."})]})]})}function Ki({repo:e,jobs:n}){const s=Wl(n);return n.length?s.length===1&&s[0].name==null?t.jsx(Rs,{repo:e,jobs:n}):t.jsx("div",{className:"fd-stages",children:s.map(r=>t.jsx(Ri,{title:r.name??"Other jobs",count:r.jobs.length,startsOpen:Gl(r,n.length),aside:t.jsx(ue,{mark:Jl(r)}),children:t.jsx(Rs,{repo:e,jobs:r.jobs})},r.name??""))}):t.jsx("p",{className:"fg-empty",children:"This pipeline has no jobs."})}function Rs({repo:e,jobs:n}){return t.jsx("ul",{className:"fd-jobs",children:n.map(s=>t.jsx(Hi,{repo:e,job:s},s.id))})}function Hi({repo:e,job:n}){const[s,r]=i.useState(()=>Vl(n)),a=_t(n.durationSec),o=`fd-job-${n.id}`;return t.jsxs("li",{className:"fd-job","data-open":s||void 0,children:[t.jsxs("button",{type:"button",className:"fg-row fd-job-row","aria-expanded":s,"aria-controls":o,onClick:()=>r(d=>!d),children:[t.jsx("span",{className:"fg-fold-chevron","aria-hidden":"true"}),t.jsx(ue,{mark:zl(n)}),t.jsx("span",{className:"fd-job-name",children:n.name}),n.allowFailure&&n.state==="failed"&&t.jsx("span",{className:"fd-job-note",children:"allowed to fail"}),a&&t.jsx("span",{className:"fd-job-time",children:a})]}),s&&t.jsxs("div",{className:"fd-job-body",id:o,children:[n.failureReason&&t.jsx("p",{className:"fd-job-reason",children:n.failureReason}),n.annotations.length>0&&t.jsx("ul",{className:"fd-annotations",children:n.annotations.map((d,l)=>t.jsxs("li",{children:[t.jsx(ue,{mark:Xl(d.level)}),d.path&&t.jsx("code",{className:"fd-ann-place",children:d.line!=null?`${d.path}:${d.line}`:d.path}),d.title&&t.jsx("strong",{className:"fd-ann-title",children:d.title}),t.jsx("span",{className:"fd-ann-message",children:d.message})]},l))}),n.logAvailable?t.jsx(Wi,{repo:e,job:n}):t.jsx("p",{className:"fd-log-bar",children:t.jsx(kt,{href:n.webUrl,children:"Open the job"})})]})]})}function Wi({repo:e,job:n}){const{api:s,scope:r,refresh:a}=Q(),[o,d]=i.useState(null),l=Ue(s,r,o?"job-log":null,{repo:e,id:n.id,lines:o},a),c=i.useRef(null);l.data&&(c.current=l.data);const u=l.data??(o?c.current:null),j=i.useRef(null),h=i.useRef(0);i.useLayoutEffect(()=>{const m=j.current;m&&(m.scrollTop=m.scrollHeight-m.clientHeight-h.current),h.current=0},[u]);const f=i.useRef(!1);i.useEffect(()=>{f.current=l.loading},[l.loading,u,l.error]);const g=Ql(o),y=()=>{if(!we(f.current))return;f.current=!0;const m=j.current;h.current=m?m.scrollHeight-m.clientHeight-m.scrollTop:0,d(g)},x=(u==null?void 0:u.webUrl)??n.webUrl;return o?t.jsxs("div",{className:"fd-log-wrap",children:[t.jsxs("p",{className:"fd-log-bar",children:[t.jsx("span",{className:"fd-log-count",children:u?u.truncated?`Last ${u.lines.length.toLocaleString()} lines`:`All ${u.lines.length.toLocaleString()} lines`:"Log"}),(u==null?void 0:u.truncated)&&g&&t.jsx("button",{type:"button",className:"btn",onClick:y,...Ce(l.loading),children:l.loading?"Loading…":"Show more lines"}),t.jsx(kt,{href:x,children:"Full log"})]}),l.error&&(u?t.jsx(ne,{error:l.error,onRetry:l.reload,compact:!0}):t.jsx(ne,{error:l.error,onRetry:l.reload})),!u&&!l.error&&t.jsx(Ae,{rows:3,label:"Loading the log"}),u&&(u.lines.length?t.jsx("pre",{ref:j,className:"fd-log",tabIndex:0,role:"region","aria-label":`${n.name} log`,children:u.lines.map((m,k)=>{const p=Yl(m);return t.jsx("span",{className:"fd-log-line","data-tone":p??void 0,children:m||" "},k)})}):t.jsx("p",{className:"fd-none",children:"The log is empty."}))]}):t.jsxs("p",{className:"fd-log-bar",children:[t.jsx("button",{type:"button",className:"btn",onClick:()=>d(Bn[0]),children:"Show log"}),t.jsx(kt,{href:x,children:"Full log"})]})}function qi({selection:e}){const{kind:n,api:s,scope:r,refresh:a}=Q(),o=mn(),d=Z[n],l=Ue(s,r,"pipeline",{repo:e.repo,id:e.id},a),c=l.data;return t.jsxs(fn,{label:`${d.pipeline} #${e.id}`,children:[t.jsx(Pt,{...o,reference:`${e.repo} #${e.id}`,copyValue:e.id,copyLabel:`${d.pipeline.toLowerCase()} id`,href:(c==null?void 0:c.webUrl)??null}),t.jsx(pn,{data:c,loading:l.loading,error:l.error,onRetry:l.reload,what:d.pipeline.toLowerCase()}),c&&t.jsxs(t.Fragment,{children:[l.error&&t.jsx(ne,{error:l.error,onRetry:l.reload,compact:!0}),t.jsx(Gi,{pipeline:c}),t.jsxs("section",{className:"fd-block",children:[t.jsx(Ft,{count:c.jobs.length,children:"Jobs"}),t.jsx(Ki,{repo:c.repo,jobs:c.jobs})]})]})]})}function Gi({pipeline:e}){const{kind:n,select:s}=Q(),r=Z[n],a=pr(e.ref),o=_t(e.durationSec),d=Kl(e.source);return t.jsxs("header",{className:"fd-head",children:[t.jsx("h2",{className:"fd-title",children:e.title||`${r.pipeline} #${e.id}`}),t.jsxs("p",{className:"fd-byline",children:[t.jsx(it,{mark:Ne(e.state)}),e.triggeredBy&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Started by"}),t.jsx(vt,{user:e.triggeredBy,size:18})]}),d&&t.jsxs("span",{className:"fd-when",children:["· ",d]}),e.createdAt!=null&&t.jsxs("span",{className:"fd-when",children:["· created ",t.jsx(ce,{at:e.createdAt})]}),o?t.jsxs("span",{className:"fd-when",children:["· took ",o]}):e.state==="running"&&e.startedAt!=null&&t.jsxs("span",{className:"fd-when",children:["· started ",t.jsx(ce,{at:e.startedAt})]})]}),t.jsxs("ul",{className:"fd-status",children:[t.jsxs("li",{className:"fd-status-line",children:[t.jsx("span",{className:"fd-status-key",children:"Ran on"}),t.jsx(ct,{value:e.ref,label:"ref",children:t.jsx("code",{className:"fd-branch",title:e.ref,children:gr(n,e.ref)})}),t.jsx(ct,{value:e.sha,label:"commit sha",children:t.jsx("code",{children:e.shortSha})})]}),a!=null&&t.jsx("li",{children:t.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>s({type:"change",repo:e.repo,number:a}),children:[t.jsx(ue,{mark:{mark:"linked",word:r.change,tone:"idle"},quiet:!0}),t.jsxs("span",{children:[r.change," ",t.jsx("code",{children:mr(n,"",a)})]}),t.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]})})]})]})}function Vi({selection:e}){const{api:n,scope:s,refresh:r}=Q(),a=mn(),o=Ue(n,s,"issue",{repo:e.repo,number:e.number},r),d=o.data,l=(d==null?void 0:d.key)??`${e.repo}#${e.number}`;return t.jsxs(fn,{label:`Issue ${l}`,children:[t.jsx(Pt,{...a,reference:l,copyLabel:"reference",href:(d==null?void 0:d.webUrl)??null}),t.jsx(pn,{data:d,loading:o.loading,error:o.error,onRetry:o.reload,what:"issue"}),d&&t.jsxs(t.Fragment,{children:[o.error&&t.jsx(ne,{error:o.error,onRetry:o.reload,compact:!0}),t.jsx(zi,{selection:e,issue:d})]})]})}function zi({selection:e,issue:n}){const{select:s}=Q(),r=It(n.titleHtml,!0),a=It(n.descriptionHtml);return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"fd-head",children:[t.jsx("h2",{className:"fd-title",children:r.length?gt(r):n.title}),t.jsxs("p",{className:"fd-byline",children:[t.jsx(it,{mark:_l(n.state,n.stateReason)}),t.jsxs("span",{children:[t.jsxs("code",{children:["#",n.number]})," opened"]}),n.createdAt!=null&&t.jsx(ce,{at:n.createdAt}),n.author&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"by"}),t.jsx(vt,{user:n.author,size:18})]}),n.state==="closed"&&n.closedAt!=null&&t.jsxs("span",{className:"fd-when",children:["· closed ",t.jsx(ce,{at:n.closedAt})]})]})]}),t.jsxs("div",{className:"fd-layout",children:[t.jsxs(vr,{label:"About this issue",children:[t.jsx(Ve,{label:n.assignees.length>1?"Assignees":"Assignee",children:t.jsx(Pn,{users:n.assignees})}),n.labels.length>0&&t.jsx(Ve,{label:"Labels",children:t.jsx($r,{labels:n.labels})}),n.milestone&&t.jsx(Ve,{label:"Milestone",children:n.milestone.webUrl?t.jsx("a",{className:"fd-plain-link",href:n.milestone.webUrl,target:"_blank",rel:"noreferrer noopener",children:n.milestone.title}):n.milestone.title}),n.parent&&t.jsx(Ve,{label:"Parent",children:t.jsx(Xi,{item:n.parent,onOpen:()=>s({type:"issue",repo:n.parent.repo,number:n.parent.number})})})]}),t.jsxs("div",{className:"fd-main",children:[a.length?t.jsx(Jn,{className:"fd-description",nodes:a}):t.jsx("p",{className:"fd-none fd-description",children:"No description."}),n.childItems.length>0&&t.jsxs("section",{className:"fd-block",children:[t.jsx(Ft,{count:n.childItems.length,aside:n.children&&t.jsxs("span",{className:"fd-progress",children:[n.children.completed," of ",n.children.total," done"]}),children:"Child items"}),t.jsx("ul",{className:"fg-rows fd-rows",children:n.childItems.map(o=>t.jsx("li",{children:t.jsx(Ji,{item:o,onOpen:()=>s({type:"issue",repo:o.repo,number:o.number})})},o.key))})]}),t.jsx(Qi,{selection:e,count:n.comments})]})]})]})}function Cr(e){return e==="open"?{mark:"open",word:"open",tone:"busy"}:{mark:"done",word:"closed",tone:"ok"}}function Ji({item:e,onOpen:n}){const{selected:s}=Q(),r=(s==null?void 0:s.type)==="issue"&&s.repo===e.repo&&s.number===e.number;return t.jsxs("button",{type:"button",className:"fg-row fd-child-row ig-row",onClick:n,"aria-current":r||void 0,"data-selected":r||void 0,children:[t.jsx(ue,{mark:Cr(e.state)}),t.jsx("span",{className:"fd-child-title",children:e.title}),t.jsxs("span",{className:"fd-child-meta",children:[e.type&&t.jsx("span",{children:e.type}),t.jsxs("code",{children:["#",e.number]})]})]})}function Xi({item:e,onOpen:n}){return t.jsxs("button",{type:"button",className:"fd-jump",onClick:n,children:[t.jsx(ue,{mark:Cr(e.state),quiet:!0}),t.jsx("span",{className:"fd-jump-title",children:e.title}),t.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]})}function Qi({selection:e,count:n}){const[s,r]=i.useState(!1);return n?t.jsxs("section",{className:"fd-block",children:[t.jsx(Ft,{count:n,children:"Comments"}),s?t.jsx(Yi,{selection:e}):t.jsxs("button",{type:"button",className:"btn fd-show-comments",onClick:()=>r(!0),children:["Show ",n.toLocaleString()," comment",n===1?"":"s"]})]}):t.jsxs("section",{className:"fd-block",children:[t.jsx(Ft,{count:0,children:"Comments"}),t.jsx("p",{className:"fd-none",children:"No comments."})]})}function Yi({selection:e}){const{api:n,scope:s,refresh:r}=Q(),a=Ze(n,s,"issue/comments",{repo:e.repo,number:e.number},r);return a.data?t.jsxs(t.Fragment,{children:[a.error&&t.jsx(ne,{error:a.error,onRetry:a.reload,compact:!0}),a.data.items.length?t.jsx("ol",{className:"fd-threads fd-issue-comments",children:a.data.items.map(o=>t.jsx("li",{className:"fd-thread",children:t.jsx("ol",{className:"fd-comments",children:t.jsx(Sr,{comment:o})})},o.id))}):t.jsx("p",{className:"fd-none",children:"No comments."}),t.jsx(et,{pages:a,label:"Load more comments"})]}):a.error?t.jsx(ne,{error:a.error,onRetry:a.reload}):t.jsx(Ae,{rows:3,label:"Loading comments"})}const Rt=["branches","changes","pipelines","issues"];function Rr(e,n){switch(n){case"branches":return"Branches";case"changes":return Z[e].changes;case"pipelines":return Z[e].pipelines;case"issues":return"Issues"}}function Zi(e,n){const s=Rr(e,n);return`Back to ${s==="Actions"?s:s.toLowerCase()}`}const ec=".fg-tab-body:not([hidden])";function Ar({kind:e,connection:n,api:s,assetUrl:r,prefs:a,narrow:o,onReconnect:d,Split:l}){const c=`${e}:${n.id}`,[u,j]=i.useState(()=>bs(a)),[h,f]=i.useState(0),[g,y]=i.useState(()=>En(c)),x=i.useCallback(A=>{y(A),Ks(c,A)},[c]),[m,k]=i.useState({loadedAt:null,loading:!1,stale:!1}),[p,T]=i.useState(!1),L=i.useRef(!1),[R,v]=i.useState(null),S=i.useRef(null),F=i.useRef(null),K=i.useRef(null);nl(K);const w=i.useRef(null),E=i.useId(),$=A=>`${E}-tab-${A}`,I=A=>`${E}-panel-${A}`,B=i.useRef(c);i.useEffect(()=>{B.current!==c&&(B.current=c,j(bs(a)),y(En(c)))},[c,a]);const C=_s(c,u.repo,u.tab),[U,W]=i.useState(null),ee=i.useMemo(()=>U&&U.key===C?{complete:U.complete,has:A=>U.items.some(re=>yt(re,A)),first:U.items[0]??null}:null,[U,C]),se=Hs({listKey:C,drawn:ee,same:yt,sideBySide:!o,root:S,listScroller:ec}),{choose:V}=se,J=se.selection,Y=i.useCallback(A=>{j(re=>{const pe={...re,...A};return ys(a,pe),pe})},[a]),ve=i.useCallback(A=>{j(re=>{const pe=re.open.includes(A)?re.open.filter(Me=>Me!==A):[...re.open,A].slice(-20),xe={...re,open:pe};return ys(a,xe),xe})},[a]),me=i.useCallback(A=>{const re=document.activeElement,pe=re instanceof HTMLElement&&re.closest(".ig-list")!=null;A&&pe&&(w.current=re),V(A);const xe=zo(A!=null,pe,o);requestAnimationFrame(()=>{var Me,Te,De;xe==="opener"&&((Me=w.current)!=null&&Me.isConnected)?w.current.focus():xe==="page"&&((De=(Te=S.current)==null?void 0:Te.querySelector(".ig-detail .fd"))==null||De.focus())})},[o,V]),dt=i.useCallback(()=>{var A;return((A=Dt(C))==null?void 0:A.section)??null},[C]),_e=i.useCallback(A=>ot(C,{section:A}),[C]),$e=i.useMemo(()=>({kind:e,connection:n,scope:c,api:s,asset:A=>r(A),refresh:h,selected:J,select:me,isOpen:A=>u.open.includes(A),toggle:ve,reportFreshness:k,onReconnect:d,narrow:o,listKey:C,reportRows:W,recallSection:dt,keepSection:_e}),[e,n,c,s,r,h,J,me,u.open,ve,d,o,C,dt,_e]),Le=Yo(e,u.tab),Ke=!Le&&!u.repo,P=Ue(s,c,Ke?"repos":null,{},h);i.useEffect(()=>{var re;const A=(re=P.data)==null?void 0:re.items[0];Ke&&A&&Y({repo:A.path})},[Ke,P.data,Y]);const be=async()=>{if(we(L.current)){L.current=!0,T(!0),v(null);try{const A=await Gn(s,en("resolve",{q:g.trim()}));A?me(A.type==="change"?{type:"change",repo:A.repo,number:A.number}:{type:"issue",repo:A.repo,number:A.number}):v("Nothing to open at that address.")}catch(A){v(A instanceof Mt?A.info.message:"Could not open it.")}finally{L.current=!1,T(!1)}}},tt=A=>{Y({tab:A}),x("")};sl(F,u.tab);const he=Z[e],Ee={view:u,setView:Y,query:g},He=t.jsxs("div",{ref:K,className:"fg-list",children:[t.jsxs("div",{className:"fg-toolbar",children:[t.jsx(bl,{value:u.repo,allowAll:Le,onChange:A=>Y({repo:A})}),t.jsx(Gs,{loadedAt:m.loadedAt,loading:m.loading,stale:m.stale,onRefresh:()=>f(A=>A+1),label:`Refresh ${he.name}`})]}),t.jsx("div",{ref:F,className:"uh-range fg-tabs",role:"tablist","aria-label":`${he.name} views`,onKeyDown:A=>{var pe;const re=Ms(A,Rt.indexOf(u.tab),Rt.length);re.kind!=="pass"&&(A.preventDefault(),A.stopPropagation(),tt(Rt[re.index]),(pe=A.currentTarget.querySelectorAll("[role=tab]")[re.index])==null||pe.focus())},children:Rt.map(A=>t.jsx("button",{id:$(A),type:"button",role:"tab",className:"uh-range-btn","aria-selected":u.tab===A,"aria-controls":I(A),tabIndex:u.tab===A?0:-1,onClick:()=>tt(A),children:Rr(e,A)},A))}),t.jsxs("div",{className:"fg-searchbar",children:[t.jsx(Wn,{value:g,onChange:A=>{x(A),v(null)},label:u.tab==="branches"?"Filter by branch name":`Search by title or number, or paste a ${he.name} link`,placeholder:u.tab==="branches"?"Filter by branch name":o?`Search, or paste a ${he.name} link`:`Search by title or number, or paste a ${he.name} link`,onKeyDown:A=>{A.key==="Enter"&&xs(g)&&be()}}),xs(g)&&t.jsx("button",{type:"button",className:"btn fg-resolve",onClick:()=>void be(),...Ce(p),children:p?"Opening…":"Open"})]}),R&&t.jsx("p",{className:"fg-note",role:"status",children:R}),Rt.map(A=>t.jsx("div",{className:"fg-tab-body",id:I(A),role:"tabpanel","aria-labelledby":$(A),hidden:u.tab!==A,children:u.tab!==A?null:Ke?P.error?t.jsx(ne,{error:P.error,onRetry:P.reload}):P.data&&!P.data.items.length?t.jsxs("p",{className:"fg-empty",children:["This token can see no ",he.repo.toLowerCase()," yet."]}):t.jsxs("p",{className:"fg-note",children:["Finding your most recent ",he.repo.toLowerCase(),"…"]}):A==="branches"?t.jsx(vl,{...Ee}):A==="changes"?t.jsx(ni,{...Ee}):A==="pipelines"?t.jsx(ci,{...Ee}):t.jsx(fi,{...Ee})},A))]}),nt=J?J.type==="change"?t.jsx(Mi,{selection:J},`${J.repo}!${J.number}`):J.type==="branch"?t.jsx(Ui,{selection:J},`${J.repo}@${J.name}`):J.type==="pipeline"?t.jsx(qi,{selection:J},`${J.repo}/p/${J.id}`):t.jsx(Vi,{selection:J},`${J.repo}#${J.number}`):null;return t.jsx(Zo,{value:$e,children:t.jsx("div",{ref:S,className:"fg-panel","data-kind":e,children:t.jsx(l,{list:He,detail:nt,onBack:()=>me(null),backLabel:Zi(e,u.tab),storageKey:e,detailKey:J?lr(J):void 0})})})}function tc(e){return t.jsx(Ar,{kind:"github",...e,Split:_n})}function nc(e){return t.jsx(Ar,{kind:"gitlab",...e,Split:_n})}const sc={jira:Oo,github:tc,gitlab:nc};function ac({kind:e,connections:n,onClose:s,onReconnect:r}){const a=na(e),o=sc[e],d=i.useId(),l=Is(),[c]=i.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),[u,j]=i.useState(!1),h=i.useRef(!1),f=i.useRef(s);f.current=s;const g=i.useCallback(()=>{h.current||(h.current=!0,f.current())},[]),y=i.useCallback(()=>{var E,$;if(u||h.current)return;const w=Array.from(document.querySelectorAll(`[data-rail-item="integration-${e}"], [data-rail-item="more"]`)).find(I=>{var B;return((B=I.checkVisibility)==null?void 0:B.call(I))??!0});($=c&&c!==document.body&&c.isConnected&&(((E=c.checkVisibility)==null?void 0:E.call(c))??!0)?c:w)==null||$.focus({preventScroll:!0}),As()?g():j(!0)},[u,c,e,g]);i.useEffect(()=>{if(!u)return;const w=window.setTimeout(g,200);return()=>window.clearTimeout(w)},[u,g]);const x=i.useRef(null),m=i.useMemo(()=>({get current(){const w=x.current;return w?Array.from(w.querySelectorAll(Gr)).find(E=>Vr({disabled:E.disabled,tabIndex:E.tabIndex,rendered:E.checkVisibility?E.checkVisibility():E.getClientRects().length>0}))??null:null}}),[]),k=zr(y,{focusRef:m}),p=Jr(y);i.useLayoutEffect(()=>{k.current&&(k.current.inert=u)},[u,k]),Xr(e);const[T,L]=i.useState(()=>{var E;const w=Qr(e);return n.some($=>$.id===w)?w:((E=n[0])==null?void 0:E.id)??""});i.useEffect(()=>{if(n.length===0){s();return}n.some(w=>w.id===T)||L(n[0].id)},[n,T,s]);const R=w=>{L(w),sa(e,w)},v=n.find(w=>w.id===T)??null,S=(v==null?void 0:v.id)??"",F=i.useMemo(()=>S?{api:ea({kind:e,id:S}),assetUrl:Zr({kind:e,id:S}),prefs:Yr(e,S)}:null,[e,S]);if(!a||!o||!v||!F)return null;const{Glyph:K}=a;return ta.createPortal(t.jsx("div",{className:"modal-backdrop",role:"presentation",...p,children:t.jsxs("div",{ref:k,id:`integration-${e}-modal`,className:"modal ig-modal",role:"dialog","aria-modal":"true","aria-labelledby":"integration-modal-title","data-kind":e,"data-closing":u||void 0,onClick:w=>w.stopPropagation(),onAnimationEnd:w=>{u&&w.target===w.currentTarget&&g()},children:[t.jsxs("div",{className:"ig-head",children:[t.jsxs("h2",{className:"ig-title",id:"integration-modal-title",children:[t.jsx("span",{className:"ig-title-glyph","aria-hidden":!0,children:t.jsx(K,{})}),a.label]}),n.length>1?t.jsxs("label",{className:"ig-conn-select",children:[t.jsx("span",{className:"vis-hidden",children:"Connection"}),t.jsx("select",{id:d,className:"sm-select",value:v.id,onChange:w=>R(w.target.value),children:n.map(w=>t.jsxs("option",{value:w.id,children:[w.name,w.name!==jt(w)?` · ${jt(w)}`:""]},w.id))})]}):t.jsx("span",{className:"ig-conn-name",title:v.baseUrl,children:v.name}),t.jsx("button",{type:"button",className:"glyph-btn ig-close",onClick:y,"aria-label":`Close ${a.label}`,title:"Close (Esc)",children:"×"})]}),t.jsx("div",{ref:x,className:"ig-body",children:t.jsx(o,{connection:v,connections:n,api:F.api,assetUrl:F.assetUrl,prefs:F.prefs,narrow:l,onReconnect:()=>{y(),r(v.id)}},v.id)})]})}),document.body)}export{ac as default};