/mission opens a live map of the main agent, its subagents and every tool call, plus a code map of the files they touch.

Zhitong's Claude Code mods. Inspired by hamzafer/claude-code-mods (MIT).
/mission opens a live web page with two tabs, Who (the main agent, its subagents and every tool call) and Code (a map of the files Claude reads and edits, the imports between them, and one line on why each changed). The page refreshes itself every second. There is no side pane.
It opens in a cmux browser split when run inside cmux, otherwise in your default browser.
How it works:
/mission opens a web page; there is no terminal pane and no screenshot step.hooks/template.ts) is plain HTML and CSS fed by a small data.js, not a hand-built SVG. Text wraps by itself, so nothing is cut with …, and restyling means editing HTML/CSS./mission has opened the page, then once per change./mission runs, and /mission off stops it. Writes are skipped when the data has not changed.A → B means B uses A (a change in A reaches B), so used files sit on the left and their users to the right. Arrows come from per-language adapters (hooks/lang.ts): JS/TS and Python follow relative imports, Ruby follows require_relative and the class or module names a file mentions (RequestChorusOtp links to request_chorus_otp.rb), as Rails loads code by name. Add a language by adding an adapter./mission side by side without sharing data./mission again) to reopen the page after closing the tab.claude plugin marketplace add zhitongLIU/claude-code-mods
claude plugin install mission@zhitong-mods
Restart Claude Code (or run /reload-plugins), then:
| Command | What it does |
|---|---|
/mission | Open the page and keep it updated. It opens on the tab you used last (Who the first time). |
/mission <base> | Put the files changed in git on the Code tab once (HEAD for the uncommitted changes, or everything against base, e.g. main), each with a one-line summary of its diff. Works with no turn running. After that the page carries on live from Claude's own work; run it again to refresh. Give a GitHub PR link or #123 instead of a base to review a pull request without checking it out: it is fetched from origin (needs gh signed in) and read from git. |
/mission findings <file.json> [--add] | Put the findings of an AI review on the page (see below). /mission findings clear takes them off. |
/mission off | Stop updating the page. |
In the page: w Who, c Code. On the code map, scroll or pinch to zoom around the pointer, drag to move, double-click (or 0) to fit it to the window again. Drag a box to pull it out of a tangle of arrows (the arrows follow); a moved box gets a small ↺ button, or double-click it, to put it back, and r resets all boxes. Your zoom and box positions are kept while the data refreshes, and box positions are remembered in the browser for that session's page. The tab is kept in the URL hash (#who, #code).
Click a changed box to slide its diff up from the bottom (the map stays above it); click the box again, the empty map or press esc to close it. Press on a line number and drag to take a range of lines (or click one line, shift-click to extend), then Add to review or Send now. Send review (n) at the top sends the comments not yet sent, each with its quoted lines, straight to this Claude session as a prompt. The page is served by a small local Node server on 127.0.0.1 (a token in the URL, one server per session, stopped by /mission off); where Node is missing or the server does not start, the page opens from disk and the same buttons copy to the clipboard instead, to paste into Claude or anything else. Copy (n) always copies every comment. Sent or copied comments stay on the page, dimmed with a ✓, and are cleared once Claude changes their file again; a comment you have not sent is never dropped, only marked outdated. Send now sends a single comment the same way. The review is kept in the browser for that session's page. Diffs come from git (against HEAD, the review base, or the pull request); a pull request given as a link uses GitHub's own patch, which GitHub leaves out for very large files.

Review findings. Findings from an AI review turn their file's box pink (⚑ n) and show under their line in the diff drawer. They come in three ways, whoever wrote the review: the ReportFindings call of /code-review is picked up on its own; the model calls the mcp__mission__findings tool, which the /mission-findings skill does from a review already in the conversation; or you load a JSON array of { file, line?, summary, scenario?, severity? } with /mission findings <file>. file is repo-relative and line is on the new side of the diff; a finding with no line, or whose line is not in the diff, sits at the top of the file's drawer. Findings on files the map does not show are counted but not drawn: run /mission <PR link or base> first.
To push findings to the pull request, tick the ones you approve (or Select findings) and choose PR or Claude and press Send to PR (n) or Send to Claude (n). After a confirmation the mod posts them with gh as one review of comments (never an approval or a request for changes); the page sends only the ids, and what is posted is what the mod holds. It needs the local server, a page about a pull request and gh signed in; pushed findings are dimmed with a ✓ and cannot be pushed twice.
Closing the browser tab does not stop the updates, because the mod cannot see it close. Run /mission off when you are done, which also stops the model calls for the "why" lines.
| File | Role |
|---|---|
hooks/register.tsx | Tracks agents, tool calls and files. After /mission, writes index.html and hljs.js once, data.js on every change and diffs.js when a diff changes, to $TMPDIR/mission-control/<session id>/, and opens the page. |
hooks/lang.ts | Language adapters: what each file links to, and which names it defines. |
hooks/map.ts | mapData() turns the touched files into plain data: cards by link depth, edges, counts. |
hooks/tree.ts | The Who tree lines. |
hooks/template.ts | The page: tabs, the tree, the card layout and the arrows. Restyle it here. |
hooks/diff.ts | Parses a unified diff into numbered rows and formats review comments. Also runs in the page. |
hooks/hl.ts, hooks/highlight.ts | Syntax colours in the diff drawer: hl.ts feeds each hunk to highlight.js, highlight.ts is the small fallback tint. Both also run in the page. |
hooks/vendor-hljs.ts | highlight.js 11.11.1 (common languages), vendored unchanged for offline use. BSD-3-Clause, © 2006 Ivan Sagalaev. |
CLAUDE_CONFIG_DIR=$(mktemp -d) claude plugin test mods/mission-control
MIT, see LICENSE. Inspired by hamzafer/claude-code-mods by Hamza Zafar, whose copyright notice stays in the license.
hooks/register.tsx 680 lines1// Mission Control: /mission opens a live web page with two tabs for the current turn.
2// who · the main loop, its subagents and every tool call they make, live
3// code · a map of the files Claude reads and edits, the imports between
4// them, a glow on what it touches right now, and one line on each change
5// A band line sums it up while Claude works. The page re-reads data.js every second.
6import { atom, read, update } from 'claude-code'
7import type { EngineInterface, Register } from 'claude-code'
8
9import type { Finding, MapFile, MissionNode, MissionWhere } from '../types'
10import { linksOf } from './lang'
11import { SERVER, parseLine, portFor, splitLines } from './bridge'
12import { addedDiff } from './diff'
13import { byPath, dismiss, markStale, merge, normalize, parseFindings, prRef, reviewPayload, splitByDiff } from './findings'
14import { HLJS } from './vendor-hljs'
15import { mapData } from './map'
16import { TEMPLATE } from './template'
17import { label, lines, summary } from './tree'
18
19const MAX_NODES = 300
20const MAX_FILES = 14
21const DIFF_MAX = 200_000 // characters of one file's diff the page gets
22const REVIEW_MAX = 40 // a review of a branch shows more files than a live turn does
23const BAND_AFTER_MS = 30_000 // the band stays this long after a turn ends
24// Tools that are Claude Code's own bookkeeping, not work: kept out of the tree.
25const INTERNAL = new Set(['SubagentHandback', 'ToolSearch', 'TaskCreate', 'TaskUpdate', 'TaskGet', 'TaskList'])
26// Files that belong on a code map: source, config and docs, not images or binaries.
27export const CODE_FILE = /\.(tsx?|jsx?|mjs|cjs|py|go|rs|rb|java|kt|swift|c|h|cc|cpp|hpp|cs|php|vue|svelte|css|scss|html|md|mdx|json|ya?ml|toml|sh|sql|lua|ex|exs|erb|haml|slim)$/i
28
29// A review also maps what a change touches around the code: env files, Dockerfiles, translations, lockfiles, schemas.
30export const REVIEW_FILE = new RegExp(`${CODE_FILE.source}|(^|/)(\\.env[^/]*|Dockerfile[^/]*|Jenkinsfile|Gemfile(\\.lock)?|go\\.sum|yarn\\.lock|pnpm-lock\\.yaml|requirements[^/]*\\.txt)$|\\.(po|pot|xlf|xliff|ini|properties|tf|proto|graphql|gql|less|sass|lock)$`, 'i')
31
32// Held by the host, so a hot reload keeps the picture.
33const nodes = atom({ plugin: 'mission', key: 'nodes' } as const, [] as MissionNode[])
34const files = atom({ plugin: 'mission', key: 'files' } as const, [] as MapFile[])
35const turn = atom({ plugin: 'mission', key: 'turn' } as const, 0)
36const diffs = atom({ plugin: 'mission', key: 'diffs' } as const, {} as Record<string, { text: string; ref?: string }>) // a changed file's diff, for the page's drawer
37const where = atom({ plugin: 'mission', key: 'where' } as const, { branch: '' } as MissionWhere) // the branch and pull request the page is about
38const findings = atom({ plugin: 'mission', key: 'findings' } as const, [] as Finding[]) // an AI review's findings, pink on the map; their index is their id
39const sid = atom({ plugin: 'mission', key: 'sid' } as const, '') // this session's folder name, so sessions never share a page
40
41// The web page's bookkeeping; a reload starts it over. `on` once /mission has opened the page.
42const page = { on: false, pending: false, dirty: false, last: '', lastDiffs: '', written: false, posting: false, note: '' } // note: what the last push to the pull request came to
43// The edits awaiting their one-line "why" live on the files atom (MapFile.edits), so a reload keeps
44// them; the "why" is asked for lazily: no model call while nobody watches.
45const asking = new Set<string>()
46// The local server that serves the page and carries "Send to Claude" back; a reload ends it with the module.
47const bridge: { base?: string; starting?: Promise<string | undefined>; stop: boolean } = { stop: false } // paths a model call is already explaining
48
49// Under the cap, the oldest tool calls go first; main and the agents always stay.
50export function cap(list: MissionNode[]) {
51 if (list.length <= MAX_NODES) return list
52 const tools = list.filter(n => n.kind === 'tool')
53 const room = Math.max(0, MAX_NODES - (list.length - tools.length))
54 const keep = new Set(room === 0 ? [] : tools.slice(-room))
55 return list.filter(n => n.kind !== 'tool' || keep.has(n))
56}
57
58// The first `max` characters, cut at a word.
59function words(text: string, max: number) {
60 const t = text.replace(/\s+/g, ' ').trim()
61 if (t.length <= max) return t
62 const cut = t.lastIndexOf(' ', max)
63 return `${t.slice(0, cut > max * 0.5 ? cut : max)}…`
64}
65
66export const register: Register = on => {
67 on('session.start', async ($, e, next) => {
68 const r = await next(e)
69 await update($, sid, () => String((r as { sessionId?: string }).sessionId ?? Math.random().toString(36).slice(2, 10)).replace(/[^\w-]/g, ''))
70 await $.command.register({ name: 'mission', description: 'Open the live web page of agents, tool calls and the code map; give a base, PR link or #123 to put what changed on the map first; off stops it', argumentHint: '[base | PR link | #123 | findings <file> | off]' }).catch(() => {})
71 await $.tool.register({
72 name: 'findings',
73 description: 'Puts the findings of a code review on the Mission Control code map: each file with a finding turns pink and the finding shows under its line in the diff. Call it with the findings of any review, whoever wrote it. `add: true` keeps the findings already shown.',
74 isDeferred: false,
75 inputSchema: {
76 type: 'object',
77 properties: {
78 findings: {
79 type: 'array',
80 items: {
81 type: 'object',
82 properties: {
83 file: { type: 'string', description: 'Repo-relative path' },
84 line: { type: 'integer', description: '1-indexed line in the new version of the file; leave out for a finding on the whole file' },
85 summary: { type: 'string', description: 'One sentence: the defect' },
86 scenario: { type: 'string', description: 'Concrete inputs or state, then the wrong result' },
87 severity: { type: 'string', description: 'e.g. high, medium, low, or a category' },
88 },
89 required: ['file', 'summary'],
90 },
91 },
92 add: { type: 'boolean', description: 'Keep the findings already on the page instead of replacing them' },
93 },
94 required: ['findings'],
95 },
96 }).catch(() => {})
97 $.clock.every(1000, () => {
98 void (async () => {
99 const busy = (await read($, nodes)).some(n => n.status === 'running')
100 if (busy) await publish($) // the clocks on running calls tick
101 })().catch(() => {})
102 })
103 return r
104 })
105
106 on('turn.start', async ($, e, next) => {
107 const t = (await read($, turn)) + 1
108 await update($, turn, () => t)
109 const main: MissionNode = { id: 'main', parent: null, kind: 'main', label: `main · ${words(e.text, 50)}`, family: 'main', status: 'running', start: Date.now() }
110 // A background agent still running from the last turn carries over, with its open calls.
111 await update($, files, list => list.map(f => (f.review ? { ...f, review: undefined } : f))) // a review is a one-time snapshot: the live map takes over
112 await update($, nodes, list => {
113 const agents = list.filter(n => n.kind === 'agent' && n.status === 'running').map(a => ({ ...a, parent: 'main' }))
114 const ids = new Set(agents.map(a => a.id))
115 const open = list.filter(n => n.kind === 'tool' && n.status === 'running' && ids.has(n.parent ?? ''))
116 return [main, ...agents, ...open]
117 })
118 await publish($)
119 return next(e)
120 })
121
122 on('agent.spawn', async ($, e, next) => {
123 const r = await next(e)
124 if (r.agentId) {
125 const id = r.agentId
126 const agent: MissionNode = { id, parent: e.parentAgentId ?? 'main', kind: 'agent', label: e.description || e.subagentType, family: 'agent', status: 'running', start: Date.now() }
127 await update($, nodes, list => cap([...list, agent]))
128 await publish($)
129 }
130 return r
131 })
132
133 // The findings tool, served here: the model hands over a review's findings and the page shows them.
134 on('tool.call', { tool: 'mcp__mission__findings' }, async ($, e) => {
135 const input = e as unknown as { findings?: unknown; add?: unknown }
136 const got = normalize(input.findings)
137 if (got.length === 0) return { result: 'No findings were given: each needs a file and a summary.' }
138 const n = await setFindings($, got, input.add === true)
139 return { result: `${got.length} findings on the Mission Control map (${n.onMap} on files shown there${n.off ? `, ${n.off} on files not on the map` : ''}). /mission opens the page.` }
140 })
141
142 // /code-review reports through ReportFindings: they go on the map without a word from the model.
143 on('tool.call', { tool: 'ReportFindings' }, async ($, e, next) => {
144 const r = await next(e)
145 const got = normalize((e as unknown as { findings?: unknown }).findings)
146 if (r.deny === undefined && r.isError !== true && got.length) await setFindings($, got, false).catch(() => {})
147 return r
148 })
149
150 on('tool.call', async ($, e, next) => {
151 if (e.tool === 'Agent') return next(e) // its subagent shows up through agent.spawn
152 if (INTERNAL.has(e.tool)) return next(e) // bookkeeping, not work a person would follow
153 const args = e as unknown as Record<string, unknown>
154 const { label: text, family } = label(args)
155 const id = e.tool_use_id
156 await update($, nodes, list => {
157 // A call from an agent this tree does not know hangs off main rather than nowhere.
158 const parent = e.agentId && list.some(n => n.id === e.agentId) ? e.agentId : 'main'
159 return cap([...list, { id, parent, kind: 'tool', label: text, family, status: 'running', start: Date.now() }])
160 })
161 await publish($)
162 const path = typeof args.file_path === 'string' ? args.file_path : undefined
163 if (path) await touch($, path, e.tool === 'Read' ? 'read' : e.tool === 'Write' ? 'write' : e.tool === 'Edit' ? 'edit' : 'search', false)
164
165 let failed = true
166 let r: Awaited<ReturnType<typeof next>>
167 try {
168 r = await next(e)
169 failed = r.deny !== undefined || r.isError === true
170 } finally {
171 await update($, nodes, list => list.map(n => (n.id === id ? { ...n, status: failed ? 'failed' : 'done', end: Date.now() } : n)))
172 await publish($)
173 }
174 if (path && !failed && (e.tool === 'Edit' || e.tool === 'Write')) {
175 const what = e.tool === 'Edit' ? `- ${String(args.old_string ?? '').slice(0, 300)}\n+ ${String(args.new_string ?? '').slice(0, 300)}` : `wrote ${String(args.content ?? '').slice(0, 400)}`
176 await touch($, path, e.tool === 'Edit' ? 'edit' : 'write', true, what)
177 }
178 return r
179 })
180
181 on('turn.complete', async ($, e, next) => {
182 const r = await next(e)
183 const id = e.agentId ?? 'main'
184 const failed = e.reason === 'error' || e.reason === 'aborted'
185 const isMain = !e.agentId
186 // The main turn ending closes everything it left marked running, so the clock can rest.
187 await update($, nodes, list => {
188 // Only main's own leftovers: a background agent still running keeps its open calls.
189 const live = new Set(list.filter(n => n.kind === 'agent' && n.status === 'running' && n.id !== id).map(n => n.id))
190 const close = (n: MissionNode) => n.id === id || (isMain && n.kind === 'tool' && !live.has(n.parent ?? ''))
191 return list.map(n => (close(n) && n.status === 'running' ? { ...n, status: failed ? 'failed' : 'done', end: Date.now() } : n))
192 })
193 await publish($)
194 if (isMain && page.on) {
195 void explainPending($).catch(() => {}) // in the background, so the turn ends at once
196 void refreshWhere($).catch(() => {})
197 }
198 return r
199 })
200
201 on('command.run', { command: 'mission' }, async ($, e) => run($, e.args))
202
203 // The band: one summary line while Claude works, and for a short while after.
204 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
205 const rest = await next(e) // what other mods and Claude Code draw here stays
206 const list = await read($, nodes)
207 const main = list.find(n => n.kind === 'main')
208 const s = summary(list)
209 const isRecent = main !== undefined && (main.status === 'running' || Date.now() - (main.end ?? 0) < BAND_AFTER_MS)
210 // While the page is served, its short address and the summary stay on the band: Cmd-click reopens a tab that was closed.
211 const link = bridge.base ? `${bridge.base}/` : undefined
212 const busy = (isRecent || link !== undefined) && s.tools + s.agents > 0
213 if (e.props.hasSurvey || (!busy && !link)) return rest
214 const t = await read($, turn)
215 const edited = (await read($, files)).filter(f => f.changedTurn === t).length
216 const { Box, Text, Link } = $.ui.resolve(e)
217 const port = link ? /:(\d+)\//.exec(link)?.[1] : undefined
218 return (
219 <Box flexDirection="column">
220 <Text wrap="truncate-end">
221 <Text color="blue" bold>{' ◈ mission: '}</Text>
222 {busy ? <Text>{`${s.agents ? `${s.running}/${s.agents} agents · ` : ''}${s.tools} tools${s.failed ? ` · ${s.failed} failed` : ''}${edited ? ` · ${edited} files changed` : ''}`}</Text> : null}
223 {link ? <Text dimColor>{busy ? ' · ' : ''}<Link href={link} label={`localhost:${port} ↗`} /></Text> : <Text dimColor>{' · /mission'}</Text>}
224 </Text>
225 {rest}
226 </Box>
227 )
228 })
229}
230
231// /mission [base | PR link | #123 | off]: opens the page (on the code map when it was given something to review),
232// or stops it. `HEAD` reviews the uncommitted changes.
233async function run($: EngineInterface, args: string) {
234 const arg = args.trim()
235 if (arg.toLowerCase() === 'off') {
236 page.on = false
237 bridge.stop = true // the server's read loop ends at its next beat, which ends the server
238 bridge.base = undefined
239 bridge.starting = undefined
240 return { text: 'Mission Control: page stopped. /mission opens it again.' }
241 }
242 const fcmd = /^findings(?:\s+(.*))?$/i.exec(arg)
243 if (fcmd) return loadFindings($, (fcmd[1] ?? '').trim())
244 let note = ''
245 let here: MissionWhere
246 if (arg) {
247 const r = await review($, arg)
248 if ('error' in r) return { text: `Mission Control review: ${r.error}` }
249 if (r.count === 0) return { text: `Mission Control review: no changed code files against ${r.ref}.` }
250 note = `review: ${r.count} changed files against ${r.ref}. `
251 here = r.where
252 } else {
253 here = await liveWhere($)
254 }
255 await update($, where, () => here)
256 const s = summary(await read($, nodes))
257 page.on = true
258 await writePage($)
259 const opened = await openPage($, arg ? 'code' : undefined, await startBridge($))
260 void explainPending($).catch(() => {}) // the map is watched now: explain what changed while it was not
261 return { text: `Mission Control: ${note}${s.agents} agents · ${s.tools} tool calls · ${(await read($, files)).length} files. ${opened}` }
262}
263
264// The page's branch and pull request, read again when a turn ends: a pull request opened (or a branch switched)
265// since /mission ran shows up. A review's own base is left alone, and gh is asked only while there is no pull request.
266async function refreshWhere($: EngineInterface) {
267 const now = await read($, where)
268 if (now.base || (now.branch && now.pr)) return
269 const next = await liveWhere($)
270 if (next.branch !== now.branch || next.pr?.number !== now.pr?.number) {
271 await update($, where, () => next)
272 await publish($)
273 }
274}
275
276// A GitHub pull request named as a link or as #123: its number, and the repo when a link says which.
277export function parsePr(arg: string) {
278 const link = /^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)(?:[/?#].*)?$/.exec(arg)
279 if (link) return { repo: link[1] as string, number: link[2] as string }
280 const num = /^#(\d+)$/.exec(arg)
281 return num ? { repo: undefined, number: num[1] as string } : undefined
282}
283
284// Fills the code map from git once: the files changed against `base` (uncommitted changes when none), or the files of
285// a pull request given as a link or #123, with their diffs queued for the one-line "why". Nothing watches git
286// afterwards; the live map carries on from Claude's own edits.
287export async function review($: EngineInterface, base: string) {
288 const arg = base.trim()
289 if (/^-/.test(arg)) return { error: `"${arg}" is not a branch, a commit or a pull request.` }
290 const pr = parsePr(arg)
291 if (pr?.repo) return reviewRemote($, pr.repo, pr.number) // a link names its repo: no clone needed
292 const git = async (argv: string[]) => $.process.run(['git', ...argv], { timeoutMs: 60_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
293 const top = await git(['rev-parse', '--show-toplevel'])
294 if (top.exitCode !== 0) return { error: 'this is not a git repository.' }
295 const root = top.stdout.trim()
296
297 // What the diff runs between, where a file's text comes from, and what to call it.
298 let from = arg || 'HEAD'
299 let to = '' // empty: the working tree
300 let label = from
301 let here: MissionWhere | undefined // set for a pull request; a plain base is looked at from the branch we are on
302 if (pr) {
303 const view = await $.process.run(['gh', 'pr', 'view', pr.number, '--json', 'baseRefName,headRefName,url'], { timeoutMs: 30_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
304 let baseRef: unknown
305 let viewed: { baseRefName?: unknown; headRefName?: unknown; url?: unknown } = {}
306 try {
307 viewed = JSON.parse(view.stdout)
308 baseRef = viewed.baseRefName
309 } catch {}
310 if (view.exitCode !== 0 || typeof baseRef !== 'string' || !/^[\w./-]+$/.test(baseRef) || baseRef.startsWith('-')) return { error: `gh could not read pull request #${pr.number} (is gh signed in?).` }
311 // Fetched without making a branch or touching the working tree; the commits are named by their ids.
312 if ((await git(['-C', root, 'fetch', '--quiet', 'origin', `pull/${pr.number}/head`])).exitCode !== 0) return { error: `git could not fetch pull request #${pr.number} from origin.` }
313 to = (await git(['-C', root, 'rev-parse', 'FETCH_HEAD'])).stdout.trim()
314 if ((await git(['-C', root, 'fetch', '--quiet', 'origin', baseRef])).exitCode !== 0) return { error: `git could not fetch ${baseRef} from origin.` }
315 const baseSha = (await git(['-C', root, 'rev-parse', 'FETCH_HEAD'])).stdout.trim()
316 from = (await git(['-C', root, 'merge-base', baseSha, to])).stdout.trim()
317 if (!from || !to) return { error: `git could not find where pull request #${pr.number} branches off ${baseRef}.` }
318 label = `PR #${pr.number} (${baseRef})`
319 here = { branch: typeof viewed.headRefName === 'string' ? viewed.headRefName : `PR #${pr.number}`, base: baseRef, pr: prOf(Number(pr.number), viewed.url) }
320 }
321
322 const range = to ? [from, to] : [from]
323 const changed = await git(['-C', root, 'diff', '--name-only', '-z', ...range, '--'])
324 if (changed.exitCode !== 0) return { error: `git could not diff against "${arg || from}".` }
325 const fresh = to ? { exitCode: 1, stdout: '' } : await git(['-C', root, 'ls-files', '--others', '--exclude-standard', '-z'])
326 const tracked = changed.stdout.split('\0').filter(Boolean)
327 const untracked = fresh.exitCode === 0 ? fresh.stdout.split('\0').filter(Boolean) : []
328 const paths = [...new Set([...tracked, ...untracked])].filter(p => REVIEW_FILE.test(p)).slice(0, REVIEW_MAX)
329 const t = await read($, turn)
330 const shown = new Map<string, { text: string; ref?: string }>()
331 const found = await Promise.all(
332 paths.map(async (rel): Promise<MapFile | undefined> => {
333 const path = `${root}/${rel}`
334 // A pull request's code is not on disk: read it from the fetched commit.
335 const text = to ? (await git(['-C', root, 'show', `${to}:${rel}`])).stdout : await $.fs.read(path).catch(() => undefined)
336 if (typeof text !== 'string' || (to && text === '')) return undefined // deleted since, or in the PR: nothing to map
337 const links = linksOf(path, text.slice(0, 200_000))
338 const d = tracked.includes(rel) ? await git(['-C', root, 'diff', '-U3', ...range, '--', rel]) : { exitCode: 0, stdout: '' }
339 const body = d.stdout.split('\n').filter(l => /^[+-]/.test(l) && !/^(\+\+\+|---)/.test(l)).join('\n').slice(0, 1500)
340 shown.set(path, { text: (d.stdout || addedDiff(text)).slice(0, DIFF_MAX), ref: label })
341 return { path, act: 'edit', at: Date.now() - 60_000, changedTurn: 0, review: true, imports: links.imports, names: links.names, edits: [body || `new file\n${text.slice(0, 400)}`], editsTurn: t } // a minute old: on the map as changed, not glowing as if Claude were editing it right now
342 }),
343 )
344 return { count: await place($, found, shown), ref: label, where: here ?? { ...(await liveWhere($)), base: arg && arg !== 'HEAD' ? arg : undefined } }
345}
346
347// A pull request's number and link, when the link is one we would open.
348function prOf(number: number, url: unknown): MissionWhere['pr'] {
349 return typeof url === 'string' && /^https:\/\/\S+$/.test(url) ? { number, url } : undefined
350}
351
352// The branch we are on and its pull request, when there is one.
353async function liveWhere($: EngineInterface): Promise<MissionWhere> {
354 const git = async (argv: string[]) => $.process.run(['git', ...argv], { timeoutMs: 10_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
355 const b = await git(['rev-parse', '--abbrev-ref', 'HEAD'])
356 let branch = b.exitCode === 0 ? b.stdout.trim() : ''
357 if (branch === 'HEAD') {
358 const sha = await git(['rev-parse', '--short', 'HEAD'])
359 return { branch: sha.exitCode === 0 ? `detached at ${sha.stdout.trim()}` : '' } // no branch, so no pull request
360 }
361 if (!branch) return { branch: '' }
362 const view = await $.process.run(['gh', 'pr', 'view', '--json', 'number,url'], { timeoutMs: 15_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
363 let pr: MissionWhere['pr']
364 try {
365 const v = JSON.parse(view.stdout) as { number?: unknown; url?: unknown }
366 if (view.exitCode === 0 && typeof v.number === 'number') pr = prOf(v.number, v.url)
367 } catch {}
368 return { branch, pr }
369}
370
371// The files a review found go on the map, in front of what Claude touched; how many did.
372async function place($: EngineInterface, found: (MapFile | undefined)[], shown: Map<string, { text: string; ref?: string }>) {
373 const list = found.filter((f): f is MapFile => f !== undefined)
374 await update($, diffs, old => ({ ...old, ...Object.fromEntries(list.flatMap(f => (shown.has(f.path) ? [[f.path, shown.get(f.path)]] : []))) }))
375 await update($, files, old => [...list, ...old.filter(f => !f.review && !list.some(x => x.path === f.path))].slice(0, REVIEW_MAX))
376 return list.length
377}
378
379// A pull request by its link, through GitHub alone: no clone, nothing fetched. The paths read /owner/repo/path.
380async function reviewRemote($: EngineInterface, repo: string, number: string) {
381 const gh = async (argv: string[]) => $.process.run(['gh', ...argv], { timeoutMs: 30_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
382 const meta = await gh(['api', `repos/${repo}/pulls/${number}`, '--jq', '{sha: .head.sha, base: .base.ref, head: .head.ref, url: .html_url}'])
383 let head: { sha?: unknown; base?: unknown; head?: unknown; url?: unknown } = {}
384 try {
385 head = JSON.parse(meta.stdout)
386 } catch {}
387 if (meta.exitCode !== 0 || typeof head.sha !== 'string' || !/^[0-9a-f]{40}$/.test(head.sha)) return { error: `gh could not read ${repo} pull request #${number} (is gh signed in, and can it see that repo?).` }
388 const sha = head.sha
389 const listed = await gh(['api', `repos/${repo}/pulls/${number}/files?per_page=100`, '--jq', '.[] | {filename, status, patch}'])
390 if (listed.exitCode !== 0) return { error: `gh could not list the files of ${repo} pull request #${number}.` }
391 const rows = listed.stdout.split('\n').flatMap(line => {
392 try {
393 const f = JSON.parse(line) as { filename?: unknown; status?: unknown; patch?: unknown }
394 return typeof f.filename === 'string' && f.status !== 'removed' && REVIEW_FILE.test(f.filename) ? [{ name: f.filename, patch: typeof f.patch === 'string' ? f.patch : '' }] : []
395 } catch {
396 return []
397 }
398 })
399 const t = await read($, turn)
400 const ref = `PR #${number} (${head.base}) ${repo}@${sha.slice(0, 7)}`
401 const shown = new Map<string, { text: string; ref?: string }>()
402 const found = await Promise.all(
403 rows.slice(0, REVIEW_MAX).map(async ({ name, patch }): Promise<MapFile | undefined> => {
404 const path = `/${repo}/${name}`
405 const raw = await gh(['api', '-H', 'Accept: application/vnd.github.raw', `repos/${repo}/contents/${name.split('/').map(encodeURIComponent).join('/')}?ref=${sha}`])
406 const text = raw.exitCode === 0 ? raw.stdout : ''
407 const links = linksOf(path, text.slice(0, 200_000))
408 const body = patch.split('\n').filter(l => /^[+-]/.test(l)).join('\n').slice(0, 1500) // a patch has no file headers: only hunk and +/- lines
409 shown.set(path, { text: patch.slice(0, DIFF_MAX), ref }) // GitHub sends no patch for a very large or binary file: the drawer says so
410 return { path, act: 'edit', at: Date.now() - 60_000, changedTurn: 0, review: true, imports: links.imports, names: links.names, edits: [body || `changed ${name}`], editsTurn: t }
411 }),
412 )
413 const here: MissionWhere = { branch: typeof head.head === 'string' ? head.head : `PR #${number}`, base: typeof head.base === 'string' ? head.base : undefined, pr: prOf(Number(number), head.url) }
414 return { count: await place($, found, shown), ref: `PR #${number} (${head.base})`, where: here }
415}
416
417// Notes a file Claude touched, with what it links to (imports and mentioned names, per language).
418async function touch($: EngineInterface, path: string, act: MapFile['act'], isChange: boolean, what?: string) {
419 if (!CODE_FILE.test(path)) return // an image, a PDF, a lockfile: not code to map
420 const t = await read($, turn)
421 const text = await $.fs.read(path).catch(() => '')
422 const links = typeof text === 'string' ? linksOf(path, text.slice(0, 200_000)) : { imports: [], names: [] } // imports sit near the top
423 await update($, files, list => {
424 const old = list.find(f => f.path === path)
425 const edits = isChange && what ? (old?.editsTurn === t ? [...(old.edits ?? []), what] : [what]) : old?.edits
426 const next: MapFile = { path, act, at: Date.now(), changedTurn: isChange ? t : (old?.changedTurn ?? 0), imports: links.imports.length ? links.imports : (old?.imports ?? []), names: links.names.length ? links.names : (old?.names ?? []), why: isChange ? undefined : old?.why, edits, editsTurn: isChange && what ? t : old?.editsTurn }
427 return [...list.filter(f => f.path !== path), next].sort((a, b) => b.at - a.at).slice(0, MAX_FILES)
428 })
429 if (isChange) {
430 const paths = (await read($, files)).map(f => f.path)
431 await update($, findings, old => markStale(old, path, paths))
432 await liveDiff($, path, typeof text === 'string' ? text : '')
433 }
434 await publish($)
435 $.clock.after(5500, () => void publish($).catch(() => {})) // again once the glow has faded
436}
437
438// What a file Claude just changed looks like against HEAD, for the page's drawer. Nothing when git cannot say.
439async function liveDiff($: EngineInterface, path: string, text: string) {
440 const dir = path.slice(0, path.lastIndexOf('/')) || '/'
441 const git = async (argv: string[]) => $.process.run(['git', '-C', dir, ...argv], { timeoutMs: 10_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
442 const d = await git(['diff', 'HEAD', '--no-color', '-U3', '--', path])
443 if (d.exitCode !== 0) return
444 const known = d.stdout !== '' || (await git(['ls-files', '--error-unmatch', '--', path])).exitCode === 0
445 const body = d.stdout || (known ? '' : addedDiff(text)) // a new file git does not know yet reads as all added
446 await update($, diffs, old => {
447 const { [path]: _, ...rest } = old
448 return body ? { ...rest, [path]: { text: body.slice(0, DIFF_MAX) } } : rest
449 })
450}
451
452// One plain line per changed file that has none yet, from what changed in its last turn.
453async function explainPending($: EngineInterface) {
454 const todo = (await read($, files)).filter(f => f.edits?.length && !asking.has(f.path)).map(f => [f.path, { turn: f.editsTurn ?? 0, edits: f.edits ?? [] }] as const)
455 if (todo.length === 0) return
456 const paths = todo.map(([path]) => path)
457 for (const path of paths) asking.add(path)
458 try {
459 const plain = (t: string) => t.replace(/[<>"]/g, ' ')
460 const body = todo.map(([p, { edits }], i) => `<file n="${i + 1}" name="${plain(p.split('/').slice(-2).join('/'))}">\n${plain(edits.join('\n').slice(0, 1500))}\n</file>`).join('\n')
461 const r = await $.model.complete({
462 model: 'haiku',
463 maxTokens: 400,
464 system: 'For each file, say in plain words what changed, at most 60 characters, no em dashes. Reply with a JSON array of strings only, one per file, in the same order.',
465 prompt: `${body}\n\nReply with the JSON array only: ${paths.length} strings.`,
466 })
467 if (!r.isAnswered) return
468 let whys: unknown
469 try {
470 whys = JSON.parse(r.text.slice(r.text.indexOf('['), r.text.lastIndexOf(']') + 1))
471 } catch {
472 return
473 }
474 if (!Array.isArray(whys)) return
475 // By position, so nothing has to match a path the model may have rewritten.
476 const byPath = new Map(todo.map(([p, { turn: t }], i) => [p, { turn: t, why: typeof whys[i] === 'string' ? (whys[i] as string).replace(/\s*—\s*/g, ', ').slice(0, 80) : undefined }]))
477 // A file edited again since was queued anew under a later turn: this answer must not label it.
478 // The edits are dropped with it, unless the file changed again since: then they stay queued for that later turn.
479 await update($, files, list => list.map(f => (byPath.get(f.path)?.why && f.editsTurn === byPath.get(f.path)?.turn ? { ...f, why: byPath.get(f.path)?.why, edits: undefined } : f)))
480 await publish($)
481 } finally {
482 for (const path of paths) asking.delete(path)
483 }
484}
485
486// Writes the page's data about once a second, only once /mission has opened it.
487async function publish($: EngineInterface) {
488 if (!page.on) return
489 if (page.pending) {
490 page.dirty = true // writing now: write once more when it is done
491 return
492 }
493 page.pending = true
494 page.dirty = false
495 $.clock.after(400, () => {
496 void (page.on ? writePage($) : Promise.resolve()) // /mission off may have come in meanwhile
497 .catch(() => {})
498 .finally(() => {
499 page.pending = false
500 if (page.dirty) void publish($).catch(() => {})
501 })
502 })
503}
504
505// Puts a review's findings on the page; how many sit on files the map shows.
506async function setFindings($: EngineInterface, got: Finding[], add: boolean) {
507 await update($, findings, old => merge(old, got, add))
508 page.note = ''
509 const all = await read($, findings)
510 const { matched, unmatched } = byPath(all, (await read($, files)).map(f => f.path))
511 await publish($)
512 return { onMap: all.length - unmatched, off: unmatched, files: Object.keys(matched).length }
513}
514
515// /mission findings <file>: findings from a JSON file; `clear` takes them off; with nothing, says what is shown.
516async function loadFindings($: EngineInterface, arg: string) {
517 if (arg === 'clear') {
518 await update($, findings, () => [])
519 await publish($)
520 return { text: 'Mission Control: findings cleared.' }
521 }
522 if (!arg) return { text: `Mission Control: ${(await read($, findings)).length} findings on the page. /mission findings <file.json> loads more; /mission findings clear removes them.` }
523 const add = /(^|\s)--add$/.test(arg)
524 const path = arg.replace(/\s*--add$/, '')
525 const raw = await $.fs.read(path).catch(() => undefined)
526 if (typeof raw !== 'string') return { text: `Mission Control: could not read ${path}.` }
527 const got = parseFindings(raw)
528 if (got.length === 0) return { text: `Mission Control: no findings in ${path}: expected a JSON array of { file, line?, summary, scenario? }.` }
529 const n = await setFindings($, got, add)
530 return { text: `Mission Control: ${got.length} findings loaded, ${n.onMap} on files the map shows${n.off ? `, ${n.off} on files that are not on it` : ''}. /mission opens the page.` }
531}
532
533// Pushes the findings the reviewer picked on the page to the pull request as one review of comments.
534// The page sends ids only: what is posted is what is held here.
535async function postFindings($: EngineInterface, ids: number[]) {
536 if (page.posting) return
537 page.posting = true
538 try {
539 const all = await read($, findings)
540 const chosen = [...new Set(ids)].flatMap(i => (all[i] && !all[i].posted ? [{ i, f: all[i] }] : []))
541 const pr = prRef((await read($, where)).pr?.url)
542 if (!pr) page.note = 'Could not post: this page is not about a pull request.'
543 else if (chosen.length === 0) page.note = 'Nothing to post: those findings were already pushed.'
544 else {
545 const gh = async (argv: string[]) => $.process.run(['gh', ...argv], { timeoutMs: 30_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
546 const sha = (await gh(['api', `repos/${pr.repo}/pulls/${pr.number}`, '--jq', '.head.sha'])).stdout.trim()
547 if (!/^[0-9a-f]{40}$/.test(sha)) page.note = `Could not post: gh could not read ${pr.repo} #${pr.number} (is gh signed in?).`
548 else {
549 // A comment on a line outside the diff makes GitHub refuse the whole review: those go in the review's text.
550 const listed = await gh(['api', `repos/${pr.repo}/pulls/${pr.number}/files?per_page=100`, '--paginate', '--jq', '.[] | {filename, patch}'])
551 const patches: Record<string, string> = {}
552 for (const line of listed.stdout.split('\n')) {
553 try {
554 const f = JSON.parse(line) as { filename?: unknown; patch?: unknown }
555 if (typeof f.filename === 'string') patches[f.filename] = typeof f.patch === 'string' ? f.patch : ''
556 } catch {}
557 }
558 const { inline, rest } = splitByDiff(chosen.map(c => c.f), patches)
559 const file = `${await pageDir($)}/review.json`
560 await $.fs.write(file, JSON.stringify(reviewPayload(inline, rest, sha)))
561 const r = (await $.process.run(['gh', 'api', '-X', 'POST', `repos/${pr.repo}/pulls/${pr.number}/reviews`, '--input', file], { timeoutMs: 30_000 }).catch(() => ({ exitCode: 1, stdout: '', stderr: '' }))) as { exitCode: number; stdout: string; stderr?: string }
562 if (r.exitCode === 0) {
563 const done = new Set(chosen.map(c => c.i))
564 await update($, findings, old => old.map((f, i) => (done.has(i) ? { ...f, posted: true } : f)))
565 page.note = `Posted ${chosen.length} finding${chosen.length === 1 ? '' : 's'} to ${pr.repo} #${pr.number}${rest.length ? ` (${rest.length} in the review text: not on a line of the diff)` : ''}.`
566 } else {
567 const why = `${r.stderr ?? ''} ${r.stdout}`.replace(/\s+/g, ' ').trim().slice(0, 160)
568 page.note = `Could not post, nothing was posted: ${why || 'GitHub refused the review (no permission?)'}`
569 }
570 }
571 }
572 } finally {
573 page.posting = false
574 await publish($)
575 }
576}
577
578async function pageDir($: EngineInterface) {
579 const tmp = ((await $.env.get('TMPDIR')) ?? '/tmp').replace(/\/$/, '')
580 return `${tmp}/mission-control/${(await read($, sid)) || 'session'}`
581}
582
583// The page is one static file; data.js is all that changes.
584async function writePage($: EngineInterface) {
585 const dir = await pageDir($)
586 const at = Date.now()
587 const list = await read($, nodes)
588 const all0 = await read($, findings)
589 const { matched } = byPath(all0.filter(f => !f.dismissed), (await read($, files)).map(f => f.path))
590 const flagged = Object.fromEntries(Object.entries(matched).map(([p, fs]) => [p, fs.filter(f => !f.posted).length || fs.length]))
591 const stale = Object.fromEntries(Object.entries(matched).map(([p, fs]) => [p, fs.some(f => !f.posted) && fs.filter(f => !f.posted).every(f => f.stale)]))
592 const shown = Object.fromEntries(Object.entries(matched).map(([p, fs]) => [p, fs.map(f => ({ id: all0.indexOf(f), file: f.file, line: f.line, summary: f.summary, scenario: f.scenario, severity: f.severity, posted: f.posted === true, stale: f.stale === true }))]))
593 const data = {
594 ...mapData(await read($, files), { at, turn: await read($, turn) }, flagged, stale),
595 who: { summary: summary(list), lines: lines(list, at).map(l => ({ prefix: l.prefix, text: l.text, status: l.status, kind: l.node.kind })) },
596 }
597 // The diffs of the files on the map. The page loads diffs.js when `rev` changes, so data.js stays small.
598 const onMap = new Set((await read($, files)).map(f => f.path))
599 const all = Object.fromEntries(Object.entries(await read($, diffs)).filter(([p]) => onMap.has(p)))
600 const diffJson = JSON.stringify(all).replace(/</g, '\\u003c')
601 const rev = [...diffJson].reduce((h, c) => (Math.imul(h, 31) + c.charCodeAt(0)) | 0, 7)
602 const here = await read($, where)
603 const json = JSON.stringify({ ...data, where: here.branch ? here : undefined, findings: shown, post: { can: Boolean(prRef(here.pr?.url)), note: page.note }, diffs: { rev, paths: Object.keys(all) } }).replace(/</g, '\\u003c')
604 if (json === page.last) return // nothing changed since the last write
605 if (!page.written) {
606 await $.fs.write(`${dir}/index.html`, TEMPLATE)
607 await $.fs.write(`${dir}/hljs.js`, HLJS) // highlight.js, for the diff drawer; the page copes without it
608 page.written = true
609 }
610 if (diffJson !== page.lastDiffs) {
611 await $.fs.write(`${dir}/diffs.js`, `window.DIFFS = ${diffJson};`) // before data.js, which tells the page it changed
612 page.lastDiffs = diffJson
613 }
614 await $.fs.write(`${dir}/data.js`, `window.MAP = ${json};`)
615 page.last = json
616}
617
618// The workspace cmux has in focus, or undefined when it cannot say (the split then goes where cmux would send it).
619async function focusedWorkspace($: EngineInterface) {
620 const r = await $.process.run(['cmux', 'identify'], { timeoutMs: 3_000 }).catch(() => ({ exitCode: 1, stdout: '' }))
621 if (r.exitCode !== 0) return undefined
622 try {
623 const ref = (JSON.parse(r.stdout) as { focused?: { workspace_ref?: unknown } }).focused?.workspace_ref
624 return typeof ref === 'string' && /^[\w:-]+$/.test(ref) ? ref : undefined
625 } catch {
626 return undefined
627 }
628}
629
630// Starts the page's local server once; resolves its address, or undefined where Node is missing or it does not come up
631// (the page then opens from disk and keeps its clipboard buttons). A line the page sent is submitted as a prompt.
632function startBridge($: EngineInterface): Promise<string | undefined> {
633 if (bridge.base) return Promise.resolve(bridge.base)
634 bridge.starting ??= new Promise<string | undefined>(resolve => {
635 bridge.stop = false
636 $.clock.after(4000, () => resolve(undefined))
637 void (async () => {
638 const dir = await pageDir($)
639 await $.fs.write(`${dir}/server.mjs`, SERVER)
640 let rest = ''
641 for await (const piece of $.process.spawn({ argv: ['node', `${dir}/server.mjs`, dir, String(portFor((await read($, sid)) || 'session'))] })) {
642 if (bridge.stop) break // leaving the loop ends the child
643 const { stream, text } = piece as { stream?: string; text?: string }
644 if (stream !== 'stdout' || text === undefined) continue
645 const got = splitLines(rest, text)
646 rest = got.rest
647 for (const line of got.done) {
648 const msg = parseLine(line)
649 if (msg && 'ready' in msg) {
650 bridge.base = `http://127.0.0.1:${msg.port}/${msg.token}`
651 resolve(bridge.base)
652 } else if (msg && 'send' in msg) void $.prompt.submit({ text: msg.send }).catch(() => {})
653 else if (msg && 'post' in msg) void postFindings($, msg.post).catch(() => {})
654 else if (msg && 'dismiss' in msg) void update($, findings, old => dismiss(old, msg.dismiss)).then(() => publish($)).catch(() => {})
655 }
656 }
657 })()
658 .catch(() => {})
659 .finally(() => {
660 bridge.base = undefined
661 bridge.starting = undefined
662 resolve(undefined)
663 })
664 })
665 return bridge.starting
666}
667
668// In a cmux split when this runs inside cmux, otherwise in the default browser.
669// Without a tab the page opens on the one the person used last.
670async function openPage($: EngineInterface, tab?: 'code', base?: string) {
671 const url = `${base ? `${base}/` : `file://${encodeURI(await pageDir($))}/index.html`}${tab ? `#${tab}` : ''}`
672 const inCmux = Boolean(await $.env.get('CMUX_WORKSPACE_ID'))
673 // cmux splits go to $CMUX_WORKSPACE_ID, fixed when Claude Code started: stale once the tab moved or the
674 // session was resumed elsewhere. The workspace in focus is the one the person just typed /mission in.
675 const workspace = inCmux ? await focusedWorkspace($) : undefined
676 const argv = inCmux ? ['cmux', 'browser', 'open-split', url, '--focus', 'true', ...(workspace ? ['--workspace', workspace] : [])] : ['open', url]
677 const r = await $.process.run(argv, { timeoutMs: 10_000 }).catch(() => ({ exitCode: 1 }))
678 return r.exitCode === 0 ? `Opened ${url}` : `Could not open a browser. Open ${url} yourself.`
679}
680hooks/lang.ts 95 lines1// Language adapters: how the code map links files in each language.
2// An adapter says, for one family of file extensions,
3// links · what a file's text points at: relative file imports (resolved to paths, extension
4// stripped) and the names it mentions (classes, modules)
5// defines · the names a file is known to define, from its path alone
6// map.ts turns imports into arrows between the files, and a mentioned name that another touched
7// file defines into one more arrow. To support a language, add an adapter to ADAPTERS.
8
9export type Links = { imports: string[]; names: string[] }
10
11export type Lang = {
12 name: string
13 ext: RegExp
14 links(path: string, text: string): Links
15 defines(path: string): string[]
16}
17
18export const stripExt = (p: string) => p.replace(/\.(tsx?|jsx?|mjs|cjs|py|go|rs|rb|vue|svelte)$/, '').replace(/\/index$/, '')
19
20const dirOf = (path: string) => path.slice(0, path.lastIndexOf('/'))
21
22function join(dir: string, rel: string) {
23 const parts = dir.split('/')
24 for (const seg of rel.split('/')) {
25 if (seg === '..') parts.pop()
26 else if (seg !== '.') parts.push(seg)
27 }
28 return parts.join('/')
29}
30
31const NONE: string[] = []
32const MAX_NAMES = 400
33
34const javascript: Lang = {
35 name: 'js',
36 ext: /\.(tsx?|jsx?|mjs|cjs|vue|svelte)$/i,
37 links(path, text) {
38 const found = new Set<string>()
39 const re = /(?:from\s+|import\s*\(\s*|require\s*\(\s*|import\s+)['"](\.{1,2}\/[^'"]+)['"]/g
40 for (const m of text.matchAll(re)) found.add(stripExt(join(dirOf(path), m[1] as string)))
41 return { imports: [...found], names: NONE }
42 },
43 defines: () => NONE,
44}
45
46const python: Lang = {
47 name: 'py',
48 ext: /\.py$/i,
49 links(path, text) {
50 const found = new Set<string>()
51 const re = /^\s*from\s+(\.+)([\w.]*)\s+import/gm
52 for (const m of text.matchAll(re)) {
53 let base = dirOf(path)
54 for (let i = 0; i < (m[1] as string).length - 1; i++) base = base.slice(0, base.lastIndexOf('/'))
55 if (m[2]) found.add(`${base}/${(m[2] as string).replace(/\./g, '/')}`)
56 }
57 return { imports: [...found], names: NONE }
58 },
59 defines: () => NONE,
60}
61
62// Rails loads code by constant name, not by import: a file links to another when it mentions
63// the class or module that the other one is named after (request_chorus_otp.rb: RequestChorusOtp).
64const RUBY_TOO_COMMON = new Set(['Base', 'Error', 'Config', 'Test', 'Spec', 'Main', 'Helper', 'Concern', 'Module', 'Class', 'Object', 'Result', 'Struct'])
65const camelize = (s: string) => s.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join('')
66
67const ruby: Lang = {
68 name: 'rb',
69 ext: /\.rb$/i,
70 links(path, text) {
71 const code = text.split('\n').filter(l => !/^\s*#/.test(l)).join('\n')
72 const imports = new Set<string>()
73 for (const m of code.matchAll(/\brequire_relative\s*\(?\s*['"]([^'"]+)['"]/g)) imports.add(stripExt(join(dirOf(path), m[1] as string)))
74 for (const m of code.matchAll(/\brequire\s*\(?\s*['"](\.{1,2}\/[^'"]+)['"]/g)) imports.add(stripExt(join(dirOf(path), m[1] as string)))
75 const names = new Set<string>()
76 for (const m of code.matchAll(/\b[A-Z][A-Za-z0-9]*(?:::[A-Z][A-Za-z0-9]*)*/g)) {
77 for (const seg of m[0].split('::')) names.add(seg)
78 if (names.size >= MAX_NAMES) break
79 }
80 return { imports: [...imports], names: [...names] }
81 },
82 defines(path) {
83 const name = camelize((path.split('/').pop() ?? '').replace(/\.rb$/i, ''))
84 return name.length < 4 || RUBY_TOO_COMMON.has(name) ? NONE : [name]
85 },
86}
87
88export const ADAPTERS: Lang[] = [javascript, python, ruby]
89
90export const langFor = (path: string) => ADAPTERS.find(l => l.ext.test(path))
91
92export function linksOf(path: string, text: string): Links {
93 return langFor(path)?.links(path, text) ?? { imports: NONE, names: NONE }
94}
95hooks/bridge.ts 103 lines1// The way back from the page to the session. The mod cannot listen on a socket, so it runs this small Node
2// server as a child process (`$.process.spawn`). It serves the page on 127.0.0.1 and turns each POST /<token>/send
3// into one JSON line on stdout, which register.tsx reads and submits as a prompt, and each POST /<token>/post
4// (the ids of findings to push to the pull request) into a line the mod answers by posting a review. Where Node is missing or the
5// server fails, the page is opened from disk and keeps its clipboard buttons.
6// Keep SERVER free of backticks, dollar-brace sequences and backslashes: it is one template literal.
7
8export const SERVER = `import http from 'node:http'
9import fs from 'node:fs'
10import path from 'node:path'
11import crypto from 'node:crypto'
12
13var dir = process.argv[2]
14var want = Number(process.argv[3]) || 0
15var token = crypto.randomBytes(6).toString('hex') // 48 bits: short enough to read on the band, ample for a loopback port
16var NL = String.fromCharCode(10)
17var TYPES = { 'index.html': 'text/html; charset=utf-8', 'data.js': 'text/javascript; charset=utf-8', 'diffs.js': 'text/javascript; charset=utf-8', 'hljs.js': 'text/javascript; charset=utf-8' }
18var MAX = 400000
19
20function out(o) { process.stdout.write(JSON.stringify(o) + NL) }
21process.stdout.on('error', function () { process.exit(0) })
22
23var server = http.createServer(function (req, res) {
24 var parts = (req.url || '').split('?')[0].split('/')
25 var local = req.headers.host === '127.0.0.1:' + server.address().port
26 if (!local || parts.length !== 3 || parts[1] !== token) { res.writeHead(404); return res.end() }
27 var name = parts[2] || 'index.html' // /<token>/ is the page
28 if (req.method === 'POST' && name === 'send') {
29 var body = ''
30 req.on('data', function (c) { body += c; if (body.length > MAX) { res.writeHead(413); res.end(); req.destroy() } })
31 req.on('end', function () {
32 var text
33 try { text = JSON.parse(body).text } catch (err) {}
34 if (typeof text !== 'string' || !text.trim()) { res.writeHead(400); return res.end() }
35 out({ send: text })
36 res.writeHead(204); res.end()
37 })
38 return
39 }
40 if (req.method === 'POST' && (name === 'post' || name === 'dismiss')) {
41 var raw = ''
42 req.on('data', function (c) { raw += c; if (raw.length > MAX) { res.writeHead(413); res.end(); req.destroy() } })
43 req.on('end', function () {
44 var ids
45 try { ids = JSON.parse(raw).ids } catch (err) {}
46 if (!Array.isArray(ids) || !ids.length || !ids.every(function (n) { return Number.isInteger(n) && n >= 0 })) { res.writeHead(400); return res.end() }
47 var line = {}
48 line[name] = ids
49 out(line)
50 res.writeHead(204); res.end()
51 })
52 return
53 }
54 if (req.method === 'GET' && TYPES[name]) {
55 fs.readFile(path.join(dir, name), function (err, buf) {
56 if (err) { res.writeHead(404); return res.end() }
57 res.writeHead(200, { 'content-type': TYPES[name], 'cache-control': 'no-store' })
58 res.end(buf)
59 })
60 return
61 }
62 res.writeHead(404); res.end()
63})
64
65function ready() {
66 out({ ready: true, port: server.address().port, token: token })
67 setInterval(function () { out({ beat: 1 }) }, 1000) // the mod stops a server by leaving its read loop
68}
69// The port a session had last time keeps the page's origin, so the comments saved in its localStorage survive.
70server.on('error', function (err) { if (want && err.code === 'EADDRINUSE') { want = 0; server.listen(0, '127.0.0.1', ready) } else { console.error(String(err)); process.exit(1) } })
71server.listen(want, '127.0.0.1', ready)
72`
73
74export type BridgeLine = { ready: true; port: number; token: string } | { send: string } | { post: number[] } | { dismiss: number[] } | { beat: true }
75
76// What a line of the server's stdout says, or undefined for anything else.
77export function parseLine(line: string): BridgeLine | undefined {
78 try {
79 const v = JSON.parse(line) as Record<string, unknown>
80 if (v.ready === true && typeof v.port === 'number' && typeof v.token === 'string' && /^\w+$/.test(v.token)) return { ready: true, port: v.port, token: v.token }
81 if (typeof v.send === 'string') return { send: v.send }
82 if (Array.isArray(v.post) && v.post.length > 0 && v.post.every(n => Number.isInteger(n) && n >= 0)) return { post: v.post as number[] }
83 if (Array.isArray(v.dismiss) && v.dismiss.length > 0 && v.dismiss.every(n => Number.isInteger(n) && n >= 0)) return { dismiss: v.dismiss as number[] }
84 if (v.beat === 1) return { beat: true }
85 } catch {
86 // not ours: ignore
87 }
88 return undefined
89}
90
91// Pieces of stdout arrive cut anywhere; the whole lines so far, and what is left of the last one.
92export function splitLines(rest: string, text: string): { done: string[]; rest: string } {
93 const parts = (rest + text).split('\n')
94 return { done: parts.slice(0, -1).filter(l => l.trim() !== ''), rest: parts[parts.length - 1] ?? '' }
95}
96
97// A port in 20000-59999 taken from the session id, the same every time.
98export function portFor(sid: string): number {
99 let h = 7
100 for (const c of sid) h = (Math.imul(h, 31) + c.charCodeAt(0)) >>> 0
101 return 20000 + (h % 40000)
102}
103hooks/diff.ts 74 lines1// The diff drawer's logic. parseDiff, formatComment and formatReview run in the page too: template.ts
2// splices their source into its script, so they may call only each other.
3
4// One row of a diff: a hunk header (h), unchanged (c), added (a) or deleted (d) line, with its numbers.
5export type DiffLine = { k: 'h' | 'c' | 'a' | 'd'; o?: number; n?: number; t: string }
6export type ReviewComment = { path: string; lines: DiffLine[]; text: string }
7
8// A unified diff of one file, with or without its file headers (a GitHub patch has none). Rows are counted off
9// each hunk's header, so a deleted line that reads "-- x" is never taken for a file header.
10export function parseDiff(text: string): DiffLine[] {
11 const out: DiffLine[] = []
12 let o = 0
13 let n = 0
14 let left = { o: 0, n: 0 }
15 for (const raw of text.split('\n')) {
16 if (left.o <= 0 && left.n <= 0) {
17 const m = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/.exec(raw)
18 if (!m) continue // file headers, "\ No newline" markers, trailing blank
19 o = Number(m[1])
20 n = Number(m[3])
21 left = { o: m[2] === undefined ? 1 : Number(m[2]), n: m[4] === undefined ? 1 : Number(m[4]) }
22 if (left.o === 0) o += 1 // a side with no lines starts one past the number it prints
23 if (left.n === 0) n += 1
24 out.push({ k: 'h', t: raw })
25 continue
26 }
27 const c = raw[0]
28 if (c === '+') {
29 out.push({ k: 'a', n, t: raw.slice(1) })
30 n++
31 left.n--
32 } else if (c === '-') {
33 out.push({ k: 'd', o, t: raw.slice(1) })
34 o++
35 left.o--
36 } else if (c === '\\') {
37 continue
38 } else {
39 out.push({ k: 'c', o, n, t: raw.slice(1) })
40 o++
41 n++
42 left.o--
43 left.n--
44 }
45 }
46 return out
47}
48
49// "path:L12-15", the lines quoted as a diff, then what the person said.
50export function formatComment(path: string, lines: DiffLine[], text: string): string {
51 const news = lines.filter(l => l.n !== undefined).map(l => l.n as number)
52 const olds = lines.filter(l => l.o !== undefined).map(l => l.o as number)
53 const nums = news.length ? news : olds
54 const lo = Math.min(...nums)
55 const hi = Math.max(...nums)
56 const where = `${path}:L${lo === hi ? lo : `${lo}-${hi}`}${news.length ? '' : ' (removed)'}`
57 const shown = lines.slice(0, 12).map(l => `> ${l.k === 'a' ? '+' : l.k === 'd' ? '-' : ' '}${l.t}`)
58 if (lines.length > 12) shown.push(`> … ${lines.length - 12} more lines`)
59 return `${where}\n${shown.join('\n')}\n\n${text}`
60}
61
62// What "Send review" and "Send now" put on the clipboard.
63export function formatReview(comments: ReviewComment[], ref: string): string {
64 const head = `Code review comments${ref ? ` on ${ref}` : ''} (${comments.length}):`
65 return `${head}\n\n${comments.map(c => formatComment(c.path, c.lines, c.text)).join('\n\n---\n\n')}`
66}
67
68// A file with no earlier version, as a diff that adds every line.
69export function addedDiff(text: string): string {
70 if (text === '') return ''
71 const rows = text.replace(/\n$/, '').split('\n')
72 return `@@ -0,0 +1,${rows.length} @@\n${rows.map(r => `+${r}`).join('\n')}`
73}
74hooks/findings.ts 138 lines1// Review findings from an AI review, shown pink on the code map and under their line in the diff drawer.
2// Any review can feed them: the findings tool, `/mission findings <file>`, or the ReportFindings call of /code-review.
3import type { Finding } from '../types'
4
5const MAX_FINDINGS = 200
6const text = (v: unknown, max: number) => (typeof v === 'string' ? v.replace(/\s+/g, ' ').trim().slice(0, max) : '')
7
8// Findings from whatever a review produced: an array, or an object holding one under `findings`.
9// Rows without a file or a summary are dropped. `ReportFindings` field names are accepted as they are.
10export function normalize(input: unknown): Finding[] {
11 const rows = Array.isArray(input) ? input : input && typeof input === 'object' ? (input as { findings?: unknown }).findings : undefined
12 if (!Array.isArray(rows)) return []
13 return rows.flatMap((raw): Finding[] => {
14 if (!raw || typeof raw !== 'object') return []
15 const r = raw as Record<string, unknown>
16 const file = text(r.file, 500)
17 const summary = text(r.summary ?? r.short_summary, 400)
18 if (!file || !summary) return []
19 const line = typeof r.line === 'number' && Number.isInteger(r.line) && r.line > 0 ? r.line : undefined
20 const scenario = text(r.scenario ?? r.failure_scenario, 1200)
21 const severity = text(r.severity ?? r.category, 40)
22 return [{ file, line, summary, scenario: scenario || undefined, severity: severity || undefined }]
23 }).slice(0, MAX_FINDINGS)
24}
25
26// Findings from a file's text: JSON only, `[]` when it is anything else.
27export function parseFindings(raw: string): Finding[] {
28 try {
29 return normalize(JSON.parse(raw))
30 } catch {
31 return []
32 }
33}
34
35// The map path a finding's file is: the path itself, or the one ending in `/<file>` (findings give repo-relative paths,
36// the map holds absolute ones). Several matches: the shortest, which is the closest to the repo root.
37export function matchPath(file: string, mapPaths: string[]): string | undefined {
38 const rel = file.replace(/^\.\//, '').replace(/^\/+/, '')
39 const hits = mapPaths.filter(p => p === file || p.endsWith(`/${rel}`))
40 return hits.sort((a, b) => a.length - b.length)[0]
41}
42
43// The findings grouped by the map path they belong to; the rest are counted apart.
44export function byPath(findings: Finding[], mapPaths: string[]) {
45 const matched: Record<string, Finding[]> = {}
46 let unmatched = 0
47 for (const f of findings) {
48 const p = matchPath(f.file, mapPaths)
49 if (p) (matched[p] ??= []).push(f)
50 else unmatched++
51 }
52 return { matched, unmatched }
53}
54
55// The findings on a file that was just edited, marked stale: they were written against the old text. Pushed ones stay as they are.
56export function markStale(all: Finding[], path: string, mapPaths: string[]): Finding[] {
57 return all.map(f => (!f.posted && !f.stale && matchPath(f.file, mapPaths) === path ? { ...f, stale: true } : f))
58}
59
60// The findings with the given ids (their index) put away.
61export function dismiss(all: Finding[], ids: number[]): Finding[] {
62 const gone = new Set(ids)
63 return all.map((f, i) => (gone.has(i) ? { ...f, dismissed: true } : f))
64}
65
66// A new set of findings on top of the old ones (`add`), or in place of them. The same file, line and summary counts once.
67export function merge(old: Finding[], next: Finding[], add: boolean): Finding[] {
68 if (!add) return next
69 const key = (f: Finding) => `${f.file}:${f.line ?? ''}:${f.summary}`
70 const seen = new Set(old.map(key))
71 return [...old, ...next.filter(f => !seen.has(key(f)))].slice(0, MAX_FINDINGS)
72}
73
74// A pull request's repo and number from its link.
75export function prRef(url: string | undefined) {
76 const m = url ? /^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)(?:[/?#].*)?$/.exec(url) : null
77 return m ? { repo: m[1] as string, number: m[2] as string } : undefined
78}
79
80// One comment as GitHub shows it: the summary, then the concrete failure.
81export function commentBody(f: Finding) {
82 return `${f.severity ? `**${f.severity}** · ` : ''}${f.summary}${f.scenario ? `\n\n${f.scenario}` : ''}`
83}
84
85// The new-side line numbers a unified patch shows: the added lines and the context around them. GitHub takes an inline
86// review comment on these lines only, and refuses the whole review when one comment is anywhere else.
87export function diffLines(patch: string): Set<number> {
88 const out = new Set<number>()
89 let at = 0
90 for (const row of patch.split('\n')) {
91 const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(row)
92 if (hunk) {
93 at = Number(hunk[1])
94 } else if (at > 0 && (row.startsWith('+') || row.startsWith(' ') || row === '')) {
95 if (row !== '') out.add(at)
96 at++
97 }
98 }
99 return out
100}
101
102const rel = (file: string) => file.replace(/^\.\//, '').replace(/^\/+/, '')
103
104// The findings that can be inline comments (their line is in the PR's diff) and the rest (no line, a line the diff does
105// not show, or a file the PR does not change), which go in the review's own text instead.
106export function splitByDiff(chosen: Finding[], patches: Record<string, string>) {
107 const cache = new Map<string, Set<number>>()
108 const inline: Finding[] = []
109 const rest: Finding[] = []
110 for (const f of chosen) {
111 const path = rel(f.file)
112 const patch = patches[path]
113 if (f.line && patch !== undefined) {
114 if (!cache.has(path)) cache.set(path, diffLines(patch))
115 if (cache.get(path)?.has(f.line)) {
116 inline.push(f)
117 continue
118 }
119 }
120 rest.push(f)
121 }
122 return { inline, rest }
123}
124
125// The body of POST /repos/{repo}/pulls/{n}/reviews, as one review of comments (nothing is approved or rejected).
126// Inline findings sit on their line of the new side; the rest are listed in the review text, with their line as written.
127export function reviewPayload(inline: Finding[], rest: Finding[], sha: string) {
128 const n = inline.length + rest.length
129 const where = (f: Finding) => `${rel(f.file)}${f.line ? `:${f.line}` : ''}`
130 const body = [`${n} finding${n === 1 ? '' : 's'} from an AI review.`, ...(rest.length ? ['', 'Not on a line of this diff:', ...rest.map(f => `- \`${where(f)}\` ${commentBody(f).replace(/\n+/g, ' ')}`)] : [])].join('\n')
131 return {
132 commit_id: sha,
133 event: 'COMMENT',
134 body,
135 comments: inline.map(f => ({ path: rel(f.file), body: commentBody(f), line: f.line, side: 'RIGHT' })),
136 }
137}
138hooks/vendor-hljs.ts 5 lines1// highlight.js v11.11.1, the common-languages build, vendored unchanged as a string: the page loads it from a file
2// written next to index.html (see writePage), so it works offline. Copyright (c) 2006, Ivan Sagalaev, BSD-3-Clause.
3// Source: https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js; regenerate by pasting a newer file here.
4export const HLJS = "/*!\n Highlight.js v11.11.1 (git: 08cb242e7d)\n (c) 2006-2024 Josh Goebel <hello@joshgoebel.com> and other contributors\n License: BSD-3-Clause\n */\nvar hljs=function(){\"use strict\";function e(n){\nreturn n instanceof Map?n.clear=n.delete=n.set=()=>{\nthrow Error(\"map is read-only\")}:n instanceof Set&&(n.add=n.clear=n.delete=()=>{\nthrow Error(\"set is read-only\")\n}),Object.freeze(n),Object.getOwnPropertyNames(n).forEach((t=>{\nconst a=n[t],i=typeof a;\"object\"!==i&&\"function\"!==i||Object.isFrozen(a)||e(a)\n})),n}class n{constructor(e){\nvoid 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}\nignoreMatch(){this.isMatchIgnored=!0}}function t(e){\nreturn e.replace(/&/g,\"&\").replace(/</g,\"<\").replace(/>/g,\">\").replace(/\"/g,\""\").replace(/'/g,\"'\")\n}function a(e,...n){const t=Object.create(null);for(const n in e)t[n]=e[n]\n;return n.forEach((e=>{for(const n in e)t[n]=e[n]})),t}const i=e=>!!e.scope\n;class r{constructor(e,n){\nthis.buffer=\"\",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){\nthis.buffer+=t(e)}openNode(e){if(!i(e))return;const n=((e,{prefix:n})=>{\nif(e.startsWith(\"language:\"))return e.replace(\"language:\",\"language-\")\n;if(e.includes(\".\")){const t=e.split(\".\")\n;return[`${n}${t.shift()}`,...t.map(((e,n)=>`${e}${\"_\".repeat(n+1)}`))].join(\" \")\n}return`${n}${e}`})(e.scope,{prefix:this.classPrefix});this.span(n)}\ncloseNode(e){i(e)&&(this.buffer+=\"</span>\")}value(){return this.buffer}span(e){\nthis.buffer+=`<span class=\"${e}\">`}}const s=(e={})=>{const n={children:[]}\n;return Object.assign(n,e),n};class o{constructor(){\nthis.rootNode=s(),this.stack=[this.rootNode]}get top(){\nreturn this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){\nthis.top.children.push(e)}openNode(e){const n=s({scope:e})\n;this.add(n),this.stack.push(n)}closeNode(){\nif(this.stack.length>1)return this.stack.pop()}closeAllNodes(){\nfor(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}\nwalk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){\nreturn\"string\"==typeof n?e.addText(n):n.children&&(e.openNode(n),\nn.children.forEach((n=>this._walk(e,n))),e.closeNode(n)),e}static _collapse(e){\n\"string\"!=typeof e&&e.children&&(e.children.every((e=>\"string\"==typeof e))?e.children=[e.children.join(\"\")]:e.children.forEach((e=>{\no._collapse(e)})))}}class l extends o{constructor(e){super(),this.options=e}\naddText(e){\"\"!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){\nthis.closeNode()}__addSublanguage(e,n){const t=e.root\n;n&&(t.scope=\"language:\"+n),this.add(t)}toHTML(){\nreturn new r(this,this.options).value()}finalize(){\nreturn this.closeAllNodes(),!0}}function c(e){\nreturn e?\"string\"==typeof e?e:e.source:null}function d(e){return b(\"(?=\",e,\")\")}\nfunction g(e){return b(\"(?:\",e,\")*\")}function u(e){return b(\"(?:\",e,\")?\")}\nfunction b(...e){return e.map((e=>c(e))).join(\"\")}function m(...e){const n=(e=>{\nconst n=e[e.length-1]\n;return\"object\"==typeof n&&n.constructor===Object?(e.splice(e.length-1,1),n):{}\n})(e);return\"(\"+(n.capture?\"\":\"?:\")+e.map((e=>c(e))).join(\"|\")+\")\"}\nfunction p(e){return RegExp(e.toString()+\"|\").exec(\"\").length-1}\nconst _=/\\[(?:[^\\\\\\]]|\\\\.)*\\]|\\(\\??|\\\\([1-9][0-9]*)|\\\\./\n;function h(e,{joinWith:n}){let t=0;return e.map((e=>{t+=1;const n=t\n;let a=c(e),i=\"\";for(;a.length>0;){const e=_.exec(a);if(!e){i+=a;break}\ni+=a.substring(0,e.index),\na=a.substring(e.index+e[0].length),\"\\\\\"===e[0][0]&&e[1]?i+=\"\\\\\"+(Number(e[1])+n):(i+=e[0],\n\"(\"===e[0]&&t++)}return i})).map((e=>`(${e})`)).join(n)}\nconst f=\"[a-zA-Z]\\\\w*\",E=\"[a-zA-Z_]\\\\w*\",y=\"\\\\b\\\\d+(\\\\.\\\\d+)?\",w=\"(-?)(\\\\b0[xX][a-fA-F0-9]+|(\\\\b\\\\d+(\\\\.\\\\d*)?|\\\\.\\\\d+)([eE][-+]?\\\\d+)?)\",v=\"\\\\b(0b[01]+)\",N={\nbegin:\"\\\\\\\\[\\\\s\\\\S]\",relevance:0},k={scope:\"string\",begin:\"'\",end:\"'\",\nillegal:\"\\\\n\",contains:[N]},x={scope:\"string\",begin:'\"',end:'\"',illegal:\"\\\\n\",\ncontains:[N]},O=(e,n,t={})=>{const i=a({scope:\"comment\",begin:e,end:n,\ncontains:[]},t);i.contains.push({scope:\"doctag\",\nbegin:\"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)\",\nend:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0})\n;const r=m(\"I\",\"a\",\"is\",\"so\",\"us\",\"to\",\"at\",\"if\",\"in\",\"it\",\"on\",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/)\n;return i.contains.push({begin:b(/[ ]+/,\"(\",r,/[.]?[:]?([.][ ]|[ ])/,\"){3}\")}),i\n},M=O(\"//\",\"$\"),A=O(\"/\\\\*\",\"\\\\*/\"),S=O(\"#\",\"$\");var C=Object.freeze({\n__proto__:null,APOS_STRING_MODE:k,BACKSLASH_ESCAPE:N,BINARY_NUMBER_MODE:{\nscope:\"number\",begin:v,relevance:0},BINARY_NUMBER_RE:v,COMMENT:O,\nC_BLOCK_COMMENT_MODE:A,C_LINE_COMMENT_MODE:M,C_NUMBER_MODE:{scope:\"number\",\nbegin:w,relevance:0},C_NUMBER_RE:w,END_SAME_AS_BEGIN:e=>Object.assign(e,{\n\"on:begin\":(e,n)=>{n.data._beginMatch=e[1]},\"on:end\":(e,n)=>{\nn.data._beginMatch!==e[1]&&n.ignoreMatch()}}),HASH_COMMENT_MODE:S,IDENT_RE:f,\nMATCH_NOTHING_RE:/\\b\\B/,METHOD_GUARD:{begin:\"\\\\.\\\\s*\"+E,relevance:0},\nNUMBER_MODE:{scope:\"number\",begin:y,relevance:0},NUMBER_RE:y,\nPHRASAL_WORDS_MODE:{\nbegin:/\\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\\b/\n},QUOTE_STRING_MODE:x,REGEXP_MODE:{scope:\"regexp\",begin:/\\/(?=[^/\\n]*\\/)/,\nend:/\\/[gimuy]*/,contains:[N,{begin:/\\[/,end:/\\]/,relevance:0,contains:[N]}]},\nRE_STARTERS_RE:\"!|!=|!==|%|%=|&|&&|&=|\\\\*|\\\\*=|\\\\+|\\\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\\\?|\\\\[|\\\\{|\\\\(|\\\\^|\\\\^=|\\\\||\\\\|=|\\\\|\\\\||~\",\nSHEBANG:(e={})=>{const n=/^#![ ]*\\//\n;return e.binary&&(e.begin=b(n,/.*\\b/,e.binary,/\\b.*/)),a({scope:\"meta\",begin:n,\nend:/$/,relevance:0,\"on:begin\":(e,n)=>{0!==e.index&&n.ignoreMatch()}},e)},\nTITLE_MODE:{scope:\"title\",begin:f,relevance:0},UNDERSCORE_IDENT_RE:E,\nUNDERSCORE_TITLE_MODE:{scope:\"title\",begin:E,relevance:0}});function T(e,n){\n\".\"===e.input[e.index-1]&&n.ignoreMatch()}function R(e,n){\nvoid 0!==e.className&&(e.scope=e.className,delete e.className)}function D(e,n){\nn&&e.beginKeywords&&(e.begin=\"\\\\b(\"+e.beginKeywords.split(\" \").join(\"|\")+\")(?!\\\\.)(?=\\\\b|\\\\s)\",\ne.__beforeBegin=T,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,\nvoid 0===e.relevance&&(e.relevance=0))}function I(e,n){\nArray.isArray(e.illegal)&&(e.illegal=m(...e.illegal))}function L(e,n){\nif(e.match){\nif(e.begin||e.end)throw Error(\"begin & end are not supported with match\")\n;e.begin=e.match,delete e.match}}function B(e,n){\nvoid 0===e.relevance&&(e.relevance=1)}const $=(e,n)=>{if(!e.beforeMatch)return\n;if(e.starts)throw Error(\"beforeMatch cannot be used with starts\")\n;const t=Object.assign({},e);Object.keys(e).forEach((n=>{delete e[n]\n})),e.keywords=t.keywords,e.begin=b(t.beforeMatch,d(t.begin)),e.starts={\nrelevance:0,contains:[Object.assign(t,{endsParent:!0})]\n},e.relevance=0,delete t.beforeMatch\n},F=[\"of\",\"and\",\"for\",\"in\",\"not\",\"or\",\"if\",\"then\",\"parent\",\"list\",\"value\"]\n;function z(e,n,t=\"keyword\"){const a=Object.create(null)\n;return\"string\"==typeof e?i(t,e.split(\" \")):Array.isArray(e)?i(t,e):Object.keys(e).forEach((t=>{\nObject.assign(a,z(e[t],n,t))})),a;function i(e,t){\nn&&(t=t.map((e=>e.toLowerCase()))),t.forEach((n=>{const t=n.split(\"|\")\n;a[t[0]]=[e,j(t[0],t[1])]}))}}function j(e,n){\nreturn n?Number(n):(e=>F.includes(e.toLowerCase()))(e)?0:1}const U={},P=e=>{\nconsole.error(e)},K=(e,...n)=>{console.log(\"WARN: \"+e,...n)},q=(e,n)=>{\nU[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),U[`${e}/${n}`]=!0)\n},H=Error();function G(e,n,{key:t}){let a=0;const i=e[t],r={},s={}\n;for(let e=1;e<=n.length;e++)s[e+a]=i[e],r[e+a]=!0,a+=p(n[e-1])\n;e[t]=s,e[t]._emit=r,e[t]._multi=!0}function Z(e){(e=>{\ne.scope&&\"object\"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,\ndelete e.scope)})(e),\"string\"==typeof e.beginScope&&(e.beginScope={\n_wrap:e.beginScope}),\"string\"==typeof e.endScope&&(e.endScope={_wrap:e.endScope\n}),(e=>{if(Array.isArray(e.begin)){\nif(e.skip||e.excludeBegin||e.returnBegin)throw P(\"skip, excludeBegin, returnBegin not compatible with beginScope: {}\"),\nH\n;if(\"object\"!=typeof e.beginScope||null===e.beginScope)throw P(\"beginScope must be object\"),\nH;G(e,e.begin,{key:\"beginScope\"}),e.begin=h(e.begin,{joinWith:\"\"})}})(e),(e=>{\nif(Array.isArray(e.end)){\nif(e.skip||e.excludeEnd||e.returnEnd)throw P(\"skip, excludeEnd, returnEnd not compatible with endScope: {}\"),\nH\n;if(\"object\"!=typeof e.endScope||null===e.endScope)throw P(\"endScope must be object\"),\nH;G(e,e.end,{key:\"endScope\"}),e.end=h(e.end,{joinWith:\"\"})}})(e)}function W(e){\nfunction n(n,t){\nreturn RegExp(c(n),\"m\"+(e.case_insensitive?\"i\":\"\")+(e.unicodeRegex?\"u\":\"\")+(t?\"g\":\"\"))\n}class t{constructor(){\nthis.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}\naddRule(e,n){\nn.position=this.position++,this.matchIndexes[this.matchAt]=n,this.regexes.push([n,e]),\nthis.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null)\n;const e=this.regexes.map((e=>e[1]));this.matcherRe=n(h(e,{joinWith:\"|\"\n}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex\n;const n=this.matcherRe.exec(e);if(!n)return null\n;const t=n.findIndex(((e,n)=>n>0&&void 0!==e)),a=this.matchIndexes[t]\n;return n.splice(0,t),Object.assign(n,a)}}class i{constructor(){\nthis.rules=[],this.multiRegexes=[],\nthis.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){\nif(this.multiRegexes[e])return this.multiRegexes[e];const n=new t\n;return this.rules.slice(e).forEach((([e,t])=>n.addRule(e,t))),\nn.compile(),this.multiRegexes[e]=n,n}resumingScanAtSamePosition(){\nreturn 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,n){\nthis.rules.push([e,n]),\"begin\"===n.type&&this.count++}exec(e){\nconst n=this.getMatcher(this.regexIndex);n.lastIndex=this.lastIndex\n;let t=n.exec(e)\n;if(this.resumingScanAtSamePosition())if(t&&t.index===this.lastIndex);else{\nconst n=this.getMatcher(0);n.lastIndex=this.lastIndex+1,t=n.exec(e)}\nreturn t&&(this.regexIndex+=t.position+1,\nthis.regexIndex===this.count&&this.considerAll()),t}}\nif(e.compilerExtensions||(e.compilerExtensions=[]),\ne.contains&&e.contains.includes(\"self\"))throw Error(\"ERR: contains `self` is not supported at the top-level of a language. See documentation.\")\n;return e.classNameAliases=a(e.classNameAliases||{}),function t(r,s){const o=r\n;if(r.isCompiled)return o\n;[R,L,Z,$].forEach((e=>e(r,s))),e.compilerExtensions.forEach((e=>e(r,s))),\nr.__beforeBegin=null,[D,I,B].forEach((e=>e(r,s))),r.isCompiled=!0;let l=null\n;return\"object\"==typeof r.keywords&&r.keywords.$pattern&&(r.keywords=Object.assign({},r.keywords),\nl=r.keywords.$pattern,\ndelete r.keywords.$pattern),l=l||/\\w+/,r.keywords&&(r.keywords=z(r.keywords,e.case_insensitive)),\no.keywordPatternRe=n(l,!0),\ns&&(r.begin||(r.begin=/\\B|\\b/),o.beginRe=n(o.begin),r.end||r.endsWithParent||(r.end=/\\B|\\b/),\nr.end&&(o.endRe=n(o.end)),\no.terminatorEnd=c(o.end)||\"\",r.endsWithParent&&s.terminatorEnd&&(o.terminatorEnd+=(r.end?\"|\":\"\")+s.terminatorEnd)),\nr.illegal&&(o.illegalRe=n(r.illegal)),\nr.contains||(r.contains=[]),r.contains=[].concat(...r.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((n=>a(e,{\nvariants:null},n)))),e.cachedVariants?e.cachedVariants:Q(e)?a(e,{\nstarts:e.starts?a(e.starts):null\n}):Object.isFrozen(e)?a(e):e))(\"self\"===e?r:e)))),r.contains.forEach((e=>{t(e,o)\n})),r.starts&&t(r.starts,s),o.matcher=(e=>{const n=new i\n;return e.contains.forEach((e=>n.addRule(e.begin,{rule:e,type:\"begin\"\n}))),e.terminatorEnd&&n.addRule(e.terminatorEnd,{type:\"end\"\n}),e.illegal&&n.addRule(e.illegal,{type:\"illegal\"}),n})(o),o}(e)}function Q(e){\nreturn!!e&&(e.endsWithParent||Q(e.starts))}class X extends Error{\nconstructor(e,n){super(e),this.name=\"HTMLInjectionError\",this.html=n}}\nconst V=t,J=a,Y=Symbol(\"nomatch\"),ee=t=>{\nconst a=Object.create(null),i=Object.create(null),r=[];let s=!0\n;const o=\"Could not find the language '{}', did you forget to load/include a language module?\",c={\ndisableAutodetect:!0,name:\"Plain text\",contains:[]};let p={\nignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,\nlanguageDetectRe:/\\blang(?:uage)?-([\\w-]+)\\b/i,classPrefix:\"hljs-\",\ncssSelector:\"pre code\",languages:null,__emitter:l};function _(e){\nreturn p.noHighlightRe.test(e)}function h(e,n,t){let a=\"\",i=\"\"\n;\"object\"==typeof n?(a=e,\nt=n.ignoreIllegals,i=n.language):(q(\"10.7.0\",\"highlight(lang, code, ...args) has been deprecated.\"),\nq(\"10.7.0\",\"Please use highlight(code, options) instead.\\nhttps://github.com/highlightjs/highlight.js/issues/2277\"),\ni=e,a=n),void 0===t&&(t=!0);const r={code:a,language:i};O(\"before:highlight\",r)\n;const s=r.result?r.result:f(r.language,r.code,t)\n;return s.code=r.code,O(\"after:highlight\",s),s}function f(e,t,i,r){\nconst l=Object.create(null);function c(){if(!O.keywords)return void A.addText(S)\n;let e=0;O.keywordPatternRe.lastIndex=0;let n=O.keywordPatternRe.exec(S),t=\"\"\n;for(;n;){t+=S.substring(e,n.index)\n;const i=v.case_insensitive?n[0].toLowerCase():n[0],r=(a=i,O.keywords[a]);if(r){\nconst[e,a]=r\n;if(A.addText(t),t=\"\",l[i]=(l[i]||0)+1,l[i]<=7&&(C+=a),e.startsWith(\"_\"))t+=n[0];else{\nconst t=v.classNameAliases[e]||e;g(n[0],t)}}else t+=n[0]\n;e=O.keywordPatternRe.lastIndex,n=O.keywordPatternRe.exec(S)}var a\n;t+=S.substring(e),A.addText(t)}function d(){null!=O.subLanguage?(()=>{\nif(\"\"===S)return;let e=null;if(\"string\"==typeof O.subLanguage){\nif(!a[O.subLanguage])return void A.addText(S)\n;e=f(O.subLanguage,S,!0,M[O.subLanguage]),M[O.subLanguage]=e._top\n}else e=E(S,O.subLanguage.length?O.subLanguage:null)\n;O.relevance>0&&(C+=e.relevance),A.__addSublanguage(e._emitter,e.language)\n})():c(),S=\"\"}function g(e,n){\n\"\"!==e&&(A.startScope(n),A.addText(e),A.endScope())}function u(e,n){let t=1\n;const a=n.length-1;for(;t<=a;){if(!e._emit[t]){t++;continue}\nconst a=v.classNameAliases[e[t]]||e[t],i=n[t];a?g(i,a):(S=i,c(),S=\"\"),t++}}\nfunction b(e,n){\nreturn e.scope&&\"string\"==typeof e.scope&&A.openNode(v.classNameAliases[e.scope]||e.scope),\ne.beginScope&&(e.beginScope._wrap?(g(S,v.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),\nS=\"\"):e.beginScope._multi&&(u(e.beginScope,n),S=\"\")),O=Object.create(e,{parent:{\nvalue:O}}),O}function m(e,t,a){let i=((e,n)=>{const t=e&&e.exec(n)\n;return t&&0===t.index})(e.endRe,a);if(i){if(e[\"on:end\"]){const a=new n(e)\n;e[\"on:end\"](t,a),a.isMatchIgnored&&(i=!1)}if(i){\nfor(;e.endsParent&&e.parent;)e=e.parent;return e}}\nif(e.endsWithParent)return m(e.parent,t,a)}function _(e){\nreturn 0===O.matcher.regexIndex?(S+=e[0],1):(D=!0,0)}function h(e){\nconst n=e[0],a=t.substring(e.index),i=m(O,e,a);if(!i)return Y;const r=O\n;O.endScope&&O.endScope._wrap?(d(),\ng(n,O.endScope._wrap)):O.endScope&&O.endScope._multi?(d(),\nu(O.endScope,e)):r.skip?S+=n:(r.returnEnd||r.excludeEnd||(S+=n),\nd(),r.excludeEnd&&(S=n));do{\nO.scope&&A.closeNode(),O.skip||O.subLanguage||(C+=O.relevance),O=O.parent\n}while(O!==i.parent);return i.starts&&b(i.starts,e),r.returnEnd?0:n.length}\nlet y={};function w(a,r){const o=r&&r[0];if(S+=a,null==o)return d(),0\n;if(\"begin\"===y.type&&\"end\"===r.type&&y.index===r.index&&\"\"===o){\nif(S+=t.slice(r.index,r.index+1),!s){const n=Error(`0 width match regex (${e})`)\n;throw n.languageName=e,n.badRule=y.rule,n}return 1}\nif(y=r,\"begin\"===r.type)return(e=>{\nconst t=e[0],a=e.rule,i=new n(a),r=[a.__beforeBegin,a[\"on:begin\"]]\n;for(const n of r)if(n&&(n(e,i),i.isMatchIgnored))return _(t)\n;return a.skip?S+=t:(a.excludeBegin&&(S+=t),\nd(),a.returnBegin||a.excludeBegin||(S=t)),b(a,e),a.returnBegin?0:t.length})(r)\n;if(\"illegal\"===r.type&&!i){\nconst e=Error('Illegal lexeme \"'+o+'\" for mode \"'+(O.scope||\"<unnamed>\")+'\"')\n;throw e.mode=O,e}if(\"end\"===r.type){const e=h(r);if(e!==Y)return e}\nif(\"illegal\"===r.type&&\"\"===o)return S+=\"\\n\",1\n;if(R>1e5&&R>3*r.index)throw Error(\"potential infinite loop, way more iterations than matches\")\n;return S+=o,o.length}const v=N(e)\n;if(!v)throw P(o.replace(\"{}\",e)),Error('Unknown language: \"'+e+'\"')\n;const k=W(v);let x=\"\",O=r||k;const M={},A=new p.__emitter(p);(()=>{const e=[]\n;for(let n=O;n!==v;n=n.parent)n.scope&&e.unshift(n.scope)\n;e.forEach((e=>A.openNode(e)))})();let S=\"\",C=0,T=0,R=0,D=!1;try{\nif(v.__emitTokens)v.__emitTokens(t,A);else{for(O.matcher.considerAll();;){\nR++,D?D=!1:O.matcher.considerAll(),O.matcher.lastIndex=T\n;const e=O.matcher.exec(t);if(!e)break;const n=w(t.substring(T,e.index),e)\n;T=e.index+n}w(t.substring(T))}return A.finalize(),x=A.toHTML(),{language:e,\nvalue:x,relevance:C,illegal:!1,_emitter:A,_top:O}}catch(n){\nif(n.message&&n.message.includes(\"Illegal\"))return{language:e,value:V(t),\nillegal:!0,relevance:0,_illegalBy:{message:n.message,index:T,\ncontext:t.slice(T-100,T+100),mode:n.mode,resultSoFar:x},_emitter:A};if(s)return{\nlanguage:e,value:V(t),illegal:!1,relevance:0,errorRaised:n,_emitter:A,_top:O}\n;throw n}}function E(e,n){n=n||p.languages||Object.keys(a);const t=(e=>{\nconst n={value:V(e),illegal:!1,relevance:0,_top:c,_emitter:new p.__emitter(p)}\n;return n._emitter.addText(e),n})(e),i=n.filter(N).filter(x).map((n=>f(n,e,!1)))\n;i.unshift(t);const r=i.sort(((e,n)=>{\nif(e.relevance!==n.relevance)return n.relevance-e.relevance\n;if(e.language&&n.language){if(N(e.language).supersetOf===n.language)return 1\n;if(N(n.language).supersetOf===e.language)return-1}return 0})),[s,o]=r,l=s\n;return l.secondBest=o,l}function y(e){let n=null;const t=(e=>{\nlet n=e.className+\" \";n+=e.parentNode?e.parentNode.className:\"\"\n;const t=p.languageDetectRe.exec(n);if(t){const n=N(t[1])\n;return n||(K(o.replace(\"{}\",t[1])),\nK(\"Falling back to no-highlight mode for this block.\",e)),n?t[1]:\"no-highlight\"}\nreturn n.split(/\\s+/).find((e=>_(e)||N(e)))})(e);if(_(t))return\n;if(O(\"before:highlightElement\",{el:e,language:t\n}),e.dataset.highlighted)return void console.log(\"Element previously highlighted. To highlight again, first unset `dataset.highlighted`.\",e)\n;if(e.children.length>0&&(p.ignoreUnescapedHTML||(console.warn(\"One of your code blocks includes unescaped HTML. This is a potentially serious security risk.\"),\nconsole.warn(\"https://github.com/highlightjs/highlight.js/wiki/security\"),\nconsole.warn(\"The element with unescaped HTML:\"),\nconsole.warn(e)),p.throwUnescapedHTML))throw new X(\"One of your code blocks includes unescaped HTML.\",e.innerHTML)\n;n=e;const a=n.textContent,r=t?h(a,{language:t,ignoreIllegals:!0}):E(a)\n;e.innerHTML=r.value,e.dataset.highlighted=\"yes\",((e,n,t)=>{const a=n&&i[n]||t\n;e.classList.add(\"hljs\"),e.classList.add(\"language-\"+a)\n})(e,t,r.language),e.result={language:r.language,re:r.relevance,\nrelevance:r.relevance},r.secondBest&&(e.secondBest={\nlanguage:r.secondBest.language,relevance:r.secondBest.relevance\n}),O(\"after:highlightElement\",{el:e,result:r,text:a})}let w=!1;function v(){\nif(\"loading\"===document.readyState)return w||window.addEventListener(\"DOMContentLoaded\",(()=>{\nv()}),!1),void(w=!0);document.querySelectorAll(p.cssSelector).forEach(y)}\nfunction N(e){return e=(e||\"\").toLowerCase(),a[e]||a[i[e]]}\nfunction k(e,{languageName:n}){\"string\"==typeof e&&(e=[e]),e.forEach((e=>{\ni[e.toLowerCase()]=n}))}function x(e){const n=N(e)\n;return n&&!n.disableAutodetect}function O(e,n){const t=e;r.forEach((e=>{\ne[t]&&e[t](n)}))}Object.assign(t,{highlight:h,highlightAuto:E,highlightAll:v,\nhighlightElement:y,\nhighlightBlock:e=>(q(\"10.7.0\",\"highlightBlock will be removed entirely in v12.0\"),\nq(\"10.7.0\",\"Please use highlightElement now.\"),y(e)),configure:e=>{p=J(p,e)},\ninitHighlighting:()=>{\nv(),q(\"10.6.0\",\"initHighlighting() deprecated. Use highlightAll() now.\")},\ninitHighlightingOnLoad:()=>{\nv(),q(\"10.6.0\",\"initHighlightingOnLoad() deprecated. Use highlightAll() now.\")\n},registerLanguage:(e,n)=>{let i=null;try{i=n(t)}catch(n){\nif(P(\"Language definition for '{}' could not be registered.\".replace(\"{}\",e)),\n!s)throw n;P(n),i=c}\ni.name||(i.name=e),a[e]=i,i.rawDefinition=n.bind(null,t),i.aliases&&k(i.aliases,{\nlanguageName:e})},unregisterLanguage:e=>{delete a[e]\n;for(const n of Object.keys(i))i[n]===e&&delete i[n]},\nlistLanguages:()=>Object.keys(a),getLanguage:N,registerAliases:k,\nautoDetection:x,inherit:J,addPlugin:e=>{(e=>{\ne[\"before:highlightBlock\"]&&!e[\"before:highlightElement\"]&&(e[\"before:highlightElement\"]=n=>{\ne[\"before:highlightBlock\"](Object.assign({block:n.el},n))\n}),e[\"after:highlightBlock\"]&&!e[\"after:highlightElement\"]&&(e[\"after:highlightElement\"]=n=>{\ne[\"after:highlightBlock\"](Object.assign({block:n.el},n))})})(e),r.push(e)},\nremovePlugin:e=>{const n=r.indexOf(e);-1!==n&&r.splice(n,1)}}),t.debugMode=()=>{\ns=!1},t.safeMode=()=>{s=!0},t.versionString=\"11.11.1\",t.regex={concat:b,\nlookahead:d,either:m,optional:u,anyNumberOfTimes:g}\n;for(const n in C)\"object\"==typeof C[n]&&e(C[n]);return Object.assign(t,C),t\n},ne=ee({});ne.newInstance=()=>ee({});const te=e=>({IMPORTANT:{scope:\"meta\",\nbegin:\"!important\"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{\nscope:\"number\",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\\b/},\nFUNCTION_DISPATCH:{className:\"built_in\",begin:/[\\w-]+(?=\\()/},\nATTRIBUTE_SELECTOR_MODE:{scope:\"selector-attr\",begin:/\\[/,end:/\\]/,illegal:\"$\",\ncontains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{\nscope:\"number\",\nbegin:e.NUMBER_RE+\"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?\",\nrelevance:0},CSS_VARIABLE:{className:\"attr\",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}\n}),ae=[\"a\",\"abbr\",\"address\",\"article\",\"aside\",\"audio\",\"b\",\"blockquote\",\"body\",\"button\",\"canvas\",\"caption\",\"cite\",\"code\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"fieldset\",\"figcaption\",\"figure\",\"footer\",\"form\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hgroup\",\"html\",\"i\",\"iframe\",\"img\",\"input\",\"ins\",\"kbd\",\"label\",\"legend\",\"li\",\"main\",\"mark\",\"menu\",\"nav\",\"object\",\"ol\",\"optgroup\",\"option\",\"p\",\"picture\",\"q\",\"quote\",\"samp\",\"section\",\"select\",\"source\",\"span\",\"strong\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"textarea\",\"tfoot\",\"th\",\"thead\",\"time\",\"tr\",\"ul\",\"var\",\"video\",\"defs\",\"g\",\"marker\",\"mask\",\"pattern\",\"svg\",\"switch\",\"symbol\",\"feBlend\",\"feColorMatrix\",\"feComponentTransfer\",\"feComposite\",\"feConvolveMatrix\",\"feDiffuseLighting\",\"feDisplacementMap\",\"feFlood\",\"feGaussianBlur\",\"feImage\",\"feMerge\",\"feMorphology\",\"feOffset\",\"feSpecularLighting\",\"feTile\",\"feTurbulence\",\"linearGradient\",\"radialGradient\",\"stop\",\"circle\",\"ellipse\",\"image\",\"line\",\"path\",\"polygon\",\"polyline\",\"rect\",\"text\",\"use\",\"textPath\",\"tspan\",\"foreignObject\",\"clipPath\"],ie=[\"any-hover\",\"any-pointer\",\"aspect-ratio\",\"color\",\"color-gamut\",\"color-index\",\"device-aspect-ratio\",\"device-height\",\"device-width\",\"display-mode\",\"forced-colors\",\"grid\",\"height\",\"hover\",\"inverted-colors\",\"monochrome\",\"orientation\",\"overflow-block\",\"overflow-inline\",\"pointer\",\"prefers-color-scheme\",\"prefers-contrast\",\"prefers-reduced-motion\",\"prefers-reduced-transparency\",\"resolution\",\"scan\",\"scripting\",\"update\",\"width\",\"min-width\",\"max-width\",\"min-height\",\"max-height\"].sort().reverse(),re=[\"active\",\"any-link\",\"blank\",\"checked\",\"current\",\"default\",\"defined\",\"dir\",\"disabled\",\"drop\",\"empty\",\"enabled\",\"first\",\"first-child\",\"first-of-type\",\"fullscreen\",\"future\",\"focus\",\"focus-visible\",\"focus-within\",\"has\",\"host\",\"host-context\",\"hover\",\"indeterminate\",\"in-range\",\"invalid\",\"is\",\"lang\",\"last-child\",\"last-of-type\",\"left\",\"link\",\"local-link\",\"not\",\"nth-child\",\"nth-col\",\"nth-last-child\",\"nth-last-col\",\"nth-last-of-type\",\"nth-of-type\",\"only-child\",\"only-of-type\",\"optional\",\"out-of-range\",\"past\",\"placeholder-shown\",\"read-only\",\"read-write\",\"required\",\"right\",\"root\",\"scope\",\"target\",\"target-within\",\"user-invalid\",\"valid\",\"visited\",\"where\"].sort().reverse(),se=[\"after\",\"backdrop\",\"before\",\"cue\",\"cue-region\",\"first-letter\",\"first-line\",\"grammar-error\",\"marker\",\"part\",\"placeholder\",\"selection\",\"slotted\",\"spelling-error\"].sort().reverse(),oe=[\"accent-color\",\"align-content\",\"align-items\",\"align-self\",\"alignment-baseline\",\"all\",\"anchor-name\",\"animation\",\"animation-composition\",\"animation-delay\",\"animation-direction\",\"animation-duration\",\"animation-fill-mode\",\"animation-iteration-count\",\"animation-name\",\"animation-play-state\",\"animation-range\",\"animation-range-end\",\"animation-range-start\",\"animation-timeline\",\"animation-timing-function\",\"appearance\",\"aspect-ratio\",\"backdrop-filter\",\"backface-visibility\",\"background\",\"background-attachment\",\"background-blend-mode\",\"background-clip\",\"background-color\",\"background-image\",\"background-origin\",\"background-position\",\"background-position-x\",\"background-position-y\",\"background-repeat\",\"background-size\",\"baseline-shift\",\"block-size\",\"border\",\"border-block\",\"border-block-color\",\"border-block-end\",\"border-block-end-color\",\"border-block-end-style\",\"border-block-end-width\",\"border-block-start\",\"border-block-start-color\",\"border-block-start-style\",\"border-block-start-width\",\"border-block-style\",\"border-block-width\",\"border-bottom\",\"border-bottom-color\",\"border-bottom-left-radius\",\"border-bottom-right-radius\",\"border-bottom-style\",\"border-bottom-width\",\"border-collapse\",\"border-color\",\"border-end-end-radius\",\"border-end-start-radius\",\"border-image\",\"border-image-outset\",\"border-image-repeat\",\"border-image-slice\",\"border-image-source\",\"border-image-width\",\"border-inline\",\"border-inline-color\",\"border-inline-end\",\"border-inline-end-color\",\"border-inline-end-style\",\"border-inline-end-width\",\"border-inline-start\",\"border-inline-start-color\",\"border-inline-start-style\",\"border-inline-start-width\",\"border-inline-style\",\"border-inline-width\",\"border-left\",\"border-left-color\",\"border-left-style\",\"border-left-width\",\"border-radius\",\"border-right\",\"border-right-color\",\"border-right-style\",\"border-right-width\",\"border-spacing\",\"border-start-end-radius\",\"border-start-start-radius\",\"border-style\",\"border-top\",\"border-top-color\",\"border-top-left-radius\",\"border-top-right-radius\",\"border-top-style\",\"border-top-width\",\"border-width\",\"bottom\",\"box-align\",\"box-decoration-break\",\"box-direction\",\"box-flex\",\"box-flex-group\",\"box-lines\",\"box-ordinal-group\",\"box-orient\",\"box-pack\",\"box-shadow\",\"box-sizing\",\"break-after\",\"break-before\",\"break-inside\",\"caption-side\",\"caret-color\",\"clear\",\"clip\",\"clip-path\",\"clip-rule\",\"color\",\"color-interpolation\",\"color-interpolation-filters\",\"color-profile\",\"color-rendering\",\"color-scheme\",\"column-count\",\"column-fill\",\"column-gap\",\"column-rule\",\"column-rule-color\",\"column-rule-style\",\"column-rule-width\",\"column-span\",\"column-width\",\"columns\",\"contain\",\"contain-intrinsic-block-size\",\"contain-intrinsic-height\",\"contain-intrinsic-inline-size\",\"contain-intrinsic-size\",\"contain-intrinsic-width\",\"container\",\"container-name\",\"container-type\",\"content\",\"content-visibility\",\"counter-increment\",\"counter-reset\",\"counter-set\",\"cue\",\"cue-after\",\"cue-before\",\"cursor\",\"cx\",\"cy\",\"direction\",\"display\",\"dominant-baseline\",\"empty-cells\",\"enable-background\",\"field-sizing\",\"fill\",\"fill-opacity\",\"fill-rule\",\"filter\",\"flex\",\"flex-basis\",\"flex-direction\",\"flex-flow\",\"flex-grow\",\"flex-shrink\",\"flex-wrap\",\"float\",\"flood-color\",\"flood-opacity\",\"flow\",\"font\",\"font-display\",\"font-family\",\"font-feature-settings\",\"font-kerning\",\"font-language-override\",\"font-optical-sizing\",\"font-palette\",\"font-size\",\"font-size-adjust\",\"font-smooth\",\"font-smoothing\",\"font-stretch\",\"font-style\",\"font-synthesis\",\"font-synthesis-position\",\"font-synthesis-small-caps\",\"font-synthesis-style\",\"font-synthesis-weight\",\"font-variant\",\"font-variant-alternates\",\"font-variant-caps\",\"font-variant-east-asian\",\"font-variant-emoji\",\"font-variant-ligatures\",\"font-variant-numeric\",\"font-variant-position\",\"font-variation-settings\",\"font-weight\",\"forced-color-adjust\",\"gap\",\"glyph-orientation-horizontal\",\"glyph-orientation-vertical\",\"grid\",\"grid-area\",\"grid-auto-columns\",\"grid-auto-flow\",\"grid-auto-rows\",\"grid-column\",\"grid-column-end\",\"grid-column-start\",\"grid-gap\",\"grid-row\",\"grid-row-end\",\"grid-row-start\",\"grid-template\",\"grid-template-areas\",\"grid-template-columns\",\"grid-template-rows\",\"hanging-punctuation\",\"height\",\"hyphenate-character\",\"hyphenate-limit-chars\",\"hyphens\",\"icon\",\"image-orientation\",\"image-rendering\",\"image-resolution\",\"ime-mode\",\"initial-letter\",\"initial-letter-align\",\"inline-size\",\"inset\",\"inset-area\",\"inset-block\",\"inset-block-end\",\"inset-block-start\",\"inset-inline\",\"inset-inline-end\",\"inset-inline-start\",\"isolation\",\"justify-content\",\"justify-items\",\"justify-self\",\"kerning\",\"left\",\"letter-spacing\",\"lighting-color\",\"line-break\",\"line-height\",\"line-height-step\",\"list-style\",\"list-style-image\",\"list-style-position\",\"list-style-type\",\"margin\",\"margin-block\",\"margin-block-end\",\"margin-block-start\",\"margin-bottom\",\"margin-inline\",\"margin-inline-end\",\"margin-inline-start\",\"margin-left\",\"margin-right\",\"margin-top\",\"margin-trim\",\"marker\",\"marker-end\",\"marker-mid\",\"marker-start\",\"marks\",\"mask\",\"mask-border\",\"mask-border-mode\",\"mask-border-outset\",\"mask-border-repeat\",\"mask-border-slice\",\"mask-border-source\",\"mask-border-width\",\"mask-clip\",\"mask-composite\",\"mask-image\",\"mask-mode\",\"mask-origin\",\"mask-position\",\"mask-repeat\",\"mask-size\",\"mask-type\",\"masonry-auto-flow\",\"math-depth\",\"math-shift\",\"math-style\",\"max-block-size\",\"max-height\",\"max-inline-size\",\"max-width\",\"min-block-size\",\"min-height\",\"min-inline-size\",\"min-width\",\"mix-blend-mode\",\"nav-down\",\"nav-index\",\"nav-left\",\"nav-right\",\"nav-up\",\"none\",\"normal\",\"object-fit\",\"object-position\",\"offset\",\"offset-anchor\",\"offset-distance\",\"offset-path\",\"offset-position\",\"offset-rotate\",\"opacity\",\"order\",\"orphans\",\"outline\",\"outline-color\",\"outline-offset\",\"outline-style\",\"outline-width\",\"overflow\",\"overflow-anchor\",\"overflow-block\",\"overflow-clip-margin\",\"overflow-inline\",\"overflow-wrap\",\"overflow-x\",\"overflow-y\",\"overlay\",\"overscroll-behavior\",\"overscroll-behavior-block\",\"overscroll-behavior-inline\",\"overscroll-behavior-x\",\"overscroll-behavior-y\",\"padding\",\"padding-block\",\"padding-block-end\",\"padding-block-start\",\"padding-bottom\",\"padding-inline\",\"padding-inline-end\",\"padding-inline-start\",\"padding-left\",\"padding-right\",\"padding-top\",\"page\",\"page-break-after\",\"page-break-before\",\"page-break-inside\",\"paint-order\",\"pause\",\"pause-after\",\"pause-before\",\"perspective\",\"perspective-origin\",\"place-content\",\"place-items\",\"place-self\",\"pointer-events\",\"position\",\"position-anchor\",\"position-visibility\",\"print-color-adjust\",\"quotes\",\"r\",\"resize\",\"rest\",\"rest-after\",\"rest-before\",\"right\",\"rotate\",\"row-gap\",\"ruby-align\",\"ruby-position\",\"scale\",\"scroll-behavior\",\"scroll-margin\",\"scroll-margin-block\",\"scroll-margin-block-end\",\"scroll-margin-block-start\",\"scroll-margin-bottom\",\"scroll-margin-inline\",\"scroll-margin-inline-end\",\"scroll-margin-inline-start\",\"scroll-margin-left\",\"scroll-margin-right\",\"scroll-margin-top\",\"scroll-padding\",\"scroll-padding-block\",\"scroll-padding-block-end\",\"scroll-padding-block-start\",\"scroll-padding-bottom\",\"scroll-padding-inline\",\"scroll-padding-inline-end\",\"scroll-padding-inline-start\",\"scroll-padding-left\",\"scroll-padding-right\",\"scroll-padding-top\",\"scroll-snap-align\",\"scroll-snap-stop\",\"scroll-snap-type\",\"scroll-timeline\",\"scroll-timeline-axis\",\"scroll-timeline-name\",\"scrollbar-color\",\"scrollbar-gutter\",\"scrollbar-width\",\"shape-image-threshold\",\"shape-margin\",\"shape-outside\",\"shape-rendering\",\"speak\",\"speak-as\",\"src\",\"stop-color\",\"stop-opacity\",\"stroke\",\"stroke-dasharray\",\"stroke-dashoffset\",\"stroke-linecap\",\"stroke-linejoin\",\"stroke-miterlimit\",\"stroke-opacity\",\"stroke-width\",\"tab-size\",\"table-layout\",\"text-align\",\"text-align-all\",\"text-align-last\",\"text-anchor\",\"text-combine-upright\",\"text-decoration\",\"text-decoration-color\",\"text-decoration-line\",\"text-decoration-skip\",\"text-decoration-skip-ink\",\"text-decoration-style\",\"text-decoration-thickness\",\"text-emphasis\",\"text-emphasis-color\",\"text-emphasis-position\",\"text-emphasis-style\",\"text-indent\",\"text-justify\",\"text-orientation\",\"text-overflow\",\"text-rendering\",\"text-shadow\",\"text-size-adjust\",\"text-transform\",\"text-underline-offset\",\"text-underline-position\",\"text-wrap\",\"text-wrap-mode\",\"text-wrap-style\",\"timeline-scope\",\"top\",\"touch-action\",\"transform\",\"transform-box\",\"transform-origin\",\"transform-style\",\"transition\",\"transition-behavior\",\"transition-delay\",\"transition-duration\",\"transition-property\",\"transition-timing-function\",\"translate\",\"unicode-bidi\",\"user-modify\",\"user-select\",\"vector-effect\",\"vertical-align\",\"view-timeline\",\"view-timeline-axis\",\"view-timeline-inset\",\"view-timeline-name\",\"view-transition-name\",\"visibility\",\"voice-balance\",\"voice-duration\",\"voice-family\",\"voice-pitch\",\"voice-range\",\"voice-rate\",\"voice-stress\",\"voice-volume\",\"white-space\",\"white-space-collapse\",\"widows\",\"width\",\"will-change\",\"word-break\",\"word-spacing\",\"word-wrap\",\"writing-mode\",\"x\",\"y\",\"z-index\",\"zoom\"].sort().reverse(),le=re.concat(se).sort().reverse()\n;var ce=\"[0-9](_*[0-9])*\",de=`\\\\.(${ce})`,ge=\"[0-9a-fA-F](_*[0-9a-fA-F])*\",ue={\nclassName:\"number\",variants:[{\nbegin:`(\\\\b(${ce})((${de})|\\\\.)?|(${de}))[eE][+-]?(${ce})[fFdD]?\\\\b`},{\nbegin:`\\\\b(${ce})((${de})[fFdD]?\\\\b|\\\\.([fFdD]\\\\b)?)`},{\nbegin:`(${de})[fFdD]?\\\\b`},{begin:`\\\\b(${ce})[fFdD]\\\\b`},{\nbegin:`\\\\b0[xX]((${ge})\\\\.?|(${ge})?\\\\.(${ge}))[pP][+-]?(${ce})[fFdD]?\\\\b`},{\nbegin:\"\\\\b(0|[1-9](_*[0-9])*)[lL]?\\\\b\"},{begin:`\\\\b0[xX](${ge})[lL]?\\\\b`},{\nbegin:\"\\\\b0(_*[0-7])*[lL]?\\\\b\"},{begin:\"\\\\b0[bB][01](_*[01])*[lL]?\\\\b\"}],\nrelevance:0};function be(e,n,t){return-1===t?\"\":e.replace(n,(a=>be(e,n,t-1)))}\nconst me=\"[A-Za-z$_][0-9A-Za-z$_]*\",pe=[\"as\",\"in\",\"of\",\"if\",\"for\",\"while\",\"finally\",\"var\",\"new\",\"function\",\"do\",\"return\",\"void\",\"else\",\"break\",\"catch\",\"instanceof\",\"with\",\"throw\",\"case\",\"default\",\"try\",\"switch\",\"continue\",\"typeof\",\"delete\",\"let\",\"yield\",\"const\",\"class\",\"debugger\",\"async\",\"await\",\"static\",\"import\",\"from\",\"export\",\"extends\",\"using\"],_e=[\"true\",\"false\",\"null\",\"undefined\",\"NaN\",\"Infinity\"],he=[\"Object\",\"Function\",\"Boolean\",\"Symbol\",\"Math\",\"Date\",\"Number\",\"BigInt\",\"String\",\"RegExp\",\"Array\",\"Float32Array\",\"Float64Array\",\"Int8Array\",\"Uint8Array\",\"Uint8ClampedArray\",\"Int16Array\",\"Int32Array\",\"Uint16Array\",\"Uint32Array\",\"BigInt64Array\",\"BigUint64Array\",\"Set\",\"Map\",\"WeakSet\",\"WeakMap\",\"ArrayBuffer\",\"SharedArrayBuffer\",\"Atomics\",\"DataView\",\"JSON\",\"Promise\",\"Generator\",\"GeneratorFunction\",\"AsyncFunction\",\"Reflect\",\"Proxy\",\"Intl\",\"WebAssembly\"],fe=[\"Error\",\"EvalError\",\"InternalError\",\"RangeError\",\"ReferenceError\",\"SyntaxError\",\"TypeError\",\"URIError\"],Ee=[\"setInterval\",\"setTimeout\",\"clearInterval\",\"clearTimeout\",\"require\",\"exports\",\"eval\",\"isFinite\",\"isNaN\",\"parseFloat\",\"parseInt\",\"decodeURI\",\"decodeURIComponent\",\"encodeURI\",\"encodeURIComponent\",\"escape\",\"unescape\"],ye=[\"arguments\",\"this\",\"super\",\"console\",\"window\",\"document\",\"localStorage\",\"sessionStorage\",\"module\",\"global\"],we=[].concat(Ee,he,fe)\n;function ve(e){const n=e.regex,t=me,a={begin:/<[A-Za-z0-9\\\\._:-]+/,\nend:/\\/[A-Za-z0-9\\\\._:-]+>|\\/>/,isTrulyOpeningTag:(e,n)=>{\nconst t=e[0].length+e.index,a=e.input[t]\n;if(\"<\"===a||\",\"===a)return void n.ignoreMatch();let i\n;\">\"===a&&(((e,{after:n})=>{const t=\"</\"+e[0].slice(1)\n;return-1!==e.input.indexOf(t,n)})(e,{after:t})||n.ignoreMatch())\n;const r=e.input.substring(t)\n;((i=r.match(/^\\s*=/))||(i=r.match(/^\\s+extends\\s+/))&&0===i.index)&&n.ignoreMatch()\n}},i={$pattern:me,keyword:pe,literal:_e,built_in:we,\"variable.language\":ye\n},r=\"[0-9](_?[0-9])*\",s=`\\\\.(${r})`,o=\"0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*\",l={\nclassName:\"number\",variants:[{\nbegin:`(\\\\b(${o})((${s})|\\\\.)?|(${s}))[eE][+-]?(${r})\\\\b`},{\nbegin:`\\\\b(${o})\\\\b((${s})\\\\b|\\\\.)?|(${s})\\\\b`},{\nbegin:\"\\\\b(0|[1-9](_?[0-9])*)n\\\\b\"},{\nbegin:\"\\\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\\\b\"},{\nbegin:\"\\\\b0[bB][0-1](_?[0-1])*n?\\\\b\"},{begin:\"\\\\b0[oO][0-7](_?[0-7])*n?\\\\b\"},{\nbegin:\"\\\\b0[0-7]+n?\\\\b\"}],relevance:0},c={className:\"subst\",begin:\"\\\\$\\\\{\",\nend:\"\\\\}\",keywords:i,contains:[]},d={begin:\".?html`\",end:\"\",starts:{end:\"`\",\nreturnEnd:!1,contains:[e.BACKSLASH_ESCAPE,c],subLanguage:\"xml\"}},g={\nbegin:\".?css`\",end:\"\",starts:{end:\"`\",returnEnd:!1,\ncontains:[e.BACKSLASH_ESCAPE,c],subLanguage:\"css\"}},u={begin:\".?gql`\",end:\"\",\nstarts:{end:\"`\",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,c],\nsubLanguage:\"graphql\"}},b={className:\"string\",begin:\"`\",end:\"`\",\ncontains:[e.BACKSLASH_ESCAPE,c]},m={className:\"comment\",\nvariants:[e.COMMENT(/\\/\\*\\*(?!\\/)/,\"\\\\*/\",{relevance:0,contains:[{\nbegin:\"(?=@[A-Za-z]+)\",relevance:0,contains:[{className:\"doctag\",\nbegin:\"@[A-Za-z]+\"},{className:\"type\",begin:\"\\\\{\",end:\"\\\\}\",excludeEnd:!0,\nexcludeBegin:!0,relevance:0},{className:\"variable\",begin:t+\"(?=\\\\s*(-)|$)\",\nendsParent:!0,relevance:0},{begin:/(?=[^\\n])\\s/,relevance:0}]}]\n}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]\n},p=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,d,g,u,b,{match:/\\$\\d+/},l]\n;c.contains=p.concat({begin:/\\{/,end:/\\}/,keywords:i,contains:[\"self\"].concat(p)\n});const _=[].concat(m,c.contains),h=_.concat([{begin:/(\\s*)\\(/,end:/\\)/,\nkeywords:i,contains:[\"self\"].concat(_)}]),f={className:\"params\",begin:/(\\s*)\\(/,\nend:/\\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:h},E={variants:[{\nmatch:[/class/,/\\s+/,t,/\\s+/,/extends/,/\\s+/,n.concat(t,\"(\",n.concat(/\\./,t),\")*\")],\nscope:{1:\"keyword\",3:\"title.class\",5:\"keyword\",7:\"title.class.inherited\"}},{\nmatch:[/class/,/\\s+/,t],scope:{1:\"keyword\",3:\"title.class\"}}]},y={relevance:0,\nmatch:n.either(/\\bJSON/,/\\b[A-Z][a-z]+([A-Z][a-z]*|\\d)*/,/\\b[A-Z]{2,}([A-Z][a-z]+|\\d)+([A-Z][a-z]*)*/,/\\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\\d)*([A-Z][a-z]*)*/),\nclassName:\"title.class\",keywords:{_:[...he,...fe]}},w={variants:[{\nmatch:[/function/,/\\s+/,t,/(?=\\s*\\()/]},{match:[/function/,/\\s*(?=\\()/]}],\nclassName:{1:\"keyword\",3:\"title.function\"},label:\"func.def\",contains:[f],\nillegal:/%/},v={\nmatch:n.concat(/\\b/,(N=[...Ee,\"super\",\"import\"].map((e=>e+\"\\\\s*\\\\(\")),\nn.concat(\"(?!\",N.join(\"|\"),\")\")),t,n.lookahead(/\\s*\\(/)),\nclassName:\"title.function\",relevance:0};var N;const k={\nbegin:n.concat(/\\./,n.lookahead(n.concat(t,/(?![0-9A-Za-z$_(])/))),end:t,\nexcludeBegin:!0,keywords:\"prototype\",className:\"property\",relevance:0},x={\nmatch:[/get|set/,/\\s+/,t,/(?=\\()/],className:{1:\"keyword\",3:\"title.function\"},\ncontains:[{begin:/\\(\\)/},f]\n},O=\"(\\\\([^()]*(\\\\([^()]*(\\\\([^()]*\\\\)[^()]*)*\\\\)[^()]*)*\\\\)|\"+e.UNDERSCORE_IDENT_RE+\")\\\\s*=>\",M={\nmatch:[/const|var|let/,/\\s+/,t,/\\s*/,/=\\s*/,/(async\\s*)?/,n.lookahead(O)],\nkeywords:\"async\",className:{1:\"keyword\",3:\"title.function\"},contains:[f]}\n;return{name:\"JavaScript\",aliases:[\"js\",\"jsx\",\"mjs\",\"cjs\"],keywords:i,exports:{\nPARAMS_CONTAINS:h,CLASS_REFERENCE:y},illegal:/#(?![$_A-z])/,\ncontains:[e.SHEBANG({label:\"shebang\",binary:\"node\",relevance:5}),{\nlabel:\"use_strict\",className:\"meta\",relevance:10,\nbegin:/^\\s*['\"]use (strict|asm)['\"]/\n},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,d,g,u,b,m,{match:/\\$\\d+/},l,y,{\nscope:\"attr\",match:t+n.lookahead(\":\"),relevance:0},M,{\nbegin:\"(\"+e.RE_STARTERS_RE+\"|\\\\b(case|return|throw)\\\\b)\\\\s*\",\nkeywords:\"return throw case\",relevance:0,contains:[m,e.REGEXP_MODE,{\nclassName:\"function\",begin:O,returnBegin:!0,end:\"\\\\s*=>\",contains:[{\nclassName:\"params\",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{\nclassName:null,begin:/\\(\\s*\\)/,skip:!0},{begin:/(\\s*)\\(/,end:/\\)/,\nexcludeBegin:!0,excludeEnd:!0,keywords:i,contains:h}]}]},{begin:/,/,relevance:0\n},{match:/\\s+/,relevance:0},{variants:[{begin:\"<>\",end:\"</>\"},{\nmatch:/<[A-Za-z0-9\\\\._:-]+\\s*\\/>/},{begin:a.begin,\n\"on:begin\":a.isTrulyOpeningTag,end:a.end}],subLanguage:\"xml\",contains:[{\nbegin:a.begin,end:a.end,skip:!0,contains:[\"self\"]}]}]},w,{\nbeginKeywords:\"while if switch catch for\"},{\nbegin:\"\\\\b(?!function)\"+e.UNDERSCORE_IDENT_RE+\"\\\\([^()]*(\\\\([^()]*(\\\\([^()]*\\\\)[^()]*)*\\\\)[^()]*)*\\\\)\\\\s*\\\\{\",\nreturnBegin:!0,label:\"func.def\",contains:[f,e.inherit(e.TITLE_MODE,{begin:t,\nclassName:\"title.function\"})]},{match:/\\.\\.\\./,relevance:0},k,{match:\"\\\\$\"+t,\nrelevance:0},{match:[/\\bconstructor(?=\\s*\\()/],className:{1:\"title.function\"},\ncontains:[f]},v,{relevance:0,match:/\\b[A-Z][A-Z_0-9]+\\b/,\nclassName:\"variable.constant\"},E,x,{match:/\\$[(.]/}]}}\nconst Ne=e=>b(/\\b/,e,/\\w$/.test(e)?/\\b/:/\\B/),ke=[\"Protocol\",\"Type\"].map(Ne),xe=[\"init\",\"self\"].map(Ne),Oe=[\"Any\",\"Self\"],Me=[\"actor\",\"any\",\"associatedtype\",\"async\",\"await\",/as\\?/,/as!/,\"as\",\"borrowing\",\"break\",\"case\",\"catch\",\"class\",\"consume\",\"consuming\",\"continue\",\"convenience\",\"copy\",\"default\",\"defer\",\"deinit\",\"didSet\",\"distributed\",\"do\",\"dynamic\",\"each\",\"else\",\"enum\",\"extension\",\"fallthrough\",/fileprivate\\(set\\)/,\"fileprivate\",\"final\",\"for\",\"func\",\"get\",\"guard\",\"if\",\"import\",\"indirect\",\"infix\",/init\\?/,/init!/,\"inout\",/internal\\(set\\)/,\"internal\",\"in\",\"is\",\"isolated\",\"nonisolated\",\"lazy\",\"let\",\"macro\",\"mutating\",\"nonmutating\",/open\\(set\\)/,\"open\",\"operator\",\"optional\",\"override\",\"package\",\"postfix\",\"precedencegroup\",\"prefix\",/private\\(set\\)/,\"private\",\"protocol\",/public\\(set\\)/,\"public\",\"repeat\",\"required\",\"rethrows\",\"return\",\"set\",\"some\",\"static\",\"struct\",\"subscript\",\"super\",\"switch\",\"throws\",\"throw\",/try\\?/,/try!/,\"try\",\"typealias\",/unowned\\(safe\\)/,/unowned\\(unsafe\\)/,\"unowned\",\"var\",\"weak\",\"where\",\"while\",\"willSet\"],Ae=[\"false\",\"nil\",\"true\"],Se=[\"assignment\",\"associativity\",\"higherThan\",\"left\",\"lowerThan\",\"none\",\"right\"],Ce=[\"#colorLiteral\",\"#column\",\"#dsohandle\",\"#else\",\"#elseif\",\"#endif\",\"#error\",\"#file\",\"#fileID\",\"#fileLiteral\",\"#filePath\",\"#function\",\"#if\",\"#imageLiteral\",\"#keyPath\",\"#line\",\"#selector\",\"#sourceLocation\",\"#warning\"],Te=[\"abs\",\"all\",\"any\",\"assert\",\"assertionFailure\",\"debugPrint\",\"dump\",\"fatalError\",\"getVaList\",\"isKnownUniquelyReferenced\",\"max\",\"min\",\"numericCast\",\"pointwiseMax\",\"pointwiseMin\",\"precondition\",\"preconditionFailure\",\"print\",\"readLine\",\"repeatElement\",\"sequence\",\"stride\",\"swap\",\"swift_unboxFromSwiftValueWithType\",\"transcode\",\"type\",\"unsafeBitCast\",\"unsafeDowncast\",\"withExtendedLifetime\",\"withUnsafeMutablePointer\",\"withUnsafePointer\",\"withVaList\",\"withoutActuallyEscaping\",\"zip\"],Re=m(/[/=\\-+!*%<>&|^~?]/,/[\\u00A1-\\u00A7]/,/[\\u00A9\\u00AB]/,/[\\u00AC\\u00AE]/,/[\\u00B0\\u00B1]/,/[\\u00B6\\u00BB\\u00BF\\u00D7\\u00F7]/,/[\\u2016-\\u2017]/,/[\\u2020-\\u2027]/,/[\\u2030-\\u203E]/,/[\\u2041-\\u2053]/,/[\\u2055-\\u205E]/,/[\\u2190-\\u23FF]/,/[\\u2500-\\u2775]/,/[\\u2794-\\u2BFF]/,/[\\u2E00-\\u2E7F]/,/[\\u3001-\\u3003]/,/[\\u3008-\\u3020]/,/[\\u3030]/),De=m(Re,/[\\u0300-\\u036F]/,/[\\u1DC0-\\u1DFF]/,/[\\u20D0-\\u20FF]/,/[\\uFE00-\\uFE0F]/,/[\\uFE20-\\uFE2F]/),Ie=b(Re,De,\"*\"),Le=m(/[a-zA-Z_]/,/[\\u00A8\\u00AA\\u00AD\\u00AF\\u00B2-\\u00B5\\u00B7-\\u00BA]/,/[\\u00BC-\\u00BE\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF]/,/[\\u0100-\\u02FF\\u0370-\\u167F\\u1681-\\u180D\\u180F-\\u1DBF]/,/[\\u1E00-\\u1FFF]/,/[\\u200B-\\u200D\\u202A-\\u202E\\u203F-\\u2040\\u2054\\u2060-\\u206F]/,/[\\u2070-\\u20CF\\u2100-\\u218F\\u2460-\\u24FF\\u2776-\\u2793]/,/[\\u2C00-\\u2DFF\\u2E80-\\u2FFF]/,/[\\u3004-\\u3007\\u3021-\\u302F\\u3031-\\u303F\\u3040-\\uD7FF]/,/[\\uF900-\\uFD3D\\uFD40-\\uFDCF\\uFDF0-\\uFE1F\\uFE30-\\uFE44]/,/[\\uFE47-\\uFEFE\\uFF00-\\uFFFD]/),Be=m(Le,/\\d/,/[\\u0300-\\u036F\\u1DC0-\\u1DFF\\u20D0-\\u20FF\\uFE20-\\uFE2F]/),$e=b(Le,Be,\"*\"),Fe=b(/[A-Z]/,Be,\"*\"),ze=[\"attached\",\"autoclosure\",b(/convention\\(/,m(\"swift\",\"block\",\"c\"),/\\)/),\"discardableResult\",\"dynamicCallable\",\"dynamicMemberLookup\",\"escaping\",\"freestanding\",\"frozen\",\"GKInspectable\",\"IBAction\",\"IBDesignable\",\"IBInspectable\",\"IBOutlet\",\"IBSegueAction\",\"inlinable\",\"main\",\"nonobjc\",\"NSApplicationMain\",\"NSCopying\",\"NSManaged\",b(/objc\\(/,$e,/\\)/),\"objc\",\"objcMembers\",\"propertyWrapper\",\"requires_stored_property_inits\",\"resultBuilder\",\"Sendable\",\"testable\",\"UIApplicationMain\",\"unchecked\",\"unknown\",\"usableFromInline\",\"warn_unqualified_access\"],je=[\"iOS\",\"iOSApplicationExtension\",\"macOS\",\"macOSApplicationExtension\",\"macCatalyst\",\"macCatalystApplicationExtension\",\"watchOS\",\"watchOSApplicationExtension\",\"tvOS\",\"tvOSApplicationExtension\",\"swift\"]\n;var Ue=Object.freeze({__proto__:null,grmr_bash:e=>{const n=e.regex,t={},a={\nbegin:/\\$\\{/,end:/\\}/,contains:[\"self\",{begin:/:-/,contains:[t]}]}\n;Object.assign(t,{className:\"variable\",variants:[{\nbegin:n.concat(/\\$[\\w\\d#@][\\w\\d_]*/,\"(?![\\\\w\\\\d])(?![$])\")},a]});const i={\nclassName:\"subst\",begin:/\\$\\(/,end:/\\)/,contains:[e.BACKSLASH_ESCAPE]\n},r=e.inherit(e.COMMENT(),{match:[/(^|\\s)/,/#.*$/],scope:{2:\"comment\"}}),s={\nbegin:/<<-?\\s*(?=\\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\\w+)/,\nend:/(\\w+)/,className:\"string\"})]}},o={className:\"string\",begin:/\"/,end:/\"/,\ncontains:[e.BACKSLASH_ESCAPE,t,i]};i.contains.push(o);const l={begin:/\\$?\\(\\(/,\nend:/\\)\\)/,contains:[{begin:/\\d+#[0-9a-f]+/,className:\"number\"},e.NUMBER_MODE,t]\n},c=e.SHEBANG({binary:\"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)\",relevance:10\n}),d={className:\"function\",begin:/\\w[\\w\\d_]*\\s*\\(\\s*\\)\\s*\\{/,returnBegin:!0,\ncontains:[e.inherit(e.TITLE_MODE,{begin:/\\w[\\w\\d_]*/})],relevance:0};return{\nname:\"Bash\",aliases:[\"sh\",\"zsh\"],keywords:{$pattern:/\\b[a-z][a-z0-9._-]+\\b/,\nkeyword:[\"if\",\"then\",\"else\",\"elif\",\"fi\",\"time\",\"for\",\"while\",\"until\",\"in\",\"do\",\"done\",\"case\",\"esac\",\"coproc\",\"function\",\"select\"],\nliteral:[\"true\",\"false\"],\nbuilt_in:[\"break\",\"cd\",\"continue\",\"eval\",\"exec\",\"exit\",\"export\",\"getopts\",\"hash\",\"pwd\",\"readonly\",\"return\",\"shift\",\"test\",\"times\",\"trap\",\"umask\",\"unset\",\"alias\",\"bind\",\"builtin\",\"caller\",\"command\",\"declare\",\"echo\",\"enable\",\"help\",\"let\",\"local\",\"logout\",\"mapfile\",\"printf\",\"read\",\"readarray\",\"source\",\"sudo\",\"type\",\"typeset\",\"ulimit\",\"unalias\",\"set\",\"shopt\",\"autoload\",\"bg\",\"bindkey\",\"bye\",\"cap\",\"chdir\",\"clone\",\"comparguments\",\"compcall\",\"compctl\",\"compdescribe\",\"compfiles\",\"compgroups\",\"compquote\",\"comptags\",\"comptry\",\"compvalues\",\"dirs\",\"disable\",\"disown\",\"echotc\",\"echoti\",\"emulate\",\"fc\",\"fg\",\"float\",\"functions\",\"getcap\",\"getln\",\"history\",\"integer\",\"jobs\",\"kill\",\"limit\",\"log\",\"noglob\",\"popd\",\"print\",\"pushd\",\"pushln\",\"rehash\",\"sched\",\"setcap\",\"setopt\",\"stat\",\"suspend\",\"ttyctl\",\"unfunction\",\"unhash\",\"unlimit\",\"unsetopt\",\"vared\",\"wait\",\"whence\",\"where\",\"which\",\"zcompile\",\"zformat\",\"zftp\",\"zle\",\"zmodload\",\"zparseopts\",\"zprof\",\"zpty\",\"zregexparse\",\"zsocket\",\"zstyle\",\"ztcp\",\"chcon\",\"chgrp\",\"chown\",\"chmod\",\"cp\",\"dd\",\"df\",\"dir\",\"dircolors\",\"ln\",\"ls\",\"mkdir\",\"mkfifo\",\"mknod\",\"mktemp\",\"mv\",\"realpath\",\"rm\",\"rmdir\",\"shred\",\"sync\",\"touch\",\"truncate\",\"vdir\",\"b2sum\",\"base32\",\"base64\",\"cat\",\"cksum\",\"comm\",\"csplit\",\"cut\",\"expand\",\"fmt\",\"fold\",\"head\",\"join\",\"md5sum\",\"nl\",\"numfmt\",\"od\",\"paste\",\"ptx\",\"pr\",\"sha1sum\",\"sha224sum\",\"sha256sum\",\"sha384sum\",\"sha512sum\",\"shuf\",\"sort\",\"split\",\"sum\",\"tac\",\"tail\",\"tr\",\"tsort\",\"unexpand\",\"uniq\",\"wc\",\"arch\",\"basename\",\"chroot\",\"date\",\"dirname\",\"du\",\"echo\",\"env\",\"expr\",\"factor\",\"groups\",\"hostid\",\"id\",\"link\",\"logname\",\"nice\",\"nohup\",\"nproc\",\"pathchk\",\"pinky\",\"printenv\",\"printf\",\"pwd\",\"readlink\",\"runcon\",\"seq\",\"sleep\",\"stat\",\"stdbuf\",\"stty\",\"tee\",\"test\",\"timeout\",\"tty\",\"uname\",\"unlink\",\"uptime\",\"users\",\"who\",\"whoami\",\"yes\"]\n},contains:[c,e.SHEBANG(),d,l,r,s,{match:/(\\/[a-z._-]+)+/},o,{match:/\\\\\"/},{\nclassName:\"string\",begin:/'/,end:/'/},{match:/\\\\'/},t]}},grmr_c:e=>{\nconst n=e.regex,t=e.COMMENT(\"//\",\"$\",{contains:[{begin:/\\\\\\n/}]\n}),a=\"decltype\\\\(auto\\\\)\",i=\"[a-zA-Z_]\\\\w*::\",r=\"(\"+a+\"|\"+n.optional(i)+\"[a-zA-Z_]\\\\w*\"+n.optional(\"<[^<>]+>\")+\")\",s={\nclassName:\"type\",variants:[{begin:\"\\\\b[a-z\\\\d_]*_t\\\\b\"},{\nmatch:/\\batomic_[a-z]{3,6}\\b/}]},o={className:\"string\",variants:[{\nbegin:'(u8?|U|L)?\"',end:'\"',illegal:\"\\\\n\",contains:[e.BACKSLASH_ESCAPE]},{\nbegin:\"(u8?|U|L)?'(\\\\\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\\\S)|.)\",\nend:\"'\",illegal:\".\"},e.END_SAME_AS_BEGIN({\nbegin:/(?:u8?|U|L)?R\"([^()\\\\ ]{0,16})\\(/,end:/\\)([^()\\\\ ]{0,16})\"/})]},l={\nclassName:\"number\",variants:[{match:/\\b(0b[01']+)/},{\nmatch:/(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/\n},{\nmatch:/(-?)\\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/\n},{match:/(-?)\\b\\d+(?:'\\d+)*(?:\\.\\d*(?:'\\d*)*)?(?:[eE][-+]?\\d+)?/}],relevance:0\n},c={className:\"meta\",begin:/#\\s*[a-z]+\\b/,end:/$/,keywords:{\nkeyword:\"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include\"\n},contains:[{begin:/\\\\\\n/,relevance:0},e.inherit(o,{className:\"string\"}),{\nclassName:\"string\",begin:/<.*?>/},t,e.C_BLOCK_COMMENT_MODE]},d={\nclassName:\"title\",begin:n.optional(i)+e.IDENT_RE,relevance:0\n},g=n.optional(i)+e.IDENT_RE+\"\\\\s*\\\\(\",u={\nkeyword:[\"asm\",\"auto\",\"break\",\"case\",\"continue\",\"default\",\"do\",\"else\",\"enum\",\"extern\",\"for\",\"fortran\",\"goto\",\"if\",\"inline\",\"register\",\"restrict\",\"return\",\"sizeof\",\"typeof\",\"typeof_unqual\",\"struct\",\"switch\",\"typedef\",\"union\",\"volatile\",\"while\",\"_Alignas\",\"_Alignof\",\"_Atomic\",\"_Generic\",\"_Noreturn\",\"_Static_assert\",\"_Thread_local\",\"alignas\",\"alignof\",\"noreturn\",\"static_assert\",\"thread_local\",\"_Pragma\"],\ntype:[\"float\",\"double\",\"signed\",\"unsigned\",\"int\",\"short\",\"long\",\"char\",\"void\",\"_Bool\",\"_BitInt\",\"_Complex\",\"_Imaginary\",\"_Decimal32\",\"_Decimal64\",\"_Decimal96\",\"_Decimal128\",\"_Decimal64x\",\"_Decimal128x\",\"_Float16\",\"_Float32\",\"_Float64\",\"_Float128\",\"_Float32x\",\"_Float64x\",\"_Float128x\",\"const\",\"static\",\"constexpr\",\"complex\",\"bool\",\"imaginary\"],\nliteral:\"true false NULL\",\nbuilt_in:\"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr\"\n},b=[c,s,t,e.C_BLOCK_COMMENT_MODE,l,o],m={variants:[{begin:/=/,end:/;/},{\nbegin:/\\(/,end:/\\)/},{beginKeywords:\"new throw return else\",end:/;/}],\nkeywords:u,contains:b.concat([{begin:/\\(/,end:/\\)/,keywords:u,\ncontains:b.concat([\"self\"]),relevance:0}]),relevance:0},p={\nbegin:\"(\"+r+\"[\\\\*&\\\\s]+)+\"+g,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,\nkeywords:u,illegal:/[^\\w\\s\\*&:<>.]/,contains:[{begin:a,keywords:u,relevance:0},{\nbegin:g,returnBegin:!0,contains:[e.inherit(d,{className:\"title.function\"})],\nrelevance:0},{relevance:0,match:/,/},{className:\"params\",begin:/\\(/,end:/\\)/,\nkeywords:u,relevance:0,contains:[t,e.C_BLOCK_COMMENT_MODE,o,l,s,{begin:/\\(/,\nend:/\\)/,keywords:u,relevance:0,contains:[\"self\",t,e.C_BLOCK_COMMENT_MODE,o,l,s]\n}]},s,t,e.C_BLOCK_COMMENT_MODE,c]};return{name:\"C\",aliases:[\"h\"],keywords:u,\ndisableAutodetect:!0,illegal:\"</\",contains:[].concat(m,p,b,[c,{\nbegin:e.IDENT_RE+\"::\",keywords:u},{className:\"class\",\nbeginKeywords:\"enum class struct union\",end:/[{;:<>=]/,contains:[{\nbeginKeywords:\"final class struct\"},e.TITLE_MODE]}]),exports:{preprocessor:c,\nstrings:o,keywords:u}}},grmr_cpp:e=>{const n=e.regex,t=e.COMMENT(\"//\",\"$\",{\ncontains:[{begin:/\\\\\\n/}]\n}),a=\"decltype\\\\(auto\\\\)\",i=\"[a-zA-Z_]\\\\w*::\",r=\"(?!struct)(\"+a+\"|\"+n.optional(i)+\"[a-zA-Z_]\\\\w*\"+n.optional(\"<[^<>]+>\")+\")\",s={\nclassName:\"type\",begin:\"\\\\b[a-z\\\\d_]*_t\\\\b\"},o={className:\"string\",variants:[{\nbegin:'(u8?|U|L)?\"',end:'\"',illegal:\"\\\\n\",contains:[e.BACKSLASH_ESCAPE]},{\nbegin:\"(u8?|U|L)?'(\\\\\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\\\S)|.)\",\nend:\"'\",illegal:\".\"},e.END_SAME_AS_BEGIN({\nbegin:/(?:u8?|U|L)?R\"([^()\\\\ ]{0,16})\\(/,end:/\\)([^()\\\\ ]{0,16})\"/})]},l={\nclassName:\"number\",variants:[{\nbegin:\"[+-]?(?:(?:[0-9](?:'?[0-9])*\\\\.(?:[0-9](?:'?[0-9])*)?|\\\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)\"\n},{\nbegin:\"[+-]?\\\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)\"\n}],relevance:0},c={className:\"meta\",begin:/#\\s*[a-z]+\\b/,end:/$/,keywords:{\nkeyword:\"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include\"\n},contains:[{begin:/\\\\\\n/,relevance:0},e.inherit(o,{className:\"string\"}),{\nclassName:\"string\",begin:/<.*?>/},t,e.C_BLOCK_COMMENT_MODE]},d={\nclassName:\"title\",begin:n.optional(i)+e.IDENT_RE,relevance:0\n},g=n.optional(i)+e.IDENT_RE+\"\\\\s*\\\\(\",u={\ntype:[\"bool\",\"char\",\"char16_t\",\"char32_t\",\"char8_t\",\"double\",\"float\",\"int\",\"long\",\"short\",\"void\",\"wchar_t\",\"unsigned\",\"signed\",\"const\",\"static\"],\nkeyword:[\"alignas\",\"alignof\",\"and\",\"and_eq\",\"asm\",\"atomic_cancel\",\"atomic_commit\",\"atomic_noexcept\",\"auto\",\"bitand\",\"bitor\",\"break\",\"case\",\"catch\",\"class\",\"co_await\",\"co_return\",\"co_yield\",\"compl\",\"concept\",\"const_cast|10\",\"consteval\",\"constexpr\",\"constinit\",\"continue\",\"decltype\",\"default\",\"delete\",\"do\",\"dynamic_cast|10\",\"else\",\"enum\",\"explicit\",\"export\",\"extern\",\"false\",\"final\",\"for\",\"friend\",\"goto\",\"if\",\"import\",\"inline\",\"module\",\"mutable\",\"namespace\",\"new\",\"noexcept\",\"not\",\"not_eq\",\"nullptr\",\"operator\",\"or\",\"or_eq\",\"override\",\"private\",\"protected\",\"public\",\"reflexpr\",\"register\",\"reinterpret_cast|10\",\"requires\",\"return\",\"sizeof\",\"static_assert\",\"static_cast|10\",\"struct\",\"switch\",\"synchronized\",\"template\",\"this\",\"thread_local\",\"throw\",\"transaction_safe\",\"transaction_safe_dynamic\",\"true\",\"try\",\"typedef\",\"typeid\",\"typename\",\"union\",\"using\",\"virtual\",\"volatile\",\"while\",\"xor\",\"xor_eq\"],\nliteral:[\"NULL\",\"false\",\"nullopt\",\"nullptr\",\"true\"],built_in:[\"_Pragma\"],\n_type_hints:[\"any\",\"auto_ptr\",\"barrier\",\"binary_semaphore\",\"bitset\",\"complex\",\"condition_variable\",\"condition_variable_any\",\"counting_semaphore\",\"deque\",\"false_type\",\"flat_map\",\"flat_set\",\"future\",\"imaginary\",\"initializer_list\",\"istringstream\",\"jthread\",\"latch\",\"lock_guard\",\"multimap\",\"multiset\",\"mutex\",\"optional\",\"ostringstream\",\"packaged_task\",\"pair\",\"promise\",\"priority_queue\",\"queue\",\"recursive_mutex\",\"recursive_timed_mutex\",\"scoped_lock\",\"set\",\"shared_future\",\"shared_lock\",\"shared_mutex\",\"shared_timed_mutex\",\"shared_ptr\",\"stack\",\"string_view\",\"stringstream\",\"timed_mutex\",\"thread\",\"true_type\",\"tuple\",\"unique_lock\",\"unique_ptr\",\"unordered_map\",\"unordered_multimap\",\"unordered_multiset\",\"unordered_set\",\"variant\",\"vector\",\"weak_ptr\",\"wstring\",\"wstring_view\"]\n},b={className:\"function.dispatch\",relevance:0,keywords:{\n_hint:[\"abort\",\"abs\",\"acos\",\"apply\",\"as_const\",\"asin\",\"atan\",\"atan2\",\"calloc\",\"ceil\",\"cerr\",\"cin\",\"clog\",\"cos\",\"cosh\",\"cout\",\"declval\",\"endl\",\"exchange\",\"exit\",\"exp\",\"fabs\",\"floor\",\"fmod\",\"forward\",\"fprintf\",\"fputs\",\"free\",\"frexp\",\"fscanf\",\"future\",\"invoke\",\"isalnum\",\"isalpha\",\"iscntrl\",\"isdigit\",\"isgraph\",\"islower\",\"isprint\",\"ispunct\",\"isspace\",\"isupper\",\"isxdigit\",\"labs\",\"launder\",\"ldexp\",\"log\",\"log10\",\"make_pair\",\"make_shared\",\"make_shared_for_overwrite\",\"make_tuple\",\"make_unique\",\"malloc\",\"memchr\",\"memcmp\",\"memcpy\",\"memset\",\"modf\",\"move\",\"pow\",\"printf\",\"putchar\",\"puts\",\"realloc\",\"scanf\",\"sin\",\"sinh\",\"snprintf\",\"sprintf\",\"sqrt\",\"sscanf\",\"std\",\"stderr\",\"stdin\",\"stdout\",\"strcat\",\"strchr\",\"strcmp\",\"strcpy\",\"strcspn\",\"strlen\",\"strncat\",\"strncmp\",\"strncpy\",\"strpbrk\",\"strrchr\",\"strspn\",\"strstr\",\"swap\",\"tan\",\"tanh\",\"terminate\",\"to_underlying\",\"tolower\",\"toupper\",\"vfprintf\",\"visit\",\"vprintf\",\"vsprintf\"]\n},\nbegin:n.concat(/\\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,n.lookahead(/(<[^<>]+>|)\\s*\\(/))\n},m=[b,c,s,t,e.C_BLOCK_COMMENT_MODE,l,o],p={variants:[{begin:/=/,end:/;/},{\nbegin:/\\(/,end:/\\)/},{beginKeywords:\"new throw return else\",end:/;/}],\nkeywords:u,contains:m.concat([{begin:/\\(/,end:/\\)/,keywords:u,\ncontains:m.concat([\"self\"]),relevance:0}]),relevance:0},_={className:\"function\",\nbegin:\"(\"+r+\"[\\\\*&\\\\s]+)+\"+g,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,\nkeywords:u,illegal:/[^\\w\\s\\*&:<>.]/,contains:[{begin:a,keywords:u,relevance:0},{\nbegin:g,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{\nbegin:/:/,endsWithParent:!0,contains:[o,l]},{relevance:0,match:/,/},{\nclassName:\"params\",begin:/\\(/,end:/\\)/,keywords:u,relevance:0,\ncontains:[t,e.C_BLOCK_COMMENT_MODE,o,l,s,{begin:/\\(/,end:/\\)/,keywords:u,\nrelevance:0,contains:[\"self\",t,e.C_BLOCK_COMMENT_MODE,o,l,s]}]\n},s,t,e.C_BLOCK_COMMENT_MODE,c]};return{name:\"C++\",\naliases:[\"cc\",\"c++\",\"h++\",\"hpp\",\"hh\",\"hxx\",\"cxx\"],keywords:u,illegal:\"</\",\nclassNameAliases:{\"function.dispatch\":\"built_in\"},\ncontains:[].concat(p,_,b,m,[c,{\nbegin:\"\\\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\\\s*<(?!<)\",\nend:\">\",keywords:u,contains:[\"self\",s]},{begin:e.IDENT_RE+\"::\",keywords:u},{\nmatch:[/\\b(?:enum(?:\\s+(?:class|struct))?|class|struct|union)/,/\\s+/,/\\w+/],\nclassName:{1:\"keyword\",3:\"title.class\"}}])}},grmr_csharp:e=>{const n={\nkeyword:[\"abstract\",\"as\",\"base\",\"break\",\"case\",\"catch\",\"class\",\"const\",\"continue\",\"do\",\"else\",\"event\",\"explicit\",\"extern\",\"finally\",\"fixed\",\"for\",\"foreach\",\"goto\",\"if\",\"implicit\",\"in\",\"interface\",\"internal\",\"is\",\"lock\",\"namespace\",\"new\",\"operator\",\"out\",\"override\",\"params\",\"private\",\"protected\",\"public\",\"readonly\",\"record\",\"ref\",\"return\",\"scoped\",\"sealed\",\"sizeof\",\"stackalloc\",\"static\",\"struct\",\"switch\",\"this\",\"throw\",\"try\",\"typeof\",\"unchecked\",\"unsafe\",\"using\",\"virtual\",\"void\",\"volatile\",\"while\"].concat([\"add\",\"alias\",\"and\",\"ascending\",\"args\",\"async\",\"await\",\"by\",\"descending\",\"dynamic\",\"equals\",\"file\",\"from\",\"get\",\"global\",\"group\",\"init\",\"into\",\"join\",\"let\",\"nameof\",\"not\",\"notnull\",\"on\",\"or\",\"orderby\",\"partial\",\"record\",\"remove\",\"required\",\"scoped\",\"select\",\"set\",\"unmanaged\",\"value|0\",\"var\",\"when\",\"where\",\"with\",\"yield\"]),\nbuilt_in:[\"bool\",\"byte\",\"char\",\"decimal\",\"delegate\",\"double\",\"dynamic\",\"enum\",\"float\",\"int\",\"long\",\"nint\",\"nuint\",\"object\",\"sbyte\",\"short\",\"string\",\"ulong\",\"uint\",\"ushort\"],\nliteral:[\"default\",\"false\",\"null\",\"true\"]},t=e.inherit(e.TITLE_MODE,{\nbegin:\"[a-zA-Z](\\\\.?\\\\w)*\"}),a={className:\"number\",variants:[{\nbegin:\"\\\\b(0b[01']+)\"},{\nbegin:\"(-?)\\\\b([\\\\d']+(\\\\.[\\\\d']*)?|\\\\.[\\\\d']+)(u|U|l|L|ul|UL|f|F|b|B)\"},{\nbegin:\"(-?)(\\\\b0[xX][a-fA-F0-9']+|(\\\\b[\\\\d']+(\\\\.[\\\\d']*)?|\\\\.[\\\\d']+)([eE][-+]?[\\\\d']+)?)\"\n}],relevance:0},i={className:\"string\",begin:'@\"',end:'\"',contains:[{begin:'\"\"'}]\n},r=e.inherit(i,{illegal:/\\n/}),s={className:\"subst\",begin:/\\{/,end:/\\}/,\nkeywords:n},o=e.inherit(s,{illegal:/\\n/}),l={className:\"string\",begin:/\\$\"/,\nend:'\"',illegal:/\\n/,contains:[{begin:/\\{\\{/},{begin:/\\}\\}/\n},e.BACKSLASH_ESCAPE,o]},c={className:\"string\",begin:/\\$@\"/,end:'\"',contains:[{\nbegin:/\\{\\{/},{begin:/\\}\\}/},{begin:'\"\"'},s]},d=e.inherit(c,{illegal:/\\n/,\ncontains:[{begin:/\\{\\{/},{begin:/\\}\\}/},{begin:'\"\"'},o]})\n;s.contains=[c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE],\no.contains=[d,l,r,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{\nillegal:/\\n/})];const g={variants:[{className:\"string\",\nbegin:/\"\"\"(\"*)(?!\")(.|\\n)*?\"\"\"\\1/,relevance:1\n},c,l,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},u={begin:\"<\",end:\">\",\ncontains:[{beginKeywords:\"in out\"},t]\n},b=e.IDENT_RE+\"(<\"+e.IDENT_RE+\"(\\\\s*,\\\\s*\"+e.IDENT_RE+\")*>)?(\\\\[\\\\])?\",m={\nbegin:\"@\"+e.IDENT_RE,relevance:0};return{name:\"C#\",aliases:[\"cs\",\"c#\"],\nkeywords:n,illegal:/::/,contains:[e.COMMENT(\"///\",\"$\",{returnBegin:!0,\ncontains:[{className:\"doctag\",variants:[{begin:\"///\",relevance:0},{\nbegin:\"\\x3c!--|--\\x3e\"},{begin:\"</?\",end:\">\"}]}]\n}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:\"meta\",begin:\"#\",\nend:\"$\",keywords:{\nkeyword:\"if else elif endif define undef warning error line region endregion pragma checksum\"\n}},g,a,{beginKeywords:\"class interface\",relevance:0,end:/[{;=]/,\nillegal:/[^\\s:,]/,contains:[{beginKeywords:\"where class\"\n},t,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:\"namespace\",\nrelevance:0,end:/[{;=]/,illegal:/[^\\s:]/,\ncontains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{\nbeginKeywords:\"record\",relevance:0,end:/[{;=]/,illegal:/[^\\s:]/,\ncontains:[t,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:\"meta\",\nbegin:\"^\\\\s*\\\\[(?=[\\\\w])\",excludeBegin:!0,end:\"\\\\]\",excludeEnd:!0,contains:[{\nclassName:\"string\",begin:/\"/,end:/\"/}]},{\nbeginKeywords:\"new return throw await else\",relevance:0},{className:\"function\",\nbegin:\"(\"+b+\"\\\\s+)+\"+e.IDENT_RE+\"\\\\s*(<[^=]+>\\\\s*)?\\\\(\",returnBegin:!0,\nend:/\\s*[{;=]/,excludeEnd:!0,keywords:n,contains:[{\nbeginKeywords:\"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial\",\nrelevance:0},{begin:e.IDENT_RE+\"\\\\s*(<[^=]+>\\\\s*)?\\\\(\",returnBegin:!0,\ncontains:[e.TITLE_MODE,u],relevance:0},{match:/\\(\\)/},{className:\"params\",\nbegin:/\\(/,end:/\\)/,excludeBegin:!0,excludeEnd:!0,keywords:n,relevance:0,\ncontains:[g,a,e.C_BLOCK_COMMENT_MODE]\n},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},m]}},grmr_css:e=>{\nconst n=e.regex,t=te(e),a=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{\nname:\"CSS\",case_insensitive:!0,illegal:/[=|'\\$]/,keywords:{\nkeyframePosition:\"from to\"},classNameAliases:{keyframePosition:\"selector-tag\"},\ncontains:[t.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/\n},t.CSS_NUMBER_MODE,{className:\"selector-id\",begin:/#[A-Za-z0-9_-]+/,relevance:0\n},{className:\"selector-class\",begin:\"\\\\.[a-zA-Z-][a-zA-Z0-9_-]*\",relevance:0\n},t.ATTRIBUTE_SELECTOR_MODE,{className:\"selector-pseudo\",variants:[{\nbegin:\":(\"+re.join(\"|\")+\")\"},{begin:\":(:)?(\"+se.join(\"|\")+\")\"}]\n},t.CSS_VARIABLE,{className:\"attribute\",begin:\"\\\\b(\"+oe.join(\"|\")+\")\\\\b\"},{\nbegin:/:/,end:/[;}{]/,\ncontains:[t.BLOCK_COMMENT,t.HEXCOLOR,t.IMPORTANT,t.CSS_NUMBER_MODE,...a,{\nbegin:/(url|data-uri)\\(/,end:/\\)/,relevance:0,keywords:{built_in:\"url data-uri\"\n},contains:[...a,{className:\"string\",begin:/[^)]/,endsWithParent:!0,\nexcludeEnd:!0}]},t.FUNCTION_DISPATCH]},{begin:n.lookahead(/@/),end:\"[{;]\",\nrelevance:0,illegal:/:/,contains:[{className:\"keyword\",begin:/@-?\\w[\\w]*(-\\w+)*/\n},{begin:/\\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{\n$pattern:/[a-z-]+/,keyword:\"and or not only\",attribute:ie.join(\" \")},contains:[{\nbegin:/[a-z-]+(?=:)/,className:\"attribute\"},...a,t.CSS_NUMBER_MODE]}]},{\nclassName:\"selector-tag\",begin:\"\\\\b(\"+ae.join(\"|\")+\")\\\\b\"}]}},grmr_diff:e=>{\nconst n=e.regex;return{name:\"Diff\",aliases:[\"patch\"],contains:[{\nclassName:\"meta\",relevance:10,\nmatch:n.either(/^@@ +-\\d+,\\d+ +\\+\\d+,\\d+ +@@/,/^\\*\\*\\* +\\d+,\\d+ +\\*\\*\\*\\*$/,/^--- +\\d+,\\d+ +----$/)\n},{className:\"comment\",variants:[{\nbegin:n.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\\*{3} /,/^\\+{3}/,/^diff --git/),\nend:/$/},{match:/^\\*{15}$/}]},{className:\"addition\",begin:/^\\+/,end:/$/},{\nclassName:\"deletion\",begin:/^-/,end:/$/},{className:\"addition\",begin:/^!/,\nend:/$/}]}},grmr_go:e=>{const n={\nkeyword:[\"break\",\"case\",\"chan\",\"const\",\"continue\",\"default\",\"defer\",\"else\",\"fallthrough\",\"for\",\"func\",\"go\",\"goto\",\"if\",\"import\",\"interface\",\"map\",\"package\",\"range\",\"return\",\"select\",\"struct\",\"switch\",\"type\",\"var\"],\ntype:[\"bool\",\"byte\",\"complex64\",\"complex128\",\"error\",\"float32\",\"float64\",\"int8\",\"int16\",\"int32\",\"int64\",\"string\",\"uint8\",\"uint16\",\"uint32\",\"uint64\",\"int\",\"uint\",\"uintptr\",\"rune\"],\nliteral:[\"true\",\"false\",\"iota\",\"nil\"],\nbuilt_in:[\"append\",\"cap\",\"close\",\"complex\",\"copy\",\"imag\",\"len\",\"make\",\"new\",\"panic\",\"print\",\"println\",\"real\",\"recover\",\"delete\"]\n};return{name:\"Go\",aliases:[\"golang\"],keywords:n,illegal:\"</\",\ncontains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:\"string\",\nvariants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:\"`\",end:\"`\"}]},{\nclassName:\"number\",variants:[{\nmatch:/-?\\b0[xX]\\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\\d(_?\\d)*i?/,relevance:0\n},{\nmatch:/-?\\b0[xX](_?[a-fA-F0-9])+((\\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\\d(_?\\d)*)?i?/,\nrelevance:0},{match:/-?\\b0[oO](_?[0-7])*i?/,relevance:0},{\nmatch:/-?\\.\\d(_?\\d)*([eE][+-]?\\d(_?\\d)*)?i?/,relevance:0},{\nmatch:/-?\\b\\d(_?\\d)*(\\.(\\d(_?\\d)*)?)?([eE][+-]?\\d(_?\\d)*)?i?/,relevance:0}]},{\nbegin:/:=/},{className:\"function\",beginKeywords:\"func\",end:\"\\\\s*(\\\\{|$)\",\nexcludeEnd:!0,contains:[e.TITLE_MODE,{className:\"params\",begin:/\\(/,end:/\\)/,\nendsParent:!0,keywords:n,illegal:/[\"']/}]}]}},grmr_graphql:e=>{const n=e.regex\n;return{name:\"GraphQL\",aliases:[\"gql\"],case_insensitive:!0,disableAutodetect:!1,\nkeywords:{\nkeyword:[\"query\",\"mutation\",\"subscription\",\"type\",\"input\",\"schema\",\"directive\",\"interface\",\"union\",\"scalar\",\"fragment\",\"enum\",\"on\"],\nliteral:[\"true\",\"false\",\"null\"]},\ncontains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{\nscope:\"punctuation\",match:/[.]{3}/,relevance:0},{scope:\"punctuation\",\nbegin:/[\\!\\(\\)\\:\\=\\[\\]\\{\\|\\}]{1}/,relevance:0},{scope:\"variable\",begin:/\\$/,\nend:/\\W/,excludeEnd:!0,relevance:0},{scope:\"meta\",match:/@\\w+/,excludeEnd:!0},{\nscope:\"symbol\",begin:n.concat(/[_A-Za-z][_0-9A-Za-z]*/,n.lookahead(/\\s*:/)),\nrelevance:0}],illegal:[/[;<']/,/BEGIN/]}},grmr_ini:e=>{const n=e.regex,t={\nclassName:\"number\",relevance:0,variants:[{begin:/([+-]+)?[\\d]+_[\\d_]+/},{\nbegin:e.NUMBER_RE}]},a=e.COMMENT();a.variants=[{begin:/;/,end:/$/},{begin:/#/,\nend:/$/}];const i={className:\"variable\",variants:[{begin:/\\$[\\w\\d\"][\\w\\d_]*/},{\nbegin:/\\$\\{(.*?)\\}/}]},r={className:\"literal\",\nbegin:/\\bon|off|true|false|yes|no\\b/},s={className:\"string\",\ncontains:[e.BACKSLASH_ESCAPE],variants:[{begin:\"'''\",end:\"'''\",relevance:10},{\nbegin:'\"\"\"',end:'\"\"\"',relevance:10},{begin:'\"',end:'\"'},{begin:\"'\",end:\"'\"}]\n},o={begin:/\\[/,end:/\\]/,contains:[a,r,i,s,t,\"self\"],relevance:0\n},l=n.either(/[A-Za-z0-9_-]+/,/\"(\\\\\"|[^\"])*\"/,/'[^']*'/);return{\nname:\"TOML, also INI\",aliases:[\"toml\"],case_insensitive:!0,illegal:/\\S/,\ncontains:[a,{className:\"section\",begin:/\\[+/,end:/\\]+/},{\nbegin:n.concat(l,\"(\\\\s*\\\\.\\\\s*\",l,\")*\",n.lookahead(/\\s*=\\s*[^#\\s]/)),\nclassName:\"attr\",starts:{end:/$/,contains:[a,o,r,i,s,t]}}]}},grmr_java:e=>{\nconst n=e.regex,t=\"[\\xc0-\\u02b8a-zA-Z_$][\\xc0-\\u02b8a-zA-Z_$0-9]*\",a=t+be(\"(?:<\"+t+\"~~~(?:\\\\s*,\\\\s*\"+t+\"~~~)*>)?\",/~~~/g,2),i={\nkeyword:[\"synchronized\",\"abstract\",\"private\",\"var\",\"static\",\"if\",\"const \",\"for\",\"while\",\"strictfp\",\"finally\",\"protected\",\"import\",\"native\",\"final\",\"void\",\"enum\",\"else\",\"break\",\"transient\",\"catch\",\"instanceof\",\"volatile\",\"case\",\"assert\",\"package\",\"default\",\"public\",\"try\",\"switch\",\"continue\",\"throws\",\"protected\",\"public\",\"private\",\"module\",\"requires\",\"exports\",\"do\",\"sealed\",\"yield\",\"permits\",\"goto\",\"when\"],\nliteral:[\"false\",\"true\",\"null\"],\ntype:[\"char\",\"boolean\",\"long\",\"float\",\"int\",\"byte\",\"short\",\"double\"],\nbuilt_in:[\"super\",\"this\"]},r={className:\"meta\",begin:\"@\"+t,contains:[{\nbegin:/\\(/,end:/\\)/,contains:[\"self\"]}]},s={className:\"params\",begin:/\\(/,\nend:/\\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0}\n;return{name:\"Java\",aliases:[\"jsp\"],keywords:i,illegal:/<\\/|#/,\ncontains:[e.COMMENT(\"/\\\\*\\\\*\",\"\\\\*/\",{relevance:0,contains:[{begin:/\\w+@/,\nrelevance:0},{className:\"doctag\",begin:\"@[A-Za-z]+\"}]}),{\nbegin:/import java\\.[a-z]+\\./,keywords:\"import\",relevance:2\n},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/\"\"\"/,end:/\"\"\"/,\nclassName:\"string\",contains:[e.BACKSLASH_ESCAPE]\n},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{\nmatch:[/\\b(?:class|interface|enum|extends|implements|new)/,/\\s+/,t],className:{\n1:\"keyword\",3:\"title.class\"}},{match:/non-sealed/,scope:\"keyword\"},{\nbegin:[n.concat(/(?!else)/,t),/\\s+/,t,/\\s+/,/=(?!=)/],className:{1:\"type\",\n3:\"variable\",5:\"operator\"}},{begin:[/record/,/\\s+/,t],className:{1:\"keyword\",\n3:\"title.class\"},contains:[s,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{\nbeginKeywords:\"new throw return else\",relevance:0},{\nbegin:[\"(?:\"+a+\"\\\\s+)\",e.UNDERSCORE_IDENT_RE,/\\s*(?=\\()/],className:{\n2:\"title.function\"},keywords:i,contains:[{className:\"params\",begin:/\\(/,\nend:/\\)/,keywords:i,relevance:0,\ncontains:[r,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,ue,e.C_BLOCK_COMMENT_MODE]\n},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},ue,r]}},grmr_javascript:ve,\ngrmr_json:e=>{const n=[\"true\",\"false\",\"null\"],t={scope:\"literal\",\nbeginKeywords:n.join(\" \")};return{name:\"JSON\",aliases:[\"jsonc\"],keywords:{\nliteral:n},contains:[{className:\"attr\",begin:/\"(\\\\.|[^\\\\\"\\r\\n])*\"(?=\\s*:)/,\nrelevance:1.01},{match:/[{}[\\],:]/,className:\"punctuation\",relevance:0\n},e.QUOTE_STRING_MODE,t,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],\nillegal:\"\\\\S\"}},grmr_kotlin:e=>{const n={\nkeyword:\"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual\",\nbuilt_in:\"Byte Short Char Int Long Boolean Float Double Void Unit Nothing\",\nliteral:\"true false null\"},t={className:\"symbol\",begin:e.UNDERSCORE_IDENT_RE+\"@\"\n},a={className:\"subst\",begin:/\\$\\{/,end:/\\}/,contains:[e.C_NUMBER_MODE]},i={\nclassName:\"variable\",begin:\"\\\\$\"+e.UNDERSCORE_IDENT_RE},r={className:\"string\",\nvariants:[{begin:'\"\"\"',end:'\"\"\"(?=[^\"])',contains:[i,a]},{begin:\"'\",end:\"'\",\nillegal:/\\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'\"',end:'\"',illegal:/\\n/,\ncontains:[e.BACKSLASH_ESCAPE,i,a]}]};a.contains.push(r);const s={\nclassName:\"meta\",\nbegin:\"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\\\s*:(?:\\\\s*\"+e.UNDERSCORE_IDENT_RE+\")?\"\n},o={className:\"meta\",begin:\"@\"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\\(/,\nend:/\\)/,contains:[e.inherit(r,{className:\"string\"}),\"self\"]}]\n},l=ue,c=e.COMMENT(\"/\\\\*\",\"\\\\*/\",{contains:[e.C_BLOCK_COMMENT_MODE]}),d={\nvariants:[{className:\"type\",begin:e.UNDERSCORE_IDENT_RE},{begin:/\\(/,end:/\\)/,\ncontains:[]}]},g=d;return g.variants[1].contains=[d],d.variants[1].contains=[g],\n{name:\"Kotlin\",aliases:[\"kt\",\"kts\"],keywords:n,\ncontains:[e.COMMENT(\"/\\\\*\\\\*\",\"\\\\*/\",{relevance:0,contains:[{className:\"doctag\",\nbegin:\"@[A-Za-z]+\"}]}),e.C_LINE_COMMENT_MODE,c,{className:\"keyword\",\nbegin:/\\b(break|continue|return|this)\\b/,starts:{contains:[{className:\"symbol\",\nbegin:/@\\w+/}]}},t,s,o,{className:\"function\",beginKeywords:\"fun\",end:\"[(]|$\",\nreturnBegin:!0,excludeEnd:!0,keywords:n,relevance:5,contains:[{\nbegin:e.UNDERSCORE_IDENT_RE+\"\\\\s*\\\\(\",returnBegin:!0,relevance:0,\ncontains:[e.UNDERSCORE_TITLE_MODE]},{className:\"type\",begin:/</,end:/>/,\nkeywords:\"reified\",relevance:0},{className:\"params\",begin:/\\(/,end:/\\)/,\nendsParent:!0,keywords:n,relevance:0,contains:[{begin:/:/,end:/[=,\\/]/,\nendsWithParent:!0,contains:[d,e.C_LINE_COMMENT_MODE,c],relevance:0\n},e.C_LINE_COMMENT_MODE,c,s,o,r,e.C_NUMBER_MODE]},c]},{\nbegin:[/class|interface|trait/,/\\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{\n3:\"title.class\"},keywords:\"class interface trait\",end:/[:\\{(]|$/,excludeEnd:!0,\nillegal:\"extends implements\",contains:[{\nbeginKeywords:\"public protected internal private constructor\"\n},e.UNDERSCORE_TITLE_MODE,{className:\"type\",begin:/</,end:/>/,excludeBegin:!0,\nexcludeEnd:!0,relevance:0},{className:\"type\",begin:/[,:]\\s*/,end:/[<\\(,){\\s]|$/,\nexcludeBegin:!0,returnEnd:!0},s,o]},r,{className:\"meta\",begin:\"^#!/usr/bin/env\",\nend:\"$\",illegal:\"\\n\"},l]}},grmr_less:e=>{\nconst n=te(e),t=le,a=\"[\\\\w-]+\",i=\"(\"+a+\"|@\\\\{\"+a+\"\\\\})\",r=[],s=[],o=e=>({\nclassName:\"string\",begin:\"~?\"+e+\".*?\"+e}),l=(e,n,t)=>({className:e,begin:n,\nrelevance:t}),c={$pattern:/[a-z-]+/,keyword:\"and or not only\",\nattribute:ie.join(\" \")},d={begin:\"\\\\(\",end:\"\\\\)\",contains:s,keywords:c,\nrelevance:0}\n;s.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,o(\"'\"),o('\"'),n.CSS_NUMBER_MODE,{\nbegin:\"(url|data-uri)\\\\(\",starts:{className:\"string\",end:\"[\\\\)\\\\n]\",\nexcludeEnd:!0}\n},n.HEXCOLOR,d,l(\"variable\",\"@@?\"+a,10),l(\"variable\",\"@\\\\{\"+a+\"\\\\}\"),l(\"built_in\",\"~?`[^`]*?`\"),{\nclassName:\"attribute\",begin:a+\"\\\\s*:\",end:\":\",returnBegin:!0,excludeEnd:!0\n},n.IMPORTANT,{beginKeywords:\"and not\"},n.FUNCTION_DISPATCH);const g=s.concat({\nbegin:/\\{/,end:/\\}/,contains:r}),u={beginKeywords:\"when\",endsWithParent:!0,\ncontains:[{beginKeywords:\"and not\"}].concat(s)},b={begin:i+\"\\\\s*:\",\nreturnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/\n},n.CSS_VARIABLE,{className:\"attribute\",begin:\"\\\\b(\"+oe.join(\"|\")+\")\\\\b\",\nend:/(?=:)/,starts:{endsWithParent:!0,illegal:\"[<=$]\",relevance:0,contains:s}}]\n},m={className:\"keyword\",\nbegin:\"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\\\b\",\nstarts:{end:\"[;{}]\",keywords:c,returnEnd:!0,contains:s,relevance:0}},p={\nclassName:\"variable\",variants:[{begin:\"@\"+a+\"\\\\s*:\",relevance:15},{begin:\"@\"+a\n}],starts:{end:\"[;}]\",returnEnd:!0,contains:g}},_={variants:[{\nbegin:\"[\\\\.#:&\\\\[>]\",end:\"[;{}]\"},{begin:i,end:/\\{/}],returnBegin:!0,\nreturnEnd:!0,illegal:\"[<='$\\\"]\",relevance:0,\ncontains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,u,l(\"keyword\",\"all\\\\b\"),l(\"variable\",\"@\\\\{\"+a+\"\\\\}\"),{\nbegin:\"\\\\b(\"+ae.join(\"|\")+\")\\\\b\",className:\"selector-tag\"\n},n.CSS_NUMBER_MODE,l(\"selector-tag\",i,0),l(\"selector-id\",\"#\"+i),l(\"selector-class\",\"\\\\.\"+i,0),l(\"selector-tag\",\"&\",0),n.ATTRIBUTE_SELECTOR_MODE,{\nclassName:\"selector-pseudo\",begin:\":(\"+re.join(\"|\")+\")\"},{\nclassName:\"selector-pseudo\",begin:\":(:)?(\"+se.join(\"|\")+\")\"},{begin:/\\(/,\nend:/\\)/,relevance:0,contains:g},{begin:\"!important\"},n.FUNCTION_DISPATCH]},h={\nbegin:a+\":(:)?\"+`(${t.join(\"|\")})`,returnBegin:!0,contains:[_]}\n;return r.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m,p,h,b,_,u,n.FUNCTION_DISPATCH),\n{name:\"Less\",case_insensitive:!0,illegal:\"[=>'/<($\\\"]\",contains:r}},\ngrmr_lua:e=>{const n=\"\\\\[=*\\\\[\",t=\"\\\\]=*\\\\]\",a={begin:n,end:t,contains:[\"self\"]\n},i=[e.COMMENT(\"--(?!\"+n+\")\",\"$\"),e.COMMENT(\"--\"+n,t,{contains:[a],relevance:10\n})];return{name:\"Lua\",aliases:[\"pluto\"],keywords:{\n$pattern:e.UNDERSCORE_IDENT_RE,literal:\"true false nil\",\nkeyword:\"and break do else elseif end for goto if in local not or repeat return then until while\",\nbuilt_in:\"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove\"\n},contains:i.concat([{className:\"function\",beginKeywords:\"function\",end:\"\\\\)\",\ncontains:[e.inherit(e.TITLE_MODE,{\nbegin:\"([_a-zA-Z]\\\\w*\\\\.)*([_a-zA-Z]\\\\w*:)?[_a-zA-Z]\\\\w*\"}),{className:\"params\",\nbegin:\"\\\\(\",endsWithParent:!0,contains:i}].concat(i)\n},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:\"string\",\nbegin:n,end:t,contains:[a],relevance:5}])}},grmr_makefile:e=>{const n={\nclassName:\"variable\",variants:[{begin:\"\\\\$\\\\(\"+e.UNDERSCORE_IDENT_RE+\"\\\\)\",\ncontains:[e.BACKSLASH_ESCAPE]},{begin:/\\$[@%<?\\^\\+\\*]/}]},t={className:\"string\",\nbegin:/\"/,end:/\"/,contains:[e.BACKSLASH_ESCAPE,n]},a={className:\"variable\",\nbegin:/\\$\\([\\w-]+\\s/,end:/\\)/,keywords:{\nbuilt_in:\"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value\"\n},contains:[n,t]},i={begin:\"^\"+e.UNDERSCORE_IDENT_RE+\"\\\\s*(?=[:+?]?=)\"},r={\nclassName:\"section\",begin:/^[^\\s]+:/,end:/$/,contains:[n]};return{\nname:\"Makefile\",aliases:[\"mk\",\"mak\",\"make\"],keywords:{$pattern:/[\\w-]+/,\nkeyword:\"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath\"\n},contains:[e.HASH_COMMENT_MODE,n,t,a,i,{className:\"meta\",begin:/^\\.PHONY:/,\nend:/$/,keywords:{$pattern:/[\\.\\w]+/,keyword:\".PHONY\"}},r]}},grmr_markdown:e=>{\nconst n={begin:/<\\/?[A-Za-z_]/,end:\">\",subLanguage:\"xml\",relevance:0},t={\nvariants:[{begin:/\\[.+?\\]\\[.*?\\]/,relevance:0},{\nbegin:/\\[.+?\\]\\(((data|javascript|mailto):|(?:http|ftp)s?:\\/\\/).*?\\)/,\nrelevance:2},{\nbegin:e.regex.concat(/\\[.+?\\]\\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\\/\\/.*?\\)/),\nrelevance:2},{begin:/\\[.+?\\]\\([./?&#].*?\\)/,relevance:1},{\nbegin:/\\[.*?\\]\\(.*?\\)/,relevance:0}],returnBegin:!0,contains:[{match:/\\[(?=\\])/\n},{className:\"string\",relevance:0,begin:\"\\\\[\",end:\"\\\\]\",excludeBegin:!0,\nreturnEnd:!0},{className:\"link\",relevance:0,begin:\"\\\\]\\\\(\",end:\"\\\\)\",\nexcludeBegin:!0,excludeEnd:!0},{className:\"symbol\",relevance:0,begin:\"\\\\]\\\\[\",\nend:\"\\\\]\",excludeBegin:!0,excludeEnd:!0}]},a={className:\"strong\",contains:[],\nvariants:[{begin:/_{2}(?!\\s)/,end:/_{2}/},{begin:/\\*{2}(?!\\s)/,end:/\\*{2}/}]\n},i={className:\"emphasis\",contains:[],variants:[{begin:/\\*(?![*\\s])/,end:/\\*/},{\nbegin:/_(?![_\\s])/,end:/_/,relevance:0}]},r=e.inherit(a,{contains:[]\n}),s=e.inherit(i,{contains:[]});a.contains.push(s),i.contains.push(r)\n;let o=[n,t];return[a,i,r,s].forEach((e=>{e.contains=e.contains.concat(o)\n})),o=o.concat(a,i),{name:\"Markdown\",aliases:[\"md\",\"mkdown\",\"mkd\"],contains:[{\nclassName:\"section\",variants:[{begin:\"^#{1,6}\",end:\"$\",contains:o},{\nbegin:\"(?=^.+?\\\\n[=-]{2,}$)\",contains:[{begin:\"^[=-]*$\"},{begin:\"^\",end:\"\\\\n\",\ncontains:o}]}]},n,{className:\"bullet\",begin:\"^[ \\t]*([*+-]|(\\\\d+\\\\.))(?=\\\\s+)\",\nend:\"\\\\s+\",excludeEnd:!0},a,i,{className:\"quote\",begin:\"^>\\\\s+\",contains:o,\nend:\"$\"},{className:\"code\",variants:[{begin:\"(`{3,})[^`](.|\\\\n)*?\\\\1`*[ ]*\"},{\nbegin:\"(~{3,})[^~](.|\\\\n)*?\\\\1~*[ ]*\"},{begin:\"```\",end:\"```+[ ]*$\"},{\nbegin:\"~~~\",end:\"~~~+[ ]*$\"},{begin:\"`.+?`\"},{begin:\"(?=^( {4}|\\\\t))\",\ncontains:[{begin:\"^( {4}|\\\\t)\",end:\"(\\\\n)$\"}],relevance:0}]},{\nbegin:\"^[-\\\\*]{3,}\",end:\"$\"},t,{begin:/^\\[[^\\n]+\\]:/,returnBegin:!0,contains:[{\nclassName:\"symbol\",begin:/\\[/,end:/\\]/,excludeBegin:!0,excludeEnd:!0},{\nclassName:\"link\",begin:/:\\s*/,end:/$/,excludeBegin:!0}]},{scope:\"literal\",\nmatch:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}},\ngrmr_objectivec:e=>{const n=/[a-zA-Z@][a-zA-Z0-9_]*/,t={$pattern:n,\nkeyword:[\"@interface\",\"@class\",\"@protocol\",\"@implementation\"]};return{\nname:\"Objective-C\",aliases:[\"mm\",\"objc\",\"obj-c\",\"obj-c++\",\"objective-c++\"],\nkeywords:{\"variable.language\":[\"this\",\"super\"],$pattern:n,\nkeyword:[\"while\",\"export\",\"sizeof\",\"typedef\",\"const\",\"struct\",\"for\",\"union\",\"volatile\",\"static\",\"mutable\",\"if\",\"do\",\"return\",\"goto\",\"enum\",\"else\",\"break\",\"extern\",\"asm\",\"case\",\"default\",\"register\",\"explicit\",\"typename\",\"switch\",\"continue\",\"inline\",\"readonly\",\"assign\",\"readwrite\",\"self\",\"@synchronized\",\"id\",\"typeof\",\"nonatomic\",\"IBOutlet\",\"IBAction\",\"strong\",\"weak\",\"copy\",\"in\",\"out\",\"inout\",\"bycopy\",\"byref\",\"oneway\",\"__strong\",\"__weak\",\"__block\",\"__autoreleasing\",\"@private\",\"@protected\",\"@public\",\"@try\",\"@property\",\"@end\",\"@throw\",\"@catch\",\"@finally\",\"@autoreleasepool\",\"@synthesize\",\"@dynamic\",\"@selector\",\"@optional\",\"@required\",\"@encode\",\"@package\",\"@import\",\"@defs\",\"@compatibility_alias\",\"__bridge\",\"__bridge_transfer\",\"__bridge_retained\",\"__bridge_retain\",\"__covariant\",\"__contravariant\",\"__kindof\",\"_Nonnull\",\"_Nullable\",\"_Null_unspecified\",\"__FUNCTION__\",\"__PRETTY_FUNCTION__\",\"__attribute__\",\"getter\",\"setter\",\"retain\",\"unsafe_unretained\",\"nonnull\",\"nullable\",\"null_unspecified\",\"null_resettable\",\"class\",\"instancetype\",\"NS_DESIGNATED_INITIALIZER\",\"NS_UNAVAILABLE\",\"NS_REQUIRES_SUPER\",\"NS_RETURNS_INNER_POINTER\",\"NS_INLINE\",\"NS_AVAILABLE\",\"NS_DEPRECATED\",\"NS_ENUM\",\"NS_OPTIONS\",\"NS_SWIFT_UNAVAILABLE\",\"NS_ASSUME_NONNULL_BEGIN\",\"NS_ASSUME_NONNULL_END\",\"NS_REFINED_FOR_SWIFT\",\"NS_SWIFT_NAME\",\"NS_SWIFT_NOTHROW\",\"NS_DURING\",\"NS_HANDLER\",\"NS_ENDHANDLER\",\"NS_VALUERETURN\",\"NS_VOIDRETURN\"],\nliteral:[\"false\",\"true\",\"FALSE\",\"TRUE\",\"nil\",\"YES\",\"NO\",\"NULL\"],\nbuilt_in:[\"dispatch_once_t\",\"dispatch_queue_t\",\"dispatch_sync\",\"dispatch_async\",\"dispatch_once\"],\ntype:[\"int\",\"float\",\"char\",\"unsigned\",\"signed\",\"short\",\"long\",\"double\",\"wchar_t\",\"unichar\",\"void\",\"bool\",\"BOOL\",\"id|0\",\"_Bool\"]\n},illegal:\"</\",contains:[{className:\"built_in\",\nbegin:\"\\\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\\\w+\"\n},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{\nclassName:\"string\",variants:[{begin:'@\"',end:'\"',illegal:\"\\\\n\",\ncontains:[e.BACKSLASH_ESCAPE]}]},{className:\"meta\",begin:/#\\s*[a-z]+\\b/,end:/$/,\nkeywords:{\nkeyword:\"if else elif endif define undef warning error line pragma ifdef ifndef include\"\n},contains:[{begin:/\\\\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{\nclassName:\"string\"}),{className:\"string\",begin:/<.*?>/,end:/$/,illegal:\"\\\\n\"\n},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:\"class\",\nbegin:\"(\"+t.keyword.join(\"|\")+\")\\\\b\",end:/(\\{|$)/,excludeEnd:!0,keywords:t,\ncontains:[e.UNDERSCORE_TITLE_MODE]},{begin:\"\\\\.\"+e.UNDERSCORE_IDENT_RE,\nrelevance:0}]}},grmr_perl:e=>{const n=e.regex,t=/[dualxmsipngr]{0,12}/,a={\n$pattern:/[\\w.]+/,\nkeyword:\"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir connect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0\"\n},i={className:\"subst\",begin:\"[$@]\\\\{\",end:\"\\\\}\",keywords:a},r={begin:/->\\{/,\nend:/\\}/},s={scope:\"attr\",match:/\\s+:\\s*\\w+(\\s*\\(.*?\\))?/},o={scope:\"variable\",\nvariants:[{begin:/\\$\\d/},{\nbegin:n.concat(/[$%@](?!\")(\\^\\w\\b|#\\w+(::\\w+)*|\\{\\w+\\}|\\w+(::\\w*)*)/,\"(?![A-Za-z])(?![@$%])\")\n},{begin:/[$%@](?!\")[^\\s\\w{=]|\\$=/,relevance:0}],contains:[s]},l={\nclassName:\"number\",variants:[{match:/0?\\.[0-9][0-9_]+\\b/},{\nmatch:/\\bv?(0|[1-9][0-9_]*(\\.[0-9_]+)?|[1-9][0-9_]*)\\b/},{\nmatch:/\\b0[0-7][0-7_]*\\b/},{match:/\\b0x[0-9a-fA-F][0-9a-fA-F_]*\\b/},{\nmatch:/\\b0b[0-1][0-1_]*\\b/}],relevance:0\n},c=[e.BACKSLASH_ESCAPE,i,o],d=[/!/,/\\//,/\\|/,/\\?/,/'/,/\"/,/#/],g=(e,a,i=\"\\\\1\")=>{\nconst r=\"\\\\1\"===i?i:n.concat(i,a)\n;return n.concat(n.concat(\"(?:\",e,\")\"),a,/(?:\\\\.|[^\\\\\\/])*?/,r,/(?:\\\\.|[^\\\\\\/])*?/,i,t)\n},u=(e,a,i)=>n.concat(n.concat(\"(?:\",e,\")\"),a,/(?:\\\\.|[^\\\\\\/])*?/,i,t),b=[o,e.HASH_COMMENT_MODE,e.COMMENT(/^=\\w/,/=cut/,{\nendsWithParent:!0}),r,{className:\"string\",contains:c,variants:[{\nbegin:\"q[qwxr]?\\\\s*\\\\(\",end:\"\\\\)\",relevance:5},{begin:\"q[qwxr]?\\\\s*\\\\[\",\nend:\"\\\\]\",relevance:5},{begin:\"q[qwxr]?\\\\s*\\\\{\",end:\"\\\\}\",relevance:5},{\nbegin:\"q[qwxr]?\\\\s*\\\\|\",end:\"\\\\|\",relevance:5},{begin:\"q[qwxr]?\\\\s*<\",end:\">\",\nrelevance:5},{begin:\"qw\\\\s+q\",end:\"q\",relevance:5},{begin:\"'\",end:\"'\",\ncontains:[e.BACKSLASH_ESCAPE]},{begin:'\"',end:'\"'},{begin:\"`\",end:\"`\",\ncontains:[e.BACKSLASH_ESCAPE]},{begin:/\\{\\w+\\}/,relevance:0},{\nbegin:\"-?\\\\w+\\\\s*=>\",relevance:0}]},l,{\nbegin:\"(\\\\/\\\\/|\"+e.RE_STARTERS_RE+\"|\\\\b(split|return|print|reverse|grep)\\\\b)\\\\s*\",\nkeywords:\"split return print reverse grep\",relevance:0,\ncontains:[e.HASH_COMMENT_MODE,{className:\"regexp\",variants:[{\nbegin:g(\"s|tr|y\",n.either(...d,{capture:!0}))},{begin:g(\"s|tr|y\",\"\\\\(\",\"\\\\)\")},{\nbegin:g(\"s|tr|y\",\"\\\\[\",\"\\\\]\")},{begin:g(\"s|tr|y\",\"\\\\{\",\"\\\\}\")}],relevance:2},{\nclassName:\"regexp\",variants:[{begin:/(m|qr)\\/\\//,relevance:0},{\nbegin:u(\"(?:m|qr)?\",/\\//,/\\//)},{begin:u(\"m|qr\",n.either(...d,{capture:!0\n}),/\\1/)},{begin:u(\"m|qr\",/\\(/,/\\)/)},{begin:u(\"m|qr\",/\\[/,/\\]/)},{\nbegin:u(\"m|qr\",/\\{/,/\\}/)}]}]},{className:\"function\",beginKeywords:\"sub method\",\nend:\"(\\\\s*\\\\(.*?\\\\))?[;{]\",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s]\n},{className:\"class\",beginKeywords:\"class\",end:\"[;{]\",excludeEnd:!0,relevance:5,\ncontains:[e.TITLE_MODE,s,l]},{begin:\"-\\\\w\\\\b\",relevance:0},{begin:\"^__DATA__$\",\nend:\"^__END__$\",subLanguage:\"mojolicious\",contains:[{begin:\"^@@.*\",end:\"$\",\nclassName:\"comment\"}]}];return i.contains=b,r.contains=b,{name:\"Perl\",\naliases:[\"pl\",\"pm\"],keywords:a,contains:b}},grmr_php:e=>{\nconst n=e.regex,t=/(?![A-Za-z0-9])(?![$])/,a=n.concat(/[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*/,t),i=n.concat(/(\\\\?[A-Z][a-z0-9_\\x7f-\\xff]+|\\\\?[A-Z]+(?=[A-Z][a-z0-9_\\x7f-\\xff])){1,}/,t),r=n.concat(/[A-Z]+/,t),s={\nscope:\"variable\",match:\"\\\\$+\"+a},o={scope:\"subst\",variants:[{begin:/\\$\\w+/},{\nbegin:/\\{\\$/,end:/\\}/}]},l=e.inherit(e.APOS_STRING_MODE,{illegal:null\n}),c=\"[ \\t\\n]\",d={scope:\"string\",variants:[e.inherit(e.QUOTE_STRING_MODE,{\nillegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(o)}),l,{\nbegin:/<<<[ \\t]*(?:(\\w+)|\"(\\w+)\")\\n/,end:/[ \\t]*(\\w+)\\b/,\ncontains:e.QUOTE_STRING_MODE.contains.concat(o),\"on:begin\":(e,n)=>{\nn.data._beginMatch=e[1]||e[2]},\"on:end\":(e,n)=>{\nn.data._beginMatch!==e[1]&&n.ignoreMatch()}},e.END_SAME_AS_BEGIN({\nbegin:/<<<[ \\t]*'(\\w+)'\\n/,end:/[ \\t]*(\\w+)\\b/})]},g={scope:\"number\",variants:[{\nbegin:\"\\\\b0[bB][01]+(?:_[01]+)*\\\\b\"},{begin:\"\\\\b0[oO][0-7]+(?:_[0-7]+)*\\\\b\"},{\nbegin:\"\\\\b0[xX][\\\\da-fA-F]+(?:_[\\\\da-fA-F]+)*\\\\b\"},{\nbegin:\"(?:\\\\b\\\\d+(?:_\\\\d+)*(\\\\.(?:\\\\d+(?:_\\\\d+)*))?|\\\\B\\\\.\\\\d+)(?:[eE][+-]?\\\\d+)?\"\n}],relevance:0\n},u=[\"false\",\"null\",\"true\"],b=[\"__CLASS__\",\"__DIR__\",\"__FILE__\",\"__FUNCTION__\",\"__COMPILER_HALT_OFFSET__\",\"__LINE__\",\"__METHOD__\",\"__NAMESPACE__\",\"__TRAIT__\",\"die\",\"echo\",\"exit\",\"include\",\"include_once\",\"print\",\"require\",\"require_once\",\"array\",\"abstract\",\"and\",\"as\",\"binary\",\"bool\",\"boolean\",\"break\",\"callable\",\"case\",\"catch\",\"class\",\"clone\",\"const\",\"continue\",\"declare\",\"default\",\"do\",\"double\",\"else\",\"elseif\",\"empty\",\"enddeclare\",\"endfor\",\"endforeach\",\"endif\",\"endswitch\",\"endwhile\",\"enum\",\"eval\",\"extends\",\"final\",\"finally\",\"float\",\"for\",\"foreach\",\"from\",\"global\",\"goto\",\"if\",\"implements\",\"instanceof\",\"insteadof\",\"int\",\"integer\",\"interface\",\"isset\",\"iterable\",\"list\",\"match|0\",\"mixed\",\"new\",\"never\",\"object\",\"or\",\"private\",\"protected\",\"public\",\"readonly\",\"real\",\"return\",\"string\",\"switch\",\"throw\",\"trait\",\"try\",\"unset\",\"use\",\"var\",\"void\",\"while\",\"xor\",\"yield\"],m=[\"Error|0\",\"AppendIterator\",\"ArgumentCountError\",\"ArithmeticError\",\"ArrayIterator\",\"ArrayObject\",\"AssertionError\",\"BadFunctionCallException\",\"BadMethodCallException\",\"CachingIterator\",\"CallbackFilterIterator\",\"CompileError\",\"Countable\",\"DirectoryIterator\",\"DivisionByZeroError\",\"DomainException\",\"EmptyIterator\",\"ErrorException\",\"Exception\",\"FilesystemIterator\",\"FilterIterator\",\"GlobIterator\",\"InfiniteIterator\",\"InvalidArgumentException\",\"IteratorIterator\",\"LengthException\",\"LimitIterator\",\"LogicException\",\"MultipleIterator\",\"NoRewindIterator\",\"OutOfBoundsException\",\"OutOfRangeException\",\"OuterIterator\",\"OverflowException\",\"ParentIterator\",\"ParseError\",\"RangeException\",\"RecursiveArrayIterator\",\"RecursiveCachingIterator\",\"RecursiveCallbackFilterIterator\",\"RecursiveDirectoryIterator\",\"RecursiveFilterIterator\",\"RecursiveIterator\",\"RecursiveIteratorIterator\",\"RecursiveRegexIterator\",\"RecursiveTreeIterator\",\"RegexIterator\",\"RuntimeException\",\"SeekableIterator\",\"SplDoublyLinkedList\",\"SplFileInfo\",\"SplFileObject\",\"SplFixedArray\",\"SplHeap\",\"SplMaxHeap\",\"SplMinHeap\",\"SplObjectStorage\",\"SplObserver\",\"SplPriorityQueue\",\"SplQueue\",\"SplStack\",\"SplSubject\",\"SplTempFileObject\",\"TypeError\",\"UnderflowException\",\"UnexpectedValueException\",\"UnhandledMatchError\",\"ArrayAccess\",\"BackedEnum\",\"Closure\",\"Fiber\",\"Generator\",\"Iterator\",\"IteratorAggregate\",\"Serializable\",\"Stringable\",\"Throwable\",\"Traversable\",\"UnitEnum\",\"WeakReference\",\"WeakMap\",\"Directory\",\"__PHP_Incomplete_Class\",\"parent\",\"php_user_filter\",\"self\",\"static\",\"stdClass\"],p={\nkeyword:b,literal:(e=>{const n=[];return e.forEach((e=>{\nn.push(e),e.toLowerCase()===e?n.push(e.toUpperCase()):n.push(e.toLowerCase())\n})),n})(u),built_in:m},_=e=>e.map((e=>e.replace(/\\|\\d+$/,\"\"))),h={variants:[{\nmatch:[/new/,n.concat(c,\"+\"),n.concat(\"(?!\",_(m).join(\"\\\\b|\"),\"\\\\b)\"),i],scope:{\n1:\"keyword\",4:\"title.class\"}}]},f=n.concat(a,\"\\\\b(?!\\\\()\"),E={variants:[{\nmatch:[n.concat(/::/,n.lookahead(/(?!class\\b)/)),f],scope:{2:\"variable.constant\"\n}},{match:[/::/,/class/],scope:{2:\"variable.language\"}},{\nmatch:[i,n.concat(/::/,n.lookahead(/(?!class\\b)/)),f],scope:{1:\"title.class\",\n3:\"variable.constant\"}},{match:[i,n.concat(\"::\",n.lookahead(/(?!class\\b)/))],\nscope:{1:\"title.class\"}},{match:[i,/::/,/class/],scope:{1:\"title.class\",\n3:\"variable.language\"}}]},y={scope:\"attr\",\nmatch:n.concat(a,n.lookahead(\":\"),n.lookahead(/(?!::)/))},w={relevance:0,\nbegin:/\\(/,end:/\\)/,keywords:p,contains:[y,s,E,e.C_BLOCK_COMMENT_MODE,d,g,h]\n},v={relevance:0,\nmatch:[/\\b/,n.concat(\"(?!fn\\\\b|function\\\\b|\",_(b).join(\"\\\\b|\"),\"|\",_(m).join(\"\\\\b|\"),\"\\\\b)\"),a,n.concat(c,\"*\"),n.lookahead(/(?=\\()/)],\nscope:{3:\"title.function.invoke\"},contains:[w]};w.contains.push(v)\n;const N=[y,E,e.C_BLOCK_COMMENT_MODE,d,g,h],k={\nbegin:n.concat(/#\\[\\s*\\\\?/,n.either(i,r)),beginScope:\"meta\",end:/]/,\nendScope:\"meta\",keywords:{literal:u,keyword:[\"new\",\"array\"]},contains:[{\nbegin:/\\[/,end:/]/,keywords:{literal:u,keyword:[\"new\",\"array\"]},\ncontains:[\"self\",...N]},...N,{scope:\"meta\",variants:[{match:i},{match:r}]}]}\n;return{case_insensitive:!1,keywords:p,\ncontains:[k,e.HASH_COMMENT_MODE,e.COMMENT(\"//\",\"$\"),e.COMMENT(\"/\\\\*\",\"\\\\*/\",{\ncontains:[{scope:\"doctag\",match:\"@[A-Za-z]+\"}]}),{match:/__halt_compiler\\(\\);/,\nkeywords:\"__halt_compiler\",starts:{scope:\"comment\",end:e.MATCH_NOTHING_RE,\ncontains:[{match:/\\?>/,scope:\"meta\",endsParent:!0}]}},{scope:\"meta\",variants:[{\nbegin:/<\\?php/,relevance:10},{begin:/<\\?=/},{begin:/<\\?/,relevance:.1},{\nbegin:/\\?>/}]},{scope:\"variable.language\",match:/\\$this\\b/},s,v,E,{\nmatch:[/const/,/\\s/,a],scope:{1:\"keyword\",3:\"variable.constant\"}},h,{\nscope:\"function\",relevance:0,beginKeywords:\"fn function\",end:/[;{]/,\nexcludeEnd:!0,illegal:\"[$%\\\\[]\",contains:[{beginKeywords:\"use\"\n},e.UNDERSCORE_TITLE_MODE,{begin:\"=>\",endsParent:!0},{scope:\"params\",\nbegin:\"\\\\(\",end:\"\\\\)\",excludeBegin:!0,excludeEnd:!0,keywords:p,\ncontains:[\"self\",k,s,E,e.C_BLOCK_COMMENT_MODE,d,g]}]},{scope:\"class\",variants:[{\nbeginKeywords:\"enum\",illegal:/[($\"]/},{beginKeywords:\"class interface trait\",\nillegal:/[:($\"]/}],relevance:0,end:/\\{/,excludeEnd:!0,contains:[{\nbeginKeywords:\"extends implements\"},e.UNDERSCORE_TITLE_MODE]},{\nbeginKeywords:\"namespace\",relevance:0,end:\";\",illegal:/[.']/,\ncontains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:\"title.class\"})]},{\nbeginKeywords:\"use\",relevance:0,end:\";\",contains:[{\nmatch:/\\b(as|const|function)\\b/,scope:\"keyword\"},e.UNDERSCORE_TITLE_MODE]},d,g]}\n},grmr_php_template:e=>({name:\"PHP template\",subLanguage:\"xml\",contains:[{\nbegin:/<\\?(php|=)?/,end:/\\?>/,subLanguage:\"php\",contains:[{begin:\"/\\\\*\",\nend:\"\\\\*/\",skip:!0},{begin:'b\"',end:'\"',skip:!0},{begin:\"b'\",end:\"'\",skip:!0\n},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,\nskip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,\ncontains:null,skip:!0})]}]}),grmr_plaintext:e=>({name:\"Plain text\",\naliases:[\"text\",\"txt\"],disableAutodetect:!0}),grmr_python:e=>{\nconst n=e.regex,t=/[\\p{XID_Start}_]\\p{XID_Continue}*/u,a=[\"and\",\"as\",\"assert\",\"async\",\"await\",\"break\",\"case\",\"class\",\"continue\",\"def\",\"del\",\"elif\",\"else\",\"except\",\"finally\",\"for\",\"from\",\"global\",\"if\",\"import\",\"in\",\"is\",\"lambda\",\"match\",\"nonlocal|10\",\"not\",\"or\",\"pass\",\"raise\",\"return\",\"try\",\"while\",\"with\",\"yield\"],i={\n$pattern:/[A-Za-z]\\w+|__\\w+__/,keyword:a,\nbuilt_in:[\"__import__\",\"abs\",\"all\",\"any\",\"ascii\",\"bin\",\"bool\",\"breakpoint\",\"bytearray\",\"bytes\",\"callable\",\"chr\",\"classmethod\",\"compile\",\"complex\",\"delattr\",\"dict\",\"dir\",\"divmod\",\"enumerate\",\"eval\",\"exec\",\"filter\",\"float\",\"format\",\"frozenset\",\"getattr\",\"globals\",\"hasattr\",\"hash\",\"help\",\"hex\",\"id\",\"input\",\"int\",\"isinstance\",\"issubclass\",\"iter\",\"len\",\"list\",\"locals\",\"map\",\"max\",\"memoryview\",\"min\",\"next\",\"object\",\"oct\",\"open\",\"ord\",\"pow\",\"print\",\"property\",\"range\",\"repr\",\"reversed\",\"round\",\"set\",\"setattr\",\"slice\",\"sorted\",\"staticmethod\",\"str\",\"sum\",\"super\",\"tuple\",\"type\",\"vars\",\"zip\"],\nliteral:[\"__debug__\",\"Ellipsis\",\"False\",\"None\",\"NotImplemented\",\"True\"],\ntype:[\"Any\",\"Callable\",\"Coroutine\",\"Dict\",\"List\",\"Literal\",\"Generic\",\"Optional\",\"Sequence\",\"Set\",\"Tuple\",\"Type\",\"Union\"]\n},r={className:\"meta\",begin:/^(>>>|\\.\\.\\.) /},s={className:\"subst\",begin:/\\{/,\nend:/\\}/,keywords:i,illegal:/#/},o={begin:/\\{\\{/,relevance:0},l={\nclassName:\"string\",contains:[e.BACKSLASH_ESCAPE],variants:[{\nbegin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,\ncontains:[e.BACKSLASH_ESCAPE,r],relevance:10},{\nbegin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?\"\"\"/,end:/\"\"\"/,\ncontains:[e.BACKSLASH_ESCAPE,r],relevance:10},{\nbegin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,\ncontains:[e.BACKSLASH_ESCAPE,r,o,s]},{begin:/([fF][rR]|[rR][fF]|[fF])\"\"\"/,\nend:/\"\"\"/,contains:[e.BACKSLASH_ESCAPE,r,o,s]},{begin:/([uU]|[rR])'/,end:/'/,\nrelevance:10},{begin:/([uU]|[rR])\"/,end:/\"/,relevance:10},{\nbegin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])\"/,\nend:/\"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,\ncontains:[e.BACKSLASH_ESCAPE,o,s]},{begin:/([fF][rR]|[rR][fF]|[fF])\"/,end:/\"/,\ncontains:[e.BACKSLASH_ESCAPE,o,s]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]\n},c=\"[0-9](_?[0-9])*\",d=`(\\\\b(${c}))?\\\\.(${c})|\\\\b(${c})\\\\.`,g=\"\\\\b|\"+a.join(\"|\"),u={\nclassName:\"number\",relevance:0,variants:[{\nbegin:`(\\\\b(${c})|(${d}))[eE][+-]?(${c})[jJ]?(?=${g})`},{begin:`(${d})[jJ]?`},{\nbegin:`\\\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{\nbegin:`\\\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\\\b0[oO](_?[0-7])+[lL]?(?=${g})`\n},{begin:`\\\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\\\b(${c})[jJ](?=${g})`\n}]},b={className:\"comment\",begin:n.lookahead(/# type:/),end:/$/,keywords:i,\ncontains:[{begin:/# type:/},{begin:/#/,end:/\\b\\B/,endsWithParent:!0}]},m={\nclassName:\"params\",variants:[{className:\"\",begin:/\\(\\s*\\)/,skip:!0},{begin:/\\(/,\nend:/\\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,\ncontains:[\"self\",r,u,l,e.HASH_COMMENT_MODE]}]};return s.contains=[l,u,r],{\nname:\"Python\",aliases:[\"py\",\"gyp\",\"ipython\"],unicodeRegex:!0,keywords:i,\nillegal:/(<\\/|\\?)|=>/,contains:[r,u,{scope:\"variable.language\",match:/\\bself\\b/\n},{beginKeywords:\"if\",relevance:0},{match:/\\bor\\b/,scope:\"keyword\"\n},l,b,e.HASH_COMMENT_MODE,{match:[/\\bdef/,/\\s+/,t],scope:{1:\"keyword\",\n3:\"title.function\"},contains:[m]},{variants:[{\nmatch:[/\\bclass/,/\\s+/,t,/\\s*/,/\\(\\s*/,t,/\\s*\\)/]},{match:[/\\bclass/,/\\s+/,t]}],\nscope:{1:\"keyword\",3:\"title.class\",6:\"title.class.inherited\"}},{\nclassName:\"meta\",begin:/^[\\t ]*@/,end:/(?=#)|$/,contains:[u,m,l]}]}},\ngrmr_python_repl:e=>({aliases:[\"pycon\"],contains:[{className:\"meta.prompt\",\nstarts:{end:/ |$/,starts:{end:\"$\",subLanguage:\"python\"}},variants:[{\nbegin:/^>>>(?=[ ]|$)/},{begin:/^\\.\\.\\.(?=[ ]|$)/}]}]}),grmr_r:e=>{\nconst n=e.regex,t=/(?:(?:[a-zA-Z]|\\.[._a-zA-Z])[._a-zA-Z0-9]*)|\\.(?!\\d)/,a=n.either(/0[xX][0-9a-fA-F]+\\.[0-9a-fA-F]*[pP][+-]?\\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\\d+)?[Li]?/,/(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?[Li]?/),i=/[=!<>:]=|\\|\\||&&|:::?|<-|<<-|->>|->|\\|>|[-+*\\/?!$&|:<=>@^~]|\\*\\*/,r=n.either(/[()]/,/[{}]/,/\\[\\[/,/[[\\]]/,/\\\\/,/,/)\n;return{name:\"R\",keywords:{$pattern:t,\nkeyword:\"function if in break next repeat else for while\",\nliteral:\"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10\",\nbuilt_in:\"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm\"\n},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:\"doctag\",match:/@examples/,\nstarts:{end:n.lookahead(n.either(/\\n^#'\\s*(?=@[a-zA-Z]+)/,/\\n^(?!#')/)),\nendsParent:!0}},{scope:\"doctag\",begin:\"@param\",end:/$/,contains:[{\nscope:\"variable\",variants:[{match:t},{match:/`(?:\\\\.|[^`\\\\])+`/}],endsParent:!0\n}]},{scope:\"doctag\",match:/@[a-zA-Z]+/},{scope:\"keyword\",match:/\\\\[a-zA-Z]+/}]\n}),e.HASH_COMMENT_MODE,{scope:\"string\",contains:[e.BACKSLASH_ESCAPE],\nvariants:[e.END_SAME_AS_BEGIN({begin:/[rR]\"(-*)\\(/,end:/\\)(-*)\"/\n}),e.END_SAME_AS_BEGIN({begin:/[rR]\"(-*)\\{/,end:/\\}(-*)\"/\n}),e.END_SAME_AS_BEGIN({begin:/[rR]\"(-*)\\[/,end:/\\](-*)\"/\n}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\\(/,end:/\\)(-*)'/\n}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\\{/,end:/\\}(-*)'/\n}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\\[/,end:/\\](-*)'/}),{begin:'\"',end:'\"',\nrelevance:0},{begin:\"'\",end:\"'\",relevance:0}]},{relevance:0,variants:[{scope:{\n1:\"operator\",2:\"number\"},match:[i,a]},{scope:{1:\"operator\",2:\"number\"},\nmatch:[/%[^%]*%/,a]},{scope:{1:\"punctuation\",2:\"number\"},match:[r,a]},{scope:{\n2:\"number\"},match:[/[^a-zA-Z0-9._]|^/,a]}]},{scope:{3:\"operator\"},\nmatch:[t,/\\s+/,/<-/,/\\s+/]},{scope:\"operator\",relevance:0,variants:[{match:i},{\nmatch:/%[^%]*%/}]},{scope:\"punctuation\",relevance:0,match:r},{begin:\"`\",end:\"`\",\ncontains:[{begin:/\\\\./}]}]}},grmr_ruby:e=>{\nconst n=e.regex,t=\"([a-zA-Z_]\\\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\\\*\\\\*|[-/+%^&*~`|]|\\\\[\\\\]=?)\",a=n.either(/\\b([A-Z]+[a-z0-9]+)+/,/\\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=n.concat(a,/(::\\w+)*/),r={\n\"variable.constant\":[\"__FILE__\",\"__LINE__\",\"__ENCODING__\"],\n\"variable.language\":[\"self\",\"super\"],\nkeyword:[\"alias\",\"and\",\"begin\",\"BEGIN\",\"break\",\"case\",\"class\",\"defined\",\"do\",\"else\",\"elsif\",\"end\",\"END\",\"ensure\",\"for\",\"if\",\"in\",\"module\",\"next\",\"not\",\"or\",\"redo\",\"require\",\"rescue\",\"retry\",\"return\",\"then\",\"undef\",\"unless\",\"until\",\"when\",\"while\",\"yield\",\"include\",\"extend\",\"prepend\",\"public\",\"private\",\"protected\",\"raise\",\"throw\"],\nbuilt_in:[\"proc\",\"lambda\",\"attr_accessor\",\"attr_reader\",\"attr_writer\",\"define_method\",\"private_constant\",\"module_function\"],\nliteral:[\"true\",\"false\",\"nil\"]},s={className:\"doctag\",begin:\"@[A-Za-z]+\"},o={\nbegin:\"#<\",end:\">\"},l=[e.COMMENT(\"#\",\"$\",{contains:[s]\n}),e.COMMENT(\"^=begin\",\"^=end\",{contains:[s],relevance:10\n}),e.COMMENT(\"^__END__\",e.MATCH_NOTHING_RE)],c={className:\"subst\",begin:/#\\{/,\nend:/\\}/,keywords:r},d={className:\"string\",contains:[e.BACKSLASH_ESCAPE,c],\nvariants:[{begin:/'/,end:/'/},{begin:/\"/,end:/\"/},{begin:/`/,end:/`/},{\nbegin:/%[qQwWx]?\\(/,end:/\\)/},{begin:/%[qQwWx]?\\[/,end:/\\]/},{\nbegin:/%[qQwWx]?\\{/,end:/\\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\\//,\nend:/\\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{\nbegin:/%[qQwWx]?\\|/,end:/\\|/},{begin:/\\B\\?(\\\\\\d{1,3})/},{\nbegin:/\\B\\?(\\\\x[A-Fa-f0-9]{1,2})/},{begin:/\\B\\?(\\\\u\\{?[A-Fa-f0-9]{1,6}\\}?)/},{\nbegin:/\\B\\?(\\\\M-\\\\C-|\\\\M-\\\\c|\\\\c\\\\M-|\\\\M-|\\\\C-\\\\M-)[\\x20-\\x7e]/},{\nbegin:/\\B\\?\\\\(c|C-)[\\x20-\\x7e]/},{begin:/\\B\\?\\\\?\\S/},{\nbegin:n.concat(/<<[-~]?'?/,n.lookahead(/(\\w+)(?=\\W)[^\\n]*\\n(?:[^\\n]*\\n)*?\\s*\\1\\b/)),\ncontains:[e.END_SAME_AS_BEGIN({begin:/(\\w+)/,end:/(\\w+)/,\ncontains:[e.BACKSLASH_ESCAPE,c]})]}]},g=\"[0-9](_?[0-9])*\",u={className:\"number\",\nrelevance:0,variants:[{\nbegin:`\\\\b([1-9](_?[0-9])*|0)(\\\\.(${g}))?([eE][+-]?(${g})|r)?i?\\\\b`},{\nbegin:\"\\\\b0[dD][0-9](_?[0-9])*r?i?\\\\b\"},{begin:\"\\\\b0[bB][0-1](_?[0-1])*r?i?\\\\b\"\n},{begin:\"\\\\b0[oO][0-7](_?[0-7])*r?i?\\\\b\"},{\nbegin:\"\\\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\\\b\"},{\nbegin:\"\\\\b0(_?[0-7])+r?i?\\\\b\"}]},b={variants:[{match:/\\(\\)/},{\nclassName:\"params\",begin:/\\(/,end:/(?=\\))/,excludeBegin:!0,endsParent:!0,\nkeywords:r}]},m=[d,{variants:[{match:[/class\\s+/,i,/\\s+<\\s+/,i]},{\nmatch:[/\\b(class|module)\\s+/,i]}],scope:{2:\"title.class\",\n4:\"title.class.inherited\"},keywords:r},{match:[/(include|extend)\\s+/,i],scope:{\n2:\"title.class\"},keywords:r},{relevance:0,match:[i,/\\.new[. (]/],scope:{\n1:\"title.class\"}},{relevance:0,match:/\\b[A-Z][A-Z_0-9]+\\b/,\nclassName:\"variable.constant\"},{relevance:0,match:a,scope:\"title.class\"},{\nmatch:[/def/,/\\s+/,t],scope:{1:\"keyword\",3:\"title.function\"},contains:[b]},{\nbegin:e.IDENT_RE+\"::\"},{className:\"symbol\",\nbegin:e.UNDERSCORE_IDENT_RE+\"(!|\\\\?)?:\",relevance:0},{className:\"symbol\",\nbegin:\":(?!\\\\s)\",contains:[d,{begin:t}],relevance:0},u,{className:\"variable\",\nbegin:\"(\\\\$\\\\W)|((\\\\$|@@?)(\\\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])\"},{\nclassName:\"params\",begin:/\\|(?!=)/,end:/\\|/,excludeBegin:!0,excludeEnd:!0,\nrelevance:0,keywords:r},{begin:\"(\"+e.RE_STARTERS_RE+\"|unless)\\\\s*\",\nkeywords:\"unless\",contains:[{className:\"regexp\",contains:[e.BACKSLASH_ESCAPE,c],\nillegal:/\\n/,variants:[{begin:\"/\",end:\"/[a-z]*\"},{begin:/%r\\{/,end:/\\}[a-z]*/},{\nbegin:\"%r\\\\(\",end:\"\\\\)[a-z]*\"},{begin:\"%r!\",end:\"![a-z]*\"},{begin:\"%r\\\\[\",\nend:\"\\\\][a-z]*\"}]}].concat(o,l),relevance:0}].concat(o,l)\n;c.contains=m,b.contains=m;const p=[{begin:/^\\s*=>/,starts:{end:\"$\",contains:m}\n},{className:\"meta.prompt\",\nbegin:\"^([>?]>|[\\\\w#]+\\\\(\\\\w+\\\\):\\\\d+:\\\\d+[>*]|(\\\\w+-)?\\\\d+\\\\.\\\\d+\\\\.\\\\d+(p\\\\d+)?[^\\\\d][^>]+>)(?=[ ])\",\nstarts:{end:\"$\",keywords:r,contains:m}}];return l.unshift(o),{name:\"Ruby\",\naliases:[\"rb\",\"gemspec\",\"podspec\",\"thor\",\"irb\"],keywords:r,illegal:/\\/\\*/,\ncontains:[e.SHEBANG({binary:\"ruby\"})].concat(p).concat(l).concat(m)}},\ngrmr_rust:e=>{\nconst n=e.regex,t=/(r#)?/,a=n.concat(t,e.UNDERSCORE_IDENT_RE),i=n.concat(t,e.IDENT_RE),r={\nclassName:\"title.function.invoke\",relevance:0,\nbegin:n.concat(/\\b/,/(?!let|for|while|if|else|match\\b)/,i,n.lookahead(/\\s*\\(/))\n},s=\"([ui](8|16|32|64|128|size)|f(32|64))?\",o=[\"drop \",\"Copy\",\"Send\",\"Sized\",\"Sync\",\"Drop\",\"Fn\",\"FnMut\",\"FnOnce\",\"ToOwned\",\"Clone\",\"Debug\",\"PartialEq\",\"PartialOrd\",\"Eq\",\"Ord\",\"AsRef\",\"AsMut\",\"Into\",\"From\",\"Default\",\"Iterator\",\"Extend\",\"IntoIterator\",\"DoubleEndedIterator\",\"ExactSizeIterator\",\"SliceConcatExt\",\"ToString\",\"assert!\",\"assert_eq!\",\"bitflags!\",\"bytes!\",\"cfg!\",\"col!\",\"concat!\",\"concat_idents!\",\"debug_assert!\",\"debug_assert_eq!\",\"env!\",\"eprintln!\",\"panic!\",\"file!\",\"format!\",\"format_args!\",\"include_bytes!\",\"include_str!\",\"line!\",\"local_data_key!\",\"module_path!\",\"option_env!\",\"print!\",\"println!\",\"select!\",\"stringify!\",\"try!\",\"unimplemented!\",\"unreachable!\",\"vec!\",\"write!\",\"writeln!\",\"macro_rules!\",\"assert_ne!\",\"debug_assert_ne!\"],l=[\"i8\",\"i16\",\"i32\",\"i64\",\"i128\",\"isize\",\"u8\",\"u16\",\"u32\",\"u64\",\"u128\",\"usize\",\"f32\",\"f64\",\"str\",\"char\",\"bool\",\"Box\",\"Option\",\"Result\",\"String\",\"Vec\"]\n;return{name:\"Rust\",aliases:[\"rs\"],keywords:{$pattern:e.IDENT_RE+\"!?\",type:l,\nkeyword:[\"abstract\",\"as\",\"async\",\"await\",\"become\",\"box\",\"break\",\"const\",\"continue\",\"crate\",\"do\",\"dyn\",\"else\",\"enum\",\"extern\",\"false\",\"final\",\"fn\",\"for\",\"if\",\"impl\",\"in\",\"let\",\"loop\",\"macro\",\"match\",\"mod\",\"move\",\"mut\",\"override\",\"priv\",\"pub\",\"ref\",\"return\",\"self\",\"Self\",\"static\",\"struct\",\"super\",\"trait\",\"true\",\"try\",\"type\",\"typeof\",\"union\",\"unsafe\",\"unsized\",\"use\",\"virtual\",\"where\",\"while\",\"yield\"],\nliteral:[\"true\",\"false\",\"Some\",\"None\",\"Ok\",\"Err\"],built_in:o},illegal:\"</\",\ncontains:[e.C_LINE_COMMENT_MODE,e.COMMENT(\"/\\\\*\",\"\\\\*/\",{contains:[\"self\"]\n}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?\"/,illegal:null}),{\nclassName:\"symbol\",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:\"string\",\nvariants:[{begin:/b?r(#*)\"(.|\\n)*?\"\\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{\nscope:\"char.escape\",match:/\\\\('|\\w|x\\w{2}|u\\w{4}|U\\w{8})/}]}]},{\nclassName:\"number\",variants:[{begin:\"\\\\b0b([01_]+)\"+s},{begin:\"\\\\b0o([0-7_]+)\"+s\n},{begin:\"\\\\b0x([A-Fa-f0-9_]+)\"+s},{\nbegin:\"\\\\b(\\\\d[\\\\d_]*(\\\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)\"+s}],relevance:0},{\nbegin:[/fn/,/\\s+/,a],className:{1:\"keyword\",3:\"title.function\"}},{\nclassName:\"meta\",begin:\"#!?\\\\[\",end:\"\\\\]\",contains:[{className:\"string\",\nbegin:/\"/,end:/\"/,contains:[e.BACKSLASH_ESCAPE]}]},{\nbegin:[/let/,/\\s+/,/(?:mut\\s+)?/,a],className:{1:\"keyword\",3:\"keyword\",\n4:\"variable\"}},{begin:[/for/,/\\s+/,a,/\\s+/,/in/],className:{1:\"keyword\",\n3:\"variable\",5:\"keyword\"}},{begin:[/type/,/\\s+/,a],className:{1:\"keyword\",\n3:\"title.class\"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\\s+/,a],\nclassName:{1:\"keyword\",3:\"title.class\"}},{begin:e.IDENT_RE+\"::\",keywords:{\nkeyword:\"Self\",built_in:o,type:l}},{className:\"punctuation\",begin:\"->\"},r]}},\ngrmr_scss:e=>{const n=te(e),t=se,a=re,i=\"@[a-z-]+\",r={className:\"variable\",\nbegin:\"(\\\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\\\b\",relevance:0};return{name:\"SCSS\",\ncase_insensitive:!0,illegal:\"[=/|']\",\ncontains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,n.CSS_NUMBER_MODE,{\nclassName:\"selector-id\",begin:\"#[A-Za-z0-9_-]+\",relevance:0},{\nclassName:\"selector-class\",begin:\"\\\\.[A-Za-z0-9_-]+\",relevance:0\n},n.ATTRIBUTE_SELECTOR_MODE,{className:\"selector-tag\",\nbegin:\"\\\\b(\"+ae.join(\"|\")+\")\\\\b\",relevance:0},{className:\"selector-pseudo\",\nbegin:\":(\"+a.join(\"|\")+\")\"},{className:\"selector-pseudo\",\nbegin:\":(:)?(\"+t.join(\"|\")+\")\"},r,{begin:/\\(/,end:/\\)/,\ncontains:[n.CSS_NUMBER_MODE]},n.CSS_VARIABLE,{className:\"attribute\",\nbegin:\"\\\\b(\"+oe.join(\"|\")+\")\\\\b\"},{\nbegin:\"\\\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\\\b\"\n},{begin:/:/,end:/[;}{]/,relevance:0,\ncontains:[n.BLOCK_COMMENT,r,n.HEXCOLOR,n.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.IMPORTANT,n.FUNCTION_DISPATCH]\n},{begin:\"@(page|font-face)\",keywords:{$pattern:i,keyword:\"@page @font-face\"}},{\nbegin:\"@\",end:\"[{;]\",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,\nkeyword:\"and or not only\",attribute:ie.join(\" \")},contains:[{begin:i,\nclassName:\"keyword\"},{begin:/[a-z-]+(?=:)/,className:\"attribute\"\n},r,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.HEXCOLOR,n.CSS_NUMBER_MODE]\n},n.FUNCTION_DISPATCH]}},grmr_shell:e=>({name:\"Shell Session\",\naliases:[\"console\",\"shellsession\"],contains:[{className:\"meta.prompt\",\nbegin:/^\\s{0,3}[/~\\w\\d[\\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\\\](?=\\s*$)/,\nsubLanguage:\"bash\"}}]}),grmr_sql:e=>{\nconst n=e.regex,t=e.COMMENT(\"--\",\"$\"),a=[\"abs\",\"acos\",\"array_agg\",\"asin\",\"atan\",\"avg\",\"cast\",\"ceil\",\"ceiling\",\"coalesce\",\"corr\",\"cos\",\"cosh\",\"count\",\"covar_pop\",\"covar_samp\",\"cume_dist\",\"dense_rank\",\"deref\",\"element\",\"exp\",\"extract\",\"first_value\",\"floor\",\"json_array\",\"json_arrayagg\",\"json_exists\",\"json_object\",\"json_objectagg\",\"json_query\",\"json_table\",\"json_table_primitive\",\"json_value\",\"lag\",\"last_value\",\"lead\",\"listagg\",\"ln\",\"log\",\"log10\",\"lower\",\"max\",\"min\",\"mod\",\"nth_value\",\"ntile\",\"nullif\",\"percent_rank\",\"percentile_cont\",\"percentile_disc\",\"position\",\"position_regex\",\"power\",\"rank\",\"regr_avgx\",\"regr_avgy\",\"regr_count\",\"regr_intercept\",\"regr_r2\",\"regr_slope\",\"regr_sxx\",\"regr_sxy\",\"regr_syy\",\"row_number\",\"sin\",\"sinh\",\"sqrt\",\"stddev_pop\",\"stddev_samp\",\"substring\",\"substring_regex\",\"sum\",\"tan\",\"tanh\",\"translate\",\"translate_regex\",\"treat\",\"trim\",\"trim_array\",\"unnest\",\"upper\",\"value_of\",\"var_pop\",\"var_samp\",\"width_bucket\"],i=a,r=[\"abs\",\"acos\",\"all\",\"allocate\",\"alter\",\"and\",\"any\",\"are\",\"array\",\"array_agg\",\"array_max_cardinality\",\"as\",\"asensitive\",\"asin\",\"asymmetric\",\"at\",\"atan\",\"atomic\",\"authorization\",\"avg\",\"begin\",\"begin_frame\",\"begin_partition\",\"between\",\"bigint\",\"binary\",\"blob\",\"boolean\",\"both\",\"by\",\"call\",\"called\",\"cardinality\",\"cascaded\",\"case\",\"cast\",\"ceil\",\"ceiling\",\"char\",\"char_length\",\"character\",\"character_length\",\"check\",\"classifier\",\"clob\",\"close\",\"coalesce\",\"collate\",\"collect\",\"column\",\"commit\",\"condition\",\"connect\",\"constraint\",\"contains\",\"convert\",\"copy\",\"corr\",\"corresponding\",\"cos\",\"cosh\",\"count\",\"covar_pop\",\"covar_samp\",\"create\",\"cross\",\"cube\",\"cume_dist\",\"current\",\"current_catalog\",\"current_date\",\"current_default_transform_group\",\"current_path\",\"current_role\",\"current_row\",\"current_schema\",\"current_time\",\"current_timestamp\",\"current_path\",\"current_role\",\"current_transform_group_for_type\",\"current_user\",\"cursor\",\"cycle\",\"date\",\"day\",\"deallocate\",\"dec\",\"decimal\",\"decfloat\",\"declare\",\"default\",\"define\",\"delete\",\"dense_rank\",\"deref\",\"describe\",\"deterministic\",\"disconnect\",\"distinct\",\"double\",\"drop\",\"dynamic\",\"each\",\"element\",\"else\",\"empty\",\"end\",\"end_frame\",\"end_partition\",\"end-exec\",\"equals\",\"escape\",\"every\",\"except\",\"exec\",\"execute\",\"exists\",\"exp\",\"external\",\"extract\",\"false\",\"fetch\",\"filter\",\"first_value\",\"float\",\"floor\",\"for\",\"foreign\",\"frame_row\",\"free\",\"from\",\"full\",\"function\",\"fusion\",\"get\",\"global\",\"grant\",\"group\",\"grouping\",\"groups\",\"having\",\"hold\",\"hour\",\"identity\",\"in\",\"indicator\",\"initial\",\"inner\",\"inout\",\"insensitive\",\"insert\",\"int\",\"integer\",\"intersect\",\"intersection\",\"interval\",\"into\",\"is\",\"join\",\"json_array\",\"json_arrayagg\",\"json_exists\",\"json_object\",\"json_objectagg\",\"json_query\",\"json_table\",\"json_table_primitive\",\"json_value\",\"lag\",\"language\",\"large\",\"last_value\",\"lateral\",\"lead\",\"leading\",\"left\",\"like\",\"like_regex\",\"listagg\",\"ln\",\"local\",\"localtime\",\"localtimestamp\",\"log\",\"log10\",\"lower\",\"match\",\"match_number\",\"match_recognize\",\"matches\",\"max\",\"member\",\"merge\",\"method\",\"min\",\"minute\",\"mod\",\"modifies\",\"module\",\"month\",\"multiset\",\"national\",\"natural\",\"nchar\",\"nclob\",\"new\",\"no\",\"none\",\"normalize\",\"not\",\"nth_value\",\"ntile\",\"null\",\"nullif\",\"numeric\",\"octet_length\",\"occurrences_regex\",\"of\",\"offset\",\"old\",\"omit\",\"on\",\"one\",\"only\",\"open\",\"or\",\"order\",\"out\",\"outer\",\"over\",\"overlaps\",\"overlay\",\"parameter\",\"partition\",\"pattern\",\"per\",\"percent\",\"percent_rank\",\"percentile_cont\",\"percentile_disc\",\"period\",\"portion\",\"position\",\"position_regex\",\"power\",\"precedes\",\"precision\",\"prepare\",\"primary\",\"procedure\",\"ptf\",\"range\",\"rank\",\"reads\",\"real\",\"recursive\",\"ref\",\"references\",\"referencing\",\"regr_avgx\",\"regr_avgy\",\"regr_count\",\"regr_intercept\",\"regr_r2\",\"regr_slope\",\"regr_sxx\",\"regr_sxy\",\"regr_syy\",\"release\",\"result\",\"return\",\"returns\",\"revoke\",\"right\",\"rollback\",\"rollup\",\"row\",\"row_number\",\"rows\",\"running\",\"savepoint\",\"scope\",\"scroll\",\"search\",\"second\",\"seek\",\"select\",\"sensitive\",\"session_user\",\"set\",\"show\",\"similar\",\"sin\",\"sinh\",\"skip\",\"smallint\",\"some\",\"specific\",\"specifictype\",\"sql\",\"sqlexception\",\"sqlstate\",\"sqlwarning\",\"sqrt\",\"start\",\"static\",\"stddev_pop\",\"stddev_samp\",\"submultiset\",\"subset\",\"substring\",\"substring_regex\",\"succeeds\",\"sum\",\"symmetric\",\"system\",\"system_time\",\"system_user\",\"table\",\"tablesample\",\"tan\",\"tanh\",\"then\",\"time\",\"timestamp\",\"timezone_hour\",\"timezone_minute\",\"to\",\"trailing\",\"translate\",\"translate_regex\",\"translation\",\"treat\",\"trigger\",\"trim\",\"trim_array\",\"true\",\"truncate\",\"uescape\",\"union\",\"unique\",\"unknown\",\"unnest\",\"update\",\"upper\",\"user\",\"using\",\"value\",\"values\",\"value_of\",\"var_pop\",\"var_samp\",\"varbinary\",\"varchar\",\"varying\",\"versioning\",\"when\",\"whenever\",\"where\",\"width_bucket\",\"window\",\"with\",\"within\",\"without\",\"year\",\"add\",\"asc\",\"collation\",\"desc\",\"final\",\"first\",\"last\",\"view\"].filter((e=>!a.includes(e))),s={\nmatch:n.concat(/\\b/,n.either(...i),/\\s*\\(/),relevance:0,keywords:{built_in:i}}\n;function o(e){\nreturn n.concat(/\\b/,n.either(...e.map((e=>e.replace(/\\s+/,\"\\\\s+\")))),/\\b/)}\nconst l={scope:\"keyword\",\nmatch:o([\"create table\",\"insert into\",\"primary key\",\"foreign key\",\"not null\",\"alter table\",\"add constraint\",\"grouping sets\",\"on overflow\",\"character set\",\"respect nulls\",\"ignore nulls\",\"nulls first\",\"nulls last\",\"depth first\",\"breadth first\"]),\nrelevance:0};return{name:\"SQL\",case_insensitive:!0,illegal:/[{}]|<\\//,keywords:{\n$pattern:/\\b[\\w\\.]+/,keyword:((e,{exceptions:n,when:t}={})=>{const a=t\n;return n=n||[],e.map((e=>e.match(/\\|\\d+$/)||n.includes(e)?e:a(e)?e+\"|0\":e))\n})(r,{when:e=>e.length<3}),literal:[\"true\",\"false\",\"unknown\"],\ntype:[\"bigint\",\"binary\",\"blob\",\"boolean\",\"char\",\"character\",\"clob\",\"date\",\"dec\",\"decfloat\",\"decimal\",\"float\",\"int\",\"integer\",\"interval\",\"nchar\",\"nclob\",\"national\",\"numeric\",\"real\",\"row\",\"smallint\",\"time\",\"timestamp\",\"varchar\",\"varying\",\"varbinary\"],\nbuilt_in:[\"current_catalog\",\"current_date\",\"current_default_transform_group\",\"current_path\",\"current_role\",\"current_schema\",\"current_transform_group_for_type\",\"current_user\",\"session_user\",\"system_time\",\"system_user\",\"current_time\",\"localtime\",\"current_timestamp\",\"localtimestamp\"]\n},contains:[{scope:\"type\",\nmatch:o([\"double precision\",\"large object\",\"with timezone\",\"without timezone\"])\n},l,s,{scope:\"variable\",match:/@[a-z0-9][a-z0-9_]*/},{scope:\"string\",variants:[{\nbegin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/\"/,end:/\"/,contains:[{\nmatch:/\"\"/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,t,{scope:\"operator\",\nmatch:/[-+*/=%^~]|&&?|\\|\\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}},\ngrmr_swift:e=>{const n={match:/\\s+/,relevance:0},t=e.COMMENT(\"/\\\\*\",\"\\\\*/\",{\ncontains:[\"self\"]}),a=[e.C_LINE_COMMENT_MODE,t],i={match:[/\\./,m(...ke,...xe)],\nclassName:{2:\"keyword\"}},r={match:b(/\\./,m(...Me)),relevance:0\n},s=Me.filter((e=>\"string\"==typeof e)).concat([\"_|0\"]),o={variants:[{\nclassName:\"keyword\",\nmatch:m(...Me.filter((e=>\"string\"!=typeof e)).concat(Oe).map(Ne),...xe)}]},l={\n$pattern:m(/\\b\\w+/,/#\\w+/),keyword:s.concat(Ce),literal:Ae},c=[i,r,o],g=[{\nmatch:b(/\\./,m(...Te)),relevance:0},{className:\"built_in\",\nmatch:b(/\\b/,m(...Te),/(?=\\()/)}],u={match:/->/,relevance:0},p=[u,{\nclassName:\"operator\",relevance:0,variants:[{match:Ie},{match:`\\\\.(\\\\.|${De})+`}]\n}],_=\"([0-9]_*)+\",h=\"([0-9a-fA-F]_*)+\",f={className:\"number\",relevance:0,\nvariants:[{match:`\\\\b(${_})(\\\\.(${_}))?([eE][+-]?(${_}))?\\\\b`},{\nmatch:`\\\\b0x(${h})(\\\\.(${h}))?([pP][+-]?(${_}))?\\\\b`},{match:/\\b0o([0-7]_*)+\\b/\n},{match:/\\b0b([01]_*)+\\b/}]},E=(e=\"\")=>({className:\"subst\",variants:[{\nmatch:b(/\\\\/,e,/[0\\\\tnr\"']/)},{match:b(/\\\\/,e,/u\\{[0-9a-fA-F]{1,8}\\}/)}]\n}),y=(e=\"\")=>({className:\"subst\",match:b(/\\\\/,e,/[\\t ]*(?:[\\r\\n]|\\r\\n)/)\n}),w=(e=\"\")=>({className:\"subst\",label:\"interpol\",begin:b(/\\\\/,e,/\\(/),end:/\\)/\n}),v=(e=\"\")=>({begin:b(e,/\"\"\"/),end:b(/\"\"\"/,e),contains:[E(e),y(e),w(e)]\n}),N=(e=\"\")=>({begin:b(e,/\"/),end:b(/\"/,e),contains:[E(e),w(e)]}),k={\nclassName:\"string\",\nvariants:[v(),v(\"#\"),v(\"##\"),v(\"###\"),N(),N(\"#\"),N(\"##\"),N(\"###\")]\n},x=[e.BACKSLASH_ESCAPE,{begin:/\\[/,end:/\\]/,relevance:0,\ncontains:[e.BACKSLASH_ESCAPE]}],O={begin:/\\/[^\\s](?=[^/\\n]*\\/)/,end:/\\//,\ncontains:x},M=e=>{const n=b(e,/\\//),t=b(/\\//,e);return{begin:n,end:t,\ncontains:[...x,{scope:\"comment\",begin:`#(?!.*${t})`,end:/$/}]}},A={\nscope:\"regexp\",variants:[M(\"###\"),M(\"##\"),M(\"#\"),O]},S={match:b(/`/,$e,/`/)\n},C=[S,{className:\"variable\",match:/\\$\\d+/},{className:\"variable\",\nmatch:`\\\\$${Be}+`}],T=[{match:/(@|#(un)?)available/,scope:\"keyword\",starts:{\ncontains:[{begin:/\\(/,end:/\\)/,keywords:je,contains:[...p,f,k]}]}},{\nscope:\"keyword\",match:b(/@/,m(...ze),d(m(/\\(/,/\\s+/)))},{scope:\"meta\",\nmatch:b(/@/,$e)}],R={match:d(/\\b[A-Z]/),relevance:0,contains:[{className:\"type\",\nmatch:b(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Be,\"+\")\n},{className:\"type\",match:Fe,relevance:0},{match:/[?!]+/,relevance:0},{\nmatch:/\\.\\.\\./,relevance:0},{match:b(/\\s+&\\s+/,d(Fe)),relevance:0}]},D={\nbegin:/</,end:/>/,keywords:l,contains:[...a,...c,...T,u,R]};R.contains.push(D)\n;const I={begin:/\\(/,end:/\\)/,relevance:0,keywords:l,contains:[\"self\",{\nmatch:b($e,/\\s*:/),keywords:\"_|0\",relevance:0\n},...a,A,...c,...g,...p,f,k,...C,...T,R]},L={begin:/</,end:/>/,\nkeywords:\"repeat each\",contains:[...a,R]},B={begin:/\\(/,end:/\\)/,keywords:l,\ncontains:[{begin:m(d(b($e,/\\s*:/)),d(b($e,/\\s+/,$e,/\\s*:/))),end:/:/,\nrelevance:0,contains:[{className:\"keyword\",match:/\\b_\\b/},{className:\"params\",\nmatch:$e}]},...a,...c,...p,f,k,...T,R,I],endsParent:!0,illegal:/[\"']/},$={\nmatch:[/(func|macro)/,/\\s+/,m(S.match,$e,Ie)],className:{1:\"keyword\",\n3:\"title.function\"},contains:[L,B,n],illegal:[/\\[/,/%/]},F={\nmatch:[/\\b(?:subscript|init[?!]?)/,/\\s*(?=[<(])/],className:{1:\"keyword\"},\ncontains:[L,B,n],illegal:/\\[|%/},z={match:[/operator/,/\\s+/,Ie],className:{\n1:\"keyword\",3:\"title\"}},j={begin:[/precedencegroup/,/\\s+/,Fe],className:{\n1:\"keyword\",3:\"title\"},contains:[R],keywords:[...Se,...Ae],end:/}/},U={\nbegin:[/(struct|protocol|class|extension|enum|actor)/,/\\s+/,$e,/\\s*/],\nbeginScope:{1:\"keyword\",3:\"title.class\"},keywords:l,contains:[L,...c,{begin:/:/,\nend:/\\{/,keywords:l,contains:[{scope:\"title.class.inherited\",match:Fe},...c],\nrelevance:0}]};for(const e of k.variants){\nconst n=e.contains.find((e=>\"interpol\"===e.label));n.keywords=l\n;const t=[...c,...g,...p,f,k,...C];n.contains=[...t,{begin:/\\(/,end:/\\)/,\ncontains:[\"self\",...t]}]}return{name:\"Swift\",keywords:l,contains:[...a,$,F,{\nmatch:[/class\\b/,/\\s+/,/func\\b/,/\\s+/,/\\b[A-Za-z_][A-Za-z0-9_]*\\b/],scope:{\n1:\"keyword\",3:\"keyword\",5:\"title.function\"}},{match:[/class\\b/,/\\s+/,/var\\b/],\nscope:{1:\"keyword\",3:\"keyword\"}},U,z,j,{beginKeywords:\"import\",end:/$/,\ncontains:[...a],relevance:0},A,...c,...g,...p,f,k,...C,...T,R,I]}},\ngrmr_typescript:e=>{\nconst n=e.regex,t=ve(e),a=me,i=[\"any\",\"void\",\"number\",\"boolean\",\"string\",\"object\",\"never\",\"symbol\",\"bigint\",\"unknown\"],r={\nbegin:[/namespace/,/\\s+/,e.IDENT_RE],beginScope:{1:\"keyword\",3:\"title.class\"}\n},s={beginKeywords:\"interface\",end:/\\{/,excludeEnd:!0,keywords:{\nkeyword:\"interface extends\",built_in:i},contains:[t.exports.CLASS_REFERENCE]\n},o={$pattern:me,\nkeyword:pe.concat([\"type\",\"interface\",\"public\",\"private\",\"protected\",\"implements\",\"declare\",\"abstract\",\"readonly\",\"enum\",\"override\",\"satisfies\"]),\nliteral:_e,built_in:we.concat(i),\"variable.language\":ye},l={className:\"meta\",\nbegin:\"@\"+a},c=(e,n,t)=>{const a=e.contains.findIndex((e=>e.label===n))\n;if(-1===a)throw Error(\"can not find mode to replace\");e.contains.splice(a,1,t)}\n;Object.assign(t.keywords,o),t.exports.PARAMS_CONTAINS.push(l)\n;const d=t.contains.find((e=>\"attr\"===e.scope)),g=Object.assign({},d,{\nmatch:n.concat(a,n.lookahead(/\\s*\\?:/))})\n;return t.exports.PARAMS_CONTAINS.push([t.exports.CLASS_REFERENCE,d,g]),\nt.contains=t.contains.concat([l,r,s,g]),\nc(t,\"shebang\",e.SHEBANG()),c(t,\"use_strict\",{className:\"meta\",relevance:10,\nbegin:/^\\s*['\"]use strict['\"]/\n}),t.contains.find((e=>\"func.def\"===e.label)).relevance=0,Object.assign(t,{\nname:\"TypeScript\",aliases:[\"ts\",\"tsx\",\"mts\",\"cts\"]}),t},grmr_vbnet:e=>{\nconst n=e.regex,t=/\\d{1,2}\\/\\d{1,2}\\/\\d{4}/,a=/\\d{4}-\\d{1,2}-\\d{1,2}/,i=/(\\d|1[012])(:\\d+){0,2} *(AM|PM)/,r=/\\d{1,2}(:\\d{1,2}){1,2}/,s={\nclassName:\"literal\",variants:[{begin:n.concat(/# */,n.either(a,t),/ *#/)},{\nbegin:n.concat(/# */,r,/ *#/)},{begin:n.concat(/# */,i,/ *#/)},{\nbegin:n.concat(/# */,n.either(a,t),/ +/,n.either(i,r),/ *#/)}]\n},o=e.COMMENT(/'''/,/$/,{contains:[{className:\"doctag\",begin:/<\\/?/,end:/>/}]\n}),l=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\\t ]|^)REM(?=\\s)/}]})\n;return{name:\"Visual Basic .NET\",aliases:[\"vb\"],case_insensitive:!0,\nclassNameAliases:{label:\"symbol\"},keywords:{\nkeyword:\"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield\",\nbuilt_in:\"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort\",\ntype:\"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort\",\nliteral:\"true false nothing\"},\nillegal:\"//|\\\\{|\\\\}|endif|gosub|variant|wend|^\\\\$ \",contains:[{\nclassName:\"string\",begin:/\"(\"\"|[^/n])\"C\\b/},{className:\"string\",begin:/\"/,\nend:/\"/,illegal:/\\n/,contains:[{begin:/\"\"/}]},s,{className:\"number\",relevance:0,\nvariants:[{begin:/\\b\\d[\\d_]*((\\.[\\d_]+(E[+-]?[\\d_]+)?)|(E[+-]?[\\d_]+))[RFD@!#]?/\n},{begin:/\\b\\d[\\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\\dA-F_]+((U?[SIL])|[%&])?/},{\nbegin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{\nclassName:\"label\",begin:/^\\w+:/},o,l,{className:\"meta\",\nbegin:/[\\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\\b/,\nend:/$/,keywords:{\nkeyword:\"const disable else elseif enable end externalsource if region then\"},\ncontains:[l]}]}},grmr_wasm:e=>{e.regex;const n=e.COMMENT(/\\(;/,/;\\)/)\n;return n.contains.push(\"self\"),{name:\"WebAssembly\",keywords:{$pattern:/[\\w.]+/,\nkeyword:[\"anyfunc\",\"block\",\"br\",\"br_if\",\"br_table\",\"call\",\"call_indirect\",\"data\",\"drop\",\"elem\",\"else\",\"end\",\"export\",\"func\",\"global.get\",\"global.set\",\"local.get\",\"local.set\",\"local.tee\",\"get_global\",\"get_local\",\"global\",\"if\",\"import\",\"local\",\"loop\",\"memory\",\"memory.grow\",\"memory.size\",\"module\",\"mut\",\"nop\",\"offset\",\"param\",\"result\",\"return\",\"select\",\"set_global\",\"set_local\",\"start\",\"table\",\"tee_local\",\"then\",\"type\",\"unreachable\"]\n},contains:[e.COMMENT(/;;/,/$/),n,{match:[/(?:offset|align)/,/\\s*/,/=/],\nclassName:{1:\"keyword\",3:\"operator\"}},{className:\"variable\",begin:/\\$[\\w_]+/},{\nmatch:/(\\((?!;)|\\))+/,className:\"punctuation\",relevance:0},{\nbegin:[/(?:func|call|call_indirect)/,/\\s+/,/\\$[^\\s)]+/],className:{1:\"keyword\",\n3:\"title.function\"}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\\.)/,\nclassName:\"type\"},{className:\"keyword\",\nmatch:/\\b(f32|f64|i32|i64)(?:\\.(?:abs|add|and|ceil|clz|const|convert_[su]\\/i(?:32|64)|copysign|ctz|demote\\/f64|div(?:_[su])?|eqz?|extend_[su]\\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\\/f32|reinterpret\\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\\/f(?:32|64))?|wrap\\/i64|xor))\\b/\n},{className:\"number\",relevance:0,\nmatch:/[+-]?\\b(?:\\d(?:_?\\d)*(?:\\.\\d(?:_?\\d)*)?(?:[eE][+-]?\\d(?:_?\\d)*)?|0x[\\da-fA-F](?:_?[\\da-fA-F])*(?:\\.[\\da-fA-F](?:_?[\\da-fA-D])*)?(?:[pP][+-]?\\d(?:_?\\d)*)?)\\b|\\binf\\b|\\bnan(?::0x[\\da-fA-F](?:_?[\\da-fA-D])*)?\\b/\n}]}},grmr_xml:e=>{\nconst n=e.regex,t=n.concat(/[\\p{L}_]/u,n.optional(/[\\p{L}0-9_.-]*:/u),/[\\p{L}0-9_.-]*/u),a={\nclassName:\"symbol\",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\\s/,\ncontains:[{className:\"keyword\",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\\n/}]\n},r=e.inherit(i,{begin:/\\(/,end:/\\)/}),s=e.inherit(e.APOS_STRING_MODE,{\nclassName:\"string\"}),o=e.inherit(e.QUOTE_STRING_MODE,{className:\"string\"}),l={\nendsWithParent:!0,illegal:/</,relevance:0,contains:[{className:\"attr\",\nbegin:/[\\p{L}0-9._:-]+/u,relevance:0},{begin:/=\\s*/,relevance:0,contains:[{\nclassName:\"string\",endsParent:!0,variants:[{begin:/\"/,end:/\"/,contains:[a]},{\nbegin:/'/,end:/'/,contains:[a]},{begin:/[^\\s\"'=<>`]+/}]}]}]};return{\nname:\"HTML, XML\",\naliases:[\"html\",\"xhtml\",\"rss\",\"atom\",\"xjb\",\"xsd\",\"xsl\",\"plist\",\"wsf\",\"svg\"],\ncase_insensitive:!0,unicodeRegex:!0,contains:[{className:\"meta\",begin:/<![a-z]/,\nend:/>/,relevance:10,contains:[i,o,s,r,{begin:/\\[/,end:/\\]/,contains:[{\nclassName:\"meta\",begin:/<![a-z]/,end:/>/,contains:[i,r,o,s]}]}]\n},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\\[CDATA\\[/,end:/\\]\\]>/,\nrelevance:10},a,{className:\"meta\",end:/\\?>/,variants:[{begin:/<\\?xml/,\nrelevance:10,contains:[o]},{begin:/<\\?[a-z][a-z0-9]+/}]},{className:\"tag\",\nbegin:/<style(?=\\s|>)/,end:/>/,keywords:{name:\"style\"},contains:[l],starts:{\nend:/<\\/style>/,returnEnd:!0,subLanguage:[\"css\",\"xml\"]}},{className:\"tag\",\nbegin:/<script(?=\\s|>)/,end:/>/,keywords:{name:\"script\"},contains:[l],starts:{\nend:/<\\/script>/,returnEnd:!0,subLanguage:[\"javascript\",\"handlebars\",\"xml\"]}},{\nclassName:\"tag\",begin:/<>|<\\/>/},{className:\"tag\",\nbegin:n.concat(/</,n.lookahead(n.concat(t,n.either(/\\/>/,/>/,/\\s/)))),\nend:/\\/?>/,contains:[{className:\"name\",begin:t,relevance:0,starts:l}]},{\nclassName:\"tag\",begin:n.concat(/<\\//,n.lookahead(n.concat(t,/>/))),contains:[{\nclassName:\"name\",begin:t,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}\n},grmr_yaml:e=>{\nconst n=\"true false yes no null\",t=\"[\\\\w#;/?:@&=+$,.~*'()[\\\\]]+\",a={\nclassName:\"string\",relevance:0,variants:[{begin:/\"/,end:/\"/},{begin:/\\S+/}],\ncontains:[e.BACKSLASH_ESCAPE,{className:\"template-variable\",variants:[{\nbegin:/\\{\\{/,end:/\\}\\}/},{begin:/%\\{/,end:/\\}/}]}]},i=e.inherit(a,{variants:[{\nbegin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/\"/,end:/\"/},{\nbegin:/[^\\s,{}[\\]]+/}]}),r={end:\",\",endsWithParent:!0,excludeEnd:!0,keywords:n,\nrelevance:0},s={begin:/\\{/,end:/\\}/,contains:[r],illegal:\"\\\\n\",relevance:0},o={\nbegin:\"\\\\[\",end:\"\\\\]\",contains:[r],illegal:\"\\\\n\",relevance:0},l=[{\nclassName:\"attr\",variants:[{begin:/[\\w*@][\\w*@ :()\\./-]*:(?=[ \\t]|$)/},{\nbegin:/\"[\\w*@][\\w*@ :()\\./-]*\":(?=[ \\t]|$)/},{\nbegin:/'[\\w*@][\\w*@ :()\\./-]*':(?=[ \\t]|$)/}]},{className:\"meta\",\nbegin:\"^---\\\\s*$\",relevance:10},{className:\"string\",\nbegin:\"[\\\\|>]([1-9]?[+-])?[ ]*\\\\n( +)[^ ][^\\\\n]*\\\\n(\\\\2[^\\\\n]+\\\\n?)*\"},{\nbegin:\"<%[%=-]?\",end:\"[%-]?%>\",subLanguage:\"ruby\",excludeBegin:!0,excludeEnd:!0,\nrelevance:0},{className:\"type\",begin:\"!\\\\w+!\"+t},{className:\"type\",\nbegin:\"!<\"+t+\">\"},{className:\"type\",begin:\"!\"+t},{className:\"type\",begin:\"!!\"+t\n},{className:\"meta\",begin:\"&\"+e.UNDERSCORE_IDENT_RE+\"$\"},{className:\"meta\",\nbegin:\"\\\\*\"+e.UNDERSCORE_IDENT_RE+\"$\"},{className:\"bullet\",begin:\"-(?=[ ]|$)\",\nrelevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},{\nclassName:\"number\",\nbegin:\"\\\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\\\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\\\.[0-9]*)?([ \\\\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\\\b\"\n},{className:\"number\",begin:e.C_NUMBER_RE+\"\\\\b\",relevance:0},s,o,{\nclassName:\"string\",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,\nscope:\"char.escape\",relevance:0}]},a],c=[...l]\n;return c.pop(),c.push(i),r.contains=c,{name:\"YAML\",case_insensitive:!0,\naliases:[\"yml\"],contains:l}}});const Pe=ne;for(const e of Object.keys(Ue)){\nconst n=e.replace(\"grmr_\",\"\").replace(\"_\",\"-\");Pe.registerLanguage(n,Ue[e])}\nreturn Pe}()\n;\"object\"==typeof exports&&\"undefined\"!=typeof module&&(module.exports=hljs);"
5hooks/map.ts 139 lines1// The "code" view: files Claude touched, the imports between them, handed to the HTML page as data.
2import type { MapFile } from '../types'
3import { CATEGORIES, categoryOf } from './category'
4import { langFor, linksOf, stripExt } from './lang'
5
6// Relative imports in a source file, resolved against its folder, extension stripped.
7export function importsOf(path: string, text: string): string[] {
8 return linksOf(path, text).imports
9}
10
11export type Edge = { from: string; to: string }
12
13// An arrow from each file to the files that use it: the ones that import it, or mention its class
14// or module (per language, see lang.ts). So an arrow reads "a change here reaches there".
15// Only files on the map can be linked.
16export function edges(files: MapFile[]): Edge[] {
17 const byBase = new Map(files.map(f => [stripExt(f.path), f.path]))
18 const owners = new Map<string, string>() // "lang:Name" → the file that defines it
19 for (const f of files) {
20 const lang = langFor(f.path)
21 for (const name of lang?.defines(f.path) ?? []) owners.set(`${lang?.name}:${name}`, f.path)
22 }
23 const out: Edge[] = []
24 const add = (user: string, used: string | undefined) => {
25 if (used && used !== user && !out.some(e => e.from === used && e.to === user)) out.push({ from: used, to: user })
26 }
27 for (const f of files) {
28 for (const target of f.imports) add(f.path, byBase.get(target))
29 const lang = langFor(f.path)
30 for (const name of f.names ?? []) add(f.path, owners.get(`${lang?.name}:${name}`))
31 }
32 return out
33}
34
35// Columns by import depth: a file goes one column right of the files it uses, so the arrows run left to right.
36export function layout(files: MapFile[], es: Edge[]) {
37 const depth = new Map(files.map(f => [f.path, 0]))
38 for (let pass = 0; pass < files.length; pass++) {
39 let moved = false
40 for (const e of es) {
41 const want = (depth.get(e.from) ?? 0) + 1
42 if (want > (depth.get(e.to) ?? 0) && want < 5) {
43 depth.set(e.to, want)
44 moved = true
45 }
46 }
47 if (!moved) break
48 }
49 const columns: string[][] = []
50 for (const f of files) {
51 const d = depth.get(f.path) ?? 0
52 ;(columns[d] ??= []).push(f.path)
53 }
54 return columns.filter(Boolean)
55}
56
57export type Look = { at: number; turn: number }
58
59export type MapCard = {
60 id: string
61 title: string
62 sub: string
63 why?: string
64 state: 'read' | 'edit' | 'changed' | null // what the card glows for: being read, being edited, changed this turn
65 live: boolean // touched in the last few seconds
66 flags: number // review findings on the file: the box is drawn pink when above 0
67 stale: boolean // every open finding on the file was written before its last edit: the box is drawn amber
68}
69
70export type MapData = {
71 files: number
72 changed: number
73 now: string // "reading login.tsx", or ''
74 nowState: 'read' | 'edit' | null
75 groups: { name: string; columns: MapCard[][] }[] // one frame per kind of file, its columns by import depth
76 edges: { from: string; to: string; hot: boolean }[]
77 extra: string[] // files only read and linked to nothing
78}
79
80// Everything the page draws, as plain data: the template lays it out and draws the arrows.
81export function mapData(files: MapFile[], look: Look, flagged: Record<string, number> = {}, stale: Record<string, boolean> = {}): MapData {
82 const { at, turn } = look
83 const isChanged = (f: MapFile) => f.review === true || (f.changedTurn === turn && turn > 0)
84 const isLive = (f: MapFile) => at - f.at < 5000
85 const es = edges(files)
86 const linked = new Set(es.flatMap(e => [e.from, e.to]))
87 const main = files.filter(f => linked.has(f.path) || isChanged(f) || isLive(f) || f.act !== 'read' || (flagged[f.path] ?? 0) > 0)
88 const extra = files.filter(f => !main.includes(f))
89 const mainEs = es.filter(e => main.some(f => f.path === e.from) && main.some(f => f.path === e.to))
90 const byPath = new Map(main.map(f => [f.path, f]))
91 const title = (f: MapFile) => titleOf(f.path, files.map(x => x.path))
92 const readLike = (f: MapFile) => f.act === 'read' || f.act === 'search'
93
94 const card = (p: string): MapCard => {
95 const f = byPath.get(p) as MapFile
96 const live = isLive(f)
97 const state = live ? (readLike(f) ? 'read' : 'edit') : isChanged(f) ? 'changed' : null
98 return { id: p, title: title(f), sub: folder(p, 2), why: f.why, state, live, flags: flagged[p] ?? 0, stale: stale[p] === true }
99 }
100 const newest = files.filter(isLive).sort((a, b) => b.at - a.at)[0]
101 return {
102 files: files.length,
103 changed: files.filter(isChanged).length,
104 now: newest ? `${newest.act === 'read' ? 'reading' : newest.act === 'search' ? 'searching' : 'editing'} ${title(newest)}` : '',
105 nowState: newest ? (readLike(newest) ? 'read' : 'edit') : null,
106 groups: CATEGORIES.flatMap(name => {
107 const inGroup = main.filter(f => categoryOf(f.path) === name)
108 const paths = new Set(inGroup.map(f => f.path))
109 const columns = layout(inGroup, mainEs.filter(e => paths.has(e.from) && paths.has(e.to))).map(col => col.map(card))
110 return inGroup.length ? [{ name, columns }] : []
111 }),
112 edges: mainEs.map(e => ({ ...e, hot: [e.from, e.to].some(p => isChanged(byPath.get(p) as MapFile) || isLive(byPath.get(p) as MapFile)) })),
113 extra: extra.map(title),
114 }
115}
116
117// A file's name, or with several of that name the nearest folder that tells them apart:
118// three `hooks/register.tsx` read as `merge-gate › register.tsx`, `snake › register.tsx`.
119export function titleOf(path: string, all: string[]) {
120 const name = base(path)
121 const same = all.filter(p => base(p) === name && p !== path)
122 if (same.length === 0) return name
123 const parts = path.split('/')
124 for (let k = 2; k <= parts.length; k++) {
125 const seg = parts[parts.length - k]
126 if (same.every(p => p.split('/').at(-k) !== seg)) return `${seg} › ${name}`
127 }
128 return `${folder(path)}/${name}`
129}
130
131function base(path: string) {
132 return path.split('/').pop() ?? path
133}
134
135// The last `n` folders of a path (`n` 1: the parent).
136function folder(path: string, n = 1) {
137 return path.split('/').slice(-1 - n, -1).join('/')
138}
139hooks/template.ts 873 lines1// The Mission Control page: plain HTML and CSS, written to $TMPDIR/mission-control/index.html.
2// Two tabs, who (the agent and tool-call tree) and code (the file map), both drawn from
3// window.MAP in data.js (see writePage in register.tsx), which it re-reads every second.
4// Restyle it here; nothing else needs to change. The tab lives in the URL hash (#who, #code).
5// Clicking a changed box on the code map slides a diff drawer up from the bottom (diffs.js, see writePage):
6// pick lines, comment, and send the review to Claude (when the mod serves the page) or copy it to paste anywhere.
7// Keep this free of backticks, dollar-brace sequences and backslashes: it is one template literal.
8import { formatComment, formatReview, parseDiff } from './diff'
9import { highlight } from './highlight'
10import { htmlRows, langOf } from './hl'
11
12export const TEMPLATE = `<!doctype html>
13<meta charset="utf-8">
14<title>Mission Control</title>
15<style>
16 :root { --bg:#0d1015; --card:#151922; --card-live:#1b2130; --line:#2a3140; --text:#e8ebf2; --dim:#7d8698; --faint:#4b5263;
17 --edge:#3a4252; --edge-hot:#6b7a96; --read:#5aa9ff; --edit:#ffa24c; --changed:#3ddc84; --flag:#ff5fa8; --stale:#ffbe3c; }
18 * { box-sizing: border-box; }
19 html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
20 font: 14px -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif; }
21 body { display: flex; flex-direction: column; background-image: radial-gradient(#1a1f28 1px, transparent 1px); background-size: 22px 22px; }
22 header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 18px 24px 0; flex: none; }
23 h1, .pill, .tab, .now, .hint { white-space: nowrap; }
24 h1 { margin: 0 12px 0 0; font-size: 20px; }
25 .tabs { display: flex; gap: 6px; margin-right: 12px; }
26 .tab { padding: 4px 14px; border: 1px solid var(--line); border-radius: 8px; background: #161b24; color: var(--dim); font: inherit; font-size: 13px; cursor: pointer; }
27 .tab.on { background: #26324a; color: var(--text); border-color: #3a4a6a; }
28 #who { flex: 1; min-height: 0; overflow: auto; padding: 18px 24px; font: 13.5px 'SF Mono', Menlo, monospace; line-height: 22px; }
29 .line { white-space: pre; }
30 .line .p { color: var(--faint); }
31 .line.running { color: #e8c547; } .line.failed { color: #ff6b6b; } .line.done.tool { color: var(--dim); } .line.done.main, .line.done.agent { color: var(--changed); font-weight: 600; }
32 .none { color: var(--dim); font: 14px -apple-system, sans-serif; }
33 .pill { padding: 3px 11px; border: 1px solid var(--line); border-radius: 12px; background: #161b24; font-size: 12.5px; color: var(--dim); }
34 .pill.on { color: var(--changed); }
35 a.pill { color: #7fc4ff; text-decoration: none; }
36 a.pill:hover { background: #1c2433; }
37 .now { display: flex; align-items: center; gap: 7px; margin-left: 8px; font-size: 13px; }
38 .now i, .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
39 .empty { margin: auto; color: var(--dim); font-size: 16px; }
40 #stage { flex: 1; min-height: 0; position: relative; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
41 #stage.drag { cursor: grabbing; }
42 .hint { margin-left: auto; font-size: 11.5px; color: var(--faint); }
43 #graph { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
44 #legend { position: absolute; left: 14px; bottom: 12px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--faint); pointer-events: none; }
45 #edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
46 .cols { display: flex; gap: 48px; align-items: flex-start; position: relative; }
47 .fcols { display: flex; gap: 64px; align-items: center; }
48 .frame { padding: 12px 20px 20px; border: 1.5px dashed var(--line); border-radius: 18px; background: rgba(255,255,255,.02); }
49 .frame.bare { padding: 0; border: 0; background: none; }
50 .frame-title { margin-bottom: 14px; font-size: 11.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
51 .col { display: flex; flex-direction: column; gap: 18px; width: max-content; max-width: 380px; min-width: 170px; }
52 .card { position: relative; padding: 10px 16px 12px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
53 box-shadow: 0 4px 12px rgba(0,0,0,.45); }
54 .card { cursor: move; }
55 .card.moving { z-index: 5; box-shadow: 0 10px 26px rgba(0,0,0,.6); }
56 .card.live { background: var(--card-live); border-width: 1.5px; }
57 .card.read { border-color: var(--read); box-shadow: 0 0 22px rgba(90,169,255,.35); }
58 .card.edit { border-color: var(--edit); box-shadow: 0 0 22px rgba(255,162,76,.35); }
59 .card.changed::before, .card.read::before, .card.edit::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3.5px; border-radius: 2px; background: var(--accent); }
60 .card.read { --accent: var(--read); } .card.edit { --accent: var(--edit); } .card.changed { --accent: var(--changed); }
61 .card.flagged { border-color: var(--flag); box-shadow: 0 0 22px rgba(255,95,168,.35); background: #20141d; --accent: var(--flag); }
62 .card.flagged::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3.5px; border-radius: 2px; background: var(--flag); }
63 .card.flagged.stale { border-color: var(--stale); box-shadow: 0 0 22px rgba(255,190,60,.25); background: #211b10; --accent: var(--stale); }
64 .card.flagged.stale::before { background: var(--stale); }
65 .tab:disabled { opacity: .4; cursor: not-allowed; }
66 .tab.export { margin-left: auto; }
67 .badge.flag { color: var(--flag); font-weight: 650; margin-left: 8px; }
68 .badge.flag.stale { color: var(--stale); }
69 .pill.flag { color: var(--flag); border-color: var(--flag); }
70 .name { display: flex; justify-content: space-between; gap: 12px; font-weight: 650; font-size: 14.5px; white-space: nowrap; }
71 .badge { color: var(--accent); font-weight: 400; font-size: 13px; }
72 .sub { margin-top: 2px; font: 11px 'SF Mono', Menlo, monospace; color: var(--faint); white-space: nowrap; }
73 .why { margin-top: 8px; font-size: 12.5px; line-height: 17px; color: #aeb6c6; overflow-wrap: anywhere; }
74 footer { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 24px 16px; }
75 footer:empty { display: none; }
76 footer b { font-weight: 400; font-size: 11.5px; color: var(--faint); margin-right: 4px; }
77 .chip { padding: 3px 11px; border: 1px solid var(--line); border-radius: 12px; background: #141820; font-size: 12px; color: var(--dim); }
78 .card.diffable:hover { border-color: #6b7a96; }
79 .reset { position: absolute; top: -11px; right: -11px; width: 26px; height: 26px; padding: 0; border: 1px solid #3a4a6a; border-radius: 50%; background: #26324a; color: var(--text); font-size: 15px; line-height: 1; cursor: pointer; opacity: .85; }
80 .reset:hover { opacity: 1; background: #3a4a6a; }
81 .card.open { outline: 2px solid #5aa9ff; outline-offset: 2px; }
82 .card.focus { border-color: var(--changed); box-shadow: 0 0 26px rgba(61,220,132,.55); }
83 .tab.go { background: #1d5fd1; border-color: #3b82f6; color: #fff; }
84 #drawer { flex: none; height: 45vh; display: flex; flex-direction: column; border-top: 1px solid #3a4a6a; background: #10141b;
85 box-shadow: 0 -12px 32px rgba(0,0,0,.55); animation: rise .18s ease-out; }
86 #drawer[hidden] { display: none; }
87 @keyframes rise { from { transform: translateY(48px); opacity: 0; } }
88 .dhead { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
89 .dhead b { font-size: 14px; white-space: nowrap; }
90 .dsub { font: 11.5px 'SF Mono', Menlo, monospace; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
91 .dcopy { margin-left: auto; padding: 2px 6px; border: 1px solid transparent; border-radius: 6px; background: none; font-size: 15px; line-height: 1; cursor: pointer; }
92 .dcopy:hover { background: #1c2433; border-color: var(--line); }
93 .dclose { border: 0; background: none; color: var(--dim); font-size: 20px; line-height: 1; cursor: pointer; }
94 .dbody { flex: 1; min-height: 0; overflow: auto; padding-bottom: 12px; }
95 .dbody .none { padding: 18px 16px; }
96 .row { display: flex; width: max-content; min-width: 100%; font: 12.5px/19px 'SF Mono', Menlo, monospace; white-space: pre; }
97 .row.k-a { background: rgba(61,220,132,.12); } .row.k-d { background: rgba(255,107,107,.12); }
98 .row.hunk { color: var(--dim); background: #151b27; padding: 2px 16px; }
99 .row.sel { background: rgba(90,169,255,.25); }
100 .ln { flex: none; width: 50px; padding-right: 10px; text-align: right; color: var(--faint); cursor: pointer; user-select: none; }
101 .ln:hover { color: #fff; background: rgba(255,255,255,.08); }
102 .mark { flex: none; width: 18px; color: var(--dim); user-select: none; }
103 .code { flex: 1; padding-right: 24px; }
104 .hljs-keyword, .hljs-doctag, .hljs-template-tag, .hljs-selector-tag { color: #c792ea; }
105 .hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: #a5d6a7; }
106 .hljs-comment, .hljs-quote { color: #6b7a96; font-style: italic; }
107 .hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #f2a65a; }
108 .hljs-title, .hljs-title.function_, .hljs-section { color: #82aaff; }
109 .hljs-title.class_, .hljs-type, .hljs-built_in, .hljs-name, .hljs-tag { color: #7fc4ff; }
110 .hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable, .hljs-template-variable, .hljs-selector-class, .hljs-selector-id { color: #e8c547; }
111 .hljs-params, .hljs-subst { color: var(--text); }
112 .hljs-meta, .hljs-link, .hljs-deletion { color: #ff8f8f; }
113 .hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }
114 .t-kw { color: #c792ea; } .t-str { color: #a5d6a7; } .t-com { color: #6b7a96; font-style: italic; } .t-num { color: #f2a65a; } .t-type { color: #7fc4ff; }
115 .note, .editor { margin: 6px 16px 8px 68px; padding: 8px 12px; border: 1px solid #3a4a6a; border-radius: 8px; background: #171d29; font: 13px -apple-system, sans-serif; width: min(640px, calc(100% - 100px)); }
116 .note { display: flex; gap: 10px; align-items: flex-start; white-space: pre-wrap; }
117 .note span { flex: 1; overflow-wrap: anywhere; }
118 .note.sent { opacity: .6; }
119 .finding { display: flex; gap: 10px; align-items: flex-start; margin: 6px 16px 8px 68px; padding: 8px 12px; border: 1px solid var(--flag); border-radius: 8px; background: #26121d; font: 13px -apple-system, sans-serif; width: min(640px, calc(100% - 100px)); white-space: normal; }
120 .finding input.fsw { margin-top: 0; }
121 .finding .fbody { flex: 1; overflow-wrap: anywhere; } .finding b { color: #ffb3d6; }
122 .finding .fsc { margin-top: 4px; color: #c9a3b6; line-height: 18px; }
123 .finding.posted { opacity: .55; }
124 .finding.stale { border-color: var(--stale); background: #211b10; } .finding.stale b { color: #ffd98a; }
125 .finding .fdis, #flist .fl-dis { flex: none; border: 0; background: none; color: var(--dim); cursor: pointer; font-size: 12px; }
126 .finding .fdis:hover, #flist .fl-dis:hover { color: var(--text); }
127 #flist label.stale .fl-line { color: var(--stale); }
128 #flist { position: fixed; right: 16px; top: 64px; width: 400px; max-width: calc(100% - 32px); max-height: 60vh; overflow: auto; z-index: 8; border: 1px solid var(--flag); border-radius: 10px; background: #1a0f17; box-shadow: 0 12px 32px rgba(0,0,0,.55); font: 13px -apple-system, sans-serif; }
129 #flist[hidden] { display: none; }
130 #flist .fl-head { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #1a0f17; border-bottom: 1px solid #4a2438; }
131 #flist .fl-head b { flex: 1; color: #ffb3d6; }
132 #flist .fl-file { padding: 8px 12px 2px; font: 11.5px 'SF Mono', Menlo, monospace; color: var(--dim); }
133 #flist label { display: flex; gap: 8px; align-items: flex-start; padding: 5px 12px; cursor: pointer; line-height: 18px; }
134 #flist label:hover { background: #26121d; }
135 #flist label.posted { opacity: .5; cursor: default; }
136 #flist .fl-line { flex: none; color: var(--flag); font: 11.5px 'SF Mono', Menlo, monospace; min-width: 34px; }
137 #flist .fl-open { border: 0; background: none; color: var(--dim); cursor: pointer; font-size: 12px; }
138 .pill.flag { cursor: pointer; }
139 input.fsw { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 40px; height: 22px; margin: 0; border-radius: 11px; background: #3a2a34; border: 1px solid #5a3a4c; cursor: pointer; transition: background .15s; }
140 input.fsw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #c9a3b6; transition: transform .15s, background .15s; }
141 input.fsw:checked { background: var(--flag); border-color: var(--flag); }
142 input.fsw:checked::after { transform: translateX(18px); background: #fff; }
143 input.fsw:disabled { opacity: .4; cursor: default; }
144 .finding { cursor: pointer; } .finding.posted { cursor: default; }
145 .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
146 .segb { padding: 5px 14px; border: 0; background: #151b27; color: var(--dim); font-size: 13px; cursor: pointer; }
147 .segb.on { background: var(--flag); color: #fff; font-weight: 650; }
148 .segb:disabled { opacity: .4; cursor: default; }
149 .swall { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #151b27; color: var(--text); font-size: 13px; cursor: pointer; user-select: none; }
150 .swall:hover { border-color: var(--flag); }
151 .note button { border: 0; background: none; color: var(--faint); cursor: pointer; }
152 .editor textarea { display: block; width: 100%; min-height: 58px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #0d1015; color: var(--text); font: 13px -apple-system, sans-serif; resize: vertical; }
153 .editor .btns { display: flex; gap: 8px; margin-top: 8px; }
154 .toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 8px 16px; border-radius: 10px; background: #26324a; border: 1px solid #3a4a6a; font-size: 13px; z-index: 9; }
155</style>
156<header id="head"></header>
157<div id="who" hidden></div>
158<div id="stage"><div id="graph"><svg id="edges"></svg><div class="cols" id="cols"></div></div><div id="legend"><svg width="30" height="8"><line x1="1" y1="4" x2="22" y2="4" stroke="#6b7a96" stroke-width="1.5"/><path d="M21,0.5L29,4L21,7.5z" fill="#6b7a96"/></svg>A → B: B uses A (a change in A reaches B)</div></div>
159<footer id="foot"></footer>
160<div id="drawer" hidden></div>
161<div id="flist" hidden></div>
162<script src="hljs.js"></script>
163<script src="data.js"></script>
164<script>
165 // Shared with the tests: the code in hooks/diff.ts, spliced in as it is.
166 ${parseDiff}
167 ${formatComment}
168 ${formatReview}
169 ${highlight}
170 ${langOf}
171 ${htmlRows}
172 // The code map's view: fitted to the window until the person zooms or drags, then kept as they left it.
173 var view = { k: 1, x: 0, y: 0, auto: true };
174 function applyView() {
175 document.getElementById('graph').style.transform = 'translate(' + view.x + 'px,' + view.y + 'px) scale(' + view.k + ')';
176 }
177 // Where the person dragged each box (offsets from its laid-out place), kept per page and across reloads.
178 var POSKEY = 'mission-pos:' + location.pathname, pos = {}, dragging = false, stale = false, model = { cards: {}, edges: [] };
179 try { pos = JSON.parse(localStorage.getItem(POSKEY) || '{}') || {}; } catch (err) { pos = {}; }
180 function savePos() { try { localStorage.setItem(POSKEY, JSON.stringify(pos)); } catch (err) {} }
181 function place(el, id) {
182 var p = pos[id];
183 el.style.transform = p ? 'translate(' + p.dx + 'px,' + p.dy + 'px)' : '';
184 }
185 // A box that has been moved carries a small button to put it back.
186 function putBack(el, id) {
187 var old = el.querySelector('.reset');
188 if (!pos[id]) { if (old) old.remove(); return; }
189 if (old) return;
190 var b = h('button', 'reset', '\u21ba');
191 b.title = 'Put this box back';
192 b.onpointerdown = function (e) { e.stopPropagation(); };
193 b.ondblclick = function (e) { e.stopPropagation(); };
194 b.onclick = function (e) {
195 e.stopPropagation();
196 delete pos[id]; savePos(); place(el, id); putBack(el, id); drawEdges();
197 };
198 el.appendChild(b);
199 }
200 var focusId = null; // the box whose links are the only ones drawn, set by double-clicking it
201 function setFocus(id) {
202 focusId = id;
203 render(window.MAP);
204 }
205 var clickTimer = null; // a click on a changed box waits to see whether it is the first half of a double-click
206 // The tab in the hash, else the one used last on this page.
207 var TABKEY = 'mission-tab:' + location.pathname;
208 function tab() {
209 if (location.hash === '#code' || location.hash === '#who') return location.hash.slice(1);
210 try { return localStorage.getItem(TABKEY) === 'code' ? 'code' : 'who'; } catch (err) { return 'who'; }
211 }
212 var SVGNS = 'http://www.w3.org/2000/svg';
213 function h(tag, cls, text) {
214 var el = document.createElement(tag);
215 if (cls) el.className = cls;
216 if (text != null) el.textContent = text;
217 return el;
218 }
219 function render(M) {
220 var head = document.getElementById('head'), cols = document.getElementById('cols'), foot = document.getElementById('foot');
221 head.textContent = ''; cols.textContent = ''; foot.textContent = '';
222 head.appendChild(h('h1', '', 'Mission Control'));
223 var tabs = h('div', 'tabs');
224 [['who', 'Who (w)'], ['code', 'Code (c)']].forEach(function (t) {
225 var b = h('button', 'tab' + (tab() === t[0] ? ' on' : ''), t[1]);
226 b.onclick = function () { location.hash = t[0]; render(window.MAP); };
227 tabs.appendChild(b);
228 });
229 head.appendChild(tabs);
230 if (M.where) {
231 head.appendChild(h('span', 'pill', '\u2387 ' + M.where.branch + (M.where.base ? ' \u2192 ' + M.where.base : '')));
232 if (M.where.pr && M.where.pr.url.indexOf('https://') === 0) {
233 var pl = h('a', 'pill', 'PR #' + M.where.pr.number + ' \u2197');
234 pl.href = M.where.pr.url; pl.target = '_blank'; pl.rel = 'noopener'; pl.title = M.where.pr.url;
235 head.appendChild(pl);
236 }
237 }
238 var S = M.who.summary;
239 head.appendChild(h('span', 'pill', S.agents + ' agents (' + S.running + ' running) \u00b7 ' + S.tools + ' tool calls' + (S.failed ? ' \u00b7 ' + S.failed + ' failed' : '')));
240 head.appendChild(h('span', 'pill', M.files + ' files'));
241 head.appendChild(h('span', 'pill' + (M.changed ? ' on' : ''), M.changed + ' changed'));
242 var FL = M.findings || {}, fAll = [];
243 Object.keys(FL).forEach(function (p) { FL[p].forEach(function (f) { fAll.push(f); }); });
244 if (fAll.length) {
245 var fp = h('span', 'pill flag', '\\u2691 ' + fAll.length + ' finding' + (fAll.length === 1 ? '' : 's') + (showList ? ' \\u25b4' : ' \\u25be'));
246 fp.title = 'Show every finding, to pick them one by one';
247 fp.onclick = function () { showList = !showList; render(window.MAP); };
248 head.appendChild(fp);
249 }
250 var openF = fAll.filter(function (f) { return !f.posted; });
251 if (openF.length) {
252 var npicked = Object.keys(fpick).length;
253 var all = h('label', 'swall'), sw = document.createElement('input');
254 sw.type = 'checkbox'; sw.className = 'fsw'; sw.checked = npicked === openF.length;
255 sw.onchange = function () { fpick = {}; if (sw.checked) openF.forEach(function (f) { fpick[f.id] = true; }); render(window.MAP); renderDrawer(); };
256 all.appendChild(sw);
257 all.appendChild(h('span', '', npicked && npicked < openF.length ? npicked + ' of ' + openF.length + ' picked' : 'All findings (' + openF.length + ')'));
258 all.title = 'Pick or drop every finding that is not pushed yet; switch them one by one in the list or under their line';
259 head.appendChild(all);
260 }
261 if (Object.keys(fpick).length) {
262 var nPick = Object.keys(fpick).length, toPr = canPost() && dest !== 'claude';
263 // Where the picked findings go: the pull request (when the page is about one) or the Claude session.
264 var seg = h('span', 'seg');
265 [['pr', 'PR'], ['claude', 'Claude']].forEach(function (d) {
266 var on = (d[0] === 'pr') === toPr, b = h('button', 'segb' + (on ? ' on' : ''), d[1]);
267 if (d[0] === 'pr' && !canPost()) { b.disabled = true; b.title = 'Needs the local server and a page about a pull request (/mission <PR link>)'; }
268 b.onclick = function () { dest = d[0]; render(window.MAP); };
269 seg.appendChild(b);
270 });
271 head.appendChild(seg);
272 if (EXPORTED) head.appendChild(modOnly(h('button', 'tab go', 'Send to Claude (' + nPick + ')')));
273 var go = h('button', 'tab go', toPr ? 'Send to PR (' + nPick + ')' : (CAN_SEND ? 'Send to Claude (' : 'Copy for Claude (') + nPick + ')');
274 go.title = toPr ? 'Push the picked findings to the pull request as one review of comments' : 'Hand the picked findings to the Claude session as a request to fix them';
275 go.onclick = toPr ? postPicked : sendPicked;
276 head.appendChild(go);
277 }
278 if (M.post && M.post.note) head.appendChild(h('span', 'pill', M.post.note));
279 renderList(M);
280 if (pending.length) {
281 var fresh = pending.filter(function (c) { return !c.sent; }).length;
282 if (fresh && EXPORTED) {
283 head.appendChild(modOnly(h('button', 'tab go', 'Send review (' + fresh + ')')));
284 } else if (fresh) {
285 var send = h('button', 'tab go', 'Send review (' + fresh + ')');
286 send.onclick = sendReview;
287 head.appendChild(send);
288 }
289 if (CAN_SEND || EXPORTED || fresh < pending.length) {
290 var all = h('button', 'tab', (CAN_SEND || EXPORTED ? 'Copy (' : fresh ? 'Copy all (' : 'Copy again (') + pending.length + ')');
291 all.title = 'Copy every comment on the page, the ones already copied too';
292 all.onclick = function () { copyAll(); };
293 head.appendChild(all);
294 }
295 var drop = h('button', 'tab', 'Discard');
296 drop.onclick = function () { pending = []; savePending(); render(window.MAP); renderDrawer(); };
297 head.appendChild(drop);
298 }
299 if (focusId && !M.groups.some(function (g) { return g.columns.some(function (col) { return col.some(function (c) { return c.id === focusId; }); }); })) focusId = null;
300 if (focusId && tab() === 'code') {
301 var xf = h('button', 'tab go', 'Exit focus (Esc)');
302 xf.title = 'Show every link again';
303 xf.onclick = function () { setFocus(null); };
304 head.appendChild(xf);
305 }
306 if (tab() === 'code') head.appendChild(h('span', 'hint', 'scroll zooms \u00b7 drag the map or a box \u00b7 click a changed box for its diff \u00b7 double-click a box: focus its links \u00b7 double-click the map: fit \u00b7 \u21ba puts a box back'));
307 if (M.now) {
308 var now = h('span', 'now', M.now);
309 now.style.color = M.nowState === 'read' ? 'var(--read)' : 'var(--edit)';
310 now.insertBefore(h('i'), now.firstChild);
311 head.appendChild(now);
312 }
313 if (EXPORTED) {
314 var snap = h('span', 'pill export', 'snapshot · ' + new Date(window.EXPORTED).toLocaleString());
315 snap.style.marginLeft = 'auto'; snap.title = 'Exported from Mission Control: it does not update';
316 head.appendChild(snap);
317 } else {
318 var ex = h('button', 'tab export', 'Export HTML');
319 if (CAN_SEND) { ex.title = 'Download this page, findings and diffs included, as one HTML file'; ex.onclick = exportPage; } else { ex.disabled = true; ex.title = 'Needs the page served by the mod'; }
320 head.appendChild(ex);
321 }
322 try { localStorage.setItem(TABKEY, tab()); } catch (err) {}
323 var whoEl = document.getElementById('who'), stageEl = document.getElementById('stage');
324 whoEl.hidden = tab() !== 'who'; stageEl.hidden = tab() !== 'code'; foot.hidden = tab() !== 'code';
325 document.getElementById('drawer').hidden = !openPath || tab() !== 'code';
326 if (tab() === 'who') {
327 whoEl.textContent = '';
328 if (!M.who.lines.length) whoEl.appendChild(h('div', 'none', 'Nothing yet. Start a task and watch it fill in.'));
329 M.who.lines.forEach(function (l) {
330 var row = h('div', 'line ' + l.status + ' ' + l.kind);
331 row.appendChild(h('span', 'p', l.prefix));
332 row.appendChild(document.createTextNode(l.text));
333 whoEl.appendChild(row);
334 });
335 return;
336 }
337 if (!M.files) {
338 document.getElementById('graph').style.display = 'none';
339 if (!document.querySelector('.empty')) document.getElementById('stage').appendChild(h('div', 'empty', 'Files Claude reads or edits show up here'));
340 return;
341 }
342 document.getElementById('graph').style.display = '';
343 var empty = document.querySelector('.empty'); if (empty) empty.remove();
344
345 // One frame per kind of file (tests, translations, config...), named when there is more than one kind.
346 var cards = {}, ci = 0, framed = M.groups.length > 1;
347 M.groups.forEach(function (g) {
348 var frame = h('div', 'frame' + (framed ? '' : ' bare')), inner = h('div', 'fcols'), n = 0;
349 g.columns.forEach(function (col) {
350 var colEl = h('div', 'col');
351 col.forEach(function (c) {
352 var el = h('div', 'card' + (c.live ? ' live' : '') + (c.state ? ' ' + c.state : '') + (c.flags ? ' flagged' : '') + (c.flags && c.stale ? ' stale' : '') + (hasDiff(M, c.id) ? ' diffable' : '') + (openPath === c.id ? ' open' : '') + (focusId === c.id ? ' focus' : ''));
353 if (hasDiff(M, c.id)) el.title = 'Click for the diff';
354 var name = h('div', 'name', c.title);
355 var badge = c.live ? (c.state === 'edit' ? '\\u270e' : '\\u25cf') : c.state === 'changed' ? '\\u2713' : '';
356 if (badge) name.appendChild(h('span', 'badge', badge));
357 if (c.flags) { var fb = h('span', 'badge flag' + (c.stale ? ' stale' : ''), '\\u2691 ' + c.flags); fb.title = c.flags + ' review finding' + (c.flags === 1 ? '' : 's') + ' on this file' + (c.stale ? ', written before the file was last edited' : ''); name.appendChild(fb); }
358 el.appendChild(name);
359 el.appendChild(h('div', 'sub', c.sub));
360 if (c.why) el.appendChild(h('div', 'why', c.why));
361 colEl.appendChild(el);
362 cards[c.id] = { el: el, col: ci };
363 n++;
364 place(el, c.id);
365 putBack(el, c.id);
366 grab(el, c.id, hasDiff(M, c.id));
367 });
368 inner.appendChild(colEl);
369 ci++;
370 });
371 if (framed) frame.appendChild(h('div', 'frame-title', g.name + ' · ' + n));
372 frame.appendChild(inner);
373 cols.appendChild(frame);
374 });
375 M.extra.length && foot.appendChild(h('b', '', 'ALSO READ'));
376 M.extra.forEach(function (t) { foot.appendChild(h('span', 'chip', t)); });
377
378 // Measure at 1x, draw the arrows in the graph's own coordinates, then scale the whole graph to fit.
379 var graph = document.getElementById('graph'), stage = document.getElementById('stage');
380 graph.style.transform = '';
381 var gw = graph.offsetWidth, gh = graph.offsetHeight;
382 model = { cards: cards, edges: M.edges };
383 drawEdges();
384 var pad = 24, s = Math.min(1.5, (stage.clientWidth - 2 * pad) / gw, (stage.clientHeight - 2 * pad) / gh);
385 if (view.auto) view = { k: s, x: (stage.clientWidth - gw * s) / 2, y: (stage.clientHeight - gh * s) / 2, auto: true };
386 applyView();
387 }
388
389 // The arrows, from where the boxes are now. Works at any zoom: positions are divided by the graph's scale.
390 function drawEdges() {
391 var graph = document.getElementById('graph'), svg = document.getElementById('edges');
392 var cards = model.cards, gw = graph.offsetWidth, gh = graph.offsetHeight;
393 svg.setAttribute('width', gw); svg.setAttribute('height', gh);
394 svg.textContent = '';
395 var defs = document.createElementNS(SVGNS, 'defs');
396 defs.innerHTML = '<marker id="a" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,1L9,5L0,9z" fill="#6b7a96"/></marker>';
397 svg.appendChild(defs);
398 var gr = graph.getBoundingClientRect(), k = gr.width / (gw || 1) || 1;
399 function box(id) {
400 var r = cards[id].el.getBoundingClientRect();
401 return { x: (r.left - gr.left) / k, y: (r.top - gr.top) / k, w: r.width / k, h: r.height / k, col: cards[id].col };
402 }
403 model.edges.forEach(function (e) {
404 if (!cards[e.from] || !cards[e.to]) return;
405 if (focusId && e.from !== focusId && e.to !== focusId) return;
406 var a = box(e.from), b = box(e.to), d;
407 var x1 = a.x + a.w, y1 = a.y + Math.min(a.h / 2, 26), x2 = b.x - 4, y2 = b.y + Math.min(b.h / 2, 26);
408 if (b.col - a.col > 1 && x2 > x1 + 8 && !pos[e.from] && !pos[e.to]) {
409 // Skips a column: arc over the cards between, so the arrow is never hidden behind one.
410 var peak = a.y < b.y ? a.y : b.y;
411 Object.keys(cards).forEach(function (id) {
412 var c = box(id);
413 if (c.col > a.col && c.col < b.col && c.y < peak) peak = c.y;
414 });
415 peak -= 34;
416 var ax = a.x + a.w * 0.7, bx = b.x + b.w * 0.3;
417 d = 'M' + ax + ',' + a.y + ' C' + ax + ',' + peak + ' ' + bx + ',' + peak + ' ' + bx + ',' + (b.y - 4);
418 } else if (x2 > x1 + 8) {
419 var mid = x1 + (x2 - x1) / 2;
420 d = 'M' + x1 + ',' + y1 + ' C' + mid + ',' + y1 + ' ' + mid + ',' + y2 + ' ' + x2 + ',' + y2;
421 } else {
422 var ay = a.y + a.h, ac = a.x + a.w / 2, bc = b.x + b.w / 2;
423 d = 'M' + ac + ',' + ay + ' C' + ac + ',' + (ay + 30) + ' ' + bc + ',' + (b.y - 30) + ' ' + bc + ',' + (b.y - 4);
424 }
425 var p = document.createElementNS(SVGNS, 'path');
426 p.setAttribute('d', d); p.setAttribute('fill', 'none');
427 p.setAttribute('stroke', e.hot ? '#6b7a96' : '#3a4252'); p.setAttribute('stroke-width', e.hot ? 2 : 1.5);
428 p.setAttribute('marker-end', 'url(#a)');
429 svg.appendChild(p);
430 });
431 }
432
433 // Drag a box to move it, so tangled arrows can be pulled apart; double-click it to put it back.
434 function grab(el, id, diffable) {
435 el.addEventListener('pointerdown', function (e) {
436 e.stopPropagation(); // not the map's own drag
437 var from = { x: e.clientX, y: e.clientY }, base = pos[id] || { dx: 0, dy: 0 }, moved = false;
438 dragging = true;
439 el.classList.add('moving');
440 try { el.setPointerCapture(e.pointerId); } catch (err) {}
441 function move(ev) {
442 if (Math.abs(ev.clientX - from.x) + Math.abs(ev.clientY - from.y) > 4) moved = true;
443 pos[id] = { dx: base.dx + (ev.clientX - from.x) / view.k, dy: base.dy + (ev.clientY - from.y) / view.k };
444 place(el, id);
445 drawEdges();
446 }
447 function end(ev) {
448 el.removeEventListener('pointermove', move);
449 el.removeEventListener('pointerup', end);
450 el.removeEventListener('pointercancel', end);
451 el.classList.remove('moving');
452 dragging = false;
453 savePos();
454 if (moved) putBack(el, id);
455 if (diffable && !moved && ev.type === 'pointerup') {
456 if (clickTimer) clearTimeout(clickTimer);
457 clickTimer = setTimeout(function () { clickTimer = null; toggleDrawer(id); }, 250);
458 return;
459 }
460 if (stale) { stale = false; render(window.MAP); }
461 }
462 el.addEventListener('pointermove', move);
463 el.addEventListener('pointerup', end);
464 el.addEventListener('pointercancel', end);
465 });
466 el.addEventListener('dblclick', function (e) {
467 e.stopPropagation();
468 if (clickTimer) { clearTimeout(clickTimer); clickTimer = null; } // a double-click is not a click
469 setFocus(focusId === id ? null : id);
470 });
471 }
472
473 // Scroll or pinch to zoom around the pointer, drag to move, double-click (or 0) to fit again.
474 (function () {
475 var stage = document.getElementById('stage'), drag = null;
476 stage.addEventListener('wheel', function (e) {
477 e.preventDefault();
478 var r = stage.getBoundingClientRect(), px = e.clientX - r.left, py = e.clientY - r.top;
479 var k = Math.min(6, Math.max(0.15, view.k * Math.exp(-e.deltaY * (e.ctrlKey ? 0.01 : 0.002))));
480 view = { k: k, x: px - (px - view.x) * (k / view.k), y: py - (py - view.y) * (k / view.k), auto: false };
481 applyView();
482 }, { passive: false });
483 stage.addEventListener('pointerdown', function (e) {
484 drag = { x: e.clientX, y: e.clientY, sx: e.clientX, sy: e.clientY };
485 stage.setPointerCapture(e.pointerId);
486 stage.classList.add('drag');
487 });
488 stage.addEventListener('pointermove', function (e) {
489 if (!drag) return;
490 view = { k: view.k, x: view.x + e.clientX - drag.x, y: view.y + e.clientY - drag.y, auto: false };
491 drag = { x: e.clientX, y: e.clientY, sx: drag.sx, sy: drag.sy };
492 applyView();
493 });
494 function end(e) {
495 // A click on the bare map, not a drag, puts the drawer away.
496 var click = drag && e.type === 'pointerup' && Math.abs(e.clientX - drag.sx) + Math.abs(e.clientY - drag.sy) < 4;
497 drag = null; stage.classList.remove('drag');
498 if (click && openPath) closeDrawer();
499 }
500 stage.addEventListener('pointerup', end);
501 stage.addEventListener('pointercancel', end);
502 stage.addEventListener('dblclick', function () { view.auto = true; render(window.MAP); });
503 })();
504
505
506 // The diff drawer: the open file, the rows picked to comment on, the comment being written, and the review so far.
507 var openPath = null, sel = null, draftText = '', EXPORTED = !!window.EXPORTED, CAN_SEND = !EXPORTED && location.protocol === 'http:', REVKEY = 'mission-review:' + (CAN_SEND ? 'http' : location.pathname), pending = [], DIFFREV = null;
508 try { pending = JSON.parse(localStorage.getItem(REVKEY) || '[]') || []; } catch (err) { pending = []; }
509 function savePending() { try { localStorage.setItem(REVKEY, JSON.stringify(pending)); } catch (err) {} }
510 function hasDiff(M, id) { return !!(M.diffs && M.diffs.paths.indexOf(id) >= 0); }
511 function toggleDrawer(id) {
512 openPath = openPath === id ? null : id;
513 sel = null; draftText = '';
514 renderDrawer();
515 render(window.MAP); // the map makes room, or takes it back
516 }
517 function closeDrawer() { if (openPath) toggleDrawer(openPath); }
518 function toast(text) {
519 var t = h('div', 'toast', text);
520 document.body.appendChild(t);
521 setTimeout(function () { t.remove(); }, 2600);
522 }
523 // To the clipboard; where the browser refuses (a file page may), a box the person can copy from.
524 function copyText(text, done) {
525 function fallback() {
526 var ta = document.createElement('textarea'), ok = false;
527 ta.value = text; ta.style.position = 'fixed'; ta.style.opacity = '0';
528 document.body.appendChild(ta); ta.select();
529 try { ok = document.execCommand('copy'); } catch (err) {}
530 ta.remove();
531 if (!ok) window.prompt('Copy this review, then paste it into Claude:', text);
532 done();
533 }
534 if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text).then(done, fallback);
535 else fallback();
536 }
537 function refOf(list) {
538 var r = list.length ? list[0].ref : '';
539 return list.every(function (c) { return c.ref === r; }) ? r : '';
540 }
541 // Copying keeps the comments, marked as sent, so a paste that goes wrong costs nothing. They go when Claude
542 // changes their file again (sweep); a comment not copied yet is never dropped, only marked outdated.
543 // To Claude's session when the page is served by the mod (CAN_SEND), else, or where that fails, to the clipboard.
544 function deliver(text, done) {
545 function copy() { copyText(text, function () { done(false); }); }
546 if (!CAN_SEND) return copy();
547 fetch('send', { method: 'POST', body: JSON.stringify({ text: text }) }).then(function (r) { if (r.ok) done(true); else copy(); }, copy);
548 }
549 function said(n, sent) {
550 var what = n + ' comment' + (n === 1 ? '' : 's');
551 return sent ? 'Sent ' + what + ' to Claude.' : 'Copied ' + what + '. Paste ' + (n === 1 ? 'it' : 'them') + ' into Claude.';
552 }
553 function ship(list, send) {
554 (send ? deliver : function (text, done) { copyText(text, function () { done(false); }); })(formatReview(list, refOf(list)), function (sent) {
555 list.forEach(function (c) { c.sent = true; });
556 savePending();
557 toast(said(list.length, sent));
558 render(window.MAP); renderDrawer();
559 });
560 }
561 function sendReview() { ship(pending.filter(function (c) { return !c.sent; }), true); }
562 function copyAll() { ship(pending.slice(), false); }
563 // A fingerprint of a file's diff: it changes when the file does.
564 function fpOf(text) {
565 var x = 7;
566 for (var i = 0; i < text.length; i++) x = (Math.imul(x, 31) + text.charCodeAt(i)) | 0;
567 return x;
568 }
569 function changedSince(c) {
570 var d = diffOf(c.path);
571 return !!(d && c.fp !== undefined && fpOf(d.text) !== c.fp);
572 }
573 // Claude has worked on a file again: its comments that were already copied have been dealt with.
574 function sweep() {
575 var kept = pending.filter(function (c) { return !(c.sent && changedSince(c)); });
576 if (kept.length === pending.length) return;
577 pending = kept; savePending();
578 render(window.MAP); renderDrawer();
579 }
580 function picked() {
581 if (!sel) return [];
582 var lo = Math.min(sel.a, sel.b), hi = Math.max(sel.a, sel.b);
583 return rowsNow.slice(lo, hi + 1).filter(function (r) { return r.k !== 'h'; });
584 }
585 function draft(send) {
586 var text = draftText.trim(), lines = picked();
587 if (!text || !lines.length) return;
588 var d = diffOf(openPath) || {};
589 var c = { id: Date.now() + '-' + Math.random(), path: openPath, ref: d.ref || '', lines: lines, text: text, fp: fpOf(d.text || ''), sent: !!send };
590 sel = null; draftText = '';
591 pending.push(c); savePending();
592 render(window.MAP); renderDrawer();
593 if (send) deliver(formatReview([c], c.ref), function (sent) { toast(said(1, sent)); });
594 }
595 var rowsNow = [], selDrag = false;
596 // The rows under the selection, lit as the mouse moves; the comment box comes once the button is let go.
597 function paintSel() {
598 var lo = Math.min(sel.a, sel.b), hi = Math.max(sel.a, sel.b);
599 [].forEach.call(document.querySelectorAll('.dbody .row[data-i]'), function (r) {
600 var i = Number(r.getAttribute('data-i'));
601 r.classList.toggle('sel', i >= lo && i <= hi);
602 });
603 }
604 window.addEventListener('mouseup', function () { if (selDrag) { selDrag = false; renderDrawer(); } });
605 function diffOf(path) { return window.DIFFS && window.DIFFS[path]; }
606 // Review findings: the reviewer picks the ones to push to the pull request. Only ids go back; the mod posts what it holds.
607 var fpick = {}, showList = false, dest = 'pr';
608 // Every finding in one panel, one checkbox each, so none needs its file opened to be picked or dropped.
609 function renderList(M) {
610 var el = document.getElementById('flist'), keep = el.scrollTop, FL = M.findings || {}, paths = Object.keys(FL);
611 el.textContent = '';
612 el.hidden = !showList || !paths.length || tab() !== 'code';
613 if (el.hidden) return;
614 var head = h('div', 'fl-head'), n = Object.keys(fpick).length;
615 head.appendChild(h('b', '', n ? n + ' picked' : 'Pick findings to post'));
616 var x = h('button', 'fl-open', '\\u00d7'); x.title = 'Close the list';
617 x.onclick = function () { showList = false; render(window.MAP); };
618 head.appendChild(x);
619 el.appendChild(head);
620 paths.forEach(function (p) {
621 var file = h('div', 'fl-file', p.split('/').slice(-2).join('/'));
622 file.title = p;
623 el.appendChild(file);
624 FL[p].forEach(function (f) {
625 var row = h('label', (f.posted ? 'posted' : '') + (f.stale && !f.posted ? ' stale' : '')), box = document.createElement('input');
626 box.type = 'checkbox'; box.className = 'fsw'; box.checked = !!fpick[f.id]; box.disabled = !!f.posted;
627 box.onchange = function () { if (box.checked) fpick[f.id] = true; else delete fpick[f.id]; render(window.MAP); renderDrawer(); };
628 row.appendChild(box);
629 row.appendChild(h('span', 'fl-line', f.line ? 'L' + f.line : 'file'));
630 row.appendChild(h('span', '', (f.posted ? '\\u2713 ' : '') + (f.stale && !f.posted ? '\\u21bb ' : '') + f.summary));
631 var go = h('button', 'fl-open', '\\u2197'); go.title = 'Open the diff at this finding';
632 go.onclick = function (e) { e.preventDefault(); if (openPath !== p) toggleDrawer(p); else renderDrawer(); };
633 row.appendChild(go);
634 row.appendChild(dismissBtn(f, 'fl-dis'));
635 el.appendChild(row);
636 });
637 });
638 el.scrollTop = keep;
639 }
640 function canPost() { return CAN_SEND && !!(window.MAP && window.MAP.post && window.MAP.post.can); }
641 function pickedFindings() {
642 var FL = (window.MAP && window.MAP.findings) || {}, out = [];
643 Object.keys(FL).forEach(function (p) { FL[p].forEach(function (f) { if (fpick[f.id]) out.push(f); }); });
644 return out;
645 }
646 // The picked findings as a request to Claude; deliver() sends it to the session, or copies it where there is no server.
647 function sendPicked() {
648 var list = pickedFindings();
649 if (!list.length) return;
650 var where = window.MAP && window.MAP.where, lines = ['Fix these ' + list.length + ' code review finding' + (list.length === 1 ? '' : 's') + (where && where.branch ? ' (branch ' + where.branch + ')' : '') + '. Check each against the code before changing it, and say if one is wrong:', ''];
651 list.forEach(function (f, i) {
652 lines.push((i + 1) + '. ' + f.file + (f.line ? ':' + f.line : '') + (f.severity ? ' [' + f.severity + ']' : '') + ' - ' + f.summary);
653 if (f.scenario) lines.push(' ' + f.scenario);
654 });
655 deliver(lines.join('\\n'), function (sent) {
656 toast(sent ? 'Sent ' + list.length + ' finding' + (list.length === 1 ? '' : 's') + ' to Claude.' : 'Copied ' + list.length + '. Paste into Claude.');
657 fpick = {}; render(window.MAP); renderDrawer();
658 });
659 }
660 function postPicked() {
661 var ids = Object.keys(fpick).map(Number);
662 if (!ids.length) return;
663 if (!confirm('Post ' + ids.length + ' comment' + (ids.length === 1 ? '' : 's') + ' to the pull request as one review?')) return;
664 fetch('post', { method: 'POST', body: JSON.stringify({ ids: ids }) }).then(function (r) {
665 if (r.ok) { fpick = {}; toast('Posting to the pull request\\u2026'); render(window.MAP); renderDrawer(); } else toast('Could not send the request');
666 }, function () { toast('Could not send the request'); });
667 }
668 // Puts a finding away for good. Only its id goes back; the mod marks it and the page stops drawing it.
669 function dismissBtn(f, cls) {
670 var b = h('button', cls, '\\u00d7'); b.title = 'Dismiss this finding';
671 b.onclick = function (e) {
672 e.preventDefault(); e.stopPropagation();
673 if (EXPORTED) return dropLocal(f); // no mod to tell: the snapshot just stops showing it
674 delete fpick[f.id];
675 fetch('dismiss', { method: 'POST', body: JSON.stringify({ ids: [f.id] }) }).then(function (r) {
676 if (!r.ok) toast('Could not dismiss');
677 }, function () { toast('Could not dismiss: needs the local server'); });
678 };
679 return b;
680 }
681 // A button for what only the mod can do: greyed out, and the hover says why.
682 function modOnly(b) { b.disabled = true; b.title = 'Only available in the Mission Control mod'; return b; }
683 // The exported page has no mod behind it: a dismissed finding is taken out of the page's own data.
684 function dropLocal(f) {
685 var M = window.MAP, FL = M.findings || {};
686 Object.keys(FL).forEach(function (p) {
687 var rest = FL[p].filter(function (x) { return x.id !== f.id; });
688 if (rest.length === FL[p].length) return;
689 if (rest.length) FL[p] = rest; else delete FL[p];
690 var open = rest.filter(function (x) { return !x.posted; });
691 M.groups.forEach(function (g) { g.columns.forEach(function (col) { col.forEach(function (c) {
692 if (c.id === p) { c.flags = open.length || rest.length; c.stale = open.length > 0 && open.every(function (x) { return x.stale; }); }
693 }); }); });
694 });
695 delete fpick[f.id];
696 render(M); renderDrawer();
697 }
698 // The page as one file to keep or send: the template, highlight.js and this page's data and diffs inlined. Opened from
699 // disk it is a snapshot (EXPORTED): nothing re-reads data.js, and what needs the mod is greyed out.
700 function exportPage() {
701 var get = function (n) { return fetch(n, { cache: 'no-store' }).then(function (r) { if (!r.ok) throw new Error(n); return r.text(); }); };
702 Promise.all([get('index.html'), get('hljs.js')]).then(function (t) {
703 var bs = String.fromCharCode(92), json = function (v) { return JSON.stringify(v).replace(new RegExp('<', 'g'), bs + 'u003c'); };
704 var data = 'window.MAP = ' + json(window.MAP) + '; window.DIFFS = ' + json(window.DIFFS || {}) + '; window.EXPORTED = ' + Date.now() + ';';
705 var hl = t[1].replace(new RegExp('<' + '/script', 'gi'), function () { return '<' + bs + '/script'; });
706 var page = t[0], tags = ['<script src="hljs.js"><' + '/script>', '<script src="data.js"><' + '/script>'];
707 if (page.indexOf(tags[0]) < 0 || page.indexOf(tags[1]) < 0) throw new Error('page');
708 page = page.replace(tags[0], function () { return '<script>' + hl + '<' + '/script>'; }).replace(tags[1], function () { return '<script>' + data + '<' + '/script>'; });
709 var where = window.MAP && window.MAP.where, name = 'mission-control-' + ((where && where.branch) || 'review').replace(new RegExp('[^A-Za-z0-9._-]+', 'g'), '-') + '-' + new Date().toISOString().slice(0, 10) + '.html';
710 var a = document.createElement('a');
711 a.href = URL.createObjectURL(new Blob([page], { type: 'text/html' })); a.download = name;
712 document.body.appendChild(a); a.click(); a.remove();
713 setTimeout(function () { URL.revokeObjectURL(a.href); }, 1000);
714 toast('Exported ' + name);
715 }).catch(function () { toast('Could not export the page'); });
716 }
717 function findingEl(f) {
718 var el = h('div', 'finding' + (f.posted ? ' posted' : '') + (f.stale && !f.posted ? ' stale' : ''));
719 var box = document.createElement('input');
720 box.type = 'checkbox'; box.className = 'fsw'; box.checked = !!fpick[f.id]; box.disabled = !!f.posted;
721 box.title = f.posted ? 'Already on the pull request' : 'Pick to send to Claude' + (canPost() ? ' or post to the pull request' : '');
722 box.onchange = function () { if (box.checked) fpick[f.id] = true; else delete fpick[f.id]; render(window.MAP); renderDrawer(); };
723 var body = h('div', 'fbody');
724 body.appendChild(h('b', '', (f.severity ? f.severity + ' \\u00b7 ' : '') + f.summary));
725 if (f.scenario) body.appendChild(h('div', 'fsc', f.scenario));
726 if (f.posted) body.appendChild(h('div', 'fsc', '\\u2713 pushed to the pull request'));
727 else if (f.stale) body.appendChild(h('div', 'fsc', '\\u21bb edited since this review: the line may have moved, or it may be fixed'));
728 el.appendChild(box); el.appendChild(body); el.appendChild(dismissBtn(f, 'fdis'));
729 el.onclick = function (e) { if (e.target !== box && !box.disabled) box.click(); }; // the whole card is the target, not just the switch
730 return el;
731 }
732 function sameRow(a, b) { return a.k === b.k && a.o === b.o && a.n === b.n; }
733 function renderDrawer() {
734 var el = document.getElementById('drawer');
735 var keep = el.querySelector('.dbody'), top = keep ? keep.scrollTop : 0;
736 el.hidden = !openPath || tab() !== 'code';
737 el.textContent = '';
738 if (el.hidden) return;
739 var head = h('div', 'dhead');
740 head.appendChild(h('b', '', openPath.split('/').slice(-2).join('/')));
741 var sub = h('span', 'dsub', openPath);
742 sub.title = 'Click or drag line numbers to comment, shift-click extends, esc closes';
743 head.appendChild(sub);
744 var cp = h('button', 'dcopy', '\ud83d\udccb'); cp.title = 'Copy the file path';
745 cp.onclick = function () { copyText(openPath, function () { toast('Copied ' + openPath); }); };
746 head.appendChild(cp);
747 var x = h('button', 'dclose', '\u00d7'); x.title = 'Close';
748 x.onclick = closeDrawer;
749 head.appendChild(x);
750 el.appendChild(head);
751 var body = h('div', 'dbody');
752 el.appendChild(body);
753 var d = diffOf(openPath);
754 rowsNow = d ? parseDiff(d.text) : [];
755 if (!d) { body.appendChild(h('div', 'none', 'Loading the diff\u2026')); return; }
756 if (!rowsNow.length) { body.appendChild(h('div', 'none', 'No diff to show: the file is too large for GitHub to send, binary, or empty.')); return; }
757 var lo = sel ? Math.min(sel.a, sel.b) : -1, hi = sel ? Math.max(sel.a, sel.b) : -1;
758 var ext = openPath.indexOf('.') < 0 ? '' : openPath.split('.').pop();
759 // highlight.js when it loaded and knows the language; otherwise the small tint of highlight()
760 var lang = window.hljs ? langOf(ext) : '', htmls = lang && window.hljs.getLanguage(lang) ? htmlRows(rowsNow, lang, window.hljs) : [];
761 var mine = pending.filter(function (c) { return c.path === openPath; }), placed = [];
762 var anchor = {}; // row index -> the comments that end on it
763 mine.forEach(function (c) {
764 var last = c.lines[c.lines.length - 1], at = -1;
765 rowsNow.forEach(function (r, i) { if (r.k !== 'h' && sameRow(r, last)) at = i; });
766 if (at < 0) at = rowsNow.length - 1; // its lines moved on: it still shows, at the end
767 (anchor[at] = anchor[at] || []).push(c);
768 });
769 var fAnchor = {};
770 ((window.MAP && window.MAP.findings && window.MAP.findings[openPath]) || []).forEach(function (f) {
771 var at = -1;
772 if (f.line) rowsNow.forEach(function (r, i) { if (r.k !== 'h' && r.k !== 'd' && r.n === f.line) at = i; });
773 if (at < 0) body.appendChild(findingEl(f)); // no line, or not in this diff: on the file
774 else (fAnchor[at] = fAnchor[at] || []).push(f);
775 });
776 rowsNow.forEach(function (r, i) {
777 if (r.k === 'h') { body.appendChild(h('div', 'row hunk', r.t)); return; }
778 var row = h('div', 'row k-' + r.k + (i >= lo && i <= hi ? ' sel' : ''));
779 row.setAttribute('data-i', String(i));
780 row.onmouseenter = function () { if (selDrag) { sel = { a: sel.a, b: i }; paintSel(); } };
781 [r.o, r.n].forEach(function (num) {
782 var cell = h('span', 'ln', num == null ? '' : String(num));
783 // Press on a number and drag down or up to take a range; shift-click extends the one already taken.
784 cell.onmousedown = function (e) {
785 if (e.button !== 0) return;
786 e.preventDefault();
787 if (e.shiftKey && sel) { sel = { a: sel.a, b: i }; renderDrawer(); return; }
788 sel = { a: i, b: i }; draftText = ''; selDrag = true;
789 var ed = document.querySelector('.editor'); if (ed) ed.remove();
790 paintSel();
791 };
792 row.appendChild(cell);
793 });
794 row.appendChild(h('span', 'mark', r.k === 'a' ? '+' : r.k === 'd' ? '-' : ' '));
795 var code = h('span', 'code');
796 if (htmls[i] !== undefined) code.innerHTML = htmls[i];
797 else highlight(r.t, ext).forEach(function (t) { code.appendChild(t[0] ? h('span', 't-' + t[0], t[1]) : document.createTextNode(t[1])); });
798 row.appendChild(code);
799 body.appendChild(row);
800 (fAnchor[i] || []).forEach(function (f) { body.appendChild(findingEl(f)); });
801 (anchor[i] || []).forEach(function (c) {
802 var late = !c.sent && changedSince(c);
803 var note = h('div', 'note' + (c.sent ? ' sent' : ''));
804 note.appendChild(h('span', '', (c.sent ? '\u2713 ' : '') + c.text + (late ? ' (outdated: the file changed since)' : '')));
805 var rm = h('button', '', '\u00d7'); rm.title = 'Remove this comment';
806 rm.onclick = function () { pending = pending.filter(function (p) { return p.id !== c.id; }); savePending(); render(window.MAP); renderDrawer(); };
807 note.appendChild(rm);
808 body.appendChild(note);
809 });
810 if (i === hi) {
811 var ed = h('div', 'editor'), ta = document.createElement('textarea');
812 ta.placeholder = 'Comment on ' + (lo === hi ? 'this line' : 'these ' + picked().length + ' lines');
813 ta.value = draftText;
814 ta.oninput = function () { draftText = ta.value; };
815 ta.onkeydown = function (e) { if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); draft(false); } };
816 ed.appendChild(ta);
817 var btns = h('div', 'btns');
818 [['Add to review', 'tab go', function () { draft(false); }], ['Send now', 'tab', function () { draft(true); }], ['Cancel', 'tab', function () { sel = null; draftText = ''; renderDrawer(); }]].forEach(function (b) {
819 var now = EXPORTED && b[0] === 'Send now', bt = h('button', b[1], now ? 'Copy now' : b[0]); bt.onclick = b[2];
820 if (now) btns.appendChild(modOnly(h('button', 'tab', 'Send now')));
821 btns.appendChild(bt);
822 });
823 ed.appendChild(btns);
824 body.appendChild(ed);
825 setTimeout(function () { ta.focus(); }, 0);
826 }
827 });
828 body.scrollTop = top;
829 }
830 // diffs.js is read again only when data.js says its contents changed.
831 function syncDiffs() {
832 var rev = window.MAP && window.MAP.diffs && window.MAP.diffs.rev;
833 if (EXPORTED || rev == null || rev === DIFFREV) return; // a snapshot carries its diffs
834 var s = document.createElement('script');
835 s.src = 'diffs.js?t=' + rev;
836 s.onload = function () { DIFFREV = rev; s.remove(); sweep(); renderDrawer(); };
837 s.onerror = function () { s.remove(); };
838 document.head.appendChild(s);
839 }
840
841 var last = JSON.stringify(window.MAP), lastF = JSON.stringify(window.MAP && window.MAP.findings);
842 render(window.MAP);
843 syncDiffs();
844 window.addEventListener('resize', function () { render(window.MAP); });
845 window.addEventListener('hashchange', function () { render(window.MAP); });
846 window.addEventListener('keydown', function (e) {
847 if (e.metaKey || e.ctrlKey || e.altKey) return;
848 if (e.target && (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT')) {
849 if (e.key === 'Escape') { sel = null; draftText = ''; renderDrawer(); }
850 return;
851 }
852 if (e.key === 'Escape') { if (focusId) setFocus(null); else closeDrawer(); }
853 if (e.key === 'w') { location.hash = 'who'; render(window.MAP); }
854 if (e.key === 'c') { location.hash = 'code'; render(window.MAP); }
855 if (e.key === '0' || e.key === 'f') { view.auto = true; render(window.MAP); }
856 if (e.key === 'r') { pos = {}; savePos(); render(window.MAP); }
857 });
858 if (!EXPORTED) {
859 setInterval(function () {
860 var s = document.createElement('script');
861 s.src = 'data.js?t=' + Date.now();
862 s.onload = function () {
863 var now = JSON.stringify(window.MAP);
864 if (now !== last) { last = now; syncDiffs(); if (dragging) stale = true; else render(window.MAP); var fnow = JSON.stringify(window.MAP && window.MAP.findings); if (fnow !== lastF) { lastF = fnow; if (!selDrag) renderDrawer(); } }
865 s.remove();
866 };
867 s.onerror = function () { s.remove(); };
868 document.head.appendChild(s);
869 }, 1000);
870 }
871</script>
872`
873hooks/tree.ts 81 lines1// The "who" view: main, its subagents and their tool calls, as tree lines.
2import type { MissionNode } from '../types'
3
4// A short label and a family for one tool call.
5export function label(e: Record<string, unknown>): { label: string; family: string } {
6 const tool = String(e.tool)
7 const s = (k: string) => (typeof e[k] === 'string' ? (e[k] as string) : '')
8 const file = (p: string) => p.split('/').slice(-2).join('/')
9 if (tool === 'Bash') return { label: s('description') || s('command').slice(0, 60), family: 'bash' }
10 if (tool === 'Edit' || tool === 'Write') return { label: file(s('file_path')), family: 'edit' }
11 if (tool === 'Read') return { label: file(s('file_path')), family: 'read' }
12 if (tool === 'Grep' || tool === 'Glob') return { label: s('pattern').slice(0, 40), family: 'search' }
13 if (tool.startsWith('mcp__')) {
14 const [, server = '', action = ''] = tool.split('__')
15 if (/playwright/.test(server)) return { label: action.replace(/^browser_/, ''), family: 'browser' }
16 return { label: action, family: `mcp:${server.replace(/^(plugin_|claude_ai_)/, '').replace(/_.*$/, '')}` }
17 }
18 return { label: tool, family: tool.toLowerCase() }
19}
20
21const ICON: Record<string, string> = { bash: '$', edit: '✎', read: '◉', search: '⌕', browser: '◎' }
22export const icon = (n: MissionNode) =>
23 n.kind === 'main' ? '◆' : n.kind === 'agent' ? '●' : (ICON[n.family] ?? (n.family.startsWith('mcp:') ? '⌁' : '·'))
24
25export function took(n: Pick<MissionNode, 'start' | 'end'>, at = Date.now()) {
26 const s = Math.max(0, ((n.end ?? at) - n.start) / 1000)
27 if (s < 10) return `${s.toFixed(1)}s`
28 if (s < 60) return `${Math.round(s)}s`
29 return `${Math.floor(s / 60)}m ${String(Math.round(s % 60)).padStart(2, '0')}s`
30}
31
32export type Line = { prefix: string; node: MissionNode; text: string; count: number; status: MissionNode['status'] }
33
34// Tree lines, depth first. Runs of the same tool family under one parent fold into one
35// line ("◎ browser: navigate → click → screenshot ×3") so a busy agent stays readable.
36export function lines(nodes: MissionNode[], at = Date.now()): Line[] {
37 const kids = new Map<string | null, MissionNode[]>()
38 for (const n of nodes) kids.set(n.parent, [...(kids.get(n.parent) ?? []), n])
39 const out: Line[] = []
40 const walk = (parent: string | null, prefix: string) => {
41 const groups: MissionNode[][] = []
42 for (const n of kids.get(parent) ?? []) {
43 const last = groups.at(-1)
44 const head = last?.[0]
45 if (last && head && n.kind === 'tool' && head.kind === 'tool' && head.family === n.family) last.push(n)
46 else groups.push([n])
47 }
48 groups.forEach((g, i) => {
49 const isLast = i === groups.length - 1
50 const n = g[0] as MissionNode
51 const branch = parent === null ? '' : isLast ? '└─ ' : '├─ '
52 const status = g.some(x => x.status === 'running') ? 'running' : g.some(x => x.status === 'failed') ? 'failed' : 'done'
53 const start = Math.min(...g.map(x => x.start))
54 const end = status === 'running' ? undefined : Math.max(...g.map(x => x.end ?? x.start))
55 let text: string
56 if (n.kind === 'tool') {
57 const name = n.family.startsWith('mcp:') ? n.family.slice(4) : n.family
58 const acts = g.map(x => x.label)
59 const shown = acts.length > 4 ? [...acts.slice(0, 3), '…', acts.at(-1)] : acts
60 const time = took({ start, end }, at)
61 text = `${icon(n)} ${name}: ${shown.join(' → ')}${g.length > 1 ? ` ×${g.length}` : ''}${time === '0.0s' ? '' : ` ${time}`}`
62 } else {
63 const tools = nodes.filter(x => x.parent === n.id && x.kind === 'tool').length
64 text = `${icon(n)} ${n.label} ${took(n, at)}${n.kind === 'agent' ? ` · ${tools} tools` : ''}`
65 }
66 out.push({ prefix: prefix + branch, node: n, text, count: g.length, status })
67 if (n.kind !== 'tool') walk(n.id, parent === null ? '' : prefix + (isLast ? ' ' : '│ '))
68 })
69 }
70 walk(null, '')
71 return out
72}
73
74export function summary(nodes: MissionNode[]) {
75 const agents = nodes.filter(n => n.kind === 'agent')
76 const running = agents.filter(n => n.status === 'running').length
77 const tools = nodes.filter(n => n.kind === 'tool').length
78 const failed = nodes.filter(n => n.kind === 'tool' && n.status === 'failed').length
79 return { agents: agents.length, running, tools, failed }
80}
81hooks/category.ts 23 lines1// What a file is for, from its path alone: the code map frames files of one kind together.
2
3export const CATEGORIES = ['Source', 'Tests', 'API & contracts', 'Database', 'Translations', 'Config & env', 'Dependencies', 'CI & infra', 'Docs', 'Styles'] as const
4export type Category = (typeof CATEGORIES)[number]
5
6// The first rule that matches wins, so a spec file under `locales/` is a test and `db/migrate/x.rb` is Database, not Source.
7const RULES: [Exclude<Category, 'Source'>, RegExp[]][] = [
8 ['Tests', [/(^|\/)(__tests__|__mocks__|__snapshots__|tests?|specs?|e2e|cypress|fixtures)\//i, /\.(test|spec)\.[a-z]+$/i, /_test\.(go|py|rb|exs?)$/i, /(^|\/)test_[^/]+\.py$/i, /_spec\.rb$/i, /(Test|Tests|Spec)\.(java|kt|swift|cs)$/]],
9 ['Translations', [/(^|\/)(locales?|i18n|translations?|lang|languages|l10n)\//i, /\.(po|pot|xlf|xliff)$/i, /(^|\/)messages[._-][\w-]+\.json$/i, /(^|\/)(en|fr|de|es|it|pt|nl)(-[a-z]{2})?\.(json|ya?ml)$/i]],
10 ['Database', [/(^|\/)(migrations?|migrate)\//i, /(^|\/)db\/(migrate|seeds?)\//i, /\.sql$/i, /(^|\/)(schema\.rb|structure\.sql)$/i, /(^|\/)prisma\//i]],
11 ['API & contracts', [/\.d\.ts$/i, /\.(proto|graphql|gql)$/i, /(^|\/)(openapi|swagger)[^/]*\.(json|ya?ml)$/i]],
12 ['CI & infra', [/(^|\/)\.github\//i, /(^|\/)\.gitlab-ci\.ya?ml$/i, /(^|\/)Jenkinsfile$/, /(^|\/)Dockerfile[^/]*$/i, /(^|\/)docker-compose[^/]*\.ya?ml$/i, /(^|\/)(terraform|k8s|kubernetes|helm|\.circleci|infra|deploy)\//i, /\.tf$/i]],
13 ['Dependencies', [/(^|\/)(package\.json|package-lock\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|Gemfile(\.lock)?|go\.(mod|sum)|requirements[^/]*\.txt|pyproject\.toml|poetry\.lock|pom\.xml|build\.gradle(\.kts)?|Cargo\.(toml|lock)|composer\.(json|lock))$/i]],
14 ['Config & env', [/(^|\/)\.env[^/]*$/i, /\.config\.[a-z]+$/i, /(^|\/)(tsconfig[^/]*\.json|\.eslintrc[^/]*|\.prettierrc[^/]*|\.babelrc|\.editorconfig)$/i, /\.(ya?ml|toml|ini|properties|json)$/i, /(^|\/)config\//i]],
15 ['Docs', [/\.(md|mdx)$/i, /(^|\/)docs?\//i]],
16 ['Styles', [/\.(css|scss|sass|less)$/i]],
17]
18
19export function categoryOf(path: string): Category {
20 for (const [name, patterns] of RULES) if (patterns.some(p => p.test(path))) return name
21 return 'Source'
22}
23hooks/highlight.ts 33 lines1// Syntax colours for the diff drawer. Runs in the page too (template.ts splices the source in), so it stands alone.
2// One line at a time and one broad keyword list for every language: a rough tint, not a parser.
3
4// A line cut into [class, text] pieces: kw, str, com, num or type, '' for the rest.
5export function highlight(text: string, ext: string): [string, string][] {
6 const e = ext.toLowerCase()
7 const hash = ' py rb sh bash zsh yml yaml toml ex exs '.includes(` ${e} `)
8 const dash = ' sql lua '.includes(` ${e} `)
9 const html = ' html vue svelte xml '.includes(` ${e} `)
10 if (' md mdx txt lock '.includes(` ${e} `)) return [['', text]]
11 const com = hash ? '#.*' : dash ? '--.*' : html ? '<!--.*?-->' : '\\/\\/.*|\\/\\*.*?\\*\\/'
12 // A line inside a /* block (its stars lead the line) is a comment whole.
13 if (!hash && !dash && /^\s*(\*|\/\*)/.test(text)) return [['com', text]]
14 const re = new RegExp(`(${com})|("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`)|(\\b\\d[\\d_.]*\\b)|([A-Za-z_$][\\w$]*)`, 'g')
15 const words =
16 ' const let var function return if else for while do class import export from default new this async await try catch finally throw switch case break continue typeof instanceof interface type extends implements public private protected static readonly enum def end then elsif elif unless module require fn pub use mut impl struct match func package go defer range yield lambda pass raise except with as in not and or is select where from join on group order by limit insert update delete create table null undefined true false nil self void None True False '
17 const out: [string, string][] = []
18 let at = 0
19 let m: RegExpExecArray | null
20 while ((m = re.exec(text))) {
21 if (m[0] === '') {
22 re.lastIndex++
23 continue
24 }
25 if (m.index > at) out.push(['', text.slice(at, m.index)])
26 const cls = m[1] ? 'com' : m[2] ? 'str' : m[3] ? 'num' : words.includes(` ${m[4]} `) ? 'kw' : /^[A-Z]/.test(m[4] as string) ? 'type' : ''
27 out.push([cls, m[0]])
28 at = m.index + m[0].length
29 }
30 if (at < text.length) out.push(['', text.slice(at)])
31 return out
32}
33hooks/hl.ts 62 lines1// Feeds the diff drawer to highlight.js. Runs in the page too (template.ts splices the source in), so these
2// two functions may call only each other.
3import type { DiffLine } from './diff'
4
5// The highlight.js language for a file extension, or '' when there is none (the drawer then uses highlight.ts).
6export function langOf(ext: string): string {
7 const by: Record<string, string> = {
8 ts: 'typescript', tsx: 'typescript', mts: 'typescript', cts: 'typescript',
9 js: 'javascript', jsx: 'javascript', mjs: 'javascript', cjs: 'javascript',
10 py: 'python', rb: 'ruby', go: 'go', rs: 'rust', java: 'java', kt: 'kotlin', swift: 'swift', php: 'php', cs: 'csharp',
11 c: 'c', h: 'c', cc: 'cpp', cpp: 'cpp', hpp: 'cpp',
12 css: 'css', scss: 'scss', html: 'xml', vue: 'xml', svelte: 'xml', xml: 'xml',
13 json: 'json', yml: 'yaml', yaml: 'yaml', toml: 'ini', sh: 'bash', bash: 'bash', zsh: 'bash', sql: 'sql', lua: 'lua', md: 'markdown', mdx: 'markdown',
14 }
15 return by[ext.toLowerCase()] ?? ''
16}
17
18// One piece of HTML per row (undefined where it could not be made). A diff shows hunks, so each hunk is
19// highlighted twice as a block, as the new file reads there (context and added lines) and as the old file read
20// (context and deleted lines): a string or comment that runs over several lines stays whole inside a hunk.
21export function htmlRows(rows: DiffLine[], lang: string, hljs: { highlight: (code: string, o: { language: string; ignoreIllegals: boolean }) => { value: string } }): (string | undefined)[] {
22 const out: (string | undefined)[] = new Array(rows.length).fill(undefined)
23 try {
24 let from = 0
25 for (let to = 0; to <= rows.length; to++) {
26 if (to < rows.length && (rows[to] as DiffLine).k !== 'h') continue
27 const seg = rows.slice(from, to).map((r, i) => ({ r, at: from + i }))
28 from = to + 1
29 for (const side of ['new', 'old'] as const) {
30 const mine = seg.filter(({ r }) => (side === 'new' ? r.k !== 'd' : r.k === 'd' || r.k === 'c'))
31 if (!mine.length) continue
32 const html = hljs.highlight(mine.map(({ r }) => r.t).join('\n'), { language: lang, ignoreIllegals: true }).value
33 // The block's HTML cut at its newlines; a span open at a cut is closed there and reopened on the next line.
34 const open: string[] = []
35 const lines: string[] = ['']
36 for (const part of html.split(/(<[^>]+>)/)) {
37 if (!part) continue
38 if (part[0] === '<') {
39 if (part[1] === '/') open.pop()
40 else open.push(part)
41 lines[lines.length - 1] += part
42 } else {
43 part.split('\n').forEach((piece, i) => {
44 if (i > 0) {
45 lines[lines.length - 1] += '</span>'.repeat(open.length)
46 lines.push(open.join(''))
47 }
48 lines[lines.length - 1] += piece
49 })
50 }
51 }
52 mine.forEach(({ r, at }, i) => {
53 if (side === 'new' || r.k === 'd') out[at] = lines[i]
54 })
55 }
56 }
57 } catch {
58 return new Array(rows.length).fill(undefined)
59 }
60 return out
61}
62