SLOPSHOPPER

ink-figure

Epistemic Ink output style, which also flags with a ↻ line a departure that recurs against a clause of an extension the user maintains, with a figure mod that…

new
★ 11v0.12.2MITupdated 2026-10-23jongwony/cc-plugin/ink-figure
A shopper browsing a rack in a slop shop
Preview could not run: harness produced no result (2 | import{a as Ec,b as Ba,c as Lc,d as kc,e as Jt,f as dn,g as yn,h as C,i as Ti,j as Ta,k ^ error: No matching export in "slop-empty:/home/runner/work/slopshop
README

ink-figure

A Claude Code output style and a mod that draws the figures it writes.

  • Style — Epistemic Ink, picked as the session's output style. It formats replies with Ink's phase headers, gates and insights, and decides when a reply needs a picture at all. It also flags, with a ↻ line, a departure that recurs against the same clause of an extension the user maintains.
  • Figure mod — draws, in the terminal transcript, the figures a reply cannot write as text, right where the fence was.

How the style and the mod work together

In every reply while the style is active, not only during a protocol run, it reaches for a fence wherever one fits. When the reader's task is taking in relations at once — a graph, a flow, states, a sequence, classes, entities — it writes a `mermaid fence; for measured values over an ordered axis, an xychart line chart (one series in whole units, the unit in the title, its scale stated); for quantities compared across items, one drawing on one scale (in text, a bar table); for a two-dimensional formula, a `math fence. It keeps a picture small enough to hold (about 12 nodes, 24 at most), never draws box art by hand, and names a focal node in the prose beside the fence, since node styling draws nothing. The mod then draws the fence:

FenceDrawn asWhat it is for
`mermaid flowchart/graph, sequence, class, state, ERbox arta computed diagram layout
`mermaid xychart with a line seriesan axis charta trend a sparkline cannot carry
`math (TeX)an image2-D structure: fractions, matrices, stacked scripts

Everything text can write stays text: bar charts, tables and shaded matrices (block characters, a stated scale, the harness's table columns), and flat expressions such as a + b = c or O(n log n). Every other mermaid kind keeps its fence.

One ui.render hook on AssistantMessage reads every fence in one pass, so a reply holding several figures draws whole.

The mod needs Claude Code v2.1.287 or later (mods on by default) and the interactive terminal. On any other surface, and for a fence that does not parse, is not a drawn kind, holds a statement outside the drawn grammar or is wider than the terminal, the fence is left as written. The Desktop app draws `math itself and shows other fences as code.

Where the fence is not drawn, it shows as written — the mermaid or TeX source, readable as it is; the style accepts that rather than fall back to hand-drawn art. The mod draws such fences under any output style, not only this one. When a turn ends, each fence of its reply that the terminal renderer would not draw is reported to the model with its own reason, and beside it any reason the whole reply was left as written, in a row the model reads and the reader does not see, so the figures it writes later fit what draws; the reply itself stands as written. The verdicts are the terminal's on every surface; where no terminal has drawn a reply, the row says the surface in use shows every fence as its source.

Install

claude plugin marketplace add jongwony/cc-plugin
claude plugin install ink-figure@cc-plugin

Then /reload-plugins in a running session. The mod draws as soon as the plugin is enabled; the style takes effect once it is picked — /output-style in a session, or in settings.json:

{ "outputStyle": "ink-figure:Epistemic Ink" }

Diagrams

Standard mermaid source, within the grammar below. A top-down flowchart or state diagram (a flowchart header with no direction is top-down, as in mermaid) is laid out left to right when no word of the drawing is lost and it fits the terminal or is no wider than the top-down layout; a flowchart written BT or LR keeps its direction. Spacing is compact: three columns between boxes and one cell inside them, left and right. A row that holds nothing but spaces and vertical lines running straight through it is taken out, so a box stands three rows tall and a vertical line keeps only the rows where it turns or ends; a line chart keeps every row, since its height is the measured scale.

Drawn grammar

The renderer reads more of mermaid than it draws faithfully, so a fence is drawn only when every statement is one of these forms; any other statement leaves the whole fence as written. Each form has a test showing its drawing keeps its labels, arrows and direction, and the drawing must still show every label whole and, for a flowchart or state diagram, every edge joined to the boxes it runs between: each line, corner, junction and arrowhead meets a stroke that runs on toward it, through a label lying on the edge, and no label sits on a box border.

KindDrawn forms
flowchartheader LR, TD, TB, BT or none; nodes A, A[text], A(text), A{text} (text quoted or not); one A --> B per line, optionally `-->\label\ (spaces inside it, padding trimmed); one edge per pair of nodes; style, classDef, class, click, linkStyle, accTitle:, accDescr:`
statedirection LR or TB; A --> B between states or [*], optionally : text; state "text" as A; A : text; one transition per pair of states
sequenceparticipant A, participant A as text; A->>B: text, A-->>B: text, a self-message included
classclass A, class A { … }, A : member: Type name, name, name(), name() Type, each with an optional + - # ~, a name once per class; `<\--, *--, o--, -->, ..>, ..\>, optionally : text`, as chains (no class above two others or below two, no cycle)
ERA ‹card›--‹card› B : label (-- or ..); A { type name … }; each entity in at most one relationship
xychartupright xychart/xychart-beta; title "text"; x-axis [a, b, …] with each category name bare or in double quotes (quoted, it may hold spaces and commas and is drawn without its quotes; single quotes are drawn as written); y-axis min --> max in integers; one line [ … ] of integers

A diagram that would stay top to bottom (a BT flowchart, a top-down one the sideways layout does not take, a state diagram with direction TB) is drawn only as one unlabelled chain: at one row between boxes a label or a branch draws over the box borders.

Outside the grammar, among others: subgraphs, composite states and every edge to them; graph RL; other edge shapes, chained edges and &; notes; sequence blocks (alt, opt, loop, …), activations, actor, autonumber, <br/> and arrows other than ->>/-->>; class methods with parameters, overloads, undirected relations, multiplicities, generics, annotations, namespaces and fan-outs; ER aliases, attribute keys and comments; a chart's axis titles, fractional values, bars, second series and horizontal; and a drawing whose title or category names would be cut or run together.

graph LR A[request] --> B[cache] B --> C[resp]

┌─────────┐   ┌───────┐   ┌──────┐
│         │   │       │   │      │
│ request ├──►│ cache ├──►│ resp │
│         │   │       │   │      │
└─────────┘   └───────┘   └──────┘

Labels are measured in screen cells, so Hangul and other double-width labels line up inside the boxes. The drawing here uses ASCII labels because a web page's monospace font does not give a Hangul character exactly two columns; in the terminal, where it does, Hangul labels such as 서울 요청 line up the same way.

Borders and junctions are drawn cyan, arrows yellow, lines dim, through element styles.

Line charts

A mermaid xychart (or xychart-beta) that holds one line series of integers is drawn on a y-axis with ticks and grid dots, its categories under the x-axis, the line in magenta. A value off its y-axis, or a series with more or fewer values than the categories, keeps its fence.

xychart-beta title "Latency" x-axis [mon, tue, wed, thu, fri] y-axis 0 --> 120 line [20, 35, 80, 60, 110]

The line is drawn as steps between the categories, on a plot at least 60 columns wide and 20 rows tall.

Math

A `math fence holds TeX (the base and ams packages) and is drawn as an image. Use it only where the structure is two-dimensional — a fraction, a matrix, a sum with stacked limits; a flat expression stays in the text.

\frac{a+b}{c} = \sqrt{x^2 + y^2}

  • The image is sized against an assumed terminal cell of 9 × 18 pixels at 16 pixels per em, since a mod cannot read the terminal's font metrics. On a terminal with another cell shape the formula is scaled to the same box of cells.
  • The ink follows the Claude Code theme: dark on a light* theme, light on a dark* theme. With auto, which follows the terminal, the ink is a middle grey that reads on either.
  • Claude Code draws the pixels where the terminal can (kitty, Ghostty); elsewhere the TeX source shows, dim, in its place.
  • Frames (\boxed) and array rules (|, \hline) are drawn as lines. Malformed TeX, an unknown macro, a dashed rule, \text holding a character the math font lacks (Hangul, for one; Latin \text{if } draws), or a line break \\ or \newline that MathJax draws as a space (anywhere but a table row: equation included) keeps the fence, as does a formula wider than the terminal, one drawn with a colour, a background, hidden parts or a stroked outline, any \pmb (each nesting doubles the work), any \DeclareMathOperator (a chain of operators built from earlier ones grows the same way; \operatorname draws), or any alignat or alignedat (its column count is allocated as written; aligned draws). Each fence is read on its own: an operator one fence declares does not reach the next. A single $$…$$ or \[…\] wrapper around the whole fence is ignored; a fence holding two display formulas keeps its fence.

Figure board

The Claude apps show a session's fences as source: following a terminal session from the mobile app or the Desktop app's Code tab, the app never asks the mod to draw. The figure board carries the figures there instead. With it on, the mod adds one section to the system prompt asking the model to keep this session's figures in one place the person can open away from the terminal — each figure with the paragraph that led into it and when, newest first. The medium is the model's choice (an Artifact page, a document, a deck), unless the person named one, and it stays the same place for the whole session, updated at the link it already has. Pin the place to keep it at hand.

The board is off by default. Turn it on from /config, the Figure board row. The section goes into the main loop's prompt while the Artifact tool is available to the model, listed or behind ToolSearch, in every session where the board is on: an interactive one, a headless run (-p, the SDK) and a cloud session alike. A teammate's prompt goes without it. Whether a reply publishes is the model's to judge, and the session's permission mode governs the publish itself.

In a cloud environment there is no /config to open, and a repository cannot supply the option: plugin options are read from user and managed settings only. The environment's Setup script sets it in the user settings with the plugin's own options command. Values go in as strings and are stored typed, so the boolean is written "true":

echo '{"figureBoard":"true"}' | claude plugin configure ink-figure@cc-plugin --values-stdin

This repository's scripts/cloud-setup.sh already runs that line and also sets the Epistemic Ink output style, so the Setup script field can be this one line:

curl -fsSL https://raw.githubusercontent.com/jongwony/cc-plugin/main/scripts/cloud-setup.sh | bash

A cloud session runs the plugins its environment's setup cache installed, so a new ink-figure version reaches cloud sessions only after the Setup script field changes and the cache is rebuilt. With the one-line field above, add or edit a comment line in it (# rebuild 2026-10-14, say) to force that rebuild without changing what it runs.

Limits

  • A diagram or chart wider than the terminal keeps its fence, as a formula does; it is drawn again when the terminal is widened enough to hold it.
  • A diagram past its size caps keeps its fence rather than holding the transcript while it is laid out: 60 nodes or 100 edges for a flowchart or state diagram; 20 participants or 150 messages for a sequence diagram; 40 classes or entities, 80 relationships or 400 members or attributes for a class or ER diagram; 120 values for a chart. So does one whose drawing would need a canvas over 250,000 cells (a label thousands of characters long between many boxes), and one with an edge the router gives up on, rather than drawing it as a straight line through the boxes between.
  • AssistantMessage is the finest site a mod can draw in, so a reply holding a figure is redrawn as Markdown pieces around it. A piece over 10,000 characters, or one carrying escape codes another mod wrote into the reply, makes the whole reply fall back to Claude Code's own drawing, and so does a link reference or footnote definition ([1]: …, its destination on the same line or the next), which the pieces would lose.
  • A fence counts as a figure when it is indented at most three spaces, as in CommonMark; one indented four is an indented code block and stays text. A fence inside a list item is drawn, and the text after it in that item follows as its own paragraph. A fence opened on a list item's or a block quote's own marker line (- ~~~, ` > ` `) is not drawn, and every fence inside it is its text.
  • A mermaid fence the renderer does not read whole keeps its source rather than drawing the rest: a Hangul flowchart or state ID (a Hangul label is fine), two statements on one line, or a class or entity left open at the end.
  • A label holding a combining mark, a joined emoji sequence, a flag, a skin-tone modifier, a one-cell character outside the Basic Multilingual Plane (𝐀, 🌡) or a control character such as a tab keeps its fence: the terminal draws those in another number of cells than the layout can count.

Renderers

  • Diagrams and charts: beautiful-mermaid 1.1.3 (MIT, hooks/vendor/LICENSE), bundled into hooks/vendor/mermaid-ascii.js with the patches in scripts/patches.mjs:
  • a bounded edge search, a work budget across a drawing's searches, and a node and edge count past which a flowchart is not laid out;
  • an edge's start junction placed on its box border — at tight spacing it landed inside the box, and a diamond's edge started a few cells away from it;
  • every statement read or the parse refused, so a fence is never drawn in part;
  • a node's or state's later text kept, as mermaid keeps it;
  • an ER relationship gap as wide as its label;
  • a routing row at least one cell tall, so a self-loop keeps its return;
  • a chart's bars grown from the axis end nearest zero when zero lies off the axis.

The kind table, the left-to-right flip and the role colouring are adapted from claude-mermaid (Gal Elmalah, MIT, hooks/vendor/LICENSE-claude-mermaid).

  • Math: MathJax 3.2.2 (Apache-2.0, hooks/vendor/LICENSE-mathjax) turns TeX into SVG outlines, bundled into hooks/vendor/math/; hooks/math.ts fills the outlines into pixels. The mod runtime has no WebAssembly and no eval, and reads no module file over 1 MiB, so the bundle is split into chunks under that size.

Build and test

hooks/vendor/mermaid-ascii.js and hooks/vendor/math/*.js are generated; rebuild them after changing scripts/patches.mjs, scripts/math-entry.mjs or a pinned renderer version (Node 22+). The build fails when a patch's anchor or target file has moved upstream, or a file would exceed 1 MiB.

cd ink-figure && npm install && npm run build:vendor
claude plugin test
Source 9 files
hooks/register.ts 171 lines
1import type { ApiContentBlock, EngineInterface, Register } from 'claude-code'
2import { BOARD_SECTION_ID, boardSectionOf } from './board.ts'
3import { SERIES_COLOURS, type Role, type Segment } from './diagrams.ts'
4import { fencesOf, piecesOf, type MathPicture } from './figures.ts'
5import { INK, inkOf, type Ink } from './math.ts'
6import { DEFAULT_COLUMNS, INLINE_MARGIN, reportOf } from './report.ts'
7
8// Every ```mermaid and ```math fence Claude writes is drawn where the fence was, on
9// the terminal: a diagram or chart as box art built from Text elements, a formula as
10// an Image. AssistantMessage is the finest site a mod gets, so a reply holding a
11// figure is redrawn as a column of its own: Markdown for the prose around each
12// fence, the figure in the fence's place. A fence that will not draw stays as
13// written; a reply with nothing to draw, or another surface, goes to Claude Code
14// untouched. When a turn ends, a fence of its reply that would not draw is reported to
15// the model in a row it reads and the person does not see as typed, so the figures it
16// writes later fit what draws. With the `figureBoard` option on, the main loop's
17// system prompt carries the figure board's instruction while the Artifact tool is
18// available to the model, listed or behind ToolSearch; a teammate's prompt goes
19// without it.
20
21// colour by role through element styles: the engine refuses escape sequences in text
22const STYLE: Record<Role, { color?: string; dimColor?: boolean }> = {
23  text: {},
24  border: { color: 'cyan' },
25  junction: { color: 'cyan' },
26  line: { dimColor: true },
27  corner: { dimColor: true },
28  arrow: { color: 'yellow' },
29  accent: { color: 'magenta' },
30}
31
32// the math ink for the current theme: read when the session starts, kept in step by
33// config.set on `theme` (the path /config and /theme both save through), and read on
34// demand only while still unknown; a read that fails settles on the ink that reads on
35// either theme. A read answers only while no theme change landed after it began:
36// `themeSet` counts those changes.
37let themeInk: Ink | null = null
38let themeSet = 0
39
40// the columns of the last terminal that drew a reply, and the main loop's response
41// text this turn, in order
42let terminalColumns: number | null = null
43let replyTexts: string[] = []
44
45const textsOf = (content: readonly ApiContentBlock[]): string[] => content.flatMap(b => (b.type === 'text' && typeof b.text === 'string' ? [b.text] : []))
46
47const readTheme = async ($: EngineInterface): Promise<Ink> => {
48  const began = themeSet
49  let ink: Ink
50  try {
51    ink = inkOf((await $.config.list()).find(row => row.key === 'theme')?.value)
52  } catch {
53    ink = INK.either
54  }
55  if (themeSet === began) themeInk = ink
56  return themeInk ?? ink
57}
58
59export const register: Register = (on, options) => {
60  const board = options?.figureBoard === true
61  // whether the engine lists the Artifact tool behind ToolSearch; null until it says
62  let isArtifactDeferred: boolean | null = null
63
64  if (board)
65    on('tool.describe', { tool: 'Artifact' }, async ($, e, next) => {
66      const result = await next(e)
67      isArtifactDeferred = (result.isDeferred ?? e.isDeferred) === true
68      return result
69    })
70
71  on('prompt.compose', async ($, e, next) => {
72    const result = await next(e)
73    // the main loop's prompt only: a teammate's render goes without it
74    if (!board || e.traits.includes('teammate')) return result
75    try {
76      const isOffered = e.tools.includes('Artifact')
77      if (!isOffered && isArtifactDeferred === null && !(await $.tool.list()).some(t => t.name === 'Artifact')) return result
78      const text = boardSectionOf(isArtifactDeferred === true || !isOffered)
79      return { ...result, sections: [...result.sections, { id: BOARD_SECTION_ID, text, scope: 'session' as const }] }
80    } catch (err) {
81      $.ui.log(`figure board instruction left out: ${err instanceof Error ? err.message : String(err)}`, { to: 'debug' })
82      return result
83    }
84  })
85
86  on('session.start', async ($, e, next) => {
87    const result = await next(e)
88    void readTheme($)
89    return result
90  })
91
92  on('config.set', { key: 'theme' }, async ($, e, next) => {
93    const result = await next(e)
94    if (result.deny === undefined) {
95      const ink = inkOf(result.value)
96      themeSet++
97      if (ink !== themeInk) {
98        themeInk = ink
99        $.ui.invalidate('ui.render')
100      }
101    }
102    return result
103  })
104
105  on('session.append', { door: 'response' }, async ($, e, next) => {
106    const result = await next(e)
107    // observing only: once next stored the row, nothing here may fail the hook
108    try {
109      if (e.agentId === undefined && result.message?.type === 'assistant') replyTexts.push(...textsOf(result.message.content))
110    } catch {}
111    return result
112  })
113
114  on('turn.start', async ($, e, next) => {
115    replyTexts = []
116    return next(e)
117  })
118
119  on('turn.complete', async ($, e, next) => {
120    const result = await next(e)
121    if (e.agentId !== undefined) return result
122    const texts = replyTexts
123    replyTexts = []
124    if (e.reason !== 'answer') return result
125    const text = reportOf(texts, terminalColumns, themeInk ?? INK.either)
126    if (text !== null) {
127      // a plugin above refuses the row by resolving { deny }; the bottom refuses a run
128      // no plugin may shape by rejecting. The reply stands either way; the debug log
129      // keeps why the report did not reach the model.
130      try {
131        const stored = await $.session.append({ message: { type: 'user', content: [{ type: 'text', text }] } })
132        if (stored.deny !== undefined) $.ui.log(`undrawn-figure report refused: ${stored.deny}`, { to: 'debug' })
133      } catch (err) {
134        $.ui.log(`undrawn-figure report refused: ${err instanceof Error ? err.message : String(err)}`, { to: 'debug' })
135      }
136    }
137    return result
138  })
139
140  on('ui.render', { component: 'AssistantMessage' }, async ($, e, next) => {
141    // the figures are terminal drawings; elsewhere the fence stays as Claude wrote it
142    if (e.surface !== 'terminal') return next(e)
143    const columns = e.viewport?.columns ?? DEFAULT_COLUMNS
144    terminalColumns = columns
145    const text = e.props.text.replace(/\r\n?/g, '\n')
146    const fences = fencesOf(text)
147    if (fences.length === 0) return next(e)
148    const math = fences.some(f => f.lang === 'math')
149    const ink = themeInk ?? (math ? await readTheme($) : INK.either)
150    const pieces = piecesOf(text, columns - INLINE_MARGIN, ink, fences)
151    if (!pieces) return next(e)
152    const { Box, Text, Markdown, Image } = $.ui.resolve(e)
153
154    const spanOf = ({ text, role, series }: Segment) =>
155      Text({ ...STYLE[role ?? 'text'], ...(series ? { color: SERIES_COLOURS[series - 1] } : {}), children: [text] })
156    const diagram = ({ lines }: { lines: Segment[][] }) =>
157      Box({
158        flexDirection: 'column',
159        children: lines.map(line => (line.length === 0 ? Text({ children: [' '] }) : Box({ flexDirection: 'row', children: line.map(spanOf) }))),
160      })
161    const formula = ({ rgba, width, height, columns, rows, tex }: MathPicture) =>
162      Image({ source: { rgba, width, height }, columns, rows, alt: tex })
163
164    return Box({
165      flexDirection: 'column',
166      rowGap: 1,
167      children: pieces.map(p => ('diagram' in p ? diagram(p.diagram) : 'math' in p ? formula(p.math) : Markdown({ text: p.markdown }))),
168    })
169  })
170}
171
hooks/board.ts 15 lines
1// The figure board's instruction: one system-prompt section the model reads while
2// the `figureBoard` option is on and the Artifact tool is available to it. The model
3// chooses the board's medium and keeps it.
4
5export const BOARD_SECTION_ID = 'ink-figure:board'
6
7export const boardSectionOf = (isArtifactDeferred = false): string =>
8  [
9    '# Figure board',
10    '',
11    'This session keeps the figures it draws in one place the person can open away from the terminal.',
12    'When a reply to the person draws a figure as a ```mermaid or ```math fence, add the figure there before writing the reply\'s final text, with the paragraph that leads into it and the time, newest first, keeping what is already there. A fence shown as an example or as syntax is not a drawn figure.',
13    `The medium and how it presents each figure are yours to choose so the figure is understood, unless the person named a medium; keep using the same place for the whole session, updating it at the link it already has.${isArtifactDeferred ? ' The Artifact tool is deferred: load it through ToolSearch first.' : ''}`,
14  ].join('\n')
15
hooks/diagrams.ts 458 lines
1import { faithfulTo, grammarOf } from './grammar.ts'
2import { renderMermaidAscii } from './vendor/mermaid-ascii.js'
3
4// Pure functions over mermaid sources: drawing them as role-tagged box art with East
5// Asian labels measured in screen cells, and choosing the layout for a width. No `$`,
6// so the tests drive these directly.
7// The kind table, LR flip and the sentinel-colour role recovery are adapted from
8// claude-mermaid (Gal Elmalah, MIT; notice in vendor/LICENSE-claude-mermaid).
9
10export type Role = 'text' | 'border' | 'line' | 'arrow' | 'corner' | 'junction' | 'accent'
11// `series`: a chart series after the first, numbered from 1 in the order its colour
12// first appears in the art (the legend, left to right)
13export type Segment = { text: string; role: Role | null; series?: number }
14// `vertical`: the source drew nothing only because it would be laid out top to bottom
15// with a label or a branch, which the compact vertical spacing draws over
16export type Rendered = { lines: Segment[][] } | { error: string; vertical?: true }
17
18export const SPACING = { paddingX: 3, paddingY: 1, boxBorderPadding: 1 } as const
19
20// a chart's later series, in turn, in colours that read on light and dark themes
21// alike; the first series takes the accent colour, and a chart with more keeps its fence
22export const SERIES_COLOURS = ['green', 'blue', 'red'] as const
23
24const KINDS: [RegExp, string][] = [
25  [/^(flowchart|graph)\b/i, 'flowchart'],
26  [/^sequenceDiagram/i, 'sequence'],
27  [/^classDiagram/i, 'class'],
28  [/^stateDiagram/i, 'state'],
29  [/^erDiagram/i, 'er'],
30  [/^xychart(-beta)?\b/i, 'xychart'],
31]
32
33export const DRAWN_KINDS: ReadonlySet<string> = new Set(KINDS.map(([, kind]) => kind))
34
35// the header: the first line that is neither blank nor a `%%` comment, as offsets
36const headerAt = (source: string): { start: number; end: number } | null => {
37  let at = 0
38  for (const line of source.split('\n')) {
39    const trimmed = line.trim()
40    if (trimmed !== '' && !trimmed.startsWith('%%')) return { start: at, end: at + line.length }
41    at += line.length + 1
42  }
43  return null
44}
45
46const headerOf = (source: string): string => {
47  const header = headerAt(source)
48  return header ? source.slice(header.start, header.end).trim() : ''
49}
50
51const withHeader = (source: string, header: { start: number; end: number }, line: string): string =>
52  source.slice(0, header.start) + line + source.slice(header.end)
53
54export const kindOf = (source: string): string => KINDS.find(([pattern]) => pattern.test(headerOf(source)))?.[1] ?? 'diagram'
55
56export const MAX_SOURCE_CHARS = 12_000
57
58// a flowchart header with no direction takes mermaid's default, top to bottom, which
59// the renderer needs spelled out
60const directed = (source: string): string => {
61  const header = headerAt(source)
62  if (!header) return source
63  const line = source.slice(header.start, header.end)
64  if (!/^\s*(flowchart|graph)\s*;?\s*$/i.test(line)) return source
65  return withHeader(source, header, `${line.replace(/\s*;?\s*$/, '')} TD`)
66}
67
68// a flowchart edge label written with padding, `-->| yes |`, is the label `yes`
69const PADDED_LABEL = /-->([ \t]*)\|[ \t]*([^|\n]*?)[ \t]*\|/g
70const trimmedLabels = (source: string): string => source.replace(PADDED_LABEL, (_, gap: string, label: string) => `-->${gap}|${label}|`)
71
72// an xychart is drawn only when it holds a line: bars are written as text
73const LINE_SERIES = /^[ \t]*line\b/m
74
75// a flowchart written top-down or bottom-up, or a state diagram with no `direction
76// LR`, as the renderer would lay it out before any sideways turn
77const verticalOf = (source: string, kind: string): boolean => {
78  if (kind === 'flowchart') return /^\s*(?:flowchart|graph)\s+(?:TD|TB|BT)\b/i.test(headerOf(source))
79  if (kind === 'state') return !/^\s*direction\s+LR\s*$/im.test(source)
80  return false
81}
82
83export const leftToRightOf = (source: string): string | null => {
84  const kind = kindOf(source)
85  const header = headerAt(source)
86  if (!header) return null
87  const line = source.slice(header.start, header.end)
88  if (kind === 'flowchart') {
89    const parts = /^(\s*(?:flowchart|graph))(?:\s+(TD|TB|BT|LR|RL))?\b(.*)$/i.exec(line)
90    if (!parts || (parts[2] && !/^(TD|TB)$/i.test(parts[2]))) return null
91    return withHeader(source, header, `${parts[1]} LR${parts[3]}`)
92  }
93  if (kind === 'state') {
94    if (/^\s*direction\s+/im.test(source)) return null
95    return withHeader(source, header, `${line}\n  direction LR`)
96  }
97  return null
98}
99
100// East Asian Wide and Fullwidth ranges (UAX #11), the ones labels meet in practice,
101// and emoji drawn as pictures by default. Ambiguous-width characters, box-drawing
102// included, stay one cell.
103const EMOJI = /\p{Emoji_Presentation}/u
104export const isWide = (cp: number): boolean =>
105  (cp >= 0x1100 && cp <= 0x115f) ||
106  (cp >= 0x2329 && cp <= 0x232a) ||
107  (cp >= 0x2e80 && cp <= 0xa4cf && cp !== 0x303f && !(cp >= 0x3248 && cp <= 0x324f) && !(cp >= 0x4dc0 && cp <= 0x4dff)) ||
108  (cp >= 0xa960 && cp <= 0xa97f) ||
109  (cp >= 0xac00 && cp <= 0xd7a3) ||
110  (cp >= 0xf900 && cp <= 0xfaff) ||
111  (cp >= 0xfe10 && cp <= 0xfe19) ||
112  (cp >= 0xfe30 && cp <= 0xfe6f) ||
113  (cp >= 0xff00 && cp <= 0xff60) ||
114  (cp >= 0xffe0 && cp <= 0xffe6) ||
115  (cp >= 0x16fe0 && cp <= 0x16fe4) ||
116  (cp >= 0x17000 && cp <= 0x18cff) ||
117  (cp >= 0x1b000 && cp <= 0x1b2ff) ||
118  (cp >= 0x1f200 && cp <= 0x1f265) ||
119  (cp >= 0x20000 && cp <= 0x3fffd) ||
120  EMOJI.test(String.fromCodePoint(cp))
121
122export const cellsOf = (cp: number): number => (isWide(cp) ? 2 : 1)
123
124export const displayWidth = (s: string): number => {
125  let n = 0
126  for (const c of s) n += cellsOf(c.codePointAt(0)!)
127  return n
128}
129
130// The renderer lays out one UTF-16 unit per grid cell, so a code point takes as
131// many cells as it has units. A wide character in the Basic Multilingual Plane
132// goes in followed by a private-use placeholder, so the layout counts it as the
133// two cells the terminal gives it; the placeholder comes out of the art again.
134// An astral character already has two units. A code point the terminal draws in
135// fewer cells than its units — a combining mark, a joiner, a modifier or flag
136// half that merges with its neighbour, an astral character one cell wide — cannot
137// be laid out, and neither can a source that already holds the placeholder or the
138// vendor's label-space placeholder (U+E001, scripts/patches.mjs), nor a control
139// character (a tab, an escape) inside a statement, which the terminal draws in some
140// other number of cells or not at all.
141const CELL = '\uE000'
142const UNPLACEABLE = /[\p{M}\p{Cf}\u1160-\u11ff\ud7b0-\ud7ff\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\uE000\ue001]/u
143const CONTROL = /\p{Cc}/u
144const unplaceableOf = (source: string): string | undefined => {
145  const mark = UNPLACEABLE.exec(source)?.[0]
146  if (mark) return mark
147  for (const line of source.split('\n')) {
148    const control = CONTROL.exec(line.trim())?.[0]
149    if (control) return control
150  }
151  for (const c of source) if (c.codePointAt(0)! > 0xffff && !isWide(c.codePointAt(0)!)) return c
152  return undefined
153}
154const widened = (source: string): string => {
155  let out = ''
156  for (const c of source) {
157    const cp = c.codePointAt(0)!
158    out += cp <= 0xffff && isWide(cp) ? c + CELL : c
159  }
160  return out
161}
162
163const ROLES: readonly Role[] = ['text', 'border', 'line', 'arrow', 'corner', 'junction', 'accent']
164const sentinel = (role: Role) => `#00000${ROLES.indexOf(role) + 1}`
165const ROLE_THEME = {
166  fg: sentinel('text'),
167  border: sentinel('border'),
168  line: sentinel('line'),
169  arrow: sentinel('arrow'),
170  corner: sentinel('corner'),
171  junction: sentinel('junction'),
172  accent: sentinel('accent'),
173  bg: '#000000',
174}
175
176// the renderer emits colour only as SGR escapes; a theme of sentinel colours turns
177// each escape back into the role it stood for, and no escape leaves this module
178const SGR = /\x1b\[([0-9;]*)m/g
179const SENTINEL_SGR = /^38;2;0;0;(\d)$/
180const TRUECOLOR_SGR = /^38;2;\d+;\d+;\d+$/
181
182// every wide character in the art still has its placeholder right after it, and every
183// placeholder its wide character right before it; a cell the renderer overwrote
184// breaks the pair, and stripping the placeholders would shift the rest of the row
185const pairedOf = (art: string): boolean => {
186  for (const line of art.replace(SGR, '').split('\n')) {
187    let wide = false
188    for (const c of line) {
189      if (c === CELL) {
190        if (!wide) return false
191        wide = false
192        continue
193      }
194      if (wide) return false
195      const cp = c.codePointAt(0)!
196      wide = cp <= 0xffff && isWide(cp)
197    }
198    if (wide) return false
199  }
200  return true
201}
202
203const sameStyle = (a: Segment, role: Role | null, series: number | undefined) => a.role === role && a.series === series
204
205// `palette` numbers each non-sentinel colour of one drawing in order of first appearance
206const segmentsOf = (line: string, palette: Map<string, number>): Segment[] => {
207  const out: Segment[] = []
208  const push = (text: string, role: Role | null, series: number | undefined) => {
209    text = text.replaceAll(CELL, '')
210    if (text === '') return
211    const last = out[out.length - 1]
212    if (last && sameStyle(last, role, series)) last.text += text
213    else out.push(series === undefined ? { text, role } : { text, role, series })
214  }
215  let role: Role | null = null
216  let series: number | undefined
217  let cursor = 0
218  for (const match of line.matchAll(SGR)) {
219    const at = match.index ?? 0
220    push(line.slice(cursor, at), role, series)
221    const params = match[1] ?? ''
222    const found = SENTINEL_SGR.exec(params)
223    if (found) {
224      role = ROLES[Number(found[1]) - 1] ?? null
225      series = undefined
226    } else if (TRUECOLOR_SGR.test(params)) {
227      if (!palette.has(params)) palette.set(params, palette.size + 1)
228      role = 'accent'
229      series = palette.get(params)
230    } else if (params === '0' || params === '') {
231      role = null
232      series = undefined
233    }
234    cursor = at + match[0].length
235  }
236  push(line.slice(cursor), role, series)
237  // spaces between the words of one label keep the label one span
238  const joined: Segment[] = []
239  for (const seg of out) {
240    const prev = joined[joined.length - 1]
241    const before = joined[joined.length - 2]
242    if (seg.role === 'text' && prev && prev.role === null && /^ +$/.test(prev.text) && before?.role === 'text') {
243      joined.pop()
244      before.text += prev.text + seg.text
245    } else joined.push({ ...seg })
246  }
247  return joined
248}
249
250export const plainOf = (line: readonly Segment[]): string => line.map(s => s.text).join('')
251
252const trimEnd = (line: Segment[]): Segment[] => {
253  const out = line.map(s => ({ ...s }))
254  while (out.length > 0) {
255    const last = out[out.length - 1]!
256    last.text = last.text.replace(/ +$/, '')
257    if (last.text !== '') break
258    out.pop()
259  }
260  return out
261}
262
263// A row holding nothing but spaces and vertical strokes, each stroke continued in the
264// rows above and below it, carries no topology: the padding inside a box above and
265// below its label, and a straight run of a vertical line. Such rows come out, one at
266// a time, until none is left; a row with a label, an arrowhead, a corner, a junction
267// or a horizontal stroke stays. A chart keeps every row: its height is a drawn length.
268const STROKE = new Set(['│', '|'])
269const FROM_ABOVE = new Set(['│', '┌', '┐', '╭', '╮', '┬', '├', '┤', '┼', '|', '+'])
270const TO_BELOW = new Set(['│', '└', '┘', '╰', '╯', '┴', '├', '┤', '┼', '|', '+'])
271
272const cellRowOf = (line: readonly Segment[]): string[] => {
273  const cells: string[] = []
274  for (const c of plainOf(line)) {
275    cells.push(c)
276    if (cellsOf(c.codePointAt(0)!) === 2) cells.push('')
277  }
278  return cells
279}
280
281export const compacted = (lines: readonly Segment[][]): Segment[][] => {
282  const out = [...lines]
283  let i = 1
284  while (i < out.length - 1) {
285    const row = cellRowOf(out[i]!)
286    const above = cellRowOf(out[i - 1]!)
287    const below = cellRowOf(out[i + 1]!)
288    const empty =
289      row.some(c => STROKE.has(c)) &&
290      row.every((c, j) => c === ' ' || (STROKE.has(c) && FROM_ABOVE.has(above[j] ?? ' ') && TO_BELOW.has(below[j] ?? ' ')))
291    if (empty) {
292      out.splice(i, 1)
293      i = Math.max(1, i - 1)
294    } else i++
295  }
296  return out
297}
298
299// A flowchart or state drawing joins every edge to the boxes it runs between. Each
300// cell of an edge (a line, a corner, a junction or an arrowhead, by the role the
301// renderer drew it in) reaches out on the sides its glyph opens to, and the cell there
302// must open back toward it, or be a box's border, which an edge meets on any side; a
303// label on the edge is passed through along the edge's own axis, so a stroke that runs
304// into a label it does not run through is loose. An arrowhead is fed on some side other
305// than its tip, and its tip needs only a mark to land on. An ASCII `+`, `.` or `'` stands
306// for any corner or crossing, so it needs two sides joined, not all four. A label drawn
307// between two strokes of a box border sits on the box rather than its edge. Box borders
308// and the text inside boxes are the boxes' own and are not read.
309type Side = 'U' | 'D' | 'L' | 'R'
310const STEP: Record<Side, readonly [number, number]> = { U: [-1, 0], D: [1, 0], L: [0, -1], R: [0, 1] }
311const BACK: Record<Side, Side> = { U: 'D', D: 'U', L: 'R', R: 'L' }
312const OPENS: Record<string, string> = {
313  '─': 'LR', '│': 'UD', '┌': 'RD', '┐': 'LD', '└': 'UR', '┘': 'UL', '╭': 'RD', '╮': 'LD', '╰': 'UR', '╯': 'UL',
314  '├': 'UDR', '┤': 'UDL', '┬': 'LRD', '┴': 'LRU', '┼': 'UDLR',
315  '-': 'LR', '|': 'UD', '+': 'UDLR', '.': 'UDLR', "'": 'UDLR',
316}
317// an arrowhead opens back toward its tail and points at its tip
318const ARROW: Record<string, readonly [Side, Side]> = {
319  '►': ['L', 'R'], '>': ['L', 'R'], '◄': ['R', 'L'], '<': ['R', 'L'],
320  '▼': ['U', 'D'], 'v': ['U', 'D'], '▲': ['D', 'U'], '^': ['D', 'U'],
321}
322const EDGE_ROLES: ReadonlySet<Role> = new Set(['line', 'corner', 'junction', 'arrow'])
323const ANY_CORNER = new Set(['+', '.', "'"])
324const SIDES: readonly Side[] = ['U', 'D', 'L', 'R']
325type Cell = { c: string; role: Role | null }
326
327const cellGridOf = (lines: readonly (readonly Segment[])[]): Cell[][] =>
328  lines.map(line => {
329    const cells: Cell[] = []
330    for (const seg of line)
331      for (const c of seg.text) {
332        cells.push({ c, role: seg.role })
333        if (cellsOf(c.codePointAt(0)!) === 2) cells.push({ c: '', role: seg.role })
334      }
335    return cells
336  })
337
338const opensOf = (cell: Cell): string => (cell.role === 'arrow' ? (ARROW[cell.c] ?? ['', ''])[0] : (OPENS[cell.c] ?? ''))
339
340export const looseEndOf = (lines: readonly (readonly Segment[])[]): string | null => {
341  const grid = cellGridOf(lines)
342  const at = (r: number, j: number): Cell | undefined => grid[r]?.[j]
343  const answers = (r: number, j: number, side: Side): boolean => {
344    const [dr, dj] = STEP[side]
345    let rr = r + dr, jj = j + dj
346    // through a label lying on the edge, along the edge's axis
347    while (at(rr, jj)?.role === 'text') { rr += dr; jj += dj }
348    const next = at(rr, jj)
349    if (!next || next.c === ' ' || next.c === '') return false
350    if (next.role === 'border') return true
351    // an arrowhead is fed on any side; its own check holds it to one
352    if (next.role === 'arrow') return true
353    return (OPENS[next.c] ?? '').includes(BACK[side])
354  }
355  for (let r = 0; r < grid.length; r++) {
356    const row = grid[r]!
357    for (let j = 0; j < row.length; j++) {
358      const cell = row[j]!
359      if (cell.role === 'text' && (j === 0 || row[j - 1]!.role !== 'text')) {
360        let k = j
361        while (row[k + 1]?.role === 'text') k++
362        const left = row[j - 1], right = row[k + 1]
363        if (left?.role === 'border' && right?.role === 'border' && OPENS[left.c]?.includes('R') && OPENS[right.c]?.includes('L'))
364          return `a label drawn on a box border at row ${r + 1}, column ${j + 1}`
365        continue
366      }
367      if (cell.role === null || !EDGE_ROLES.has(cell.role)) continue
368      const loose = `an edge drawn detached at row ${r + 1}, column ${j + 1}`
369      if (cell.role === 'arrow') {
370        const tip = ARROW[cell.c]?.[1]
371        if (tip === undefined) continue
372        const [dr, dj] = STEP[tip]
373        const landing = at(r + dr, j + dj)
374        if (!landing || landing.c === ' ' || landing.c === '' || !SIDES.some(side => side !== tip && answers(r, j, side))) return loose
375        continue
376      }
377      if (ANY_CORNER.has(cell.c)) {
378        if (SIDES.filter(side => answers(r, j, side)).length < 2) return loose
379        continue
380      }
381      for (const side of opensOf(cell) as Iterable<Side>) if (!answers(r, j, side)) return loose
382    }
383  }
384  return null
385}
386
387export const renderOf = (source: string, useAscii = false): Rendered => {
388  const kind = kindOf(source)
389  if (!DRAWN_KINDS.has(kind)) return { error: `${kind} diagrams are not drawn` }
390  if (kind === 'xychart' && !LINE_SERIES.test(source)) return { error: 'a chart with no line series is written as text' }
391  if (source.length > MAX_SOURCE_CHARS) return { error: `too big to draw (${source.length} characters)` }
392  const composed = (kind === 'flowchart' ? trimmedLabels(directed(source)) : directed(source)).normalize('NFC')
393  const unplaceable = unplaceableOf(composed)
394  if (unplaceable) return { error: `U+${unplaceable.codePointAt(0)!.toString(16).toUpperCase()} cannot be laid out in cells` }
395  const grammar = grammarOf(composed, kind)
396  if ('error' in grammar) return grammar
397  if (!grammar.chain && verticalOf(composed, kind)) return { error: 'a top-down drawing with a label or a branch', vertical: true }
398  try {
399    const art = renderMermaidAscii(widened(composed), { useAscii, ...SPACING, colorMode: 'truecolor', theme: ROLE_THEME })
400    if (!pairedOf(art)) return { error: 'the layout drew over a wide character' }
401    const palette = new Map<string, number>()
402    let lines = art.split('\n').map(line => trimEnd(segmentsOf(line, palette)))
403    if (palette.size > SERIES_COLOURS.length) return { error: `${palette.size + 1} series, more than the colours that read on every theme` }
404    while (lines.length > 0 && lines[lines.length - 1]!.length === 0) lines.pop()
405    while (lines.length > 0 && lines[0]!.length === 0) lines.shift()
406    if (lines.length === 0 || lines.every(l => plainOf(l).trim() === '')) return { error: 'nothing to draw' }
407    if (kind !== 'xychart') lines = compacted(lines)
408    const unfaithful = faithfulTo(grammar, lines.map(plainOf)) ?? (kind === 'flowchart' || kind === 'state' ? looseEndOf(lines) : null)
409    return unfaithful ? { error: unfaithful } : { lines }
410  } catch (err) {
411    return { error: err instanceof Error ? err.message : String(err) }
412  }
413}
414
415export const widthOf = (lines: readonly (readonly Segment[])[]): number =>
416  lines.reduce((max, line) => Math.max(max, displayWidth(plainOf(line))), 0)
417
418const tokensOf = (lines: readonly (readonly Segment[])[]): Map<string, number> => {
419  const out = new Map<string, number>()
420  for (const line of lines) for (const token of plainOf(line).match(/[\p{L}\p{N}_+#-]+/gu) ?? []) out.set(token, (out.get(token) ?? 0) + 1)
421  return out
422}
423
424// the sideways layout wins when every word of the original survives and it fits,
425// or is at least no wider than the original
426export const pickLayout = (base: Rendered, sideways: Rendered, columns: number): Rendered => {
427  if (!('lines' in base) || !('lines' in sideways)) return base
428  const have = tokensOf(sideways.lines)
429  for (const [token, count] of tokensOf(base.lines)) if ((have.get(token) ?? 0) < count) return base
430  const width = widthOf(sideways.lines)
431  return width <= columns || width <= widthOf(base.lines) ? sideways : base
432}
433
434// Both layouts a source can take, neither depending on the room; the sideways one
435// is tried only when the source's own layout drew, or would have drawn but for its
436// vertical spacing. `layouts.runs` counts calls.
437export type Layouts = { base: Rendered; sideways: Rendered | null }
438export const layouts = { runs: 0 }
439export const layoutsOf = (source: string): Layouts => {
440  layouts.runs++
441  const base = renderOf(source)
442  if ('error' in base && !base.vertical) return { base, sideways: null }
443  const sideways = leftToRightOf(source)
444  return { base, sideways: sideways ? renderOf(sideways) : null }
445}
446
447export const chosenOf = ({ base, sideways }: Layouts, columns: number): Rendered => {
448  if (!sideways) return base
449  if ('error' in base) return 'lines' in sideways ? sideways : base
450  return pickLayout(base, sideways, columns)
451}
452
453// a drawing wider than the room keeps its fence: a cut drawing would leave out boxes
454export const fitsIn = (art: Rendered, columns: number): art is { lines: Segment[][] } =>
455  'lines' in art && widthOf(art.lines) <= columns
456
457export const drawn = (source: string, columns: number): Rendered => chosenOf(layoutsOf(source), columns)
458
hooks/figures.ts 206 lines
1import { chosenOf, fitsIn, kindOf, layoutsOf, widthOf, type Layouts, type Segment } from './diagrams.ts'
2import { INK, MAX_CELLS, mathLayoutOf, mathOf, type Ink } from './math.ts'
3
4// One pass over a reply: every ```mermaid and ```math fence, in order, with the
5// prose between them kept as Markdown.
6
7export type MathPicture = { rgba: string; width: number; height: number; columns: number; rows: number; tex: string }
8export type Piece = { markdown: string } | { diagram: { lines: Segment[][] } } | { math: MathPicture }
9export type FenceBlock = { lang: 'mermaid' | 'math'; start: number; end: number; source: string }
10// Why a fence draws or not on its own: its kind (a mermaid diagram's header kind, or
11// `math`), that it draws (with its figure, unless only measured), or the reason it
12// stays as written and, for a figure that drew too wide, its width in cells.
13export type FenceVerdict = { kind: string; drawn: true; piece?: Piece } | { kind: string; drawn: false; reason: string; cells?: number }
14// The reply's verdict: one per fence in order, each its own; `held`, the reason the
15// whole reply is left as written even where a fence would draw, or null; and the
16// pieces the reply is drawn as, null when the caller leaves the message untouched or
17// the verdict was only measured.
18export type ReplyVerdict = { fences: FenceVerdict[]; held: string | null; pieces: Piece[] | null }
19
20// Markdown element limit per chunk
21export const MAX_MARKDOWN_CHARS = 10_000
22
23// Markdown takes tab and newline as its only control characters
24const DRAWABLE = /^[^\x00-\x08\x0b-\x1f\x7f]*$/
25// a link reference or footnote definition, which applies across the whole reply; its
26// destination may stand on the next line
27const DEFINITION = /^ {0,3}\[[^\]\n]+\]:/m
28
29const FENCE_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/
30// a fence opened after a list item's or a block quote's marker
31const CONTAINER_FENCE = /^ {0,3}(?:(?:[-*+]|\d{1,9}[.)])[ \t]+|>[ \t]?)+ {0,3}(`{3,}|~{3,})(.*)$/
32// a fence closing one opened in a container, at the container's indent or marker
33const CONTAINER_CLOSE = /^[ \t]*(?:>[ \t]?)*[ \t]*(`{3,}|~{3,})[ \t]*$/
34const LANG = /^[ \t]*(mermaid|math)(?![\w-])/i
35
36const opens = (fence: RegExpExecArray | null): fence is RegExpExecArray => fence !== null && !(fence[1]!.startsWith('`') && fence[2]!.includes('`'))
37
38// Fenced code blocks as CommonMark reads them: a fence line is indented at most
39// three spaces, and closes on the same character, at least as long, with nothing
40// after it. A mermaid or math fence on a line of its own, at 0–3 spaces (a list
41// item's indented content included), that opens while no other fence is open is a
42// figure. A fence opened on a list item's or block quote's marker line is tracked
43// so that a fence inside it stays its text, and is never drawn itself.
44export const fencesOf = (text: string): FenceBlock[] => {
45  const blocks: FenceBlock[] = []
46  let open: { mark: string; start: number; body: number; lang: FenceBlock['lang'] | null; container: boolean } | null = null
47  let at = 0
48  for (const line of text.split('\n')) {
49    const next = at + line.length + 1
50    const fence = FENCE_LINE.exec(line)
51    if (open === null) {
52      if (opens(fence)) {
53        const lang = LANG.exec(fence[2]!)?.[1]?.toLowerCase() as FenceBlock['lang'] | undefined
54        open = { mark: fence[1]!, start: at, body: next, lang: lang ?? null, container: false }
55      } else {
56        const contained = CONTAINER_FENCE.exec(line)
57        if (opens(contained)) open = { mark: contained[1]!, start: at, body: next, lang: null, container: true }
58      }
59    } else if (open.container) {
60      const close = CONTAINER_CLOSE.exec(line)
61      if (close && close[1]![0] === open.mark[0] && close[1]!.length >= open.mark.length) open = null
62    } else if (fence && fence[1]![0] === open.mark[0] && fence[1]!.length >= open.mark.length && fence[2]!.trim() === '') {
63      const source = text.slice(open.body, Math.max(open.body, at - 1)).replace(/\r\n?/g, '\n').trim()
64      if (open.lang && source !== '') blocks.push({ lang: open.lang, start: open.start, end: at + line.length, source })
65      open = null
66    }
67    at = next
68  }
69  return blocks
70}
71
72// Drawn figures by fence, so a streaming reply draws only the fence that changed;
73// least recently used first out, within a count and a byte budget.
74const CACHE_LIMIT = 200
75const CACHE_BYTES = 16 * 1024 * 1024
76type Drawing = { layouts: Layouts } | { math: MathPicture | { error: string } }
77const figures = new Map<string, { drawing: Drawing; bytes: number }>()
78let cachedBytes = 0
79
80export const fenceKindOf = (block: FenceBlock): string => (block.lang === 'math' ? 'math' : kindOf(block.source))
81
82const WIDE = 'wider than the room'
83
84// Neither drawing depends on the room: a diagram's layouts are kept by source and
85// chosen for the room after the lookup, and a formula is drawn once at the widest
86// an Image takes; either one wider than the room keeps its fence. A measured verdict
87// reads the cache but never fills it, and lays a formula out without filling a pixel.
88const verdictOf = (block: FenceBlock, columns: number, ink: Ink, measure: boolean): FenceVerdict => {
89  const kind = fenceKindOf(block)
90  if (measure && block.lang === 'math' && !figures.has(keyOf(block, ink))) {
91    const layout = mathLayoutOf(block.source, MAX_CELLS)
92    if ('error' in layout) return { kind, drawn: false, reason: layout.error }
93    return layout.columns <= columns ? { kind, drawn: true } : { kind, drawn: false, reason: WIDE, cells: layout.columns }
94  }
95  const drawing = cachedDrawingOf(block, ink, !measure)
96  if ('layouts' in drawing) {
97    const art = chosenOf(drawing.layouts, columns)
98    if ('error' in art) return { kind, drawn: false, reason: art.error }
99    const { lines } = art
100    return fitsIn(art, columns) ? { kind, drawn: true, piece: { diagram: { lines } } } : { kind, drawn: false, reason: WIDE, cells: widthOf(lines) }
101  }
102  if ('error' in drawing.math) return { kind, drawn: false, reason: drawing.math.error }
103  return drawing.math.columns <= columns
104    ? { kind, drawn: true, piece: { math: drawing.math } }
105    : { kind, drawn: false, reason: WIDE, cells: drawing.math.columns }
106}
107
108const keyOf = (block: FenceBlock, ink: Ink): string =>
109  (block.lang === 'mermaid' ? [block.lang, block.source] : [block.lang, ink.join(','), block.source]).join('\u0000')
110
111// the figures held for the drawing, for a test to read
112export const cached = () => ({ count: figures.size, bytes: cachedBytes })
113
114const cachedDrawingOf = (block: FenceBlock, ink: Ink, store: boolean): Drawing => {
115  const key = keyOf(block, ink)
116  const hit = figures.get(key)
117  if (hit) {
118    figures.delete(key)
119    figures.set(key, hit)
120    return hit.drawing
121  }
122  let drawing: Drawing
123  if (block.lang === 'mermaid') drawing = { layouts: layoutsOf(block.source) }
124  else {
125    const art = mathOf(block.source, MAX_CELLS, ink)
126    drawing = { math: 'rgba' in art ? { ...art, rgba: art.rgba.toBase64(), tex: block.source } : { error: art.error } }
127  }
128  if (!store) return drawing
129  const bytes = 'math' in drawing && 'rgba' in drawing.math ? drawing.math.rgba.length : 0
130  figures.set(key, { drawing, bytes })
131  cachedBytes += bytes
132  while (figures.size > CACHE_LIMIT || cachedBytes > CACHE_BYTES) {
133    const [oldest, entry] = figures.entries().next().value!
134    figures.delete(oldest)
135    cachedBytes -= entry.bytes
136  }
137  return drawing
138}
139
140const pushMarkdown = (pieces: Piece[], text: string) => {
141  if (text.trim() !== '') pieces.push({ markdown: text.replace(/^\n+/, '').replace(/\n+$/, '') })
142}
143
144const handable = (markdown: string): boolean => markdown.length <= MAX_MARKDOWN_CHARS && DRAWABLE.test(markdown)
145
146const PROSE_UNHANDABLE = `the prose around the fences holds a control character or a run over ${MAX_MARKDOWN_CHARS} characters`
147const JOINED_UNHANDABLE = `an undrawn fence's source joined to the prose beside it holds a control character or a run over ${MAX_MARKDOWN_CHARS} characters`
148
149// What keeps a whole reply as written before any figure is weighed: a definition its
150// pieces would lose, or prose between the fences that cannot be handed to Markdown.
151const heldOf = (text: string, blocks: readonly FenceBlock[]): string | null => {
152  if (DEFINITION.test(text)) return 'the reply holds a link reference or footnote definition'
153  let gap = 0
154  for (const block of blocks) {
155    if (!handable(text.slice(gap, block.start).trim())) return PROSE_UNHANDABLE
156    gap = block.end
157  }
158  return handable(text.slice(gap).trim()) ? null : PROSE_UNHANDABLE
159}
160
161// The reply's verdict: each fence's own verdict, always, so a reason that keeps the
162// whole reply as written is reported beside a fence's reason and never in its place;
163// then the markdown between the drawn fences, an undrawn fence staying in it as
164// written. The pieces are null when nothing draws, the reply is held, or `measure`
165// asks for verdicts alone; `fences` takes the reply's fences already found.
166export const verdictsOf = (reply: string, columns: number, ink: Ink = INK.either, fences?: readonly FenceBlock[], measure = false): ReplyVerdict => {
167  const text = reply.replace(/\r\n?/g, '\n')
168  const blocks = fences ?? fencesOf(text)
169  if (blocks.length === 0) return { fences: [], held: null, pieces: null }
170  const verdicts = blocks.map(block => verdictOf(block, columns, ink, measure))
171  const held = heldOf(text, blocks)
172  if (held !== null) return { fences: verdicts, held, pieces: null }
173  if (!verdicts.some(v => v.drawn)) return { fences: verdicts, held: null, pieces: null }
174  const runs: string[] = []
175  let pending = ''
176  let cursor = 0
177  blocks.forEach((block, i) => {
178    if (!verdicts[i]!.drawn) return
179    runs.push(pending + text.slice(cursor, block.start))
180    pending = ''
181    cursor = block.end
182  })
183  runs.push(pending + text.slice(cursor))
184  const trimmed = runs.map(r => r.replace(/^\n+/, '').replace(/\n+$/, ''))
185  if (trimmed.some(r => r.trim() !== '' && !handable(r))) return { fences: verdicts, held: JOINED_UNHANDABLE, pieces: null }
186  if (measure) return { fences: verdicts, held: null, pieces: null }
187  const pieces: Piece[] = []
188  let r = 0
189  pushMarkdown(pieces, runs[r++]!)
190  for (const v of verdicts) {
191    if (!v.drawn) continue
192    pieces.push(v.piece!)
193    pushMarkdown(pieces, runs[r++]!)
194  }
195  return { fences: verdicts, held: null, pieces }
196}
197
198// The reply as pieces, as its verdict draws it; a held reply is left before any
199// figure is drawn.
200export const piecesOf = (reply: string, columns: number, ink: Ink = INK.either, fences?: readonly FenceBlock[]): Piece[] | null => {
201  const text = reply.replace(/\r\n?/g, '\n')
202  const blocks = fences ?? fencesOf(text)
203  if (blocks.length === 0 || heldOf(text, blocks) !== null) return null
204  return verdictsOf(text, columns, ink, blocks).pieces
205}
206
hooks/math.ts 511 lines
1import { adaptor, texToSvg, type LiteNode } from './vendor/math/mathjax.js'
2
3// Pure functions over ```math fences: TeX to MathJax's SVG lite DOM, its glyph
4// outlines and rules filled into RGBA pixels, sized to a box of terminal cells.
5// No `$`, so the tests drive these directly.
6
7export type Ink = readonly [number, number, number]
8export type MathArt = { rgba: Uint8Array; width: number; height: number; columns: number; rows: number }
9export type MathRendered = MathArt | { error: string }
10
11// the terminal cell the picture is sized against, in pixels: an assumption, since a
12// mod cannot read the terminal's font metrics
13export const CELL_PX = { width: 9, height: 18 } as const
14// pixels per em, so a formula's letters stand about as tall as the transcript's
15export const EM_PX = 16
16export const MAX_TEX_CHARS = 2_000
17// the Image element's bounds: 2048 pixels a side, 2 MiB of decoded pixels, 255 cells
18const MAX_SIDE_PX = 2048
19const MAX_BYTES = 2 * 1024 * 1024
20export const MAX_CELLS = 255
21
22type Matrix = readonly [number, number, number, number, number, number]
23type Point = readonly [number, number]
24
25const IDENTITY: Matrix = [1, 0, 0, 1, 0, 0]
26
27const times = (p: Matrix, q: Matrix): Matrix => [
28  p[0] * q[0] + p[2] * q[1],
29  p[1] * q[0] + p[3] * q[1],
30  p[0] * q[2] + p[2] * q[3],
31  p[1] * q[2] + p[3] * q[3],
32  p[0] * q[4] + p[2] * q[5] + p[4],
33  p[1] * q[4] + p[3] * q[5] + p[5],
34]
35
36const at = (m: Matrix, x: number, y: number): Point => [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]
37
38// translate, scale and rotate, the operations MathJax writes; any other throws
39const transformOf = (value: string | null | undefined): Matrix => {
40  let m = IDENTITY
41  const text = value ?? ''
42  if (text.replace(/(translate|scale|rotate)\([^)]*\)/g, '').trim() !== '') throw new Error(`transform ${text}`)
43  for (const [, op, args] of text.matchAll(/(translate|scale|rotate)\(([^)]*)\)/g)) {
44    const n = args!.split(/[\s,]+/).filter(Boolean).map(Number)
45    if (n.some(v => !Number.isFinite(v))) throw new Error(`transform ${text}`)
46    if (op === 'translate') m = times(m, [1, 0, 0, 1, n[0] ?? 0, n[1] ?? 0])
47    else if (op === 'scale') m = times(m, [n[0] ?? 1, 0, 0, n[1] ?? n[0] ?? 1, 0, 0])
48    else {
49      const a = ((n[0] ?? 0) * Math.PI) / 180, cx = n[1] ?? 0, cy = n[2] ?? 0
50      const cos = Math.cos(a), sin = Math.sin(a)
51      m = times(m, [1, 0, 0, 1, cx, cy])
52      m = times(m, [cos, sin, -sin, cos, 0, 0])
53      m = times(m, [1, 0, 0, 1, -cx, -cy])
54    }
55  }
56  return m
57}
58
59const QUAD_STEPS = 8
60const CUBIC_STEPS = 10
61
62// an SVG path's outline as closed rings of points, curves flattened to segments
63export const ringsOf = (d: string): Point[][] => {
64  const tokens = d.match(/[MLHVQTCSZAmlhvqtcsza]|-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g) ?? []
65  const rings: Point[][] = []
66  let ring: Point[] = []
67  let i = 0
68  let command = ''
69  let x = 0, y = 0, startX = 0, startY = 0, controlX = 0, controlY = 0
70  let previous = ''
71  const num = (): number => {
72    const value = Number(tokens[i++])
73    if (!Number.isFinite(value)) throw new Error('malformed path')
74    return value
75  }
76  const quad = (x1: number, y1: number, x2: number, y2: number) => {
77    for (let s = 1; s <= QUAD_STEPS; s++) {
78      const t = s / QUAD_STEPS, u = 1 - t
79      ring.push([u * u * x + 2 * u * t * x1 + t * t * x2, u * u * y + 2 * u * t * y1 + t * t * y2])
80    }
81  }
82  const cubic = (x1: number, y1: number, x2: number, y2: number, x3: number, y3: number) => {
83    for (let s = 1; s <= CUBIC_STEPS; s++) {
84      const t = s / CUBIC_STEPS, u = 1 - t
85      ring.push([
86        u * u * u * x + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t * t * t * x3,
87        u * u * u * y + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t * t * t * y3,
88      ])
89    }
90  }
91  while (i < tokens.length) {
92    if (/^[A-Za-z]$/.test(tokens[i]!)) command = tokens[i++]!
93    const relative = command !== command.toUpperCase()
94    const ox = relative ? x : 0, oy = relative ? y : 0
95    switch (command.toUpperCase()) {
96      case 'M':
97        if (ring.length > 0) rings.push(ring)
98        x = ox + num(); y = oy + num(); startX = x; startY = y
99        ring = [[x, y]]
100        command = relative ? 'l' : 'L'
101        previous = 'M'
102        break
103      case 'L': x = ox + num(); y = oy + num(); ring.push([x, y]); previous = 'L'; break
104      case 'H': x = ox + num(); ring.push([x, y]); previous = 'L'; break
105      case 'V': y = oy + num(); ring.push([x, y]); previous = 'L'; break
106      case 'Q': {
107        const x1 = ox + num(), y1 = oy + num(), x2 = ox + num(), y2 = oy + num()
108        quad(x1, y1, x2, y2)
109        controlX = x1; controlY = y1; x = x2; y = y2; previous = 'Q'
110        break
111      }
112      case 'T': {
113        const x1 = previous === 'Q' ? 2 * x - controlX : x, y1 = previous === 'Q' ? 2 * y - controlY : y
114        const x2 = ox + num(), y2 = oy + num()
115        quad(x1, y1, x2, y2)
116        controlX = x1; controlY = y1; x = x2; y = y2; previous = 'Q'
117        break
118      }
119      case 'C': {
120        const x1 = ox + num(), y1 = oy + num(), x2 = ox + num(), y2 = oy + num(), x3 = ox + num(), y3 = oy + num()
121        cubic(x1, y1, x2, y2, x3, y3)
122        controlX = x2; controlY = y2; x = x3; y = y3; previous = 'C'
123        break
124      }
125      case 'S': {
126        const x1 = previous === 'C' ? 2 * x - controlX : x, y1 = previous === 'C' ? 2 * y - controlY : y
127        const x2 = ox + num(), y2 = oy + num(), x3 = ox + num(), y3 = oy + num()
128        cubic(x1, y1, x2, y2, x3, y3)
129        controlX = x2; controlY = y2; x = x3; y = y3; previous = 'C'
130        break
131      }
132      case 'Z':
133        if (ring.length > 0) rings.push(ring)
134        ring = []
135        x = startX; y = startY; previous = 'Z'
136        command = ''
137        break
138      default:
139        throw new Error(`path command ${command || tokens[i]}`)
140    }
141  }
142  if (ring.length > 0) rings.push(ring)
143  return rings
144}
145
146// the ink a theme reads: dark on a light theme, light on a dark one, and a middle
147// grey that reads on either when the theme does not say (`auto` follows the terminal)
148export const INK = { light: [0x26, 0x26, 0x26], dark: [0xe4, 0xe4, 0xe4], either: [0x8a, 0x93, 0x9e] } as const satisfies Record<string, Ink>
149
150export const inkOf = (theme: unknown): Ink =>
151  typeof theme === 'string' && theme.startsWith('light') ? INK.light : typeof theme === 'string' && theme.startsWith('dark') ? INK.dark : INK.either
152
153// the elements the fill draws; any other throws, so the fence stays
154const DRAWN = new Set(['svg', 'g', 'path', 'rect', 'line'])
155// the width MathJax's stylesheet gives a table's rules and frame
156const TABLE_RULE = 70
157
158// The fill paints every outline in one ink, fully opaque. A presentation it cannot
159// honour — a style (the root's vertical-align aside), hiding, transparency, a colour
160// or a background — is named so the fence stays. MathJax writes \rule as a black
161// background rect on an mspace, which is the ink; a background on any other node
162// is a background.
163const OPAQUE = new Set(['opacity', 'fill-opacity', 'stroke-opacity'])
164const unhonouredOf = (node: LiteNode, kind: string, root: boolean, parent: LiteNode | null): string | null => {
165  const rule =
166    kind === 'rect' &&
167    adaptor.getAttribute(node, 'fill') === 'black' &&
168    parent !== null &&
169    adaptor.getAttribute(parent, 'data-mml-node') === 'mspace'
170  for (const { name, value } of adaptor.allAttributes(node)) {
171    const v = String(value).trim()
172    if (name === 'style' && v !== '' && !(root && /^vertical-align:[^;]*;?$/.test(v))) return `style="${v}"`
173    if (name === 'display' || name === 'visibility' || name === 'data-background' || (name === 'data-bgcolor' && !rule)) return `${name}="${v}"`
174    if (OPAQUE.has(name) && Number(v) !== 1) return `${name}="${v}"`
175    if ((name === 'fill' || name === 'stroke') && v !== 'currentColor' && v !== 'none' && !(rule && name === 'fill')) return `${name}="${v}"`
176  }
177  return null
178}
179
180// An axis-aligned clip, [left, top, right, bottom], in the coordinates of the
181// outlines it clips; null draws everywhere.
182type Clip = readonly [number, number, number, number] | null
183// one element's outlines, filled together under its clip
184export type Shape = { rings: Point[][]; clip: Clip }
185
186const box = (x0: number, y0: number, x1: number, y1: number, reverse = false): Point[] =>
187  reverse ? [[x0, y0], [x0, y1], [x1, y1], [x1, y0]] : [[x0, y0], [x1, y0], [x1, y1], [x0, y1]]
188
189type Paint = { fill: string; stroke: string; strokeWidth: number }
190
191const meet = (a: Clip, b: Clip): Clip =>
192  a === null ? b : b === null ? a : [Math.max(a[0], b[0]), Math.max(a[1], b[1]), Math.min(a[2], b[2]), Math.min(a[3], b[3])]
193
194// Every outline under the root svg, in its coordinates, one shape per element:
195// glyph paths and filled rules as they are, a stroked rect as its frame and a line
196// as a quad of its stroke width. A nested svg maps its viewBox onto its viewport
197// and clips to it, unless the stylesheet leaves it visible (a table cell's). Throws
198// on an error node, an element or attribute the fill cannot draw (a dashed rule, a
199// rounded frame, a stroked path), so the fence stays.
200export const outlinesOf = (svg: LiteNode): Shape[] => {
201  const shapes: Shape[] = []
202  const attr = (node: LiteNode, name: string) => adaptor.getAttribute(node, name)
203  const number = (node: LiteNode, name: string, fallback = 0): number => {
204    const value = attr(node, name)
205    const n = value == null ? fallback : Number(String(value).replace(/px$/, ''))
206    if (!Number.isFinite(n)) throw new Error(`${name}="${value}"`)
207    return n
208  }
209  // `fill`, `stroke` and `stroke-width` arrive inherited from the ancestors, as SVG paints them
210  const walk = (node: LiteNode, outer: Matrix, clip: Clip, parent: LiteNode | null, grandparent: LiteNode | null, inherited: Paint) => {
211    const kind = adaptor.kind(node)
212    if (kind === '#text' || kind === '#comment') return
213    if (!DRAWN.has(kind)) throw new Error(`cannot fill <${kind}>`)
214    if (attr(node, 'data-mml-node') === 'merror') throw new Error('TeX error')
215    const unhonoured = unhonouredOf(node, kind, node === svg, parent)
216    if (unhonoured) throw new Error(`cannot honour ${unhonoured}`)
217    if (/\bmjx-(dashed|dotted)\b/.test(attr(node, 'class') ?? '') || attr(node, 'stroke-dasharray') != null) throw new Error('a dashed rule')
218    const paint: Paint = {
219      fill: String(attr(node, 'fill') ?? inherited.fill).trim(),
220      stroke: String(attr(node, 'stroke') ?? inherited.stroke).trim(),
221      strokeWidth: number(node, 'stroke-width', inherited.strokeWidth),
222    }
223    let m = times(outer, transformOf(attr(node, 'transform')))
224    let shape: Shape | null = null
225    const put = (ring: Point[]) => {
226      if (!shape) shapes.push((shape = { rings: [], clip }))
227      shape.rings.push(ring.map(([px, py]) => at(m, px, py)))
228    }
229    if (kind === 'svg' && node !== svg) {
230      const x = number(node, 'x'), y = number(node, 'y'), w = number(node, 'width'), h = number(node, 'height')
231      const view = attr(node, 'viewBox')
232      let inner: Matrix = [1, 0, 0, 1, x, y]
233      if (view != null) {
234        const [vx, vy, vw, vh] = view.trim().split(/[\s,]+/).map(Number) as [number, number, number, number]
235        if (![vx, vy, vw, vh].every(Number.isFinite) || vw <= 0 || vh <= 0) throw new Error(`viewBox="${view}"`)
236        const aspect = (attr(node, 'preserveAspectRatio') ?? 'xMidYMid meet').trim()
237        let sx = w / vw, sy = h / vh, tx = x, ty = y
238        if (aspect !== 'none') {
239          if (!/^xMidYMid( meet)?$/.test(aspect)) throw new Error(`preserveAspectRatio="${aspect}"`)
240          sx = sy = Math.min(sx, sy)
241          tx += (w - vw * sx) / 2
242          ty += (h - vh * sy) / 2
243        }
244        inner = [sx, 0, 0, sy, tx - vx * sx, ty - vy * sy]
245      }
246      const visible = attr(node, 'overflow') === 'visible' || (grandparent !== null && attr(grandparent, 'data-mml-node') === 'mtable')
247      if (!visible) {
248        if (m[1] !== 0 || m[2] !== 0) throw new Error('a turned viewport')
249        const [ax, ay] = at(m, x, y), [bx, by] = at(m, x + w, y + h)
250        clip = meet(clip, [Math.min(ax, bx), Math.min(ay, by), Math.max(ax, bx), Math.max(ay, by)])
251      }
252      m = times(m, inner)
253    } else if (kind === 'path') {
254      if (paint.fill === 'none') throw new Error('an unfilled path')
255      if (paint.stroke !== 'none' && paint.strokeWidth > 0) throw new Error('a stroked path')
256      for (const ring of ringsOf(attr(node, 'd') ?? '')) put(ring)
257    } else if (kind === 'rect') {
258      if (number(node, 'rx') !== 0 || number(node, 'ry') !== 0) throw new Error('a rounded frame')
259      const x = number(node, 'x'), y = number(node, 'y'), w = number(node, 'width'), h = number(node, 'height')
260      const framed = attr(node, 'data-frame') === 'true'
261      if (paint.fill !== 'none' && !framed) put(box(x, y, x + w, y + h))
262      else {
263        if (paint.stroke === 'none') throw new Error('an unstroked frame')
264        const t = number(node, 'stroke-width', framed ? TABLE_RULE : NaN) / 2
265        put(box(x - t, y - t, x + w + t, y + h + t))
266        if (w > 2 * t && h > 2 * t) put(box(x + t, y + t, x + w - t, y + h - t, true))
267      }
268    } else if (kind === 'line') {
269      if (paint.stroke === 'none') throw new Error('an unstroked rule')
270      const x1 = number(node, 'x1'), y1 = number(node, 'y1'), x2 = number(node, 'x2'), y2 = number(node, 'y2')
271      const t = number(node, 'stroke-width', attr(node, 'data-line') != null ? TABLE_RULE : NaN) / 2
272      const length = Math.hypot(x2 - x1, y2 - y1)
273      if (length > 0) {
274        const nx = (-(y2 - y1) / length) * t, ny = ((x2 - x1) / length) * t
275        put([[x1 + nx, y1 + ny], [x2 + nx, y2 + ny], [x2 - nx, y2 - ny], [x1 - nx, y1 - ny]])
276      }
277    }
278    for (const child of adaptor.childNodes(node)) walk(child, m, clip, node, parent, paint)
279  }
280  walk(svg, IDENTITY, null, null, null, { fill: 'currentColor', stroke: 'none', strokeWidth: 1 })
281  return shapes
282}
283
284const SUBSAMPLES = 4
285// edge crossings one fill may compute before the formula counts as too complex
286const MAX_WORK = 20_000_000
287
288type Edge = { x0: number; y0: number; x1: number; y1: number; dir: number }
289
290// a shape that is one axis-aligned rectangle, as [left, top, right, bottom]
291const boxOf = (rings: readonly Point[][]): [number, number, number, number] | null => {
292  if (rings.length !== 1 || rings[0]!.length !== 4) return null
293  const ring = rings[0]!
294  for (let k = 0; k < 4; k++) {
295    const a = ring[k]!, b = ring[(k + 1) % 4]!
296    if (a[0] !== b[0] && a[1] !== b[1]) return null
297  }
298  const xs = ring.map(p => p[0]), ys = ring.map(p => p[1])
299  return [Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)]
300}
301
302// Nonzero-winding scanline fill with SUBSAMPLES rows per pixel and exact horizontal
303// coverage; an axis-aligned rectangle (a rule, a fraction bar) is covered exactly in
304// both directions, so one thinner than a subsample row still leaves its ink. Each
305// shape (one element) is filled on its own, within its clip and its bounding box,
306// and coverages add up to full: independent elements never cancel, and pieces that
307// abut leave no seam. The rings and clips are already in pixels. Throws past
308// MAX_WORK crossings.
309const filled = (shapes: readonly Shape[], width: number, height: number, ink: Ink): Uint8Array => {
310  const cover = new Float32Array(width * height)
311  let own = new Float32Array(0)
312  let work = 0
313  for (const { rings, clip } of shapes) {
314    const rect = boxOf(rings)
315    if (rect) {
316      const [cl, ct, cr, cb] = clip ?? [0, 0, width, height]
317      const l = Math.max(0, cl, rect[0]), r = Math.min(width, cr, rect[2])
318      const t = Math.max(0, ct, rect[1]), b = Math.min(height, cb, rect[3])
319      if (r <= l || b <= t) continue
320      for (let row = Math.floor(t); row < Math.ceil(b); row++) {
321        const v = Math.min(b, row + 1) - Math.max(t, row)
322        for (let c = Math.floor(l); c < Math.ceil(r); c++) {
323          const h = Math.min(r, c + 1) - Math.max(l, c)
324          cover[row * width + c] = Math.min(1, cover[row * width + c]! + v * h)
325        }
326        work += Math.ceil(r) - Math.floor(l)
327        if (work > MAX_WORK) throw new Error('too complex to draw')
328      }
329      continue
330    }
331    let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity
332    for (const ring of rings)
333      for (const [x, y] of ring) {
334        if (x < minX) minX = x
335        if (x > maxX) maxX = x
336        if (y < minY) minY = y
337        if (y > maxY) maxY = y
338      }
339    const [cl, ct, cr, cb] = clip ?? [0, 0, width, height]
340    const left0 = Math.max(0, cl, minX), right0 = Math.min(width, cr, maxX)
341    const top0 = Math.max(0, ct, minY), bottom0 = Math.min(height, cb, maxY)
342    if (right0 <= left0 || bottom0 <= top0) continue
343    const bx = Math.floor(left0), bw = Math.ceil(right0) - bx
344    const firstRow = Math.floor(top0), lastRow = Math.ceil(bottom0)
345    const size = bw * (lastRow - firstRow)
346    if (own.length < size) own = new Float32Array(size)
347    else own.fill(0, 0, size)
348    const edges: Edge[] = []
349    for (const ring of rings)
350      for (let k = 0; k < ring.length; k++) {
351        const a = ring[k]!, b = ring[(k + 1) % ring.length]!
352        if (a[1] === b[1]) continue
353        edges.push(a[1] < b[1] ? { x0: a[0], y0: a[1], x1: b[0], y1: b[1], dir: 1 } : { x0: b[0], y0: b[1], x1: a[0], y1: a[1], dir: -1 })
354      }
355    edges.sort((p, q) => p.y0 - q.y0)
356    const active: Edge[] = []
357    const crossings: [number, number][] = []
358    let next = 0
359    for (let row = firstRow; row < lastRow; row++)
360      for (let s = 0; s < SUBSAMPLES; s++) {
361        const sy = row + (s + 0.5) / SUBSAMPLES
362        if (sy < top0 || sy >= bottom0) continue
363        while (next < edges.length && edges[next]!.y0 <= sy) active.push(edges[next++]!)
364        let kept = 0
365        for (const e of active) if (e.y1 > sy) active[kept++] = e
366        active.length = kept
367        if (kept === 0) continue
368        work += kept
369        if (work > MAX_WORK) throw new Error('too complex to draw')
370        crossings.length = 0
371        for (const e of active) crossings.push([e.x0 + ((sy - e.y0) * (e.x1 - e.x0)) / (e.y1 - e.y0), e.dir])
372        crossings.sort((p, q) => p[0] - q[0])
373        let winding = 0
374        const base = (row - firstRow) * bw - bx
375        for (let k = 0; k < crossings.length - 1; k++) {
376          winding += crossings[k]![1]
377          if (winding === 0) continue
378          const left = Math.max(left0, crossings[k]![0]), right = Math.min(right0, crossings[k + 1]![0])
379          if (right <= left) continue
380          const li = Math.floor(left), ri = Math.floor(right)
381          if (li === ri) {
382            own[base + li]! += (right - left) / SUBSAMPLES
383            continue
384          }
385          own[base + li]! += (li + 1 - left) / SUBSAMPLES
386          for (let c = li + 1; c < ri; c++) own[base + c]! += 1 / SUBSAMPLES
387          if (ri < bx + bw) own[base + ri]! += (right - ri) / SUBSAMPLES
388        }
389      }
390    for (let row = firstRow; row < lastRow; row++) {
391      const from = (row - firstRow) * bw, to = row * width + bx
392      for (let c = 0; c < bw; c++) {
393        const v = own[from + c]!
394        if (v > 0) cover[to + c] = Math.min(1, cover[to + c]! + v)
395      }
396    }
397  }
398  const rgba = new Uint8Array(width * height * 4)
399  for (let p = 0; p < width * height; p++) {
400    rgba[p * 4] = ink[0]
401    rgba[p * 4 + 1] = ink[1]
402    rgba[p * 4 + 2] = ink[2]
403    rgba[p * 4 + 3] = Math.round(cover[p]! * 255)
404  }
405  return rgba
406}
407
408// a fence that is exactly one display wrapper keeps only the TeX inside it
409const unwrapped = (tex: string): string => {
410  const t = tex.trim()
411  const wrapped = /^\$\$((?:(?!\$\$)[\s\S])*)\$\$$/.exec(t) ?? /^\\\[((?:(?!(?<!\\)\\[[\]])[\s\S])*)\\\]$/.exec(t)
412  return (wrapped ? wrapped[1]! : t).trim()
413}
414
415// What MathJax would build before any bound here can stop it: \pmb sets its
416// argument twice, so its outlines double per nesting; an operator \DeclareMathOperator
417// defines may use earlier ones any number of times, so a chain grows the same way;
418// and an alignat environment allocates the column count its argument gives.
419const PMB = /\\pmb(?![a-zA-Z])/
420const DECLARE = /\\DeclareMathOperator(?![a-zA-Z])/
421const ALIGNAT = /\\begin\s*\{\s*(?:x{0,2}alignat\*?|alignedat)\s*\}/
422const unboundedOf = (tex: string): string | null => {
423  if (PMB.test(tex)) return '\\pmb'
424  if (DECLARE.test(tex)) return '\\DeclareMathOperator'
425  if (ALIGNAT.test(tex)) return 'an alignat environment'
426  return null
427}
428
429// the extent of the outlines, each within its clip, as [left, top, right, bottom]
430const extentOf = (shapes: readonly Shape[]): [number, number, number, number] | null => {
431  let l = Infinity, t = Infinity, r = -Infinity, b = -Infinity
432  for (const { rings, clip } of shapes) {
433    let sl = Infinity, st = Infinity, sr = -Infinity, sb = -Infinity
434    for (const ring of rings)
435      for (const [x, y] of ring) {
436        if (x < sl) sl = x
437        if (x > sr) sr = x
438        if (y < st) st = y
439        if (y > sb) sb = y
440      }
441    if (clip) [sl, st, sr, sb] = [Math.max(sl, clip[0]), Math.max(st, clip[1]), Math.min(sr, clip[2]), Math.min(sb, clip[3])]
442    if (sr <= sl || sb <= st) continue
443    l = Math.min(l, sl); t = Math.min(t, st); r = Math.max(r, sr); b = Math.max(b, sb)
444  }
445  return r > l && b > t ? [l, t, r, b] : null
446}
447
448const inked = (rgba: Uint8Array): boolean => {
449  for (let i = 3; i < rgba.length; i += 4) if (rgba[i]! > 0) return true
450  return false
451}
452
453// The formula laid out on a box of whole cells, the box no wider than `columns`, without
454// filling a pixel: what a verdict needs, and what `mathOf` fills. The bitmap is padded
455// to columns × rows cells of CELL_PX so the terminal scales it without distortion, the
456// formula at the left and centred top to bottom. The box covers the viewBox and any
457// outline drawn past it (a \smash, an \rlap).
458type MathLayout = { shapes: Shape[]; width: number; height: number; columns: number; rows: number }
459export const mathLayoutOf = (source: string, columns: number): MathLayout | { error: string } => {
460  const tex = unwrapped(source)
461  if (tex === '') return { error: 'nothing to draw' }
462  if (tex.length > MAX_TEX_CHARS) return { error: `too big to draw (${tex.length} characters)` }
463  if (tex.includes('$$')) return { error: 'more than one display formula' }
464  const unbounded = unboundedOf(tex)
465  if (unbounded) return { error: `${unbounded} cannot be drawn within bounds` }
466  try {
467    const svg = texToSvg(tex)
468    const view = (adaptor.getAttribute(svg, 'viewBox') ?? '').split(/\s+/).map(Number)
469    if (view.length !== 4 || view.some(n => !Number.isFinite(n)) || view[2]! <= 0 || view[3]! <= 0) return { error: 'no picture' }
470    const outlines = outlinesOf(svg)
471    const extent = extentOf(outlines)
472    if (!extent) return { error: 'nothing to draw' }
473    let [vx, vy, vw, vh] = view as [number, number, number, number]
474    const right = Math.max(vx + vw, extent[2]), bottom = Math.max(vy + vh, extent[3])
475    vx = Math.min(vx, extent[0]); vy = Math.min(vy, extent[1])
476    vw = right - vx; vh = bottom - vy
477    const scale = EM_PX / 1000
478    const inkWidth = vw * scale, inkHeight = vh * scale
479    const cols = Math.ceil(inkWidth / CELL_PX.width)
480    const rows = Math.ceil(inkHeight / CELL_PX.height)
481    if (cols > Math.min(MAX_CELLS, columns)) return { error: `${cols} columns wide` }
482    if (rows > MAX_CELLS) return { error: `${rows} rows tall` }
483    const width = cols * CELL_PX.width, height = rows * CELL_PX.height
484    if (width > MAX_SIDE_PX || height > MAX_SIDE_PX || width * height * 4 > MAX_BYTES) return { error: `${width}×${height} pixels` }
485    const top = (height - inkHeight) / 2
486    const px = ([x, y]: Point): Point => [(x - vx) * scale, (y - vy) * scale + top]
487    const shapes = outlines.map(({ rings, clip }): Shape => {
488      if (clip === null) return { rings: rings.map(ring => ring.map(px)), clip }
489      const [l, t] = px([clip[0], clip[1]]), [r, b] = px([clip[2], clip[3]])
490      return { rings: rings.map(ring => ring.map(px)), clip: [l, t, r, b] }
491    })
492    return { shapes, width, height, columns: cols, rows }
493  } catch (err) {
494    return { error: err instanceof Error ? err.message : String(err) }
495  }
496}
497
498// The formula as pixels on its layout's box.
499export const mathOf = (source: string, columns: number, ink: Ink): MathRendered => {
500  const layout = mathLayoutOf(source, columns)
501  if ('error' in layout) return layout
502  const { shapes, width, height, columns: cols, rows } = layout
503  try {
504    const rgba = filled(shapes, width, height, ink)
505    if (!inked(rgba)) return { error: 'nothing to draw' }
506    return { rgba, width, height, columns: cols, rows }
507  } catch (err) {
508    return { error: err instanceof Error ? err.message : String(err) }
509  }
510}
511
hooks/report.ts 57 lines
1import { fencesOf, verdictsOf } from './figures.ts'
2import { INK, type Ink } from './math.ts'
3
4// What the model reads after a turn whose reply held a fence the terminal renderer
5// would not draw: each such fence by its place in the turn and its kind, with its own
6// verdict's reason, and beside it any reason the whole reply is left as written. The
7// verdicts are the terminal renderer's (`verdictsOf`, measured only), against the last
8// terminal that drew a reply this session, or against the default width when none has,
9// in which case the surface in use shows every fence as its source.
10
11// the transcript's gutter and margins the drawing must clear
12export const INLINE_MARGIN = 6
13// the width the drawing assumes when the terminal gives none
14export const DEFAULT_COLUMNS = 80
15
16export const reportOf = (texts: readonly string[], terminalColumns: number | null, ink: Ink = INK.either): string | null => {
17  const columns = (terminalColumns ?? DEFAULT_COLUMNS) - INLINE_MARGIN
18  const lines: string[] = []
19  let undrawn = 0
20  let ordinal = 0
21  for (const raw of texts) {
22    const text = raw.replace(/\r\n?/g, '\n')
23    const fences = fencesOf(text)
24    if (fences.length === 0) continue
25    const verdict = verdictsOf(text, columns, ink, fences, true)
26    const first = ordinal + 1
27    for (const fence of verdict.fences) {
28      ordinal++
29      if (fence.drawn) continue
30      undrawn++
31      const kind = fence.kind === 'math' ? 'math' : `mermaid ${fence.kind}`
32      const reason =
33        fence.cells === undefined
34          ? fence.reason
35          : terminalColumns === null
36            ? `drew ${fence.cells} cells wide, over the ${DEFAULT_COLUMNS}-column default (room ${columns})`
37            : `drew ${fence.cells} cells wide; the terminal last seen was ${terminalColumns} columns (room ${columns})`
38      lines.push(`- figure ${ordinal} (${kind}): ${reason}`)
39    }
40    if (verdict.held !== null) {
41      const span = first === ordinal ? `figure ${first}` : `figures ${first}–${ordinal}`
42      const drawable = verdict.fences.filter(f => f.drawn).length
43      undrawn += drawable
44      lines.push(`- ${span}: the whole reply text holding ${first === ordinal ? 'it' : 'them'} is left as written, because ${verdict.held}${drawable > 0 ? ` (${drawable} would draw on ${drawable === 1 ? 'its' : 'their'} own)` : ''}`)
45    }
46  }
47  if (lines.length === 0) return null
48  const count = undrawn === 1 ? 'a figure' : `${undrawn} figures`
49  return [
50    terminalColumns === null
51      ? `[ink-figure] No terminal has drawn a reply this session, so the surface in use shows every fence as its source. These are the terminal renderer's verdicts: it would not draw ${count} of your last reply.`
52      : `[ink-figure] The terminal renderer did not draw ${count} of your last reply; on the terminal ${undrawn === 1 ? 'it shows' : 'they show'} as fence source.`,
53    ...lines,
54    'This is for the figures you write later in this session (the drawn grammar is in the ink-figure README). The reply stands as written: do not re-emit it.',
55  ].join('\n')
56}
57
hooks/grammar.ts 373 lines
1// The grammar each mermaid kind is drawn from. The renderer reads more of mermaid than
2// it draws faithfully: it parses a statement and then drops a part of it, draws one
3// arrow as another, or lays two things over each other. So a fence is drawn only when
4// every statement belongs to the forms below, each shown by a test to draw what it
5// says; anything else keeps the whole fence as written. `labels` are the texts the
6// drawing must show whole, `categories` the x-axis names it must show in order, and
7// `chain` says a top-down drawing is safe at the compact vertical spacing: no edge
8// label, and no node with more than one edge in or out.
9
10export type Admitted = { labels: string[]; categories: string[]; chain: boolean }
11export type Grammar = Admitted | { error: string }
12
13const ID = String.raw`[\p{L}\p{N}_]+`
14// label text: no markup the renderer reads as something else (entities, HTML,
15// markdown strings, nested shapes, pipes, quotes)
16const TEXT = String.raw`[^\[\](){}"|<>#\x60;]+`
17const QUOTED = String.raw`"[^"<>#\x60]*"`
18
19const statementsOf = (source: string): string[] =>
20  source
21    .split('\n')
22    .map(l => l.trim())
23    .filter(l => l !== '' && !l.startsWith('%%'))
24
25const outside = (line: string): Grammar => ({ error: `a statement outside the drawn grammar: ${line}` })
26
27const unquote = (s: string): string => (s.startsWith('"') ? s.slice(1, -1) : s).trim()
28
29const pairOf = (a: string, b: string): string => [a, b].sort().join('\u0000')
30
31// counts of edges in and out per node; `chain` holds when none exceeds one
32const degrees = () => {
33  const out = new Map<string, number>()
34  const into = new Map<string, number>()
35  return {
36    add(from: string, to: string) {
37      out.set(from, (out.get(from) ?? 0) + 1)
38      into.set(to, (into.get(to) ?? 0) + 1)
39    },
40    chain: () => [...out.values(), ...into.values()].every(n => n <= 1),
41  }
42}
43
44// flowchart: `graph`/`flowchart` LR, TD, TB, BT or none; nodes `A`, `A[text]`,
45// `A(text)`, `A{text}` (text quoted or not); one `-->` edge per statement, with an
46// optional `|label|`, spaces allowed inside it; at most one edge between two nodes;
47// style, class, click and accessibility statements, which draw nothing
48const SHAPE = String.raw`(?:\[(${QUOTED}|${TEXT})\]|\((${QUOTED}|${TEXT})\)|\{(${QUOTED}|${TEXT})\})`
49const NODE = String.raw`(${ID})${SHAPE}?`
50const FLOW_HEADER = /^(?:flowchart|graph)(?:\s+(?:LR|TD|TB|BT))?\s*;?$/i
51const FLOW_NODE = new RegExp(String.raw`^${NODE}\s*;?$`, 'u')
52const EDGE_LABEL = String.raw`[^|<>#"\x60\s](?:[^|<>#"\x60]*[^|<>#"\x60\s])?`
53const FLOW_EDGE = new RegExp(String.raw`^${NODE}\s*-->\s*(?:\|(${EDGE_LABEL})\|\s*)?${NODE}\s*;?$`, 'u')
54const FLOW_SILENT = /^(?:(?:style|classDef|class|click|linkStyle)\s|acc(?:Title|Descr)\s*:)/
55
56const flowchartOf = (lines: string[]): Grammar => {
57  if (!FLOW_HEADER.test(lines[0] ?? '')) return outside(lines[0] ?? '')
58  const text = new Map<string, string>()
59  const edgeLabels: string[] = []
60  const pairs = new Set<string>()
61  const deg = degrees()
62  let selfLoop = false
63  const node = (id: string, ...shape: (string | undefined)[]) => {
64    const label = shape.find(s => s !== undefined)
65    if (label !== undefined) text.set(id, unquote(label))
66    else if (!text.has(id)) text.set(id, id)
67  }
68  for (const line of lines.slice(1)) {
69    if (FLOW_SILENT.test(line)) continue
70    const edge = FLOW_EDGE.exec(line)
71    if (edge) {
72      const [, from, a1, a2, a3, label, to, b1, b2, b3] = edge
73      node(from!, a1, a2, a3)
74      node(to!, b1, b2, b3)
75      if (from === to) selfLoop = true
76      const pair = pairOf(from!, to!)
77      if (pairs.has(pair)) return { error: `two edges between ${from} and ${to}` }
78      pairs.add(pair)
79      deg.add(from!, to!)
80      if (label) edgeLabels.push(label)
81      continue
82    }
83    const one = FLOW_NODE.exec(line)
84    if (one) {
85      node(one[1]!, one[2], one[3], one[4])
86      continue
87    }
88    return outside(line)
89  }
90  const labels = [...text.values(), ...edgeLabels].filter(l => l !== '')
91  return { labels, categories: [], chain: edgeLabels.length === 0 && !selfLoop && deg.chain() }
92}
93
94// state: `stateDiagram`/`stateDiagram-v2`; `direction LR|TB`; `A --> B` between
95// states or `[*]`, with an optional label; `state "text" as A`; `A : text`; at most
96// one transition between two states; no composite state, note, fork or choice
97const STATE = String.raw`(\[\*\]|${ID})`
98const STATE_HEADER = /^stateDiagram(?:-v2)?\s*$/
99const STATE_DIRECTION = /^direction\s+(?:LR|TB)\s*$/
100const STATE_EDGE = new RegExp(String.raw`^${STATE}\s*-->\s*${STATE}\s*(?::\s*(${TEXT}))?$`, 'u')
101const STATE_ALIAS = new RegExp(String.raw`^state\s+(${QUOTED})\s+as\s+(${ID})$`, 'u')
102const STATE_TEXT = new RegExp(String.raw`^(${ID})\s*:\s*(${TEXT})$`, 'u')
103
104const stateOf = (lines: string[]): Grammar => {
105  if (!STATE_HEADER.test(lines[0] ?? '')) return outside(lines[0] ?? '')
106  const names = new Map<string, string>()
107  const described = new Set<string>()
108  const texts: string[] = []
109  const edgeLabels: string[] = []
110  const pairs = new Set<string>()
111  const deg = degrees()
112  let selfLoop = false
113  const state = (id: string) => {
114    if (id !== '[*]' && !names.has(id)) names.set(id, id)
115  }
116  for (const line of lines.slice(1)) {
117    if (STATE_DIRECTION.test(line)) continue
118    const edge = STATE_EDGE.exec(line)
119    if (edge) {
120      const [, rawFrom, rawTo, label] = edge
121      const from = rawFrom === '[*]' ? '[*]start' : rawFrom!
122      const to = rawTo === '[*]' ? '[*]end' : rawTo!
123      state(rawFrom!)
124      state(rawTo!)
125      if (from === to) selfLoop = true
126      const pair = pairOf(from, to)
127      if (pairs.has(pair)) return { error: `two transitions between ${rawFrom} and ${rawTo}` }
128      pairs.add(pair)
129      deg.add(from, to)
130      if (label?.trim()) edgeLabels.push(label.trim())
131      continue
132    }
133    const alias = STATE_ALIAS.exec(line)
134    if (alias) {
135      names.set(alias[2]!, unquote(alias[1]!))
136      continue
137    }
138    const text = STATE_TEXT.exec(line)
139    if (text) {
140      state(text[1]!)
141      described.add(text[1]!)
142      texts.push(text[2]!.trim())
143      continue
144    }
145    return outside(line)
146  }
147  // a state with a description and no `state "…" as` name is drawn as its description
148  const shown = [...names].filter(([id, name]) => name !== id || !described.has(id)).map(([, name]) => name)
149  const labels = [...shown, ...texts, ...edgeLabels].filter(l => l !== '')
150  return { labels, categories: [], chain: edgeLabels.length === 0 && !selfLoop && deg.chain() }
151}
152
153// sequence: `participant A` or `participant A as text`; `A->>B: text` and
154// `A-->>B: text`, a self-message included; nothing else (no note, block, activation,
155// actor, numbering or other arrow)
156const SEQ_PARTICIPANT = new RegExp(String.raw`^participant\s+(${ID})(?:\s+as\s+([^<>#;:"]+))?$`, 'u')
157const SEQ_MESSAGE = new RegExp(String.raw`^(${ID})\s*(?:->>|-->>)\s*(${ID})\s*:([^<>#;"\x60]*)$`, 'u')
158
159const sequenceOf = (lines: string[]): Grammar => {
160  if (!/^sequenceDiagram\s*$/.test(lines[0] ?? '')) return outside(lines[0] ?? '')
161  const names = new Map<string, string>()
162  const texts: string[] = []
163  for (const line of lines.slice(1)) {
164    const participant = SEQ_PARTICIPANT.exec(line)
165    if (participant) {
166      names.set(participant[1]!, participant[2]?.trim() || participant[1]!)
167      continue
168    }
169    const message = SEQ_MESSAGE.exec(line)
170    if (message) {
171      for (const id of [message[1]!, message[2]!]) if (!names.has(id)) names.set(id, id)
172      if (message[3]!.trim()) texts.push(message[3]!.trim())
173      continue
174    }
175    return outside(line)
176  }
177  return { labels: [...names.values(), ...texts], categories: [], chain: true }
178}
179
180// class: `class A`, `class A { … }`, `A : member`; a member is `Type name` or `name`,
181// or a method with no parameters `name()` or `name() Type`, each with an optional
182// visibility mark, no member name twice in a class; a relation `<|--`, `*--`,
183// `o--`, `-->`, `..>` or `..|>` with an optional label. The relations form chains:
184// no class sits above two others or below two, and none closes a cycle.
185const MEMBER_ATTR = new RegExp(String.raw`^([+\-#~]?)(?:(${ID})\s+)?(${ID})$`, 'u')
186const MEMBER_METHOD = new RegExp(String.raw`^([+\-#~]?)(${ID})\(\)(?:\s+(${ID}))?$`, 'u')
187const CLASS_OPEN = new RegExp(String.raw`^class\s+(${ID})\s*(\{)?$`, 'u')
188const CLASS_MEMBER = new RegExp(String.raw`^(${ID})\s*:\s*(.+)$`, 'u')
189const CLASS_RELATION = new RegExp(String.raw`^(${ID})\s+(<\|--|\*--|o--|-->|\.\.>|\.\.\|>)\s+(${ID})\s*(?::\s*(${TEXT}))?$`, 'u')
190
191const classOf = (lines: string[]): Grammar => {
192  if (!/^classDiagram\s*$/.test(lines[0] ?? '')) return outside(lines[0] ?? '')
193  const classes = new Set<string>()
194  const members = new Map<string, Set<string>>()
195  const labels: string[] = []
196  const above = new Map<string, number>()
197  const below = new Map<string, number>()
198  const root = new Map<string, string>()
199  const find = (c: string): string => {
200    while (root.has(c) && root.get(c) !== c) c = root.get(c)!
201    return c
202  }
203  const member = (owner: string, text: string): string | null => {
204    const method = MEMBER_METHOD.exec(text)
205    const attr = method ? null : MEMBER_ATTR.exec(text)
206    if (!method && !attr) return text
207    const [, vis, a, b] = (method ?? attr)!
208    const name = method ? a! : b!
209    const type = method ? b : a
210    const seen = members.get(owner) ?? new Set<string>()
211    if (seen.has(name)) return text
212    seen.add(name)
213    members.set(owner, seen)
214    labels.push(type ? `${vis}${name}: ${type}` : `${vis}${name}`)
215    return null
216  }
217  let open: string | null = null
218  for (const line of lines.slice(1)) {
219    if (open !== null) {
220      if (line === '}') open = null
221      else if (member(open, line) !== null) return outside(line)
222      continue
223    }
224    const decl = CLASS_OPEN.exec(line)
225    if (decl) {
226      classes.add(decl[1]!)
227      if (decl[2]) open = decl[1]!
228      continue
229    }
230    const relation = CLASS_RELATION.exec(line)
231    if (relation) {
232      const [, left, op, right, label] = relation
233      classes.add(left!)
234      classes.add(right!)
235      const [upper, lower] = op === '..|>' ? [right!, left!] : [left!, right!]
236      above.set(upper, (above.get(upper) ?? 0) + 1)
237      below.set(lower, (below.get(lower) ?? 0) + 1)
238      if (above.get(upper)! > 1 || below.get(lower)! > 1) return { error: `${upper} or ${lower} takes part in two relations on one side` }
239      const [ru, rl] = [find(upper), find(lower)]
240      if (ru === rl) return { error: `the relation between ${left} and ${right} closes a cycle` }
241      root.set(ru, rl)
242      if (label?.trim()) labels.push(label.trim())
243      continue
244    }
245    const one = CLASS_MEMBER.exec(line)
246    if (one) {
247      classes.add(one[1]!)
248      if (member(one[1]!, one[2]!.trim()) !== null) return outside(line)
249      continue
250    }
251    return outside(line)
252  }
253  return { labels: [...classes, ...labels], categories: [], chain: true }
254}
255
256// ER: a relationship `A ||--o{ B : label` (cardinalities `||`, `|o`, `}o`, `}|`
257// on the left and their mirrors on the right, line `--` or `..`), an entity block
258// `A { … }` of `type name` attributes; every entity in at most one relationship
259const ER_RELATION = new RegExp(
260  String.raw`^(${ID})\s+(?:\|\||\|o|\}o|\}\|)(?:--|\.\.)(?:\|\||o\||o\{|\|\{)\s+(${ID})\s*:\s*(${QUOTED}|[\p{L}\p{N}_-]+)$`,
261  'u',
262)
263const ER_OPEN = new RegExp(String.raw`^(${ID})\s*\{$`, 'u')
264const ER_ATTRIBUTE = new RegExp(String.raw`^(${ID})\s+(${ID})$`, 'u')
265
266const erOf = (lines: string[]): Grammar => {
267  if (!/^erDiagram\s*$/.test(lines[0] ?? '')) return outside(lines[0] ?? '')
268  const entities = new Set<string>()
269  const related = new Set<string>()
270  const labels: string[] = []
271  let open = false
272  for (const line of lines.slice(1)) {
273    if (open) {
274      if (line === '}') open = false
275      else {
276        const attribute = ER_ATTRIBUTE.exec(line)
277        if (!attribute) return outside(line)
278        labels.push(`${attribute[1]} ${attribute[2]}`)
279      }
280      continue
281    }
282    const block = ER_OPEN.exec(line)
283    if (block) {
284      entities.add(block[1]!)
285      open = true
286      continue
287    }
288    const relation = ER_RELATION.exec(line)
289    if (relation) {
290      const [, a, b, label] = relation
291      for (const e of [a!, b!]) {
292        if (related.has(e)) return { error: `${e} takes part in two relationships` }
293        related.add(e)
294        entities.add(e)
295      }
296      if (a === b) return { error: `${a} relates to itself` }
297      const text = unquote(label!)
298      if (text) labels.push(text)
299      continue
300    }
301    return outside(line)
302  }
303  return { labels: [...entities, ...labels], categories: [], chain: true }
304}
305
306// xychart: `xychart` or `xychart-beta`, upright; a quoted `title`; `x-axis [a, "b c"]`
307// with no axis title; `y-axis min --> max` in integers with no axis title; one
308// `line` series of integers. No bars, second series, horizontal orientation,
309// axis title or fractional value.
310const INT = String.raw`-?\d{1,12}`
311const CHART_HEADER = /^xychart(?:-beta)?\s*$/
312const CHART_TITLE = /^title\s+"([^"]+)"$/
313const CATEGORY = String.raw`(?:${QUOTED}|[^\[\],"]*)`
314const CHART_X = new RegExp(String.raw`^x-axis\s*\[(\s*${CATEGORY}\s*(?:,\s*${CATEGORY}\s*)*)\]$`)
315const CATEGORIES = new RegExp(String.raw`\s*(${QUOTED}|[^,"]*?)\s*(?:,|$)`, 'gy')
316const CHART_Y = new RegExp(String.raw`^y-axis\s+${INT}\s*-->\s*${INT}$`)
317const CHART_LINE = new RegExp(String.raw`^line\s*\[\s*${INT}(?:\s*,\s*${INT})*\s*\]$`)
318
319const chartOf = (lines: string[]): Grammar => {
320  if (!CHART_HEADER.test(lines[0] ?? '')) return outside(lines[0] ?? '')
321  const labels: string[] = []
322  let categories: string[] = []
323  let series = 0
324  for (const line of lines.slice(1)) {
325    const title = CHART_TITLE.exec(line)
326    if (title) {
327      labels.push(title[1]!.trim())
328      continue
329    }
330    const x = CHART_X.exec(line)
331    if (x) {
332      categories = [...x[1]!.matchAll(CATEGORIES)].map(m => unquote(m[1]!)).slice(0, -1)
333      if (categories.some(c => c === '')) return outside(line)
334      continue
335    }
336    if (CHART_Y.test(line)) continue
337    if (CHART_LINE.test(line)) {
338      if (++series > 1) return { error: 'a second series' }
339      continue
340    }
341    return outside(line)
342  }
343  return { labels, categories, chain: true }
344}
345
346const GRAMMARS: Record<string, (lines: string[]) => Grammar> = {
347  flowchart: flowchartOf,
348  state: stateOf,
349  sequence: sequenceOf,
350  class: classOf,
351  er: erOf,
352  xychart: chartOf,
353}
354
355export const grammarOf = (source: string, kind: string): Grammar => {
356  const grammar = GRAMMARS[kind]
357  return grammar ? grammar(statementsOf(source)) : { error: `${kind} diagrams are not drawn` }
358}
359
360const escaped = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
361
362// what the drawing must show for the grammar to have drawn faithfully: every label
363// whole, and the categories in order on one row with space between them
364export const faithfulTo = (admitted: Admitted, art: readonly string[]): string | null => {
365  const all = art.join('\n')
366  for (const label of admitted.labels) if (!all.includes(label)) return `the drawing lost "${label}"`
367  if (admitted.categories.length > 0) {
368    const row = new RegExp(String.raw`(?:^|\s)${admitted.categories.map(escaped).join(String.raw`\s+`)}(?:\s|$)`)
369    if (!art.some(line => row.test(line))) return 'the drawing ran the categories together'
370  }
371  return null
372}
373
hooks/vendor/mermaid-ascii.js 5658 lines
1// Generated by scripts/build-vendor.mjs from beautiful-mermaid (MIT, see hooks/vendor/LICENSE) with scripts/patches.mjs applied. Do not edit.
2
3// node_modules/beautiful-mermaid/src/multiline-utils.ts
4function normalizeBrTags(label) {
5  const unquoted = label.startsWith('"') && label.endsWith('"') ? label.slice(1, -1) : label;
6  return unquoted.replace(/<br\s*\/?>/gi, "\n").replace(/\\n/g, "\n").replace(/<\/?(?:sub|sup|small|mark)\s*>/gi, "").replace(/\*\*(.+?)\*\*/g, "<b>$1</b>").replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g, "<i>$1</i>").replace(/~~(.+?)~~/g, "<s>$1</s>");
7}
8
9// node_modules/beautiful-mermaid/src/parser.ts
10function parseMermaid(text) {
11  const lines = text.split("\n").map((l) => l.trim().replace(/;$/, "").trim()).filter((l) => l.length > 0 && !l.startsWith("%%"));
12  if (lines.length === 0) {
13    throw new Error("Empty mermaid diagram");
14  }
15  const header = lines[0];
16  if (/^stateDiagram(-v2)?\s*$/i.test(header)) {
17    return parseStateDiagram(lines);
18  }
19  return parseFlowchart(lines);
20}
21function parseFlowchart(lines) {
22  const headerMatch = lines[0].match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);
23  if (!headerMatch) {
24    throw new Error(`Invalid mermaid header: "${lines[0]}". Expected "graph TD", "flowchart LR", "stateDiagram-v2", etc.`);
25  }
26  const direction = headerMatch[1].toUpperCase();
27  const graph = {
28    direction,
29    nodes: /* @__PURE__ */ new Map(),
30    edges: [],
31    subgraphs: [],
32    classDefs: /* @__PURE__ */ new Map(),
33    classAssignments: /* @__PURE__ */ new Map(),
34    nodeStyles: /* @__PURE__ */ new Map(),
35    linkStyles: /* @__PURE__ */ new Map()
36  };
37  const subgraphStack = [];
38  for (let i = 1; i < lines.length; i++) {
39    const line = lines[i];
40    const classDefMatch = line.match(/^classDef\s+(\w+)\s+(.+)$/);
41    if (classDefMatch) {
42      const name = classDefMatch[1];
43      const propsStr = classDefMatch[2];
44      const props = parseStyleProps(propsStr);
45      graph.classDefs.set(name, props);
46      continue;
47    }
48    const classAssignMatch = line.match(/^class\s+([\w,-]+)\s+(\w+)$/);
49    if (classAssignMatch) {
50      const nodeIds = classAssignMatch[1].split(",").map((s) => s.trim());
51      const className = classAssignMatch[2];
52      for (const id of nodeIds) {
53        graph.classAssignments.set(id, className);
54      }
55      continue;
56    }
57    const styleMatch = line.match(/^style\s+([\w,-]+)\s+(.+)$/);
58    if (styleMatch) {
59      const nodeIds = styleMatch[1].split(",").map((s) => s.trim());
60      const props = parseStyleProps(styleMatch[2]);
61      for (const id of nodeIds) {
62        graph.nodeStyles.set(id, { ...graph.nodeStyles.get(id), ...props });
63      }
64      continue;
65    }
66    const linkStyleMatch = line.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
67    if (linkStyleMatch) {
68      const target = linkStyleMatch[1].trim();
69      const props = parseStyleProps(linkStyleMatch[2]);
70      if (target === "default") {
71        graph.linkStyles.set("default", { ...graph.linkStyles.get("default"), ...props });
72      } else {
73        const indices = target.split(",").map((s) => parseInt(s.trim(), 10));
74        for (const idx of indices) {
75          if (!isNaN(idx)) {
76            graph.linkStyles.set(idx, { ...graph.linkStyles.get(idx), ...props });
77          }
78        }
79      }
80      continue;
81    }
82    const dirMatch = line.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
83    if (dirMatch && subgraphStack.length > 0) {
84      subgraphStack[subgraphStack.length - 1].direction = dirMatch[1].toUpperCase();
85      continue;
86    }
87    const subgraphMatch = line.match(/^subgraph\s+(.+)$/);
88    if (subgraphMatch) {
89      const rest = subgraphMatch[1].trim();
90      const bracketMatch = rest.match(/^([\w-]+)\s*\[(.+)\]$/);
91      let id;
92      let label;
93      if (bracketMatch) {
94        id = bracketMatch[1];
95        label = normalizeBrTags(bracketMatch[2]);
96      } else {
97        label = normalizeBrTags(rest);
98        id = rest.replace(/\s+/g, "_").replace(/[^\w]/g, "");
99      }
100      const sg = { id, label, nodeIds: [], children: [] };
101      subgraphStack.push(sg);
102      continue;
103    }
104    if (line === "end") {
105      const completed = subgraphStack.pop();
106      if (completed) {
107        if (subgraphStack.length > 0) {
108          subgraphStack[subgraphStack.length - 1].children.push(completed);
109        } else {
110          graph.subgraphs.push(completed);
111        }
112      }
113      continue;
114    }
115    if (/^(click|accTitle|accDescr)\b/.test(line)) continue;
116    parseEdgeLine(line, graph, subgraphStack);
117  }
118  if (subgraphStack.length > 0) throw new Error("a subgraph left open");
119  return graph;
120}
121function parseStateDiagram(lines) {
122  const graph = {
123    direction: "TD",
124    nodes: /* @__PURE__ */ new Map(),
125    edges: [],
126    subgraphs: [],
127    classDefs: /* @__PURE__ */ new Map(),
128    classAssignments: /* @__PURE__ */ new Map(),
129    nodeStyles: /* @__PURE__ */ new Map(),
130    linkStyles: /* @__PURE__ */ new Map()
131  };
132  const compositeStack = [];
133  const compositeStateIds = /* @__PURE__ */ new Set();
134  let startCount = 0;
135  let endCount = 0;
136  for (let i = 1; i < lines.length; i++) {
137    const line = lines[i];
138    const dirMatch = line.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
139    if (dirMatch) {
140      if (compositeStack.length > 0) {
141        compositeStack[compositeStack.length - 1].direction = dirMatch[1].toUpperCase();
142      } else {
143        graph.direction = dirMatch[1].toUpperCase();
144      }
145      continue;
146    }
147    const linkStyleMatch = line.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
148    if (linkStyleMatch) {
149      const target = linkStyleMatch[1].trim();
150      const props = parseStyleProps(linkStyleMatch[2]);
151      if (target === "default") {
152        graph.linkStyles.set("default", { ...graph.linkStyles.get("default"), ...props });
153      } else {
154        const indices = target.split(",").map((s) => parseInt(s.trim(), 10));
155        for (const idx of indices) {
156          if (!isNaN(idx)) {
157            graph.linkStyles.set(idx, { ...graph.linkStyles.get(idx), ...props });
158          }
159        }
160      }
161      continue;
162    }
163    const compositeMatch = line.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);
164    if (compositeMatch) {
165      const label = compositeMatch[1] ?? compositeMatch[2];
166      const id = compositeMatch[2];
167      const sg = { id, label, nodeIds: [], children: [] };
168      compositeStack.push(sg);
169      compositeStateIds.add(id);
170      graph.nodes.delete(id);
171      continue;
172    }
173    if (line === "}") {
174      const completed = compositeStack.pop();
175      if (completed) {
176        if (compositeStack.length > 0) {
177          compositeStack[compositeStack.length - 1].children.push(completed);
178        } else {
179          graph.subgraphs.push(completed);
180        }
181      }
182      continue;
183    }
184    const stateAliasMatch = line.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);
185    if (stateAliasMatch) {
186      const label = normalizeBrTags(stateAliasMatch[1]);
187      const id = stateAliasMatch[2];
188      registerStateNode(graph, compositeStack, { id, label, shape: "rounded" });
189      continue;
190    }
191    const transitionMatch = line.match(/^(\[\*\]|[\w\p{L}-]+)\s*(-->)\s*(\[\*\]|[\w\p{L}-]+)(?:\s*:\s*(.+))?$/u);
192    if (transitionMatch) {
193      let sourceId = transitionMatch[1];
194      let targetId = transitionMatch[3];
195      const rawTransitionLabel = transitionMatch[4]?.trim();
196      const edgeLabel = rawTransitionLabel ? normalizeBrTags(rawTransitionLabel) : void 0;
197      if (sourceId === "[*]") {
198        startCount++;
199        sourceId = `_start${startCount > 1 ? startCount : ""}`;
200        registerStateNode(graph, compositeStack, { id: sourceId, label: "", shape: "state-start" });
201      } else if (!compositeStateIds.has(sourceId)) {
202        ensureStateNode(graph, compositeStack, sourceId);
203      }
204      if (targetId === "[*]") {
205        endCount++;
206        targetId = `_end${endCount > 1 ? endCount : ""}`;
207        registerStateNode(graph, compositeStack, { id: targetId, label: "", shape: "state-end" });
208      } else if (!compositeStateIds.has(targetId)) {
209        ensureStateNode(graph, compositeStack, targetId);
210      }
211      graph.edges.push({
212        source: sourceId,
213        target: targetId,
214        label: edgeLabel,
215        style: "solid",
216        hasArrowStart: false,
217        hasArrowEnd: true
218      });
219      continue;
220    }
221    const stateDescMatch = line.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);
222    if (stateDescMatch) {
223      const id = stateDescMatch[1];
224      const label = normalizeBrTags(stateDescMatch[2].trim());
225      registerStateNode(graph, compositeStack, { id, label, shape: "rounded" });
226      continue;
227    }
228    if (/^(classDef|class|style|click|accTitle|accDescr)\b/.test(line)) continue;
229    throw new Error(`unparsed statement: ${line}`);
230  }
231  if (compositeStack.length > 0) throw new Error("a composite state left open");
232  return graph;
233}
234function registerStateNode(graph, compositeStack, node) {
235  const existing = graph.nodes.get(node.id);
236  if (!existing || existing.label === existing.id) graph.nodes.set(node.id, node);
237  else if (existing.label !== node.label) existing.label = `${existing.label}
238${node.label}`;
239  if (compositeStack.length > 0) {
240    const current = compositeStack[compositeStack.length - 1];
241    if (!current.nodeIds.includes(node.id)) {
242      current.nodeIds.push(node.id);
243    }
244  }
245}
246function ensureStateNode(graph, compositeStack, id) {
247  if (!graph.nodes.has(id)) {
248    registerStateNode(graph, compositeStack, { id, label: id, shape: "rounded" });
249  } else {
250    if (compositeStack.length > 0) {
251      const current = compositeStack[compositeStack.length - 1];
252      if (!current.nodeIds.includes(id)) {
253        current.nodeIds.push(id);
254      }
255    }
256  }
257}
258function parseStyleProps(propsStr) {
259  const cleaned = propsStr.replace(/;\s*$/, "");
260  const props = {};
261  for (const pair of cleaned.split(",")) {
262    const colonIdx = pair.indexOf(":");
263    if (colonIdx > 0) {
264      const key = pair.slice(0, colonIdx).trim();
265      const val = pair.slice(colonIdx + 1).trim();
266      if (key && val) {
267        props[key] = val;
268      }
269    }
270  }
271  return props;
272}
273var ARROW_REGEX = /^(<)?(-->|-.->|==>|---|-\.-|===)(?:\|([^|]*)\|)?/;
274var TEXT_ARROW_REGEX = /^(<)?(--|-\.|==)\s+(.+?)\s+(-->|---|\.\->|-\.\-|==>|===)/;
275var NODE_PATTERNS = [
276  // Triple delimiters (must be first)
277  { regex: /^([\w-]+)\(\(\((.+?)\)\)\)/, shape: "doublecircle" },
278  // A(((text)))
279  // Double delimiters with mixed brackets
280  { regex: /^([\w-]+)\(\[(.+?)\]\)/, shape: "stadium" },
281  // A([text])
282  { regex: /^([\w-]+)\(\((.+?)\)\)/, shape: "circle" },
283  // A((text))
284  { regex: /^([\w-]+)\[\[(.+?)\]\]/, shape: "subroutine" },
285  // A[[text]]
286  { regex: /^([\w-]+)\[\((.+?)\)\]/, shape: "cylinder" },
287  // A[(text)]
288  // Trapezoid variants — must come before plain [text]
289  { regex: /^([\w-]+)\[\/(.+?)\\\]/, shape: "trapezoid" },
290  // A[/text\]
291  { regex: /^([\w-]+)\[\\(.+?)\/\]/, shape: "trapezoid-alt" },
292  // A[\text/]
293  // Asymmetric flag shape
294  { regex: /^([\w-]+)>(.+?)\]/, shape: "asymmetric" },
295  // A>text]
296  // Double curly braces (hexagon) — must come before single {text}
297  { regex: /^([\w-]+)\{\{(.+?)\}\}/, shape: "hexagon" },
298  // A{{text}}
299  // Single-char delimiters (last — most common, least specific)
300  { regex: /^([\w-]+)\[(.+?)\]/, shape: "rectangle" },
301  // A[text]
302  { regex: /^([\w-]+)\((.+?)\)/, shape: "rounded" },
303  // A(text)
304  { regex: /^([\w-]+)\{(.+?)\}/, shape: "diamond" }
305  // A{text}
306];
307var BARE_NODE_REGEX = /^(\w+(?:-\w+)*)/;
308var CLASS_SHORTHAND_REGEX = /^:::([\w][\w-]*)/;
309function parseEdgeLine(line, graph, subgraphStack) {
310  let remaining = line.trim();
311  const firstGroup = consumeNodeGroup(remaining, graph, subgraphStack);
312  if (!firstGroup || firstGroup.ids.length === 0) throw new Error(`unparsed statement: ${line}`);
313  remaining = firstGroup.remaining.trim();
314  let prevGroupIds = firstGroup.ids;
315  while (remaining.length > 0) {
316    let hasArrowStart;
317    let style;
318    let hasArrowEnd;
319    let edgeLabel;
320    const arrowMatch = remaining.match(ARROW_REGEX);
321    if (arrowMatch) {
322      hasArrowStart = Boolean(arrowMatch[1]);
323      const arrowOp = arrowMatch[2];
324      const rawEdgeLabel = arrowMatch[3]?.trim();
325      edgeLabel = rawEdgeLabel ? normalizeBrTags(rawEdgeLabel) : void 0;
326      remaining = remaining.slice(arrowMatch[0].length).trim();
327      style = arrowStyleFromOp(arrowOp);
328      hasArrowEnd = arrowOp.endsWith(">");
329    } else {
330      const textMatch = remaining.match(TEXT_ARROW_REGEX);
331      if (!textMatch) throw new Error(`unparsed statement: ${line}`);
332      hasArrowStart = Boolean(textMatch[1]);
333      const rawLabel = textMatch[3].trim();
334      edgeLabel = rawLabel ? normalizeBrTags(rawLabel) : void 0;
335      const openOp = textMatch[2];
336      const closeOp = textMatch[4];
337      remaining = remaining.slice(textMatch[0].length).trim();
338      style = textArrowStyleFromOps(openOp, closeOp);
339      hasArrowEnd = closeOp.endsWith(">");
340    }
341    const nextGroup = consumeNodeGroup(remaining, graph, subgraphStack);
342    if (!nextGroup || nextGroup.ids.length === 0) throw new Error(`unparsed statement: ${line}`);
343    remaining = nextGroup.remaining.trim();
344    for (const sourceId of prevGroupIds) {
345      for (const targetId of nextGroup.ids) {
346        graph.edges.push({
347          source: sourceId,
348          target: targetId,
349          label: edgeLabel,
350          style,
351          hasArrowStart,
352          hasArrowEnd
353        });
354      }
355    }
356    prevGroupIds = nextGroup.ids;
357  }
358}
359function consumeNodeGroup(text, graph, subgraphStack) {
360  const first = consumeNode(text, graph, subgraphStack);
361  if (!first) return null;
362  const ids = [first.id];
363  let remaining = first.remaining.trim();
364  while (remaining.startsWith("&")) {
365    remaining = remaining.slice(1).trim();
366    const next = consumeNode(remaining, graph, subgraphStack);
367    if (!next) break;
368    ids.push(next.id);
369    remaining = next.remaining.trim();
370  }
371  return { ids, remaining };
372}
373function consumeNode(text, graph, subgraphStack) {
374  let id = null;
375  let remaining = text;
376  for (const { regex, shape } of NODE_PATTERNS) {
377    const match = text.match(regex);
378    if (match) {
379      id = match[1];
380      const label = normalizeBrTags(match[2]);
381      registerNode(graph, subgraphStack, { id, label, shape });
382      remaining = text.slice(match[0].length);
383      break;
384    }
385  }
386  if (id === null) {
387    const bareMatch = text.match(BARE_NODE_REGEX);
388    if (bareMatch) {
389      id = bareMatch[1];
390      if (!graph.nodes.has(id)) {
391        registerNode(graph, subgraphStack, { id, label: id, shape: "rectangle" });
392      }
393      remaining = text.slice(bareMatch[0].length);
394    }
395  }
396  if (id === null) return null;
397  const classMatch = remaining.match(CLASS_SHORTHAND_REGEX);
398  if (classMatch) {
399    graph.classAssignments.set(id, classMatch[1]);
400    remaining = remaining.slice(classMatch[0].length);
401  }
402  return { id, remaining };
403}
404function registerNode(graph, subgraphStack, node) {
405  graph.nodes.set(node.id, node);
406  trackInSubgraph(subgraphStack, node.id);
407}
408function trackInSubgraph(subgraphStack, nodeId) {
409  if (subgraphStack.length > 0) {
410    const current = subgraphStack[subgraphStack.length - 1];
411    if (!current.nodeIds.includes(nodeId)) {
412      current.nodeIds.push(nodeId);
413    }
414  }
415}
416function arrowStyleFromOp(op) {
417  if (op === "-.->") return "dotted";
418  if (op === "-.-") return "dotted";
419  if (op === "==>") return "thick";
420  if (op === "===") return "thick";
421  return "solid";
422}
423function textArrowStyleFromOps(openOp, closeOp) {
424  if (openOp === "-." || closeOp === ".->" || closeOp === "-.-") return "dotted";
425  if (openOp === "==" || closeOp === "==>" || closeOp === "===") return "thick";
426  return "solid";
427}
428
429// node_modules/beautiful-mermaid/src/ascii/types.ts
430var Up = { x: 1, y: 0 };
431var Down = { x: 1, y: 2 };
432var Left = { x: 0, y: 1 };
433var Right = { x: 2, y: 1 };
434var UpperRight = { x: 2, y: 0 };
435var UpperLeft = { x: 0, y: 0 };
436var LowerRight = { x: 2, y: 2 };
437var LowerLeft = { x: 0, y: 2 };
438var Middle = { x: 1, y: 1 };
439function gridCoordEquals(a, b) {
440  return a.x === b.x && a.y === b.y;
441}
442function drawingCoordEquals(a, b) {
443  return a.x === b.x && a.y === b.y;
444}
445function gridCoordDirection(c, dir) {
446  return { x: c.x + dir.x, y: c.y + dir.y };
447}
448function gridKey(c) {
449  return `${c.x},${c.y}`;
450}
451var EMPTY_STYLE = { name: "", styles: {} };
452
453// node_modules/beautiful-mermaid/src/ascii/pathfinder.ts
454var MinHeap = class {
455  items = [];
456  get length() {
457    return this.items.length;
458  }
459  push(item) {
460    this.items.push(item);
461    this.bubbleUp(this.items.length - 1);
462  }
463  pop() {
464    if (this.items.length === 0) return void 0;
465    const top = this.items[0];
466    const last = this.items.pop();
467    if (this.items.length > 0) {
468      this.items[0] = last;
469      this.sinkDown(0);
470    }
471    return top;
472  }
473  bubbleUp(i) {
474    while (i > 0) {
475      const parent = i - 1 >> 1;
476      if (this.items[i].priority < this.items[parent].priority) {
477        ;
478        [this.items[i], this.items[parent]] = [this.items[parent], this.items[i]];
479        i = parent;
480      } else {
481        break;
482      }
483    }
484  }
485  sinkDown(i) {
486    const n = this.items.length;
487    while (true) {
488      let smallest = i;
489      const left = 2 * i + 1;
490      const right = 2 * i + 2;
491      if (left < n && this.items[left].priority < this.items[smallest].priority) {
492        smallest = left;
493      }
494      if (right < n && this.items[right].priority < this.items[smallest].priority) {
495        smallest = right;
496      }
497      if (smallest !== i) {
498        ;
499        [this.items[i], this.items[smallest]] = [this.items[smallest], this.items[i]];
500        i = smallest;
501      } else {
502        break;
503      }
504    }
505  }
506};
507function heuristic(a, b) {
508  const absX = Math.abs(a.x - b.x);
509  const absY = Math.abs(a.y - b.y);
510  if (absX === 0 || absY === 0) {
511    return absX + absY;
512  }
513  return absX + absY + 1;
514}
515var MOVE_DIRS = [
516  { x: 1, y: 0 },
517  { x: -1, y: 0 },
518  { x: 0, y: 1 },
519  { x: 0, y: -1 }
520];
521function isFreeInGrid(grid, c) {
522  if (c.x < 0 || c.y < 0) return false;
523  return !grid.has(gridKey(c));
524}
525var pathWork = { spent: 0, limit: 4e5, capped: false };
526function getPath(grid, from, to) {
527  const pq = new MinHeap();
528  pq.push({ coord: from, priority: 0 });
529  const costSoFar = /* @__PURE__ */ new Map();
530  costSoFar.set(gridKey(from), 0);
531  const cameFrom = /* @__PURE__ */ new Map();
532  cameFrom.set(gridKey(from), null);
533  const MAX_EXPANSIONS = 4e4;
534  let expansions = 0;
535  pathWork.capped = false;
536  while (pq.length > 0) {
537    if (++expansions > MAX_EXPANSIONS) {
538      pathWork.capped = true;
539      return null;
540    }
541    if (++pathWork.spent > pathWork.limit) throw new Error("too complex to lay out");
542    const current = pq.pop().coord;
543    if (gridCoordEquals(current, to)) {
544      const path = [];
545      let c = current;
546      while (c !== null) {
547        path.unshift(c);
548        c = cameFrom.get(gridKey(c)) ?? null;
549      }
550      return path;
551    }
552    const currentCost = costSoFar.get(gridKey(current));
553    for (const dir of MOVE_DIRS) {
554      const next = { x: current.x + dir.x, y: current.y + dir.y };
555      if (!isFreeInGrid(grid, next) && !gridCoordEquals(next, to)) {
556        continue;
557      }
558      const newCost = currentCost + 1;
559      const nextKey = gridKey(next);
560      const existingCost = costSoFar.get(nextKey);
561      if (existingCost === void 0 || newCost < existingCost) {
562        costSoFar.set(nextKey, newCost);
563        const priority = newCost + heuristic(next, to);
564        pq.push({ coord: next, priority });
565        cameFrom.set(nextKey, current);
566      }
567    }
568  }
569  return null;
570}
571function mergePath(path) {
572  if (path.length <= 2) return path;
573  const toRemove = /* @__PURE__ */ new Set();
574  let step0 = path[0];
575  let step1 = path[1];
576  for (let idx = 2; idx < path.length; idx++) {
577    const step2 = path[idx];
578    const prevDx = step1.x - step0.x;
579    const prevDy = step1.y - step0.y;
580    const dx = step2.x - step1.x;
581    const dy = step2.y - step1.y;
582    if (prevDx === dx && prevDy === dy) {
583      toRemove.add(idx - 1);
584    }
585    step0 = step1;
586    step1 = step2;
587  }
588  return path.filter((_, i) => !toRemove.has(i));
589}
590
591// node_modules/beautiful-mermaid/src/ascii/ansi.ts
592var DEFAULT_ASCII_THEME = {
593  fg: "#27272a",
594  // zinc-800 — primary text
595  border: "#a1a1aa",
596  // zinc-400 — node borders (12% mix)
597  line: "#71717a",
598  // zinc-500 — edge lines (35% mix)
599  arrow: "#52525b",
600  // zinc-600 — arrowheads (60% mix)
601  corner: "#71717a",
602  // same as line
603  junction: "#a1a1aa"
604  // same as border
605};
606function detectColorMode() {
607  const proc = globalThis.process;
608  if (proc) {
609    if (!proc.stdout?.isTTY) {
610      return "none";
611    }
612    const colorTerm = proc.env?.COLORTERM?.toLowerCase() ?? "";
613    const term = proc.env?.TERM?.toLowerCase() ?? "";
614    if (colorTerm === "truecolor" || colorTerm === "24bit") {
615      return "truecolor";
616    }
617    if (term.includes("256color") || term.includes("256")) {
618      return "ansi256";
619    }
620    if (term && term !== "dumb") {
621      return "ansi16";
622    }
623    return "none";
624  }
625  if (typeof document !== "undefined") {
626    return "html";
627  }
628  return "none";
629}
630function parseHex(hex) {
631  const h = hex.replace("#", "");
632  if (h.length === 3) {
633    return {
634      r: parseInt(h[0] + h[0], 16),
635      g: parseInt(h[1] + h[1], 16),
636      b: parseInt(h[2] + h[2], 16)
637    };
638  }
639  return {
640    r: parseInt(h.substring(0, 2), 16),
641    g: parseInt(h.substring(2, 4), 16),
642    b: parseInt(h.substring(4, 6), 16)
643  };
644}
645var ESC = "\x1B[";
646var RESET = `${ESC}0m`;
647function truecolorFg(hex) {
648  const { r, g, b } = parseHex(hex);
649  return `${ESC}38;2;${r};${g};${b}m`;
650}
651function rgbTo256(r, g, b) {
652  const avg = (r + g + b) / 3;
653  const maxDiff = Math.max(Math.abs(r - avg), Math.abs(g - avg), Math.abs(b - avg));
654  if (maxDiff < 10) {
655    const gray = Math.round(avg / 255 * 23);
656    return 232 + Math.min(23, Math.max(0, gray));
657  }
658  const toIndex = (v) => {
659    if (v < 48) return 0;
660    if (v < 115) return 1;
661    return Math.min(5, Math.floor((v - 35) / 40));
662  };
663  const ri = toIndex(r);
664  const gi = toIndex(g);
665  const bi = toIndex(b);
666  return 16 + 36 * ri + 6 * gi + bi;
667}
668function ansi256Fg(hex) {
669  const { r, g, b } = parseHex(hex);
670  const index = rgbTo256(r, g, b);
671  return `${ESC}38;5;${index}m`;
672}
673function ansi16Fg(hex) {
674  const { r, g, b } = parseHex(hex);
675  const luma = 0.299 * r + 0.587 * g + 0.114 * b;
676  const bright = luma > 100 ? 0 : 60;
677  let code;
678  if (r > 180 && g < 100 && b < 100) code = 31;
679  else if (g > 180 && r < 100 && b < 100) code = 32;
680  else if (r > 150 && g > 150 && b < 100) code = 33;
681  else if (b > 180 && r < 100 && g < 100) code = 34;
682  else if (r > 150 && b > 150 && g < 100) code = 35;
683  else if (g > 150 && b > 150 && r < 100) code = 36;
684  else if (luma > 200) code = 37;
685  else if (luma < 50) code = 30;
686  else code = 37;
687  return `${ESC}${code + bright}m`;
688}
689function escapeHtml(text) {
690  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
691}
692function htmlSpan(hex, text) {
693  return `<span style="color:${hex}">${escapeHtml(text)}</span>`;
694}
695function getRoleColor(role, theme) {
696  switch (role) {
697    case "text":
698      return theme.fg;
699    case "border":
700      return theme.border;
701    case "line":
702      return theme.line;
703    case "arrow":
704      return theme.arrow;
705    case "corner":
706      return theme.corner ?? theme.line;
707    case "junction":
708      return theme.junction ?? theme.border;
709    default:
710      return theme.fg;
711  }
712}
713function getAnsiColor(role, theme, mode) {
714  if (mode === "none") return "";
715  const hex = getRoleColor(role, theme);
716  switch (mode) {
717    case "truecolor":
718      return truecolorFg(hex);
719    case "ansi256":
720      return ansi256Fg(hex);
721    case "ansi16":
722      return ansi16Fg(hex);
723    default:
724      return "";
725  }
726}
727function colorizeLine(chars, roles, theme, mode) {
728  if (mode === "none") {
729    return chars.join("");
730  }
731  if (mode === "html") {
732    return colorizeLineHtml(chars, roles, theme);
733  }
734  let result = "";
735  let currentRole = null;
736  let buffer = "";
737  for (let i = 0; i < chars.length; i++) {
738    const char = chars[i];
739    const role = roles[i] ?? null;
740    if (char === " ") {
741      if (buffer.length > 0) {
742        if (currentRole !== null) {
743          result += getAnsiColor(currentRole, theme, mode) + buffer + RESET;
744        } else {
745          result += buffer;
746        }
747        buffer = "";
748        currentRole = null;
749      }
750      result += char;
751      continue;
752    }
753    if (role === currentRole) {
754      buffer += char;
755      continue;
756    }
757    if (buffer.length > 0) {
758      if (currentRole !== null) {
759        result += getAnsiColor(currentRole, theme, mode) + buffer + RESET;
760      } else {
761        result += buffer;
762      }
763    }
764    buffer = char;
765    currentRole = role;
766  }
767  if (buffer.length > 0 && currentRole !== null) {
768    result += getAnsiColor(currentRole, theme, mode) + buffer + RESET;
769  } else if (buffer.length > 0) {
770    result += buffer;
771  }
772  return result;
773}
774function colorizeLineHtml(chars, roles, theme) {
775  let result = "";
776  let currentRole = null;
777  let buffer = "";
778  const flush = () => {
779    if (buffer.length === 0) return;
780    if (currentRole !== null) {
781      result += htmlSpan(getRoleColor(currentRole, theme), buffer);
782    } else {
783      result += escapeHtml(buffer);
784    }
785    buffer = "";
786    currentRole = null;
787  };
788  for (let i = 0; i < chars.length; i++) {
789    const char = chars[i];
790    const role = roles[i] ?? null;
791    if (char === " ") {
792      flush();
793      result += " ";
794      continue;
795    }
796    if (role === currentRole) {
797      buffer += char;
798      continue;
799    }
800    flush();
801    buffer = char;
802    currentRole = role;
803  }
804  flush();
805  return result;
806}
807function colorizeText(text, hex, mode) {
808  if (mode === "none" || text.length === 0) return text;
809  if (mode === "html") return htmlSpan(hex, text);
810  let code;
811  switch (mode) {
812    case "truecolor":
813      code = truecolorFg(hex);
814      break;
815    case "ansi256":
816      code = ansi256Fg(hex);
817      break;
818    case "ansi16":
819      code = ansi16Fg(hex);
820      break;
821    default:
822      return text;
823  }
824  return `${code}${text}${RESET}`;
825}
826
827// node_modules/beautiful-mermaid/src/ascii/canvas.ts
828function mkCanvas(x, y) {
829  if ((x + 1) * (y + 1) > 25e4) throw new Error(`too big to lay out (${(x + 1) * (y + 1)} canvas cells)`);
830  const canvas = [];
831  for (let i = 0; i <= x; i++) {
832    const col = [];
833    for (let j = 0; j <= y; j++) {
834      col.push(" ");
835    }
836    canvas.push(col);
837  }
838  return canvas;
839}
840function copyCanvas(source) {
841  const [maxX, maxY] = getCanvasSize(source);
842  return mkCanvas(maxX, maxY);
843}
844function mkRoleCanvas(x, y) {
845  if ((x + 1) * (y + 1) > 25e4) throw new Error(`too big to lay out (${(x + 1) * (y + 1)} canvas cells)`);
846  const roleCanvas = [];
847  for (let i = 0; i <= x; i++) {
848    const col = [];
849    for (let j = 0; j <= y; j++) {
850      col.push(null);
851    }
852    roleCanvas.push(col);
853  }
854  return roleCanvas;
855}
856function increaseRoleCanvasSize(roleCanvas, newX, newY) {
857  const currX = roleCanvas.length - 1;
858  const currY = (roleCanvas[0]?.length ?? 1) - 1;
859  const targetX = Math.max(newX, currX);
860  const targetY = Math.max(newY, currY);
861  const grown = mkRoleCanvas(targetX, targetY);
862  for (let x = 0; x < grown.length; x++) {
863    for (let y = 0; y < grown[0].length; y++) {
864      if (x < roleCanvas.length && y < roleCanvas[0].length) {
865        grown[x][y] = roleCanvas[x][y];
866      }
867    }
868  }
869  roleCanvas.length = 0;
870  roleCanvas.push(...grown);
871  return roleCanvas;
872}
873function setRole(roleCanvas, x, y, role) {
874  if (x >= roleCanvas.length || y >= (roleCanvas[0]?.length ?? 0)) {
875    increaseRoleCanvasSize(roleCanvas, x, y);
876  }
877  roleCanvas[x][y] = role;
878}
879function getCanvasSize(canvas) {
880  return [canvas.length - 1, (canvas[0]?.length ?? 1) - 1];
881}
882function increaseSize(canvas, newX, newY) {
883  const [currX, currY] = getCanvasSize(canvas);
884  const targetX = Math.max(newX, currX);
885  const targetY = Math.max(newY, currY);
886  const grown = mkCanvas(targetX, targetY);
887  for (let x = 0; x < grown.length; x++) {
888    for (let y = 0; y < grown[0].length; y++) {
889      if (x < canvas.length && y < canvas[0].length) {
890        grown[x][y] = canvas[x][y];
891      }
892    }
893  }
894  canvas.length = 0;
895  canvas.push(...grown);
896  return canvas;
897}
898var JUNCTION_CHARS = /* @__PURE__ */ new Set([
899  "\u2500",
900  "\u2502",
901  "\u250C",
902  "\u2510",
903  "\u2514",
904  "\u2518",
905  "\u251C",
906  "\u2524",
907  "\u252C",
908  "\u2534",
909  "\u253C",
910  "\u2574",
911  "\u2575",
912  "\u2576",
913  "\u2577"
914]);
915function isJunctionChar(c) {
916  return JUNCTION_CHARS.has(c);
917}
918function isAlphanumeric(c) {
919  return /^[a-zA-Z0-9]$/.test(c);
920}
921var JUNCTION_MAP = {
922  "\u2500": { "\u2502": "\u253C", "\u250C": "\u252C", "\u2510": "\u252C", "\u2514": "\u2534", "\u2518": "\u2534", "\u251C": "\u253C", "\u2524": "\u253C", "\u252C": "\u252C", "\u2534": "\u2534" },
923  "\u2502": { "\u2500": "\u253C", "\u250C": "\u251C", "\u2510": "\u2524", "\u2514": "\u251C", "\u2518": "\u2524", "\u251C": "\u251C", "\u2524": "\u2524", "\u252C": "\u253C", "\u2534": "\u253C" },
924  "\u250C": { "\u2500": "\u252C", "\u2502": "\u251C", "\u2510": "\u252C", "\u2514": "\u251C", "\u2518": "\u253C", "\u251C": "\u251C", "\u2524": "\u253C", "\u252C": "\u252C", "\u2534": "\u253C" },
925  "\u2510": { "\u2500": "\u252C", "\u2502": "\u2524", "\u250C": "\u252C", "\u2514": "\u253C", "\u2518": "\u2524", "\u251C": "\u253C", "\u2524": "\u2524", "\u252C": "\u252C", "\u2534": "\u253C" },
926  "\u2514": { "\u2500": "\u2534", "\u2502": "\u251C", "\u250C": "\u251C", "\u2510": "\u253C", "\u2518": "\u2534", "\u251C": "\u251C", "\u2524": "\u253C", "\u252C": "\u253C", "\u2534": "\u2534" },
927  "\u2518": { "\u2500": "\u2534", "\u2502": "\u2524", "\u250C": "\u253C", "\u2510": "\u2524", "\u2514": "\u2534", "\u251C": "\u253C", "\u2524": "\u2524", "\u252C": "\u253C", "\u2534": "\u2534" },
928  "\u251C": { "\u2500": "\u253C", "\u2502": "\u251C", "\u250C": "\u251C", "\u2510": "\u253C", "\u2514": "\u251C", "\u2518": "\u253C", "\u2524": "\u253C", "\u252C": "\u253C", "\u2534": "\u253C" },
929  "\u2524": { "\u2500": "\u253C", "\u2502": "\u2524", "\u250C": "\u253C", "\u2510": "\u2524", "\u2514": "\u253C", "\u2518": "\u2524", "\u251C": "\u253C", "\u252C": "\u253C", "\u2534": "\u253C" },
930  "\u252C": { "\u2500": "\u252C", "\u2502": "\u253C", "\u250C": "\u252C", "\u2510": "\u252C", "\u2514": "\u253C", "\u2518": "\u253C", "\u251C": "\u253C", "\u2524": "\u253C", "\u2534": "\u253C" },
931  "\u2534": { "\u2500": "\u2534", "\u2502": "\u253C", "\u250C": "\u253C", "\u2510": "\u253C", "\u2514": "\u2534", "\u2518": "\u2534", "\u251C": "\u253C", "\u2524": "\u253C", "\u252C": "\u253C" }
932};
933function mergeJunctions(c1, c2) {
934  return JUNCTION_MAP[c1]?.[c2] ?? c1;
935}
936function mergeCanvases(base, offset, useAscii, ...overlays) {
937  let [maxX, maxY] = getCanvasSize(base);
938  for (const overlay of overlays) {
939    const [oX, oY] = getCanvasSize(overlay);
940    maxX = Math.max(maxX, oX + offset.x);
941    maxY = Math.max(maxY, oY + offset.y);
942  }
943  const merged = mkCanvas(maxX, maxY);
944  for (let x = 0; x <= maxX; x++) {
945    for (let y = 0; y <= maxY; y++) {
946      if (x < base.length && y < base[0].length) {
947        merged[x][y] = base[x][y];
948      }
949    }
950  }
951  for (const overlay of overlays) {
952    for (let x = 0; x < overlay.length; x++) {
953      for (let y = 0; y < overlay[0].length; y++) {
954        const c = overlay[x][y];
955        const under = merged[x + offset.x]?.[y + offset.y];
956        if (c === "\uE001" && under !== " " && under !== "\u2500" && under !== "-") continue;
957        if (c !== " ") {
958          const mx = x + offset.x;
959          const my = y + offset.y;
960          const current = merged[mx][my];
961          if (!useAscii && isJunctionChar(c) && isJunctionChar(current)) {
962            merged[mx][my] = mergeJunctions(current, c);
963          } else if (isAlphanumeric(current) && isAlphanumeric(c)) {
964          } else {
965            merged[mx][my] = c;
966          }
967        }
968      }
969    }
970  }
971  return merged;
972}
973function canvasToString(canvas, options) {
974  const [maxX, maxY] = getCanvasSize(canvas);
975  const lines = [];
976  const roleCanvas = options?.roleCanvas;
977  const colorMode = options?.colorMode ?? "none";
978  const theme = options?.theme ?? DEFAULT_ASCII_THEME;
979  for (let y = 0; y <= maxY; y++) {
980    if (colorMode === "none" || !roleCanvas) {
981      let line = "";
982      for (let x = 0; x <= maxX; x++) {
983        line += canvas[x][y];
984      }
985      lines.push(line);
986    } else {
987      const chars = [];
988      const roles = [];
989      for (let x = 0; x <= maxX; x++) {
990        chars.push(canvas[x][y]);
991        roles.push(roleCanvas[x]?.[y] ?? null);
992      }
993      lines.push(colorizeLine(chars, roles, theme, colorMode));
994    }
995  }
996  return lines.join("\n");
997}
998var VERTICAL_FLIP_MAP = {
999  // Unicode arrows
1000  "\u25B2": "\u25BC",
1001  "\u25BC": "\u25B2",
1002  "\u25E4": "\u25E3",
1003  "\u25E3": "\u25E4",
1004  "\u25E5": "\u25E2",
1005  "\u25E2": "\u25E5",
1006  // ASCII arrows
1007  "^": "v",
1008  "v": "^",
1009  // Unicode corners
1010  "\u250C": "\u2514",
1011  "\u2514": "\u250C",
1012  "\u2510": "\u2518",
1013  "\u2518": "\u2510",
1014  // Unicode junctions (T-pieces flip vertically)
1015  "\u252C": "\u2534",
1016  "\u2534": "\u252C",
1017  // Box-start junctions (exit points from node boxes)
1018  "\u2575": "\u2577",
1019  "\u2577": "\u2575"
1020};
1021function flipCanvasVertically(canvas) {
1022  for (const col of canvas) {
1023    col.reverse();
1024  }
1025  for (const col of canvas) {
1026    for (let y = 0; y < col.length; y++) {
1027      const flipped = VERTICAL_FLIP_MAP[col[y]];
1028      if (flipped) col[y] = flipped;
1029    }
1030  }
1031  return canvas;
1032}
1033function flipRoleCanvasVertically(roleCanvas) {
1034  for (const col of roleCanvas) {
1035    col.reverse();
1036  }
1037  return roleCanvas;
1038}
1039function drawText(canvas, start, text, forceOverwrite = false) {
1040  increaseSize(canvas, start.x + text.length, start.y);
1041  for (let i = 0; i < text.length; i++) {
1042    const x = start.x + i;
1043    const current = canvas[x][start.y];
1044    if (forceOverwrite || current === " ") {
1045      canvas[x][start.y] = text[i];
1046    }
1047  }
1048}
1049function setCanvasSizeToGrid(canvas, columnWidth, rowHeight) {
1050  let maxX = 0;
1051  let maxY = 0;
1052  for (const w of columnWidth.values()) maxX += w;
1053  for (const h of rowHeight.values()) maxY += h;
1054  increaseSize(canvas, maxX - 1, maxY - 1);
1055}
1056function setRoleCanvasSizeToGrid(roleCanvas, columnWidth, rowHeight) {
1057  let maxX = 0;
1058  let maxY = 0;
1059  for (const w of columnWidth.values()) maxX += w;
1060  for (const h of rowHeight.values()) maxY += h;
1061  increaseRoleCanvasSize(roleCanvas, maxX - 1, maxY - 1);
1062}
1063
1064// node_modules/beautiful-mermaid/src/ascii/converter.ts
1065function convertToAsciiGraph(parsed, config) {
1066  const nodeMap = /* @__PURE__ */ new Map();
1067  let index = 0;
1068  for (const [id, mNode] of parsed.nodes) {
1069    const asciiNode = {
1070      // Use the parser ID as the unique identity key to avoid collisions
1071      // when multiple nodes share the same label (e.g. A[Web Server], C[Web Server]).
1072      name: id,
1073      // The label is used for rendering inside the box.
1074      displayLabel: mNode.label,
1075      // Preserve shape from parser for shape-aware rendering
1076      shape: mNode.shape,
1077      index,
1078      gridCoord: null,
1079      drawingCoord: null,
1080      drawing: null,
1081      drawn: false,
1082      styleClassName: "",
1083      styleClass: EMPTY_STYLE
1084    };
1085    nodeMap.set(id, asciiNode);
1086    index++;
1087  }
1088  const nodes = [...nodeMap.values()];
1089  const edges = [];
1090  for (const mEdge of parsed.edges) {
1091    const from = nodeMap.get(mEdge.source);
1092    const to = nodeMap.get(mEdge.target);
1093    if (!from || !to) continue;
1094    edges.push({
1095      from,
1096      to,
1097      text: mEdge.label ?? "",
1098      path: [],
1099      labelLine: [],
1100      startDir: { x: 0, y: 0 },
1101      endDir: { x: 0, y: 0 },
1102      style: mEdge.style,
1103      hasArrowStart: mEdge.hasArrowStart,
1104      hasArrowEnd: mEdge.hasArrowEnd
1105    });
1106  }
1107  const subgraphs = [];
1108  for (const mSg of parsed.subgraphs) {
1109    convertSubgraph(mSg, null, nodeMap, subgraphs);
1110  }
1111  deduplicateSubgraphNodes(parsed.subgraphs, subgraphs, nodeMap, parsed);
1112  for (const [nodeId, className] of parsed.classAssignments) {
1113    const node = nodeMap.get(nodeId);
1114    const classDef = parsed.classDefs.get(className);
1115    if (node && classDef) {
1116      node.styleClassName = className;
1117      node.styleClass = { name: className, styles: classDef };
1118    }
1119  }
1120  return {
1121    nodes,
1122    edges,
1123    canvas: mkCanvas(0, 0),
1124    roleCanvas: mkRoleCanvas(0, 0),
1125    grid: /* @__PURE__ */ new Map(),
1126    columnWidth: /* @__PURE__ */ new Map(),
1127    rowHeight: /* @__PURE__ */ new Map(),
1128    subgraphs,
1129    config,
1130    offsetX: 0,
1131    offsetY: 0,
1132    bundles: []
1133    // Populated by analyzeEdgeBundles() during layout
1134  };
1135}
1136function convertSubgraph(mSg, parent, nodeMap, allSubgraphs) {
1137  let normalizedDirection;
1138  if (mSg.direction) {
1139    normalizedDirection = mSg.direction === "LR" || mSg.direction === "RL" ? "LR" : "TD";
1140  }
1141  const sg = {
1142    name: mSg.label,
1143    nodes: [],
1144    parent,
1145    children: [],
1146    minX: 0,
1147    minY: 0,
1148    maxX: 0,
1149    maxY: 0,
1150    direction: normalizedDirection
1151  };
1152  for (const nodeId of mSg.nodeIds) {
1153    const node = nodeMap.get(nodeId);
1154    if (node) sg.nodes.push(node);
1155  }
1156  allSubgraphs.push(sg);
1157  for (const childMSg of mSg.children) {
1158    const child = convertSubgraph(childMSg, sg, nodeMap, allSubgraphs);
1159    sg.children.push(child);
1160    for (const childNode of child.nodes) {
1161      if (!sg.nodes.includes(childNode)) {
1162        sg.nodes.push(childNode);
1163      }
1164    }
1165  }
1166  return sg;
1167}
1168function deduplicateSubgraphNodes(mermaidSubgraphs, asciiSubgraphs, nodeMap, parsed) {
1169  const sgMap = /* @__PURE__ */ new Map();
1170  buildSgMap(mermaidSubgraphs, asciiSubgraphs, sgMap);
1171  const nodeOwner = /* @__PURE__ */ new Map();
1172  function claimNodes(mSg) {
1173    const asciiSg = sgMap.get(mSg);
1174    if (!asciiSg) return;
1175    for (const child of mSg.children) {
1176      claimNodes(child);
1177    }
1178    for (const nodeId of mSg.nodeIds) {
1179      if (!nodeOwner.has(nodeId)) {
1180        nodeOwner.set(nodeId, asciiSg);
1181      }
1182    }
1183  }
1184  for (const mSg of mermaidSubgraphs) {
1185    claimNodes(mSg);
1186  }
1187  for (const asciiSg of asciiSubgraphs) {
1188    asciiSg.nodes = asciiSg.nodes.filter((node) => {
1189      let nodeId;
1190      for (const [id, n] of nodeMap) {
1191        if (n === node) {
1192          nodeId = id;
1193          break;
1194        }
1195      }
1196      if (!nodeId) return false;
1197      const owner = nodeOwner.get(nodeId);
1198      if (!owner) return true;
1199      return isAncestorOrSelf(asciiSg, owner);
1200    });
hooks/vendor/math/mathjax.js 15 lines
1// Generated by scripts/build-vendor.mjs from mathjax-full (Apache-2.0, see hooks/vendor/LICENSE-mathjax). Do not edit.
2import{a as Ec,b as Ba,c as Lc,d as kc,e as Jt,f as dn,g as yn,h as C,i as Ti,j as Ta,k as Na,l as Vc,m as Ni,n as qc,o as Ea,p as Dc,q as Gc,r as Ic,s as La,t as Wc,u as Ei,v as Kr,w as Fc,x as ka,y as Rc,z as Hc}from"./chunk-VNJGBPWC.js";import{a as Xc}from"./chunk-BDTJHJJV.js";import{a as Va}from"./chunk-EJW2DPPI.js";import{a as m,b as qe,c as Xe}from"./chunk-ATNJRYB5.js";var Li=m(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.AbstractOutputJax=void 0;var qa=Xe(),zc=Lc(),Jc=(function(){function i(r){r===void 0&&(r={}),this.adaptor=null;var t=this.constructor;this.options=(0,qa.userOptions)((0,qa.defaultOptions)({},t.OPTIONS),r),this.postFilters=new zc.FunctionList}return Object.defineProperty(i.prototype,"name",{get:function(){return this.constructor.NAME},enumerable:!1,configurable:!0}),i.prototype.setAdaptor=function(r){this.adaptor=r},i.prototype.initialize=function(){},i.prototype.reset=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t]},i.prototype.getMetrics=function(r){},i.prototype.styleSheet=function(r){return null},i.prototype.pageElements=function(r){return null},i.prototype.executeFilters=function(r,t,e,n){var o={math:t,document:e,data:n};return r.execute(o),o.data},i.NAME="generic",i.OPTIONS={},i})();vn.AbstractOutputJax=Jc});var xn=m(jt=>{"use strict";var nt=jt&&jt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},ki=jt&&jt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Kc=jt&&jt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(jt,"__esModule",{value:!0});jt.Styles=void 0;var Ur=["top","right","bottom","left"],mn=["width","style","color"];function Vi(i){for(var r=i.split(/((?:'[^']*'|"[^"]*"|,[\s\n]|[^\s\n])*)/g),t=[];r.length>1;)r.shift(),t.push(r.shift());return t}function gn(i){var r,t,e=Vi(this.styles[i]);e.length===0&&e.push(""),e.length===1&&e.push(e[0]),e.length===2&&e.push(e[0]),e.length===3&&e.push(e[1]);try{for(var n=nt(Zt.connect[i].children),o=n.next();!o.done;o=n.next()){var a=o.value;this.setStyle(this.childName(i,a),e.shift())}}catch(s){r={error:s}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}}function Uc(i){var r,t,e=Zt.connect[i].children,n=[];try{for(var o=nt(e),a=o.next();!a.done;a=o.next()){var s=a.value,l=this.styles[i+"-"+s];if(!l){delete this.styles[i];return}n.push(l)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}n[3]===n[1]&&(n.pop(),n[2]===n[0]&&(n.pop(),n[1]===n[0]&&n.pop())),this.styles[i]=n.join(" ")}function $c(i){var r,t;try{for(var e=nt(Zt.connect[i].children),n=e.next();!n.done;n=e.next()){var o=n.value;this.setStyle(this.childName(i,o),this.styles[i])}}catch(a){r={error:a}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(r)throw r.error}}}function Yc(i){var r,t,e=Kc([],ki(Zt.connect[i].children),!1),n=this.styles[this.childName(i,e.shift())];try{for(var o=nt(e),a=o.next();!a.done;a=o.next()){var s=a.value;if(this.styles[this.childName(i,s)]!==n){delete this.styles[i];return}}}catch(l){r={error:l}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}this.styles[i]=n}var Da={width:/^(?:[\d.]+(?:[a-z]+)|thin|medium|thick|inherit|initial|unset)$/,style:/^(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|inherit|initial|unset)$/};function _n(i){var r,t,e,n,o={width:"",style:"",color:""};try{for(var a=nt(Vi(this.styles[i])),s=a.next();!s.done;s=a.next()){var l=s.value;l.match(Da.width)&&o.width===""?o.width=l:l.match(Da.style)&&o.style===""?o.style=l:o.color=l}}catch(h){r={error:h}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}try{for(var u=nt(Zt.connect[i].children),c=u.next();!c.done;c=u.next()){var f=c.value;this.setStyle(this.childName(i,f),o[f])}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}}function wn(i){var r,t,e=[];try{for(var n=nt(Zt.connect[i].children),o=n.next();!o.done;o=n.next()){var a=o.value,s=this.styles[this.childName(i,a)];s&&e.push(s)}}catch(l){r={error:l}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}e.length?this.styles[i]=e.join(" "):delete this.styles[i]}var Ga={style:/^(?:normal|italic|oblique|inherit|initial|unset)$/,variant:new RegExp("^(?:"+["normal|none","inherit|initial|unset","common-ligatures|no-common-ligatures","discretionary-ligatures|no-discretionary-ligatures","historical-ligatures|no-historical-ligatures","contextual|no-contextual","(?:stylistic|character-variant|swash|ornaments|annotation)\\([^)]*\\)","small-caps|all-small-caps|petite-caps|all-petite-caps|unicase|titling-caps","lining-nums|oldstyle-nums|proportional-nums|tabular-nums","diagonal-fractions|stacked-fractions","ordinal|slashed-zero","jis78|jis83|jis90|jis04|simplified|traditional","full-width|proportional-width","ruby"].join("|")+")$"),weight:/^(?:normal|bold|bolder|lighter|[1-9]00|inherit|initial|unset)$/,stretch:new RegExp("^(?:"+["normal","(?:(?:ultra|extra|semi)-)?condensed","(?:(?:semi|extra|ulta)-)?expanded","inherit|initial|unset"].join("|")+")$"),size:new RegExp("^(?:"+["xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller","[d.]+%|[d.]+[a-z]+","inherit|initial|unset"].join("|")+")(?:/(?:normal|[d.+](?:%|[a-z]+)?))?$")};function Qc(i){var r,t,e,n,o=Vi(this.styles[i]),a={style:"",variant:[],weight:"",stretch:"",size:"",family:"","line-height":""};try{for(var s=nt(o),l=s.next();!l.done;l=s.next()){var u=l.value;a.family=u;try{for(var c=(e=void 0,nt(Object.keys(Ga))),f=c.next();!f.done;f=c.next()){var h=f.value;if((Array.isArray(a[h])||a[h]==="")&&u.match(Ga[h]))if(h==="size"){var p=ki(u.split(/\//),2),d=p[0],y=p[1];a[h]=d,y&&(a["line-height"]=y)}else a.size===""&&(Array.isArray(a[h])?a[h].push(u):a[h]=u)}}catch(v){e={error:v}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}}}catch(v){r={error:v}}finally{try{l&&!l.done&&(t=s.return)&&t.call(s)}finally{if(r)throw r.error}}Zc(i,a),delete this.styles[i]}function Zc(i,r){var t,e;try{for(var n=nt(Zt.connect[i].children),o=n.next();!o.done;o=n.next()){var a=o.value,s=this.childName(i,a);if(Array.isArray(r[a])){var l=r[a];l.length&&(this.styles[s]=l.join(" "))}else r[a]!==""&&(this.styles[s]=r[a])}}catch(u){t={error:u}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}}function tf(i){}var Zt=(function(){function i(r){r===void 0&&(r=""),this.parse(r)}return Object.defineProperty(i.prototype,"cssText",{get:function(){var r,t,e=[];try{for(var n=nt(Object.keys(this.styles)),o=n.next();!o.done;o=n.next()){var a=o.value,s=this.parentName(a);this.styles[s]||e.push(a+": "+this.styles[a]+";")}}catch(l){r={error:l}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}return e.join(" ")},enumerable:!1,configurable:!0}),i.prototype.set=function(r,t){for(r=this.normalizeName(r),this.setStyle(r,t),i.connect[r]&&!i.connect[r].combine&&(this.combineChildren(r),delete this.styles[r]);r.match(/-/)&&(r=this.parentName(r),!!i.connect[r]);)i.connect[r].combine.call(this,r)},i.prototype.get=function(r){return r=this.normalizeName(r),this.styles.hasOwnProperty(r)?this.styles[r]:""},i.prototype.setStyle=function(r,t){this.styles[r]=t,i.connect[r]&&i.connect[r].children&&i.connect[r].split.call(this,r),t===""&&delete this.styles[r]},i.prototype.combineChildren=function(r){var t,e,n=this.parentName(r);try{for(var o=nt(i.connect[r].children),a=o.next();!a.done;a=o.next()){var s=a.value,l=this.childName(n,s);i.connect[l].combine.call(this,l)}}catch(u){t={error:u}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}},i.prototype.parentName=function(r){var t=r.replace(/-[^-]*$/,"");return r===t?"":t},i.prototype.childName=function(r,t){return t.match(/-/)?t:(i.connect[r]&&!i.connect[r].combine&&(t+=r.replace(/.*-/,"-"),r=this.parentName(r)),r+"-"+t)},i.prototype.normalizeName=function(r){return r.replace(/[A-Z]/g,function(t){return"-"+t.toLowerCase()})},i.prototype.parse=function(r){r===void 0&&(r="");var t=this.constructor.pattern;this.styles={};for(var e=r.replace(t.comment,"").split(t.style);e.length>1;){var n=ki(e.splice(0,3),3),o=n[0],a=n[1],s=n[2];if(o.match(/[^\s\n]/))return;this.set(a,s)}},i.pattern={style:/([-a-z]+)[\s\n]*:[\s\n]*((?:'[^']*'|"[^"]*"|\n|.)*?)[\s\n]*(?:;|$)/g,comment:/\/\*[^]*?\*\//g},i.connect={padding:{children:Ur,split:gn,combine:Uc},border:{children:Ur,split:$c,combine:Yc},"border-top":{children:mn,split:_n,combine:wn},"border-right":{children:mn,split:_n,combine:wn},"border-bottom":{children:mn,split:_n,combine:wn},"border-left":{children:mn,split:_n,combine:wn},"border-width":{children:Ur,split:gn,combine:null},"border-style":{children:Ur,split:gn,combine:null},"border-color":{children:Ur,split:gn,combine:null},font:{children:["style","variant","weight","stretch","line-height","size","family"],split:Qc,combine:tf}},i})();jt.Styles=Zt});var Ia=m(ze=>{"use strict";var Mn=ze&&ze.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(ze,"__esModule",{value:!0});ze.CssStyles=void 0;var ef=(function(){function i(r){r===void 0&&(r=null),this.styles={},this.addStyles(r)}return Object.defineProperty(i.prototype,"cssText",{get:function(){return this.getStyleString()},enumerable:!1,configurable:!0}),i.prototype.addStyles=function(r){var t,e;if(r)try{for(var n=Mn(Object.keys(r)),o=n.next();!o.done;o=n.next()){var a=o.value;this.styles[a]||(this.styles[a]={}),Object.assign(this.styles[a],r[a])}}catch(s){t={error:s}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}},i.prototype.removeStyles=function(){for(var r,t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{for(var o=Mn(e),a=o.next();!a.done;a=o.next()){var s=a.value;delete this.styles[s]}}catch(l){r={error:l}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}},i.prototype.clear=function(){this.styles={}},i.prototype.getStyleString=function(){return this.getStyleRules().join(`
3
4`)},i.prototype.getStyleRules=function(){var r,t,e=Object.keys(this.styles),n=new Array(e.length),o=0;try{for(var a=Mn(e),s=a.next();!s.done;s=a.next()){var l=s.value;n[o++]=l+` {
5`+this.getStyleDefString(this.styles[l])+`
6}`}}catch(u){r={error:u}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}return n},i.prototype.getStyleDefString=function(r){var t,e,n=Object.keys(r),o=new Array(n.length),a=0;try{for(var s=Mn(n),l=s.next();!l.done;l=s.next()){var u=l.value;o[a++]="  "+u+": "+r[u]+";"}}catch(c){t={error:c}}finally{try{l&&!l.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return o.join(`
7`)},i})();ze.CssStyles=ef});var Fa=m(it=>{"use strict";var rf=it&&it.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),bn=it&&it.__assign||function(){return bn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},bn.apply(this,arguments)},qi=it&&it.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},te=it&&it.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(it,"__esModule",{value:!0});it.CommonOutputJax=void 0;var Wa=Li(),Di=dn(),nf=Xe(),of=Kr(),af=xn(),sf=Ia(),lf=(function(i){rf(r,i);function r(t,e,n){t===void 0&&(t=null),e===void 0&&(e=null),n===void 0&&(n=null);var o=this,a=qi((0,nf.separateOptions)(t,n.OPTIONS),2),s=a[0],l=a[1];return o=i.call(this,s)||this,o.factory=o.options.wrapperFactory||new e,o.factory.jax=o,o.cssStyles=o.options.cssStyles||new sf.CssStyles,o.font=o.options.font||new n(l),o.unknownCache=new Map,o}return r.prototype.typeset=function(t,e){this.setDocument(e);var n=this.createNode();return this.toDOM(t,n,e),n},r.prototype.createNode=function(){var t=this.constructor.NAME;return this.html("mjx-container",{class:"MathJax",jax:t})},r.prototype.setScale=function(t){var e=this.math.metrics.scale*this.options.scale;e!==1&&this.adaptor.setStyle(t,"fontSize",(0,of.percent)(e))},r.prototype.toDOM=function(t,e,n){n===void 0&&(n=null),this.setDocument(n),this.math=t,this.pxPerEm=t.metrics.ex/this.font.params.x_height,t.root.setTeXclass(null),this.setScale(e),this.nodeMap=new Map,this.container=e,this.processMath(t.root,e),this.nodeMap=null,this.executeFilters(this.postFilters,t,n,e)},r.prototype.getBBox=function(t,e){this.setDocument(e),this.math=t,t.root.setTeXclass(null),this.nodeMap=new Map;var n=this.factory.wrap(t.root).getOuterBBox();return this.nodeMap=null,n},r.prototype.getMetrics=function(t){var e,n;this.setDocument(t);var o=this.adaptor,a=this.getMetricMaps(t);try{for(var s=te(t.math),l=s.next();!l.done;l=s.next()){var u=l.value,c=o.parent(u.start.node);if(u.state()<Di.STATE.METRICS&&c){var f=a[u.display?1:0],h=f.get(c),p=h.em,d=h.ex,y=h.containerWidth,v=h.lineWidth,_=h.scale,g=h.family;u.setMetrics(p,d,y,v,_),this.options.mtextInheritFont&&(u.outputData.mtextFamily=g),this.options.merrorInheritFont&&(u.outputData.merrorFamily=g),u.state(Di.STATE.METRICS)}}}catch(w){e={error:w}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}},r.prototype.getMetricsFor=function(t,e){var n=this.options.mtextInheritFont||this.options.merrorInheritFont,o=this.getTestElement(t,e),a=this.measureMetrics(o,n);return this.adaptor.remove(o),a},r.prototype.getMetricMaps=function(t){var e,n,o,a,s,l,u,c,f,h,p=this.adaptor,d=[new Map,new Map];try{for(var y=te(t.math),v=y.next();!v.done;v=y.next()){var _=v.value,g=p.parent(_.start.node);if(g&&_.state()<Di.STATE.METRICS){var w=d[_.display?1:0];w.has(g)||w.set(g,this.getTestElement(g,_.display))}}}catch(zt){e={error:zt}}finally{try{v&&!v.done&&(n=y.return)&&n.call(y)}finally{if(e)throw e.error}}var M=this.options.mtextInheritFont||this.options.merrorInheritFont,b=[new Map,new Map];try{for(var P=te(b.keys()),B=P.next();!B.done;B=P.next()){var E=B.value;try{for(var T=(s=void 0,te(d[E].keys())),A=T.next();!A.done;A=T.next()){var g=A.value;b[E].set(g,this.measureMetrics(d[E].get(g),M))}}catch(zt){s={error:zt}}finally{try{A&&!A.done&&(l=T.return)&&l.call(T)}finally{if(s)throw s.error}}}}catch(zt){o={error:zt}}finally{try{B&&!B.done&&(a=P.return)&&a.call(P)}finally{if(o)throw o.error}}try{for(var G=te(b.keys()),D=G.next();!D.done;D=G.next()){var E=D.value;try{for(var et=(f=void 0,te(d[E].values())),Ve=et.next();!Ve.done;Ve=et.next()){var g=Ve.value;p.remove(g)}}catch(Pi){f={error:Pi}}finally{try{Ve&&!Ve.done&&(h=et.return)&&h.call(et)}finally{if(f)throw f.error}}}}catch(zt){u={error:zt}}finally{try{D&&!D.done&&(c=G.return)&&c.call(G)}finally{if(u)throw u.error}}return b},r.prototype.getTestElement=function(t,e){var n=this.adaptor;if(!this.testInline){this.testInline=this.html("mjx-test",{style:{display:"inline-block",width:"100%","font-style":"normal","font-weight":"normal","font-size":"100%","font-size-adjust":"none","text-indent":0,"text-transform":"none","letter-spacing":"normal","word-spacing":"normal",overflow:"hidden",height:"1px","margin-right":"-1px"}},[this.html("mjx-left-box",{style:{display:"inline-block",width:0,float:"left"}}),this.html("mjx-ex-box",{style:{position:"absolute",overflow:"hidden",width:"1px",height:"60ex"}}),this.html("mjx-right-box",{style:{display:"inline-block",width:0,float:"right"}})]),this.testDisplay=n.clone(this.testInline),n.setStyle(this.testDisplay,"display","table"),n.setStyle(this.testDisplay,"margin-right",""),n.setStyle(n.firstChild(this.testDisplay),"display","none");var o=n.lastChild(this.testDisplay);n.setStyle(o,"display","table-cell"),n.setStyle(o,"width","10000em"),n.setStyle(o,"float","")}return n.append(t,n.clone(e?this.testDisplay:this.testInline))},r.prototype.measureMetrics=function(t,e){var n=this.adaptor,o=e?n.fontFamily(t):"",a=n.fontSize(t),s=qi(n.nodeSize(n.childNode(t,1)),2),l=s[0],u=s[1],c=l?u/60:a*this.options.exFactor,f=l?n.getStyle(t,"display")==="table"?n.nodeSize(n.lastChild(t))[0]-1:n.nodeBBox(n.lastChild(t)).left-n.nodeBBox(n.firstChild(t)).left-2:1e6,h=Math.max(this.options.minScale,this.options.matchFontHeight?c/this.font.params.x_height/a:1),p=1e6;return{em:a,ex:c,containerWidth:f,lineWidth:p,scale:h,family:o}},r.prototype.styleSheet=function(t){var e,n;if(this.setDocument(t),this.cssStyles.clear(),this.cssStyles.addStyles(this.constructor.commonStyles),"getStyles"in t)try{for(var o=te(t.getStyles()),a=o.next();!a.done;a=o.next()){var s=a.value;this.cssStyles.addStyles(s)}}catch(u){e={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}this.addWrapperStyles(this.cssStyles),this.addFontStyles(this.cssStyles);var l=this.html("style",{id:"MJX-styles"},[this.text(`
8`+this.cssStyles.cssText+`
9`)]);return l},r.prototype.addFontStyles=function(t){t.addStyles(this.font.styles)},r.prototype.addWrapperStyles=function(t){var e,n;try{for(var o=te(this.factory.getKinds()),a=o.next();!a.done;a=o.next()){var s=a.value;this.addClassStyles(this.factory.getNodeClass(s),t)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}},r.prototype.addClassStyles=function(t,e){e.addStyles(t.styles)},r.prototype.setDocument=function(t){t&&(this.document=t,this.adaptor.document=t.document)},r.prototype.html=function(t,e,n,o){return e===void 0&&(e={}),n===void 0&&(n=[]),this.adaptor.node(t,e,n,o)},r.prototype.text=function(t){return this.adaptor.text(t)},r.prototype.fixed=function(t,e){return e===void 0&&(e=3),Math.abs(t)<6e-4?"0":t.toFixed(e).replace(/\.?0+$/,"")},r.prototype.measureText=function(t,e,n){n===void 0&&(n=["",!1,!1]);var o=this.unknownText(t,e);if(e==="-explicitFont"){var a=this.cssFontStyles(n);this.adaptor.setAttributes(o,{style:a})}return this.measureTextNodeWithCache(o,t,e,n)},r.prototype.measureTextNodeWithCache=function(t,e,n,o){o===void 0&&(o=["",!1,!1]),n==="-explicitFont"&&(n=[o[0],o[1]?"T":"F",o[2]?"T":"F",""].join("-")),this.unknownCache.has(n)||this.unknownCache.set(n,new Map);var a=this.unknownCache.get(n),s=a.get(e);if(s)return s;var l=this.measureTextNode(t);return a.set(e,l),l},r.prototype.measureXMLnode=function(t){var e=this.adaptor,n=this.html("mjx-xml-block",{style:{display:"inline-block"}},[e.clone(t)]),o=this.html("mjx-baseline",{style:{display:"inline-block",width:0,height:0}}),a={position:"absolute",display:"inline-block","font-family":"initial","line-height":"normal"},s=this.html("mjx-measure-xml",{style:a},[o,n]);e.append(e.parent(this.math.start.node),this.container),e.append(this.container,s);var l=this.math.metrics.em*this.math.metrics.scale,u=e.nodeBBox(n),c=u.left,f=u.right,h=u.bottom,p=u.top,d=(f-c)/l,y=(e.nodeBBox(o).top-p)/l,v=(h-p)/l-y;return e.remove(this.container),e.remove(s),{w:d,h:y,d:v}},r.prototype.cssFontStyles=function(t,e){e===void 0&&(e={});var n=qi(t,3),o=n[0],a=n[1],s=n[2];return e["font-family"]=this.font.getFamily(o),a&&(e["font-style"]="italic"),s&&(e["font-weight"]="bold"),e},r.prototype.getFontData=function(t){return t||(t=new af.Styles),[this.font.getFamily(t.get("font-family")),t.get("font-style")==="italic",t.get("font-weight")==="bold"]},r.NAME="Common",r.OPTIONS=bn(bn({},Wa.AbstractOutputJax.OPTIONS),{scale:1,minScale:.5,mtextInheritFont:!1,merrorInheritFont:!1,mtextFont:"",merrorFont:"serif",mathmlSpacing:!1,skipAttributes:{},exFactor:.5,displayAlign:"center",displayIndent:"0",wrapperFactory:null,font:null,cssStyles:null}),r.commonStyles={},r})(Wa.AbstractOutputJax);it.CommonOutputJax=lf});var Ra=m(At=>{"use strict";var uf=At&&At.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),cf=At&&At.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},ff=At&&At.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(At,"__esModule",{value:!0});At.AbstractWrapperFactory=void 0;var hf=Ea(),pf=(function(i){uf(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.wrap=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return this.create.apply(this,ff([t.kind,t],cf(e),!1))},r})(hf.AbstractFactory);At.AbstractWrapperFactory=pf});var Ha=m(Je=>{"use strict";var df=Je&&Je.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Je,"__esModule",{value:!0});Je.CommonWrapperFactory=void 0;var yf=Ra(),vf=(function(i){df(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.jax=null,t}return Object.defineProperty(r.prototype,"Wrappers",{get:function(){return this.node},enumerable:!1,configurable:!0}),r.defaultNodes={},r})(yf.AbstractWrapperFactory);Je.CommonWrapperFactory=vf});var Kt=m(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.BBox=void 0;var ee=Kr(),mf=(function(){function i(r){r===void 0&&(r={w:0,h:-ee.BIGDIMEN,d:-ee.BIGDIMEN}),this.w=r.w||0,this.h="h"in r?r.h:-ee.BIGDIMEN,this.d="d"in r?r.d:-ee.BIGDIMEN,this.L=this.R=this.ic=this.sk=this.dx=0,this.scale=this.rscale=1,this.pwidth=""}return i.zero=function(){return new i({h:0,d:0,w:0})},i.empty=function(){return new i},i.prototype.empty=function(){return this.w=0,this.h=this.d=-ee.BIGDIMEN,this},i.prototype.clean=function(){this.w===-ee.BIGDIMEN&&(this.w=0),this.h===-ee.BIGDIMEN&&(this.h=0),this.d===-ee.BIGDIMEN&&(this.d=0)},i.prototype.rescale=function(r){this.w*=r,this.h*=r,this.d*=r},i.prototype.combine=function(r,t,e){t===void 0&&(t=0),e===void 0&&(e=0);var n=r.rscale,o=t+n*(r.w+r.L+r.R),a=e+n*r.h,s=n*r.d-e;o>this.w&&(this.w=o),a>this.h&&(this.h=a),s>this.d&&(this.d=s)},i.prototype.append=function(r){var t=r.rscale;this.w+=t*(r.w+r.L+r.R),t*r.h>this.h&&(this.h=t*r.h),t*r.d>this.d&&(this.d=t*r.d)},i.prototype.updateFrom=function(r){this.h=r.h,this.d=r.d,this.w=r.w,r.pwidth&&(this.pwidth=r.pwidth)},i.fullWidth="100%",i.StyleAdjust=[["borderTopWidth","h"],["borderRightWidth","w"],["borderBottomWidth","d"],["borderLeftWidth","w",0],["paddingTop","h"],["paddingRight","w"],["paddingBottom","d"],["paddingLeft","w",0]],i})();Sn.BBox=mf});var Xa=m(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.AbstractWrapper=void 0;var gf=(function(){function i(r,t){this.factory=r,this.node=t}return Object.defineProperty(i.prototype,"kind",{get:function(){return this.node.kind},enumerable:!1,configurable:!0}),i.prototype.wrap=function(r){return this.factory.wrap(r)},i})();On.AbstractWrapper=gf});var Qa=m(W=>{"use strict";var _f=W&&W.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),wf=W&&W.__createBinding||(Object.create?(function(i,r,t,e){e===void 0&&(e=t);var n=Object.getOwnPropertyDescriptor(r,t);(!n||("get"in n?!r.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(i,e,n)}):(function(i,r,t,e){e===void 0&&(e=t),i[e]=r[t]})),xf=W&&W.__setModuleDefault||(Object.create?(function(i,r){Object.defineProperty(i,"default",{enumerable:!0,value:r})}):function(i,r){i.default=r}),Mf=W&&W.__importStar||function(i){if(i&&i.__esModule)return i;var r={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&wf(r,i,t);return xf(r,i),r},jn=W&&W.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},za=W&&W.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},bf=W&&W.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(W,"__esModule",{value:!0});W.CommonWrapper=void 0;var Sf=Xa(),Ja=C(),Of=Jt(),$r=Mf(Kr()),Ka=xn(),Yr=Kt(),Ua=Va(),$a=2/18;function Ya(i,r){return i?r<$a?0:$a:r}var jf=(function(i){_f(r,i);function r(t,e,n){n===void 0&&(n=null);var o=i.call(this,t,e)||this;return o.parent=null,o.removedStyles=null,o.styles=null,o.variant="",o.bboxComputed=!1,o.stretch=Ua.NOSTRETCH,o.font=null,o.parent=n,o.font=t.jax.font,o.bbox=Yr.BBox.zero(),o.getStyles(),o.getVariant(),o.getScale(),o.getSpace(),o.childNodes=e.childNodes.map(function(a){var s=o.wrap(a);return s.bbox.pwidth&&(e.notParent||e.isKind("math"))&&(o.bbox.pwidth=Yr.BBox.fullWidth),s}),o}return Object.defineProperty(r.prototype,"jax",{get:function(){return this.factory.jax},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"adaptor",{get:function(){return this.factory.jax.adaptor},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"metrics",{get:function(){return this.factory.jax.math.metrics},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fixesPWidth",{get:function(){return!this.node.notParent&&!this.node.isToken},enumerable:!1,configurable:!0}),r.prototype.wrap=function(t,e){e===void 0&&(e=null);var n=this.factory.wrap(t,e||this);return e&&e.childNodes.push(n),this.jax.nodeMap.set(t,n),n},r.prototype.getBBox=function(t){if(t===void 0&&(t=!0),this.bboxComputed)return this.bbox;var e=t?this.bbox:Yr.BBox.zero();return this.computeBBox(e),this.bboxComputed=t,e},r.prototype.getOuterBBox=function(t){var e,n;t===void 0&&(t=!0);var o=this.getBBox(t);if(!this.styles)return o;var a=new Yr.BBox;Object.assign(a,o);try{for(var s=jn(Yr.BBox.StyleAdjust),l=s.next();!l.done;l=s.next()){var u=za(l.value,2),c=u[0],f=u[1],h=this.styles.get(c);h&&(a[f]+=this.length2em(h,1,a.rscale))}}catch(p){e={error:p}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return a},r.prototype.computeBBox=function(t,e){var n,o;e===void 0&&(e=!1),t.empty();try{for(var a=jn(this.childNodes),s=a.next();!s.done;s=a.next()){var l=s.value;t.append(l.getOuterBBox())}}catch(u){n={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}t.clean(),this.fixesPWidth&&this.setChildPWidths(e)&&this.computeBBox(t,!0)},r.prototype.setChildPWidths=function(t,e,n){var o,a;if(e===void 0&&(e=null),n===void 0&&(n=!0),t)return!1;n&&(this.bbox.pwidth="");var s=!1;try{for(var l=jn(this.childNodes),u=l.next();!u.done;u=l.next()){var c=u.value,f=c.getOuterBBox();f.pwidth&&c.setChildPWidths(t,e===null?f.w:e,n)&&(s=!0)}}catch(h){o={error:h}}finally{try{u&&!u.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}return s},r.prototype.invalidateBBox=function(){this.bboxComputed&&(this.bboxComputed=!1,this.parent&&this.parent.invalidateBBox())},r.prototype.copySkewIC=function(t){var e=this.childNodes[0];e?.bbox.sk&&(t.sk=e.bbox.sk),e?.bbox.dx&&(t.dx=e.bbox.dx);var n=this.childNodes[this.childNodes.length-1];n?.bbox.ic&&(t.ic=n.bbox.ic,t.w+=t.ic)},r.prototype.getStyles=function(){var t=this.node.attributes.getExplicit("style");if(t)for(var e=this.styles=new Ka.Styles(t),n=0,o=r.removeStyles.length;n<o;n++){var a=r.removeStyles[n];e.get(a)&&(this.removedStyles||(this.removedStyles={}),this.removedStyles[a]=e.get(a),e.set(a,""))}},r.prototype.getVariant=function(){if(this.node.isToken){var t=this.node.attributes,e=t.get("mathvariant");if(!t.getExplicit("mathvariant")){var n=t.getList("fontfamily","fontweight","fontstyle");if(this.removedStyles){var o=this.removedStyles;o.fontFamily&&(n.family=o.fontFamily),o.fontWeight&&(n.weight=o.fontWeight),o.fontStyle&&(n.style=o.fontStyle)}n.fontfamily&&(n.family=n.fontfamily),n.fontweight&&(n.weight=n.fontweight),n.fontstyle&&(n.style=n.fontstyle),n.weight&&n.weight.match(/^\d+$/)&&(n.weight=parseInt(n.weight)>600?"bold":"normal"),n.family?e=this.explicitVariant(n.family,n.weight,n.style):(this.node.getProperty("variantForm")&&(e="-tex-variant"),e=(r.BOLDVARIANTS[n.weight]||{})[e]||e,e=(r.ITALICVARIANTS[n.style]||{})[e]||e)}this.variant=e}},r.prototype.explicitVariant=function(t,e,n){var o=this.styles;return o||(o=this.styles=new Ka.Styles),o.set("fontFamily",t),e&&o.set("fontWeight",e),n&&o.set("fontStyle",n),"-explicitFont"},r.prototype.getScale=function(){var t=1,e=this.parent,n=e?e.bbox.scale:1,o=this.node.attributes,a=Math.min(o.get("scriptlevel"),2),s=o.get("fontsize"),l=this.node.isToken||this.node.isKind("mstyle")?o.get("mathsize"):o.getInherited("mathsize");if(a!==0){t=Math.pow(o.get("scriptsizemultiplier"),a);var u=this.length2em(o.get("scriptminsize"),.8,1);t<u&&(t=u)}this.removedStyles&&this.removedStyles.fontSize&&!s&&(s=this.removedStyles.fontSize),s&&!o.getExplicit("mathsize")&&(l=s),l!=="1"&&(t*=this.length2em(l,1,1)),this.bbox.scale=t,this.bbox.rscale=t/n},r.prototype.getSpace=function(){var t=this.isTopEmbellished(),e=this.node.hasSpacingAttributes();this.jax.options.mathmlSpacing||e?t&&this.getMathMLSpacing():this.getTeXSpacing(t,e)},r.prototype.getMathMLSpacing=function(){var t=this.node.coreMO(),e=t.coreParent(),n=e.parent;if(!(!n||!n.isKind("mrow")||n.childNodes.length===1)){var o=t.attributes,a=o.get("scriptlevel")>0;this.bbox.L=o.isSet("lspace")?Math.max(0,this.length2em(o.get("lspace"))):Ya(a,t.lspace),this.bbox.R=o.isSet("rspace")?Math.max(0,this.length2em(o.get("rspace"))):Ya(a,t.rspace);var s=n.childIndex(e);if(s!==0){var l=n.childNodes[s-1];if(l.isEmbellished){var u=this.jax.nodeMap.get(l).getBBox();u.R&&(this.bbox.L=Math.max(0,this.bbox.L-u.R))}}}},r.prototype.getTeXSpacing=function(t,e){if(!e){var n=this.node.texSpacing();n&&(this.bbox.L=this.length2em(n))}if(t||e){var o=this.node.coreMO().attributes;o.isSet("lspace")&&(this.bbox.L=Math.max(0,this.length2em(o.get("lspace")))),o.isSet("rspace")&&(this.bbox.R=Math.max(0,this.length2em(o.get("rspace"))))}},r.prototype.isTopEmbellished=function(){return this.node.isEmbellished&&!(this.node.parent&&this.node.parent.isEmbellished)},r.prototype.core=function(){return this.jax.nodeMap.get(this.node.core())},r.prototype.coreMO=function(){return this.jax.nodeMap.get(this.node.coreMO())},r.prototype.getText=function(){var t,e,n="";if(this.node.isToken)try{for(var o=jn(this.node.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;s instanceof Ja.TextNode&&(n+=s.getText())}}catch(l){t={error:l}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return n},r.prototype.canStretch=function(t){if(this.stretch=Ua.NOSTRETCH,this.node.isEmbellished){var e=this.core();e&&e.node!==this.node&&e.canStretch(t)&&(this.stretch=e.stretch)}return this.stretch.dir!==0},r.prototype.getAlignShift=function(){var t,e=(t=this.node.attributes).getList.apply(t,bf([],za(Ja.indentAttributes),!1)),n=e.indentalign,o=e.indentshift,a=e.indentalignfirst,s=e.indentshiftfirst;a!=="indentalign"&&(n=a),n==="auto"&&(n=this.jax.options.displayAlign),s!=="indentshift"&&(o=s),o==="auto"&&(o=this.jax.options.displayIndent,n==="right"&&!o.match(/^\s*0[a-z]*\s*$/)&&(o=("-"+o.trim()).replace(/^--/,"")));var l=this.length2em(o,this.metrics.containerWidth);return[n,l]},r.prototype.getAlignX=function(t,e,n){return n==="right"?t-(e.w+e.R)*e.rscale:n==="left"?e.L*e.rscale:(t-e.w*e.rscale)/2},r.prototype.getAlignY=function(t,e,n,o,a){return a==="top"?t-n:a==="bottom"?o-e:a==="center"?(t-n-(e-o))/2:0},r.prototype.getWrapWidth=function(t){return this.childNodes[t].getBBox().w},r.prototype.getChildAlign=function(t){return"left"},r.prototype.percent=function(t){return $r.percent(t)},r.prototype.em=function(t){return $r.em(t)},r.prototype.px=function(t,e){return e===void 0&&(e=-$r.BIGDIMEN),$r.px(t,e,this.metrics.em)},r.prototype.length2em=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=null),n===null&&(n=this.bbox.scale),$r.length2em(t,e,n,this.jax.pxPerEm)},r.prototype.unicodeChars=function(t,e){e===void 0&&(e=this.variant);var n=(0,Of.unicodeChars)(t),o=this.font.getVariant(e);if(o&&o.chars){var a=o.chars;n=n.map(function(s){return((a[s]||[])[3]||{}).smp||s})}return n},r.prototype.remapChars=function(t){return t},r.prototype.mmlText=function(t){return this.node.factory.create("text").setText(t)},r.prototype.mmlNode=function(t,e,n){return e===void 0&&(e={}),n===void 0&&(n=[]),this.node.factory.create(t,e,n)},r.prototype.createMo=function(t){var e=this.node.factory,n=e.create("text").setText(t),o=e.create("mo",{stretchy:!0},[n]);o.inheritAttributesFrom(this.node);var a=this.wrap(o);return a.parent=this,a},r.prototype.getVariantChar=function(t,e){var n=this.font.getChar(t,e)||[0,0,0,{unknown:!0}];return n.length===3&&(n[3]={}),n},r.kind="unknown",r.styles={},r.removeStyles=["fontSize","fontFamily","fontWeight","fontStyle","fontVariant","font"],r.skipAttributes={fontfamily:!0,fontsize:!0,fontweight:!0,fontstyle:!0,color:!0,background:!0,class:!0,href:!0,style:!0,xmlns:!0},r.BOLDVARIANTS={bold:{normal:"bold",italic:"bold-italic",fraktur:"bold-fraktur",script:"bold-script","sans-serif":"bold-sans-serif","sans-serif-italic":"sans-serif-bold-italic"},normal:{bold:"normal","bold-italic":"italic","bold-fraktur":"fraktur","bold-script":"script","bold-sans-serif":"sans-serif","sans-serif-bold-italic":"sans-serif-italic"}},r.ITALICVARIANTS={italic:{normal:"italic",bold:"bold-italic","sans-serif":"sans-serif-italic","bold-sans-serif":"sans-serif-bold-italic"},normal:{italic:"normal","bold-italic":"bold","sans-serif-italic":"sans-serif","sans-serif-bold-italic":"bold-sans-serif"}},r})(Sf.AbstractWrapper);W.CommonWrapper=jf});var k=m(Ct=>{"use strict";var Af=Ct&&Ct.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ke=Ct&&Ct.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},De=Ct&&Ct.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(Ct,"__esModule",{value:!0});Ct.SVGWrapper=void 0;var Cf=Kt(),Pf=Qa(),Bf=Gi(),Tf=(function(i){Af(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.element=null,t.dx=0,t}return r.prototype.toSVG=function(t){this.addChildren(this.standardSVGnode(t))},r.prototype.addChildren=function(t){var e,n,o=0;try{for(var a=Ke(this.childNodes),s=a.next();!s.done;s=a.next()){var l=s.value;l.toSVG(t);var u=l.getOuterBBox();l.element&&l.place(o+u.L*u.rscale,0),o+=(u.L+u.w+u.R)*u.rscale}}catch(c){e={error:c}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}},r.prototype.standardSVGnode=function(t){var e=this.createSVGnode(t);return this.handleStyles(),this.handleScale(),this.handleBorder(),this.handleColor(),this.handleAttributes(),e},r.prototype.createSVGnode=function(t){this.element=this.svg("g",{"data-mml-node":this.node.kind});var e=this.node.attributes.get("href");if(e){t=this.adaptor.append(t,this.svg("a",{href:e}));var n=this.getOuterBBox(),o=n.h,a=n.d,s=n.w;this.adaptor.append(this.element,this.svg("rect",{"data-hitbox":!0,fill:"none",stroke:"none","pointer-events":"all",width:this.fixed(s),height:this.fixed(o+a),y:this.fixed(-a)}))}return this.adaptor.append(t,this.element),this.element},r.prototype.handleStyles=function(){var t=this;if(this.styles){var e=this.styles.cssText;e&&this.adaptor.setAttribute(this.element,"style",e),Cf.BBox.StyleAdjust.forEach(function(n){var o=De(n,3),a=o[0],s=o[2];if(s===0){var l=t.styles.get(a);l&&(t.dx+=t.length2em(l,1,t.bbox.rscale))}})}},r.prototype.handleScale=function(){if(this.bbox.rscale!==1){var t="scale("+this.fixed(this.bbox.rscale/1e3,3)+")";this.adaptor.setAttribute(this.element,"transform",t)}},r.prototype.handleColor=function(){var t,e=this.adaptor,n=this.node.attributes,o=n.getExplicit("mathcolor"),a=n.getExplicit("color"),s=n.getExplicit("mathbackground"),l=n.getExplicit("background"),u=((t=this.styles)===null||t===void 0?void 0:t.get("background-color"))||"";if((o||a)&&(e.setAttribute(this.element,"fill",o||a),e.setAttribute(this.element,"stroke",o||a)),s||l||u){var c=this.getOuterBBox(),f=c.h,h=c.d,p=c.w,d=this.svg("rect",{fill:s||l||u,x:this.fixed(-this.dx),y:this.fixed(-h),width:this.fixed(p),height:this.fixed(f+h),"data-bgcolor":!0}),y=e.firstChild(this.element);y?e.insert(d,y):e.append(this.element,d)}},r.prototype.handleBorder=function(){var t,e,n,o;if(this.styles){var a=Array(4).fill(0),s=Array(4),l=Array(4);try{for(var u=Ke([["Top",0],["Right",1],["Bottom",2],["Left",3]]),c=u.next();!c.done;c=u.next()){var f=De(c.value,2),h=f[0],p=f[1],d="border"+h,y=this.styles.get(d+"Width");y&&(a[p]=Math.max(0,this.length2em(y,1,this.bbox.rscale)),s[p]=this.styles.get(d+"Style")||"solid",l[p]=this.styles.get(d+"Color")||"currentColor")}}catch(Bi){t={error:Bi}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}var v=r.borderFuzz,_=this.getOuterBBox(),g=De([_.h+v,_.d+v,_.w+v],3),w=g[0],M=g[1],b=g[2],P=[b,w],B=[-v,w],E=[b,-M],T=[-v,-M],A=[b-a[1],w-a[0]],G=[-v+a[3],w-a[0]],D=[b-a[1],-M+a[2]],et=[-v+a[3],-M+a[2]],Ve=[[B,P,A,G],[E,P,A,D],[T,E,D,et],[T,B,G,et]],zt=this.adaptor,Pi=zt.firstChild(this.element);try{for(var pn=Ke([0,1,2,3]),Jr=pn.next();!Jr.done;Jr=pn.next()){var p=Jr.value;if(a[p]){var Pa=Ve[p];s[p]==="dashed"||s[p]==="dotted"?this.addBorderBroken(Pa,l[p],s[p],a[p],p):this.addBorderSolid(Pa,l[p],Pi)}}}catch(Bi){n={error:Bi}}finally{try{Jr&&!Jr.done&&(o=pn.return)&&o.call(pn)}finally{if(n)throw n.error}}}},r.prototype.addBorderSolid=function(t,e,n){var o=this,a=this.svg("polygon",{points:t.map(function(s){var l=De(s,2),u=l[0],c=l[1];return"".concat(o.fixed(u-o.dx),",").concat(o.fixed(c))}).join(" "),stroke:"none",fill:e});n?this.adaptor.insert(a,n):this.adaptor.append(this.element,a)},r.prototype.addBorderBroken=function(t,e,n,o,a){var s=n==="dotted",l=o/2,u=De([[l,-l,-l,-l],[-l,l,-l,-l],[l,l,-l,l],[l,l,l,-l]][a],4),c=u[0],f=u[1],h=u[2],p=u[3],d=De(t,2),y=d[0],v=d[1],_=y[0]+c-this.dx,g=y[1]+f,w=v[0]+h-this.dx,M=v[1]+p,b=Math.abs(a%2?M-g:w-_),P=Math.ceil(s?b/(2*o):(b-o)/(4*o)),B=b/(4*P+1),E=this.svg("line",{x1:this.fixed(_),y1:this.fixed(g),x2:this.fixed(w),y2:this.fixed(M),"stroke-width":this.fixed(o),stroke:e,"stroke-linecap":s?"round":"square","stroke-dasharray":s?[1,this.fixed(b/P-.002)].join(" "):[this.fixed(B),this.fixed(3*B)].join(" ")}),T=this.adaptor,A=T.firstChild(this.element);A?T.insert(E,A):T.append(this.element,E)},r.prototype.handleAttributes=function(){var t,e,n,o,a=this.node.attributes,s=a.getAllDefaults(),l=r.skipAttributes;try{for(var u=Ke(a.getExplicitNames()),c=u.next();!c.done;c=u.next()){var f=c.value;(l[f]===!1||!(f in s)&&!l[f]&&!this.adaptor.hasAttribute(this.element,f))&&this.adaptor.setAttribute(this.element,f,a.getExplicit(f))}}catch(v){t={error:v}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}if(a.get("class")){var h=a.get("class").trim().split(/ +/);try{for(var p=Ke(h),d=p.next();!d.done;d=p.next()){var y=d.value;this.adaptor.addClass(this.element,y)}}catch(v){n={error:v}}finally{try{d&&!d.done&&(o=p.return)&&o.call(p)}finally{if(n)throw n.error}}}},r.prototype.place=function(t,e,n){if(n===void 0&&(n=null),t+=this.dx,!!(t||e)){n||(n=this.element,e=this.handleId(e));var o="translate(".concat(this.fixed(t),",").concat(this.fixed(e),")"),a=this.adaptor.getAttribute(n,"transform")||"";this.adaptor.setAttribute(n,"transform",o+(a?" "+a:""))}},r.prototype.handleId=function(t){if(!this.node.attributes||!this.node.attributes.get("id"))return t;var e=this.adaptor,n=this.getBBox().h,o=e.childNodes(this.element);o.forEach(function(s){return e.remove(s)});var a=this.svg("g",{"data-idbox":!0,transform:"translate(0,".concat(this.fixed(-n),")")},o);return e.append(this.element,this.svg("text",{"data-id-align":!0},[this.text("")])),e.append(this.element,a),t+n},r.prototype.firstChild=function(){var t=this.adaptor,e=t.firstChild(this.element);return e&&t.kind(e)==="text"&&t.getAttribute(e,"data-id-align")&&(e=t.firstChild(t.next(e))),e&&t.kind(e)==="rect"&&t.getAttribute(e,"data-hitbox")&&(e=t.next(e)),e},r.prototype.placeChar=function(t,e,n,o,a){var s,l;a===void 0&&(a=null),a===null&&(a=this.variant);var u=t.toString(16).toUpperCase(),c=De(this.getVariantChar(a,t),4),f=c[2],h=c[3];if("p"in h){var p=h.p?"M"+h.p+"Z":"";this.place(e,n,this.adaptor.append(o,this.charNode(a,u,p)))}else if("c"in h){var d=this.adaptor.append(o,this.svg("g",{"data-c":u}));this.place(e,n,d),e=0;try{for(var y=Ke(this.unicodeChars(h.c,a)),v=y.next();!v.done;v=y.next()){var _=v.value;e+=this.placeChar(_,e,n,d,a)}}catch(M){s={error:M}}finally{try{v&&!v.done&&(l=y.return)&&l.call(y)}finally{if(s)throw s.error}}}else if(h.unknown){var g=String.fromCodePoint(t),w=this.adaptor.append(o,this.jax.unknownText(g,a));return this.place(e,n,w),this.jax.measureTextNodeWithCache(w,g,a).w}return f},r.prototype.charNode=function(t,e,n){var o=this.jax.options.fontCache;return o!=="none"?this.useNode(t,e,n):this.pathNode(e,n)},r.prototype.pathNode=function(t,e){return this.svg("path",{"data-c":t,d:e})},r.prototype.useNode=function(t,e,n){var o=this.svg("use",{"data-c":e}),a="#"+this.jax.fontCache.cachePath(t,e,n);return this.adaptor.setAttribute(o,"href",a,Bf.XLINKNS),o},r.prototype.drawBBox=function(){var t=this.getBBox(),e=t.w,n=t.h,o=t.d,a=this.svg("g",{style:{opacity:.25}},[this.svg("rect",{fill:"red",height:this.fixed(n),width:this.fixed(e)}),this.svg("rect",{fill:"green",height:this.fixed(o),width:this.fixed(e),y:this.fixed(-o)})]),s=this.element||this.parent.element;this.adaptor.append(s,a)},r.prototype.html=function(t,e,n){return e===void 0&&(e={}),n===void 0&&(n=[]),this.jax.html(t,e,n)},r.prototype.svg=function(t,e,n){return e===void 0&&(e={}),n===void 0&&(n=[]),this.jax.svg(t,e,n)},r.prototype.text=function(t){return this.jax.text(t)},r.prototype.fixed=function(t,e){return e===void 0&&(e=1),this.jax.fixed(t*1e3,e)},r.kind="unknown",r.borderFuzz=.005,r})(Pf.CommonWrapper);Ct.SVGWrapper=Tf});var Za=m(Ue=>{"use strict";var Nf=Ue&&Ue.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Ue,"__esModule",{value:!0});Ue.CommonMathMixin=void 0;function Ef(i){return(function(r){Nf(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.getWrapWidth=function(e){return this.parent?this.getBBox().w:this.metrics.containerWidth/this.jax.pxPerEm},t})(i)}Ue.CommonMathMixin=Ef});var Ii=m(re=>{"use strict";var Lf=re&&re.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),An=re&&re.__assign||function(){return An=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},An.apply(this,arguments)};Object.defineProperty(re,"__esModule",{value:!0});re.MmlMath=void 0;var ts=C(),kf=(function(i){Lf(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"math"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){this.attributes.get("mode")==="display"&&this.attributes.setInherited("display","block"),t=this.addInheritedAttributes(t,this.attributes.getAllAttributes()),e=!!this.attributes.get("displaystyle")||!this.attributes.get("displaystyle")&&this.attributes.get("display")==="block",this.attributes.setInherited("displaystyle",e),n=this.attributes.get("scriptlevel")||this.constructor.defaults.scriptlevel,i.prototype.setChildInheritedAttributes.call(this,t,e,n,o)},r.defaults=An(An({},ts.AbstractMmlLayoutNode.defaults),{mathvariant:"normal",mathsize:"normal",mathcolor:"",mathbackground:"transparent",dir:"ltr",scriptlevel:0,displaystyle:!1,display:"inline",maxwidth:"",overflow:"linebreak",altimg:"","altimg-width":"","altimg-height":"","altimg-valign":"",alttext:"",cdgroup:"",scriptsizemultiplier:1/Math.sqrt(2),scriptminsize:"8px",infixlinebreakstyle:"before",lineleading:"1ex",linebreakmultchar:"\u2062",indentshift:"auto",indentalign:"auto",indenttarget:"",indentalignfirst:"indentalign",indentshiftfirst:"indentshift",indentalignlast:"indentalign",indentshiftlast:"indentshift"}),r})(ts.AbstractMmlLayoutNode);re.MmlMath=kf});var es=m(Pt=>{"use strict";var Vf=Pt&&Pt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),qf=Pt&&Pt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Df=Pt&&Pt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.SVGmath=void 0;var Gf=k(),If=Za(),Wf=Ii(),Ff=Kt(),Rf=(function(i){Vf(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){i.prototype.toSVG.call(this,t);var e=this.adaptor,n=this.node.attributes.get("display")==="block";n&&(e.setAttribute(this.jax.container,"display","true"),this.handleDisplay()),this.jax.document.options.internalSpeechTitles&&this.handleSpeech()},r.prototype.handleDisplay=function(){var t=qf(this.getAlignShift(),2),e=t[0],n=t[1];if(e!=="center"&&this.adaptor.setAttribute(this.jax.container,"justify",e),this.bbox.pwidth===Ff.BBox.fullWidth){if(this.adaptor.setAttribute(this.jax.container,"width","full"),this.jax.table){var o=this.jax.table.getOuterBBox(),a=o.L,s=o.w,l=o.R;e==="right"?l=Math.max(l||-n,-n):e==="left"?a=Math.max(a||n,n):e==="center"&&(s+=2*Math.abs(n)),this.jax.minwidth=Math.max(0,a+s+l)}}else this.jax.shift=n},r.prototype.handleSpeech=function(){var t,e,n=this.adaptor,o=this.node.attributes,a=o.get("aria-label")||o.get("data-semantic-speech");if(a){var s=this.getTitleID(),l=this.svg("title",{id:s},[this.text(a)]);n.insert(l,n.firstChild(this.element)),n.setAttribute(this.element,"aria-labeledby",s),n.removeAttribute(this.element,"aria-label");try{for(var u=Df(this.childNodes[0].childNodes),c=u.next();!c.done;c=u.next()){var f=c.value;n.setAttribute(f.element,"aria-hidden","true")}}catch(h){t={error:h}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}}},r.prototype.getTitleID=function(){return"mjx-svg-title-"+String(this.jax.options.titleID++)},r.prototype.setChildPWidths=function(t,e,n){return e===void 0&&(e=null),n===void 0&&(n=!0),i.prototype.setChildPWidths.call(this,t,this.parent?e:this.metrics.containerWidth/this.jax.pxPerEm,!1)},r.kind=Wf.MmlMath.prototype.kind,r.styles={'mjx-container[jax="SVG"][display="true"]':{display:"block","text-align":"center",margin:"1em 0"},'mjx-container[jax="SVG"][display="true"][width="full"]':{display:"flex"},'mjx-container[jax="SVG"][justify="left"]':{"text-align":"left"},'mjx-container[jax="SVG"][justify="right"]':{"text-align":"right"}},r})((0,If.CommonMathMixin)(Gf.SVGWrapper));Pt.SVGmath=Rf});var Wi=m($=>{"use strict";var rs=$&&$.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Hf=$&&$.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Xf=$&&$.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},Cn=$&&$.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty($,"__esModule",{value:!0});$.CommonInferredMrowMixin=$.CommonMrowMixin=void 0;var zf=Kt();function Jf(i){return(function(r){rs(t,r);function t(){for(var e,n,o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=r.apply(this,Xf([],Hf(o),!1))||this;s.stretchChildren();try{for(var l=Cn(s.childNodes),u=l.next();!u.done;u=l.next()){var c=u.value;if(c.bbox.pwidth){s.bbox.pwidth=zf.BBox.fullWidth;break}}}catch(f){e={error:f}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}return s}return Object.defineProperty(t.prototype,"fixesPWidth",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.stretchChildren=function(){var e,n,o,a,s,l,u=[];try{for(var c=Cn(this.childNodes),f=c.next();!f.done;f=c.next()){var h=f.value;h.canStretch(1)&&u.push(h)}}catch(G){e={error:G}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(e)throw e.error}}var p=u.length,d=this.childNodes.length;if(p&&d>1){var y=0,v=0,_=p>1&&p===d;try{for(var g=Cn(this.childNodes),w=g.next();!w.done;w=g.next()){var h=w.value,M=h.stretch.dir===0;if(_||M){var b=h.getOuterBBox(M),P=b.h,B=b.d,E=b.rscale;P*=E,B*=E,P>y&&(y=P),B>v&&(v=B)}}}catch(G){o={error:G}}finally{try{w&&!w.done&&(a=g.return)&&a.call(g)}finally{if(o)throw o.error}}try{for(var T=Cn(u),A=T.next();!A.done;A=T.next()){var h=A.value;h.coreMO().getStretchedVariant([y,v])}}catch(G){s={error:G}}finally{try{A&&!A.done&&(l=T.return)&&l.call(T)}finally{if(s)throw s.error}}}},t})(i)}$.CommonMrowMixin=Jf;function Kf(i){return(function(r){rs(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.getScale=function(){this.bbox.scale=this.parent.bbox.scale,this.bbox.rscale=1},t})(i)}$.CommonInferredMrowMixin=Kf});var Xi=m(ot=>{"use strict";var ns=ot&&ot.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ri=ot&&ot.__assign||function(){return Ri=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Ri.apply(this,arguments)},$e=ot&&ot.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(ot,"__esModule",{value:!0});ot.MmlInferredMrow=ot.MmlMrow=void 0;var Fi=C(),Hi=(function(i){ns(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t._core=null,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mrow"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSpacelike",{get:function(){var t,e;try{for(var n=$e(this.childNodes),o=n.next();!o.done;o=n.next()){var a=o.value;if(!a.isSpacelike)return!1}}catch(s){t={error:s}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return!0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isEmbellished",{get:function(){var t,e,n=!1,o=0;try{for(var a=$e(this.childNodes),s=a.next();!s.done;s=a.next()){var l=s.value;if(l){if(l.isEmbellished){if(n)return!1;n=!0,this._core=o}else if(!l.isSpacelike)return!1}o++}}catch(u){t={error:u}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}return n},enumerable:!1,configurable:!0}),r.prototype.core=function(){return!this.isEmbellished||this._core==null?this:this.childNodes[this._core]},r.prototype.coreMO=function(){return!this.isEmbellished||this._core==null?this:this.childNodes[this._core].coreMO()},r.prototype.nonSpaceLength=function(){var t,e,n=0;try{for(var o=$e(this.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;s&&!s.isSpacelike&&n++}}catch(l){t={error:l}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}return n},r.prototype.firstNonSpace=function(){var t,e;try{for(var n=$e(this.childNodes),o=n.next();!o.done;o=n.next()){var a=o.value;if(a&&!a.isSpacelike)return a}}catch(s){t={error:s}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return null},r.prototype.lastNonSpace=function(){for(var t=this.childNodes.length;--t>=0;){var e=this.childNodes[t];if(e&&!e.isSpacelike)return e}return null},r.prototype.setTeXclass=function(t){var e,n,o,a;if(this.getProperty("open")!=null||this.getProperty("close")!=null){this.getPrevClass(t),t=null;try{for(var s=$e(this.childNodes),l=s.next();!l.done;l=s.next()){var u=l.value;t=u.setTeXclass(t)}}catch(h){e={error:h}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}this.texClass==null&&(this.texClass=Fi.TEXCLASS.INNER)}else{try{for(var c=$e(this.childNodes),f=c.next();!f.done;f=c.next()){var u=f.value;t=u.setTeXclass(t)}}catch(h){o={error:h}}finally{try{f&&!f.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}this.childNodes[0]&&this.updateTeXclass(this.childNodes[0])}return t},r.defaults=Ri({},Fi.AbstractMmlNode.defaults),r})(Fi.AbstractMmlNode);ot.MmlMrow=Hi;var Uf=(function(i){ns(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"inferredMrow"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isInferred",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notParent",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.toString=function(){return"["+this.childNodes.join(",")+"]"},r.defaults=Hi.defaults,r})(Hi);ot.MmlInferredMrow=Uf});var ss=m(ne=>{"use strict";var is=ne&&ne.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(ne,"__esModule",{value:!0});ne.SVGinferredMrow=ne.SVGmrow=void 0;var $f=k(),Yf=Wi(),Qf=Wi(),os=Xi(),as=(function(i){is(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.node.isInferred?this.element=t:this.standardSVGnode(t);this.addChildren(e)},r.kind=os.MmlMrow.prototype.kind,r})((0,Yf.CommonMrowMixin)($f.SVGWrapper));ne.SVGmrow=as;var Zf=(function(i){is(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=os.MmlInferredMrow.prototype.kind,r})((0,Qf.CommonInferredMrowMixin)(as));ne.SVGinferredMrow=Zf});var ls=m(Ye=>{"use strict";var th=Ye&&Ye.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Ye,"__esModule",{value:!0});Ye.CommonMiMixin=void 0;function eh(i){return(function(r){th(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1),r.prototype.computeBBox.call(this,e),this.copySkewIC(e)},t})(i)}Ye.CommonMiMixin=eh});var Ji=m(ie=>{"use strict";var rh=ie&&ie.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),zi=ie&&ie.__assign||function(){return zi=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},zi.apply(this,arguments)};Object.defineProperty(ie,"__esModule",{value:!0});ie.MmlMi=void 0;var Pn=C(),nh=(function(i){rh(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=Pn.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mi"},enumerable:!1,configurable:!0}),r.prototype.setInheritedAttributes=function(t,e,n,o){t===void 0&&(t={}),e===void 0&&(e=!1),n===void 0&&(n=0),o===void 0&&(o=!1),i.prototype.setInheritedAttributes.call(this,t,e,n,o);var a=this.getText();a.match(r.singleCharacter)&&!t.mathvariant&&this.attributes.setInherited("mathvariant","italic")},r.prototype.setTeXclass=function(t){this.getPrevClass(t);var e=this.getText();return e.length>1&&e.match(r.operatorName)&&this.attributes.get("mathvariant")==="normal"&&this.getProperty("autoOP")===void 0&&this.getProperty("texClass")===void 0&&(this.texClass=Pn.TEXCLASS.OP,this.setProperty("autoOP",!0)),this},r.defaults=zi({},Pn.AbstractMmlTokenNode.defaults),r.operatorName=/^[a-z][a-z0-9]*$/i,r.singleCharacter=/^[\uD800-\uDBFF]?.[\u0300-\u036F\u1AB0-\u1ABE\u1DC0-\u1DFF\u20D0-\u20EF]*$/,r})(Pn.AbstractMmlTokenNode);ie.MmlMi=nh});var us=m(Qe=>{"use strict";var ih=Qe&&Qe.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Qe,"__esModule",{value:!0});Qe.SVGmi=void 0;var oh=k(),ah=ls(),sh=Ji(),lh=(function(i){ih(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=sh.MmlMi.prototype.kind,r})((0,ah.CommonMiMixin)(oh.SVGWrapper));Qe.SVGmi=lh});var fs=m(J=>{"use strict";var uh=J&&J.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Tn=J&&J.__assign||function(){return Tn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Tn.apply(this,arguments)},oe=J&&J.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},ch=J&&J.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},fh=J&&J.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},Bn;Object.defineProperty(J,"__esModule",{value:!0});J.CommonMoMixin=J.DirectionVH=void 0;var cs=Kt(),hh=Jt(),ph=Va();J.DirectionVH=(Bn={},Bn[1]="v",Bn[2]="h",Bn);function dh(i){return(function(r){uh(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,ch([],oe(e),!1))||this;return o.size=null,o.isAccent=o.node.isAccent,o}return t.prototype.computeBBox=function(e,n){if(n===void 0&&(n=!1),this.protoBBox(e),this.node.attributes.get("symmetric")&&this.stretch.dir!==2){var o=this.getCenterOffset(e);e.h+=o,e.d-=o}this.node.getProperty("mathaccent")&&(this.stretch.dir===0||this.size>=0)&&(e.w=0)},t.prototype.protoBBox=function(e){var n=this.stretch.dir!==0;n&&this.size===null&&this.getStretchedVariant([0]),!(n&&this.size<0)&&(r.prototype.computeBBox.call(this,e),this.copySkewIC(e))},t.prototype.getAccentOffset=function(){var e=cs.BBox.empty();return this.protoBBox(e),-e.w/2},t.prototype.getCenterOffset=function(e){return e===void 0&&(e=null),e||(e=cs.BBox.empty(),r.prototype.computeBBox.call(this,e)),(e.h+e.d)/2+this.font.params.axis_height-e.h},t.prototype.getVariant=function(){if(this.node.attributes.get("largeop")){this.variant=this.node.attributes.get("displaystyle")?"-largeop":"-smallop";return}if(!this.node.attributes.getExplicit("mathvariant")&&this.node.getProperty("pseudoscript")===!1){this.variant="-tex-variant";return}r.prototype.getVariant.call(this)},t.prototype.canStretch=function(e){if(this.stretch.dir!==0)return this.stretch.dir===e;var n=this.node.attributes;if(!n.get("stretchy"))return!1;var o=this.getText();if(Array.from(o).length!==1)return!1;var a=this.font.getDelimiter(o.codePointAt(0));return this.stretch=a&&a.dir===e?a:ph.NOSTRETCH,this.stretch.dir!==0},t.prototype.getStretchedVariant=function(e,n){var o,a;if(n===void 0&&(n=!1),this.stretch.dir!==0){var s=this.getWH(e),l=this.getSize("minsize",0),u=this.getSize("maxsize",1/0),c=this.node.getProperty("mathaccent");s=Math.max(l,Math.min(u,s));var f=this.font.params.delimiterfactor/1e3,h=this.font.params.delimitershortfall,p=l||n?s:c?Math.min(s/f,s+h):Math.max(s*f,s-h),d=this.stretch,y=d.c||this.getText().codePointAt(0),v=0;if(d.sizes)try{for(var _=fh(d.sizes),g=_.next();!g.done;g=_.next()){var w=g.value;if(w>=p){c&&v&&v--,this.variant=this.font.getSizeVariant(y,v),this.size=v,d.schar&&d.schar[v]&&(this.stretch=Tn(Tn({},this.stretch),{c:d.schar[v]}));return}v++}}catch(M){o={error:M}}finally{try{g&&!g.done&&(a=_.return)&&a.call(_)}finally{if(o)throw o.error}}d.stretch?(this.size=-1,this.invalidateBBox(),this.getStretchBBox(e,this.checkExtendedHeight(s,d),d)):(this.variant=this.font.getSizeVariant(y,v-1),this.size=v-1)}},t.prototype.getSize=function(e,n){var o=this.node.attributes;return o.isSet(e)&&(n=this.length2em(o.get(e),1,1)),n},t.prototype.getWH=function(e){if(e.length===0)return 0;if(e.length===1)return e[0];var n=oe(e,2),o=n[0],a=n[1],s=this.font.params.axis_height;return this.node.attributes.get("symmetric")?2*Math.max(o-s,a+s):o+a},t.prototype.getStretchBBox=function(e,n,o){var a;o.hasOwnProperty("min")&&o.min>n&&(n=o.min);var s=oe(o.HDW,3),l=s[0],u=s[1],c=s[2];this.stretch.dir===1?(a=oe(this.getBaseline(e,n,o),2),l=a[0],u=a[1]):c=n,this.bbox.h=l,this.bbox.d=u,this.bbox.w=c},t.prototype.getBaseline=function(e,n,o){var a=e.length===2&&e[0]+e[1]===n,s=this.node.attributes.get("symmetric"),l=oe(a?e:[n,0],2),u=l[0],c=l[1],f=oe([u+c,0],2),h=f[0],p=f[1];if(s){var d=this.font.params.axis_height;a&&(h=2*Math.max(u-d,c+d)),p=h/2-d}else if(a)p=c;else{var y=oe(o.HDW||[.75,.25],2),v=y[0],_=y[1];p=_*(h/(v+_))}return[h-p,p]},t.prototype.checkExtendedHeight=function(e,n){if(n.fullExt){var o=oe(n.fullExt,2),a=o[0],s=o[1],l=Math.ceil(Math.max(0,e-s)/a);e=s+l*a}return e},t.prototype.remapChars=function(e){var n=this.node.getProperty("primes");if(n)return(0,hh.unicodeChars)(n);if(e.length===1){var o=this.node.coreParent().parent,a=this.isAccent&&!o.isKind("mrow"),s=a?"accent":"mo",l=this.font.getRemappedChar(s,e[0]);l&&(e=this.unicodeChars(l,this.variant))}return e},t})(i)}J.CommonMoMixin=dh});var ps=m(Bt=>{"use strict";var yh=Bt&&Bt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),vh=Bt&&Bt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},Ge=Bt&&Bt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.SVGmo=void 0;var mh=k(),gh=fs(),_h=Ti(),Nn=.1,hs=.1,wh=(function(i){yh(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.node.attributes,n=e.get("symmetric")&&this.stretch.dir!==2,o=this.stretch.dir!==0;o&&this.size===null&&this.getStretchedVariant([]);var a=this.standardSVGnode(t);if(o&&this.size<0)this.stretchSVG();else{var s=n||e.get("largeop")?this.fixed(this.getCenterOffset()):"0",l=this.node.getProperty("mathaccent")?this.fixed(this.getAccentOffset()):"0";(s!=="0"||l!=="0")&&this.adaptor.setAttribute(a,"transform","translate(".concat(l," ").concat(s,")")),this.addChildren(a)}},r.prototype.stretchSVG=function(){var t=this.stretch.stretch,e=this.getStretchVariants(),n=this.getBBox();this.stretch.dir===1?this.stretchVertical(t,e,n):this.stretchHorizontal(t,e,n)},r.prototype.getStretchVariants=function(){var t,e,n=this.stretch.c||this.getText().codePointAt(0),o=[];try{for(var a=vh(this.stretch.stretch.keys()),s=a.next();!s.done;s=a.next()){var l=s.value;o[l]=this.font.getStretchVariant(n,l)}}catch(u){t={error:u}}finally{try{s&&!s.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}return o},r.prototype.stretchVertical=function(t,e,n){var o=n.h,a=n.d,s=n.w,l=this.addTop(t[0],e[0],o,s),u=this.addBot(t[2],e[2],a,s);if(t.length===4){var c=Ge(this.addMidV(t[3],e[3],s),2),f=c[0],h=c[1];this.addExtV(t[1],e[1],o,0,l,f,s),this.addExtV(t[1],e[1],0,a,h,u,s)}else this.addExtV(t[1],e[1],o,a,l,u,s)},r.prototype.stretchHorizontal=function(t,e,n){var o=n.w,a=this.addLeft(t[0],e[0]),s=this.addRight(t[2],e[2],o);if(t.length===4){var l=Ge(this.addMidH(t[3],e[3],o),2),u=l[0],c=l[1],f=o/2;this.addExtH(t[1],e[1],f,a,f-u),this.addExtH(t[1],e[1],f,c-f,s,f)}else this.addExtH(t[1],e[1],o,a,s)},r.prototype.getChar=function(t,e){var n=this.font.getChar(e,t)||[0,0,0,null];return[n[0],n[1],n[2],n[3]||{}]},r.prototype.addGlyph=function(t,e,n,o,a){return a===void 0&&(a=null),this.placeChar(t,n,o,a||this.element,e)},r.prototype.addTop=function(t,e,n,o){if(!t)return 0;var a=Ge(this.getChar(t,e),3),s=a[0],l=a[1],u=a[2];return this.addGlyph(t,e,(o-u)/2,n-s),s+l},r.prototype.addExtV=function(t,e,n,o,a,s,l){var u=this;if(t){a=Math.max(0,a-Nn),s=Math.max(0,s-Nn);var c=this.adaptor,f=Ge(this.getChar(t,e),3),h=f[0],p=f[1],d=f[2],y=n+o-a-s,v=1.5*y/(h+p),_=(v*(h-p)-y)/2;if(!(y<=0)){var g=this.svg("svg",{width:this.fixed(d),height:this.fixed(y),y:this.fixed(s-o),x:this.fixed((l-d)/2),viewBox:[0,_,d,y].map(function(M){return u.fixed(M)}).join(" ")});this.addGlyph(t,e,0,0,g);var w=c.lastChild(g);c.setAttribute(w,"transform","scale(1,".concat(this.jax.fixed(v),")")),c.append(this.element,g)}}},r.prototype.addBot=function(t,e,n,o){if(!t)return 0;var a=Ge(this.getChar(t,e),3),s=a[0],l=a[1],u=a[2];return this.addGlyph(t,e,(o-u)/2,l-n),s+l},r.prototype.addMidV=function(t,e,n){if(!t)return[0,0];var o=Ge(this.getChar(t,e),3),a=o[0],s=o[1],l=o[2],u=(s-a)/2+this.font.params.axis_height;return this.addGlyph(t,e,(n-l)/2,u),[a+u,s-u]},r.prototype.addLeft=function(t,e){return t?this.addGlyph(t,e,0,0):0},r.prototype.addExtH=function(t,e,n,o,a,s){var l=this;if(s===void 0&&(s=0),!!t){a=Math.max(0,a-hs),o=Math.max(0,o-hs);var u=this.adaptor,c=Ge(this.getChar(t,e),3),f=c[0],h=c[1],p=c[2],d=n-o-a,y=f+h+2*Nn,v=1.5*(d/p),_=-(h+Nn);if(!(d<=0)){var g=this.svg("svg",{width:this.fixed(d),height:this.fixed(y),x:this.fixed(s+o),y:this.fixed(_),viewBox:[(v*p-d)/2,_,d,y].map(function(M){return l.fixed(M)}).join(" ")});this.addGlyph(t,e,0,0,g);var w=u.lastChild(g);u.setAttribute(w,"transform","scale("+this.jax.fixed(v)+",1)"),u.append(this.element,g)}}},r.prototype.addRight=function(t,e,n){if(!t)return 0;var o=this.getChar(t,e)[2];return this.addGlyph(t,e,n-o,0)},r.prototype.addMidH=function(t,e,n){if(!t)return[0,0];var o=this.getChar(t,e)[2];return this.addGlyph(t,e,(n-o)/2,0),[(n-o)/2,(n+o)/2]},r.kind=_h.MmlMo.prototype.kind,r})((0,gh.CommonMoMixin)(mh.SVGWrapper));Bt.SVGmo=wh});var ds=m(Ze=>{"use strict";var xh=Ze&&Ze.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Ze,"__esModule",{value:!0});Ze.CommonMnMixin=void 0;function Mh(i){return(function(r){xh(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.remapChars=function(e){if(e.length){var n=this.font.getRemappedChar("mn",e[0]);if(n){var o=this.unicodeChars(n,this.variant);o.length===1?e[0]=o[0]:e=o.concat(e.slice(1))}}return e},t})(i)}Ze.CommonMnMixin=Mh});var $i=m(ae=>{"use strict";var bh=ae&&ae.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ui=ae&&ae.__assign||function(){return Ui=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Ui.apply(this,arguments)};Object.defineProperty(ae,"__esModule",{value:!0});ae.MmlMn=void 0;var Ki=C(),Sh=(function(i){bh(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=Ki.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mn"},enumerable:!1,configurable:!0}),r.defaults=Ui({},Ki.AbstractMmlTokenNode.defaults),r})(Ki.AbstractMmlTokenNode);ae.MmlMn=Sh});var ys=m(tr=>{"use strict";var Oh=tr&&tr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(tr,"__esModule",{value:!0});tr.SVGmn=void 0;var jh=k(),Ah=ds(),Ch=$i(),Ph=(function(i){Oh(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=Ch.MmlMn.prototype.kind,r})((0,Ah.CommonMnMixin)(jh.SVGWrapper));tr.SVGmn=Ph});var vs=m(Tt=>{"use strict";var Bh=Tt&&Tt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Th=Tt&&Tt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Nh=Tt&&Tt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.CommonMsMixin=void 0;function Eh(i){return(function(r){Bh(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Nh([],Th(e),!1))||this,a=o.node.attributes,s=a.getList("lquote","rquote");return o.variant!=="monospace"&&(!a.isSet("lquote")&&s.lquote==='"'&&(s.lquote="\u201C"),!a.isSet("rquote")&&s.rquote==='"'&&(s.rquote="\u201D")),o.childNodes.unshift(o.createText(s.lquote)),o.childNodes.push(o.createText(s.rquote)),o}return t.prototype.createText=function(e){var n=this.wrap(this.mmlText(e));return n.parent=this,n},t})(i)}Tt.CommonMsMixin=Eh});var Qi=m(se=>{"use strict";var Lh=se&&se.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),En=se&&se.__assign||function(){return En=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},En.apply(this,arguments)};Object.defineProperty(se,"__esModule",{value:!0});se.MmlMs=void 0;var Yi=C(),kh=(function(i){Lh(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=Yi.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"ms"},enumerable:!1,configurable:!0}),r.defaults=En(En({},Yi.AbstractMmlTokenNode.defaults),{lquote:'"',rquote:'"'}),r})(Yi.AbstractMmlTokenNode);se.MmlMs=kh});var ms=m(er=>{"use strict";var Vh=er&&er.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(er,"__esModule",{value:!0});er.SVGms=void 0;var qh=k(),Dh=vs(),Gh=Qi(),Ih=(function(i){Vh(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=Gh.MmlMs.prototype.kind,r})((0,Dh.CommonMsMixin)(qh.SVGWrapper));er.SVGms=Ih});var gs=m(rr=>{"use strict";var Wh=rr&&rr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(rr,"__esModule",{value:!0});rr.CommonMtextMixin=void 0;function Fh(i){var r;return r=(function(t){Wh(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.getVariant=function(){var n=this.jax.options,o=this.jax.math.outputData,a=(!!o.merrorFamily||!!n.merrorFont)&&this.node.Parent.isKind("merror");if(o.mtextFamily||n.mtextFont||a){var s=this.node.attributes.get("mathvariant"),l=this.constructor.INHERITFONTS[s]||this.jax.font.getCssFont(s),u=l[0]||(a?o.merrorFamily||n.merrorFont:o.mtextFamily||n.mtextFont);this.variant=this.explicitVariant(u,l[2]?"bold":"",l[1]?"italic":"");return}t.prototype.getVariant.call(this)},e})(i),r.INHERITFONTS={normal:["",!1,!1],bold:["",!1,!0],italic:["",!0,!1],"bold-italic":["",!0,!0]},r}rr.CommonMtextMixin=Fh});var eo=m(le=>{"use strict";var Rh=le&&le.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),to=le&&le.__assign||function(){return to=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},to.apply(this,arguments)};Object.defineProperty(le,"__esModule",{value:!0});le.MmlMtext=void 0;var Zi=C(),Hh=(function(i){Rh(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=Zi.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mtext"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSpacelike",{get:function(){return!0},enumerable:!1,configurable:!0}),r.defaults=to({},Zi.AbstractMmlTokenNode.defaults),r})(Zi.AbstractMmlTokenNode);le.MmlMtext=Hh});var _s=m(nr=>{"use strict";var Xh=nr&&nr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(nr,"__esModule",{value:!0});nr.SVGmtext=void 0;var zh=k(),Jh=gs(),Kh=eo(),Uh=(function(i){Xh(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=Kh.MmlMtext.prototype.kind,r})((0,Jh.CommonMtextMixin)(zh.SVGWrapper));nr.SVGmtext=Uh});var io=m(ue=>{"use strict";var $h=ue&&ue.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),no=ue&&ue.__assign||function(){return no=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},no.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0});ue.MmlMerror=void 0;var ro=C(),Yh=(function(i){$h(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=ro.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"merror"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.defaults=no({},ro.AbstractMmlNode.defaults),r})(ro.AbstractMmlNode);ue.MmlMerror=Yh});var ws=m(ir=>{"use strict";var Qh=ir&&ir.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(ir,"__esModule",{value:!0});ir.SVGmerror=void 0;var Zh=k(),tp=io(),ep=(function(i){Qh(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t),n=this.getBBox(),o=n.h,a=n.d,s=n.w;this.adaptor.append(this.element,this.svg("rect",{"data-background":!0,width:this.fixed(s),height:this.fixed(o+a),y:this.fixed(-a)}));var l=this.node.attributes.get("title");l&&this.adaptor.append(this.element,this.svg("title",{},[this.adaptor.text(l)])),this.addChildren(e)},r.kind=tp.MmlMerror.prototype.kind,r.styles={'g[data-mml-node="merror"] > g':{fill:"red",stroke:"red"},'g[data-mml-node="merror"] > rect[data-background]':{fill:"yellow",stroke:"none"}},r})(Zh.SVGWrapper);ir.SVGmerror=ep});var xs=m(or=>{"use strict";var rp=or&&or.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(or,"__esModule",{value:!0});or.CommonMspaceMixin=void 0;function np(i){return(function(r){rp(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1);var o=this.node.attributes;e.w=this.length2em(o.get("width"),0),e.h=this.length2em(o.get("height"),0),e.d=this.length2em(o.get("depth"),0)},t.prototype.handleVariant=function(){},t})(i)}or.CommonMspaceMixin=np});var ao=m(ce=>{"use strict";var ip=ce&&ce.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ln=ce&&ce.__assign||function(){return Ln=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Ln.apply(this,arguments)};Object.defineProperty(ce,"__esModule",{value:!0});ce.MmlMspace=void 0;var oo=C(),op=(function(i){ip(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=oo.TEXCLASS.NONE,t}return r.prototype.setTeXclass=function(t){return t},Object.defineProperty(r.prototype,"kind",{get:function(){return"mspace"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSpacelike",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"hasNewline",{get:function(){var t=this.attributes;return t.getExplicit("width")==null&&t.getExplicit("height")==null&&t.getExplicit("depth")==null&&t.get("linebreak")==="newline"},enumerable:!1,configurable:!0}),r.defaults=Ln(Ln({},oo.AbstractMmlTokenNode.defaults),{width:"0em",height:"0ex",depth:"0ex",linebreak:"auto"}),r})(oo.AbstractMmlTokenNode);ce.MmlMspace=op});var Ms=m(ar=>{"use strict";var ap=ar&&ar.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(ar,"__esModule",{value:!0});ar.SVGmspace=void 0;var sp=k(),lp=xs(),up=ao(),cp=(function(i){ap(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=up.MmlMspace.prototype.kind,r})((0,lp.CommonMspaceMixin)(sp.SVGWrapper));ar.SVGmspace=cp});var bs=m(fe=>{"use strict";var fp=fe&&fe.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),hp=fe&&fe.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(fe,"__esModule",{value:!0});fe.CommonMpaddedMixin=void 0;function pp(i){return(function(r){fp(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.getDimens=function(){var e=this.node.attributes.getList("width","height","depth","lspace","voffset"),n=this.childNodes[0].getBBox(),o=n.w,a=n.h,s=n.d,l=o,u=a,c=s,f=0,h=0,p=0;e.width!==""&&(o=this.dimen(e.width,n,"w",0)),e.height!==""&&(a=this.dimen(e.height,n,"h",0)),e.depth!==""&&(s=this.dimen(e.depth,n,"d",0)),e.voffset!==""&&(h=this.dimen(e.voffset,n)),e.lspace!==""&&(f=this.dimen(e.lspace,n));var d=this.node.attributes.get("data-align");return d&&(p=this.getAlignX(o,n,d)),[u,c,l,a-u,s-c,o-l,f,h,p]},t.prototype.dimen=function(e,n,o,a){o===void 0&&(o=""),a===void 0&&(a=null),e=String(e);var s=e.match(/width|height|depth/),l=s?n[s[0].charAt(0)]:o?n[o]:0,u=this.length2em(e,l)||0;return e.match(/^[-+]/)&&o&&(u+=l),a!=null&&(u=Math.max(a,u)),u},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1);var o=hp(this.getDimens(),6),a=o[0],s=o[1],l=o[2],u=o[3],c=o[4],f=o[5];e.w=l+f,e.h=a+u,e.d=s+c,this.setChildPWidths(n,e.w)},t.prototype.getWrapWidth=function(e){return this.getBBox().w},t.prototype.getChildAlign=function(e){return this.node.attributes.get("data-align")||"left"},t})(i)}fe.CommonMpaddedMixin=pp});var so=m(he=>{"use strict";var dp=he&&he.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),kn=he&&he.__assign||function(){return kn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},kn.apply(this,arguments)};Object.defineProperty(he,"__esModule",{value:!0});he.MmlMpadded=void 0;var Ss=C(),yp=(function(i){dp(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mpadded"},enumerable:!1,configurable:!0}),r.defaults=kn(kn({},Ss.AbstractMmlLayoutNode.defaults),{width:"",height:"",depth:"",lspace:0,voffset:0}),r})(Ss.AbstractMmlLayoutNode);he.MmlMpadded=yp});var Os=m(pe=>{"use strict";var vp=pe&&pe.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),mp=pe&&pe.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(pe,"__esModule",{value:!0});pe.SVGmpadded=void 0;var gp=k(),_p=bs(),wp=so(),xp=(function(i){vp(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t),n=mp(this.getDimens(),9),o=n[5],a=n[6],s=n[7],l=n[8],u=this.node.attributes.get("data-align")||"left",c=a+l-(o<0&&u!=="left"?u==="center"?o/2:o:0);(c||s)&&(e=this.adaptor.append(e,this.svg("g")),this.place(c,s,e)),this.addChildren(e)},r.kind=wp.MmlMpadded.prototype.kind,r})((0,_p.CommonMpaddedMixin)(gp.SVGWrapper));pe.SVGmpadded=xp});var co=m(de=>{"use strict";var Mp=de&&de.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),uo=de&&de.__assign||function(){return uo=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},uo.apply(this,arguments)};Object.defineProperty(de,"__esModule",{value:!0});de.MmlMphantom=void 0;var lo=C(),bp=(function(i){Mp(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=lo.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mphantom"},enumerable:!1,configurable:!0}),r.defaults=uo({},lo.AbstractMmlLayoutNode.defaults),r})(lo.AbstractMmlLayoutNode);de.MmlMphantom=bp});var js=m(sr=>{"use strict";var Sp=sr&&sr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(sr,"__esModule",{value:!0});sr.SVGmphantom=void 0;var Op=k(),jp=co(),Ap=(function(i){Sp(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){this.standardSVGnode(t)},r.kind=jp.MmlMphantom.prototype.kind,r})(Op.SVGWrapper);sr.SVGmphantom=Ap});var Cs=m(Nt=>{"use strict";var Cp=Nt&&Nt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),As=Nt&&Nt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Pp=Nt&&Nt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.CommonMfracMixin=void 0;function Bp(i){return(function(r){Cp(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Pp([],As(e),!1))||this;if(o.bevel=null,o.pad=o.node.getProperty("withDelims")?0:o.font.params.nulldelimiterspace,o.node.attributes.get("bevelled")){var a=o.getBevelData(o.isDisplay()).H,s=o.bevel=o.createMo("/");s.node.attributes.set("symmetric",!0),s.canStretch(1),s.getStretchedVariant([a],!0)}return o}return t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1),e.empty();var o=this.node.attributes.getList("linethickness","bevelled"),a=o.linethickness,s=o.bevelled,l=this.isDisplay(),u=null;if(s)this.getBevelledBBox(e,l);else{var c=this.length2em(String(a),.06);u=-2*this.pad,c===0?this.getAtopBBox(e,l):(this.getFractionBBox(e,l,c),u-=.2),u+=e.w}e.clean(),this.setChildPWidths(n,u)},t.prototype.getFractionBBox=function(e,n,o){var a=this.childNodes[0].getOuterBBox(),s=this.childNodes[1].getOuterBBox(),l=this.font.params,u=l.axis_height,c=this.getTUV(n,o),f=c.T,h=c.u,p=c.v;e.combine(a,0,u+f+Math.max(a.d*a.rscale,h)),e.combine(s,0,u-f-Math.max(s.h*s.rscale,p)),e.w+=2*this.pad+.2},t.prototype.getTUV=function(e,n){var o=this.font.params,a=o.axis_height,s=(e?3.5:1.5)*n;return{T:(e?3.5:1.5)*n,u:(e?o.num1:o.num2)-a-s,v:(e?o.denom1:o.denom2)+a-s}},t.prototype.getAtopBBox=function(e,n){var o=this.getUVQ(n),a=o.u,s=o.v,l=o.nbox,u=o.dbox;e.combine(l,0,a),e.combine(u,0,-s),e.w+=2*this.pad},t.prototype.getUVQ=function(e){var n=this.childNodes[0].getOuterBBox(),o=this.childNodes[1].getOuterBBox(),a=this.font.params,s=As(e?[a.num1,a.denom1]:[a.num3,a.denom2],2),l=s[0],u=s[1],c=(e?7:3)*a.rule_thickness,f=l-n.d*n.scale-(o.h*o.scale-u);return f<c&&(l+=(c-f)/2,u+=(c-f)/2,f=c),{u:l,v:u,q:f,nbox:n,dbox:o}},t.prototype.getBevelledBBox=function(e,n){var o=this.getBevelData(n),a=o.u,s=o.v,l=o.delta,u=o.nbox,c=o.dbox,f=this.bevel.getOuterBBox();e.combine(u,0,a),e.combine(f,e.w-l/2,0),e.combine(c,e.w-l/2,s)},t.prototype.getBevelData=function(e){var n=this.childNodes[0].getOuterBBox(),o=this.childNodes[1].getOuterBBox(),a=e?.4:.15,s=Math.max(n.scale*(n.h+n.d),o.scale*(o.h+o.d))+2*a,l=this.font.params.axis_height,u=n.scale*(n.d-n.h)/2+l+a,c=o.scale*(o.d-o.h)/2+l-a;return{H:s,delta:a,u,v:c,nbox:n,dbox:o}},t.prototype.canStretch=function(e){return!1},t.prototype.isDisplay=function(){var e=this.node.attributes.getList("displaystyle","scriptlevel"),n=e.displaystyle,o=e.scriptlevel;return n&&o===0},t.prototype.getWrapWidth=function(e){var n=this.node.attributes;if(n.get("bevelled"))return this.childNodes[e].getOuterBBox().w;var o=this.getBBox().w,a=this.length2em(n.get("linethickness"));return o-(a?.2:0)-2*this.pad},t.prototype.getChildAlign=function(e){var n=this.node.attributes;return n.get("bevelled")?"left":n.get(["numalign","denomalign"][e])},t})(i)}Nt.CommonMfracMixin=Bp});var fo=m(Et=>{"use strict";var Tp=Et&&Et.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Vn=Et&&Et.__assign||function(){return Vn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Vn.apply(this,arguments)},Np=Et&&Et.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Et,"__esModule",{value:!0});Et.MmlMfrac=void 0;var Ps=C(),Ep=(function(i){Tp(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mfrac"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 2},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setTeXclass=function(t){var e,n;this.getPrevClass(t);try{for(var o=Np(this.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;s.setTeXclass(null)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return this},r.prototype.setChildInheritedAttributes=function(t,e,n,o){(!e||n>0)&&n++,this.childNodes[0].setInheritedAttributes(t,!1,n,o),this.childNodes[1].setInheritedAttributes(t,!1,n,!0)},r.defaults=Vn(Vn({},Ps.AbstractMmlBaseNode.defaults),{linethickness:"medium",numalign:"center",denomalign:"center",bevelled:!1}),r})(Ps.AbstractMmlBaseNode);Et.MmlMfrac=Ep});var Bs=m(ye=>{"use strict";var Lp=ye&&ye.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),ho=ye&&ye.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(ye,"__esModule",{value:!0});ye.SVGmfrac=void 0;var kp=k(),Vp=Cs(),qp=fo(),Dp=(function(i){Lp(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){this.standardSVGnode(t);var e=this.node.attributes.getList("linethickness","bevelled"),n=e.linethickness,o=e.bevelled,a=this.isDisplay();if(o)this.makeBevelled(a);else{var s=this.length2em(String(n),.06);s===0?this.makeAtop(a):this.makeFraction(a,s)}},r.prototype.makeFraction=function(t,e){var n=this.element,o=this.node.attributes.getList("numalign","denomalign"),a=o.numalign,s=o.denomalign,l=ho(this.childNodes,2),u=l[0],c=l[1],f=u.getOuterBBox(),h=c.getOuterBBox(),p=this.font.params,d=p.axis_height,y=.1,v=this.node.getProperty("withDelims")?0:p.nulldelimiterspace,_=Math.max((f.L+f.w+f.R)*f.rscale,(h.L+h.w+h.R)*h.rscale),g=this.getAlignX(_,f,a)+y+v,w=this.getAlignX(_,h,s)+y+v,M=this.getTUV(t,e),b=M.T,P=M.u,B=M.v;u.toSVG(n),u.place(g,d+b+Math.max(f.d*f.rscale,P)),c.toSVG(n),c.place(w,d-b-Math.max(h.h*h.rscale,B)),this.adaptor.append(n,this.svg("rect",{width:this.fixed(_+2*y),height:this.fixed(e),x:this.fixed(v),y:this.fixed(d-e/2)}))},r.prototype.makeAtop=function(t){var e=this.element,n=this.node.attributes.getList("numalign","denomalign"),o=n.numalign,a=n.denomalign,s=ho(this.childNodes,2),l=s[0],u=s[1],c=l.getOuterBBox(),f=u.getOuterBBox(),h=this.font.params,p=this.node.getProperty("withDelims")?0:h.nulldelimiterspace,d=Math.max((c.L+c.w+c.R)*c.rscale,(f.L+f.w+f.R)*f.rscale),y=this.getAlignX(d,c,o)+p,v=this.getAlignX(d,f,a)+p,_=this.getUVQ(t),g=_.u,w=_.v;l.toSVG(e),l.place(y,g),u.toSVG(e),u.place(v,-w)},r.prototype.makeBevelled=function(t){var e=this.element,n=ho(this.childNodes,2),o=n[0],a=n[1],s=this.getBevelData(t),l=s.u,u=s.v,c=s.delta,f=s.nbox,h=s.dbox,p=(f.L+f.w+f.R)*f.rscale;o.toSVG(e),this.bevel.toSVG(e),a.toSVG(e),o.place(f.L*f.rscale,l),this.bevel.place(p-c/2,0),a.place(p+this.bevel.getOuterBBox().w+h.L*h.rscale-c,u)},r.kind=qp.MmlMfrac.prototype.kind,r})((0,Vp.CommonMfracMixin)(kp.SVGWrapper));ye.SVGmfrac=Dp});var Ns=m(Lt=>{"use strict";var Gp=Lt&&Lt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ts=Lt&&Lt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Ip=Lt&&Lt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Lt,"__esModule",{value:!0});Lt.CommonMsqrtMixin=void 0;var Wp=Kt();function Fp(i){return(function(r){Gp(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Ip([],Ts(e),!1))||this,a=o.createMo("\u221A");a.canStretch(1);var s=o.childNodes[o.base].getOuterBBox(),l=s.h,u=s.d,c=o.font.params.rule_thickness,f=o.node.attributes.get("displaystyle")?o.font.params.x_height:c;return o.surdH=l+u+2*c+f/4,a.getStretchedVariant([o.surdH-u,u],!0),o}return Object.defineProperty(t.prototype,"base",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surd",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return null},enumerable:!1,configurable:!0}),t.prototype.createMo=function(e){var n=r.prototype.createMo.call(this,e);return this.childNodes.push(n),n},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1);var o=this.childNodes[this.surd].getBBox(),a=new Wp.BBox(this.childNodes[this.base].getOuterBBox()),s=this.getPQ(o)[1],l=this.font.params.rule_thickness,u=a.h+s+l,c=Ts(this.getRootDimens(o,u),1),f=c[0];e.h=u+l,this.combineRootBBox(e,o,u),e.combine(o,f,u-o.h),e.combine(a,f+o.w,0),e.clean(),this.setChildPWidths(n)},t.prototype.combineRootBBox=function(e,n,o){},t.prototype.getPQ=function(e){var n=this.font.params.rule_thickness,o=this.node.attributes.get("displaystyle")?this.font.params.x_height:n,a=e.h+e.d>this.surdH?(e.h+e.d-(this.surdH-2*n-o/2))/2:n+o/4;return[o,a]},t.prototype.getRootDimens=function(e,n){return[0,0,0,0]},t})(i)}Lt.CommonMsqrtMixin=Fp});var vo=m(ve=>{"use strict";var Rp=ve&&ve.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),yo=ve&&ve.__assign||function(){return yo=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},yo.apply(this,arguments)};Object.defineProperty(ve,"__esModule",{value:!0});ve.MmlMsqrt=void 0;var po=C(),Hp=(function(i){Rp(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=po.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"msqrt"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setTeXclass=function(t){return this.getPrevClass(t),this.childNodes[0].setTeXclass(null),this},r.prototype.setChildInheritedAttributes=function(t,e,n,o){this.childNodes[0].setInheritedAttributes(t,e,n,!0)},r.defaults=yo({},po.AbstractMmlNode.defaults),r})(po.AbstractMmlNode);ve.MmlMsqrt=Hp});var mo=m(lr=>{"use strict";var Xp=lr&&lr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(lr,"__esModule",{value:!0});lr.SVGmsqrt=void 0;var zp=k(),Jp=Ns(),Kp=vo(),Up=(function(i){Xp(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.dx=0,t}return r.prototype.toSVG=function(t){var e=this.childNodes[this.surd],n=this.childNodes[this.base],o=this.root?this.childNodes[this.root]:null,a=e.getBBox(),s=n.getOuterBBox(),l=this.getPQ(a)[1],u=this.font.params.rule_thickness*this.bbox.scale,c=s.h+l+u,f=this.standardSVGnode(t),h=this.adaptor.append(f,this.svg("g"));this.addRoot(f,o,a,c),e.toSVG(f),e.place(this.dx,c-a.h),n.toSVG(h),n.place(this.dx+a.w,0),this.adaptor.append(f,this.svg("rect",{width:this.fixed(s.w),height:this.fixed(u),x:this.fixed(this.dx+a.w),y:this.fixed(c-u)}))},r.prototype.addRoot=function(t,e,n,o){},r.kind=Kp.MmlMsqrt.prototype.kind,r})((0,Jp.CommonMsqrtMixin)(zp.SVGWrapper));lr.SVGmsqrt=Up});var Es=m(ur=>{"use strict";var $p=ur&&ur.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(ur,"__esModule",{value:!0});ur.CommonMrootMixin=void 0;function Yp(i){return(function(r){$p(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"surd",{get:function(){return 2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"root",{get:function(){return 1},enumerable:!1,configurable:!0}),t.prototype.combineRootBBox=function(e,n,o){var a=this.childNodes[this.root].getOuterBBox(),s=this.getRootDimens(n,o)[1];e.combine(a,0,s)},t.prototype.getRootDimens=function(e,n){var o=this.childNodes[this.surd],a=this.childNodes[this.root].getOuterBBox(),s=(o.size<0?.5:.6)*e.w,l=a.w,u=a.rscale,c=Math.max(l,s/u),f=Math.max(0,c-l),h=this.rootHeight(a,e,o.size,n),p=c*u-s;return[p,h,f]},t.prototype.rootHeight=function(e,n,o,a){var s=n.h+n.d,l=(o<0?1.9:.55*s)-(s-a);return l+Math.max(0,e.d*e.rscale)},t})(i)}ur.CommonMrootMixin=Yp});var wo=m(me=>{"use strict";var Qp=me&&me.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),_o=me&&me.__assign||function(){return _o=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},_o.apply(this,arguments)};Object.defineProperty(me,"__esModule",{value:!0});me.MmlMroot=void 0;var go=C(),Zp=(function(i){Qp(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=go.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mroot"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 2},enumerable:!1,configurable:!0}),r.prototype.setTeXclass=function(t){return this.getPrevClass(t),this.childNodes[0].setTeXclass(null),this.childNodes[1].setTeXclass(null),this},r.prototype.setChildInheritedAttributes=function(t,e,n,o){this.childNodes[0].setInheritedAttributes(t,e,n,!0),this.childNodes[1].setInheritedAttributes(t,!1,n+2,o)},r.defaults=_o({},go.AbstractMmlNode.defaults),r})(go.AbstractMmlNode);me.MmlMroot=Zp});var Ls=m(ge=>{"use strict";var td=ge&&ge.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),ed=ge&&ge.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(ge,"__esModule",{value:!0});ge.SVGmroot=void 0;var rd=mo(),nd=Es(),id=wo(),od=(function(i){td(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.addRoot=function(t,e,n,o){e.toSVG(t);var a=ed(this.getRootDimens(n,o),3),s=a[0],l=a[1],u=a[2],c=e.getOuterBBox();e.place(u*c.rscale,l),this.dx=s},r.kind=id.MmlMroot.prototype.kind,r})((0,nd.CommonMrootMixin)(rd.SVGmsqrt));ge.SVGmroot=od});var ks=m(at=>{"use strict";var ad=at&&at.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),sd=at&&at.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},ld=at&&at.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},ud=at&&at.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(at,"__esModule",{value:!0});at.CommonMfencedMixin=void 0;function cd(i){return(function(r){ad(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,ld([],sd(e),!1))||this;return o.mrow=null,o.createMrow(),o.addMrowChildren(),o}return t.prototype.createMrow=function(){var e=this.node.factory,n=e.create("inferredMrow");n.inheritAttributesFrom(this.node),this.mrow=this.wrap(n),this.mrow.parent=this},t.prototype.addMrowChildren=function(){var e,n,o=this.node,a=this.mrow;this.addMo(o.open),this.childNodes.length&&a.childNodes.push(this.childNodes[0]);var s=0;try{for(var l=ud(this.childNodes.slice(1)),u=l.next();!u.done;u=l.next()){var c=u.value;this.addMo(o.separators[s++]),a.childNodes.push(c)}}catch(f){e={error:f}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}this.addMo(o.close),a.stretchChildren()},t.prototype.addMo=function(e){if(e){var n=this.wrap(e);this.mrow.childNodes.push(n),n.parent=this.mrow}},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1),e.updateFrom(this.mrow.getOuterBBox()),this.setChildPWidths(n)},t})(i)}at.CommonMfencedMixin=cd});var xo=m(kt=>{"use strict";var fd=kt&&kt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),qn=kt&&kt.__assign||function(){return qn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},qn.apply(this,arguments)},Vs=kt&&kt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(kt,"__esModule",{value:!0});kt.MmlMfenced=void 0;var Qr=C(),hd=(function(i){fd(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=Qr.TEXCLASS.INNER,t.separators=[],t.open=null,t.close=null,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mfenced"},enumerable:!1,configurable:!0}),r.prototype.setTeXclass=function(t){this.getPrevClass(t),this.open&&(t=this.open.setTeXclass(t)),this.childNodes[0]&&(t=this.childNodes[0].setTeXclass(t));for(var e=1,n=this.childNodes.length;e<n;e++)this.separators[e-1]&&(t=this.separators[e-1].setTeXclass(t)),this.childNodes[e]&&(t=this.childNodes[e].setTeXclass(t));return this.close&&(t=this.close.setTeXclass(t)),this.updateTeXclass(this.open),t},r.prototype.setChildInheritedAttributes=function(t,e,n,o){var a,s;this.addFakeNodes();try{for(var l=Vs([this.open,this.close].concat(this.separators)),u=l.next();!u.done;u=l.next()){var c=u.value;c&&c.setInheritedAttributes(t,e,n,o)}}catch(f){a={error:f}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}i.prototype.setChildInheritedAttributes.call(this,t,e,n,o)},r.prototype.addFakeNodes=function(){var t,e,n=this.attributes.getList("open","close","separators"),o=n.open,a=n.close,s=n.separators;if(o=o.replace(/[ \t\n\r]/g,""),a=a.replace(/[ \t\n\r]/g,""),s=s.replace(/[ \t\n\r]/g,""),o&&(this.open=this.fakeNode(o,{fence:!0,form:"prefix"},Qr.TEXCLASS.OPEN)),s){for(;s.length<this.childNodes.length-1;)s+=s.charAt(s.length-1);var l=0;try{for(var u=Vs(this.childNodes.slice(1)),c=u.next();!c.done;c=u.next()){var f=c.value;f&&this.separators.push(this.fakeNode(s.charAt(l++)))}}catch(h){t={error:h}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}}a&&(this.close=this.fakeNode(a,{fence:!0,form:"postfix"},Qr.TEXCLASS.CLOSE))},r.prototype.fakeNode=function(t,e,n){e===void 0&&(e={}),n===void 0&&(n=null);var o=this.factory.create("text").setText(t),a=this.factory.create("mo",e,[o]);return a.texClass=n,a.parent=this,a},r.defaults=qn(qn({},Qr.AbstractMmlNode.defaults),{open:"(",close:")",separators:","}),r})(Qr.AbstractMmlNode);kt.MmlMfenced=hd});var qs=m(_e=>{"use strict";var pd=_e&&_e.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),dd=_e&&_e.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(_e,"__esModule",{value:!0});_e.SVGmfenced=void 0;var yd=k(),vd=ks(),md=xo(),gd=(function(i){pd(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t);this.setChildrenParent(this.mrow),this.mrow.toSVG(e),this.setChildrenParent(this)},r.prototype.setChildrenParent=function(t){var e,n;try{for(var o=dd(this.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;s.parent=t}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}},r.kind=md.MmlMfenced.prototype.kind,r})((0,vd.CommonMfencedMixin)(yd.SVGWrapper));_e.SVGmfenced=gd});var Gs=m(st=>{"use strict";var _d=st&&st.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Mo=st&&st.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Ds=st&&st.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},cr=st&&st.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(st,"__esModule",{value:!0});st.CommonScriptbaseMixin=void 0;var wd=C();function xd(i){var r;return r=(function(t){_d(e,t);function e(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var a=t.apply(this,Ds([],Mo(n),!1))||this;a.baseScale=1,a.baseIc=0,a.baseRemoveIc=!1,a.baseIsChar=!1,a.baseHasAccentOver=null,a.baseHasAccentUnder=null,a.isLineAbove=!1,a.isLineBelow=!1,a.isMathAccent=!1;var s=a.baseCore=a.getBaseCore();return s&&(a.setBaseAccentsFor(s),a.baseScale=a.getBaseScale(),a.baseIc=a.getBaseIc(),a.baseIsChar=a.isCharBase(),a.isMathAccent=a.baseIsChar&&a.scriptChild&&!!a.scriptChild.coreMO().node.getProperty("mathaccent"),a.checkLineAccents(),a.baseRemoveIc=!a.isLineAbove&&!a.isLineBelow&&(!a.constructor.useIC||a.isMathAccent)),a}return Object.defineProperty(e.prototype,"baseChild",{get:function(){return this.childNodes[this.node.base]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scriptChild",{get:function(){return this.childNodes[1]},enumerable:!1,configurable:!0}),e.prototype.getBaseCore=function(){for(var n=this.getSemanticBase()||this.childNodes[0];n&&(n.childNodes.length===1&&(n.node.isKind("mrow")||n.node.isKind("TeXAtom")&&n.node.texClass!==wd.TEXCLASS.VCENTER||n.node.isKind("mstyle")||n.node.isKind("mpadded")||n.node.isKind("mphantom")||n.node.isKind("semantics"))||n.node.isKind("munderover")&&n.isMathAccent);)this.setBaseAccentsFor(n),n=n.childNodes[0];return n||(this.baseHasAccentOver=this.baseHasAccentUnder=!1),n||this.childNodes[0]},e.prototype.setBaseAccentsFor=function(n){n.node.isKind("munderover")&&(this.baseHasAccentOver===null&&(this.baseHasAccentOver=!!n.node.attributes.get("accent")),this.baseHasAccentUnder===null&&(this.baseHasAccentUnder=!!n.node.attributes.get("accentunder")))},e.prototype.getSemanticBase=function(){var n=this.node.attributes.getExplicit("data-semantic-fencepointer");return this.getBaseFence(this.baseChild,n)},e.prototype.getBaseFence=function(n,o){var a,s;if(!n||!n.node.attributes||!o)return null;if(n.node.attributes.getExplicit("data-semantic-id")===o)return n;try{for(var l=cr(n.childNodes),u=l.next();!u.done;u=l.next()){var c=u.value,f=this.getBaseFence(c,o);if(f)return f}}catch(h){a={error:h}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}return null},e.prototype.getBaseScale=function(){for(var n=this.baseCore,o=1;n&&n!==this;){var a=n.getOuterBBox();o*=a.rscale,n=n.parent}return o},e.prototype.getBaseIc=function(){return this.baseCore.getOuterBBox().ic*this.baseScale},e.prototype.getAdjustedIc=function(){var n=this.baseCore.getOuterBBox();return(n.ic?1.05*n.ic+.05:0)*this.baseScale},e.prototype.isCharBase=function(){var n=this.baseCore;return(n.node.isKind("mo")&&n.size===null||n.node.isKind("mi")||n.node.isKind("mn"))&&n.bbox.rscale===1&&Array.from(n.getText()).length===1},e.prototype.checkLineAccents=function(){if(this.node.isKind("munderover"))if(this.node.isKind("mover"))this.isLineAbove=this.isLineAccent(this.scriptChild);else if(this.node.isKind("munder"))this.isLineBelow=this.isLineAccent(this.scriptChild);else{var n=this;this.isLineAbove=this.isLineAccent(n.overChild),this.isLineBelow=this.isLineAccent(n.underChild)}},e.prototype.isLineAccent=function(n){var o=n.coreMO().node;return o.isToken&&o.getText()==="\u2015"},e.prototype.getBaseWidth=function(){var n=this.baseChild.getOuterBBox();return n.w*n.rscale-(this.baseRemoveIc?this.baseIc:0)+this.font.params.extra_ic},e.prototype.computeBBox=function(n,o){o===void 0&&(o=!1);var a=this.getBaseWidth(),s=Mo(this.getOffset(),2),l=s[0],u=s[1];n.append(this.baseChild.getOuterBBox()),n.combine(this.scriptChild.getOuterBBox(),a+l,u),n.w+=this.font.params.scriptspace,n.clean(),this.setChildPWidths(o)},e.prototype.getOffset=function(){return[0,0]},e.prototype.baseCharZero=function(n){var o=!!this.baseCore.node.attributes.get("largeop"),a=this.baseScale;return this.baseIsChar&&!o&&a===1?0:n},e.prototype.getV=function(){var n=this.baseCore.getOuterBBox(),o=this.scriptChild.getOuterBBox(),a=this.font.params,s=this.length2em(this.node.attributes.get("subscriptshift"),a.sub1);return Math.max(this.baseCharZero(n.d*this.baseScale+a.sub_drop*o.rscale),s,o.h*o.rscale-4/5*a.x_height)},e.prototype.getU=function(){var n=this.baseCore.getOuterBBox(),o=this.scriptChild.getOuterBBox(),a=this.font.params,s=this.node.attributes.getList("displaystyle","superscriptshift"),l=this.node.getProperty("texprimestyle"),u=l?a.sup3:s.displaystyle?a.sup1:a.sup2,c=this.length2em(s.superscriptshift,u);return Math.max(this.baseCharZero(n.h*this.baseScale-a.sup_drop*o.rscale),c,o.d*o.rscale+1/4*a.x_height)},e.prototype.hasMovableLimits=function(){var n=this.node.attributes.get("displaystyle"),o=this.baseChild.coreMO().node;return!n&&!!o.attributes.get("movablelimits")},e.prototype.getOverKU=function(n,o){var a=this.node.attributes.get("accent"),s=this.font.params,l=o.d*o.rscale,u=s.rule_thickness*s.separation_factor,c=this.baseHasAccentOver?u:0,f=this.isLineAbove?3*s.rule_thickness:u,h=(a?f:Math.max(s.big_op_spacing1,s.big_op_spacing3-Math.max(0,l)))-c;return[h,n.h*n.rscale+h+l]},e.prototype.getUnderKV=function(n,o){var a=this.node.attributes.get("accentunder"),s=this.font.params,l=o.h*o.rscale,u=s.rule_thickness*s.separation_factor,c=this.baseHasAccentUnder?u:0,f=this.isLineBelow?3*s.rule_thickness:u,h=(a?f:Math.max(s.big_op_spacing2,s.big_op_spacing4-l))-c;return[h,-(n.d*n.rscale+h+l)]},e.prototype.getDeltaW=function(n,o){var a,s,l,u;o===void 0&&(o=[0,0,0]);var c=this.node.attributes.get("align"),f=n.map(function(M){return M.w*M.rscale});f[0]-=this.baseRemoveIc&&!this.baseCore.node.attributes.get("largeop")?this.baseIc:0;var h=Math.max.apply(Math,Ds([],Mo(f),!1)),p=[],d=0;try{for(var y=cr(f.keys()),v=y.next();!v.done;v=y.next()){var _=v.value;p[_]=(c==="center"?(h-f[_])/2:c==="right"?h-f[_]:0)+o[_],p[_]<d&&(d=-p[_])}}catch(M){a={error:M}}finally{try{v&&!v.done&&(s=y.return)&&s.call(y)}finally{if(a)throw a.error}}if(d)try{for(var g=cr(p.keys()),w=g.next();!w.done;w=g.next()){var _=w.value;p[_]+=d}}catch(M){l={error:M}}finally{try{w&&!w.done&&(u=g.return)&&u.call(g)}finally{if(l)throw l.error}}return[1,2].map(function(M){return p[M]+=n[M]?n[M].dx*n[0].scale:0}),p},e.prototype.getDelta=function(n){n===void 0&&(n=!1);var o=this.node.attributes.get("accent"),a=this.baseCore.getOuterBBox(),s=a.sk,l=a.ic;return((o&&!n?s:0)+this.font.skewIcFactor*l)*this.baseScale},e.prototype.stretchChildren=function(){var n,o,a,s,l,u,c=[];try{for(var f=cr(this.childNodes),h=f.next();!h.done;h=f.next()){var p=h.value;p.canStretch(2)&&c.push(p)}}catch(A){n={error:A}}finally{try{h&&!h.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}var d=c.length,y=this.childNodes.length;if(d&&y>1){var v=0,_=d>1&&d===y;try{for(var g=cr(this.childNodes),w=g.next();!w.done;w=g.next()){var p=w.value,M=p.stretch.dir===0;if(_||M){var b=p.getOuterBBox(M),P=b.w,B=b.rscale;P*B>v&&(v=P*B)}}}catch(A){a={error:A}}finally{try{w&&!w.done&&(s=g.return)&&s.call(g)}finally{if(a)throw a.error}}try{for(var E=cr(c),T=E.next();!T.done;T=E.next()){var p=T.value;p.coreMO().getStretchedVariant([v/p.bbox.rscale])}}catch(A){l={error:A}}finally{try{T&&!T.done&&(u=E.return)&&u.call(E)}finally{if(l)throw l.error}}}},e})(i),r.useIC=!0,r}st.CommonScriptbaseMixin=xd});var Is=m(we=>{"use strict";var Md=we&&we.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),bd=we&&we.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(we,"__esModule",{value:!0});we.SVGscriptbase=void 0;var Sd=k(),Od=Gs(),jd=(function(i){Md(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t),n=this.getBaseWidth(),o=bd(this.getOffset(),2),a=o[0],s=o[1];this.baseChild.toSVG(e),this.scriptChild.toSVG(e),this.scriptChild.place(n+a,s)},r.kind="scriptbase",r})((0,Od.CommonScriptbaseMixin)(Sd.SVGWrapper));we.SVGscriptbase=jd});var Dn=m(lt=>{"use strict";var So=lt&&lt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),bo=lt&&lt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(lt,"__esModule",{value:!0});lt.CommonMsubsupMixin=lt.CommonMsupMixin=lt.CommonMsubMixin=void 0;function Ad(i){var r;return r=(function(t){So(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return Object.defineProperty(e.prototype,"scriptChild",{get:function(){return this.childNodes[this.node.sub]},enumerable:!1,configurable:!0}),e.prototype.getOffset=function(){return[0,-this.getV()]},e})(i),r.useIC=!1,r}lt.CommonMsubMixin=Ad;function Cd(i){return(function(r){So(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"scriptChild",{get:function(){return this.childNodes[this.node.sup]},enumerable:!1,configurable:!0}),t.prototype.getOffset=function(){var e=this.getAdjustedIc()-(this.baseRemoveIc?0:this.baseIc);return[e,this.getU()]},t})(i)}lt.CommonMsupMixin=Cd;function Pd(i){var r;return r=(function(t){So(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.UVQ=null,n}return Object.defineProperty(e.prototype,"subChild",{get:function(){return this.childNodes[this.node.sub]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supChild",{get:function(){return this.childNodes[this.node.sup]},enumerable:!1,configurable:!0}),e.prototype.computeBBox=function(n,o){o===void 0&&(o=!1);var a=this.baseChild.getOuterBBox(),s=bo([this.subChild.getOuterBBox(),this.supChild.getOuterBBox()],2),l=s[0],u=s[1];n.empty(),n.append(a);var c=this.getBaseWidth(),f=this.getAdjustedIc(),h=bo(this.getUVQ(),2),p=h[0],d=h[1];n.combine(l,c,d),n.combine(u,c+f,p),n.w+=this.font.params.scriptspace,n.clean(),this.setChildPWidths(o)},e.prototype.getUVQ=function(n,o){n===void 0&&(n=this.subChild.getOuterBBox()),o===void 0&&(o=this.supChild.getOuterBBox());var a=this.baseCore.getOuterBBox();if(this.UVQ)return this.UVQ;var s=this.font.params,l=3*s.rule_thickness,u=this.length2em(this.node.attributes.get("subscriptshift"),s.sub2),c=this.baseCharZero(a.d*this.baseScale+s.sub_drop*n.rscale),f=bo([this.getU(),Math.max(c,u)],2),h=f[0],p=f[1],d=h-o.d*o.rscale-(n.h*n.rscale-p);if(d<l){p+=l-d;var y=4/5*s.x_height-(h-o.d*o.rscale);y>0&&(h+=y,p-=y)}return h=Math.max(this.length2em(this.node.attributes.get("superscriptshift"),h),h),p=Math.max(this.length2em(this.node.attributes.get("subscriptshift"),p),p),d=h-o.d*o.rscale-(n.h*n.rscale-p),this.UVQ=[h,-p,d],this.UVQ},e})(i),r.useIC=!1,r}lt.CommonMsubsupMixin=Pd});var Gn=m(ut=>{"use strict";var Oo=ut&&ut.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),fr=ut&&ut.__assign||function(){return fr=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},fr.apply(this,arguments)};Object.defineProperty(ut,"__esModule",{value:!0});ut.MmlMsup=ut.MmlMsub=ut.MmlMsubsup=void 0;var Ws=C(),Zr=(function(i){Oo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"msubsup"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 3},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"base",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sub",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sup",{get:function(){return 2},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){var a=this.childNodes;a[0].setInheritedAttributes(t,e,n,o),a[1].setInheritedAttributes(t,!1,n+1,o||this.sub===1),a[2]&&a[2].setInheritedAttributes(t,!1,n+1,o||this.sub===2)},r.defaults=fr(fr({},Ws.AbstractMmlBaseNode.defaults),{subscriptshift:"",superscriptshift:""}),r})(Ws.AbstractMmlBaseNode);ut.MmlMsubsup=Zr;var Bd=(function(i){Oo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"msub"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 2},enumerable:!1,configurable:!0}),r.defaults=fr({},Zr.defaults),r})(Zr);ut.MmlMsub=Bd;var Td=(function(i){Oo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"msup"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 2},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sup",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sub",{get:function(){return 2},enumerable:!1,configurable:!0}),r.defaults=fr({},Zr.defaults),r})(Zr);ut.MmlMsup=Td});var In=m(ct=>{"use strict";var jo=ct&&ct.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Fs=ct&&ct.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(ct,"__esModule",{value:!0});ct.SVGmsubsup=ct.SVGmsup=ct.SVGmsub=void 0;var Ao=Is(),Nd=Dn(),Ed=Dn(),Ld=Dn(),Co=Gn(),kd=(function(i){jo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=Co.MmlMsub.prototype.kind,r})((0,Nd.CommonMsubMixin)(Ao.SVGscriptbase));ct.SVGmsub=kd;var Vd=(function(i){jo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=Co.MmlMsup.prototype.kind,r})((0,Ed.CommonMsupMixin)(Ao.SVGscriptbase));ct.SVGmsup=Vd;var qd=(function(i){jo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t),n=Fs([this.baseChild,this.supChild,this.subChild],3),o=n[0],a=n[1],s=n[2],l=this.getBaseWidth(),u=this.getAdjustedIc(),c=Fs(this.getUVQ(),2),f=c[0],h=c[1];o.toSVG(e),a.toSVG(e),s.toSVG(e),s.place(l,h),a.place(l+u,f)},r.kind=Co.MmlMsubsup.prototype.kind,r})((0,Ld.CommonMsubsupMixin)(Ao.SVGscriptbase));ct.SVGmsubsup=qd});var Wn=m(Y=>{"use strict";var Po=Y&&Y.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),hr=Y&&Y.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Bo=Y&&Y.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Y,"__esModule",{value:!0});Y.CommonMunderoverMixin=Y.CommonMoverMixin=Y.CommonMunderMixin=void 0;function Dd(i){return(function(r){Po(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Bo([],hr(e),!1))||this;return o.stretchChildren(),o}return Object.defineProperty(t.prototype,"scriptChild",{get:function(){return this.childNodes[this.node.under]},enumerable:!1,configurable:!0}),t.prototype.computeBBox=function(e,n){if(n===void 0&&(n=!1),this.hasMovableLimits()){r.prototype.computeBBox.call(this,e,n);return}e.empty();var o=this.baseChild.getOuterBBox(),a=this.scriptChild.getOuterBBox(),s=this.getUnderKV(o,a)[1],l=this.isLineBelow?0:this.getDelta(!0),u=hr(this.getDeltaW([o,a],[0,-l]),2),c=u[0],f=u[1];e.combine(o,c,0),e.combine(a,f,s),e.d+=this.font.params.big_op_spacing5,e.clean(),this.setChildPWidths(n)},t})(i)}Y.CommonMunderMixin=Dd;function Gd(i){return(function(r){Po(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Bo([],hr(e),!1))||this;return o.stretchChildren(),o}return Object.defineProperty(t.prototype,"scriptChild",{get:function(){return this.childNodes[this.node.over]},enumerable:!1,configurable:!0}),t.prototype.computeBBox=function(e){if(this.hasMovableLimits()){r.prototype.computeBBox.call(this,e);return}e.empty();var n=this.baseChild.getOuterBBox(),o=this.scriptChild.getOuterBBox();this.node.attributes.get("accent")&&(n.h=Math.max(n.h,this.font.params.x_height*n.scale));var a=this.getOverKU(n,o)[1],s=this.isLineAbove?0:this.getDelta(),l=hr(this.getDeltaW([n,o],[0,s]),2),u=l[0],c=l[1];e.combine(n,u,0),e.combine(o,c,a),e.h+=this.font.params.big_op_spacing5,e.clean()},t})(i)}Y.CommonMoverMixin=Gd;function Id(i){return(function(r){Po(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Bo([],hr(e),!1))||this;return o.stretchChildren(),o}return Object.defineProperty(t.prototype,"underChild",{get:function(){return this.childNodes[this.node.under]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"overChild",{get:function(){return this.childNodes[this.node.over]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subChild",{get:function(){return this.underChild},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"supChild",{get:function(){return this.overChild},enumerable:!1,configurable:!0}),t.prototype.computeBBox=function(e){if(this.hasMovableLimits()){r.prototype.computeBBox.call(this,e);return}e.empty();var n=this.overChild.getOuterBBox(),o=this.baseChild.getOuterBBox(),a=this.underChild.getOuterBBox();this.node.attributes.get("accent")&&(o.h=Math.max(o.h,this.font.params.x_height*o.scale));var s=this.getOverKU(o,n)[1],l=this.getUnderKV(o,a)[1],u=this.getDelta(),c=hr(this.getDeltaW([o,a,n],[0,this.isLineBelow?0:-u,this.isLineAbove?0:u]),3),f=c[0],h=c[1],p=c[2];e.combine(o,f,0),e.combine(n,p,s),e.combine(a,h,l);var d=this.font.params.big_op_spacing5;e.h+=d,e.d+=d,e.clean()},t})(i)}Y.CommonMunderoverMixin=Id});var No=m(ft=>{"use strict";var To=ft&&ft.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),pr=ft&&ft.__assign||function(){return pr=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},pr.apply(this,arguments)};Object.defineProperty(ft,"__esModule",{value:!0});ft.MmlMover=ft.MmlMunder=ft.MmlMunderover=void 0;var Rs=C(),tn=(function(i){To(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"munderover"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 3},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"base",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"under",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"over",{get:function(){return 2},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){var a=this.childNodes;a[0].setInheritedAttributes(t,e,n,o||!!a[this.over]);var s=!!(!e&&a[0].coreMO().attributes.get("movablelimits")),l=this.constructor.ACCENTS;a[1].setInheritedAttributes(t,!1,this.getScriptlevel(l[1],s,n),o||this.under===1),this.setInheritedAccent(1,l[1],e,n,o,s),a[2]&&(a[2].setInheritedAttributes(t,!1,this.getScriptlevel(l[2],s,n),o||this.under===2),this.setInheritedAccent(2,l[2],e,n,o,s))},r.prototype.getScriptlevel=function(t,e,n){return(e||!this.attributes.get(t))&&n++,n},r.prototype.setInheritedAccent=function(t,e,n,o,a,s){var l=this.childNodes[t];if(this.attributes.getExplicit(e)==null&&l.isEmbellished){var u=l.coreMO().attributes.get("accent");this.attributes.setInherited(e,u),u!==this.attributes.getDefault(e)&&l.setInheritedAttributes({},n,this.getScriptlevel(e,s,o),a)}},r.defaults=pr(pr({},Rs.AbstractMmlBaseNode.defaults),{accent:!1,accentunder:!1,align:"center"}),r.ACCENTS=["","accentunder","accent"],r})(Rs.AbstractMmlBaseNode);ft.MmlMunderover=tn;var Wd=(function(i){To(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"munder"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 2},enumerable:!1,configurable:!0}),r.defaults=pr({},tn.defaults),r})(tn);ft.MmlMunder=Wd;var Fd=(function(i){To(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mover"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 2},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"over",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"under",{get:function(){return 2},enumerable:!1,configurable:!0}),r.defaults=pr({},tn.defaults),r.ACCENTS=["","accent","accentunder"],r})(tn);ft.MmlMover=Fd});var Hs=m(ht=>{"use strict";var Eo=ht&&ht.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ut=ht&&ht.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(ht,"__esModule",{value:!0});ht.SVGmunderover=ht.SVGmover=ht.SVGmunder=void 0;var Lo=In(),Rd=Wn(),Hd=Wn(),Xd=Wn(),ko=No(),zd=(function(i){Eo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){if(this.hasMovableLimits()){i.prototype.toSVG.call(this,t);return}var e=this.standardSVGnode(t),n=Ut([this.baseChild,this.scriptChild],2),o=n[0],a=n[1],s=Ut([o.getOuterBBox(),a.getOuterBBox()],2),l=s[0],u=s[1];o.toSVG(e),a.toSVG(e);var c=this.isLineBelow?0:this.getDelta(!0),f=this.getUnderKV(l,u)[1],h=Ut(this.getDeltaW([l,u],[0,-c]),2),p=h[0],d=h[1];o.place(p,0),a.place(d,f)},r.kind=ko.MmlMunder.prototype.kind,r})((0,Rd.CommonMunderMixin)(Lo.SVGmsub));ht.SVGmunder=zd;var Jd=(function(i){Eo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){if(this.hasMovableLimits()){i.prototype.toSVG.call(this,t);return}var e=this.standardSVGnode(t),n=Ut([this.baseChild,this.scriptChild],2),o=n[0],a=n[1],s=Ut([o.getOuterBBox(),a.getOuterBBox()],2),l=s[0],u=s[1];o.toSVG(e),a.toSVG(e);var c=this.isLineAbove?0:this.getDelta(),f=this.getOverKU(l,u)[1],h=Ut(this.getDeltaW([l,u],[0,c]),2),p=h[0],d=h[1];o.place(p,0),a.place(d,f)},r.kind=ko.MmlMover.prototype.kind,r})((0,Hd.CommonMoverMixin)(Lo.SVGmsup));ht.SVGmover=Jd;var Kd=(function(i){Eo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){if(this.hasMovableLimits()){i.prototype.toSVG.call(this,t);return}var e=this.standardSVGnode(t),n=Ut([this.baseChild,this.overChild,this.underChild],3),o=n[0],a=n[1],s=n[2],l=Ut([o.getOuterBBox(),a.getOuterBBox(),s.getOuterBBox()],3),u=l[0],c=l[1],f=l[2];o.toSVG(e),s.toSVG(e),a.toSVG(e);var h=this.getDelta(),p=this.getOverKU(u,c)[1],d=this.getUnderKV(u,f)[1],y=Ut(this.getDeltaW([u,f,c],[0,this.isLineBelow?0:-h,this.isLineAbove?0:h]),3),v=y[0],_=y[1],g=y[2];o.place(v,0),s.place(_,d),a.place(g,p)},r.kind=ko.MmlMunderover.prototype.kind,r})((0,Xd.CommonMunderoverMixin)(Lo.SVGmsubsup));ht.SVGmunderover=Kd});var Xs=m(H=>{"use strict";var Ud=H&&H.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),dr=H&&H.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},$d=H&&H.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},Yd=H&&H.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(H,"__esModule",{value:!0});H.CommonMmultiscriptsMixin=H.ScriptNames=H.NextScript=void 0;var yr=Kt();H.NextScript={base:"subList",subList:"supList",supList:"subList",psubList:"psupList",psupList:"psubList"};H.ScriptNames=["sup","sup","psup","psub"];function Qd(i){return(function(r){Ud(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,$d([],dr(e),!1))||this;return o.scriptData=null,o.firstPrescript=0,o.getScriptData(),o}return t.prototype.combinePrePost=function(e,n){var o=new yr.BBox(e);return o.combine(n,0,0),o},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1);var o=this.font.params.scriptspace,a=this.scriptData,s=this.combinePrePost(a.sub,a.psub),l=this.combinePrePost(a.sup,a.psup),u=dr(this.getUVQ(s,l),2),c=u[0],f=u[1];if(e.empty(),a.numPrescripts&&(e.combine(a.psup,o,c),e.combine(a.psub,o,f)),e.append(a.base),a.numScripts){var h=e.w;e.combine(a.sup,h,c),e.combine(a.sub,h,f),e.w+=o}e.clean(),this.setChildPWidths(n)},t.prototype.getScriptData=function(){var e=this.scriptData={base:null,sub:yr.BBox.empty(),sup:yr.BBox.empty(),psub:yr.BBox.empty(),psup:yr.BBox.empty(),numPrescripts:0,numScripts:0},n=this.getScriptBBoxLists();this.combineBBoxLists(e.sub,e.sup,n.subList,n.supList),this.combineBBoxLists(e.psub,e.psup,n.psubList,n.psupList),e.base=n.base[0],e.numPrescripts=n.psubList.length,e.numScripts=n.subList.length},t.prototype.getScriptBBoxLists=function(){var e,n,o={base:[],subList:[],supList:[],psubList:[],psupList:[]},a="base";try{for(var s=Yd(this.childNodes),l=s.next();!l.done;l=s.next()){var u=l.value;u.node.isKind("mprescripts")?a="psubList":(o[a].push(u.getOuterBBox()),a=H.NextScript[a])}}catch(c){e={error:c}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return this.firstPrescript=o.subList.length+o.supList.length+2,this.padLists(o.subList,o.supList),this.padLists(o.psubList,o.psupList),o},t.prototype.padLists=function(e,n){e.length>n.length&&n.push(yr.BBox.empty())},t.prototype.combineBBoxLists=function(e,n,o,a){for(var s=0;s<o.length;s++){var l=dr(this.getScaledWHD(o[s]),3),u=l[0],c=l[1],f=l[2],h=dr(this.getScaledWHD(a[s]),3),p=h[0],d=h[1],y=h[2],v=Math.max(u,p);e.w+=v,n.w+=v,c>e.h&&(e.h=c),f>e.d&&(e.d=f),d>n.h&&(n.h=d),y>n.d&&(n.d=y)}},t.prototype.getScaledWHD=function(e){var n=e.w,o=e.h,a=e.d,s=e.rscale;return[n*s,o*s,a*s]},t.prototype.getUVQ=function(e,n){var o;if(!this.UVQ){var a=dr([0,0,0],3),s=a[0],l=a[1],u=a[2];e.h===0&&e.d===0?s=this.getU():n.h===0&&n.d===0?s=-this.getV():(o=dr(r.prototype.getUVQ.call(this,e,n),3),s=o[0],l=o[1],u=o[2]),this.UVQ=[s,l,u]}return this.UVQ},t})(i)}H.CommonMmultiscriptsMixin=Qd});var qo=m(pt=>{"use strict";var Vo=pt&&pt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),en=pt&&pt.__assign||function(){return en=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},en.apply(this,arguments)};Object.defineProperty(pt,"__esModule",{value:!0});pt.MmlNone=pt.MmlMprescripts=pt.MmlMmultiscripts=void 0;var Fn=C(),zs=Gn(),Zd=(function(i){Vo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mmultiscripts"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 1},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){this.childNodes[0].setInheritedAttributes(t,e,n,o);for(var a=!1,s=1,l=0;s<this.childNodes.length;s++){var u=this.childNodes[s];if(u.isKind("mprescripts")){if(!a&&(a=!0,s%2===0)){var c=this.factory.create("mrow");this.childNodes.splice(s,0,c),c.parent=this,s++}}else{var f=o||l%2===0;u.setInheritedAttributes(t,!1,n+1,f),l++}}this.childNodes.length%2===(a?1:0)&&(this.appendChild(this.factory.create("mrow")),this.childNodes[this.childNodes.length-1].setInheritedAttributes(t,!1,n+1,o))},r.prototype.verifyChildren=function(t){for(var e=!1,n=t.fixMmultiscripts,o=0;o<this.childNodes.length;o++){var a=this.childNodes[o];a.isKind("mprescripts")&&(e?a.mError(a.kind+" can only appear once in "+this.kind,t,!0):(e=!0,o%2===0&&!n&&this.mError("There must be an equal number of prescripts of each type",t)))}this.childNodes.length%2===(e?1:0)&&!n&&this.mError("There must be an equal number of scripts of each type",t),i.prototype.verifyChildren.call(this,t)},r.defaults=en({},zs.MmlMsubsup.defaults),r})(zs.MmlMsubsup);pt.MmlMmultiscripts=Zd;var ty=(function(i){Vo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mprescripts"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 0},enumerable:!1,configurable:!0}),r.prototype.verifyTree=function(t){i.prototype.verifyTree.call(this,t),this.parent&&!this.parent.isKind("mmultiscripts")&&this.mError(this.kind+" must be a child of mmultiscripts",t,!0)},r.defaults=en({},Fn.AbstractMmlNode.defaults),r})(Fn.AbstractMmlNode);pt.MmlMprescripts=ty;var ey=(function(i){Vo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"none"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 0},enumerable:!1,configurable:!0}),r.prototype.verifyTree=function(t){i.prototype.verifyTree.call(this,t),this.parent&&!this.parent.isKind("mmultiscripts")&&this.mError(this.kind+" must be a child of mmultiscripts",t,!0)},r.defaults=en({},Fn.AbstractMmlNode.defaults),r})(Fn.AbstractMmlNode);pt.MmlNone=ey});var Ks=m(Vt=>{"use strict";var ry=Vt&&Vt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),rn=Vt&&Vt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.SVGmmultiscripts=Vt.AlignX=void 0;var ny=In(),iy=Xs(),oy=qo(),ay=Jt();function Js(i){return{left:function(r,t){return 0},center:function(r,t){return(t-r)/2},right:function(r,t){return t-r}}[i]||(function(r,t){return 0})}Vt.AlignX=Js;var sy=(function(i){ry(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t),n=this.scriptData,o=this.node.getProperty("scriptalign")||"right left",a=rn((0,ay.split)(o+" "+o),2),s=a[0],l=a[1],u=this.combinePrePost(n.sub,n.psub),c=this.combinePrePost(n.sup,n.psup),f=rn(this.getUVQ(u,c),2),h=f[0],p=f[1],d=0;n.numPrescripts&&(d=this.addScripts(.05,h,p,this.firstPrescript,n.numPrescripts,s));var y=this.baseChild;y.toSVG(e),y.place(d,0),d+=y.getOuterBBox().w,n.numScripts&&this.addScripts(d,h,p,1,n.numScripts,l)},r.prototype.addScripts=function(t,e,n,o,a,s){var l=this.adaptor,u=Js(s),c=l.append(this.element,this.svg("g")),f=l.append(this.element,this.svg("g"));this.place(t,e,c),this.place(t,n,f);for(var h=o+2*a,p=0;o<h;){var d=rn([this.childNodes[o++],this.childNodes[o++]],2),y=d[0],v=d[1],_=rn([y.getOuterBBox(),v.getOuterBBox()],2),g=_[0],w=_[1],M=rn([g.rscale,w.rscale],2),b=M[0],P=M[1],B=Math.max(g.w*b,w.w*P);y.toSVG(f),v.toSVG(c),y.place(p+u(g.w*b,B),0),v.place(p+u(w.w*P,B),0),p+=B}return t+p},r.kind=oy.MmlMmultiscripts.prototype.kind,r})((0,iy.CommonMmultiscriptsMixin)(ny.SVGmsubsup));Vt.SVGmmultiscripts=sy});var Us=m(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.max=vr.sum=void 0;function ly(i){return i.reduce(function(r,t){return r+t},0)}vr.sum=ly;function uy(i){return i.reduce(function(r,t){return Math.max(r,t)},0)}vr.max=uy});var $s=m(dt=>{"use strict";var cy=dt&&dt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),qt=dt&&dt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},fy=dt&&dt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},Rn=dt&&dt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(dt,"__esModule",{value:!0});dt.CommonMtableMixin=void 0;var hy=Kt(),$t=Jt(),Yt=Us();function py(i){return(function(r){cy(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,fy([],qt(e),!1))||this;o.numCols=0,o.numRows=0,o.data=null,o.pwidthCells=[],o.pWidth=0,o.numCols=(0,Yt.max)(o.tableRows.map(function(s){return s.numCells})),o.numRows=o.childNodes.length,o.hasLabels=o.childNodes.reduce(function(s,l){return s||l.node.isKind("mlabeledtr")},!1),o.findContainer(),o.isTop=!o.container||o.container.node.isKind("math")&&!o.container.parent,o.isTop&&(o.jax.table=o),o.getPercentageWidth();var a=o.node.attributes;return o.frame=a.get("frame")!=="none",o.fLine=o.frame&&a.get("frame")?.07:0,o.fSpace=o.frame?o.convertLengths(o.getAttributeArray("framespacing")):[0,0],o.cSpace=o.convertLengths(o.getColumnAttributes("columnspacing")),o.rSpace=o.convertLengths(o.getRowAttributes("rowspacing")),o.cLines=o.getColumnAttributes("columnlines").map(function(s){return s==="none"?0:.07}),o.rLines=o.getRowAttributes("rowlines").map(function(s){return s==="none"?0:.07}),o.cWidths=o.getColumnWidths(),o.stretchRows(),o.stretchColumns(),o}return Object.defineProperty(t.prototype,"tableRows",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),t.prototype.findContainer=function(){for(var e=this,n=e.parent;n&&(n.node.notParent||n.node.isKind("mrow"));)e=n,n=n.parent;this.container=n,this.containerI=e.node.childPosition()},t.prototype.getPercentageWidth=function(){if(this.hasLabels)this.bbox.pwidth=hy.BBox.fullWidth;else{var e=this.node.attributes.get("width");(0,$t.isPercent)(e)&&(this.bbox.pwidth=e)}},t.prototype.stretchRows=function(){for(var e=this.node.attributes.get("equalrows"),n=e?this.getEqualRowHeight():0,o=e?this.getTableData():{H:[0],D:[0]},a=o.H,s=o.D,l=this.tableRows,u=0;u<this.numRows;u++){var c=e?[(n+a[u]-s[u])/2,(n-a[u]+s[u])/2]:null;l[u].stretchChildren(c)}},t.prototype.stretchColumns=function(){for(var e=0;e<this.numCols;e++){var n=typeof this.cWidths[e]=="number"?this.cWidths[e]:null;this.stretchColumn(e,n)}},t.prototype.stretchColumn=function(e,n){var o,a,s,l,u,c,f=[];try{for(var h=Rn(this.tableRows),p=h.next();!p.done;p=h.next()){var d=p.value,y=d.getChild(e);if(y){var v=y.childNodes[0];v.stretch.dir===0&&v.canStretch(2)&&f.push(v)}}}catch(A){o={error:A}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(o)throw o.error}}var _=f.length,g=this.childNodes.length;if(_&&g>1){if(n===null){n=0;var w=_>1&&_===g;try{for(var M=Rn(this.tableRows),b=M.next();!b.done;b=M.next()){var d=b.value,y=d.getChild(e);if(y){var v=y.childNodes[0],P=v.stretch.dir===0;if(w||P){var B=v.getBBox(P).w;B>n&&(n=B)}}}}catch(A){s={error:A}}finally{try{b&&!b.done&&(l=M.return)&&l.call(M)}finally{if(s)throw s.error}}}try{for(var E=Rn(f),T=E.next();!T.done;T=E.next()){var v=T.value;v.coreMO().getStretchedVariant([n])}}catch(A){u={error:A}}finally{try{T&&!T.done&&(c=E.return)&&c.call(E)}finally{if(u)throw u.error}}}},t.prototype.getTableData=function(){if(this.data)return this.data;for(var e=new Array(this.numRows).fill(0),n=new Array(this.numRows).fill(0),o=new Array(this.numCols).fill(0),a=new Array(this.numRows),s=new Array(this.numRows),l=[0],u=this.tableRows,c=0;c<u.length;c++){for(var f=0,h=u[c],p=h.node.attributes.get("rowalign"),d=0;d<h.numCells;d++){var y=h.getChild(d);f=this.updateHDW(y,d,c,p,e,n,o,f),this.recordPWidthCell(y,d)}a[c]=e[c],s[c]=n[c],h.labeled&&(f=this.updateHDW(h.childNodes[0],0,c,p,e,n,l,f)),this.extendHD(c,e,n,f),this.extendHD(c,a,s,f)}var v=l[0];return this.data={H:e,D:n,W:o,NH:a,ND:s,L:v},this.data},t.prototype.updateHDW=function(e,n,o,a,s,l,u,c){var f=e.getBBox(),h=f.h,p=f.d,d=f.w,y=e.parent.bbox.rscale;e.parent.bbox.rscale!==1&&(h*=y,p*=y,d*=y),this.node.getProperty("useHeight")&&(h<.75&&(h=.75),p<.25&&(p=.25));var v=0;return a=e.node.attributes.get("rowalign")||a,a!=="baseline"&&a!=="axis"&&(v=h+p,h=p=0),h>s[o]&&(s[o]=h),p>l[o]&&(l[o]=p),v>c&&(c=v),u&&d>u[n]&&(u[n]=d),c},t.prototype.extendHD=function(e,n,o,a){var s=(a-(n[e]+o[e]))/2;s<1e-5||(n[e]+=s,o[e]+=s)},t.prototype.recordPWidthCell=function(e,n){e.childNodes[0]&&e.childNodes[0].getBBox().pwidth&&this.pwidthCells.push([e,n])},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1);var o=this.getTableData(),a=o.H,s=o.D,l,u;if(this.node.attributes.get("equalrows")){var c=this.getEqualRowHeight();l=(0,Yt.sum)([].concat(this.rLines,this.rSpace))+c*this.numRows}else l=(0,Yt.sum)(a.concat(s,this.rLines,this.rSpace));l+=2*(this.fLine+this.fSpace[1]);var f=this.getComputedWidths();u=(0,Yt.sum)(f.concat(this.cLines,this.cSpace))+2*(this.fLine+this.fSpace[0]);var h=this.node.attributes.get("width");h!=="auto"&&(u=Math.max(this.length2em(h,0)+2*this.fLine,u));var p=qt(this.getBBoxHD(l),2),d=p[0],y=p[1];e.h=d,e.d=y,e.w=u;var v=qt(this.getBBoxLR(),2),_=v[0],g=v[1];e.L=_,e.R=g,(0,$t.isPercent)(h)||this.setColumnPWidths()},t.prototype.setChildPWidths=function(e,n,o){var a=this.node.attributes.get("width");if(!(0,$t.isPercent)(a))return!1;this.hasLabels||(this.bbox.pwidth="",this.container.bbox.pwidth="");var s=this.bbox,l=s.w,u=s.L,c=s.R,f=this.node.attributes.get("data-width-includes-label"),h=Math.max(l,this.length2em(a,Math.max(n,u+l+c)))-(f?u+c:0),p=this.node.attributes.get("equalcolumns")?Array(this.numCols).fill(this.percent(1/Math.max(1,this.numCols))):this.getColumnAttributes("columnwidth",0);this.cWidths=this.getColumnWidthsFixed(p,h);var d=this.getComputedWidths();return this.pWidth=(0,Yt.sum)(d.concat(this.cLines,this.cSpace))+2*(this.fLine+this.fSpace[0]),this.isTop&&(this.bbox.w=this.pWidth),this.setColumnPWidths(),this.pWidth!==l&&this.parent.invalidateBBox(),this.pWidth!==l},t.prototype.setColumnPWidths=function(){var e,n,o=this.cWidths;try{for(var a=Rn(this.pwidthCells),s=a.next();!s.done;s=a.next()){var l=qt(s.value,2),u=l[0],c=l[1];u.setChildPWidths(!1,o[c])&&(u.invalidateBBox(),u.getBBox())}}catch(f){e={error:f}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}},t.prototype.getBBoxHD=function(e){var n=qt(this.getAlignmentRow(),2),o=n[0],a=n[1];if(a===null){var s=this.font.params.axis_height,l=e/2,u={top:[0,e],center:[l,l],bottom:[e,0],baseline:[l,l],axis:[l+s,l-s]};return u[o]||[l,l]}else{var c=this.getVerticalPosition(a,o);return[c,e-c]}},t.prototype.getBBoxLR=function(){if(this.hasLabels){var e=this.node.attributes,n=e.get("side"),o=qt(this.getPadAlignShift(n),2),a=o[0],s=o[1],l=this.hasLabels&&!!e.get("data-width-includes-label");return l&&this.frame&&this.fSpace[0]&&(a-=this.fSpace[0]),s==="center"&&!l?[a,a]:n==="left"?[a,0]:[0,a]}return[0,0]},t.prototype.getPadAlignShift=function(e){var n=this.getTableData().L,o=this.length2em(this.node.attributes.get("minlabelspacing")),a=n+o,s=qt(this.styles==null?["",""]:[this.styles.get("padding-left"),this.styles.get("padding-right")],2),l=s[0],u=s[1];(l||u)&&(a=Math.max(a,this.length2em(l||"0"),this.length2em(u||"0")));var c=qt(this.getAlignShift(),2),f=c[0],h=c[1];return f===e&&(h=e==="left"?Math.max(a,h)-a:Math.min(-a,h)+a),[a,f,h]},t.prototype.getAlignShift=function(){return this.isTop?r.prototype.getAlignShift.call(this):[this.container.getChildAlign(this.containerI),0]},t.prototype.getWidth=function(){return this.pWidth||this.getBBox().w},t.prototype.getEqualRowHeight=function(){var e=this.getTableData(),n=e.H,o=e.D,a=Array.from(n.keys()).map(function(s){return n[s]+o[s]});return Math.max.apply(Math,a)},t.prototype.getComputedWidths=function(){var e=this,n=this.getTableData().W,o=Array.from(n.keys()).map(function(a){return typeof e.cWidths[a]=="number"?e.cWidths[a]:n[a]});return this.node.attributes.get("equalcolumns")&&(o=Array(o.length).fill((0,Yt.max)(o))),o},t.prototype.getColumnWidths=function(){var e=this.node.attributes.get("width");if(this.node.attributes.get("equalcolumns"))return this.getEqualColumns(e);var n=this.getColumnAttributes("columnwidth",0);return e==="auto"?this.getColumnWidthsAuto(n):(0,$t.isPercent)(e)?this.getColumnWidthsPercent(n):this.getColumnWidthsFixed(n,this.length2em(e))},t.prototype.getEqualColumns=function(e){var n=Math.max(1,this.numCols),o;if(e==="auto"){var a=this.getTableData().W;o=(0,Yt.max)(a)}else if((0,$t.isPercent)(e))o=this.percent(1/n);else{var s=(0,Yt.sum)([].concat(this.cLines,this.cSpace))+2*this.fSpace[0];o=Math.max(0,this.length2em(e)-s)/n}return Array(this.numCols).fill(o)},t.prototype.getColumnWidthsAuto=function(e){var n=this;return e.map(function(o){return o==="auto"||o==="fit"?null:(0,$t.isPercent)(o)?o:n.length2em(o)})},t.prototype.getColumnWidthsPercent=function(e){var n=this,o=e.indexOf("fit")>=0,a=(o?this.getTableData():{W:null}).W;return Array.from(e.keys()).map(function(s){var l=e[s];return l==="fit"?null:l==="auto"?o?a[s]:null:(0,$t.isPercent)(l)?l:n.length2em(l)})},t.prototype.getColumnWidthsFixed=function(e,n){var o=this,a=Array.from(e.keys()),s=a.filter(function(d){return e[d]==="fit"}),l=a.filter(function(d){return e[d]==="auto"}),u=s.length||l.length,c=(u?this.getTableData():{W:null}).W,f=n-(0,Yt.sum)([].concat(this.cLines,this.cSpace))-2*this.fSpace[0],h=f;a.forEach(function(d){var y=e[d];h-=y==="fit"||y==="auto"?c[d]:o.length2em(y,f)});var p=u&&h>0?h/u:0;return a.map(function(d){var y=e[d];return y==="fit"?c[d]+p:y==="auto"?c[d]+(s.length===0?p:0):o.length2em(y,f)})},t.prototype.getVerticalPosition=function(e,n){for(var o=this.node.attributes.get("equalrows"),a=this.getTableData(),s=a.H,l=a.D,u=o?this.getEqualRowHeight():0,c=this.getRowHalfSpacing(),f=this.fLine,h=0;h<e;h++)f+=c[h]+(o?u:s[h]+l[h])+c[h+1]+this.rLines[h];var p=qt(o?[(u+s[e]-l[e])/2,(u-s[e]+l[e])/2]:[s[e],l[e]],2),d=p[0],y=p[1],v={top:0,center:c[e]+(d+y)/2,bottom:c[e]+d+y+c[e+1],baseline:c[e]+d,axis:c[e]+d-.25};return f+=v[n]||0,f},t.prototype.getEmHalfSpacing=function(e,n,o){o===void 0&&(o=1);var a=this.em(e*o),s=this.addEm(n,2/o);return s.unshift(a),s.push(a),s},t.prototype.getRowHalfSpacing=function(){var e=this.rSpace.map(function(n){return n/2});return e.unshift(this.fSpace[1]),e.push(this.fSpace[1]),e},t.prototype.getColumnHalfSpacing=function(){var e=this.cSpace.map(function(n){return n/2});return e.unshift(this.fSpace[0]),e.push(this.fSpace[0]),e},t.prototype.getAlignmentRow=function(){var e=qt((0,$t.split)(this.node.attributes.get("align")),2),n=e[0],o=e[1];if(o==null)return[n,null];var a=parseInt(o);return a<0&&(a+=this.numRows+1),[n,a<1||a>this.numRows?null:a-1]},t.prototype.getColumnAttributes=function(e,n){n===void 0&&(n=1);var o=this.numCols-n,a=this.getAttributeArray(e);if(a.length===0)return null;for(;a.length<o;)a.push(a[a.length-1]);return a.length>o&&a.splice(o),a},t.prototype.getRowAttributes=function(e,n){n===void 0&&(n=1);var o=this.numRows-n,a=this.getAttributeArray(e);if(a.length===0)return null;for(;a.length<o;)a.push(a[a.length-1]);return a.length>o&&a.splice(o),a},t.prototype.getAttributeArray=function(e){var n=this.node.attributes.get(e);return n?(0,$t.split)(n):[this.node.attributes.getDefault(e)]},t.prototype.addEm=function(e,n){var o=this;return n===void 0&&(n=1),e?e.map(function(a){return o.em(a/n)}):null},t.prototype.convertLengths=function(e){var n=this;return e?e.map(function(o){return n.length2em(o)}):null},t})(i)}dt.CommonMtableMixin=py});var Do=m(Dt=>{"use strict";var dy=Dt&&Dt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),zn=Dt&&Dt.__assign||function(){return zn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},zn.apply(this,arguments)},Hn=Dt&&Dt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Dt,"__esModule",{value:!0});Dt.MmlMtable=void 0;var Xn=C(),yy=Jt(),vy=(function(i){dy(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.properties={useHeight:!0},t.texclass=Xn.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mtable"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setInheritedAttributes=function(t,e,n,o){var a,s;try{for(var l=Hn(Xn.indentAttributes),u=l.next();!u.done;u=l.next()){var c=u.value;t[c]&&this.attributes.setInherited(c,t[c][1]),this.attributes.getExplicit(c)!==void 0&&delete this.attributes.getAllAttributes()[c]}}catch(f){a={error:f}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(a)throw a.error}}i.prototype.setInheritedAttributes.call(this,t,e,n,o)},r.prototype.setChildInheritedAttributes=function(t,e,n,o){var a,s,l,u;try{for(var c=Hn(this.childNodes),f=c.next();!f.done;f=c.next()){var h=f.value;h.isKind("mtr")||this.replaceChild(this.factory.create("mtr"),h).appendChild(h)}}catch(_){a={error:_}}finally{try{f&&!f.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}n=this.getProperty("scriptlevel")||n,e=!!(this.attributes.getExplicit("displaystyle")||this.attributes.getDefault("displaystyle")),t=this.addInheritedAttributes(t,{columnalign:this.attributes.get("columnalign"),rowalign:"center"});var p=this.attributes.getExplicit("data-cramped"),d=(0,yy.split)(this.attributes.get("rowalign"));try{for(var y=Hn(this.childNodes),v=y.next();!v.done;v=y.next()){var h=v.value;t.rowalign[1]=d.shift()||t.rowalign[1],h.setInheritedAttributes(t,e,n,!!p)}}catch(_){l={error:_}}finally{try{v&&!v.done&&(u=y.return)&&u.call(y)}finally{if(l)throw l.error}}},r.prototype.verifyChildren=function(t){for(var e=null,n=this.factory,o=0;o<this.childNodes.length;o++){var a=this.childNodes[o];if(a.isKind("mtr"))e=null;else{var s=a.isKind("mtd");if(e?(this.removeChild(a),o--):e=this.replaceChild(n.create("mtr"),a),e.appendChild(s?a:n.create("mtd",{},[a])),!t.fixMtables){a.parent.removeChild(a),a.parent=this,s&&e.appendChild(n.create("mtd"));var l=a.mError("Children of "+this.kind+" must be mtr or mlabeledtr",t,s);e.childNodes[e.childNodes.length-1].appendChild(l)}}}i.prototype.verifyChildren.call(this,t)},r.prototype.setTeXclass=function(t){var e,n;this.getPrevClass(t);try{for(var o=Hn(this.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;s.setTeXclass(null)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return this},r.defaults=zn(zn({},Xn.AbstractMmlNode.defaults),{align:"axis",rowalign:"baseline",columnalign:"center",groupalign:"{left}",alignmentscope:!0,columnwidth:"auto",width:"auto",rowspacing:"1ex",columnspacing:".8em",rowlines:"none",columnlines:"none",frame:"none",framespacing:"0.4em 0.5ex",equalrows:!1,equalcolumns:!1,displaystyle:!1,side:"right",minlabelspacing:"0.8em"}),r})(Xn.AbstractMmlNode);Dt.MmlMtable=vy});var Qs=m(Gt=>{"use strict";var my=Gt&&Gt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),mr=Gt&&Gt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Ys=Gt&&Gt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.SVGmtable=void 0;var gy=k(),_y=$s(),wy=Do(),xy="mjx-",My=(function(i){my(r,i);function r(t,e,n){n===void 0&&(n=null);var o=i.call(this,t,e,n)||this,a={"data-labels":!0};return o.isTop&&(a.transform="matrix(1 0 0 -1 0 0)"),o.labels=o.svg("g",a),o}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t);this.placeRows(e),this.handleColumnLines(e),this.handleRowLines(e),this.handleFrame(e);var n=this.handlePWidth(e);this.handleLabels(e,t,n)},r.prototype.placeRows=function(t){for(var e,n,o,a=this.node.attributes.get("equalrows"),s=this.getTableData(),l=s.H,u=s.D,c=this.getEqualRowHeight(),f=this.getRowHalfSpacing(),h=Ys(Ys([this.fLine],mr(this.rLines),!1),[this.fLine],!1),p=this.getBBox().h-h[0],d=0;d<this.numRows;d++){var y=this.childNodes[d];e=mr(this.getRowHD(a,c,l[d],u[d]),2),y.H=e[0],y.D=e[1],n=mr([f[d],f[d+1]],2),y.tSpace=n[0],y.bSpace=n[1],o=mr([h[d],h[d+1]],2),y.tLine=o[0],y.bLine=o[1],y.toSVG(t),y.place(0,p-f[d]-y.H),p-=f[d]+y.H+y.D+f[d+1]+h[d+1]}},r.prototype.getRowHD=function(t,e,n,o){return t?[(e+n-o)/2,(e-n+o)/2]:[n,o]},r.prototype.handleColor=function(){i.prototype.handleColor.call(this);var t=this.firstChild();t&&this.adaptor.setAttribute(t,"width",this.fixed(this.getWidth()))},r.prototype.handleColumnLines=function(t){if(this.node.attributes.get("columnlines")!=="none"){var e=this.getColumnAttributes("columnlines");if(e)for(var n=this.getColumnHalfSpacing(),o=this.cLines,a=this.getComputedWidths(),s=this.fLine,l=0;l<e.length;l++)s+=n[l]+a[l]+n[l+1],e[l]!=="none"&&this.adaptor.append(t,this.makeVLine(s,e[l],o[l])),s+=o[l]}},r.prototype.handleRowLines=function(t){if(this.node.attributes.get("rowlines")!=="none"){var e=this.getRowAttributes("rowlines");if(e)for(var n=this.node.attributes.get("equalrows"),o=this.getTableData(),a=o.H,s=o.D,l=this.getEqualRowHeight(),u=this.getRowHalfSpacing(),c=this.rLines,f=this.getBBox().h-this.fLine,h=0;h<e.length;h++){var p=mr(this.getRowHD(n,l,a[h],s[h]),2),d=p[0],y=p[1];f-=u[h]+d+y+u[h+1],e[h]!=="none"&&this.adaptor.append(t,this.makeHLine(f,e[h],c[h])),f-=c[h]}}},r.prototype.handleFrame=function(t){if(this.frame&&this.fLine){var e=this.getBBox(),n=e.h,o=e.d,a=e.w,s=this.node.attributes.get("frame");this.adaptor.append(t,this.makeFrame(a,n,o,s))}},r.prototype.handlePWidth=function(t){if(!this.pWidth)return 0;var e=this.getBBox(),n=e.w,o=e.L,a=e.R,s=o+this.pWidth+a,l=this.getAlignShift()[0],u=Math.max(this.isTop?s:0,this.container.getWrapWidth(this.containerI))-o-a,c=n-(this.pWidth>u?u:this.pWidth),f=l==="left"?0:l==="right"?c:c/2;if(f){var h=this.svg("g",{},this.adaptor.childNodes(t));this.place(f,0,h),this.adaptor.append(t,h)}return f},r.prototype.lineClass=function(t){return xy+t},r.prototype.makeFrame=function(t,e,n,o){var a=this.fLine;return this.svg("rect",this.setLineThickness(a,o,{"data-frame":!0,class:this.lineClass(o),width:this.fixed(t-a),height:this.fixed(e+n-a),x:this.fixed(a/2),y:this.fixed(a/2-n)}))},r.prototype.makeVLine=function(t,e,n){var o=this.getBBox(),a=o.h,s=o.d,l=e==="dotted"?n/2:0,u=this.fixed(t+n/2);return this.svg("line",this.setLineThickness(n,e,{"data-line":"v",class:this.lineClass(e),x1:u,y1:this.fixed(l-s),x2:u,y2:this.fixed(a-l)}))},r.prototype.makeHLine=function(t,e,n){var o=this.getBBox().w,a=e==="dotted"?n/2:0,s=this.fixed(t-n/2);return this.svg("line",this.setLineThickness(n,e,{"data-line":"h",class:this.lineClass(e),x1:this.fixed(a),y1:s,x2:this.fixed(o-a),y2:s}))},r.prototype.setLineThickness=function(t,e,n){return t!==.07&&(n["stroke-thickness"]=this.fixed(t),e!=="solid"&&(n["stroke-dasharray"]=(e==="dotted"?"0,":"")+this.fixed(2*t))),n},r.prototype.handleLabels=function(t,e,n){if(this.hasLabels){var o=this.labels,a=this.node.attributes,s=a.get("side");this.spaceLabels(),this.isTop?this.topTable(t,o,s):this.subTable(t,o,s,n)}},r.prototype.spaceLabels=function(){for(var t=this.adaptor,e=this.getBBox().h,n=this.getTableData().L,o=this.getRowHalfSpacing(),a=e-this.fLine,s=t.firstChild(this.labels),l=0;l<this.numRows;l++){var u=this.childNodes[l];if(u.node.isKind("mlabeledtr")){var c=u.childNodes[0];a-=o[l]+u.H,u.placeCell(c,{x:0,y:a,w:n,lSpace:0,rSpace:0,lLine:0,rLine:0}),a-=u.D+o[l+1]+this.rLines[l],s=t.next(s)}else a-=o[l]+u.H+u.D+o[l+1]+this.rLines[l]}},r.prototype.topTable=function(t,e,n){var o=this.adaptor,a=this.getBBox(),s=a.h,l=a.d,u=a.w,c=a.L,f=a.R,h=c+(this.pWidth||u)+f,p=this.getTableData().L,d=mr(this.getPadAlignShift(n),3),y=d[1],v=d[2],_=v+(y==="right"?-h:y==="center"?-h/2:0)+c,g="matrix(1 0 0 -1 0 0)",w="scale(".concat(this.jax.fixed(this.font.params.x_height*1e3/this.metrics.ex,2),")"),M="translate(0 ".concat(this.fixed(s),") ").concat(g," ").concat(w),b=this.svg("svg",{"data-table":!0,preserveAspectRatio:y==="left"?"xMinYMid":y==="right"?"xMaxYMid":"xMidYMid",viewBox:[this.fixed(-_),this.fixed(-s),1,this.fixed(s+l)].join(" ")},[this.svg("g",{transform:g},o.childNodes(t))]);e=this.svg("svg",{"data-labels":!0,preserveAspectRatio:n==="left"?"xMinYMid":"xMaxYMid",viewBox:[n==="left"?0:this.fixed(p),this.fixed(-s),1,this.fixed(s+l)].join(" ")},[e]),o.append(t,this.svg("g",{transform:M},[b,e])),this.place(-c,0,t)},r.prototype.subTable=function(t,e,n,o){var a=this.adaptor,s=this.getBBox(),l=s.w,u=s.L,c=s.R,f=u+(this.pWidth||l)+c,h=this.getTableData().L,p=this.getAlignShift()[0],d=Math.max(f,this.container.getWrapWidth(this.containerI));this.place(n==="left"?(p==="left"?0:p==="right"?f-d+o:(f-d)/2+o)-u:(p==="left"?d:p==="right"?f+o:(d+f)/2+o)-u-h,0,e),a.append(t,e)},r.kind=wy.MmlMtable.prototype.kind,r.styles={'g[data-mml-node="mtable"] > line[data-line], svg[data-table] > g > line[data-line]':{"stroke-width":"70px",fill:"none"},'g[data-mml-node="mtable"] > rect[data-frame], svg[data-table] > g > rect[data-frame]':{"stroke-width":"70px",fill:"none"},'g[data-mml-node="mtable"] > .mjx-dashed, svg[data-table] > g > .mjx-dashed':{"stroke-dasharray":"140"},'g[data-mml-node="mtable"] > .mjx-dotted, svg[data-table] > g > .mjx-dotted':{"stroke-linecap":"round","stroke-dasharray":"0,140"},'g[data-mml-node="mtable"] > g > svg':{overflow:"visible"}},r})((0,_y.CommonMtableMixin)(gy.SVGWrapper));Gt.SVGmtable=My});var Io=m(It=>{"use strict";var Zs=It&&It.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Go=It&&It.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(It,"__esModule",{value:!0});It.CommonMlabeledtrMixin=It.CommonMtrMixin=void 0;function by(i){return(function(r){Zs(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"fixesPWidth",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numCells",{get:function(){return this.childNodes.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"labeled",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tableCells",{get:function(){return this.childNodes},enumerable:!1,configurable:!0}),t.prototype.getChild=function(e){return this.childNodes[e]},t.prototype.getChildBBoxes=function(){return this.childNodes.map(function(e){return e.getBBox()})},t.prototype.stretchChildren=function(e){var n,o,a,s,l,u;e===void 0&&(e=null);var c=[],f=this.labeled?this.childNodes.slice(1):this.childNodes;try{for(var h=Go(f),p=h.next();!p.done;p=h.next()){var d=p.value,y=d.childNodes[0];y.canStretch(1)&&c.push(y)}}catch(et){n={error:et}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}var v=c.length,_=this.childNodes.length;if(v&&_>1){if(e===null){var g=0,w=0,M=v>1&&v===_;try{for(var b=Go(f),P=b.next();!P.done;P=b.next()){var d=P.value,y=d.childNodes[0],B=y.stretch.dir===0;if(M||B){var E=y.getBBox(B),T=E.h,A=E.d;T>g&&(g=T),A>w&&(w=A)}}}catch(et){a={error:et}}finally{try{P&&!P.done&&(s=b.return)&&s.call(b)}finally{if(a)throw a.error}}e=[g,w]}try{for(var G=Go(c),D=G.next();!D.done;D=G.next()){var y=D.value;y.coreMO().getStretchedVariant(e)}}catch(et){l={error:et}}finally{try{D&&!D.done&&(u=G.return)&&u.call(G)}finally{if(l)throw l.error}}}},t})(i)}It.CommonMtrMixin=by;function Sy(i){return(function(r){Zs(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"numCells",{get:function(){return Math.max(0,this.childNodes.length-1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"labeled",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tableCells",{get:function(){return this.childNodes.slice(1)},enumerable:!1,configurable:!0}),t.prototype.getChild=function(e){return this.childNodes[e+1]},t.prototype.getChildBBoxes=function(){return this.childNodes.slice(1).map(function(e){return e.getBBox()})},t})(i)}It.CommonMlabeledtrMixin=Sy});var Fo=m(yt=>{"use strict";var el=yt&&yt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Kn=yt&&yt.__assign||function(){return Kn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Kn.apply(this,arguments)},Jn=yt&&yt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(yt,"__esModule",{value:!0});yt.MmlMlabeledtr=yt.MmlMtr=void 0;var tl=C(),Wo=yn(),Oy=Jt(),rl=(function(i){el(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mtr"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){var a,s,l,u;try{for(var c=Jn(this.childNodes),f=c.next();!f.done;f=c.next()){var h=f.value;h.isKind("mtd")||this.replaceChild(this.factory.create("mtd"),h).appendChild(h)}}catch(v){a={error:v}}finally{try{f&&!f.done&&(s=c.return)&&s.call(c)}finally{if(a)throw a.error}}var p=(0,Oy.split)(this.attributes.get("columnalign"));this.arity===1&&p.unshift(this.parent.attributes.get("side")),t=this.addInheritedAttributes(t,{rowalign:this.attributes.get("rowalign"),columnalign:"center"});try{for(var d=Jn(this.childNodes),y=d.next();!y.done;y=d.next()){var h=y.value;t.columnalign[1]=p.shift()||t.columnalign[1],h.setInheritedAttributes(t,e,n,o)}}catch(v){l={error:v}}finally{try{y&&!y.done&&(u=d.return)&&u.call(d)}finally{if(l)throw l.error}}},r.prototype.verifyChildren=function(t){var e,n;if(this.parent&&!this.parent.isKind("mtable")){this.mError(this.kind+" can only be a child of an mtable",t,!0);return}try{for(var o=Jn(this.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;if(!s.isKind("mtd")){var l=this.replaceChild(this.factory.create("mtd"),s);l.appendChild(s),t.fixMtables||s.mError("Children of "+this.kind+" must be mtd",t)}}}catch(u){e={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}i.prototype.verifyChildren.call(this,t)},r.prototype.setTeXclass=function(t){var e,n;this.getPrevClass(t);try{for(var o=Jn(this.childNodes),a=o.next();!a.done;a=o.next()){var s=a.value;s.setTeXclass(null)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return this},r.defaults=Kn(Kn({},tl.AbstractMmlNode.defaults),{rowalign:Wo.INHERIT,columnalign:Wo.INHERIT,groupalign:Wo.INHERIT}),r})(tl.AbstractMmlNode);yt.MmlMtr=rl;var jy=(function(i){el(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mlabeledtr"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 1},enumerable:!1,configurable:!0}),r})(rl);yt.MmlMlabeledtr=jy});var sl=m(vt=>{"use strict";var il=vt&&vt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ie=vt&&vt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},nl=vt&&vt.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(vt,"__esModule",{value:!0});vt.SVGmlabeledtr=vt.SVGmtr=void 0;var Ay=k(),Cy=Io(),Py=Io(),ol=Fo(),al=(function(i){il(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t);this.placeCells(e),this.placeColor()},r.prototype.placeCells=function(t){for(var e=this.parent.getColumnHalfSpacing(),n=nl(nl([this.parent.fLine],Ie(this.parent.cLines),!1),[this.parent.fLine],!1),o=this.parent.getComputedWidths(),a=1/this.getBBox().rscale,s=n[0],l=0;l<this.numCells;l++){var u=this.getChild(l);u.toSVG(t),s+=this.placeCell(u,{x:s,y:0,lSpace:e[l]*a,rSpace:e[l+1]*a,w:o[l]*a,lLine:n[l]*a,rLine:n[l+1]*a})}},r.prototype.placeCell=function(t,e){var n=e.x,o=e.y,a=e.lSpace,s=e.w,l=e.rSpace,u=e.lLine,c=e.rLine,f=1/this.getBBox().rscale,h=Ie([this.H*f,this.D*f],2),p=h[0],d=h[1],y=Ie([this.tSpace*f,this.bSpace*f],2),v=y[0],_=y[1],g=Ie(t.placeCell(n+a,o,s,p,d),2),w=g[0],M=g[1],b=a+s+l;return t.placeColor(-(w+a+u/2),-(d+_+M),b+(u+c)/2,p+d+v+_),b+c},r.prototype.placeColor=function(){var t=1/this.getBBox().rscale,e=this.adaptor,n=this.firstChild();if(n&&e.kind(n)==="rect"&&e.getAttribute(n,"data-bgcolor")){var o=Ie([this.tLine/2*t,this.bLine/2*t],2),a=o[0],s=o[1],l=Ie([this.tSpace*t,this.bSpace*t],2),u=l[0],c=l[1],f=Ie([this.H*t,this.D*t],2),h=f[0],p=f[1];e.setAttribute(n,"y",this.fixed(-(p+c+s))),e.setAttribute(n,"width",this.fixed(this.parent.getWidth()*t)),e.setAttribute(n,"height",this.fixed(a+u+h+p+c+s))}},r.kind=ol.MmlMtr.prototype.kind,r})((0,Cy.CommonMtrMixin)(Ay.SVGWrapper));vt.SVGmtr=al;var By=(function(i){il(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){i.prototype.toSVG.call(this,t);var e=this.childNodes[0];e&&e.toSVG(this.parent.labels)},r.kind=ol.MmlMlabeledtr.prototype.kind,r})((0,Py.CommonMlabeledtrMixin)(al));vt.SVGmlabeledtr=By});var ll=m(gr=>{"use strict";var Ty=gr&&gr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(gr,"__esModule",{value:!0});gr.CommonMtdMixin=void 0;function Ny(i){return(function(r){Ty(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"fixesPWidth",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.invalidateBBox=function(){this.bboxComputed=!1},t.prototype.getWrapWidth=function(e){var n=this.parent.parent,o=this.parent,a=this.node.childPosition()-(o.labeled?1:0);return typeof n.cWidths[a]=="number"?n.cWidths[a]:n.getTableData().W[a]},t.prototype.getChildAlign=function(e){return this.node.attributes.get("columnalign")},t})(i)}gr.CommonMtdMixin=Ny});var Ho=m(xe=>{"use strict";var Ey=xe&&xe.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Un=xe&&xe.__assign||function(){return Un=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Un.apply(this,arguments)};Object.defineProperty(xe,"__esModule",{value:!0});xe.MmlMtd=void 0;var ul=C(),Ro=yn(),Ly=(function(i){Ey(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mtd"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContainer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.verifyChildren=function(t){if(this.parent&&!this.parent.isKind("mtr")){this.mError(this.kind+" can only be a child of an mtr or mlabeledtr",t,!0);return}i.prototype.verifyChildren.call(this,t)},r.prototype.setTeXclass=function(t){return this.getPrevClass(t),this.childNodes[0].setTeXclass(null),this},r.defaults=Un(Un({},ul.AbstractMmlBaseNode.defaults),{rowspan:1,columnspan:1,rowalign:Ro.INHERIT,columnalign:Ro.INHERIT,groupalign:Ro.INHERIT}),r})(ul.AbstractMmlBaseNode);xe.MmlMtd=Ly});var cl=m(_r=>{"use strict";var ky=_r&&_r.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(_r,"__esModule",{value:!0});_r.SVGmtd=void 0;var Vy=k(),qy=ll(),Dy=Ho(),Gy=(function(i){ky(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.placeCell=function(t,e,n,o,a){var s=this.getBBox(),l=Math.max(s.h,.75),u=Math.max(s.d,.25),c=this.node.attributes.get("columnalign"),f=this.node.attributes.get("rowalign"),h=this.getAlignX(n,s,c),p=this.getAlignY(o,a,l,u,f);return this.place(t+h,e+p),[h,p]},r.prototype.placeColor=function(t,e,n,o){var a=this.adaptor,s=this.firstChild();s&&a.kind(s)==="rect"&&a.getAttribute(s,"data-bgcolor")&&(a.setAttribute(s,"x",this.fixed(t)),a.setAttribute(s,"y",this.fixed(e)),a.setAttribute(s,"width",this.fixed(n)),a.setAttribute(s,"height",this.fixed(o)))},r.kind=Dy.MmlMtd.prototype.kind,r})((0,qy.CommonMtdMixin)(Vy.SVGWrapper));_r.SVGmtd=Gy});var zo=m(Q=>{"use strict";var Iy=Q&&Q.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Xo=Q&&Q.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Wy=Q&&Q.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Q,"__esModule",{value:!0});Q.CommonMactionMixin=Q.TooltipData=void 0;var Fy=Jt();Q.TooltipData={dx:".2em",dy:".1em",postDelay:600,clearDelay:100,hoverTimer:new Map,clearTimer:new Map,stopTimers:function(i,r){r.clearTimer.has(i)&&(clearTimeout(r.clearTimer.get(i)),r.clearTimer.delete(i)),r.hoverTimer.has(i)&&(clearTimeout(r.hoverTimer.get(i)),r.hoverTimer.delete(i))}};function Ry(i){return(function(r){Iy(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,Wy([],Xo(e),!1))||this,a=o.constructor.actions,s=o.node.attributes.get("actiontype"),l=Xo(a.get(s)||[(function(f,h){}),{}],2),u=l[0],c=l[1];return o.action=u,o.data=c,o.getParameters(),o}return Object.defineProperty(t.prototype,"selected",{get:function(){var e=this.node.attributes.get("selection"),n=Math.max(1,Math.min(this.childNodes.length,e))-1;return this.childNodes[n]||this.wrap(this.node.selected)},enumerable:!1,configurable:!0}),t.prototype.getParameters=function(){var e=this.node.attributes.get("data-offsets"),n=Xo((0,Fy.split)(e||""),2),o=n[0],a=n[1];this.dx=this.length2em(o||Q.TooltipData.dx),this.dy=this.length2em(a||Q.TooltipData.dy)},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1),e.updateFrom(this.selected.getOuterBBox()),this.selected.setChildPWidths(n)},t})(i)}Q.CommonMactionMixin=Ry});var Jo=m(Me=>{"use strict";var Hy=Me&&Me.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),$n=Me&&Me.__assign||function(){return $n=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},$n.apply(this,arguments)};Object.defineProperty(Me,"__esModule",{value:!0});Me.MmlMaction=void 0;var fl=C(),Xy=(function(i){Hy(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"maction"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"selected",{get:function(){var t=this.attributes.get("selection"),e=Math.max(1,Math.min(this.childNodes.length,t))-1;return this.childNodes[e]||this.factory.create("mrow")},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isEmbellished",{get:function(){return this.selected.isEmbellished},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSpacelike",{get:function(){return this.selected.isSpacelike},enumerable:!1,configurable:!0}),r.prototype.core=function(){return this.selected.core()},r.prototype.coreMO=function(){return this.selected.coreMO()},r.prototype.verifyAttributes=function(t){if(i.prototype.verifyAttributes.call(this,t),this.attributes.get("actiontype")!=="toggle"&&this.attributes.getExplicit("selection")!==void 0){var e=this.attributes.getAllAttributes();delete e.selection}},r.prototype.setTeXclass=function(t){this.attributes.get("actiontype")==="tooltip"&&this.childNodes[1]&&this.childNodes[1].setTeXclass(null);var e=this.selected;return t=e.setTeXclass(t),this.updateTeXclass(e),t},r.prototype.nextToggleSelection=function(){var t=Math.max(1,this.attributes.get("selection")+1);t>this.childNodes.length&&(t=1),this.attributes.set("selection",t)},r.defaults=$n($n({},fl.AbstractMmlNode.defaults),{actiontype:"toggle",selection:1}),r})(fl.AbstractMmlNode);Me.MmlMaction=Xy});var hl=m(wr=>{"use strict";var zy=wr&&wr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(wr,"__esModule",{value:!0});wr.SVGmaction=void 0;var Jy=k(),Ky=zo(),Uy=zo(),$y=Jo(),Yy=(function(i){zy(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t),n=this.selected,o=n.getOuterBBox(),a=o.h,s=o.d,l=o.w;this.adaptor.append(this.element,this.svg("rect",{width:this.fixed(l),height:this.fixed(a+s),y:this.fixed(-s),fill:"none","pointer-events":"all"})),n.toSVG(e);var u=n.getOuterBBox();n.element&&n.place(u.L*u.rscale,0),this.action(this,this.data)},r.prototype.setEventHandler=function(t,e){this.element.addEventListener(t,e)},r.kind=$y.MmlMaction.prototype.kind,r.styles={'[jax="SVG"] mjx-tool':{display:"inline-block",position:"relative",width:0,height:0},'[jax="SVG"] mjx-tool > mjx-tip':{position:"absolute",top:0,left:0},"mjx-tool > mjx-tip":{display:"inline-block",padding:".2em",border:"1px solid #888","font-size":"70%","background-color":"#F8F8F8",color:"black","box-shadow":"2px 2px 5px #AAAAAA"},'g[data-mml-node="maction"][data-toggle]':{cursor:"pointer"},"mjx-status":{display:"block",position:"fixed",left:"1em",bottom:"1em","min-width":"25%",padding:".2em .4em",border:"1px solid #888","font-size":"90%","background-color":"#F8F8F8",color:"black"}},r.actions=new Map([["toggle",[function(t,e){t.adaptor.setAttribute(t.element,"data-toggle",t.node.attributes.get("selection"));var n=t.factory.jax.math,o=t.factory.jax.document,a=t.node;t.setEventHandler("click",function(s){n.end.node||(n.start.node=n.end.node=n.typesetRoot,n.start.n=n.end.n=0),a.nextToggleSelection(),n.rerender(o),s.stopPropagation()})},{}]],["tooltip",[function(t,e){var n=t.childNodes[1];if(n){var o=t.firstChild();if(n.node.isKind("mtext")){var a=n.node.getText();t.adaptor.insert(t.svg("title",{},[t.text(a)]),o)}else{var s=t.adaptor,l=t.jax.container,u=t.node.factory.create("math",{},[t.childNodes[1].node]),c=t.html("mjx-tool",{},[t.html("mjx-tip")]),f=s.append(o,t.svg("foreignObject",{style:{display:"none"}},[c]));t.jax.processMath(u,s.firstChild(c)),t.childNodes[1].node.parent=t.node,t.setEventHandler("mouseover",function(h){e.stopTimers(t,e),e.hoverTimer.set(t,setTimeout(function(){s.setStyle(c,"left","0"),s.setStyle(c,"top","0"),s.append(l,c);var p=s.nodeBBox(c),d=s.nodeBBox(t.element),y=(d.right-p.left)/t.metrics.em+t.dx,v=(d.bottom-p.bottom)/t.metrics.em+t.dy;s.setStyle(c,"left",t.px(y)),s.setStyle(c,"top",t.px(v))},e.postDelay)),h.stopPropagation()}),t.setEventHandler("mouseout",function(h){e.stopTimers(t,e);var p=setTimeout(function(){return s.append(f,c)},e.clearDelay);e.clearTimer.set(t,p),h.stopPropagation()})}}},Uy.TooltipData]],["statusline",[function(t,e){var n=t.childNodes[1];if(n&&n.node.isKind("mtext")){var o=t.adaptor,a=n.node.getText();o.setAttribute(t.element,"data-statusline",a),t.setEventHandler("mouseover",function(s){if(e.status===null){var l=o.body(o.document);e.status=o.append(l,t.html("mjx-status",{},[t.text(a)]))}s.stopPropagation()}),t.setEventHandler("mouseout",function(s){e.status&&(o.remove(e.status),e.status=null),s.stopPropagation()})}},{status:null}]]]),r})((0,Ky.CommonMactionMixin)(Jy.SVGWrapper));wr.SVGmaction=Yy});var Yn=m(x=>{"use strict";var xr=x&&x.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(x,"__esModule",{value:!0});x.CommonArrow=x.CommonDiagonalArrow=x.CommonDiagonalStrike=x.CommonBorder2=x.CommonBorder=x.arrowBBox=x.diagonalArrowDef=x.arrowDef=x.arrowBBoxW=x.arrowBBoxHD=x.arrowHead=x.fullBorder=x.fullPadding=x.fullBBox=x.sideNames=x.sideIndex=x.SOLID=x.PADDING=x.THICKNESS=x.ARROWY=x.ARROWDX=x.ARROWX=void 0;x.ARROWX=4,x.ARROWDX=1,x.ARROWY=2;x.THICKNESS=.067;x.PADDING=.2;x.SOLID=x.THICKNESS+"em solid";x.sideIndex={top:0,right:1,bottom:2,left:3};x.sideNames=Object.keys(x.sideIndex);x.fullBBox=(function(i){return new Array(4).fill(i.thickness+i.padding)});x.fullPadding=(function(i){return new Array(4).fill(i.padding)});x.fullBorder=(function(i){return new Array(4).fill(i.thickness)});var Qy=function(i){return Math.max(i.padding,i.thickness*(i.arrowhead.x+i.arrowhead.dx+1))};x.arrowHead=Qy;var Zy=function(i,r){if(i.childNodes[0]){var t=i.childNodes[0].getBBox(),e=t.h,n=t.d;r[0]=r[2]=Math.max(0,i.thickness*i.arrowhead.y-(e+n)/2)}return r};x.arrowBBoxHD=Zy;var tv=function(i,r){if(i.childNodes[0]){var t=i.childNodes[0].getBBox().w;r[1]=r[3]=Math.max(0,i.thickness*i.arrowhead.y-t/2)}return r};x.arrowBBoxW=tv;x.arrowDef={up:[-Math.PI/2,!1,!0,"verticalstrike"],down:[Math.PI/2,!1,!0,"verticakstrike"],right:[0,!1,!1,"horizontalstrike"],left:[Math.PI,!1,!1,"horizontalstrike"],updown:[Math.PI/2,!0,!0,"verticalstrike uparrow downarrow"],leftright:[0,!0,!1,"horizontalstrike leftarrow rightarrow"]};x.diagonalArrowDef={updiagonal:[-1,0,!1,"updiagonalstrike northeastarrow"],northeast:[-1,0,!1,"updiagonalstrike updiagonalarrow"],southeast:[1,0,!1,"downdiagonalstrike"],northwest:[1,Math.PI,!1,"downdiagonalstrike"],southwest:[-1,Math.PI,!1,"updiagonalstrike"],northeastsouthwest:[-1,0,!0,"updiagonalstrike northeastarrow updiagonalarrow southwestarrow"],northwestsoutheast:[1,0,!0,"downdiagonalstrike northwestarrow southeastarrow"]};x.arrowBBox={up:function(i){return(0,x.arrowBBoxW)(i,[(0,x.arrowHead)(i),0,i.padding,0])},down:function(i){return(0,x.arrowBBoxW)(i,[i.padding,0,(0,x.arrowHead)(i),0])},right:function(i){return(0,x.arrowBBoxHD)(i,[0,(0,x.arrowHead)(i),0,i.padding])},left:function(i){return(0,x.arrowBBoxHD)(i,[0,i.padding,0,(0,x.arrowHead)(i)])},updown:function(i){return(0,x.arrowBBoxW)(i,[(0,x.arrowHead)(i),0,(0,x.arrowHead)(i),0])},leftright:function(i){return(0,x.arrowBBoxHD)(i,[0,(0,x.arrowHead)(i),0,(0,x.arrowHead)(i)])}};var ev=function(i){return function(r){var t=x.sideIndex[r];return[r,{renderer:i,bbox:function(e){var n=[0,0,0,0];return n[t]=e.thickness+e.padding,n},border:function(e){var n=[0,0,0,0];return n[t]=e.thickness,n}}]}};x.CommonBorder=ev;var rv=function(i){return function(r,t,e){var n=x.sideIndex[t],o=x.sideIndex[e];return[r,{renderer:i,bbox:function(a){var s=a.thickness+a.padding,l=[0,0,0,0];return l[n]=l[o]=s,l},border:function(a){var s=[0,0,0,0];return s[n]=s[o]=a.thickness,s},remove:t+" "+e}]}};x.CommonBorder2=rv;var nv=function(i){return function(r){var t="mjx-"+r.charAt(0)+"strike";return[r+"diagonalstrike",{renderer:i(t),bbox:x.fullBBox}]}};x.CommonDiagonalStrike=nv;var iv=function(i){return function(r){var t=xr(x.diagonalArrowDef[r],4),e=t[0],n=t[1],o=t[2],a=t[3];return[r+"arrow",{renderer:function(s,l){var u=xr(s.arrowAW(),2),c=u[0],f=u[1],h=s.arrow(f,e*(c-n),o);i(s,h)},bbox:function(s){var l=s.arrowData(),u=l.a,c=l.x,f=l.y,h=xr([s.arrowhead.x,s.arrowhead.y,s.arrowhead.dx],3),p=h[0],d=h[1],y=h[2],v=xr(s.getArgMod(p+y,d),2),_=v[0],g=v[1],w=f+(_>u?s.thickness*g*Math.sin(_-u):0),M=c+(_>Math.PI/2-u?s.thickness*g*Math.sin(_+u-Math.PI/2):0);return[w,M,w,M]},remove:a}]}};x.CommonDiagonalArrow=iv;var ov=function(i){return function(r){var t=xr(x.arrowDef[r],4),e=t[0],n=t[1],o=t[2],a=t[3];return[r+"arrow",{renderer:function(s,l){var u=s.getBBox(),c=u.w,f=u.h,h=u.d,p=xr(o?[f+h,"X"]:[c,"Y"],2),d=p[0],y=p[1],v=s.getOffset(y),_=s.arrow(d,e,n,y,v);i(s,_)},bbox:x.arrowBBox[r],remove:a}]}};x.CommonArrow=ov});var dl=m(F=>{"use strict";var av=F&&F.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),sv=F&&F.__createBinding||(Object.create?(function(i,r,t,e){e===void 0&&(e=t);var n=Object.getOwnPropertyDescriptor(r,t);(!n||("get"in n?!r.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(i,e,n)}):(function(i,r,t,e){e===void 0&&(e=t),i[e]=r[t]})),lv=F&&F.__setModuleDefault||(Object.create?(function(i,r){Object.defineProperty(i,"default",{enumerable:!0,value:r})}):function(i,r){i.default=r}),uv=F&&F.__importStar||function(i){if(i&&i.__esModule)return i;var r={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&sv(r,i,t);return lv(r,i),r},We=F&&F.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},cv=F&&F.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},Mr=F&&F.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(F,"__esModule",{value:!0});F.CommonMencloseMixin=void 0;var Wt=uv(Yn()),pl=Jt();function fv(i){return(function(r){av(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,cv([],We(e),!1))||this;return o.notations={},o.renderChild=null,o.msqrt=null,o.padding=Wt.PADDING,o.thickness=Wt.THICKNESS,o.arrowhead={x:Wt.ARROWX,y:Wt.ARROWY,dx:Wt.ARROWDX},o.TRBL=[0,0,0,0],o.getParameters(),o.getNotations(),o.removeRedundantNotations(),o.initializeNotations(),o.TRBL=o.getBBoxExtenders(),o}return t.prototype.getParameters=function(){var e=this.node.attributes,n=e.get("data-padding");n!==void 0&&(this.padding=this.length2em(n,Wt.PADDING));var o=e.get("data-thickness");o!==void 0&&(this.thickness=this.length2em(o,Wt.THICKNESS));var a=e.get("data-arrowhead");if(a!==void 0){var s=We((0,pl.split)(a),3),l=s[0],u=s[1],c=s[2];this.arrowhead={x:l?parseFloat(l):Wt.ARROWX,y:u?parseFloat(u):Wt.ARROWY,dx:c?parseFloat(c):Wt.ARROWDX}}},t.prototype.getNotations=function(){var e,n,o=this.constructor.notations;try{for(var a=Mr((0,pl.split)(this.node.attributes.get("notation"))),s=a.next();!s.done;s=a.next()){var l=s.value,u=o.get(l);u&&(this.notations[l]=u,u.renderChild&&(this.renderChild=u.renderer))}}catch(c){e={error:c}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}},t.prototype.removeRedundantNotations=function(){var e,n,o,a;try{for(var s=Mr(Object.keys(this.notations)),l=s.next();!l.done;l=s.next()){var u=l.value;if(this.notations[u]){var c=this.notations[u].remove||"";try{for(var f=(o=void 0,Mr(c.split(/ /))),h=f.next();!h.done;h=f.next()){var p=h.value;delete this.notations[p]}}catch(d){o={error:d}}finally{try{h&&!h.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}}}catch(d){e={error:d}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}},t.prototype.initializeNotations=function(){var e,n;try{for(var o=Mr(Object.keys(this.notations)),a=o.next();!a.done;a=o.next()){var s=a.value,l=this.notations[s].init;l&&l(this)}}catch(u){e={error:u}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1);var o=We(this.TRBL,4),a=o[0],s=o[1],l=o[2],u=o[3],c=this.childNodes[0].getBBox();e.combine(c,u,0),e.h+=a,e.d+=l,e.w+=s,this.setChildPWidths(n)},t.prototype.getBBoxExtenders=function(){var e,n,o=[0,0,0,0];try{for(var a=Mr(Object.keys(this.notations)),s=a.next();!s.done;s=a.next()){var l=s.value;this.maximizeEntries(o,this.notations[l].bbox(this))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return o},t.prototype.getPadding=function(){var e,n,o=this,a=[0,0,0,0];try{for(var s=Mr(Object.keys(this.notations)),l=s.next();!l.done;l=s.next()){var u=l.value,c=this.notations[u].border;c&&this.maximizeEntries(a,c(this))}}catch(f){e={error:f}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return[0,1,2,3].map(function(f){return o.TRBL[f]-a[f]})},t.prototype.maximizeEntries=function(e,n){for(var o=0;o<e.length;o++)e[o]<n[o]&&(e[o]=n[o])},t.prototype.getOffset=function(e){var n=We(this.TRBL,4),o=n[0],a=n[1],s=n[2],l=n[3],u=(e==="X"?a-l:s-o)/2;return Math.abs(u)>.001?u:0},t.prototype.getArgMod=function(e,n){return[Math.atan2(n,e),Math.sqrt(e*e+n*n)]},t.prototype.arrow=function(e,n,o,a,s){return a===void 0&&(a=""),s===void 0&&(s=0),null},t.prototype.arrowData=function(){var e=We([this.padding,this.thickness],2),n=e[0],o=e[1],a=o*(this.arrowhead.x+Math.max(1,this.arrowhead.dx)),s=this.childNodes[0].getBBox(),l=s.h,u=s.d,c=s.w,f=l+u,h=Math.sqrt(f*f+c*c),p=Math.max(n,a*c/h),d=Math.max(n,a*f/h),y=We(this.getArgMod(c+2*p,f+2*d),2),v=y[0],_=y[1];return{a:v,W:_,x:p,y:d}},t.prototype.arrowAW=function(){var e=this.childNodes[0].getBBox(),n=e.h,o=e.d,a=e.w,s=We(this.TRBL,4),l=s[0],u=s[1],c=s[2],f=s[3];return this.getArgMod(f+a+u,l+n+o+c)},t.prototype.createMsqrt=function(e){var n=this.node.factory,o=n.create("msqrt");o.inheritAttributesFrom(this.node),o.childNodes[0]=e.node;var a=this.wrap(o);return a.parent=this,a},t.prototype.sqrtTRBL=function(){var e=this.msqrt.getBBox(),n=this.msqrt.childNodes[0].getBBox();return[e.h-n.h,0,e.d-n.d,e.w-n.w]},t})(i)}F.CommonMencloseMixin=fv});var vl=m(N=>{"use strict";var yl=N&&N.__createBinding||(Object.create?(function(i,r,t,e){e===void 0&&(e=t);var n=Object.getOwnPropertyDescriptor(r,t);(!n||("get"in n?!r.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(i,e,n)}):(function(i,r,t,e){e===void 0&&(e=t),i[e]=r[t]})),hv=N&&N.__setModuleDefault||(Object.create?(function(i,r){Object.defineProperty(i,"default",{enumerable:!0,value:r})}):function(i,r){i.default=r}),pv=N&&N.__importStar||function(i){if(i&&i.__esModule)return i;var r={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&yl(r,i,t);return hv(r,i),r},dv=N&&N.__exportStar||function(i,r){for(var t in i)t!=="default"&&!Object.prototype.hasOwnProperty.call(r,t)&&yl(r,i,t)};Object.defineProperty(N,"__esModule",{value:!0});N.Arrow=N.DiagonalArrow=N.DiagonalStrike=N.Border2=N.Border=N.RenderLine=N.lineOffset=N.lineData=N.computeLineData=void 0;var nn=pv(Yn());dv(Yn(),N);N.computeLineData={top:function(i,r,t,e){return[0,i-e,t,i-e]},right:function(i,r,t,e){return[t-e,-r,t-e,i]},bottom:function(i,r,t,e){return[0,e-r,t,e-r]},left:function(i,r,t,e){return[e,-r,e,i]},vertical:function(i,r,t,e){return[t/2,i,t/2,-r]},horizontal:function(i,r,t,e){return[0,(i-r)/2,t,(i-r)/2]},up:function(i,r,t,e){return[e,e-r,t-e,i-e]},down:function(i,r,t,e){return[e,i-e,t-e,e-r]}};var yv=function(i,r,t){t===void 0&&(t="");var e=i.getBBox(),n=e.h,o=e.d,a=e.w,s=i.thickness/2;return(0,N.lineOffset)(N.computeLineData[r](n,o,a,s),i,t)};N.lineData=yv;var vv=function(i,r,t){if(t){var e=r.getOffset(t);e&&(t==="X"?(i[0]-=e,i[2]-=e):(i[1]-=e,i[3]-=e))}return i};N.lineOffset=vv;var mv=function(i,r){return r===void 0&&(r=""),(function(t,e){var n=t.line((0,N.lineData)(t,i,r));t.adaptor.append(t.element,n)})};N.RenderLine=mv;var gv=function(i){return nn.CommonBorder(function(r,t){r.adaptor.append(r.element,r.line((0,N.lineData)(r,i)))})(i)};N.Border=gv;var _v=function(i,r,t){return nn.CommonBorder2(function(e,n){e.adaptor.append(e.element,e.line((0,N.lineData)(e,r))),e.adaptor.append(e.element,e.line((0,N.lineData)(e,t)))})(i,r,t)};N.Border2=_v;var wv=function(i){return nn.CommonDiagonalStrike(function(r){return function(t,e){t.adaptor.append(t.element,t.line((0,N.lineData)(t,i)))}})(i)};N.DiagonalStrike=wv;var xv=function(i){return nn.CommonDiagonalArrow(function(r,t){r.adaptor.append(r.element,t)})(i)};N.DiagonalArrow=xv;var Mv=function(i){return nn.CommonArrow(function(r,t){r.adaptor.append(r.element,t)})(i)};N.Arrow=Mv});var Uo=m(be=>{"use strict";var bv=be&&be.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Qn=be&&be.__assign||function(){return Qn=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Qn.apply(this,arguments)};Object.defineProperty(be,"__esModule",{value:!0});be.MmlMenclose=void 0;var Ko=C(),Sv=(function(i){bv(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=Ko.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"menclose"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"linebreakContininer",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setTeXclass=function(t){return t=this.childNodes[0].setTeXclass(t),this.updateTeXclass(this.childNodes[0]),t},r.defaults=Qn(Qn({},Ko.AbstractMmlNode.defaults),{notation:"longdiv"}),r})(Ko.AbstractMmlNode);be.MmlMenclose=Sv});var gl=m(K=>{"use strict";var Ov=K&&K.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),jv=K&&K.__createBinding||(Object.create?(function(i,r,t,e){e===void 0&&(e=t);var n=Object.getOwnPropertyDescriptor(r,t);(!n||("get"in n?!r.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(i,e,n)}):(function(i,r,t,e){e===void 0&&(e=t),i[e]=r[t]})),Av=K&&K.__setModuleDefault||(Object.create?(function(i,r){Object.defineProperty(i,"default",{enumerable:!0,value:r})}):function(i,r){i.default=r}),Cv=K&&K.__importStar||function(i){if(i&&i.__esModule)return i;var r={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&jv(r,i,t);return Av(r,i),r},Pv=K&&K.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},ml=K&&K.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(K,"__esModule",{value:!0});K.SVGmenclose=void 0;var Bv=k(),Tv=dl(),L=Cv(vl()),Nv=Uo(),Ev=(function(i){Ov(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e,n,o=this.standardSVGnode(t),a=this.getBBoxExtenders()[3],s={};a>0&&(s.transform="translate("+this.fixed(a)+", 0)");var l=this.adaptor.append(o,this.svg("g",s));this.renderChild?this.renderChild(this,l):this.childNodes[0].toSVG(l);try{for(var u=Pv(Object.keys(this.notations)),c=u.next();!c.done;c=u.next()){var f=c.value,h=this.notations[f];!h.renderChild&&h.renderer(this,o)}}catch(p){e={error:p}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}},r.prototype.arrow=function(t,e,n,o,a){o===void 0&&(o=""),a===void 0&&(a=0);var s=this.getBBox(),l=s.w,u=s.h,c=s.d,f=(t-l)/2,h=(u-c)/2,p=this.thickness,d=p/2,y=ml([p*this.arrowhead.x,p*this.arrowhead.y,p*this.arrowhead.dx],3),v=y[0],_=y[1],g=y[2],w=n?this.fill("M",l+f,h,"l",-(v+g),_,"l",g,d-_,"L",v-f,h+d,"l",g,_-d,"l",-(v+g),-_,"l",v+g,-_,"l",-g,_-d,"L",l+f-v,h-d,"l",-g,d-_,"Z"):this.fill("M",l+f,h,"l",-(v+g),_,"l",g,d-_,"L",-f,h+d,"l",0,-p,"L",l+f-v,h-d,"l",-g,d-_,"Z"),M=[];if(a&&M.push(o==="X"?"translate(".concat(this.fixed(-a)," 0)"):"translate(0 ".concat(this.fixed(a),")")),e){var b=this.jax.fixed(-e*180/Math.PI);M.push("rotate(".concat(b," ").concat(this.fixed(l/2)," ").concat(this.fixed(h),")"))}return M.length&&this.adaptor.setAttribute(w,"transform",M.join(" ")),w},r.prototype.line=function(t){var e=ml(t,4),n=e[0],o=e[1],a=e[2],s=e[3];return this.svg("line",{x1:this.fixed(n),y1:this.fixed(o),x2:this.fixed(a),y2:this.fixed(s),"stroke-width":this.fixed(this.thickness)})},r.prototype.box=function(t,e,n,o){o===void 0&&(o=0);var a=this.thickness,s={x:this.fixed(a/2),y:this.fixed(a/2-n),width:this.fixed(t-a),height:this.fixed(e+n-a),fill:"none","stroke-width":this.fixed(a)};return o&&(s.rx=this.fixed(o)),this.svg("rect",s)},r.prototype.ellipse=function(t,e,n){var o=this.thickness;return this.svg("ellipse",{rx:this.fixed((t-o)/2),ry:this.fixed((e+n-o)/2),cx:this.fixed(t/2),cy:this.fixed((e-n)/2),fill:"none","stroke-width":this.fixed(o)})},r.prototype.path=function(t){for(var e=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return this.svg("path",{d:n.map(function(a){return typeof a=="string"?a:e.fixed(a)}).join(" "),style:{"stroke-width":this.fixed(this.thickness)},"stroke-linecap":"round","stroke-linejoin":t,fill:"none"})},r.prototype.fill=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return this.svg("path",{d:e.map(function(o){return typeof o=="string"?o:t.fixed(o)}).join(" ")})},r.kind=Nv.MmlMenclose.prototype.kind,r.notations=new Map([L.Border("top"),L.Border("right"),L.Border("bottom"),L.Border("left"),L.Border2("actuarial","top","right"),L.Border2("madruwb","bottom","right"),L.DiagonalStrike("up"),L.DiagonalStrike("down"),["horizontalstrike",{renderer:L.RenderLine("horizontal","Y"),bbox:function(t){return[0,t.padding,0,t.padding]}}],["verticalstrike",{renderer:L.RenderLine("vertical","X"),bbox:function(t){return[t.padding,0,t.padding,0]}}],["box",{renderer:function(t,e){var n=t.getBBox(),o=n.w,a=n.h,s=n.d;t.adaptor.append(t.element,t.box(o,a,s))},bbox:L.fullBBox,border:L.fullBorder,remove:"left right top bottom"}],["roundedbox",{renderer:function(t,e){var n=t.getBBox(),o=n.w,a=n.h,s=n.d,l=t.thickness+t.padding;t.adaptor.append(t.element,t.box(o,a,s,l))},bbox:L.fullBBox}],["circle",{renderer:function(t,e){var n=t.getBBox(),o=n.w,a=n.h,s=n.d;t.adaptor.append(t.element,t.ellipse(o,a,s))},bbox:L.fullBBox}],["phasorangle",{renderer:function(t,e){var n=t.getBBox(),o=n.w,a=n.h,s=n.d,l=t.getArgMod(1.75*t.padding,a+s)[0],u=t.thickness/2,c=a+s,f=Math.cos(l);t.adaptor.append(t.element,t.path("mitre","M",o,u-s,"L",u+f*u,u-s,"L",f*c+u,c-s-u))},bbox:function(t){var e=t.padding/2,n=t.thickness;return[2*e,e,e+n,3*e+n]},border:function(t){return[0,0,t.thickness,0]},remove:"bottom"}],L.Arrow("up"),L.Arrow("down"),L.Arrow("left"),L.Arrow("right"),L.Arrow("updown"),L.Arrow("leftright"),L.DiagonalArrow("updiagonal"),L.DiagonalArrow("northeast"),L.DiagonalArrow("southeast"),L.DiagonalArrow("northwest"),L.DiagonalArrow("southwest"),L.DiagonalArrow("northeastsouthwest"),L.DiagonalArrow("northwestsoutheast"),["longdiv",{renderer:function(t,e){var n=t.getBBox(),o=n.w,a=n.h,s=n.d,l=t.thickness/2,u=t.padding;t.adaptor.append(t.element,t.path("round","M",l,l-s,"a",u-l/2,(a+s)/2-4*l,0,"0,1",0,a+s-2*l,"L",o-l,a-l))},bbox:function(t){var e=t.padding,n=t.thickness;return[e+n,e,e,2*e+n/2]}}],["radical",{renderer:function(t,e){t.msqrt.toSVG(e);var n=t.sqrtTRBL()[3];t.place(-n,0,e)},init:function(t){t.msqrt=t.createMsqrt(t.childNodes[0])},bbox:function(t){return t.sqrtTRBL()},renderChild:!0}]]),r})((0,Tv.CommonMencloseMixin)(Bv.SVGWrapper));K.SVGmenclose=Ev});var _l=m(br=>{"use strict";var Lv=br&&br.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(br,"__esModule",{value:!0});br.CommonSemanticsMixin=void 0;function kv(i){return(function(r){Lv(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.computeBBox=function(e,n){if(n===void 0&&(n=!1),this.childNodes.length){var o=this.childNodes[0].getBBox(),a=o.w,s=o.h,l=o.d;e.w=a,e.h=s,e.d=l}},t})(i)}br.CommonSemanticsMixin=kv});var Qo=m(mt=>{"use strict";var Yo=mt&&mt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Fe=mt&&mt.__assign||function(){return Fe=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Fe.apply(this,arguments)};Object.defineProperty(mt,"__esModule",{value:!0});mt.MmlAnnotation=mt.MmlAnnotationXML=mt.MmlSemantics=void 0;var Zn=C(),Vv=(function(i){Yo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"semantics"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notParent",{get:function(){return!0},enumerable:!1,configurable:!0}),r.defaults=Fe(Fe({},Zn.AbstractMmlBaseNode.defaults),{definitionUrl:null,encoding:null}),r})(Zn.AbstractMmlBaseNode);mt.MmlSemantics=Vv;var $o=(function(i){Yo(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"annotation-xml"},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(){},r.defaults=Fe(Fe({},Zn.AbstractMmlNode.defaults),{definitionUrl:null,encoding:null,cd:"mathmlkeys",name:"",src:null}),r})(Zn.AbstractMmlNode);mt.MmlAnnotationXML=$o;var qv=(function(i){Yo(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.properties={isChars:!0},t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"annotation"},enumerable:!1,configurable:!0}),r.defaults=Fe({},$o.defaults),r})($o);mt.MmlAnnotation=qv});var wl=m(gt=>{"use strict";var ti=gt&&gt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(gt,"__esModule",{value:!0});gt.SVGxml=gt.SVGannotationXML=gt.SVGannotation=gt.SVGsemantics=void 0;var ei=k(),Dv=_l(),Zo=Qo(),Gv=C(),Iv=(function(i){ti(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t);this.childNodes.length&&this.childNodes[0].toSVG(e)},r.kind=Zo.MmlSemantics.prototype.kind,r})((0,Dv.CommonSemanticsMixin)(ei.SVGWrapper));gt.SVGsemantics=Iv;var Wv=(function(i){ti(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){i.prototype.toSVG.call(this,t)},r.prototype.computeBBox=function(){return this.bbox},r.kind=Zo.MmlAnnotation.prototype.kind,r})(ei.SVGWrapper);gt.SVGannotation=Wv;var Fv=(function(i){ti(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.kind=Zo.MmlAnnotationXML.prototype.kind,r.styles={"foreignObject[data-mjx-xml]":{"font-family":"initial","line-height":"normal",overflow:"visible"}},r})(ei.SVGWrapper);gt.SVGannotationXML=Fv;var Rv=(function(i){ti(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.adaptor.clone(this.node.getXML()),n=this.jax.math.metrics.em*this.jax.math.metrics.scale,o=this.fixed(1/n),a=this.getBBox(),s=a.w,l=a.h,u=a.d;this.element=this.adaptor.append(t,this.svg("foreignObject",{"data-mjx-xml":!0,y:this.jax.fixed(-l*n)+"px",width:this.jax.fixed(s*n)+"px",height:this.jax.fixed((l+u)*n)+"px",transform:"scale(".concat(o,") matrix(1 0 0 -1 0 0)")},[e]))},r.prototype.computeBBox=function(t,e){e===void 0&&(e=!1);var n=this.jax.measureXMLnode(this.node.getXML()),o=n.w,a=n.h,s=n.d;t.w=o,t.h=a,t.d=s},r.prototype.getStyles=function(){},r.prototype.getScale=function(){},r.prototype.getVariant=function(){},r.kind=Gv.XMLNode.prototype.kind,r.autoStyle=!1,r})(ei.SVGWrapper);gt.SVGxml=Rv});var xl=m(Ft=>{"use strict";var Hv=Ft&&Ft.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Xv=Ft&&Ft.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},zv=Ft&&Ft.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.CommonMglyphMixin=void 0;function Jv(i){return(function(r){Hv(t,r);function t(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=r.apply(this,zv([],Xv(e),!1))||this;return o.getParameters(),o}return t.prototype.getParameters=function(){var e=this.node.attributes.getList("width","height","valign","src","index"),n=e.width,o=e.height,a=e.valign,s=e.src,l=e.index;if(s)this.width=n==="auto"?1:this.length2em(n),this.height=o==="auto"?1:this.length2em(o),this.valign=this.length2em(a||"0");else{var u=String.fromCodePoint(parseInt(l)),c=this.node.factory;this.charWrapper=this.wrap(c.create("text").setText(u)),this.charWrapper.parent=this}},t.prototype.computeBBox=function(e,n){n===void 0&&(n=!1),this.charWrapper?e.updateFrom(this.charWrapper.getBBox()):(e.w=this.width,e.h=this.height+this.valign,e.d=-this.valign)},t})(i)}Ft.CommonMglyphMixin=Jv});var ea=m(Se=>{"use strict";var Kv=Se&&Se.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),ri=Se&&Se.__assign||function(){return ri=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},ri.apply(this,arguments)};Object.defineProperty(Se,"__esModule",{value:!0});Se.MmlMglyph=void 0;var ta=C(),Uv=(function(i){Kv(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.texclass=ta.TEXCLASS.ORD,t}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mglyph"},enumerable:!1,configurable:!0}),r.prototype.verifyAttributes=function(t){var e=this.attributes.getList("src","fontfamily","index"),n=e.src,o=e.fontfamily,a=e.index;n===""&&(o===""||a==="")?this.mError("mglyph must have either src or fontfamily and index attributes",t,!0):i.prototype.verifyAttributes.call(this,t)},r.defaults=ri(ri({},ta.AbstractMmlTokenNode.defaults),{alt:"",src:"",index:"",width:"auto",height:"auto",valign:"0em"}),r})(ta.AbstractMmlTokenNode);Se.MmlMglyph=Uv});var Ml=m(Sr=>{"use strict";var $v=Sr&&Sr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Sr,"__esModule",{value:!0});Sr.SVGmglyph=void 0;var Yv=k(),Qv=xl(),Zv=ea(),tm=(function(i){$v(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e=this.standardSVGnode(t);if(this.charWrapper){this.charWrapper.toSVG(e);return}var n=this.node.attributes.getList("src","alt"),o=n.src,a=n.alt,s=this.fixed(this.height),l=this.fixed(this.width),u=this.fixed(this.height+(this.valign||0)),c={width:l,height:s,transform:"translate(0 "+u+") matrix(1 0 0 -1 0 0)",preserveAspectRatio:"none","aria-label":a,href:o},f=this.svg("image",c);this.adaptor.append(e,f)},r.kind=Zv.MmlMglyph.prototype.kind,r})((0,Qv.CommonMglyphMixin)(Yv.SVGWrapper));Sr.SVGmglyph=tm});var bl=m(Or=>{"use strict";var em=Or&&Or.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Or,"__esModule",{value:!0});Or.CommonTeXAtomMixin=void 0;var rm=C();function nm(i){return(function(r){em(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.computeBBox=function(e,n){if(n===void 0&&(n=!1),r.prototype.computeBBox.call(this,e,n),this.childNodes[0]&&this.childNodes[0].bbox.ic&&(e.ic=this.childNodes[0].bbox.ic),this.node.texClass===rm.TEXCLASS.VCENTER){var o=e.h,a=e.d,s=this.font.params.axis_height,l=(o+a)/2+s-o;e.h+=l,e.d-=l}},t})(i)}Or.CommonTeXAtomMixin=nm});var ia=m(Oe=>{"use strict";var im=Oe&&Oe.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),na=Oe&&Oe.__assign||function(){return na=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},na.apply(this,arguments)};Object.defineProperty(Oe,"__esModule",{value:!0});Oe.TeXAtom=void 0;var ra=C(),om=Ti(),Sl=(function(i){im(r,i);function r(t,e,n){var o=i.call(this,t,e,n)||this;return o.texclass=ra.TEXCLASS.ORD,o.setProperty("texClass",o.texClass),o}return Object.defineProperty(r.prototype,"kind",{get:function(){return"TeXAtom"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return-1},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notParent",{get:function(){return this.childNodes[0]&&this.childNodes[0].childNodes.length===1},enumerable:!1,configurable:!0}),r.prototype.setTeXclass=function(t){return this.childNodes[0].setTeXclass(null),this.adjustTeXclass(t)},r.prototype.adjustTeXclass=function(t){return t},r.defaults=na({},ra.AbstractMmlBaseNode.defaults),r})(ra.AbstractMmlBaseNode);Oe.TeXAtom=Sl;Sl.prototype.adjustTeXclass=om.MmlMo.prototype.adjustTeXclass});var jl=m(jr=>{"use strict";var am=jr&&jr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(jr,"__esModule",{value:!0});jr.SVGTeXAtom=void 0;var sm=k(),lm=bl(),um=ia(),Ol=C(),cm=(function(i){am(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){if(i.prototype.toSVG.call(this,t),this.adaptor.setAttribute(this.element,"data-mjx-texclass",Ol.TEXCLASSNAMES[this.node.texClass]),this.node.texClass===Ol.TEXCLASS.VCENTER){var e=this.childNodes[0].getBBox(),n=e.h,o=e.d,a=this.font.params.axis_height,s=(n+o)/2+a-n,l="translate(0 "+this.fixed(s)+")";this.adaptor.setAttribute(this.element,"transform",l)}},r.kind=um.TeXAtom.prototype.kind,r})((0,lm.CommonTeXAtomMixin)(sm.SVGWrapper));jr.SVGTeXAtom=cm});var Al=m(Rt=>{"use strict";var fm=Rt&&Rt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),hm=Rt&&Rt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},pm=Rt&&Rt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(Rt,"__esModule",{value:!0});Rt.CommonTextNodeMixin=void 0;function dm(i){return(function(r){fm(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.computeBBox=function(e,n){var o,a;n===void 0&&(n=!1);var s=this.parent.variant,l=this.node.getText();if(s==="-explicitFont"){var u=this.jax.getFontData(this.parent.styles),c=this.jax.measureText(l,s,u),f=c.w,h=c.h,p=c.d;e.h=h,e.d=p,e.w=f}else{var d=this.remappedText(l,s);e.empty();try{for(var y=hm(d),v=y.next();!v.done;v=y.next()){var _=v.value,g=pm(this.getVariantChar(s,_),4),h=g[0],p=g[1],f=g[2],w=g[3];if(w.unknown){var M=this.jax.measureText(String.fromCodePoint(_),s);f=M.w,h=M.h,p=M.d}e.w+=f,h>e.h&&(e.h=h),p>e.d&&(e.d=p),e.ic=w.ic||0,e.sk=w.sk||0,e.dx=w.dx||0}}catch(b){o={error:b}}finally{try{v&&!v.done&&(a=y.return)&&a.call(y)}finally{if(o)throw o.error}}d.length>1&&(e.sk=0),e.clean()}},t.prototype.remappedText=function(e,n){var o=this.parent.stretch.c;return o?[o]:this.parent.remapChars(this.unicodeChars(e,n))},t.prototype.getStyles=function(){},t.prototype.getVariant=function(){},t.prototype.getScale=function(){},t.prototype.getSpace=function(){},t})(i)}Rt.CommonTextNodeMixin=dm});var Cl=m(je=>{"use strict";var ym=je&&je.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),vm=je&&je.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(je,"__esModule",{value:!0});je.SVGTextNode=void 0;var mm=C(),gm=k(),_m=Al(),wm=(function(i){ym(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.toSVG=function(t){var e,n,o=this.node.getText(),a=this.parent.variant;if(o.length!==0)if(a==="-explicitFont")this.element=this.adaptor.append(t,this.jax.unknownText(o,a));else{var s=this.remappedText(o,a);this.parent.childNodes.length>1&&(t=this.element=this.adaptor.append(t,this.svg("g",{"data-mml-node":"text"})));var l=0;try{for(var u=vm(s),c=u.next();!c.done;c=u.next()){var f=c.value;l+=this.placeChar(f,l,0,t,a)}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}}},r.kind=mm.TextNode.prototype.kind,r.styles={'mjx-container[jax="SVG"] path[data-c], mjx-container[jax="SVG"] use[data-c]':{"stroke-width":3}},r})((0,_m.CommonTextNodeMixin)(gm.SVGWrapper));je.SVGTextNode=wm});var Ql=m(oi=>{"use strict";var j;Object.defineProperty(oi,"__esModule",{value:!0});oi.SVGWrappers=void 0;var Pl=k(),Bl=es(),ni=ss(),Tl=us(),Nl=ps(),El=ys(),Ll=ms(),kl=_s(),Vl=ws(),ql=Ms(),Dl=Os(),Gl=js(),Il=Bs(),Wl=mo(),Fl=Ls(),Rl=qs(),Ar=In(),Cr=Hs(),Hl=Ks(),Xl=Qs(),ii=sl(),zl=cl(),Jl=hl(),Kl=gl(),Ae=wl(),Ul=Ml(),$l=jl(),Yl=Cl();oi.SVGWrappers=(j={},j[Bl.SVGmath.kind]=Bl.SVGmath,j[ni.SVGmrow.kind]=ni.SVGmrow,j[ni.SVGinferredMrow.kind]=ni.SVGinferredMrow,j[Tl.SVGmi.kind]=Tl.SVGmi,j[Nl.SVGmo.kind]=Nl.SVGmo,j[El.SVGmn.kind]=El.SVGmn,j[Ll.SVGms.kind]=Ll.SVGms,j[kl.SVGmtext.kind]=kl.SVGmtext,j[Vl.SVGmerror.kind]=Vl.SVGmerror,j[ql.SVGmspace.kind]=ql.SVGmspace,j[Dl.SVGmpadded.kind]=Dl.SVGmpadded,j[Gl.SVGmphantom.kind]=Gl.SVGmphantom,j[Il.SVGmfrac.kind]=Il.SVGmfrac,j[Wl.SVGmsqrt.kind]=Wl.SVGmsqrt,j[Fl.SVGmroot.kind]=Fl.SVGmroot,j[Rl.SVGmfenced.kind]=Rl.SVGmfenced,j[Ar.SVGmsub.kind]=Ar.SVGmsub,j[Ar.SVGmsup.kind]=Ar.SVGmsup,j[Ar.SVGmsubsup.kind]=Ar.SVGmsubsup,j[Cr.SVGmunder.kind]=Cr.SVGmunder,j[Cr.SVGmover.kind]=Cr.SVGmover,j[Cr.SVGmunderover.kind]=Cr.SVGmunderover,j[Hl.SVGmmultiscripts.kind]=Hl.SVGmmultiscripts,j[Xl.SVGmtable.kind]=Xl.SVGmtable,j[ii.SVGmtr.kind]=ii.SVGmtr,j[ii.SVGmlabeledtr.kind]=ii.SVGmlabeledtr,j[zl.SVGmtd.kind]=zl.SVGmtd,j[Jl.SVGmaction.kind]=Jl.SVGmaction,j[Kl.SVGmenclose.kind]=Kl.SVGmenclose,j[Ae.SVGsemantics.kind]=Ae.SVGsemantics,j[Ae.SVGannotation.kind]=Ae.SVGannotation,j[Ae.SVGannotationXML.kind]=Ae.SVGannotationXML,j[Ae.SVGxml.kind]=Ae.SVGxml,j[Ul.SVGmglyph.kind]=Ul.SVGmglyph,j[$l.SVGTeXAtom.kind]=$l.SVGTeXAtom,j[Yl.SVGTextNode.kind]=Yl.SVGTextNode,j[Pl.SVGWrapper.kind]=Pl.SVGWrapper,j)});var Zl=m(Pr=>{"use strict";var xm=Pr&&Pr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Pr,"__esModule",{value:!0});Pr.SVGWrapperFactory=void 0;var Mm=Ha(),bm=Ql(),Sm=(function(i){xm(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.jax=null,t}return r.defaultNodes=bm.SVGWrappers,r})(Mm.CommonWrapperFactory);Pr.SVGWrapperFactory=Sm});var tu=m(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.FontCache=void 0;var Om=(function(){function i(r){this.cache=new Map,this.defs=null,this.localID="",this.nextID=0,this.jax=r}return i.prototype.cachePath=function(r,t,e){var n="MJX-"+this.localID+(this.jax.font.getVariant(r).cacheID||"")+"-"+t;return this.cache.has(n)||(this.cache.set(n,e),this.jax.adaptor.append(this.defs,this.jax.svg("path",{id:n,d:e}))),n},i.prototype.clearLocalID=function(){this.localID=""},i.prototype.useLocalID=function(r){r===void 0&&(r=null),this.localID=(r??++this.nextID)+(r===""?"":"-")},i.prototype.clearCache=function(){this.cache=new Map,this.defs=this.jax.svg("defs")},i.prototype.getCache=function(){return this.defs},i})();ai.FontCache=Om});var Gi=m(X=>{"use strict";var jm=X&&X.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),si=X&&X.__assign||function(){return si=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},si.apply(this,arguments)},eu=X&&X.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(X,"__esModule",{value:!0});X.SVG=X.XLINKNS=X.SVGNS=void 0;var ru=Fa(),Am=Zl(),Cm=Xc(),Pm=tu(),Bm=Jt(),Tm=Kr();X.SVGNS="http://www.w3.org/2000/svg";X.XLINKNS="http://www.w3.org/1999/xlink";var Nm=(function(i){jm(r,i);function r(t){t===void 0&&(t=null);var e=i.call(this,t,Am.SVGWrapperFactory,Cm.TeXFont)||this;return e.minwidth=0,e.shift=0,e.container=null,e.svgStyles=null,e.fontCache=new Pm.FontCache(e),e}return r.prototype.initialize=function(){this.options.fontCache==="global"&&this.fontCache.clearCache()},r.prototype.clearFontCache=function(){this.fontCache.clearCache()},r.prototype.reset=function(){this.clearFontCache()},r.prototype.setScale=function(t){this.options.scale!==1&&this.adaptor.setStyle(t,"fontSize",(0,Tm.percent)(this.options.scale))},r.prototype.escaped=function(t,e){return this.setDocument(e),this.html("span",{},[this.text(t.math)])},r.prototype.styleSheet=function(t){if(this.svgStyles)return this.svgStyles;var e=this.svgStyles=i.prototype.styleSheet.call(this,t);return this.adaptor.setAttribute(e,"id",r.STYLESHEETID),e},r.prototype.pageElements=function(t){return this.options.fontCache==="global"&&!this.findCache(t)?this.svg("svg",{id:r.FONTCACHEID,style:{display:"none"}},[this.fontCache.getCache()]):null},r.prototype.findCache=function(t){for(var e=this.adaptor,n=e.tags(e.body(t.document),"svg"),o=n.length-1;o>=0;o--)if(this.adaptor.getAttribute(n[o],"id")===r.FONTCACHEID)return!0;return!1},r.prototype.processMath=function(t,e){var n=this.container;this.container=e;var o=this.factory.wrap(t),a=eu(this.createRoot(o),2),s=a[0],l=a[1];this.typesetSVG(o,s,l),this.container=n},r.prototype.createRoot=function(t){var e=t.getOuterBBox(),n=e.w,o=e.h,a=e.d,s=e.pwidth,l=t.metrics.em/1e3,u=Math.max(n,l),c=Math.max(o+a,l),f=this.svg("g",{stroke:"currentColor",fill:"currentColor","stroke-width":0,transform:"scale(1,-1)"}),h=this.adaptor,p=h.append(this.container,this.svg("svg",{xmlns:X.SVGNS,width:this.ex(u),height:this.ex(c),role:"img",focusable:!1,style:{"vertical-align":this.ex(-a)},viewBox:[0,this.fixed(-o*1e3,1),this.fixed(u*1e3,1),this.fixed(c*1e3,1)].join(" ")},[f]));if(u===.001&&(h.setAttribute(p,"preserveAspectRatio","xMidYMid slice"),n<0&&h.setStyle(this.container,"margin-right",this.ex(n))),s){h.setStyle(p,"min-width",this.ex(u)),h.setAttribute(p,"width",s),h.removeAttribute(p,"viewBox");var d=this.fixed(t.metrics.ex/(this.font.params.x_height*1e3),6);h.setAttribute(f,"transform","scale(".concat(d,",-").concat(d,") translate(0, ").concat(this.fixed(-o*1e3,1),")"))}return this.options.fontCache!=="none"&&h.setAttribute(p,"xmlns:xlink",X.XLINKNS),[p,f]},r.prototype.typesetSVG=function(t,e,n){var o=this.adaptor;if(this.minwidth=this.shift=0,this.options.fontCache==="local"&&(this.fontCache.clearCache(),this.fontCache.useLocalID(this.options.localID),o.insert(this.fontCache.getCache(),n)),t.toSVG(n),this.fontCache.clearLocalID(),this.minwidth)o.setStyle(e,"minWidth",this.ex(this.minwidth)),o.setStyle(this.container,"minWidth",this.ex(this.minwidth));else if(this.shift){var a=o.getAttribute(this.container,"justify")||"center";this.setIndent(e,a,this.shift)}},r.prototype.setIndent=function(t,e,n){(e==="center"||e==="left")&&this.adaptor.setStyle(t,"margin-left",this.ex(n)),(e==="center"||e==="right")&&this.adaptor.setStyle(t,"margin-right",this.ex(-n))},r.prototype.ex=function(t){return t/=this.font.params.x_height,Math.abs(t)<.001?"0":t.toFixed(3).replace(/\.?0+$/,"")+"ex"},r.prototype.svg=function(t,e,n){return e===void 0&&(e={}),n===void 0&&(n=[]),this.html(t,e,n,X.SVGNS)},r.prototype.unknownText=function(t,e){var n=this.math.metrics,o=this.font.params.x_height/n.ex*n.em*1e3,a=this.svg("text",{"data-variant":e,transform:"scale(1,-1)","font-size":this.fixed(o,1)+"px"},[this.text(t)]),s=this.adaptor;if(e!=="-explicitFont"){var l=(0,Bm.unicodeChars)(t);if(l.length!==1||l[0]<119808||l[0]>120831){var u=eu(this.font.getCssFont(e),3),c=u[0],f=u[1],h=u[2];s.setAttribute(a,"font-family",c),f&&s.setAttribute(a,"font-style","italic"),h&&s.setAttribute(a,"font-weight","bold")}}return a},r.prototype.measureTextNode=function(t){var e=this.adaptor;t=e.clone(t),e.removeAttribute(t,"transform");var n=this.fixed(this.font.params.x_height*1e3,1),o=this.svg("svg",{position:"absolute",visibility:"hidden",width:"1ex",height:"1ex",viewBox:[0,0,n,n].join(" ")},[t]);e.append(e.body(e.document),o);var a=e.nodeSize(t,1e3,!0)[0];return e.remove(o),{w:a,h:.75,d:.2}},r.NAME="SVG",r.OPTIONS=si(si({},ru.CommonOutputJax.OPTIONS),{internalSpeechTitles:!0,titleID:0,fontCache:"local",localID:null}),r.commonStyles={'mjx-container[jax="SVG"]':{direction:"ltr"},'mjx-container[jax="SVG"] > svg':{overflow:"visible","min-height":"1px","min-width":"1px"},'mjx-container[jax="SVG"] > svg a':{fill:"blue",stroke:"blue"}},r.FONTCACHEID="MJX-SVG-global-cache",r.STYLESHEETID="MJX-SVG-styles",r})(ru.CommonOutputJax);X.SVG=Nm});var nu=m(Br=>{"use strict";var li=Br&&Br.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Br,"__esModule",{value:!0});Br.AbstractDOMAdaptor=void 0;var Em=(function(){function i(r){r===void 0&&(r=null),this.document=r}return i.prototype.node=function(r,t,e,n){var o,a;t===void 0&&(t={}),e===void 0&&(e=[]);var s=this.create(r,n);this.setAttributes(s,t);try{for(var l=li(e),u=l.next();!u.done;u=l.next()){var c=u.value;this.append(s,c)}}catch(f){o={error:f}}finally{try{u&&!u.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}return s},i.prototype.setAttributes=function(r,t){var e,n,o,a,s,l;if(t.style&&typeof t.style!="string")try{for(var u=li(Object.keys(t.style)),c=u.next();!c.done;c=u.next()){var f=c.value;this.setStyle(r,f.replace(/-([a-z])/g,function(v,_){return _.toUpperCase()}),t.style[f])}}catch(v){e={error:v}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}if(t.properties)try{for(var h=li(Object.keys(t.properties)),p=h.next();!p.done;p=h.next()){var f=p.value;r[f]=t.properties[f]}}catch(v){o={error:v}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(o)throw o.error}}try{for(var d=li(Object.keys(t)),y=d.next();!y.done;y=d.next()){var f=y.value;(f!=="style"||typeof t.style=="string")&&f!=="properties"&&this.setAttribute(r,f,t[f])}}catch(v){s={error:v}}finally{try{y&&!y.done&&(l=d.return)&&l.call(d)}finally{if(s)throw s.error}}},i.prototype.replace=function(r,t){return this.insert(r,t),this.remove(t),t},i.prototype.childNode=function(r,t){return this.childNodes(r)[t]},i.prototype.allClasses=function(r){var t=this.getAttribute(r,"class");return t?t.replace(/  +/g," ").replace(/^ /,"").replace(/ $/,"").split(/ /):[]},i})();Br.AbstractDOMAdaptor=Em});var iu=m(St=>{"use strict";var Lm=St&&St.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),ci=St&&St.__assign||function(){return ci=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},ci.apply(this,arguments)};Object.defineProperty(St,"__esModule",{value:!0});St.NodeMixin=St.NodeMixinOptions=void 0;var ui=Xe();St.NodeMixinOptions={badCSS:!0,badSizes:!0};function km(i,r){var t;return r===void 0&&(r={}),r=(0,ui.userOptions)((0,ui.defaultOptions)({},St.NodeMixinOptions),r),t=(function(e){Lm(n,e);function n(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=e.call(this,o[0])||this,l=s.constructor;return s.options=(0,ui.userOptions)((0,ui.defaultOptions)({},l.OPTIONS),o[1]),s}return n.prototype.fontSize=function(o){return r.badCSS?this.options.fontSize:e.prototype.fontSize.call(this,o)},n.prototype.fontFamily=function(o){return r.badCSS?this.options.fontFamily:e.prototype.fontFamily.call(this,o)},n.prototype.nodeSize=function(o,a,s){if(a===void 0&&(a=1),s===void 0&&(s=null),!r.badSizes)return e.prototype.nodeSize.call(this,o,a,s);var l=this.textContent(o),u=Array.from(l.replace(n.cjkPattern,"")).length,c=Array.from(l).length-u;return[c*this.options.cjkCharWidth+u*this.options.unknownCharWidth,this.options.unknownCharHeight]},n.prototype.nodeBBox=function(o){return r.badSizes?{left:0,right:0,top:0,bottom:0}:e.prototype.nodeBBox.call(this,o)},n})(i),t.OPTIONS=ci(ci({},r.badCSS?{fontSize:16,fontFamily:"Times"}:{}),r.badSizes?{cjkCharWidth:1,unknownCharWidth:.6,unknownCharHeight:.8}:{}),t.cjkPattern=new RegExp(["[","\u1100-\u115F","\u2329\u232A","\u2E80-\u303E","\u3040-\u3247","\u3250-\u4DBF","\u4E00-\uA4C6","\uA960-\uA97C","\uAC00-\uD7A3","\uF900-\uFAFF","\uFE10-\uFE19","\uFE30-\uFE6B","\uFF01-\uFF60\uFFE0-\uFFE6","\u{1B000}-\u{1B001}","\u{1F200}-\u{1F251}","\u{20000}-\u{3FFFD}","]"].join(""),"gu"),t}St.NodeMixin=km});var on=m(_t=>{"use strict";var oa=_t&&_t.__assign||function(){return oa=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},oa.apply(this,arguments)},Vm=_t&&_t.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},qm=_t&&_t.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},Dm=_t&&_t.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(_t,"__esModule",{value:!0});_t.LiteElement=void 0;var Gm=(function(){function i(r,t,e){var n,o;t===void 0&&(t={}),e===void 0&&(e=[]),this.kind=r,this.attributes=oa({},t),this.children=qm([],Vm(e),!1);try{for(var a=Dm(this.children),s=a.next();!s.done;s=a.next()){var l=s.value;l.parent=this}}catch(u){n={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}this.styles=null}return i})();_t.LiteElement=Gm});var sa=m(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.LiteDocument=void 0;var aa=on(),Im=(function(){function i(){this.root=new aa.LiteElement("html",{},[this.head=new aa.LiteElement("head"),this.body=new aa.LiteElement("body")]),this.type=""}return Object.defineProperty(i.prototype,"kind",{get:function(){return"#document"},enumerable:!1,configurable:!0}),i})();fi.LiteDocument=Im});var la=m(Ce=>{"use strict";var Wm=Ce&&Ce.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Ce,"__esModule",{value:!0});Ce.LiteComment=Ce.LiteText=void 0;var ou=(function(){function i(r){r===void 0&&(r=""),this.value=r}return Object.defineProperty(i.prototype,"kind",{get:function(){return"#text"},enumerable:!1,configurable:!0}),i})();Ce.LiteText=ou;var Fm=(function(i){Wm(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"#comment"},enumerable:!1,configurable:!0}),r})(ou);Ce.LiteComment=Fm});var au=m(Pe=>{"use strict";var Rm=Pe&&Pe.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Hm=Pe&&Pe.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Pe,"__esModule",{value:!0});Pe.LiteList=void 0;var Xm=(function(){function i(r){this.nodes=[],this.nodes=Hm([],Rm(r),!1)}return i.prototype.append=function(r){this.nodes.push(r)},i.prototype[Symbol.iterator]=function(){var r=0;return{next:function(){return r===this.nodes.length?{value:null,done:!0}:{value:this.nodes[r++],done:!1}}}},i})();Pe.LiteList=Xm});var fa=m(z=>{"use strict";var zm=z&&z.__createBinding||(Object.create?(function(i,r,t,e){e===void 0&&(e=t);var n=Object.getOwnPropertyDescriptor(r,t);(!n||("get"in n?!r.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(i,e,n)}):(function(i,r,t,e){e===void 0&&(e=t),i[e]=r[t]})),Jm=z&&z.__setModuleDefault||(Object.create?(function(i,r){Object.defineProperty(i,"default",{enumerable:!0,value:r})}):function(i,r){i.default=r}),Km=z&&z.__importStar||function(i){if(i&&i.__esModule)return i;var r={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&zm(r,i,t);return Jm(r,i),r},Um=z&&z.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},ua=z&&z.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(z,"__esModule",{value:!0});z.LiteParser=z.PATTERNS=void 0;var su=Km(Vc()),$m=on(),lu=la(),ca;(function(i){i.TAGNAME="[a-z][^\\s\\n>]*",i.ATTNAME="[a-z][^\\s\\n>=]*",i.VALUE=`(?:'[^']*'|"[^"]*"|[^\\s\\n]+)`,i.VALUESPLIT=`(?:'([^']*)'|"([^"]*)"|([^\\s\\n]+))`,i.SPACE="(?:\\s|\\n)+",i.OPTIONALSPACE="(?:\\s|\\n)*",i.ATTRIBUTE=i.ATTNAME+"(?:"+i.OPTIONALSPACE+"="+i.OPTIONALSPACE+i.VALUE+")?",i.ATTRIBUTESPLIT="("+i.ATTNAME+")(?:"+i.OPTIONALSPACE+"="+i.OPTIONALSPACE+i.VALUESPLIT+")?",i.TAG="(<(?:"+i.TAGNAME+"(?:"+i.SPACE+i.ATTRIBUTE+")*"+i.OPTIONALSPACE+"/?|/"+i.TAGNAME+"|!--[^]*?--|![^]*?)(?:>|$))",i.tag=new RegExp(i.TAG,"i"),i.attr=new RegExp(i.ATTRIBUTE,"i"),i.attrsplit=new RegExp(i.ATTRIBUTESPLIT,"i")})(ca=z.PATTERNS||(z.PATTERNS={}));var Ym=(function(){function i(){}return i.prototype.parseFromString=function(r,t,e){t===void 0&&(t="text/html"),e===void 0&&(e=null);for(var n=e.createDocument(),o=e.body(n),a=r.replace(/<\?.*?\?>/g,"").split(ca.tag);a.length;){var s=a.shift(),l=a.shift();s&&this.addText(e,o,s),l&&l.charAt(l.length-1)===">"&&(l.charAt(1)==="!"?this.addComment(e,o,l):l.charAt(1)==="/"?o=this.closeTag(e,o,l):o=this.openTag(e,o,l,a))}return this.checkDocument(e,n),n},i.prototype.addText=function(r,t,e){return e=su.translate(e),r.append(t,r.text(e))},i.prototype.addComment=function(r,t,e){return r.append(t,new lu.LiteComment(e))},i.prototype.closeTag=function(r,t,e){for(var n=e.slice(2,e.length-1).toLowerCase();r.parent(t)&&r.kind(t)!==n;)t=r.parent(t);return r.parent(t)},i.prototype.openTag=function(r,t,e,n){var o=this.constructor.PCDATA,a=this.constructor.SELF_CLOSING,s=e.match(/<(.*?)[\s\n>\/]/)[1].toLowerCase(),l=r.node(s),u=e.replace(/^<.*?[\s\n>]/,"").split(ca.attrsplit);return(u.pop().match(/>$/)||u.length<5)&&(this.addAttributes(r,l,u),r.append(t,l),!a[s]&&!e.match(/\/>$/)&&(o[s]?this.handlePCDATA(r,l,s,n):t=l)),t},i.prototype.addAttributes=function(r,t,e){for(var n=this.constructor.CDATA_ATTR;e.length;){var o=Um(e.splice(0,5),5),a=o[1],s=o[2],l=o[3],u=o[4],c=s||l||u||"";n[a]||(c=su.translate(c)),r.setAttribute(t,a,c)}},i.prototype.handlePCDATA=function(r,t,e,n){for(var o=[],a="</"+e+">",s="";n.length&&s!==a;)o.push(s),o.push(n.shift()),s=n.shift();r.append(t,r.text(o.join("")))},i.prototype.checkDocument=function(r,t){var e,n,o,a,s=this.getOnlyChild(r,r.body(t));if(s){try{for(var l=ua(r.childNodes(r.body(t))),u=l.next();!u.done;u=l.next()){var c=u.value;if(c===s)break;c instanceof lu.LiteComment&&c.value.match(/^<!DOCTYPE/)&&(t.type=c.value)}}catch(p){e={error:p}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}switch(r.kind(s)){case"html":try{for(var f=ua(s.children),h=f.next();!h.done;h=f.next()){var c=h.value;switch(r.kind(c)){case"head":t.head=c;break;case"body":t.body=c;break}}}catch(p){o={error:p}}finally{try{h&&!h.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}t.root=s,r.remove(s),r.parent(t.body)!==s&&r.append(s,t.body),r.parent(t.head)!==s&&r.insert(t.head,t.body);break;case"head":t.head=r.replace(s,t.head);break;case"body":t.body=r.replace(s,t.body);break}}},i.prototype.getOnlyChild=function(r,t){var e,n,o=null;try{for(var a=ua(r.childNodes(t)),s=a.next();!s.done;s=a.next()){var l=s.value;if(l instanceof $m.LiteElement){if(o)return null;o=l}}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return o},i.prototype.serialize=function(r,t,e){var n=this;e===void 0&&(e=!1);var o=this.constructor.SELF_CLOSING,a=this.constructor.CDATA_ATTR,s=r.kind(t),l=r.allAttributes(t).map(function(f){return f.name+'="'+(a[f.name]?f.value:n.protectAttribute(f.value))+'"'}).join(" "),u=this.serializeInner(r,t,e),c="<"+s+(l?" "+l:"")+((!e||u)&&!o[s]?">".concat(u,"</").concat(s,">"):e?"/>":">");return c},i.prototype.serializeInner=function(r,t,e){var n=this;e===void 0&&(e=!1);var o=this.constructor.PCDATA;return o.hasOwnProperty(t.kind)?r.childNodes(t).map(function(a){return r.value(a)}).join(""):r.childNodes(t).map(function(a){var s=r.kind(a);return s==="#text"?n.protectHTML(r.value(a)):s==="#comment"?a.value:n.serialize(r,a,e)}).join("")},i.prototype.protectAttribute=function(r){return typeof r!="string"&&(r=String(r)),r.replace(/"/g,"&quot;")},i.prototype.protectHTML=function(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},i.SELF_CLOSING={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,menuitem:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},i.PCDATA={option:!0,textarea:!0,fieldset:!0,title:!0,style:!0,script:!0},i.CDATA_ATTR={style:!0,datafld:!0,datasrc:!0,href:!0,src:!0,longdesc:!0,usemap:!0,cite:!0,datetime:!0,action:!0,axis:!0,profile:!0,content:!0,scheme:!0},i})();z.LiteParser=Ym});var cu=m(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.LiteWindow=void 0;var Qm=on(),uu=sa(),ha=au(),Zm=fa(),tg=(function(){function i(){this.DOMParser=Zm.LiteParser,this.NodeList=ha.LiteList,this.HTMLCollection=ha.LiteList,this.HTMLElement=Qm.LiteElement,this.DocumentFragment=ha.LiteList,this.Document=uu.LiteDocument,this.document=new uu.LiteDocument}return i})();hi.LiteWindow=tg});var mu=m(R=>{"use strict";var du=R&&R.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),pa=R&&R.__assign||function(){return pa=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},pa.apply(this,arguments)},fu=R&&R.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},eg=R&&R.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},rg=R&&R.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(R,"__esModule",{value:!0});R.liteAdaptor=R.LiteAdaptor=R.LiteBase=void 0;var ng=nu(),ig=iu(),og=sa(),hu=on(),an=la(),ag=cu(),sg=fa(),pu=xn(),yu=(function(i){du(r,i);function r(){var t=i.call(this)||this;return t.parser=new sg.LiteParser,t.window=new ag.LiteWindow,t}return r.prototype.parse=function(t,e){return this.parser.parseFromString(t,e,this)},r.prototype.create=function(t,e){return e===void 0&&(e=null),new hu.LiteElement(t)},r.prototype.text=function(t){return new an.LiteText(t)},r.prototype.comment=function(t){return new an.LiteComment(t)},r.prototype.createDocument=function(){return new og.LiteDocument},r.prototype.head=function(t){return t.head},r.prototype.body=function(t){return t.body},r.prototype.root=function(t){return t.root},r.prototype.doctype=function(t){return t.type},r.prototype.tags=function(t,e,n){n===void 0&&(n=null);var o=[],a=[];if(n)return a;for(var s=t;s;){var l=s.kind;l!=="#text"&&l!=="#comment"&&(s=s,l===e&&a.push(s),s.children.length&&(o=s.children.concat(o))),s=o.shift()}return a},r.prototype.elementById=function(t,e){for(var n=[],o=t;o;){if(o.kind!=="#text"&&o.kind!=="#comment"){if(o=o,o.attributes.id===e)return o;o.children.length&&(n=o.children.concat(n))}o=n.shift()}return null},r.prototype.elementsByClass=function(t,e){for(var n=[],o=[],a=t;a;){if(a.kind!=="#text"&&a.kind!=="#comment"){a=a;var s=(a.attributes.class||"").trim().split(/ +/);s.includes(e)&&o.push(a),a.children.length&&(n=a.children.concat(n))}a=n.shift()}return o},r.prototype.getElements=function(t,e){var n,o,a=[],s=this.body(e);try{for(var l=fu(t),u=l.next();!u.done;u=l.next()){var c=u.value;if(typeof c=="string")if(c.charAt(0)==="#"){var f=this.elementById(s,c.slice(1));f&&a.push(f)}else c.charAt(0)==="."?a=a.concat(this.elementsByClass(s,c.slice(1))):c.match(/^[-a-z][-a-z0-9]*$/i)&&(a=a.concat(this.tags(s,c)));else Array.isArray(c)?a=a.concat(c):c instanceof this.window.NodeList||c instanceof this.window.HTMLCollection?a=a.concat(c.nodes):a.push(c)}}catch(h){n={error:h}}finally{try{u&&!u.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}return a},r.prototype.contains=function(t,e){for(;e&&e!==t;)e=this.parent(e);return!!e},r.prototype.parent=function(t){return t.parent},r.prototype.childIndex=function(t){return t.parent?t.parent.children.findIndex(function(e){return e===t}):-1},r.prototype.append=function(t,e){return e.parent&&this.remove(e),t.children.push(e),e.parent=t,e},r.prototype.insert=function(t,e){if(t.parent&&this.remove(t),e&&e.parent){var n=this.childIndex(e);e.parent.children.splice(n,0,t),t.parent=e.parent}},r.prototype.remove=function(t){var e=this.childIndex(t);return e>=0&&t.parent.children.splice(e,1),t.parent=null,t},r.prototype.replace=function(t,e){var n=this.childIndex(e);return n>=0&&(e.parent.children[n]=t,t.parent=e.parent,e.parent=null),e},r.prototype.clone=function(t){var e=this,n=new hu.LiteElement(t.kind);return n.attributes=pa({},t.attributes),n.children=t.children.map(function(o){if(o.kind==="#text")return new an.LiteText(o.value);if(o.kind==="#comment")return new an.LiteComment(o.value);var a=e.clone(o);return a.parent=n,a}),n},r.prototype.split=function(t,e){var n=new an.LiteText(t.value.slice(e));return t.value=t.value.slice(0,e),t.parent.children.splice(this.childIndex(t)+1,0,n),n.parent=t.parent,n},r.prototype.next=function(t){var e=t.parent;if(!e)return null;var n=this.childIndex(t)+1;return n>=0&&n<e.children.length?e.children[n]:null},r.prototype.previous=function(t){var e=t.parent;if(!e)return null;var n=this.childIndex(t)-1;return n>=0?e.children[n]:null},r.prototype.firstChild=function(t){return t.children[0]},r.prototype.lastChild=function(t){return t.children[t.children.length-1]},r.prototype.childNodes=function(t){return rg([],eg(t.children),!1)},r.prototype.childNode=function(t,e){return t.children[e]},r.prototype.kind=function(t){return t.kind},r.prototype.value=function(t){return t.kind==="#text"?t.value:t.kind==="#comment"?t.value.replace(/^<!(--)?((?:.|\n)*)\1>$/,"$2"):""},r.prototype.textContent=function(t){var e=this;return t.children.reduce(function(n,o){return n+(o.kind==="#text"?o.value:o.kind==="#comment"?"":e.textContent(o))},"")},r.prototype.innerHTML=function(t){return this.parser.serializeInner(this,t)},r.prototype.outerHTML=function(t){return this.parser.serialize(this,t)},r.prototype.serializeXML=function(t){return this.parser.serialize(this,t,!0)},r.prototype.setAttribute=function(t,e,n,o){o===void 0&&(o=null),typeof n!="string"&&(n=String(n)),o&&(e=o.replace(/.*\//,"")+":"+e.replace(/^.*:/,"")),t.attributes[e]=n,e==="style"&&(t.styles=null)},r.prototype.getAttribute=function(t,e){return t.attributes[e]},r.prototype.removeAttribute=function(t,e){delete t.attributes[e]},r.prototype.hasAttribute=function(t,e){return t.attributes.hasOwnProperty(e)},r.prototype.allAttributes=function(t){var e,n,o=t.attributes,a=[];try{for(var s=fu(Object.keys(o)),l=s.next();!l.done;l=s.next()){var u=l.value;a.push({name:u,value:o[u]})}}catch(c){e={error:c}}finally{try{l&&!l.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return a},r.prototype.addClass=function(t,e){var n=(t.attributes.class||"").split(/ /);n.find(function(o){return o===e})||(n.push(e),t.attributes.class=n.join(" "))},r.prototype.removeClass=function(t,e){var n=(t.attributes.class||"").split(/ /),o=n.findIndex(function(a){return a===e});o>=0&&(n.splice(o,1),t.attributes.class=n.join(" "))},r.prototype.hasClass=function(t,e){var n=(t.attributes.class||"").split(/ /);return!!n.find(function(o){return o===e})},r.prototype.setStyle=function(t,e,n){t.styles||(t.styles=new pu.Styles(this.getAttribute(t,"style"))),t.styles.set(e,n),t.attributes.style=t.styles.cssText},r.prototype.getStyle=function(t,e){if(!t.styles){var n=this.getAttribute(t,"style");if(!n)return"";t.styles=new pu.Styles(n)}return t.styles.get(e)},r.prototype.allStyles=function(t){return this.getAttribute(t,"style")},r.prototype.insertRules=function(t,e){t.children=[this.text(e.join(`
10
11`)+`
12
13`+this.textContent(t))]},r.prototype.fontSize=function(t){return 0},r.prototype.fontFamily=function(t){return""},r.prototype.nodeSize=function(t,e,n){return e===void 0&&(e=1),n===void 0&&(n=null),[0,0]},r.prototype.nodeBBox=function(t){return{left:0,right:0,top:0,bottom:0}},r})(ng.AbstractDOMAdaptor);R.LiteBase=yu;var vu=(function(i){du(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r})((0,ig.NodeMixin)(yu));R.LiteAdaptor=vu;function lg(i){return i===void 0&&(i=null),new vu(null,i)}R.liteAdaptor=lg});var _u=m(V=>{"use strict";var gu=V&&V.__generator||function(i,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},e,n,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(c){return l([u,c])}}function l(u){if(e)throw new TypeError("Generator is already executing.");for(;t;)try{if(e=1,n&&(o=u[0]&2?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){t.label=u[1];break}if(u[0]===6&&t.label<o[1]){t.label=o[1],o=u;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(u);break}o[2]&&t.ops.pop(),t.trys.pop();continue}u=r.call(i,t)}catch(c){u=[6,c],n=0}finally{e=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}},Tr=V&&V.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},ug=V&&V.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))},pi=V&&V.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(V,"__esModule",{value:!0});V.LinkedList=V.ListItem=V.END=void 0;V.END=Symbol();var sn=(function(){function i(r){r===void 0&&(r=null),this.next=null,this.prev=null,this.data=r}return i})();V.ListItem=sn;var cg=(function(){function i(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];this.list=new sn(V.END),this.list.next=this.list.prev=this.list,this.push.apply(this,ug([],Tr(r),!1))}return i.prototype.isBefore=function(r,t){return r<t},i.prototype.push=function(){for(var r,t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{for(var o=pi(e),a=o.next();!a.done;a=o.next()){var s=a.value,l=new sn(s);l.next=this.list,l.prev=this.list.prev,this.list.prev=l,l.prev.next=l}}catch(u){r={error:u}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}return this},i.prototype.pop=function(){var r=this.list.prev;return r.data===V.END?null:(this.list.prev=r.prev,r.prev.next=this.list,r.next=r.prev=null,r.data)},i.prototype.unshift=function(){for(var r,t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{for(var o=pi(e.slice(0).reverse()),a=o.next();!a.done;a=o.next()){var s=a.value,l=new sn(s);l.next=this.list.next,l.prev=this.list,this.list.next=l,l.next.prev=l}}catch(u){r={error:u}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}return this},i.prototype.shift=function(){var r=this.list.next;return r.data===V.END?null:(this.list.next=r.next,r.next.prev=this.list,r.next=r.prev=null,r.data)},i.prototype.remove=function(){for(var r,t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=new Map;try{for(var a=pi(e),s=a.next();!s.done;s=a.next()){var l=s.value;o.set(l,!0)}}catch(f){r={error:f}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}for(var u=this.list.next;u.data!==V.END;){var c=u.next;o.has(u.data)&&(u.prev.next=u.next,u.next.prev=u.prev,u.next=u.prev=null),u=c}},i.prototype.clear=function(){return this.list.next.prev=this.list.prev.next=null,this.list.next=this.list.prev=this.list,this},i.prototype[Symbol.iterator]=function(){var r;return gu(this,function(t){switch(t.label){case 0:r=this.list.next,t.label=1;case 1:return r.data===V.END?[3,3]:[4,r.data];case 2:return t.sent(),r=r.next,[3,1];case 3:return[2]}})},i.prototype.reversed=function(){var r;return gu(this,function(t){switch(t.label){case 0:r=this.list.prev,t.label=1;case 1:return r.data===V.END?[3,3]:[4,r.data];case 2:return t.sent(),r=r.prev,[3,1];case 3:return[2]}})},i.prototype.insert=function(r,t){t===void 0&&(t=null),t===null&&(t=this.isBefore.bind(this));for(var e=new sn(r),n=this.list.next;n.data!==V.END&&t(n.data,e.data);)n=n.next;return e.prev=n.prev,e.next=n,n.prev.next=n.prev=e,this},i.prototype.sort=function(r){var t,e;r===void 0&&(r=null),r===null&&(r=this.isBefore.bind(this));var n=[];try{for(var o=pi(this),a=o.next();!a.done;a=o.next()){var s=a.value;n.push(new i(s))}}catch(c){t={error:c}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}for(this.list.next=this.list.prev=this.list;n.length>1;){var l=n.shift(),u=n.shift();l.merge(u,r),n.push(l)}return n.length&&(this.list=n[0].list),this},i.prototype.merge=function(r,t){var e,n,o,a,s;t===void 0&&(t=null),t===null&&(t=this.isBefore.bind(this));for(var l=this.list.next,u=r.list.next;l.data!==V.END&&u.data!==V.END;)t(u.data,l.data)?(e=Tr([l,u],2),u.prev.next=e[0],l.prev.next=e[1],n=Tr([l.prev,u.prev],2),u.prev=n[0],l.prev=n[1],o=Tr([r.list,this.list],2),this.list.prev.next=o[0],r.list.prev.next=o[1],a=Tr([r.list.prev,this.list.prev],2),this.list.prev=a[0],r.list.prev=a[1],s=Tr([u.next,l],2),l=s[0],u=s[1]):l=l.next;return u.data!==V.END&&(this.list.prev.next=r.list.next,r.list.next.prev=this.list.prev,r.list.prev.next=this.list,this.list.prev=r.list.prev,r.list.next=r.list.prev=r.list),this},i})();V.LinkedList=cg});var da=m(Nr=>{"use strict";var fg=Nr&&Nr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Nr,"__esModule",{value:!0});Nr.AbstractMathList=void 0;var hg=_u(),pg=(function(i){fg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.isBefore=function(t,e){return t.start.i<e.start.i||t.start.i===e.start.i&&t.start.n<e.start.n},r})(hg.LinkedList);Nr.AbstractMathList=pg});var wu=m(Er=>{"use strict";var dg=Er&&Er.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Er,"__esModule",{value:!0});Er.AbstractNodeFactory=void 0;var yg=Ea(),vg=(function(i){dg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.create=function(t,e,n){return e===void 0&&(e={}),n===void 0&&(n=[]),this.node[t](e,n)},r})(yg.AbstractFactory);Er.AbstractNodeFactory=vg});var Mu=m(Be=>{"use strict";var mg=Be&&Be.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),di=Be&&Be.__assign||function(){return di=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},di.apply(this,arguments)};Object.defineProperty(Be,"__esModule",{value:!0});Be.MmlMstyle=void 0;var xu=C(),ln=yn(),gg=(function(i){mg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"mstyle"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notParent",{get:function(){return this.childNodes[0]&&this.childNodes[0].childNodes.length===1},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){var a=this.attributes.getExplicit("scriptlevel");a!=null&&(a=a.toString(),a.match(/^\s*[-+]/)?n+=parseInt(a):n=parseInt(a),o=!1);var s=this.attributes.getExplicit("displaystyle");s!=null&&(e=s===!0,o=!1);var l=this.attributes.getExplicit("data-cramped");l!=null&&(o=l),t=this.addInheritedAttributes(t,this.attributes.getAllAttributes()),this.childNodes[0].setInheritedAttributes(t,e,n,o)},r.defaults=di(di({},xu.AbstractMmlLayoutNode.defaults),{scriptlevel:ln.INHERIT,displaystyle:ln.INHERIT,scriptsizemultiplier:1/Math.sqrt(2),scriptminsize:"8px",mathbackground:ln.INHERIT,mathcolor:ln.INHERIT,dir:ln.INHERIT,infixlinebreakstyle:"before"}),r})(xu.AbstractMmlLayoutNode);Be.MmlMstyle=gg});var Su=m(Te=>{"use strict";var _g=Te&&Te.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),yi=Te&&Te.__assign||function(){return yi=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},yi.apply(this,arguments)};Object.defineProperty(Te,"__esModule",{value:!0});Te.MmlMaligngroup=void 0;var bu=C(),wg=yn(),xg=(function(i){_g(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"maligngroup"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSpacelike",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setChildInheritedAttributes=function(t,e,n,o){t=this.addInheritedAttributes(t,this.attributes.getAllAttributes()),i.prototype.setChildInheritedAttributes.call(this,t,e,n,o)},r.defaults=yi(yi({},bu.AbstractMmlLayoutNode.defaults),{groupalign:wg.INHERIT}),r})(bu.AbstractMmlLayoutNode);Te.MmlMaligngroup=xg});var ju=m(Ne=>{"use strict";var Mg=Ne&&Ne.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),vi=Ne&&Ne.__assign||function(){return vi=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},vi.apply(this,arguments)};Object.defineProperty(Ne,"__esModule",{value:!0});Ne.MmlMalignmark=void 0;var Ou=C(),bg=(function(i){Mg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"malignmark"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 0},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isSpacelike",{get:function(){return!0},enumerable:!1,configurable:!0}),r.defaults=vi(vi({},Ou.AbstractMmlNode.defaults),{edge:"left"}),r})(Ou.AbstractMmlNode);Ne.MmlMalignmark=bg});var Cu=m(Ee=>{"use strict";var Sg=Ee&&Ee.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),ya=Ee&&Ee.__assign||function(){return ya=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},ya.apply(this,arguments)};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.MathChoice=void 0;var Au=C(),Og=(function(i){Sg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"kind",{get:function(){return"MathChoice"},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"arity",{get:function(){return 4},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notParent",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.setInheritedAttributes=function(t,e,n,o){var a=e?0:Math.max(0,Math.min(n,2))+1,s=this.childNodes[a]||this.factory.create("mrow");this.parent.replaceChild(s,this),s.setInheritedAttributes(t,e,n,o)},r.defaults=ya({},Au.AbstractMmlBaseNode.defaults),r})(Au.AbstractMmlBaseNode);Ee.MathChoice=Og});var Zu=m(wi=>{"use strict";var S;Object.defineProperty(wi,"__esModule",{value:!0});wi.MML=void 0;var mi=C(),Pu=Ii(),Bu=Ji(),Tu=$i(),Nu=Ti(),Eu=eo(),Lu=ao(),ku=Qi(),gi=Xi(),Vu=fo(),qu=vo(),Du=wo(),Gu=Mu(),Iu=io(),Wu=so(),Fu=co(),Ru=xo(),Hu=Uo(),Xu=Jo(),Lr=Gn(),kr=No(),Vr=qo(),zu=Do(),_i=Fo(),Ju=Ho(),Ku=Su(),Uu=ju(),$u=ea(),qr=Qo(),Yu=ia(),Qu=Cu();wi.MML=(S={},S[Pu.MmlMath.prototype.kind]=Pu.MmlMath,S[Bu.MmlMi.prototype.kind]=Bu.MmlMi,S[Tu.MmlMn.prototype.kind]=Tu.MmlMn,S[Nu.MmlMo.prototype.kind]=Nu.MmlMo,S[Eu.MmlMtext.prototype.kind]=Eu.MmlMtext,S[Lu.MmlMspace.prototype.kind]=Lu.MmlMspace,S[ku.MmlMs.prototype.kind]=ku.MmlMs,S[gi.MmlMrow.prototype.kind]=gi.MmlMrow,S[gi.MmlInferredMrow.prototype.kind]=gi.MmlInferredMrow,S[Vu.MmlMfrac.prototype.kind]=Vu.MmlMfrac,S[qu.MmlMsqrt.prototype.kind]=qu.MmlMsqrt,S[Du.MmlMroot.prototype.kind]=Du.MmlMroot,S[Gu.MmlMstyle.prototype.kind]=Gu.MmlMstyle,S[Iu.MmlMerror.prototype.kind]=Iu.MmlMerror,S[Wu.MmlMpadded.prototype.kind]=Wu.MmlMpadded,S[Fu.MmlMphantom.prototype.kind]=Fu.MmlMphantom,S[Ru.MmlMfenced.prototype.kind]=Ru.MmlMfenced,S[Hu.MmlMenclose.prototype.kind]=Hu.MmlMenclose,S[Xu.MmlMaction.prototype.kind]=Xu.MmlMaction,S[Lr.MmlMsub.prototype.kind]=Lr.MmlMsub,S[Lr.MmlMsup.prototype.kind]=Lr.MmlMsup,S[Lr.MmlMsubsup.prototype.kind]=Lr.MmlMsubsup,S[kr.MmlMunder.prototype.kind]=kr.MmlMunder,S[kr.MmlMover.prototype.kind]=kr.MmlMover,S[kr.MmlMunderover.prototype.kind]=kr.MmlMunderover,S[Vr.MmlMmultiscripts.prototype.kind]=Vr.MmlMmultiscripts,S[Vr.MmlMprescripts.prototype.kind]=Vr.MmlMprescripts,S[Vr.MmlNone.prototype.kind]=Vr.MmlNone,S[zu.MmlMtable.prototype.kind]=zu.MmlMtable,S[_i.MmlMlabeledtr.prototype.kind]=_i.MmlMlabeledtr,S[_i.MmlMtr.prototype.kind]=_i.MmlMtr,S[Ju.MmlMtd.prototype.kind]=Ju.MmlMtd,S[Ku.MmlMaligngroup.prototype.kind]=Ku.MmlMaligngroup,S[Uu.MmlMalignmark.prototype.kind]=Uu.MmlMalignmark,S[$u.MmlMglyph.prototype.kind]=$u.MmlMglyph,S[qr.MmlSemantics.prototype.kind]=qr.MmlSemantics,S[qr.MmlAnnotation.prototype.kind]=qr.MmlAnnotation,S[qr.MmlAnnotationXML.prototype.kind]=qr.MmlAnnotationXML,S[Yu.TeXAtom.prototype.kind]=Yu.TeXAtom,S[Qu.MathChoice.prototype.kind]=Qu.MathChoice,S[mi.TextNode.prototype.kind]=mi.TextNode,S[mi.XMLNode.prototype.kind]=mi.XMLNode,S)});var tc=m(Dr=>{"use strict";var jg=Dr&&Dr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Dr,"__esModule",{value:!0});Dr.MmlFactory=void 0;var Ag=wu(),Cg=Zu(),Pg=(function(i){jg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"MML",{get:function(){return this.node},enumerable:!1,configurable:!0}),r.defaultNodes=Cg.MML,r})(Ag.AbstractNodeFactory);Dr.MmlFactory=Pg});var rc=m(Z=>{"use strict";var Bg=Z&&Z.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Tg=Z&&Z.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},Ng=Z&&Z.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Eg=Z&&Z.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(Z,"__esModule",{value:!0});Z.BitFieldClass=Z.BitField=void 0;var ec=(function(){function i(){this.bits=0}return i.allocate=function(){for(var r,t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{for(var o=Tg(e),a=o.next();!a.done;a=o.next()){var s=a.value;if(this.has(s))throw new Error("Bit already allocated for "+s);if(this.next===i.MAXBIT)throw new Error("Maximum number of bits already allocated");this.names.set(s,this.next),this.next<<=1}}catch(l){r={error:l}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(r)throw r.error}}},i.has=function(r){return this.names.has(r)},i.prototype.set=function(r){this.bits|=this.getBit(r)},i.prototype.clear=function(r){this.bits&=~this.getBit(r)},i.prototype.isSet=function(r){return!!(this.bits&this.getBit(r))},i.prototype.reset=function(){this.bits=0},i.prototype.getBit=function(r){var t=this.constructor.names.get(r);if(!t)throw new Error("Unknown bit-field name: "+r);return t},i.MAXBIT=1<<31,i.next=1,i.names=new Map,i})();Z.BitField=ec;function Lg(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];var t=(function(e){Bg(n,e);function n(){return e!==null&&e.apply(this,arguments)||this}return n})(ec);return t.allocate.apply(t,Eg([],Ng(i),!1)),t}Z.BitFieldClass=Lg});var ga=m(I=>{"use strict";var cn=I&&I.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),wt=I&&I.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},Ht=I&&I.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},va=I&&I.__spreadArray||function(i,r,t){if(t||arguments.length===2)for(var e=0,n=r.length,o;e<n;e++)(o||!(e in r))&&(o||(o=Array.prototype.slice.call(r,0,e)),o[e]=r[e]);return i.concat(o||Array.prototype.slice.call(r))};Object.defineProperty(I,"__esModule",{value:!0});I.AbstractMathDocument=I.resetAllOptions=I.resetOptions=I.RenderList=void 0;var un=Xe(),kg=kc(),Vg=Li(),qg=da(),tt=dn(),Dg=tc(),Gg=rc(),Ig=Ec(),ma=(function(i){cn(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.create=function(t){var e,n,o=new this;try{for(var a=wt(Object.keys(t)),s=a.next();!s.done;s=a.next()){var l=s.value,u=Ht(this.action(l,t[l]),2),c=u[0],f=u[1];f&&o.add(c,f)}}catch(h){e={error:h}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return o},r.action=function(t,e){var n,o,a,s,l,u,c=!0,f=e[0];if(e.length===1||typeof e[1]=="boolean")e.length===2&&(c=e[1]),n=Ht(this.methodActions(t),2),l=n[0],u=n[1];else if(typeof e[1]=="string")if(typeof e[2]=="string"){e.length===4&&(c=e[3]);var h=Ht(e.slice(1),2),p=h[0],d=h[1];o=Ht(this.methodActions(p,d),2),l=o[0],u=o[1]}else e.length===3&&(c=e[2]),a=Ht(this.methodActions(e[1]),2),l=a[0],u=a[1];else e.length===4&&(c=e[3]),s=Ht(e.slice(1),2),l=s[0],u=s[1];return[{id:t,renderDoc:l,renderMath:u,convert:c},f]},r.methodActions=function(t,e){return e===void 0&&(e=t),[function(n){return t&&n[t](),!1},function(n,o){return e&&n[e](o),!1}]},r.prototype.renderDoc=function(t,e){var n,o;e===void 0&&(e=tt.STATE.UNPROCESSED);try{for(var a=wt(this.items),s=a.next();!s.done;s=a.next()){var l=s.value;if(l.priority>=e&&l.item.renderDoc(t))return}}catch(u){n={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}},r.prototype.renderMath=function(t,e,n){var o,a;n===void 0&&(n=tt.STATE.UNPROCESSED);try{for(var s=wt(this.items),l=s.next();!l.done;l=s.next()){var u=l.value;if(u.priority>=n&&u.item.renderMath(t,e))return}}catch(c){o={error:c}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(o)throw o.error}}},r.prototype.renderConvert=function(t,e,n){var o,a;n===void 0&&(n=tt.STATE.LAST);try{for(var s=wt(this.items),l=s.next();!l.done;l=s.next()){var u=l.value;if(u.priority>n||u.item.convert&&u.item.renderMath(t,e))return}}catch(c){o={error:c}}finally{try{l&&!l.done&&(a=s.return)&&a.call(s)}finally{if(o)throw o.error}}},r.prototype.findID=function(t){var e,n;try{for(var o=wt(this.items),a=o.next();!a.done;a=o.next()){var s=a.value;if(s.item.id===t)return s.item}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return null},r})(Ig.PrioritizedList);I.RenderList=ma;I.resetOptions={all:!1,processed:!1,inputJax:null,outputJax:null};I.resetAllOptions={all:!0,processed:!0,inputJax:[],outputJax:[]};var Wg=(function(i){cn(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.compile=function(t){return null},r})(kg.AbstractInputJax),Fg=(function(i){cn(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r.prototype.typeset=function(t,e){return e===void 0&&(e=null),null},r.prototype.escaped=function(t,e){return null},r})(Vg.AbstractOutputJax),nc=(function(i){cn(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r})(qg.AbstractMathList),Rg=(function(i){cn(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r})(tt.AbstractMathItem),Hg=(function(){function i(r,t,e){var n=this,o=this.constructor;this.document=r,this.options=(0,un.userOptions)((0,un.defaultOptions)({},o.OPTIONS),e),this.math=new(this.options.MathList||nc),this.renderActions=ma.create(this.options.renderActions),this.processed=new i.ProcessBits,this.outputJax=this.options.OutputJax||new Fg;var a=this.options.InputJax||[new Wg];Array.isArray(a)||(a=[a]),this.inputJax=a,this.adaptor=t,this.outputJax.setAdaptor(t),this.inputJax.map(function(s){return s.setAdaptor(t)}),this.mmlFactory=this.options.MmlFactory||new Dg.MmlFactory,this.inputJax.map(function(s){return s.setMmlFactory(n.mmlFactory)}),this.outputJax.initialize(),this.inputJax.map(function(s){return s.initialize()})}return Object.defineProperty(i.prototype,"kind",{get:function(){return this.constructor.KIND},enumerable:!1,configurable:!0}),i.prototype.addRenderAction=function(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var n=Ht(ma.action(r,t),2),o=n[0],a=n[1];this.renderActions.add(o,a)},i.prototype.removeRenderAction=function(r){var t=this.renderActions.findID(r);t&&this.renderActions.remove(t)},i.prototype.render=function(){return this.renderActions.renderDoc(this),this},i.prototype.rerender=function(r){return r===void 0&&(r=tt.STATE.RERENDER),this.state(r-1),this.render(),this},i.prototype.convert=function(r,t){t===void 0&&(t={});var e=(0,un.userOptions)({format:this.inputJax[0].name,display:!0,end:tt.STATE.LAST,em:16,ex:8,containerWidth:null,lineWidth:1e6,scale:1,family:""},t),n=e.format,o=e.display,a=e.end,s=e.ex,l=e.em,u=e.containerWidth,c=e.lineWidth,f=e.scale,h=e.family;u===null&&(u=80*s);var p=this.inputJax.reduce(function(y,v){return v.name===n?v:y},null),d=new this.options.MathItem(r,p,o);return d.start.node=this.adaptor.body(this.document),d.setMetrics(l,s,u,c,f),this.outputJax.options.mtextInheritFont&&(d.outputData.mtextFamily=h),this.outputJax.options.merrorInheritFont&&(d.outputData.merrorFamily=h),d.convert(this,a),d.typesetRoot||d.root},i.prototype.findMath=function(r){return r===void 0&&(r=null),this.processed.set("findMath"),this},i.prototype.compile=function(){var r,t,e,n;if(!this.processed.isSet("compile")){var o=[];try{for(var a=wt(this.math),s=a.next();!s.done;s=a.next()){var l=s.value;this.compileMath(l),l.inputData.recompile!==void 0&&o.push(l)}}catch(h){r={error:h}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}try{for(var u=wt(o),c=u.next();!c.done;c=u.next()){var l=c.value,f=l.inputData.recompile;l.state(f.state),l.inputData.recompile=f,this.compileMath(l)}}catch(h){e={error:h}}finally{try{c&&!c.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}this.processed.set("compile")}return this},i.prototype.compileMath=function(r){try{r.compile(this)}catch(t){if(t.retry||t.restart)throw t;this.options.compileError(this,r,t),r.inputData.error=t}},i.prototype.compileError=function(r,t){r.root=this.mmlFactory.create("math",null,[this.mmlFactory.create("merror",{"data-mjx-error":t.message,title:t.message},[this.mmlFactory.create("mtext",null,[this.mmlFactory.create("text").setText("Math input error")])])]),r.display&&r.root.attributes.set("display","block"),r.inputData.error=t.message},i.prototype.typeset=function(){var r,t;if(!this.processed.isSet("typeset")){try{for(var e=wt(this.math),n=e.next();!n.done;n=e.next()){var o=n.value;try{o.typeset(this)}catch(a){if(a.retry||a.restart)throw a;this.options.typesetError(this,o,a),o.outputData.error=a}}}catch(a){r={error:a}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(r)throw r.error}}this.processed.set("typeset")}return this},i.prototype.typesetError=function(r,t){r.typesetRoot=this.adaptor.node("mjx-container",{class:"MathJax mjx-output-error",jax:this.outputJax.name},[this.adaptor.node("span",{"data-mjx-error":t.message,title:t.message,style:{color:"red","background-color":"yellow","line-height":"normal"}},[this.adaptor.text("Math output error")])]),r.display&&this.adaptor.setAttributes(r.typesetRoot,{style:{display:"block",margin:"1em 0","text-align":"center"}}),r.outputData.error=t.message},i.prototype.getMetrics=function(){return this.processed.isSet("getMetrics")||(this.outputJax.getMetrics(this),this.processed.set("getMetrics")),this},i.prototype.updateDocument=function(){var r,t;if(!this.processed.isSet("updateDocument")){try{for(var e=wt(this.math.reversed()),n=e.next();!n.done;n=e.next()){var o=n.value;o.updateDocument(this)}}catch(a){r={error:a}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(r)throw r.error}}this.processed.set("updateDocument")}return this},i.prototype.removeFromDocument=function(r){return r===void 0&&(r=!1),this},i.prototype.state=function(r,t){var e,n;t===void 0&&(t=!1);try{for(var o=wt(this.math),a=o.next();!a.done;a=o.next()){var s=a.value;s.state(r,t)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return r<tt.STATE.INSERTED&&this.processed.clear("updateDocument"),r<tt.STATE.TYPESET&&(this.processed.clear("typeset"),this.processed.clear("getMetrics")),r<tt.STATE.COMPILED&&this.processed.clear("compile"),this},i.prototype.reset=function(r){var t;return r===void 0&&(r={processed:!0}),r=(0,un.userOptions)(Object.assign({},I.resetOptions),r),r.all&&Object.assign(r,I.resetAllOptions),r.processed&&this.processed.reset(),r.inputJax&&this.inputJax.forEach(function(e){return e.reset.apply(e,va([],Ht(r.inputJax),!1))}),r.outputJax&&(t=this.outputJax).reset.apply(t,va([],Ht(r.outputJax),!1)),this},i.prototype.clear=function(){return this.reset(),this.math.clear(),this},i.prototype.concat=function(r){return this.math.merge(r),this},i.prototype.clearMathItemsWithin=function(r){var t,e=this.getMathItemsWithin(r);return(t=this.math).remove.apply(t,va([],Ht(e),!1)),e},i.prototype.getMathItemsWithin=function(r){var t,e,n,o;Array.isArray(r)||(r=[r]);var a=this.adaptor,s=[],l=a.getElements(r,this.document);try{t:for(var u=wt(this.math),c=u.next();!c.done;c=u.next()){var f=c.value;try{for(var h=(n=void 0,wt(l)),p=h.next();!p.done;p=h.next()){var d=p.value;if(f.start.node&&a.contains(d,f.start.node)){s.push(f);continue t}}}catch(y){n={error:y}}finally{try{p&&!p.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}return s},i.KIND="MathDocument",i.OPTIONS={OutputJax:null,InputJax:null,MmlFactory:null,MathList:nc,MathItem:Rg,compileError:function(r,t,e){r.compileError(t,e)},typesetError:function(r,t,e){r.typesetError(t,e)},renderActions:(0,un.expandable)({find:[tt.STATE.FINDMATH,"findMath","",!1],compile:[tt.STATE.COMPILED],metrics:[tt.STATE.METRICS,"getMetrics","",!1],typeset:[tt.STATE.TYPESET],update:[tt.STATE.INSERTED,"updateDocument",!1]})},i.ProcessBits=(0,Gg.BitFieldClass)("findMath","compile","getMetrics","typeset","updateDocument"),i})();I.AbstractMathDocument=Hg});var ic=m(Gr=>{"use strict";var Xg=Gr&&Gr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Gr,"__esModule",{value:!0});Gr.AbstractHandler=void 0;var zg=ga(),Jg=(function(i){Xg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r})(zg.AbstractMathDocument),Kg=(function(){function i(r,t){t===void 0&&(t=5),this.documentClass=Jg,this.adaptor=r,this.priority=t}return Object.defineProperty(i.prototype,"name",{get:function(){return this.constructor.NAME},enumerable:!1,configurable:!0}),i.prototype.handlesDocument=function(r){return!1},i.prototype.create=function(r,t){return new this.documentClass(r,this.adaptor,t)},i.NAME="generic",i})();Gr.AbstractHandler=Kg});var oc=m(Ir=>{"use strict";var Ug=Ir&&Ir.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Ir,"__esModule",{value:!0});Ir.HTMLMathItem=void 0;var xi=dn(),$g=(function(i){Ug(r,i);function r(t,e,n,o,a){return n===void 0&&(n=!0),o===void 0&&(o={node:null,n:0,delim:""}),a===void 0&&(a={node:null,n:0,delim:""}),i.call(this,t,e,n,o,a)||this}return Object.defineProperty(r.prototype,"adaptor",{get:function(){return this.inputJax.adaptor},enumerable:!1,configurable:!0}),r.prototype.updateDocument=function(t){if(this.state()<xi.STATE.INSERTED){if(this.inputJax.processStrings){var e=this.start.node;if(e===this.end.node)this.end.n&&this.end.n<this.adaptor.value(this.end.node).length&&this.adaptor.split(this.end.node,this.end.n),this.start.n&&(e=this.adaptor.split(this.start.node,this.start.n)),this.adaptor.replace(this.typesetRoot,e);else{for(this.start.n&&(e=this.adaptor.split(e,this.start.n));e!==this.end.node;){var n=this.adaptor.next(e);this.adaptor.remove(e),e=n}this.adaptor.insert(this.typesetRoot,e),this.end.n<this.adaptor.value(e).length&&this.adaptor.split(e,this.end.n),this.adaptor.remove(e)}}else this.adaptor.replace(this.typesetRoot,this.start.node);this.start.node=this.end.node=this.typesetRoot,this.start.n=this.end.n=0,this.state(xi.STATE.INSERTED)}},r.prototype.updateStyleSheet=function(t){t.addStyleSheet()},r.prototype.removeFromDocument=function(t){if(t===void 0&&(t=!1),this.state()>=xi.STATE.TYPESET){var e=this.adaptor,n=this.start.node,o=e.text("");if(t){var a=this.start.delim+this.math+this.end.delim;if(this.inputJax.processStrings)o=e.text(a);else{var s=e.parse(a,"text/html");o=e.firstChild(e.body(s))}}e.parent(n)&&e.replace(o,n),this.start.node=this.end.node=o,this.start.n=this.end.n=0}},r})(xi.AbstractMathItem);Ir.HTMLMathItem=$g});var ac=m(Wr=>{"use strict";var Yg=Wr&&Wr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Wr,"__esModule",{value:!0});Wr.HTMLMathList=void 0;var Qg=da(),Zg=(function(i){Yg(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r})(Qg.AbstractMathList);Wr.HTMLMathList=Zg});var lc=m(Fr=>{"use strict";var sc=Fr&&Fr.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o};Object.defineProperty(Fr,"__esModule",{value:!0});Fr.HTMLDomStrings=void 0;var fn=Xe(),t_=(function(){function i(r){r===void 0&&(r=null);var t=this.constructor;this.options=(0,fn.userOptions)((0,fn.defaultOptions)({},t.OPTIONS),r),this.init(),this.getPatterns()}return i.prototype.init=function(){this.strings=[],this.string="",this.snodes=[],this.nodes=[],this.stack=[]},i.prototype.getPatterns=function(){var r=(0,fn.makeArray)(this.options.skipHtmlTags),t=(0,fn.makeArray)(this.options.ignoreHtmlClass),e=(0,fn.makeArray)(this.options.processHtmlClass);this.skipHtmlTags=new RegExp("^(?:"+r.join("|")+")$","i"),this.ignoreHtmlClass=new RegExp("(?:^| )(?:"+t.join("|")+")(?: |$)"),this.processHtmlClass=new RegExp("(?:^| )(?:"+e+")(?: |$)")},i.prototype.pushString=function(){this.string.match(/\S/)&&(this.strings.push(this.string),this.nodes.push(this.snodes)),this.string="",this.snodes=[]},i.prototype.extendString=function(r,t){this.snodes.push([r,t.length]),this.string+=t},i.prototype.handleText=function(r,t){return t||this.extendString(r,this.adaptor.value(r)),this.adaptor.next(r)},i.prototype.handleTag=function(r,t){if(!t){var e=this.options.includeHtmlTags[this.adaptor.kind(r)];this.extendString(r,e)}return this.adaptor.next(r)},i.prototype.handleContainer=function(r,t){this.pushString();var e=this.adaptor.getAttribute(r,"class")||"",n=this.adaptor.kind(r)||"",o=this.processHtmlClass.exec(e),a=r;return this.adaptor.firstChild(r)&&!this.adaptor.getAttribute(r,"data-MJX")&&(o||!this.skipHtmlTags.exec(n))?(this.adaptor.next(r)&&this.stack.push([this.adaptor.next(r),t]),a=this.adaptor.firstChild(r),t=(t||this.ignoreHtmlClass.exec(e))&&!o):a=this.adaptor.next(r),[a,t]},i.prototype.handleOther=function(r,t){return this.pushString(),this.adaptor.next(r)},i.prototype.find=function(r){var t,e;this.init();for(var n=this.adaptor.next(r),o=!1,a=this.options.includeHtmlTags;r&&r!==n;){var s=this.adaptor.kind(r);s==="#text"?r=this.handleText(r,o):a.hasOwnProperty(s)?r=this.handleTag(r,o):s?(t=sc(this.handleContainer(r,o),2),r=t[0],o=t[1]):r=this.handleOther(r,o),!r&&this.stack.length&&(this.pushString(),e=sc(this.stack.pop(),2),r=e[0],o=e[1])}this.pushString();var l=[this.strings,this.nodes];return this.init(),l},i.OPTIONS={skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml"],includeHtmlTags:{br:`
14`,wbr:"","#comment":""},ignoreHtmlClass:"mathjax_ignore",processHtmlClass:"mathjax_process"},i})();Fr.HTMLDomStrings=t_});var cc=m(xt=>{"use strict";var e_=xt&&xt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Rr=xt&&xt.__assign||function(){return Rr=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Rr.apply(this,arguments)},Mi=xt&&xt.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Re=xt&&xt.__values||function(i){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&i[r],e=0;if(t)return t.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&e>=i.length&&(i=void 0),{value:i&&i[e++],done:!i}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(xt,"__esModule",{value:!0});xt.HTMLDocument=void 0;var _a=ga(),wa=Xe(),r_=oc(),n_=ac(),uc=lc(),xa=dn(),i_=(function(i){e_(r,i);function r(t,e,n){var o=this,a=Mi((0,wa.separateOptions)(n,uc.HTMLDomStrings.OPTIONS),2),s=a[0],l=a[1];return o=i.call(this,t,e,s)||this,o.domStrings=o.options.DomStrings||new uc.HTMLDomStrings(l),o.domStrings.adaptor=e,o.styles=[],o}return r.prototype.findPosition=function(t,e,n,o){var a,s,l=this.adaptor;try{for(var u=Re(o[t]),c=u.next();!c.done;c=u.next()){var f=c.value,h=Mi(f,2),p=h[0],d=h[1];if(e<=d&&l.kind(p)==="#text")return{node:p,n:Math.max(e,0),delim:n};e-=d}}catch(y){a={error:y}}finally{try{c&&!c.done&&(s=u.return)&&s.call(u)}finally{if(a)throw a.error}}return{node:null,n:0,delim:n}},r.prototype.mathItem=function(t,e,n){var o=t.math,a=this.findPosition(t.n,t.start.n,t.open,n),s=this.findPosition(t.n,t.end.n,t.close,n);return new this.options.MathItem(o,e,t.display,a,s)},r.prototype.findMath=function(t){var e,n,o,a,s,l,u,c,f;if(!this.processed.isSet("findMath")){this.adaptor.document=this.document,t=(0,wa.userOptions)({elements:this.options.elements||[this.adaptor.body(this.document)]},t);try{for(var h=Re(this.adaptor.getElements(t.elements,this.document)),p=h.next();!p.done;p=h.next()){var d=p.value,y=Mi([null,null],2),v=y[0],_=y[1];try{for(var g=(o=void 0,Re(this.inputJax)),w=g.next();!w.done;w=g.next()){var M=w.value,b=new this.options.MathList;if(M.processStrings){v===null&&(s=Mi(this.domStrings.find(d),2),v=s[0],_=s[1]);try{for(var P=(l=void 0,Re(M.findMath(v))),B=P.next();!B.done;B=P.next()){var E=B.value;b.push(this.mathItem(E,M,_))}}catch(D){l={error:D}}finally{try{B&&!B.done&&(u=P.return)&&u.call(P)}finally{if(l)throw l.error}}}else try{for(var T=(c=void 0,Re(M.findMath(d))),A=T.next();!A.done;A=T.next()){var E=A.value,G=new this.options.MathItem(E.math,M,E.display,E.start,E.end);b.push(G)}}catch(D){c={error:D}}finally{try{A&&!A.done&&(f=T.return)&&f.call(T)}finally{if(c)throw c.error}}this.math.merge(b)}}catch(D){o={error:D}}finally{try{w&&!w.done&&(a=g.return)&&a.call(g)}finally{if(o)throw o.error}}}}catch(D){e={error:D}}finally{try{p&&!p.done&&(n=h.return)&&n.call(h)}finally{if(e)throw e.error}}this.processed.set("findMath")}return this},r.prototype.updateDocument=function(){return this.processed.isSet("updateDocument")||(this.addPageElements(),this.addStyleSheet(),i.prototype.updateDocument.call(this),this.processed.set("updateDocument")),this},r.prototype.addPageElements=function(){var t=this.adaptor.body(this.document),e=this.documentPageElements();e&&this.adaptor.append(t,e)},r.prototype.addStyleSheet=function(){var t=this.documentStyleSheet(),e=this.adaptor;if(t&&!e.parent(t)){var n=e.head(this.document),o=this.findSheet(n,e.getAttribute(t,"id"));o?e.replace(t,o):e.append(n,t)}},r.prototype.findSheet=function(t,e){var n,o;if(e)try{for(var a=Re(this.adaptor.tags(t,"style")),s=a.next();!s.done;s=a.next()){var l=s.value;if(this.adaptor.getAttribute(l,"id")===e)return l}}catch(u){n={error:u}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return null},r.prototype.removeFromDocument=function(t){var e,n;if(t===void 0&&(t=!1),this.processed.isSet("updateDocument"))try{for(var o=Re(this.math),a=o.next();!a.done;a=o.next()){var s=a.value;s.state()>=xa.STATE.INSERTED&&s.state(xa.STATE.TYPESET,t)}}catch(l){e={error:l}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return this.processed.clear("updateDocument"),this},r.prototype.documentStyleSheet=function(){return this.outputJax.styleSheet(this)},r.prototype.documentPageElements=function(){return this.outputJax.pageElements(this)},r.prototype.addStyles=function(t){this.styles.push(t)},r.prototype.getStyles=function(){return this.styles},r.KIND="HTML",r.OPTIONS=Rr(Rr({},_a.AbstractMathDocument.OPTIONS),{renderActions:(0,wa.expandable)(Rr(Rr({},_a.AbstractMathDocument.OPTIONS.renderActions),{styles:[xa.STATE.INSERTED+1,"","updateStyleSheet",!1]})),MathList:n_.HTMLMathList,MathItem:r_.HTMLMathItem,DomStrings:null}),r})(_a.AbstractMathDocument);xt.HTMLDocument=i_});var fc=m(Hr=>{"use strict";var o_=Hr&&Hr.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})();Object.defineProperty(Hr,"__esModule",{value:!0});Hr.HTMLHandler=void 0;var a_=ic(),s_=cc(),l_=(function(i){o_(r,i);function r(){var t=i!==null&&i.apply(this,arguments)||this;return t.documentClass=s_.HTMLDocument,t}return r.prototype.handlesDocument=function(t){var e=this.adaptor;if(typeof t=="string")try{t=e.parse(t,"text/html")}catch{}return t instanceof e.window.Document||t instanceof e.window.HTMLElement||t instanceof e.window.DocumentFragment},r.prototype.create=function(t,e){var n=this.adaptor;if(typeof t=="string")t=n.parse(t,"text/html");else if(t instanceof n.window.HTMLElement||t instanceof n.window.DocumentFragment){var o=t;t=n.parse("","text/html"),n.append(n.body(t),o)}return i.prototype.create.call(this,t,e)},r})(a_.AbstractHandler);Hr.HTMLHandler=l_});var hc=m(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.RegisterHTMLHandler=void 0;var u_=Ba(),c_=fc();function f_(i){var r=new c_.HTMLHandler(i);return u_.mathjax.handlers.register(r),r}bi.RegisterHTMLHandler=f_});var vc=m(bt=>{"use strict";var pc=bt&&bt.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),ba=bt&&bt.__assign||function(){return ba=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},ba.apply(this,arguments)},Sa=bt&&bt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(bt,"__esModule",{value:!0});bt.FlalignItem=bt.MultlineItem=void 0;var dc=Wc(),h_=Sa(Ni()),Mt=Sa(Ta()),yc=Sa(Na()),Ma=Ei(),p_=(function(i){pc(r,i);function r(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var o=i.call(this,t)||this;return o.factory.configuration.tags.start("multline",!0,e[0]),o}return Object.defineProperty(r.prototype,"kind",{get:function(){return"multline"},enumerable:!1,configurable:!0}),r.prototype.EndEntry=function(){this.table.length&&h_.default.fixInitialMO(this.factory.configuration,this.nodes);var t=this.getProperty("shove"),e=this.create("node","mtd",this.nodes,t?{columnalign:t}:{});this.setProperty("shove",null),this.row.push(e),this.Clear()},r.prototype.EndRow=function(){if(this.row.length!==1)throw new yc.default("MultlineRowsOneCol","The rows within the %1 environment must have exactly one column","multline");var t=this.create("node","mtr",this.row);this.table.push(t),this.row=[]},r.prototype.EndTable=function(){if(i.prototype.EndTable.call(this),this.table.length){var t=this.table.length-1,e=-1;Mt.default.getAttribute(Mt.default.getChildren(this.table[0])[0],"columnalign")||Mt.default.setAttribute(Mt.default.getChildren(this.table[0])[0],"columnalign",Ma.TexConstant.Align.LEFT),Mt.default.getAttribute(Mt.default.getChildren(this.table[t])[0],"columnalign")||Mt.default.setAttribute(Mt.default.getChildren(this.table[t])[0],"columnalign",Ma.TexConstant.Align.RIGHT);var n=this.factory.configuration.tags.getTag();if(n){e=this.arraydef.side===Ma.TexConstant.Align.LEFT?0:this.table.length-1;var o=this.table[e],a=this.create("node","mlabeledtr",[n].concat(Mt.default.getChildren(o)));Mt.default.copyAttributes(o,a),this.table[e]=a}}this.factory.configuration.tags.end()},r})(dc.ArrayItem);bt.MultlineItem=p_;var d_=(function(i){pc(r,i);function r(t,e,n,o,a){var s=i.call(this,t)||this;return s.name=e,s.numbered=n,s.padded=o,s.center=a,s.factory.configuration.tags.start(e,n,n),s}return Object.defineProperty(r.prototype,"kind",{get:function(){return"flalign"},enumerable:!1,configurable:!0}),r.prototype.EndEntry=function(){i.prototype.EndEntry.call(this);var t=this.getProperty("xalignat");if(t&&this.row.length>t)throw new yc.default("XalignOverflow","Extra %1 in row of %2","&",this.name)},r.prototype.EndRow=function(){for(var t,e=this.row,n=this.getProperty("xalignat");e.length<n;)e.push(this.create("node","mtd"));for(this.row=[],this.padded&&this.row.push(this.create("node","mtd"));t=e.shift();)this.row.push(t),t=e.shift(),t&&this.row.push(t),(e.length||this.padded)&&this.row.push(this.create("node","mtd"));this.row.length>this.maxrow&&(this.maxrow=this.row.length),i.prototype.EndRow.call(this);var o=this.table[this.table.length-1];if(this.getProperty("zeroWidthLabel")&&o.isKind("mlabeledtr")){var a=Mt.default.getChildren(o)[0],s=this.factory.configuration.options.tagSide,l=ba({width:0},s==="right"?{lspace:"-1width"}:{}),u=this.create("node","mpadded",Mt.default.getChildren(a),l);a.setChildren([u])}},r.prototype.EndTable=function(){if(i.prototype.EndTable.call(this),this.center&&this.maxrow<=2){var t=this.arraydef;delete t.width,delete this.global.indentalign}},r})(dc.EqnArrayItem);bt.FlalignItem=d_});var Aa=m(O=>{"use strict";var Si=O&&O.__assign||function(){return Si=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},Si.apply(this,arguments)},mc=O&&O.__read||function(i,r){var t=typeof Symbol=="function"&&i[Symbol.iterator];if(!t)return i;var e=t.call(i),n,o=[],a;try{for(;(r===void 0||r-- >0)&&!(n=e.next()).done;)o.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=e.return)&&t.call(e)}finally{if(a)throw a.error}}return o},Xr=O&&O.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(O,"__esModule",{value:!0});O.NEW_OPS=O.AmsMethods=void 0;var rt=Xr(Ni()),y_=Xr(ka()),q=Xr(Ta()),Oa=Ei(),Oi=Xr(qc()),Le=Xr(Na()),v_=Ic(),Ot=Xr(Fc()),ja=C();O.AmsMethods={};O.AmsMethods.AmsEqnArray=function(i,r,t,e,n,o,a){var s=i.GetBrackets("\\begin{"+r.getName()+"}"),l=Ot.default.EqnArray(i,r,t,e,n,o,a);return rt.default.setArrayAlign(l,s)};O.AmsMethods.AlignAt=function(i,r,t,e){var n=r.getName(),o,a,s="",l=[];if(e||(a=i.GetBrackets("\\begin{"+n+"}")),o=i.GetArgument("\\begin{"+n+"}"),o.match(/[^0-9]/))throw new Le.default("PositiveIntegerArg","Argument to %1 must me a positive integer","\\begin{"+n+"}");for(var u=parseInt(o,10);u>0;)s+="rl",l.push("0em 0em"),u--;var c=l.join(" ");if(e)return O.AmsMethods.EqnArray(i,r,t,e,s,c);var f=O.AmsMethods.EqnArray(i,r,t,e,s,c);return rt.default.setArrayAlign(f,a)};O.AmsMethods.Multline=function(i,r,t){i.Push(r),rt.default.checkEqnEnv(i);var e=i.itemFactory.create("multline",t,i.stack);return e.arraydef={displaystyle:!0,rowspacing:".5em",columnspacing:"100%",width:i.options.ams.multlineWidth,side:i.options.tagSide,minlabelspacing:i.options.tagIndent,framespacing:i.options.ams.multlineIndent+" 0",frame:"","data-width-includes-label":!0},e};O.AmsMethods.XalignAt=function(i,r,t,e){var n=i.GetArgument("\\begin{"+r.getName()+"}");if(n.match(/[^0-9]/))throw new Le.default("PositiveIntegerArg","Argument to %1 must me a positive integer","\\begin{"+r.getName()+"}");var o=e?"crl":"rlc",a=e?"fit auto auto":"auto auto fit",s=O.AmsMethods.FlalignArray(i,r,t,e,!1,o,a,!0);return s.setProperty("xalignat",2*parseInt(n)),s};O.AmsMethods.FlalignArray=function(i,r,t,e,n,o,a,s){s===void 0&&(s=!1),i.Push(r),rt.default.checkEqnEnv(i),o=o.split("").join(" ").replace(/r/g,"right").replace(/l/g,"left").replace(/c/g,"center");var l=i.itemFactory.create("flalign",r.getName(),t,e,n,i.stack);return l.arraydef={width:"100%",displaystyle:!0,columnalign:o,columnspacing:"0em",columnwidth:a,rowspacing:"3pt",side:i.options.tagSide,minlabelspacing:s?"0":i.options.tagIndent,"data-width-includes-label":!0},l.setProperty("zeroWidthLabel",s),l};O.NEW_OPS="ams-declare-ops";O.AmsMethods.HandleDeclareOp=function(i,r){var t=i.GetStar()?"*":"",e=rt.default.trimSpaces(i.GetArgument(r));e.charAt(0)==="\\"&&(e=e.substr(1));var n=i.GetArgument(r);i.configuration.handlers.retrieve(O.NEW_OPS).add(e,new v_.Macro(e,O.AmsMethods.Macro,["\\operatorname".concat(t,"{").concat(n,"}")]))};O.AmsMethods.HandleOperatorName=function(i,r){var t=i.GetStar(),e=rt.default.trimSpaces(i.GetArgument(r)),n=new Oi.default(e,Si(Si({},i.stack.env),{font:Oa.TexConstant.Variant.NORMAL,multiLetterIdentifiers:/^[-*a-z]+/i,operatorLetters:!0}),i.configuration).mml();if(n.isKind("mi")||(n=i.create("node","TeXAtom",[n])),q.default.setProperties(n,{movesupsub:t,movablelimits:!0,texClass:ja.TEXCLASS.OP}),!t){var o=i.GetNext(),a=i.i;o==="\\"&&++i.i&&i.GetCS()!=="limits"&&(i.i=a)}i.Push(n)};O.AmsMethods.SideSet=function(i,r){var t=mc(gc(i.ParseArg(r)),2),e=t[0],n=t[1],o=mc(gc(i.ParseArg(r)),2),a=o[0],s=o[1],l=i.ParseArg(r),u=l;e&&(n?e.replaceChild(i.create("node","mphantom",[i.create("node","mpadded",[rt.default.copyNode(l,i)],{width:0})]),q.default.getChildAt(e,0)):(u=i.create("node","mmultiscripts",[l]),a&&q.default.appendChildren(u,[q.default.getChildAt(a,1)||i.create("node","none"),q.default.getChildAt(a,2)||i.create("node","none")]),q.default.setProperty(u,"scriptalign","left"),q.default.appendChildren(u,[i.create("node","mprescripts"),q.default.getChildAt(e,1)||i.create("node","none"),q.default.getChildAt(e,2)||i.create("node","none")]))),a&&u===l&&(a.replaceChild(l,q.default.getChildAt(a,0)),u=a);var c=i.create("node","TeXAtom",[],{texClass:ja.TEXCLASS.OP,movesupsub:!0,movablelimits:!0});n&&(e&&c.appendChild(e),c.appendChild(n)),c.appendChild(u),s&&c.appendChild(s),i.Push(c)};function gc(i){if(!i||i.isInferred&&i.childNodes.length===0)return[null,null];if(i.isKind("msubsup")&&_c(i))return[i,null];var r=q.default.getChildAt(i,0);return i.isInferred&&r&&_c(r)?(i.childNodes.splice(0,1),[r,i]):[null,i]}function _c(i){var r=i.childNodes[0];return r&&r.isKind("mi")&&r.getText()===""}O.AmsMethods.operatorLetter=function(i,r){return i.stack.env.operatorLetters?y_.default.variable(i,r):!1};O.AmsMethods.MultiIntegral=function(i,r,t){var e=i.GetNext();if(e==="\\"){var n=i.i;e=i.GetArgument(r),i.i=n,e==="\\limits"&&(r==="\\idotsint"?t="\\!\\!\\mathop{\\,\\,"+t+"}":t="\\!\\!\\!\\mathop{\\,\\,\\,"+t+"}")}i.string=t+" "+i.string.slice(i.i),i.i=0};O.AmsMethods.xArrow=function(i,r,t,e,n){var o={width:"+"+rt.default.Em((e+n)/18),lspace:rt.default.Em(e/18)},a=i.GetBrackets(r),s=i.ParseArg(r),l=i.create("node","mspace",[],{depth:".25em"}),u=i.create("token","mo",{stretchy:!0,texClass:ja.TEXCLASS.REL},String.fromCodePoint(t));u=i.create("node","mstyle",[u],{scriptlevel:0});var c=i.create("node","munderover",[u]),f=i.create("node","mpadded",[s,l],o);if(q.default.setAttribute(f,"voffset","-.2em"),q.default.setAttribute(f,"height","-.2em"),q.default.setChild(c,c.over,f),a){var h=new Oi.default(a,i.stack.env,i.configuration).mml(),p=i.create("node","mspace",[],{height:".75em"});f=i.create("node","mpadded",[h,p],o),q.default.setAttribute(f,"voffset",".15em"),q.default.setAttribute(f,"depth","-.15em"),q.default.setChild(c,c.under,f)}q.default.setProperty(c,"subsupOK",!0),i.Push(c)};O.AmsMethods.HandleShove=function(i,r,t){var e=i.stack.Top();if(e.kind!=="multline")throw new Le.default("CommandOnlyAllowedInEnv","%1 only allowed in %2 environment",i.currentCS,"multline");if(e.Size())throw new Le.default("CommandAtTheBeginingOfLine","%1 must come at the beginning of the line",i.currentCS);e.setProperty("shove",t)};O.AmsMethods.CFrac=function(i,r){var t=rt.default.trimSpaces(i.GetBrackets(r,"")),e=i.GetArgument(r),n=i.GetArgument(r),o={l:Oa.TexConstant.Align.LEFT,r:Oa.TexConstant.Align.RIGHT,"":""},a=new Oi.default("\\strut\\textstyle{"+e+"}",i.stack.env,i.configuration).mml(),s=new Oi.default("\\strut\\textstyle{"+n+"}",i.stack.env,i.configuration).mml(),l=i.create("node","mfrac",[a,s]);if(t=o[t],t==null)throw new Le.default("IllegalAlign","Illegal alignment specified in %1",i.currentCS);t&&q.default.setProperties(l,{numalign:t,denomalign:t}),i.Push(l)};O.AmsMethods.Genfrac=function(i,r,t,e,n,o){t==null&&(t=i.GetDelimiterArg(r)),e==null&&(e=i.GetDelimiterArg(r)),n==null&&(n=i.GetArgument(r)),o==null&&(o=rt.default.trimSpaces(i.GetArgument(r)));var a=i.ParseArg(r),s=i.ParseArg(r),l=i.create("node","mfrac",[a,s]);if(n!==""&&q.default.setAttribute(l,"linethickness",n),(t||e)&&(q.default.setProperty(l,"withDelims",!0),l=rt.default.fixedFence(i.configuration,t,l,e)),o!==""){var u=parseInt(o,10),c=["D","T","S","SS"][u];if(c==null)throw new Le.default("BadMathStyleFor","Bad math style for %1",i.currentCS);l=i.create("node","mstyle",[l]),c==="D"?q.default.setProperties(l,{displaystyle:!0,scriptlevel:0}):q.default.setProperties(l,{displaystyle:!1,scriptlevel:u-1})}i.Push(l)};O.AmsMethods.HandleTag=function(i,r){if(!i.tags.currentTag.taggable&&i.tags.env)throw new Le.default("CommandNotAllowedInEnv","%1 not allowed in %2 environment",i.currentCS,i.tags.env);if(i.tags.currentTag.tag)throw new Le.default("MultipleCommand","Multiple %1",i.currentCS);var t=i.GetStar(),e=rt.default.trimSpaces(i.GetArgument(r));i.tags.tag(e,t)};O.AmsMethods.HandleNoTag=Ot.default.HandleNoTag;O.AmsMethods.HandleRef=Ot.default.HandleRef;O.AmsMethods.Macro=Ot.default.Macro;O.AmsMethods.Accent=Ot.default.Accent;O.AmsMethods.Tilde=Ot.default.Tilde;O.AmsMethods.Array=Ot.default.Array;O.AmsMethods.Spacer=Ot.default.Spacer;O.AmsMethods.NamedOp=Ot.default.NamedOp;O.AmsMethods.EqnArray=Ot.default.EqnArray;O.AmsMethods.Equation=Ot.default.Equation});var xc=m(Xt=>{"use strict";var m_=Xt&&Xt.__createBinding||(Object.create?(function(i,r,t,e){e===void 0&&(e=t);var n=Object.getOwnPropertyDescriptor(r,t);(!n||("get"in n?!r.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(i,e,n)}):(function(i,r,t,e){e===void 0&&(e=t),i[e]=r[t]})),g_=Xt&&Xt.__setModuleDefault||(Object.create?(function(i,r){Object.defineProperty(i,"default",{enumerable:!0,value:r})}):function(i,r){i.default=r}),__=Xt&&Xt.__importStar||function(i){if(i&&i.__esModule)return i;var r={};if(i!=null)for(var t in i)t!=="default"&&Object.prototype.hasOwnProperty.call(i,t)&&m_(r,i,t);return g_(r,i),r},wc=Xt&&Xt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Xt,"__esModule",{value:!0});var ji=Aa(),Qt=__(La()),U=Ei(),zr=wc(ka()),He=wc(Ni()),hn=C(),Ca=Kr();new Qt.CharacterMap("AMSmath-mathchar0mo",zr.default.mathchar0mo,{iiiint:["\u2A0C",{texClass:hn.TEXCLASS.OP}]});new Qt.RegExpMap("AMSmath-operatorLetter",ji.AmsMethods.operatorLetter,/[-*]/i);new Qt.CommandMap("AMSmath-macros",{mathring:["Accent","02DA"],nobreakspace:"Tilde",negmedspace:["Spacer",Ca.MATHSPACE.negativemediummathspace],negthickspace:["Spacer",Ca.MATHSPACE.negativethickmathspace],idotsint:["MultiIntegral","\\int\\cdots\\int"],dddot:["Accent","20DB"],ddddot:["Accent","20DC"],sideset:"SideSet",boxed:["Macro","\\fbox{$\\displaystyle{#1}$}",1],tag:"HandleTag",notag:"HandleNoTag",eqref:["HandleRef",!0],substack:["Macro","\\begin{subarray}{c}#1\\end{subarray}",1],injlim:["NamedOp","inj&thinsp;lim"],projlim:["NamedOp","proj&thinsp;lim"],varliminf:["Macro","\\mathop{\\underline{\\mmlToken{mi}{lim}}}"],varlimsup:["Macro","\\mathop{\\overline{\\mmlToken{mi}{lim}}}"],varinjlim:["Macro","\\mathop{\\underrightarrow{\\mmlToken{mi}{lim}}}"],varprojlim:["Macro","\\mathop{\\underleftarrow{\\mmlToken{mi}{lim}}}"],DeclareMathOperator:"HandleDeclareOp",operatorname:"HandleOperatorName",genfrac:"Genfrac",frac:["Genfrac","","","",""],tfrac:["Genfrac","","","","1"],dfrac:["Genfrac","","","","0"],binom:["Genfrac","(",")","0",""],tbinom:["Genfrac","(",")","0","1"],dbinom:["Genfrac","(",")","0","0"],cfrac:"CFrac",shoveleft:["HandleShove",U.TexConstant.Align.LEFT],shoveright:["HandleShove",U.TexConstant.Align.RIGHT],xrightarrow:["xArrow",8594,5,10],xleftarrow:["xArrow",8592,10,5]},ji.AmsMethods);new Qt.EnvironmentMap("AMSmath-environment",zr.default.environment,{"equation*":["Equation",null,!1],"eqnarray*":["EqnArray",null,!1,!0,"rcl",He.default.cols(0,Ca.MATHSPACE.thickmathspace),".5em"],align:["EqnArray",null,!0,!0,"rl",He.default.cols(0,2)],"align*":["EqnArray",null,!1,!0,"rl",He.default.cols(0,2)],multline:["Multline",null,!0],"multline*":["Multline",null,!1],split:["EqnArray",null,!1,!1,"rl",He.default.cols(0)],gather:["EqnArray",null,!0,!0,"c"],"gather*":["EqnArray",null,!1,!0,"c"],alignat:["AlignAt",null,!0,!0],"alignat*":["AlignAt",null,!1,!0],alignedat:["AlignAt",null,!1,!1],aligned:["AmsEqnArray",null,null,null,"rl",He.default.cols(0,2),".5em","D"],gathered:["AmsEqnArray",null,null,null,"c",null,".5em","D"],xalignat:["XalignAt",null,!0,!0],"xalignat*":["XalignAt",null,!1,!0],xxalignat:["XalignAt",null,!1,!1],flalign:["FlalignArray",null,!0,!1,!0,"rlc","auto auto fit"],"flalign*":["FlalignArray",null,!1,!1,!0,"rlc","auto auto fit"],subarray:["Array",null,null,null,null,He.default.cols(0),"0.1em","S",1],smallmatrix:["Array",null,null,null,"c",He.default.cols(1/3),".2em","S",1],matrix:["Array",null,null,null,"c"],pmatrix:["Array",null,"(",")","c"],bmatrix:["Array",null,"[","]","c"],Bmatrix:["Array",null,"\\{","\\}","c"],vmatrix:["Array",null,"\\vert","\\vert","c"],Vmatrix:["Array",null,"\\Vert","\\Vert","c"],cases:["Array",null,"\\{",".","ll",null,".2em","T"]},ji.AmsMethods);new Qt.DelimiterMap("AMSmath-delimiter",zr.default.delimiter,{"\\lvert":["|",{texClass:hn.TEXCLASS.OPEN}],"\\rvert":["|",{texClass:hn.TEXCLASS.CLOSE}],"\\lVert":["\u2016",{texClass:hn.TEXCLASS.OPEN}],"\\rVert":["\u2016",{texClass:hn.TEXCLASS.CLOSE}]});new Qt.CharacterMap("AMSsymbols-mathchar0mi",zr.default.mathchar0mi,{digamma:"\u03DD",varkappa:"\u03F0",varGamma:["\u0393",{mathvariant:U.TexConstant.Variant.ITALIC}],varDelta:["\u0394",{mathvariant:U.TexConstant.Variant.ITALIC}],varTheta:["\u0398",{mathvariant:U.TexConstant.Variant.ITALIC}],varLambda:["\u039B",{mathvariant:U.TexConstant.Variant.ITALIC}],varXi:["\u039E",{mathvariant:U.TexConstant.Variant.ITALIC}],varPi:["\u03A0",{mathvariant:U.TexConstant.Variant.ITALIC}],varSigma:["\u03A3",{mathvariant:U.TexConstant.Variant.ITALIC}],varUpsilon:["\u03A5",{mathvariant:U.TexConstant.Variant.ITALIC}],varPhi:["\u03A6",{mathvariant:U.TexConstant.Variant.ITALIC}],varPsi:["\u03A8",{mathvariant:U.TexConstant.Variant.ITALIC}],varOmega:["\u03A9",{mathvariant:U.TexConstant.Variant.ITALIC}],beth:"\u2136",gimel:"\u2137",daleth:"\u2138",backprime:["\u2035",{variantForm:!0}],hslash:"\u210F",varnothing:["\u2205",{variantForm:!0}],blacktriangle:"\u25B4",triangledown:["\u25BD",{variantForm:!0}],blacktriangledown:"\u25BE",square:"\u25FB",Box:"\u25FB",blacksquare:"\u25FC",lozenge:"\u25CA",Diamond:"\u25CA",blacklozenge:"\u29EB",circledS:["\u24C8",{mathvariant:U.TexConstant.Variant.NORMAL}],bigstar:"\u2605",sphericalangle:"\u2222",measuredangle:"\u2221",nexists:"\u2204",complement:"\u2201",mho:"\u2127",eth:["\xF0",{mathvariant:U.TexConstant.Variant.NORMAL}],Finv:"\u2132",diagup:"\u2571",Game:"\u2141",diagdown:"\u2572",Bbbk:["k",{mathvariant:U.TexConstant.Variant.DOUBLESTRUCK}],yen:"\xA5",circledR:"\xAE",checkmark:"\u2713",maltese:"\u2720"});new Qt.CharacterMap("AMSsymbols-mathchar0mo",zr.default.mathchar0mo,{dotplus:"\u2214",ltimes:"\u22C9",smallsetminus:["\u2216",{variantForm:!0}],rtimes:"\u22CA",Cap:"\u22D2",doublecap:"\u22D2",leftthreetimes:"\u22CB",Cup:"\u22D3",doublecup:"\u22D3",rightthreetimes:"\u22CC",barwedge:"\u22BC",curlywedge:"\u22CF",veebar:"\u22BB",curlyvee:"\u22CE",doublebarwedge:"\u2A5E",boxminus:"\u229F",circleddash:"\u229D",boxtimes:"\u22A0",circledast:"\u229B",boxdot:"\u22A1",circledcirc:"\u229A",boxplus:"\u229E",centerdot:["\u22C5",{variantForm:!0}],divideontimes:"\u22C7",intercal:"\u22BA",leqq:"\u2266",geqq:"\u2267",leqslant:"\u2A7D",geqslant:"\u2A7E",eqslantless:"\u2A95",eqslantgtr:"\u2A96",lesssim:"\u2272",gtrsim:"\u2273",lessapprox:"\u2A85",gtrapprox:"\u2A86",approxeq:"\u224A",lessdot:"\u22D6",gtrdot:"\u22D7",lll:"\u22D8",llless:"\u22D8",ggg:"\u22D9",gggtr:"\u22D9",lessgtr:"\u2276",gtrless:"\u2277",lesseqgtr:"\u22DA",gtreqless:"\u22DB",lesseqqgtr:"\u2A8B",gtreqqless:"\u2A8C",doteqdot:"\u2251",Doteq:"\u2251",eqcirc:"\u2256",risingdotseq:"\u2253",circeq:"\u2257",fallingdotseq:"\u2252",triangleq:"\u225C",backsim:"\u223D",thicksim:["\u223C",{variantForm:!0}],backsimeq:"\u22CD",thickapprox:["\u2248",{variantForm:!0}],subseteqq:"\u2AC5",supseteqq:"\u2AC6",Subset:"\u22D0",Supset:"\u22D1",sqsubset:"\u228F",sqsupset:"\u2290",preccurlyeq:"\u227C",succcurlyeq:"\u227D",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",precsim:"\u227E",succsim:"\u227F",precapprox:"\u2AB7",succapprox:"\u2AB8",vartriangleleft:"\u22B2",lhd:"\u22B2",vartriangleright:"\u22B3",rhd:"\u22B3",trianglelefteq:"\u22B4",unlhd:"\u22B4",trianglerighteq:"\u22B5",unrhd:"\u22B5",vDash:["\u22A8",{variantForm:!0}],Vdash:"\u22A9",Vvdash:"\u22AA",smallsmile:["\u2323",{variantForm:!0}],shortmid:["\u2223",{variantForm:!0}],smallfrown:["\u2322",{variantForm:!0}],shortparallel:["\u2225",{variantForm:!0}],bumpeq:"\u224F",between:"\u226C",Bumpeq:"\u224E",pitchfork:"\u22D4",varpropto:["\u221D",{variantForm:!0}],backepsilon:"\u220D",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",therefore:"\u2234",because:"\u2235",eqsim:"\u2242",vartriangle:["\u25B3",{variantForm:!0}],Join:"\u22C8",nless:"\u226E",ngtr:"\u226F",nleq:"\u2270",ngeq:"\u2271",nleqslant:["\u2A87",{variantForm:!0}],ngeqslant:["\u2A88",{variantForm:!0}],nleqq:["\u2270",{variantForm:!0}],ngeqq:["\u2271",{variantForm:!0}],lneq:"\u2A87",gneq:"\u2A88",lneqq:"\u2268",gneqq:"\u2269",lvertneqq:["\u2268",{variantForm:!0}],gvertneqq:["\u2269",{variantForm:!0}],lnsim:"\u22E6",gnsim:"\u22E7",lnapprox:"\u2A89",gnapprox:"\u2A8A",nprec:"\u2280",nsucc:"\u2281",npreceq:["\u22E0",{variantForm:!0}],nsucceq:["\u22E1",{variantForm:!0}],precneqq:"\u2AB5",succneqq:"\u2AB6",precnsim:"\u22E8",succnsim:"\u22E9",precnapprox:"\u2AB9",succnapprox:"\u2ABA",nsim:"\u2241",ncong:"\u2247",nshortmid:["\u2224",{variantForm:!0}],nshortparallel:["\u2226",{variantForm:!0}],nmid:"\u2224",nparallel:"\u2226",nvdash:"\u22AC",nvDash:"\u22AD",nVdash:"\u22AE",nVDash:"\u22AF",ntriangleleft:"\u22EA",ntriangleright:"\u22EB",ntrianglelefteq:"\u22EC",ntrianglerighteq:"\u22ED",nsubseteq:"\u2288",nsupseteq:"\u2289",nsubseteqq:["\u2288",{variantForm:!0}],nsupseteqq:["\u2289",{variantForm:!0}],subsetneq:"\u228A",supsetneq:"\u228B",varsubsetneq:["\u228A",{variantForm:!0}],varsupsetneq:["\u228B",{variantForm:!0}],subsetneqq:"\u2ACB",supsetneqq:"\u2ACC",varsubsetneqq:["\u2ACB",{variantForm:!0}],varsupsetneqq:["\u2ACC",{variantForm:!0}],leftleftarrows:"\u21C7",rightrightarrows:"\u21C9",leftrightarrows:"\u21C6",rightleftarrows:"\u21C4",Lleftarrow:"\u21DA",Rrightarrow:"\u21DB",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",leftarrowtail:"\u21A2",rightarrowtail:"\u21A3",looparrowleft:"\u21AB",looparrowright:"\u21AC",leftrightharpoons:"\u21CB",rightleftharpoons:["\u21CC",{variantForm:!0}],curvearrowleft:"\u21B6",curvearrowright:"\u21B7",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",Lsh:"\u21B0",Rsh:"\u21B1",upuparrows:"\u21C8",downdownarrows:"\u21CA",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",downharpoonleft:"\u21C3",restriction:"\u21BE",multimap:"\u22B8",downharpoonright:"\u21C2",leftrightsquigarrow:"\u21AD",rightsquigarrow:"\u21DD",leadsto:"\u21DD",dashrightarrow:"\u21E2",dashleftarrow:"\u21E0",nleftarrow:"\u219A",nrightarrow:"\u219B",nLeftarrow:"\u21CD",nRightarrow:"\u21CF",nleftrightarrow:"\u21AE",nLeftrightarrow:"\u21CE"});new Qt.DelimiterMap("AMSsymbols-delimiter",zr.default.delimiter,{"\\ulcorner":"\u231C","\\urcorner":"\u231D","\\llcorner":"\u231E","\\lrcorner":"\u231F"});new Qt.CommandMap("AMSsymbols-macros",{implies:["Macro","\\;\\Longrightarrow\\;"],impliedby:["Macro","\\;\\Longleftarrow\\;"]},ji.AmsMethods)});var Oc=m(ke=>{"use strict";var w_=ke&&ke.__extends||(function(){var i=function(r,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},i(r,t)};return function(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");i(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}})(),Ai;Object.defineProperty(ke,"__esModule",{value:!0});ke.AmsConfiguration=ke.AmsTags=void 0;var bc=Gc(),Ci=vc(),x_=Dc(),Mc=Aa();xc();var M_=La(),Sc=(function(i){w_(r,i);function r(){return i!==null&&i.apply(this,arguments)||this}return r})(x_.AbstractTags);ke.AmsTags=Sc;var b_=function(i){new M_.CommandMap(Mc.NEW_OPS,{},{}),i.append(bc.Configuration.local({handler:{macro:[Mc.NEW_OPS]},priority:-1}))};ke.AmsConfiguration=bc.Configuration.create("ams",{handler:{character:["AMSmath-operatorLetter"],delimiter:["AMSsymbols-delimiter","AMSmath-delimiter"],macro:["AMSsymbols-mathchar0mi","AMSsymbols-mathchar0mo","AMSsymbols-delimiter","AMSsymbols-macros","AMSmath-mathchar0mo","AMSmath-macros","AMSmath-delimiter"],environment:["AMSmath-environment"]},items:(Ai={},Ai[Ci.MultlineItem.prototype.kind]=Ci.MultlineItem,Ai[Ci.FlalignItem.prototype.kind]=Ci.FlalignItem,Ai),tags:{ams:Sc},init:b_,config:function(i,r){r.parseOptions.options.multlineWidth&&(r.parseOptions.options.ams.multlineWidth=r.parseOptions.options.multlineWidth),delete r.parseOptions.options.multlineWidth},options:{multlineWidth:"",ams:{multlineWidth:"100%",multlineIndent:"1em"}}})});var jc=qe(Ba(),1),Ac=qe(Hc(),1),Cc=qe(Gi(),1),Pc=qe(mu(),1),Bc=qe(hc(),1),R0=qe(Rc(),1),H0=qe(Oc(),1),Tc=(0,Pc.liteAdaptor)();(0,Bc.RegisterHTMLHandler)(Tc);var Nc=i=>i.attributes?.get?.("linebreak")==="newline"?!0:(i.childNodes??[]).some(r=>r&&Nc(r)),X0=i=>{let r=new Ac.TeX({packages:["base","ams"]}),t=!1;r.postFilters.add(({data:o})=>{t=Nc(o.root)});let e=jc.mathjax.document("",{InputJax:r,OutputJax:new Cc.SVG({fontCache:"none"})}),n=Tc.firstChild(e.convert(i,{display:!0}));if(t)throw new Error("a line break MathJax draws as a space");return n};export{Tc as adaptor,X0 as texToSvg};
15