@preventive/triage 1.0.0-alpha.46 → 1.0.0-alpha.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/client/dependency-paths.d.ts +2 -1
  2. package/client/dependency-paths.js +16 -4
  3. package/common/managed/agent-tasks.ts +12 -12
  4. package/common/managed/github-agents.ts +29 -10
  5. package/out/activity.js +4 -0
  6. package/out/chunk-6LNQTKAV.js +52 -0
  7. package/out/chunk-7BKKYVWR.js +7 -0
  8. package/out/chunk-7VAWINQF.js +6 -0
  9. package/out/chunk-C2AVODGZ.js +36 -0
  10. package/out/{chunk-I2MDGSQX.js → chunk-IO7JTZ6O.js} +1 -1
  11. package/out/chunk-MOACFRJ4.js +3 -0
  12. package/out/chunk-O6M574JI.js +1 -0
  13. package/out/chunk-PBZPYIG7.js +1 -0
  14. package/out/chunk-PENGGKX7.js +233 -0
  15. package/out/{chunk-OKRLLE5I.js → chunk-PWFUOLZK.js} +1 -1
  16. package/out/chunk-SZD5CW5R.js +3 -0
  17. package/out/{chunk-G24A42V6.js → chunk-TQJDYHVE.js} +1 -1
  18. package/out/{chunk-3PS4KWD2.js → chunk-WCPJDAYA.js} +1 -1
  19. package/out/{chunk-7XRR4OFU.js → chunk-WYLQWYLA.js} +1 -1
  20. package/out/chunk-X6PJAK3T.js +1 -0
  21. package/out/client-managed-import.js +1 -1
  22. package/out/client-managed.js +26 -26
  23. package/out/client-sync.js +2 -2
  24. package/out/compare.js +14 -14
  25. package/out/dialogs.js +40 -40
  26. package/out/graph.js +11 -11
  27. package/out/index.html +12 -12
  28. package/out/scan.js +2 -2
  29. package/out/terminal.js +215 -215
  30. package/out/view.css +1 -1
  31. package/out/view.js +15 -15
  32. package/package.json +9 -5
  33. package/risk/index.d.ts +4 -2
  34. package/risk/npm/assess.js +15 -4
  35. package/risk/npm/registry.js +6 -1
  36. package/risk/npm/score.js +1 -1
  37. package/server-managed/activity.ts +24 -11
  38. package/server-managed/agent-merges.ts +10 -8
  39. package/server-managed/app-agents.ts +8 -21
  40. package/server-managed/bundle-build-worker.js +7 -3
  41. package/server-managed/bundle-build.ts +5 -3
  42. package/server-managed/bundle-cache.ts +9 -3
  43. package/server-managed/bundle.ts +3 -4
  44. package/server-managed/cache-storage.ts +3 -2
  45. package/server-managed/commit-coauthors.ts +11 -10
  46. package/server-managed/commit-lockfiles.ts +22 -21
  47. package/server-managed/db-methods.ts +338 -187
  48. package/server-managed/db-neon.ts +31 -8
  49. package/server-managed/db.ts +2 -0
  50. package/server-managed/dependabot-access.ts +1 -1
  51. package/server-managed/dependency-review-comments.ts +7 -4
  52. package/server-managed/dependency-reviews.ts +71 -33
  53. package/server-managed/github-accounts.ts +28 -1
  54. package/server-managed/github-app.ts +27 -23
  55. package/server-managed/github-graphql.ts +39 -0
  56. package/server-managed/github-issue-links.ts +8 -1
  57. package/server-managed/github-metadata.ts +2 -2
  58. package/server-managed/http-response.ts +28 -10
  59. package/server-managed/http.ts +736 -247
  60. package/server-managed/index.ts +2 -2
  61. package/server-managed/link-reports.ts +5 -1
  62. package/server-managed/managed-issues.ts +3 -0
  63. package/server-managed/npm-delta.ts +16 -0
  64. package/server-managed/npm-kept.ts +51 -10
  65. package/server-managed/npm-loads.ts +48 -28
  66. package/server-managed/npm-manifest.ts +1 -1
  67. package/server-managed/npm-packages.ts +31 -15
  68. package/server-managed/npm-risk.ts +64 -17
  69. package/server-managed/object-storage.ts +4 -3
  70. package/server-managed/pretty-print.ts +45 -12
  71. package/server-managed/public-workspace.ts +3 -3
  72. package/server-managed/pull-dependencies.ts +84 -36
  73. package/server-managed/pull-dependency-reviews.ts +13 -10
  74. package/server-managed/rename-diff-worker.js +1 -1
  75. package/server-managed/report-store.ts +16 -11
  76. package/server-managed/repository-agents.ts +9 -6
  77. package/server-managed/repository-browser.ts +17 -5
  78. package/server-managed/repository-code.ts +180 -17
  79. package/server-managed/repository-dependency-reviews.ts +7 -0
  80. package/server-managed/repository-history.ts +85 -152
  81. package/server-managed/repository-issues.ts +27 -13
  82. package/server-managed/repository-pulse.ts +9 -3
  83. package/server-managed/repository-squashes.ts +145 -0
  84. package/server-managed/request-timing.ts +63 -0
  85. package/server-managed/reviewed-dependencies.ts +3 -2
  86. package/server-managed/session.ts +34 -12
  87. package/server-managed/solidity-entry-points.ts +5 -3
  88. package/server-managed/sql-postgres.ts +3 -0
  89. package/server-managed/sql.ts +17 -8
  90. package/server-managed/storage-db.ts +11 -3
  91. package/server-managed/storage-encryption.ts +23 -12
  92. package/server-managed/storage-maintenance.ts +5 -2
  93. package/server-managed/storage-payload.ts +18 -0
  94. package/server-managed/storage-stores.ts +3 -2
  95. package/server-managed/storage.ts +4 -2
  96. package/server-managed/team-feed.ts +19 -12
  97. package/server-managed/team-npm-scopes.ts +29 -0
  98. package/server-managed/team-reports.ts +74 -17
  99. package/server-managed/uploads.ts +29 -9
  100. package/out/chunk-4UFAMJAX.js +0 -1
  101. package/out/chunk-BOIXMUU5.js +0 -3
  102. package/out/chunk-CC4OM6TZ.js +0 -3
  103. package/out/chunk-JKGQ3O7O.js +0 -6
  104. package/out/chunk-LE5ZWLG4.js +0 -235
  105. package/out/chunk-MSION3G4.js +0 -36
  106. package/out/chunk-S6GIXWQW.js +0 -52
  107. package/out/chunk-V3KWNNMY.js +0 -1
  108. package/out/chunk-WQ74ZBZF.js +0 -7
@@ -1,2 +1,3 @@
1
1
  export function isDependencyFile(file: unknown, directory: string): boolean
2
- export function dependencyDirectory(reports: Iterable<{ groups?: Iterable<Iterable<{ file?: unknown }>>; tree?: unknown }>): 'node_modules' | 'vendor' | 'dependencies'
2
+ export function dependencyDirectory(reports: Iterable<{ groups?: Iterable<Iterable<{ file?: unknown }>>; tree?: unknown; treeDependencies?: unknown }>): 'node_modules' | 'vendor' | 'dependencies'
3
+ export function treeDependencyDirectory(tree: unknown): 'node_modules' | 'vendor' | null
@@ -6,6 +6,8 @@ export function isDependencyFile(file, directory) {
6
6
  return path.startsWith(`${directory}/`) || path.includes(`/${directory}/`)
7
7
  }
8
8
 
9
+ // A team's reports tell the one their tree names (`treeDependencies`) in place
10
+ // of the tree, which is asked for apart (server-managed/team-reports.ts).
9
11
  export function dependencyDirectory(reports) {
10
12
  let vendor = false
11
13
  for (const report of reports) {
@@ -15,10 +17,20 @@ export function dependencyDirectory(reports) {
15
17
  if (isDependencyFile(finding.file, 'vendor')) vendor = true
16
18
  }
17
19
  }
18
- for (const file of Object.keys(report.tree ?? {})) {
19
- if (isDependencyFile(file, 'node_modules')) return 'node_modules'
20
- if (isDependencyFile(file, 'vendor')) vendor = true
21
- }
20
+ const named = report.tree ? treeDependencyDirectory(report.tree) : report.treeDependencies
21
+ if (named === 'node_modules') return 'node_modules'
22
+ if (named === 'vendor') vendor = true
22
23
  }
23
24
  return vendor ? 'vendor' : 'dependencies'
24
25
  }
26
+
27
+ // The dependency directory a report's file tree names: node_modules, else
28
+ // vendor, else none.
29
+ export function treeDependencyDirectory(tree) {
30
+ let vendor = false
31
+ for (const file of Object.keys(tree ?? {})) {
32
+ if (isDependencyFile(file, 'node_modules')) return 'node_modules'
33
+ if (isDependencyFile(file, 'vendor')) vendor = true
34
+ }
35
+ return vendor ? 'vendor' : null
36
+ }
@@ -13,14 +13,16 @@
13
13
  // requests are one session, and a commit its own.
14
14
  //
15
15
  // The agents are Claude and Codex, and those the server knows by their GitHub
16
- // Apps or accounts (repository-agents.ts APP_AGENTS): each told by its
17
- // fingerprint, a line of its texts, by the account its work is authored by,
18
- // or by its branches' prefix, the server's to read, and named to the client
16
+ // Apps or accounts (server-managed/app-agents.ts APP_AGENTS): each told by its
17
+ // fingerprint, a line of its texts, by the account its work is authored by
18
+ // (github-agents.ts githubAgent), or by its branches' prefix, the server's to
19
+ // read, and named to the client
19
20
  // by its id, name and avatar (AppAgent). Such an agent names no session:
20
21
  // a pull request of its is a session alone, with its branch; Claude's or
21
22
  // Codex's marks on its work show those as its tools. A pull request labelled
22
23
  // for an agent (labelAgents) is that agent's too, where its own texts and
23
24
  // branch name none: the mark one who ran it gives work it left unmarked.
25
+ import { githubAgent } from './github-agents.ts'
24
26
 
25
27
  // 'claude', 'codex', or an app agent's id.
26
28
  export type Agent = string
@@ -30,10 +32,10 @@ export type Agent = string
30
32
  // `app-<id>` a GitHub App's, `user-<id>` a GitHub account's), where the app
31
33
  // draws no mark of its own for it (Copilot's, ui/view/repository-tiles.js).
32
34
  export interface AppAgent { id: string; name: string; avatar?: string }
33
- // How the server tells one: its fingerprint, a line of an artifact's texts
34
- // starting with it; the GitHub account its work is authored by, its id and
35
- // the logins GitHub names it by; its branches' prefix.
36
- export interface AppAgentMarks { id: string; fingerprint?: string; account?: { id: number; logins: readonly string[] }; prefix: string }
35
+ // How the server tells one, beside the accounts its work is authored by (its
36
+ // id githubAgent's): its fingerprint, a line of an artifact's texts starting
37
+ // with it; its branches' prefix.
38
+ export interface AppAgentMarks { id: string; fingerprint?: string; prefix: string }
37
39
  // An artifact's author, as GitHub names its account: its login and id.
38
40
  export interface AgentAuthor { login: string; id: number }
39
41
 
@@ -120,21 +122,19 @@ export function labelAgents(labels: unknown[], ids: readonly string[]): Agent[]
120
122
  // The sessions and tasks `texts` link, whether they carry Claude's marks and
121
123
  // Codex's, and the agents of `apps` whose fingerprints start a line of them
122
124
  // (not one a text quotes, as one describing it may), whose account `author`
123
- // is, by its id and login both, or whose prefix the branch `branch` is under;
125
+ // is (githubAgent), or whose prefix the branch `branch` is under;
124
126
  // Claude, Codex or the agents of `apps` its `labels` name (labelAgents).
125
127
  export function agentSignals(texts: unknown[], apps: readonly AppAgentMarks[] = [], branch: string | null = null,
126
128
  author: AgentAuthor | null = null, labels: unknown[] = []): AgentSignals {
127
129
  const strings = texts.filter((text): text is string => typeof text === 'string')
128
130
  const found = (pattern: RegExp) => [...new Set(strings.flatMap(text => [...text.matchAll(pattern)].map(match => match[1]!)))].slice(0, MAX_LINKS)
129
131
  const lines = strings.flatMap(text => text.split('\n').map(line => line.trimStart()))
130
- const login = author?.login.toLowerCase()
131
- const authored = ({ account }: AppAgentMarks) => author !== null && account !== undefined && account.id === author.id
132
- && account.logins.some(name => name.toLowerCase() === login)
132
+ const authored = author ? githubAgent(author.login, author.id) : null
133
133
  const labelled = labelAgents(labels, ['claude', 'codex', ...apps.map(app => app.id)])
134
134
  return { sessions: found(SESSION), tasks: found(CODEX_TASK), claude: labelled.includes('claude') || strings.some(text => CLAUDE_MARK.test(text)),
135
135
  codex: labelled.includes('codex') || strings.some(text => CODEX_MARK.test(trailerBlock(text))),
136
136
  agents: apps.filter(app => (app.fingerprint && lines.some(line => line.startsWith(app.fingerprint!)))
137
- || authored(app) || branch?.startsWith(app.prefix) || labelled.includes(app.id)).map(app => app.id) }
137
+ || authored === app.id || branch?.startsWith(app.prefix) || labelled.includes(app.id)).map(app => app.id) }
138
138
  }
139
139
 
140
140
  // The agent a branch's name says made it, and the issue or pull request the
@@ -1,8 +1,7 @@
1
1
  // Agents by their own GitHub accounts, where a repository's activity names
2
2
  // them: each its name, and how the app draws it, by its mark, as the Agents
3
3
  // tab does (ui/view/provider-icons.js), or by its avatar, which
4
- // /api/avatar/<avatar> serves (server-managed/repository-agents.ts
5
- // APP_AGENTS, the Agents tab's marks); its accounts, each by the logins GitHub's REST and GraphQL APIs
4
+ // /api/avatar/<avatar> serves; its accounts, each by the logins GitHub's REST and GraphQL APIs
6
5
  // name it by and its numeric id where known, which GitHub never gives
7
6
  // another; and the names its commits carry where GitHub names no account for
8
7
  // them. Claude Code's commits are authored as Claude <noreply@anthropic.com>,
@@ -21,21 +20,37 @@
21
20
  // in its address. GitHub's Agentic Workflows (gh-aw) post, and approve or
22
21
  // review pull requests, as GitHub Actions' bot, `github-actions` (41898282,
23
22
  // `[bot]` to the REST API), its mark the GitHub Actions App's avatar; other
24
- // workflows the bot runs are as much its own. Cursor's agents commit as whoever ran them, with a
23
+ // workflows the bot runs are as much its own. Neo, its GitHub App (3115942),
24
+ // as its account (274065190) and its App's bot (268952163), each known by
25
+ // its id alone, whatever GitHub names it, and drawn by its App's avatar,
26
+ // wherever either or its fingerprint names it. Cursor's agents commit as whoever ran them, with a
25
27
  // `Co-authored-by: Cursor Agent <cursoragent@cursor.com>` trailer; the app
26
28
  // has no mark of Cursor's, and draws it by its name's letter. Each by the
27
29
  // addresses (`emails`) its commits name it by, as author or co-author.
30
+ //
31
+ // Those the Agents tab tells beside Claude and Codex (whose sessions and
32
+ // tasks it tells them by, common/managed/agent-tasks.ts), the server's app
33
+ // agents (server-managed/app-agents.ts APP_AGENTS), by their branches'
34
+ // prefix (`prefix`), the accounts their work is authored by, and the
35
+ // fingerprint (`fingerprint`) they leave as a line of their pull
36
+ // requests' bodies and their commits' messages, where they leave one:
37
+ // Neo's, on `neo/` branches; Copilot's coding agent's, on `copilot/`;
38
+ // Dependabot's, on `dependabot/<ecosystem>/…`. Their work may carry
39
+ // Claude's or Codex's marks too, those its tools.
28
40
  export interface GithubAgentAccount { id?: number; logins: readonly string[] }
29
41
  export interface GithubAgent { name: string; mark?: 'anthropic' | 'openai' | 'github-copilot'; avatar?: string; accounts: readonly GithubAgentAccount[]; names: readonly string[]
30
- emails?: readonly string[] }
42
+ emails?: readonly string[]; prefix?: string; fingerprint?: string }
31
43
 
32
44
  export const GITHUB_AGENTS = {
33
45
  claude: { name: 'Claude', mark: 'anthropic', accounts: [{ id: 81847, logins: ['claude'] }, { logins: ['claude[bot]'] }], names: ['Claude'], emails: ['noreply@anthropic.com'] },
34
46
  codex: { name: 'Codex', mark: 'openai', accounts: [{ id: 199175422, logins: ['chatgpt-codex-connector', 'chatgpt-codex-connector[bot]'] }], names: ['Codex'],
35
47
  emails: ['codex@openai.com'] },
48
+ neo: { name: 'Neo', avatar: 'app-3115942', accounts: [{ id: 274065190, logins: [] }, { id: 268952163, logins: [] }], names: [], prefix: 'neo/',
49
+ fingerprint: '🤖 Generated with [Neo](' },
36
50
  copilot: { name: 'Copilot', mark: 'github-copilot', accounts: [{ id: 198982749, logins: ['Copilot', 'copilot-swe-agent'] },
37
- { id: 175728472, logins: ['Copilot', 'copilot-pull-request-reviewer', 'copilot-pull-request-reviewer[bot]'] }], names: ['Copilot'] },
38
- dependabot: { name: 'Dependabot', avatar: 'app-29110', accounts: [{ id: 49699333, logins: ['dependabot', 'dependabot[bot]'] }], names: ['dependabot[bot]'] },
51
+ { id: 175728472, logins: ['Copilot', 'copilot-pull-request-reviewer', 'copilot-pull-request-reviewer[bot]'] }], names: ['Copilot'], prefix: 'copilot/' },
52
+ dependabot: { name: 'Dependabot', avatar: 'app-29110', accounts: [{ id: 49699333, logins: ['dependabot', 'dependabot[bot]'] }], names: ['dependabot[bot]'],
53
+ prefix: 'dependabot/' },
39
54
  actions: { name: 'GitHub Actions', avatar: 'app-15368', accounts: [{ id: 41898282, logins: ['github-actions', 'github-actions[bot]'] }], names: ['github-actions[bot]'] },
40
55
  cursor: { name: 'Cursor', accounts: [], names: ['Cursor Agent'], emails: ['cursoragent@cursor.com'] },
41
56
  } as const satisfies Record<string, GithubAgent>
@@ -50,6 +65,8 @@ for (const [agent, { accounts }] of agents) {
50
65
  for (const login of logins) byLogin.set(login.toLowerCase(), { agent, ids: [...byLogin.get(login.toLowerCase())?.ids ?? [], id] })
51
66
  }
52
67
  }
68
+ // The accounts known by their ids alone, no login of theirs: each its agent.
69
+ const byId = new Map(agents.flatMap(([agent, { accounts }]) => accounts.flatMap(({ id, logins }) => id !== undefined && logins.length === 0 ? [[id, agent] as const] : [])))
53
70
  const byName = new Map(agents.flatMap(([agent, { names }]) => names.map(name => [name.toLowerCase(), agent] as const)))
54
71
  const byEmail = new Map(agents.flatMap(([agent, { emails = [] }]) => emails.map(email => [email, agent] as const)))
55
72
 
@@ -60,13 +77,15 @@ export const emailAgent = (email: unknown): GithubAgentId | null => typeof email
60
77
  // The agent an author is: by their login, GitHub matching logins regardless
61
78
  // of case, their account's id the agent's where both are known, so another
62
79
  // account GitHub names by the same login (a user's, the bot's GraphQL login
63
- // may be) is not; for an author GitHub names no account for, by the name
64
- // they carry. Null for anyone else: a human's account is theirs, whatever
65
- // their commits name them.
80
+ // may be) is not; an account known by its id alone, by that, whatever its
81
+ // login; for an author GitHub names no account for, by the name they carry.
82
+ // Null for anyone else: a human's account is theirs, whatever their commits
83
+ // name them.
66
84
  export function githubAgent(login: string | null, account: number | null = null, name: string | null = null): GithubAgentId | null {
67
85
  if (typeof login !== 'string') return typeof name === 'string' ? byName.get(name.trim().toLowerCase()) ?? null : null
68
86
  const known = byLogin.get(login.toLowerCase())
69
- return known && (account === null || known.ids.includes(undefined) || known.ids.includes(account)) ? known.agent : null
87
+ if (known && (account === null || known.ids.includes(undefined) || known.ids.includes(account))) return known.agent
88
+ return account === null ? null : byId.get(account) ?? null
70
89
  }
71
90
 
72
91
  // Whether the accounts `ids` a login is named by are all one agent's, as
@@ -0,0 +1,4 @@
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-X6PJAK3T.js";import{$e as s,Aa as c,Ea as l,Fa as u,Ga as d,Ha as f,Ia as p,Je as m,Ka as h,Ke as g,La as _,Le as v,Me as y,Ne as b,Oe as x,Pd as S,Pe as ee,Qe as te,Re as ne,Se as re,Te as ie,Ue as ae,Ve as oe,We as se,Xe as ce,Ye as le,Ze as ue,_e as de,af as fe,bf as pe,cb as me,db as C,ff as he,pa as ge,sa as _e,ta as ve,tc as ye,tf as be,ua as xe,uf as Se,w,xa as Ce,ya as we,za as Te}from"./chunk-PENGGKX7.js";import"./chunk-JCIIBLKR.js";import"./chunk-VH4XMZIW.js";import"./chunk-O6M574JI.js";import{M as Ee}from"./chunk-6LNQTKAV.js";import"./chunk-7VAWINQF.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as De}from"./chunk-C2AVODGZ.js";import"./chunk-IO7JTZ6O.js";import"./chunk-WCPJDAYA.js";import"./chunk-IYPY47MC.js";import{a as T}from"./chunk-PWFUOLZK.js";import"./chunk-BC2UCLFJ.js";import"./chunk-SXV2T5C4.js";import{A as Oe,d as ke,e as Ae,f as je,g as Me,z as Ne}from"./chunk-WFYLMF6Z.js";import"./chunk-C4Z6ZBXV.js";import{c as E,d as D,g as O,j as Pe}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var Fe=e=>e.committedAt??-1/0;function Ie(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)=>Fe(e)-Fe(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 Le(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 Re(e,{linear:t=!1,trunk:n=null,colors:r=8}={}){let i=new Set(e.map(e=>e.sha)),a=+(n?.size>0),o=[],s=[],c=[],l=[],u=[],d=0,f=0,p=()=>{let e=o.indexOf(null,a);return e===-1?Math.max(o.length,a):e},m=e=>{if(n?.has(e))return 0;let t=o.indexOf(e);return t===-1?null:t},h=e=>{let t=Math.max(1,r-a),n=new Set([e-1,e+1].filter(e=>o[e]!=null).map(e=>s[e])),i=Array.from({length:t},(e,t)=>t).find(e=>!n.has(a+(f+e)%t))??0,c=a+(f+i)%t;return f=(f+i+1)%t,c};for(let[r,a]of e.entries()){let f=e[r+1],g=t?f?[f.sha]:a.parents.slice(0,1):[...new Set(a.parents)],_=g.filter(e=>i.has(e)),v=m(a.sha),y=v??p(),b=n?.has(a.sha)?0:v===null?h(y):s[y];for(let[e,t]of o.entries())t===a.sha&&(o[e]=null);c.push({commit:a,col:y,color:b});let x=new Set;o[y]=_[0]??null,s[y]=b,_.length>0&&x.add(y);let S=[];for(let e of _.slice(1)){let t=n?.has(e)?0:o.indexOf(e);if(t===-1||o[t]!==e){let t=p();s[t]=h(t),o[t]=e,x.add(t)}else S.push(t)}let ee=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:ee,color:b}),ee=!1;for(let e=0;e<o.length;e++)o[e]??=null;if(d=Math.max(d,o.length),f){let e=m(f.sha);for(let[t,n]of o.entries())n!==null&&l.push({row:r,from:x.has(t)?y:t,to:n===f.sha?e:t,color:s[t]});for(let t of S)l.push({row:r,from:y,to:o[t]===f.sha?e:t,color:s[t]})}for(;o.length>0&&o.at(-1)===null;)o.pop()}return{rows:c,segments:l,stubs:u,width:Math.max(d,+(c.length>0))}}function k(e,t,n,{ready:r,failed:i,settled:a=()=>{},retryMs:o,repaint:s}){let c=e.get(t);if(c&&Date.now()<c.until)return c;let l=c?.status===`ready`?c:null;if(l?.rereading)return l;let u=l??{status:`loading`,until:1/0};return l?l.rereading=!0:e.set(t,u),n().then(n=>{if(e.get(t)!==u||l&&Date.now()<l.until)return null;let i=r(n);return e.set(t,i),a(i),null},n=>{if(e.get(t)!==u)return null;if(l)return n?.name!==`AbortError`&&(l.until=Date.now()+o),null;let r=i(n);return r?e.set(t,r):e.delete(t),null}).finally(()=>{l&&(l.rereading=!1),s()}),u}var ze=12,A=24,Be=9,Ve=8,He=3,Ue=`a[href], .history-commit`,We=3e5,Ge=15e3,Ke=3e4,qe=3e3,Je=10,Ye=25,Xe=new Map,j=new Set,Ze=null,Qe=`all`,$e=new Set;function M(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Ze&&(Xe.clear(),$e.clear(),Ze=e),Xe}var N=()=>{for(let e of j)e.requestUpdate()};function et(e,t,n=new Set){let r={status:`ready`,until:Date.now()+We,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 tt(e,t){let n=new Set(e.pulls.map(e=>e.merge)),r=t.filter(e=>!n.has(e.merge));r.length>0&&(e.pulls=[...e.pulls,...r])}function nt(e,t,n,r,i,a=1){setTimeout(()=>{M().get(e)===t&&n(r,i).then(o=>(M().get(e)!==t||(tt(t,o.pulls),o.pullsPending&&a<Je&&nt(e,t,n,r,i,a+1)),null),()=>null).finally(N)},qe)}function rt(e,t,n){return k(M(),e,()=>t(1),{ready:e=>et(e,n),settled:n=>{n.pullsPending&&nt(e,n,t,1,null)},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+Ke,error:e?.message||`The history could not be read.`,code:e?.code??null},retryMs:Ke,repaint:N})}function it(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,Ge),c=et(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&&nt(e,c,n,1,null),null},()=>null).finally(()=>{t.refreshing=!1,N()})}function at(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,Ye).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function ot(e,t,n,r){if(t.loadingMore||!t.more)return;t.loadingMore=!0,t.moreError=null,t.until=Date.now()+We,N();let i={next:t.next};n(t.page+1,i).then(a=>{if(M().get(e)!==t)return null;let o=new Set(t.commits.map(e=>e.sha));return t.commits=[...t.commits,...a.commits.filter(e=>!o.has(e.sha))],tt(t,a.pulls),t.page+=1,t.more=a.more===!0,r?.(t),t.until=Date.now()+We,a.pullsPending&&nt(e,t,n,t.page,i),null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More commits could not be read.`),null)).finally(()=>{t.loadingMore=!1,N()})}var st=/^[a-f\d]{40}$/u,ct=e=>typeof e?.sha==`string`&&st.test(e.sha)&&Array.isArray(e.parents);function lt(e){if(!Array.isArray(e?.commits))throw Error(`The server answered with no history.`);let t=e.commits.filter(ct),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&typeof e.sha==`string`&&st.test(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>typeof e?.merge==`string`&&st.test(e.merge)&&Number.isSafeInteger(e.number)&&typeof e.head==`string`&&st.test(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(ct)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.sha==`string`&&st.test(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function ut(e,t,n){let r=dt(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 dt(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 ft=6e4,pt=60*ft,mt=24*pt;function ht(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-ft&&n<ft)return`now`;if(n>0&&n<pt)return`${Math.floor(n/ft)}m`;if(n>0&&n<mt)return`${Math.floor(n/pt)}h`;if(n>0&&n<7*mt)return`${Math.floor(n/mt)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function gt({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}function _t(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),E`<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 vt=e=>Be+e*ze,yt=e=>e*A+A/2;function bt({row:e,from:t,to:n}){let[r,i,a,o]=[vt(t),vt(n),yt(e),yt(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 xt=({row:e,col:t,straight:n})=>n?`M${vt(t)} ${yt(e)+6}v${A*.55}`:`M${vt(t)+4} ${yt(e)+5}l${ze*.6} ${A*.5}`;function St(e,t){let n=Array.from({length:Ve},()=>[]);for(let t of e.segments)n[t.color].push(bt(t));let r=Array.from({length:Ve},()=>[]);for(let t of e.stubs)r[t.color].push(xt(t));let i=Be*2+(e.width-1)*ze;return E`<svg class="history-graph" width="${i}" height="${e.rows.length*A}" aria-hidden="true">${n.map((e,t)=>e.length>0?D`<path class=${`lane-${t}`} d=${e.join(``)}/>`:O)} ${r.map((e,t)=>e.length>0?D`<path class=${`history-stub lane-${t}`} d=${e.join(``)}/>`:O)} ${e.rows.map(({commit:e,col:n,color:r},i)=>D`<circle class=${`lane-${r}${e.sha===t?` is-shown`:``}`} cx=${vt(n)} cy=${yt(i)}
2
+ r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function Ct(e,t,n,r){if(!e?.length)return O;let i=e=>{let t=De({"history-ref":!0,[`is-${e.kind}`]:!0,"is-default":e.main===!0,"is-shown":e.kind===n.kind&&e.name===n.name}),i=E`${e.kind===`tag`?ke(Oe):e.kind===`pull`?ke(Ne):O}<span>${e.name}</span>`;return e.kind===`pull`&&r?E`<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>`:E`<span class="${t}">${i}</span>`},a=e.slice(He);return E`<span class="history-refs" style="${T({"--ref":`var(--lane-${t})`})}">${e.slice(0,He).map(i)}${a.length>0?E`<span class="history-ref is-more" data-tooltip="${a.map(e=>e.name).join(`, `)}">+${a.length}</span>`:O}</span>`}function wt(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)=>l(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 lt(e)}),c=t===`path`?null:at,u=rt(o,s,c);return a&&u.status===`ready`&&!u.refreshing&&!u.sought.has(r)&&!(u.retryAt>Date.now())&&!dt(u.commits,u.pulls??[]).some(e=>e.sha===r)&&it(o,u,s,c,r),a&&u.status===`error`&&u.code===`github-token-required`?($e.add(n),wt(e,`revision`)):{mode:t,key:o,entry:u,more:()=>ot(o,u,s,c)}}var Tt=e=>wt(e,e.path?`path`:`revision`),Et=e=>{j.add(e)},Dt=e=>{j.delete(e)};function Ot(e){M().delete(e),N()}var kt=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1},refs:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this.refs=null,this._drawn=null,this._moreButton=null,this._mode=null}connectedCallback(){super.connectedCallback(),j.add(this)}disconnectedCallback(){super.disconnectedCallback(),j.delete(this),this._moreButton&&C(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.history-more > button`);this._moreButton&&this._moreButton!==e&&C(this._moreButton),this._moreButton=e,e&&me(e,t=>{t&&this.readNear(e)})}readNear(e){e===this._moreButton&&e.isConnected&&!e.disabled&&!e.parentElement.querySelector(`[role=alert]`)&&this._mode!==`unmerged`&&e.click()}mode(){let{repoId:e,path:t}=this.repository;return t?`path`:(M(),$e.has(e)?`revision`:Qe)}history(e){return wt(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:Ie(e===`unmerged`?ut(t.commits,t.pulls??[],a):dt(t.commits,t.pulls??[])),s=e===`all`?a:e===`revision`?o[0]?.sha:null,c=Re(o,{linear:i,trunk:s&&!i?Le(o,s):null,colors:Ve});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){Qe=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`);be({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(Ue)]:[],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(${Ue})`))e.tabIndex=e===s?0:-1;s.focus()}}render(){if(!this.repository)return O;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=$e.has(this.repository.repoId);return E`<div class="history-bar">${S(`commits`)} ${e===`path`?E`<span class="history-scope">Commits touching <code>${this.repository.path}</code></span>`:d?E`<span class="history-scope">Every branch needs your GitHub sign-in.</span>`:E`<div class="history-modes" role="group" aria-label="Branches"><button type="button" aria-pressed="${String(e===`all`)}" @click="${()=>this.pick(`all`)}">All branches</button> <button type="button" aria-pressed="${String(e===`unmerged`)}" @click="${()=>this.pick(`unmerged`)}">Unmerged</button></div>`} ${i?E`<span class="history-summary">${u}${l>0?` on ${l} branch${l===1?``:`es`}`:``}</span>`:O}</div>${i?this.renderCommits(e,n,r,o,a):n.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${n.error}</p><button type="button" @click="${()=>{M().delete(t),N()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading the history…</div>`}`}renderCommits(e,t,n,r,i){if(r.rows.length===0&&(e!==`unmerged`||!t.more&&!t.moreError))return E`<div class="bundles-slide-placeholder">${e===`unmerged`?`Every branch read is merged.`:`No commits.`}</div>`;let a=this.repository.commit,o=Se(this.repository,this.refs),s=gt(t,i),l=Math.max(0,r.rows.findIndex(e=>e.commit.sha===a)),u=Be*2+(r.width-1)*ze,d=this.repo??this.repository.repo,f=d?`https://github.com/${d.split(`/`).map(encodeURIComponent).join(`/`)}`:null;return E`<div class="history-scroll">${e===`all`&&!t.refreshing&&!(t.retryAt>Date.now())&&!r.rows.some(e=>e.commit.sha===a)?E`<p class="history-note"><code>${a.slice(0,7)}</code> isn’t among these commits.</p>`:O}<div class="history-lines" style="${T({"--history-graph":`${u}px`})}">${St(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 E`<li class="${De({"history-row":!0,"is-shown":e.sha===a})}">${f?E`<a class="history-sha" href="${`${f}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${u} on GitHub`}">${u}</a>`:E`<code class="history-sha">${u}</code>`} ${Ct(r,t,o,f)} <span class="history-subject" id="${`history-subject-${e.sha}`}">${_t(e.subject||`(no message)`,f)}</span> <button type="button" class="history-commit" id="${`history-commit-${e.sha}`}" tabindex="${n===l?0:-1}" aria-labelledby="${`history-subject-${e.sha} history-commit-${e.sha}`}" aria-current="${e.sha===a?`true`:O}" @click="${()=>this.open(e,r)}"><span class="history-author">${c(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?E`<time class="history-time" datetime="${i.toISOString()}">${ht(e.committedAt)}</time>`:E`<span class="history-time"></span>`}</button></li>`})}</ol></div>${t.cut?E`<p class="history-note">Only the first 5,000 branches by name are read.</p>`:O} ${t.more||t.moreError?E`<div class="history-more">${t.moreError?E`<span role="alert">${t.moreError}</span>`:O} <button type="button" ?disabled="${t.loadingMore}" @click="${n}">${t.loadingMore?`Reading…`:`Older commits`}</button></div>`:O}</div>`}};customElements.get(`repository-history`)||customElements.define(`repository-history`,kt);function At(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 jt=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,Mt=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],Nt=new Set([`claude`,`codex`]);function Pt({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,Mt(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}=At(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=jt(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}=At(t.head);n&&s(e,[n]);let i=jt(t);if(t.signals.agents.length>0){i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`);continue}i&&(n||Mt(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 Ft=e=>(t,n)=>(e(t)??0)-(e(n)??0);function It({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(Ft(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(Ft(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>jt(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>At(e.head).issue??[]),...o(`branch:`).flatMap(e=>At(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(Ft(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(Ft(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=>!Nt.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 Lt(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 Pt(e).flatMap(e=>It(e,n)??[]).filter(e=>!r(e)).toSorted(Ft(e=>e.updatedAt)).toReversed()}var Rt=3e5,zt=/^[a-z][a-z\d-]{0,31}$/u,Bt=/^(?:app|user)-[1-9]\d{0,11}$/u,Vt=3e4,Ht=12,Ut=new Map,Wt=new Set,Gt=null,Kt=`all`;function qt(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Gt&&(Ut.clear(),Gt=e),Ut}var Jt=()=>{for(let e of Wt)e.requestUpdate()};function Yt(e){if(!Array.isArray(e?.pulls)||!Array.isArray(e.commits))throw Error(`The server answered with no pull requests or commits.`);let t=(Array.isArray(e.agents)?e.agents:[]).filter(e=>typeof e?.id==`string`&&zt.test(e.id)&&![`claude`,`codex`,`all`].includes(e.id)&&typeof e.name==`string`&&e.name.trim()&&(e.avatar===void 0||typeof e.avatar==`string`&&Bt.test(e.avatar))).map(({id:e,name:t,avatar:n})=>[e,{id:e,name:t.trim().slice(0,64),avatar:n??null}]),n=e=>Array.isArray(e?.signals?.sessions)&&Array.isArray(e.signals.tasks),r=e=>({...e,signals:{...e.signals,agents:Array.isArray(e.signals.agents)?e.signals.agents.filter(e=>typeof e==`string`&&zt.test(e)&&![`claude`,`codex`,`all`].includes(e)):[]}});return{pulls:e.pulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`&&Array.isArray(e.closes)&&n(e)).map(r),commits:e.commits.filter(e=>typeof e?.oid==`string`&&/^[a-f\d]{40}$/u.test(e.oid)&&n(e)).map(r),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`&&n(e)).map(r):[],agents:[...new Map(t).values()],more:e.more===!0,after:e.more===!0?{pulls:e.after?.pulls??null,commits:e.after?.commits??null}:null}}var Xt=e=>Object.assign(e,{sessions:Lt(e,{branchesSince:e.after?.pulls?Math.min(...e.pulls.map(e=>e.updatedAt??1/0)):null})});function Zt(e,t){return k(qt(),e,()=>t(null).then(e=>(de(e.agents),e)),{ready:e=>Xt({status:`ready`,until:Date.now()+Rt,...e,loadingMore:!1,moreError:null}),failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+Vt,error:e?.message||`The agents' work could not be read.`},retryMs:Vt,repaint:Jt})}function Qt(e,t,n){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+Rt,Jt(),n(t.after).then(n=>{if(qt().get(e)!==t)return null;let r=new Set(t.pulls.map(e=>e.number)),i=new Set(t.commits.map(e=>e.oid));t.pulls=[...t.pulls,...n.pulls.filter(e=>!r.has(e.number))],t.commits=[...t.commits,...n.commits.filter(e=>!i.has(e.oid))],t.more=n.more,t.after=n.after,t.until=Date.now()+Rt;let a=t.sessions.length;return Xt(t),t.stalled=t.sessions.length<=a,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More could not be read.`),null)).finally(()=>{t.loadingMore=!1,Jt()}))}function $t(e,t,n){let r=n.trim().toLowerCase().split(/\s+/u).filter(Boolean);return e.filter(e=>{if(t!==`all`&&!e.agents.includes(t))return!1;if(r.length===0)return!0;let n=[e.title,...e.authors,...e.authors.map(ve),...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])].join(`
3
+ `).toLowerCase();return r.every(e=>n.includes(e))})}var en={open:`open`,merged:`merged`,closed:`closed`,branch:`draft`},tn=e=>(e.agents??[]).map(e=>e.id).filter(t=>(e.sessions??[]).some(e=>e.agents.includes(t))),nn=e=>[`claude`,`codex`,...tn(e)],rn=[[`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 an(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 on(e,t,n){let r=2*Math.PI*9;return E`<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?D`<circle class="read-gauge-arc" cx="11" cy="11" r="9" transform="rotate(-90 11 11)" stroke-dasharray=${`${r*e/100} ${r}`}/>`:O}</svg> ${e===100?E`<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>`:E`<span class="read-gauge-value" aria-hidden="true">${e}%</span>`}</span>`}function sn(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 cn=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1},_filter:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this._filter=``,this._moreButton=null}connectedCallback(){super.connectedCallback(),Wt.add(this)}disconnectedCallback(){super.disconnectedCallback(),Wt.delete(this),this._moreButton&&C(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.issues-more > button`);this._moreButton&&this._moreButton!==e&&C(this._moreButton),this._moreButton=e,e&&me(e,t=>{t&&this.readNear(e)})}readNear(e){e===this._moreButton&&e.isConnected&&!e.disabled&&!this._filter.trim()&&!e.parentElement.querySelector(`[role=alert]`)&&!this.list().entry.stalled&&e.click()}list(){let{repoId:e}=this.repository,t=`${e}`,n=t=>f(e,t??{}).then(Yt),r=Zt(t,n);return{key:t,entry:r,more:()=>Qt(t,r,n)}}pick(e){Kt=e,Jt()}render(){if(!this.repository)return O;let{key:e,entry:t,more:n}=this.list(),r=t.status===`ready`,i=r?t.sessions:[],a=e=>r?E`<span class="n">${(e===`all`?i:i.filter(t=>t.agents.includes(e))).length}${t.more?`+`:``}</span>`:O,o=nn(t).includes(Kt)?Kt:`all`,c=$t(i,o,this._filter);return E`<div class="history-bar issues-bar">${S(`agents`)}<div class="history-modes" role="group" aria-label="Agents"><button type="button" aria-pressed="${String(o===`all`)}" @click="${()=>this.pick(`all`)}">All${a(`all`)}</button> ${nn(t).map(e=>E`<button type="button" class="${`agent-pick is-${e}`}" aria-pressed="${String(o===e)}" @click="${()=>this.pick(e)}">${fe(e)}${s(e)}${a(e)}</button>`)}</div><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):O} ${r?on(an(t),`${t.pulls.length} pull request${t.pulls.length===1?``:`s`} read`,t.loadingMore):O}</div>${r?this.renderSessions(t,c,n,o):t.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${t.error}</p><button type="button" @click="${()=>{qt().delete(e),Jt()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading what the agents did…</div>`}`}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 E`<span class="agent-totals">${[...tn(e),`claude`,`codex`].filter(n).map(n=>{let r=sn(e.sessions,n);return E`<span class="agent-stats" role="group" aria-label="${s(n)}"><span class="${`agent-mark is-${n}`}">${fe(n)}</span> ${rn.filter(([e])=>r[e]>0).map(([e,n,i,a])=>{let o=`${r[e].toLocaleString(`en-US`)}${t[e]?`+`:``}`,s=`${o} ${r[e]===1&&!t[e]?i:a}`;return E`<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`:`${s(r)} sessions`;return E`<div class="issues-scroll">${t.length>0?E`<ol class="issues-grid" aria-label="Sessions">${t.map(e=>this.renderSession(e))}</ol>`:E`<p class="history-note">${e.sessions.length>0&&this._filter.trim()?`None of the ${i} read match.`:`No ${i} among those read.`}</p>`} ${e.more||e.moreError?E`<div class="history-more issues-more">${e.moreError?E`<span role="alert">${e.moreError}</span>`:O} <button type="button" ?disabled="${e.loadingMore}" @click="${()=>{e.stalled=!1,n()}}">${e.loadingMore?`Reading…`:`More`}</button></div>`:O}</div>`}openSession(e,t){!pe(e)||e.target?.closest?.(`.agent-chip.is-commit`)||(e.preventDefault(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{session:t}}))}openItem(e,t,n){pe(e)&&(e.preventDefault(),e.stopPropagation(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{number:t,preview:n}}))}renderSession(e){let t=this.repo??this.repository.repo,n=he(e,t),r=e.updatedAt==null?null:new Date(e.updatedAt),i=e.authors.find(e=>!Ce(e)),a=e.pulls.length+e.commits.length,o=a!==e.pulls.length+e.commits.length,c=r?E`<time datetime="${r.toISOString()}">${ht(e.updatedAt)}</time>`:O,l=e.additions||e.deletions?E`<span class="issue-diff"><span class="is-added">+${e.additions.toLocaleString(`en-US`)}</span> <span class="is-deleted">−${e.deletions.toLocaleString(`en-US`)}</span></span>`:O,u=a===1,d=[i?E`<span class="issue-author">${xe(i)}</span>`:O,u?O:c,a===0?E`<span>no pull request</span>`:o?E`<span>${a} tasks</span>`:O,u?O:l].filter(e=>e!==O),f=[...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}`,E`<code>${e.oid.slice(0,7)}</code>`,null]),...e.issues.map(e=>[`is-issue is-${e.state===`open`?`open`:`merged`}`,`issues/${e.number}`,E`<span class="sr-only">Issue </span>#${e.number}`,{kind:`issues`,reason:null,...e}])];return E`<li class="${`issue-tile agent-tile is-${en[e.state]}`}"><div class="issue-body" @click="${t=>this.openSession(t,e)}"><span class="issue-rail">${e.agents.map(e=>E`<span class="${`agent-mark is-${e}`}" role="img" aria-label="${s(e)}">${fe(e)}</span>`)}</span> <span class="issue-lines">${n?E`<a class="issue-name" href="${n}" target="_blank" rel="noopener noreferrer">${e.title||`(no title)`}</a>`:E`<button type="button" class="issue-name">${e.title||`(no title)`}</button>`} ${d.length>0?E`<span class="issue-meta">${d}</span>`:O} ${f.length>0?E`<span class="agent-task-row"><span class="agent-chips">${f.slice(0,Ht).map(([e,n,r,i],a)=>E`<a class="${`agent-chip ${e}`}" href="${t?`https://github.com/${t}/${n}`:O}" target="_blank" rel="noopener noreferrer" @click="${i?e=>this.openItem(e,i.number,i):O}" data-rest="${a<f.length-1?f.length-1-a:O}">${r}</a>`)}</span>${u&&(c!==O||l!==O)?E`<span class="issue-meta">${c}${l}</span>`:O}</span>`:O} ${e.branches[0]?E`<span class="issue-branch"><code>${e.branches[0]}</code>${e.branches.length>1?E`<span>+${e.branches.length-1}</span>`:O}</span>`:O}</span></div></li>`}};customElements.get(`repository-agents`)||customElements.define(`repository-agents`,cn);var ln=3e5,un=3e4,dn=1e3,fn=5,pn=5e3,mn=12,P=864e5,F=7*P,hn=8,gn=3,_n=[[1,`Week`,`the week before`],[4,`Month`,`the month before`],[13,`Quarter`,`the quarter before`],[52,`Year`,`the year before`]],vn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],yn=[1,2,3,4,5,6,0],bn=6,xn=new Map,Sn=new Map,Cn=new Map,wn=new Map,Tn=new Set,En=null,I=4,Dn={pulls:`merged`,issues:`closed`},On={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:`]]]},kn=[`merged`,`opened`,`closed`,`created`],An=te(D`<circle cx="8" cy="8" r="2.75"/><path d="M8 1v4.25M8 10.75V15"/>`),jn={agent:`Commit with agents`,without:`Commit without agents`,release:`Release`},Mn=10,Nn=10;function L(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==En&&(xn.clear(),Sn.clear(),Cn.clear(),wn.clear(),En=e),xn}var R=()=>{for(let e of Tn)e.requestUpdate()},z=e=>Number.isSafeInteger(e)&&e>=0?e:0,Pn=(e,t)=>({count:z(e?.[t]?.count),previous:Number.isSafeInteger(e?.[t]?.previous)?e[t].previous:null,items:Array.isArray(e?.[t]?.items)?e[t].items.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.title==`string`):[]});function Fn(e){if(!Number.isSafeInteger(e?.since)||!_n.some(([t])=>t===e.weeks))throw Error(`The server answered with no period.`);let t=t=>Pn(e,t),n=e=>Array.isArray(e)&&e.length===7&&e.every(Array.isArray)?e.map(([e,t])=>[z(e),z(t)]):null,r=e=>Array.isArray(e)&&e.length===7?e.map(z):null,i=Array.isArray(e.stats?.weeks)?e.stats.weeks.filter(e=>Number.isSafeInteger(e?.week)&&Array.isArray(e.days)).map(e=>({...e,dayLines:n(e.dayLines),agentDays:r(e.agentDays),releaseDays:r(e.releaseDays),directDays:r(e.directDays)})):[],a=e.stats&&Array.isArray(e.stats.weeks)&&Array.isArray(e.stats.contributors)&&Array.isArray(e.stats.punch)?{weeks:i,contributors:e.stats.contributors.filter(e=>(typeof e?.login==`string`||typeof e?.name==`string`)&&Array.isArray(e.weeks)).map(e=>({login:typeof e.login==`string`?e.login:null,id:Number.isSafeInteger(e.id)?e.id:null,name:typeof e.name==`string`?e.name:null,weeks:e.weeks,days:Array.isArray(e.days)?e.days:null})),punch:yn.map(t=>Array.from({length:24},(n,r)=>z(e.stats.punch[t]?.[r]))),periodPunch:e.stats.periodPunch===!0,lines:typeof e.stats.lines==`boolean`?e.stats.lines:null,agents:i.length>0&&i.every(e=>e.agentDays!==null),releases:i.length>0&&i.every(e=>e.releaseDays!==null),direct:i.length>0&&i.every(e=>e.directDays!==null)&&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:typeof e.subject==`string`?e.subject:``,login:typeof e.login==`string`?e.login:null,id:Number.isSafeInteger(e.id)?e.id:null,name:typeof e.name==`string`?e.name:null,kind:typeof e.kind==`string`&&Object.hasOwn(jn,e.kind)?e.kind:null})):[]}:null;return{weeks:e.weeks,since:e.since,merged:t(`merged`),opened:t(`opened`),closed:t(`closed`),created:t(`created`),stats:a,reading:Number.isSafeInteger(e.reading)?e.reading:null,pulls:Number.isSafeInteger(e.pulls)?e.pulls:null,pending:e.pending===!0}}function In(e,t){Cn.set(e,t),t.answer.stats&&wn.set(e,t.answer)}var B=e=>e.reading??e.pulls,Ln=e=>B(e)===null?e.pending?[pn,mn]:null:[dn,fn];function Rn(e,t){let n=`${e}\0${t}`;return k(L(),n,()=>h(e,t).then(Fn),{ready:e=>({status:`ready`,until:Date.now()+ln,answer:e,tries:0,asking:!1}),settled:r=>{In(e,r),Ln(r.answer)&&zn(n,r,e,t,Ln(r.answer)[0])},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+un,error:e?.message||`The repository’s pulse could not be read.`},retryMs:un,repaint:R})}function zn(e,t,n,r,i){t.asking=!0,setTimeout(()=>{L().get(e)===t&&h(n,r).then(Fn).then(i=>{if(L().get(e)!==t)return null;let a=B(i)!==null&&B(t.answer)!==null&&B(i)>B(t.answer);t.answer=i,t.until=Date.now()+ln,t.tries=a?0:t.tries+1;let o=Ln(i);return o&&t.tries<o[1]?zn(e,t,n,r,o[0]):t.asking=!1,null},()=>(t.asking=!1,null)).finally(R)},i)}function Bn(e,t,n){return L(),k(Sn,[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`),()=>_(e,t,n),{ready:e=>({status:`ready`,until:Date.now()+ln,answer:Object.fromEntries(kn.map(t=>[t,Pn(e,t)]))}),failed:e=>({status:`error`,until:Date.now()+un,error:e?.message||`These couldn’t be read.`}),retryMs:un,repaint:R})}var Vn=e=>e.agents===!0&&e.weeks.some(e=>e.agentDays.some(e=>e>0)),Hn=e=>e.releases===!0&&e.weeks.some(e=>e.releaseDays.some(e=>e>0)),V=(e,t,n,r=`days`)=>e.reduce((e,i)=>e+i[r].reduce((e,r,a)=>{let o=i.week+a*P;return o>=t&&o<=n?e+z(r):e},0),0);function Un(e,t=Date.now()){let n=Math.floor(t/P)*P;return n-new Date(n).getUTCDay()*P-(e-1)*F}function Wn(e,t,n,r=Date.now()){return{weeks:n,since:e?.since??Un(n,r),merged:e?.merged??null,opened:e?.opened??null,closed:e?.closed??null,created:e?.created??null,stats:{...t.stats,otherPunch:t.weeks!==n},reading:e?.reading??null,pulls:e?.pulls??null,pending:e?.pending??!1}}function Gn(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=Math.floor(t/P)*P,a=e.weeks*F,o=n.weeks.filter(e=>e.week>=r),s=n.weeks.length>0&&n.weeks[0].week<=r-a,c=e=>n.lines===!0?o.reduce((t,n)=>t+z(n[e]),0):null;return{commits:V(n.weeks,r,i),previous:s?V(n.weeks,r-a,i-a):null,agents:n.agents?V(n.weeks,r,i,`agentDays`):null,previousAgents:n.agents&&s?V(n.weeks,r-a,i-a,`agentDays`):null,releases:n.releases?V(n.weeks,r,i,`releaseDays`):null,previousReleases:n.releases&&s?V(n.weeks,r-a,i-a,`releaseDays`):null,additions:c(`additions`),deletions:c(`deletions`),authors:qn(n.contributors,r).length}}function Kn({id:e=null,login:t,name:n}){let r=Ce(t,n);if(r)return`agent:${r}`;let i=_e(t)?.id;return i==null?e===null?t?`@${t.toLowerCase()}`:`=${n}`:`#${e}`:`user:${i}`}function qn(e,t,n=1/0){let r=new Map;for(let i of e){let{login:e,name:a}=i,o=Kn(i);r.set(o,(i.days??i.weeks).reduce((e,[r,i,a,o])=>r>=t&&r<n?{...e,commits:e.commits+z(i),additions:e.additions+z(a),deletions:e.deletions+z(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 Jn(e,t){let n=e.contributors.filter(e=>Kn(e)===t),r=n.length>0&&n.every(e=>e.days),i=e.weeks.map(({week:e})=>({week:e,days:Array.from({length:7},()=>0),dayLines:Array.from({length:7},()=>[0,0]),agentDays:Array.from({length:7},()=>0),releaseDays:Array.from({length:7},()=>0),directDays:Array.from({length:7},()=>0),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))/F)];if(!n||(n.commits+=z(t),n.additions+=z(a),n.deletions+=z(o),!r))continue;let u=Math.floor((e-n.week)/P);n.days[u]+=z(t),n.dayLines[u]=[n.dayLines[u][0]+z(a),n.dayLines[u][1]+z(o)],n.agentDays[u]+=z(s),n.releaseDays[u]+=z(c),n.directDays[u]+=z(l)}let a=e.agents===!0&&r&&n.every(e=>e.days.every(e=>e.length>4)),o=e.releases===!0&&r&&n.every(e=>e.days.every(e=>e.length>5)),s=e.direct===!0&&r&&n.every(e=>e.days.every(e=>e.length>6));return{...e,weeks:i,agents:a,releases:o,direct:s,byDays:r}}function Yn(e,t,n,r=null,i=Date.now()){let a=r===null?e:Jn(e,r);if(!e?.direct||!a.direct)return null;let o=Math.min(n-P,Math.floor(i/P)*P),s=e.directCommits.filter(e=>e.at>=t&&e.at<o+P&&(r===null||Kn(e)===r));return{count:V(a.weeks,t,o,`directDays`),items:s}}function Xn(e,t=Date.now()){let{stats:n,since:r,weeks:i}=e,a=n.lines===!0;if(i>4)return n.weeks.filter(e=>e.week>=r).map(e=>({from:e.week,to:e.week+F,day:!1,commits:z(e.commits),agents:n.agents?e.agentDays.reduce((e,t)=>e+t,0):null,releases:n.releases?e.releaseDays.reduce((e,t)=>e+t,0):null,additions:a?z(e.additions):null,deletions:a?z(e.deletions):null,future:!1}));let o=Math.floor(t/P)*P;return Array.from({length:i*7},(e,t)=>{let i=r+t*P,s=n.weeks.find(e=>i>=e.week&&i<e.week+F),c=s?Math.floor((i-s.week)/P):0,l=a?s?.dayLines?.[c]??null:null;return{from:i,to:i+P,day:!0,commits:z(s?.days[c]),agents:n.agents?z(s?.agentDays[c]):null,releases:n.releases?z(s?.releaseDays[c]):null,additions:l?.[0]??null,deletions:l?.[1]??null,future:i>o}})}function Zn(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()*P;return[n,n+F,!0]}function Qn(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 H=e=>e.toLocaleString(`en-US`),$n=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),U=e=>$n.format(e),W=(e,t,n=`${t}s`)=>`${H(e)} ${e===1?t:n}`,G=(e,t=!1)=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...t?{year:`numeric`}:{},timeZone:`UTC`}),er=e=>new Date(e).toISOString().slice(0,10),tr=(e,t)=>new Date(e).getUTCFullYear()!==new Date(t).getUTCFullYear(),nr=(e,t)=>{let n=Math.floor(t/P)*P,r=tr(e,n);return e>=n?G(n,r):`${G(e,r)} \u2013 ${G(n,r)}`},rr=(e,t)=>e.day?new Date(e.from).toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,...tr(e.from,t)?{year:`numeric`}:{},timeZone:`UTC`}):`Week of ${G(e.from,tr(e.from,t))}`,ir=(e,t,n={})=>`${rr(e,t)}: ${W(e.commits,`commit`)}${n.agents?`, ${H(e.agents)} with agents`:``}${n.releases?`, ${W(e.releases,`release`)}`:``}${e.additions===null?``:`, +${H(e.additions)} \u2212${H(e.deletions)} lines`}`;function ar(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?G(e[t].from):``;if(n===13)return t%2==0?G(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 or=(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 ${H(t)} ${n}`,sr=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function cr(e,t=!1){let[n,r]=t?[`latest `,`: the year shown is as it was before.`]:[``,`.`];return e.reading===null?e.pulls===null?[`GitHub is still counting this repository\u2019s ${n}commits\u2026`,`GitHub hasn\u2019t counted this repository\u2019s ${n}commits yet.`,`Ask again`]:[`Reading the pull requests merged in this repository\u2026 ${H(e.pulls)} so far`,`${H(e.pulls)} of the pull requests merged in this repository read so far${r}`,`Read on`]:[`Reading this repository\u2019s ${n}commits\u2026 ${H(e.reading)} of the last year so far`,`${H(e.reading)} of this repository\u2019s commits of the last year read so far${r}`,`Read on`]}var lr=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,ur=E`<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>`,dr=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,fr=e=>e.login?we(e.login,e.name,e.login):we(null,e.name),pr=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1},_column:{state:!0},_typed:{state:!0},_picked:{state:!0},_everyone:{state:!0},_person:{state:!0},_allDirect:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this._column=null,this._typed=!1,this._picked=null,this._everyone=!1,this._person=null,this._allDirect=!1}connectedCallback(){super.connectedCallback(),Tn.add(this)}disconnectedCallback(){super.disconnectedCallback(),Tn.delete(this)}willUpdate(e){!e.has(`repository`)||e.get(`repository`)?.repoId===this.repository?.repoId||(this._column=null,this._picked=null,this._everyone=!1,this._person=null,this._allDirect=!1)}pick(e){I=e,this._column=null,this._picked=null,this._everyone=!1,this._allDirect=!1,R()}showList(e,t){Dn[e]=t,R()}askAgain(){let{repoId:e}=this.repository,t=`${e}\0${I}`,n=L().get(t);n?.status!==`ready`||n.asking||(n.tries=0,zn(t,n,e,I,0),R())}render(){if(!this.repository)return O;let{repoId:e}=this.repository,t=Rn(e,I);t.status===`ready`&&In(e,t);let n=Date.now(),r=t.status===`ready`?t.answer:null,i=wn.get(e),a=r?.stats?r:i&&t.status!==`error`?Wn(r,i,I,n):r,o=!a&&t.status===`loading`?Cn.get(e)??null:null,s=a?{answer:a,asking:t.asking===!0}:o,c=s?.answer.stats&&(B(s.answer)!==null||s.answer.pending);return E`<div class="history-bar">${S(`pulse`)}<div class="history-modes" role="group" aria-label="Period">${_n.map(([e,t])=>E`<button type="button" aria-pressed="${String(I===e)}" @click="${()=>this.pick(e)}">${t}</button>`)}</div>${s?E`<span class="pulse-range">${nr(s.answer.since,n)}</span>`:O} ${c?E`<span class="pulse-updating" role="status">${this.renderWaiting(s,cr(s.answer,!0))}</span>`:O}</div>${s?E`<div class="${`pulse-scroll${o?` is-reading`:``}`}" aria-busy="${String(t.status!==`ready`)}">${this.renderPulse(s,n)}</div>`:t.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${t.error}</p><button type="button" @click="${()=>{L().delete(`${e}\0${I}`),R()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading the repository’s pulse…</div>`}`}renderPulse(e,t){let{answer:n}=e,r=_n.find(([e])=>e===n.weeks)[2],i=Gn(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,H(n[t].count),or(n[t].count,n[t].previous,r),`${H(n[i].count)} opened`):this.renderTile(e,`–`,`Reading…`,``),l=this.renderLists(n,a,t);return E`<section class="pulse-tiles" aria-label="Figures">${this.renderTile(`Commits`,i.commits===null?`–`:H(i.commits),o??or(i.commits,i.previous,r),`to the default branch`)} ${this.renderTile(`Contributors`,i.authors===null?`–`:H(i.authors),o,`who made them`)} ${c(`Pull requests merged`,`merged`,`opened`)} ${c(`Issues closed`,`closed`,`created`)} ${n.stats?.lines===!1?O:this.renderTile(`Lines`,i.additions===null?`–`:E`<span class="is-added">+${H(i.additions)}</span> <span class="is-removed">−${H(i.deletions)}</span>`,s,`added and removed`,i.additions===null?O:this.renderRatio(i.additions,i.deletions))} ${i.agents===null||!Vn(n.stats)?O:this.renderAgentsTile(i,r)}</section><div class="${`pulse-grid${l.length>2?` is-lists`:``}`}">${n.stats?E`${this.renderActivity(e,t)}${this.renderContributors(n,t)}`:E`<div class="pulse-pending pulse-wide" role="status">${this.renderWaiting(e,cr(n))}</div>`} ${l} ${n.stats?this.renderPunch(n.stats):O}</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?`, ${W(e.releases,`release`)} apart`:``;return this.renderTile(E`<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?`–`:`${sr(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:lr(sr(e.agents,n),sr(e.previousAgents,r),t),n===0?`no commits${i}`:`${H(e.agents)} of ${W(n,`commit`)}${i}`)}renderWaiting(e,[t,n,r]){return e.asking?t:E`${n} <button type="button" class="history-link" @click="${()=>this.askAgain()}">${r}</button>`}renderTile(e,t,n,r,i=O){return E`<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?E`<span class="pulse-tile-note">${r}</span>`:O}</div>`}renderRatio(e,t){return e+t===0?O:E`<span class="pulse-ratio" aria-hidden="true">${[[`is-added`,e],[`is-removed`,t]].map(([n,r])=>r>0?E`<span class="${n}" style="${T({"--share":`${r/(e+t)}`})}"></span>`:O)}</span>`}renderActivity(e,t){let{answer:n}=e,r=this._person===null?null:n.stats.contributors.find(e=>Kn(e)===this._person)??null,i=r?Jn(n.stats,this._person):n.stats,a=Xn({...n,stats:i},t),o=a[0]?.day?`day`:`week`,s=r?Te(r.login,r.name):null,c=r?E`<span>a ${o} by</span><button type="button" class="pulse-picked is-person" aria-label="${`${s}\u2019s: show everyone\u2019s`}" @click="${()=>this.showPerson(null)}">${fr(r)}<span aria-hidden="true">×</span></button>`:E`<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 E`<figure class="pulse-panel pulse-activity"><figcaption class="pulse-head"><h3>Commits</h3>${c}</figcaption><p class="pulse-note">${l}</p></figure>`;let u=Qn(Math.max(...a.map(e=>e.commits))),d=i.lines===!0&&a.every(e=>e.additions!==null)?Qn(Math.max(...a.flatMap(e=>[e.additions,e.deletions]))):null,f={agents:Vn(n.stats)&&a.some(e=>e.agents!==null),releases:Hn(n.stats)&&a.some(e=>e.releases!==null)},p=f.agents||f.releases,m=n.weeks===1,h=Math.floor(t/P)*P,g=a[this._column]&&!a[this._column].future?this._column:null,_=a.findIndex(e=>e.from===this._picked),v=(e,r,i,o)=>E`<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`:O}" aria-label="${i?ir(e,t,f):O}" aria-hidden="${i?O:`true`}" @pointerenter="${()=>this.point(e.future?null:r)}" @click="${()=>this.pickColumn(a,r)}">${o}</span>`,y=(e,t)=>m&&!e.future?E`<span class="pulse-figure">${t}</span>`:O,b=(e,t,n=O)=>E`<span class="${`pulse-bar${e}`}" style="${T({"--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?E`<span class="${`pulse-part${e}`}" style="${T({"--part":`${t}`})}"></span>`:O)};return E`<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?E`<span class="pulse-legend">${f.agents?E`<span class="pulse-key"></span>With agents<span class="pulse-key is-without"></span>Without`:O}${f.releases?E`<span class="pulse-key is-release"></span>Releases`:O}</span>`:O}</figcaption><div class="pulse-plots" @pointerleave="${()=>this.point(null)}"><div class="pulse-plot">${this.renderTicks(u.ticks.map(e=>[e/u.top,U(e),e===0]))}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!0,E`${y(e,H(e.commits))}${p?b(` is-split`,e.commits/u.top,x(e)):b(``,e.commits/u.top)}`))}</div></div>${d?E`<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,`+${U(d.top)}`],[.5,`0`,!0],[0,`\u2212${U(d.top)}`]])}<div class="pulse-columns">${a.map((e,t)=>v(e,t,!1,E`<span class="pulse-half">${y(e,`+${U(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${U(e.deletions)}`)}</span>`))}</div></div>`:i.lines===!1?E`<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?E`<p class="pulse-note">GitHub counts this repository’s lines a week, not a day: the quarter and the year show them.</p>`:E`<p class="pulse-note" role="status">${this.renderWaiting(e,[`GitHub is still counting lines added and removed…`,`GitHub hasn’t counted lines added and removed yet.`,`Ask again`])}</p>`}<div class="${`pulse-axis${m?` is-each`:``}`}" aria-hidden="true">${a.map((e,t)=>E`<span class="${e.future?`is-future`:e.day&&e.from===h?`is-today`:``}">${ar(a,t,n.weeks)}</span>`)}</div>${g===null?O:this.renderTip(n,a,g,t,f,!r)}</div><span class="sr-only" aria-live="polite">${this._typed&&g!==null?ir(a[g],t,f):``}</span></figure>`}renderTip(e,t,n,r,i,a){let o=t[n],s=Math.floor(r/P)*P,[c,l,u]=Zn(o,e.stats.contributors),d=a?qn(e.stats.contributors,c,l).slice(0,gn):[],f=(n+.5)/t.length;return E`<div class="${`pulse-tip${f>.6?` is-left`:``}`}" style="${T({"--x":`${f}`})}" aria-hidden="true"><span class="pulse-tip-when">${rr(o,r)}${o.day?o.from===s?E`<span>today</span>`:O:r<o.to?E`<span>so far</span>`:O}</span> <span class="pulse-tip-row"><span class="${`pulse-tip-key${i.agents||i.releases?` is-none`:``}`}"></span><strong>${H(o.commits)}</strong> ${o.commits===1?`commit`:`commits`}</span> ${i.agents?E`<span class="pulse-tip-row"><span class="pulse-tip-key"></span><strong>${H(o.agents)}</strong> with agents</span>`:O} ${i.releases?E`<span class="pulse-tip-row"><span class="pulse-tip-key is-release"></span><strong>${H(o.releases)}</strong> ${o.releases===1?`release`:`releases`}</span>`:O} ${o.additions===null?O:E`<span class="pulse-tip-row"><span class="pulse-tip-key is-added"></span><strong>+${H(o.additions)}</strong> added</span> <span class="pulse-tip-row"><span class="pulse-tip-key is-removed"></span><strong>−${H(o.deletions)}</strong> removed</span>`} ${d.length>0?E`<span class="pulse-tip-people">${u?E`<span class="pulse-tip-note">Its week’s</span>`:O} ${d.map(e=>E`<span class="pulse-tip-person">${fr(e)}<strong>${H(e.commits)}</strong></span>`)}</span>`:O}</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 E`<div class="pulse-ticks" aria-hidden="true">${e.map(([e,t,n])=>E`<span class="${n?`is-zero`:O}" style="${T({"--at":`${e}`})}"><span>${t}</span></span>`)}</div>`}renderContributors(e,t){let{contributors:n}=e.stats,r=Xn(e,t).find(e=>e.from===this._picked)??null,[i,a,o]=r?Zn(r,n):[e.since,1/0,!1],s=qn(n,i,a),c=s[0]?.commits??1,l=e.stats.lines===!0,u=r?o?`Week of ${G(i,tr(i,t))}`:rr(r,t):null;return E`<figure class="pulse-panel pulse-people"><figcaption class="pulse-head"><h3>Contributors</h3>${u?E`<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>`:E`<span>by their commits in the period</span>`}</figcaption>${s.length===0?E`<p class="pulse-note">No commits ${r?o||!r.day?`that week`:`that day`:`in the period`}.</p>`:E`<ol class="${`pulse-ranks${this._person===null?``:` is-picking`}`}">${(this._everyone?s:s.slice(0,hn)).map(e=>E`<li class="${e.key===this._person?`is-person`:O}"><span class="pulse-rank-who"><button type="button" class="pulse-rank-name" aria-pressed="${String(e.key===this._person)}" @click="${()=>this.showPerson(e.key)}">${fr(e)}</button> ${e.login?E`<a class="pulse-rank-profile" href="${dr(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${Te(e.login,e.name)} on GitHub`}">${ur}</a>`:O}</span> <span class="pulse-rank-bar"><span style="${T({"--value":`${e.commits/c}`})}"></span><span class="pulse-rank-value">${H(e.commits)}</span></span> ${l?E`<span class="pulse-rank-lines"><span class="is-added">+${U(e.additions)}</span> <span class="is-removed">−${U(e.deletions)}</span></span>`:O}</li>`)}</ol>${s.length>hn?E`<button type="button" class="history-link pulse-more" @click="${()=>{this._everyone=!this._everyone}}">${this._everyone?`Fewer`:`and ${W(s.length-hn,`more`,`more`)}`}</button>`:O}`}</figure>`}renderPunch(e){let{punch:t}=e,n=Math.max(1,...t.flat());return E`<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)=>E`<span class="pulse-punch-day">${vn[yn[t]].slice(0,3)}</span>${e.map((e,r)=>{let i=`${vn[yn[t]]}s, ${String(r).padStart(2,`0`)}:00\u2013${String(r+1).padStart(2,`0`)}:00: ${W(e,`commit`)}`;return E`<span class="${`pulse-cell is-${e===0?0:Math.ceil(e/n*bn)}`}" role="img" aria-label="${i}" data-tooltip="${i}"></span>`})}`)} <span></span>${Array.from({length:24},(e,t)=>E`<span class="pulse-punch-hour">${t%6==0?`${t}h`:``}</span>`)}</div><div class="pulse-scale" aria-hidden="true">Fewer${Array.from({length:bn},(e,t)=>E`<span class="${`pulse-cell is-${t+1}`}"></span>`)}More</div></figure>`}renderLists(e,t,n){let r=e.stats?Yn(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?Yn(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,r=t?.who?Te(t.who.login,t.who.name):null,i=t?[r&&`by ${r}`,t.when].filter(Boolean).join(` `):``,a=t?[r&&`by ${r}`,t.when??`in the period`].filter(Boolean).join(` `):`in the period`,o=this._allDirect?e.items:e.items.slice(0,Mn),s=Math.max(0,e.count-e.items.length);return E`<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?E`<span class="pulse-narrowed">${i}</span>`:O}<span class="pulse-count">${H(e.count)}</span></div>${e.count===0?E`<p class="pulse-note">None ${a}.</p>`:E`<ol>${o.map(e=>E`<li><a class="${`pulse-item is-commit${e.kind?` is-${e.kind}`:``}`}" href="${n?`https://github.com/${n}/commit/${e.sha}`:O}" target="_blank" rel="noopener noreferrer"><span class="issue-state" role="img" aria-label="${e.kind?jn[e.kind]:`Commit`}">${An}</span> <span class="pulse-item-title">${e.subject||`(no message)`}</span> <span class="pulse-item-meta"><span>${e.sha.slice(0,7)}</span><span>${fr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${ht(e.at)}</time></span></a></li>`)}</ol>`} ${e.items.length>Mn?E`<button type="button" class="history-link pulse-more" @click="${()=>{this._allDirect=!this._allDirect}}">${this._allDirect?`Fewer`:`and ${W(e.items.length-Mn,`more`,`more`)}`}</button>`:O} ${s>0?E`<p class="pulse-note">${e.items.length>0?W(s,`older commit`,`older commits`):W(s,`commit`)} not listed.</p>`:O}</section>`}narrowing(e,t){let n=this._picked===null||!e.stats?null:Xn(e,t).find(e=>e.from===this._picked)??null,r=this._person===null||!e.stats?null:e.stats.contributors.filter(e=>Kn(e)===this._person);if(!n&&!r)return null;let i=[...new Set((r??[]).flatMap(e=>e.login?[e.login]:[]))].slice(0,Nn);return{from:er(n?.from??e.since),to:n?er(n.to-P):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${rr(n,t)}`:`in the w${rr(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]=On[t],[a,,o]=i.find(([e])=>e===Dn[t]),s=n&&!n.nobody?Bn(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}`:`>=${er(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,h=n?.who?Te(n.who.login,n.who.name):null,g=n?[h&&`by ${h}`,n.when??`in the period`].filter(Boolean).join(` `):`in the period`,_=n?[h&&`by ${h}`,n.when].filter(Boolean).join(` `):``;return E`<section class="pulse-panel pulse-list" aria-label="${r}"><div class="pulse-head"><h3>${r}</h3>${n?E`<span class="pulse-narrowed">${_}</span>`:O}<div class="history-modes" role="group" aria-label="${`${r} shown`}">${i.map(([e,n])=>E`<button type="button" aria-pressed="${String(e===a)}" @click="${()=>this.showList(t,e)}">${n}<span class="n">${c?.[e]?H(c[e].count):`–`}</span></button>`)}</div></div>${n?.nobody?E`<p class="pulse-note">${h}’s commits name no GitHub account to find their ${r.toLowerCase()} by.</p>`:s?.status===`error`?E`<p class="pulse-note" role="alert">${s.error}</p>`:u===null?E`<p class="pulse-note" role="status">Reading…</p>`:u.length===0?E`<p class="pulse-note">None ${g}.</p>`:E`<ol>${u.map(e=>{let[n,r]=ue(t,e);return E`<li><a class="${`pulse-item is-${n}`}" href="${d?`https://github.com/${d}/${t===`pulls`?`pull`:`issues`}/${e.number}`:O}" target="_blank" rel="noopener noreferrer" @click="${n=>this.openItem(n,t,e)}"><span class="issue-state" role="img" aria-label="${r}">${ne[t][n]}</span> <span class="pulse-item-title">${e.title||`(no title)`}</span> <span class="pulse-item-meta"><span>#${e.number}</span>${e.author?E`<span>${xe(e.author)}</span>`:O} ${e.at==null?O:E`<time datetime="${new Date(e.at).toISOString()}">${ht(e.at)}</time>`}</span></a></li>`})}</ol>`} ${m&&u!==null&&l>u.length?E`<a class="pulse-all" href="${m}" target="_blank" rel="noopener noreferrer">All ${H(l)} on GitHub</a>`:O}</section>`}openItem(e,t,n){pe(e)&&(e.preventDefault(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{number:n.number,preview:{...n,kind:t,labels:[],comments:0}}}))}};customElements.get(`repository-pulse`)||customElements.define(`repository-pulse`,pr);var mr=864e5,hr=[100,300,1e3];function gr(e,t){return Ie(e).filter(e=>e.parents.length<=1&&Number.isFinite(e.committedAt)).slice(0,t).toReversed()}var _r=1,vr=.08,yr=.6;function br(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/mr;t.push(n===0?0:t[n-1]+Math.min(yr,Math.max(vr,i*_r)))}return t}function xr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function Sr(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 Cr=.9,wr=2,Tr=1,Er=5,Dr=1,Or=.06;function kr(){let e=Ar(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Ar(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}}function jr(e,t){let n=e.dirs.get(t);if(n)return n;let r=t.lastIndexOf(`/`),i=jr(e,r===-1?``:t.slice(0,r)),a=Ar(t,i),[o,s]=[0,i.dirs.length];for(;o<s;){let e=o+s>>1;i.dirs[e].name<a.name?o=e+1:s=e}return i.dirs.splice(o,0,a),e.dirs.set(t,a),Jr(i),e.layout=!0,a}function Mr(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=t.lastIndexOf(`/`),o=jr(e,a===-1?``:t.slice(0,a));i={path:t,name:t.slice(a+1),extension:xr(t),dir:o,ox:0,oy:0,touched:r,kind:n,removed:null},o.files.push(i),e.files.set(t,i),Jr(o),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 Nr(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);Jr(r),e.layout=!0}var Pr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Fr(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=Pr(n),s=o.length>1?Math.min(Or,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 Ir(e,t){for(let[n,r]of Pr(t)){let t=Mr(e,n,r,-1/0);t&&r===`D`&&Nr(e,t)}}function Lr(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 Rr(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=Mr(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<Cr);for(let n of[...e.going])t-n.removed>=Tr&&Nr(e,n);for(let[n,r]of e.users)t-r.active>Er+Dr&&e.users.delete(n)}var zr=6,Br=2.2,Vr=12,Hr=Math.PI*(3-Math.sqrt(5)),Ur=46,Wr=34,Gr=e=>e===0?0:zr*.62*Math.sqrt(e)+Br;function Kr(e){let t=zr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Hr),t*Math.sin(e*Hr)]}function qr(e){Yr(e.root),Xr(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function Jr(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function Yr(e){if(!e.dirty)return;for(let t of e.dirs)Yr(t);e.cluster=Math.max(Gr(e.files.length),Br)+Vr/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)li(t,n);else{Zr([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=ni([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 Xr(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);Xr(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function Zr(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;Qr(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];Qr(i.c,a.c,n);let r=a.next,o=a.c.r,s=i.previous,c=i.c.r;do if(o<=c){if($r(r.c,n)){a=r,i.next=a,a.previous=i,t--;continue e}o+=r.c.r,r=r.next}else{if($r(s.c,n)){i=s,i.next=a,a.previous=i,t--;continue e}c+=s.c.r,s=s.previous}while(r!==s.next);let l={c:n,previous:i,next:a};i.next=a.previous=a=l;let u=ei(i);for(let e=l.next;e!==a;e=e.next){let t=ei(e);t<u&&([i,u]=[e,t])}a=i.next}}function Qr(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;if(o>s){let t=(a+s-o)/(2*a),c=Math.sqrt(Math.max(0,s/a-t*t));[n.x,n.y]=[e.x-t*r-c*i,e.y-t*i+c*r]}else{let e=(a+o-s)/(2*a),c=Math.sqrt(Math.max(0,o/a-e*e));[n.x,n.y]=[t.x+e*r-c*i,t.y+e*i+c*r]}}var $r=(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 ei(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 ti=64;function ni(e){let t=e.toSorted((e,t)=>q(`${e.x},${e.y}`)-q(`${t.x},${t.y}`)),n=[],r=null,i=0;for(let a=0;a<t.length;a++)if(!(r&&oi(r,t[a]))){if(n=ii(n,t[a]),r=K(n),!Number.isFinite(r.x+r.y+r.r)||++i>ti*t.length)return ri(e);a=-1}return r}function ri(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 ii(e,t){if(e.every(e=>oi(t,e)))return[t];for(let n of e)if(!ai(t,n)&&e.every(e=>oi(K([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!ai(K([r,i]),t)&&!ai(K([r,t]),i)&&!ai(K([i,t]),r)&&e.every(e=>oi(K([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var ai=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function oi(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 K([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 si=60,ci=.5;function li(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t)r.x===void 0&&(ui(r,e,n),n.push(r));for(let n=0;n<si;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-ci)continue;let a=t>1e-6?Math.atan2(r.y,r.x):q(r.child.name);[r.x,r.y]=[Math.cos(a)*i,Math.sin(a)*i],n=!0}let r=t.toSorted((e,t)=>e.x-e.r-(t.x-t.r));for(let[e,t]of r.entries())for(let i=e+1;i<r.length&&r[i].x-r[i].r<t.x+t.r;i++){let e=r[i],a=t.r+e.r,[o,s]=[e.x-t.x,e.y-t.y];if(Math.abs(s)>=a-ci)continue;let c=Math.hypot(o,s);if(c>=a-ci)continue;let l=c>1e-6?Math.atan2(s,o):q(e.child.name),[u,d]=[e.r**2,t.r**2].map(n=>n/(t.r**2+e.r**2)*(a-c));[t.x,t.y]=[t.x-Math.cos(l)*u,t.y-Math.sin(l)*u],[e.x,e.y]=[e.x+Math.cos(l)*d,e.y+Math.sin(l)*d],n=!0}if(!n)return}}function ui(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-ci&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-ci),i=[],a=(t,n)=>{for(let[r,a]of[[t,n],[n,t]]){let t={r:e.r};Qr(r,a,t),i.push(t)}};for(let e of n)a(t,e);let o=n.toSorted((e,t)=>e.x-e.r-(t.x-t.r));for(let[t,n]of o.entries())for(let r=t+1;r<o.length&&o[r].x-o[r].r<n.x+n.r+2*e.r;r++){let t=o[r];Math.hypot(t.x-n.x,t.y-n.y)<n.r+t.r+2*e.r&&a(n,t)}let s=q(e.child.name);n.length===0&&i.push({x:Math.cos(s)*(t.r+e.r),y:Math.sin(s)*(t.r+e.r)});let c=null;for(let e of i)r(e)&&(!c||Math.hypot(e.x,e.y)<Math.hypot(c.x,c.y))&&(c=e);let l=Math.max(t.r,...n.map(e=>Math.hypot(e.x,e.y)+e.r))+e.r;[e.x,e.y]=c?[c.x,c.y]:[Math.cos(s)*l,Math.sin(s)*l]}function di(e,t,n=Wr){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]=Kr(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=q(e.key);[e.x,e.y]=[n+Math.cos(t)*Ur*3,r+Math.sin(t)*Ur*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Ur,r+(e.y-r)/i*Ur];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(q(r.key)),Math.sin(q(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 q(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 fi(e){e.layout&&qr(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]=Kr(e)}}function pi(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,Gr(t.files.length)+Br);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var mi=[.5,1,2,4,8],hi=20,gi=50,_i=8,vi={side:40,top:64,bottom:40},yi=3,bi=10,J=11,xi=72,Si=250,Ci=1.8,wi=2,Ti=new Set([`A`,`M`,`D`,`R`]),Ei=new Map,Di=new Map,Oi=new Set,ki=new Map,Ai=new Set,ji=new Map,Mi=null,Ni=300,Pi=1;function Fi(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Mi&&(Ei.clear(),Di.clear(),Oi.clear(),ki.clear(),Mi=e),Ei}var Ii=()=>{for(let e of Ai)e.requestUpdate()},Li=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Ri(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=Fi().get(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:kr(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return Ei.set(a,s),s}var zi={files:[],cut:!1},Bi=e=>e.commits[0]?.parents[0]??null,Vi=e=>`${e.repoId}\0${e.path}\0${Bi(e)}`,Y=e=>Bi(e)?ki.get(Vi(e)):zi,X=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,Z=(e,t)=>Di.get(X(e,t)),Hi=(e,t)=>Oi.has(X(e,t)),Ui=(e,t)=>ki.get(X(e,t)),Wi=(e,t)=>!(!Z(e,t.sha)||Hi(e,t.sha)&&!Ui(e,t.sha));function Gi(e){let t=0;for(;t<(e.commits?.length??0)&&Wi(e,e.commits[t]);)t++;return t}function Ki(e,t){if(!Array.isArray(e)||!Ti.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 qi(e){let t=Y(e),n=e.commits.filter(t=>Z(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(xr(t),(e.counts.get(xr(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of Pr(Z(e,t.sha)))r!==`D`&&i(n);Sr(e.colors,e.counts,_i)}function Ji(e){if(e.treeReading||e.error)return;let t=[...e.commits.slice(e.next),...e.commits.slice(0,e.next)],n=Bi(e)&&!Y(e),r=n?Bi(e):t.find(t=>Hi(e,t.sha)&&!Ui(e,t.sha))?.sha;if(!r)return;e.treeReading=!0;let i=X(e,r);d(e.repoId,e.path,r).then(t=>{if(Fi().get(e.key)!==e)return null;let r=Array.isArray(t?.files)?t.files.map(t=>Ki([t,`A`],e.path)?.[0]).filter(Boolean):[];return ki.set(i,{files:r,cut:t?.cut===!0||!n&&!Array.isArray(t?.files)}),null},t=>(t?.name!==`AbortError`&&(e.error=t?.message||(n?`The files the commits start from could not be read.`:`The files a commit leaves could not be read.`)),null)).finally(()=>{e.treeReading=!1,Ii()})}function Yi(e,t,n){let r=Z(e,n.sha),i=Hi(e,n.sha)?Ui(e,n.sha):null;return i?[...r,...Lr(t,i.files,i.cut,Pr(r))]:r}function Xi(e,t){let n=kr();n.start=Y(e),Ir(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))Ir(n,Yi(e,n,r));return fi(n),n}function Zi(e){if(e.reading||e.error||!e.commits)return;let t=Gi(e)===0?hi:gi,n=[...e.commits.slice(e.next),...e.commits.slice(0,e.next)].filter(t=>!Z(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&(e.reading=!0,u(e.repoId,e.path,n).then(t=>{if(Fi().get(e.key)!==e)return null;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)Di.set(X(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>Ki(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&Oi.add(X(e,t));return null},t=>(t?.name!==`AbortError`&&(e.error=t?.message||`What the commits changed could not be read.`),null)).finally(()=>{e.reading=!1,Ii()}))}function Qi(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(ge,i)?i:Ce(n,r),a=e?null:_e(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?ge[e].name:a?a.name??a.login:r??n,c=e?ge[e].mark??null:null,l=e?!c&&ge[e].avatar?`/api/avatar/${ge[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 $i={anthropic:[Ae,4,5,8],openai:[je,4,5,8],"github-copilot":[Me,0,0,24]},ea={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},ta=new Map,na=e=>ta.get(e)??ta.set(e,new Path2D($i[e][0])).get(e);function ra(e){let t=ji.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,ji.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var Q=e=>e.toLocaleString(`en-US`),ia=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),aa=e=>e===.5?`½×`:`${e}\xD7`,oa=D`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,sa=D`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,ca=D`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,la=class extends Pe{static properties={repository:{attribute:!1},repo:{attribute:!1}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,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(),Ai.add(this),Et(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(),Ai.delete(this),Dt(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Ai].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}=Tt(this.repository);if(t.status!==`ready`)return;if(t.commits.filter(e=>e.parents.length<=1&&Number.isFinite(e.committedAt)).length<e.count&&t.more){!t.loadingMore&&!t.moreError&&n();return}e.commits=gr(t.commits,e.count),e.times=br(e.commits)}Ji(e),Zi(e);let t=Y(e);t&&(qi(e),e.scene.start!==t&&this.seek(e.next),!e.started&&Gi(e)>0&&(e.started=!0,e.playing=!Li(),this.requestUpdate()))}pickCount(e){Ni=e,Ii()}pickSpeed(e){Pi=e,Ii()}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||!Y(t))return;let n=Math.max(0,Math.min(e,Gi(t)));Object.assign(t,{scene:Xi(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)&&(Rr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=Si&&(qr(n.scene),this._laidOut=e),di(n.scene,t,Math.max(Wr,xi/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*Pi,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!Wi(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+yr)-r;Fr(e.scene,Qi(t),Yi(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+wi&&(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={background:t(`background`),text:t(`text`),muted:t(`muted`),surface:t(`surface`),added:t(`added`),modified:t(`modified`),removed:t(`removed`),kinds:Array.from({length:_i},(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,Br*u.zoom),g=h<Ci,_=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<wr){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)/wr),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/Tr);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)/Cr)*.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>wr||b(e.name,d(e.x)+Math.max(6,(Gr(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=bi){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/wr),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-Er)/Dr));let[i,a]=Object.hasOwn(ea,e.agent)?ea[e.agent]:[r.surface,r.text];s.fillStyle=i,s.beginPath(),s.arc(t,n,J,0,2*Math.PI),s.fill();let o=e.image?ra(e.image):null;if(e.mark&&Object.hasOwn($i,e.mark)){let[,r,i,o]=$i[e.mark],c=J*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(na(e.mark)),s.restore(),s.beginPath(),s.arc(t,n,J,0,2*Math.PI)}else o?(s.save(),s.clip(),s.drawImage(o,t-J,n-J,J*2,J*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+J+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=pi(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(yi,(t-2*vi.side)/Math.max(1,i.maxX-i.minX),(n-vi.top-vi.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-(vi.top-vi.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))<=J+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 O;let e=Ri(this.repository,Ni);this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:Tt(this.repository),n=e.commits?.length??0,r=Gi(e),i=e.next>0?e.commits[e.next-1]:null,a=e.commits?e.people??=new Set(e.commits.flatMap(e=>Qi(e).map(e=>e.key))).size:0,o=(e.commits?Y(e):null)?.cut||e.commits?.some(t=>Hi(e,t.sha)&&Ui(e,t.sha)?.cut),s=e.commits&&n>0?`${Q(n)} commit${n===1?``:`s`} by ${Q(a)}, ${ia(e.commits[0].committedAt)} \u2013 ${ia(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return E`<div class="history-bar">${S(`replay`)}<div class="history-modes" role="group" aria-label="Commits played">${hr.map(e=>E`<button type="button" aria-pressed="${String(Ni===e)}" @click="${()=>this.pickCount(e)}">Last ${Q(e)}</button>`)}</div>${s?E`<span class="history-summary">${s}</span>`:O}</div><div class="replay-stage"><canvas class="replay-canvas" role="img" aria-label="${i?`The repository\u2019s files as of ${ia(i.committedAt)}, ${Q(e.next)} of ${Q(n)} commits played`:`The repository’s files, as its commits change them`}" @pointermove="${this.pointer}" @pointerleave="${this.pointer}"></canvas>${i?E`<div class="replay-day"><time datetime="${new Date(i.committedAt).toISOString()}">${ia(i.committedAt)}</time> <span>${Q(e.next)} of ${Q(n)}</span></div>${this.renderCommit(i)}`:O} ${this.renderKey(e)} ${this.renderStatus(e,t,r)} ${this._hovered?E`<div class="replay-tip" style="${T({left:`${this._hovered.x}px`,top:`${this._hovered.y}px`})}">${this._hovered.text}</div>`:O}<div class="replay-swatches" aria-hidden="true">${[`background`,`text`,`muted`,`surface`,`added`,`modified`,`removed`,...Array.from({length:_i},(e,t)=>`kind-${t}`)].map(e=>E`<span class="${`is-${e}`}"></span>`)}</div></div>${this.renderControls(e,n,r)}`}renderCommit(e){let t=this.repo??this.repository.repo,n=t?`https://github.com/${t.split(`/`).map(encodeURIComponent).join(`/`)}`:null,r=e.sha.slice(0,7);return E`<p class="replay-commit">${n?E`<a class="replay-sha" href="${`${n}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" aria-label="${`Commit ${r} on GitHub`}">${r}</a>`:E`<code class="replay-sha">${r}</code>`} <span class="replay-commit-subject">${_t(e.subject||`(no message)`,n)}</span> <span class="replay-commit-author">${c(e.authorLogin,e.authorName,e.coauthors)}</span></p>`}renderKey(e){if(e.colors.size===0)return O;let t=[...e.colors].toSorted((t,n)=>(e.counts.get(n[0])??0)-(e.counts.get(t[0])??0));return E`<ul class="replay-key" aria-label="Kinds of files">${t.map(([e,t])=>E`<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){if(t?.entry.status===`error`)return E`<div class="replay-status is-error"><p role="alert">${t.entry.error}</p><button type="button" @click="${()=>Ot(t.key)}">Retry</button></div>`;if(e.error)return E`<div class="replay-status is-error"><p role="alert">${e.error}</p><button type="button" @click="${()=>{e.error=null,Ii()}}">Retry</button></div>`;if(t?.entry.status===`ready`&&t.entry.moreError)return E`<div class="replay-status is-error"><p role="alert">${t.entry.moreError}</p><button type="button" @click="${()=>t.more()}">Retry</button></div>`;if(t){let e=t.entry.status===`ready`?t.entry.commits.length:0;return E`<div class="replay-status" role="status">${e>0?`Reading commits\u2026 ${Q(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?E`<div class="replay-status">No commits to play.</div>`:Y(e)?n===0?E`<div class="replay-status" role="status">Reading what the commits changed…</div>`:e.waiting?E`<div class="replay-status is-waiting" role="status">Reading what the next commits changed…</div>`:O:E`<div class="replay-status" role="status">Reading the files as they were before ${ia(e.commits[0].committedAt)}…</div>`}renderControls(e,t,n){let r=e.ended?`Play again`:e.playing?`Pause`:`Play`,i=n>0&&!!(e.commits&&Y(e)),a=e=>`${t>0?e/t*100:0}%`;return E`<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?ca:e.playing?sa:oa}</svg></button><div class="replay-track" style="${T({"--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="${`${Q(e.next)} of ${Q(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div><div class="history-modes" role="group" aria-label="Speed">${mi.map(e=>E`<button type="button" aria-pressed="${String(Pi===e)}" @click="${()=>this.pickSpeed(e)}">${aa(e)}</button>`)}</div></div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,la);var ua=3e5,da=3e4,fa=8,pa=20,ma=new Map,ha=new Set,ga=null,_a={issues:`open`,pulls:`open`};function va(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==ga&&(ma.clear(),ga=e),ma}var $=()=>{for(let e of ha)e.requestUpdate()};m(e=>{for(let t of ha)(!e||t.repository?.repoId===e.repoId)&&t.requestUpdate()});function ya(e){if(!Array.isArray(e?.items))throw Error(`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 ba(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 xa(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));n.counted=r}function Sa(e,t,n){return k(va(),e,()=>t(null),{ready:e=>{let t={status:`ready`,until:Date.now()+ua,...e,countsAt:e.readAt,loadingMore:!1,moreError:null};return n(t),t},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+da,error:e?.message||`The list could not be read.`},retryMs:da,repaint:$})}function Ca(e,t,n,r){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+ua,$(),n(t.after).then(n=>{if(va().get(e)!==t)return null;let i=new Set(t.items.map(e=>e.number));return t.items=[...t.items,...n.items.filter(e=>!i.has(e.number))],n.readAt>=t.countsAt&&(t.counts=n.counts,t.countsAt=n.readAt,r(t)),t.more=n.more,t.after=n.after,t.until=Date.now()+ua,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More could not be read.`),null)).finally(()=>{t.loadingMore=!1,$()}))}function wa(e,t){let n=t.trim().toLowerCase().split(/\s+/u).filter(Boolean);return n.length===0?e:e.filter(e=>{let t=[`#${e.number}`,e.title,e.author??``,ve(e.author)??``,e.head??``,...e.labels.map(e=>e.name)].join(`
4
+ `).toLowerCase();return n.every(e=>t.includes(e))})}var Ta=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Ea=e=>e<1e3?String(e):Ta.format(e);function Da(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>fa?fa-1:fa),r=e=>E`<span class="issue-label" style="${T(e.color?{"--label":`#${e.color}`}:{})}" data-tooltip-truncated data-tooltip="${e.name}">${e.name}</span>`,i=e=>E`${r(e[0])}${e.length>1?E`<span class="issue-labels-rest" style="${T({"--labels":String(e.length-1)})}">${i(e.slice(1))}</span>`:O}`;return E`${n.length>0?i(n):O}${t>n.length?E`<span class="issue-label is-more">+${t-n.length}</span>`:O}`}var Oa={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`};function ka({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,pa);return[t>0?`${e.slice(0,pa).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${Oa[e.unsupported]})`).join(`, `)}${a>0?` and ${a.toLocaleString(`en-US`)} more`:``} can\u2019t be reviewed`:null,n.length>0||r>0||i?`not every lockfile it changes was read`:null].filter(Boolean).join(`; `)}function Aa(e){if(e.status!==`ready`)return O;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=y(e),o=e.review?x(e).count:0,s=ee(e);if(t.length===0&&o===0&&!s)return O;let c=i?`+`:``,l=t=>{let n=b(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${Oa[t.unsupported]}`:n===`baseline`?`, needs no review`:t.reviewed?`, reviewed`:t.rejected?`, rejected`:t.patched&&n===`wanted`?`, patched, unreviewed`:n?`, ${t.reviews}/${e.review.required} reviews`:``},u=e=>`${e.name}@${e.version??`?`}${e.was?` (was ${e.was.join(`, `)}${l(e)})`:` (new${l(e)})`}`,d=t.length-pa,f=[t.length>0?`New in its lockfiles: ${t.slice(0,pa).map(u).join(`, `)}${d>0?` and ${d.toLocaleString(`en-US`)}${c} more`:i?` and more`:``}`:null,o>0?`${o.toLocaleString(`en-US`)} other ${o===1?`version`:`versions`} in its lockfiles unreviewed`:null,s?`Its review fails: ${ka(s)}`:null].filter(Boolean).join(`. `),p=[n?`${n.toLocaleString(`en-US`)} new`:null,r?`${r.toLocaleString(`en-US`)} updated`:null].filter(Boolean).join(`, `),m=a&&o?`${a.toLocaleString(`en-US`)} + ${o.toLocaleString(`en-US`)} to review`:a?`${a.toLocaleString(`en-US`)} to review`:o?`${o.toLocaleString(`en-US`)} unreviewed`:``;return E`<span class="issue-deps" data-tooltip="${f}">${le}<span class="issue-deps-names">${[...new Set(t.map(e=>e.name))].join(`, `)}</span> ${p?E`<span class="issue-deps-count">${p}${c}</span>`:O} ${s?E`<span class="issue-deps-review is-failed">${s.count>0?`${s.count.toLocaleString(`en-US`)} can\u2019t be reviewed`:`lockfiles unread`}</span>`:e.review?m?E`<span class="issue-deps-review is-wanted">${m}</span>`:E`<span class="issue-deps-review is-passed" role="img" aria-label="Every version reviewed">${ie.success[1]}</span>`:O}</span>`}var ja=class extends ye{static properties={repository:{attribute:!1},repo:{attribute:!1},kind:{},_filter:{state:!0}};createRenderRoot(){return this}constructor(){super(),this.repository=null,this.repo=null,this.kind=`issues`,this._filter=``,this._moreButton=null}connectedCallback(){super.connectedCallback(),ha.add(this)}disconnectedCallback(){super.disconnectedCallback(),ha.delete(this),this._moreButton&&C(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.issues-more > button`);this._moreButton&&this._moreButton!==e&&C(this._moreButton),this._moreButton=e,e&&me(e,t=>{t&&this.readNear(e)})}readNear(e){e===this._moreButton&&e.isConnected&&!e.disabled&&!this._filter.trim()&&!e.parentElement.querySelector(`[role=alert]`)&&e.click()}list(e){let{repoId:t}=this.repository,r=this.kind,i=`${t}\0${r}\0${e}`,a=i=>p(t,r,{state:e,after:i}).then(ya).then(e=>(n(t,e.items,e.readAt,r),e)),o=e=>xa(t,r,e),s=Sa(i,a,o);return{key:i,entry:s,more:()=>Ca(i,s,a,o)}}pick(e){_a[this.kind]=e,$()}render(){if(!this.repository)return O;let e=_a[this.kind],{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=va().get(`${this.repository.repoId}\0${this.kind}\0${o}`),c=i?ba(this.repository.repoId,this.kind,e,n):null,l=c?c.counts:s?.status===`ready`?ba(this.repository.repoId,this.kind,o,s).counts:null,u=e=>l?E`<span class="n">${l[e].toLocaleString(`en-US`)}</span>`:O,d=c?wa(c.items,this._filter):[];return E`<div class="history-bar issues-bar">${S(this.kind)}<div class="history-modes" role="group" aria-label="${this.kind===`pulls`?`Pull requests`:`Issues`}"><button type="button" aria-pressed="${String(e===`open`)}" @click="${()=>this.pick(`open`)}">Open${u(`open`)}</button> <button type="button" aria-pressed="${String(e===`closed`)}" @click="${()=>this.pick(`closed`)}">Closed${u(`closed`)}</button></div><input class="issues-filter" type="search" placeholder="Filter" aria-label="${`Filter the ${a} read`}" .value="${this._filter}" @input="${e=>{this._filter=e.target.value}}"> ${c&&this._filter.trim()?E`<span class="history-summary">${d.length} of ${c.items.length} read</span>`:O}</div>${c?this.renderTiles(n,c.items,d,r,`${e} ${a}`):n.status===`error`?E`<div class="bundles-slide-placeholder is-error"><p role="alert">${n.error}</p><button type="button" @click="${()=>{va().delete(t),$()}}">Retry</button></div>`:E`<div class="bundles-slide-placeholder" role="status">Reading the ${a}…</div>`}`}renderTiles(e,t,n,r,i){if(t.length===0)return E`<div class="bundles-slide-placeholder">No ${i}.</div>`;let a=this.repo??this.repository.repo,o=this.kind===`pulls`?`pull`:`issues`;return E`<div class="issues-scroll">${n.length===0?E`<p class="history-note">None of the ${i} read match.</p>`:E`<ol class="issues-grid" aria-label="${i}">${n.map(e=>{let[t,n]=ue(this.kind,e),r=this.renderTile(e,t,n);return E`<li class="${De({"issue-tile":!0,[`is-${t}`]:!0})}">${a?E`<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>`:E`<div class="issue-body" @click="${t=>this.openTile(t,e)}">${r}</div>`}</li>`})}</ol>`} ${e.more||e.moreError?E`<div class="history-more issues-more">${e.moreError?E`<span role="alert">${e.moreError}</span>`:O} <button type="button" ?disabled="${e.loadingMore}" @click="${r}">${e.loadingMore?`Reading…`:`More`}</button></div>`:O}</div>`}openTile(e,t){pe(e)&&(e.preventDefault(),Ee({repository:{...this.repository,repo:this.repo??this.repository.repo},target:{number:t.number,preview:{...t,kind:this.kind}}}))}renderTile(t,n,r){let i=this.kind===`pulls`,a=i&&t.state===`open`&&g(t)?v(this.repository.repoId,t.number,!0):null,o=t.updatedAt==null?null:new Date(t.updatedAt),s=i&&t.checks?ie[t.checks]:null,c=i&&t.state===`open`&&t.review?ae[t.review]:null,l=t.comments>0?`${t.comments.toLocaleString(`en-US`)} comment${t.comments===1?``:`s`}`:null,u=(e,[n,r])=>E`<span class="${`issue-${e} is-${t[e]}`}" role="img" aria-label="${n}" data-tooltip="${n}">${r}</span>`;return E`<span class="issue-rail"><span class="issue-state" role="img" aria-label="${r}">${ne[this.kind][n]}</span> ${i?E`<span class="issue-marks">${c?u(`review`,c):O}${s?u(`checks`,s):O}</span>`:O} ${l?E`<span class="issue-comments" role="img" aria-label="${l}" data-tooltip="${l}">${re}<span>${Ea(t.comments)}</span></span>`:O} </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">${xe(t.author,t.author??`ghost`)}</span> ${o?E`<time datetime="${o.toISOString()}">${ht(t.updatedAt)}</time>`:O} </span>${t.labels.length>0||t.moreLabels>0?E`<span class="issue-labels">${Da(t)}</span>`:O} ${i&&t.head?E`<span class="issue-branch"><code>${t.head}</code>${t.base?E`<span aria-hidden="true">→</span><code>${t.base}</code>`:O} <span class="issue-diff"><span class="is-added">+${t.additions.toLocaleString(`en-US`)}</span> <span class="is-deleted">−${t.deletions.toLocaleString(`en-US`)}</span></span></span>`:O} ${i&&t.state===`open`?e(t.reviews):O} ${a?Aa(a):O}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,ja);