@preventive/triage 1.0.0-alpha.45 → 1.0.0-alpha.47

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 (110) hide show
  1. package/client/linked-findings.js +3 -0
  2. package/common/bundle-metadata.d.ts +1 -0
  3. package/common/bundle-metadata.js +1 -1
  4. package/common/bundle-sources.js +5 -1
  5. package/common/line-diff.js +5 -4
  6. package/common/managed/agent-tasks.ts +5 -3
  7. package/common/managed/github-agents.ts +28 -10
  8. package/out/activity.js +4 -0
  9. package/out/{chunk-NPW52BM2.js → chunk-4HI2MSAV.js} +13 -13
  10. package/out/chunk-5AHIQFFG.js +36 -0
  11. package/out/chunk-6ANSHRFQ.js +6 -0
  12. package/out/chunk-6WF3KNTL.js +3 -0
  13. package/out/chunk-7BKKYVWR.js +7 -0
  14. package/out/{chunk-HMAJDVXN.js → chunk-FH24VHSJ.js} +1 -1
  15. package/out/chunk-NOZJULWS.js +52 -0
  16. package/out/{chunk-OKRLLE5I.js → chunk-PWFUOLZK.js} +1 -1
  17. package/out/chunk-S6U2J62U.js +232 -0
  18. package/out/chunk-SPEFPML6.js +2 -0
  19. package/out/chunk-UENXT2HK.js +3 -0
  20. package/out/chunk-VL43BTSO.js +1 -0
  21. package/out/{chunk-3PS4KWD2.js → chunk-WCPJDAYA.js} +1 -1
  22. package/out/chunk-ZCS4UYHI.js +1 -0
  23. package/out/chunk-ZGNMDGSB.js +1 -0
  24. package/out/client-managed-import.js +1 -1
  25. package/out/client-managed.js +15 -15
  26. package/out/client-sync.js +2 -2
  27. package/out/compare.js +12 -12
  28. package/out/dialogs.js +28 -28
  29. package/out/graph.js +11 -11
  30. package/out/index.html +11 -11
  31. package/out/scan.js +2 -2
  32. package/out/terminal.js +6 -6
  33. package/out/view.css +1 -1
  34. package/out/view.js +15 -15
  35. package/package.json +4 -1
  36. package/risk/actions/findings.js +14 -9
  37. package/risk/actions/scripts/shell.js +5 -1
  38. package/risk/index.d.ts +9 -4
  39. package/risk/npm/assess.js +15 -4
  40. package/risk/npm/registry.js +6 -1
  41. package/server-e2e/app.ts +5 -4
  42. package/server-e2e/http.ts +5 -2
  43. package/server-managed/activity.ts +24 -11
  44. package/server-managed/app-agents.ts +10 -21
  45. package/server-managed/bundle-build-worker.js +7 -3
  46. package/server-managed/bundle-build.ts +5 -3
  47. package/server-managed/bundle-cache.ts +16 -4
  48. package/server-managed/bundle.ts +3 -4
  49. package/server-managed/combined.ts +3 -2
  50. package/server-managed/commit-coauthors.ts +5 -9
  51. package/server-managed/commit-lockfiles.ts +21 -11
  52. package/server-managed/config.ts +6 -0
  53. package/server-managed/db-methods.ts +321 -156
  54. package/server-managed/db-neon.ts +71 -24
  55. package/server-managed/db-schema.ts +4 -0
  56. package/server-managed/db.ts +2 -1
  57. package/server-managed/dependency-reviews.ts +13 -3
  58. package/server-managed/github-app.ts +12 -6
  59. package/server-managed/github-issue-links.ts +11 -5
  60. package/server-managed/github-pulls.ts +2 -2
  61. package/server-managed/github-requests.ts +39 -0
  62. package/server-managed/http-response.ts +10 -2
  63. package/server-managed/http.ts +269 -143
  64. package/server-managed/index.ts +8 -7
  65. package/server-managed/kept-briefly.ts +37 -0
  66. package/server-managed/link-reports.ts +5 -1
  67. package/server-managed/npm-delta.ts +11 -6
  68. package/server-managed/npm-kept.ts +51 -7
  69. package/server-managed/npm-loads.ts +117 -35
  70. package/server-managed/npm-packages.ts +107 -14
  71. package/server-managed/npm-risk.ts +68 -18
  72. package/server-managed/pretty-print.ts +112 -35
  73. package/server-managed/pull-dependencies.ts +29 -9
  74. package/server-managed/pull-dependency-reviews.ts +8 -8
  75. package/server-managed/queue.ts +16 -0
  76. package/server-managed/rename-diff.ts +22 -13
  77. package/server-managed/report-sources.ts +1 -1
  78. package/server-managed/report-store.ts +50 -12
  79. package/server-managed/repository-actions.ts +15 -6
  80. package/server-managed/repository-agents.ts +1 -1
  81. package/server-managed/repository-browser.ts +123 -33
  82. package/server-managed/repository-code.ts +28 -11
  83. package/server-managed/repository-dependency-reviews.ts +41 -19
  84. package/server-managed/repository-history.ts +24 -8
  85. package/server-managed/repository-pulse.ts +9 -2
  86. package/server-managed/repository-risk-audit.ts +13 -0
  87. package/server-managed/repository-risk-read.ts +11 -6
  88. package/server-managed/repository-risk.ts +27 -20
  89. package/server-managed/session.ts +18 -4
  90. package/server-managed/solidity-entry-points.ts +5 -3
  91. package/server-managed/sql-postgres.ts +3 -0
  92. package/server-managed/sql.ts +6 -2
  93. package/server-managed/storage-db.ts +11 -3
  94. package/server-managed/storage-encryption.ts +7 -4
  95. package/server-managed/storage.ts +8 -4
  96. package/server-managed/team-feed.ts +3 -1
  97. package/server-managed/team-reports.ts +30 -13
  98. package/server-managed/uploads.ts +29 -9
  99. package/server-managed/upstream-cache.ts +12 -0
  100. package/server.ts +14 -5
  101. package/out/chunk-5DHL5NG3.js +0 -2
  102. package/out/chunk-6HNXNIQY.js +0 -52
  103. package/out/chunk-AFLZH7WG.js +0 -1
  104. package/out/chunk-NV7ES4EW.js +0 -1
  105. package/out/chunk-PTGDYLNS.js +0 -36
  106. package/out/chunk-Q6MVYGYV.js +0 -3
  107. package/out/chunk-QRD6GIG5.js +0 -229
  108. package/out/chunk-WI7Z5A2T.js +0 -6
  109. package/out/chunk-WQ74ZBZF.js +0 -7
  110. package/out/chunk-XVBEOGOS.js +0 -3
@@ -63,6 +63,9 @@ function entryId(entry) {
63
63
  // A file whose every link normalises away is still a links file; it
64
64
  // just has no links, which its view says plainly.
65
65
  export function parseLinkedFindings(content) {
66
+ // Only text opening an array can parse to one, so a report — which
67
+ // opens an object — is turned away without being parsed twice.
68
+ if (typeof content === 'string' && !/^\s*\[/u.test(content)) return null
66
69
  let data
67
70
  try { data = JSON.parse(content) } catch { return null }
68
71
  if (!Array.isArray(data) || data.length === 0) return null
@@ -5,6 +5,7 @@ export const FILE_HASH: RegExp
5
5
  export interface BundleIdentity { integrity: string; kind: string | null; size: number }
6
6
  export interface BundleDetails extends BundleIdentity { bundle?: unknown; json?: unknown; map?: SourceMap; edges?: readonly SourcemapEdge[] }
7
7
  export function parseBundleContents(text: string, identity: BundleIdentity): BundleDetails
8
+ export function computeBundleFileHashes(details: BundleDetails): Promise<Map<string, string>>
8
9
  export interface BundleMetadata extends Record<string, unknown> {
9
10
  files: [string, number | null, string | null, number | null][]
10
11
  codeStats: { files: number; lines: number; bytes: number }
@@ -174,7 +174,7 @@ export function parseBundleMetadata(data, integrity) {
174
174
  || [...unsized].some((path) => typeof path !== 'string' || !fileSizes.has(path) || fileSizes.get(path) !== null)) throw new Error('Invalid bundle metadata')
175
175
  const details = { integrity, kind: data.kind, size: data.size, metadataOnly: true, fileSizes, fileHashes, lineCounts, unsizedFiles: unsized, stale }
176
176
  if (data.kind === 'stasis') {
177
- details.bundle = Bundle.parse(JSON.stringify(data.bundle))
177
+ details.bundle = Bundle.fromJSON(data.bundle)
178
178
  const paths = details.bundle.sources
179
179
  if (paths.size !== fileSizes.size || [...paths.keys()].some((path) => !fileSizes.has(path))) throw new Error('Invalid bundle metadata inventory')
180
180
  // A file is hashed exactly when it is source: a resource has bytes and
@@ -282,15 +282,19 @@ export function bundleSourceSizes(details) {
282
282
  //
283
283
  // Returns null for sourcemap bundles (and anything without parsed
284
284
  // modules) — they carry no package metadata, so callers fall back to
285
- // the path heuristic alone.
285
+ // the path heuristic alone. Kept by the bundle, as its sources are:
286
+ // callers only read it.
287
+ const packageDirsCache = new WeakMap()
286
288
  export function bundlePackageDirs(details) {
287
289
  if (details?.kind !== 'stasis' || !details.bundle?.modules) return null
290
+ if (packageDirsCache.has(details.bundle)) return packageDirsCache.get(details.bundle)
288
291
  const map = new Map()
289
292
  for (const [dir, info] of details.bundle.modules) {
290
293
  for (const rel of Object.keys(info.files)) {
291
294
  map.set(dir === '.' ? rel : `${dir}/${rel}`, dir)
292
295
  }
293
296
  }
297
+ packageDirsCache.set(details.bundle, map)
294
298
  return map
295
299
  }
296
300
 
@@ -5,7 +5,7 @@
5
5
  //
6
6
  // Lines are numbered the way the diff numbers them: from zero, a final
7
7
  // newline ending the last line rather than starting an empty one.
8
- import { diff, parseDiff } from '@preventive/diff'
8
+ import { changeSet } from '@preventive/diff'
9
9
 
10
10
  export function textLines(text) {
11
11
  if (text === '') return []
@@ -25,10 +25,11 @@ const spacing = line => line.replace(/[ \t\n\v\f\r]+$/u, '').replaceAll(/[ \t\n\
25
25
 
26
26
  // Each `a[a0..a1)` replaced by `b[b0..b1)`. `ignoreWhitespace` is diff -b:
27
27
  // lines differing only in how much whitespace they have pair up as unchanged,
28
- // whitespace added or removed between other characters still a change.
28
+ // whitespace added or removed between other characters still a change. Those
29
+ // a unified diff with no context shows (horizon 0), found without printing
30
+ // one and reading it back.
29
31
  export function changeBlocks(before, after, ignoreWhitespace = false) {
30
- const text = diff(before, after, { format: 'unified', context: 0, whitespace: ignoreWhitespace ? 'change' : 'none' })
31
- return text ? (parseDiff(text)[0]?.blocks ?? []).map(({ a0, a1, b0, b1 }) => ({ a0, a1, b0, b1 })) : []
32
+ return changeSet(before, after, { horizon: 0, whitespace: ignoreWhitespace ? 'change' : 'none' }).map(({ a0, a1, b0, b1 }) => ({ a0, a1, b0, b1 }))
32
33
  }
33
34
 
34
35
  // Whether `blocks` take `before`'s lines to `after`'s: each in order and apart
@@ -32,7 +32,8 @@ export type Agent = string
32
32
  export interface AppAgent { id: string; name: string; avatar?: string }
33
33
  // How the server tells one: its fingerprint, a line of an artifact's texts
34
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.
35
+ // the logins GitHub names it by, none for one known by its id alone; its
36
+ // branches' prefix.
36
37
  export interface AppAgentMarks { id: string; fingerprint?: string; account?: { id: number; logins: readonly string[] }; prefix: string }
37
38
  // An artifact's author, as GitHub names its account: its login and id.
38
39
  export interface AgentAuthor { login: string; id: number }
@@ -120,7 +121,8 @@ export function labelAgents(labels: unknown[], ids: readonly string[]): Agent[]
120
121
  // The sessions and tasks `texts` link, whether they carry Claude's marks and
121
122
  // Codex's, and the agents of `apps` whose fingerprints start a line of them
122
123
  // (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;
124
+ // is, by its id and login both (its id alone where it names no login), or
125
+ // 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 {
@@ -129,7 +131,7 @@ export function agentSignals(texts: unknown[], apps: readonly AppAgentMarks[] =
129
131
  const lines = strings.flatMap(text => text.split('\n').map(line => line.trimStart()))
130
132
  const login = author?.login.toLowerCase()
131
133
  const authored = ({ account }: AppAgentMarks) => author !== null && account !== undefined && account.id === author.id
132
- && account.logins.some(name => name.toLowerCase() === login)
134
+ && (account.logins.length === 0 || account.logins.some(name => name.toLowerCase() === login))
133
135
  const labelled = labelAgents(labels, ['claude', 'codex', ...apps.map(app => app.id)])
134
136
  return { sessions: found(SESSION), tasks: found(CODEX_TASK), claude: labelled.includes('claude') || strings.some(text => CLAUDE_MARK.test(text)),
135
137
  codex: labelled.includes('codex') || strings.some(text => CODEX_MARK.test(trailerBlock(text))),
@@ -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,36 @@
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), known by its id alone, whatever GitHub names
25
+ // it, and drawn by its App's avatar, wherever its account or its fingerprint
26
+ // 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`), their first account, the one their work is authored by,
35
+ // and the 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: [] }], names: [], prefix: 'neo/', fingerprint: '🤖 Generated with [Neo](' },
36
49
  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]'] },
50
+ { id: 175728472, logins: ['Copilot', 'copilot-pull-request-reviewer', 'copilot-pull-request-reviewer[bot]'] }], names: ['Copilot'], prefix: 'copilot/' },
51
+ dependabot: { name: 'Dependabot', avatar: 'app-29110', accounts: [{ id: 49699333, logins: ['dependabot', 'dependabot[bot]'] }], names: ['dependabot[bot]'],
52
+ prefix: 'dependabot/' },
39
53
  actions: { name: 'GitHub Actions', avatar: 'app-15368', accounts: [{ id: 41898282, logins: ['github-actions', 'github-actions[bot]'] }], names: ['github-actions[bot]'] },
40
54
  cursor: { name: 'Cursor', accounts: [], names: ['Cursor Agent'], emails: ['cursoragent@cursor.com'] },
41
55
  } as const satisfies Record<string, GithubAgent>
@@ -50,6 +64,8 @@ for (const [agent, { accounts }] of agents) {
50
64
  for (const login of logins) byLogin.set(login.toLowerCase(), { agent, ids: [...byLogin.get(login.toLowerCase())?.ids ?? [], id] })
51
65
  }
52
66
  }
67
+ // The accounts known by their ids alone, no login of theirs: each its agent.
68
+ const byId = new Map(agents.flatMap(([agent, { accounts }]) => accounts.flatMap(({ id, logins }) => id !== undefined && logins.length === 0 ? [[id, agent] as const] : [])))
53
69
  const byName = new Map(agents.flatMap(([agent, { names }]) => names.map(name => [name.toLowerCase(), agent] as const)))
54
70
  const byEmail = new Map(agents.flatMap(([agent, { emails = [] }]) => emails.map(email => [email, agent] as const)))
55
71
 
@@ -60,13 +76,15 @@ export const emailAgent = (email: unknown): GithubAgentId | null => typeof email
60
76
  // The agent an author is: by their login, GitHub matching logins regardless
61
77
  // of case, their account's id the agent's where both are known, so another
62
78
  // 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.
79
+ // may be) is not; an account known by its id alone, by that, whatever its
80
+ // login; for an author GitHub names no account for, by the name they carry.
81
+ // Null for anyone else: a human's account is theirs, whatever their commits
82
+ // name them.
66
83
  export function githubAgent(login: string | null, account: number | null = null, name: string | null = null): GithubAgentId | null {
67
84
  if (typeof login !== 'string') return typeof name === 'string' ? byName.get(name.trim().toLowerCase()) ?? null : null
68
85
  const known = byLogin.get(login.toLowerCase())
69
- return known && (account === null || known.ids.includes(undefined) || known.ids.includes(account)) ? known.agent : null
86
+ if (known && (account === null || known.ids.includes(undefined) || known.ids.includes(account))) return known.agent
87
+ return account === null ? null : byId.get(account) ?? null
70
88
  }
71
89
 
72
90
  // 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-VL43BTSO.js";import{$e as s,Da as c,Ea as l,Fa as u,Ga as d,Ha as f,Ie as p,Ja as m,Je as h,Ka as g,Ke as _,Le as v,Me as y,Ne as b,Od as x,Oe as ee,Pe as te,Qe as ne,Re as re,Se as ie,Te as ae,Ue as oe,Ve as se,We as ce,Xe as le,Ye as ue,Ze as de,_e as fe,af as pe,bb as me,cb as S,ef as he,pa as C,sa as ge,sc as _e,sf as ve,ta as ye,tf as be,ua as xe,w,wa as Se,xa as Ce,ya as we,za as Te}from"./chunk-S6U2J62U.js";import"./chunk-JCIIBLKR.js";import"./chunk-VH4XMZIW.js";import"./chunk-ZGNMDGSB.js";import{M as Ee}from"./chunk-NOZJULWS.js";import"./chunk-6ANSHRFQ.js";import"./chunk-NRPC74AM.js";import"./chunk-7BKKYVWR.js";import"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import{a as De}from"./chunk-5AHIQFFG.js";import"./chunk-I2MDGSQX.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 ee=[];for(let e of _.slice(1)){let t=n?.has(e)?0:o.indexOf(e);if(t===-1||o[t]!==e){let t=p();s[t]=h(t),o[t]=e,x.add(t)}else ee.push(t)}let te=o[y]===null;for(let e of g.filter(e=>!i.has(e)))u.push({row:r,col:y,straight:te,color:b}),te=!1;for(let e=0;e<o.length;e++)o[e]??=null;if(d=Math.max(d,o.length),f){let e=m(f.sha);for(let[t,n]of o.entries())n!==null&&l.push({row:r,from:x.has(t)?y:t,to:n===f.sha?e:t,color:s[t]});for(let t of ee)l.push({row:r,from:y,to:o[t]===f.sha?e:t,color:s[t]})}for(;o.length>0&&o.at(-1)===null;)o.pop()}return{rows:c,segments:l,stubs:u,width:Math.max(d,+(c.length>0))}}function ze(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 Be=12,k=24,Ve=9,He=8,Ue=3,We=`a[href], .history-commit`,Ge=3e5,Ke=15e3,qe=3e4,Je=25,Ye=new Map,Xe=new Set,Ze=null,Qe=`all`,$e=new Set;function A(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Ze&&(Ye.clear(),$e.clear(),Ze=e),Ye}var j=()=>{for(let e of Xe)e.requestUpdate()};function et(e,t,n=new Set){let r={status:`ready`,until:Date.now()+Ge,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,openPulls:e.openPulls,loadingMore:!1,moreError:null,sought:n};return t?.(r),r}function tt(e,t,n){return ze(A(),e,()=>t(1),{ready:e=>et(e,n),failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+qe,error:e?.message||`The history could not be read.`,code:e?.code??null},retryMs:qe,repaint:j})}function nt(e,t,n,r,i){let a=t.sought;t.sought=new Set(a).add(i),t.refreshing=!0,n(1,null,!0).then(n=>{if(A().get(e)!==t)return null;let o=t.retried===i?0:Math.min(Number(n.retryIn)||0,Ke),s=et(n,r,o>0?a:t.sought);return o>0&&(Object.assign(s,{retried:i,retryAt:Date.now()+o}),setTimeout(j,o)),A().set(e,s),null},()=>null).finally(()=>{t.refreshing=!1,j()})}function rt(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,Je).map(([e])=>e);for(let t of e.next)e.asked.add(t);return e.more&&=e.next.length>0,e}function it(e,t,n,r){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+Ge,j(),n(t.page+1,t).then(n=>{if(A().get(e)!==t)return null;let i=new Set(t.commits.map(e=>e.sha));t.commits=[...t.commits,...n.commits.filter(e=>!i.has(e.sha))];let a=new Set(t.pulls.map(e=>e.merge));return t.pulls=[...t.pulls,...n.pulls.filter(e=>!a.has(e.merge))],t.page+=1,t.more=n.more===!0,r?.(t),t.until=Date.now()+Ge,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More commits could not be read.`),null)).finally(()=>{t.loadingMore=!1,j()}))}var at=/^[a-f\d]{40}$/u,ot=e=>typeof e?.sha==`string`&&at.test(e.sha)&&Array.isArray(e.parents);function st(e){if(!Array.isArray(e?.commits))throw Error(`The server answered with no history.`);let t=e.commits.filter(ot),n=Array.isArray(e.unread)?e.unread.filter(e=>typeof e?.name==`string`&&typeof e.sha==`string`&&at.test(e.sha)):[],r=Array.isArray(e.pulls)?e.pulls.filter(e=>typeof e?.merge==`string`&&at.test(e.merge)&&Number.isSafeInteger(e.number)&&typeof e.head==`string`&&at.test(e.head)&&Array.isArray(e.commits)).map(e=>({...e,commits:e.commits.filter(ot)})):[],i=Array.isArray(e.openPulls)?e.openPulls.filter(e=>Number.isSafeInteger(e?.number)&&typeof e.sha==`string`&&at.test(e.sha)):[];return{...e,commits:t,unread:n,pulls:r,openPulls:i}}function ct(e,t,n){let r=lt(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 lt(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 ut=6e4,dt=60*ut,ft=24*dt;function M(e,t=Date.now()){if(e==null)return``;let n=t-e;if(n>=-ut&&n<ut)return`now`;if(n>0&&n<dt)return`${Math.floor(n/ut)}m`;if(n>0&&n<ft)return`${Math.floor(n/dt)}h`;if(n>0&&n<7*ft)return`${Math.floor(n/ft)}d`;let r=new Date(e);return r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(t).getFullYear()?{}:{year:`numeric`}})}function pt({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 mt(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 N=e=>Ve+e*Be,ht=e=>e*k+k/2;function gt({row:e,from:t,to:n}){let[r,i,a,o]=[N(t),N(n),ht(e),ht(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 _t=({row:e,col:t,straight:n})=>n?`M${N(t)} ${ht(e)+6}v${k*.55}`:`M${N(t)+4} ${ht(e)+5}l${Be*.6} ${k*.5}`;function vt(e,t){let n=Array.from({length:He},()=>[]);for(let t of e.segments)n[t.color].push(gt(t));let r=Array.from({length:He},()=>[]);for(let t of e.stubs)r[t.color].push(_t(t));let i=Ve*2+(e.width-1)*Be;return E`<svg class="history-graph" width="${i}" height="${e.rows.length*k}" 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=${N(n)} cy=${ht(i)}
2
+ r=${e.sha===t?4.5:e.parents.length>1?3:3.5}/>`)}</svg>`}function yt(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(Ue);return E`<span class="history-refs" style="${T({"--ref":`var(--lane-${t})`})}">${e.slice(0,Ue).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 bt(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)=>c(n,a?``:r,i,{page:e,all:a,...s?{fresh:!0}:{},...t!==`path`&&e>1?{from:o.next}:{}}).then(e=>{if(!a&&e?.commit!==r)throw Error(`The server answered with another revision's history.`);return st(e)}),l=t===`path`?null:rt,u=tt(o,s,l);return a&&u.status===`ready`&&!u.refreshing&&!u.sought.has(r)&&!(u.retryAt>Date.now())&&!lt(u.commits,u.pulls??[]).some(e=>e.sha===r)&&nt(o,u,s,l,r),a&&u.status===`error`&&u.code===`github-token-required`?($e.add(n),bt(e,`revision`)):{mode:t,key:o,entry:u,more:()=>it(o,u,s,l)}}var xt=e=>bt(e,e.path?`path`:`revision`),St=e=>{Xe.add(e)},Ct=e=>{Xe.delete(e)};function wt(e){A().delete(e),j()}var Tt=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(),Xe.add(this)}disconnectedCallback(){super.disconnectedCallback(),Xe.delete(this),this._moreButton&&S(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.history-more > button`);this._moreButton&&this._moreButton!==e&&S(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`:(A(),$e.has(e)?`revision`:Qe)}history(e){return bt(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`?ct(t.commits,t.pulls??[],a):lt(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:He});return this._drawn={commits:t.commits,pulls:t.pulls,mode:e,defaultBranch:n,layout:c},c}pick(e){Qe=e,j()}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`);ve({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(We)]:[],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(${We})`))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">${x(`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="${()=>{A().delete(t),j()}}">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=be(this.repository,this.refs),s=pt(t,i),c=Math.max(0,r.rows.findIndex(e=>e.commit.sha===a)),l=Ve*2+(r.width-1)*Be,u=this.repo??this.repository.repo,d=u?`https://github.com/${u.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":`${l}px`})}">${vt(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),l=e.sha.slice(0,7);return E`<li class="${De({"history-row":!0,"is-shown":e.sha===a})}">${d?E`<a class="history-sha" href="${`${d}/commit/${e.sha}`}" target="_blank" rel="noopener noreferrer" tabindex="-1" aria-label="${`Commit ${l} on GitHub`}">${l}</a>`:E`<code class="history-sha">${l}</code>`} ${yt(r,t,o,d)} <span class="history-subject" id="${`history-subject-${e.sha}`}">${mt(e.subject||`(no message)`,d)}</span> <button type="button" class="history-commit" id="${`history-commit-${e.sha}`}" tabindex="${n===c?0:-1}" aria-labelledby="${`history-subject-${e.sha} history-commit-${e.sha}`}" aria-current="${e.sha===a?`true`:O}" @click="${()=>this.open(e,r)}"><span class="history-author">${Te(e.authorLogin,e.authorName,e.coauthors)}</span> ${i?E`<time class="history-time" datetime="${i.toISOString()}">${M(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`,Tt);function Et(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 Dt=e=>e.head&&e.fork?`${e.fork}:${e.head}`:e.head,Ot=e=>[...e.agents,...e.sessions.length>0||e.claude?[`claude`]:[],...e.tasks.length>0||e.codex?[`codex`]:[]],kt=new Set([`claude`,`codex`]);function At({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,Ot(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}=Et(e.name);n&&s(t,[n])}let u=new Map;for(let t of e){let e=Dt(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}=Et(t.head);n&&s(e,[n]);let i=Dt(t);if(t.signals.agents.length>0){i!==null&&u.get(i)===t.number&&a(e,`branch:${i}`);continue}i&&(n||Ot(t.signals).length>0||l.has(i))&&a(e,`branch:${i}`),r&&a(e,`pull:${r}`)}for(let e of t)c(`commit:${e.oid}`,e.signals);let d=new Map;for(let e of r.keys()){let t=i(e),n=d.get(t)??{agents:new Set,keys:[]};n.keys.push(e);for(let t of o.get(e)??[])n.agents.add(t);d.set(t,n)}return[...d.values()]}var jt=e=>(t,n)=>(e(t)??0)-(e(n)??0);function Mt({agents:e,keys:t},{pulls:n,commits:r,issues:i,branches:a}){if(e.size===0)return null;let o=e=>t.filter(t=>t.startsWith(e)).map(t=>t.slice(e.length)),s=o(`pull:`).flatMap(e=>n.get(Number(e))??[]).toSorted(jt(e=>e.createdAt)),c=o(`commit:`).flatMap(e=>r.get(e)??[]).toSorted(jt(e=>e.at)),l=[...new Set([...o(`branch:`),...s.flatMap(e=>Dt(e)??[])])],u=[...new Set([...s.flatMap(e=>e.closes),...s.flatMap(e=>Et(e.head).issue??[]),...o(`branch:`).flatMap(e=>Et(e).issue??[])])].flatMap(e=>i.get(e)??[]).toSorted(jt(e=>e.createdAt)),d=l.flatMap(e=>a.get(e)??[]),f=[...s,...c,...u,...d];if(f.length===0)return null;let[p,m]=[o(`task:`),o(`session:`)],h=f.flatMap(e=>(`createdAt`in e?e.createdAt:e.at)??[]),g=f.flatMap(e=>(`updatedAt`in e?e.updatedAt:e.at)??[]),_=new Set(s.map(e=>e.state)),v=[...s.map(e=>({at:e.createdAt,title:e.title})),...c.map(e=>({at:e.at,title:e.title}))].toSorted(jt(e=>e.at))[0],y=[...s,...c];return{id:m[0]??p[0]??(s[0]?`pull-${s[0].number}`:c[0]?.oid??l[0]??``),agents:[...[...e].filter(e=>!kt.has(e)),...[`claude`,`codex`].filter(t=>e.has(t))],sessions:m,tasks:p,title:v?.title??u[0]?.title??l[0]??``,authors:[...new Set(f.flatMap(e=>e.author??[]))],startedAt:h.length>0?Math.min(...h):null,updatedAt:g.length>0?Math.max(...g):null,state:_.has(`open`)?`open`:_.has(`merged`)||c.length>0?`merged`:_.has(`closed`)?`closed`:`branch`,pulls:s.map(({number:e,title:t,state:n,draft:r})=>({number:e,title:t,state:n,draft:r})).toReversed(),commits:c.map(({oid:e,title:t})=>({oid:e,title:t})).toReversed(),issues:u.map(({number:e,title:t,state:n})=>({number:e,title:t,state:n})),branches:l,commitCount:s.reduce((e,t)=>e+t.commits,0)+c.length,additions:y.reduce((e,t)=>e+t.additions,0),deletions:y.reduce((e,t)=>e+t.deletions,0)}}function Nt(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 At(e).flatMap(e=>Mt(e,n)??[]).filter(e=>!r(e)).toSorted(jt(e=>e.updatedAt)).toReversed()}var Pt=3e5,Ft=/^[a-z][a-z\d-]{0,31}$/u,It=/^(?:app|user)-[1-9]\d{0,11}$/u,Lt=3e4,Rt=12,zt=new Map,Bt=new Set,Vt=null,Ht=`all`;function Ut(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Vt&&(zt.clear(),Vt=e),zt}var Wt=()=>{for(let e of Bt)e.requestUpdate()};function Gt(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`&&Ft.test(e.id)&&![`claude`,`codex`,`all`].includes(e.id)&&typeof e.name==`string`&&e.name.trim()&&(e.avatar===void 0||typeof e.avatar==`string`&&It.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`&&Ft.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 Kt=e=>Object.assign(e,{sessions:Nt(e,{branchesSince:e.after?.pulls?Math.min(...e.pulls.map(e=>e.updatedAt??1/0)):null})});function qt(e,t){return ze(Ut(),e,()=>t(null).then(e=>(de(e.agents),e)),{ready:e=>Kt({status:`ready`,until:Date.now()+Pt,...e,loadingMore:!1,moreError:null}),failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+Lt,error:e?.message||`The agents' work could not be read.`},retryMs:Lt,repaint:Wt})}function Jt(e,t,n){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+Pt,Wt(),n(t.after).then(n=>{if(Ut().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()+Pt;let a=t.sessions.length;return Kt(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,Wt()}))}function Yt(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(ye),...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 Xt={open:`open`,merged:`merged`,closed:`closed`,branch:`draft`},Zt=e=>(e.agents??[]).map(e=>e.id).filter(t=>(e.sessions??[]).some(e=>e.agents.includes(t))),Qt=e=>[`claude`,`codex`,...Zt(e)],$t=[[`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 en(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 tn(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 nn(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 rn=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(),Bt.add(this)}disconnectedCallback(){super.disconnectedCallback(),Bt.delete(this),this._moreButton&&S(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.issues-more > button`);this._moreButton&&this._moreButton!==e&&S(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=>d(e,t??{}).then(Gt),r=qt(t,n);return{key:t,entry:r,more:()=>Jt(t,r,n)}}pick(e){Ht=e,Wt()}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=Qt(t).includes(Ht)?Ht:`all`,c=Yt(i,o,this._filter);return E`<div class="history-bar issues-bar">${x(`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> ${Qt(t).map(e=>E`<button type="button" class="${`agent-pick is-${e}`}" aria-pressed="${String(o===e)}" @click="${()=>this.pick(e)}">${s(e)}${fe(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?tn(en(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="${()=>{Ut().delete(e),Wt()}}">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">${[...Zt(e),`claude`,`codex`].filter(n).map(n=>{let r=nn(e.sessions,n);return E`<span class="agent-stats" role="group" aria-label="${fe(n)}"><span class="${`agent-mark is-${n}`}">${s(n)}</span> ${$t.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`:`${fe(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=>!Se(e)),a=e.pulls.length+e.commits.length,o=a!==e.pulls.length+e.commits.length,c=r?E`<time datetime="${r.toISOString()}">${M(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-${Xt[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="${fe(e)}">${s(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,Rt).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`,rn);var an=3e5,on=3e4,sn=1e3,cn=5,ln=5e3,un=12,P=864e5,F=7*P,dn=8,fn=3,pn=[[1,`Week`,`the week before`],[4,`Month`,`the month before`],[13,`Quarter`,`the quarter before`],[52,`Year`,`the year before`]],mn=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],hn=[1,2,3,4,5,6,0],gn=6,_n=new Map,vn=new Map,yn=new Map,bn=new Map,xn=new Set,Sn=null,I=4,Cn={pulls:`merged`,issues:`closed`},wn={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:`]]]},Tn=[`merged`,`opened`,`closed`,`created`],En=te(D`<circle cx="8" cy="8" r="2.75"/><path d="M8 1v4.25M8 10.75V15"/>`),Dn={agent:`Commit with agents`,without:`Commit without agents`,release:`Release`},On=10,kn=10;function L(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Sn&&(_n.clear(),vn.clear(),yn.clear(),bn.clear(),Sn=e),_n}var R=()=>{for(let e of xn)e.requestUpdate()},z=e=>Number.isSafeInteger(e)&&e>=0?e:0,An=(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 jn(e){if(!Number.isSafeInteger(e?.since)||!pn.some(([t])=>t===e.weeks))throw Error(`The server answered with no period.`);let t=t=>An(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:hn.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(Dn,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 Mn(e,t){yn.set(e,t),t.answer.stats&&bn.set(e,t.answer)}var B=e=>e.reading??e.pulls,Nn=e=>B(e)===null?e.pending?[ln,un]:null:[sn,cn];function Pn(e,t){let n=`${e}\0${t}`;return ze(L(),n,()=>m(e,t).then(jn),{ready:e=>({status:`ready`,until:Date.now()+an,answer:e,tries:0,asking:!1}),settled:r=>{Mn(e,r),Nn(r.answer)&&Fn(n,r,e,t,Nn(r.answer)[0])},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+on,error:e?.message||`The repository’s pulse could not be read.`},retryMs:on,repaint:R})}function Fn(e,t,n,r,i){t.asking=!0,setTimeout(()=>{L().get(e)===t&&m(n,r).then(jn).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()+an,t.tries=a?0:t.tries+1;let o=Nn(i);return o&&t.tries<o[1]?Fn(e,t,n,r,o[0]):t.asking=!1,null},()=>(t.asking=!1,null)).finally(R)},i)}function In(e,t,n){return L(),ze(vn,[e,t,n.from,n.to??``,n.authors.join(`,`)].join(`\0`),()=>g(e,t,n),{ready:e=>({status:`ready`,until:Date.now()+an,answer:Object.fromEntries(Tn.map(t=>[t,An(e,t)]))}),failed:e=>({status:`error`,until:Date.now()+on,error:e?.message||`These couldn’t be read.`}),retryMs:on,repaint:R})}var Ln=e=>e.agents===!0&&e.weeks.some(e=>e.agentDays.some(e=>e>0)),Rn=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 zn(e,t=Date.now()){let n=Math.floor(t/P)*P;return n-new Date(n).getUTCDay()*P-(e-1)*F}function Bn(e,t,n,r=Date.now()){return{weeks:n,since:e?.since??zn(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 Vn(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:Un(n.contributors,r).length}}function Hn({id:e=null,login:t,name:n}){let r=Se(t,n);if(r)return`agent:${r}`;let i=ge(t)?.id;return i==null?e===null?t?`@${t.toLowerCase()}`:`=${n}`:`#${e}`:`user:${i}`}function Un(e,t,n=1/0){let r=new Map;for(let i of e){let{login:e,name:a}=i,o=Hn(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 Wn(e,t){let n=e.contributors.filter(e=>Hn(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 Gn(e,t,n,r=null,i=Date.now()){let a=r===null?e:Wn(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||Hn(e)===r));return{count:V(a.weeks,t,o,`directDays`),items:s}}function Kn(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 qn(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 Jn(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`),Yn=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),U=e=>Yn.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`}),Xn=e=>new Date(e).toISOString().slice(0,10),Zn=(e,t)=>new Date(e).getUTCFullYear()!==new Date(t).getUTCFullYear(),Qn=(e,t)=>{let n=Math.floor(t/P)*P,r=Zn(e,n);return e>=n?G(n,r):`${G(e,r)} \u2013 ${G(n,r)}`},K=(e,t)=>e.day?new Date(e.from).toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,...Zn(e.from,t)?{year:`numeric`}:{},timeZone:`UTC`}):`Week of ${G(e.from,Zn(e.from,t))}`,$n=(e,t,n={})=>`${K(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 er(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 tr=(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}`,nr=(e,t)=>e===0?0:e===t?100:Math.min(99,Math.max(1,Math.round(e/t*100)));function rr(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 ir=(e,t,n)=>e===t?`Same as ${n}`:`${e>t?`↑`:`↓`} from ${t}% ${n}`,ar=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>`,or=e=>e.endsWith(`[bot]`)?`https://github.com/apps/${encodeURIComponent(e.slice(0,-5))}`:`https://github.com/${encodeURIComponent(e)}`,sr=e=>e.login?Ce(e.login,e.name,e.login):Ce(null,e.name),cr=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(),xn.add(this)}disconnectedCallback(){super.disconnectedCallback(),xn.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){Cn[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,Fn(t,n,e,I,0),R())}render(){if(!this.repository)return O;let{repoId:e}=this.repository,t=Pn(e,I);t.status===`ready`&&Mn(e,t);let n=Date.now(),r=t.status===`ready`?t.answer:null,i=bn.get(e),a=r?.stats?r:i&&t.status!==`error`?Bn(r,i,I,n):r,o=!a&&t.status===`loading`?yn.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">${x(`pulse`)}<div class="history-modes" role="group" aria-label="Period">${pn.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">${Qn(s.answer.since,n)}</span>`:O} ${c?E`<span class="pulse-updating" role="status">${this.renderWaiting(s,rr(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=pn.find(([e])=>e===n.weeks)[2],i=Vn(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),tr(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??tr(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||!Ln(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,rr(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?`–`:`${nr(e.agents,n)}%`,e.previousAgents===null||n===0||!r?null:ir(nr(e.agents,n),nr(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=>Hn(e)===this._person)??null,i=r?Wn(n.stats,this._person):n.stats,a=Kn({...n,stats:i},t),o=a[0]?.day?`day`:`week`,s=r?we(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)}">${sr(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=Jn(Math.max(...a.map(e=>e.commits))),d=i.lines===!0&&a.every(e=>e.additions!==null)?Jn(Math.max(...a.flatMap(e=>[e.additions,e.deletions]))):null,f={agents:Ln(n.stats)&&a.some(e=>e.agents!==null),releases:Rn(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?$n(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`:``}">${er(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?$n(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]=qn(o,e.stats.contributors),d=a?Un(e.stats.contributors,c,l).slice(0,fn):[],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">${K(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">${sr(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=Kn(e,t).find(e=>e.from===this._picked)??null,[i,a,o]=r?qn(r,n):[e.since,1/0,!1],s=Un(n,i,a),c=s[0]?.commits??1,l=e.stats.lines===!0,u=r?o?`Week of ${G(i,Zn(i,t))}`:K(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,dn)).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)}">${sr(e)}</button> ${e.login?E`<a class="pulse-rank-profile" href="${or(e.login)}" target="_blank" rel="noopener noreferrer" aria-label="${`${we(e.login,e.name)} on GitHub`}">${ar}</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>dn?E`<button type="button" class="history-link pulse-more" @click="${()=>{this._everyone=!this._everyone}}">${this._everyone?`Fewer`:`and ${W(s.length-dn,`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">${mn[hn[t]].slice(0,3)}</span>${e.map((e,r)=>{let i=`${mn[hn[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*gn)}`}" 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:gn},(e,t)=>E`<span class="${`pulse-cell is-${t+1}`}"></span>`)}More</div></figure>`}renderLists(e,t,n){let r=e.stats?Gn(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?Gn(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?we(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,On),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?Dn[e.kind]:`Commit`}">${En}</span> <span class="pulse-item-title">${e.subject||`(no message)`}</span> <span class="pulse-item-meta"><span>${e.sha.slice(0,7)}</span><span>${sr(e)}</span><time datetime="${new Date(e.at).toISOString()}">${M(e.at)}</time></span></a></li>`)}</ol>`} ${e.items.length>On?E`<button type="button" class="history-link pulse-more" @click="${()=>{this._allDirect=!this._allDirect}}">${this._allDirect?`Fewer`:`and ${W(e.items.length-On,`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:Kn(e,t).find(e=>e.from===this._picked)??null,r=this._person===null||!e.stats?null:e.stats.contributors.filter(e=>Hn(e)===this._person);if(!n&&!r)return null;let i=[...new Set((r??[]).flatMap(e=>e.login?[e.login]:[]))].slice(0,kn);return{from:Xn(n?.from??e.since),to:n?Xn(n.to-P):null,authors:i,nobody:r!==null&&i.length===0,who:r?.[0]??null,when:n?n.day?`on ${K(n,t)}`:`in the w${K(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]=wn[t],[a,,o]=i.find(([e])=>e===Cn[t]),s=n&&!n.nobody?In(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}`:`>=${Xn(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?we(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()}">${M(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`,cr);var lr=864e5,ur=[100,300,1e3];function dr(e,t){return Ie(e).filter(e=>e.parents.length<=1&&Number.isFinite(e.committedAt)).slice(0,t).toReversed()}var fr=1,pr=.08,mr=.6;function hr(e){let t=[];for(let[n,r]of e.entries()){let i=n===0?0:(r.committedAt-e[n-1].committedAt)/lr;t.push(n===0?0:t[n-1]+Math.min(mr,Math.max(pr,i*fr)))}return t}function gr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n>0?t.slice(n+1).toLowerCase():``}function _r(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 vr=.9,yr=2,br=1,xr=5,Sr=1,Cr=.06;function wr(){let e=Tr(``,null);return{root:e,dirs:new Map([[``,e]]),files:new Map,going:new Set,users:new Map,beams:[],due:[],layout:!0}}function Tr(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 Er(e,t){let n=e.dirs.get(t);if(n)return n;let r=t.lastIndexOf(`/`),i=Er(e,r===-1?``:t.slice(0,r)),a=Tr(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),Ur(i),e.layout=!0,a}function Dr(e,t,n,r){let i=e.files.get(t);if(n===`D`&&!i)return null;if(!i){let a=t.lastIndexOf(`/`),o=Er(e,a===-1?``:t.slice(0,a));i={path:t,name:t.slice(a+1),extension:gr(t),dir:o,ox:0,oy:0,touched:r,kind:n,removed:null},o.files.push(i),e.files.set(t,i),Ur(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 Or(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);Ur(r),e.layout=!0}var kr=e=>e.flatMap(([e,t,n])=>t===`R`?[[n,`D`],[e,`A`]]:[[e,t]]);function Ar(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=kr(n),s=o.length>1?Math.min(Cr,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 jr(e,t){for(let[n,r]of kr(t)){let t=Dr(e,n,r,-1/0);t&&r===`D`&&Or(e,t)}}function Mr(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 Nr(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=Dr(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<vr);for(let n of[...e.going])t-n.removed>=br&&Or(e,n);for(let[n,r]of e.users)t-r.active>xr+Sr&&e.users.delete(n)}var Pr=6,Fr=2.2,Ir=12,Lr=Math.PI*(3-Math.sqrt(5)),Rr=46,zr=34,Br=e=>e===0?0:Pr*.62*Math.sqrt(e)+Fr;function Vr(e){let t=Pr*.62*Math.sqrt(e+.5);return[t*Math.cos(e*Lr),t*Math.sin(e*Lr)]}function Hr(e){Wr(e.root),Gr(e.root,-e.root.node[0],-e.root.node[1],0),e.layout=!1}function Ur(e){for(let t=e;t&&!t.dirty;t=t.parent)t.dirty=!0}function Wr(e){if(!e.dirty)return;for(let t of e.dirs)Wr(t);e.cluster=Math.max(Br(e.files.length),Fr)+Ir/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)ii(t,n);else{Kr([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=Zr([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 Gr(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);Gr(t,n,r,Math.atan2(r-e.ty,n-e.tx))}}function Kr(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(Jr(r.c,n)){a=r,i.next=a,a.previous=i,t--;continue e}o+=r.c.r,r=r.next}else{if(Jr(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=Yr(i);for(let e=l.next;e!==a;e=e.next){let t=Yr(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 Jr=(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 Yr(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 Xr=64;function Zr(e){let t=e.toSorted((e,t)=>J(`${e.x},${e.y}`)-J(`${t.x},${t.y}`)),n=[],r=null,i=0;for(let a=0;a<t.length;a++)if(!(r&&ti(r,t[a]))){if(n=$r(n,t[a]),r=q(n),!Number.isFinite(r.x+r.y+r.r)||++i>Xr*t.length)return Qr(e);a=-1}return r}function Qr(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 $r(e,t){if(e.every(e=>ti(t,e)))return[t];for(let n of e)if(!ei(t,n)&&e.every(e=>ti(q([n,t]),e)))return[n,t];for(let[n,r]of e.entries())for(let i of e.slice(n+1))if(!ei(q([r,i]),t)&&!ei(q([r,t]),i)&&!ei(q([i,t]),r)&&e.every(e=>ti(q([r,i,t]),e)))return[r,i,t];return[...e,t].length<=3?[...e,t]:[t]}var ei=(e,t)=>e.r-t.r>=0&&(e.r-t.r)**2>=(t.x-e.x)**2+(t.y-e.y)**2;function ti(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 q([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 ni=60,ri=.5;function ii(e,t){let n=t.filter(e=>e.x!==void 0);for(let r of t)r.x===void 0&&(ai(r,e,n),n.push(r));for(let n=0;n<ni;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-ri)continue;let a=t>1e-6?Math.atan2(r.y,r.x):J(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-ri)continue;let c=Math.hypot(o,s);if(c>=a-ri)continue;let l=c>1e-6?Math.atan2(s,o):J(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 ai(e,t,n){let r=r=>Math.hypot(r.x,r.y)>=t.r+e.r-ri&&n.every(t=>Math.hypot(t.x-r.x,t.y-r.y)>=t.r+e.r-ri),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=J(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 oi(e,t,n=zr){let r=e=>1-Math.exp(-t*e),i=r(3),a=r(6),o=r(2.5);for(let t of e.dirs.values()){t.x+=(t.tx-t.x)*i,t.y+=(t.ty-t.y)*i;for(let[e,n]of t.files.entries()){let[t,r]=Vr(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=J(e.key);[e.x,e.y]=[n+Math.cos(t)*Rr*3,r+Math.sin(t)*Rr*3]}let i=Math.hypot(e.x-n,e.y-r)||1,[a,s]=[n+(e.x-n)/i*Rr,r+(e.y-r)/i*Rr];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(J(r.key)),Math.sin(J(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 J(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 si(e){e.layout&&Hr(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]=Vr(e)}}function ci(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,Br(t.files.length)+Fr);for(let t of e.users.values())Number.isNaN(t.x)||n(t.x,t.y,14);return t}var li=[.5,1,2,4,8],ui=20,di=50,fi=8,pi={side:40,top:64,bottom:40},mi=3,hi=10,Y=11,gi=72,_i=250,vi=1.8,yi=2,bi=new Set([`A`,`M`,`D`,`R`]),xi=new Map,Si=new Map,Ci=new Set,wi=new Map,Ti=new Set,Ei=new Map,Di=null,Oi=300,ki=1;function Ai(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==Di&&(xi.clear(),Si.clear(),Ci.clear(),wi.clear(),Di=e),xi}var ji=()=>{for(let e of Ti)e.requestUpdate()},Mi=()=>globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0;function Ni(e,t){let{repoId:n,commit:r,path:i}=e,a=`${n}\0${r}\0${i}\0${t}`,o=Ai().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:wr(),clock:0,next:0,playing:!1,waiting:!1,ended:!1,started:!1};return xi.set(a,s),s}var Pi={files:[],cut:!1},Fi=e=>e.commits[0]?.parents[0]??null,Ii=e=>`${e.repoId}\0${e.path}\0${Fi(e)}`,X=e=>Fi(e)?wi.get(Ii(e)):Pi,Z=(e,t)=>`${e.repoId}\0${e.path}\0${t}`,Q=(e,t)=>Si.get(Z(e,t)),Li=(e,t)=>Ci.has(Z(e,t)),Ri=(e,t)=>wi.get(Z(e,t)),zi=(e,t)=>!(!Q(e,t.sha)||Li(e,t.sha)&&!Ri(e,t.sha));function Bi(e){let t=0;for(;t<(e.commits?.length??0)&&zi(e,e.commits[t]);)t++;return t}function Vi(e,t){if(!Array.isArray(e)||!bi.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 Hi(e){let t=X(e),n=e.commits.filter(t=>Q(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(gr(t),(e.counts.get(gr(t))??0)+1);for(let e of t?.files??[])i(e);for(let t of n)for(let[n,r]of kr(Q(e,t.sha)))r!==`D`&&i(n);_r(e.colors,e.counts,fi)}function Ui(e){if(e.treeReading||e.error)return;let t=[...e.commits.slice(e.next),...e.commits.slice(0,e.next)],n=Fi(e)&&!X(e),r=n?Fi(e):t.find(t=>Li(e,t.sha)&&!Ri(e,t.sha))?.sha;if(!r)return;e.treeReading=!0;let i=Z(e,r);u(e.repoId,e.path,r).then(t=>{if(Ai().get(e.key)!==e)return null;let r=Array.isArray(t?.files)?t.files.map(t=>Vi([t,`A`],e.path)?.[0]).filter(Boolean):[];return wi.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,ji()})}function Wi(e,t,n){let r=Q(e,n.sha),i=Li(e,n.sha)?Ri(e,n.sha):null;return i?[...r,...Mr(t,i.files,i.cut,kr(r))]:r}function Gi(e,t){let n=wr();n.start=X(e),jr(n,n.start.files.map(e=>[e,`A`]));for(let r of e.commits.slice(0,t))jr(n,Wi(e,n,r));return si(n),n}function Ki(e){if(e.reading||e.error||!e.commits)return;let t=Bi(e)===0?ui:di,n=[...e.commits.slice(e.next),...e.commits.slice(0,e.next)].filter(t=>!Q(e,t.sha)).slice(0,t).map(e=>e.sha);n.length!==0&&(e.reading=!0,l(e.repoId,e.path,n).then(t=>{if(Ai().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)Si.set(Z(e,t),Array.isArray(r.get(t)?.files)?r.get(t).files.map(t=>Vi(t,e.path)).filter(Boolean):[]),r.get(t)?.more===!0&&Ci.add(Z(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,ji()}))}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(C,i)?i:Se(n,r),a=e?null:ge(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?C[e].name:a?a.name??a.login:r??n,c=e?C[e].mark??null:null,l=e?!c&&C[e].avatar?`/api/avatar/${C[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 Ji={anthropic:[Ae,4,5,8],openai:[je,4,5,8],"github-copilot":[Me,0,0,24]},Yi={claude:[`#d97757`,`#fff`],codex:[`#fff`,`#000`],copilot:[`#0d1117`,`#fff`]},Xi=new Map,Zi=e=>Xi.get(e)??Xi.set(e,new Path2D(Ji[e][0])).get(e);function Qi(e){let t=Ei.get(e);return t||(t=new Image,t.decoding=`async`,t.src=e,Ei.set(e,t)),t.complete&&t.naturalWidth>0?t:null}var $=e=>e.toLocaleString(`en-US`),$i=e=>new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),ea=e=>e===.5?`½×`:`${e}\xD7`,ta=D`<path d="M5 3.25v9.5L12.75 8z" fill="currentColor"/>`,na=D`<path d="M5.25 3.5v9M10.75 3.5v9"/>`,ra=D`<path d="M3.25 8a4.75 4.75 0 1 0 1.4-3.36M3.25 2.5v2.75H6"/>`,ia=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(),Ti.add(this),St(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(),Ti.delete(this),Ct(this),this._themes?.abort(),this._resize?.disconnect(),cancelAnimationFrame(this._frame),this._frame=null,this.replay&&![...Ti].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}=xt(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=dr(t.commits,e.count),e.times=hr(e.commits)}Ui(e),Ki(e);let t=X(e);t&&(Hi(e),e.scene.start!==t&&this.seek(e.next),!e.started&&Bi(e)>0&&(e.started=!0,e.playing=!Mi(),this.requestUpdate()))}pickCount(e){Oi=e,ji()}pickSpeed(e){ki=e,ji()}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||!X(t))return;let n=Math.max(0,Math.min(e,Bi(t)));Object.assign(t,{scene:Gi(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)&&(Nr(n.scene,n.clock),n.scene.layout&&e-this._laidOut>=_i&&(Hr(n.scene),this._laidOut=e),oi(n.scene,t,Math.max(zr,gi/(this._camera?.zoom??1))),this.draw(n,t)))}play(e,t){let n=e.clock+t*ki,r=e.waiting;for(e.waiting=!1;e.next<e.commits.length&&e.times[e.next]<=n;){let t=e.commits[e.next];if(!zi(e,t)){n=e.times[e.next],e.waiting=!0;break}let r=e.times[e.next],i=(e.times[e.next+1]??r+mr)-r;Ar(e.scene,qi(t),Wi(e,e.scene,t),r,i*.8),e.next++}e.clock=n,e.next>=e.commits.length&&n>(e.times.at(-1)??0)+yi&&(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:fi},(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,Fr*u.zoom),g=h<vi,_=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<yr){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)/yr),n=e.removed===null?1:Math.max(0,1-(l-e.removed)/br);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)/vr)*.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>yr||b(e.name,d(e.x)+Math.max(6,(Br(e.files.length)+3)*u.zoom),f(e.y));let x=v.filter(e=>e.removed===null);if(x.length<=hi){s.fillStyle=r.text;for(let e of x)s.globalAlpha=Math.max(0,1-(l-e.touched)/yr),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-xr)/Sr));let[i,a]=Object.hasOwn(Yi,e.agent)?Yi[e.agent]:[r.surface,r.text];s.fillStyle=i,s.beginPath(),s.arc(t,n,Y,0,2*Math.PI),s.fill();let o=e.image?Qi(e.image):null;if(e.mark&&Object.hasOwn(Ji,e.mark)){let[,r,i,o]=Ji[e.mark],c=Y*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(Zi(e.mark)),s.restore(),s.beginPath(),s.arc(t,n,Y,0,2*Math.PI)}else o?(s.save(),s.clip(),s.drawImage(o,t-Y,n-Y,Y*2,Y*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+Y+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=ci(e),a=Number.isFinite(i.minX),o=a?Math.max(.02,Math.min(mi,(t-2*pi.side)/Math.max(1,i.maxX-i.minX),(n-pi.top-pi.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-(pi.top-pi.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))<=Y+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=Ni(this.repository,Oi);this.replay&&this.replay!==e&&(this.replay.playing=!1),this.replay=e;let t=e.commits?null:xt(this.repository),n=e.commits?.length??0,r=Bi(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?X(e):null)?.cut||e.commits?.some(t=>Li(e,t.sha)&&Ri(e,t.sha)?.cut),s=e.commits&&n>0?`${$(n)} commit${n===1?``:`s`} by ${$(a)}, ${$i(e.commits[0].committedAt)} \u2013 ${$i(e.commits.at(-1).committedAt)}${o?`, drawn in part: more files than are read`:``}`:``;return E`<div class="history-bar">${x(`replay`)}<div class="history-modes" role="group" aria-label="Commits played">${ur.map(e=>E`<button type="button" aria-pressed="${String(Oi===e)}" @click="${()=>this.pickCount(e)}">Last ${$(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 ${$i(i.committedAt)}, ${$(e.next)} of ${$(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()}">${$i(i.committedAt)}</time> <span>${$(e.next)} of ${$(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:fi},(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">${mt(e.subject||`(no message)`,n)}</span> <span class="replay-commit-author">${Te(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="${()=>wt(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,ji()}}">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 ${$(e)} so far`:`Reading the history…`}</div>`}return e.commits.length===0?E`<div class="replay-status">No commits to play.</div>`:X(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 ${$i(e.commits[0].committedAt)}…</div>`}renderControls(e,t,n){let r=e.ended?`Play again`:e.playing?`Pause`:`Play`,i=n>0&&!!(e.commits&&X(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?ra:e.playing?na:ta}</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="${`${$(e.next)} of ${$(t)} commits`}" @input="${e=>this.seek(Number(e.target.value))}"></div><div class="history-modes" role="group" aria-label="Speed">${li.map(e=>E`<button type="button" aria-pressed="${String(ki===e)}" @click="${()=>this.pickSpeed(e)}">${ea(e)}</button>`)}</div></div>`}};customElements.get(`repository-replay`)||customElements.define(`repository-replay`,ia);var aa=3e5,oa=3e4,sa=8,ca=20,la=new Map,ua=new Set,da=null,fa={issues:`open`,pulls:`open`};function pa(){let e=w.managedSession?`${w.managedSession.id}\0${w.managedSession.role}`:null;return e!==da&&(la.clear(),da=e),la}var ma=()=>{for(let e of ua)e.requestUpdate()};p(e=>{for(let t of ua)(!e||t.repository?.repoId===e.repoId)&&t.requestUpdate()});function ha(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 ga(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 _a(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 va(e,t,n){return ze(pa(),e,()=>t(null),{ready:e=>{let t={status:`ready`,until:Date.now()+aa,...e,countsAt:e.readAt,loadingMore:!1,moreError:null};return n(t),t},failed:e=>e?.name===`AbortError`?null:{status:`error`,until:Date.now()+oa,error:e?.message||`The list could not be read.`},retryMs:oa,repaint:ma})}function ya(e,t,n,r){t.loadingMore||!t.more||(t.loadingMore=!0,t.moreError=null,t.until=Date.now()+aa,ma(),n(t.after).then(n=>{if(pa().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()+aa,null},e=>(e?.name!==`AbortError`&&(t.moreError=e?.message||`More could not be read.`),null)).finally(()=>{t.loadingMore=!1,ma()}))}function ba(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??``,ye(e.author)??``,e.head??``,...e.labels.map(e=>e.name)].join(`
4
+ `).toLowerCase();return n.every(e=>t.includes(e))})}var xa=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumSignificantDigits:2}),Sa=e=>e<1e3?String(e):xa.format(e);function Ca(e){let t=e.labels.length+(e.moreLabels??0),n=e.labels.slice(0,t>sa?sa-1:sa),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 wa={git:`from git`,tarball:`a tarball not npm’s registry’s`,integrity:`locked with no integrity`};function Ta({versions:e,count:t,unread:n,unchecked:r,cut:i}){let a=t-Math.min(e.length,ca);return[t>0?`${e.slice(0,ca).map(e=>`${e.name}${e.version?`@${e.version}`:``} (${wa[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 Ea(e){if(e.status!==`ready`)return O;let{versions:t,fresh:n,updated:r,more:i,toReview:a}=v(e),o=e.review?b(e).count:0,s=ee(e);if(t.length===0&&o===0&&!s)return O;let c=i?`+`:``,l=t=>{let n=y(t,e.review);return n===`unsupported`?`, can\u2019t be reviewed: ${wa[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-ca,f=[t.length>0?`New in its lockfiles: ${t.slice(0,ca).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: ${Ta(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 Da=class extends _e{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(),ua.add(this)}disconnectedCallback(){super.disconnectedCallback(),ua.delete(this),this._moreButton&&S(this._moreButton),this._moreButton=null}updated(){let e=this.querySelector(`.issues-more > button`);this._moreButton&&this._moreButton!==e&&S(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=>f(t,r,{state:e,after:i}).then(ha).then(e=>(n(t,e.items,e.readAt,r),e)),o=e=>_a(t,r,e),s=va(i,a,o);return{key:i,entry:s,more:()=>ya(i,s,a,o)}}pick(e){fa[this.kind]=e,ma()}render(){if(!this.repository)return O;let e=fa[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=pa().get(`${this.repository.repoId}\0${this.kind}\0${o}`),c=i?ga(this.repository.repoId,this.kind,e,n):null,l=c?c.counts:s?.status===`ready`?ga(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?ba(c.items,this._filter):[];return E`<div class="history-bar issues-bar">${x(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="${()=>{pa().delete(t),ma()}}">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`&&h(t)?_(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>${Sa(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()}">${M(t.updatedAt)}</time>`:O} </span>${t.labels.length>0||t.moreLabels>0?E`<span class="issue-labels">${Ca(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?Ea(a):O}</span>`}};customElements.get(`repository-issues`)||customElements.define(`repository-issues`,Da);
@@ -1,17 +1,17 @@
1
1
  import{f as e,g as t,j as n,k as r,l as i,m as a}from"./chunk-PXK7EU4V.js";var o=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: ?(.*?))?\n?$/u,s=/^\*{15,}(?: (.*?))?\n?$/u,c=/^\*{3} (\d+)(?:,(\d+))? \*{4}\n?$/u,l=/^--- (\d+)(?:,(\d+))? ----\n?$/u,u=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n?$/u,d=t,f=t?new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:p}=String.prototype;function m(e,t,n){if(t||e.length===n.length)return n;if(p){if(p.call(e))return n;throw TypeError(i)}let r=0,a=n.length-3;for(;r<=a;){let t=n.indexOf(239,r);if(t===-1||t>a)break;if(r=t+1,n[t+1]===191&&n[t+2]===189){if(e===g(n))return n;throw TypeError(i)}}return n}function h(t,n=!1){if(typeof t!=`string`)throw TypeError(r);return t.length===0?new Uint8Array:m(t,n,e.encode(t))}function g(e,t=!1){return n(e),e.byteLength===0?``:t?d.decode(e):f.decode(e)}var _=(e,t=`uint8`)=>a(h(e,!1),t),v=(e,t=`uint8`)=>a(h(e,!0),t),y=e=>g(e,!1),b=e=>g(e,!0),x=/[ \t\n\v\f\r]/gu,ee=/[ \t\n\v\f\r]+/gu,S=/[ \t\n\v\f\r]+$/u,C=e=>e.replace(/[A-Z]/gu,e=>e.toLowerCase());function w({ignoreCase:e=!1,whitespace:t=`none`}={}){let n=null;return t===`all`?n=e=>e.replace(x,``):t===`change`?n=e=>e.replace(S,``).replace(ee,` `):t===`trailing`&&(n=e=>e.replace(S,``)),e?n?e=>C(n(e)):C:n}function T(e){let t=[];for(let n=0;n<e.length;){let r=e.indexOf(`
2
- `,n),i=r<0?e.length:r+1;t.push(e.slice(n,i)),n=i}return t}var E=class extends Error{constructor(e,t){super(t===void 0?e:`${e} at line ${t+1}`),this.name=`PatchError`,this.line=t}},D=(e,t)=>t===0?Number(e):Number(e)-1,O=e=>e!==void 0&&e.startsWith(`\\`),k=e=>e.replace(/\n$/u,``);function A(e){let t=T(e),n=[],r={old:null,new:null},i=!1;for(let e=0;e<t.length;){let a=t[e],c=j(a,i);if(i=!a.startsWith(`***************`)&&a.startsWith(`*** `),c){r=c.names??{...r,[c.slot]:c.name},e++;continue}let l=o.test(a)?`unified`:s.test(a)?`context`:u.test(a)?`normal`:null;if(l===null){e++;continue}let d=[],f=ie[l];for(let n=f(t,e);n!==null&&(d.push(n.hunk),e=n.next,!(e>=t.length||j(t[e],!1)));n=f(t,e));n.push({old:r.old,new:r.new,format:l,hunks:d,blocks:te(d)}),r={old:null,new:null}}return n}function j(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(c.test(e)||l.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]===`--- `?{slot:t?`new`:`old`,name:r[2]}:{slot:r[1]===`*** `?`old`:`new`,name:r[2]}:null}function te(e){let t=[];for(let n of e){let e=n.oldStart,r=n.newStart,i=null,a=()=>{i&&=(t.push(i),e=i.a1,r=i.b1,null)};for(let{tag:t,text:o}of n.lines){if(t===` `){a(),e++,r++;continue}t===`-`&&i?.insert.length&&a(),i??={a0:e,a1:e,b0:r,b1:r,remove:[],insert:[]},t===`-`?(i.a1++,i.remove.push(o)):(i.b1++,i.insert.push(o))}a()}return t}function ne(e,t){let n=o.exec(e[t]??``);if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),i=n[4]===void 0?1:Number(n[4]),a={oldStart:D(n[1],r),newStart:D(n[3],i),label:n[5]||null,lines:[]},s=0,c=t+1,l=0;for(;l<r||s<i;c++){let t=e[c];if(t===void 0)throw new E(`the patch ends inside a hunk`,c);let n=t===`
2
+ `,n),i=r<0?e.length:r+1;t.push(e.slice(n,i)),n=i}return t}var E=class extends Error{constructor(e,t){super(t===void 0?e:`${e} at line ${t+1}`),this.name=`PatchError`,this.line=t}},D=(e,t)=>t===0?Number(e):Number(e)-1,O=e=>e!==void 0&&e.startsWith(`\\`),k=e=>e.replace(/\n$/u,``);function te(e){let t=T(e),n=[],r={old:null,new:null},i=!1;for(let e=0;e<t.length;){let a=t[e],c=A(a,i);if(i=!a.startsWith(`***************`)&&a.startsWith(`*** `),c){r=c.names??{...r,[c.slot]:c.name},e++;continue}let l=o.test(a)?`unified`:s.test(a)?`context`:u.test(a)?`normal`:null;if(l===null){e++;continue}let d=[],f=ae[l];for(let n=f(t,e);n!==null&&(d.push(n.hunk),e=n.next,!(e>=t.length||A(t[e],!1)));n=f(t,e));n.push({old:r.old,new:r.new,format:l,hunks:d,blocks:ne(d)}),r={old:null,new:null}}return n}function A(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(c.test(e)||l.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]===`--- `?{slot:t?`new`:`old`,name:r[2]}:{slot:r[1]===`*** `?`old`:`new`,name:r[2]}:null}function ne(e){let t=[];for(let n of e){let e=n.oldStart,r=n.newStart,i=null,a=()=>{i&&=(t.push(i),e=i.a1,r=i.b1,null)};for(let{tag:t,text:o}of n.lines){if(t===` `){a(),e++,r++;continue}t===`-`&&i?.insert.length&&a(),i??={a0:e,a1:e,b0:r,b1:r,remove:[],insert:[]},t===`-`?(i.a1++,i.remove.push(o)):(i.b1++,i.insert.push(o))}a()}return t}function re(e,t){let n=o.exec(e[t]??``);if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),i=n[4]===void 0?1:Number(n[4]),a={oldStart:D(n[1],r),newStart:D(n[3],i),label:n[5]||null,lines:[]},s=0,c=t+1,l=0;for(;l<r||s<i;c++){let t=e[c];if(t===void 0)throw new E(`the patch ends inside a hunk`,c);let n=t===`
3
3
  `?` `:t[0];if(n!==` `&&n!==`-`&&n!==`+`)throw new E(`a hunk line begins with ${JSON.stringify(n)}`,c);let o=t===`
4
- `?t:t.slice(1);if(O(e[c+1])&&(o=k(o),c++),n!==`+`&&l++,n!==`-`&&s++,l>r||s>i)throw new E(`a hunk has more lines than its header says`,c);a.lines.push({tag:n,text:o})}return{hunk:a,next:c}}function M(e,t){let n=u.exec(e[t]??``);if(!n)return null;let[,r,i,a,o,s]=n,c=a===`a`?0:Number(i??r)-Number(r)+1,l=a===`d`?0:Number(s??o)-Number(o)+1;if(c<0||l<0)throw new E(`a change command counts backwards`,t);let d={oldStart:a===`a`?Number(r):Number(r)-1,newStart:a===`d`?Number(o):Number(o)-1,label:null,lines:[]},f=t+1,p=(t,n,r)=>{for(let i=0;i<t;i++,f++){let t=e[f];if(t===void 0)throw new E(`the patch ends inside a hunk`,f);if(t[0]!==n)throw new E(`${JSON.stringify(n)} expected`,f);let i=t.slice(2);O(e[f+1])&&(i=k(i),f++),d.lines.push({tag:r,text:i})}};if(p(c,`<`,`-`),a===`c`){if(e[f]!==`---
5
- `)throw new E(`'---' expected`,f);f++}return p(l,`>`,`+`),{hunk:d,next:f}}function re(e,t){let n=s.exec(e[t]??``);if(!n)return null;let r=c.exec(e[t+1]??``);if(!r)throw new E(`'*** ' range expected`,t+1);let i=t+2,a=N(e,i,l,`-`);i=a.next;let o=l.exec(e[i]??``);if(!o)throw new E(`'--- ' range expected`,i);let u=N(e,i+1,null,`+`),d=a.lines.length===0?u.lines.filter(e=>e.tag===` `):a.lines,f=u.lines.length===0?a.lines.filter(e=>e.tag===` `):u.lines;return{hunk:{oldStart:D(r[1],d.length),newStart:D(o[1],f.length),label:n[1]||null,lines:P(d,f)},next:u.next}}function N(e,t,n,r){let i=[],a=t;for(;a<e.length;a++){let t=e[a];if(n&&n.test(t)||s.test(t)||c.test(t)||!n&&l.test(t))break;if(O(t)){i[i.length-1].text=k(i.at(-1).text);continue}let o=t===`
4
+ `?t:t.slice(1);if(O(e[c+1])&&(o=k(o),c++),n!==`+`&&l++,n!==`-`&&s++,l>r||s>i)throw new E(`a hunk has more lines than its header says`,c);a.lines.push({tag:n,text:o})}return{hunk:a,next:c}}function j(e,t){let n=u.exec(e[t]??``);if(!n)return null;let[,r,i,a,o,s]=n,c=a===`a`?0:Number(i??r)-Number(r)+1,l=a===`d`?0:Number(s??o)-Number(o)+1;if(c<0||l<0)throw new E(`a change command counts backwards`,t);let d={oldStart:a===`a`?Number(r):Number(r)-1,newStart:a===`d`?Number(o):Number(o)-1,label:null,lines:[]},f=t+1,p=(t,n,r)=>{for(let i=0;i<t;i++,f++){let t=e[f];if(t===void 0)throw new E(`the patch ends inside a hunk`,f);if(t[0]!==n)throw new E(`${JSON.stringify(n)} expected`,f);let i=t.slice(2);O(e[f+1])&&(i=k(i),f++),d.lines.push({tag:r,text:i})}};if(p(c,`<`,`-`),a===`c`){if(e[f]!==`---
5
+ `)throw new E(`'---' expected`,f);f++}return p(l,`>`,`+`),{hunk:d,next:f}}function ie(e,t){let n=s.exec(e[t]??``);if(!n)return null;let r=c.exec(e[t+1]??``);if(!r)throw new E(`'*** ' range expected`,t+1);let i=t+2,a=M(e,i,l,`-`);i=a.next;let o=l.exec(e[i]??``);if(!o)throw new E(`'--- ' range expected`,i);let u=M(e,i+1,null,`+`),d=a.lines.length===0?u.lines.filter(e=>e.tag===` `):a.lines,f=u.lines.length===0?a.lines.filter(e=>e.tag===` `):u.lines;return{hunk:{oldStart:D(r[1],d.length),newStart:D(o[1],f.length),label:n[1]||null,lines:N(d,f)},next:u.next}}function M(e,t,n,r){let i=[],a=t;for(;a<e.length;a++){let t=e[a];if(n&&n.test(t)||s.test(t)||c.test(t)||!n&&l.test(t))break;if(O(t)){i[i.length-1].text=k(i.at(-1).text);continue}let o=t===`
6
6
  `?` `:t[0];if(o!==` `&&o!==`!`&&o!==`-`&&o!==`+`)break;i.push({tag:o===` `?` `:r,text:t===`
7
- `?t:t.slice(2)})}return{lines:i,next:a}}function P(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){if(e[r]?.tag===` `&&t[i]?.tag===` `){n.push(e[r]),r++,i++;continue}for(;r<e.length&&e[r].tag!==` `;)n.push(e[r]),r++;for(;i<t.length&&t[i].tag!==` `;)n.push(t[i]),i++;e[r]?.tag===` `&&t[i]===void 0?(n.push(e[r]),r++):t[i]?.tag===` `&&e[r]===void 0&&(n.push(t[i]),i++)}return n}var ie={unified:ne,context:re,normal:M},F=class extends Error{constructor(e){super(`the rendered diff does not say what the change set says (${e})`),this.name=`FormatError`}};function I(e,t,n,r){if(n.length===0){if(r!==``)throw new F(`there was nothing to print, and something was printed`);return}let i;try{i=A(r)}catch(e){throw new F(`it does not read back (${e.message})`)}if(i.length!==1)throw new F(`${i.length} files read back, not one`);let a=i[0].blocks;if(a.length!==n.length)throw new F(`${a.length} blocks read back, not ${n.length}`);for(let[e,t]of a.entries()){let r=n[e];if(t.a0!==r.a0||t.a1!==r.a1||t.b0!==r.b0||t.b1!==r.b1)throw new F(`block ${e+1} reads back somewhere else`)}for(let n of i[0].hunks){let r=i[0].format===`context`&&!n.lines.some(({tag:e})=>e===`-`),a=n.oldStart,o=n.newStart;for(let{tag:i,text:s}of n.lines){if(s!==(i===`+`||i===` `&&r?t[o]:e[a]))throw new F(`a ${i===`+`?`added`:i===`-`?`removed`:`kept`} line is not the line it stands for`);i!==`+`&&a++,i!==`-`&&o++}}}function ae(e,t,n,r){let i=[],a=0;for(;a<e.length;){let o=a;for(;o+1<e.length&&e[o+1].a0-e[o].a1<=2*t;)o++;let s=e[a],c=e[o];i.push({blocks:e.slice(a,o+1),a0:Math.max(0,s.a0-t),a1:Math.min(n,c.a1+t),b0:Math.max(0,s.b0-t),b1:Math.min(r,c.b1+t)}),a=o+1}return i}var L=e=>(t,n,r,{context:i,label:a=null})=>{let o=``;for(let s of ae(r,i,t.length,n.length))o+=e(t,n,s,a?a(s.a0):null);return I(t,n,r,o),o},oe=`
7
+ `?t:t.slice(2)})}return{lines:i,next:a}}function N(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){if(e[r]?.tag===` `&&t[i]?.tag===` `){n.push(e[r]),r++,i++;continue}for(;r<e.length&&e[r].tag!==` `;)n.push(e[r]),r++;for(;i<t.length&&t[i].tag!==` `;)n.push(t[i]),i++;e[r]?.tag===` `&&t[i]===void 0?(n.push(e[r]),r++):t[i]?.tag===` `&&e[r]===void 0&&(n.push(t[i]),i++)}return n}var ae={unified:re,context:ie,normal:j},P=class extends Error{constructor(e){super(`the rendered diff does not say what the change set says (${e})`),this.name=`FormatError`}};function F(e,t,n,r){if(n.length===0){if(r!==``)throw new P(`there was nothing to print, and something was printed`);return}let i;try{i=te(r)}catch(e){throw new P(`it does not read back (${e.message})`)}if(i.length!==1)throw new P(`${i.length} files read back, not one`);let a=i[0].blocks;if(a.length!==n.length)throw new P(`${a.length} blocks read back, not ${n.length}`);for(let[e,t]of a.entries()){let r=n[e];if(t.a0!==r.a0||t.a1!==r.a1||t.b0!==r.b0||t.b1!==r.b1)throw new P(`block ${e+1} reads back somewhere else`)}for(let n of i[0].hunks){let r=i[0].format===`context`&&!n.lines.some(({tag:e})=>e===`-`),a=n.oldStart,o=n.newStart;for(let{tag:i,text:s}of n.lines){if(s!==(i===`+`||i===` `&&r?t[o]:e[a]))throw new P(`a ${i===`+`?`added`:i===`-`?`removed`:`kept`} line is not the line it stands for`);i!==`+`&&a++,i!==`-`&&o++}}}function oe(e,t,n,r){let i=[],a=0;for(;a<e.length;){let o=a;for(;o+1<e.length&&e[o+1].a0-e[o].a1<=2*t;)o++;let s=e[a],c=e[o];i.push({blocks:e.slice(a,o+1),a0:Math.max(0,s.a0-t),a1:Math.min(n,c.a1+t),b0:Math.max(0,s.b0-t),b1:Math.min(r,c.b1+t)}),a=o+1}return i}var I=e=>(t,n,r,{context:i,label:a=null})=>{let o=``;for(let s of oe(r,i,t.length,n.length))o+=e(t,n,s,a?a(s.a0):null);return F(t,n,r,o),o},se=`
8
8
  \
9
- `,R=(e,t)=>e+t+(t.endsWith(`
10
- `)?``:oe);function z(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function se(e,t,n){let r=``;for(let{a0:i,a1:a,b0:o,b1:s}of n){let n=i===a?`a`:o===s?`d`:`c`;r+=z(i,a)+n+z(o,s)+`
11
- `;for(let t=i;t<a;t++)r+=R(`< `,e[t]);n===`c`&&(r+=`---
12
- `);for(let e=o;e<s;e++)r+=R(`> `,t[e])}return I(e,t,n,r),r}function B(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}var ce=L((e,t,n,r)=>{let i=`@@ -${B(n.a0,n.a1)} +${B(n.b0,n.b1)} @@${r===null?``:` `+r}
13
- `,a=n.a0,o=n.b0;for(let{a0:r,a1:s,b1:c}of n.blocks){for(;a<r;a++,o++)i+=R(` `,e[a]);for(;a<s;a++)i+=R(`-`,e[a]);for(;o<c;o++)i+=R(`+`,t[o])}for(;a<n.a1;a++,o++)i+=R(` `,e[a]);return i});function V(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}var le=L((e,t,n,r)=>{let i=`***************${r===null?``:` `+r}
14
- `;return i+=`*** ${V(n.a0,n.a1)} ****
15
- `,n.blocks.some(e=>e.a0<e.a1)&&(i+=H(e,n.a0,n.a1,n.blocks,`a`)),i+=`--- ${V(n.b0,n.b1)} ----
16
- `,n.blocks.some(e=>e.b0<e.b1)&&(i+=H(t,n.b0,n.b1,n.blocks,`b`)),i});function H(e,t,n,r,i){let a=i+`1`,o=i+`0`,s=i===`a`?`b`:`a`,c=``,l=t;for(let t of r){for(;l<t[o];l++)c+=R(` `,e[l]);let n=t[s+`0`]<t[s+`1`]?`! `:i===`a`?`- `:`+ `;for(;l<t[a];l++)c+=R(n,e[l])}for(;l<n;l++)c+=R(` `,e[l]);return c}function U(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function W(e,t,n){let r=t.length,i=U(n),a=0,o=0,s=0,c=()=>{if(a===r||e[s]!==e[a])return!1;for(t[s++]=0,t[a++]=1,o++;a<r&&t[a];)a++;return!0},l=()=>{if(s===0||e[s-1]!==e[a-1])return!1;for(t[--s]=1,t[--a]=0,o--;s>0&&t[s-1];)s--;return!0};for(let e=0;e<r;e++){if(!t[e]){o++;continue}for(s=e,a=e;a<r&&t[a];a++);let n=-1;for(let e=-1;e!==a-s;){for(e=a-s;l(););for(n=i[o]?a:-1;c();)i[o]&&(n=a)}if(n!==-1)for(let e=a-n;e>0;e--)l();e=a-1}}function ue(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function G(e,t,{ignoreCase:n=!1,whitespace:r=`none`,minimal:i=!1,discard:a=!0,slide:o=!0,horizon:s=1/0}={}){let c=w({ignoreCase:n,whitespace:r});if(c===null&&J(e,t,null))return[];let{A:l,B:u,classes:d}=pe(e,t,c),f=new Uint8Array(l.length),p=new Uint8Array(u.length),m=de(e,t,s),[h,g]=i||!a?[null,null]:fe(l,u,d,m),_=q(m.lo,m.hiA,h,f),v=q(m.lo,m.hiB,g,p),y=new Uint8Array(_.length),b=new Uint8Array(v.length);me(_.map(e=>l[e]),v.map(e=>u[e]),y,b,i);for(let e=0;e<_.length;e++)y[e]&&(f[_[e]]=1);for(let e=0;e<v.length;e++)b[e]&&(p[v[e]]=1);if(o){let{lo:e,hiA:t,hiB:n}=m;W(l.subarray(e,t),f.subarray(e,t),p.subarray(e,n)),W(u.subarray(e,n),p.subarray(e,n),f.subarray(e,t))}let x=_e(f,p);return Y(e,t,x,c),x}function de(e,t,n){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let a=Math.max(0,i-n),o=0;for(;o<r-a&&e[e.length-1-o]===t[t.length-1-o];)o++;let s=Math.max(0,o-n);return{lo:a,hiA:e.length-s,hiB:t.length-s}}function fe(e,t,n,{lo:r,hiA:i,hiB:a}){let o=new Int32Array(n),s=new Int32Array(n);for(let t=r;t<i;t++)o[e[t]]++;for(let e=r;e<a;e++)s[t[e]]++;return[K(e.subarray(r,i),s),K(t.subarray(r,a),o)]}function K(e,t){let n=e.length,r=new Uint8Array(n),i=5;for(let e=Math.floor(n/64)>>2;e>0;e>>=2)i*=2;for(let a=0;a<n;a++){let n=t[e[a]];n===0?r[a]=1:n>i&&(r[a]=2)}for(let e=0;e<n;e++){if(r[e]===2){r[e]=0;continue}if(r[e]===0)continue;let t=e,i=0;for(;t<n&&r[t]!==0;t++)r[t]===2&&i++;for(;t>e&&r[t-1]===2;)r[--t]=0,i--;let a=t-e;if(i*4>a){for(;t>e;)r[--t]===2&&(r[t]=0);continue}let o=1;for(let e=a>>4;e>0;e>>=2)o<<=1;o++;for(let t=0,n=0;n<a;n++)r[e+n]===2?o===++t?n-=t:o<t&&(r[e+n]=0):t=0;for(let t=0,n=0;n<a&&!(n>=8&&r[e+n]===1||(r[e+n]===2?(t=0,r[e+n]=0):r[e+n]===0?t=0:t++,t===3));n++);e+=a-1;for(let t=0,n=0;n<a&&!(n>=8&&r[e-n]===1||(r[e-n]===2?(t=0,r[e-n]=0):r[e-n]===0?t=0:t++,t===3));n++);}return r}function q(e,t,n,r){let i=[];for(let a=e;a<t;a++)n!==null&&n[a-e]!==0?r[a]=1:i.push(a);return Int32Array.from(i)}function J(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(e,t)=>n(e)===n(t):(e,t)=>e===t;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function pe(e,t,n){let r=new Map,i=e=>{let t=n?n(e):e,i=r.get(t);return i===void 0&&(i=r.size,r.set(t,i)),i};return{A:Int32Array.from(e,i),B:Int32Array.from(t,i),classes:r.size}}function me(e,t,n,r,i){let a=e.length+t.length+3,o={A:e,B:t,fd:new Int32Array(a),bd:new Int32Array(a),base:t.length+1,limit:ue(e.length+t.length)},s=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:i}],c={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;s.length;){let{xoff:i,xlim:a,yoff:l,ylim:u,minimal:d}=s.pop();for(;i<a&&l<u&&e[i]===t[l];)i++,l++;for(;i<a&&l<u&&e[a-1]===t[u-1];)a--,u--;if(i===a){for(;l<u;l++)r[l]=1;continue}if(l===u){for(;i<a;i++)n[i]=1;continue}he(o,i,a,l,u,d,c),s.push({xoff:c.xmid,xlim:a,yoff:c.ymid,ylim:u,minimal:c.hiMinimal}),s.push({xoff:i,xlim:c.xmid,yoff:l,ylim:c.ymid,minimal:c.loMinimal})}}function he(e,t,n,r,i,a,o){let{A:s,B:c,fd:l,bd:u,base:d,limit:f}=e,p=n-r,m=t-i,h=n-i,g=t-r,_=h,v=h,y=g,b=g,x=!!(g-h&1);l[d+g]=t,u[d+h]=n;for(let h=1;;h++){b>m?l[d+--b-1]=-1:++b,y<p?l[d+ ++y+1]=-1:--y;for(let e=y;e>=b;e-=2){let t=l[d+e+1],r=l[d+e-1],a=r<t?t:r+1,f=a-e;for(;a<n&&f<i&&s[a]===c[f];)a++,f++;if(l[d+e]=a,x&&v<=e&&e<=_&&u[d+e]<=a){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}v>m?u[d+--v-1]=2147483647:++v,_<p?u[d+ ++_+1]=2147483647:--_;for(let e=_;e>=v;e-=2){let n=u[d+e+1],i=u[d+e-1],a=i<n?i:n-1,f=a-e;for(;t<a&&r<f&&s[a-1]===c[f-1];)a--,f--;if(u[d+e]=a,!x&&b<=e&&e<=y&&a<=l[d+e]){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}if(!(a||h<f)){ge(e,{xoff:t,xlim:n,yoff:r,ylim:i,fmin:b,fmax:y,bmin:v,bmax:_},o);return}}}function ge(e,t,n){let{fd:r,bd:i,base:a}=e,{xoff:o,xlim:s,yoff:c,ylim:l,fmin:u,fmax:d,bmin:f,bmax:p}=t,m=0,h=-1;for(let e=d;e>=u;e-=2){let t=Math.min(r[a+e],s),n=t-e;l<n&&(t=l+e,n=l),h<t+n&&(h=t+n,m=t)}let g=0,_=2147483647;for(let e=p;e>=f;e-=2){let t=Math.max(o,i[a+e]),n=t-e;n<c&&(t=c+e,n=c),t+n<_&&(_=t+n,g=t)}s+l-_<h-(o+c)?(n.xmid=m,n.ymid=h-m,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=_-g,n.loMinimal=!1,n.hiMinimal=!0)}function _e(e,t){let n=[],r=t.length,i=e.length,a=0,o=0;for(;a<i||o<r;){if(a<i&&o<r&&!e[a]&&!t[o]){a++,o++;continue}let s=a,c=o;for(;a<i&&e[a];)a++;for(;o<r&&t[o];)o++;if(s===a&&c===o)throw new X(`a kept line has no counterpart`);n.push({a0:s,a1:a,b0:c,b1:o})}return n}function Y(e,t,n,r=null){let i=r?(e,t)=>r(e)===r(t):(e,t)=>e===t,a=0,o=0;for(let{a0:r,a1:s,b0:c,b1:l}of n){if(r<a||c<o||s<r||l<c||s>e.length||l>t.length)throw new X(`a block is out of order or out of range`);if(r===s&&c===l)throw new X(`a block changes nothing`);if(r-a!==c-o)throw new X(`the kept lines before a block differ in count`);for(;a<r;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`);a=s,o=l}if(e.length-a!==t.length-o)throw new X(`the kept lines after the last block differ in count`);for(;a<e.length;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`)}var X=class extends Error{constructor(e){super(`the computed change set does not reconstruct the second file (${e})`),this.name=`DiffError`}},Z={unified:ce,context:le,normal:se},Q=`Files differ
17
- `;function ve(e,t,n){if(e===t)return``;let r=w(n);return r===null?Q:J(T(e),T(t),r)?``:Q}function $(e,t){if(!(Number.isInteger(e)&&e>=0)&&e!==1/0)throw RangeError(`${t} is a number of lines, not ${e}`);return e}function ye(e,t,{slide:n=!0,horizon:r=3,...i}={}){let a=T(e),o=T(t);return G(a,o,{...i,slide:n,horizon:$(r,`horizon`)}).map(({a0:e,a1:t,b0:n,b1:r})=>({a0:e,a1:t,b0:n,b1:r,remove:a.slice(e,t),insert:o.slice(n,r)}))}function be(e,t,n,{format:r=`unified`,context:i=3,label:a=null,...o}={}){if(!Object.hasOwn(Z,r))throw RangeError(`a change set prints as unified, context or normal, not ${r}`);let s=T(e),c=T(t);return Y(s,c,n,w(o)),n.length===0?``:Z[r](s,c,n,{context:i,label:a})}function xe(e,t,{format:n=`unified`,context:r=3,label:i=null,...a}={}){if(n===`brief`)return ve(e,t,a);let o=T(e),s=T(t),{slide:c=!0,horizon:l=0,...u}=a,d=$(l,`horizon`),f=G(o,s,{...u,slide:c,horizon:n===`normal`?d:Math.max(d,$(r,`context`))});return f.length===0?``:Z[n](o,s,f,{context:r,label:i})}export{o as a,s as b,u as c,A as d,F as e,X as f,ye as g,be as h,xe as i,_ as j,v as k,y as l,b as m};
9
+ `,L=(e,t)=>e+t+(t.endsWith(`
10
+ `)?``:se);function R(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function ce(e,t,n){let r=``;for(let{a0:i,a1:a,b0:o,b1:s}of n){let n=i===a?`a`:o===s?`d`:`c`;r+=R(i,a)+n+R(o,s)+`
11
+ `;for(let t=i;t<a;t++)r+=L(`< `,e[t]);n===`c`&&(r+=`---
12
+ `);for(let e=o;e<s;e++)r+=L(`> `,t[e])}return F(e,t,n,r),r}function z(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}var le=I((e,t,n,r)=>{let i=`@@ -${z(n.a0,n.a1)} +${z(n.b0,n.b1)} @@${r===null?``:` `+r}
13
+ `,a=n.a0,o=n.b0;for(let{a0:r,a1:s,b1:c}of n.blocks){for(;a<r;a++,o++)i+=L(` `,e[a]);for(;a<s;a++)i+=L(`-`,e[a]);for(;o<c;o++)i+=L(`+`,t[o])}for(;a<n.a1;a++,o++)i+=L(` `,e[a]);return i});function B(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}var V=I((e,t,n,r)=>{let i=`***************${r===null?``:` `+r}
14
+ `;return i+=`*** ${B(n.a0,n.a1)} ****
15
+ `,n.blocks.some(e=>e.a0<e.a1)&&(i+=H(e,n.a0,n.a1,n.blocks,`a`)),i+=`--- ${B(n.b0,n.b1)} ----
16
+ `,n.blocks.some(e=>e.b0<e.b1)&&(i+=H(t,n.b0,n.b1,n.blocks,`b`)),i});function H(e,t,n,r,i){let a=i+`1`,o=i+`0`,s=i===`a`?`b`:`a`,c=``,l=t;for(let t of r){for(;l<t[o];l++)c+=L(` `,e[l]);let n=t[s+`0`]<t[s+`1`]?`! `:i===`a`?`- `:`+ `;for(;l<t[a];l++)c+=L(n,e[l])}for(;l<n;l++)c+=L(` `,e[l]);return c}function U(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function W(e,t,n){let r=t.length,i=U(n),a=0,o=0,s=0,c=()=>{if(a===r||e[s]!==e[a])return!1;for(t[s++]=0,t[a++]=1,o++;a<r&&t[a];)a++;return!0},l=()=>{if(s===0||e[s-1]!==e[a-1])return!1;for(t[--s]=1,t[--a]=0,o--;s>0&&t[s-1];)s--;return!0};for(let e=0;e<r;e++){if(!t[e]){o++;continue}for(s=e,a=e;a<r&&t[a];a++);let n=-1;for(let e=-1;e!==a-s;){for(e=a-s;l(););for(n=i[o]?a:-1;c();)i[o]&&(n=a)}if(n!==-1)for(let e=a-n;e>0;e--)l();e=a-1}}function ue(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function G(e,t,{ignoreCase:n=!1,whitespace:r=`none`,minimal:i=!1,discard:a=!0,slide:o=!0,horizon:s=1/0}={}){let c=w({ignoreCase:n,whitespace:r});if(c===null&&J(e,t,null))return[];let{A:l,B:u,classes:d}=pe(e,t,c),f=new Uint8Array(l.length),p=new Uint8Array(u.length),m=de(e,t,s),[h,g]=i||!a?[null,null]:fe(l,u,d,m),_=q(m.lo,m.hiA,h,f),v=q(m.lo,m.hiB,g,p),y=new Uint8Array(_.length),b=new Uint8Array(v.length);me(_.map(e=>l[e]),v.map(e=>u[e]),y,b,i);for(let e=0;e<_.length;e++)y[e]&&(f[_[e]]=1);for(let e=0;e<v.length;e++)b[e]&&(p[v[e]]=1);if(o){let{lo:e,hiA:t,hiB:n}=m;W(l.subarray(e,t),f.subarray(e,t),p.subarray(e,n)),W(u.subarray(e,n),p.subarray(e,n),f.subarray(e,t))}let x=_e(f,p);return Y(e,t,x,c),x}function de(e,t,n){let r=Math.min(e.length,t.length),i=0;for(;i<r&&e[i]===t[i];)i++;let a=Math.max(0,i-n),o=0;for(;o<r-a&&e[e.length-1-o]===t[t.length-1-o];)o++;let s=Math.max(0,o-n);return{lo:a,hiA:e.length-s,hiB:t.length-s}}function fe(e,t,n,{lo:r,hiA:i,hiB:a}){let o=new Int32Array(n),s=new Int32Array(n);for(let t=r;t<i;t++)o[e[t]]++;for(let e=r;e<a;e++)s[t[e]]++;return[K(e.subarray(r,i),s),K(t.subarray(r,a),o)]}function K(e,t){let n=e.length,r=new Uint8Array(n),i=5;for(let e=Math.floor(n/64)>>2;e>0;e>>=2)i*=2;for(let a=0;a<n;a++){let n=t[e[a]];n===0?r[a]=1:n>i&&(r[a]=2)}for(let e=0;e<n;e++){if(r[e]===2){r[e]=0;continue}if(r[e]===0)continue;let t=e,i=0;for(;t<n&&r[t]!==0;t++)r[t]===2&&i++;for(;t>e&&r[t-1]===2;)r[--t]=0,i--;let a=t-e;if(i*4>a){for(;t>e;)r[--t]===2&&(r[t]=0);continue}let o=1;for(let e=a>>4;e>0;e>>=2)o<<=1;o++;for(let t=0,n=0;n<a;n++)r[e+n]===2?o===++t?n-=t:o<t&&(r[e+n]=0):t=0;for(let t=0,n=0;n<a&&!(n>=8&&r[e+n]===1||(r[e+n]===2?(t=0,r[e+n]=0):r[e+n]===0?t=0:t++,t===3));n++);e+=a-1;for(let t=0,n=0;n<a&&!(n>=8&&r[e-n]===1||(r[e-n]===2?(t=0,r[e-n]=0):r[e-n]===0?t=0:t++,t===3));n++);}return r}function q(e,t,n,r){let i=[];for(let a=e;a<t;a++)n!==null&&n[a-e]!==0?r[a]=1:i.push(a);return Int32Array.from(i)}function J(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(e,t)=>n(e)===n(t):(e,t)=>e===t;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function pe(e,t,n){let r=new Map,i=e=>{let t=n?n(e):e,i=r.get(t);return i===void 0&&(i=r.size,r.set(t,i)),i};return{A:Int32Array.from(e,i),B:Int32Array.from(t,i),classes:r.size}}function me(e,t,n,r,i){let a=e.length+t.length+3,o={A:e,B:t,fd:new Int32Array(a),bd:new Int32Array(a),base:t.length+1,limit:ue(e.length+t.length)},s=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:i}],c={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;s.length;){let{xoff:i,xlim:a,yoff:l,ylim:u,minimal:d}=s.pop();for(;i<a&&l<u&&e[i]===t[l];)i++,l++;for(;i<a&&l<u&&e[a-1]===t[u-1];)a--,u--;if(i===a){for(;l<u;l++)r[l]=1;continue}if(l===u){for(;i<a;i++)n[i]=1;continue}he(o,i,a,l,u,d,c),s.push({xoff:c.xmid,xlim:a,yoff:c.ymid,ylim:u,minimal:c.hiMinimal}),s.push({xoff:i,xlim:c.xmid,yoff:l,ylim:c.ymid,minimal:c.loMinimal})}}function he(e,t,n,r,i,a,o){let{A:s,B:c,fd:l,bd:u,base:d,limit:f}=e,p=n-r,m=t-i,h=n-i,g=t-r,_=h,v=h,y=g,b=g,x=!!(g-h&1);l[d+g]=t,u[d+h]=n;for(let h=1;;h++){b>m?l[d+--b-1]=-1:++b,y<p?l[d+ ++y+1]=-1:--y;for(let e=y;e>=b;e-=2){let t=l[d+e+1],r=l[d+e-1],a=r<t?t:r+1,f=a-e;for(;a<n&&f<i&&s[a]===c[f];)a++,f++;if(l[d+e]=a,x&&v<=e&&e<=_&&u[d+e]<=a){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}v>m?u[d+--v-1]=2147483647:++v,_<p?u[d+ ++_+1]=2147483647:--_;for(let e=_;e>=v;e-=2){let n=u[d+e+1],i=u[d+e-1],a=i<n?i:n-1,f=a-e;for(;t<a&&r<f&&s[a-1]===c[f-1];)a--,f--;if(u[d+e]=a,!x&&b<=e&&e<=y&&a<=l[d+e]){o.xmid=a,o.ymid=f,o.loMinimal=o.hiMinimal=!0;return}}if(!(a||h<f)){ge(e,{xoff:t,xlim:n,yoff:r,ylim:i,fmin:b,fmax:y,bmin:v,bmax:_},o);return}}}function ge(e,t,n){let{fd:r,bd:i,base:a}=e,{xoff:o,xlim:s,yoff:c,ylim:l,fmin:u,fmax:d,bmin:f,bmax:p}=t,m=0,h=-1;for(let e=d;e>=u;e-=2){let t=Math.min(r[a+e],s),n=t-e;l<n&&(t=l+e,n=l),h<t+n&&(h=t+n,m=t)}let g=0,_=2147483647;for(let e=p;e>=f;e-=2){let t=Math.max(o,i[a+e]),n=t-e;n<c&&(t=c+e,n=c),t+n<_&&(_=t+n,g=t)}s+l-_<h-(o+c)?(n.xmid=m,n.ymid=h-m,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=_-g,n.loMinimal=!1,n.hiMinimal=!0)}function _e(e,t){let n=[],r=t.length,i=e.length,a=0,o=0;for(;a<i||o<r;){if(a<i&&o<r&&!e[a]&&!t[o]){a++,o++;continue}let s=a,c=o;for(;a<i&&e[a];)a++;for(;o<r&&t[o];)o++;if(s===a&&c===o)throw new X(`a kept line has no counterpart`);n.push({a0:s,a1:a,b0:c,b1:o})}return n}function Y(e,t,n,r=null){let i=r?(e,t)=>r(e)===r(t):(e,t)=>e===t,a=0,o=0;for(let{a0:r,a1:s,b0:c,b1:l}of n){if(r<a||c<o||s<r||l<c||s>e.length||l>t.length)throw new X(`a block is out of order or out of range`);if(r===s&&c===l)throw new X(`a block changes nothing`);if(r-a!==c-o)throw new X(`the kept lines before a block differ in count`);for(;a<r;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`);a=s,o=l}if(e.length-a!==t.length-o)throw new X(`the kept lines after the last block differ in count`);for(;a<e.length;a++,o++)if(!i(e[a],t[o]))throw new X(`kept line ${a+1} does not match`)}var X=class extends Error{constructor(e){super(`the computed change set does not reconstruct the second file (${e})`),this.name=`DiffError`}},Z={unified:le,context:V,normal:ce},Q=`Files differ
17
+ `;function ve(e,t,n){if(e===t)return``;let r=w(n);return r===null?Q:J(T(e),T(t),r)?``:Q}function $(e,t){if(!(Number.isInteger(e)&&e>=0)&&e!==1/0)throw RangeError(`${t} is a number of lines, not ${e}`);return e}function ye(e,t,{slide:n=!0,horizon:r=3,...i}={}){let a=T(e),o=T(t);return G(a,o,{...i,slide:n,horizon:$(r,`horizon`)}).map(({a0:e,a1:t,b0:n,b1:r})=>({a0:e,a1:t,b0:n,b1:r,remove:a.slice(e,t),insert:o.slice(n,r)}))}function be(e,t,n,{format:r=`unified`,context:i=3,label:a=null,...o}={}){if(!Object.hasOwn(Z,r))throw RangeError(`a change set prints as unified, context or normal, not ${r}`);let s=T(e),c=T(t);return Y(s,c,n,w(o)),n.length===0?``:Z[r](s,c,n,{context:i,label:a})}function xe(e,t,{format:n=`unified`,context:r=3,label:i=null,...a}={}){if(n===`brief`)return ve(e,t,a);let o=T(e),s=T(t),{slide:c=!0,horizon:l=0,...u}=a,d=$(l,`horizon`),f=G(o,s,{...u,slide:c,horizon:n===`normal`?d:Math.max(d,$(r,`context`))});return f.length===0?``:Z[n](o,s,f,{context:r,label:i})}export{o as a,s as b,u as c,P as d,X as e,ye as f,be as g,xe as h,_ as i,v as j,y as k,b as l};