@preventive/triage 1.0.0-alpha.80 → 1.0.0-alpha.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/activity.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,d as n,e as r,f as i,h as a,i as o}from"./chunk-OWSEQOL5.js";import{$f as s,Aa as c,Ae as l,Ba as u,Be as d,Ca as f,Ce as p,Da as m,De as h,Ee as g,Fa as _,Fe as v,Ga as y,Hf as b,If as x,Le as S,Me as C,Mf as ee,Ne as te,Oe as ne,Of as re,Pe as ie,Pf as ae,Qe as w,Tf as oe,Uf as se,Vf as ce,Vg as le,Wf as ue,Wg as de,Xf as fe,Yf as pe,Zf as me,_f as he,ag as ge,bg as _e,cg as ve,dg as ye,eg as be,fg as xe,gg as Se,kg as Ce,la as T,oa as we,pa as Te,qa as Ee,re as De,sa as Oe,se as ke,ta as Ae,tc as je,te as E,ua as Me,uc as Ne,va as Pe,ve as Fe,we as Ie,xe as Le,ye as Re,za as ze,ze as D}from"./chunk-YKCRCNYZ.js";import"./chunk-A4BBBHQU.js";import"./chunk-MV66NL3G.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import"./chunk-N57OWFKY.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-7YO4QV5P.js";import"./chunk-DUS5ARE2.js";import"./chunk-5M2X3QPK.js";import"./chunk-DUASGS2O.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as Be}from"./chunk-5QWPKTCE.js";import"./chunk-5EAVJAD2.js";import{e as Ve}from"./chunk-74JZTGTO.js";import"./chunk-IYPY47MC.js";import{A as He,B as Ue,d as We,e as Ge,f as Ke,g as qe}from"./chunk-ITUKKCCK.js";import{a as O}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import"./chunk-LBD3M3J6.js";import"./chunk-QRKFPLA4.js";import{c as k,d as A,g as j,j as Je}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Ye=e=>e.committedAt??-1/0;function Xe(e){let t=new Map(e.map((e,t)=>[e.sha,t])),n=new Map(e.map(e=>[e.sha,0]));for(let r of e)for(let e of new Set(r.parents))t.has(e)&&n.set(e,n.get(e)+1);let r=(e,n)=>Ye(e)-Ye(n)||t.get(n.sha)-t.get(e.sha),i=e.filter(e=>n.get(e.sha)===0).toSorted(r),a=[];for(;i.length>0;){let o=i.pop();a.push(o);for(let a of new Set(o.parents)){if(!t.has(a))continue;let o=n.get(a)-1;if(n.set(a,o),o>0)continue;let s=e[t.get(a)],c=i.length,l=0;for(;l<c;){let e=l+c>>1;r(i[e],s)<0?l=e+1:c=e}i.splice(l,0,s)}}return a}function Ze(e,t){let n=new Map(e.map(e=>[e.sha,e])),r=new Set;for(let e=n.get(t);e&&!r.has(e.sha);e=n.get(e.parents[0]))r.add(e.sha);return r}function Qe(e,{linear:t=!1,trunk:n=null,colors:r=8}={}){let i=new Set(e.map(e=>e.sha)),a=+(n?.size>0),o=[],s=[],c=[],l=[],u=[],d=0,f=0,p=()=>{let e=o.indexOf(null,a);return e===-1?Math.max(o.length,a):e},m=e=>{if(n?.has(e))return 0;let t=o.indexOf(e);return t===-1?null:t},h=e=>{let t=Math.max(1,r-a),n=new Set([e-1,e+1].filter(e=>o[e]!=null).map(e=>s[e])),i=Array.from({length:t},(e,t)=>t).find(e=>!n.has(a+(f+e)%t))??0,c=a+(f+i)%t;return f=(f+i+1)%t,c};for(let[r,a]of e.entries()){let f=e[r+1],g=t?f?[f.sha]:a.parents.slice(0,1):[...new Set(a.parents)],_=g.filter(e=>i.has(e)),v=m(a.sha),y=v??p(),b=n?.has(a.sha)?0:v===null?h(y):s[y];for(let[e,t]of o.entries())t===a.sha&&(o[e]=null);c.push({commit:a,col:y,color:b});let x=new Set;o[y]=_[0]??null,s[y]=b,_.length>0&&x.add(y);let S=[];for(let e of _.slice(1)){let t=n?.has(e)?0:o.indexOf(e);if(t===-1||o[t]!==e){let t=p();s[t]=h(t),o[t]=e,x.add(t)}else S.push(t)}let C=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:C,color:b}),C=!1;for(let e=0;e<o.length;e++)o[e]??=null;if(d=Math.max(d,o.length),f){let e=m(f.sha);for(let[t,n]of o.entries())n!==null&&l.push({row:r,from:x.has(t)?y:t,to:n===f.sha?e:t,color:s[t]});for(let t of S)l.push({row:r,from:y,to:o[t]===f.sha?e:t,color:s[t]})}for(;o.length>0&&o.at(-1)===null;)o.pop()}return{rows:c,segments:l,stubs:u,width:Math.max(d,+(c.length>0))}}var $e=12,M=24,et=9,tt=8,nt=3,rt=`a[href], .history-commit`,it=15e3,at=3e3,ot=10,st=25,ct=`all`,lt=new Set,N=Fe(new Map,lt),{Shown:ut,shown:dt,repaint:P}=d(Je);function ft(e,t,n=new Set){let r={status:`ready`,until:Date.now()+De,page:1,commits:e.commits,more:e.more===!0,branches:e.branches??[],tags:e.tags??[],defaultBranch:e.defaultBranch??null,unread:e.unread,cut:e.cut===!0,pulls:e.pulls,pullsPending:e.pullsPending===!0,openPulls:e.openPulls,loadingMore:!1,moreError:null,sought:n};return t?.(r),r}function pt(e,t){let n=D(e.pulls,t,e=>e.merge);n.length>e.pulls.length&&(e.pulls=n)}function mt(e,t,n,r,i,a=1){setTimeout(()=>{N().get(e)===t&&n(r,i).then(o=>(N().get(e)!==t||(pt(t,o.pulls),o.pullsPending&&a<ot&&mt(e,t,n,r,i,a+1)),null),()=>null).finally(P)},at)}function ht(e,t,n){return Le(N(),e,()=>t(1),{ready:e=>ft(e,n),settled:n=>{n.pullsPending&&mt(e,n,t,1,null)},failed:e=>{let t=Ie(e,`The history could not be read.`);return t&&{...t,code:e?.code??null}},repaint:P})}function gt(e,t,n,r,i){let a=t.sought;t.sought=new Set(a).add(i),t.refreshing=!0,n(1,null,!0).then(o=>{if(N().get(e)!==t)return null;let s=t.retried===i?0:Math.min(Number(o.retryIn)||0,it),c=ft(o,r,s>0?a:t.sought);return s>0&&(Object.assign(c,{retried:i,retryAt:Date.now()+s}),setTimeout(P,s)),N().set(e,c),c.pullsPending&&mt(e,c,n,1,null),null},()=>null).finally(()=>{t.refreshing=!1,P()})}function _t(e){let t=new Set(e.commits.map(e=>e.sha));e.branches=[...e.branches,...e.unread.flatMap(({name:e,sha:n})=>t.has(n)?[{name:e,sha:n}]:[])],e.unread=e.unread.filter(e=>!t.has(e.sha)),e.asked??=new Set;let n=new Map,r=(t,r)=>{e.asked.has(t)||n.set(t,Math.max(n.get(t)??-1/0,r??0))};for(let n of e.commits)for(let e of n.parents)t.has(e)||r(e,n.committedAt);for(let t of e.unread)r(t.sha,t.at);e.next=[...n].toSorted((e,t)=>t[1]-e[1]).slice(0,st).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function vt(e,t,n,r){let i={next:t.next};p(t,{held:()=>N().get(e)===t,ask:()=>n(t.page+1,i),merge:a=>{t.commits=D(t.commits,a.commits,e=>e.sha),pt(t,a.pulls),t.page+=1,t.more=a.more===!0,r?.(t),a.pullsPending&&mt(e,t,n,t.page,i)},error:`More commits could not be read.`,repaint:P})}var yt=e=>typeof e==`string`&&/^[a-f\d]{40}$/u.test(e),bt=e=>yt(e?.sha)&&Array.isArray(e.parents);function xt(e){if(!Array.isArray(e?.commits))throw TypeError(`The server answered with no history.`);let t=e.commits.filter(bt),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&yt(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>yt(e?.merge)&&Number.isSafeInteger(e.number)&&yt(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(bt)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&yt(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function St(e,t,n){let r=Ct(e,t),i=new Map(r.map(e=>[e.sha,e]));if(!i.has(n))return r;let a=new Set;for(let e=[n];e.length>0;){let t=e.pop();a.has(t)||!i.has(t)||(a.add(t),e.push(...i.get(t).parents))}let o=i.get(n);for(let e=new Set;i.has(o.parents[0])&&!e.has(o.sha);o=i.get(o.parents[0]))e.add(o.sha);let s=o.parents.length>0?o.committedAt??1/0:-1/0;return r.filter(e=>!a.has(e.sha)&&(e.committedAt??-1/0)>s)}function Ct(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.merge,e])),r=new Set(e.map(e=>e.sha)),i=new Map;for(let e of t)for(let t of e.commits)!r.has(t.sha)&&!i.has(t.sha)&&i.set(t.sha,{...t,pull:e.number});return[...e.map(e=>{let t=n.get(e.sha);return t&&e.parents.length===1&&t.head!==e.parents[0]?{...e,parents:[e.parents[0],t.head]}:e}),...i.values()]}var wt=6e4,Tt=60*wt,Et=24*Tt;function Dt(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-wt&&n<wt)return`now`;if(n>0&&n<Tt)return`${Math.floor(n/wt)}m`;if(n>0&&n<Et)return`${Math.floor(n/Tt)}h`;if(n>0&&n<7*Et)return`${Math.floor(n/Et)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function Ot({branches:e=[],tags:t=[],pulls:n=[],openPulls:r=[]},i){let a=new Map,o=(e,t)=>a.set(e,[...a.get(e)??[],t]);for(let t of e.toSorted((e,t)=>+(t.name===i)-(e.name===i)))o(t.sha,{kind:`branch`,name:t.name,main:t.name===i});let s=new Set;for(let{number:e,sha:t}of[...n.map(e=>({number:e.number,sha:e.head})),...r])s.has(e)||(s.add(e),o(t,{kind:`pull`,name:`#${e}`,number:e}));for(let e of t)o(e.sha,{kind:`tag`,name:e.name});return a}var kt=e=>e?`https://github.com/${e.split(`/`).map(encodeURIComponent).join(`/`)}`:null;function At(e,t){if(!t)return e;let n=[],r=0;for(let i of e.matchAll(/(?<=^|[\s([])#(\d+)\b/gu))n.push(e.slice(r,i.index),k`<a href="${`${t}/issues/${i[1]}`}" target="_blank" rel="noopener noreferrer" tabindex="-1">${i[0]}</a>`),r=i.index+i[0].length;return r===0?e:[...n,e.slice(r)]}var F=e=>et+e*$e,jt=e=>e*M+M/2,Mt=e=>et*2+(e.width-1)*$e;function Nt({row:e,from:t,to:n}){let[r,i,a,o]=[F(t),F(n),jt(e),jt(e+1)];if(r===i)return`M${r} ${a}V${o}`;let s=(a+o)/2;return`M${r} ${a}C${r} ${s} ${i} ${s} ${i} ${o}`}var Pt=({row:e,col:t,straight:n})=>n?`M${F(t)} ${jt(e)+6}v${M*.55}`:`M${F(t)+4} ${jt(e)+5}l${$e*.6} ${M*.5}`;function Ft(e,t){let n=(e,t,n=``)=>{let r=Array.from({length:tt},()=>[]);for(let n of e)r[n.color].push(t(n));return r.map((e,t)=>e.length>0?A`<path class=${`${n}lane-${t}`} d=${e.join(``)}/>`:j)};return k`<svg class="history-graph" width="${Mt(e)}" height="${e.rows.length*M}" aria-hidden="true">${n(e.segments,Nt)} ${n(e.stubs,Pt,`history-stub `)} ${e.rows.map(({commit:e,col:n,color:r},i)=>A`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${F(n)} cy=${jt(i)}
1
+ import{a as e,c as t,d as n,e as r,f as i,h as a,i as o}from"./chunk-H4FEC57K.js";import{$f as s,Aa as c,Ae as l,Ba as u,Be as d,Ca as f,Ce as p,Da as m,De as h,Ee as g,Fa as _,Fe as v,Ga as y,Hf as b,If as x,Le as S,Me as C,Mf as ee,Ne as te,Oe as ne,Of as re,Pe as ie,Pf as ae,Qe as w,Tf as oe,Uf as se,Vf as ce,Vg as le,Wf as ue,Wg as de,Xf as fe,Yf as pe,Zf as me,_f as he,ag as ge,bg as _e,cg as ve,dg as ye,eg as be,fg as xe,gg as Se,kg as Ce,la as T,oa as we,pa as Te,qa as Ee,re as De,sa as Oe,se as ke,ta as Ae,tc as je,te as E,ua as Me,uc as Ne,va as Pe,ve as Fe,we as Ie,xe as Le,ye as Re,za as ze,ze as D}from"./chunk-563V5VVT.js";import"./chunk-A4BBBHQU.js";import"./chunk-6WMQVUT2.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import"./chunk-N57OWFKY.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-7YO4QV5P.js";import"./chunk-DOYTKRIR.js";import"./chunk-5M2X3QPK.js";import"./chunk-DUASGS2O.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as Be}from"./chunk-5QWPKTCE.js";import"./chunk-5EAVJAD2.js";import{e as Ve}from"./chunk-74JZTGTO.js";import"./chunk-IYPY47MC.js";import{A as He,B as Ue,d as We,e as Ge,f as Ke,g as qe}from"./chunk-ITUKKCCK.js";import{a as O}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import"./chunk-LBD3M3J6.js";import"./chunk-QRKFPLA4.js";import{c as k,d as A,g as j,j as Je}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Ye=e=>e.committedAt??-1/0;function Xe(e){let t=new Map(e.map((e,t)=>[e.sha,t])),n=new Map(e.map(e=>[e.sha,0]));for(let r of e)for(let e of new Set(r.parents))t.has(e)&&n.set(e,n.get(e)+1);let r=(e,n)=>Ye(e)-Ye(n)||t.get(n.sha)-t.get(e.sha),i=e.filter(e=>n.get(e.sha)===0).toSorted(r),a=[];for(;i.length>0;){let o=i.pop();a.push(o);for(let a of new Set(o.parents)){if(!t.has(a))continue;let o=n.get(a)-1;if(n.set(a,o),o>0)continue;let s=e[t.get(a)],c=i.length,l=0;for(;l<c;){let e=l+c>>1;r(i[e],s)<0?l=e+1:c=e}i.splice(l,0,s)}}return a}function Ze(e,t){let n=new Map(e.map(e=>[e.sha,e])),r=new Set;for(let e=n.get(t);e&&!r.has(e.sha);e=n.get(e.parents[0]))r.add(e.sha);return r}function Qe(e,{linear:t=!1,trunk:n=null,colors:r=8}={}){let i=new Set(e.map(e=>e.sha)),a=+(n?.size>0),o=[],s=[],c=[],l=[],u=[],d=0,f=0,p=()=>{let e=o.indexOf(null,a);return e===-1?Math.max(o.length,a):e},m=e=>{if(n?.has(e))return 0;let t=o.indexOf(e);return t===-1?null:t},h=e=>{let t=Math.max(1,r-a),n=new Set([e-1,e+1].filter(e=>o[e]!=null).map(e=>s[e])),i=Array.from({length:t},(e,t)=>t).find(e=>!n.has(a+(f+e)%t))??0,c=a+(f+i)%t;return f=(f+i+1)%t,c};for(let[r,a]of e.entries()){let f=e[r+1],g=t?f?[f.sha]:a.parents.slice(0,1):[...new Set(a.parents)],_=g.filter(e=>i.has(e)),v=m(a.sha),y=v??p(),b=n?.has(a.sha)?0:v===null?h(y):s[y];for(let[e,t]of o.entries())t===a.sha&&(o[e]=null);c.push({commit:a,col:y,color:b});let x=new Set;o[y]=_[0]??null,s[y]=b,_.length>0&&x.add(y);let S=[];for(let e of _.slice(1)){let t=n?.has(e)?0:o.indexOf(e);if(t===-1||o[t]!==e){let t=p();s[t]=h(t),o[t]=e,x.add(t)}else S.push(t)}let C=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:C,color:b}),C=!1;for(let e=0;e<o.length;e++)o[e]??=null;if(d=Math.max(d,o.length),f){let e=m(f.sha);for(let[t,n]of o.entries())n!==null&&l.push({row:r,from:x.has(t)?y:t,to:n===f.sha?e:t,color:s[t]});for(let t of S)l.push({row:r,from:y,to:o[t]===f.sha?e:t,color:s[t]})}for(;o.length>0&&o.at(-1)===null;)o.pop()}return{rows:c,segments:l,stubs:u,width:Math.max(d,+(c.length>0))}}var $e=12,M=24,et=9,tt=8,nt=3,rt=`a[href], .history-commit`,it=15e3,at=3e3,ot=10,st=25,ct=`all`,lt=new Set,N=Fe(new Map,lt),{Shown:ut,shown:dt,repaint:P}=d(Je);function ft(e,t,n=new Set){let r={status:`ready`,until:Date.now()+De,page:1,commits:e.commits,more:e.more===!0,branches:e.branches??[],tags:e.tags??[],defaultBranch:e.defaultBranch??null,unread:e.unread,cut:e.cut===!0,pulls:e.pulls,pullsPending:e.pullsPending===!0,openPulls:e.openPulls,loadingMore:!1,moreError:null,sought:n};return t?.(r),r}function pt(e,t){let n=D(e.pulls,t,e=>e.merge);n.length>e.pulls.length&&(e.pulls=n)}function mt(e,t,n,r,i,a=1){setTimeout(()=>{N().get(e)===t&&n(r,i).then(o=>(N().get(e)!==t||(pt(t,o.pulls),o.pullsPending&&a<ot&&mt(e,t,n,r,i,a+1)),null),()=>null).finally(P)},at)}function ht(e,t,n){return Le(N(),e,()=>t(1),{ready:e=>ft(e,n),settled:n=>{n.pullsPending&&mt(e,n,t,1,null)},failed:e=>{let t=Ie(e,`The history could not be read.`);return t&&{...t,code:e?.code??null}},repaint:P})}function gt(e,t,n,r,i){let a=t.sought;t.sought=new Set(a).add(i),t.refreshing=!0,n(1,null,!0).then(o=>{if(N().get(e)!==t)return null;let s=t.retried===i?0:Math.min(Number(o.retryIn)||0,it),c=ft(o,r,s>0?a:t.sought);return s>0&&(Object.assign(c,{retried:i,retryAt:Date.now()+s}),setTimeout(P,s)),N().set(e,c),c.pullsPending&&mt(e,c,n,1,null),null},()=>null).finally(()=>{t.refreshing=!1,P()})}function _t(e){let t=new Set(e.commits.map(e=>e.sha));e.branches=[...e.branches,...e.unread.flatMap(({name:e,sha:n})=>t.has(n)?[{name:e,sha:n}]:[])],e.unread=e.unread.filter(e=>!t.has(e.sha)),e.asked??=new Set;let n=new Map,r=(t,r)=>{e.asked.has(t)||n.set(t,Math.max(n.get(t)??-1/0,r??0))};for(let n of e.commits)for(let e of n.parents)t.has(e)||r(e,n.committedAt);for(let t of e.unread)r(t.sha,t.at);e.next=[...n].toSorted((e,t)=>t[1]-e[1]).slice(0,st).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function vt(e,t,n,r){let i={next:t.next};p(t,{held:()=>N().get(e)===t,ask:()=>n(t.page+1,i),merge:a=>{t.commits=D(t.commits,a.commits,e=>e.sha),pt(t,a.pulls),t.page+=1,t.more=a.more===!0,r?.(t),a.pullsPending&&mt(e,t,n,t.page,i)},error:`More commits could not be read.`,repaint:P})}var yt=e=>typeof e==`string`&&/^[a-f\d]{40}$/u.test(e),bt=e=>yt(e?.sha)&&Array.isArray(e.parents);function xt(e){if(!Array.isArray(e?.commits))throw TypeError(`The server answered with no history.`);let t=e.commits.filter(bt),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&yt(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>yt(e?.merge)&&Number.isSafeInteger(e.number)&&yt(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(bt)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&yt(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function St(e,t,n){let r=Ct(e,t),i=new Map(r.map(e=>[e.sha,e]));if(!i.has(n))return r;let a=new Set;for(let e=[n];e.length>0;){let t=e.pop();a.has(t)||!i.has(t)||(a.add(t),e.push(...i.get(t).parents))}let o=i.get(n);for(let e=new Set;i.has(o.parents[0])&&!e.has(o.sha);o=i.get(o.parents[0]))e.add(o.sha);let s=o.parents.length>0?o.committedAt??1/0:-1/0;return r.filter(e=>!a.has(e.sha)&&(e.committedAt??-1/0)>s)}function Ct(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.merge,e])),r=new Set(e.map(e=>e.sha)),i=new Map;for(let e of t)for(let t of e.commits)!r.has(t.sha)&&!i.has(t.sha)&&i.set(t.sha,{...t,pull:e.number});return[...e.map(e=>{let t=n.get(e.sha);return t&&e.parents.length===1&&t.head!==e.parents[0]?{...e,parents:[e.parents[0],t.head]}:e}),...i.values()]}var wt=6e4,Tt=60*wt,Et=24*Tt;function Dt(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-wt&&n<wt)return`now`;if(n>0&&n<Tt)return`${Math.floor(n/wt)}m`;if(n>0&&n<Et)return`${Math.floor(n/Tt)}h`;if(n>0&&n<7*Et)return`${Math.floor(n/Et)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function Ot({branches:e=[],tags:t=[],pulls:n=[],openPulls:r=[]},i){let a=new Map,o=(e,t)=>a.set(e,[...a.get(e)??[],t]);for(let t of e.toSorted((e,t)=>+(t.name===i)-(e.name===i)))o(t.sha,{kind:`branch`,name:t.name,main:t.name===i});let s=new Set;for(let{number:e,sha:t}of[...n.map(e=>({number:e.number,sha:e.head})),...r])s.has(e)||(s.add(e),o(t,{kind:`pull`,name:`#${e}`,number:e}));for(let e of t)o(e.sha,{kind:`tag`,name:e.name});return a}var kt=e=>e?`https://github.com/${e.split(`/`).map(encodeURIComponent).join(`/`)}`:null;function At(e,t){if(!t)return e;let n=[],r=0;for(let i of e.matchAll(/(?<=^|[\s([])#(\d+)\b/gu))n.push(e.slice(r,i.index),k`<a href="${`${t}/issues/${i[1]}`}" target="_blank" rel="noopener noreferrer" tabindex="-1">${i[0]}</a>`),r=i.index+i[0].length;return r===0?e:[...n,e.slice(r)]}var F=e=>et+e*$e,jt=e=>e*M+M/2,Mt=e=>et*2+(e.width-1)*$e;function Nt({row:e,from:t,to:n}){let[r,i,a,o]=[F(t),F(n),jt(e),jt(e+1)];if(r===i)return`M${r} ${a}V${o}`;let s=(a+o)/2;return`M${r} ${a}C${r} ${s} ${i} ${s} ${i} ${o}`}var Pt=({row:e,col:t,straight:n})=>n?`M${F(t)} ${jt(e)+6}v${M*.55}`:`M${F(t)+4} ${jt(e)+5}l${$e*.6} ${M*.5}`;function Ft(e,t){let n=(e,t,n=``)=>{let r=Array.from({length:tt},()=>[]);for(let n of e)r[n.color].push(t(n));return r.map((e,t)=>e.length>0?A`<path class=${`${n}lane-${t}`} d=${e.join(``)}/>`:j)};return k`<svg class="history-graph" width="${Mt(e)}" height="${e.rows.length*M}" aria-hidden="true">${n(e.segments,Nt)} ${n(e.stubs,Pt,`history-stub `)} ${e.rows.map(({commit:e,col:n,color:r},i)=>A`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${F(n)} cy=${jt(i)}
2
2
  r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function It(e,t,n,r){if(!e?.length)return j;let i=e=>{let t=Be({"history-ref":!0,[`is-${e.kind}`]:!0,"is-default":e.main===!0,"is-shown":e.kind===n.kind&&e.name===n.name}),i=k`${e.kind===`tag`?We(Ue):e.kind===`pull`?We(He):j}<span>${e.name}</span>`;return e.kind===`pull`&&r?k`<a class="${t}" href="${`${r}/pull/${e.number}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Pull request ${e.name} on GitHub`}">${i}</a>`:k`<span class="${t}">${i}</span>`},a=e.slice(nt);return k`<span class="history-refs" style="${O({"--ref":`var(--lane-${t})`})}">${e.slice(0,nt).map(i)}${a.length>0?k`<span class="history-ref is-more" data-tooltip="${a.map(e=>e.name).join(`, `)}">+${a.length}</span>`:j}</span>`}function Lt(e,t){let{repoId:n,commit:r,path:i}=e,a=t===`all`||t===`unmerged`,o=a?`all\0${n}`:`${n}\0${r}\0${i}`,s=(e,o,s=!1)=>ze(n,a?``:r,i,{page:e,all:a,...s?{fresh:!0}:{},...t!==`path`&&e>1?{from:o.next}:{}}).then(e=>{if(!a&&e?.commit!==r)throw Error(`The server answered with another revision's history.`);return xt(e)}),c=t===`path`?null:_t,l=ht(o,s,c);return!a||l.status!==`ready`||l.refreshing||l.sought.has(r)||l.retryAt>Date.now()||Ct(l.commits,l.pulls??[]).some(e=>e.sha===r)||gt(o,l,s,c,r),a&&l.status===`error`&&l.code===`github-token-required`?(lt.add(n),Lt(e,`revision`)):{mode:t,key:o,entry:l,more:()=>vt(o,l,s,c)}}var Rt=e=>Lt(e,e.path?`path`:`revision`),zt=e=>{dt.add(e)},Bt=e=>{dt.delete(e)};function Vt(e){N().delete(e),P()}var Ht=class extends ut{static properties={refs:{attribute:!1}};constructor(){super(),this.refs=null,this._drawn=null,this._mode=null}updated(){this.watchMore(()=>this._mode!==`unmerged`)}mode(){let{repoId:e,path:t}=this.repository;return t?`path`:(N(),lt.has(e)?`revision`:ct)}history(e){return Lt(this.repository,e)}layout(e,t,n){let r=this._drawn;if(r?.commits===t.commits&&r.pulls===t.pulls&&r.mode===e&&r.defaultBranch===n)return r.layout;let i=e===`path`,a=t.branches.find(e=>e.name===n)?.sha,o=i?t.commits:Xe(e===`unmerged`?St(t.commits,t.pulls??[],a):Ct(t.commits,t.pulls??[])),s=e===`all`?a:e===`revision`?o[0]?.sha:null,c=Qe(o,{linear:i,trunk:s&&!i?Ze(o,s):null,colors:tt});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){ct=e,P()}open(e,t){let{repoId:n,repo:r,path:i}=this.repository,a=t?.find(e=>e.kind===`branch`)??t?.find(e=>e.kind===`tag`);le({repoId:n,repo:r,path:i,commit:e.sha,bundleTab:`commits`,...a?{revision:{kind:a.kind,name:a.name}}:{}})}keydown(e){let t=[...this.querySelectorAll(`.history-row`)],n=e.target.closest(`.history-row`),r=n?[...n.querySelectorAll(rt)]:[],i=r.indexOf(e.target);if(i===-1)return;let a={ArrowLeft:-1,ArrowRight:1}[e.key],o={ArrowUp:-1,ArrowDown:1}[e.key],s=a?r[i+a]:(o?t[t.indexOf(n)+o]:{Home:t[0],End:t.at(-1)}[e.key])?.querySelector(`.history-commit`);if(s){e.preventDefault();for(let e of this.querySelectorAll(`.history-row :is(${rt})`))e.tabIndex=e===s?0:-1;s.focus()}}render(){if(!this.repository)return j;let{mode:e,key:t,entry:n,more:r}=this.history(this.mode());this._mode=e;let i=n.status===`ready`,a=e===`all`||e===`unmerged`?n.defaultBranch:this.refs?.status===`ready`?this.refs.value.defaultBranch??null:null,o=i?this.layout(e,n,a):null,s=e===`unmerged`?o?.rows.length??0:n.commits?.length??0,c=e===`unmerged`&&o?new Set(o.rows.map(e=>e.commit.sha)):null,l=i&&e===`all`?n.branches.length:c?n.branches.filter(e=>c.has(e.sha)).length:0,u=i?`${s}${n.more||n.cut?`+`:``} commit${s===1?``:`s`}`:``,d=lt.has(this.repository.repoId);return k`<div class="history-bar">${w(`commits`)} ${e===`path`?k`<span class="history-scope">Commits touching <code>${this.repository.path}</code></span>`:d?k`<span class="history-scope">Every branch needs your GitHub sign-in.</span>`:h(`Branches`,[[`all`,`All branches`],[`unmerged`,`Unmerged`]],e,e=>()=>this.pick(e),{spaced:!0})} ${i?k`<span class="history-summary">${u}${l>0?` on ${l} branch${l===1?``:`es`}`:``}</span>`:j}</div>${i?this.renderCommits(e,n,r,o,a):v(n,`Reading the history…`,()=>Vt(t))}`}renderCommits(e,t,n,r,i){if(r.rows.length===0&&(e!==`unmerged`||!t.more&&!t.moreError))return k`<div class="bundles-slide-placeholder">${e===`unmerged`?`Every branch read is merged.`:`No commits.`}</div>`;let a=this.repository.commit,o=de(this.repository,this.refs),s=Ot(t,i),c=Math.max(0,r.rows.findIndex(e=>e.commit.sha===a)),l=kt(this.repo??this.repository.repo);return k`<div class="history-scroll">${e===`all`&&!t.refreshing&&!(t.retryAt>Date.now())&&!r.rows.some(e=>e.commit.sha===a)?k`<p class="history-note"><code>${a.slice(0,7)}</code> isn’t among these commits.</p>`:j}<div class="history-lines" style="${O({"--history-graph":`${Mt(r)}px`})}">${Ft(r,a)}<ol class="history-list" aria-label="Commits" @keydown="${this.keydown}">${r.rows.map(({commit:e,color:t},n)=>{let r=s.get(e.sha),i=e.committedAt==null?null:new Date(e.committedAt),u=e.sha.slice(0,7);return k`<li class="${Be({"history-row":!0,"is-shown":e.sha===a})}">${l?k`<a class="history-sha" href="${`${l}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${u} on GitHub`}">${u}</a>`:k`<code class="history-sha">${u}</code>`} ${It(r,t,o,l)} <span class="history-subject" id="${`history-subject-${e.sha}`}">${At(e.subject||`(no message)`,l)}</span> <button type="button" class="history-commit" id="${`history-commit-${e.sha}`}" tabindex="${n===c?0:-1}" aria-labelledby="${`history-subject-${e.sha} history-commit-${e.sha}`}" aria-current="${e.sha===a?`true`:j}" @click="${()=>this.open(e,r)}"><span class="history-author">${Pe(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?k`<time class="history-time" datetime="${i.toISOString()}">${Dt(e.committedAt)}</time>`:k`<span class="history-time"></span>`}</button></li>`})}</ol></div>${t.cut?k`<p class="history-note">Only the first 5,000 branches by name are read.</p>`:j} ${g(t,n,`Older commits`)}</div>`}};customElements.get(`repository-history`)||customElements.define(`repository-history`,Ht);function Ut(e){let t=e?.startsWith(`claude/`)?`claude`:e?.startsWith(`codex/`)?`codex`:null,n=t===`claude`?/^claude\/(issue|pr)-([1-9]\d{0,9})-/u.exec(e):null;return{agent:t,issue:n?.[1]===`issue`?Number(n[2]):null,pull:n?.[1]===`pr`?Number(n[2]):null}}var Wt=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,Gt=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],Kt=new Set([`claude`,`codex`]);function qt({pulls:e=[],commits:t=[],branches:n=[]}){let r=new Map,i=e=>{let t=e;for(;r.has(t)&&r.get(t)!==t;)t=r.get(t);return r.set(e,t),t},a=(e,t)=>{let[n,a]=[i(e),i(t)];n!==a&&r.set(a,n)},o=new Map,s=(e,t)=>{for(let n of t)o.set(e,new Set([...o.get(e)??[],n]))},c=(e,t)=>{if(i(e),t.agents.length===0)for(let n of t.sessions)a(e,`session:${n}`);if(t.agents.length===0)for(let n of t.tasks)a(e,`task:${n}`);s(e,Gt(t))},l=new Set(n.map(e=>e.name));for(let e of n){let t=`branch:${e.name}`;c(t,e.signals);let{agent:n}=Ut(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=Wt(t);e!==null&&t.number>(u.get(e)??0)&&u.set(e,t.number)}for(let t of e){let e=`pull:${t.number}`;c(e,t.signals);let{agent:n,pull:r}=Ut(t.head);n&&s(e,[n]);let i=Wt(t);t.signals.agents.length>0?i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`):(i&&(n||Gt(t.signals).length>0||l.has(i))&&a(e,`branch:${i}`),r&&a(e,`pull:${r}`))}for(let e of t)c(`commit:${e.oid}`,e.signals);let d=new Map;for(let e of r.keys()){let t=i(e),n=d.get(t)??{agents:new Set,keys:[]};n.keys.push(e);for(let t of o.get(e)??[])n.agents.add(t);d.set(t,n)}return[...d.values()]}var Jt=e=>(t,n)=>(e(t)??0)-(e(n)??0);function Yt({agents:e,keys:t},{pulls:n,commits:r,issues:i,branches:a}){if(e.size===0)return null;let o=e=>t.filter(t=>t.startsWith(e)).map(t=>t.slice(e.length)),s=o(`pull:`).flatMap(e=>n.get(Number(e))??[]).toSorted(Jt(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(Jt(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>Wt(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>Ut(e.head).issue??[]),...o(`branch:`).flatMap(e=>Ut(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(Jt(e=>e.createdAt)),d=l.flatMap(e=>a.get(e)??[]),f=[...s,...c,...u,...d];if(f.length===0)return null;let[p,m]=[o(`task:`),o(`session:`)],h=f.flatMap(e=>(`createdAt`in e?e.createdAt:e.at)??[]),g=f.flatMap(e=>(`updatedAt`in e?e.updatedAt:e.at)??[]),_=new Set(s.map(e=>e.state)),v=[...s.map(e=>({at:e.createdAt,title:e.title})),...c.map(e=>({at:e.at,title:e.title}))].toSorted(Jt(e=>e.at))[0],y=[...s,...c];return{id:m[0]??p[0]??(s[0]?`pull-${s[0].number}`:c[0]?.oid??l[0]??``),agents:[...[...e].filter(e=>!Kt.has(e)),...[`claude`,`codex`].filter(t=>e.has(t))],sessions:m,tasks:p,title:v?.title??u[0]?.title??l[0]??``,authors:[...new Set(f.flatMap(e=>e.author??[]))],startedAt:h.length>0?Math.min(...h):null,updatedAt:g.length>0?Math.max(...g):null,state:_.has(`open`)?`open`:_.has(`merged`)||c.length>0?`merged`:_.has(`closed`)?`closed`:`branch`,pulls:s.map(({number:e,title:t,state:n,draft:r})=>({number:e,title:t,state:n,draft:r})).toReversed(),commits:c.map(({oid:e,title:t})=>({oid:e,title:t})).toReversed(),issues:u.map(({number:e,title:t,state:n})=>({number:e,title:t,state:n})),branches:l,commitCount:s.reduce((e,t)=>e+t.commits,0)+c.length,additions:y.reduce((e,t)=>e+t.additions,0),deletions:y.reduce((e,t)=>e+t.deletions,0)}}function Xt(e,{branchesSince:t=null}={}){let n={pulls:new Map((e.pulls??[]).map(e=>[e.number,e])),commits:new Map((e.commits??[]).map(e=>[e.oid,e])),issues:new Map((e.issues??[]).map(e=>[e.number,e])),branches:new Map((e.branches??[]).map(e=>[e.name,e]))},r=e=>t!==null&&e.pulls.length===0&&e.commits.length===0&&(e.updatedAt??0)<t;return qt(e).flatMap(e=>Yt(e,n)??[]).filter(e=>!r(e)).toSorted(Jt(e=>e.updatedAt)).toReversed()}var Zt=/^[a-z][a-z\d-]{0,31}$/u,Qt=/^(?:app|user)-[1-9]\d{0,11}$/u,$t=12,en=Fe(new Map),{Shown:tn,repaint:nn}=d(Je);C(e=>{e===`agents`&&nn()});function rn(e){if(!Array.isArray(e?.pulls)||!Array.isArray(e.commits))throw TypeError(`The server answered with no pull requests or commits.`);let t=e=>typeof e==`string`&&Zt.test(e)&&![`claude`,`codex`,`all`].includes(e),n=(Array.isArray(e.agents)?e.agents:[]).filter(e=>t(e?.id)&&typeof e.name==`string`&&e.name.trim()&&(e.avatar===void 0||typeof e.avatar==`string`&&Qt.test(e.avatar))).map(({id:e,name:t,avatar:n})=>[e,{id:e,name:t.trim().slice(0,64),avatar:n??null}]),r=e=>Array.isArray(e?.signals?.sessions)&&Array.isArray(e.signals.tasks),i=e=>({...e,signals:{...e.signals,agents:Array.isArray(e.signals.agents)?e.signals.agents.filter(t):[]}});return{pulls:e.pulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`&&Array.isArray(e.closes)&&r(e)).map(i),commits:e.commits.filter(e=>typeof e?.oid==`string`&&/^[a-f\d]{40}$/u.test(e.oid)&&r(e)).map(i),issues:Array.isArray(e.issues)?e.issues.filter(e=>Number.isSafeInteger(e?.number)):[],branches:Array.isArray(e.branches)?e.branches.filter(e=>typeof e?.name==`string`&&r(e)).map(i):[],agents:[...new Map(n).values()],more:e.more===!0,after:e.more===!0?{pulls:e.after?.pulls??null,commits:e.after?.commits??null}:null}}var an=e=>Object.assign(e,{sessions:Xt(e,{branchesSince:e.after?.pulls?Math.min(...e.pulls.map(e=>e.updatedAt??1/0)):null})}),on=(e,t,n)=>l(e.filter(e=>t===`all`||e.agents.includes(t)),n,e=>[e.title,...e.authors,...e.authors.map(Te),...e.branches,...e.sessions,...e.tasks,...e.pulls.flatMap(e=>[`#${e.number}`,e.title]),...e.commits.flatMap(e=>[e.oid.slice(0,7),e.title]),...e.issues.flatMap(e=>[`#${e.number}`,e.title])]),sn={open:`open`,merged:`merged`,closed:`closed`,branch:`draft`},cn=e=>(e.agents??[]).map(e=>e.id).filter(t=>(e.sessions??[]).some(e=>e.agents.includes(t))),ln=e=>[`claude`,`codex`,...cn(e)],un=[[`pulls`,s,`pull request`,`pull requests`],[`branches`,ge,`branch`,`branches`],[`commits`,_e,`commit to the default branch without a pull request`,`commits to the default branch without a pull request`]];function dn(e){if(!e.after?.pulls)return 100;let t=Math.max(e.pulls.length,...e.pulls.map(e=>e.number),...(e.issues??[]).map(e=>e.number));return t>0?Math.min(99,Math.floor(100*e.pulls.length/t)):0}function fn(e,t,n){let r=2*Math.PI*9;return k`<span class="${`history-summary read-gauge${n?` is-reading`:``}`}" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${e}" aria-label="${t}" data-tooltip="${t}"><svg class="read-gauge-ring" viewBox="0 0 22 22" aria-hidden="true"><circle class="read-gauge-track" cx="11" cy="11" r="9"/>${e>0?A`<circle class="read-gauge-arc" cx="11" cy="11" r="9" transform="rotate(-90 11 11)" stroke-dasharray=${`${r*e/100} ${r}`}/>`:j}</svg> ${e===100?k`<svg class="read-gauge-check" viewBox="0 0 16 16" aria-hidden="true"><path d="m4.25 8.5 2.5 2.5 5-5.5"/></svg>`:k`<span class="read-gauge-value" aria-hidden="true">${e}%</span>`}</span>`}function pn(e,t){let n=e.filter(e=>e.agents.includes(t));return{pulls:n.reduce((e,t)=>e+t.pulls.length,0),branches:new Set(n.flatMap(e=>e.branches)).size,commits:n.reduce((e,t)=>e+t.commits.length,0)}}var mn=class extends tn{static properties={_filter:{state:!0}};constructor(){super(),this._filter=``}updated(){this.watchMore(()=>!this._filter.trim()&&!this.list().entry.stalled)}list(){let{repoId:e}=this.repository,t=t=>f(e,t??{}).then(rn);return Re(en,`${e}`,{first:()=>t(null).then(e=>(be(e.agents),e)),next:t,message:`The agents' work could not be read.`,repaint:nn,ready:an,merge:(e,t)=>{e.pulls=D(e.pulls,t.pulls,e=>e.number),e.commits=D(e.commits,t.commits,e=>e.oid);let n=e.sessions.length;an(e),e.stalled=e.sessions.length<=n}})}pick(e){ie(this.repository,`agents`,e)}render(){if(!this.repository)return j;let{key:e,entry:t,more:n}=this.list(),r=t.status===`ready`,i=r?t.sessions:[],a=e=>r?k`<span class="n">${(e===`all`?i:i.filter(t=>t.agents.includes(e))).length}${t.more?`+`:``}</span>`:j,o=S(`agents`),s=ln(t).includes(o)?o:`all`,c=on(i,s,this._filter);return k`<div class="history-bar issues-bar">${w(`agents`)}${h(`Agents`,[[`all`,k`All${a(`all`)}`],...ln(t).map(e=>[e,k`${Se(e)}${xe(e)}${a(e)}`])],s,e=>()=>this.pick(e),{kindOf:e=>e===`all`?j:`agent-pick is-${e}`,spaced:!0})}<input class="issues-filter" type="search" placeholder="Filter" aria-label="Filter the sessions read" .value="${this._filter}" @input="${e=>{this._filter=e.target.value}}"> ${r?this.renderStats(t):j} ${r?fn(dn(t),`${t.pulls.length} pull request${t.pulls.length===1?``:`s`} read`,t.loadingMore):j}</div>${r?this.renderSessions(t,c,n,s):v(t,`Reading what the agents did…`,()=>{en().delete(e),nn()})}`}renderStats(e){let t={pulls:!!e.after?.pulls,branches:!!e.after?.pulls,commits:!!e.after?.commits},n=t=>e.sessions.some(e=>e.agents.includes(t));return k`<span class="agent-totals">${[...cn(e),`claude`,`codex`].filter(n).map(n=>{let r=pn(e.sessions,n);return k`<span class="agent-stats" role="group" aria-label="${xe(n)}"><span class="${`agent-mark is-${n}`}">${Se(n)}</span> ${un.filter(([e])=>r[e]>0).map(([e,n,i,a])=>{let o=`${E(r[e])}${t[e]?`+`:``}`,s=`${o} ${r[e]===1&&!t[e]?i:a}`;return k`<span class="agent-stat" role="img" aria-label="${s}" data-tooltip="${s}">${n}${o}</span>`})}</span>`})}</span>`}renderSessions(e,t,n,r){let i=r===`all`?`agents' sessions`:`${xe(r)} sessions`;return k`<div class="issues-scroll">${t.length>0?k`<ol class="issues-grid" aria-label="Sessions">${t.map(e=>this.renderSession(e))}</ol>`:k`<p class="history-note">${e.sessions.length>0&&this._filter.trim()?`None of the ${i} read match.`:`No ${i} among those read.`}</p>`} ${g(e,()=>{e.stalled=!1,n()},`More`,`history-more issues-more`)}</div>`}openSession(e,t){e.target?.closest?.(`.agent-chip.is-commit`)||this.openPopup(e,{session:t})}openItem(e,t,n){this.openPopup(e,{number:t,preview:n})&&e.stopPropagation()}renderSession(e){let t=this.repo??this.repository.repo,n=Ce(e,t),r=e.updatedAt==null?null:new Date(e.updatedAt),i=e.authors.find(e=>!Oe(e)),a=e.pulls.length+e.commits.length,o=r?k`<time datetime="${r.toISOString()}">${Dt(e.updatedAt)}</time>`:j,s=e.additions||e.deletions?k`<span class="issue-diff"><span class="is-added">+${E(e.additions)}</span> <span class="is-deleted">−${E(e.deletions)}</span></span>`:j,c=a===1,l=[i?k`<span class="issue-author">${Ee(i)}</span>`:j,c?j:o,a===0?k`<span>no pull request</span>`:j,c?j:s].filter(e=>e!==j),u=[...e.pulls.map(e=>[`is-${e.draft&&e.state===`open`?`draft`:e.state}`,`pull/${e.number}`,`#${e.number}`,{kind:`pulls`,...e}]),...e.commits.map(e=>[`is-commit`,`commit/${e.oid}`,k`<code>${e.oid.slice(0,7)}</code>`,null]),...e.issues.map(e=>[`is-issue is-${e.state===`open`?`open`:`merged`}`,`issues/${e.number}`,k`<span class="sr-only">Issue </span>#${e.number}`,{kind:`issues`,reason:null,...e}])];return k`<li class="${`issue-tile agent-tile is-${sn[e.state]}`}"><div class="issue-body" @click="${t=>this.openSession(t,e)}"><span class="issue-rail">${e.agents.map(e=>k`<span class="${`agent-mark is-${e}`}" role="img" aria-label="${xe(e)}">${Se(e)}</span>`)}</span> <span class="issue-lines">${n?k`<a class="issue-name" href="${n}" target="_blank" rel="noopener noreferrer">${e.title||`(no title)`}</a>`:k`<button type="button" class="issue-name">${e.title||`(no title)`}</button>`} ${l.length>0?k`<span class="issue-meta">${l}</span>`:j} ${u.length>0?k`<span class="agent-task-row"><span class="agent-chips">${u.slice(0,$t).map(([e,n,r,i],a)=>k`<a class="${`agent-chip ${e}`}" href="${t?`https://github.com/${t}/${n}`:j}" target="_blank" rel="noopener noreferrer" @click="${i?e=>this.openItem(e,i.number,i):j}" data-rest="${a<u.length-1?u.length-1-a:j}">${r}</a>`)}</span>${c&&(o!==j||s!==j)?k`<span class="issue-meta">${o}${s}</span>`:j}</span>`:j} ${e.branches[0]?k`<span class="issue-branch"><code>${e.branches[0]}</code>${e.branches.length>1?k`<span>+${e.branches.length-1}</span>`:j}</span>`:j}</span></div></li>`}};customElements.get(`repository-agents`)||customElements.define(`repository-agents`,mn);var hn=1e3,gn=5,_n=60,vn=5e3,yn=12,I=864e5,L=7*I,R=e=>Math.floor(e/I)*I,bn=()=>Array.from({length:7},()=>0),xn=8,Sn=3,Cn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],wn=[1,2,3,4,5,6,0],Tn=6,En=new Map,Dn=new Map,On=new Map,z=Fe(new Map,En,Dn,On),{Shown:kn,shown:An,repaint:B}=d(Je),jn={pulls:`merged`,issues:`closed`},Mn={pulls:[`Pull requests`,[[`merged`,`Merged`,`is:pr is:merged merged:`],[`opened`,`Opened`,`is:pr created:`]]],issues:[`Issues`,[[`closed`,`Closed`,`is:issue is:closed closed:`],[`created`,`Opened`,`is:issue created:`]]]},Nn=[`merged`,`opened`,`closed`,`created`],Pn=ue(A`<circle cx="8" cy="8" r="2.75"/><path d="M8 1v4.25M8 10.75V15"/>`),Fn={agent:`Commit with agents`,without:`Commit without agents`,release:`Release`},In=10,Ln=10;C(e=>{if(e===`pulse`)for(let e of An)e.periodShown()});var V=e=>Number.isSafeInteger(e)&&e>=0?e:0,H=e=>Number.isSafeInteger(e)?e:null,U=e=>typeof e==`string`?e:null,Rn=e=>Object.fromEntries(Nn.map(t=>[t,{count:V(e?.[t]?.count),previous:H(e?.[t]?.previous),items:Array.isArray(e?.[t]?.items)?e[t].items.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`):[]}]));function zn(e){if(!Number.isSafeInteger(e?.since)||!te.some(([t])=>t===e.weeks))throw Error(`The server answered with no period.`);let t=e=>Array.isArray(e)&&e.length===7&&e.every(Array.isArray)?e.map(([e,t])=>[V(e),V(t)]):null,n=e=>Array.isArray(e)&&e.length===7?e.map(V):null,r=Array.isArray(e.stats?.weeks)?e.stats.weeks.filter(e=>Number.isSafeInteger(e?.week)&&Array.isArray(e.days)).map(e=>({...e,dayLines:t(e.dayLines),agentDays:n(e.agentDays),releaseDays:n(e.releaseDays),directDays:n(e.directDays)})):[],i=e=>r.length>0&&r.every(t=>t[e]!==null),a=e.stats&&Array.isArray(e.stats.weeks)&&Array.isArray(e.stats.contributors)&&Array.isArray(e.stats.punch)?{weeks:r,contributors:e.stats.contributors.filter(e=>(typeof e?.login==`string`||typeof e?.name==`string`)&&Array.isArray(e.weeks)).map(e=>({login:U(e.login),id:H(e.id),name:U(e.name),weeks:e.weeks,days:Array.isArray(e.days)?e.days:null})),punch:wn.map(t=>Array.from({length:24},(n,r)=>V(e.stats.punch[t]?.[r]))),periodPunch:e.stats.periodPunch===!0,from:H(e.stats.from),lines:typeof e.stats.lines==`boolean`?e.stats.lines:null,agents:i(`agentDays`),releases:i(`releaseDays`),direct:i(`directDays`)&&Array.isArray(e.stats.directCommits),directCommits:Array.isArray(e.stats.directCommits)?e.stats.directCommits.filter(e=>typeof e?.sha==`string`&&Number.isSafeInteger(e.at)).map(e=>({sha:e.sha,at:e.at,subject:U(e.subject)??``,login:U(e.login),id:H(e.id),name:U(e.name),kind:typeof e.kind==`string`&&Object.hasOwn(Fn,e.kind)?e.kind:null})):[]}:null;return{weeks:e.weeks,since:e.since,...Rn(e),stats:a,reading:H(e.reading),pulls:H(e.pulls),pending:e.pending===!0,behind:e.behind===!0}}function Bn(e,t){Dn.set(e,t),t.answer.stats&&On.set(e,t.answer)}var W=e=>e.reading??e.pulls,Vn=e=>W(e)===null?e.pending?[vn,yn]:null:[hn,gn];function Hn(e,t){let n=`${e}\0${t}`;return Le(z(),n,()=>_(e,t).then(zn),{ready:e=>({answer:e,tries:0,asking:!1}),settled:r=>{Bn(e,r),Vn(r.answer)&&Un(n,r,e,t,Vn(r.answer)[0])},message:`The repository’s pulse could not be read.`,repaint:B})}function Un(e,t,n,r,i){t.asking=!0,setTimeout(()=>{z().get(e)===t&&_(n,r).then(zn).then(i=>{if(z().get(e)!==t)return null;t.behind=i.behind?(t.behind??0)+1:0;let a=W(i)!==null&&W(t.answer)!==null&&W(i)>W(t.answer)||t.behind>0&&t.behind<=_n;t.answer=i,t.until=Date.now()+De,t.tries=a?0:t.tries+1;let o=Vn(i);return o&&t.tries<o[1]?Un(e,t,n,r,o[0]):t.asking=!1,null},()=>(t.asking=!1,null)).finally(B)},i)}function Wn(e,t,n){z();let r=[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`);return Le(En,r,()=>y(e,t,n),{ready:e=>({answer:Rn(e)}),failed:e=>({status:`error`,until:Date.now()+ke,error:e?.message||`These couldn’t be read.`}),repaint:B})}var Gn=(e,t)=>e[t]===!0&&e.weeks.some(e=>e[t===`agents`?`agentDays`:`releaseDays`].some(e=>e>0)),Kn=(e,t,n,r=`days`)=>e.reduce((e,i)=>e+i[r].reduce((e,r,a)=>{let o=i.week+a*I;return o>=t&&o<=n?e+V(r):e},0),0);function qn(e,t){let n=R(t);return n-new Date(n).getUTCDay()*I-(e-1)*L}var Jn=(e,t)=>e.from===null||e.from===void 0||e.from<t;function Yn(e,t,n,r){return{weeks:n,since:e?.since??qn(n,r),...Object.fromEntries(Nn.map(t=>[t,e?.[t]??null])),stats:{...t.stats,otherPunch:t.weeks!==n},reading:e?.reading??null,pulls:e?.pulls??null,pending:e?.pending??!1}}function Xn(e,t=Date.now()){let{stats:n,since:r}=e;if(!n)return{commits:null,previous:null,agents:null,previousAgents:null,releases:null,previousReleases:null,additions:null,deletions:null,authors:null};let i=R(t),a=e.weeks*L,o=n.weeks.filter(e=>e.week>=r),s=n.weeks.length>0&&n.weeks[0].week<=r-a&&Jn(n,r-a),c=(e,t=0)=>Kn(n.weeks,r-t,i-t,e),l=e=>n.lines===!0?o.reduce((t,n)=>t+V(n[e]),0):null;return{commits:c(`days`),previous:s?c(`days`,a):null,agents:n.agents?c(`agentDays`):null,previousAgents:n.agents&&s?c(`agentDays`,a):null,releases:n.releases?c(`releaseDays`):null,previousReleases:n.releases&&s?c(`releaseDays`,a):null,additions:l(`additions`),deletions:l(`deletions`),authors:Zn(n.contributors,r).length}}function G({id:e=null,login:t,name:n}){let r=Oe(t,n);if(r)return`agent:${r}`;let i=we(t)?.id;return i==null?e===null?t?`@${t.toLowerCase()}`:`=${n}`:`#${e}`:`user:${i}`}function Zn(e,t,n=1/0){let r=new Map;for(let i of e){let{login:e,name:a}=i,o=G(i);r.set(o,(i.days??i.weeks).reduce((e,[r,i,a,o])=>r>=t&&r<n?{...e,commits:e.commits+V(i),additions:e.additions+V(a),deletions:e.deletions+V(o)}:e,r.get(o)??{key:o,login:e,name:a,commits:0,additions:0,deletions:0}))}return[...r.values()].filter(e=>e.commits>0).toSorted((e,t)=>t.commits-e.commits||(e.login??e.name).localeCompare(t.login??t.name))}function Qn(e,t){let n=e.contributors.filter(e=>G(e)===t),r=n.length>0&&n.every(e=>e.days),i=e.weeks.map(({week:e})=>({week:e,days:bn(),dayLines:Array.from({length:7},()=>[0,0]),agentDays:bn(),releaseDays:bn(),directDays:bn(),commits:0,additions:0,deletions:0}));for(let[e,t,a,o,s,c,l]of n.flatMap(e=>r?e.days:e.weeks)){let n=i[Math.floor((e-(i[0]?.week??0))/L)];if(!n||(n.commits+=V(t),n.additions+=V(a),n.deletions+=V(o),!r))continue;let u=Math.floor((e-n.week)/I);n.dayLines[u]=[n.dayLines[u][0]+V(a),n.dayLines[u][1]+V(o)];for(let[e,r]of[[`days`,t],[`agentDays`,s],[`releaseDays`,c],[`directDays`,l]])n[e][u]+=V(r)}let a=(t,i)=>e[t]===!0&&r&&n.every(e=>e.days.every(e=>e.length>i));return{...e,weeks:i,agents:a(`agents`,4),releases:a(`releases`,5),direct:a(`direct`,6),byDays:r}}function $n(e,t,n,r,i){let a=r===null?e:Qn(e,r);if(!e?.direct||!a.direct)return null;let o=Math.min(n-I,R(i)),s=e.directCommits.filter(e=>e.at>=t&&e.at<o+I&&(r===null||G(e)===r));return{count:Kn(a.weeks,t,o,`directDays`),items:s}}function er(e,t=Date.now()){let{stats:n,since:r,weeks:i}=e,a=n.lines===!0,o=e=>e.reduce((e,t)=>e+t,0);if(i>4)return n.weeks.filter(e=>e.week>=r).map(e=>({from:e.week,to:e.week+L,day:!1,commits:V(e.commits),agents:n.agents?o(e.agentDays):null,releases:n.releases?o(e.releaseDays):null,additions:a?V(e.additions):null,deletions:a?V(e.deletions):null,future:!1}));let s=R(t);return Array.from({length:i*7},(e,t)=>{let i=r+t*I,o=n.weeks.find(e=>i>=e.week&&i<e.week+L),c=o?Math.floor((i-o.week)/I):0,l=a?o?.dayLines?.[c]??null:null;return{from:i,to:i+I,day:!0,commits:V(o?.days[c]),agents:n.agents?V(o?.agentDays[c]):null,releases:n.releases?V(o?.releaseDays[c]):null,additions:l?.[0]??null,deletions:l?.[1]??null,future:i>s}})}function tr(e,t){if(!e.day||t.every(e=>e.days))return[e.from,e.to,!1];let n=e.from-new Date(e.from).getUTCDay()*I;return[n,n+L,!0]}function nr(e){if(!(e>0))return{top:1,ticks:[0,1]};let t=e/3,n=10**Math.floor(Math.log10(t)),r=Math.max(1,[1,2,5,10].map(e=>e*n).find(e=>e>=t)),i=Math.ceil(e/r)*r;return{top:i,ticks:Array.from({length:i/r+1},(e,t)=>t*r)}}var rr=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),K=e=>rr.format(e),q=(e,t,n=`${t}s`)=>`${E(e)} ${e===1?t:n}`,J=(e,t=!1,n=!1)=>new Date(e).toLocaleDateString(`en-US`,{...n?{weekday:`short`}:{},month:`short`,day:`numeric`,...t?{year:`numeric`}:{},timeZone:`UTC`}),ir=e=>new Date(e).toISOString().slice(0,10),ar=(e,t)=>new Date(e).getUTCFullYear()!==new Date(t).getUTCFullYear(),or=(e,t)=>{let n=R(t),r=ar(e,n);return e>=n?J(n,r):`${J(e,r)} \u2013 ${J(n,r)}`},sr=(e,t)=>`${e.day?``:`Week of `}${J(e.from,ar(e.from,t),e.day)}`,cr=(e,t,n={})=>`${sr(e,t)}: ${q(e.commits,`commit`)}${n.agents?`, ${E(e.agents)} with agents`:``}${n.releases?`, ${q(e.releases,`release`)}`:``}${e.additions===null?``:`, +${E(e.additions)} \u2212${E(e.deletions)} lines`}`;function lr(e,t,n){let r=new Date(e[t].from);if(n===1)return`${r.toLocaleDateString(`en-US`,{weekday:`short`,timeZone:`UTC`})} ${r.getUTCDate()}`;if(n===4)return r.getUTCDay()===0?J(e[t].from):``;if(n===13)return t%2==0?J(e[t].from):``;let i=r.getUTCMonth();return(t===0?e.length>3&&new Date(e[3].from).getUTCMonth()===i:new Date(e[t-1].from).getUTCMonth()!==i)?i===0?String(r.getUTCFullYear()):r.toLocaleDateString(`en-US`,{month:`short`,timeZone:`UTC`}):``}var ur=(e,t,n)=>t===null||e===null?null:e===t?`Same as ${n}`:`${e>t?`↑`:`↓`}${t>0?` ${Math.max(1,Math.round(Math.abs(e-t)/t*100))}%`:``} from ${E(t)} ${n}`,dr=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function fr(e,t=!1){let[n,r]=t?[`latest `,`: the year shown is as it was before.`]:[``,`.`],i=e.weeks===52?` of the last year`:``;return e.reading===null?e.pulls===null?[`GitHub is still counting this repository\u2019s ${n}commits\u2026`,`GitHub hasn\u2019t counted this repository\u2019s ${n}commits yet.`,`Ask again`]:[`Reading this repository\u2019s pull requests\u2026 ${E(e.pulls)} so far`,`${E(e.pulls)} of this repository\u2019s pull requests read so far${r}`,`Read on`]:[`Reading this repository\u2019s ${n}commits\u2026 ${E(e.reading)}${i} so far`,`${E(e.reading)} of this repository\u2019s commits${i} read so far${r}`,`Read on`]}var pr=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,mr=k`<svg viewBox="0 0 16 16" width="11" height="11" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 13 13 3M5 3h8v8"/></svg>`,hr=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,gr=e=>e.login?Ae(e.login,e.name,e.login):Ae(null,e.name);function _r(e){let t=e?.who?Me(e.who.login,e.who.name):null,n=t&&`by ${t}`;return{who:t,to:e?[n,e.when].filter(Boolean).join(` `):``,scope:e?[n,e.when??`in the period`].filter(Boolean).join(` `):`in the period`}}var vr=(e,t,n)=>e>0?k`<button type="button" class="history-link pulse-more" @click="${n}">${t?`Fewer`:`and ${q(e,`more`,`more`)}`}</button>`:j,yr=class extends kn{static properties={_column:{state:!0},_typed:{state:!0},_picked:{state:!0},_everyone:{state:!0},_person:{state:!0},_allDirect:{state:!0}};constructor(){super(),this._column=null,this._typed=!1,this._picked=null,this._everyone=!1,this._person=null,this._allDirect=!1}willUpdate(e){!e.has(`repository`)||e.get(`repository`)?.repoId===this.repository?.repoId||Object.assign(this,{_column:null,_picked:null,_everyone:!1,_person:null,_allDirect:!1})}pick(e){ie(this.repository,`pulse`,te.find(([t])=>t===e)[1].toLowerCase()),this.periodShown()}periodShown(){Object.assign(this,{_column:null,_picked:null,_everyone:!1,_allDirect:!1}),this.requestUpdate()}showList(e,t){jn[e]=t,B()}askAgain(){let{repoId:e}=this.repository,t=ne(),n=`${e}\0${t}`,r=z().get(n);r?.status!==`ready`||r.asking||(r.tries=0,Un(n,r,e,t,0),B())}render(){if(!this.repository)return j;let{repoId:e}=this.repository,t=ne(),n=Hn(e,t);n.status===`ready`&&Bn(e,n);let r=Date.now(),i=n.status===`ready`?n.answer:null,a=On.get(e),o=i?.stats&&Jn(i.stats,i.since)?i:a&&n.status!==`error`&&Jn(a.stats,qn(t,r))?Yn(i,a,t,r):i&&{...i,stats:null},s=!o&&n.status===`loading`?Dn.get(e)??null:null,c=o?{answer:o,asking:n.asking===!0}:s,l=c?.answer.stats&&(W(c.answer)!==null||c.answer.pending);return k`<div class="history-bar">${w(`pulse`)}${h(`Period`,te,t,e=>()=>this.pick(e))}${c?k`<span class="pulse-range">${or(c.answer.since,r)}</span>`:j} ${l?k`<span class="pulse-updating" role="status">${this.renderWaiting(c,fr(c.answer,!0))}</span>`:j}</div>${c?k`<div class="${`pulse-scroll${s?` is-reading`:``}`}" aria-busy="${String(n.status!==`ready`)}">${this.renderPulse(c,r)}</div>`:v(n,`Reading the repository’s pulse…`,()=>{z().delete(`${e}\0${t}`),B()})}`}renderPulse(e,t){let{answer:n}=e,r=te.find(([e])=>e===n.weeks)[2],i=Xn(n,t),a=this.narrowing(n,t),o=n.stats?null:n.reading===null?n.pulls===null?`Counting…`:`Reading pull requests…`:`Reading commits…`,s=o??(n.stats?.lines===null?`Counting…`:null),c=(e,t,i)=>n[t]?this.renderTile(e,E(n[t].count),ur(n[t].count,n[t].previous,r),`${E(n[i].count)} opened`):this.renderTile(e,`–`,`Reading…`,``),l=this.renderLists(n,a,t);return k`<section class="pulse-tiles" aria-label="Figures">${this.renderTile(`Commits`,i.commits===null?`–`:E(i.commits),o??ur(i.commits,i.previous,r),`to the default branch`)} ${this.renderTile(`Contributors`,i.authors===null?`–`:E(i.authors),o,`who made them`)} ${c(`Pull requests merged`,`merged`,`opened`)} ${c(`Issues closed`,`closed`,`created`)} ${n.stats?.lines===!1?j:this.renderTile(`Lines`,i.additions===null?`–`:k`<span class="is-added">+${E(i.additions)}</span> <span class="is-removed">−${E(i.deletions)}</span>`,s,`added and removed`,i.additions===null?j:this.renderRatio(i.additions,i.deletions))} ${i.agents===null||!Gn(n.stats,`agents`)?j:this.renderAgentsTile(i,r)}</section><div class="${`pulse-grid${l.length>2?` is-lists`:``}`}">${n.stats?k`${this.renderActivity(e,t)}${this.renderContributors(n,t)}`:k`<div class="pulse-pending pulse-wide" role="status">${this.renderWaiting(e,fr(n))}</div>`} ${l} ${n.stats?this.renderPunch(n.stats):j}</div>`}renderAgentsTile(e,t){let n=e.commits-(e.releases??0),r=e.previous===null?null:e.previous-(e.previousReleases??0),i=e.releases>0?`, ${q(e.releases,`release`)} apart`:``;return this.renderTile(k`<span data-tooltip="${`Commits an agent made or co-authored, or merged from an agent’s branch or a pull request labelled for one; releases, tagged commits changing only package.json, lockfiles and changelogs, counted in neither`}">With agents</span>`,n===0?`–`:`${dr(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:pr(dr(e.agents,n),dr(e.previousAgents,r),t),n===0?`no commits${i}`:`${E(e.agents)} of ${q(n,`commit`)}${i}`)}renderWaiting(e,[t,n,r]){return e.asking?t:k`${n} <button type="button" class="history-link" @click="${()=>this.askAgain()}">${r}</button>`}renderTile(e,t,n,r,i=j){return k`<div class="pulse-tile"><span class="pulse-tile-label">${e}</span> <span class="pulse-tile-value">${t}</span> ${i} <span class="pulse-tile-note">${n??r}</span> ${n?k`<span class="pulse-tile-note">${r}</span>`:j}</div>`}renderRatio(e,t){return e+t===0?j:k`<span class="pulse-ratio" aria-hidden="true">${[[`is-added`,e],[`is-removed`,t]].map(([n,r])=>r>0?k`<span class="${n}" style="${O({"--share":`${r/(e+t)}`})}"></span>`:j)}</span>`}renderActivity(e,t){let{answer:n}=e,r=this._person===null?null:n.stats.contributors.find(e=>G(e)===this._person)??null,i=r?Qn(n.stats,this._person):n.stats,a=er({...n,stats:i},t),o=a[0]?.day?`day`:`week`,s=r?Me(r.login,r.name):null,c=r?k`<span>a ${o} by</span><button type="button" class="pulse-picked is-person" aria-label="${`${s}\u2019s: show everyone\u2019s`}" @click="${()=>this.showPerson(null)}">${gr(r)}<span aria-hidden="true">×</span></button>`:k`<span>a ${o}</span>`,l=r&&!i.byDays&&o===`day`?`GitHub counts each contributor’s commits a week, not a day, in a repository this large: the quarter and the year show theirs.`:a.some(e=>e.commits>0)?null:`No commits${r?` by ${s}`:``} in the period.`;if(l)return k`<figure class="pulse-panel pulse-activity"><figcaption class="pulse-head"><h3>Commits</h3>${c}</figcaption><p class="pulse-note">${l}</p></figure>`;let u=nr(Math.max(...a.map(e=>e.commits))),d=i.lines===!0&&a.every(e=>e.additions!==null)?nr(Math.max(...a.flatMap(e=>[e.additions,e.deletions]))):null,f={agents:Gn(n.stats,`agents`)&&a.some(e=>e.agents!==null),releases:Gn(n.stats,`releases`)&&a.some(e=>e.releases!==null)},p=f.agents||f.releases,m=n.weeks===1,h=R(t),g=a[this._column]&&!a[this._column].future?this._column:null,_=a.findIndex(e=>e.from===this._picked),v=(e,r,i,o)=>k`<span class="${`pulse-column${r===g?` is-at`:``}${r===_?` is-picked`:``}${e.future?` is-future`:``}${e.day&&n.weeks===4&&[0,6].includes(new Date(e.from).getUTCDay())?` is-weekend`:``}`}" role="${i?`img`:j}" aria-label="${i?cr(e,t,f):j}" aria-hidden="${i?j:`true`}" @pointerenter="${()=>this.point(e.future?null:r)}" @click="${()=>this.pickColumn(a,r)}">${o}</span>`,y=(e,t)=>m&&!e.future?k`<span class="pulse-figure">${t}</span>`:j,b=(e,t,n=j)=>k`<span class="${`pulse-bar${e}`}" style="${O({"--value":`${t}`})}">${n}</span>`,x=e=>{let t=f.releases?e.releases:0,n=e.commits-t;return[...f.agents?[[``,e.agents],[` is-without`,n-e.agents]]:[[``,n]],[` is-release`,t]].map(([e,t])=>t>0?k`<span class="${`pulse-part${e}`}" style="${O({"--part":`${t}`})}"></span>`:j)};return k`<figure class="${`pulse-panel pulse-activity${m?` is-written`:``}`}" tabindex="0" aria-label="${`Commits${d?` and lines`:``} a ${o}${r?` by ${s}`:``}: the arrow keys read each ${o}, Enter picks it for its contributors`}" @keydown="${e=>this.readColumns(e,a)}" @focus="${e=>this.focusColumns(e,a)}" @blur="${()=>this.point(null)}"><figcaption class="pulse-head"><h3>Commits</h3>${c}${p?k`<span class="pulse-legend">${f.agents?k`<span class="pulse-key"></span>With agents<span class="pulse-key is-without"></span>Without`:j}${f.releases?k`<span class="pulse-key is-release"></span>Releases`:j}</span>`:j}</figcaption><div class="pulse-plots" @pointerleave="${()=>this.point(null)}"><div class="pulse-plot">${this.renderTicks(u.ticks.map(e=>[e/u.top,K(e),e===0]))}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!0,k`${y(e,E(e.commits))}${p?b(` is-split`,e.commits/u.top,x(e)):b(``,e.commits/u.top)}`))}</div></div>${d?k`<div class="pulse-head is-sub"><h3>Lines</h3><span>added and removed a ${o}</span> <span class="pulse-legend"><span class="pulse-key is-added"></span>Added<span class="pulse-key is-removed"></span>Removed</span></div><div class="pulse-plot is-diverging">${this.renderTicks([[1,`+${K(d.top)}`],[.5,`0`,!0],[0,`\u2212${K(d.top)}`]])}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!1,k`<span class="pulse-half">${y(e,`+${K(e.additions)}`)}${b(` is-added`,e.additions/d.top)}</span> <span class="pulse-half is-below">${b(` is-removed`,e.deletions/d.top)}${y(e,`\u2212${K(e.deletions)}`)}</span>`))}</div></div>`:i.lines===!1?k`<p class="pulse-note">GitHub doesn’t count lines added and removed in a repository of 10,000 commits or more.</p>`:i.lines===!0?k`<p class="pulse-note">GitHub counts this repository’s lines a week, not a day: the quarter and the year show them.</p>`:k`<p class="pulse-note" role="status">${this.renderWaiting(e,[`GitHub is still counting lines added and removed…`,`GitHub hasn’t counted lines added and removed yet.`,`Ask again`])}</p>`}<div class="${`pulse-axis${m?` is-each`:``}`}" aria-hidden="true">${a.map((e,t)=>k`<span class="${e.future?`is-future`:e.day&&e.from===h?`is-today`:``}">${lr(a,t,n.weeks)}</span>`)}</div>${g===null?j:this.renderTip(n,a,g,t,f,!r)}</div><span class="sr-only" aria-live="polite">${this._typed&&g!==null?cr(a[g],t,f):``}</span></figure>`}renderTip(e,t,n,r,i,a){let o=t[n],s=R(r),[c,l,u]=tr(o,e.stats.contributors),d=a?Zn(e.stats.contributors,c,l).slice(0,Sn):[],f=(n+.5)/t.length;return k`<div class="${`pulse-tip${f>.6?` is-left`:``}`}" style="${O({"--x":`${f}`})}" aria-hidden="true"><span class="pulse-tip-when">${sr(o,r)}${o.day?o.from===s?k`<span>today</span>`:j:r<o.to?k`<span>so far</span>`:j}</span> <span class="pulse-tip-row"><span class="${`pulse-tip-key${i.agents||i.releases?` is-none`:``}`}"></span><strong>${E(o.commits)}</strong> ${o.commits===1?`commit`:`commits`}</span> ${i.agents?k`<span class="pulse-tip-row"><span class="pulse-tip-key"></span><strong>${E(o.agents)}</strong> with agents</span>`:j} ${i.releases?k`<span class="pulse-tip-row"><span class="pulse-tip-key is-release"></span><strong>${E(o.releases)}</strong> ${o.releases===1?`release`:`releases`}</span>`:j} ${o.additions===null?j:k`<span class="pulse-tip-row"><span class="pulse-tip-key is-added"></span><strong>+${E(o.additions)}</strong> added</span> <span class="pulse-tip-row"><span class="pulse-tip-key is-removed"></span><strong>−${E(o.deletions)}</strong> removed</span>`} ${d.length>0?k`<span class="pulse-tip-people">${u?k`<span class="pulse-tip-note">Its week’s</span>`:j} ${d.map(e=>k`<span class="pulse-tip-person">${gr(e)}<strong>${E(e.commits)}</strong></span>`)}</span>`:j}</div>`}point(e){this._column=e,this._typed=!1}showPerson(e){this._person=e===this._person?null:e,this._column=null,this._allDirect=!1}pickColumn(e,t){let n=e[t];!n||n.future||(this._picked=this._picked===n.from?null:n.from,this._everyone=!1,this._allDirect=!1)}focusColumns(e,t){if(!e.target.matches?.(`:focus-visible`))return;let n=t.findIndex(e=>e.from===this._picked);this._column=n>=0?n:t.findLastIndex(e=>!e.future),this._typed=!0}readColumns(e,t){let n=t.flatMap((e,t)=>e.future?[]:[t]);if(n.length===0)return;let r=t.findIndex(e=>e.from===this._picked),i=n.indexOf(n.includes(this._column)?this._column:n.includes(r)?r:n.at(-1)),a={ArrowLeft:i-1,ArrowRight:i+1,Home:0,End:n.length-1}[e.key];if(a!==void 0)this._column=n[Math.min(Math.max(a,0),n.length-1)];else if(e.key===`Enter`||e.key===` `)this._column=n[i],this.pickColumn(t,n[i]);else if(e.key===`Escape`&&(this._picked!==null||this._column!==null))this._picked=null,this._column=null;else return;this._typed=!0,e.preventDefault()}renderTicks(e){return k`<div class="pulse-ticks" aria-hidden="true">${e.map(([e,t,n])=>k`<span class="${n?`is-zero`:j}" style="${O({"--at":`${e}`})}"><span>${t}</span></span>`)}</div>`}renderContributors(e,t){let{contributors:n}=e.stats,r=er(e,t).find(e=>e.from===this._picked)??null,[i,a,o]=r?tr(r,n):[e.since,1/0,!1],s=Zn(n,i,a),c=s[0]?.commits??1,l=e.stats.lines===!0,u=r?o?`Week of ${J(i,ar(i,t))}`:sr(r,t):null;return k`<figure class="pulse-panel pulse-people"><figcaption class="pulse-head"><h3>Contributors</h3>${u?k`<button type="button" class="pulse-picked" aria-label="${`${u}: show the whole period\u2019s`}" @click="${()=>{this._picked=null,this._everyone=!1}}">${u}<span aria-hidden="true">×</span></button>`:k`<span>by their commits in the period</span>`}</figcaption>${s.length===0?k`<p class="pulse-note">No commits ${r?o||!r.day?`that week`:`that day`:`in the period`}.</p>`:k`<ol class="${`pulse-ranks${this._person===null?``:` is-picking`}`}">${(this._everyone?s:s.slice(0,xn)).map(e=>k`<li class="${e.key===this._person?`is-person`:j}"><span class="pulse-rank-who"><button type="button" class="pulse-rank-name" aria-pressed="${String(e.key===this._person)}" @click="${()=>this.showPerson(e.key)}">${gr(e)}</button> ${e.login?k`<a class="pulse-rank-profile" href="${hr(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${Me(e.login,e.name)} on GitHub`}">${mr}</a>`:j}</span> <span class="pulse-rank-bar"><span style="${O({"--value":`${e.commits/c}`})}"></span><span class="pulse-rank-value">${E(e.commits)}</span></span> ${l?k`<span class="pulse-rank-lines"><span class="is-added">+${K(e.additions)}</span> <span class="is-removed">−${K(e.deletions)}</span></span>`:j}</li>`)}</ol>${vr(s.length-xn,this._everyone,()=>{this._everyone=!this._everyone})}`}</figure>`}renderPunch(e){let{punch:t}=e,n=Math.max(1,...t.flat());return k`<figure class="${`pulse-panel${e.otherPunch?` is-reading`:``}`}" aria-busy="${String(e.otherPunch===!0)}"><figcaption class="pulse-head"><h3>When commits are made</h3><span>by day and hour, in each author’s own time zone${e.periodPunch?``:`, not only the period’s`}</span></figcaption><div class="pulse-punch">${t.map((e,t)=>k`<span class="pulse-punch-day">${Cn[wn[t]].slice(0,3)}</span>${e.map((e,r)=>{let i=`${Cn[wn[t]]}s, ${String(r).padStart(2,`0`)}:00\u2013${String(r+1).padStart(2,`0`)}:00: ${q(e,`commit`)}`;return k`<span class="${`pulse-cell is-${e===0?0:Math.ceil(e/n*Tn)}`}" role="img" aria-label="${i}" data-tooltip="${i}"></span>`})}`)} <span></span>${Array.from({length:24},(e,t)=>k`<span class="pulse-punch-hour">${t%6==0?`${t}h`:``}</span>`)}</div><div class="pulse-scale" aria-hidden="true">Fewer${Array.from({length:Tn},(e,t)=>k`<span class="${`pulse-cell is-${t+1}`}"></span>`)}More</div></figure>`}renderLists(e,t,n){let r=e.stats?$n(e.stats,e.since,1/0,null,n):null,i=r!==null&&r.count>0,a=e.closed&&e.created?e.closed.count+e.created.count:null,o=i&&t?$n(e.stats,t.since??e.since,t.until??1/0,t.person??null,n)??{count:0,items:[]}:r;return[this.renderList(e,`pulls`,t),...i?[this.renderDirect(o,t)]:[],...i&&a===0?[]:[this.renderList(e,`issues`,t)]]}renderDirect(e,t){let n=this.repo??this.repository.repo,{to:r,scope:i}=_r(t),a=this._allDirect?e.items:e.items.slice(0,In),o=Math.max(0,e.count-e.items.length);return k`<section class="pulse-panel pulse-list" aria-label="Direct commits"><div class="pulse-head"><h3 data-tooltip="Commits pushed to the default branch, not merged from a pull request">Direct commits</h3>${t?k`<span class="pulse-narrowed">${r}</span>`:j}<span class="pulse-count">${E(e.count)}</span></div>${e.count===0?k`<p class="pulse-note">None ${i}.</p>`:k`<ol>${a.map(e=>k`<li><a class="${`pulse-item is-commit${e.kind?` is-${e.kind}`:``}`}" href="${n?`https://github.com/${n}/commit/${e.sha}`:j}" target="_blank" rel="noopener noreferrer"><span class="issue-state" role="img" aria-label="${e.kind?Fn[e.kind]:`Commit`}">${Pn}</span> <span class="pulse-item-title">${e.subject||`(no message)`}</span> <span class="pulse-item-meta"><span>${e.sha.slice(0,7)}</span><span>${gr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${Dt(e.at)}</time></span></a></li>`)}</ol>`} ${vr(e.items.length-In,this._allDirect,()=>{this._allDirect=!this._allDirect})} ${o>0?k`<p class="pulse-note">${e.items.length>0?q(o,`older commit`,`older commits`):q(o,`commit`)} not listed.</p>`:j}</section>`}narrowing(e,t){let n=this._picked===null||!e.stats?null:er(e,t).find(e=>e.from===this._picked)??null,r=this._person===null||!e.stats?null:e.stats.contributors.filter(e=>G(e)===this._person);if(!n&&!r)return null;let i=[...new Set((r??[]).flatMap(e=>e.login?[e.login]:[]))].slice(0,Ln);return{from:ir(n?.from??e.since),to:n?ir(n.to-I):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${sr(n,t)}`:`in the w${sr(n,t).slice(1)}`:null,since:n?.from??e.since,until:n?.to??1/0,person:r?this._person:null}}renderList(e,t,n=null){let[r,i]=Mn[t],[a,,o]=i.find(([e])=>e===jn[t]),s=n&&!n.nobody?Wn(this.repository.repoId,e.weeks,n):null,c=n?s?.status===`ready`?s.answer:null:e,{count:l,items:u}=c?.[a]??{count:null,items:null},d=this.repo??this.repository.repo,f=n?n.to===null?`>=${n.from}`:`${n.from}..${n.to}`:`>=${ir(e.since)}`,p=(n?.authors??[]).map(e=>` author:${e.endsWith(`[bot]`)?`app/${e.slice(0,-5)}`:e}`).join(``),m=d?`https://github.com/${d}/${t===`pulls`?`pulls`:`issues`}?q=${encodeURIComponent(`${o}${f}${p}`)}`:null,{who:g,to:_,scope:v}=_r(n);return k`<section class="pulse-panel pulse-list" aria-label="${r}"><div class="pulse-head"><h3>${r}</h3>${n?k`<span class="pulse-narrowed">${_}</span>`:j}${h(`${r} shown`,i.map(([e,t])=>[e,k`${t}<span class="n">${c?.[e]?E(c[e].count):`–`}</span>`]),a,e=>()=>this.showList(t,e))}</div>${n?.nobody?k`<p class="pulse-note">${g}’s commits name no GitHub account to find their ${r.toLowerCase()} by.</p>`:s?.status===`error`?k`<p class="pulse-note" role="alert">${s.error}</p>`:u===null?k`<p class="pulse-note" role="status">Reading…</p>`:u.length===0?k`<p class="pulse-note">None ${v}.</p>`:k`<ol>${u.map(e=>{let[n,r]=ye(t,e);return k`<li><a class="${`pulse-item is-${n}`}" href="${d?`https://github.com/${d}/${t===`pulls`?`pull`:`issues`}/${e.number}`:j}" target="_blank" rel="noopener noreferrer" @click="${n=>this.openItem(n,t,e)}"><span class="issue-state" role="img" aria-label="${r}">${fe[t][n]}</span> <span class="pulse-item-title">${e.title||`(no title)`}</span> <span class="pulse-item-meta"><span>#${e.number}</span>${e.author?k`<span>${Ee(e.author)}</span>`:j} ${e.at==null?j:k`<time datetime="${new Date(e.at).toISOString()}">${Dt(e.at)}</time>`}</span></a></li>`})}</ol>`} ${m&&u!==null&&l>u.length?k`<a class="pulse-all" href="${m}" target="_blank" rel="noopener noreferrer">All ${E(l)} on GitHub</a>`:j}</section>`}openItem(e,t,n){this.openPopup(e,{number:n.number,preview:{...n,kind:t,labels:[],comments:0}})}};customElements.get(`repository-pulse`)||customElements.define(`repository-pulse`,yr);var br=864e5,xr=[100,300,1e3],Sr=e=>e.parents.length<=1&&Number.isFinite(e.committedAt),Cr=(e,t)=>Xe(e).filter(Sr).slice(0,t).toReversed(),wr=1,Tr=.08,Er=.6;function Dr(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/br;t.push(n===0?0:t[n-1]+Math.min(Er,Math.max(Tr,i*wr)))}return t}function Or(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function kr(e,t,n){let r=new Set(e.values()),i=Array.from({length:n},(e,t)=>t).filter(e=>!r.has(e)),a=[...t].filter(([t])=>t!==``&&!e.has(t)).toSorted((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]));for(let[t]of a.slice(0,i.length))e.set(t,i.shift());return e}var Ar=.9,jr=2,Mr=1,Nr=5,Pr=1,Fr=.06;function Ir(){let e=Lr(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Lr(e,t){return{path:e,name:e.slice(e.lastIndexOf(`/`)+1),parent:t,dirs:[],files:[],depth:t?t.depth+1:0,x:t?.x??0,y:t?.y??0,tx:t?.tx??0,ty:t?.ty??0,cluster:0,radius:0,node:[0,0],at:[0,0],lx:void 0,ly:void 0,packed:!1,dirty:!0,touched:-1/0}}var Rr=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`)));function zr(e,t){let n=e.dirs.get(t);if(n)return n;let r=zr(e,Rr(t)),i=Lr(t,r),[a,o]=[0,r.dirs.length];for(;a<o;){let e=a+o>>1;r.dirs[e].name<i.name?a=e+1:o=e}return r.dirs.splice(a,0,i),e.dirs.set(t,i),ni(r),e.layout=!0,i}function Br(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=zr(e,Rr(t));i={path:t,name:t.slice(t.lastIndexOf(`/`)+1),extension:Or(t),dir:a,ox:0,oy:0,touched:r,kind:n,removed:null},a.files.push(i),e.files.set(t,i),ni(a),e.layout=!0}i.touched=r,i.kind=n,i.removed=n===`D`?i.removed??r:null,n===`D`?e.going.add(i):e.going.delete(i);for(let e=i.dir;e;e=e.parent)e.touched=r;return i}function Vr(e,t){let{dir:n}=t;n.files.splice(n.files.indexOf(t),1),e.files.delete(t.path),e.going.delete(t);let r=n;for(;r.parent&&r.files.length===0&&r.dirs.length===0;r=r.parent)r.parent.dirs.splice(r.parent.dirs.indexOf(r),1),e.dirs.delete(r.path);ni(r),e.layout=!0}var Hr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Ur(e,t,n,r,i){let a=t.map(t=>{let n=e.users.get(t.key)??{...t,x:NaN,y:NaN,active:r};return e.users.set(t.key,n),n.active=r,n}),o=Hr(n),s=o.length>1?Math.min(Fr,i/o.length):0;for(let[t,[n,i]]of o.entries())e.due.push({at:r+t*s,path:n,kind:i,users:a});e.due.sort((e,t)=>e.at-t.at)}function Wr(e,t){for(let[n,r]of Hr(t)){let t=Br(e,n,r,-1/0);t&&r===`D`&&Vr(e,t)}}function Gr(e,t,n,r=[]){let i=new Set([...e.files.values()].filter(e=>e.removed===null).map(e=>e.path));for(let[t,n]of[...e.due.map(e=>[e.path,e.kind]),...r])n===`D`?i.delete(t):i.add(t);let a=new Set(t);return[...t.filter(e=>!i.has(e)).map(e=>[e,`A`]),...n?[]:[...i].filter(e=>!a.has(e)).map(e=>[e,`D`])]}function Kr(e,t){let n=0;for(;n<e.due.length&&e.due[n].at<=t;n++){let{at:t,path:r,kind:i,users:a}=e.due[n],o=Br(e,r,i,t);if(o)for(let n of a)e.beams.push({user:n,file:o,kind:i,at:t})}n>0&&e.due.splice(0,n),e.beams=e.beams.filter(e=>t-e.at<Ar);for(let n of[...e.going])t-n.removed>=Mr&&Vr(e,n);for(let[n,r]of e.users)t-r.active>Nr+Pr&&e.users.delete(n)}var qr=6,Jr=2.2,Yr=12,Xr=Math.PI*(3-Math.sqrt(5)),Zr=46,Qr=34,$r=e=>e===0?0:qr*.62*Math.sqrt(e)+Jr;function ei(e){let t=qr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Xr),t*Math.sin(e*Xr)]}function ti(e){ri(e.root),ii(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function ni(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function ri(e){if(!e.dirty)return;for(let t of e.dirs)ri(t);e.cluster=Math.max($r(e.files.length),Jr)+Yr/2;let t={x:0,y:0,r:e.cluster},n=e.dirs.map(e=>({child:e,x:e.lx,y:e.ly,r:e.radius}));if(e.packed)_i(t,n);else{ai([t,...n.toSorted((e,t)=>t.r-e.r||(e.child.name<t.child.name?-1:1))]);for(let e of n)[e.x,e.y]=[e.x-t.x,e.y-t.y];[t.x,t.y]=[0,0]}let r=ui([t,...n]);e.radius=r.r,e.node=[-r.x,-r.y];for(let e of n)[e.child.lx,e.child.ly]=[e.x,e.y],e.child.at=[e.x-r.x,e.y-r.y];e.packed=!0,e.dirty=!1}function ii(e,t,n,r){let[i,a]=[Math.cos(r),Math.sin(r)],o=([e,r])=>[t+e*i-r*a,n+e*a+r*i];[e.tx,e.ty]=o(e.node);for(let t of e.dirs){let[n,r]=o(t.at);ii(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function ai(e){let[t,n,r]=e;if(!t||([t.x,t.y]=[0,0],!n)||([t.x,n.x,n.y]=[-n.r,t.r,0],!r))return;oi(n,t,r);let i={c:t},a={c:n},o={c:r};i.next=o.previous=a,a.next=i.previous=o,o.next=a.previous=i;e:for(let t=3;t<e.length;t++){let n=e[t];oi(i.c,a.c,n);let r=a.next,o=a.c.r,s=i.previous,c=i.c.r;do{let e=o<=c,l=e?r:s;if(si(l.c,n)){e?a=l:i=l,i.next=a,a.previous=i,t--;continue e}e?[o,r]=[o+r.c.r,r.next]:[c,s]=[c+s.c.r,s.previous]}while(r!==s.next);let l={c:n,previous:i,next:a};i.next=a.previous=a=l;let u=ci(i);for(let e=l.next;e!==a;e=e.next){let t=ci(e);t<u&&([i,u]=[e,t])}a=i.next}}function oi(e,t,n){let[r,i]=[e.x-t.x,e.y-t.y],a=r*r+i*i;if(!a){[n.x,n.y]=[t.x+n.r,t.y];return}let o=(t.r+n.r)**2,s=(e.r+n.r)**2,[c,l,u,d]=o>s?[e,-1,s,o]:[t,1,o,s],f=(a+u-d)/(2*a),p=Math.sqrt(Math.max(0,u/a-f*f));[n.x,n.y]=[c.x+l*f*r-p*i,c.y+l*f*i+p*r]}var si=(e,t)=>{let n=e.r+t.r-1e-6;return n>0&&n*n>(t.x-e.x)**2+(t.y-e.y)**2};function ci(e){let[t,n]=[e.c,e.next.c],r=t.r+n.r;return((t.x*n.r+n.x*t.r)/r)**2+((t.y*n.r+n.y*t.r)/r)**2}var li=64;function ui(e){let t=e.toSorted((e,t)=>X(`${e.x},${e.y}`)-X(`${t.x},${t.y}`)),n=[],r=null,i=0;for(let a=0;a<t.length;a++)if(!(r&&mi(r,t[a]))){if(n=fi(n,t[a]),r=Y(n),!Number.isFinite(r.x+r.y+r.r)||++i>li*t.length)return di(e);a=-1}return r}function di(e){let[t,n]=[0,1].map(t=>{let n=e.flatMap(e=>t===0?[e.x-e.r,e.x+e.r]:[e.y-e.r,e.y+e.r]);return(Math.min(...n)+Math.max(...n))/2});return{x:t,y:n,r:Math.max(...e.map(e=>Math.hypot(e.x-t,e.y-n)+e.r))}}function fi(e,t){if(e.every(e=>mi(t,e)))return[t];for(let n of e)if(!pi(t,n)&&e.every(e=>mi(Y([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!pi(Y([r,i]),t)&&!pi(Y([r,t]),i)&&!pi(Y([i,t]),r)&&e.every(e=>mi(Y([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var pi=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function mi(e,t){let n=e.r-t.r+Math.max(e.r,t.r,1)*1e-9;return n>0&&n*n>(t.x-e.x)**2+(t.y-e.y)**2}function Y([e,t,n]){if(!t)return{x:e.x,y:e.y,r:e.r};if(!n){let[n,r,i]=[t.x-e.x,t.y-e.y,t.r-e.r],a=Math.hypot(n,r)||1e-12;return{x:(e.x+t.x+n/a*i)/2,y:(e.y+t.y+r/a*i)/2,r:(a+e.r+t.r)/2}}let[r,i,a,o,s,c]=[e.x-t.x,e.x-n.x,e.y-t.y,e.y-n.y,t.r-e.r,n.r-e.r],l=e.x**2+e.y**2-e.r**2,[u,d]=[l-t.x**2-t.y**2+t.r**2,l-n.x**2-n.y**2+n.r**2],f=i*a-r*o,[p,m,h,g]=[(a*d-o*u)/(f*2)-e.x,(o*s-a*c)/f,(i*u-r*d)/(f*2)-e.y,(r*c-i*s)/f],[_,v,y]=[m**2+g**2-1,2*(e.r+p*m+h*g),p**2+h**2-e.r**2],b=-(Math.abs(_)>1e-6?(v+Math.sqrt(v*v-4*_*y))/(2*_):y/v);return{x:e.x+p+m*b,y:e.y+h+g*b,r:b}}var hi=60,gi=.5;function _i(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t.filter(e=>e.x===void 0))vi(r,e,n),n.push(r);for(let n=0;n<hi;n++){let n=!1;for(let r of t){let t=Math.hypot(r.x,r.y),i=e.r+r.r;if(t>=i-gi)continue;let a=t>1e-6?Math.atan2(r.y,r.x):X(r.child.name);[r.x,r.y]=[Math.cos(a)*i,Math.sin(a)*i],n=!0}if(yi(t,0,(e,t)=>{let r=e.r+t.r,[i,a]=[t.x-e.x,t.y-e.y];if(Math.abs(a)>=r-gi)return;let o=Math.hypot(i,a);if(o>=r-gi)return;let s=o>1e-6?Math.atan2(a,i):X(t.child.name),[c,l]=[t.r**2,e.r**2].map(n=>n/(e.r**2+t.r**2)*(r-o));[e.x,e.y]=[e.x-Math.cos(s)*c,e.y-Math.sin(s)*c],[t.x,t.y]=[t.x+Math.cos(s)*l,t.y+Math.sin(s)*l],n=!0}),!n)return}}function vi(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-gi&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-gi),i=[],a=(t,n)=>{for(let[r,a]of[[t,n],[n,t]]){let t={r:e.r};oi(r,a,t),i.push(t)}};for(let e of n)a(t,e);yi(n,2*e.r,(t,n)=>{Math.hypot(n.x-t.x,n.y-t.y)<t.r+n.r+2*e.r&&a(t,n)});let o=X(e.child.name);n.length===0&&i.push({x:Math.cos(o)*(t.r+e.r),y:Math.sin(o)*(t.r+e.r)});let s=null;for(let e of i)r(e)&&(!s||Math.hypot(e.x,e.y)<Math.hypot(s.x,s.y))&&(s=e);let c=Math.max(t.r,...n.map(e=>Math.hypot(e.x,e.y)+e.r))+e.r;[e.x,e.y]=s?[s.x,s.y]:[Math.cos(o)*c,Math.sin(o)*c]}function yi(e,t,n){let r=e.toSorted((e,t)=>e.x-e.r-(t.x-t.r));for(let[e,i]of r.entries())for(let a=e+1;a<r.length&&r[a].x-r[a].r<i.x+i.r+t;a++)n(i,r[a])}function bi(e,t,n=Qr){let r=e=>1-Math.exp(-t*e),i=r(3),a=r(6),o=r(2.5);for(let t of e.dirs.values()){t.x+=(t.tx-t.x)*i,t.y+=(t.ty-t.y)*i;for(let[e,n]of t.files.entries()){let[t,r]=ei(e);n.ox+=(t-n.ox)*a,n.oy+=(r-n.oy)*a}}let s=new Map;for(let{user:t,file:n}of e.beams){let e=s.get(t)??s.set(t,{x:0,y:0,count:0}).get(t);e.x+=n.dir.x+n.ox,e.y+=n.dir.y+n.oy,e.count++}for(let[e,t]of s){let[n,r]=[t.x/t.count,t.y/t.count];if(Number.isNaN(e.x)){let t=X(e.key);[e.x,e.y]=[n+Math.cos(t)*Zr*3,r+Math.sin(t)*Zr*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Zr,r+(e.y-r)/i*Zr];e.x+=(a-e.x)*o,e.y+=(s-e.y)*o}let c=[...e.users.values()].filter(e=>!Number.isNaN(e.x));for(let[e,t]of c.entries())for(let r of c.slice(e+1)){let[e,i]=[r.x-t.x,r.y-t.y],a=Math.hypot(e,i);if(a>=n)continue;let[s,c]=a>0?[e/a,i/a]:[Math.cos(X(r.key)),Math.sin(X(r.key))],l=(n-a)/2*o;[t.x,t.y,r.x,r.y]=[t.x-s*l,t.y-c*l,r.x+s*l,r.y+c*l]}}function X(e){let t=0;for(let n of e)t=t*31+n.codePointAt(0)|0;return(t>>>0)/2**32*2*Math.PI}function xi(e){e.layout&&ti(e);for(let t of e.dirs.values()){t.x=t.tx,t.y=t.ty;for(let[e,n]of t.files.entries())[n.ox,n.oy]=ei(e)}}function Si(e){let t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},n=(e,n,r)=>{t.minX=Math.min(t.minX,e-r),t.minY=Math.min(t.minY,n-r),t.maxX=Math.max(t.maxX,e+r),t.maxY=Math.max(t.maxY,n+r)};for(let t of e.dirs.values())n(t.x,t.y,$r(t.files.length)+Jr);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var Ci=[.5,1,2,4,8],wi=20,Ti=50,Ei=8,Di=[`background`,`text`,`muted`,`surface`,`added`,`modified`,`removed`],Oi={side:40,top:64,bottom:40},ki=3,Ai=10,Z=11,ji=72,Mi=250,Ni=1.8,Pi=2,Fi=new Set([`A`,`M`,`D`,`R`]),Ii=2,Li=new Map,Ri=new Map,zi=new Set,Bi=new Map,Vi=new Map,Hi=Fe(Li,Ri,zi,Bi),{Shown:Ui,shown:Wi,repaint:Gi}=d(Je),Ki=()=>Number(S(`replay`)??300),qi=1;C(e=>{e===`replay`&&Gi()});var Ji=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Yi(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=je(Hi(),a);if(o)return o;let s={key:a,repoId:n,path:i,count:t,commits:null,times:[],reading:!1,treeReading:!1,error:null,counted:``,counts:new Map,colors:new Map,people:null,scene:Ir(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return Hi().set(a,s),Ne(Li,Ii,e=>[...Wi].some(t=>t.replay===e),Xi),s}function Xi(e,t){if(Li.delete(e),[...Li.values()].some(e=>e.repoId===t.repoId&&e.path===t.path))return;let n=`${t.repoId}\0${t.path}\0`;for(let e of[Ri,Bi,zi])for(let t of[...e.keys()])t.startsWith(n)&&e.delete(t)}var Zi={files:[],cut:!1},Qi=e=>e.commits[0]?.parents[0]??null,Q=e=>Qi(e)?ta(e,Qi(e)):Zi,$=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,$i=(e,t)=>Ri.get($(e,t)),ea=(e,t)=>zi.has($(e,t)),ta=(e,t)=>Bi.get($(e,t)),na=(e,t)=>!(!$i(e,t.sha)||ea(e,t.sha)&&!ta(e,t.sha));function ra(e){let t=0;for(;t<(e.commits?.length??0)&&na(e,e.commits[t]);)t++;return t}function ia(e,t){if(!Array.isArray(e)||!Fi.has(e[1]))return null;let n=e=>typeof e==`string`&&(t===``||e.startsWith(`${t}/`))?e.slice(t===``?0:t.length+1):null,[r,i,a]=[n(e[0]),e[1],n(e[2])];return!r||i===`R`&&!a?null:i===`R`?[r,i,a]:[r,i]}function aa(e){let t=Q(e),n=e.commits.filter(t=>$i(e,t.sha)),r=`${t?t.files.length:`-`}\0${n.length}`;if(r===e.counted)return;e.counted=r,e.counts=new Map;let i=t=>e.counts.set(Or(t),(e.counts.get(Or(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of Hr($i(e,t.sha)))r!==`D`&&i(n);kr(e.colors,e.counts,Ei)}var oa=e=>[...e.commits.slice(e.next),...e.commits.slice(0,e.next)];function sa(e,t,n,r,i){e[t]=!0,n().then(t=>(Hi().get(e.key)===e&&r(t),null),t=>(t?.name!==`AbortError`&&(e.error=t?.message||i),null)).finally(()=>{e[t]=!1,Gi()})}function ca(e){if(e.treeReading||e.error)return;let t=Qi(e)&&!Q(e),n=t?Qi(e):oa(e).find(t=>ea(e,t.sha)&&!ta(e,t.sha))?.sha;n&&sa(e,`treeReading`,()=>u(e.repoId,e.path,n),r=>{let i=Array.isArray(r?.files)?r.files.map(t=>ia([t,`A`],e.path)?.[0]).filter(Boolean):[];Bi.set($(e,n),{files:i,cut:r?.cut===!0||!t&&!Array.isArray(r?.files)})},t?`The files the commits start from could not be read.`:`The files a commit leaves could not be read.`)}function la(e,t,n){let r=$i(e,n.sha),i=ea(e,n.sha)?ta(e,n.sha):null;return i?[...r,...Gr(t,i.files,i.cut,Hr(r))]:r}function ua(e,t){let n=Ir();n.start=Q(e),Wr(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))Wr(n,la(e,n,r));return xi(n),n}function da(e){if(e.reading||e.error||!e.commits)return;let t=ra(e)===0?wi:Ti,n=oa(e).filter(t=>!$i(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&sa(e,`reading`,()=>c(e.repoId,e.path,n),t=>{let r=new Map((Array.isArray(t?.changes)?t.changes:[]).filter(e=>typeof e?.sha==`string`).map(e=>[e.sha,e]));for(let t of n)Ri.set($(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>ia(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&zi.add($(e,t))},`What the commits changed could not be read.`)}function fa(e){let t=new Map;for(let{login:n=null,name:r=null,agent:i=null}of[{login:e.authorLogin,name:e.authorName},...e.coauthors??[]]){if(typeof n!=`string`&&typeof r!=`string`)continue;let e=typeof i==`string`&&Object.hasOwn(T,i)?i:Oe(n,r),a=e?null:we(n),o=e?`agent:${e}`:a?`user:${a.id}`:typeof n==`string`?`login:${n.toLowerCase()}`:`name:${r.toLowerCase()}`;if(t.has(o))continue;let s=e?T[e].name:a?a.name??a.login:r??n,c=e?T[e].mark??null:null,l=e?!c&&T[e].avatar?`/api/avatar/${T[e].avatar}`:null:a?`/api/avatar/${encodeURIComponent(a.id)}`:null;t.set(o,{key:o,label:s,letter:s.trim()[0]?.toUpperCase()??`?`,agent:e,mark:c,image:l})}return[...t.values()]}var pa={anthropic:[Ge,4,5,8],openai:[Ke,4,5,8],"github-copilot":[qe,0,0,24]},ma={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},ha=new Map,ga=e=>ha.get(e)??ha.set(e,new Path2D(pa[e][0])).get(e);function _a(e){let t=Vi.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,Vi.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var va=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ya=e=>e===.5?`½×`:`${e}\xD7`,ba=A`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,xa=A`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,Sa=A`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,Ca=class extends Ui{constructor(){super(),this.replay=null,this._frame=null,this._last=0,this._camera=null,this._colors=null,this._themes=null,this._resize=null,this._restless=0,this._laidOut=-1/0,this._pointer=null,this._hovered=null,this._shownNext=-1}connectedCallback(){super.connectedCallback(),zt(this),this._themes=new AbortController,globalThis.addEventListener(`deepview-theme-changed`,()=>this.themeChanged(),{signal:this._themes.signal}),this._resize=globalThis.ResizeObserver?new ResizeObserver(()=>{this.restless()}):null,this._resize?.observe(this),this._last=performance.now(),this._frame=requestAnimationFrame(e=>this.frame(e))}disconnectedCallback(){super.disconnectedCallback(),Bt(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Wi].some(e=>e.replay===this.replay)&&(this.replay.playing=!1)}updated(){let e=this.replay;if(!e)return;if(this.restless(),!e.commits){let{entry:t,more:n}=Rt(this.repository);if(t.status!==`ready`)return;if(t.commits.filter(Sr).length<e.count&&t.more){!t.loadingMore&&!t.moreError&&n();return}e.commits=Cr(t.commits,e.count),e.times=Dr(e.commits)}ca(e),da(e);let t=Q(e);t&&(aa(e),e.scene.start!==t&&this.seek(e.next),!e.started&&ra(e)>0&&(e.started=!0,e.playing=!Ji(),this.requestUpdate()))}pickCount(e){ie(this.repository,`replay`,String(e))}pickSpeed(e){qi=e,Gi()}toggle(){let e=this.replay;e?.commits?.length&&(e.ended?(this.seek(0),e.playing=!0):e.playing=!e.playing,e.started=!0,this.requestUpdate())}seek(e){let t=this.replay;if(!t?.commits||!Q(t))return;let n=Math.max(0,Math.min(e,ra(t)));Object.assign(t,{scene:ua(t,n),next:n,clock:n>0?t.times[n-1]:-.001,ended:!1,waiting:!1}),this._camera=null,this.requestUpdate()}restless(){this._restless=performance.now()+3e3}themeChanged(){this.readColors(),this.restless(),this.replay&&this.draw(this.replay,0)}frame(e){this._frame=requestAnimationFrame(e=>this.frame(e));let t=Math.min(.1,Math.max(0,(e-this._last)/1e3));this._last=e;let n=this.replay;n&&(n.playing&&n.commits&&this.play(n,t),n.next!==this._shownNext&&(this._shownNext=n.next,this.requestUpdate()),this._colors||this.readColors(),(n.playing||e<this._restless)&&(Kr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=Mi&&(ti(n.scene),this._laidOut=e),bi(n.scene,t,Math.max(Qr,ji/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*qi,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!na(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+Er)-r;Ur(e.scene,fa(t),la(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+Pi&&(e.playing=!1,e.ended=!0),(r!==e.waiting||e.ended)&&this.requestUpdate()}readColors(){let e=this.querySelector(`.replay-swatches`);if(!e)return;let t=t=>getComputedStyle(e.querySelector(`.is-${t}`)).color,n={...Object.fromEntries(Di.map(e=>[e,t(e)])),kinds:Array.from({length:Ei},(e,n)=>t(`kind-${n}`)),font:getComputedStyle(this).fontFamily},r=Object.assign(document.createElement(`canvas`),{width:1,height:1}).getContext(`2d`,{willReadFrequently:!0});n.pixels=new Map([n.muted,...n.kinds].map(e=>(r.clearRect(0,0,1,1),r.fillStyle=e,r.fillRect(0,0,1,1),[e,[...r.getImageData(0,0,1,1).data]]))),this._colors=n}draw(e,t){let n=this.querySelector(`canvas`),r=this._colors;if(!n||!r)return;let{clientHeight:i,clientWidth:a}=n;if(a===0||i===0)return;let o=globalThis.devicePixelRatio||1;(n.width!==Math.round(a*o)||n.height!==Math.round(i*o))&&(n.width=Math.round(a*o),n.height=Math.round(i*o));let s=n.getContext(`2d`);if(!s)return;s.setTransform(o,0,0,o,0,0),s.clearRect(0,0,a,i);let{scene:c,clock:l}=e,u=this.aim(c,a,i,t),d=e=>(e-u.x)*u.zoom+a/2,f=e=>(e-u.y)*u.zoom+i/2,p=e=>d(e.dir.x+e.ox),m=e=>f(e.dir.y+e.oy);s.lineCap=`round`,s.strokeStyle=r.muted,s.globalAlpha=.35,s.lineWidth=Math.max(1,Math.min(2.5,1.5*u.zoom)),s.beginPath();for(let e of c.dirs.values())e.parent&&(s.moveTo(d(e.parent.x),f(e.parent.y)),s.lineTo(d(e.x),f(e.y)));s.stroke();let h=Math.max(1.2,Jr*u.zoom),g=h<Ni,_=t=>e.colors.has(t.extension)?r.kinds[e.colors.get(t.extension)]:r.muted,v=[],y=new Map;for(let e of c.files.values()){if(e.removed!==null||l-e.touched<jr){v.push(e);continue}let[t,n]=[p(e),m(e)];if(t<-h||n<-h||t>a+h||n>i+h)continue;let r=_(e);(y.get(r)??y.set(r,[]).get(r)).push(t,n)}if(g)s.globalAlpha=1,s.drawImage(this.dotLayer(n,y,o,h*o,.85),0,0,a,i);else{s.globalAlpha=.85;for(let[e,t]of y){s.fillStyle=e,s.beginPath();for(let e=0;e<t.length;e+=2)s.moveTo(t[e]+h,t[e+1]),s.arc(t[e],t[e+1],h,0,2*Math.PI);s.fill()}}for(let e of v){let t=Math.max(0,1-(l-e.touched)/jr),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/Mr);s.globalAlpha=.85*n+.15*t,s.fillStyle=_(e),s.beginPath(),s.arc(p(e),m(e),h*(1+t)*n,0,2*Math.PI),s.fill()}s.lineWidth=1.5;for(let e of c.beams)Number.isNaN(e.user.x)||(s.globalAlpha=Math.max(0,1-(l-e.at)/Ar)*.85,s.strokeStyle=e.kind===`A`?r.added:e.kind===`D`?r.removed:r.modified,s.beginPath(),s.moveTo(d(e.user.x),f(e.user.y)),s.lineTo(p(e.file),m(e.file)),s.stroke());let b=(e,t,n)=>{s.strokeText(e,t,n),s.fillText(e,t,n)};s.lineJoin=`round`,s.globalAlpha=1,s.textBaseline=`middle`,s.font=`11px ${r.font}`,s.fillStyle=r.muted,s.strokeStyle=r.background,s.lineWidth=3;for(let e of c.dirs.values())!e.parent||e.depth>1&&l-e.touched>jr||b(e.name,d(e.x)+Math.max(6,($r(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=Ai){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/jr),b(e.name,p(e)+h*2+3,m(e))}s.textAlign=`center`;for(let e of c.users.values()){if(Number.isNaN(e.x))continue;let[t,n]=[d(e.x),f(e.y)];s.globalAlpha=Math.max(0,Math.min(1,1-(l-e.active-Nr)/Pr));let[i,a]=Object.hasOwn(ma,e.agent)?ma[e.agent]:[r.surface,r.text];s.fillStyle=i,s.beginPath(),s.arc(t,n,Z,0,2*Math.PI),s.fill();let o=e.image?_a(e.image):null;if(e.mark&&Object.hasOwn(pa,e.mark)){let[,r,i,o]=pa[e.mark],c=Z*2*.62;s.save(),s.translate(t-c/2,n-c/2),s.scale(c/o,c/o),s.translate(-r,-i),s.fillStyle=a,s.fill(ga(e.mark)),s.restore(),s.beginPath(),s.arc(t,n,Z,0,2*Math.PI)}else o?(s.save(),s.clip(),s.drawImage(o,t-Z,n-Z,Z*2,Z*2),s.restore()):(s.fillStyle=r.text,s.font=`600 11px ${r.font}`,s.fillText(e.letter,t,n+.5));s.strokeStyle=r.muted,s.lineWidth=1,s.stroke(),s.fillStyle=r.text,s.strokeStyle=r.background,s.lineWidth=3,s.font=`11px ${r.font}`,b(e.label,t,n+Z+9)}s.textAlign=`start`,s.globalAlpha=1,this.hover(c,d,f,p,m,h)}dotLayer(e,t,n,r,i){let[a,o]=[e.width,e.height];if(this._dots?.wide!==a||this._dots?.high!==o){let e=new ImageData(a,o);this._dots={wide:a,high:o,image:e,pixels:new Uint32Array(e.data.buffer),layer:Object.assign(document.createElement(`canvas`),{width:a,height:o})}}let{image:s,pixels:c,layer:l}=this._dots;c.fill(0);for(let[e,s]of t){let[t,l,u,d]=this._colors.pixels.get(e)??[128,128,128,255],f=(Math.round(d*i)<<24|u<<16|l<<8|t)>>>0;for(let e=0;e<s.length;e+=2){let t=s[e]*n,i=s[e+1]*n,l=Math.max(0,Math.round(t-r)),u=Math.min(a,Math.round(t+r)),d=Math.min(o,Math.round(i+r));for(let e=Math.max(0,Math.round(i-r));e<d;e++)for(let t=e*a+l,n=e*a+u;t<n;t++)c[t]=f}}return l.getContext(`2d`).putImageData(s,0,0),l}aim(e,t,n,r){let i=Si(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(ki,(t-2*Oi.side)/Math.max(1,i.maxX-i.minX),(n-Oi.top-Oi.bottom)/Math.max(1,i.maxY-i.minY))):1,s={x:a?(i.minX+i.maxX)/2:0,y:a?(i.minY+i.maxY)/2-(Oi.top-Oi.bottom)/2/o:0,zoom:o};if(this._camera){let e=1-Math.exp(-r*1.8);this._camera.x+=(s.x-this._camera.x)*e,this._camera.y+=(s.y-this._camera.y)*e,this._camera.zoom=Math.exp(Math.log(this._camera.zoom)+(Math.log(s.zoom)-Math.log(this._camera.zoom))*e)}else this._camera=s;return this._camera}hover(e,t,n,r,i,a){let o=this._pointer,s=null;if(o){let c=(e,t)=>Math.hypot(e-o.x,t-o.y),l=[...e.users.values()].find(e=>!Number.isNaN(e.x)&&c(t(e.x),n(e.y))<=Z+2),u=a+4,d=null;if(!l)for(let t of e.files.values()){let e=c(r(t),i(t));e<=u&&([u,d]=[e,t])}let f=l||d?null:[...e.dirs.values()].find(e=>e.parent&&c(t(e.x),n(e.y))<=6);s=l?l.label:d?this.pathName(d.path):f?`${this.pathName(f.path)}/`:null}let c=s?{text:s,x:o.x,y:o.y}:null;(c?.text!==this._hovered?.text||c?.x!==this._hovered?.x||c?.y!==this._hovered?.y)&&(this._hovered=c,this.requestUpdate())}pathName(e){return this.repository.path?`${this.repository.path}/${e}`:e}pointer(e){let t=e.currentTarget.getBoundingClientRect();this._pointer=e.type===`pointerleave`?null:{x:e.clientX-t.left,y:e.clientY-t.top},this.restless()}render(){if(!this.repository)return j;let e=Yi(this.repository,Ki());this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:Rt(this.repository),n=e.commits?.length??0,r=ra(e),i=e.next>0?e.commits[e.next-1]:null,a=e.commits?e.people??=new Set(e.commits.flatMap(e=>fa(e).map(e=>e.key))).size:0,o=(e.commits?Q(e):null)?.cut||e.commits?.some(t=>ea(e,t.sha)&&ta(e,t.sha)?.cut),s=e.commits&&n>0?`${E(n)} commit${n===1?``:`s`} by ${E(a)}, ${va(e.commits[0].committedAt)} \u2013 ${va(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return k`<div class="history-bar">${w(`replay`)}${h(`Commits played`,xr.map(e=>[e,k`Last ${E(e)}`]),e.count,e=>()=>this.pickCount(e))}${s?k`<span class="history-summary">${s}</span>`:j}</div><div class="replay-stage"><canvas class="replay-canvas" role="img" aria-label="${i?`The repository\u2019s files as of ${va(i.committedAt)}, ${E(e.next)} of ${E(n)} commits played`:`The repository’s files, as its commits change them`}" @pointermove="${this.pointer}" @pointerleave="${this.pointer}"></canvas>${i?k`<div class="replay-day"><time datetime="${new Date(i.committedAt).toISOString()}">${va(i.committedAt)}</time> <span>${E(e.next)} of ${E(n)}</span></div>${this.renderCommit(i)}`:j} ${this.renderKey(e)} ${this.renderStatus(e,t,r)} ${this._hovered?k`<div class="replay-tip" style="${O({left:`${this._hovered.x}px`,top:`${this._hovered.y}px`})}">${this._hovered.text}</div>`:j}<div class="replay-swatches" aria-hidden="true">${[...Di,...Array.from({length:Ei},(e,t)=>`kind-${t}`)].map(e=>k`<span class="${`is-${e}`}"></span>`)}</div></div>${this.renderControls(e,n,r)}`}renderCommit(e){let t=kt(this.repo??this.repository.repo),n=e.sha.slice(0,7);return k`<p class="replay-commit">${t?k`<a class="replay-sha" href="${`${t}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" aria-label="${`Commit ${n} on GitHub`}">${n}</a>`:k`<code class="replay-sha">${n}</code>`} <span class="replay-commit-subject">${At(e.subject||`(no message)`,t)}</span> <span class="replay-commit-author">${Pe(e.authorLogin,e.authorName,e.coauthors)}</span></p>`}renderKey(e){if(e.colors.size===0)return j;let t=[...e.colors].toSorted((t,n)=>(e.counts.get(n[0])??0)-(e.counts.get(t[0])??0));return k`<ul class="replay-key" aria-label="Kinds of files">${t.map(([e,t])=>k`<li><span class="${`replay-dot is-kind-${t}`}"></span>.${e}</li>`)}<li><span class="replay-dot is-muted"></span>Other</li><li class="replay-beams"><span class="replay-beam is-added"></span>Added</li><li><span class="replay-beam is-modified"></span>Modified</li><li><span class="replay-beam is-removed"></span>Removed</li></ul>`}renderStatus(e,t,n){let[r,i,a]=t?.entry.status===`error`?[`history`,t.entry.error,()=>Vt(t.key)]:e.error?[`replay`,e.error,()=>{e.error=null,Gi()}]:t?.entry.status===`ready`&&t.entry.moreError?[`more`,t.entry.moreError,()=>t.more()]:[];if(a)return Ve(r,k`<div class="replay-status is-error"><p role="alert">${i}</p><button type="button" @click="${a}">Retry</button></div>`);if(t){let e=t.entry.status===`ready`?t.entry.commits.length:0;return k`<div class="replay-status" role="status">${e>0?`Reading commits\u2026 ${E(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?k`<div class="replay-status">No commits to play.</div>`:Q(e)?n===0?k`<div class="replay-status" role="status">Reading what the commits changed…</div>`:e.waiting?k`<div class="replay-status is-waiting" role="status">Reading what the next commits changed…</div>`:j:k`<div class="replay-status" role="status">Reading the files as they were before ${va(e.commits[0].committedAt)}…</div>`}renderControls(e,t,n){let r=e.ended?`Play again`:e.playing?`Pause`:`Play`,i=n>0&&!!(e.commits&&Q(e)),a=e=>`${t>0?e/t*100:0}%`;return k`<div class="replay-controls"><button type="button" class="replay-play" aria-label="${r}" ?disabled="${!i}" @click="${()=>this.toggle()}"><svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.ended?Sa:e.playing?xa:ba}</svg></button><div class="replay-track" style="${O({"--buffered":a(n),"--played":a(e.next)})}"><input type="range" min="0" max="${t}" step="1" .value="${String(e.next)}" aria-label="Commits played" ?disabled="${!i}" aria-valuetext="${`${E(e.next)} of ${E(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div>${h(`Speed`,Ci.map(e=>[e,ya(e)]),qi,e=>()=>this.pickSpeed(e))}</div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,Ca);var wa=8,Ta=20,Ea=Fe(new Map),{Shown:Da,shown:Oa,repaint:ka}=d(ce);C(e=>{(e===`issues`||e===`pulls`)&&ka()}),b(e=>{for(let t of Oa)e&&t.repository?.repoId!==e.repoId||t.requestUpdate()});function Aa(e){if(!Array.isArray(e?.items))throw TypeError(`The server answered with no list.`);return{items:e.items.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`&&Array.isArray(e.labels)),counts:{open:e.counts?.open??0,closed:e.counts?.closed??0},more:e.more===!0,after:e.more===!0?e.after:null,readAt:t(e)}}function ja(e,t,n,s){let c=e=>e.state===`open`==(n===`open`),l=s.items.map(t=>r(e,t.number)??{item:t,readAt:s.readAt}),u=l.map(({item:e})=>e),d=new Set(u.map(e=>e.number)),f=s.more?s.items.at(-1)?.updatedAt??0:null,p=i(e,t).filter(({item:e,readAt:t})=>t>s.readAt&&!d.has(e.number)&&c(e)&&(f===null||(e.updatedAt??0)>=f)).toSorted((e,t)=>(t.item.updatedAt??0)-(e.item.updatedAt??0));for(let{item:e}of p){let t=u.findIndex(t=>(t.updatedAt??0)<(e.updatedAt??0));u.splice(t===-1?u.length:t,0,e)}let m=s.countsAt??s.readAt,h=e=>{let t=a(e.item),n=e.item.closedAt??e.item.mergedAt??null;return(t===`closed`?n!==null&&n<=m:(e.item.updatedAt??1/0)<=m)?t:s.counted?.get(e.item.number)??o(e,m)},g=new Map(i(e,t).map(e=>[e.item.number,e]));for(let e of l)g.has(e.item.number)||g.set(e.item.number,e);let _=0;for(let e of g.values()){let t=h(e);t!==a(e.item)&&(_+=t===n?1:-1)}let v=n===`open`?`closed`:`open`;return{items:u,counts:{[n]:Math.max(0,s.counts[n]-_),[v]:Math.max(0,s.counts[v]+_)}}}function Ma(e,t,n){let r=new Map(i(e,t).map(e=>[e.item.number,o(e,n.countsAt)]));for(let e of n.items)r.has(e.number)||r.set(e.number,a(e));return n.counted=r,n}var Na=(e,t)=>l(e,t,e=>[`#${e.number}`,e.title,e.author??``,Te(e.author)??``,e.head??``,...e.labels.map(e=>e.name)]),Pa=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Fa=e=>e<1e3?String(e):Pa.format(e);function Ia(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>wa?wa-1:wa),r=e=>k`<span class="issue-label" style="${O(e.color?{"--label":`#${e.color}`}:{})}" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span>`,i=e=>k`${r(e[0])}${e.length>1?k`<span class="issue-labels-rest" style="${O({"--labels":String(e.length-1)})}">${i(e.slice(1))}</span>`:j}`;return k`${n.length>0?i(n):j}${t>n.length?k`<span class="issue-label is-more">+${t-n.length}</span>`:j}`}var La={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`,unlocked:`locked by no lockfile read`};function Ra({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,Ta);return[t>0?`${e.slice(0,Ta).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${La[e.unsupported]})`).join(`, `)}${a>0?` and ${E(a)} more`:``} can\u2019t be reviewed`:null,n.length>0||r>0||i?`not every lockfile it changes was read`:null].filter(Boolean).join(`; `)}function za(e){if(e.status!==`ready`)return j;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=re(e),o=e.review?oe(e).count:0,s=se(e);if(t.length===0&&o===0&&!s&&!e.pending)return j;let c=i?`+`:``,l=t=>{let n=ae(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${La[t.unsupported]}`:n===`baseline`?`, needs no review`:t.reviewed?`, reviewed`:t.rejected?`, rejected`:n?`, ${t.reviews}/${e.review.required} reviews`:``},u=e=>`${e.name}@${e.version??`?`}${e.patch?`, patched`:``}${e.was?` (was ${e.was.join(`, `)}${l(e)})`:` (new${l(e)})`}`,d=t.length-Ta,f=[t.length>0?`New in its lockfiles: ${t.slice(0,Ta).map(u).join(`, `)}${d>0?` and ${E(d)}${c} more`:i?` and more`:``}`:null,o>0?`${E(o)} on the base branch unreviewed`:null,s?`Its review fails: ${Ra(s)}`:null,e.pending?`Stasis is still working out what its stasis.config.json’s entries reach`:null].filter(Boolean).join(`. `),p=[n?`${E(n)} new`:null,r?`${E(r)} updated`:null].filter(Boolean).join(`, `),m=a&&o?`${E(a)} + ${E(o)} to review`:a?`${E(a)} to review`:o?`${E(o)} unreviewed`:``;return k`<span class="issue-deps" data-tooltip="${f}">${ve}<span class="issue-deps-names">${[...new Set(t.map(e=>e.name))].join(`, `)}</span> ${p?k`<span class="issue-deps-count">${p}${c}</span>`:j} ${s?k`<span class="issue-deps-review is-failed">${s.count>0?`${E(s.count)} can\u2019t be reviewed`:`lockfiles unread`}</span>`:e.pending?k`<span class="issue-deps-review is-pending" role="status">${m?`${m}, `:``}Stasis building…</span>`:e.review?m?k`<span class="issue-deps-review is-wanted">${m}</span>`:k`<span class="issue-deps-review is-passed" role="img" aria-label="Every version reviewed">${me.success[1]}</span>`:j}</span>`}var Ba=class extends Da{static properties={kind:{},_filter:{state:!0}};constructor(){super(),this.kind=`issues`,this._filter=``}updated(){this.watchMore(()=>!this._filter.trim())}list(e){let{repoId:t}=this.repository,r=this.kind,i=i=>m(t,r,{state:e,after:i}).then(Aa).then(e=>(n(t,e.items,e.readAt,r),e));return Re(Ea,`${t}\0${r}\0${e}`,{first:()=>i(null),next:i,message:`The list could not be read.`,repaint:ka,ready:e=>Ma(t,r,{...e,countsAt:e.readAt}),merge:(e,n)=>{e.items=D(e.items,n.items,e=>e.number),n.readAt>=e.countsAt&&(e.counts=n.counts,e.countsAt=n.readAt,Ma(t,r,e))}})}pick(e){ie(this.repository,this.kind,e)}render(){if(!this.repository)return j;let e=S(this.kind)??`open`,{key:t,entry:n,more:r}=this.list(e),i=n.status===`ready`,a=this.kind===`pulls`?`pull requests`:`issues`,o=e===`open`?`closed`:`open`,s=Ea().get(`${this.repository.repoId}\0${this.kind}\0${o}`),c=i?ja(this.repository.repoId,this.kind,e,n):null,l=c?c.counts:s?.status===`ready`?ja(this.repository.repoId,this.kind,o,s).counts:null,u=e=>l?k`<span class="n">${E(l[e])}</span>`:j,d=c?Na(c.items,this._filter):[];return k`<div class="history-bar issues-bar">${w(this.kind)}${h(this.kind===`pulls`?`Pull requests`:`Issues`,[[`open`,k`Open${u(`open`)}`],[`closed`,k`Closed${u(`closed`)}`]],e,e=>()=>this.pick(e),{spaced:!0})}<input class="issues-filter" type="search" placeholder="Filter" aria-label="${`Filter the ${a} read`}" .value="${this._filter}" @input="${e=>{this._filter=e.target.value}}"> ${c&&this._filter.trim()?k`<span class="history-summary">${d.length} of ${c.items.length} read</span>`:j}</div>${c?this.renderTiles(n,c.items,d,r,`${e} ${a}`):v(n,`Reading the ${a}\u2026`,()=>{Ea().delete(t),ka()})}`}renderTiles(e,t,n,r,i){if(t.length===0)return k`<div class="bundles-slide-placeholder">No ${i}.</div>`;let a=this.repo??this.repository.repo,o=this.kind===`pulls`?`pull`:`issues`;return k`<div class="issues-scroll">${n.length===0?k`<p class="history-note">None of the ${i} read match.</p>`:k`<ol class="issues-grid" aria-label="${i}">${n.map(e=>{let[t,n]=ye(this.kind,e),r=this.renderTile(e,t,n);return k`<li class="${Be({"issue-tile":!0,[`is-${t}`]:!0})}">${a?k`<a class="issue-body" href="${`https://github.com/${a}/${o}/${e.number}`}" target="_blank" rel="noopener noreferrer" @click="${t=>this.openTile(t,e)}">${r}</a>`:k`<div class="issue-body" @click="${t=>this.openTile(t,e)}">${r}</div>`}</li>`})}</ol>`} ${g(e,r,`More`,`history-more issues-more`)}</div>`}openTile(e,t){this.openPopup(e,{number:t.number,preview:{...t,kind:this.kind}})}renderTile(t,n,r){let i=this.kind===`pulls`,a=i&&t.state===`open`&&x(t)?ee(this.repository.repoId,t.number,!0,{listed:!0}):null,o=t.updatedAt==null?null:new Date(t.updatedAt),s=i&&t.checks?me[t.checks]:null,c=i&&t.state===`open`&&t.review?he[t.review]:null,l=t.comments>0?`${E(t.comments)} comment${t.comments===1?``:`s`}`:null,u=(e,[n,r])=>k`<span class="${`issue-${e} is-${t[e]}`}" role="img" aria-label="${n}" data-tooltip="${n}">${r}</span>`;return k`<span class="issue-rail"><span class="issue-state" role="img" aria-label="${r}">${fe[this.kind][n]}</span> ${i?k`<span class="issue-marks">${c?u(`review`,c):j}${s?u(`checks`,s):j}</span>`:j} ${l?k`<span class="issue-comments" role="img" aria-label="${l}" data-tooltip="${l}">${pe}<span>${Fa(t.comments)}</span></span>`:j} </span><span class="issue-lines"><span class="issue-name">${t.title||`(no title)`}</span> <span class="issue-meta"><span class="issue-number">#${t.number}</span> <span class="issue-author">${Ee(t.author,t.author??`ghost`)}</span> ${o?k`<time datetime="${o.toISOString()}">${Dt(t.updatedAt)}</time>`:j} </span>${t.labels.length>0||t.moreLabels>0?k`<span class="issue-labels">${Ia(t)}</span>`:j} ${i&&t.head?k`<span class="issue-branch"><code>${t.head}</code>${t.base?k`<span aria-hidden="true">→</span><code>${t.base}</code>`:j} <span class="issue-diff"><span class="is-added">+${E(t.additions)}</span> <span class="is-deleted">−${E(t.deletions)}</span></span></span>`:j} ${i&&t.state===`open`?e(t.reviews):j} ${a?za(a):j}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,Ba);