@preventive/triage 1.0.0-alpha.87 → 1.0.0-alpha.88
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/common/default-scan-models.ts +1 -0
- package/common/line-diff.d.ts +2 -1
- package/common/line-diff.js +12 -5
- package/common/pretty-json.js +25 -0
- package/common/pretty-print.d.ts +1 -0
- package/common/pretty-print.js +5 -0
- package/out/activity.js +2 -2
- package/out/{chunk-Q2NFBTNH.js → chunk-4GHLPL2P.js} +1 -1
- package/out/chunk-5PWEAEA5.js +1 -0
- package/out/chunk-7KUZQB6S.js +267 -0
- package/out/{chunk-PSS7UX5T.js → chunk-A4HSJCXG.js} +1 -1
- package/out/{chunk-6CCSTJWB.js → chunk-ESXA7KID.js} +1 -1
- package/out/{chunk-WKXQOUNH.js → chunk-U6JONPTN.js} +1 -1
- package/out/chunk-VRFGZ6MV.js +1 -0
- package/out/client-managed.js +1 -1
- package/out/compare.js +13 -13
- package/out/dialogs.js +22 -22
- package/out/index.html +4 -4
- package/out/scan.js +1 -1
- package/out/view.js +15 -15
- package/package.json +2 -2
- package/server-managed/bundle-build-worker.js +13 -6
- package/server-managed/bundle-build.ts +7 -5
- package/server-managed/npm-delta-worker.js +56 -8
- package/server-managed/npm-delta.ts +1 -1
- package/server-managed/pretty-format.d.ts +3 -2
- package/server-managed/pretty-format.js +17 -3
- package/server-managed/pretty-print.ts +18 -16
- package/server-managed/stasis-dependencies.ts +14 -5
- package/server-managed/type-only-proof.js +22 -2
- package/out/chunk-5LY6QSPD.js +0 -265
- package/out/chunk-7PXMWWTQ.js +0 -1
- package/out/chunk-ZKJ7COEH.js +0 -1
- /package/out/{chunk-3YPZ7UBC.js → chunk-WBK5ZN4K.js} +0 -0
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-
|
|
2
|
-
r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function Rt(e,t,n,r){if(!e?.length)return A;let i=e=>{let t=Ve({"history-ref":!0,[`is-${e.kind}`]:!0,"is-default":e.main===!0,"is-shown":e.kind===n.kind&&e.name===n.name}),i=O`${e.kind===`tag`?Ge(We):e.kind===`pull`?Ge(Ue):A}<span>${e.name}</span>`;return e.kind===`pull`&&r?O`<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>`:O`<span class="${t}">${i}</span>`},a=e.slice(rt);return O`<span class="history-refs" style="${D({"--ref":`var(--lane-${t})`})}">${e.slice(0,rt).map(i)}${a.length>0?O`<span class="history-ref is-more" data-tooltip="${a.map(e=>e.name).join(`, `)}">+${a.length}</span>`:A}</span>`}function zt(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)=>ve(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 St(e)}),c=t===`path`?null:vt,l=gt(o,s,c);return!a||l.status!==`ready`||l.refreshing||l.sought.has(r)||l.retryAt>Date.now()||wt(l.commits,l.pulls??[]).some(e=>e.sha===r)||_t(o,l,s,c,r),a&&l.status===`error`&&l.code===`github-token-required`?(ut.add(n),zt(e,`revision`)):{mode:t,key:o,entry:l,more:()=>yt(o,l,s,c)}}var Bt=e=>zt(e,e.path?`path`:`revision`),Vt=e=>{ft.add(e)},Ht=e=>{ft.delete(e)};function Ut(e){M().delete(e),N()}var Wt=class extends dt{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`:(M(),ut.has(e)?`revision`:lt)}history(e){return zt(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:Ze(e===`unmerged`?Ct(t.commits,t.pulls??[],a):wt(t.commits,t.pulls??[])),s=e===`all`?a:e===`revision`?o[0]?.sha:null,c=$e(o,{linear:i,trunk:s&&!i?Qe(o,s):null,colors:nt});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){lt=e,N()}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`);y({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(it)]:[],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(${it})`))e.tabIndex=e===s?0:-1;s.focus()}}render(){if(!this.repository)return A;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=ut.has(this.repository.repoId);return O`<div class="history-bar">${h(`commits`)} ${e===`path`?O`<span class="history-scope">Commits touching <code>${this.repository.path}</code></span>`:d?O`<span class="history-scope">Every branch needs your GitHub sign-in.</span>`:E(`Branches`,[[`all`,`All branches`],[`unmerged`,`Unmerged`]],e,e=>()=>this.pick(e),{spaced:!0})} ${i?O`<span class="history-summary">${u}${l>0?` on ${l} branch${l===1?``:`es`}`:``}</span>`:A}</div>${i?this.renderCommits(e,n,r,o,a):Ae(n,`Reading the history…`,()=>Ut(t))}`}renderCommits(e,t,n,r,i){if(r.rows.length===0&&(e!==`unmerged`||!t.more&&!t.moreError))return O`<div class="bundles-slide-placeholder">${e===`unmerged`?`Every branch read is merged.`:`No commits.`}</div>`;let a=this.repository.commit,o=x(this.repository,this.refs),s=kt(t,i),c=Math.max(0,r.rows.findIndex(e=>e.commit.sha===a)),l=At(this.repo??this.repository.repo);return O`<div class="history-scroll">${e===`all`&&!t.refreshing&&!(t.retryAt>Date.now())&&!r.rows.some(e=>e.commit.sha===a)?O`<p class="history-note"><code>${a.slice(0,7)}</code> isn’t among these commits.</p>`:A}<div class="history-lines" style="${D({"--history-graph":`${Pt(r)}px`})}">${Lt(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 O`<li class="${Ve({"history-row":!0,"is-shown":e.sha===a})}">${l?O`<a class="history-sha" href="${`${l}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${u} on GitHub`}">${u}</a>`:O`<code class="history-sha">${u}</code>`} ${Rt(r,t,o,l)} <span class="history-subject" id="${`history-subject-${e.sha}`}">${jt(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`:A}" @click="${()=>this.open(e,r)}"><span class="history-author">${Ne(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?O`<time class="history-time" datetime="${i.toISOString()}">${Ot(e.committedAt)}</time>`:O`<span class="history-time"></span>`}</button></li>`})}</ol></div>${t.cut?O`<p class="history-note">Only the first 5,000 branches by name are read.</p>`:A} ${De(t,n,`Older commits`)}</div>`}};customElements.get(`repository-history`)||customElements.define(`repository-history`,Wt);function Gt(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 Kt=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,qt=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],Jt=new Set([`claude`,`codex`]);function Yt({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,qt(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}=Gt(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=Kt(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}=Gt(t.head);n&&s(e,[n]);let i=Kt(t);t.signals.agents.length>0?i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`):(i&&(n||qt(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 P=e=>(t,n)=>(e(t)??0)-(e(n)??0);function Xt({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(P(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(P(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>Kt(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>Gt(e.head).issue??[]),...o(`branch:`).flatMap(e=>Gt(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(P(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(P(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=>!Jt.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 Zt(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 Yt(e).flatMap(e=>Xt(e,n)??[]).filter(e=>!r(e)).toSorted(P(e=>e.updatedAt)).toReversed()}var Qt=/^[a-z][a-z\d-]{0,31}$/u,$t=/^(?:app|user)-[1-9]\d{0,11}$/u,en=12,tn=C(new Map),{Shown:nn,repaint:rn}=T(Ye);u(e=>{e===`agents`&&rn()});function an(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`&&Qt.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`&&$t.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 on=e=>Object.assign(e,{sessions:Zt(e,{branchesSince:e.after?.pulls?Math.min(...e.pulls.map(e=>e.updatedAt??1/0)):null})}),sn=(e,t,n)=>Se(e.filter(e=>t===`all`||e.agents.includes(t)),n,e=>[e.title,...e.authors,...e.authors.map(Ie),...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])]),cn={open:`open`,merged:`merged`,closed:`closed`,branch:`draft`},ln=e=>(e.agents??[]).map(e=>e.id).filter(t=>(e.sessions??[]).some(e=>e.agents.includes(t))),un=e=>[`claude`,`codex`,...ln(e)],dn=[[`pulls`,re,`pull request`,`pull requests`],[`branches`,ie,`branch`,`branches`],[`commits`,ae,`commit to the default branch without a pull request`,`commits to the default branch without a pull request`]];function fn(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 pn(e,t,n){let r=2*Math.PI*9;return O`<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?k`<circle class="read-gauge-arc" cx="11" cy="11" r="9" transform="rotate(-90 11 11)" stroke-dasharray=${`${r*e/100} ${r}`}/>`:A}</svg> ${e===100?O`<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>`:O`<span class="read-gauge-value" aria-hidden="true">${e}%</span>`}</span>`}function mn(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 hn=class extends nn{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=>Ce(e,t??{}).then(an);return ye(tn,`${e}`,{first:()=>t(null).then(e=>(ce(e.agents),e)),next:t,message:`The agents' work could not be read.`,repaint:rn,ready:on,merge:(e,t)=>{e.pulls=w(e.pulls,t.pulls,e=>e.number),e.commits=w(e.commits,t.commits,e=>e.oid);let n=e.sessions.length;on(e),e.stalled=e.sessions.length<=n}})}pick(e){p(this.repository,`agents`,e)}render(){if(!this.repository)return A;let{key:e,entry:t,more:n}=this.list(),r=t.status===`ready`,i=r?t.sessions:[],a=e=>r?O`<span class="n">${(e===`all`?i:i.filter(t=>t.agents.includes(e))).length}${t.more?`+`:``}</span>`:A,o=c(`agents`),s=un(t).includes(o)?o:`all`,l=sn(i,s,this._filter);return O`<div class="history-bar issues-bar">${h(`agents`)}${E(`Agents`,[[`all`,O`All${a(`all`)}`],...un(t).map(e=>[e,O`${ue(e)}${le(e)}${a(e)}`])],s,e=>()=>this.pick(e),{kindOf:e=>e===`all`?A:`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):A} ${r?pn(fn(t),`${t.pulls.length} pull request${t.pulls.length===1?``:`s`} read`,t.loadingMore):A}</div>${r?this.renderSessions(t,l,n,s):Ae(t,`Reading what the agents did…`,()=>{tn().delete(e),rn()})}`}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 O`<span class="agent-totals">${[...ln(e),`claude`,`codex`].filter(n).map(n=>{let r=mn(e.sessions,n);return O`<span class="agent-stats" role="group" aria-label="${le(n)}"><span class="${`agent-mark is-${n}`}">${ue(n)}</span> ${dn.filter(([e])=>r[e]>0).map(([e,n,i,a])=>{let o=`${S(r[e])}${t[e]?`+`:``}`,s=`${o} ${r[e]===1&&!t[e]?i:a}`;return O`<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`:`${le(r)} sessions`;return O`<div class="issues-scroll">${t.length>0?O`<ol class="issues-grid" aria-label="Sessions">${t.map(e=>this.renderSession(e))}</ol>`:O`<p class="history-note">${e.sessions.length>0&&this._filter.trim()?`None of the ${i} read match.`:`No ${i} among those read.`}</p>`} ${De(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=de(e,t),r=e.updatedAt==null?null:new Date(e.updatedAt),i=e.authors.find(e=>!Re(e)),a=e.pulls.length+e.commits.length,o=r?O`<time datetime="${r.toISOString()}">${Ot(e.updatedAt)}</time>`:A,s=e.additions||e.deletions?O`<span class="issue-diff"><span class="is-added">+${S(e.additions)}</span> <span class="is-deleted">−${S(e.deletions)}</span></span>`:A,c=a===1,l=[i?O`<span class="issue-author">${Le(i)}</span>`:A,c?A:o,a===0?O`<span>no pull request</span>`:A,c?A:s].filter(e=>e!==A),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}`,O`<code>${e.oid.slice(0,7)}</code>`,null]),...e.issues.map(e=>[`is-issue is-${e.state===`open`?`open`:`merged`}`,`issues/${e.number}`,O`<span class="sr-only">Issue </span>#${e.number}`,{kind:`issues`,reason:null,...e}])];return O`<li class="${`issue-tile agent-tile is-${cn[e.state]}`}"><div class="issue-body" @click="${t=>this.openSession(t,e)}"><span class="issue-rail">${e.agents.map(e=>O`<span class="${`agent-mark is-${e}`}" role="img" aria-label="${le(e)}">${ue(e)}</span>`)}</span> <span class="issue-lines">${n?O`<a class="issue-name" href="${n}" target="_blank" rel="noopener noreferrer">${e.title||`(no title)`}</a>`:O`<button type="button" class="issue-name">${e.title||`(no title)`}</button>`} ${l.length>0?O`<span class="issue-meta">${l}</span>`:A} ${u.length>0?O`<span class="agent-task-row"><span class="agent-chips">${u.slice(0,en).map(([e,n,r,i],a)=>O`<a class="${`agent-chip ${e}`}" href="${t?`https://github.com/${t}/${n}`:A}" target="_blank" rel="noopener noreferrer" @click="${i?e=>this.openItem(e,i.number,i):A}" data-rest="${a<u.length-1?u.length-1-a:A}">${r}</a>`)}</span>${c&&(o!==A||s!==A)?O`<span class="issue-meta">${o}${s}</span>`:A}</span>`:A} ${e.branches[0]?O`<span class="issue-branch"><code>${e.branches[0]}</code>${e.branches.length>1?O`<span>+${e.branches.length-1}</span>`:A}</span>`:A}</span></div></li>`}};customElements.get(`repository-agents`)||customElements.define(`repository-agents`,hn);var gn=1e3,_n=5e3,vn=3e4,yn=6e5,F=864e5,I=7*F,L=e=>Math.floor(e/F)*F,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,R=C(new Map,En,Dn,On),{Shown:kn,shown:An,repaint:z}=T(Ye),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=v(k`<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;u(e=>{if(e===`pulse`)for(let e of An)e.periodShown()});var B=e=>Number.isSafeInteger(e)&&e>=0?e:0,V=e=>Number.isSafeInteger(e)?e:null,H=e=>typeof e==`string`?e:null,Rn=e=>Object.fromEntries(Nn.map(t=>[t,{count:B(e?.[t]?.count),previous:V(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)||!d.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])=>[B(e),B(t)]):null,n=e=>Array.isArray(e)&&e.length===7?e.map(B):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:H(e.login),id:V(e.id),name:H(e.name),weeks:e.weeks,days:Array.isArray(e.days)?e.days:null})),punch:wn.map(t=>Array.from({length:24},(n,r)=>B(e.stats.punch[t]?.[r]))),periodPunch:e.stats.periodPunch===!0,from:V(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:H(e.subject)??``,login:H(e.login),id:V(e.id),name:H(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:V(e.reading),pulls:V(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 U=e=>e.reading??e.pulls,Vn=(e,t=0)=>{let n=U(e)===null?e.pending?_n:null:gn;return n===null?null:Math.min(vn,n*2**t)};function Hn(e,t){let n=`${e}\0${t}`,r=_e(R(),n,()=>Ee(e,t).then(zn),{ready:e=>({answer:e,stalls:0,asking:!1,moved:Date.now()}),settled:t=>{Bn(e,t)},message:`The repository’s pulse could not be read.`,repaint:z});return r.status===`ready`&&!r.asking&&Vn(r.answer)!==null&&Un(n,r,e,t,Vn(r.answer)),r}function Un(e,t,n,r,i){t.asking=!0,setTimeout(()=>{if(R().get(e)===t){if(Date.now()-t.moved>=yn){t.asking=!1,t.moved=Date.now();return}Ee(n,r).then(zn).then(i=>{if(R().get(e)!==t)return null;let a=i.behind||U(i)!==null&&U(t.answer)!==null&&U(i)>U(t.answer);t.answer=i,t.until=Date.now()+fe,t.stalls=a?0:t.stalls+1,a&&(t.moved=Date.now());let o=Vn(i,t.stalls);return o===null?t.asking=!1:Un(e,t,n,r,o),null},()=>(R().get(e)!==t||(t.stalls++,Un(e,t,n,r,Vn(t.answer,t.stalls)??Math.min(vn,gn*2**t.stalls))),null)).finally(z)}},i)}function Wn(e,t,n){R();let r=[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`);return _e(En,r,()=>ke(e,t,n),{ready:e=>({answer:Rn(e)}),failed:e=>({status:`error`,until:Date.now()+pe,error:e?.message||`These couldn’t be read.`}),repaint:z})}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*F;return o>=t&&o<=n?e+B(r):e},0),0);function qn(e,t){let n=L(t);return n-new Date(n).getUTCDay()*F-(e-1)*I}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=L(t),a=e.weeks*I,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+B(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 W({id:e=null,login:t,name:n}){let r=Re(t,n);if(r)return`agent:${r}`;let i=Fe(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=W(i);r.set(o,(i.days??i.weeks).reduce((e,[r,i,a,o])=>r>=t&&r<n?{...e,commits:e.commits+B(i),additions:e.additions+B(a),deletions:e.deletions+B(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=>W(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))/I)];if(!n||(n.commits+=B(t),n.additions+=B(a),n.deletions+=B(o),!r))continue;let u=Math.floor((e-n.week)/F);n.dayLines[u]=[n.dayLines[u][0]+B(a),n.dayLines[u][1]+B(o)];for(let[e,r]of[[`days`,t],[`agentDays`,s],[`releaseDays`,c],[`directDays`,l]])n[e][u]+=B(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-F,L(i)),s=e.directCommits.filter(e=>e.at>=t&&e.at<o+F&&(r===null||W(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+I,day:!1,commits:B(e.commits),agents:n.agents?o(e.agentDays):null,releases:n.releases?o(e.releaseDays):null,additions:a?B(e.additions):null,deletions:a?B(e.deletions):null,future:!1}));let s=L(t);return Array.from({length:i*7},(e,t)=>{let i=r+t*F,o=n.weeks.find(e=>i>=e.week&&i<e.week+I),c=o?Math.floor((i-o.week)/F):0,l=a?o?.dayLines?.[c]??null:null;return{from:i,to:i+F,day:!0,commits:B(o?.days[c]),agents:n.agents?B(o?.agentDays[c]):null,releases:n.releases?B(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()*F;return[n,n+I,!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}),G=e=>rr.format(e),K=(e,t,n=`${t}s`)=>`${S(e)} ${e===1?t:n}`,q=(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=L(t),r=ar(e,n);return e>=n?q(n,r):`${q(e,r)} \u2013 ${q(n,r)}`},J=(e,t)=>`${e.day?``:`Week of `}${q(e.from,ar(e.from,t),e.day)}`,sr=(e,t,n={})=>`${J(e,t)}: ${K(e.commits,`commit`)}${n.agents?`, ${S(e.agents)} with agents`:``}${n.releases?`, ${K(e.releases,`release`)}`:``}${e.additions===null?``:`, +${S(e.additions)} \u2212${S(e.deletions)} lines`}`;function cr(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?q(e[t].from):``;if(n===13)return t%2==0?q(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 lr=(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 ${S(t)} ${n}`,ur=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function dr(e,t=!1){let n=t?`latest `:``;return e.reading===null?e.pulls===null?`GitHub is still counting this repository\u2019s ${n}commits\u2026`:`Reading this repository\u2019s pull requests\u2026 ${S(e.pulls)} so far`:`Reading this repository\u2019s ${n}commits\u2026 ${S(e.reading)}${e.weeks===52?` of the last year`:``} so far`}var fr=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,pr=O`<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>`,mr=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,hr=e=>e.login?ze(e.login,e.name,e.login):ze(null,e.name);function gr(e){let t=e?.who?Be(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 _r=(e,t,n)=>e>0?O`<button type="button" class="history-link pulse-more" @click="${n}">${t?`Fewer`:`and ${K(e,`more`,`more`)}`}</button>`:A,vr=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){p(this.repository,`pulse`,d.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,z()}render(){if(!this.repository)return A;let{repoId:e}=this.repository,t=f(),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&&(U(c.answer)!==null||c.answer.pending);return O`<div class="history-bar">${h(`pulse`)}${E(`Period`,d,t,e=>()=>this.pick(e))}${c?O`<span class="pulse-range">${or(c.answer.since,r)}</span>`:A} ${l?O`<span class="pulse-updating" role="status">${dr(c.answer,!0)}</span>`:A}</div>${c?O`<div class="${`pulse-scroll${s?` is-reading`:``}`}" aria-busy="${String(n.status!==`ready`)}">${this.renderPulse(c,r)}</div>`:Ae(n,`Reading the repository’s pulse…`,()=>{R().delete(`${e}\0${t}`),z()})}`}renderPulse(e,t){let{answer:n}=e,r=d.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,S(n[t].count),lr(n[t].count,n[t].previous,r),`${S(n[i].count)} opened`):this.renderTile(e,`–`,`Reading…`,``),l=this.renderLists(n,a,t);return O`<section class="pulse-tiles" aria-label="Figures">${this.renderTile(`Commits`,i.commits===null?`–`:S(i.commits),o??lr(i.commits,i.previous,r),`to the default branch`)} ${this.renderTile(`Contributors`,i.authors===null?`–`:S(i.authors),o,`who made them`)} ${c(`Pull requests merged`,`merged`,`opened`)} ${c(`Issues closed`,`closed`,`created`)} ${n.stats?.lines===!1?A:this.renderTile(`Lines`,i.additions===null?`–`:O`<span class="is-added">+${S(i.additions)}</span> <span class="is-removed">−${S(i.deletions)}</span>`,s,`added and removed`,i.additions===null?A:this.renderRatio(i.additions,i.deletions))} ${i.agents===null||!Gn(n.stats,`agents`)?A:this.renderAgentsTile(i,r)}</section><div class="${`pulse-grid${l.length>2?` is-lists`:``}`}">${n.stats?O`${this.renderActivity(e,t)}${this.renderContributors(n,t)}`:O`<div class="pulse-pending pulse-wide" role="status">${dr(n)}</div>`} ${l} ${n.stats?this.renderPunch(n.stats):A}</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?`, ${K(e.releases,`release`)} apart`:``;return this.renderTile(O`<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?`–`:`${ur(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:fr(ur(e.agents,n),ur(e.previousAgents,r),t),n===0?`no commits${i}`:`${S(e.agents)} of ${K(n,`commit`)}${i}`)}renderTile(e,t,n,r,i=A){return O`<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?O`<span class="pulse-tile-note">${r}</span>`:A}</div>`}renderRatio(e,t){return e+t===0?A:O`<span class="pulse-ratio" aria-hidden="true">${[[`is-added`,e],[`is-removed`,t]].map(([n,r])=>r>0?O`<span class="${n}" style="${D({"--share":`${r/(e+t)}`})}"></span>`:A)}</span>`}renderActivity(e,t){let{answer:n}=e,r=this._person===null?null:n.stats.contributors.find(e=>W(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?Be(r.login,r.name):null,c=r?O`<span>a ${o} by</span><button type="button" class="pulse-picked is-person" aria-label="${`${s}\u2019s: show everyone\u2019s`}" @click="${()=>this.showPerson(null)}">${hr(r)}<span aria-hidden="true">×</span></button>`:O`<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 O`<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=L(t),g=a[this._column]&&!a[this._column].future?this._column:null,_=a.findIndex(e=>e.from===this._picked),v=(e,r,i,o)=>O`<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`:A}" aria-label="${i?sr(e,t,f):A}" aria-hidden="${i?A:`true`}" @pointerenter="${()=>this.point(e.future?null:r)}" @click="${()=>this.pickColumn(a,r)}">${o}</span>`,y=(e,t)=>m&&!e.future?O`<span class="pulse-figure">${t}</span>`:A,b=(e,t,n=A)=>O`<span class="${`pulse-bar${e}`}" style="${D({"--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?O`<span class="${`pulse-part${e}`}" style="${D({"--part":`${t}`})}"></span>`:A)};return O`<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?O`<span class="pulse-legend">${f.agents?O`<span class="pulse-key"></span>With agents<span class="pulse-key is-without"></span>Without`:A}${f.releases?O`<span class="pulse-key is-release"></span>Releases`:A}</span>`:A}</figcaption><div class="pulse-plots" @pointerleave="${()=>this.point(null)}"><div class="pulse-plot">${this.renderTicks(u.ticks.map(e=>[e/u.top,G(e),e===0]))}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!0,O`${y(e,S(e.commits))}${p?b(` is-split`,e.commits/u.top,x(e)):b(``,e.commits/u.top)}`))}</div></div>${d?O`<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,`+${G(d.top)}`],[.5,`0`,!0],[0,`\u2212${G(d.top)}`]])}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!1,O`<span class="pulse-half">${y(e,`+${G(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${G(e.deletions)}`)}</span>`))}</div></div>`:i.lines===!1?O`<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?O`<p class="pulse-note">GitHub counts this repository’s lines a week, not a day: the quarter and the year show them.</p>`:O`<p class="pulse-note" role="status">GitHub is still counting lines added and removed…</p>`}<div class="${`pulse-axis${m?` is-each`:``}`}" aria-hidden="true">${a.map((e,t)=>O`<span class="${e.future?`is-future`:e.day&&e.from===h?`is-today`:``}">${cr(a,t,n.weeks)}</span>`)}</div>${g===null?A:this.renderTip(n,a,g,t,f,!r)}</div><span class="sr-only" aria-live="polite">${this._typed&&g!==null?sr(a[g],t,f):``}</span></figure>`}renderTip(e,t,n,r,i,a){let o=t[n],s=L(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 O`<div class="${`pulse-tip${f>.6?` is-left`:``}`}" style="${D({"--x":`${f}`})}" aria-hidden="true"><span class="pulse-tip-when">${J(o,r)}${o.day?o.from===s?O`<span>today</span>`:A:r<o.to?O`<span>so far</span>`:A}</span> <span class="pulse-tip-row"><span class="${`pulse-tip-key${i.agents||i.releases?` is-none`:``}`}"></span><strong>${S(o.commits)}</strong> ${o.commits===1?`commit`:`commits`}</span> ${i.agents?O`<span class="pulse-tip-row"><span class="pulse-tip-key"></span><strong>${S(o.agents)}</strong> with agents</span>`:A} ${i.releases?O`<span class="pulse-tip-row"><span class="pulse-tip-key is-release"></span><strong>${S(o.releases)}</strong> ${o.releases===1?`release`:`releases`}</span>`:A} ${o.additions===null?A:O`<span class="pulse-tip-row"><span class="pulse-tip-key is-added"></span><strong>+${S(o.additions)}</strong> added</span> <span class="pulse-tip-row"><span class="pulse-tip-key is-removed"></span><strong>−${S(o.deletions)}</strong> removed</span>`} ${d.length>0?O`<span class="pulse-tip-people">${u?O`<span class="pulse-tip-note">Its week’s</span>`:A} ${d.map(e=>O`<span class="pulse-tip-person">${hr(e)}<strong>${S(e.commits)}</strong></span>`)}</span>`:A}</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 O`<div class="pulse-ticks" aria-hidden="true">${e.map(([e,t,n])=>O`<span class="${n?`is-zero`:A}" style="${D({"--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 ${q(i,ar(i,t))}`:J(r,t):null;return O`<figure class="pulse-panel pulse-people"><figcaption class="pulse-head"><h3>Contributors</h3>${u?O`<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>`:O`<span>by their commits in the period</span>`}</figcaption>${s.length===0?O`<p class="pulse-note">No commits ${r?o||!r.day?`that week`:`that day`:`in the period`}.</p>`:O`<ol class="${`pulse-ranks${this._person===null?``:` is-picking`}`}">${(this._everyone?s:s.slice(0,xn)).map(e=>O`<li class="${e.key===this._person?`is-person`:A}"><span class="pulse-rank-who"><button type="button" class="pulse-rank-name" aria-pressed="${String(e.key===this._person)}" @click="${()=>this.showPerson(e.key)}">${hr(e)}</button> ${e.login?O`<a class="pulse-rank-profile" href="${mr(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${Be(e.login,e.name)} on GitHub`}">${pr}</a>`:A}</span> <span class="pulse-rank-bar"><span style="${D({"--value":`${e.commits/c}`})}"></span><span class="pulse-rank-value">${S(e.commits)}</span></span> ${l?O`<span class="pulse-rank-lines"><span class="is-added">+${G(e.additions)}</span> <span class="is-removed">−${G(e.deletions)}</span></span>`:A}</li>`)}</ol>${_r(s.length-xn,this._everyone,()=>{this._everyone=!this._everyone})}`}</figure>`}renderPunch(e){let{punch:t}=e,n=Math.max(1,...t.flat());return O`<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)=>O`<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: ${K(e,`commit`)}`;return O`<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)=>O`<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)=>O`<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}=gr(t),a=this._allDirect?e.items:e.items.slice(0,In),o=Math.max(0,e.count-e.items.length);return O`<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?O`<span class="pulse-narrowed">${r}</span>`:A}<span class="pulse-count">${S(e.count)}</span></div>${e.count===0?O`<p class="pulse-note">None ${i}.</p>`:O`<ol>${a.map(e=>O`<li><a class="${`pulse-item is-commit${e.kind?` is-${e.kind}`:``}`}" href="${n?`https://github.com/${n}/commit/${e.sha}`:A}" 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>${hr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${Ot(e.at)}</time></span></a></li>`)}</ol>`} ${_r(e.items.length-In,this._allDirect,()=>{this._allDirect=!this._allDirect})} ${o>0?O`<p class="pulse-note">${e.items.length>0?K(o,`older commit`,`older commits`):K(o,`commit`)} not listed.</p>`:A}</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=>W(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-F):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${J(n,t)}`:`in the w${J(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:h,to:g,scope:_}=gr(n);return O`<section class="pulse-panel pulse-list" aria-label="${r}"><div class="pulse-head"><h3>${r}</h3>${n?O`<span class="pulse-narrowed">${g}</span>`:A}${E(`${r} shown`,i.map(([e,t])=>[e,O`${t}<span class="n">${c?.[e]?S(c[e].count):`–`}</span>`]),a,e=>()=>this.showList(t,e))}</div>${n?.nobody?O`<p class="pulse-note">${h}’s commits name no GitHub account to find their ${r.toLowerCase()} by.</p>`:s?.status===`error`?O`<p class="pulse-note" role="alert">${s.error}</p>`:u===null?O`<p class="pulse-note" role="status">Reading…</p>`:u.length===0?O`<p class="pulse-note">None ${_}.</p>`:O`<ol>${u.map(e=>{let[n,r]=se(t,e);return O`<li><a class="${`pulse-item is-${n}`}" href="${d?`https://github.com/${d}/${t===`pulls`?`pull`:`issues`}/${e.number}`:A}" target="_blank" rel="noopener noreferrer" @click="${n=>this.openItem(n,t,e)}"><span class="issue-state" role="img" aria-label="${r}">${b[t][n]}</span> <span class="pulse-item-title">${e.title||`(no title)`}</span> <span class="pulse-item-meta"><span>#${e.number}</span>${e.author?O`<span>${Le(e.author)}</span>`:A} ${e.at==null?A:O`<time datetime="${new Date(e.at).toISOString()}">${Ot(e.at)}</time>`}</span></a></li>`})}</ol>`} ${m&&u!==null&&l>u.length?O`<a class="pulse-all" href="${m}" target="_blank" rel="noopener noreferrer">All ${S(l)} on GitHub</a>`:A}</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`,vr);var yr=864e5,br=[100,300,1e3],xr=e=>e.parents.length<=1&&Number.isFinite(e.committedAt),Sr=(e,t)=>Ze(e).filter(xr).slice(0,t).toReversed(),Cr=1,wr=.08,Tr=.6;function Er(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/yr;t.push(n===0?0:t[n-1]+Math.min(Tr,Math.max(wr,i*Cr)))}return t}function Dr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Or(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 kr=.9,Ar=2,jr=1,Mr=5,Nr=1,Pr=.06;function Fr(){let e=Ir(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Ir(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 Lr=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`)));function Rr(e,t){let n=e.dirs.get(t);if(n)return n;let r=Rr(e,Lr(t)),i=Ir(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),ti(r),e.layout=!0,i}function zr(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=Rr(e,Lr(t));i={path:t,name:t.slice(t.lastIndexOf(`/`)+1),extension:Dr(t),dir:a,ox:0,oy:0,touched:r,kind:n,removed:null},a.files.push(i),e.files.set(t,i),ti(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 Br(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);ti(r),e.layout=!0}var Vr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Hr(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=Vr(n),s=o.length>1?Math.min(Pr,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 Ur(e,t){for(let[n,r]of Vr(t)){let t=zr(e,n,r,-1/0);t&&r===`D`&&Br(e,t)}}function Wr(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 Gr(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=zr(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<kr);for(let n of[...e.going])t-n.removed>=jr&&Br(e,n);for(let[n,r]of e.users)t-r.active>Mr+Nr&&e.users.delete(n)}var Kr=6,qr=2.2,Jr=12,Yr=Math.PI*(3-Math.sqrt(5)),Xr=46,Zr=34,Qr=e=>e===0?0:Kr*.62*Math.sqrt(e)+qr;function $r(e){let t=Kr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Yr),t*Math.sin(e*Yr)]}function ei(e){ni(e.root),ri(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function ti(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function ni(e){if(!e.dirty)return;for(let t of e.dirs)ni(t);e.cluster=Math.max(Qr(e.files.length),qr)+Jr/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)gi(t,n);else{ii([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=li([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 ri(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);ri(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function ii(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;ai(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];ai(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(oi(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=si(i);for(let e=l.next;e!==a;e=e.next){let t=si(e);t<u&&([i,u]=[e,t])}a=i.next}}function ai(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 oi=(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 si(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 ci=64;function li(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&&pi(r,t[a]))){if(n=di(n,t[a]),r=Y(n),!Number.isFinite(r.x+r.y+r.r)||++i>ci*t.length)return ui(e);a=-1}return r}function ui(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 di(e,t){if(e.every(e=>pi(t,e)))return[t];for(let n of e)if(!fi(t,n)&&e.every(e=>pi(Y([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!fi(Y([r,i]),t)&&!fi(Y([r,t]),i)&&!fi(Y([i,t]),r)&&e.every(e=>pi(Y([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var fi=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function pi(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 mi=60,hi=.5;function gi(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t.filter(e=>e.x===void 0))_i(r,e,n),n.push(r);for(let n=0;n<mi;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-hi)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(vi(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-hi)return;let o=Math.hypot(i,a);if(o>=r-hi)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 _i(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-hi&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-hi),i=[],a=(t,n)=>{for(let[r,a]of[[t,n],[n,t]]){let t={r:e.r};ai(r,a,t),i.push(t)}};for(let e of n)a(t,e);vi(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 vi(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 yi(e,t,n=Zr){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]=$r(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)*Xr*3,r+Math.sin(t)*Xr*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Xr,r+(e.y-r)/i*Xr];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 bi(e){e.layout&&ei(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]=$r(e)}}function xi(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,Qr(t.files.length)+qr);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var Si=[.5,1,2,4,8],Ci=20,wi=50,Ti=8,Ei=[`background`,`text`,`muted`,`surface`,`added`,`modified`,`removed`],Di={side:40,top:64,bottom:40},Oi=3,ki=10,Z=11,Ai=72,ji=250,Mi=1.8,Ni=2,Pi=new Set([`A`,`M`,`D`,`R`]),Fi=2,Ii=new Map,Li=new Map,Ri=new Set,zi=new Map,Bi=new Map,Vi=C(Ii,Li,Ri,zi),{Shown:Hi,shown:Ui,repaint:Wi}=T(Ye),Gi=()=>Number(c(`replay`)??300),Ki=1;u(e=>{e===`replay`&&Wi()});var qi=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Ji(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=me(Vi(),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:Fr(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return Vi().set(a,s),he(Ii,Fi,e=>[...Ui].some(t=>t.replay===e),Yi),s}function Yi(e,t){if(Ii.delete(e),[...Ii.values()].some(e=>e.repoId===t.repoId&&e.path===t.path))return;let n=`${t.repoId}\0${t.path}\0`;for(let e of[Li,zi,Ri])for(let t of[...e.keys()])t.startsWith(n)&&e.delete(t)}var Xi={files:[],cut:!1},Zi=e=>e.commits[0]?.parents[0]??null,Q=e=>Zi(e)?ea(e,Zi(e)):Xi,$=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,Qi=(e,t)=>Li.get($(e,t)),$i=(e,t)=>Ri.has($(e,t)),ea=(e,t)=>zi.get($(e,t)),ta=(e,t)=>!(!Qi(e,t.sha)||$i(e,t.sha)&&!ea(e,t.sha));function na(e){let t=0;for(;t<(e.commits?.length??0)&&ta(e,e.commits[t]);)t++;return t}function ra(e,t){if(!Array.isArray(e)||!Pi.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 ia(e){let t=Q(e),n=e.commits.filter(t=>Qi(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(Dr(t),(e.counts.get(Dr(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of Vr(Qi(e,t.sha)))r!==`D`&&i(n);Or(e.colors,e.counts,Ti)}var aa=e=>[...e.commits.slice(e.next),...e.commits.slice(0,e.next)];function oa(e,t,n,r,i){e[t]=!0,n().then(t=>(Vi().get(e.key)===e&&r(t),null),t=>(t?.name!==`AbortError`&&(e.error=t?.message||i),null)).finally(()=>{e[t]=!1,Wi()})}function sa(e){if(e.treeReading||e.error)return;let t=Zi(e)&&!Q(e),n=t?Zi(e):aa(e).find(t=>$i(e,t.sha)&&!ea(e,t.sha))?.sha;n&&oa(e,`treeReading`,()=>xe(e.repoId,e.path,n),r=>{let i=Array.isArray(r?.files)?r.files.map(t=>ra([t,`A`],e.path)?.[0]).filter(Boolean):[];zi.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 ca(e,t,n){let r=Qi(e,n.sha),i=$i(e,n.sha)?ea(e,n.sha):null;return i?[...r,...Wr(t,i.files,i.cut,Vr(r))]:r}function la(e,t){let n=Fr();n.start=Q(e),Ur(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))Ur(n,ca(e,n,r));return bi(n),n}function ua(e){if(e.reading||e.error||!e.commits)return;let t=na(e)===0?Ci:wi,n=aa(e).filter(t=>!Qi(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&oa(e,`reading`,()=>be(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)Li.set($(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>ra(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&Ri.add($(e,t))},`What the commits changed could not be read.`)}function da(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(Pe,i)?i:Re(n,r),a=e?null:Fe(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?Pe[e].name:a?a.name??a.login:r??n,c=e?Pe[e].mark??null:null,l=e?!c&&Pe[e].avatar?`/api/avatar/${Pe[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 fa={anthropic:[Ke,4,5,8],openai:[qe,4,5,8],"github-copilot":[Je,0,0,24]},pa={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},ma=new Map,ha=e=>ma.get(e)??ma.set(e,new Path2D(fa[e][0])).get(e);function ga(e){let t=Bi.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,Bi.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var _a=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),va=e=>e===.5?`½×`:`${e}\xD7`,ya=k`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,ba=k`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,xa=k`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,Sa=class extends Hi{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(),Vt(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(),Ht(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Ui].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}=Bt(this.repository);if(t.status!==`ready`)return;if(t.commits.filter(xr).length<e.count&&t.more){!t.loadingMore&&!t.moreError&&n();return}e.commits=Sr(t.commits,e.count),e.times=Er(e.commits)}sa(e),ua(e);let t=Q(e);t&&(ia(e),e.scene.start!==t&&this.seek(e.next),!e.started&&na(e)>0&&(e.started=!0,e.playing=!qi(),this.requestUpdate()))}pickCount(e){p(this.repository,`replay`,String(e))}pickSpeed(e){Ki=e,Wi()}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,na(t)));Object.assign(t,{scene:la(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)&&(Gr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=ji&&(ei(n.scene),this._laidOut=e),yi(n.scene,t,Math.max(Zr,Ai/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*Ki,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!ta(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+Tr)-r;Hr(e.scene,da(t),ca(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+Ni&&(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(Ei.map(e=>[e,t(e)])),kinds:Array.from({length:Ti},(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,qr*u.zoom),g=h<Mi,_=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<Ar){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)/Ar),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/jr);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)/kr)*.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>Ar||b(e.name,d(e.x)+Math.max(6,(Qr(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=ki){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/Ar),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-Mr)/Nr));let[i,a]=Object.hasOwn(pa,e.agent)?pa[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?ga(e.image):null;if(e.mark&&Object.hasOwn(fa,e.mark)){let[,r,i,o]=fa[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(ha(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=xi(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(Oi,(t-2*Di.side)/Math.max(1,i.maxX-i.minX),(n-Di.top-Di.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-(Di.top-Di.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 A;let e=Ji(this.repository,Gi());this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:Bt(this.repository),n=e.commits?.length??0,r=na(e),i=e.next>0?e.commits[e.next-1]:null,a=e.commits?e.people??=new Set(e.commits.flatMap(e=>da(e).map(e=>e.key))).size:0,o=(e.commits?Q(e):null)?.cut||e.commits?.some(t=>$i(e,t.sha)&&ea(e,t.sha)?.cut),s=e.commits&&n>0?`${S(n)} commit${n===1?``:`s`} by ${S(a)}, ${_a(e.commits[0].committedAt)} \u2013 ${_a(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return O`<div class="history-bar">${h(`replay`)}${E(`Commits played`,br.map(e=>[e,O`Last ${S(e)}`]),e.count,e=>()=>this.pickCount(e))}${s?O`<span class="history-summary">${s}</span>`:A}</div><div class="replay-stage"><canvas class="replay-canvas" role="img" aria-label="${i?`The repository\u2019s files as of ${_a(i.committedAt)}, ${S(e.next)} of ${S(n)} commits played`:`The repository’s files, as its commits change them`}" @pointermove="${this.pointer}" @pointerleave="${this.pointer}"></canvas>${i?O`<div class="replay-day"><time datetime="${new Date(i.committedAt).toISOString()}">${_a(i.committedAt)}</time> <span>${S(e.next)} of ${S(n)}</span></div>${this.renderCommit(i)}`:A} ${this.renderKey(e)} ${this.renderStatus(e,t,r)} ${this._hovered?O`<div class="replay-tip" style="${D({left:`${this._hovered.x}px`,top:`${this._hovered.y}px`})}">${this._hovered.text}</div>`:A}<div class="replay-swatches" aria-hidden="true">${[...Ei,...Array.from({length:Ti},(e,t)=>`kind-${t}`)].map(e=>O`<span class="${`is-${e}`}"></span>`)}</div></div>${this.renderControls(e,n,r)}`}renderCommit(e){let t=At(this.repo??this.repository.repo),n=e.sha.slice(0,7);return O`<p class="replay-commit">${t?O`<a class="replay-sha" href="${`${t}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" aria-label="${`Commit ${n} on GitHub`}">${n}</a>`:O`<code class="replay-sha">${n}</code>`} <span class="replay-commit-subject">${jt(e.subject||`(no message)`,t)}</span> <span class="replay-commit-author">${Ne(e.authorLogin,e.authorName,e.coauthors)}</span></p>`}renderKey(e){if(e.colors.size===0)return A;let t=[...e.colors].toSorted((t,n)=>(e.counts.get(n[0])??0)-(e.counts.get(t[0])??0));return O`<ul class="replay-key" aria-label="Kinds of files">${t.map(([e,t])=>O`<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,()=>Ut(t.key)]:e.error?[`replay`,e.error,()=>{e.error=null,Wi()}]:t?.entry.status===`ready`&&t.entry.moreError?[`more`,t.entry.moreError,()=>t.more()]:[];if(a)return He(r,O`<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 O`<div class="replay-status" role="status">${e>0?`Reading commits\u2026 ${S(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?O`<div class="replay-status">No commits to play.</div>`:Q(e)?n===0?O`<div class="replay-status" role="status">Reading what the commits changed…</div>`:e.waiting?O`<div class="replay-status is-waiting" role="status">Reading what the next commits changed…</div>`:A:O`<div class="replay-status" role="status">Reading the files as they were before ${_a(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 O`<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?xa:e.playing?ba:ya}</svg></button><div class="replay-track" style="${D({"--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="${`${S(e.next)} of ${S(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div>${E(`Speed`,Si.map(e=>[e,va(e)]),Ki,e=>()=>this.pickSpeed(e))}</div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,Sa);var Ca=8,wa=20,Ta=C(new Map),{Shown:Ea,shown:Da,repaint:Oa}=T(_);u(e=>{(e===`issues`||e===`pulls`)&&Oa()}),Oe(e=>{for(let t of Da)e&&t.repository?.repoId!==e.repoId||t.requestUpdate()});function ka(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 Aa(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 ja(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 Ma=(e,t)=>Se(e,t,e=>[`#${e.number}`,e.title,e.author??``,Ie(e.author)??``,e.head??``,...e.labels.map(e=>e.name)]),Na=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Pa=e=>e<1e3?String(e):Na.format(e);function Fa(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>Ca?Ca-1:Ca),r=e=>O`<span class="issue-label" style="${D(e.color?{"--label":`#${e.color}`}:{})}" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span>`,i=e=>O`${r(e[0])}${e.length>1?O`<span class="issue-labels-rest" style="${D({"--labels":String(e.length-1)})}">${i(e.slice(1))}</span>`:A}`;return O`${n.length>0?i(n):A}${t>n.length?O`<span class="issue-label is-more">+${t-n.length}</span>`:A}`}var Ia={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`,unlocked:`locked by no lockfile read`};function La({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,wa);return[t>0?`${e.slice(0,wa).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${Ia[e.unsupported]})`).join(`, `)}${a>0?` and ${S(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 Ra(e){if(e.status!==`ready`)return A;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=s(e),o=e.review?m(e).count:0,c=g(e);if(t.length===0&&o===0&&!c&&!e.pending)return A;let u=i?`+`:``,d=t=>{let n=l(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${Ia[t.unsupported]}`:n===`baseline`?`, needs no review`:t.reviewed?`, reviewed`:t.rejected?`, rejected`:n?`, ${t.reviews}/${e.review.required} reviews`:``},f=e=>`${e.name}@${e.version??`?`}${e.patch?`, patched`:``}${e.was?` (was ${e.was.join(`, `)}${d(e)})`:` (new${d(e)})`}`,p=t.length-wa,h=[t.length>0?`New in its lockfiles: ${t.slice(0,wa).map(f).join(`, `)}${p>0?` and ${S(p)}${u} more`:i?` and more`:``}`:null,o>0?`${S(o)} on the base branch unreviewed`:null,c?`Its review fails: ${La(c)}`:null,e.pending?`Stasis is still working out what its stasis.config.json’s entries reach`:null].filter(Boolean).join(`. `),_=[n?`${S(n)} new`:null,r?`${S(r)} updated`:null].filter(Boolean).join(`, `),v=a&&o?`${S(a)} + ${S(o)} to review`:a?`${S(a)} to review`:o?`${S(o)} unreviewed`:``;return O`<span class="issue-deps" data-tooltip="${h}">${oe}<span class="issue-deps-names">${[...new Set(t.map(e=>e.name))].join(`, `)}</span> ${_?O`<span class="issue-deps-count">${_}${u}</span>`:A} ${c?O`<span class="issue-deps-review is-failed">${c.count>0?`${S(c.count)} can\u2019t be reviewed`:`lockfiles unread`}</span>`:e.pending?O`<span class="issue-deps-review is-pending" role="status">${v?`${v}, `:``}Stasis building…</span>`:e.review?v?O`<span class="issue-deps-review is-wanted">${v}</span>`:O`<span class="issue-deps-review is-passed" role="img" aria-label="Every version reviewed">${te.success[1]}</span>`:A}</span>`}var za=class extends Ea{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=>we(t,r,{state:e,after:i}).then(ka).then(e=>(n(t,e.items,e.readAt,r),e));return ye(Ta,`${t}\0${r}\0${e}`,{first:()=>i(null),next:i,message:`The list could not be read.`,repaint:Oa,ready:e=>ja(t,r,{...e,countsAt:e.readAt}),merge:(e,n)=>{e.items=w(e.items,n.items,e=>e.number),n.readAt>=e.countsAt&&(e.counts=n.counts,e.countsAt=n.readAt,ja(t,r,e))}})}pick(e){p(this.repository,this.kind,e)}render(){if(!this.repository)return A;let e=c(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=Ta().get(`${this.repository.repoId}\0${this.kind}\0${o}`),l=i?Aa(this.repository.repoId,this.kind,e,n):null,u=l?l.counts:s?.status===`ready`?Aa(this.repository.repoId,this.kind,o,s).counts:null,d=e=>u?O`<span class="n">${S(u[e])}</span>`:A,f=l?Ma(l.items,this._filter):[];return O`<div class="history-bar issues-bar">${h(this.kind)}${E(this.kind===`pulls`?`Pull requests`:`Issues`,[[`open`,O`Open${d(`open`)}`],[`closed`,O`Closed${d(`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}}"> ${l&&this._filter.trim()?O`<span class="history-summary">${f.length} of ${l.items.length} read</span>`:A}</div>${l?this.renderTiles(n,l.items,f,r,`${e} ${a}`):Ae(n,`Reading the ${a}\u2026`,()=>{Ta().delete(t),Oa()})}`}renderTiles(e,t,n,r,i){if(t.length===0)return O`<div class="bundles-slide-placeholder">No ${i}.</div>`;let a=this.repo??this.repository.repo,o=this.kind===`pulls`?`pull`:`issues`;return O`<div class="issues-scroll">${n.length===0?O`<p class="history-note">None of the ${i} read match.</p>`:O`<ol class="issues-grid" aria-label="${i}">${n.map(e=>{let[t,n]=se(this.kind,e),r=this.renderTile(e,t,n);return O`<li class="${Ve({"issue-tile":!0,[`is-${t}`]:!0})}">${a?O`<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>`:O`<div class="issue-body" @click="${t=>this.openTile(t,e)}">${r}</div>`}</li>`})}</ol>`} ${De(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`&&je(t)?Me(this.repository.repoId,t.number,!0,{listed:!0}):null,o=t.updatedAt==null?null:new Date(t.updatedAt),s=i&&t.checks?te[t.checks]:null,c=i&&t.state===`open`&&t.review?ne[t.review]:null,l=t.comments>0?`${S(t.comments)} comment${t.comments===1?``:`s`}`:null,u=(e,[n,r])=>O`<span class="${`issue-${e} is-${t[e]}`}" role="img" aria-label="${n}" data-tooltip="${n}">${r}</span>`;return O`<span class="issue-rail"><span class="issue-state" role="img" aria-label="${r}">${b[this.kind][n]}</span> ${i?O`<span class="issue-marks">${c?u(`review`,c):A}${s?u(`checks`,s):A}</span>`:A} ${l?O`<span class="issue-comments" role="img" aria-label="${l}" data-tooltip="${l}">${ee}<span>${Pa(t.comments)}</span></span>`:A} </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">${Le(t.author,t.author??`ghost`)}</span> ${o?O`<time datetime="${o.toISOString()}">${Ot(t.updatedAt)}</time>`:A} </span>${t.labels.length>0||t.moreLabels>0?O`<span class="issue-labels">${Fa(t)}</span>`:A} ${i&&t.head?O`<span class="issue-branch"><code>${t.head}</code>${t.base?O`<span aria-hidden="true">→</span><code>${t.base}</code>`:A} <span class="issue-diff"><span class="is-added">+${S(t.additions)}</span> <span class="is-deleted">−${S(t.deletions)}</span></span></span>`:A} ${i&&t.state===`open`?e(t.reviews):A} ${a?Ra(a):A}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,za);
|
|
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-4GHLPL2P.js";import{Ae as s,Af as c,Ef as l,Gf as u,He as d,Hf as f,Ie as p,Je as m,Ke as h,Le as g,Lf as _,Me as v,Mf as y,Nf as b,Of as x,Og as ee,Pf as te,Pg as ne,Qf as re,Rf as ie,Sf as ae,Tf as oe,Uf as se,Vf as ce,Wf as le,Xf as ue,Yf as de,Zf as fe,_f as pe,cg as me,jc as he,kc as ge,me as _e,ne as ve,oa as ye,oe as S,pa as be,qa as xe,qe as C,ra as Se,re as Ce,sa as we,se as Te,te as Ee,ua as De,ue as w,va as Oe,ve as ke,we as T,xe as Ae,ye as E,ze as je,zf as Me}from"./chunk-7KUZQB6S.js";import"./chunk-A4BBBHQU.js";import"./chunk-WBK5ZN4K.js";import"./chunk-VYYUMYVW.js";import"./chunk-7HP2VYIC.js";import"./chunk-N57OWFKY.js";import"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import"./chunk-XRAAYXPR.js";import{A as Ne,m as Pe,s as Fe,t as Ie,u as Le,x as Re,y as ze,z as Be}from"./chunk-ZPIUN4FW.js";import"./chunk-KP2XM324.js";import"./chunk-DUASGS2O.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as Ve}from"./chunk-3TJCEPHF.js";import"./chunk-TKPNRQNN.js";import{e as He}from"./chunk-74JZTGTO.js";import"./chunk-IYPY47MC.js";import{C as Ue,D as We,d as Ge,e as Ke,f as qe,g as Je}from"./chunk-G5JKKNZF.js";import{a as D}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import"./chunk-BZJU5EEV.js";import"./chunk-QRKFPLA4.js";import{c as O,d as k,g as A,j as Ye}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Xe=e=>e.committedAt??-1/0;function Ze(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)=>Xe(e)-Xe(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 Qe(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 $e(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 ee=[];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 ee.push(t)}let te=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:te,color:b}),te=!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 ee)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 et=12,j=24,tt=9,nt=8,rt=3,it=`a[href], .history-commit`,at=15e3,ot=3e3,st=10,ct=25,lt=`all`,ut=new Set,M=C(new Map,ut),{Shown:dt,shown:ft,repaint:N}=T(Ye);function pt(e,t,n=new Set){let r={status:`ready`,until:Date.now()+_e,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 mt(e,t){let n=w(e.pulls,t,e=>e.merge);n.length>e.pulls.length&&(e.pulls=n)}function ht(e,t,n,r,i,a=1){setTimeout(()=>{M().get(e)===t&&n(r,i).then(o=>(M().get(e)!==t||(mt(t,o.pulls),o.pullsPending&&a<st&&ht(e,t,n,r,i,a+1)),null),()=>null).finally(N)},ot)}function gt(e,t,n){return Te(M(),e,()=>t(1),{ready:e=>pt(e,n),settled:n=>{n.pullsPending&&ht(e,n,t,1,null)},failed:e=>{let t=Ce(e,`The history could not be read.`);return t&&{...t,code:e?.code??null}},repaint:N})}function _t(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(M().get(e)!==t)return null;let s=t.retried===i?0:Math.min(Number(o.retryIn)||0,at),c=pt(o,r,s>0?a:t.sought);return s>0&&(Object.assign(c,{retried:i,retryAt:Date.now()+s}),setTimeout(N,s)),M().set(e,c),c.pullsPending&&ht(e,c,n,1,null),null},()=>null).finally(()=>{t.refreshing=!1,N()})}function vt(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,ct).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function yt(e,t,n,r){let i={next:t.next};Ae(t,{held:()=>M().get(e)===t,ask:()=>n(t.page+1,i),merge:a=>{t.commits=w(t.commits,a.commits,e=>e.sha),mt(t,a.pulls),t.page+=1,t.more=a.more===!0,r?.(t),a.pullsPending&&ht(e,t,n,t.page,i)},error:`More commits could not be read.`,repaint:N})}var bt=e=>typeof e==`string`&&/^[a-f\d]{40}$/u.test(e),xt=e=>bt(e?.sha)&&Array.isArray(e.parents);function St(e){if(!Array.isArray(e?.commits))throw TypeError(`The server answered with no history.`);let t=e.commits.filter(xt),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&bt(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>bt(e?.merge)&&Number.isSafeInteger(e.number)&&bt(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(xt)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&bt(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function Ct(e,t,n){let r=wt(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 wt(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 Tt=6e4,Et=60*Tt,Dt=24*Et;function P(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-Tt&&n<Tt)return`now`;if(n>0&&n<Et)return`${Math.floor(n/Tt)}m`;if(n>0&&n<Dt)return`${Math.floor(n/Et)}h`;if(n>0&&n<7*Dt)return`${Math.floor(n/Dt)}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),O`<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 jt=e=>tt+e*et,Mt=e=>e*j+j/2,Nt=e=>tt*2+(e.width-1)*et;function Pt({row:e,from:t,to:n}){let[r,i,a,o]=[jt(t),jt(n),Mt(e),Mt(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 Ft=({row:e,col:t,straight:n})=>n?`M${jt(t)} ${Mt(e)+6}v${j*.55}`:`M${jt(t)+4} ${Mt(e)+5}l${et*.6} ${j*.5}`;function It(e,t){let n=(e,t,n=``)=>{let r=Array.from({length:nt},()=>[]);for(let n of e)r[n.color].push(t(n));return r.map((e,t)=>e.length>0?k`<path class=${`${n}lane-${t}`} d=${e.join(``)}/>`:A)};return O`<svg class="history-graph" width="${Nt(e)}" height="${e.rows.length*j}" aria-hidden="true">${n(e.segments,Pt)} ${n(e.stubs,Ft,`history-stub `)} ${e.rows.map(({commit:e,col:n,color:r},i)=>k`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${jt(n)} cy=${Mt(i)}
|
|
2
|
+
r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function Lt(e,t,n,r){if(!e?.length)return A;let i=e=>{let t=Ve({"history-ref":!0,[`is-${e.kind}`]:!0,"is-default":e.main===!0,"is-shown":e.kind===n.kind&&e.name===n.name}),i=O`${e.kind===`tag`?Ge(We):e.kind===`pull`?Ge(Ue):A}<span>${e.name}</span>`;return e.kind===`pull`&&r?O`<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>`:O`<span class="${t}">${i}</span>`},a=e.slice(rt);return O`<span class="history-refs" style="${D({"--ref":`var(--lane-${t})`})}">${e.slice(0,rt).map(i)}${a.length>0?O`<span class="history-ref is-more" data-tooltip="${a.map(e=>e.name).join(`, `)}">+${a.length}</span>`:A}</span>`}function Rt(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)=>ye(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 St(e)}),c=t===`path`?null:vt,l=gt(o,s,c);return!a||l.status!==`ready`||l.refreshing||l.sought.has(r)||l.retryAt>Date.now()||wt(l.commits,l.pulls??[]).some(e=>e.sha===r)||_t(o,l,s,c,r),a&&l.status===`error`&&l.code===`github-token-required`?(ut.add(n),Rt(e,`revision`)):{mode:t,key:o,entry:l,more:()=>yt(o,l,s,c)}}var zt=e=>Rt(e,e.path?`path`:`revision`),Bt=e=>{ft.add(e)},Vt=e=>{ft.delete(e)};function Ht(e){M().delete(e),N()}var Ut=class extends dt{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`:(M(),ut.has(e)?`revision`:lt)}history(e){return Rt(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:Ze(e===`unmerged`?Ct(t.commits,t.pulls??[],a):wt(t.commits,t.pulls??[])),s=e===`all`?a:e===`revision`?o[0]?.sha:null,c=$e(o,{linear:i,trunk:s&&!i?Qe(o,s):null,colors:nt});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){lt=e,N()}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`);ee({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(it)]:[],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(${it})`))e.tabIndex=e===s?0:-1;s.focus()}}render(){if(!this.repository)return A;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,c=e===`unmerged`?o?.rows.length??0:n.commits?.length??0,l=e===`unmerged`&&o?new Set(o.rows.map(e=>e.commit.sha)):null,u=i&&e===`all`?n.branches.length:l?n.branches.filter(e=>l.has(e.sha)).length:0,d=i?`${c}${n.more||n.cut?`+`:``} commit${c===1?``:`s`}`:``,f=ut.has(this.repository.repoId);return O`<div class="history-bar">${v(`commits`)} ${e===`path`?O`<span class="history-scope">Commits touching <code>${this.repository.path}</code></span>`:f?O`<span class="history-scope">Every branch needs your GitHub sign-in.</span>`:E(`Branches`,[[`all`,`All branches`],[`unmerged`,`Unmerged`]],e,e=>()=>this.pick(e),{spaced:!0})} ${i?O`<span class="history-summary">${d}${u>0?` on ${u} branch${u===1?``:`es`}`:``}</span>`:A}</div>${i?this.renderCommits(e,n,r,o,a):s(n,`Reading the history…`,()=>Ht(t))}`}renderCommits(e,t,n,r,i){if(r.rows.length===0&&(e!==`unmerged`||!t.more&&!t.moreError))return O`<div class="bundles-slide-placeholder">${e===`unmerged`?`Every branch read is merged.`:`No commits.`}</div>`;let a=this.repository.commit,o=ne(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 O`<div class="history-scroll">${e===`all`&&!t.refreshing&&!(t.retryAt>Date.now())&&!r.rows.some(e=>e.commit.sha===a)?O`<p class="history-note"><code>${a.slice(0,7)}</code> isn’t among these commits.</p>`:A}<div class="history-lines" style="${D({"--history-graph":`${Nt(r)}px`})}">${It(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 O`<li class="${Ve({"history-row":!0,"is-shown":e.sha===a})}">${l?O`<a class="history-sha" href="${`${l}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${u} on GitHub`}">${u}</a>`:O`<code class="history-sha">${u}</code>`} ${Lt(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`:A}" @click="${()=>this.open(e,r)}"><span class="history-author">${Ne(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?O`<time class="history-time" datetime="${i.toISOString()}">${P(e.committedAt)}</time>`:O`<span class="history-time"></span>`}</button></li>`})}</ol></div>${t.cut?O`<p class="history-note">Only the first 5,000 branches by name are read.</p>`:A} ${je(t,n,`Older commits`)}</div>`}};customElements.get(`repository-history`)||customElements.define(`repository-history`,Ut);function Wt(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 Gt=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,Kt=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],qt=new Set([`claude`,`codex`]);function Jt({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,Kt(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}=Wt(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=Gt(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}=Wt(t.head);n&&s(e,[n]);let i=Gt(t);t.signals.agents.length>0?i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`):(i&&(n||Kt(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 F=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(F(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(F(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>Gt(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>Wt(e.head).issue??[]),...o(`branch:`).flatMap(e=>Wt(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(F(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(F(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=>!qt.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 Jt(e).flatMap(e=>Yt(e,n)??[]).filter(e=>!r(e)).toSorted(F(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=C(new Map),{Shown:tn,repaint:nn}=T(Ye);p(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)=>ke(e.filter(e=>t===`all`||e.agents.includes(t)),n,e=>[e.title,...e.authors,...e.authors.map(Ie),...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`,oe,`pull request`,`pull requests`],[`branches`,se,`branch`,`branches`],[`commits`,ce,`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 O`<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?k`<circle class="read-gauge-arc" cx="11" cy="11" r="9" transform="rotate(-90 11 11)" stroke-dasharray=${`${r*e/100} ${r}`}/>`:A}</svg> ${e===100?O`<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>`:O`<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=>Se(e,t??{}).then(rn);return Ee(en,`${e}`,{first:()=>t(null).then(e=>(de(e.agents),e)),next:t,message:`The agents' work could not be read.`,repaint:nn,ready:an,merge:(e,t)=>{e.pulls=w(e.pulls,t.pulls,e=>e.number),e.commits=w(e.commits,t.commits,e=>e.oid);let n=e.sessions.length;an(e),e.stalled=e.sessions.length<=n}})}pick(e){g(this.repository,`agents`,e)}render(){if(!this.repository)return A;let{key:e,entry:t,more:n}=this.list(),r=t.status===`ready`,i=r?t.sessions:[],a=e=>r?O`<span class="n">${(e===`all`?i:i.filter(t=>t.agents.includes(e))).length}${t.more?`+`:``}</span>`:A,o=d(`agents`),c=ln(t).includes(o)?o:`all`,l=on(i,c,this._filter);return O`<div class="history-bar issues-bar">${v(`agents`)}${E(`Agents`,[[`all`,O`All${a(`all`)}`],...ln(t).map(e=>[e,O`${pe(e)}${fe(e)}${a(e)}`])],c,e=>()=>this.pick(e),{kindOf:e=>e===`all`?A:`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):A} ${r?fn(dn(t),`${t.pulls.length} pull request${t.pulls.length===1?``:`s`} read`,t.loadingMore):A}</div>${r?this.renderSessions(t,l,n,c):s(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 O`<span class="agent-totals">${[...cn(e),`claude`,`codex`].filter(n).map(n=>{let r=pn(e.sessions,n);return O`<span class="agent-stats" role="group" aria-label="${fe(n)}"><span class="${`agent-mark is-${n}`}">${pe(n)}</span> ${un.filter(([e])=>r[e]>0).map(([e,n,i,a])=>{let o=`${S(r[e])}${t[e]?`+`:``}`,s=`${o} ${r[e]===1&&!t[e]?i:a}`;return O`<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`:`${fe(r)} sessions`;return O`<div class="issues-scroll">${t.length>0?O`<ol class="issues-grid" aria-label="Sessions">${t.map(e=>this.renderSession(e))}</ol>`:O`<p class="history-note">${e.sessions.length>0&&this._filter.trim()?`None of the ${i} read match.`:`No ${i} among those read.`}</p>`} ${je(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=me(e,t),r=e.updatedAt==null?null:new Date(e.updatedAt),i=e.authors.find(e=>!Re(e)),a=e.pulls.length+e.commits.length,o=r?O`<time datetime="${r.toISOString()}">${P(e.updatedAt)}</time>`:A,s=e.additions||e.deletions?O`<span class="issue-diff"><span class="is-added">+${S(e.additions)}</span> <span class="is-deleted">−${S(e.deletions)}</span></span>`:A,c=a===1,l=[i?O`<span class="issue-author">${Le(i)}</span>`:A,c?A:o,a===0?O`<span>no pull request</span>`:A,c?A:s].filter(e=>e!==A),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}`,O`<code>${e.oid.slice(0,7)}</code>`,null]),...e.issues.map(e=>[`is-issue is-${e.state===`open`?`open`:`merged`}`,`issues/${e.number}`,O`<span class="sr-only">Issue </span>#${e.number}`,{kind:`issues`,reason:null,...e}])];return O`<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=>O`<span class="${`agent-mark is-${e}`}" role="img" aria-label="${fe(e)}">${pe(e)}</span>`)}</span> <span class="issue-lines">${n?O`<a class="issue-name" href="${n}" target="_blank" rel="noopener noreferrer">${e.title||`(no title)`}</a>`:O`<button type="button" class="issue-name">${e.title||`(no title)`}</button>`} ${l.length>0?O`<span class="issue-meta">${l}</span>`:A} ${u.length>0?O`<span class="agent-task-row"><span class="agent-chips">${u.slice(0,$t).map(([e,n,r,i],a)=>O`<a class="${`agent-chip ${e}`}" href="${t?`https://github.com/${t}/${n}`:A}" target="_blank" rel="noopener noreferrer" @click="${i?e=>this.openItem(e,i.number,i):A}" data-rest="${a<u.length-1?u.length-1-a:A}">${r}</a>`)}</span>${c&&(o!==A||s!==A)?O`<span class="issue-meta">${o}${s}</span>`:A}</span>`:A} ${e.branches[0]?O`<span class="issue-branch"><code>${e.branches[0]}</code>${e.branches.length>1?O`<span>+${e.branches.length-1}</span>`:A}</span>`:A}</span></div></li>`}};customElements.get(`repository-agents`)||customElements.define(`repository-agents`,mn);var hn=1e3,gn=5e3,_n=3e4,vn=6e5,I=864e5,L=7*I,R=e=>Math.floor(e/I)*I,yn=()=>Array.from({length:7},()=>0),bn=8,xn=3,Sn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Cn=[1,2,3,4,5,6,0],wn=6,Tn=new Map,En=new Map,Dn=new Map,z=C(new Map,Tn,En,Dn),{Shown:On,shown:kn,repaint:B}=T(Ye),An={pulls:`merged`,issues:`closed`},jn={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:`]]]},Mn=[`merged`,`opened`,`closed`,`created`],Nn=x(k`<circle cx="8" cy="8" r="2.75"/><path d="M8 1v4.25M8 10.75V15"/>`),Pn={agent:`Commit with agents`,without:`Commit without agents`,release:`Release`},Fn=10,In=10;p(e=>{if(e===`pulse`)for(let e of kn)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,Ln=e=>Object.fromEntries(Mn.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 Rn(e){if(!Number.isSafeInteger(e?.since)||!m.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:Cn.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(Pn,e.kind)?e.kind:null})):[]}:null;return{weeks:e.weeks,since:e.since,...Ln(e),stats:a,reading:H(e.reading),pulls:H(e.pulls),pending:e.pending===!0,behind:e.behind===!0}}function zn(e,t){En.set(e,t),t.answer.stats&&Dn.set(e,t.answer)}var W=e=>e.reading??e.pulls,Bn=(e,t=0)=>{let n=W(e)===null?e.pending?gn:null:hn;return n===null?null:Math.min(_n,n*2**t)};function Vn(e,t){let n=`${e}\0${t}`,r=Te(z(),n,()=>De(e,t).then(Rn),{ready:e=>({answer:e,stalls:0,asking:!1,moved:Date.now()}),settled:t=>{zn(e,t)},message:`The repository’s pulse could not be read.`,repaint:B});return r.status===`ready`&&!r.asking&&Bn(r.answer)!==null&&Hn(n,r,e,t,Bn(r.answer)),r}function Hn(e,t,n,r,i){t.asking=!0,setTimeout(()=>{if(z().get(e)===t){if(Date.now()-t.moved>=vn){t.asking=!1,t.moved=Date.now();return}De(n,r).then(Rn).then(i=>{if(z().get(e)!==t)return null;let a=i.behind||W(i)!==null&&W(t.answer)!==null&&W(i)>W(t.answer);t.answer=i,t.until=Date.now()+_e,t.stalls=a?0:t.stalls+1,a&&(t.moved=Date.now());let o=Bn(i,t.stalls);return o===null?t.asking=!1:Hn(e,t,n,r,o),null},()=>(z().get(e)!==t||(t.stalls++,Hn(e,t,n,r,Bn(t.answer,t.stalls)??Math.min(_n,hn*2**t.stalls))),null)).finally(B)}},i)}function Un(e,t,n){z();let r=[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`);return Te(Tn,r,()=>Oe(e,t,n),{ready:e=>({answer:Ln(e)}),failed:e=>({status:`error`,until:Date.now()+ve,error:e?.message||`These couldn’t be read.`}),repaint:B})}var Wn=(e,t)=>e[t]===!0&&e.weeks.some(e=>e[t===`agents`?`agentDays`:`releaseDays`].some(e=>e>0)),Gn=(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 Kn(e,t){let n=R(t);return n-new Date(n).getUTCDay()*I-(e-1)*L}var qn=(e,t)=>e.from===null||e.from===void 0||e.from<t;function Jn(e,t,n,r){return{weeks:n,since:e?.since??Kn(n,r),...Object.fromEntries(Mn.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 Yn(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&&qn(n,r-a),c=(e,t=0)=>Gn(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:Xn(n.contributors,r).length}}function G({id:e=null,login:t,name:n}){let r=Re(t,n);if(r)return`agent:${r}`;let i=Fe(t)?.id;return i==null?e===null?t?`@${t.toLowerCase()}`:`=${n}`:`#${e}`:`user:${i}`}function Xn(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 Zn(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:yn(),dayLines:Array.from({length:7},()=>[0,0]),agentDays:yn(),releaseDays:yn(),directDays:yn(),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 Qn(e,t,n,r,i){let a=r===null?e:Zn(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:Gn(a.weeks,t,o,`directDays`),items:s}}function $n(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 er(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 tr(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 nr=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),K=e=>nr.format(e),q=(e,t,n=`${t}s`)=>`${S(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`}),rr=e=>new Date(e).toISOString().slice(0,10),ir=(e,t)=>new Date(e).getUTCFullYear()!==new Date(t).getUTCFullYear(),ar=(e,t)=>{let n=R(t),r=ir(e,n);return e>=n?J(n,r):`${J(e,r)} \u2013 ${J(n,r)}`},or=(e,t)=>`${e.day?``:`Week of `}${J(e.from,ir(e.from,t),e.day)}`,sr=(e,t,n={})=>`${or(e,t)}: ${q(e.commits,`commit`)}${n.agents?`, ${S(e.agents)} with agents`:``}${n.releases?`, ${q(e.releases,`release`)}`:``}${e.additions===null?``:`, +${S(e.additions)} \u2212${S(e.deletions)} lines`}`;function cr(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 lr=(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 ${S(t)} ${n}`,ur=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function dr(e,t=!1){let n=t?`latest `:``;return e.reading===null?e.pulls===null?`GitHub is still counting this repository\u2019s ${n}commits\u2026`:`Reading this repository\u2019s pull requests\u2026 ${S(e.pulls)} so far`:`Reading this repository\u2019s ${n}commits\u2026 ${S(e.reading)}${e.weeks===52?` of the last year`:``} so far`}var fr=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,pr=O`<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>`,mr=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,hr=e=>e.login?ze(e.login,e.name,e.login):ze(null,e.name);function gr(e){let t=e?.who?Be(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 _r=(e,t,n)=>e>0?O`<button type="button" class="history-link pulse-more" @click="${n}">${t?`Fewer`:`and ${q(e,`more`,`more`)}`}</button>`:A,vr=class extends On{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){g(this.repository,`pulse`,m.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){An[e]=t,B()}render(){if(!this.repository)return A;let{repoId:e}=this.repository,t=h(),n=Vn(e,t);n.status===`ready`&&zn(e,n);let r=Date.now(),i=n.status===`ready`?n.answer:null,a=Dn.get(e),o=i?.stats&&qn(i.stats,i.since)?i:a&&n.status!==`error`&&qn(a.stats,Kn(t,r))?Jn(i,a,t,r):i&&{...i,stats:null},c=!o&&n.status===`loading`?En.get(e)??null:null,l=o?{answer:o,asking:n.asking===!0}:c,u=l?.answer.stats&&(W(l.answer)!==null||l.answer.pending);return O`<div class="history-bar">${v(`pulse`)}${E(`Period`,m,t,e=>()=>this.pick(e))}${l?O`<span class="pulse-range">${ar(l.answer.since,r)}</span>`:A} ${u?O`<span class="pulse-updating" role="status">${dr(l.answer,!0)}</span>`:A}</div>${l?O`<div class="${`pulse-scroll${c?` is-reading`:``}`}" aria-busy="${String(n.status!==`ready`)}">${this.renderPulse(l,r)}</div>`:s(n,`Reading the repository’s pulse…`,()=>{z().delete(`${e}\0${t}`),B()})}`}renderPulse(e,t){let{answer:n}=e,r=m.find(([e])=>e===n.weeks)[2],i=Yn(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,S(n[t].count),lr(n[t].count,n[t].previous,r),`${S(n[i].count)} opened`):this.renderTile(e,`–`,`Reading…`,``),l=this.renderLists(n,a,t);return O`<section class="pulse-tiles" aria-label="Figures">${this.renderTile(`Commits`,i.commits===null?`–`:S(i.commits),o??lr(i.commits,i.previous,r),`to the default branch`)} ${this.renderTile(`Contributors`,i.authors===null?`–`:S(i.authors),o,`who made them`)} ${c(`Pull requests merged`,`merged`,`opened`)} ${c(`Issues closed`,`closed`,`created`)} ${n.stats?.lines===!1?A:this.renderTile(`Lines`,i.additions===null?`–`:O`<span class="is-added">+${S(i.additions)}</span> <span class="is-removed">−${S(i.deletions)}</span>`,s,`added and removed`,i.additions===null?A:this.renderRatio(i.additions,i.deletions))} ${i.agents===null||!Wn(n.stats,`agents`)?A:this.renderAgentsTile(i,r)}</section><div class="${`pulse-grid${l.length>2?` is-lists`:``}`}">${n.stats?O`${this.renderActivity(e,t)}${this.renderContributors(n,t)}`:O`<div class="pulse-pending pulse-wide" role="status">${dr(n)}</div>`} ${l} ${n.stats?this.renderPunch(n.stats):A}</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(O`<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?`–`:`${ur(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:fr(ur(e.agents,n),ur(e.previousAgents,r),t),n===0?`no commits${i}`:`${S(e.agents)} of ${q(n,`commit`)}${i}`)}renderTile(e,t,n,r,i=A){return O`<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?O`<span class="pulse-tile-note">${r}</span>`:A}</div>`}renderRatio(e,t){return e+t===0?A:O`<span class="pulse-ratio" aria-hidden="true">${[[`is-added`,e],[`is-removed`,t]].map(([n,r])=>r>0?O`<span class="${n}" style="${D({"--share":`${r/(e+t)}`})}"></span>`:A)}</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?Zn(n.stats,this._person):n.stats,a=$n({...n,stats:i},t),o=a[0]?.day?`day`:`week`,s=r?Be(r.login,r.name):null,c=r?O`<span>a ${o} by</span><button type="button" class="pulse-picked is-person" aria-label="${`${s}\u2019s: show everyone\u2019s`}" @click="${()=>this.showPerson(null)}">${hr(r)}<span aria-hidden="true">×</span></button>`:O`<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 O`<figure class="pulse-panel pulse-activity"><figcaption class="pulse-head"><h3>Commits</h3>${c}</figcaption><p class="pulse-note">${l}</p></figure>`;let u=tr(Math.max(...a.map(e=>e.commits))),d=i.lines===!0&&a.every(e=>e.additions!==null)?tr(Math.max(...a.flatMap(e=>[e.additions,e.deletions]))):null,f={agents:Wn(n.stats,`agents`)&&a.some(e=>e.agents!==null),releases:Wn(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)=>O`<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`:A}" aria-label="${i?sr(e,t,f):A}" aria-hidden="${i?A:`true`}" @pointerenter="${()=>this.point(e.future?null:r)}" @click="${()=>this.pickColumn(a,r)}">${o}</span>`,y=(e,t)=>m&&!e.future?O`<span class="pulse-figure">${t}</span>`:A,b=(e,t,n=A)=>O`<span class="${`pulse-bar${e}`}" style="${D({"--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?O`<span class="${`pulse-part${e}`}" style="${D({"--part":`${t}`})}"></span>`:A)};return O`<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?O`<span class="pulse-legend">${f.agents?O`<span class="pulse-key"></span>With agents<span class="pulse-key is-without"></span>Without`:A}${f.releases?O`<span class="pulse-key is-release"></span>Releases`:A}</span>`:A}</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,O`${y(e,S(e.commits))}${p?b(` is-split`,e.commits/u.top,x(e)):b(``,e.commits/u.top)}`))}</div></div>${d?O`<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,O`<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?O`<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?O`<p class="pulse-note">GitHub counts this repository’s lines a week, not a day: the quarter and the year show them.</p>`:O`<p class="pulse-note" role="status">GitHub is still counting lines added and removed…</p>`}<div class="${`pulse-axis${m?` is-each`:``}`}" aria-hidden="true">${a.map((e,t)=>O`<span class="${e.future?`is-future`:e.day&&e.from===h?`is-today`:``}">${cr(a,t,n.weeks)}</span>`)}</div>${g===null?A:this.renderTip(n,a,g,t,f,!r)}</div><span class="sr-only" aria-live="polite">${this._typed&&g!==null?sr(a[g],t,f):``}</span></figure>`}renderTip(e,t,n,r,i,a){let o=t[n],s=R(r),[c,l,u]=er(o,e.stats.contributors),d=a?Xn(e.stats.contributors,c,l).slice(0,xn):[],f=(n+.5)/t.length;return O`<div class="${`pulse-tip${f>.6?` is-left`:``}`}" style="${D({"--x":`${f}`})}" aria-hidden="true"><span class="pulse-tip-when">${or(o,r)}${o.day?o.from===s?O`<span>today</span>`:A:r<o.to?O`<span>so far</span>`:A}</span> <span class="pulse-tip-row"><span class="${`pulse-tip-key${i.agents||i.releases?` is-none`:``}`}"></span><strong>${S(o.commits)}</strong> ${o.commits===1?`commit`:`commits`}</span> ${i.agents?O`<span class="pulse-tip-row"><span class="pulse-tip-key"></span><strong>${S(o.agents)}</strong> with agents</span>`:A} ${i.releases?O`<span class="pulse-tip-row"><span class="pulse-tip-key is-release"></span><strong>${S(o.releases)}</strong> ${o.releases===1?`release`:`releases`}</span>`:A} ${o.additions===null?A:O`<span class="pulse-tip-row"><span class="pulse-tip-key is-added"></span><strong>+${S(o.additions)}</strong> added</span> <span class="pulse-tip-row"><span class="pulse-tip-key is-removed"></span><strong>−${S(o.deletions)}</strong> removed</span>`} ${d.length>0?O`<span class="pulse-tip-people">${u?O`<span class="pulse-tip-note">Its week’s</span>`:A} ${d.map(e=>O`<span class="pulse-tip-person">${hr(e)}<strong>${S(e.commits)}</strong></span>`)}</span>`:A}</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 O`<div class="pulse-ticks" aria-hidden="true">${e.map(([e,t,n])=>O`<span class="${n?`is-zero`:A}" style="${D({"--at":`${e}`})}"><span>${t}</span></span>`)}</div>`}renderContributors(e,t){let{contributors:n}=e.stats,r=$n(e,t).find(e=>e.from===this._picked)??null,[i,a,o]=r?er(r,n):[e.since,1/0,!1],s=Xn(n,i,a),c=s[0]?.commits??1,l=e.stats.lines===!0,u=r?o?`Week of ${J(i,ir(i,t))}`:or(r,t):null;return O`<figure class="pulse-panel pulse-people"><figcaption class="pulse-head"><h3>Contributors</h3>${u?O`<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>`:O`<span>by their commits in the period</span>`}</figcaption>${s.length===0?O`<p class="pulse-note">No commits ${r?o||!r.day?`that week`:`that day`:`in the period`}.</p>`:O`<ol class="${`pulse-ranks${this._person===null?``:` is-picking`}`}">${(this._everyone?s:s.slice(0,bn)).map(e=>O`<li class="${e.key===this._person?`is-person`:A}"><span class="pulse-rank-who"><button type="button" class="pulse-rank-name" aria-pressed="${String(e.key===this._person)}" @click="${()=>this.showPerson(e.key)}">${hr(e)}</button> ${e.login?O`<a class="pulse-rank-profile" href="${mr(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${Be(e.login,e.name)} on GitHub`}">${pr}</a>`:A}</span> <span class="pulse-rank-bar"><span style="${D({"--value":`${e.commits/c}`})}"></span><span class="pulse-rank-value">${S(e.commits)}</span></span> ${l?O`<span class="pulse-rank-lines"><span class="is-added">+${K(e.additions)}</span> <span class="is-removed">−${K(e.deletions)}</span></span>`:A}</li>`)}</ol>${_r(s.length-bn,this._everyone,()=>{this._everyone=!this._everyone})}`}</figure>`}renderPunch(e){let{punch:t}=e,n=Math.max(1,...t.flat());return O`<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)=>O`<span class="pulse-punch-day">${Sn[Cn[t]].slice(0,3)}</span>${e.map((e,r)=>{let i=`${Sn[Cn[t]]}s, ${String(r).padStart(2,`0`)}:00\u2013${String(r+1).padStart(2,`0`)}:00: ${q(e,`commit`)}`;return O`<span class="${`pulse-cell is-${e===0?0:Math.ceil(e/n*wn)}`}" role="img" aria-label="${i}" data-tooltip="${i}"></span>`})}`)} <span></span>${Array.from({length:24},(e,t)=>O`<span class="pulse-punch-hour">${t%6==0?`${t}h`:``}</span>`)}</div><div class="pulse-scale" aria-hidden="true">Fewer${Array.from({length:wn},(e,t)=>O`<span class="${`pulse-cell is-${t+1}`}"></span>`)}More</div></figure>`}renderLists(e,t,n){let r=e.stats?Qn(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?Qn(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}=gr(t),a=this._allDirect?e.items:e.items.slice(0,Fn),o=Math.max(0,e.count-e.items.length);return O`<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?O`<span class="pulse-narrowed">${r}</span>`:A}<span class="pulse-count">${S(e.count)}</span></div>${e.count===0?O`<p class="pulse-note">None ${i}.</p>`:O`<ol>${a.map(e=>O`<li><a class="${`pulse-item is-commit${e.kind?` is-${e.kind}`:``}`}" href="${n?`https://github.com/${n}/commit/${e.sha}`:A}" target="_blank" rel="noopener noreferrer"><span class="issue-state" role="img" aria-label="${e.kind?Pn[e.kind]:`Commit`}">${Nn}</span> <span class="pulse-item-title">${e.subject||`(no message)`}</span> <span class="pulse-item-meta"><span>${e.sha.slice(0,7)}</span><span>${hr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${P(e.at)}</time></span></a></li>`)}</ol>`} ${_r(e.items.length-Fn,this._allDirect,()=>{this._allDirect=!this._allDirect})} ${o>0?O`<p class="pulse-note">${e.items.length>0?q(o,`older commit`,`older commits`):q(o,`commit`)} not listed.</p>`:A}</section>`}narrowing(e,t){let n=this._picked===null||!e.stats?null:$n(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,In);return{from:rr(n?.from??e.since),to:n?rr(n.to-I):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${or(n,t)}`:`in the w${or(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]=jn[t],[a,,o]=i.find(([e])=>e===An[t]),s=n&&!n.nobody?Un(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}`:`>=${rr(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:h,to:g,scope:_}=gr(n);return O`<section class="pulse-panel pulse-list" aria-label="${r}"><div class="pulse-head"><h3>${r}</h3>${n?O`<span class="pulse-narrowed">${g}</span>`:A}${E(`${r} shown`,i.map(([e,t])=>[e,O`${t}<span class="n">${c?.[e]?S(c[e].count):`–`}</span>`]),a,e=>()=>this.showList(t,e))}</div>${n?.nobody?O`<p class="pulse-note">${h}’s commits name no GitHub account to find their ${r.toLowerCase()} by.</p>`:s?.status===`error`?O`<p class="pulse-note" role="alert">${s.error}</p>`:u===null?O`<p class="pulse-note" role="status">Reading…</p>`:u.length===0?O`<p class="pulse-note">None ${_}.</p>`:O`<ol>${u.map(e=>{let[n,r]=ue(t,e);return O`<li><a class="${`pulse-item is-${n}`}" href="${d?`https://github.com/${d}/${t===`pulls`?`pull`:`issues`}/${e.number}`:A}" target="_blank" rel="noopener noreferrer" @click="${n=>this.openItem(n,t,e)}"><span class="issue-state" role="img" aria-label="${r}">${te[t][n]}</span> <span class="pulse-item-title">${e.title||`(no title)`}</span> <span class="pulse-item-meta"><span>#${e.number}</span>${e.author?O`<span>${Le(e.author)}</span>`:A} ${e.at==null?A:O`<time datetime="${new Date(e.at).toISOString()}">${P(e.at)}</time>`}</span></a></li>`})}</ol>`} ${m&&u!==null&&l>u.length?O`<a class="pulse-all" href="${m}" target="_blank" rel="noopener noreferrer">All ${S(l)} on GitHub</a>`:A}</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`,vr);var yr=864e5,br=[100,300,1e3],xr=e=>e.parents.length<=1&&Number.isFinite(e.committedAt),Sr=(e,t)=>Ze(e).filter(xr).slice(0,t).toReversed(),Cr=1,wr=.08,Tr=.6;function Er(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/yr;t.push(n===0?0:t[n-1]+Math.min(Tr,Math.max(wr,i*Cr)))}return t}function Dr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Or(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 kr=.9,Ar=2,jr=1,Mr=5,Nr=1,Pr=.06;function Fr(){let e=Ir(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Ir(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 Lr=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`)));function Rr(e,t){let n=e.dirs.get(t);if(n)return n;let r=Rr(e,Lr(t)),i=Ir(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),ti(r),e.layout=!0,i}function zr(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=Rr(e,Lr(t));i={path:t,name:t.slice(t.lastIndexOf(`/`)+1),extension:Dr(t),dir:a,ox:0,oy:0,touched:r,kind:n,removed:null},a.files.push(i),e.files.set(t,i),ti(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 Br(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);ti(r),e.layout=!0}var Vr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Hr(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=Vr(n),s=o.length>1?Math.min(Pr,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 Ur(e,t){for(let[n,r]of Vr(t)){let t=zr(e,n,r,-1/0);t&&r===`D`&&Br(e,t)}}function Wr(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 Gr(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=zr(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<kr);for(let n of[...e.going])t-n.removed>=jr&&Br(e,n);for(let[n,r]of e.users)t-r.active>Mr+Nr&&e.users.delete(n)}var Kr=6,qr=2.2,Jr=12,Yr=Math.PI*(3-Math.sqrt(5)),Xr=46,Zr=34,Qr=e=>e===0?0:Kr*.62*Math.sqrt(e)+qr;function $r(e){let t=Kr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Yr),t*Math.sin(e*Yr)]}function ei(e){ni(e.root),ri(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function ti(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function ni(e){if(!e.dirty)return;for(let t of e.dirs)ni(t);e.cluster=Math.max(Qr(e.files.length),qr)+Jr/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)gi(t,n);else{ii([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=li([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 ri(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);ri(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function ii(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;ai(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];ai(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(oi(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=si(i);for(let e=l.next;e!==a;e=e.next){let t=si(e);t<u&&([i,u]=[e,t])}a=i.next}}function ai(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 oi=(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 si(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 ci=64;function li(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&&pi(r,t[a]))){if(n=di(n,t[a]),r=Y(n),!Number.isFinite(r.x+r.y+r.r)||++i>ci*t.length)return ui(e);a=-1}return r}function ui(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 di(e,t){if(e.every(e=>pi(t,e)))return[t];for(let n of e)if(!fi(t,n)&&e.every(e=>pi(Y([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!fi(Y([r,i]),t)&&!fi(Y([r,t]),i)&&!fi(Y([i,t]),r)&&e.every(e=>pi(Y([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var fi=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function pi(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 mi=60,hi=.5;function gi(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t.filter(e=>e.x===void 0))_i(r,e,n),n.push(r);for(let n=0;n<mi;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-hi)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(vi(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-hi)return;let o=Math.hypot(i,a);if(o>=r-hi)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 _i(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-hi&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-hi),i=[],a=(t,n)=>{for(let[r,a]of[[t,n],[n,t]]){let t={r:e.r};ai(r,a,t),i.push(t)}};for(let e of n)a(t,e);vi(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 vi(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 yi(e,t,n=Zr){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]=$r(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)*Xr*3,r+Math.sin(t)*Xr*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Xr,r+(e.y-r)/i*Xr];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 bi(e){e.layout&&ei(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]=$r(e)}}function xi(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,Qr(t.files.length)+qr);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var Si=[.5,1,2,4,8],Ci=20,wi=50,Ti=8,Ei=[`background`,`text`,`muted`,`surface`,`added`,`modified`,`removed`],Di={side:40,top:64,bottom:40},Oi=3,ki=10,Z=11,Ai=72,ji=250,Mi=1.8,Ni=2,Pi=new Set([`A`,`M`,`D`,`R`]),Fi=2,Ii=new Map,Li=new Map,Ri=new Set,zi=new Map,Bi=new Map,Vi=C(Ii,Li,Ri,zi),{Shown:Hi,shown:Ui,repaint:Wi}=T(Ye),Gi=()=>Number(d(`replay`)??300),Ki=1;p(e=>{e===`replay`&&Wi()});var qi=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Ji(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=he(Vi(),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:Fr(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return Vi().set(a,s),ge(Ii,Fi,e=>[...Ui].some(t=>t.replay===e),Yi),s}function Yi(e,t){if(Ii.delete(e),[...Ii.values()].some(e=>e.repoId===t.repoId&&e.path===t.path))return;let n=`${t.repoId}\0${t.path}\0`;for(let e of[Li,zi,Ri])for(let t of[...e.keys()])t.startsWith(n)&&e.delete(t)}var Xi={files:[],cut:!1},Zi=e=>e.commits[0]?.parents[0]??null,Q=e=>Zi(e)?ea(e,Zi(e)):Xi,$=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,Qi=(e,t)=>Li.get($(e,t)),$i=(e,t)=>Ri.has($(e,t)),ea=(e,t)=>zi.get($(e,t)),ta=(e,t)=>!(!Qi(e,t.sha)||$i(e,t.sha)&&!ea(e,t.sha));function na(e){let t=0;for(;t<(e.commits?.length??0)&&ta(e,e.commits[t]);)t++;return t}function ra(e,t){if(!Array.isArray(e)||!Pi.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 ia(e){let t=Q(e),n=e.commits.filter(t=>Qi(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(Dr(t),(e.counts.get(Dr(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of Vr(Qi(e,t.sha)))r!==`D`&&i(n);Or(e.colors,e.counts,Ti)}var aa=e=>[...e.commits.slice(e.next),...e.commits.slice(0,e.next)];function oa(e,t,n,r,i){e[t]=!0,n().then(t=>(Vi().get(e.key)===e&&r(t),null),t=>(t?.name!==`AbortError`&&(e.error=t?.message||i),null)).finally(()=>{e[t]=!1,Wi()})}function sa(e){if(e.treeReading||e.error)return;let t=Zi(e)&&!Q(e),n=t?Zi(e):aa(e).find(t=>$i(e,t.sha)&&!ea(e,t.sha))?.sha;n&&oa(e,`treeReading`,()=>xe(e.repoId,e.path,n),r=>{let i=Array.isArray(r?.files)?r.files.map(t=>ra([t,`A`],e.path)?.[0]).filter(Boolean):[];zi.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 ca(e,t,n){let r=Qi(e,n.sha),i=$i(e,n.sha)?ea(e,n.sha):null;return i?[...r,...Wr(t,i.files,i.cut,Vr(r))]:r}function la(e,t){let n=Fr();n.start=Q(e),Ur(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))Ur(n,ca(e,n,r));return bi(n),n}function ua(e){if(e.reading||e.error||!e.commits)return;let t=na(e)===0?Ci:wi,n=aa(e).filter(t=>!Qi(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&oa(e,`reading`,()=>be(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)Li.set($(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>ra(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&Ri.add($(e,t))},`What the commits changed could not be read.`)}function da(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(Pe,i)?i:Re(n,r),a=e?null:Fe(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?Pe[e].name:a?a.name??a.login:r??n,c=e?Pe[e].mark??null:null,l=e?!c&&Pe[e].avatar?`/api/avatar/${Pe[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 fa={anthropic:[Ke,4,5,8],openai:[qe,4,5,8],"github-copilot":[Je,0,0,24]},pa={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},ma=new Map,ha=e=>ma.get(e)??ma.set(e,new Path2D(fa[e][0])).get(e);function ga(e){let t=Bi.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,Bi.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var _a=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),va=e=>e===.5?`½×`:`${e}\xD7`,ya=k`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,ba=k`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,xa=k`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,Sa=class extends Hi{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(),Bt(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(),Vt(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Ui].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}=zt(this.repository);if(t.status!==`ready`)return;if(t.commits.filter(xr).length<e.count&&t.more){!t.loadingMore&&!t.moreError&&n();return}e.commits=Sr(t.commits,e.count),e.times=Er(e.commits)}sa(e),ua(e);let t=Q(e);t&&(ia(e),e.scene.start!==t&&this.seek(e.next),!e.started&&na(e)>0&&(e.started=!0,e.playing=!qi(),this.requestUpdate()))}pickCount(e){g(this.repository,`replay`,String(e))}pickSpeed(e){Ki=e,Wi()}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,na(t)));Object.assign(t,{scene:la(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)&&(Gr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=ji&&(ei(n.scene),this._laidOut=e),yi(n.scene,t,Math.max(Zr,Ai/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*Ki,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!ta(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+Tr)-r;Hr(e.scene,da(t),ca(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+Ni&&(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(Ei.map(e=>[e,t(e)])),kinds:Array.from({length:Ti},(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,qr*u.zoom),g=h<Mi,_=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<Ar){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)/Ar),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/jr);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)/kr)*.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>Ar||b(e.name,d(e.x)+Math.max(6,(Qr(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=ki){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/Ar),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-Mr)/Nr));let[i,a]=Object.hasOwn(pa,e.agent)?pa[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?ga(e.image):null;if(e.mark&&Object.hasOwn(fa,e.mark)){let[,r,i,o]=fa[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(ha(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=xi(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(Oi,(t-2*Di.side)/Math.max(1,i.maxX-i.minX),(n-Di.top-Di.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-(Di.top-Di.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 A;let e=Ji(this.repository,Gi());this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:zt(this.repository),n=e.commits?.length??0,r=na(e),i=e.next>0?e.commits[e.next-1]:null,a=e.commits?e.people??=new Set(e.commits.flatMap(e=>da(e).map(e=>e.key))).size:0,o=(e.commits?Q(e):null)?.cut||e.commits?.some(t=>$i(e,t.sha)&&ea(e,t.sha)?.cut),s=e.commits&&n>0?`${S(n)} commit${n===1?``:`s`} by ${S(a)}, ${_a(e.commits[0].committedAt)} \u2013 ${_a(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return O`<div class="history-bar">${v(`replay`)}${E(`Commits played`,br.map(e=>[e,O`Last ${S(e)}`]),e.count,e=>()=>this.pickCount(e))}${s?O`<span class="history-summary">${s}</span>`:A}</div><div class="replay-stage"><canvas class="replay-canvas" role="img" aria-label="${i?`The repository\u2019s files as of ${_a(i.committedAt)}, ${S(e.next)} of ${S(n)} commits played`:`The repository’s files, as its commits change them`}" @pointermove="${this.pointer}" @pointerleave="${this.pointer}"></canvas>${i?O`<div class="replay-day"><time datetime="${new Date(i.committedAt).toISOString()}">${_a(i.committedAt)}</time> <span>${S(e.next)} of ${S(n)}</span></div>${this.renderCommit(i)}`:A} ${this.renderKey(e)} ${this.renderStatus(e,t,r)} ${this._hovered?O`<div class="replay-tip" style="${D({left:`${this._hovered.x}px`,top:`${this._hovered.y}px`})}">${this._hovered.text}</div>`:A}<div class="replay-swatches" aria-hidden="true">${[...Ei,...Array.from({length:Ti},(e,t)=>`kind-${t}`)].map(e=>O`<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 O`<p class="replay-commit">${t?O`<a class="replay-sha" href="${`${t}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" aria-label="${`Commit ${n} on GitHub`}">${n}</a>`:O`<code class="replay-sha">${n}</code>`} <span class="replay-commit-subject">${At(e.subject||`(no message)`,t)}</span> <span class="replay-commit-author">${Ne(e.authorLogin,e.authorName,e.coauthors)}</span></p>`}renderKey(e){if(e.colors.size===0)return A;let t=[...e.colors].toSorted((t,n)=>(e.counts.get(n[0])??0)-(e.counts.get(t[0])??0));return O`<ul class="replay-key" aria-label="Kinds of files">${t.map(([e,t])=>O`<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,()=>Ht(t.key)]:e.error?[`replay`,e.error,()=>{e.error=null,Wi()}]:t?.entry.status===`ready`&&t.entry.moreError?[`more`,t.entry.moreError,()=>t.more()]:[];if(a)return He(r,O`<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 O`<div class="replay-status" role="status">${e>0?`Reading commits\u2026 ${S(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?O`<div class="replay-status">No commits to play.</div>`:Q(e)?n===0?O`<div class="replay-status" role="status">Reading what the commits changed…</div>`:e.waiting?O`<div class="replay-status is-waiting" role="status">Reading what the next commits changed…</div>`:A:O`<div class="replay-status" role="status">Reading the files as they were before ${_a(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 O`<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?xa:e.playing?ba:ya}</svg></button><div class="replay-track" style="${D({"--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="${`${S(e.next)} of ${S(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div>${E(`Speed`,Si.map(e=>[e,va(e)]),Ki,e=>()=>this.pickSpeed(e))}</div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,Sa);var Ca=8,wa=20,Ta=C(new Map),{Shown:Ea,shown:Da,repaint:Oa}=T(b);p(e=>{(e===`issues`||e===`pulls`)&&Oa()}),Me(e=>{for(let t of Da)e&&t.repository?.repoId!==e.repoId||t.requestUpdate()});function ka(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 Aa(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 ja(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 Ma=(e,t)=>ke(e,t,e=>[`#${e.number}`,e.title,e.author??``,Ie(e.author)??``,e.head??``,...e.labels.map(e=>e.name)]),Na=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Pa=e=>e<1e3?String(e):Na.format(e);function Fa(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>Ca?Ca-1:Ca),r=e=>O`<span class="issue-label" style="${D(e.color?{"--label":`#${e.color}`}:{})}" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span>`,i=e=>O`${r(e[0])}${e.length>1?O`<span class="issue-labels-rest" style="${D({"--labels":String(e.length-1)})}">${i(e.slice(1))}</span>`:A}`;return O`${n.length>0?i(n):A}${t>n.length?O`<span class="issue-label is-more">+${t-n.length}</span>`:A}`}var Ia={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`,unlocked:`locked by no lockfile read`};function La({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,wa);return[t>0?`${e.slice(0,wa).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${Ia[e.unsupported]})`).join(`, `)}${a>0?` and ${S(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 Ra(e){if(e.status!==`ready`)return A;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=u(e),o=e.review?_(e).count:0,s=y(e);if(t.length===0&&o===0&&!s&&!e.pending)return A;let c=i?`+`:``,l=t=>{let n=f(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${Ia[t.unsupported]}`:n===`baseline`?`, needs no review`:t.reviewed?`, reviewed`:t.rejected?`, rejected`:n?`, ${t.reviews}/${e.review.required} reviews`:``},d=e=>`${e.name}@${e.version??`?`}${e.patch?`, patched`:``}${e.was?` (was ${e.was.join(`, `)}${l(e)})`:` (new${l(e)})`}`,p=t.length-wa,m=[t.length>0?`New in its lockfiles: ${t.slice(0,wa).map(d).join(`, `)}${p>0?` and ${S(p)}${c} more`:i?` and more`:``}`:null,o>0?`${S(o)} on the base branch unreviewed`:null,s?`Its review fails: ${La(s)}`:null,e.pending?`Stasis is still working out what its stasis.config.json’s entries reach`:null].filter(Boolean).join(`. `),h=[n?`${S(n)} new`:null,r?`${S(r)} updated`:null].filter(Boolean).join(`, `),g=a&&o?`${S(a)} + ${S(o)} to review`:a?`${S(a)} to review`:o?`${S(o)} unreviewed`:``;return O`<span class="issue-deps" data-tooltip="${m}">${le}<span class="issue-deps-names">${[...new Set(t.map(e=>e.name))].join(`, `)}</span> ${h?O`<span class="issue-deps-count">${h}${c}</span>`:A} ${s?O`<span class="issue-deps-review is-failed">${s.count>0?`${S(s.count)} can\u2019t be reviewed`:`lockfiles unread`}</span>`:e.pending?O`<span class="issue-deps-review is-pending" role="status">${g?`${g}, `:``}Stasis building…</span>`:e.review?g?O`<span class="issue-deps-review is-wanted">${g}</span>`:O`<span class="issue-deps-review is-passed" role="img" aria-label="Every version reviewed">${ie.success[1]}</span>`:A}</span>`}var za=class extends Ea{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=>we(t,r,{state:e,after:i}).then(ka).then(e=>(n(t,e.items,e.readAt,r),e));return Ee(Ta,`${t}\0${r}\0${e}`,{first:()=>i(null),next:i,message:`The list could not be read.`,repaint:Oa,ready:e=>ja(t,r,{...e,countsAt:e.readAt}),merge:(e,n)=>{e.items=w(e.items,n.items,e=>e.number),n.readAt>=e.countsAt&&(e.counts=n.counts,e.countsAt=n.readAt,ja(t,r,e))}})}pick(e){g(this.repository,this.kind,e)}render(){if(!this.repository)return A;let e=d(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`,c=Ta().get(`${this.repository.repoId}\0${this.kind}\0${o}`),l=i?Aa(this.repository.repoId,this.kind,e,n):null,u=l?l.counts:c?.status===`ready`?Aa(this.repository.repoId,this.kind,o,c).counts:null,f=e=>u?O`<span class="n">${S(u[e])}</span>`:A,p=l?Ma(l.items,this._filter):[];return O`<div class="history-bar issues-bar">${v(this.kind)}${E(this.kind===`pulls`?`Pull requests`:`Issues`,[[`open`,O`Open${f(`open`)}`],[`closed`,O`Closed${f(`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}}"> ${l&&this._filter.trim()?O`<span class="history-summary">${p.length} of ${l.items.length} read</span>`:A}</div>${l?this.renderTiles(n,l.items,p,r,`${e} ${a}`):s(n,`Reading the ${a}\u2026`,()=>{Ta().delete(t),Oa()})}`}renderTiles(e,t,n,r,i){if(t.length===0)return O`<div class="bundles-slide-placeholder">No ${i}.</div>`;let a=this.repo??this.repository.repo,o=this.kind===`pulls`?`pull`:`issues`;return O`<div class="issues-scroll">${n.length===0?O`<p class="history-note">None of the ${i} read match.</p>`:O`<ol class="issues-grid" aria-label="${i}">${n.map(e=>{let[t,n]=ue(this.kind,e),r=this.renderTile(e,t,n);return O`<li class="${Ve({"issue-tile":!0,[`is-${t}`]:!0})}">${a?O`<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>`:O`<div class="issue-body" @click="${t=>this.openTile(t,e)}">${r}</div>`}</li>`})}</ol>`} ${je(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`&&c(t)?l(this.repository.repoId,t.number,!0,{listed:!0}):null,o=t.updatedAt==null?null:new Date(t.updatedAt),s=i&&t.checks?ie[t.checks]:null,u=i&&t.state===`open`&&t.review?ae[t.review]:null,d=t.comments>0?`${S(t.comments)} comment${t.comments===1?``:`s`}`:null,f=(e,[n,r])=>O`<span class="${`issue-${e} is-${t[e]}`}" role="img" aria-label="${n}" data-tooltip="${n}">${r}</span>`;return O`<span class="issue-rail"><span class="issue-state" role="img" aria-label="${r}">${te[this.kind][n]}</span> ${i?O`<span class="issue-marks">${u?f(`review`,u):A}${s?f(`checks`,s):A}</span>`:A} ${d?O`<span class="issue-comments" role="img" aria-label="${d}" data-tooltip="${d}">${re}<span>${Pa(t.comments)}</span></span>`:A} </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">${Le(t.author,t.author??`ghost`)}</span> ${o?O`<time datetime="${o.toISOString()}">${P(t.updatedAt)}</time>`:A} </span>${t.labels.length>0||t.moreLabels>0?O`<span class="issue-labels">${Fa(t)}</span>`:A} ${i&&t.head?O`<span class="issue-branch"><code>${t.head}</code>${t.base?O`<span aria-hidden="true">→</span><code>${t.base}</code>`:A} <span class="issue-diff"><span class="is-added">+${S(t.additions)}</span> <span class="is-deleted">−${S(t.deletions)}</span></span></span>`:A} ${i&&t.state===`open`?e(t.reviews):A} ${a?Ra(a):A}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,za);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Of as e,Qf as t,Sf as n,pe as r,qe as i}from"./chunk-7KUZQB6S.js";import{a,u as o}from"./chunk-ZPIUN4FW.js";import{c as s,d as c,g as l}from"./chunk-2XUEZHIP.js";var u=e(c`<path d="M3.5 8.4l2.9 2.9 6.1-6.6"/>`),d=e(c`<circle class="fill" cx="8" cy="8" r="3"/>`),f=e(c`<path d="M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6"/>`),p=e(c`<circle class="dotted" cx="8" cy="8" r="5.5"/>`),m=e(c`<path d="M2.6 3.2h7.6v5.3H6.3L4 10.4V8.5H2.6z"/><path d="M12.2 6.2h1.2v5.3H12v1.9l-2.3-1.9H7"/>`),h={approved:[`approved`,n.approved[1],`Approved`],changes:[`changes`,n.changes[1],`Changes requested`],commented:[`commented`,t,`Commented`],dismissed:[`dismissed`,t,`Review dismissed`]},g={done:[`reviewed`,u,`Reviewed`],running:[`running`,d,`Reviewing`],failed:[`failed`,f,`Review failed`],requested:[`requested`,p,`Asked to review again`]},_=[`requested`,p,`Review requested`],v=e=>e.slice(0,7),y=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),b=(e,t,n=!1)=>`${e.toLocaleString(`en-US`)}${n?`+`:``} ${t}${e===1&&!n?``:`s`}`;function x(e){return e?e.failed?g.failed:e.requested?g.requested:g[e.code?.status]??null:null}function S(e){let t=x(e.codex),n=e.codex?.code?.commit??null;return[...t?[{who:o(e.codex.login,`Codex`),standing:t,commit:n,stale:n!==null&&n!==e.head}]:[],...e.reviewers.map(t=>({who:o(t.login,t.login??`someone`),standing:h[t.state]??_,requested:t.requested&&!!h[t.state],workflow:t.workflow??null,commit:t.commit,at:t.at,stale:t.commit!==null&&t.commit!==e.head}))]}var C=e=>(e.moreReviews??0)+(e.moreRequests??0),w=e=>[e.moreReviews>0?b(e.moreReviews,`more review`):null,e.moreRequests>0?b(e.moreRequests,`more review request`):null].filter(Boolean).join(` and `);function T(e){if(!e.head)return!0;let t=e.codex?.code;return t?.status===`done`&&t.commit===e.head||e.reviewers.some(t=>h[t.state]&&t.state!==`dismissed`&&t.commit===e.head)?!0:e.moreReviews>0&&null}var E=e=>e?s`<span class="${`review-severity is-${e}`}">${e.toUpperCase()}</span>`:l;function D(e){if(!e)return l;let t=S(e),{open:n,more:r,severity:i}=e.threads,a=n>0?`${b(n,`open review thread`,r)}${i?`, the gravest ${i.toUpperCase()}`:``}`:r?`No open review thread among those read; more on GitHub`:null,o=T(e);return s`<span class="issue-reviews">${t.map(({who:e,standing:[t,n,r],commit:i,stale:a,requested:o})=>{let c=`${r}${o?`, and requested again`:``}${a?`, on an earlier commit (${v(i)})`:i?`, on the latest commit`:``}`;return s`<span class="${`review-mark is-${t}${a?` is-stale`:``}`}"><span class="review-glyph" role="img" aria-label="${c}" data-tooltip="${c}">${n}</span><span class="review-who">${e}</span></span>`})} ${C(e)>0?s`<span class="review-more" data-tooltip="${`${w(e)}, on GitHub`}">+${C(e)}</span>`:l} ${a?s`<span class="review-threads" role="img" aria-label="${a}" data-tooltip="${a}">${m}<span>${n}${r?`+`:``}</span>${E(i)}</span>`:l} ${o===!1?s`<span class="review-unreviewed" data-tooltip="${t.length>0?`No review is on the latest commit`:`No reviews yet`}">Unreviewed</span>`:o===null?s`<span class="review-unreviewed" data-tooltip="No review read is on the latest commit; more on GitHub">Unreviewed?</span>`:l}</span>`}function O(e,t,n){if(!e)return l;let r=s`<code>${v(e)}</code>`;return s`<span class="review-on">on ${n?s`<a href="${`https://github.com/${n}/commit/${e}`}" target="_blank" rel="noopener noreferrer">${r}</a>`:r}${e===t?`, the latest commit`:`, an earlier commit`}</span>`}function k(e,t){if(!e)return l;let{head:n,codex:r}=e,i=(e,[i,a,c],l)=>s`<li class="review-row">${o(r.login,`Codex`)} <span class="${`review-state is-${i}`}">${a}${l}: ${c.toLowerCase()}</span>${O(e.commit,n,t)}</li>`,a=[...r?.code?[i(r.code,x(r)??g.done,`Code review`)]:[],...r?.security?[i(r.security,g[r.security.status]??g.done,`Security review`)]:[],...S({...e,codex:null}).map(({who:e,standing:[r,i,a],commit:o,at:c,requested:u,workflow:d})=>s`<li class="review-row">${e} <span class="${`review-state is-${r}`}">${i}${a}${u?`, requested again`:``}</span>${d?s`<span class="review-on">by the workflow <code>${d}</code></span>`:l}${O(o,n,t)}${c?s`<time datetime="${new Date(c).toISOString()}">${y(c)}</time>`:l}</li>`)],{open:c,resolved:u,more:d,list:f=[]}=e.threads;return s`<section class="repo-item-section"><h4>Reviews</h4>${a.length>0?s`<ul>${a}</ul>`:s`<p class="repo-item-quiet">No reviews yet.</p>`} ${C(e)>0?s`<p class="repo-item-quiet">And ${w(e)}, on GitHub.</p>`:l} ${T(e)===null?s`<p class="repo-item-quiet">No review read is on the latest commit, <code>${v(n)}</code>; one of those on GitHub may be.</p>`:a.length>0&&!T(e)?s`<p class="repo-item-quiet">No review is on the latest commit, <code>${v(n)}</code>.</p>`:l}</section>${c>0||u>0?s`<section class="repo-item-section"><h4>Open threads</h4>${f.length>0?s`<ul>${f.map(e=>s`<li><a class="repo-item-row review-thread" href="${e.url??l}" target="_blank" rel="noopener noreferrer">${E(e.severity)}<span class="repo-item-title">${e.title||`(no comment)`}</span> ${e.path?s`<code class="review-path">${e.path}${e.line?`:${e.line}`:``}</code>`:l} ${e.outdated?s`<span class="repo-item-quiet">outdated</span>`:l}</a></li>`)}</ul>`:s`<p class="repo-item-quiet">${d?`None open among those read.`:`None open.`}</p>`} ${u>0||d?s`<p class="repo-item-quiet">${u>0?`${b(u,`thread`)} resolved`:``}${d?`${u>0?`; `:``}more on GitHub`:``}.</p>`:l}</section>`:l}`}var A=a({items:new Map,changes:0}),j=i(A.items),M=(e,t,n)=>`${e}\0${t}\0${n}`,N=e=>Number.isSafeInteger(e?.readAt)&&e.readAt>0?e.readAt:Date.now();function P(e,t,n,i=null){j();let a=r(),o=!1;for(let r of t){let t=M(a,e,r.number),s=A.items.get(t);if(s&&s.readAt>n)continue;let c=s&&R(s.item),l=!c||c===R(r)?s?.moved??null:{from:c,before:s.readAt};A.items.set(t,{item:{...r,kind:r.kind??i??s?.item.kind??null},readAt:n,moved:l}),o=!0}o&&A.changes++}var F=(e,t)=>A.items.get(M(r(),e,t))??null;function I(e,t){let n=M(r(),e,``);return A.changes,[...A.items].flatMap(([e,r])=>e.startsWith(n)&&r.item.kind===t?[r]:[])}var L=()=>A.changes,R=e=>e.state===`open`?`open`:`closed`;function z(e,t){let n=R(e.item);if(e.readAt<=t||!e.moved)return n;if(e.moved.before>=t)return e.moved.from;let r=e.item.closedAt??e.item.mergedAt??null;return n===`closed`&&r!==null&&r>t?e.moved.from:n}export{D as a,k as b,N as c,P as d,F as e,I as f,L as g,R as h,z as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-GO7FT4OD.js";import{b as t,c as n,d as r,e as i}from"./chunk-RAM3GDAD.js";import{c as a,d as o,e as s,f as c,h as l,k as u,l as d,m as f,o as p,q as m}from"./chunk-WBK5ZN4K.js";import"./chunk-N57OWFKY.js";import{a as h}from"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import{m as g,q as _,s as v,w as y}from"./chunk-KP2XM324.js";import"./chunk-DUASGS2O.js";import{b}from"./chunk-IYPY47MC.js";import"./chunk-QRKFPLA4.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";function x(e){if(e instanceof Uint8Array)return{proven:!1,reason:`unsupported`,at:null};if(typeof e!=`string`)throw TypeError(`a text must be a string or its UTF-8 bytes, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a text must be a well-formed string`);return{proven:!1,reason:`unsupported`,at:null}}var S=e=>e.subarray(0,8e3).includes(0),C=(e,t)=>(e+Math.imul(t,97)>>>0)%107927,w=e=>Uint8Array.from({length:256},(t,n)=>Number(n===10||e.includes(String.fromCodePoint(n)))),T=w(``),E=w(`,;={}`);function D(e,t=T){let n=!S(e),r=new Map,i=(e,t)=>r.set(e,(r.get(e)??0)+t),a=0,o=0,s=0;for(let r=0;r<e.length;r++){let c=e[r];if(n&&c===13&&e[r+1]===10)continue;let l=a;a=(a<<7^o>>>25)+c>>>0,o=(o<<7^l>>>25)>>>0,!(++s<64&&t[c]===0)&&(i(C(a,o),s),s=0,a=0,o=0)}s>0&&i(C(a,o),s);let c=Uint32Array.from(r.keys()).sort();return{hashes:c,bytes:Float64Array.from(c,e=>r.get(e)),total:r.values().reduce((e,t)=>e+t,0)}}function ee(e,t){let n=0;for(let r=0,i=0;r<e.hashes.length&&i<t.hashes.length;)e.hashes[r]<t.hashes[i]?r++:e.hashes[r]>t.hashes[i]?i++:n+=Math.min(e.bytes[r++],t.bytes[i++]);return n}function te(e,t,n){let r=0,i=e.total,a=t.total;for(let o=0,s=0;o<e.hashes.length&&s<t.hashes.length;)if(e.hashes[o]<t.hashes[s]?i-=e.bytes[o++]:(e.hashes[o]>t.hashes[s]||(r+=Math.min(e.bytes[o],t.bytes[s]),i-=e.bytes[o++]),a-=t.bytes[s++]),(r+Math.min(i,a))*6e4<n)return 0;return r}function O(e,t,n,r,i=!1){if(e===null||t===null||t.length===0)return 0;let a=Math.abs(e.length-t.length),o=Math.max(e.length,t.length);if(o*(6e4-n)<a*6e4)return 0;let s=r(e),c=r(t),l=i?te(s,c,n*o):ee(s,c);return Math.trunc(l*6e4/o)}var k=/^[\w-]{6,}$/u,A=/[\dA-Z]/u,ne=/^(?:\.[\w-]+)+$/u,re=/^[\w-]{8,32}$/u;function j(e){let t=[];for(let n=e.length-1;n>0;n--){if(e[n]!==`-`&&e[n]!==`.`)continue;let r=e.indexOf(`.`,n+1),i=e.slice(r),a=e.slice(n+1,r);r!==-1&&re.test(a)&&ne.test(i)&&/[A-Za-z]/u.test(a)&&A.test(a)&&t.push([e.slice(0,n),a,i])}return t}var ie=e=>e.replaceAll(/\d/gu,`0`).replaceAll(/[a-z]/gu,`a`).replaceAll(/[A-Z]/gu,`A`);function ae(e,t){let n=j(t);for(let[t,r,i]of j(e)){let e=n.find(e=>e[2]===i);if(e&&e[1]!==r)return e[0]===t&&ie(e[1])!==ie(r)}return!1}function oe(e){let t=e.lastIndexOf(`/`),n=e.slice(t+1),r=n.lastIndexOf(`.`),i=r>0?n.slice(r):``;return{name:n,key:`${e.slice(0,t+1)}\0${i}\0${n.length}`}}function se(e,t){let n=e.length,r=0;for(;r<e.length&&e[r]===t[r];)r++;for(;n>r&&e[n-1]===t[n-1];)n--;for(;r>0&&!`-._`.includes(e[r-1]);)r--;for(;n<e.length&&e[n]!==`.`;)n++;let i=e.slice(r,n),a=t.slice(r,n);return r>0&&k.test(i)&&k.test(a)&&(A.test(i)||A.test(a))}function ce({sources:e,dests:t,pairs:n,used:r,record:i,punctuatedScoreOf:a},{remaining:o,open:s},c,l){let u=(e,t)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>[t,oe(e[t].path)])),d=u(t,s),f=u(e,o),p=Map.groupBy(f.keys(),e=>f.get(e).key),m=Map.groupBy(d.keys(),e=>d.get(e).key),h=[];for(let[e,t]of m){let n=p.get(e)??[];for(let e of t)for(let t of n)se(f.get(t).name,d.get(e).name)&&h.push({s:t,d:e})}let g=Map.groupBy(h,({d:e})=>e),_=Map.groupBy(h,({s:e})=>e),v=[];for(let{s:e,d:t}of h){let n=_.get(e).length===1&&g.get(t).length===1&&ae(f.get(e).name,d.get(t).name),r=a(e,t,n?0:c);(n||r>=c)&&v.push({s:e,d:t,score:r})}let y=[],b=new Set,x=new Set;for(let e of v.sort((e,t)=>t.score-e.score))n.has(e.d)||r.has(e.s)||(x.has(e.s)||b.has(e.d)||l(e)?(y.push(e),x.add(e.s),b.add(e.d)):i(e.d,e.s,e.score));return y}var le=/(?<![\p{L}\p{N}_$])(?:0[box][\d_a-f]+n?|\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?\d+)?n?)|(?<![\p{N}.])\.\d[\d_]*(?:e[+-]?\d+)?/giu;function ue(e){let t=e.toLowerCase(),n=/^0[box]|n$/u.test(t)?null:/^([^e]*)(?:e([+-]?)0*(\d+))?$/u.exec(t);if(!n)return t;let[,r=``,i=``,a=``]=n,o=(r.startsWith(`.`)?`0${r}`:r).replace(/(\.\d+?)0+$/u,`$1`).replace(/\.$/u,``),s=/^0+$/u.test(a);return a===``||s&&o.includes(`.`)?o:`${o}e${i===`-`&&!s?`-`:``}${a}`}var de=e=>e.replaceAll(le,ue).replaceAll(/,(?=(?:\s|\/\/[^\n\r\u2028\u2029]*(?![^\n\r\u2028\u2029])|\/\*(?:[^*]|\*(?!\/))*\*\/)*[\])}>])/gu,``).replaceAll(/(?<!\\)\\+(?=["'])/gu,e=>e.slice(e.length%2)).replaceAll(/[\s();]/gu,``).replaceAll(`'`,`"`);function fe(e,t){let n=e.length;if(n!==t.length)return!1;let r=0;if(n>=32&&(e.byteOffset&3)==(t.byteOffset&3)){for(let n=4-(e.byteOffset&3)&3;r<n;r++)if(e[r]!==t[r])return!1;let i=n-r>>>2,a=new Int32Array(e.buffer,e.byteOffset+r,i),o=new Int32Array(t.buffer,t.byteOffset+r,i);for(let e=0;e<i;e++)if(a[e]!==o[e])return!1;r+=i*4}for(;r<n;r++)if(e[r]!==t[r])return!1;return!0}var M=class extends Error{constructor(e,t,n){let r=n===void 0?``:` in the ${n} tree`;super(t===void 0?e:`${e}: ${JSON.stringify(t)}${r}`),this.name=`CompareError`,this.path=t,this.tree=n}},pe=new Set([`file`,`contiguous-file`]),me=new Set([`fifo`,`character-device`,`block-device`]),he=/(?:^|\/)\.{0,2}(?:\/|$)/u;function ge(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`)}function _e(e,t,n,r){if(typeof e!=`string`)throw TypeError(`an entry's name must be a string, not ${typeof e}`);if(e!==`.`||t!==`directory`){if(r?e===``:he.test(e))throw new M(r?`a name must not be empty`:"a name must be a relative path with no empty, `.` or `..` segment",e,n);if(!e.isWellFormed())throw new M(`a name must be well-formed Unicode`,e,n)}}function ve(e,t,n){if(typeof e!=`string`||e===``)throw new M(`a link must name its target`,t,n);if(!e.isWellFormed())throw new M(`a link target must be well-formed Unicode`,t,n);return e}function ye(e){if(e===void 0)return new Uint8Array;if(e instanceof Uint8Array)return e;if(typeof e!=`string`)throw TypeError(`a file's data must be a string or a Uint8Array, not ${typeof e}`);if(!e.isWellFormed())throw TypeError(`a file's text must be well-formed Unicode`);return e}var N=e=>typeof e==`string`?h(e):e;function be(e,t,n){if(typeof e!=`object`||!e)throw TypeError(`an entry must be an object, not ${e===null?`null`:typeof e}`);let{name:r,type:i=`file`,mode:a,linkname:o,data:s}=e;if(_e(r,i,t,n),a!==void 0&&ge(a),pe.has(i))return{path:r,type:`file`,mode:a??420,data:ye(s)};if(i===`symlink`||i===`hardlink`)return{path:r,type:i,target:ve(o,r,t)};if(i===`directory`)return{path:r,type:i};throw me.has(i)?new M(`a ${i} is neither a file nor a link`,r,t):TypeError(`${JSON.stringify(i)} is not an entry type`)}function P(e,t){return e.type===t.type?e.type===`symlink`?e.target===t.target:e.data===t.data?!0:typeof e.data==`string`&&typeof t.data==`string`?!1:fe(N(e.data),N(t.data)):!1}function xe(e,t,n){let r=new Set([e.path]),i=t.get(e.target);for(;i?.type===`hardlink`;){if(r.has(i.path))throw new M(`a hard link leads back to itself`,e.path,n);r.add(i.path),i=t.get(i.target)}if(i===void 0||i.type===`directory`)throw new M(`a hard link must name a file or a link in the tree`,e.path,n);return{...i,path:e.path}}function F(e,t,n){let r=new Map;for(let i of e){let e=be(i,t,n);if(e.type!==`directory`||e.path!==`.`){if(r.has(e.path))throw new M(`a name is given twice`,e.path,t);r.set(e.path,e)}}let i=new Map;for(let[e,a]of r){for(let i=n?-1:e.lastIndexOf(`/`);i>0;i=e.lastIndexOf(`/`,i-1)){let n=r.get(e.slice(0,i));if(n!==void 0&&n.type!==`directory`)throw new M(`a path lies under a ${n.type===`symlink`?`link`:`file`}`,e,t)}a.type===`hardlink`?i.set(e,xe(a,r,t)):a.type!==`directory`&&i.set(e,a)}return i}var Se=100,Ce=4,I=e=>e.slice(e.lastIndexOf(`/`)+1);function L(t,n){if(t.type===`symlink`)return`l${t.target}`;let r=n(t);return`f${r.length}:${e(r)}`}function we({sources:e,dests:t,sourceNames:n,destNames:r,used:i,record:a,bytes:o}){let s=Map.groupBy(e.keys(),t=>L(e[t],o));for(let c=0;c<t.length;c++){let l=-1,u=Se;for(let a of s.get(L(t[c],o))??[])if(!i.has(a)&&P(e[a],t[c])&&((l===-1||n[a]===r[c])&&(l=a),n[a]===r[c]||--u===0))break;l!==-1&&a(c,l,6e4)}}var Te=new Map([[`.ts`,`.js`],[`.mts`,`.mjs`],[`.cts`,`.cjs`],[`.tsx`,`.jsx`]]),R=new Map([...[`.js`,`.mjs`,`.cjs`,`.jsx`,`.ts`,`.mts`,`.cts`,`.tsx`].map(e=>[e,`script`]),...[`.css`,`.scss`,`.sass`,`.less`].map(e=>[e,`style`])]);function z(e){let t=e.split(`/`),n=t.pop(),r=n.lastIndexOf(`.`);return r>0?{dirs:t,stem:n.slice(0,r),extension:n.slice(r)}:{dirs:t,stem:n,extension:``}}function B(e){let{dirs:t,stem:n,extension:r}=z(e);return JSON.stringify([t.map(e=>e===`lib`||e===`src`?null:e),n,Te.get(r)??r])}function Ee(e){let{dirs:t,stem:n,extension:r}=z(e),i=[n,R.get(r)??r],a=t.lastIndexOf(`node_modules`),o=a===-1?0:a+(t[a+1]?.startsWith(`@`)?3:2),s=[JSON.stringify([...i,t])];for(let e=o;e<t.length;e++)s.push(JSON.stringify([...i,t.toSpliced(e,1,null)]));return s}var V=(e,t)=>Math.max(t,e+Math.trunc((6e4-e)/2));function H({pairs:e,used:t,scoreOf:n},{remaining:r,open:i},{s:a,d:o,score:s},c){let l=V(s,c);return i.some(t=>t!==o&&!e.has(t)&&n(a,t,l)>=l)||r.some(e=>e!==a&&!t.has(e)&&n(e,o,l)>=l)}function De(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=Map.groupBy(t.remaining.filter(e=>i[e].type===`file`),e=>B(i[e].path)),d=t.open.filter(e=>a[e].type===`file`).flatMap(e=>(u.get(B(a[e].path))??[]).map(t=>({s:t,d:e,score:l(t,e,0)})));for(let i of d.sort((e,t)=>t.score-e.score))o.has(i.d)||s.has(i.s)||n&&H(e,t,i,r)||c(i.d,i.s,i.score)}function Oe(e,t,n,r){let{sources:i,dests:a,pairs:o,used:s,record:c,scoreOf:l}=e,u=new Map,d=(e,t,n)=>new Map(t.filter(t=>e[t].type===`file`).map(t=>{let r=Ee(e[t].path);for(let e of r)(u.get(e)??u.set(e,{sources:[],dests:[]}).get(e))[n].push(t);return[t,r]})),f=d(a,t.open.filter(e=>!o.has(e)),`dests`),p=d(i,t.remaining.filter(e=>!s.has(e)),`sources`),m=(e,t)=>{let n=new Set(e.flatMap(e=>u.get(e)[t]));return n.size===1?[...n][0]:-1};for(let[i,a]of p){let o=m(a,`dests`);if(o===-1||m(f.get(o),`sources`)!==i)continue;let s={s:i,d:o,score:l(i,o,0)};n&&H(e,t,s,r)||c(o,i,s.score)}}function ke(e,t,n){let r=G(e),i=t<6e4&&r.remaining.length*r.open.length<=n*n;De(e,r,i,t),Oe(e,r,i,t)}function U(e,t){let n=new Map;for(let r of t)n.set(e[r],n.has(e[r])?-1:r);return n}function Ae({sourceNames:e,destNames:t,record:n,scoreOf:r},{remaining:i,open:a},o){let s=U(t,a),c=U(e,i);for(let t of i){let i=s.get(e[t]);if(i===void 0||i===-1||c.get(e[t])===-1)continue;let a=r(t,i,o);a>=o&&n(i,t,a)}}var W=(e,t)=>t.score-e.score||t.nameScore-e.nameScore;function je(e,t){if(e.length<Ce){e.push(t);return}let n=0;for(let t=1;t<e.length;t++)W(e[t],e[n])>0&&(n=t);W(e[n],t)>0&&(e[n]=t)}function Me({sourceNames:e,destNames:t,pairs:n,used:r,record:i,scoreOf:a},{remaining:o,open:s},c,l){let u=[];for(let n of s){let r=[];for(let i of o)je(r,{score:a(i,n,c),nameScore:+(e[i]===t[n]),dst:n,src:i});u.push(...r)}let d=0,f=e=>{for(;d<l.length&&V(l[d].score,c)>e;d++){let{s:e,d:t,score:a}=l[d];!n.has(t)&&!r.has(e)&&i(t,e,a)}};for(let{dst:e,src:t,score:a}of u.sort(W)){if(a<c)break;f(a),!n.has(e)&&!r.has(t)&&i(e,t,a)}f(-1/0)}function Ne(e){if(e.type!==`file`||!R.has(z(e.path).extension))return null;let t=typeof e.data==`string`?e.data:a(e);return t===void 0?null:N(de(t))}var Pe=2048,Fe=(e,t)=>t<Pe?K(e):e+Math.trunc((6e4-e)/10);function Ie(e,t){let n=new Map,r=new Map,i=e=>r.has(e)?r.get(e):r.set(e,Ne(e)).get(e),a=e=>n.get(e)??n.set(e,D(e,E)).get(e);Me({...e,scoreOf:(n,r)=>{let[o,s]=[i(e.sources[n]),i(e.dests[r])],c=Fe(t,Math.max(o?.length??0,s?.length??0)),l=O(o,s,c,a);return l>=c?l:0}},G(e),Fe(t,Pe),[])}var G=({sources:e,dests:t,pairs:n,used:r})=>({remaining:e.keys().filter(e=>!r.has(e)).toArray(),open:t.keys().filter(e=>!n.has(e)).toArray()}),K=e=>V(e,e);function Le(e,t,{minimum:n,limit:r,byPath:i,byForm:a=!1}){let o=new Map,s=new Set;if(e.length===0||t.length===0)return o;let c=new Map,l=new Map,u=new Map,d=e=>e.type===`file`?l.get(e)??l.set(e,N(e.data)).get(e):null,f=e=>c.get(e)??c.set(e,D(e)).get(e),p=e=>u.get(e)??u.set(e,D(e,E)).get(e),m={sources:e,dests:t,pairs:o,used:s,sourceNames:e.map(e=>I(e.path)),destNames:t.map(e=>I(e.path)),record(e,t,n){o.set(e,{source:t,score:n}),s.add(t)},bytes:d,scoreOf:(n,r,i)=>O(d(e[n]),d(t[r]),i,f),punctuatedScoreOf:(n,r,i)=>O(d(e[n]),d(t[r]),i,p,!0)};if(we(m),i&&ke(m,n,r),n>=6e4)return o;Ae(m,G(m),K(n));let h=G(m);if(h.remaining.length*h.open.length>r*r)return o;let g=i?ce(m,h,K(n),e=>H(m,h,e,n)):[];return Me(m,G(m),n,g),a&&Ie(m,n),o}var Re=50,ze=1e3;function q(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}function Be(e){if(e===!1)return null;let t=e===!0?Re:e;if(typeof t!=`number`)throw TypeError(`renames must be a boolean or a percentage, not ${typeof e}`);if(!(t>0&&t<=100))throw RangeError(`renames must be a percentage above 0 and at most 100, not ${e}`);return Math.max(1,Math.trunc(6e4*t/100))}function Ve({renamesByPath:e,renamesByForm:t,renameLimit:n,renameGroup:r,paths:i,lines:a}){if(o(`renamesByPath`,e),o(`renamesByForm`,t),s(`renameLimit`,n),r!==null&&typeof r!=`function`)throw TypeError(`renameGroup must be a function, not ${typeof r}`);if(i!==`tree`&&i!==`keys`)throw RangeError(`paths must be 'tree' or 'keys', not ${i}`);o(`lines`,a)}var He=(e,t)=>P(e,t)&&(e.type!==`file`||e.mode===t.mode),J=(e,t,n,r=null)=>({status:e,old:t,new:n,similarity:r}),Ue=/\.d\.(?:[^./]+\.)?[cm]?ts$/u,We=e=>e.endsWith(`.mts`)?`module`:e.endsWith(`.cts`)?`commonjs`:null,Ge=/^export\s*\{\s*\}\s*;?$/u;function Ke(e){if(e===null)return{proven:!0,runtime:``,loads:!1};try{return a(e)===void 0?{proven:!1}:x(e.data)}catch{return{proven:!1}}}function qe(e){if(![e.old,e.new].filter(e=>e!==null).every(e=>e.type===`file`&&Ue.test(e.path))||e.old&&e.new&&e.old.mode!==e.new.mode)return e;let t=Ke(e.new),n=Ke(e.old);return!n.proven||!t.proven||n.runtime!==t.runtime&&!(e.old===null&&Ge.test(t.runtime))||n.loads&&e.old&&e.new&&e.old.path!==e.new.path&&We(e.old.path)!==We(e.new.path)?e:{...e,typeOnly:!0}}function Je(e,t){let n=[],r=[],i=[];for(let[n,a]of e){let e=t.get(n);e===void 0?i.push(a):e.type===a.type?He(a,e)||r.push(J(`modified`,a,e)):r.push(J(`type-changed`,a,e))}for(let[r,i]of t)e.has(r)||n.push(i);return i.sort((e,t)=>q(e.path,t.path)),n.sort((e,t)=>q(e.path,t.path)),{changes:r,deleted:i,added:n}}function Ye(e,t,{group:n,...r}){if(n===null)return Le(e,t,r);let i=new Map,a=e=>Map.groupBy(e.keys(),t=>n(e[t].path)),o=a(e);for(let[n,s]of a(t)){let a=o.get(n);if(a!==void 0)for(let[n,{source:o,score:c}]of Le(a.map(t=>e[t]),s.map(e=>t[e]),r))i.set(s[n],{source:a[o],score:c})}return i}function Xe(e,t,{renames:n=!0,renamesByPath:r=!0,renamesByForm:i=!1,renameLimit:a=ze,renameGroup:o=null,paths:s=`tree`,lines:u=!0,horizon:d,whitespace:f,ignoreCase:p,shortest:m}={}){let h=Be(n);Ve({renamesByPath:r,renamesByForm:i,renameLimit:a,renameGroup:o,paths:s,lines:u});let g=c({horizon:d,whitespace:f,ignoreCase:p,shortest:m}),_=s===`keys`,{changes:v,deleted:y,added:b}=Je(F(e,`old`,_),F(t,`new`,_)),x=h===null?new Map:Ye(y,b,{minimum:h,limit:a,byPath:r,byForm:i,group:o});for(let[e,t]of b.entries()){let n=x.get(e);v.push(n===void 0?J(`added`,null,t):J(`renamed`,y[n.source],t,Math.trunc(n.score*100/6e4)))}let S=new Set(x.values().map(({source:e})=>e));for(let[e,t]of y.entries())S.has(e)||v.push(J(`deleted`,t,null));return v.sort((e,t)=>q((e.new??e.old).path,(t.new??t.old).path)),(u?v.map(e=>({...e,...l(e.old,e.new,g)})):v).map(qe)}function Y(e,t,n){let r=new Map,i=new Set,a=0;for(let o of e){let e=u(n,o);e===null||!t.has(e)||(r.set(o,e),i.add(e),e!==o&&a++)}for(let n of e)r.has(n)||!t.has(n)||i.has(n)||(r.set(n,n),i.add(n));let o=r.size;for(let a of e){if(r.has(a))continue;let e=u(n,a)??d(n,a);for(;t.has(e)||i.has(e);)e=`../${e}`;r.set(a,e),i.add(e)}return{paths:r,paired:o,moved:a}}function Ze(e,t){let n=new Set(e),r=new Set(t),i=(e,t)=>{let n=new Map;for(let r of e)for(let e=r.indexOf(`/`);e!==-1;e=r.indexOf(`/`,e+1)){let i=r.slice(0,e+1);t.has(r.slice(e+1))&&n.set(i,(n.get(i)??0)+1)}let r=null,i=!1;for(let[e,t]of n)t>(n.get(r)??0)?[r,i]=[e,!1]:t===n.get(r)&&(i=!0);return i?null:r},a=Y(n,r,null).paired,o=[[{base:``,other:i(r,n)},n],[{base:i(n,r),other:``},r]].filter(([e])=>e.base!==null&&e.other!==null).map(([e,t])=>({root:e,side:t,...Y(n,r,e)})).filter(({side:e,paired:t,moved:n})=>t>a&&n*2>=e.size);return o.length===2&&o[0].paired===o[1].paired?null:o.toSorted((e,t)=>t.paired-e.paired)[0]?.root??null}function X(e,t){let n=[...e],r=new Set(t),i=Ze(n,r);return{root:i,paths:Y(n,r,i).paths}}function Qe(e,t,n){if(!e&&!t)return null;let r=[...e??[]],i=Map.groupBy(r,([,e])=>e),a=new Map(i.entries().map(([e,t])=>[e,f(n,e,t.map(([t])=>t.slice(e.length+1)))]));return new Map([...r.map(([e,t])=>[n.paths.get(e)??e,a.get(t)]),...t??[]])}function $e(e,t,n=new Map,i=new Map,a=null,o=()=>!1){let s=e=>{let t=n.get(e)??i.get(e);return t===void 0?[...new Set([e,ot(a,e)??e])]:[t]},c=[],l=[],u=[],d=new Set;for(let n of e.values()){let e=s(n.parent).map(e=>t.get(r(e,n.specifier,n.conditions,n.platform))).find(Boolean),a=i.get(n.target)??n.target;if(e){if(d.add(e.key),!s(n.target).includes(e.target)){let{target:t,...n}=e;c.push({...n,baseTarget:a,otherTarget:t})}continue}let u=s(n.parent).find(o);if(u===void 0)continue;let{specifier:f,conditions:p,platform:m}=n;l.push({key:r(u,f,p,m),parent:u,specifier:f,conditions:p,platform:m,baseTarget:a,otherTarget:null})}for(let e of t.values()){if(d.has(e.key)||!o(e.parent))continue;let{target:t,...n}=e;u.push({...n,baseTarget:null,otherTarget:t})}for(let e of[c,l,u])e.sort((e,t)=>e.key.localeCompare(t.key));return{changed:c,onlyBase:l,onlyOther:u,totalChanges:c.length+l.length+u.length}}function Z(e){return g(e)??0}function et(e,t){return e===t||e?.format===`base64`&&t?.format===`base64`&&e.data===t.data||e?.format===`digest`&&t?.format===`digest`&&e.digest===t.digest}function tt(e){if(e?.npmExecutable instanceof Set)return t=>({executable:e.npmExecutable.has(t)});if(e?.kind!==`stasis`||!e.bundle)return null;let{formats:t,executable:n,entries:r}=e.bundle;return e=>({format:t?.get(e),executable:n?.has(e)??!1,entry:r?.has(e)??!1})}function nt(e,t){return!e||!t?[]:[`format`,`executable`,`entry`].filter(n=>e[n]!==t[n]).map(n=>({field:n,from:e[n],to:t[n]}))}function Q(e){return(t,n)=>Math.abs(n.delta)-Math.abs(t.delta)||t[e].localeCompare(n[e])}function $(e){return(t,n)=>n.bytes-t.bytes||t[e].localeCompare(n[e])}function rt(e,t){return typeof e==`string`?`\0text\0${e.toWellFormed()}`:e?.format===`base64`?`\0base64\0${e.data}`:e?.format===`digest`?`\0digest\0${e.digest}`:`\0none\0${t}`}var it=250;function at(e,t,n,r,i){let a=(e,t,n)=>e.filter(({path:e})=>e!==``&&e.isWellFormed()).map(({path:e},r)=>({name:e,data:rt(t.get(e),`${n}${r}`)})),o={paths:`keys`,renameGroup:i,renameLimit:it,renamesByForm:!0,lines:!1},s=Xe(a(e,n,`a`),a(t,r,`b`),o);return new Map(s.filter(({status:e})=>e===`renamed`).map(e=>[e.old.path,e.new.path]))}function ot(e,t){return e?e.base===``?`${e.other}${t}`:t.startsWith(e.base)?t.slice(e.base.length):null:t}function st(){return{baseBytes:0,otherBytes:0,onlyBaseFiles:0,onlyOtherFiles:0,changedFiles:0}}function ct(e,t,n,r=X(e.keys(),t.keys()),i=[]){let{root:a,paths:o}=r,s=new Map([...o].map(([e,t])=>[t,e]));e=new Map([...e].map(([e,t])=>[o.get(e),t]));let c=e=>s.get(e)===e?{}:{basePath:s.get(e)},l=(e,t)=>{let n=nt(i[0]?.(e),i[1]?.(t));return n.length>0?{meta:n}:{}},u=[],d=[],f=[],p=0,m=0,h=0,g=0,_=0,v=0,y=new Map,b=e=>{let t=n(e),r=y.get(t);return r||(r=st(),y.set(t,r)),r},x=new Set([...e.keys(),...t.keys()]);for(let n of x){let r=e.has(n),i=t.has(n),a=b(n);if(r&&i){let r=e.get(n),i=t.get(n),o=et(r,i),u=l(s.get(n),n),d=Z(r),h=o?d:Z(i);if(p+=d,m+=h,a.baseBytes+=d,a.otherBytes+=h,o&&!u.meta)v++;else{let e=h-d;f.push({path:n,...c(n),baseBytes:d,otherBytes:h,delta:e,...u,...o?{modified:!1}:{}}),_+=e,a.changedFiles++}}else if(r){let t=Z(e.get(n));p+=t,h+=t,a.baseBytes+=t,a.onlyBaseFiles++,u.push({path:n,...c(n),bytes:t})}else{let e=Z(t.get(n));m+=e,g+=e,a.otherBytes+=e,a.onlyOtherFiles++,d.push({path:n,bytes:e})}}let S=at(u,d,e,t,n);if(S.size>0){let n=new Set(S.values());for(let[n,r]of S){let i=e.get(n),a=t.get(r),o=et(i,a),c=Z(i),u=o?c:Z(a);h-=c,g-=u,f.push({path:r,renamedFrom:n,basePath:s.get(n),baseBytes:c,otherBytes:u,delta:u-c,modified:!o,...l(s.get(n),r)}),_+=u-c;let d=b(n);d.onlyBaseFiles--,d.onlyOtherFiles--,d.changedFiles++}u.splice(0,u.length,...u.filter(e=>!S.has(e.path))),d.splice(0,d.length,...d.filter(e=>!n.has(e.path)))}let C=[],w=[],T=[],E=[];for(let[e,t]of y){let n=t.baseBytes>0||t.onlyBaseFiles>0||t.changedFiles>0,r=t.otherBytes>0||t.onlyOtherFiles>0||t.changedFiles>0,i=t.onlyBaseFiles+t.onlyOtherFiles+t.changedFiles;n&&!r?C.push({pkg:e,bytes:t.baseBytes}):r&&!n?w.push({pkg:e,bytes:t.otherBytes}):i>0||t.baseBytes!==t.otherBytes?T.push({pkg:e,baseBytes:t.baseBytes,otherBytes:t.otherBytes,delta:t.otherBytes-t.baseBytes}):E.push({pkg:e,bytes:t.baseBytes})}return u.sort($(`path`)),d.sort($(`path`)),f.sort(Q(`path`)),C.sort($(`pkg`)),w.sort($(`pkg`)),T.sort(Q(`pkg`)),{totals:{baseFiles:e.size,baseBytes:p,otherFiles:t.size,otherBytes:m,onlyBaseFiles:u.length,onlyBaseBytes:h,onlyOtherFiles:d.length,onlyOtherBytes:g,changedFiles:f.length,renamedFiles:S.size,changedDelta:_,unchangedFiles:v,fileDelta:t.size-e.size,byteDelta:m-p,identical:u.length===0&&d.length===0&&f.length===0},files:{onlyBase:u,onlyOther:d,changed:f,root:a,basePaths:o},packages:{onlyBase:C,onlyOther:w,changed:T,unchanged:E}}}function lt(e,r,a=null){let[o,s]=[e,r],[c,l]=t(o,s,a),u=n(o,c),d=n(s,l),f=X(u.keys(),d.keys()),h=Qe(_(o),_(s),f),g=ct(u,d,e=>b(e,{packageDir:h?.get(e)}),f,[tt(o),tt(s)]),x=y(o),S=y(s),C=(e,t)=>{let n=0;for(let r of t)n+=e.get(r)??0;return n};Object.assign(g.totals,{baseLines:C(x,u.keys()),otherLines:C(S,d.keys())});for(let e of g.files.onlyBase)e.lines=x.get(e.basePath??e.path)??0;for(let e of g.files.onlyOther)e.lines=S.get(e.path)??0;for(let e of g.files.changed)Object.assign(e,{baseLines:x.get(e.basePath??e.path)??0,otherLines:S.get(e.path)??0});let w=new Set([...g.files.onlyOther,...g.files.changed.filter(e=>e.modified!==!1)].map(e=>e.path));g.resolutions=$e(i(o,c),i(s,l),new Map(g.files.changed.filter(e=>e.renamedFrom!=null).map(e=>[e.basePath,e.path])),g.files.basePaths,g.files.root,e=>d.has(e)&&!w.has(e));let T=e=>b(``,{packageDir:e}),E=v(o,c?u.keys():null,T),D=v(s,l?d.keys():null,T);return g.versionUpdates=m(E,D),g.packageRows=p(g.packages,E,D),g.scope=a??``,g}export{lt as prepareComparison};
|