ccdeck 3.45.0 → 3.46.0

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 (31) hide show
  1. package/README.md +7 -4
  2. package/bin/cli/startup.js +4 -3
  3. package/dist/web/assets/BrowserWatchModal-CoX9FIUE.js +1 -0
  4. package/dist/web/assets/IntegrationModal-B1ypkK-E.js +5 -0
  5. package/dist/web/assets/RadioPanel-biw_BbZq.js +1 -0
  6. package/dist/web/assets/TrafficRadar-nhtFoYVv.js +8 -0
  7. package/dist/web/assets/{UsageHistoryModal-DAhplVju.js → UsageHistoryModal-Bd-JRAa4.js} +1 -1
  8. package/dist/web/assets/app-BlRY6EME.css +1 -0
  9. package/dist/web/assets/app-DhGvSH7o.js +319 -0
  10. package/dist/web/assets/{index-r8Ymr47Q.js → index-DmENqVdt.js} +1 -1
  11. package/dist/web/index.html +3 -3
  12. package/package.json +1 -1
  13. package/release-notes.json +30 -0
  14. package/src/server/claude-accounts.mjs +35 -19
  15. package/src/server/claude-login.mjs +111 -0
  16. package/src/server/cswap-admin.mjs +12 -3
  17. package/src/server/installer.mjs +24 -7
  18. package/src/server/login-service.mjs +2 -2
  19. package/src/server/skill-hook.mjs +28 -22
  20. package/src/server/system-metrics.mjs +4 -0
  21. package/src/server/tool-audit-routes.mjs +4 -0
  22. package/src/server/traffic-radar-config.mjs +33 -0
  23. package/src/server/traffic-radar-platform.mjs +84 -17
  24. package/src/server/traffic-radar-service.mjs +6 -3
  25. package/src/server/traffic-radar.mjs +32 -9
  26. package/dist/web/assets/BrowserWatchModal-Cbzf3TWa.js +0 -1
  27. package/dist/web/assets/IntegrationModal-BnnBr0a3.js +0 -5
  28. package/dist/web/assets/RadioPanel-BIqrMLQN.js +0 -1
  29. package/dist/web/assets/TrafficRadar-D1gZCIwX.js +0 -8
  30. package/dist/web/assets/app-BW3NYUYB.js +0 -318
  31. package/dist/web/assets/app-C5RY_wZ4.css +0 -1
@@ -1,5 +0,0 @@
1
- import{r as Us,w as _s,a as d,j as e,u as Hs,b as Ws,q as qs,I as Rt,c as qe,d as Je,e as ns,m as ht,A as rs,s as yt,f as Gs,g as kt,t as as,R as Ks,h as zs,i as Js,k as Vs,l as Xs,n as Ys,o as Qs,p as Zs,v as en,x as tn,y as sn}from"./app-BW3NYUYB.js";const ce={min:320,standard:440,max:1600},nn=420,rn=8,an="(max-width: 899px)",ls=t=>`agent-dag.integrations.${t}.detail-width`;function Te(t,s){const n=Math.max(ce.min,Math.min(ce.max,s-nn-rn));return Math.round(Math.min(n,Math.max(ce.min,Number.isFinite(t)?t:ce.standard)))}function ln(t){const s=Number(Us(ls(t)));return Number.isFinite(s)&&s>=ce.min&&s<=ce.max?Math.round(s):ce.standard}function on(t,s){_s(ls(t),String(Math.round(s)))}function cn({width:t,workspace:s,controls:n,onCommit:r}){const a=d.useRef(null),l=d.useRef(null),i=()=>{var x;return((x=s.current)==null?void 0:x.clientWidth)??window.innerWidth},o=Te(t,i()),c=x=>{var g,h;(g=s.current)==null||g.style.setProperty("--ig-detail-w",`${x}px`),(h=a.current)==null||h.setAttribute("aria-valuenow",String(x))},u=x=>{c(x),r(x)},j=x=>{var g;x.button===0&&(x.preventDefault(),x.currentTarget.setPointerCapture(x.pointerId),l.current={x:x.clientX,width:o,room:i(),last:o},(g=s.current)==null||g.setAttribute("data-resizing",""))},f=x=>{const g=l.current;g&&(g.last=Te(g.width+g.x-x.clientX,g.room),c(g.last))},N=()=>{var g;const x=l.current;x&&(l.current=null,(g=s.current)==null||g.removeAttribute("data-resizing"),u(x.last))},b=x=>{const g=x.shiftKey?64:16,h=x.key==="ArrowLeft"?o+g:x.key==="ArrowRight"?o-g:x.key==="Home"?ce.min:x.key==="End"?ce.max:x.key==="Enter"?ce.standard:null;h!==null&&(x.preventDefault(),u(Te(h,i())))};return e.jsx("div",{ref:a,className:"ig-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Detail width","aria-controls":n,"aria-valuemin":ce.min,"aria-valuemax":Te(ce.max,i()),"aria-valuenow":o,tabIndex:0,title:"Drag to resize · double-click for the standard width",onPointerDown:j,onPointerMove:f,onPointerUp:N,onPointerCancel:N,onLostPointerCapture:N,onDoubleClick:()=>u(Te(ce.standard,i())),onKeyDown:b})}function os(){return Hs(an)}function wt({list:t,detail:s,onBack:n,backLabel:r,storageKey:a}){const l=os(),i=`${d.useId()}-detail`,o=d.useRef(null),[c,u]=d.useState(()=>ln(a)),j=N=>{u(N),on(a,N)},f=s!=null;return e.jsxs("div",{ref:o,className:"ig-split","data-detail":f||void 0,"data-drill-in":l||void 0,style:{"--ig-detail-w":`${c}px`},children:[e.jsx("div",{className:"ig-list",hidden:l&&f||void 0,children:t}),f&&!l&&e.jsx(cn,{width:c,workspace:o,controls:i,onCommit:j}),f&&e.jsxs("section",{className:"ig-detail",id:i,"aria-label":"Details",children:[l&&e.jsxs("button",{type:"button",className:"ig-back","data-ig-back":!0,onClick:n,children:[e.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:e.jsx("path",{d:"M8.6 3 4.6 7l4 4"})}),r]}),s]})]})}const Le=(t,s,n={},r)=>Ws(t,`${s}${qs(n)}`,{signal:r}),is=(t,s,n,r)=>Le(t,"boards",{startAt:s||void 0,name:n},r),dn=(t,s,n)=>Le(t,`board/${encodeURIComponent(s)}`,{},n),un=(t,s,n,r)=>Le(t,`board/${encodeURIComponent(s)}/closed-sprints`,{startAt:n||void 0},r),Lt=(t,s,n,r)=>Le(t,`board/${encodeURIComponent(s)}/issues`,{source:n.source,sprint:n.sprint,column:n.column,cursor:n.cursor||void 0,backlog:n.backlog,mine:n.mine,quick:n.quick.join(",")||void 0},r),hn=(t,s,n)=>Le(t,`issue/${encodeURIComponent(s)}/subtasks`,{},n),mn=(t,s,n)=>Le(t,`issue/${encodeURIComponent(s)}`,{},n);function pn(t,s,n){var o;let r;try{r=new URL(n)}catch{return null}const a=typeof((o=t.meta)==null?void 0:o.apiBase)=="string"?t.meta.apiBase:"";let l="";try{l=new URL(t.baseUrl).origin}catch{}if(a&&r.origin===l&&/^\/(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 i=r.protocol==="http:"&&/^(localhost|127\.0\.0\.1|\[::1\])$/.test(r.hostname)&&t.allowedOrigins.includes(r.origin);return r.protocol!=="https:"&&!i?null:s(r.href)}const at=t=>`sprint:${t.id}`;function Et(t,s=[]){const n=[];if(t.hasSprints){for(const r of t.sprints.active)n.push({id:at(r),kind:"active",title:r.name,sprint:r,defaultOpen:!0,paged:!1});for(const r of t.sprints.future)n.push({id:at(r),kind:"future",title:r.name,sprint:r,defaultOpen:!1,paged:!1});t.hasBacklog&&n.push({id:"backlog",kind:"backlog",title:"Backlog",defaultOpen:!1,paged:!0});for(const r of s)n.push({id:at(r),kind:"closed",title:r.name,sprint:r,defaultOpen:!1,paged:!1});return n}return n.push({id:"column:todo",kind:"column",column:"todo",title:"To Do",defaultOpen:!0,paged:!1}),n.push({id:"column:progress",kind:"column",column:"progress",title:"In Progress",defaultOpen:!0,paged:!1}),n.push({id:"column:done",kind:"column",column:"done",title:"Done in the last 14 days",defaultOpen:!1,paged:!1}),t.hasBacklog&&n.push({id:"backlog",kind:"backlog",title:"Backlog",defaultOpen:!1,paged:!0}),n}function lt(t,s){return Object.hasOwn(s,t.id)?s[t.id]:t.defaultOpen}const Pe=t=>t.kind==="issue"?t.issue.key:t.parent.key;function fn(t,s=new Set){const n=new Map;for(const l of t)!s.has(l.key)&&!n.has(l.key)&&n.set(l.key,l);const r=[],a=new Map;for(const l of n.values()){const i=l.type.subtask&&l.parent?l.parent.key:null;if(i&&i!==l.key){let c=a.get(i);if(!c){const u=n.get(i);u&&!s.has(i)?c={kind:"issue",issue:u,matched:[]}:(c={kind:"context",parent:l.parent,matched:[]},r.push(c)),a.set(i,c)}c.matched.push(l);continue}let o=a.get(l.key);o||(o={kind:"issue",issue:l,matched:[]},a.set(l.key,o)),r.push(o)}for(const l of n.keys())s.add(l);return r}const cs=t=>t.status.category==="done";function gn(t,s){return s?t.key.toLowerCase().includes(s)||t.summary.toLowerCase().includes(s):!0}function jn(t,s,n){const r=s.search.trim().toLowerCase();if(!r&&!s.hideDone)return t.slice();const a=i=>(!s.hideDone||!cs(i))&&gn(i,r),l=[];for(const i of t){const o=i.matched.filter(a),c=(n==null?void 0:n(Pe(i)))??[],u=o.length>0||c.some(a);i.kind==="issue"?(a(i.issue)||u)&&l.push({...i,matched:o}):u&&l.push({...i,matched:o})}return l}function xn(t){return t.flatMap(s=>s.kind==="issue"?[s.issue]:s.matched)}function bn(t,s){const n=xn(t),r={new:0,indeterminate:0,done:0},a=new Map;let l=0,i=0;for(const c of n){const u=s==="count"?1:s==="points"?c.points??0:c.estimate??0;if(r[c.status.category]+=u,c.assignee){const j=a.get(c.assignee.id);j?j.n++:a.set(c.assignee.id,{person:c.assignee,n:1})}c.mine&&(l++,cs(c)&&i++)}const o=[...a.values()].sort((c,u)=>u.n-c.n||c.person.name.localeCompare(u.person.name)).map(c=>c.person);return{count:n.length,totals:r,assignees:o,mine:l,mineDone:i}}function Ae(t,s={hoursPerDay:8,daysPerWeek:5}){if(t==null||!Number.isFinite(t))return"";let n=Math.round(t/60);if(n<=0)return"0m";const r=60,a=Math.round(s.hoursPerDay*r),l=Math.round(a*s.daysPerWeek),i=[];for(const[o,c]of[[l,"w"],[a,"d"],[r,"h"],[1,"m"]]){if(o<=0)continue;const u=Math.floor(n/o);u>0&&(i.push(`${u}${c}`),n-=u*o)}return i.join(" ")}function Mt(t,s,n){return s==="time"?Ae(t,n)||"0m":s==="points"?`${Number.isInteger(t)?t:t.toFixed(1)}`:String(t)}function Tt(t){if(!t)return"";const s=new Date(t);return Number.isNaN(s.getTime())?"":s.toLocaleDateString(void 0,{day:"numeric",month:"short"})}function De(t,s=!1){if(!t)return"";const n=new Date(String(t).replace(/([+-]\d{2})(\d{2})$/,"$1:$2"));return Number.isNaN(n.getTime())?String(t):s?n.toLocaleString(void 0,{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Nn(t,s=Date.now()){const n=Math.max(0,Math.round((s-t)/1e3));if(n<45)return"just now";const r=Math.round(n/60);if(r<60)return`${r}m ago`;const a=Math.round(r/60);return a<24?`${a}h ago`:`${Math.round(a/24)}d ago`}function yn(t){return t==null?"":t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const kn=5*6e4,wn=2*6e4,vn=24,Dt={shown:!1,sprints:[],total:0,isLast:!1,loading:!1,error:null},$n={status:"idle",issues:[],next:"",total:null,capped:!1,error:null,more:!1},xe=new Map,Sn=(t,s,n)=>`${t}|${s}|${n.mine?"mine":"all"}|${n.quick.join(",")}`;function Cn(t,s){for(xe.delete(t),xe.set(t,s);xe.size>vn;)xe.delete(xe.keys().next().value)}function Ft(t,s){for(const[n,r]of[...xe.entries()].reverse())if(n.startsWith(`${t}|${s}|`)&&r.overview)return{overview:r.overview,groups:{},subtasks:{},closed:{...Dt,shown:r.closed.shown,sprints:r.closed.sprints,total:r.closed.total,isLast:r.closed.isLast},loadedAt:0};return{overview:null,groups:{},subtasks:{},closed:Dt,loadedAt:0}}function fe(t){return t instanceof Rt?t:new Rt("upstream",t instanceof Error&&t.message?t.message:"Jira could not be read.")}const mt=t=>t instanceof DOMException&&t.name==="AbortError",An=new Set(["auth","expired","rate-limit","tls","unreachable","incompatible","network","unavailable"]);function It(t,s,n,r=""){const a={mine:s.mine,quick:s.quick};return t.kind==="backlog"?{...a,source:"backlog",cursor:r}:t.kind==="column"?{...a,source:"kanban",column:t.column,backlog:n.hasBacklog}:{...a,source:"sprint",sprint:t.sprint.id}}async function Rn(t,s,n){let r=0;const a=Array.from({length:Math.min(s,t.length)},async()=>{for(;r<t.length;)await n(t[r++])});await Promise.all(a)}function Ln(t,s,n,r){const a=n?Sn(s,n,r):"",[l,i]=d.useState(()=>a&&xe.get(a)||Ft(s,n??"")),o=d.useRef(l),[c,u]=d.useState(!1),[j,f]=d.useState(null),N=d.useRef(0),b=d.useRef(null),x=d.useRef(a),g=d.useRef(r);g.current=r;const h=d.useCallback((S,L)=>{if(S!==x.current)return;const T=L(o.current);o.current=T,S&&Cn(S,T),i(T)},[]),p=d.useCallback((S,L,T)=>{h(S,E=>({...E,groups:{...E.groups,[L]:T(E.groups[L]??$n)}}))},[h]),v=d.useCallback(async(S,L,T,E)=>{if(n){p(S,L.id,D=>({...D,status:"loading",error:null}));try{const D=await Lt(t,n,It(L,g.current,T),E);p(S,L.id,()=>({status:"ready",issues:D.issues,next:D.next,total:D.total,capped:D.capped,error:null,more:!1}))}catch(D){if(mt(D)||E.aborted)return;const F=fe(D);if(p(S,L.id,G=>({...G,status:"error",error:F,more:!1})),An.has(F.kind))throw F}}},[n,t,p]),k=d.useCallback(()=>{var D;if(!n)return;const S=x.current,L=++N.current;(D=b.current)==null||D.abort();const T=new AbortController;b.current=T;const{signal:E}=T;u(!0),f(null),(async()=>{try{const F=await dn(t,n,E);if(L!==N.current)return;h(S,m=>({...m,overview:F,subtasks:{}}));const G=o.current.closed,ne=Et(F,G.shown?G.sprints:[]),z=ne.filter(m=>m.kind==="active"||m.kind==="column"&&m.column!=="done"),re=ne.filter(m=>!z.includes(m)&&(m.kind!=="closed"||o.current.groups[m.id]));await Promise.all(z.map(m=>v(S,m,F,E))),await Rn(re,3,m=>E.aborted?Promise.resolve():v(S,m,F,E)),L===N.current&&h(S,m=>({...m,loadedAt:Date.now()}))}catch(F){if(mt(F)||E.aborted||L!==N.current)return;T.abort(),f(fe(F))}finally{L===N.current&&u(!1)}})()},[n,t,v,h]);d.useEffect(()=>{var T;x.current=a;const S=a?xe.get(a):void 0,L=S??Ft(s,n??"");if(o.current=L,i(L),f(null),!n){(T=b.current)==null||T.abort(),u(!1);return}(!S||Date.now()-S.loadedAt>kn)&&k()},[a]),d.useEffect(()=>()=>{var S;(S=b.current)==null||S.abort()},[]);const A=d.useCallback((S,L=!1)=>{const T=o.current.overview,E=o.current.groups[S.id];if(!T||E&&E.status!=="idle"&&!(L&&E.status==="error"))return;const D=b.current&&!b.current.signal.aborted?b.current.signal:new AbortController().signal,F=x.current;v(F,S,T,D).catch(G=>f(fe(G)))},[v]),C=d.useCallback(S=>{const L=o.current.overview,T=o.current.groups[S.id];if(!n||!L||!T||!T.next||T.more)return;const E=x.current;p(E,S.id,D=>({...D,more:!0,error:null})),(async()=>{try{const D=await Lt(t,n,It(S,g.current,L,T.next));p(E,S.id,F=>{const G=new Set(F.issues.map(ne=>ne.key));return{...F,issues:[...F.issues,...D.issues.filter(ne=>!G.has(ne.key))],next:D.next,total:D.total??F.total,more:!1}})}catch(D){const F=fe(D);p(E,S.id,G=>({...G,more:!1,error:F}))}})()},[n,t,p]),y=d.useCallback(S=>{if(!n)return;const L=x.current;h(L,T=>({...T,closed:{...T.closed,shown:!0,loading:!0,error:null}})),(async()=>{try{const T=await un(t,n,S);h(L,E=>{const D=new Set(E.closed.sprints.map(G=>G.id)),F=S===0?T.sprints:[...E.closed.sprints,...T.sprints.filter(G=>!D.has(G.id))];return{...E,closed:{shown:!0,sprints:F,total:T.total,isLast:T.isLast,loading:!1,error:null}}})}catch(T){const E=fe(T);h(L,D=>({...D,closed:{...D.closed,loading:!1,error:E}}))}})()},[n,t,h]),I=d.useCallback(S=>{const L=x.current;if(!S){h(L,E=>({...E,closed:{...E.closed,shown:!1}}));return}const T=o.current.closed;T.sprints.length||T.loading?h(L,E=>({...E,closed:{...E.closed,shown:!0}})):y(0)},[y,h]),Q=d.useCallback(()=>{const S=o.current.closed;S.loading||S.isLast||y(S.sprints.length)},[y]),V=d.useCallback(S=>{const L=o.current.subtasks[S];if(L&&L.status!=="error")return;const T=x.current,E=D=>h(T,F=>({...F,subtasks:{...F.subtasks,[S]:D}}));E({status:"loading",issues:(L==null?void 0:L.issues)??[],error:null}),hn(t,S).then(D=>E({status:"ready",issues:D.issues,error:null})).catch(D=>E({status:"error",issues:[],error:fe(D)}))},[t,h]),oe=l.closed,M=l.overview?Et(l.overview,oe.shown?oe.sprints:[]):[];return{snap:l,groups:M,loading:c,error:j,refresh:k,ensureGroup:A,loadMore:C,showClosed:I,moreClosed:Q,loadSubtasks:V}}const $e=new Map;function En(t,s,n){const r=n?`${s}|${n}`:"",[a,l]=d.useState(()=>{var x;return r?((x=$e.get(r))==null?void 0:x.data)??null:null}),[i,o]=d.useState(!1),[c,u]=d.useState(null),[j,f]=d.useState(0),N=d.useRef(!1);d.useEffect(()=>{if(!n){l(null),u(null);return}const x=$e.get(r);if(l((x==null?void 0:x.data)??null),u(null),x&&!N.current&&Date.now()-x.at<wn){o(!1);return}N.current=!1;const g=new AbortController;return o(!0),mn(t,n,g.signal).then(h=>{$e.set(r,{at:Date.now(),data:h}),$e.size>60&&$e.delete($e.keys().next().value),l(h)}).catch(h=>{!mt(h)&&!g.signal.aborted&&u(fe(h))}).finally(()=>{g.signal.aborted||o(!1)}),()=>g.abort()},[r,t,n,j]);const b=d.useCallback(()=>{N.current=!0,f(x=>x+1)},[]);return{data:a,loading:i,error:c,reload:b}}const ot=new Set;function ds({src:t,label:s,fallback:n,className:r="jr-icon"}){const[a,l]=d.useState(()=>!t||ot.has(t));return d.useEffect(()=>l(!t||ot.has(t)),[t]),!t||a?n?e.jsx(e.Fragment,{children:n}):e.jsx("span",{className:r,title:s,"aria-hidden":!0}):e.jsx("img",{className:r,src:t,alt:"",title:s,width:16,height:16,loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,onError:()=>{ot.add(t),l(!0)}})}function Mn(t,s=!1){const n=t.trim().toLowerCase();return s||/^sub-?\s?task/.test(n)?"subtask":/bug|defect|incident/.test(n)?"bug":/story|feature|improvement|requirement/.test(n)?"story":/epic/.test(n)?"epic":/task|chore|spike|support|request/.test(n)?"task":"other"}const Tn={bug:e.jsx("circle",{className:"jr-glyph-mark",cx:"8",cy:"8",r:"2.6"}),story:e.jsx("path",{className:"jr-glyph-mark",d:"M5.5 4h5v8L8 10.2 5.5 12z"}),task:e.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:e.jsx("path",{className:"jr-glyph-mark",d:"M4.5 4.5h4.2v4.2H4.5zM7.3 7.3h4.2v4.2H7.3z",fillRule:"evenodd"}),epic:e.jsx("path",{className:"jr-glyph-mark",d:"M9 3 5 9h2.6L7 13l4-6H8.4z"}),other:e.jsx("circle",{className:"jr-glyph-mark",cx:"8",cy:"8",r:"1.8"})};function Dn({type:t,subtask:s}){const n=t.epic?"epic":Mn(t.name,s??t.subtask);return e.jsxs("svg",{className:"jr-icon jr-type-glyph","data-shape":n,width:"16",height:"16",viewBox:"0 0 16 16",role:"img","aria-label":t.name,children:[e.jsx("title",{children:t.name}),e.jsx("rect",{className:"jr-glyph-tile",x:"1",y:"1",width:"14",height:"14",rx:"3"}),Tn[n]]})}function Fn(t){const s=t.trim().toLowerCase();return/highest|blocker|critical|urgent/.test(s)?"highest":/high|major/.test(s)?"high":/medium|normal|moderate/.test(s)?"medium":/lowest|trivial/.test(s)?"lowest":/low|minor/.test(s)?"low":null}const In={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 Pn({priority:t}){const s=Fn(t.name);return s?e.jsxs("svg",{className:"jr-icon jr-priority-glyph","data-level":s,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: ${t.name}`,children:[e.jsx("title",{children:`Priority: ${t.name}`}),e.jsx("path",{d:In[s]})]}):e.jsx("span",{className:"jr-icon",title:`Priority: ${t.name}`,"aria-hidden":!0})}const Ve=({type:t,subtask:s})=>e.jsx(ds,{src:t.icon,label:t.name,fallback:e.jsx(Dn,{type:t,subtask:s})}),vt=({priority:t})=>t?e.jsx(ds,{src:t.icon,label:`Priority: ${t.name}`,fallback:e.jsx(Pn,{priority:t})}):e.jsx("span",{className:"jr-icon","aria-hidden":!0});function us({epic:t}){return e.jsx("span",{className:"jr-epic","data-color":t.color??void 0,title:`Epic ${t.key}: ${t.name}`,children:t.name})}function hs({status:t}){return e.jsx("span",{className:"jr-status","data-cat":t.category,children:t.name})}function On({issue:t,estimation:s,time:n}){if(s==="points")return t.points==null?null:e.jsx("span",{className:"jr-estimate",title:"Story points",children:Number.isInteger(t.points)?t.points:t.points.toFixed(1)});const r=Ae(t.estimate,n),a=t.remaining!=null&&t.remaining!==t.estimate?Ae(t.remaining,n):"";return!r&&!a?null:e.jsxs("span",{className:"jr-estimate",title:`${r?`Original estimate ${r}`:"No original estimate"}${a?` · ${a} remaining`:""}`,children:[r||"–",a&&e.jsxs("span",{className:"jr-remaining",children:[" · ",a," left"]})]})}function ms(){return e.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:[e.jsx("path",{d:"M3.5 12.5V1.8",fill:"none",strokeLinecap:"round"}),e.jsx("path",{d:"M3.5 2.2h7l-1.6 2.9 1.6 2.9h-7z"})]})}function pt({open:t}){return e.jsx("svg",{className:"jr-chevron","data-open":t||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:e.jsx("path",{d:"m5.2 3 4 4-4 4"})})}function ps(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"6.1",cy:"6.1",r:"4.1"}),e.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]})}function Bn(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M11.8 2.6v3h-3"}),e.jsx("path",{d:"M11.6 5.4A5 5 0 1 0 12 8.3"})]})}function Pt(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M8 2.2h3.8V6M11.6 2.4 6.4 7.6"}),e.jsx("path",{d:"M10.4 8.6v2.6a.8.8 0 0 1-.8.8H2.8a.8.8 0 0 1-.8-.8V4.4a.8.8 0 0 1 .8-.8h2.6"})]})}function Un(t,s){const n=qe(s);switch(t.kind){case"auth":return{title:"Jira did not accept the saved token",body:t.message,reconnect:!0};case"expired":return{title:"The saved token no longer works",body:`${t.message} Make a new token and paste it in Settings.`,reconnect:!0};case"permission":return{title:"Your account cannot read this",body:t.message,reconnect:!1};case"unreachable":return{title:`${n} did not answer`,body:t.message,reconnect:!1};case"tls":return{title:`${n}'s certificate is not trusted here`,body:`${t.message} The deck checks every certificate and has no way to skip it: add the issuing authority to this machine's trust store, then try again.`,reconnect:!1};case"rate-limit":return{title:"Jira asked the deck to slow down",body:t.retryAfter?`Try again in ${t.retryAfter} seconds.`:"Try again in a minute.",reconnect:!1};case"incompatible":return{title:"This Jira cannot be read this way",body:t.message,reconnect:!1};case"not-found":return{title:"Not there any more",body:t.message,reconnect:!1};case"network":return{title:"The deck could not be reached",body:t.message,reconnect:!1};case"unavailable":return{title:"Jira is unavailable on this deck",body:"The deck cannot read Jira right now. Try again in a moment.",reconnect:!1};default:return{title:"Jira could not be read",body:t.message,reconnect:!1}}}function Ge({error:t,conn:s,stale:n,onRetry:r,onReconnect:a,compact:l}){const i=Un(t,s);return e.jsxs("div",{className:l?"jr-failure jr-failure-compact":"jr-failure",role:"alert","data-kind":t.kind,children:[e.jsxs("div",{className:"jr-failure-text",children:[e.jsx("strong",{children:i.title}),e.jsxs("span",{children:[i.body,t.detail&&t.kind!=="auth"&&t.kind!=="expired"?` Jira said: ${t.detail}`:"",n?" Showing what was read last.":""]})]}),e.jsxs("div",{className:"jr-failure-actions",children:[i.reconnect&&e.jsx("button",{type:"button",className:"btn primary",onClick:a,children:"Reconnect"}),r&&t.kind!=="auth"&&t.kind!=="expired"&&e.jsx("button",{type:"button",className:"btn",onClick:r,children:"Try again"})]})]})}const it=5,Ot={new:"To Do",indeterminate:"In Progress",done:"Done"};function Bt(t,s=""){const n=t.assignee?t.assignee.name:"unassigned";return`${t.key}: ${t.summary}. ${t.type.name}, ${t.status.name}, ${n}${t.flagged?", flagged":""}${s}`}function Ut({issue:t,estimation:s,time:n}){const r=t.status.category==="done";return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{type:t.type}),e.jsx(vt,{priority:t.priority}),e.jsx("span",{className:"jr-key","data-done":r||void 0,children:t.key}),e.jsx("span",{className:"jr-summary",children:t.summary}),e.jsxs("span",{className:"jr-meta",children:[t.flagged&&e.jsx("span",{className:"jr-flagged",title:"Flagged",children:e.jsx(ms,{})}),t.fixVersions.slice(0,2).map(a=>e.jsx("span",{className:"jr-version",children:a},a)),t.fixVersions.length>2&&e.jsxs("span",{className:"jr-version",title:t.fixVersions.slice(2).join(", "),children:["+",t.fixVersions.length-2]}),t.epic&&e.jsx(us,{epic:t.epic}),e.jsx(On,{issue:t,estimation:s,time:n}),t.assignee?e.jsx("span",{className:"jr-assignee",title:t.assignee.name,children:e.jsx(Je,{src:t.assignee.avatar,name:t.assignee.name,size:20})}):e.jsx("span",{className:"jr-assignee jr-unassigned",title:"Unassigned","aria-hidden":!0})]})]})}function _n(t){const{conn:s,overview:n,groups:r,snap:a,expanded:l,onToggleGroup:i,filter:o,mine:c,filtered:u,selected:j,onOpen:f,onRetryGroup:N,onMore:b,onShowClosed:x,onMoreClosed:g,loadSubtasks:h,onReconnect:p}=t,v=d.useRef(null),[k,A]=d.useState({}),[C,y]=d.useState(null),I=n.estimation.kind,Q=n.timeTracking,V=d.useMemo(()=>{const m=new Set;return r.map($=>{const P=a.groups[$.id],B=fn((P==null?void 0:P.issues)??[],m),_=jn(B,o,J=>{var W;return(W=a.subtasks[J])==null?void 0:W.issues});return{def:$,data:P,rows:_,stats:bn(_,I)}})},[r,a.groups,a.subtasks,o,I]),oe=m=>k[Pe(m)]??m.kind==="context";d.useEffect(()=>{for(const{def:m,rows:$}of V)if(lt(m,l))for(const P of $){if(!oe(P))continue;const B=Pe(P);if(!a.subtasks[B]){if(P.kind==="issue"){const _=P.issue.subtaskKeys;if(!u&&_.length>0&&_.every(J=>P.matched.some(W=>W.key===J))||_.length===0)continue}h(B)}}},[V,k,l]);const M=(m,$)=>A(P=>({...P,[m]:$})),S=()=>{var m;return Array.from(((m=v.current)==null?void 0:m.querySelectorAll("[data-nav]"))??[])},L=m=>{var $;m&&(m.focus(),($=m.scrollIntoView)==null||$.call(m,{block:"nearest"}))},T=m=>{var J,W;const $=m.target;if(!$.dataset.nav||m.altKey||m.ctrlKey||m.metaKey)return;const P=S(),B=P.indexOf($),_=$.getAttribute("data-expanded");switch(m.key){case"ArrowDown":m.preventDefault(),L(P[Math.min(P.length-1,B+1)]);return;case"ArrowUp":m.preventDefault(),L(P[Math.max(0,B-1)]);return;case"Home":m.preventDefault(),L(P[0]);return;case"End":m.preventDefault(),L(P[P.length-1]);return;case"ArrowRight":_==="false"?(m.preventDefault(),(J=document.getElementById($.dataset.toggle??""))==null||J.click()):_==="true"&&(m.preventDefault(),L(P[B+1]));return;case"ArrowLeft":_==="true"?(m.preventDefault(),(W=document.getElementById($.dataset.toggle??""))==null||W.click()):$.dataset.parent&&(m.preventDefault(),L(P.find(w=>w.dataset.nav===$.dataset.parent)));return}},E=d.useMemo(()=>{for(const{def:m,rows:$}of V)if(lt(m,l)&&$.length>0)return`${m.id}/${Pe($[0])}`;return null},[V,l]);d.useEffect(()=>{var m;C&&!((m=v.current)!=null&&m.querySelector(`[data-nav="${CSS.escape(C)}"]`))&&y(null)});const D=m=>m===(C??E)?0:-1,F=(m,$,P,B)=>{const _=Pe(m),J=`${$.id}/${_}`,W=oe(m),w=a.subtasks[_],O=m.kind==="issue"?m.issue.subtaskKeys.length:0,X=O>0||m.matched.length>0||m.kind==="context",ae=`jr-toggle-${$.id.replace(/[^a-z0-9]/gi,"-")}-${_}`,le=(w==null?void 0:w.status)==="ready"?w.issues.filter(ee=>!o.hideDone||ee.status.category!=="done"):m.matched,me=((w==null?void 0:w.status)==="ready"?w.issues:m.matched).filter(ee=>ee.mine).length,ie=m.kind==="issue"?Bt(m.issue,X?`, ${O||m.matched.length} sub-tasks${me?`, ${me} yours`:""}`:""):`${m.parent.key}: ${m.parent.summary}. ${c?"Not assigned to you":"Parent not in this list"}; shown for ${m.matched.length} sub-task${m.matched.length===1?"":"s"}`,q=m.kind==="issue"?m.issue:null;return e.jsxs("li",{className:"jr-item","data-context":m.kind==="context"||void 0,children:[e.jsxs("div",{className:"jr-row","data-selected":j===_||void 0,"data-done":(q==null?void 0:q.status.category)==="done"||void 0,"data-mine":(q==null?void 0:q.mine)||void 0,children:[X?e.jsx("button",{type:"button",id:ae,className:"jr-toggle",tabIndex:-1,"aria-expanded":W,"aria-label":`${W?"Hide":"Show"} sub-tasks of ${_}`,onClick:()=>M(_,!W),children:e.jsx(pt,{open:W})}):e.jsx("span",{className:"jr-toggle-space","aria-hidden":!0}),e.jsx("button",{type:"button",className:"jr-row-main","data-nav":J,"data-key":_,"data-parent":B,"data-toggle":X?ae:void 0,"data-expanded":X?String(W):void 0,tabIndex:D(J),"aria-current":j===_||void 0,"aria-label":ie,onFocus:()=>y(J),onClick:()=>f(_),children:q?e.jsx(Ut,{issue:q,estimation:I,time:Q}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{type:m.kind==="context"?m.parent.type:m.issue.type}),e.jsx(vt,{priority:m.kind==="context"?m.parent.priority:null}),e.jsx("span",{className:"jr-key","data-done":m.kind==="context"&&m.parent.status.category==="done"||void 0,children:m.kind==="context"?m.parent.key:""}),e.jsx("span",{className:"jr-summary",children:m.kind==="context"?m.parent.summary:""}),e.jsx("span",{className:"jr-meta",children:e.jsx("span",{className:"jr-context-tag",children:c?"not assigned to you":"parent not in this list"})})]})})]}),X&&W&&e.jsxs("ul",{className:"jr-subrows",role:"list","aria-label":`Sub-tasks of ${_}`,children:[(w==null?void 0:w.status)==="loading"&&le.length===0&&e.jsx("li",{className:"jr-subnote",role:"status",children:"Reading sub-tasks…"}),(w==null?void 0:w.status)==="error"&&e.jsxs("li",{className:"jr-subnote",role:"alert",children:["Sub-tasks could not be read. ",e.jsx("button",{type:"button",className:"jr-link-btn",onClick:()=>h(_),children:"Try again"})]}),le.map(ee=>{const Ee=`${$.id}/${ee.key}/${J}`;return e.jsx("li",{className:"jr-item",children:e.jsxs("div",{className:"jr-row jr-subrow","data-selected":j===ee.key||void 0,"data-done":ee.status.category==="done"||void 0,"data-mine":ee.mine||void 0,children:[e.jsx("span",{className:"jr-toggle-space","aria-hidden":!0}),e.jsx("button",{type:"button",className:"jr-row-main","data-nav":Ee,"data-key":ee.key,"data-parent":J,tabIndex:D(Ee),"aria-current":j===ee.key||void 0,"aria-label":Bt(ee,ee.mine?", yours":""),onFocus:()=>y(Ee),onClick:()=>f(ee.key),children:e.jsx(Ut,{issue:ee,estimation:I,time:Q})})]})},ee.key)}),(w==null?void 0:w.status)==="ready"&&le.length===0&&e.jsx("li",{className:"jr-subnote",children:o.hideDone?"Every sub-task is done.":"No sub-tasks."})]})]},_)},G=n.hasSprints,ne=G&&n.sprints.active.length===0,z=a.closed,re=V.findIndex(m=>m.def.kind==="closed");return e.jsxs("div",{className:"jr-board",ref:v,onKeyDown:T,children:[ne&&e.jsx("p",{className:"jr-board-note",children:"No sprint is active on this board. The future sprints and the backlog are below."}),V.map(({def:m,data:$,rows:P,stats:B},_)=>{const J=lt(m,l),W=`jr-group-${m.id.replace(/[^a-z0-9]/gi,"-")}`,w=`g:${m.id}`,O=m.sprint,X=O&&(O.startDate||O.endDate)?`${Tt(O.startDate)||"?"} – ${Tt(O.completeDate??O.endDate)||"?"}`:"",ae=($==null?void 0:$.status)==="ready"||(($==null?void 0:$.issues.length)??0)>0,le=($==null?void 0:$.total)!=null&&m.paged&&$.total>B.count&&!o.search&&!o.hideDone,me=ae?le?`${B.count} of ${$.total}`:`${B.count}`:($==null?void 0:$.status)==="error"?"":"…",ie=B.assignees;return e.jsxs(d.Fragment,{children:[_===re&&e.jsx("h3",{className:"jr-closed-title",children:"Closed sprints"}),e.jsxs("section",{className:"jr-group","data-kind":m.kind,"aria-labelledby":`${W}-title`,children:[e.jsxs("div",{className:"jr-group-head",children:[e.jsx("h3",{className:"jr-group-title",id:`${W}-title`,children:e.jsxs("button",{type:"button",id:`${W}-toggle`,className:"jr-group-toggle","data-nav":w,"data-toggle":`${W}-toggle`,"data-expanded":String(J),"aria-expanded":J,"aria-controls":W,onClick:()=>i(m,!J),children:[e.jsx(pt,{open:J}),e.jsx("span",{className:"jr-group-name",children:m.title}),m.kind==="active"&&e.jsx("span",{className:"jr-badge",children:"Active"}),X&&e.jsx("span",{className:"jr-group-dates",children:X}),e.jsxs("span",{className:"jr-group-count",children:[me," ",ae?B.count===1&&!le?"issue":"issues":e.jsx("span",{className:"vis-hidden",children:"issues, not read yet"})]})]})}),ae&&e.jsxs("div",{className:"jr-group-facts",children:[B.mine>0&&!c&&e.jsxs("span",{className:"jr-mine",title:"Yours, and how many of those are done",children:["Mine ",B.mineDone,"/",B.mine]}),B.mine>0&&c&&e.jsxs("span",{className:"jr-mine",title:"How many of yours are done",children:[B.mineDone,"/",B.mine," done"]}),ie.length>0&&e.jsxs("span",{className:"jr-stack",role:"img",title:ie.map(q=>q.name).join(", "),"aria-label":`Assigned to ${ie.map(q=>q.name).join(", ")}`,children:[ie.slice(0,it).map(q=>e.jsx(Je,{src:q.avatar,name:q.name,size:20},q.id)),ie.length>it&&e.jsxs("span",{className:"jr-stack-more",children:["+",ie.length-it]})]}),e.jsx("span",{className:"jr-totals",children:["new","indeterminate","done"].map(q=>e.jsxs("span",{className:"jr-total","data-cat":q,title:`${Ot[q]}: ${Mt(B.totals[q],I,Q)}`,children:[e.jsxs("span",{className:"vis-hidden",children:[Ot[q]," "]}),Mt(B.totals[q],I,Q)]},q))})]})]}),(O==null?void 0:O.goal)&&J&&e.jsx("p",{className:"jr-goal",children:O.goal}),J&&e.jsxs("div",{id:W,className:"jr-group-body",children:[($==null?void 0:$.status)==="error"&&$.error&&e.jsx(Ge,{error:$.error,conn:s,stale:$.issues.length>0,onRetry:()=>N(m),onReconnect:p,compact:!0}),(!$||$.status==="idle"||$.status==="loading"&&$.issues.length===0)&&e.jsxs("div",{className:"jr-skeleton jr-skeleton-rows",role:"status","aria-label":`Reading ${m.title}`,children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),ae&&P.length===0&&e.jsx("p",{className:"jr-empty-group",children:(($==null?void 0:$.issues.length)??0)>0?"Nothing here matches the filters.":c?"None of your issues are here.":u?"Nothing here matches the filters.":"No issues."}),P.length>0&&e.jsx("ul",{className:"jr-rows",children:P.map(q=>F(q,m))}),($==null?void 0:$.capped)&&e.jsx("p",{className:"jr-board-note",children:"The first 600 issues are shown. Open the sprint in Jira for the rest."}),m.paged&&($==null?void 0:$.next)&&e.jsx("button",{type:"button",className:"btn jr-more","aria-busy":$.more||void 0,onClick:()=>b(m),children:$.more?"Reading…":$.total!=null?`Show more (${$.issues.length} of ${$.total})`:"Show more"})]})]})]},m.id)}),G&&e.jsxs("div",{className:"jr-closed-foot",children:[z.error&&e.jsxs("p",{className:"jr-subnote",role:"alert",children:["Closed sprints could not be read: ",z.error.message]}),z.shown?e.jsxs(e.Fragment,{children:[z.sprints.length===0&&!z.loading&&e.jsx("p",{className:"jr-subnote",children:"No closed sprints on this board."}),!z.isLast&&z.sprints.length>0&&e.jsx("button",{type:"button",className:"btn","aria-busy":z.loading||void 0,onClick:g,children:z.loading?"Reading…":`Show older sprints (${z.sprints.length} of ${z.total})`}),e.jsx("button",{type:"button",className:"btn",onClick:()=>x(!1),children:"Hide closed sprints"})]}):e.jsx("button",{type:"button",className:"btn","aria-busy":z.loading||void 0,onClick:()=>x(!0),children:z.loading?"Reading closed sprints…":"Show closed sprints"})]})]})}const Hn=1,Wn=3,qn=48,Gn=2e4,Kn=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"]),zn={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:"h5",H2:"h6",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"},Jn=new Set(["br","hr","img"]),Vn={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 Xn(t){var r;const n=(((r=t.getAttribute)==null?void 0:r.call(t,"class"))??"").split(/\s+/).map(a=>Vn[a]).filter(Boolean);return n.length?[...new Set(n)].join(" "):void 0}function _t(t,s){const n=String(t??"").trim();if(!n)return null;let r;try{r=new URL(n,`${s.replace(/\/+$/,"")}/`)}catch{return null}return r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password?null:r.href}function Ht(t){const s=Number.parseInt(String(t??""),10);return Number.isFinite(s)&&s>1&&s<=100?s:void 0}function fs({href:t,alt:s,emoticon:n}){return n?e.jsx(e.Fragment,{children:s}):e.jsx("a",{className:"jr-image-link",href:t,target:"_blank",rel:"noreferrer noopener",children:s||"Image"})}function Yn({src:t,href:s,alt:n,emoticon:r}){const[a,l]=d.useState(!1);return a?e.jsx(fs,{href:s,alt:n,emoticon:r}):e.jsx("img",{className:r?"jr-emoticon":"jr-image",src:t,alt:n,loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,onError:()=>l(!0)})}function Qn(t){return typeof DOMParser>"u"?null:new DOMParser().parseFromString(t,"text/html").body}function Zn(t,s,n=Qn){if(!t||!t.trim())return null;const r=n(t);if(!r)return t.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();let a=Gn;const l=(o,c,u)=>{var g,h,p,v,k,A;if(--a<0)return null;if(o.nodeType===Wn)return o.nodeValue??"";if(o.nodeType!==Hn)return null;const j=String(o.nodeName).toUpperCase();if(Kn.has(j))return null;const f=()=>{if(u>=qn)return[];const C=[],y=o.childNodes;for(let I=0;I<y.length;I++){const Q=l(y[I],`${c}.${I}`,u+1);Q!==null&&Q!==""&&C.push(Q)}return C},N=zn[j];if(!N){const C=f();return C.length?d.createElement(d.Fragment,{key:c},...C):null}const b=Xn(o);if(N==="img"){const C=_t((g=o.getAttribute)==null?void 0:g.call(o,"src"),s.baseUrl);if(!C)return null;const y=(((h=o.getAttribute)==null?void 0:h.call(o,"alt"))??((p=o.getAttribute)==null?void 0:p.call(o,"title"))??"").slice(0,200),I=s.image(C),Q=b==="jr-emoticon";return I?e.jsx(Yn,{src:I,href:C,alt:y,emoticon:Q},c):e.jsx(fs,{href:C,alt:y,emoticon:Q},c)}if(N==="a"){const C=_t((v=o.getAttribute)==null?void 0:v.call(o,"href"),s.baseUrl),y=f();return C?d.createElement("a",{key:c,href:C,target:"_blank",rel:"noreferrer noopener",className:b},...y.length?y:[C]):y.length?d.createElement(d.Fragment,{key:c},...y):null}const x={key:c};if(b&&(x.className=b),N==="td"||N==="th"){const C=Ht((k=o.getAttribute)==null?void 0:k.call(o,"colspan")),y=Ht((A=o.getAttribute)==null?void 0:A.call(o,"rowspan"));C&&(x.colSpan=C),y&&(x.rowSpan=y)}return N==="table"?e.jsx("div",{className:"jr-table-wrap",children:d.createElement("table",{className:b},...f())},c):Jn.has(N)?d.createElement(N,x):d.createElement(N,x,...f())},i=[];for(let o=0;o<r.childNodes.length;o++){const c=l(r.childNodes[o],String(o),0);c!==null&&c!==""&&i.push(c)}return i.length?i:null}function Wt({html:t,ctx:s,className:n="jr-html",empty:r}){const a=d.useMemo(()=>Zn(t,s),[t,s]);return a?e.jsx("div",{className:n,children:a}):r?e.jsx(e.Fragment,{children:r}):null}function se({label:t,children:s}){return s==null||s===""||Array.isArray(s)&&s.length===0?null:e.jsxs("div",{className:"jr-field",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function ct({person:t,fallback:s}){return t?e.jsxs("span",{className:"jr-person",children:[e.jsx(Je,{src:t.avatar,name:t.name,size:18}),t.name]}):e.jsx("span",{className:"jr-dim",children:s})}function er({issues:t,onOpen:s}){return e.jsx("ul",{className:"jr-detail-subtasks",children:t.map(n=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"jr-detail-sub","data-mine":n.mine||void 0,"data-done":n.status.category==="done"||void 0,onClick:()=>s(n.key),"aria-label":`${n.key}: ${n.summary}. ${n.status.name}${n.assignee?`, ${n.assignee.name}`:", unassigned"}${n.mine?", yours":""}`,children:[e.jsx(Ve,{type:n.type}),e.jsx("span",{className:"jr-key",children:n.key}),e.jsx("span",{className:"jr-summary",children:n.summary}),e.jsx(hs,{status:n.status}),n.assignee?e.jsx(Je,{src:n.assignee.avatar,name:n.assignee.name,size:18}):e.jsx("span",{className:"jr-avatar-blank","aria-hidden":!0})]})},n.key))})}function tr({conn:t,api:s,assetUrl:n,trail:r,estimation:a,time:l,onOpen:i,onTrail:o,onReconnect:c}){var C;const u=r[r.length-1]??null,{data:j,loading:f,error:N,reload:b}=En(s,t.id,u),[x,g]=d.useState(null),h=d.useMemo(()=>({baseUrl:t.baseUrl,image:y=>pn(t,n,y)}),[t,n]);d.useEffect(()=>{if(!x)return;const y=window.setTimeout(()=>g(null),2e3);return()=>window.clearTimeout(y)},[x]);const p=j&&j.issue.key===u?j.issue:null,v=async y=>{p&&await ns(y==="key"?p.key:p.url)&&g(y)},k=[];p!=null&&p.project.name&&k.push({label:p.project.name,title:p.project.key});const A=(C=p==null?void 0:p.parent)==null?void 0:C.key;return A&&!r.slice(0,-1).includes(A)&&k.push({label:A,title:p.parent.summary,go:()=>i(A,"replace")}),r.slice(0,-1).forEach((y,I)=>k.push({label:y,title:`Back to ${y}`,go:()=>o(I)})),u?e.jsxs("article",{className:"jr-detail","aria-busy":f||void 0,"aria-labelledby":"jira-detail-title",children:[e.jsxs("ol",{className:"jr-crumbs",role:"list","aria-label":"Where this issue is",children:[k.map((y,I)=>e.jsx("li",{children:y.go?e.jsx("button",{type:"button",className:"jr-crumb",title:y.title,onClick:y.go,children:y.label}):e.jsx("span",{className:"jr-crumb-text",title:y.title,children:y.label})},`${y.label}-${I}`)),e.jsx("li",{"aria-current":"page",children:e.jsx("span",{className:"jr-crumb-text jr-crumb-here",children:u})})]}),N&&e.jsx(Ge,{error:N,conn:t,stale:!!p,onRetry:b,onReconnect:c,compact:!0}),!p&&f&&e.jsxs("div",{className:"jr-skeleton",role:"status","aria-label":`Reading ${u}`,children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"jr-detail-head",children:[e.jsxs("div",{className:"jr-detail-kicker",children:[e.jsx(Ve,{type:p.type}),e.jsx("a",{className:"jr-key jr-key-link",href:p.url,target:"_blank",rel:"noreferrer noopener","data-done":p.status.category==="done"||void 0,children:p.key}),e.jsx(hs,{status:p.status}),p.flagged&&e.jsxs("span",{className:"jr-flagged",children:[e.jsx(ms,{})," Flagged"]})]}),e.jsx("h3",{id:"jira-detail-title",tabIndex:-1,className:"jr-detail-title",children:p.summary}),e.jsxs("div",{className:"jr-detail-actions",children:[e.jsxs("a",{className:"jr-open",href:p.url,target:"_blank",rel:"noreferrer noopener",children:["Open in Jira ",e.jsx(Pt,{})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void v("key"),children:x==="key"?"Copied":"Copy key"}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void v("link"),children:x==="link"?"Copied":"Copy link"}),e.jsx("span",{className:"vis-hidden",role:"status",children:x?`Copied the ${x==="key"?"key":"link"}`:""})]})]}),e.jsxs("dl",{className:"jr-fields",children:[e.jsxs(se,{label:"Status",children:[p.status.name,p.resolution?e.jsxs("span",{className:"jr-dim",children:[" · ",p.resolution]}):null]}),e.jsx(se,{label:"Assignee",children:e.jsx(ct,{person:p.assignee,fallback:"Unassigned"})}),e.jsx(se,{label:"Reporter",children:e.jsx(ct,{person:p.reporter,fallback:"Nobody"})}),e.jsx(se,{label:"Type",children:p.type.name}),e.jsx(se,{label:"Priority",children:p.priority?e.jsxs("span",{className:"jr-person",children:[e.jsx(vt,{priority:p.priority}),p.priority.name]}):null}),e.jsx(se,{label:"Sprint",children:p.sprint?e.jsxs(e.Fragment,{children:[p.sprint.name,p.sprint.state?e.jsxs("span",{className:"jr-dim",children:[" · ",p.sprint.state]}):null]}):null}),e.jsx(se,{label:"Epic",children:p.epic?e.jsx(us,{epic:p.epic}):null}),e.jsx(se,{label:"Fix versions",children:p.fixVersions.length?e.jsx("span",{className:"jr-chips",children:p.fixVersions.map(y=>e.jsx("span",{className:"jr-version",children:y},y))}):null}),e.jsx(se,{label:"Labels",children:p.labels.length?e.jsx("span",{className:"jr-chips",children:p.labels.map(y=>e.jsx("span",{className:"jr-label",children:y},y))}):null}),e.jsx(se,{label:"Components",children:p.components.join(", ")}),a==="points"&&e.jsx(se,{label:"Story points",children:p.points!=null?String(p.points):null}),e.jsx(se,{label:"Original estimate",children:Ae(p.estimate,l)}),e.jsx(se,{label:"Remaining",children:Ae(p.remaining,l)}),e.jsx(se,{label:"Time spent",children:Ae(p.timeSpent,l)}),e.jsx(se,{label:"Due",children:De(p.dueDate)}),e.jsx(se,{label:"Created",children:De(p.created,!0)}),e.jsx(se,{label:"Updated",children:De(p.updated,!0)})]}),e.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-desc",children:[e.jsx("h4",{id:"jira-detail-desc",children:"Description"}),e.jsx(Wt,{html:p.descriptionHtml,ctx:h,empty:e.jsx("p",{className:"jr-dim",children:"No description."})})]}),j.subtasks.length>0&&e.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-subs",children:[e.jsxs("h4",{id:"jira-detail-subs",children:["Sub-tasks ",e.jsx("span",{className:"jr-count",children:j.subtasks.length})]}),e.jsx(er,{issues:j.subtasks,onOpen:y=>i(y,"push")})]}),j.attachments.length>0&&e.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-files",children:[e.jsxs("h4",{id:"jira-detail-files",children:["Attachments ",e.jsx("span",{className:"jr-count",children:j.attachments.length})]}),e.jsx("ul",{className:"jr-files",children:j.attachments.map(y=>e.jsxs("li",{children:[y.url?e.jsxs("a",{href:y.url,target:"_blank",rel:"noreferrer noopener",title:"Opens in Jira",children:[y.filename,e.jsx(Pt,{})]}):e.jsx("span",{children:y.filename}),e.jsx("span",{className:"jr-dim",children:[yn(y.size),De(y.created)].filter(Boolean).join(" · ")})]},y.id))})]}),e.jsxs("section",{className:"jr-detail-section","aria-labelledby":"jira-detail-comments",children:[e.jsxs("h4",{id:"jira-detail-comments",children:["Comments ",e.jsx("span",{className:"jr-count",children:j.comments.total>j.comments.items.length?`${j.comments.items.length} of ${j.comments.total}`:j.comments.total})]}),j.comments.items.length===0&&e.jsx("p",{className:"jr-dim",children:"No comments."}),e.jsx("ol",{className:"jr-comments",children:j.comments.items.map(y=>e.jsxs("li",{className:"jr-comment",children:[e.jsxs("div",{className:"jr-comment-head",children:[e.jsx(ct,{person:y.author,fallback:"Someone"}),e.jsx("time",{className:"jr-dim",dateTime:y.created,children:De(y.created,!0)}),y.updated&&y.updated!==y.created&&e.jsx("span",{className:"jr-dim",children:"edited"})]}),e.jsx(Wt,{html:y.html,ctx:h,empty:e.jsx("p",{className:"jr-dim",children:"(empty)"})})]},y.id))}),j.comments.total>j.comments.items.length&&e.jsx("p",{className:"jr-dim",children:e.jsx("a",{href:p.url,target:"_blank",rel:"noreferrer noopener",children:"The older comments are in Jira"})})]})]})]}):null}const sr=t=>typeof t=="string"&&t.length>0&&t.length<=40,qt=t=>typeof t=="boolean",nr=t=>!!t&&typeof t=="object"&&!Array.isArray(t)&&Object.values(t).every(s=>typeof s=="boolean"),rr=t=>!!t&&typeof t=="object"&&typeof t.board=="string"&&Array.isArray(t.ids)&&t.ids.every(s=>typeof s=="string");function ar(t){const[s,n]=d.useState(()=>Date.now());return d.useEffect(()=>{const r=window.setInterval(()=>n(Date.now()),t);return()=>window.clearInterval(r)},[t]),s}function lr({api:t,current:s,anchorId:n,onPick:r,onClose:a}){const[l,i]=d.useState(""),[o,c]=d.useState({boards:[],isLast:!1,total:null,loading:!0,error:null}),u=d.useRef(null),j=d.useRef(null),f=d.useRef(0),N=d.useCallback((g,h)=>{const p=++f.current;c(v=>({...v,loading:!0,error:null,...h===0?{boards:[]}:{}})),is(t,h,g).then(v=>{p===f.current&&c(k=>({boards:h===0?v.boards:[...k.boards,...v.boards.filter(A=>!k.boards.some(C=>C.id===A.id))],isLast:v.isLast,total:v.total,loading:!1,error:null}))}).catch(v=>{p===f.current&&c(k=>({...k,loading:!1,error:fe(v)}))})},[t]);d.useEffect(()=>{const g=window.setTimeout(()=>N(l.trim(),0),l?250:0);return()=>window.clearTimeout(g)},[l,N]);const b=()=>{var g;return Array.from(((g=j.current)==null?void 0:g.querySelectorAll("button[data-board]"))??[])},x=g=>{var k;if(g.key!=="ArrowDown"&&g.key!=="ArrowUp")return;const h=b();if(!h.length)return;g.preventDefault();const p=h.indexOf(document.activeElement),v=g.key==="ArrowDown"?p<0?0:Math.min(h.length-1,p+1):p<=0?-1:p-1;v<0?(k=u.current)==null||k.focus():h[v].focus()};return e.jsx(rs,{anchorId:n,portalRootId:"integration-jira-modal",id:"jira-board-picker",className:"jr-board-pop",role:"dialog",labelledBy:"jira-board-picker-title",focusRef:u,onClose:a,children:e.jsxs("div",{className:"jr-board-pop-inner",onKeyDown:x,children:[e.jsx("p",{className:"jr-board-pop-title",id:"jira-board-picker-title",children:"Boards"}),e.jsxs("label",{className:"jr-search jr-board-search",children:[e.jsx(ps,{}),e.jsx("input",{ref:u,type:"search",placeholder:"Find a board by name","aria-label":"Find a board by name",value:l,onChange:g=>i(g.target.value)})]}),e.jsx("ul",{className:"jr-board-list",role:"list",ref:j,"aria-label":"Boards","aria-busy":o.loading||void 0,children:o.boards.map(g=>e.jsx("li",{children:e.jsxs("button",{type:"button","data-board":g.id,className:"jr-board-item","aria-current":String(g.id)===s||void 0,onClick:()=>r(g),children:[e.jsx("span",{className:"jr-board-item-name",children:g.name}),e.jsx("span",{className:"jr-board-item-meta",children:[g.type,g.projectName||g.projectKey].filter(Boolean).join(" · ")})]})},g.id))}),o.loading&&e.jsx("p",{className:"jr-board-pop-note",role:"status",children:"Reading boards…"}),!o.loading&&o.error&&e.jsx("p",{className:"jr-board-pop-note",role:"alert",children:o.error.message}),!o.loading&&!o.error&&o.boards.length===0&&e.jsx("p",{className:"jr-board-pop-note",children:l?"No board by that name.":"No boards this account can see."}),!o.loading&&!o.isLast&&o.boards.length>0&&e.jsxs("button",{type:"button",className:"btn jr-board-more",onClick:()=>N(l.trim(),o.boards.length),children:["Show more boards",o.total!=null?` (${o.boards.length} of ${o.total})`:""]})]})})}function or({connection:t,api:s,assetUrl:n,prefs:r,narrow:a,onReconnect:l}){var At;const[i,o]=d.useState(()=>r.read("board",sr)??null),[c,u]=d.useState(()=>r.read("boardName",R=>typeof R=="string")??""),[j,f]=d.useState(()=>r.read("mine",qt)??!0),[N,b]=d.useState(()=>r.read("hideDone",qt)??!1),[x,g]=d.useState(()=>{const R=r.read("quick",rr);return R&&R.board===i?R.ids:[]}),[h,p]=d.useState(()=>r.read("expanded",nr)??{}),[v,k]=d.useState(""),[A,C]=d.useState(!1),[y,I]=d.useState([]),[Q,V]=d.useState(null),[oe,M]=d.useState(!1),S=ar(3e4),L=d.useRef(null);d.useEffect(()=>{r.write("mine",j)},[r,j]),d.useEffect(()=>{r.write("hideDone",N)},[r,N]),d.useEffect(()=>{i&&r.write("quick",{board:i,ids:x})},[r,i,x]),d.useEffect(()=>{r.write("expanded",h)},[r,h]);const T=d.useCallback(R=>{const Y=String(R.id);o(Y),u(R.name),r.write("board",Y),r.write("boardName",R.name),g([]),I([])},[r]),E=d.useCallback(()=>{V(null),M(!1),is(s,0,"").then(R=>{R.boards[0]?T(R.boards[0]):M(!0)}).catch(R=>V(fe(R)))},[s,T]);d.useEffect(()=>{i||E()},[i,E]);const D=d.useMemo(()=>({mine:j,quick:x}),[j,x]),F=Ln(s,t.id,i,D),{snap:G,groups:ne,loading:z,error:re}=F,m=G.overview&&String(G.overview.board.id)===i?G.overview:null;d.useEffect(()=>{m&&m.board.name&&m.board.name!==c&&(u(m.board.name),r.write("boardName",m.board.name))},[m,c,r]);const{ensureGroup:$}=F;d.useEffect(()=>{for(const R of ne)R.kind==="closed"&&h[R.id]&&$(R)},[ne,h,$]);const P=(R,Y)=>p(Me=>({...Me,[R.id]:Y})),B=j||N||x.length>0||v.trim()!=="",_=()=>{f(!1),b(!1),g([]),k("")},J=d.useMemo(()=>({search:v,hideDone:N}),[v,N]),W=y.length>0,w=R=>{I([R]),a&&requestAnimationFrame(()=>{var Y;return(Y=document.getElementById("jira-detail-title"))==null?void 0:Y.focus()})},O=d.useCallback(()=>{const R=y[0];I([]),requestAnimationFrame(()=>{const Y=R?document.querySelector(`.jr-row-main[data-key="${CSS.escape(R)}"]`):null;Y==null||Y.focus()})},[y]),X=d.useRef(O);X.current=O,d.useEffect(()=>{if(!(!a||!W))return ht.push(()=>X.current(),0,"popover")},[a,W]);const[ae,le]=d.useState(!1),me=ae&&v!=="";d.useEffect(()=>{if(me)return ht.push(()=>k(""),0,"popover")},[me]);const ie=qe(t),q=G.loadedAt?Nn(G.loadedAt,S):"",ee=m?null:re??Q,Ee=oe?e.jsxs("div",{className:"jr-state",children:[e.jsx("h3",{children:"No boards here"}),e.jsxs("p",{children:["This account cannot see any board on ",ie,". A board appears here once you are given access to one in Jira."]}),e.jsx("p",{children:e.jsx("a",{className:"jr-open",href:`${t.baseUrl}/secure/ManageRapidViews.jspa`,target:"_blank",rel:"noreferrer noopener",children:"Open boards in Jira"})})]}):ee?e.jsxs("div",{className:"jr-state",children:[e.jsx(Ge,{error:ee,conn:t,onRetry:i?F.refresh:E,onReconnect:l}),ee.kind==="not-found"&&i&&e.jsx("p",{children:e.jsx("button",{type:"button",className:"btn",onClick:()=>C(!0),children:"Choose another board"})})]}):m?e.jsxs(e.Fragment,{children:[re&&e.jsx(Ge,{error:re,conn:t,stale:!0,onRetry:F.refresh,onReconnect:l,compact:!0}),e.jsx(_n,{conn:t,overview:m,groups:ne,snap:G,expanded:h,onToggleGroup:P,filter:J,mine:j,filtered:B,selected:y[y.length-1]??null,onOpen:w,onRetryGroup:R=>F.ensureGroup(R,!0),onMore:F.loadMore,onShowClosed:F.showClosed,onMoreClosed:F.moreClosed,loadSubtasks:F.loadSubtasks,onReconnect:l})]}):e.jsxs("div",{className:"jr-skeleton jr-skeleton-board",role:"status","aria-label":"Reading the board",children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),Os=W&&m?e.jsx(tr,{conn:t,api:s,assetUrl:n,trail:y,estimation:m.estimation.kind,time:m.timeTracking,onOpen:(R,Y)=>I(Me=>Y==="push"?[...Me.filter(Bs=>Bs!==R),R]:[R]),onTrail:R=>I(Y=>Y.slice(0,R+1)),onReconnect:l}):null;return e.jsxs("div",{className:"jr-panel","data-deployment":((At=t.meta)==null?void 0:At.deployment)==="cloud"?"cloud":"server",children:[e.jsxs("div",{className:"jr-toolbar",hidden:a&&W,children:[e.jsxs("div",{className:"jr-toolbar-row",children:[e.jsxs("button",{type:"button",id:"jira-board-button",className:"btn jr-board-btn","aria-haspopup":"dialog","aria-expanded":A,"aria-controls":A?"jira-board-picker":void 0,onClick:()=>C(R=>!R),children:[e.jsx("span",{className:"jr-board-btn-label",children:"Board"}),e.jsx("span",{className:"jr-board-btn-name",children:(m==null?void 0:m.board.name)||c||(i?`Board ${i}`:"Choose a board")}),e.jsx(pt,{open:A})]}),(m==null?void 0:m.board.projectName)&&e.jsx("span",{className:"jr-board-project",children:m.board.projectName}),e.jsx("span",{className:"jr-fresh",role:"status","aria-live":"polite",children:z?G.loadedAt?"Updating…":"Reading…":q?`Updated ${q}`:""}),e.jsx("button",{type:"button",className:"glyph-btn jr-refresh","aria-label":"Refresh the board",title:"Refresh","aria-busy":z||void 0,"data-loading":z||void 0,disabled:!i,onClick:()=>{i?F.refresh():E()},children:e.jsx(Bn,{})})]}),e.jsxs("div",{className:"jr-filters",role:"group","aria-label":"Filters",children:[e.jsxs("label",{className:"jr-search",children:[e.jsx(ps,{}),e.jsx("input",{ref:L,type:"search",placeholder:"Search key or summary","aria-label":"Search issues by key or summary",value:v,onChange:R=>k(R.target.value),onFocus:()=>le(!0),onBlur:()=>le(!1)})]}),e.jsxs("div",{className:"jr-filter-chips",children:[e.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":j,onClick:()=>f(R=>!R),children:"Only my issues"}),e.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":N,onClick:()=>b(R=>!R),children:"Hide done"}),((m==null?void 0:m.quickFilters)??[]).map(R=>e.jsx("button",{type:"button",className:"btn jr-chip","aria-pressed":x.includes(R.id),title:R.description||void 0,onClick:()=>g(Y=>Y.includes(R.id)?Y.filter(Me=>Me!==R.id):[...Y,R.id]),children:R.name},R.id)),B&&e.jsx("button",{type:"button",className:"jr-link-btn jr-clear",onClick:_,children:"Clear filters"})]})]})]}),e.jsx(wt,{storageKey:"jira",list:e.jsx("div",{className:"jr-list-scroll",children:Ee}),detail:Os,onBack:O,backLabel:"Back to the board"}),A&&e.jsx(lr,{api:s,current:i,anchorId:"jira-board-button",onPick:R=>{var Y;T(R),C(!1),(Y=document.getElementById("jira-board-button"))==null||Y.focus()},onClose:()=>C(!1)})]})}const H={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"}},ir=12e4;function Ke(t,s={}){const n=new URLSearchParams;for(const[a,l]of Object.entries(s))l!=null&&l!==""&&n.set(a,String(l));const r=n.toString();return`${t}${r?`?${r}`:""}`}class Oe extends Error{constructor(s){super(s.message),this.info=s,this.name="ForgeReadError"}}async function $t(t,s,n){let r;try{r=await t(s,{signal:n,headers:{accept:"application/json"}})}catch(i){throw(i==null?void 0:i.name)==="AbortError"?i:new Oe({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 l=a==null?void 0:a.error;throw l&&typeof l=="object"&&typeof l.kind=="string"?new Oe(l):new Oe({kind:"upstream",message:typeof l=="string"?l:`the deck answered ${r.status}`,status:r.status})}const Ce=new Map,cr=200;function We(t){return Ce.get(t)??{data:null,loadedAt:null,error:null}}function ft(t,s){for(Ce.delete(t),Ce.set(t,s);Ce.size>cr;)Ce.delete(Ce.keys().next().value)}function dr(t,s,n=!1){return n||t.loadedAt==null||s-t.loadedAt>=ir}function ur(t){return t.data!=null&&t.error!=null}const Gt={success:{mark:"✓",word:"passed",tone:"ok"},failed:{mark:"✕",word:"failed",tone:"bad"},running:{mark:"●",word:"running",tone:"busy"},pending:{mark:"○",word:"pending",tone:"busy"},canceled:{mark:"⊘",word:"canceled",tone:"idle"},skipped:{mark:"»",word:"skipped",tone:"idle"},manual:{mark:"▷",word:"manual",tone:"idle"},none:{mark:"–",word:"no pipeline",tone:"idle"}};function ue(t){return Gt[t??"none"]??Gt.none}function Xe(t){return t.state==="merged"?{mark:"⇢",word:"Merged",tone:"ok"}:t.state==="closed"?{mark:"⊘",word:"Closed",tone:"idle"}:t.draft?{mark:"◌",word:"Draft",tone:"idle"}:t.approved?{mark:"✓",word:"Approved",tone:"ok"}:{mark:"●",word:"Open",tone:"busy"}}function gs(t){switch(t){case"approved":return{mark:"✓",word:"approved",tone:"ok"};case"changes_requested":return{mark:"✕",word:"changes requested",tone:"bad"};case"commented":return{mark:"…",word:"commented",tone:"idle"};default:return{mark:"◌",word:"review pending",tone:"idle"}}}function ze(t){return t==null?"–":t>=1e3?"999+":String(t)}function He(t){if(t==null||!Number.isFinite(t)||t<0)return null;const s=Math.round(t);return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`:`${Math.floor(s/3600)}h ${String(Math.floor(s%3600/60)).padStart(2,"0")}m`}function hr(t,s,n=Date.now()){const r=H[t].name,a={auth:{title:`${r} refused the token`,detail:"It may have been revoked. Update it in Settings › Integrations.",action:"connection"},expired:{title:`The ${r} token has expired`,detail:"Create a new one and paste it in Settings › Integrations.",action:"connection"},permission:{title:"The token cannot read this",detail:`${s.message}. Check the token's scopes in Settings › Integrations.`,action:"connection"},unreachable:{title:`${r} did not answer`,detail:"Check the network or VPN, and whether the instance is up.",action:"retry"},tls:{title:`${r}'s certificate is not trusted`,detail:"This machine does not trust the instance's certificate. Add its CA to the system, or set NODE_EXTRA_CA_CERTS.",action:"retry"},"rate-limit":{title:`${r} asked to slow down`,detail:s.retryAfter!=null?`Try again ${mr(s.retryAfter,n)}.`:"Try again in a minute.",action:"retry"},incompatible:{title:`This is not a ${r} API`,detail:`${s.message}. Check the address in Settings › Integrations.`,action:"connection"},"not-found":{title:"Not found",detail:"It was deleted, moved, or this token cannot see it.",action:"retry"},upstream:{title:`${r} answered with an error`,detail:s.message,action:"retry"},invalid:{title:"The deck could not ask for that",detail:s.message,action:"retry"},unavailable:{title:`${r} is unavailable on this deck`,detail:"The deck cannot read it right now. Try again in a moment.",action:"retry"}};return a[s.kind]??a.upstream}function mr(t,s){return t<60?`in ${Math.max(1,t)}s`:`after ${new Date(s+t*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`}function pr(t){const s=[],n=[];for(const r of t)(r.stale&&!r.isDefault?n:s).push(r);return{active:s,stale:n}}function fr(t){const s=[],n=[];for(const r of t)(r.approvedByMe?n:s).push(r);return{waiting:s,approved:n}}function Ye(t,s){const n=s.trim().toLowerCase();if(!n)return!0;const r=[t.key,t.title,t.name,t.number!=null?String(t.number):null].filter(a=>typeof a=="string").join(`
2
- `).toLowerCase();return n.replace(/^[#!]/,"").split(/\s+/).every(a=>r.includes(a))}function Kt(t){const s=t.trim();return/^https?:\/\/\S+\/(?:-\/)?(?:merge_requests|issues|pull)\/\d+/.test(s)||/^[\w.-]+(?:\/[\w.-]+)+[#!]\d+$/.test(s)}const Fe={tab:"branches",filter:"all",state:"open",sort:"created",issueState:"open"},gr=["branches","changes","pipelines","issues"],js="view",jr=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function zt(t){return xr(t.read(js,jr)??{})}function Jt(t,s){t.write(js,s)}function xr(t){const s=(n,r,a)=>r.includes(n)?n:a;return{repo:typeof t.repo=="string"&&t.repo.length<=255?t.repo:null,tab:s(t.tab,gr,Fe.tab),filter:s(t.filter,["all","mine","review"],Fe.filter),state:s(t.state,["open","merged","closed"],Fe.state),sort:s(t.sort,["created","updated"],Fe.sort),issueState:s(t.issueState,["open","closed"],Fe.issueState),open:Array.isArray(t.open)?t.open.filter(n=>typeof n=="string").slice(0,20):[]}}function br(t,s,n){return t?n||!s?"page":"stay":"opener"}function Nr(t,s){return s==="branches"?!1:s==="issues"?t==="gitlab":!0}function xs(t){return t instanceof Oe?t.info:{kind:"upstream",message:"the read failed"}}function pe(t,s,n,r={},a=0){const l=n?Ke(n,r):null,i=l?`${s}
3
- ${l}`:null,[o,c]=d.useState(()=>Se(i?We(i):null,!1)),[u,j]=d.useState(0),f=d.useRef(a);d.useEffect(()=>{if(!i||!l){c(Se(null,!1));return}const b=We(i),x=u>0||a!==f.current;if(f.current=a,!dr(b,Date.now(),x)){c(Se(b,!1));return}c(Se(b,!0));const g=new AbortController;return $t(t,l,g.signal).then(h=>{const p={data:h,loadedAt:Date.now(),error:null};ft(i,p),g.signal.aborted||c(Se(p,!1))},h=>{if(g.signal.aborted||(h==null?void 0:h.name)==="AbortError")return;const p={...We(i),error:xs(h)};ft(i,p),c(Se(p,!1))}),()=>g.abort()},[t,i,l,a,u]);const N=d.useCallback(()=>j(b=>b+1),[]);return{...o,reload:N}}function Se(t,s){return{data:(t==null?void 0:t.data)??null,error:(t==null?void 0:t.error)??null,loading:s,loadedAt:(t==null?void 0:t.loadedAt)??null,stale:t?ur(t):!1}}function be(t,s,n,r={},a=0){var k;const l=pe(t,s,n,r,a),i=n?Ke(n,r):null,o=i?`${s}
4
- ${i}
5
- more`:null,[c,u]=d.useState(()=>({key:o,...Vt(o)})),[j,f]=d.useState(!1),[N,b]=d.useState(null),x=d.useRef(!1),g=l.loadedAt;d.useEffect(()=>{b(null);const A=Vt(o);u(A.base!=null&&A.base===g?{key:o,...A}:{key:o,items:[],next:void 0,base:g})},[o,g]);const h=c.next!==void 0?c.next:((k=l.data)==null?void 0:k.next)??null,p=d.useCallback(()=>{!n||!h||!o||!yt(x.current)||(x.current=!0,f(!0),b(null),$t(t,Ke(n,{...r,cursor:h})).then(A=>{u(C=>{const y={key:o,items:[...C.items,...A.items],next:A.next,base:C.base??g};return ft(o,{data:y,loadedAt:Date.now(),error:null}),y})},A=>b(xs(A))).finally(()=>{x.current=!1,f(!1)}))},[t,n,h,o,r,g]),v=l.data?{items:[...l.data.items,...c.key===o?c.items:[]],next:h,total:l.data.total}:null;return{...l,data:v,loadingMore:j,moreError:N,loadMore:p,reload:l.reload}}function Vt(t){const s=t?We(t).data:null;return s?{items:s.items,next:s.next,base:s.base}:{items:[],next:void 0,base:null}}const bs=d.createContext(null);function yr({value:t,children:s}){return e.jsx(bs.Provider,{value:t,children:s})}function U(){const t=d.useContext(bs);if(!t)throw new Error("useForge outside a forge panel");return t}function Qe(t,s){if(!t||t.type!==s.type||t.repo!==s.repo)return!1;switch(s.type){case"change":case"issue":return t.number===s.number;case"branch":return t.name===s.name;case"pipeline":return t.id===s.id}}function te({mark:t,quiet:s=!1,className:n}){return e.jsxs("span",{className:n?`fg-mark ${n}`:"fg-mark","data-tone":t.tone,title:t.word,children:[e.jsx("span",{"aria-hidden":"true",children:t.mark}),e.jsx("span",{className:s?"fg-sr":"fg-mark-word",children:t.word})]})}function ke({mark:t}){return e.jsxs("span",{className:"fg-badge","data-tone":t.tone,children:[e.jsx("span",{"aria-hidden":"true",children:t.mark})," ",t.word]})}function ye({id:t,title:s,count:n,defaultOpen:r,children:a,aside:l}){const{isOpen:i,toggle:o}=U(),c=i(t)?!r:r;return e.jsxs("section",{className:"fg-group","data-open":c||void 0,children:[e.jsxs("h3",{className:"fg-group-head",children:[e.jsxs("button",{type:"button",className:"fg-fold","aria-expanded":c,onClick:()=>o(t),children:[e.jsx("span",{className:"fg-fold-chevron","aria-hidden":"true"}),s,n!=null&&e.jsx("span",{className:"fg-count",children:n.toLocaleString()})]}),l]}),c&&a]})}function K({error:t,onRetry:s,compact:n=!1}){const{kind:r,onReconnect:a}=U(),l=hr(r,t);return e.jsxs("div",{className:n?"fg-failure fg-failure-compact":"fg-failure",role:"alert",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[n?"Showing the last answer. ":"",l.title,"."]})," ",l.detail]}),l.action==="connection"?e.jsx("button",{type:"button",className:"btn",onClick:a,children:"Open connection settings"}):e.jsx("button",{type:"button",className:"btn",onClick:s,children:"Try again"})]})}function Ne({pages:t,label:s="Load more"}){var n;return t.moreError?e.jsx(K,{error:t.moreError,onRetry:t.loadMore,compact:!0}):(n=t.data)!=null&&n.next?e.jsx("button",{type:"button",className:"btn fg-more",onClick:t.loadMore,...kt(t.loadingMore),children:t.loadingMore?"Loading…":s}):null}function he({rows:t=6,label:s}){return e.jsx("div",{className:"fg-loading",role:"status","aria-label":s,children:Array.from({length:t},(n,r)=>e.jsx("i",{},r))})}const Xt=new Set;function je({user:t,size:s=20,nameless:n=!1}){const{asset:r}=U(),[a,l]=d.useState(!1);if(!t)return null;const i=t.name||t.login,o=t.avatarUrl,c=o&&!a&&!Xt.has(o)?r(o):null;return e.jsxs("span",{className:"fg-person",title:n?i:void 0,children:[c?e.jsx("img",{className:"fg-avatar",src:c,alt:"",width:s,height:s,referrerPolicy:"no-referrer",onError:()=>{Xt.add(o),l(!0)}}):e.jsx("span",{className:"fg-avatar fg-avatar-initial",style:{width:s,height:s},"aria-hidden":"true",children:i.slice(0,1).toUpperCase()}),n?e.jsx("span",{className:"fg-sr",children:i}):e.jsx("span",{className:"fg-person-name",children:i})]})}function Z({at:t}){const[,s]=d.useState(0);return d.useEffect(()=>{const n=window.setInterval(()=>s(r=>r+1),3e4);return()=>window.clearInterval(n)},[]),t==null?null:e.jsx("time",{dateTime:new Date(t).toISOString(),title:new Date(t).toLocaleString(),children:Gs(Date.now()-t)})}function we({value:t,label:s,children:n}){const[r,a]=d.useState(!1);return d.useEffect(()=>{if(!r)return;const l=window.setTimeout(()=>a(!1),1500);return()=>window.clearTimeout(l)},[r]),e.jsxs("span",{className:"fg-copyable",children:[n??e.jsx("code",{children:t}),e.jsx("button",{type:"button",className:"fg-copy","aria-label":r?`${s} copied`:`Copy ${s}`,title:r?"Copied":`Copy ${s}`,onClick:l=>{l.stopPropagation(),ns(t).then(i=>a(!!i))},children:e.jsx("span",{"aria-hidden":"true",children:r?"✓":"⧉"})})]})}function ve({href:t,children:s}){const{kind:n}=U();return t?e.jsxs("a",{className:"fg-open",href:t,target:"_blank",rel:"noreferrer noopener",children:[s??`Open in ${n==="github"?"GitHub":"GitLab"}`," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):null}function St(t){const s=H[t].repo.toLowerCase();return s.endsWith("y")?`${s.slice(0,-1)}ies`:`${s}s`}function Ns(t){return`All ${St(t)}`}function ys(t){const s=t.lastIndexOf("/");return s<0?{group:"",name:t}:{group:t.slice(0,s+1),name:t.slice(s+1)}}function ks(t,s,n){return n?s.key:`${t}${s.number}`}const kr=/^\s*(?:\[(?:draft|wip)\]|\((?:draft|wip)\)|(?:draft|wip)\s*:)\s*/i;function wr(t,s){return s&&t.replace(kr,"")||t}function vr(t){return t.state==="merged"&&t.mergedAt!=null?{verb:"merged",at:t.mergedAt}:t.state==="closed"&&t.closedAt!=null?{verb:"closed",at:t.closedAt}:{verb:"updated",at:t.updatedAt}}function $r(t){return t.state!=="closed"?null:t.stateReason==="not_planned"?{mark:"⊘",word:"Not planned",tone:"idle"}:t.stateReason==="duplicate"?{mark:"⊘",word:"Duplicate",tone:"idle"}:null}function Sr(t){const s=t.findIndex(n=>n.isDefault);return s<=0?t:[t[s],...t.slice(0,s),...t.slice(s+1)]}function Cr(t){return t==null||!Number.isFinite(t)||t<0?null:t.toLocaleString("en-US")}function Ar(t){return typeof t=="string"&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)?t:null}function Rr(t,s,n){if(t==null||s==null)return null;const r=n?`“${n}”`:"the default branch",a=l=>l>=1e3?"999+":String(l);return`${a(t)} ${t===1?"commit":"commits"} behind, ${a(s)} ahead of ${r}`}function Lr(t,s){const n=s.name.split("/").map(encodeURIComponent).join("/"),r=t==="gitlab"?"/-/tree/":"/tree/";for(const a of new Set([n,s.name])){const l=`${r}${a}`;if(!s.webUrl.endsWith(l))continue;const i=s.webUrl.slice(0,-l.length);if(!/^https?:\/\/[^/]+\/\S+$/.test(i))break;return t==="gitlab"?`${i}/-/merge_requests/new?merge_request%5Bsource_branch%5D=${encodeURIComponent(s.name)}`:`${i}/compare/${n}?expand=1`}return s.webUrl}function Er(t,s){if(!s)return{workflow:null,title:null};if(t!=="github")return{workflow:null,title:s};const n=s.indexOf(" · ");return n>0&&n<s.length-3?{workflow:s.slice(0,n),title:s.slice(n+3)}:{workflow:null,title:s}}const Mr={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 Tr(t){return t?Mr[t]??t.replace(/_/g," "):null}function Ze(t,s,n){return t.data==null?t.error?"failed":"loading":s===0?"empty":n===0?"no-match":"rows"}function Re(t,s){return`No ${t} match “${s.trim()}”.`}function et(t,s){return s!=null&&s>t?`Load more · ${t.toLocaleString("en-US")} of ${s.toLocaleString("en-US")}`:"Load more"}function Dr(t,s){const n=H[t].changes.toLowerCase(),r=s.acrossRepos?"":` in this ${H[t].repo.toLowerCase()}`;return s.filter==="mine"?`You have no ${s.state} ${n}${r}.`:s.filter==="review"?s.state==="open"?`Nothing is waiting for your review${r}.`:`No ${s.state} ${n} asked for your review${r}.`:`No ${s.state} ${n}${r}.`}function Fr(t,s){const n=`${H[t].pipeline.toLowerCase()}s`;return s?`No ${n} in your most recently active ${St(t)}.`:`No ${n} in this ${H[t].repo.toLowerCase()} yet.`}function Ir(t,s,n){const r=H[t].repo.toLowerCase();if(t==="github")return`This ${r} has no ${s} issues.`;const a=n?"":` in this ${r}`;return s==="open"?`No open issues are assigned to you${a}.`:`No closed issues were assigned to you${a}.`}function tt(t,s){const{loadedAt:n,loading:r,stale:a}=s;d.useEffect(()=>{t({loadedAt:n,loading:r,stale:a})},[t,n,r,a])}function Pr({value:t,allowAll:s,onChange:n}){const{kind:r}=U(),a=d.useId(),[l,i]=d.useState(!1),o=d.useRef(null),c=H[r].repo,u=t??(s?Ns(r):`Choose a ${c.toLowerCase()}`),j=t?ys(t):null,f=d.useCallback(()=>{var N;i(!1),(N=o.current)==null||N.focus({preventScroll:!0})},[]);return e.jsxs("span",{className:"fgl-repo",id:`${a}-layer`,children:[e.jsxs("button",{ref:o,id:`${a}-trigger`,type:"button",className:"btn fgl-repo-trigger","aria-label":`${c}: ${u}`,"aria-haspopup":"dialog","aria-expanded":l,title:t??void 0,onClick:()=>i(N=>!N),onKeyDown:N=>{(N.key==="ArrowDown"||N.key==="ArrowUp")&&(N.preventDefault(),i(!0))},children:[e.jsx(Ur,{}),j?e.jsxs("span",{className:"fgl-repo-path",children:[e.jsx("span",{className:"fgl-repo-group",children:j.group}),e.jsx("span",{className:"fgl-repo-name",children:j.name})]}):e.jsx("span",{className:"fgl-repo-all",children:u}),e.jsx(_r,{})]}),l&&e.jsx(rs,{anchorId:`${a}-layer`,portalRootId:`${a}-layer`,id:`${a}-popup`,className:"fgl-repo-pop",role:"dialog",labelledBy:`${a}-trigger`,onClose:f,children:e.jsx(Or,{value:t,allowAll:s,onPick:N=>{n(N),f()},onEscape:f})})]})}function Or({value:t,allowAll:s,onPick:n,onEscape:r}){var oe;const{kind:a,api:l,scope:i,refresh:o}=U(),c=d.useId(),[u,j]=d.useState(""),[f,N]=d.useState(""),b=d.useRef(null),x=d.useRef(null),g=St(a);d.useEffect(()=>{const M=window.setTimeout(()=>N(u.trim()),250);return()=>window.clearTimeout(M)},[u]);const h=be(l,i,"repos",{search:f||void 0},o),p=(oe=h.data)==null?void 0:oe.items,v=d.useMemo(()=>{const M=[];s&&!f&&M.push({value:null,repo:null}),t&&!f&&p&&!p.some(S=>S.path===t)&&M.push({value:t,repo:null});for(const S of p??[])M.push({value:S.path,repo:S});return M},[s,f,t,p]),[k,A]=d.useState(0),C=p!=null;d.useEffect(()=>{A(Math.max(0,v.findIndex(M=>M.value===t)))},[f,C]);const y=Math.min(k,v.length-1);d.useEffect(()=>{var M;(M=b.current)==null||M.focus({preventScroll:!0})},[]),d.useEffect(()=>{var M,S;(S=(M=x.current)==null?void 0:M.querySelector('[data-active="true"]'))==null||S.scrollIntoView({block:"nearest"})},[y,v.length]);const I=M=>{const S=v.length;M.key==="ArrowDown"||M.key==="ArrowUp"?(M.preventDefault(),S&&A((Math.max(0,y)+(M.key==="ArrowDown"?1:-1)+S)%S)):M.key==="Home"||M.key==="End"?(M.preventDefault(),A(M.key==="Home"?0:Math.max(0,S-1))):M.key==="Enter"&&y>=0&&v[y]&&(M.preventDefault(),n(v[y].value))},Q=u.trim()!==f,V=p==null?h.error?"failed":"loading":v.length?"rows":"empty";return e.jsxs("div",{className:"fgl-repo-body",onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),r())},children:[e.jsxs("label",{className:"fgl-repo-search",children:[e.jsxs("span",{className:"fg-sr",children:["Search ",g]}),e.jsx(Hr,{}),e.jsx("input",{ref:b,className:"ap-manage-input",role:"combobox",placeholder:`Search ${g}…`,autoComplete:"off",spellCheck:!1,value:u,"aria-expanded":v.length>0,"aria-autocomplete":"list","aria-controls":`${c}-options`,"aria-activedescendant":V==="rows"&&y>=0?`${c}-option-${y}`:void 0,"aria-busy":Q||h.loading,onChange:M=>j(M.target.value),onKeyDown:I})]}),e.jsxs("div",{ref:x,className:"fgl-repo-scroll",children:[h.error&&p&&e.jsx(K,{error:h.error,onRetry:h.reload,compact:!0}),V==="loading"&&e.jsx(he,{rows:4,label:`Loading ${g}`}),V==="failed"&&h.error&&e.jsx(K,{error:h.error,onRetry:h.reload}),V==="empty"&&e.jsx("p",{className:"fgl-repo-none",role:"status",children:f?`No ${g} match “${f}”.`:`This token can see no ${g}.`}),e.jsx("div",{id:`${c}-options`,className:"fgl-repo-options",role:"listbox","aria-label":H[a].repo,hidden:V!=="rows",children:V==="rows"&&v.map((M,S)=>e.jsx(Br,{id:`${c}-option-${S}`,option:M,selected:M.value===t,active:S===y,onHover:()=>{S!==y&&A(S)},onPick:()=>n(M.value)},M.value??"(all)"))}),h.data&&e.jsx(Ne,{pages:h,label:`More ${g}`})]})]})}function Br({id:t,option:s,selected:n,active:r,onHover:a,onPick:l}){var c,u;const{kind:i}=U(),o=s.value?ys(s.value):null;return e.jsxs("button",{id:t,type:"button",role:"option",tabIndex:-1,className:"fgl-repo-option","aria-selected":n,"data-active":r,onPointerMove:a,onClick:l,children:[e.jsx("span",{className:"fgl-repo-option-text",children:o?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fgl-repo-option-name",children:o.name}),o.group&&e.jsx("span",{className:"fgl-repo-option-group",children:o.group.slice(0,-1)})]}):e.jsx("span",{className:"fgl-repo-option-name",children:Ns(i)})}),((c=s.repo)==null?void 0:c.archived)&&e.jsx("span",{className:"fg-badge",children:"archived"}),((u=s.repo)==null?void 0:u.lastActivityAt)!=null&&e.jsx("span",{className:"fgl-repo-option-when",children:e.jsx(Z,{at:s.repo.lastActivityAt})}),e.jsx("span",{className:"fgl-repo-check","aria-hidden":"true",children:n&&e.jsx(Wr,{})})]})}function Ur(){return e.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:[e.jsx("path",{d:"M3.5 2.5h8a1 1 0 0 1 1 1v8.5h-8.5a1 1 0 0 0-1 1z"}),e.jsx("path",{d:"M3.5 13a1 1 0 0 0 1 1h8v-2"}),e.jsx("path",{d:"M6 5.5h4"})]})}function _r(){return e.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:e.jsx("path",{d:"M2.5 4l2.5 2.5L7.5 4"})})}function Hr(){return e.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:[e.jsx("circle",{cx:"7",cy:"7",r:"4.5"}),e.jsx("path",{d:"M10.5 10.5L14 14"})]})}function Wr(){return e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5l3 3 6-7"})})}function qr({view:t,query:s}){var g;const{kind:n,api:r,scope:a,refresh:l,reportFreshness:i}=U(),o=t.repo??"",c=be(r,a,o?"branches":null,{repo:o},l);tt(i,c);const u=d.useMemo(()=>{var h;return((h=c.data)==null?void 0:h.items)??[]},[c.data]),j=d.useMemo(()=>u.filter(h=>Ye({name:h.name},s)),[u,s]),f=d.useMemo(()=>pr(Sr(j)),[j]),N=((g=u.find(h=>h.isDefault))==null?void 0:g.name)??null,b=Ze(c,u.length,j.length),x=h=>e.jsx("ul",{className:"fg-rows",children:h.map(p=>e.jsx(Gr,{kind:n,repo:o,branch:p,defaultBranch:N},p.name))});return e.jsxs("div",{className:"fgl",children:[c.error&&c.data&&e.jsx(K,{error:c.error,onRetry:c.reload,compact:!0}),b==="loading"&&e.jsx(he,{label:"Loading branches"}),b==="failed"&&c.error&&e.jsx(K,{error:c.error,onRetry:c.reload}),b==="empty"&&e.jsxs("p",{className:"fg-empty",children:["This ",H[n].repo.toLowerCase()," has no branches."]}),b==="no-match"&&e.jsx("p",{className:"fg-empty",children:Re("branches",s)}),b==="rows"&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{id:"branches-active",title:"Active branches",count:f.active.length,defaultOpen:!0,children:f.active.length?x(f.active):e.jsx("p",{className:"fgl-group-empty",children:s.trim()?Re("active branches",s):"Every branch loaded so far is stale."})}),f.stale.length>0&&e.jsx(ye,{id:"branches-stale",title:"Stale branches",count:f.stale.length,defaultOpen:!1,aside:e.jsx("span",{className:"fgl-group-note",children:"No commits in 90 days"}),children:x(f.stale)})]}),c.data&&e.jsx(Ne,{pages:c,label:et(u.length,c.data.total)})]})}function Gr({kind:t,repo:s,branch:n,defaultBranch:r}){const{selected:a,select:l}=U(),i=H[t],o=n.change?{type:"change",repo:s,number:n.change.number}:{type:"branch",repo:s,name:n.name},c=Qe(a,o),u=n.isDefault?null:Rr(n.behind,n.ahead,r),j=n.change?`${i.changeSigil}${n.change.number}`:null,f=n.change?Xe(n.change):null;return e.jsxs("li",{className:"fgl-branch","data-selected":c||void 0,children:[e.jsx("button",{type:"button",className:"fgl-hit","aria-current":c||void 0,"aria-label":n.change?`${n.name}, ${i.change.toLowerCase()} ${j}`:n.name,onClick:()=>l(o)}),e.jsxs("span",{className:"fgl-branch-name",children:[e.jsx(we,{value:n.name,label:"branch name",children:e.jsx("code",{className:"fgl-branch-code",children:n.name})}),n.isDefault&&e.jsx("span",{className:"fg-badge",children:"default"}),n.protected&&e.jsx("span",{className:"fg-badge",children:"protected"})]}),e.jsxs("span",{className:"fg-meta fgl-commit",children:[e.jsx("code",{children:n.commit.shortSha}),e.jsx("span",{className:"fgl-dot","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"fgl-commit-title",children:n.commit.title}),n.commit.committedAt!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fgl-dot","aria-hidden":"true",children:"·"}),e.jsx(Z,{at:n.commit.committedAt})]})]}),e.jsxs("span",{className:"fgl-stats","data-empty":!u&&!n.ci||void 0,children:[e.jsx("span",{className:"fgl-diverge","data-empty":!u||void 0,children:u&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fgl-behind","aria-hidden":"true",children:ze(n.behind)}),e.jsx("span",{className:"fgl-diverge-rule","aria-hidden":"true"}),e.jsx("span",{"aria-hidden":"true",children:ze(n.ahead)}),e.jsx("span",{className:"fg-sr",children:u})]})}),e.jsx("span",{className:"fgl-ci",children:n.ci&&e.jsx(te,{mark:ue(n.ci.state)})})]}),e.jsx("span",{className:"fgl-branch-change",children:f&&j?e.jsxs("span",{className:"fg-badge","data-tone":f.tone,title:`${i.change} ${j}: ${f.word}`,children:[e.jsx("span",{"aria-hidden":"true",children:f.mark})," ",e.jsx("code",{children:j})," ",f.word]}):!n.isDefault&&e.jsxs("a",{className:"fg-open fgl-create",href:Lr(t,n),target:"_blank",rel:"noreferrer noopener",children:["Create ",i.change.toLowerCase()," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})})]})}const Kr=[{state:"open",label:"Open"},{state:"merged",label:"Merged"},{state:"closed",label:"Closed"}],zr=[{filter:"all",label:"All"},{filter:"mine",label:"Mine"},{filter:"review",label:"Review requests"}],Jr={mark:"◌",word:"Draft",tone:"idle"},Vr=Xe({state:"open",draft:!1,approved:!0});function Xr({view:t,setView:s,query:n}){const{kind:r,api:a,scope:l,refresh:i,reportFreshness:o}=U(),c=H[r],u=t.repo??void 0,j=t.repo==null,f=be(a,l,"changes",{repo:u,filter:t.filter,state:t.state,sort:t.sort},i),N=pe(a,l,"change-counts",{repo:u,filter:t.filter},i);tt(o,f);const b=d.useMemo(()=>{var k;return((k=f.data)==null?void 0:k.items)??[]},[f.data]),x=d.useMemo(()=>b.filter(k=>Ye({key:k.key,title:k.title,name:k.sourceBranch,number:k.number},n)),[b,n]),g=Ze(f,b.length,x.length),h=t.filter==="review"&&t.state==="open"?fr(x):null,p=c.changes.toLowerCase(),v=k=>e.jsx("ul",{className:"fg-rows",children:k.map(A=>e.jsx(Qr,{kind:r,change:A,acrossRepos:j},A.key))});return e.jsxs("div",{className:"fgl",children:[e.jsxs("div",{className:"fgl-controls",children:[e.jsx("div",{className:"uh-range fgl-seg",role:"group","aria-label":`${c.changes} by state`,children:Kr.map(({state:k,label:A})=>{var y;const C=Cr((y=N.data)==null?void 0:y[k]);return e.jsxs("button",{type:"button",className:"uh-range-btn","aria-pressed":t.state===k,onClick:()=>s({state:k}),children:[A,C&&e.jsx("span",{className:"fgl-seg-count",children:C})]},k)})}),e.jsx("div",{className:"uh-range fgl-seg",role:"group","aria-label":`Which ${p}`,children:zr.map(({filter:k,label:A})=>e.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":t.filter===k,onClick:()=>s({filter:k}),children:A},k))}),e.jsx(Yr,{sort:t.sort,onChange:k=>s({sort:k})})]}),f.error&&f.data&&e.jsx(K,{error:f.error,onRetry:f.reload,compact:!0}),g==="loading"&&e.jsx(he,{label:`Loading ${p}`}),g==="failed"&&f.error&&e.jsx(K,{error:f.error,onRetry:f.reload}),g==="empty"&&e.jsx("p",{className:"fg-empty",children:Dr(r,{state:t.state,filter:t.filter,acrossRepos:j})}),g==="no-match"&&e.jsx("p",{className:"fg-empty",children:Re(p,n)}),g==="rows"&&(h?e.jsxs(e.Fragment,{children:[e.jsx(ye,{id:"reviews-waiting",title:"Waiting for my review",count:h.waiting.length,defaultOpen:!0,children:h.waiting.length?v(h.waiting):e.jsx("p",{className:"fgl-group-empty",children:n.trim()?Re(`${p} waiting for you`,n):"Nothing loaded is waiting for you; you approved every one."})}),h.approved.length>0&&e.jsx(ye,{id:"reviews-approved",title:"Approved by me",count:h.approved.length,defaultOpen:!1,children:v(h.approved)})]}):e.jsx("div",{className:"fgl-flat",children:v(x)})),f.data&&e.jsx(Ne,{pages:f,label:et(b.length,f.data.total)})]})}function Yr({sort:t,onChange:s}){const n=t==="created"?"updated":"created";return e.jsxs("button",{type:"button",className:"btn fgl-sort",title:`Newest ${t} first. Sort by ${n} instead.`,"aria-label":`Sorted by ${t==="created"?"date created":"last updated"}, newest first. Sort by ${n==="created"?"date created":"last updated"} instead.`,onClick:()=>s(n),children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M2 3h8M3.5 6h5M5 9h2"})}),t==="created"?"Created":"Updated"]})}function Qr({kind:t,change:s,acrossRepos:n}){const{selected:r,select:a}=U(),l={type:"change",repo:s.repo,number:s.number},i=Qe(r,l),o=vr(s),c=s.author?s.author.name||s.author.login:null;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"fg-row fgl-row","data-selected":i||void 0,"aria-current":i||void 0,onClick:()=>a(l),children:[e.jsxs("span",{className:"fg-row-title fgl-title",children:[s.draft&&e.jsx(ke,{mark:Jr}),e.jsx("span",{className:"fgl-title-text",children:wr(s.title,s.draft)}),e.jsx($s,{labels:s.labels})]}),e.jsxs("span",{className:"fgl-side",children:[s.ci&&e.jsx(te,{mark:ue(s.ci.state)}),s.state==="open"&&s.approved&&e.jsx(ke,{mark:Vr}),e.jsx(Zr,{reviewers:s.reviewers}),e.jsx(vs,{count:s.comments})]}),e.jsxs("span",{className:"fg-meta fgl-meta",children:[e.jsx("code",{children:ks(H[t].changeSigil,s,n)}),s.createdAt!=null&&e.jsxs(e.Fragment,{children:[" · created ",e.jsx(Z,{at:s.createdAt})]}),c&&e.jsxs(e.Fragment,{children:[" by ",c]})]}),e.jsx("span",{className:"fgl-when",children:o.at!=null&&e.jsxs(e.Fragment,{children:[o.verb," ",e.jsx(Z,{at:o.at})]})})]})})}function Zr({reviewers:t}){return t.length?e.jsxs("span",{className:"fgl-people",children:[e.jsx("span",{className:"fg-sr",children:t.length===1?"Reviewer: ":"Reviewers: "}),t.slice(0,3).map((s,n)=>{const r=gs(s.state);return e.jsxs("span",{className:"fgl-reviewer","data-tone":r.tone,title:`${s.name||s.login}: ${r.word}`,children:[n>0&&e.jsx("span",{className:"fg-sr",children:"; "}),e.jsx(je,{user:s,size:20,nameless:!0}),s.state!=="pending"&&e.jsx("span",{className:"fgl-reviewer-mark","aria-hidden":"true",children:r.mark}),e.jsxs("span",{className:"fg-sr",children:[", ",r.word]})]},s.login)}),e.jsx(ws,{count:t.length-3})]}):null}function ea({users:t,label:s}){return t.length?e.jsxs("span",{className:"fgl-people",children:[e.jsxs("span",{className:"fg-sr",children:[s,": "]}),t.slice(0,3).map((n,r)=>e.jsxs(d.Fragment,{children:[r>0&&e.jsx("span",{className:"fg-sr",children:", "}),e.jsx(je,{user:n,size:20,nameless:!0})]},n.login)),e.jsx(ws,{count:t.length-3})]}):null}function ws({count:t}){return t<=0?null:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"fgl-people-more","aria-hidden":"true",children:["+",t]}),e.jsxs("span",{className:"fg-sr",children:[" and ",t," more"]})]})}function vs({count:t}){return t?e.jsxs("span",{className:"fgl-comments",title:`${t} ${t===1?"comment":"comments"}`,children:[e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 3.5h11v7.5h-6l-3 2.5v-2.5h-2z"})}),t.toLocaleString("en-US"),e.jsxs("span",{className:"fg-sr",children:[" ",t===1?"comment":"comments"]})]}):null}function $s({labels:t}){return t.length?e.jsxs("span",{className:"fgl-labels",children:[t.slice(0,4).map(s=>{const n=Ar(s.color);return e.jsxs("span",{className:"fgl-label",title:s.name,children:[n&&e.jsx("i",{className:"fgl-label-dot",style:{background:n},"aria-hidden":"true"}),e.jsx("span",{className:"fgl-label-name",children:s.name})]},s.name)}),t.length>4&&e.jsxs("span",{className:"fgl-label",title:t.slice(4).map(s=>s.name).join(", "),children:["+",t.length-4]})]}):null}function ta({view:t,query:s}){const{kind:n,api:r,scope:a,refresh:l,reportFreshness:i}=U(),o=t.repo==null,c=be(r,a,"pipelines",{repo:t.repo??void 0},l);tt(i,c);const u=d.useMemo(()=>{var b;return((b=c.data)==null?void 0:b.items)??[]},[c.data]),j=d.useMemo(()=>u.filter(b=>Ye({title:b.title??"",name:b.ref,key:`${b.repo} ${b.shortSha}`},s)),[u,s]),f=Ze(c,u.length,j.length),N=`${H[n].pipeline.toLowerCase()}s`;return e.jsxs("div",{className:"fgl",children:[c.error&&c.data&&e.jsx(K,{error:c.error,onRetry:c.reload,compact:!0}),f==="loading"&&e.jsx(he,{label:`Loading ${N}`}),f==="failed"&&c.error&&e.jsx(K,{error:c.error,onRetry:c.reload}),f==="empty"&&e.jsx("p",{className:"fg-empty",children:Fr(n,o)}),f==="no-match"&&e.jsx("p",{className:"fg-empty",children:Re(N,s)}),f==="rows"&&e.jsx("div",{className:"fgl-flat",children:e.jsx("ul",{className:"fg-rows",children:j.map(b=>e.jsx(sa,{kind:n,pipeline:b,acrossRepos:o},`${b.repo}/${b.id}`))})}),c.data&&e.jsx(Ne,{pages:c,label:et(u.length,c.data.total)})]})}function sa({kind:t,pipeline:s,acrossRepos:n}){const{selected:r,select:a}=U(),l={type:"pipeline",repo:s.repo,id:s.id},i=Qe(r,l),{workflow:o,title:c}=Er(t,s.title),u=He(s.durationSec),j=Tr(s.source),f=s.state==="running"&&s.startedAt!=null&&s.finishedAt==null,N=s.finishedAt??s.createdAt,b=s.triggeredBy?s.triggeredBy.name||s.triggeredBy.login:null;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"fg-row fgl-row fgl-pipeline","data-selected":i||void 0,"aria-current":i||void 0,onClick:()=>a(l),children:[e.jsx("span",{className:"fgl-status",children:e.jsx(te,{mark:ue(s.state)})}),e.jsx("span",{className:"fgl-duration",children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fg-sr",children:"ran for "}),u]}):f&&e.jsxs(e.Fragment,{children:["started ",e.jsx(Z,{at:s.startedAt})]})}),e.jsx("span",{className:"fg-row-title fgl-title",children:e.jsx("span",{className:"fgl-title-text",children:c??`${H[t].pipeline} ${s.id}`})}),e.jsxs("span",{className:"fg-meta fgl-meta",children:[n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fgl-repo-ref",children:s.repo})," · "]}),e.jsx(na,{}),e.jsx("code",{children:s.ref}),s.shortSha&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{children:s.shortSha})]}),o&&e.jsxs(e.Fragment,{children:[" · ",o]}),j&&e.jsxs(e.Fragment,{children:[" · ",j]})]}),e.jsx("span",{className:"fgl-side",children:s.triggeredBy&&e.jsx("span",{title:b??void 0,children:e.jsx(je,{user:s.triggeredBy,size:20,nameless:!0})})}),e.jsx("span",{className:"fgl-when",children:N!=null&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"fgl-when-verb",children:[s.finishedAt!=null?"finished":"created"," "]}),e.jsx(Z,{at:N})]})})]})})}function na(){return e.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:[e.jsx("circle",{cx:"4.5",cy:"3.5",r:"1.5"}),e.jsx("circle",{cx:"4.5",cy:"12.5",r:"1.5"}),e.jsx("circle",{cx:"11.5",cy:"5.5",r:"1.5"}),e.jsx("path",{d:"M4.5 5v6M11.5 7c0 3-7 2-7 4"})]})}const ra=[{state:"open",label:"Open"},{state:"closed",label:"Closed"}];function aa({view:t,setView:s,query:n}){var g;const{kind:r,api:a,scope:l,refresh:i,reportFreshness:o,connection:c}=U(),u=t.repo==null,j=be(a,l,"issues",{repo:t.repo??void 0,state:t.issueState},i);tt(o,j);const f=d.useMemo(()=>{var h;return((h=j.data)==null?void 0:h.items)??[]},[j.data]),N=d.useMemo(()=>f.filter(h=>Ye({key:h.key,title:h.title,number:h.number},n)),[f,n]),b=Ze(j,f.length,N.length),x=r==="gitlab"?((g=c.account)==null?void 0:g.login)??null:null;return e.jsxs("div",{className:"fgl",children:[e.jsxs("div",{className:"fgl-controls",children:[e.jsx("div",{className:"uh-range fgl-seg",role:"group","aria-label":"Issues by state",children:ra.map(({state:h,label:p})=>e.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":t.issueState===h,onClick:()=>s({issueState:h}),children:p},h))}),r==="gitlab"&&e.jsx("span",{className:"fgl-controls-note",children:"Assigned to you"})]}),j.error&&j.data&&e.jsx(K,{error:j.error,onRetry:j.reload,compact:!0}),b==="loading"&&e.jsx(he,{label:"Loading issues"}),b==="failed"&&j.error&&e.jsx(K,{error:j.error,onRetry:j.reload}),b==="empty"&&e.jsx("p",{className:"fg-empty",children:Ir(r,t.issueState,u)}),b==="no-match"&&e.jsx("p",{className:"fg-empty",children:Re("issues",n)}),b==="rows"&&e.jsx("div",{className:"fgl-flat",children:e.jsx("ul",{className:"fg-rows",children:N.map(h=>e.jsx(la,{issue:h,acrossRepos:u,me:x},h.key))})}),j.data&&e.jsx(Ne,{pages:j,label:et(f.length,j.data.total)})]})}function la({issue:t,acrossRepos:s,me:n}){const{selected:r,select:a}=U(),l={type:"issue",repo:t.repo,number:t.number},i=Qe(r,l),o=t.author?t.author.name||t.author.login:null,c=n?t.assignees.filter(f=>f.login!==n):t.assignees,u=$r(t),j=t.state==="closed"&&t.closedAt!=null?t.closedAt:t.updatedAt;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"fg-row fgl-row","data-selected":i||void 0,"aria-current":i||void 0,onClick:()=>a(l),children:[e.jsxs("span",{className:"fg-row-title fgl-title",children:[u&&e.jsx(ke,{mark:u}),e.jsx("span",{className:"fgl-title-text",children:t.title}),e.jsx($s,{labels:t.labels})]}),e.jsxs("span",{className:"fgl-side",children:[t.children&&t.children.total>0&&e.jsxs("span",{className:"fgl-children",title:`${t.children.completed} of ${t.children.total} child items done`,children:[e.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:[e.jsx("rect",{x:"2.5",y:"2.5",width:"11",height:"11",rx:"2"}),e.jsx("path",{d:"M5.5 8.2l1.8 1.8 3.4-4"})]}),t.children.completed,"/",t.children.total,e.jsx("span",{className:"fg-sr",children:" child items done"})]}),e.jsx(ea,{users:c,label:"Assigned to"}),e.jsx(vs,{count:t.comments})]}),e.jsxs("span",{className:"fg-meta fgl-meta",children:[e.jsx("code",{children:ks("#",t,s)}),t.createdAt!=null&&e.jsxs(e.Fragment,{children:[" · opened ",e.jsx(Z,{at:t.createdAt})]}),o&&e.jsxs(e.Fragment,{children:[" by ",o]}),t.milestone&&e.jsxs(e.Fragment,{children:[" · ",t.milestone.title]})]}),e.jsx("span",{className:"fgl-when",children:j!=null&&e.jsxs(e.Fragment,{children:[t.state==="closed"&&t.closedAt!=null?"closed":"updated"," ",e.jsx(Z,{at:j})]})})]})})}function Ss(t,s,n){return`${s}${H[t].changeSigil}${n}`}function Cs(t){const s=/^refs\/(?:merge-requests|pull)\/(\d{1,12})\/(?:head|merge|train)$/.exec(t??"");return s?Number(s[1]):null}function As(t,s){const n=Cs(s);return n!=null?`${H[t].changeSigil}${n}`:s.replace(/^refs\/(?:heads|tags)\//,"")}function oa(t){const s=/\/(?:-\/pipelines|actions\/runs)\/(\d{1,15})(?:[/?#]|$)/.exec(t??"");return s?s[1]:null}function ia(t,s,n,r){const a=s.replace(/\/+$/,""),l=n.split("/").map(encodeURIComponent).join("/");return t==="github"?`${a}/${l}/compare/${r.split("/").map(encodeURIComponent).join("/")}?expand=1`:`${a}/${l}/-/merge_requests/new?${new URLSearchParams({"merge_request[source_branch]":r})}`}function ca(t,s){const n=t==="github";return[{id:"overview",label:n?"Conversation":"Overview",count:s.discussions},{id:"commits",label:"Commits",count:s.commits},{id:"pipelines",label:H[t].pipelines,count:s.pipelines},{id:"changes",label:n?"Files changed":"Changes",count:s.files}]}function da(t){return Xe({state:t.state,draft:t.draft,approved:!1})}const gt=/^\s*(?:\[draft\]|\(draft\)|draft:|\[wip\]|wip:)\s*/i;function ua(t){return t.replace(gt,"")||t}function ha(t){const s=t[0];if(!s||s.t!=="text"||!gt.test(s.text))return t;const n=s.text.replace(gt,"");return n?[{t:"text",text:n},...t.slice(1)]:t.slice(1)}function ma(t){return{id:`comment:${t.id}`,resolvable:!1,resolved:!1,path:null,line:null,outdated:!1,comments:[t],webUrl:t.webUrl}}const Yt=t=>{var s;return((s=t.comments[0])==null?void 0:s.createdAt)??Number.MAX_SAFE_INTEGER};function pa(t){const s=[],n=[],r=[];for(const a of t.threads)a.comments.length&&(a.resolvable?(a.resolved?n:s).push(a):r.push(a));for(const a of t.generalComments)r.push(ma(a));return r.sort((a,l)=>Yt(a)-Yt(l)),{unresolved:s,resolved:n,general:r}}function Rs(t){const s=t.lastIndexOf("/");return s<0?{dir:"",name:t}:{dir:t.slice(0,s+1),name:t.slice(s+1)}}function fa(t){return t.path?t.line!=null?`${t.path}:${t.line}`:t.path:null}function ga(t){return t.name||t.login}function ja(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function xa(t){return t.approvedBy.length?{mark:{mark:"✓",word:"approved",tone:"ok"},text:`Approved by ${ja(t.approvedBy.map(ga))}`}:t.approvalsLeft!=null&&t.approvalsLeft>0?{mark:{mark:"◌",word:"approval required",tone:"idle"},text:`Requires ${t.approvalsLeft} more approval${t.approvalsLeft===1?"":"s"}`}:null}function ba(t){switch(t){case"added":return"new";case"deleted":return"deleted";case"renamed":return"renamed";default:return null}}function Na(t){const s=t.lastIndexOf("::");return s>0&&s<t.length-2?{scope:t.slice(0,s),value:t.slice(s+2)}:{scope:null,value:t}}function ya(t){return t&&/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t:null}function ka(t,s){return t==="open"?{mark:"●",word:"Open",tone:"busy"}:s==="not_planned"?{mark:"⊘",word:"Closed · not planned",tone:"idle"}:s==="duplicate"?{mark:"⊘",word:"Closed · duplicate",tone:"idle"}:{mark:"✓",word:"Closed",tone:"idle"}}function wa(t){return t?{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"}[t]??t.replace(/_/g," "):null}function va(t){if(!t.length)return"none";const s=t.map(n=>n.state==="failed"&&n.allowFailure?"success":n.state);return s.includes("failed")?"failed":s.includes("running")?"running":s.includes("pending")?"pending":s.every(n=>n==="skipped")?"skipped":s.every(n=>n==="manual"||n==="skipped")?"manual":s.includes("canceled")?"canceled":"success"}function $a(t){const s=[],n=new Map;for(const r of t){const a=r.stage||null;n.has(a)||(n.set(a,[]),s.push(a)),n.get(a).push(r)}return s.map(r=>{const a=n.get(r);return{name:r,jobs:a,state:va(a)}})}const Sa=8;function Ca(t,s){return t.state==="failed"||s<=Sa}function Aa(t){return t.state==="failed"&&!t.allowFailure}function Ra(t){switch(t){case"failure":return{mark:"✕",word:"failure",tone:"bad"};case"warning":return{mark:"!",word:"warning",tone:"busy"};default:return{mark:"i",word:"notice",tone:"idle"}}}const jt=[80,200,500];function La(t){return t==null?jt[0]:jt.find(s=>s>t)??null}function Ea(t){return/^\s*(?:::error\b|error\b|fatal\b|ERROR:|FAILED\b|✕|×)/i.test(t)||/\bJob failed\b/.test(t)?"err":/^\s*(?:::warning\b|warning\b|warn\b)/i.test(t)?"warn":null}function Ma(t){const s={};for(const[n,r]of Object.entries(t))n==="colspan"?s.colSpan=Number(r):n==="rowspan"?s.rowSpan=Number(r):n==="start"?s.start=Number(r):n==="open"?s.open=!0:n==="align"?s.style={textAlign:r.toLowerCase()}:s[n]=r;return s}function Ta({node:t}){const[s,n]=d.useState(!1),r=t.alt.trim()||"image";return!t.src||s?e.jsxs("a",{className:"fh-image-link",href:t.href,target:"_blank",rel:"noreferrer noopener",children:[r," ↗"]}):e.jsx("a",{className:"fh-image",href:t.href,target:"_blank",rel:"noreferrer noopener",children:e.jsx("img",{src:t.src,alt:t.alt,width:t.width??void 0,height:t.height??void 0,loading:"lazy",referrerPolicy:"no-referrer",onError:()=>n(!0)})})}function Be(t){return t.map((s,n)=>{switch(s.t){case"text":return s.text;case"link":return e.jsx("a",{href:s.href,title:s.title??void 0,target:"_blank",rel:"noreferrer noopener",children:Be(s.kids)},n);case"img":return e.jsx(Ta,{node:s},n);case"check":return e.jsx("input",{type:"checkbox",className:"fh-check",checked:s.checked,disabled:!0,readOnly:!0},n);case"el":{const r=s.tag;return s.tag==="hr"||s.tag==="br"?e.jsx(r,{},n):e.jsx(r,{...Ma(s.attrs),children:Be(s.kids)},n)}}})}function Ct({nodes:t,className:s}){return e.jsx("div",{className:s?`forge-html ${s}`:"forge-html",children:Be(t)})}const Da=1,Fa=3,Ia={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:[]},Pa={code:[],em:[],strong:[],b:[],i:[],u:[],s:[],del:[],ins:[],mark:[],sup:[],sub:[],kbd:[],small:[],abbr:["title"],q:[],cite:[]},Oa=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"]),Ba=new Set(["http:","https:","mailto:"]),Qt=new Set(["http:","https:"]),Ls=2048,Ua=48;function dt(t,s,n){const r=(t??"").trim();if(!r||r.length>Ls)return null;let a;try{a=new URL(r,new URL(s).origin+"/")}catch{return null}return n.has(a.protocol)?a.toString():null}function de(t,s){var r;const n=(r=t.getAttribute)==null?void 0:r.call(t,s);return typeof n=="string"?n:null}function Zt(t){const s=Number(t);return Number.isInteger(s)&&s>0&&s<1e4?s:null}function _a(t,s){const n={left:s.maxNodes??5e3,cut:!1},r=xt(t,s,n,0);return n.cut&&r.push({t:"text",text:" …"}),r}function xt(t,s,n,r){const a=[],l=t.childNodes;for(let i=0;i<l.length;i++){if(n.left<=0){n.cut=!0;break}a.push(...Ha(l[i],s,n,r))}return a}function Ha(t,s,n,r){var c,u,j,f;if(n.left--,t.nodeType===Fa)return t.nodeValue?[{t:"text",text:t.nodeValue}]:[];if(t.nodeType!==Da)return[];const a=t.nodeName.toLowerCase();if(Oa.has(a))return[];if(r>=Ua)return xt(t,s,n,r);const l=()=>xt(t,s,n,r+1);if(a==="a"){const N=dt(de(t,"href"),s.baseUrl,Ba);return!N||(c=de(t,"href"))!=null&&c.trim().startsWith("#")?l():[{t:"link",href:N,title:((u=de(t,"title"))==null?void 0:u.slice(0,300))??null,kids:l()}]}if(a==="img"){const N=dt(de(t,"data-src")??de(t,"src"),s.baseUrl,Qt);if(!N)return[];const b=(de(t,"alt")??"").slice(0,300);return s.inline?[{t:"text",text:b}]:[{t:"img",src:s.asset(N),href:N,alt:b,width:Zt(de(t,"width")),height:Zt(de(t,"height"))}]}if(a==="video"||a==="audio"){const N=dt(de(t,"data-src")??de(t,"src"),s.baseUrl,Qt);return N&&!s.inline?[{t:"link",href:N,title:null,kids:[{t:"text",text:`${a} ↗`}]}]:[]}if(a==="input")return((j=de(t,"type"))==null?void 0:j.toLowerCase())==="checkbox"&&!s.inline?[{t:"check",checked:((f=t.getAttribute)==null?void 0:f.call(t,"checked"))!=null}]:[];const i=Pa[a]??(s.inline?void 0:Ia[a]);if(!i)return l();const o={};for(const N of i){const b=de(t,N);b!=null&&b.length<=Ls&&(o[N]=b)}o.start!=null&&!/^\d{1,6}$/.test(o.start)&&delete o.start;for(const N of["colspan","rowspan"])o[N]!=null&&!/^\d{1,3}$/.test(o[N])&&delete o[N];return o.align!=null&&!/^(?:left|right|center)$/i.test(o.align)&&delete o.align,[{t:"el",tag:a,attrs:o,kids:l()}]}function Wa(t,s){if(!t)return[];const n=new DOMParser().parseFromString(t,"text/html");return _a(n.body,s)}function qa(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}function Es({dir:t}){if(!t)return null;const s=t.split("/").slice(0,-1);return e.jsx("span",{className:"fd-path-dir",children:s.map((n,r)=>e.jsxs("span",{children:[n,"/",e.jsx("wbr",{})]},r))})}function st({label:t,children:s}){const n=d.useRef(null);return d.useLayoutEffect(()=>{var a;const r=(a=n.current)==null?void 0:a.closest(".ig-detail");r&&(r.scrollTop=0)},[]),e.jsx("article",{ref:n,className:"fd","aria-label":t,tabIndex:-1,children:s})}function nt({reference:t,copyValue:s,copyLabel:n,href:r}){const{select:a,narrow:l}=U();return e.jsxs("div",{className:"fd-bar",children:[e.jsx("span",{className:"fd-ref",children:e.jsx(we,{value:s??t,label:n,children:e.jsx("code",{children:t})})}),e.jsxs("span",{className:"fd-bar-end",children:[e.jsx(ve,{href:r}),!l&&e.jsx("button",{type:"button",className:"glyph-btn fd-close","aria-label":"Close details",title:"Close",onClick:()=>a(null),children:e.jsx(qa,{})})]})]})}function rt({data:t,loading:s,error:n,onRetry:r,what:a}){return t?null:(n==null?void 0:n.kind)==="not-found"?e.jsxs("p",{className:"fg-empty",children:["This ",a," no longer exists, or this token cannot see it."]}):n?e.jsx(K,{error:n,onRetry:r}):s?e.jsx(he,{rows:5,label:`Loading the ${a}`}):null}function Ue(t,s=!1){const{connection:n,asset:r}=U();return d.useMemo(()=>t?Wa(t,{baseUrl:n.baseUrl,asset:r,inline:s}):[],[t,s,n.baseUrl,r])}function ge({label:t,children:s}){return e.jsxs("div",{className:"fd-fact",children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ms({label:t,children:s}){return e.jsx("aside",{className:"fd-side","aria-label":t,children:e.jsx("dl",{className:"fd-facts",children:s})})}function bt({users:t,extra:s}){return t.length?e.jsx("ul",{className:"fd-people",children:t.map(n=>e.jsxs("li",{children:[e.jsx(je,{user:n,size:20}),s==null?void 0:s(n)]},n.login))}):e.jsx("span",{className:"fd-none",children:"None"})}function Ga({users:t,max:s=12}){if(!t.length)return e.jsx("span",{className:"fd-none",children:"None"});const n=t.slice(0,s);return e.jsxs("ul",{className:"fd-faces",children:[n.map(r=>e.jsx("li",{children:e.jsx(je,{user:r,size:22,nameless:!0})},r.login)),t.length>s&&e.jsxs("li",{className:"fd-faces-more",children:["+",t.length-s]})]})}function Ka({label:t}){const s=ya(t.color),{scope:n,value:r}=Na(t.name);return e.jsxs("span",{className:"fd-label",title:t.name,children:[e.jsx("span",{className:"fd-swatch",style:s?{backgroundColor:s}:void 0,"aria-hidden":"true"}),n&&e.jsx("span",{className:"fd-label-scope",children:n}),e.jsx("span",{className:"fd-label-value",children:r})]})}function Ts({labels:t}){return t.length?e.jsx("span",{className:"fd-labels",children:t.map(s=>e.jsx(Ka,{label:s},s.name))}):e.jsx("span",{className:"fd-none",children:"None"})}function Nt({commit:t}){return e.jsxs("li",{className:"fd-item",children:[t.webUrl?e.jsxs("a",{className:"fd-item-title fd-out",href:t.webUrl,target:"_blank",rel:"noreferrer noopener",children:[t.title,e.jsx("span",{className:"fd-out-mark","aria-hidden":"true",children:" ↗"})]}):e.jsx("span",{className:"fd-item-title",children:t.title}),e.jsxs("span",{className:"fd-item-meta",children:[e.jsx(we,{value:t.sha,label:"commit sha",children:e.jsx("code",{children:t.shortSha})}),t.authorName&&e.jsx("span",{children:t.authorName}),t.authoredAt!=null&&e.jsx(Z,{at:t.authoredAt})]})]})}function _e({children:t,count:s,aside:n}){return e.jsxs("h3",{className:"fd-heading",children:[e.jsx("span",{children:t}),s!=null&&e.jsx("span",{className:"fg-count",children:s.toLocaleString()}),n]})}function za({title:t,count:s,startsOpen:n,aside:r,children:a}){const[l,i]=d.useState(n);return e.jsxs("section",{className:"fg-group fd-fold","data-open":l||void 0,children:[e.jsxs("h3",{className:"fg-group-head fd-fold-head",children:[e.jsxs("button",{type:"button",className:"fg-fold","aria-expanded":l,onClick:()=>i(o=>!o),children:[e.jsx("span",{className:"fg-fold-chevron","aria-hidden":"true"}),t,s!=null&&e.jsx("span",{className:"fg-count",children:s.toLocaleString()})]}),r]}),l&&a]})}function es(t){return`Open this comment in ${H[t].name}`}function Ds({comment:t}){const{kind:s}=U(),n=Ue(t.bodyHtml);return e.jsxs("li",{className:"fd-comment",children:[e.jsxs("div",{className:"fd-comment-head",children:[t.author?e.jsx(je,{user:t.author,size:20}):e.jsx("span",{className:"fd-none",children:"Someone"}),t.createdAt!=null&&e.jsx("span",{className:"fd-comment-time",children:e.jsx(Z,{at:t.createdAt})}),t.webUrl&&e.jsx("a",{className:"fd-comment-link",href:t.webUrl,target:"_blank",rel:"noreferrer noopener","aria-label":es(s),title:es(s),children:e.jsx("span",{"aria-hidden":"true",children:"↗"})})]}),n.length?e.jsx(Ct,{className:"fd-comment-body",nodes:n}):e.jsx("p",{className:"fd-comment-body fd-none",children:"No text."})]})}function Ja({thread:t}){const s=t.path?Rs(t.path):null;return e.jsxs("li",{className:"fd-thread",children:[s&&e.jsxs("div",{className:"fd-thread-head",children:[e.jsxs("code",{className:"fd-path",title:fa(t)??void 0,children:[e.jsx(Es,{dir:s.dir}),e.jsxs("span",{className:"fd-path-name",children:[s.name,t.line!=null&&e.jsxs("span",{className:"fd-path-line",children:[":",t.line]})]})]}),t.outdated&&e.jsx("span",{className:"fg-badge fd-outdated",children:"outdated"})]}),e.jsx("ol",{className:"fd-comments",children:t.comments.map(n=>e.jsx(Ds,{comment:n},n.id))})]})}function ut({threads:t}){return e.jsx("ol",{className:"fd-threads",children:t.map(s=>e.jsx(Ja,{thread:s},s.id))})}function Va({selection:t}){const{kind:s,api:n,scope:r,refresh:a}=U(),l=H[s],i={repo:t.repo,number:t.number},o=pe(n,r,"change",i,a),c=o.data,u=!!c&&(c.ci!=null||c.counts.pipelines>0),j=pe(n,r,u?"change/pipelines":null,i,a),[f,N]=d.useState("overview"),b=(c==null?void 0:c.key)??Ss(s,t.repo,t.number),x=d.useId(),g=v=>`${x}-tab-${v}`,h=v=>`${x}-panel-${v}`,p=c?ca(s,c.counts):[];return e.jsxs(st,{label:`${l.change} ${b}`,children:[e.jsx(nt,{reference:b,copyLabel:"reference",href:(c==null?void 0:c.webUrl)??null}),e.jsx(rt,{data:c,loading:o.loading,error:o.error,onRetry:o.reload,what:l.change.toLowerCase()}),c&&e.jsxs(e.Fragment,{children:[o.error&&e.jsx(K,{error:o.error,onRetry:o.reload,compact:!0}),e.jsx(Xa,{change:c,pipelines:j.data}),e.jsxs("div",{className:"fd-layout",children:[e.jsx(Ya,{change:c}),e.jsxs("div",{className:"fd-main",children:[e.jsx("div",{className:"uh-range fd-sections",role:"tablist","aria-label":`${l.change} sections`,onKeyDown:v=>{var A;const k=as(v,p.findIndex(C=>C.id===f),p.length);k.kind!=="pass"&&(v.preventDefault(),v.stopPropagation(),N(p[k.index].id),(A=v.currentTarget.querySelectorAll("[role=tab]")[k.index])==null||A.focus())},children:p.map(v=>e.jsxs("button",{id:g(v.id),type:"button",role:"tab",className:"uh-range-btn","aria-selected":f===v.id,"aria-controls":h(v.id),tabIndex:f===v.id?0:-1,onClick:()=>N(v.id),children:[e.jsx("span",{className:"fd-section-label",children:v.label}),e.jsx("span",{className:"fd-section-count",children:v.count.toLocaleString()})]},v.id))}),p.map(v=>e.jsx("div",{className:"fd-section",id:h(v.id),role:"tabpanel","aria-labelledby":g(v.id),hidden:f!==v.id,children:f!==v.id?null:v.id==="overview"?e.jsx(Qa,{change:c}):v.id==="commits"?e.jsx(Za,{selection:t}):v.id==="pipelines"?e.jsx(el,{repo:t.repo,read:j}):e.jsx(tl,{selection:t})},v.id))]})]})]})]})}function Xa({change:t,pipelines:s}){var N,b,x;const{kind:n,select:r}=U(),a=H[n],l=t.state==="open"&&t.draft,i=Ue(t.titleHtml,!0),o=i.length?Be(l?ha(i):i):l?ua(t.title):t.title,c=(s==null?void 0:s[0])??null,u=oa((N=t.ci)==null?void 0:N.webUrl)??(c==null?void 0:c.id)??null,j=((b=t.ci)==null?void 0:b.state)??(c==null?void 0:c.state)??null,f=xa(t);return e.jsxs("header",{className:"fd-head",children:[e.jsx("h2",{className:"fd-title",children:o}),e.jsxs("p",{className:"fd-byline",children:[e.jsx(ke,{mark:da(t)}),t.author&&e.jsx(je,{user:t.author,size:18}),e.jsx("span",{children:"requested to merge"}),e.jsx(we,{value:t.sourceBranch,label:"source branch",children:e.jsx("code",{className:"fd-branch",children:t.sourceBranch})}),e.jsx("span",{children:"into"}),e.jsx("code",{className:"fd-branch",children:t.targetBranch}),t.createdAt!=null&&e.jsxs("span",{className:"fd-when",children:["· created ",e.jsx(Z,{at:t.createdAt})]}),t.state==="merged"&&t.mergedAt!=null&&e.jsxs("span",{className:"fd-when",children:["· merged ",e.jsx(Z,{at:t.mergedAt})]}),t.state==="closed"&&t.closedAt!=null&&e.jsxs("span",{className:"fd-when",children:["· closed ",e.jsx(Z,{at:t.closedAt})]})]}),(j||f)&&e.jsxs("ul",{className:"fd-status",children:[j&&e.jsx("li",{children:u?e.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>r({type:"pipeline",repo:t.repo,id:u}),children:[e.jsx(te,{mark:ue(j)}),e.jsxs("span",{children:[a.pipeline," ",e.jsxs("code",{children:["#",u]})]}),e.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]}):e.jsxs("span",{className:"fd-status-line",children:[e.jsx(te,{mark:ue(j)}),e.jsx(ve,{href:((x=t.ci)==null?void 0:x.webUrl)??null,children:"Checks"})]})}),f&&e.jsxs("li",{className:"fd-status-line",children:[e.jsx(te,{mark:f.mark,quiet:!0}),e.jsx("span",{children:f.text})]})]})]})}function Ya({change:t}){return e.jsxs(Ms,{label:"About this change",children:[e.jsx(ge,{label:t.assignees.length>1?"Assignees":"Assignee",children:e.jsx(bt,{users:t.assignees})}),e.jsx(ge,{label:t.reviewers.length>1?"Reviewers":"Reviewer",children:e.jsx(bt,{users:t.reviewers,extra:s=>e.jsx(te,{className:"fd-review",mark:gs(s.state)})})}),t.labels.length>0&&e.jsx(ge,{label:"Labels",children:e.jsx(Ts,{labels:t.labels})}),t.milestone&&e.jsx(ge,{label:"Milestone",children:t.milestone.webUrl?e.jsx("a",{className:"fd-plain-link",href:t.milestone.webUrl,target:"_blank",rel:"noreferrer noopener",children:t.milestone.title}):t.milestone.title}),t.participants.length>0&&e.jsx(ge,{label:`Participants · ${t.participants.length}`,children:e.jsx(Ga,{users:t.participants})})]})}function Qa({change:t}){const s=Ue(t.descriptionHtml),{unresolved:n,resolved:r,general:a}=pa(t),l=!n.length&&!r.length&&!a.length;return e.jsxs(e.Fragment,{children:[s.length?e.jsx(Ct,{className:"fd-description",nodes:s}):e.jsx("p",{className:"fd-none fd-description",children:"No description."}),e.jsxs("div",{className:"fd-discussions",children:[l&&e.jsx("p",{className:"fg-empty",children:"No discussions yet."}),n.length>0&&e.jsx(ye,{id:"change:unresolved",title:"Unresolved threads",count:n.length,defaultOpen:!0,children:e.jsx(ut,{threads:n})}),!n.length&&r.length>0&&e.jsx("p",{className:"fd-status-line fd-all-resolved",children:e.jsx(te,{mark:{mark:"✓",word:"All threads resolved",tone:"ok"}})}),r.length>0&&e.jsx(ye,{id:"change:resolved",title:"Resolved threads",count:r.length,defaultOpen:!1,children:e.jsx(ut,{threads:r})}),a.length>0&&e.jsx(ye,{id:"change:general",title:"General comments",count:a.length,defaultOpen:!1,children:e.jsx(ut,{threads:a})})]})]})}function Za({selection:t}){const{api:s,scope:n,refresh:r}=U(),a=be(s,n,"change/commits",{repo:t.repo,number:t.number},r);return a.data?e.jsxs(e.Fragment,{children:[a.error&&e.jsx(K,{error:a.error,onRetry:a.reload,compact:!0}),a.data.items.length?e.jsx("ul",{className:"fd-items",children:a.data.items.map(l=>e.jsx(Nt,{commit:l},l.sha))}):e.jsx("p",{className:"fg-empty",children:"No commits."}),e.jsx(Ne,{pages:a,label:"Load more commits"})]}):a.error?e.jsx(K,{error:a.error,onRetry:a.reload}):e.jsx(he,{rows:4,label:"Loading commits"})}function el({repo:t,read:s}){const{kind:n,select:r,selected:a}=U(),l=H[n];return s.data?s.data.length?e.jsxs(e.Fragment,{children:[s.error&&e.jsx(K,{error:s.error,onRetry:s.reload,compact:!0}),e.jsx("ul",{className:"fg-rows fd-rows",children:s.data.map(i=>{const o=(a==null?void 0:a.type)==="pipeline"&&a.id===i.id,c=He(i.durationSec);return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"fg-row fd-pipe-row","aria-current":o||void 0,"data-selected":o||void 0,onClick:()=>r({type:"pipeline",repo:t,id:i.id}),children:[e.jsx(te,{mark:ue(i.state)}),e.jsx("span",{className:"fd-pipe-id",children:e.jsxs("code",{children:["#",i.id]})}),e.jsxs("span",{className:"fd-pipe-meta",children:[e.jsx("code",{className:"fd-branch",title:i.ref,children:As(n,i.ref)}),e.jsx("code",{children:i.shortSha}),i.title&&e.jsx("span",{className:"fd-pipe-title",children:i.title})]}),e.jsxs("span",{className:"fd-pipe-when",children:[c&&e.jsx("span",{children:c}),i.createdAt!=null&&e.jsx(Z,{at:i.createdAt})]})]})},i.id)})})]}):e.jsxs("p",{className:"fg-empty",children:["No ",l.pipelines.toLowerCase()," ran for this ",l.change.toLowerCase(),"."]}):s.error?e.jsx(K,{error:s.error,onRetry:s.reload}):s.loading?e.jsx(he,{rows:3,label:`Loading ${l.pipelines.toLowerCase()}`}):e.jsxs("p",{className:"fg-empty",children:["No ",l.pipelines.toLowerCase()," ran for this ",l.change.toLowerCase(),"."]})}function tl({selection:t}){const{api:s,scope:n,refresh:r}=U(),a=be(s,n,"change/files",{repo:t.repo,number:t.number},r);return a.data?e.jsxs(e.Fragment,{children:[a.error&&e.jsx(K,{error:a.error,onRetry:a.reload,compact:!0}),a.data.items.length?e.jsx("ul",{className:"fd-files",children:a.data.items.map(l=>e.jsx(sl,{file:l},`${l.oldPath??""}>${l.path}`))}):e.jsx("p",{className:"fg-empty",children:"No changed files."}),e.jsx(Ne,{pages:a,label:"Load more files"})]}):a.error?e.jsx(K,{error:a.error,onRetry:a.reload}):e.jsx(he,{rows:5,label:"Loading changed files"})}function sl({file:t}){const s=ba(t.status),{dir:n,name:r}=Rs(t.path),a=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"fd-file-path",children:[t.oldPath&&t.oldPath!==t.path&&e.jsxs("span",{className:"fd-file-old",children:[e.jsx("code",{children:t.oldPath})," ",e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("span",{className:"fd-sr",children:" renamed to"})," "]}),e.jsxs("code",{children:[e.jsx(Es,{dir:n}),e.jsx("span",{className:"fd-path-name",children:r})]})]}),e.jsxs("span",{className:"fd-file-end",children:[s&&e.jsx("span",{className:"fd-file-status","data-status":t.status,children:s}),e.jsxs("span",{className:"fd-diffstat",title:`${t.additions} added, ${t.deletions} removed`,children:[e.jsxs("span",{className:"fd-add","data-zero":t.additions===0||void 0,children:["+",t.additions.toLocaleString()]}),e.jsxs("span",{className:"fd-del","data-zero":t.deletions===0||void 0,children:["−",t.deletions.toLocaleString()]})]}),t.webUrl&&e.jsx("span",{className:"fd-out-mark","aria-hidden":"true",children:"↗"})]})]});return e.jsx("li",{children:t.webUrl?e.jsx("a",{className:"fd-file",href:t.webUrl,target:"_blank",rel:"noreferrer noopener",children:a}):e.jsx("span",{className:"fd-file",children:a})})}const ts=10;function nl({selection:t}){const{kind:s,api:n,scope:r,refresh:a}=U(),l=pe(n,r,"branch",{repo:t.repo,name:t.name},a),i=l.data;return e.jsxs(st,{label:`Branch ${t.name}`,children:[e.jsx(nt,{reference:t.repo,copyLabel:H[s].repo.toLowerCase(),href:(i==null?void 0:i.branch.webUrl)??null}),e.jsx(rt,{data:i,loading:l.loading,error:l.error,onRetry:l.reload,what:"branch"}),i&&e.jsxs(e.Fragment,{children:[l.error&&e.jsx(K,{error:l.error,onRetry:l.reload,compact:!0}),e.jsx(rl,{repo:t.repo,detail:i})]})]})}function rl({repo:t,detail:s}){var p,v;const{kind:n,api:r,scope:a,refresh:l,connection:i,select:o}=U(),c=H[n],u=s.branch,f=((v=(p=pe(r,a,u.isDefault?null:"repos",{},l).data)==null?void 0:p.items.find(k=>k.path===t))==null?void 0:v.defaultBranch)??null,[N,b]=d.useState(!1),x=s.pipeline,g=x?He(x.durationSec):null,h=N?s.commitsAhead:s.commitsAhead.slice(0,ts);return e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"fd-head",children:[e.jsx("h2",{className:"fd-title fd-title-mono",children:e.jsx(we,{value:u.name,label:"branch name",children:e.jsx("code",{children:u.name})})}),(u.isDefault||u.protected||u.stale)&&e.jsxs("p",{className:"fd-byline",children:[u.isDefault&&e.jsx("span",{className:"fg-badge",children:"default"}),u.protected&&e.jsx("span",{className:"fg-badge",children:"protected"}),u.stale&&e.jsx("span",{className:"fg-badge",children:"stale"})]})]}),e.jsxs("dl",{className:"fd-facts fd-facts-page",children:[e.jsxs("div",{className:"fd-fact",children:[e.jsx("dt",{children:"Latest commit"}),e.jsx("dd",{children:e.jsx("ul",{className:"fd-items fd-items-bare",children:e.jsx(Nt,{commit:{...u.commit,authoredAt:u.commit.committedAt}})})})]}),!u.isDefault&&e.jsxs("div",{className:"fd-fact",children:[e.jsxs("dt",{children:["Compared with ",f??"the default branch"]}),e.jsxs("dd",{className:"fd-diverge",children:[e.jsxs("span",{children:[e.jsx("strong",{children:ze(u.behind)})," behind"]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("span",{children:[e.jsx("strong",{children:ze(u.ahead)})," ahead"]})]})]}),e.jsxs("div",{className:"fd-fact",children:[e.jsx("dt",{children:c.pipeline}),e.jsx("dd",{children:x?e.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>o({type:"pipeline",repo:t,id:x.id}),children:[e.jsx(te,{mark:ue(x.state)}),e.jsx("span",{children:e.jsxs("code",{children:["#",x.id]})}),g&&e.jsx("span",{className:"fd-jump-meta",children:g}),x.createdAt!=null&&e.jsx("span",{className:"fd-jump-meta",children:e.jsx(Z,{at:x.createdAt})}),e.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]}):u.ci?e.jsxs("span",{className:"fd-status-line",children:[e.jsx(te,{mark:ue(u.ci.state)}),e.jsx(ve,{href:u.ci.webUrl})]}):e.jsx(te,{mark:ue("none")})})]}),!u.isDefault&&e.jsxs("div",{className:"fd-fact",children:[e.jsx("dt",{children:c.change}),e.jsx("dd",{children:u.change?e.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>o({type:"change",repo:t,number:u.change.number}),children:[e.jsx(ke,{mark:Xe(u.change)}),e.jsx("span",{children:e.jsxs("code",{children:[c.changeSigil,u.change.number]})}),e.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]}):e.jsxs(ve,{href:ia(n,i.baseUrl,t,u.name),children:["Create ",c.change.toLowerCase()]})})]})]}),!u.isDefault&&e.jsxs("section",{className:"fd-block",children:[e.jsxs(_e,{count:u.ahead??s.commitsAhead.length,children:["Commits not in ",f??"the default branch"]}),s.commitsAhead.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"fd-items",children:h.map(k=>e.jsx(Nt,{commit:k},k.sha))}),!N&&s.commitsAhead.length>ts&&e.jsxs("button",{type:"button",className:"btn fg-more",onClick:()=>b(!0),children:["Show all ",s.commitsAhead.length.toLocaleString()]})]}):e.jsx("p",{className:"fg-empty",children:u.ahead===0?`Every commit here is already in ${f??"the default branch"}.`:"The forge listed none."})]})]})}function al({repo:t,jobs:s}){const n=$a(s);return s.length?n.length===1&&n[0].name==null?e.jsx(ss,{repo:t,jobs:s}):e.jsx("div",{className:"fd-stages",children:n.map(r=>e.jsx(za,{title:r.name??"Other jobs",count:r.jobs.length,startsOpen:Ca(r,s.length),aside:e.jsx(te,{mark:ue(r.state)}),children:e.jsx(ss,{repo:t,jobs:r.jobs})},r.name??""))}):e.jsx("p",{className:"fg-empty",children:"This pipeline has no jobs."})}function ss({repo:t,jobs:s}){return e.jsx("ul",{className:"fd-jobs",children:s.map(n=>e.jsx(ll,{repo:t,job:n},n.id))})}function ll({repo:t,job:s}){const[n,r]=d.useState(()=>Aa(s)),a=He(s.durationSec),l=`fd-job-${s.id}`;return e.jsxs("li",{className:"fd-job","data-open":n||void 0,children:[e.jsxs("button",{type:"button",className:"fg-row fd-job-row","aria-expanded":n,"aria-controls":l,onClick:()=>r(i=>!i),children:[e.jsx("span",{className:"fg-fold-chevron","aria-hidden":"true"}),e.jsx(te,{mark:ue(s.state)}),e.jsx("span",{className:"fd-job-name",children:s.name}),s.allowFailure&&s.state==="failed"&&e.jsx("span",{className:"fd-job-note",children:"allowed to fail"}),a&&e.jsx("span",{className:"fd-job-time",children:a})]}),n&&e.jsxs("div",{className:"fd-job-body",id:l,children:[s.failureReason&&e.jsx("p",{className:"fd-job-reason",children:s.failureReason}),s.annotations.length>0&&e.jsx("ul",{className:"fd-annotations",children:s.annotations.map((i,o)=>e.jsxs("li",{children:[e.jsx(te,{mark:Ra(i.level)}),i.path&&e.jsx("code",{className:"fd-ann-place",children:i.line!=null?`${i.path}:${i.line}`:i.path}),i.title&&e.jsx("strong",{className:"fd-ann-title",children:i.title}),e.jsx("span",{className:"fd-ann-message",children:i.message})]},o))}),s.logAvailable?e.jsx(ol,{repo:t,job:s}):e.jsx("p",{className:"fd-log-bar",children:e.jsx(ve,{href:s.webUrl,children:"Open the job"})})]})]})}function ol({repo:t,job:s}){const{api:n,scope:r,refresh:a}=U(),[l,i]=d.useState(null),o=pe(n,r,l?"job-log":null,{repo:t,id:s.id,lines:l},a),c=d.useRef(null);o.data&&(c.current=o.data);const u=o.data??(l?c.current:null),j=d.useRef(null),f=d.useRef(0);d.useLayoutEffect(()=>{const h=j.current;h&&(h.scrollTop=h.scrollHeight-h.clientHeight-f.current),f.current=0},[u]);const N=d.useRef(!1);d.useEffect(()=>{N.current=o.loading},[o.loading,u,o.error]);const b=La(l),x=()=>{if(!yt(N.current))return;N.current=!0;const h=j.current;f.current=h?h.scrollHeight-h.clientHeight-h.scrollTop:0,i(b)},g=(u==null?void 0:u.webUrl)??s.webUrl;return l?e.jsxs("div",{className:"fd-log-wrap",children:[e.jsxs("p",{className:"fd-log-bar",children:[e.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)&&b&&e.jsx("button",{type:"button",className:"btn",onClick:x,...kt(o.loading),children:o.loading?"Loading…":"Show more lines"}),e.jsx(ve,{href:g,children:"Full log"})]}),o.error&&(u?e.jsx(K,{error:o.error,onRetry:o.reload,compact:!0}):e.jsx(K,{error:o.error,onRetry:o.reload})),!u&&!o.error&&e.jsx(he,{rows:3,label:"Loading the log"}),u&&(u.lines.length?e.jsx("pre",{ref:j,className:"fd-log",children:u.lines.map((h,p)=>{const v=Ea(h);return e.jsx("span",{className:"fd-log-line","data-tone":v??void 0,children:h||" "},p)})}):e.jsx("p",{className:"fd-none",children:"The log is empty."}))]}):e.jsxs("p",{className:"fd-log-bar",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>i(jt[0]),children:"Show log"}),e.jsx(ve,{href:g,children:"Full log"})]})}function il({selection:t}){const{kind:s,api:n,scope:r,refresh:a}=U(),l=H[s],i=pe(n,r,"pipeline",{repo:t.repo,id:t.id},a),o=i.data;return e.jsxs(st,{label:`${l.pipeline} #${t.id}`,children:[e.jsx(nt,{reference:`${t.repo} #${t.id}`,copyValue:t.id,copyLabel:`${l.pipeline.toLowerCase()} id`,href:(o==null?void 0:o.webUrl)??null}),e.jsx(rt,{data:o,loading:i.loading,error:i.error,onRetry:i.reload,what:l.pipeline.toLowerCase()}),o&&e.jsxs(e.Fragment,{children:[i.error&&e.jsx(K,{error:i.error,onRetry:i.reload,compact:!0}),e.jsx(cl,{pipeline:o}),e.jsxs("section",{className:"fd-block",children:[e.jsx(_e,{count:o.jobs.length,children:"Jobs"}),e.jsx(al,{repo:o.repo,jobs:o.jobs})]})]})]})}function cl({pipeline:t}){const{kind:s,select:n}=U(),r=H[s],a=Cs(t.ref),l=He(t.durationSec),i=wa(t.source);return e.jsxs("header",{className:"fd-head",children:[e.jsx("h2",{className:"fd-title",children:t.title||`${r.pipeline} #${t.id}`}),e.jsxs("p",{className:"fd-byline",children:[e.jsx(ke,{mark:ue(t.state)}),t.triggeredBy&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Started by"}),e.jsx(je,{user:t.triggeredBy,size:18})]}),i&&e.jsxs("span",{className:"fd-when",children:["· ",i]}),t.createdAt!=null&&e.jsxs("span",{className:"fd-when",children:["· created ",e.jsx(Z,{at:t.createdAt})]}),l?e.jsxs("span",{className:"fd-when",children:["· took ",l]}):t.state==="running"&&t.startedAt!=null&&e.jsxs("span",{className:"fd-when",children:["· started ",e.jsx(Z,{at:t.startedAt})]})]}),e.jsxs("ul",{className:"fd-status",children:[e.jsxs("li",{className:"fd-status-line",children:[e.jsx("span",{className:"fd-status-key",children:"Ran on"}),e.jsx(we,{value:t.ref,label:"ref",children:e.jsx("code",{className:"fd-branch",title:t.ref,children:As(s,t.ref)})}),e.jsx(we,{value:t.sha,label:"commit sha",children:e.jsx("code",{children:t.shortSha})})]}),a!=null&&e.jsx("li",{children:e.jsxs("button",{type:"button",className:"fd-jump",onClick:()=>n({type:"change",repo:t.repo,number:a}),children:[e.jsx(te,{mark:{mark:"⇄",word:r.change,tone:"idle"},quiet:!0}),e.jsxs("span",{children:[r.change," ",e.jsx("code",{children:Ss(s,"",a)})]}),e.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]})})]})]})}function dl({selection:t}){const{api:s,scope:n,refresh:r}=U(),a=pe(s,n,"issue",{repo:t.repo,number:t.number},r),l=a.data,i=(l==null?void 0:l.key)??`${t.repo}#${t.number}`;return e.jsxs(st,{label:`Issue ${i}`,children:[e.jsx(nt,{reference:i,copyLabel:"reference",href:(l==null?void 0:l.webUrl)??null}),e.jsx(rt,{data:l,loading:a.loading,error:a.error,onRetry:a.reload,what:"issue"}),l&&e.jsxs(e.Fragment,{children:[a.error&&e.jsx(K,{error:a.error,onRetry:a.reload,compact:!0}),e.jsx(ul,{selection:t,issue:l})]})]})}function ul({selection:t,issue:s}){const{select:n}=U(),r=Ue(s.titleHtml,!0),a=Ue(s.descriptionHtml);return e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"fd-head",children:[e.jsx("h2",{className:"fd-title",children:r.length?Be(r):s.title}),e.jsxs("p",{className:"fd-byline",children:[e.jsx(ke,{mark:ka(s.state,s.stateReason)}),e.jsxs("span",{children:[e.jsxs("code",{children:["#",s.number]})," opened"]}),s.createdAt!=null&&e.jsx(Z,{at:s.createdAt}),s.author&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"by"}),e.jsx(je,{user:s.author,size:18})]}),s.state==="closed"&&s.closedAt!=null&&e.jsxs("span",{className:"fd-when",children:["· closed ",e.jsx(Z,{at:s.closedAt})]})]})]}),e.jsxs("div",{className:"fd-layout",children:[e.jsxs(Ms,{label:"About this issue",children:[e.jsx(ge,{label:s.assignees.length>1?"Assignees":"Assignee",children:e.jsx(bt,{users:s.assignees})}),s.labels.length>0&&e.jsx(ge,{label:"Labels",children:e.jsx(Ts,{labels:s.labels})}),s.milestone&&e.jsx(ge,{label:"Milestone",children:s.milestone.webUrl?e.jsx("a",{className:"fd-plain-link",href:s.milestone.webUrl,target:"_blank",rel:"noreferrer noopener",children:s.milestone.title}):s.milestone.title}),s.parent&&e.jsx(ge,{label:"Parent",children:e.jsx(ml,{item:s.parent,onOpen:()=>n({type:"issue",repo:s.parent.repo,number:s.parent.number})})})]}),e.jsxs("div",{className:"fd-main",children:[a.length?e.jsx(Ct,{className:"fd-description",nodes:a}):e.jsx("p",{className:"fd-none fd-description",children:"No description."}),s.childItems.length>0&&e.jsxs("section",{className:"fd-block",children:[e.jsx(_e,{count:s.childItems.length,aside:s.children&&e.jsxs("span",{className:"fd-progress",children:[s.children.completed," of ",s.children.total," done"]}),children:"Child items"}),e.jsx("ul",{className:"fg-rows fd-rows",children:s.childItems.map(l=>e.jsx("li",{children:e.jsx(hl,{item:l,onOpen:()=>n({type:"issue",repo:l.repo,number:l.number})})},l.key))})]}),e.jsx(pl,{selection:t,count:s.comments})]})]})]})}function Fs(t){return t==="open"?{mark:"○",word:"open",tone:"busy"}:{mark:"✓",word:"closed",tone:"ok"}}function hl({item:t,onOpen:s}){const{selected:n}=U(),r=(n==null?void 0:n.type)==="issue"&&n.repo===t.repo&&n.number===t.number;return e.jsxs("button",{type:"button",className:"fg-row fd-child-row",onClick:s,"aria-current":r||void 0,"data-selected":r||void 0,children:[e.jsx(te,{mark:Fs(t.state)}),e.jsx("span",{className:"fd-child-title",children:t.title}),e.jsxs("span",{className:"fd-child-meta",children:[t.type&&e.jsx("span",{children:t.type}),e.jsxs("code",{children:["#",t.number]})]})]})}function ml({item:t,onOpen:s}){return e.jsxs("button",{type:"button",className:"fd-jump",onClick:s,children:[e.jsx(te,{mark:Fs(t.state),quiet:!0}),e.jsx("span",{className:"fd-jump-title",children:t.title}),e.jsx("span",{className:"fd-jump-arrow","aria-hidden":"true",children:"›"})]})}function pl({selection:t,count:s}){const[n,r]=d.useState(!1);return s?e.jsxs("section",{className:"fd-block",children:[e.jsx(_e,{count:s,children:"Comments"}),n?e.jsx(fl,{selection:t}):e.jsxs("button",{type:"button",className:"btn fd-show-comments",onClick:()=>r(!0),children:["Show ",s.toLocaleString()," comment",s===1?"":"s"]})]}):e.jsxs("section",{className:"fd-block",children:[e.jsx(_e,{count:0,children:"Comments"}),e.jsx("p",{className:"fd-none",children:"No comments."})]})}function fl({selection:t}){const{api:s,scope:n,refresh:r}=U(),a=be(s,n,"issue/comments",{repo:t.repo,number:t.number},r);return a.data?e.jsxs(e.Fragment,{children:[a.error&&e.jsx(K,{error:a.error,onRetry:a.reload,compact:!0}),a.data.items.length?e.jsx("ol",{className:"fd-threads fd-issue-comments",children:a.data.items.map(l=>e.jsx("li",{className:"fd-thread",children:e.jsx("ol",{className:"fd-comments",children:e.jsx(Ds,{comment:l})})},l.id))}):e.jsx("p",{className:"fd-none",children:"No comments."}),e.jsx(Ne,{pages:a,label:"Load more comments"})]}):a.error?e.jsx(K,{error:a.error,onRetry:a.reload}):e.jsx(he,{rows:3,label:"Loading comments"})}const Ie=["branches","changes","pipelines","issues"];function Is(t,s){switch(s){case"branches":return"Branches";case"changes":return H[t].changes;case"pipelines":return H[t].pipelines;case"issues":return"Issues"}}function gl(t,s){const n=Is(t,s);return`Back to ${n==="Actions"?n:n.toLowerCase()}`}function Ps({kind:t,connection:s,api:n,assetUrl:r,prefs:a,narrow:l,onReconnect:i,Split:o}){const c=`${t}:${s.id}`,[u,j]=d.useState(()=>zt(a)),[f,N]=d.useState(0),[b,x]=d.useState(null),[g,h]=d.useState(""),[p,v]=d.useState({loadedAt:null,loading:!1,stale:!1}),[k,A]=d.useState(!1),C=d.useRef(!1),[y,I]=d.useState(null),Q=d.useRef(null),V=d.useRef(null),oe=d.useId(),M=w=>`${oe}-tab-${w}`,S=w=>`${oe}-panel-${w}`;d.useEffect(()=>{j(zt(a)),x(null),h("")},[c,a]);const L=d.useCallback(w=>{j(O=>{const X={...O,...w};return Jt(a,X),X})},[a]),T=d.useCallback(w=>{j(O=>{const X=O.open.includes(w)?O.open.filter(le=>le!==w):[...O.open,w].slice(-20),ae={...O,open:X};return Jt(a,ae),ae})},[a]),E=d.useCallback(w=>{const O=document.activeElement,X=O instanceof HTMLElement&&O.closest(".ig-list")!=null;w&&X&&(V.current=O),x(w);const ae=br(w!=null,X,l);requestAnimationFrame(()=>{var le,me,ie;ae==="opener"&&((le=V.current)!=null&&le.isConnected)?V.current.focus():ae==="page"&&((ie=(me=Q.current)==null?void 0:me.querySelector(".ig-detail .fd"))==null||ie.focus())})},[l]),D=b!=null,F=d.useRef(E);F.current=E,d.useEffect(()=>{if(!(!l||!D))return ht.push(()=>F.current(null),0,"popover")},[l,D]);const G=d.useMemo(()=>({kind:t,connection:s,scope:c,api:n,asset:w=>r(w),refresh:f,selected:b,select:E,isOpen:w=>u.open.includes(w),toggle:T,reportFreshness:v,onReconnect:i,narrow:l}),[t,s,c,n,r,f,b,E,u.open,T,i,l]),ne=Nr(t,u.tab),z=!ne&&!u.repo,re=pe(n,c,z?"repos":null,{},f);d.useEffect(()=>{var O;const w=(O=re.data)==null?void 0:O.items[0];z&&w&&L({repo:w.path})},[z,re.data,L]);const m=async()=>{if(yt(C.current)){C.current=!0,A(!0),I(null);try{const w=await $t(n,Ke("resolve",{q:g.trim()}));w?E(w.type==="change"?{type:"change",repo:w.repo,number:w.number}:{type:"issue",repo:w.repo,number:w.number}):I("Nothing to open at that address.")}catch(w){I(w instanceof Oe?w.info.message:"Could not open it.")}finally{C.current=!1,A(!1)}}},$=w=>{L({tab:w}),h("")},P=H[t],B={view:u,setView:L,query:g},_=p.loading?p.loadedAt?"Updating…":"Loading…":p.loadedAt?e.jsxs(e.Fragment,{children:[p.stale?"Not updated · last answer ":"Updated ",e.jsx(Z,{at:p.loadedAt})]}):null,J=e.jsxs("div",{className:"fg-list",children:[e.jsxs("div",{className:"fg-toolbar",children:[e.jsx(Pr,{value:u.repo,allowAll:ne,onChange:w=>L({repo:w})}),e.jsx("span",{className:"fg-fresh",role:"status","data-stale":p.stale||void 0,children:_}),e.jsx("button",{type:"button",className:"glyph-btn fg-refresh","aria-label":`Refresh ${P.name}`,title:"Refresh","data-loading":p.loading||void 0,"aria-busy":p.loading,onClick:()=>N(w=>w+1),children:e.jsx(Ks,{})})]}),e.jsx("div",{className:"uh-range fg-tabs",role:"tablist","aria-label":`${P.name} views`,onKeyDown:w=>{var X;const O=as(w,Ie.indexOf(u.tab),Ie.length);O.kind!=="pass"&&(w.preventDefault(),w.stopPropagation(),$(Ie[O.index]),(X=w.currentTarget.querySelectorAll("[role=tab]")[O.index])==null||X.focus())},children:Ie.map(w=>e.jsx("button",{id:M(w),type:"button",role:"tab",className:"uh-range-btn","aria-selected":u.tab===w,"aria-controls":S(w),tabIndex:u.tab===w?0:-1,onClick:()=>$(w),children:Is(t,w)},w))}),e.jsxs("div",{className:"fg-searchbar",children:[e.jsxs("label",{className:"fg-search",children:[e.jsx("span",{className:"fg-sr",children:"Search the list, or paste a link"}),e.jsx("input",{type:"search",placeholder:u.tab==="branches"?"Filter by branch name":`Search by title or number, or paste a ${P.name} link`,value:g,onChange:w=>{h(w.target.value),I(null)},onKeyDown:w=>{w.key==="Enter"&&Kt(g)&&m()}})]}),Kt(g)&&e.jsx("button",{type:"button",className:"btn fg-resolve",onClick:()=>void m(),...kt(k),children:k?"Opening…":"Open"})]}),y&&e.jsx("p",{className:"fg-note",role:"status",children:y}),Ie.map(w=>e.jsx("div",{className:"fg-tab-body",id:S(w),role:"tabpanel","aria-labelledby":M(w),hidden:u.tab!==w,children:u.tab!==w?null:z?re.error?e.jsx(K,{error:re.error,onRetry:re.reload}):re.data&&!re.data.items.length?e.jsxs("p",{className:"fg-empty",children:["This token can see no ",P.repo.toLowerCase()," yet."]}):e.jsxs("p",{className:"fg-note",children:["Finding your most recent ",P.repo.toLowerCase(),"…"]}):w==="branches"?e.jsx(qr,{...B}):w==="changes"?e.jsx(Xr,{...B}):w==="pipelines"?e.jsx(ta,{...B}):e.jsx(aa,{...B})},w))]}),W=b?b.type==="change"?e.jsx(Va,{selection:b},`${b.repo}!${b.number}`):b.type==="branch"?e.jsx(nl,{selection:b},`${b.repo}@${b.name}`):b.type==="pipeline"?e.jsx(il,{selection:b},`${b.repo}/p/${b.id}`):e.jsx(dl,{selection:b},`${b.repo}#${b.number}`):null;return e.jsx(yr,{value:G,children:e.jsx("div",{ref:Q,className:"fg-panel","data-kind":t,children:e.jsx(o,{list:J,detail:W,onBack:()=>E(null),backLabel:gl(t,u.tab),storageKey:t})})})}function jl(t){return e.jsx(Ps,{kind:"github",...t,Split:wt})}function xl(t){return e.jsx(Ps,{kind:"gitlab",...t,Split:wt})}const bl={jira:or,github:jl,gitlab:xl};function yl({kind:t,connections:s,onClose:n,onReconnect:r}){const a=tn(t),l=bl[t],i=d.useId(),o=os(),[c]=d.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),u=d.useCallback(()=>{n(),requestAnimationFrame(()=>{var A,C;const k=Array.from(document.querySelectorAll(`[data-rail-item="integration-${t}"], [data-rail-item="more"]`)).find(y=>{var I;return((I=y.checkVisibility)==null?void 0:I.call(y))??!0});(C=c&&c!==document.body&&c.isConnected&&(((A=c.checkVisibility)==null?void 0:A.call(c))??!0)?c:k)==null||C.focus({preventScroll:!0})})},[n,c,t]),j=zs(u),f=Js(u);Vs(t);const[N,b]=d.useState(()=>{var A;const k=Xs(t);return s.some(C=>C.id===k)?k:((A=s[0])==null?void 0:A.id)??""});d.useEffect(()=>{if(s.length===0){n();return}s.some(k=>k.id===N)||b(s[0].id)},[s,N,n]);const x=k=>{b(k),sn(t,k)},g=s.find(k=>k.id===N)??null,h=(g==null?void 0:g.id)??"",p=d.useMemo(()=>h?{api:Zs({kind:t,id:h}),assetUrl:Qs({kind:t,id:h}),prefs:Ys(t,h)}:null,[t,h]);if(!a||!l||!g||!p)return null;const{Glyph:v}=a;return en.createPortal(e.jsx("div",{className:"modal-backdrop",role:"presentation",...f,children:e.jsxs("div",{ref:j,id:`integration-${t}-modal`,className:"modal ig-modal",role:"dialog","aria-modal":"true","aria-labelledby":"integration-modal-title","data-kind":t,onClick:k=>k.stopPropagation(),children:[e.jsxs("header",{className:"ig-head",children:[e.jsxs("h2",{className:"ig-title",id:"integration-modal-title",children:[e.jsx("span",{className:"ig-title-glyph","aria-hidden":!0,children:e.jsx(v,{})}),a.label]}),s.length>1?e.jsxs("label",{className:"ig-conn-select",children:[e.jsx("span",{className:"vis-hidden",children:"Connection"}),e.jsx("select",{id:i,className:"sm-select",value:g.id,onChange:k=>x(k.target.value),children:s.map(k=>e.jsxs("option",{value:k.id,children:[k.name,k.name!==qe(k)?` · ${qe(k)}`:""]},k.id))})]}):e.jsx("span",{className:"ig-conn-name",title:g.baseUrl,children:g.name}),e.jsx("button",{type:"button",className:"glyph-btn ig-close",onClick:u,"aria-label":`Close ${a.label}`,title:"Close (Esc)",children:"×"})]}),e.jsx("div",{className:"ig-body",children:e.jsx(l,{connection:g,connections:s,api:p.api,assetUrl:p.assetUrl,prefs:p.prefs,narrow:o,onReconnect:()=>{u(),r(g.id)}},g.id)})]})}),document.body)}export{yl as default};