diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42b4048..968877b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,10 @@ jobs: poetry install --with dev --all-extras - name: Install Pandoc # apt version seems too old uses: r-lib/actions/setup-pandoc@v2 + - name: Install Node # Without it, the maths is not rendered and its tests skip + uses: actions/setup-node@v4 + with: + node-version: '22' # The validator compiles a set the way lambda-feedback/PDF-generator does, so it # needs what that image installs: xelatex with braket, cancel, xeCJK and the # Noto Sans fonts the template sets as its main and CJK fonts. diff --git a/docs/source/contributing/installation.md b/docs/source/contributing/installation.md index 005dd18..82d0bd6 100644 --- a/docs/source/contributing/installation.md +++ b/docs/source/contributing/installation.md @@ -21,6 +21,9 @@ $ pre-commit install $ in2lambda --help ``` +The test suite also renders maths with KaTeX, so install [Node.js](https://nodejs.org) to run all of +it; the tests that need it skip without it. + To exit the environment: ```shell $ exit diff --git a/docs/source/quickstart.md b/docs/source/quickstart.md index 03fbe78..12cb7e1 100644 --- a/docs/source/quickstart.md +++ b/docs/source/quickstart.md @@ -75,6 +75,8 @@ By default, this generates an `out` directory in the same place that the command Before writing anything, in2lambda prints the problems it can detect that would stop the set importing or make it render wrongly — an answer that doesn't fit the box marking it, a figure the export won't contain, maths that KaTeX can't display. Each names the question, part and field to go and look at. They are warnings rather than errors: the `out` directory is written either way, since a problem found here may well be deliberate. +The maths is checked by rendering it with KaTeX itself, the way Lambda Feedback will, which needs [Node.js](https://nodejs.org) installed. Without Node.js everything else is still checked and in2lambda says the maths was not. + With [xelatex](https://tug.org/texlive/) installed alongside pandoc, the set is also compiled the way Lambda Feedback makes a PDF of it, and any LaTeX error names the field it is in. Without it, one warning says which packages to install instead. Check the [command line tool reference](reference/command-line) for more information. diff --git a/in2lambda/main.py b/in2lambda/main.py index 1d1ea2e..293f99a 100644 --- a/in2lambda/main.py +++ b/in2lambda/main.py @@ -9,6 +9,7 @@ import getpass import importlib import shlex +import warnings from collections.abc import ( # Rather than typing's, which beartype warns on. Callable, Iterator, @@ -141,9 +142,16 @@ def runner( ) # Report before writing anything: the problems are the set's whether or not it is - # written out, and an author reading the command line should see them first. - for problem in set_obj.problems(): + # written out, and an author reading the command line should see them first. A check + # that could not be run at all - the maths, with no Node.js to render it - warns + # instead, and is caught here so that it reads as a line rather than a traceback. + with warnings.catch_warnings(record=True) as not_checked: + warnings.simplefilter("always") + problems = set_obj.problems() + for problem in problems: click.echo(f"Warning: {problem}") + for warning in not_checked: + click.echo(f"Warning: {warning.message}") # Read the Python API format and convert to JSON. if output_dir is not None: diff --git a/in2lambda/validation/__init__.py b/in2lambda/validation/__init__.py index 1d42e67..5a819d3 100644 --- a/in2lambda/validation/__init__.py +++ b/in2lambda/validation/__init__.py @@ -7,11 +7,21 @@ Everything here reports, never refuses: :func:`validate` returns what it found and the export goes ahead regardless, since a problem may well be deliberate. + +Maths is rendered with KaTeX itself, which needs Node.js, and the set is compiled as the +PDF generator compiles it, which needs pandoc and xelatex. Both are optional: without +Node the maths check is skipped with a warning saying so, and without the compiler +:mod:`in2lambda.validation.pdf` reports what to install. """ +import json import re +import shutil +import subprocess +import warnings from functools import cache from pathlib import Path +from typing import NamedTuple from in2lambda.api.problem import Problem from in2lambda.api.question import Question @@ -34,6 +44,20 @@ _DEGREES = re.compile(r"\^\s*\{?\s*\\circ") """``^\\circ``, with or without braces around it.""" +_CHECK = Path(__file__).parent / "katex" / "check.js" +"""The Node script that renders expressions with the KaTeX packaged beside it.""" + + +class _Expression(NamedTuple): + """One piece of maths to render, and where in the set it was written.""" + + location: str + start: int + """Where the expression, opening delimiter included, begins in its field, from 1.""" + end: int + tex: str + display: bool + def validate(question_set: Set, compile: bool = True) -> list[Problem]: r"""Everything in2lambda can tell is wrong with a set, in the order it is written. @@ -46,8 +70,10 @@ def validate(question_set: Set, compile: bool = True) -> list[Problem]: Returns: One :class:`~in2lambda.api.problem.Problem` per problem found, each naming the - question, part and field to look at. An empty list means nothing was found - - not that the set will import, since only some mistakes can be seen from here. + question, part and field to look at, in the order they are written - save for + what KaTeX refused, which comes last because the whole set is rendered at once. + An empty list means nothing was found - not that the set will import, since + only some mistakes can be seen from here. Examples: >>> from in2lambda.api.set import Set @@ -59,16 +85,18 @@ def validate(question_set: Set, compile: bool = True) -> list[Problem]: """ problems: list[Problem] = [] # Every markdown field with the location to report it against, kept so that the - # whole set can then be compiled in one go rather than a field at a time. + # whole set can then be compiled in one go rather than a field at a time. The maths + # is collected the same way, and rendered in one Node process. fields: list[tuple[str, str]] = [] images: list[str] = [] + expressions: list[_Expression] = [] def check( markdown: str, question: Question, location: str, compiled: bool = True ) -> list[Problem]: if compiled: fields.append((location, markdown)) - return _markdown_problems(markdown, question, location) + return _markdown_problems(markdown, question, location, expressions) for number, question in enumerate(question_set.questions, start=1): where = f'Question {number} "{question.title}"' @@ -119,16 +147,22 @@ def check( if compile: problems += pdf.problems(fields, images) - return problems + return problems + _katex_rejections(expressions) def _markdown_problems( - markdown: str, question: Question, location: str + markdown: str, + question: Question, + location: str, + expressions: list[_Expression], ) -> list[Problem]: """Every problem in one markdown field, reported against `location`. The question is needed because an image reference is only good if that image is among the question's, and so will be written into the export's ``media/``. + + The field's maths is appended to `expressions` rather than rendered here, so that + the whole set takes one Node process instead of one per field. """ problems: list[Problem] = [] @@ -144,30 +178,44 @@ def _markdown_problems( Problem(location, f"the export will not contain the image {reference}") ) - problems += _katex_problems(markdown, location) + problems += _katex_problems(markdown, location, expressions, delimiters) return problems -def _katex_problems(markdown: str, location: str) -> list[Problem]: - """Maths that KaTeX, which Lambda Feedback renders with, will not display.""" +def _katex_problems( + markdown: str, + location: str, + expressions: list[_Expression], + delimiters: MathDelimiterError, +) -> list[Problem]: + """Maths that KaTeX, which Lambda Feedback renders with, will not display. + + Expressions the lists have nothing to say about are appended to `expressions` for + KaTeX itself to render. The ones they do object to are not: their message says what + to write instead, where KaTeX's only says what it choked on, and one fault reads + better as one line. + """ problems: list[Problem] = [] lacks = _katex_lacks() for span in _MATHS.finditer(markdown): - maths = span[1] if span[1] is not None else span[2] - for command in _COMMAND.findall(maths): - if command in lacks: - replacement = lacks[command] - problems.append( - Problem( - location, - ( - f"KaTeX does not render {command}; write {replacement} instead" - if replacement - else f"KaTeX does not render {command}" - ), - ) + display = span[1] is not None + maths = span[1] if display else span[2] + unsupported = [ + command for command in _COMMAND.findall(maths) if command in lacks + ] + for command in unsupported: + replacement = lacks[command] + problems.append( + Problem( + location, + ( + f"KaTeX does not render {command}; write {replacement} instead" + if replacement + else f"KaTeX does not render {command}" + ), ) + ) if _DEGREES.search(maths): problems.append( Problem( @@ -175,10 +223,80 @@ def _katex_problems(markdown: str, location: str) -> list[Problem]: "^\\circ does not display; write the degree sign ° instead", ) ) + # Where the field's delimiters are wrong, what is between them is not reliably + # the expression the author meant, so it is not rendered. The checks above are + # reported against the field rather than a character range, so they still run. + if not unsupported and delimiters is MathDelimiterError.PASSED: + expressions.append( + _Expression(location, span.start() + 1, span.end(), maths, display) + ) return problems +def _katex_rejections(expressions: list[_Expression]) -> list[Problem]: + """What KaTeX itself refuses to render, the whole set in one Node process. + + Node is optional: someone authoring questions in Python should not have to install + it, so without it this one check is skipped and says what to install instead. + """ + if not expressions: + return [] + + node = _node() + if node is None: + warnings.warn( + "Maths was not checked against KaTeX: install Node.js " + "(https://nodejs.org) and run again", + stacklevel=3, + ) + return [] + + try: + rendered = subprocess.run( + [node, str(_CHECK)], + input=json.dumps( + [ + {"tex": expression.tex, "display": expression.display} + for expression in expressions + ] + ), + capture_output=True, + # Not the locale's encoding: KaTeX marks where it stopped reading with + # combining low lines, so its messages are never ASCII, and Node writes + # them as UTF-8 whatever LANG says. + encoding="utf-8", + check=True, + ) + rejections = json.loads(rendered.stdout) + except (OSError, subprocess.SubprocessError, json.JSONDecodeError) as error: + # Anything named node on the PATH is run here, and it may not be Node.js at all. + # Validation reports, never refuses, so a check that cannot be run says so and + # leaves the rest of the report - and the export - alone. + warnings.warn( + f"Maths was not checked against KaTeX: running {node} failed ({error})", + stacklevel=3, + ) + return [] + + problems: list[Problem] = [] + for rejection in rejections: + expression = expressions[rejection["index"]] + problems.append( + Problem( + f"{expression.location}, characters {expression.start}-{expression.end}", + f"KaTeX rejects it: {rejection['message']}", + ) + ) + return problems + + +@cache +def _node() -> str | None: + """Where node is, or None if it is not installed.""" + return shutil.which("node") + + @cache def _katex_lacks() -> dict[str, str | None]: """What KaTeX lacks, keyed by the command as it is written rather than as a regex. diff --git a/in2lambda/validation/katex/LICENSE b/in2lambda/validation/katex/LICENSE new file mode 100644 index 0000000..37c6433 --- /dev/null +++ b/in2lambda/validation/katex/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2020 Khan Academy and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/in2lambda/validation/katex/README.md b/in2lambda/validation/katex/README.md new file mode 100644 index 0000000..b1bf76e --- /dev/null +++ b/in2lambda/validation/katex/README.md @@ -0,0 +1,7 @@ +# KaTeX, as shipped + +`katex.min.js` is `dist/katex.min.js` from the katex npm package, version 0.18.7, copied verbatim, +with KaTeX's own `LICENSE` beside it. `check.js` is ours and renders with it. + +To move to a newer version: download the tarball (`npm pack katex@`), copy `dist/katex.min.js` +and `LICENSE` out of it over these two, and change the version named above. diff --git a/in2lambda/validation/katex/check.js b/in2lambda/validation/katex/check.js new file mode 100644 index 0000000..76470d0 --- /dev/null +++ b/in2lambda/validation/katex/check.js @@ -0,0 +1,39 @@ +// Renders maths with KaTeX itself, so that what Lambda Feedback's browser would refuse +// is refused here. Reads a JSON array of {"tex": ..., "display": bool} from stdin and +// writes a JSON array of {"index": i, "message": ...} for the ones KaTeX threw on. +// +// One process renders every expression in a set: starting node costs more than the +// rendering does. + +const katex = require("./katex.min.js"); + +let input = ""; +process.stdin.setEncoding("utf8"); +process.stdin.on("data", (chunk) => (input += chunk)); +process.stdin.on("end", () => { + const rejections = []; + + JSON.parse(input).forEach((expression, index) => { + try { + katex.renderToString(expression.tex, { + displayMode: expression.display, + strict: true, + throwOnError: true, + }); + } catch (error) { + rejections.push({ + index, + message: error.message + // Every message begins "KaTeX parse error: "; the report already says who is + // speaking, so the constant part is dropped here. + .replace(/^KaTeX parse error: /, "") + // The message quotes the maths it choked on, which for display maths runs + // over lines, and a reported problem is one line. + .replace(/\s*\n\s*/g, " ") + .trim(), + }); + } + }); + + process.stdout.write(JSON.stringify(rejections)); +}); diff --git a/in2lambda/validation/katex/katex.min.js b/in2lambda/validation/katex/katex.min.js new file mode 100644 index 0000000..ff17da3 --- /dev/null +++ b/in2lambda/validation/katex/katex.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.katex=t():e.katex=t()}("undefined"!=typeof self?self:this,function(){return function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{default:function(){return po}});class r extends Error{constructor(e,t){let n,o,s="KaTeX parse error: "+e;const i=t&&t.loc;if(i&&i.start<=i.end){const e=i.lexer.input;n=i.start,o=i.end,n===e.length?s+=" at end of input: ":s+=" at position "+(n+1)+": ";const t=e.slice(n,o).replace(/[^]/g,"$&\u0332");let r,a;r=n>15?"\u2026"+e.slice(n-15,n):e.slice(0,n),a=o+15e.replace(o,"-$1").toLowerCase(),i={"&":"&",">":">","<":"<",'"':""","'":"'"},a=/[&><"']/g,l=e=>String(e).replace(a,e=>i[e]),c=e=>"ordgroup"===e.type||"color"===e.type?1===e.body.length?c(e.body[0]):e:"font"===e.type?c(e.body):e,h=new Set(["mathord","textord","atom"]),m=e=>h.has(c(e).type),u={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format "},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color ",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro ",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness ",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size ",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand ",cliProcessor:e=>"Infinity"===e?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function p(e){if(Object.prototype.hasOwnProperty.call(e,"default")&&void 0!==e.default)return e.default;return function(e){if("string"!=typeof e)return e.enum[0];switch(e){case"boolean":return!1;case"string":return"";case"number":return 0;case"object":return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}(Array.isArray(e.type)?e.type[0]:e.type)}function d(e,t,r,n){const o=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0,s=Object.prototype.hasOwnProperty.call(n,"processor")?n.processor:void 0;e[t]=void 0!==o?s?s(o):o:p(n)}class g{constructor(e){void 0===e&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{};for(const t of Object.keys(u)){const r=u[t];r&&d(this,t,e,r)}}reportNonstrict(e,t,r){let o=this.strict;if("function"==typeof o&&(o=o(e,t,r)),o&&"ignore"!==o){if(!0===o||"error"===o)throw new n("LaTeX-incompatible input and strict mode is set to 'error': "+t+" ["+e+"]",r);"warn"===o?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+o+"': "+t+" ["+e+"]")}}useStrictBehavior(e,t,r){let n=this.strict;if("function"==typeof n)try{n=n(e,t,r)}catch(e){n="error"}return!(!n||"ignore"===n)&&(!0===n||"error"===n||("warn"===n?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+n+"': "+t+" ["+e+"]"),!1)))}isTrusted(e){if("url"in e&&e.url&&!e.protocol){const t=(e=>{const t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?":"!==t[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?t[1].toLowerCase():null:"_relative"})(e.url);if(null==t)return!1;e.protocol=t}const t="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(t)}}class f{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return b[y[this.id]]}sub(){return b[x[this.id]]}fracNum(){return b[w[this.id]]}fracDen(){return b[v[this.id]]}cramp(){return b[k[this.id]]}text(){return b[z[this.id]]}isTight(){return this.size>=2}}const b=[new f(0,0,!1),new f(1,0,!0),new f(2,1,!1),new f(3,1,!0),new f(4,2,!1),new f(5,2,!0),new f(6,3,!1),new f(7,3,!0)],y=[4,5,4,5,6,7,6,7],x=[5,5,5,5,7,7,7,7],w=[2,3,4,5,6,7,6,7],v=[3,3,5,5,7,7,7,7],k=[1,1,3,3,5,5,7,7],z=[0,1,2,3,2,3,2,3];var S={DISPLAY:b[0],TEXT:b[2],SCRIPT:b[4],SCRIPTSCRIPT:b[6]};const M=[{name:"latin",blocks:[[256,591],[768,879]]},{name:"cyrillic",blocks:[[1024,1279]]},{name:"armenian",blocks:[[1328,1423]]},{name:"brahmic",blocks:[[2304,4255]]},{name:"georgian",blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:"hangul",blocks:[[44032,55215]]}];const A=[];function T(e){for(let t=0;t=A[t]&&e<=A[t+1])return!0;return!1}M.forEach(e=>e.blocks.forEach(e=>A.push(...e)));const C=e=>e+" "+e,B=80,q={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:C("M40 281 V428 H0 V94 H40 V241 H400000 v40z"),leftbracketunder:C("M0 0 h120 V290 H399995 v120 H0z"),leftbracketover:C("M0 440 h120 V150 H399995 v-120 H0z"),leftmapsto:C("M40 281 V448H0V74H40V241H400000v40z"),leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:C("M0 50 h400000 v40H0z m0 194h40000v40H0z"),midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:C("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"),rightbracketunder:C("M399995 0 h-120 V290 H0 v120 H400000z"),rightbracketover:C("M399995 440 h-120 V150 H0 v-120 H399995z"),rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"};class I{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createDocumentFragment();for(let t=0;t{if("toText"in e)return e.toText();throw new Error("Expected MathDomNode with toText, got "+e.constructor.name)}).join("")}}const R={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:1.00375,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:1.00375},O={ex:!0,em:!0,mu:!0},E=function(e){return"string"!=typeof e&&(e=e.unit),e in R||e in O||"ex"===e},H=function(e,t){let r;if(e.unit in R)r=R[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if("mu"===e.unit)r=t.fontMetrics().cssEmPerMu;else{let o;if(o=t.style.isTight()?t.havingStyle(t.style.text()):t,"ex"===e.unit)r=o.fontMetrics().xHeight;else{if("em"!==e.unit)throw new n("Invalid unit: '"+e.unit+"'");r=o.fontMetrics().quad}o!==t&&(r*=o.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},N=function(e){return+e.toFixed(4)+"em"},D=function(e){return e.filter(e=>e).join(" ")},L=function(e){let t="";for(const r of Object.keys(e)){const n=e[r];void 0!==n&&(t+=s(r)+":"+n+";")}return t},F=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");const e=t.getColor();e&&(this.style.color=e)}},P=function(e){const t=document.createElement(e);t.className=D(this.classes),Object.assign(t.style,this.style);for(const e of Object.keys(this.attributes))t.setAttribute(e,this.attributes[e]);for(let e=0;e/=\x00-\x1f]/,G=function(e){let t="<"+e;this.classes.length&&(t+=' class="'+l(D(this.classes))+'"');const r=L(this.style);r&&(t+=' style="'+l(r)+'"');for(const e of Object.keys(this.attributes)){if(V.test(e))throw new n("Invalid attribute name '"+e+"'");t+=" "+e+'="'+l(this.attributes[e])+'"'}t+=">";for(let e=0;e",t};class j{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,F.call(this,e,r,n),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return P.call(this,"span")}toMarkup(){return G.call(this,"span")}}class U{constructor(e,t,r,n){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,F.call(this,t,n),this.children=r||[],this.setAttribute("href",e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return P.call(this,"a")}toMarkup(){return G.call(this,"a")}}class X{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.height=0,this.depth=0,this.maxFontSize=0,this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createElement("img");return e.src=this.src,e.alt=this.alt,e.className="mord",Object.assign(e.style,this.style),e}toMarkup(){let e=''+l(this.alt)+'=n[0]&&e<=n[1])return r.name}}return null}(this.text.charCodeAt(0));l&&this.classes.push(l+"_fallback"),/[\xee\xef\xed\xec]/.test(this.text)&&(this.text=Y[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){const e=document.createTextNode(this.text);let t=null;return this.italic>0&&(t=document.createElement("span"),t.style.marginRight=N(this.italic)),this.classes.length>0&&(t=t||document.createElement("span"),t.className=D(this.classes)),Object.keys(this.style).length>0&&(t=t||document.createElement("span"),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){let e=!1,t="0&&(r+="margin-right:"+N(this.italic)+";"),r+=L(this.style),r&&(e=!0,t+=' style="'+l(r)+'"');const n=l(this.text);return e?(t+=">",t+=n,t+="",t):n}}class _{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");for(const t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(let t=0;t':''}}class Z{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){const e=document.createElementNS("http://www.w3.org/2000/svg","line");for(const t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){let e="","\\gt",!0),oe(se,ae,be,"\u2208","\\in",!0),oe(se,ae,be,"\ue020","\\@not"),oe(se,ae,be,"\u2282","\\subset",!0),oe(se,ae,be,"\u2283","\\supset",!0),oe(se,ae,be,"\u2286","\\subseteq",!0),oe(se,ae,be,"\u2287","\\supseteq",!0),oe(se,le,be,"\u2288","\\nsubseteq",!0),oe(se,le,be,"\u2289","\\nsupseteq",!0),oe(se,ae,be,"\u22a8","\\models"),oe(se,ae,be,"\u2190","\\leftarrow",!0),oe(se,ae,be,"\u2264","\\le"),oe(se,ae,be,"\u2264","\\leq",!0),oe(se,ae,be,"<","\\lt",!0),oe(se,ae,be,"\u2192","\\rightarrow",!0),oe(se,ae,be,"\u2192","\\to"),oe(se,le,be,"\u2271","\\ngeq",!0),oe(se,le,be,"\u2270","\\nleq",!0),oe(se,ae,ye,"\xa0","\\ "),oe(se,ae,ye,"\xa0","\\space"),oe(se,ae,ye,"\xa0","\\nobreakspace"),oe(ie,ae,ye,"\xa0","\\ "),oe(ie,ae,ye,"\xa0"," "),oe(ie,ae,ye,"\xa0","\\space"),oe(ie,ae,ye,"\xa0","\\nobreakspace"),oe(se,ae,ye,"","\\nobreak"),oe(se,ae,ye,"","\\allowbreak"),oe(se,ae,fe,",",","),oe(se,ae,fe,";",";"),oe(se,le,he,"\u22bc","\\barwedge",!0),oe(se,le,he,"\u22bb","\\veebar",!0),oe(se,ae,he,"\u2299","\\odot",!0),oe(se,ae,he,"\u2295","\\oplus",!0),oe(se,ae,he,"\u2297","\\otimes",!0),oe(se,ae,xe,"\u2202","\\partial",!0),oe(se,ae,he,"\u2298","\\oslash",!0),oe(se,le,he,"\u229a","\\circledcirc",!0),oe(se,le,he,"\u22a1","\\boxdot",!0),oe(se,ae,he,"\u25b3","\\bigtriangleup"),oe(se,ae,he,"\u25bd","\\bigtriangledown"),oe(se,ae,he,"\u2020","\\dagger"),oe(se,ae,he,"\u22c4","\\diamond"),oe(se,ae,he,"\u22c6","\\star"),oe(se,ae,he,"\u25c3","\\triangleleft"),oe(se,ae,he,"\u25b9","\\triangleright"),oe(se,ae,ge,"{","\\{"),oe(ie,ae,xe,"{","\\{"),oe(ie,ae,xe,"{","\\textbraceleft"),oe(se,ae,me,"}","\\}"),oe(ie,ae,xe,"}","\\}"),oe(ie,ae,xe,"}","\\textbraceright"),oe(se,ae,ge,"{","\\lbrace"),oe(se,ae,me,"}","\\rbrace"),oe(se,ae,ge,"[","\\lbrack",!0),oe(ie,ae,xe,"[","\\lbrack",!0),oe(se,ae,me,"]","\\rbrack",!0),oe(ie,ae,xe,"]","\\rbrack",!0),oe(se,ae,ge,"(","\\lparen",!0),oe(se,ae,me,")","\\rparen",!0),oe(ie,ae,xe,"<","\\textless",!0),oe(ie,ae,xe,">","\\textgreater",!0),oe(se,ae,ge,"\u230a","\\lfloor",!0),oe(se,ae,me,"\u230b","\\rfloor",!0),oe(se,ae,ge,"\u2308","\\lceil",!0),oe(se,ae,me,"\u2309","\\rceil",!0),oe(se,ae,xe,"\\","\\backslash"),oe(se,ae,xe,"\u2223","|"),oe(se,ae,xe,"\u2223","\\vert"),oe(ie,ae,xe,"|","\\textbar",!0),oe(se,ae,xe,"\u2225","\\|"),oe(se,ae,xe,"\u2225","\\Vert"),oe(ie,ae,xe,"\u2225","\\textbardbl"),oe(ie,ae,xe,"~","\\textasciitilde"),oe(ie,ae,xe,"\\","\\textbackslash"),oe(ie,ae,xe,"^","\\textasciicircum"),oe(se,ae,be,"\u2191","\\uparrow",!0),oe(se,ae,be,"\u21d1","\\Uparrow",!0),oe(se,ae,be,"\u2193","\\downarrow",!0),oe(se,ae,be,"\u21d3","\\Downarrow",!0),oe(se,ae,be,"\u2195","\\updownarrow",!0),oe(se,ae,be,"\u21d5","\\Updownarrow",!0),oe(se,ae,de,"\u2210","\\coprod"),oe(se,ae,de,"\u22c1","\\bigvee"),oe(se,ae,de,"\u22c0","\\bigwedge"),oe(se,ae,de,"\u2a04","\\biguplus"),oe(se,ae,de,"\u22c2","\\bigcap"),oe(se,ae,de,"\u22c3","\\bigcup"),oe(se,ae,de,"\u222b","\\int"),oe(se,ae,de,"\u222b","\\intop"),oe(se,ae,de,"\u222c","\\iint"),oe(se,ae,de,"\u222d","\\iiint"),oe(se,ae,de,"\u220f","\\prod"),oe(se,ae,de,"\u2211","\\sum"),oe(se,ae,de,"\u2a02","\\bigotimes"),oe(se,ae,de,"\u2a01","\\bigoplus"),oe(se,ae,de,"\u2a00","\\bigodot"),oe(se,ae,de,"\u222e","\\oint"),oe(se,ae,de,"\u222f","\\oiint"),oe(se,ae,de,"\u2230","\\oiiint"),oe(se,ae,de,"\u2a06","\\bigsqcup"),oe(se,ae,de,"\u222b","\\smallint"),oe(ie,ae,ue,"\u2026","\\textellipsis"),oe(se,ae,ue,"\u2026","\\mathellipsis"),oe(ie,ae,ue,"\u2026","\\ldots",!0),oe(se,ae,ue,"\u2026","\\ldots",!0),oe(se,ae,ue,"\u22ef","\\@cdots",!0),oe(se,ae,ue,"\u22f1","\\ddots",!0),oe(se,ae,xe,"\u22ee","\\varvdots"),oe(ie,ae,xe,"\u22ee","\\varvdots"),oe(se,ae,ce,"\u02ca","\\acute"),oe(se,ae,ce,"\u02cb","\\grave"),oe(se,ae,ce,"\xa8","\\ddot"),oe(se,ae,ce,"~","\\tilde"),oe(se,ae,ce,"\u02c9","\\bar"),oe(se,ae,ce,"\u02d8","\\breve"),oe(se,ae,ce,"\u02c7","\\check"),oe(se,ae,ce,"^","\\hat"),oe(se,ae,ce,"\u20d7","\\vec"),oe(se,ae,ce,"\u02d9","\\dot"),oe(se,ae,ce,"\u02da","\\mathring"),oe(se,ae,pe,"\ue131","\\@imath"),oe(se,ae,pe,"\ue237","\\@jmath"),oe(se,ae,xe,"\u0131","\u0131"),oe(se,ae,xe,"\u0237","\u0237"),oe(ie,ae,xe,"\u0131","\\i",!0),oe(ie,ae,xe,"\u0237","\\j",!0),oe(ie,ae,xe,"\xdf","\\ss",!0),oe(ie,ae,xe,"\xe6","\\ae",!0),oe(ie,ae,xe,"\u0153","\\oe",!0),oe(ie,ae,xe,"\xf8","\\o",!0),oe(ie,ae,xe,"\xc6","\\AE",!0),oe(ie,ae,xe,"\u0152","\\OE",!0),oe(ie,ae,xe,"\xd8","\\O",!0),oe(ie,ae,ce,"\u02ca","\\'"),oe(ie,ae,ce,"\u02cb","\\`"),oe(ie,ae,ce,"\u02c6","\\^"),oe(ie,ae,ce,"\u02dc","\\~"),oe(ie,ae,ce,"\u02c9","\\="),oe(ie,ae,ce,"\u02d8","\\u"),oe(ie,ae,ce,"\u02d9","\\."),oe(ie,ae,ce,"\xb8","\\c"),oe(ie,ae,ce,"\u02da","\\r"),oe(ie,ae,ce,"\u02c7","\\v"),oe(ie,ae,ce,"\xa8",'\\"'),oe(ie,ae,ce,"\u02dd","\\H"),oe(ie,ae,ce,"\u25ef","\\textcircled");const we={"--":!0,"---":!0,"``":!0,"''":!0};oe(ie,ae,xe,"\u2013","--",!0),oe(ie,ae,xe,"\u2013","\\textendash"),oe(ie,ae,xe,"\u2014","---",!0),oe(ie,ae,xe,"\u2014","\\textemdash"),oe(ie,ae,xe,"\u2018","`",!0),oe(ie,ae,xe,"\u2018","\\textquoteleft"),oe(ie,ae,xe,"\u2019","'",!0),oe(ie,ae,xe,"\u2019","\\textquoteright"),oe(ie,ae,xe,"\u201c","``",!0),oe(ie,ae,xe,"\u201c","\\textquotedblleft"),oe(ie,ae,xe,"\u201d","''",!0),oe(ie,ae,xe,"\u201d","\\textquotedblright"),oe(se,ae,xe,"\xb0","\\degree",!0),oe(ie,ae,xe,"\xb0","\\degree"),oe(ie,ae,xe,"\xb0","\\textdegree",!0),oe(se,ae,xe,"\xa3","\\pounds"),oe(se,ae,xe,"\xa3","\\mathsterling",!0),oe(ie,ae,xe,"\xa3","\\pounds"),oe(ie,ae,xe,"\xa3","\\textsterling",!0),oe(se,le,xe,"\u2720","\\maltese"),oe(ie,le,xe,"\u2720","\\maltese");const ve='0123456789/@."';for(let e=0;e<14;e++){const t=ve.charAt(e);oe(se,ae,xe,t,t)}const ke='0123456789!@*()-=+";:?/.,';for(let e=0;e<25;e++){const t=ke.charAt(e);oe(ie,ae,xe,t,t)}const ze="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";for(let e=0;e<52;e++){const t=ze.charAt(e);oe(se,ae,pe,t,t),oe(ie,ae,xe,t,t)}let Se;oe(se,le,xe,"C","\u2102"),oe(ie,le,xe,"C","\u2102"),oe(se,le,xe,"H","\u210d"),oe(ie,le,xe,"H","\u210d"),oe(se,le,xe,"N","\u2115"),oe(ie,le,xe,"N","\u2115"),oe(se,le,xe,"P","\u2119"),oe(ie,le,xe,"P","\u2119"),oe(se,le,xe,"Q","\u211a"),oe(ie,le,xe,"Q","\u211a"),oe(se,le,xe,"R","\u211d"),oe(ie,le,xe,"R","\u211d"),oe(se,le,xe,"Z","\u2124"),oe(ie,le,xe,"Z","\u2124"),oe(se,ae,pe,"h","\u210e"),oe(ie,ae,pe,"h","\u210e");for(let e=0;e<52;e++){const t=ze.charAt(e);Se=String.fromCharCode(55349,56320+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56372+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56424+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56580+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56684+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56736+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56788+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56840+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56944+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),e<26&&(Se=String.fromCharCode(55349,56632+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,56476+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se))}Se=String.fromCharCode(55349,56668),oe(se,ae,pe,"k",Se),oe(ie,ae,xe,"k",Se);for(let e=0;e<10;e++){const t=e.toString();Se=String.fromCharCode(55349,57294+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,57314+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,57324+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se),Se=String.fromCharCode(55349,57334+e),oe(se,ae,pe,t,Se),oe(ie,ae,xe,t,Se)}const Me="\xd0\xde\xfe";for(let e=0;e<3;e++){const t=Me.charAt(e);oe(se,ae,pe,t,t),oe(ie,ae,xe,t,t)}const Ae={mathClass:"mathbf",textClass:"textbf",font:"Main-Bold"},Te={mathClass:"mathnormal",textClass:"textit",font:"Math-Italic"},Ce={mathClass:"boldsymbol",textClass:"boldsymbol",font:"Main-BoldItalic"},Be={mathClass:"",textClass:"",font:""},qe={mathClass:"mathfrak",textClass:"textfrak",font:"Fraktur-Regular"},Ie={mathClass:"mathbb",textClass:"textbb",font:"AMS-Regular"},Re={mathClass:"mathboldfrak",textClass:"textboldfrak",font:"Fraktur-Regular"},Oe={mathClass:"mathsf",textClass:"textsf",font:"SansSerif-Regular"},Ee={mathClass:"mathboldsf",textClass:"textboldsf",font:"SansSerif-Bold"},He={mathClass:"mathitsf",textClass:"textitsf",font:"SansSerif-Italic"},Ne={mathClass:"mathtt",textClass:"texttt",font:"Typewriter-Regular"},De=[Ae,Ae,Te,Te,Ce,Ce,{mathClass:"mathscr",textClass:"textscr",font:"Script-Regular"},Be,Be,Be,qe,qe,Ie,Ie,Re,Re,Oe,Oe,Ee,Ee,He,He,Be,Be,Ne,Ne],Le=[Ae,Be,Oe,Ee,Ne],Fe=function(e,t,r){if(ne[r][e]){const t=ne[r][e].replace;t&&(e=t)}return{value:e,metrics:ee(e,t,r)}},Pe=function(e,t,r,n,o){const s=Fe(e,t,r),i=s.metrics;let a;if(e=s.value,i){let t=i.italic;("text"===r||n&&"mathit"===n.font)&&(t=0),a=new W(e,i.height,i.depth,t,i.skew,i.width,o)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+e+"' in style '"+t+"' and mode '"+r+"'"),a=new W(e,0,0,0,0,0,o);if(n){a.maxFontSize=n.sizeMultiplier,n.style.isTight()&&a.classes.push("mtight");const e=n.getColor();e&&(a.style.color=e)}return a},Ve=function(e,t,r,n){return void 0===n&&(n=[]),"boldsymbol"===r.font&&Fe(e,"Main-Bold",t).metrics?Pe(e,"Main-Bold",t,r,n.concat(["mathbf"])):"\\"===e||"main"===ne[t][e].font?Pe(e,"Main-Regular",t,r,n):Pe(e,"AMS-Regular",t,r,n.concat(["amsrm"]))},Ge=function(e,t){const r="mathord"===e.type?"mathord":"textord",o=e.mode,s=e.text,i=["mord"],a=t.font,l=t.fontFamily,c=t.fontWeight,h=t.fontShape,m="math"===o||"text"===o&&!!a,u=m?a:l;let p="",d="";if(55349===s.charCodeAt(0)){const e=(e=>{const t=1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536;if(119808<=t&&t<120484){const e=Math.floor((t-119808)/26);return De[e]}if(120782<=t&&t<=120831){const e=Math.floor((t-120782)/10);return Le[e]}if(120485===t||120486===t)return De[0];if(120486{if(D(e.classes)!==D(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||0!==e.italic&&e.hasClass("mathnormal"))return!1;if(1===e.classes.length){const t=e.classes[0];if("mbin"===t||"mord"===t)return!1}for(const r of Object.keys(e.style))if(e.style[r]!==t.style[r])return!1;for(const r of Object.keys(t.style))if(e.style[r]!==t.style[r])return!1;return!0},Ue=e=>{for(let t=0;tt&&(t=s.height),s.depth>r&&(r=s.depth),s.maxFontSize>n&&(n=s.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=n},Ye=function(e,t,r,n){const o=new j(e,t,r,n);return Xe(o),o},We=(e,t,r,n)=>new j(e,t,r,n),_e=function(e,t,r){const n=Ye([e],[],t);return n.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),n.style.borderBottomWidth=N(n.height),n.maxFontSize=1,n},$e=function(e){const t=new I(e);return Xe(t),t},Ze=function(e,t){return e instanceof I?Ye([],[e],t):e},Ke=function(e,t){const r=function(e){if("individualShift"===e.positionType){const t=e.children,r=[t[0]],n=-t[0].shift-t[0].elem.depth;let o=n;for(let e=1;e{const r=Ye(["mspace"],[],t),n=H(e,t);return r.style.marginRight=N(n),r},Qe=(e,t,r)=>{let n,o;switch(e){case"amsrm":n="AMS";break;case"textrm":n="Main";break;case"textsf":n="SansSerif";break;case"texttt":n="Typewriter";break;default:n=e}return o="textbf"===t&&"textit"===r?"BoldItalic":"textbf"===t?"Bold":"textit"===r?"Italic":"Regular",n+"-"+o},et={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},tt={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},rt=function(e,t){const r=tt[e],n=r[0],o=r[1],s=r[2],i=new $(n),a=new _([i],{width:N(o),height:N(s),style:"width:"+N(o),viewBox:"0 0 "+1e3*o+" "+1e3*s,preserveAspectRatio:"xMinYMin"}),l=We(["katex-overlay"],[a],t);return l.height=s,l.style.height=N(s),l.style.width=N(o),l},nt={number:3,unit:"mu"},ot={number:4,unit:"mu"},st={number:5,unit:"mu"},it={mord:{mop:nt,mbin:ot,mrel:st,minner:nt},mop:{mord:nt,mop:nt,mrel:st,minner:nt},mbin:{mord:ot,mop:ot,mopen:ot,minner:ot},mrel:{mord:st,mop:st,mopen:st,minner:st},mopen:{},mclose:{mop:nt,mbin:ot,mrel:st,minner:nt},mpunct:{mord:nt,mop:nt,mrel:st,mopen:nt,mclose:nt,mpunct:nt,minner:nt},minner:{mord:nt,mop:nt,mbin:ot,mrel:st,mopen:nt,mpunct:nt,minner:nt}},at={mord:{mop:nt},mop:{mord:nt,mop:nt},mbin:{},mrel:{},mopen:{},mclose:{mop:nt},mpunct:{},minner:{mop:nt}},lt={},ct={},ht={};function mt(e){const t=e.type,r=e.names,n=e.htmlBuilder,o=e.mathmlBuilder;for(let t=0;t{const r=t.classes[0],n=e.classes[0];"mbin"===r&&ft.has(n)?t.classes[0]="mord":"mbin"===n&>.has(r)&&(e.classes[0]="mord")},{node:i},a,l),wt(o,(e,t)=>{var r,n;const o=zt(t),i=zt(e),a=o&&i?e.hasClass("mtight")?null==(r=at[o])?void 0:r[i]:null==(n=it[o])?void 0:n[i]:null;if(a)return Je(a,s)},{node:i},a,l),o},wt=function(e,t,r,n,o){n&&e.push(n);let s=0;for(;sr=>{e.splice(t+1,0,r),s++})(s)}n&&e.pop()},vt=function(e){return e instanceof I||e instanceof U||e instanceof j&&e.hasClass("enclosing")?e:null},kt=function(e,t){const r=vt(e);if(r){const e=r.children;if(e.length){if("right"===t)return kt(e[e.length-1],"right");if("left"===t)return kt(e[0],"left")}}return e},zt=function(e,t){if(!e)return null;t&&(e=kt(e,t));const r=e.classes[0];return yt[r]||null},St=function(e,t){const r=["nulldelimiter"].concat(e.baseSizingClasses());return Ye(t.concat(r))},Mt=function(e,t,r){if(!e)return Ye();if(ct[e.type]){let n=ct[e.type](e,t);if(r&&t.size!==r.size){n=Ye(t.sizingClasses(r),[n],t);const e=t.sizeMultiplier/r.sizeMultiplier;n.height*=e,n.depth*=e}return n}throw new n("Got group of unknown type: '"+e.type+"'")};function At(e,t){const r=Ye(["katex-base"],e,t),n=Ye(["katex-strut"]);return n.style.height=N(r.height+r.depth),r.depth&&(n.style.verticalAlign=N(-r.depth)),r.children.unshift(n),r}function Tt(e,t){let r=null;1===e.length&&"tag"===e[0].type&&(r=e[0].tag,e=e[0].body);const n=xt(e,t,"root");let o;2===n.length&&n[1].hasClass("katex-tag")&&(o=n.pop());const s=[];let i,a=[];for(let e=0;e0&&(s.push(At(a,t)),a=[]),s.push(n[e]));a.length>0&&s.push(At(a,t)),r?(i=At(xt(r,t,!0),t),i.classes=["katex-tag"],s.push(i)):o&&s.push(o);const l=Ye(["katex-html"],s);if(l.setAttribute("aria-hidden","true"),i){const e=i.children[0];e.style.height=N(l.height+l.depth),l.depth&&(e.style.verticalAlign=N(-l.depth))}return l}function Ct(e){return new I(e)}class Bt{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){const e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(const t of Object.entries(this.attributes)){const r=t[0],n=t[1];e.setAttribute(r,n)}this.classes.length>0&&(e.className=D(this.classes));for(let t=0;t0&&(e+=' class ="'+l(D(this.classes))+'"'),e+=">";for(let t=0;t",e}toText(){return this.children.map(e=>e.toText()).join("")}}class qt{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return l(this.toText())}toText(){return this.text}}class It{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?"\u200a":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200a":e>=-.05556&&e<=-.05555?"\u200a\u2063":e>=-.1667&&e<=-.1666?"\u2009\u2063":e>=-.2223&&e<=-.2222?"\u205f\u2063":e>=-.2778&&e<=-.2777?"\u2005\u2063":null}toNode(){if(this.character)return document.createTextNode(this.character);{const e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",N(this.width)),e}}toMarkup(){return this.character?""+this.character+"":''}toText(){return this.character?this.character:" "}}const Rt=new Set(["\\imath","\\jmath"]),Ot=new Set(["mrow","mtable"]),Et=function(e,t,r){var n,o;return ne[t][e]&&ne[t][e].replace&&55349!==e.charCodeAt(0)&&(!Object.prototype.hasOwnProperty.call(we,e)||"tt"!==(null==r||null==(n=r.fontFamily)?void 0:n.slice(4,6))&&"tt"!==(null==r||null==(o=r.font)?void 0:o.slice(4,6)))&&(e=ne[t][e].replace),new qt(e)},Ht=function(e){return 1===e.length?e[0]:new Bt("mrow",e)},Nt={mathit:"italic",boldsymbol:e=>"textord"===e.type?"bold":"bold-italic",mathbf:"bold",mathbb:"double-struck",mathsfit:"sans-serif-italic",mathfrak:"fraktur",mathscr:"script",mathcal:"script",mathsf:"sans-serif",mathtt:"monospace"},Dt=(e,t)=>{if("text"===e.mode){if("texttt"===t.fontFamily)return"monospace";if("textsf"===t.fontFamily)return"textit"===t.fontShape&&"textbf"===t.fontWeight?"sans-serif-bold-italic":"textit"===t.fontShape?"sans-serif-italic":"textbf"===t.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===t.fontShape&&"textbf"===t.fontWeight)return"bold-italic";if("textit"===t.fontShape)return"italic";if("textbf"===t.fontWeight)return"bold"}const r=t.font;if(!r||"mathnormal"===r)return null;const n=e.mode,o=Nt[r];if(o)return"function"==typeof o?o(e):o;let s=e.text;if(Rt.has(s))return null;if(ne[n][s]){const e=ne[n][s].replace;e&&(s=e)}return ee(s,et[r].fontName,n)?et[r].variant:null};function Lt(e){if(!e)return!1;if("mi"===e.type&&1===e.children.length){const t=e.children[0];return t instanceof qt&&"."===t.text}if("mo"===e.type&&1===e.children.length&&"true"===e.getAttribute("separator")&&"0em"===e.getAttribute("lspace")&&"0em"===e.getAttribute("rspace")){const t=e.children[0];return t instanceof qt&&","===t.text}return!1}const Ft=function(e,t,r){if(1===e.length){const n=Vt(e[0],t);return r&&n instanceof Bt&&"mo"===n.type&&(n.setAttribute("lspace","0em"),n.setAttribute("rspace","0em")),[n]}const n=[];let o;for(let r=0;r=1&&("mn"===o.type||Lt(o))){const e=s.children[0];e instanceof Bt&&"mn"===e.type&&(e.children=[...o.children,...e.children],n.pop())}else if("mi"===o.type&&1===o.children.length){const e=o.children[0];if(e instanceof qt&&"\u0338"===e.text&&("mo"===s.type||"mi"===s.type||"mn"===s.type)){const e=s.children[0];e instanceof qt&&e.text.length>0&&(e.text=e.text.slice(0,1)+"\u0338"+e.text.slice(1),n.pop())}}}n.push(s),o=s}return n},Pt=function(e,t,r){return Ht(Ft(e,t,r))},Vt=function(e,t){if(!e)return new Bt("mrow");if(ht[e.type])return ht[e.type](e,t);throw new n("Got group of unknown type: '"+e.type+"'")};function Gt(e,t,r,n,o){const s=Ft(e,r);let i;i=1===s.length&&s[0]instanceof Bt&&Ot.has(s[0].type)?s[0]:new Bt("mrow",s);const a=new Bt("annotation",[new qt(t)]);a.setAttribute("encoding","application/x-tex");const l=new Bt("semantics",[i,a]),c=new Bt("math",[l]);c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n&&c.setAttribute("display","block");return Ye([o?"katex":"katex-mathml"],[c])}const jt=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],Ut=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Xt=function(e,t){return t.size<2?e:jt[e-1][t.size-1]};class Yt{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||Yt.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=Ut[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){const t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(t,e),new Yt(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:Xt(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:Ut[e-1]})}havingBaseStyle(e){e=e||this.style.text();const t=Xt(Yt.BASESIZE,e);return this.size===t&&this.textSize===Yt.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){let e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["katex-sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==Yt.BASESIZE?["katex-sizing","reset-size"+this.size,"size"+Yt.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=function(e){let t;if(t=e>=5?0:e>=3?1:2,!te[t]){const e=te[t]={cssEmPerMu:J.quad[t]/18};for(const r of Object.keys(J))e[r]=J[r][t]}return te[t]}(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}Yt.BASESIZE=6;var Wt=Yt;const _t=function(e){return new Wt({style:e.displayMode?S.DISPLAY:S.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},$t=function(e,t){if(t.displayMode){const r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=Ye(r,[e])}return e},Zt=function(e,t,r){const n=_t(r);let o;if("mathml"===r.output)return Gt(e,t,n,r.displayMode,!0);if("html"===r.output){const t=Tt(e,n);o=Ye(["katex"],[t])}else{const s=Gt(e,t,n,r.displayMode,!1),i=Tt(e,n);o=Ye(["katex"],[s,i])}return $t(o,r)};const Kt={widehat:"^",widecheck:"\u02c7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23df",overbrace:"\u23de",underbracket:"\u23b5",overbracket:"\u23b4",overgroup:"\u23e0",undergroup:"\u23e1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xlongequal:"=",xtofrom:"\u21c4",xrightleftarrows:"\u21c4",xrightequilibrium:"\u21cc",xleftequilibrium:"\u21cb","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},Jt=function(e){const t=new Bt("mo",[new qt(Kt[e.replace(/^\\/,"")])]);return t.setAttribute("stretchy","true"),t},Qt={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overbracket:[["leftbracketover","rightbracketover"],1.6,440],underbracket:[["leftbracketunder","rightbracketunder"],1.6,410],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},er=new Set(["widehat","widecheck","widetilde","utilde"]),tr=function(e,t){const r=function(){let r=4e5;const n=e.label.slice(1);if(er.has(n)&&"base"in e){const o="ordgroup"===e.base.type?e.base.body.length:1;let s,i,a;if(o>5)"widehat"===n||"widecheck"===n?(s=420,r=2364,a=.42,i=n+"4"):(s=312,r=2340,a=.34,i="tilde4");else{const e=[1,1,2,2,3,3][o];"widehat"===n||"widecheck"===n?(r=[0,1062,2364,2364,2364][e],s=[0,239,300,360,420][e],a=[0,.24,.3,.3,.36,.42][e],i=n+e):(r=[0,600,1033,2339,2340][e],s=[0,260,286,306,312][e],a=[0,.26,.286,.3,.306,.34][e],i="tilde"+e)}const l=new $(i),c=new _([l],{width:"100%",height:N(a),viewBox:"0 0 "+r+" "+s,preserveAspectRatio:"none"});return{span:We([],[c],t),minWidth:0,height:a}}{const e=[],o=Qt[n];if(!o)throw new Error('No SVG data for "'+n+'".');const s=o[0],i=o[1],a=o[2],l=a/1e3,c=s.length;let h,m;if(1===c){if(4!==o.length)throw new Error('Expected 4-tuple for single-path SVG data "'+n+'".');h=["hide-tail"],m=[o[3]]}else if(2===c)h=["halfarrow-left","halfarrow-right"],m=["xMinYMin","xMaxYMin"];else{if(3!==c)throw new Error("Correct katexImagesData or update code here to support\n "+c+" children.");h=["brace-left","brace-center","brace-right"],m=["xMinYMin","xMidYMin","xMaxYMin"]}for(let n=0;n0&&(n.style.minWidth=N(o)),n},rr=new Set(["bin","close","inner","open","punct","rel"]),nr=new Set(["accent-token","mathord","op-token","spacing","textord"]);function or(e,t){if(!e||e.type!==t)throw new Error("Expected node of type "+t+", but got "+(e?"node of type "+e.type:String(e)));return e}function sr(e){const t=ir(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?"node of type "+e.type:String(e)));return t}function ir(e){return"atom"===e.type||nr.has(e.type)?e:null}function ar(e,t,r){let o="";for(const s of e.body)if("textord"===s.type)o+=s.text;else{if(!r||"spacing"!==s.type||" "!==s.text)throw new n(t,e);o+=" "}return o}const lr=e=>{return e instanceof W?e:((t=e)instanceof j||t instanceof U||t instanceof I)&&1===e.children.length?lr(e.children[0]):void 0;var t},cr=(e,t)=>{let r,n,o;e&&"supsub"===e.type?(n=or(e.base,"accent"),r=n.base,e.base=r,o=function(e){if(e instanceof j)return e;throw new Error("Expected span but got "+String(e)+".")}(Mt(e,t)),e.base=n):(n=or(e,"accent"),r=n.base);const s=Mt(r,t.havingCrampedStyle());let i=0;var a,l;n.isShifty&&m(r)&&(i=null!=(a=null==(l=lr(s))?void 0:l.skew)?a:0);const c="\\c"===n.label;let h,u=c?s.height+s.depth:Math.min(s.height,t.fontMetrics().xHeight);if(n.isStretchy)h=tr(n,t),h=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:i>0?{width:"calc(100% - "+N(2*i)+")",marginLeft:N(2*i)}:void 0}]});else{let e,r;"\\vec"===n.label?(e=rt("vec",t),r=tt.vec[1]):(e=Ge({type:"textord",mode:n.mode,text:n.label},t),e=function(e){if(e instanceof W)return e;throw new Error("Expected symbolNode but got "+String(e)+".")}(e),e.italic=0,r=e.width,c&&(u+=e.depth)),h=Ye(["accent-body"],[e]);const o="\\textcircled"===n.label;o&&(h.classes.push("accent-full"),u=s.height);let a=i;o||(a-=r/2),h.style.left=N(a),"\\textcircled"===n.label&&(h.style.top=".2em"),h=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-u},{type:"elem",elem:h}]})}const p=Ye(["mord","katex-accent"],[h],t);return o?(o.children[0]=p,o.height=Math.max(p.height,o.height),o.classes[0]="mord",o):p},hr=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(e=>"\\"+e).join("|"));mt({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],numArgs:1,handler:(e,t)=>{const r=pt(t[0]),n=!hr.test(e.funcName),o=!n||"\\widehat"===e.funcName||"\\widetilde"===e.funcName||"\\widecheck"===e.funcName;return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:n,isShifty:o,base:r}},htmlBuilder:cr,mathmlBuilder:(e,t)=>{const r=e.isStretchy?Jt(e.label):new Bt("mo",[Et(e.label,e.mode)]),n=new Bt("mover",[Vt(e.base,t),r]);return n.setAttribute("accent","true"),n}}),mt({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"],handler:(e,t)=>{const r=t[0];let n=e.parser.mode;return"math"===n&&(e.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+e.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}}}),mt({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],numArgs:1,handler:(e,t)=>{let r=e.parser,n=e.funcName;const o=t[0];return{type:"accentUnder",mode:r.mode,label:n,base:o}},htmlBuilder:(e,t)=>{const r=Mt(e.base,t),n=tr(e,t),o="\\utilde"===e.label?.12:0,s=Ke({positionType:"top",positionData:r.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:o},{type:"elem",elem:r}]});return Ye(["mord","accentunder"],[s],t)},mathmlBuilder:(e,t)=>{const r=Jt(e.label),n=new Bt("munder",[Vt(e.base,t),r]);return n.setAttribute("accentunder","true"),n}});const mr=e=>{const t=new Bt("mpadded",e?[e]:[]);return t.setAttribute("width","+0.6em"),t.setAttribute("lspace","0.3em"),t};mt({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],numArgs:1,numOptionalArgs:1,handler(e,t,r){let n=e.parser,o=e.funcName;return{type:"xArrow",mode:n.mode,label:o,body:t[0],below:r[0]}},htmlBuilder(e,t){const r=t.style;let n=t.havingStyle(r.sup());const o=Ze(Mt(e.body,n,t),t),s="\\x"===e.label.slice(0,2)?"x":"cd";let i;o.classes.push(s+"-arrow-pad"),e.below&&(n=t.havingStyle(r.sub()),i=Ze(Mt(e.below,n,t),t),i.classes.push(s+"-arrow-pad"));const a=tr(e,t),l=-t.fontMetrics().axisHeight+.5*a.height;let c,h=-t.fontMetrics().axisHeight-.5*a.height-.111;if((o.depth>.25||"\\xleftequilibrium"===e.label)&&(h-=o.depth),i){const e=-t.fontMetrics().axisHeight+i.height+.5*a.height+.111;c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:h},{type:"elem",elem:a,shift:l,wrapperClasses:["svg-align"]},{type:"elem",elem:i,shift:e}]})}else c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:h},{type:"elem",elem:a,shift:l,wrapperClasses:["svg-align"]}]});return Ye(["mrel","x-arrow"],[c],t)},mathmlBuilder(e,t){const r=Jt(e.label);let n;if(r.setAttribute("minsize","x"===e.label.charAt(0)?"1.75em":"3.0em"),e.body){const o=mr(Vt(e.body,t));if(e.below){const s=mr(Vt(e.below,t));n=new Bt("munderover",[r,s,o])}else n=new Bt("mover",[r,o])}else if(e.below){const o=mr(Vt(e.below,t));n=new Bt("munder",[r,o])}else n=mr(),n=new Bt("mover",[r,n]);return n}}),mt({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],numArgs:1,primitive:!0,handler(e,t){let r=e.parser,n=e.funcName;const o=t[0];return{type:"mclass",mode:r.mode,mclass:"m"+n.slice(5),body:dt(o),isCharacterBox:m(o)}},htmlBuilder:function(e,t){const r=xt(e.body,t,!0);return Ye([e.mclass],r,t)},mathmlBuilder:function(e,t){let r;const n=Ft(e.body,t);return"minner"===e.mclass?r=new Bt("mpadded",n):"mord"===e.mclass?e.isCharacterBox?(r=n[0],r.type="mi"):r=new Bt("mi",n):(e.isCharacterBox?(r=n[0],r.type="mo"):r=new Bt("mo",n),"mbin"===e.mclass?(r.attributes.lspace="0.22em",r.attributes.rspace="0.22em"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0.17em"):"mopen"!==e.mclass&&"mclose"!==e.mclass||(r.attributes.lspace="0em",r.attributes.rspace="0em")),r}});const ur=e=>{const t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};mt({type:"mclass",names:["\\@binrel"],numArgs:2,handler(e,t){return{type:"mclass",mode:e.parser.mode,mclass:ur(t[0]),body:dt(t[1]),isCharacterBox:m(t[1])}}}),mt({type:"mclass",names:["\\stackrel","\\overset","\\underset"],numArgs:2,handler(e,t){let r=e.parser,n=e.funcName;const o=t[1],s=t[0];let i;i="\\stackrel"!==n?ur(o):"mrel";const a={type:"op",mode:o.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==n,body:dt(o)},l="\\underset"===n?{type:"supsub",mode:s.mode,base:a,sub:s}:{type:"supsub",mode:s.mode,base:a,sup:s};return{type:"mclass",mode:r.mode,mclass:i,body:[l],isCharacterBox:m(l)}}}),mt({type:"pmb",names:["\\pmb"],numArgs:1,allowedInText:!0,handler(e,t){return{type:"pmb",mode:e.parser.mode,mclass:ur(t[0]),body:dt(t[0])}},htmlBuilder(e,t){const r=xt(e.body,t,!0),n=Ye([e.mclass],r,t);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(e,t){const r=Ft(e.body,t),n=new Bt("mstyle",r);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});const pr={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},dr=()=>({type:"styling",body:[],mode:"math",style:"display",resetFont:!0}),gr=e=>"textord"===e.type&&"@"===e.text,fr=(e,t)=>("mathord"===e.type||"atom"===e.type)&&e.text===t;function br(e,t,r){const n=pr[e];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(n,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":{const e={type:"atom",text:n,mode:"math",family:"rel"},o={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[e],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[o],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{const e={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[e],[])}default:return{type:"textord",text:" ",mode:"math"}}}mt({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],numArgs:1,handler(e,t){let r=e.parser,n=e.funcName;return{type:"cdlabel",mode:r.mode,side:n.slice(4),label:t[0]}},htmlBuilder(e,t){const r=t.havingStyle(t.style.sup()),n=Ze(Mt(e.label,r,t),t);return n.classes.push("cd-label-"+e.side),n.style.bottom=N(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(e,t){let r=new Bt("mrow",[Vt(e.label,t)]);return r=new Bt("mpadded",[r]),r.setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new Bt("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),mt({type:"cdlabelparent",names:["\\\\cdparent"],numArgs:1,handler(e,t){return{type:"cdlabelparent",mode:e.parser.mode,fragment:t[0]}},htmlBuilder(e,t){const r=Ze(Mt(e.fragment,t),t);return r.classes.push("cd-vert-arrow"),r},mathmlBuilder(e,t){return new Bt("mrow",[Vt(e.fragment,t)])}}),mt({type:"textord",names:["\\@char"],numArgs:1,allowedInText:!0,handler(e,t){let r=e.parser;const o=ar(or(t[0],"ordgroup"),"\\@char has non-numeric argument");let s,i=parseInt(o);if(isNaN(i))throw new n("\\@char has non-numeric argument "+o);if(i<0||i>1114111)throw new n("\\@char with invalid code point "+o);return i<=65535?s=String.fromCharCode(i):(i-=65536,s=String.fromCharCode(55296+(i>>10),56320+(1023&i))),{type:"textord",mode:r.mode,text:s}}});mt({type:"color",names:["\\textcolor"],numArgs:2,allowedInText:!0,argTypes:["color","original"],handler(e,t){let r=e.parser;const n=or(t[0],"color-token").color,o=t[1];return{type:"color",mode:r.mode,color:n,body:dt(o)}},htmlBuilder:(e,t)=>{const r=xt(e.body,t.withColor(e.color),!1);return $e(r)},mathmlBuilder:(e,t)=>{const r=Ft(e.body,t.withColor(e.color)),n=new Bt("mstyle",r);return n.setAttribute("mathcolor",e.color),n}}),mt({type:"color",names:["\\color"],numArgs:1,allowedInText:!0,argTypes:["color"],handler(e,t){let r=e.parser,n=e.breakOnTokenText;const o=or(t[0],"color-token").color;r.gullet.macros.set("\\current@color",o);const s=r.parseExpression(!0,n);return{type:"color",mode:r.mode,color:o,body:s}}}),mt({type:"cr",names:["\\\\"],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,r){let n=e.parser;const o="["===n.gullet.future().text?n.parseSizeGroup(!0):null,s=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:s,size:o&&or(o,"size").value}},htmlBuilder(e,t){const r=Ye(["mspace"],[],t);return e.newLine&&(r.classes.push("katex-newline"),e.size&&(r.style.marginTop=N(H(e.size,t)))),r},mathmlBuilder(e,t){const r=new Bt("mspace");return e.newLine&&(r.setAttribute("linebreak","newline"),e.size&&r.setAttribute("height",N(H(e.size,t)))),r}});const yr={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},xr=e=>{const t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new n("Expected a control sequence",e);return t},wr=(e,t,r,n)=>{let o=e.gullet.macros.get(r.text);null==o&&(r.noexpand=!0,o={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,o,n)};mt({type:"internal",names:["\\global","\\long","\\\\globallong"],numArgs:0,allowedInText:!0,handler(e){let t=e.parser,r=e.funcName;t.consumeSpaces();const o=t.fetch();if(yr[o.text])return"\\global"!==r&&"\\\\globallong"!==r||(o.text=yr[o.text]),or(t.parseFunction(),"internal");throw new n("Invalid token after macro prefix",o)}}),mt({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){let t=e.parser,r=e.funcName,o=t.gullet.popToken();const s=o.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(s))throw new n("Expected a control sequence",o);let i,a=0;const l=[[]];for(;"{"!==t.gullet.future().text;)if(o=t.gullet.popToken(),"#"===o.text){if("{"===t.gullet.future().text){i=t.gullet.future(),l[a].push("{");break}if(o=t.gullet.popToken(),!/^[1-9]$/.test(o.text))throw new n('Invalid argument number "'+o.text+'"');if(parseInt(o.text)!==a+1)throw new n('Argument number "'+o.text+'" out of order');a++,l.push([])}else{if("EOF"===o.text)throw new n("Expected a macro definition");l[a].push(o.text)}let c=t.gullet.consumeArg().tokens;return i&&c.unshift(i),"\\edef"!==r&&"\\xdef"!==r||(c=t.gullet.expandTokens(c),c.reverse()),t.gullet.macros.set(s,{tokens:c,numArgs:a,delimiters:l},r===yr[r]),{type:"internal",mode:t.mode}}}),mt({type:"internal",names:["\\let","\\\\globallet"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){let t=e.parser,r=e.funcName;const n=xr(t.gullet.popToken());t.gullet.consumeSpaces();const o=(e=>{let t=e.gullet.popToken();return"="===t.text&&(t=e.gullet.popToken()," "===t.text&&(t=e.gullet.popToken())),t})(t);return wr(t,n,o,"\\\\globallet"===r),{type:"internal",mode:t.mode}}}),mt({type:"internal",names:["\\futurelet","\\\\globalfuture"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){let t=e.parser,r=e.funcName;const n=xr(t.gullet.popToken()),o=t.gullet.popToken(),s=t.gullet.popToken();return wr(t,n,s,"\\\\globalfuture"===r),t.gullet.pushToken(s),t.gullet.pushToken(o),{type:"internal",mode:t.mode}}});const vr=function(e,t,r){const n=ee(ne.math[e]&&ne.math[e].replace||e,t,r);if(!n)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return n},kr=function(e,t,r,n){const o=r.havingBaseStyle(t),s=Ye(n.concat(o.sizingClasses(r)),[e],r),i=o.sizeMultiplier/r.sizeMultiplier;return s.height*=i,s.depth*=i,s.maxFontSize=o.sizeMultiplier,s},zr=function(e,t,r){const n=t.havingBaseStyle(r),o=(1-t.sizeMultiplier/n.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=N(o),e.height-=o,e.depth+=o},Sr=function(e,t,r,n,o,s){const i=function(e,t,r,n){return Pe(e,"Size"+t+"-Regular",r,n)}(e,t,o,n),a=kr(Ye(["delimsizing","size"+t],[i],n),S.TEXT,n,s);return r&&zr(a,n,S.TEXT),a},Mr=function(e,t,r){let n;n="Size1-Regular"===t?"delim-size1":"delim-size4";return{type:"elem",elem:Ye(["delimsizinginner",n],[Ye([],[Pe(e,t,r)])])}},Ar=function(e,t,r){const n=K["Size4-Regular"][e.charCodeAt(0)]?K["Size4-Regular"][e.charCodeAt(0)][4]:K["Size1-Regular"][e.charCodeAt(0)][4],o=new $("inner",function(e,t){switch(e){case"\u239c":return C("M291 0 H417 V"+t+" H291z");case"\u2223":return C("M145 0 H188 V"+t+" H145z");case"\u2225":return C("M145 0 H188 V"+t+" H145z")+C("M367 0 H410 V"+t+" H367z");case"\u239f":return C("M457 0 H583 V"+t+" H457z");case"\u23a2":return C("M319 0 H403 V"+t+" H319z");case"\u23a5":return C("M263 0 H347 V"+t+" H263z");case"\u23aa":return C("M384 0 H504 V"+t+" H384z");case"\u23d0":return C("M312 0 H355 V"+t+" H312z");case"\u2016":return C("M257 0 H300 V"+t+" H257z")+C("M478 0 H521 V"+t+" H478z");default:return""}}(e,Math.round(1e3*t))),s=new _([o],{width:N(n),height:N(t),style:"width:"+N(n),viewBox:"0 0 "+1e3*n+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),i=We([],[s],r);return i.height=t,i.style.height=N(t),i.style.width=N(n),{type:"elem",elem:i}},Tr={type:"kern",size:-.008},Cr=new Set(["|","\\lvert","\\rvert","\\vert"]),Br=new Set(["\\|","\\lVert","\\rVert","\\Vert"]),qr=function(e,t,r,n,o,s){let i,a,l,c,h="",m=0;i=l=c=e,a=null;let u="Size1-Regular";"\\uparrow"===e?l=c="\u23d0":"\\Uparrow"===e?l=c="\u2016":"\\downarrow"===e?i=l="\u23d0":"\\Downarrow"===e?i=l="\u2016":"\\updownarrow"===e?(i="\\uparrow",l="\u23d0",c="\\downarrow"):"\\Updownarrow"===e?(i="\\Uparrow",l="\u2016",c="\\Downarrow"):Cr.has(e)?(l="\u2223",h="vert",m=333):Br.has(e)?(l="\u2225",h="doublevert",m=556):"["===e||"\\lbrack"===e?(i="\u23a1",l="\u23a2",c="\u23a3",u="Size4-Regular",h="lbrack",m=667):"]"===e||"\\rbrack"===e?(i="\u23a4",l="\u23a5",c="\u23a6",u="Size4-Regular",h="rbrack",m=667):"\\lfloor"===e||"\u230a"===e?(l=i="\u23a2",c="\u23a3",u="Size4-Regular",h="lfloor",m=667):"\\lceil"===e||"\u2308"===e?(i="\u23a1",l=c="\u23a2",u="Size4-Regular",h="lceil",m=667):"\\rfloor"===e||"\u230b"===e?(l=i="\u23a5",c="\u23a6",u="Size4-Regular",h="rfloor",m=667):"\\rceil"===e||"\u2309"===e?(i="\u23a4",l=c="\u23a5",u="Size4-Regular",h="rceil",m=667):"("===e||"\\lparen"===e?(i="\u239b",l="\u239c",c="\u239d",u="Size4-Regular",h="lparen",m=875):")"===e||"\\rparen"===e?(i="\u239e",l="\u239f",c="\u23a0",u="Size4-Regular",h="rparen",m=875):"\\{"===e||"\\lbrace"===e?(i="\u23a7",a="\u23a8",c="\u23a9",l="\u23aa",u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(i="\u23ab",a="\u23ac",c="\u23ad",l="\u23aa",u="Size4-Regular"):"\\lgroup"===e||"\u27ee"===e?(i="\u23a7",c="\u23a9",l="\u23aa",u="Size4-Regular"):"\\rgroup"===e||"\u27ef"===e?(i="\u23ab",c="\u23ad",l="\u23aa",u="Size4-Regular"):"\\lmoustache"===e||"\u23b0"===e?(i="\u23a7",c="\u23ad",l="\u23aa",u="Size4-Regular"):"\\rmoustache"!==e&&"\u23b1"!==e||(i="\u23ab",c="\u23a9",l="\u23aa",u="Size4-Regular");const p=vr(i,u,o),d=p.height+p.depth,g=vr(l,u,o),f=g.height+g.depth,b=vr(c,u,o),y=b.height+b.depth;let x=0,w=1;if(null!==a){const e=vr(a,u,o);x=e.height+e.depth,w=2}const v=d+y+x,k=v+Math.max(0,Math.ceil((t-v)/(w*f)))*w*f;let z=n.fontMetrics().axisHeight;r&&(z*=n.sizeMultiplier);const M=k/2-z,A=[];if(h.length>0){const e=k-d-y,t=Math.round(1e3*k),r=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v"+t+" v1759 v84 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v"+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z";case"doublevert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z\nM367 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v"+t+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+t+" v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+t+" v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v602 h84z\nM403 1759 V0 H319 V1759 v"+t+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v602 h84z\nM347 1759 V0 h-84 V1759 v"+t+" v602 h84z";case"lparen":return"M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0,"+(t+84)+"c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-"+(t+92)+"c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";case"rparen":return"M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,"+(t+9)+"\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-"+(t+144)+"c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";default:throw new Error("Unknown stretchy delimiter.")}}(h,Math.round(1e3*e)),o=new $(h,r),s=N(m/1e3),i=N(t/1e3),a=new _([o],{width:s,height:i,viewBox:"0 0 "+m+" "+t}),l=We([],[a],n);l.height=t/1e3,l.style.width=s,l.style.height=i,A.push({type:"elem",elem:l})}else{if(A.push(Mr(c,u,o)),A.push(Tr),null===a){const e=k-d-y+.016;A.push(Ar(l,e,n))}else{const e=(k-d-y-x)/2+.016;A.push(Ar(l,e,n)),A.push(Tr),A.push(Mr(a,u,o)),A.push(Tr),A.push(Ar(l,e,n))}A.push(Tr),A.push(Mr(i,u,o))}const T=n.havingBaseStyle(S.TEXT),C=Ke({positionType:"bottom",positionData:M,children:A});return kr(Ye(["delimsizing","mult"],[C],T),S.TEXT,n,s)},Ir=.08,Rr=function(e,t,r,n,o){const s=function(e,t,r){t*=1e3;let n="";switch(e){case"sqrtMain":n=function(e,t){return"M95,"+(622+e+t)+"\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl"+e/2.075+" -"+e+"\nc5.3,-9.3,12,-14,20,-14\nH400000v"+(40+e)+"H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM"+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize1":n=function(e,t){return"M263,"+(601+e+t)+"c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl"+e/2.084+" -"+e+"\nc4.7,-7.3,11,-11,19,-11\nH40000v"+(40+e)+"H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize2":n=function(e,t){return"M983 "+(10+e+t)+"\nl"+e/3.13+" -"+e+"\nc4,-6.7,10,-10,18,-10 H400000v"+(40+e)+"\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize3":n=function(e,t){return"M424,"+(2398+e+t)+"\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl"+e/4.223+" -"+e+"c4,-6.7,10,-10,18,-10 H400000\nv"+(40+e)+"H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M"+(1001+e)+" "+t+"\nh400000v"+(40+e)+"h-400000z"}(t,B);break;case"sqrtSize4":n=function(e,t){return"M473,"+(2713+e+t)+"\nc339.3,-1799.3,509.3,-2700,510,-2702 l"+e/5.298+" -"+e+"\nc3.3,-7.3,9.3,-11,18,-11 H400000v"+(40+e)+"H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM"+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"}(t,B);break;case"sqrtTall":n=function(e,t,r){return"M702 "+(e+t)+"H400000"+(40+e)+"\nH742v"+(r-54-t-e)+"l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 "+t+"H400000v"+(40+e)+"H742z"}(t,B,r)}return n}(e,n,r),i=new $(e,s),a=new _([i],{width:"400em",height:N(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return We(["hide-tail"],[a],o)},Or=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","\\surd"]),Er=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1"]),Hr=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Nr=[0,1.2,1.8,2.4,3],Dr=function(e,t,r,o,s){if("<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),Or.has(e)||Hr.has(e))return Sr(e,t,!1,r,o,s);if(Er.has(e))return qr(e,Nr[t],!1,r,o,s);throw new n("Illegal delimiter: '"+e+"'")},Lr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],Fr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"stack"}],Pr=[{type:"small",style:S.SCRIPTSCRIPT},{type:"small",style:S.SCRIPT},{type:"small",style:S.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],Vr=function(e){if("small"===e.type)return"Main-Regular";if("large"===e.type)return"Size"+e.size+"-Regular";if("stack"===e.type)return"Size4-Regular";{const t=e.type;throw new Error("Add support for delim type '"+t+"' here.")}},Gr=function(e,t,r,n){for(let o=Math.min(2,3-n.style.size);ot)return s}return r[r.length-1]},jr=function(e,t,r,n,o,s){let i;"<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),i=Hr.has(e)?Lr:Or.has(e)?Pr:Fr;const a=Gr(e,t,i,n);return"small"===a.type?function(e,t,r,n,o,s){const i=Pe(e,"Main-Regular",o,n),a=kr(i,t,n,s);return r&&zr(a,n,t),a}(e,a.style,r,n,o,s):"large"===a.type?Sr(e,a.size,r,n,o,s):qr(e,t,r,n,o,s)},Ur=function(e,t,r,n,o,s){const i=n.fontMetrics().axisHeight*n.sizeMultiplier,a=5/n.fontMetrics().ptPerEm,l=Math.max(t-i,r+i),c=Math.max(l/500*901,2*l-a);return jr(e,c,!0,n,o,s)},Xr={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},Yr=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27e8","\\rangle","\u27e9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]);function Wr(e){return"isMiddle"in e}function _r(e,t){const r=ir(e);if(r&&Yr.has(r.text))return r;throw new n(r?"Invalid delimiter '"+r.text+"' after '"+t.funcName+"'":"Invalid delimiter type '"+e.type+"'",e)}function $r(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}mt({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],numArgs:1,argTypes:["primitive"],handler:(e,t)=>{const r=_r(pt(t[0]),e);return{type:"delimsizing",mode:e.parser.mode,size:Xr[e.funcName].size,mclass:Xr[e.funcName].mclass,delim:r.text}},htmlBuilder:(e,t)=>"."===e.delim?Ye([e.mclass]):Dr(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{const t=[];"."!==e.delim&&t.push(Et(e.delim,e.mode));const r=new Bt("mo",t);"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r.setAttribute("stretchy","true");const n=N(Nr[e.size]);return r.setAttribute("minsize",n),r.setAttribute("maxsize",n),r}}),mt({type:"leftright-right",names:["\\right"],numArgs:1,primitive:!0,handler:(e,t)=>{const r=e.parser.gullet.macros.get("\\current@color");if(r&&"string"!=typeof r)throw new n("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:e.parser.mode,delim:_r(t[0],e).text,color:r}}}),mt({type:"leftright",names:["\\left"],numArgs:1,primitive:!0,handler:(e,t)=>{const r=_r(t[0],e),n=e.parser;++n.leftrightDepth;const o=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);const s=or(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:o,left:r.text,right:s.delim,rightColor:s.color}},htmlBuilder:(e,t)=>{$r(e);const r=xt(e.body,t,!0,["mopen","mclose"]);let n,o,s=0,i=0,a=!1;for(let e=0;e{$r(e);const r=Ft(e.body,t);if("."!==e.left){const t=new Bt("mo",[Et(e.left,e.mode)]);t.setAttribute("fence","true"),r.unshift(t)}if("."!==e.right){const t=new Bt("mo",[Et(e.right,e.mode)]);t.setAttribute("fence","true"),e.rightColor&&t.setAttribute("mathcolor",e.rightColor),r.push(t)}return Ht(r)}}),mt({type:"middle",names:["\\middle"],numArgs:1,primitive:!0,handler:(e,t)=>{const r=_r(t[0],e);if(!e.parser.leftrightDepth)throw new n("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},htmlBuilder:(e,t)=>{let r;return"."===e.delim?r=St(t,[]):(r=Dr(e.delim,1,t,e.mode,[]),r.isMiddle={delim:e.delim,options:t}),r},mathmlBuilder:(e,t)=>{const r="\\vert"===e.delim||"|"===e.delim?Et("|","text"):Et(e.delim,e.mode),n=new Bt("mo",[r]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});mt({type:"enclose",names:["\\colorbox"],numArgs:2,allowedInText:!0,argTypes:["color","hbox"],handler(e,t,r){let n=e.parser,o=e.funcName;const s=or(t[0],"color-token").color,i=t[1];return{type:"enclose",mode:n.mode,label:o,backgroundColor:s,body:i}},htmlBuilder:(e,t)=>{const r=Ze(Mt(e.body,t),t),n=e.label.slice(1);let o,s,i=t.sizeMultiplier;const a=m(e.body);if("sout"===n)o=Ye(["katex-stretchy","katex-sout"]),o.height=t.fontMetrics().defaultRuleThickness/i,s=-.5*t.fontMetrics().xHeight;else if("phase"===n){const e=H({number:.6,unit:"pt"},t),n=H({number:.35,unit:"ex"},t);i/=t.havingBaseSizing().sizeMultiplier;const a=r.height+r.depth+e+n;r.style.paddingLeft=N(a/2+e);const c=Math.floor(1e3*a*i),h="M400000 "+(l=c)+" H0 L"+l/2+" 0 l65 45 L145 "+(l-80)+" H400000z",m=new _([new $("phase",h)],{width:"400em",height:N(c/1e3),viewBox:"0 0 400000 "+c,preserveAspectRatio:"xMinYMin slice"});o=We(["hide-tail"],[m],t),o.style.height=N(a),s=r.depth+e+n}else{let i,l;/cancel/.test(n)?a||r.classes.push("cancel-pad"):"angl"===n?r.classes.push("anglpad"):r.classes.push("boxpad");let c=0;/box/.test(n)?(c=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),i=t.fontMetrics().fboxsep+("colorbox"===n?0:c),l=i):"angl"===n?(c=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness),i=4*c,l=Math.max(0,.25-r.depth)):(i=a?.2:0,l=i),o=function(e,t,r,n,o){let s;const i=e.height+e.depth+r+n;if(/fbox|color|angl/.test(t)){if(s=Ye(["katex-stretchy",t],[],o),"fbox"===t){const e=o.color&&o.getColor();e&&(s.style.borderColor=e)}}else{const e=[];/^[bx]cancel$/.test(t)&&e.push(new Z({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&e.push(new Z({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));const r=new _(e,{width:"100%",height:N(i)});s=We([],[r],o)}return s.height=i,s.style.height=N(i),s}(r,n,i,l,t),/fbox|boxed|fcolorbox/.test(n)?(o.style.borderStyle="solid",o.style.borderWidth=N(c)):"angl"===n&&.049!==c&&(o.style.borderTopWidth=N(c),o.style.borderRightWidth=N(c)),s=r.depth+l,e.backgroundColor&&(o.style.backgroundColor=e.backgroundColor,e.borderColor&&(o.style.borderColor=e.borderColor))}var l;let c;if(e.backgroundColor)c=Ke({positionType:"individualShift",children:[{type:"elem",elem:o,shift:s},{type:"elem",elem:r,shift:0}]});else{const e=/cancel|phase/.test(n)?["svg-align"]:[];c=Ke({positionType:"individualShift",children:[{type:"elem",elem:r,shift:0},{type:"elem",elem:o,shift:s,wrapperClasses:e}]})}return/cancel/.test(n)&&(c.height=r.height,c.depth=r.depth),/cancel/.test(n)&&!a?Ye(["mord","cancel-lap"],[c],t):Ye(["mord"],[c],t)},mathmlBuilder:(e,t)=>{let r;const n=new Bt(e.label.includes("colorbox")?"mpadded":"menclose",[Vt(e.body,t)]);switch(e.label){case"\\cancel":n.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":n.setAttribute("notation","downdiagonalstrike");break;case"\\phase":n.setAttribute("notation","phasorangle");break;case"\\sout":n.setAttribute("notation","horizontalstrike");break;case"\\fbox":n.setAttribute("notation","box");break;case"\\angl":n.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(r=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*r+"pt"),n.setAttribute("height","+"+2*r+"pt"),n.setAttribute("lspace",r+"pt"),n.setAttribute("voffset",r+"pt"),"\\fcolorbox"===e.label){const r=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);n.setAttribute("style","border: "+N(r)+" solid "+e.borderColor)}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return e.backgroundColor&&n.setAttribute("mathbackground",e.backgroundColor),n}}),mt({type:"enclose",names:["\\fcolorbox"],numArgs:3,allowedInText:!0,argTypes:["color","color","hbox"],handler(e,t,r){let n=e.parser,o=e.funcName;const s=or(t[0],"color-token").color,i=or(t[1],"color-token").color,a=t[2];return{type:"enclose",mode:n.mode,label:o,backgroundColor:i,borderColor:s,body:a}}}),mt({type:"enclose",names:["\\fbox"],numArgs:1,argTypes:["hbox"],allowedInText:!0,handler(e,t){return{type:"enclose",mode:e.parser.mode,label:"\\fbox",body:t[0]}}}),mt({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\phase"],numArgs:1,handler(e,t){let r=e.parser,n=e.funcName;const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}}}),mt({type:"enclose",names:["\\sout"],numArgs:1,allowedInText:!0,handler(e,t){let r=e.parser,n=e.funcName;"math"===r.mode&&r.settings.reportNonstrict("mathVsSout","LaTeX's \\sout works only in text mode");const o=t[0];return{type:"enclose",mode:r.mode,label:n,body:o}}}),mt({type:"enclose",names:["\\angl"],numArgs:1,argTypes:["hbox"],allowedInText:!1,handler(e,t){return{type:"enclose",mode:e.parser.mode,label:"\\angl",body:t[0]}}});const Zr={};function Kr(e){let t=e.type,r=e.names,n=e.props,o=e.handler,s=e.htmlBuilder,i=e.mathmlBuilder;const a={type:t,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:o};for(let e=0;e{if(!e.parser.settings.displayMode)throw new n("{"+e.envName+"} can be used only in display mode.")},on=new Set(["gather","gather*"]);function sn(e){if(!e.includes("ed"))return!e.includes("*")}function an(e,t,r){let o=t.hskipBeforeAndAfter,s=t.addJot,i=t.cols,a=t.arraystretch,l=t.colSeparationType,c=t.autoTag,h=t.singleRow,m=t.emptySingleRow,u=t.maxNumCols,p=t.leqno;if(e.gullet.beginGroup(),h||e.gullet.macros.set("\\cr","\\\\\\relax"),!a){const t=e.gullet.expandMacroAsText("\\arraystretch");if(null==t)a=1;else if(a=parseFloat(t),!a||a<0)throw new n("Invalid \\arraystretch: "+t)}e.gullet.beginGroup();let d=[];const g=[d],f=[],b=[],y=null!=c?[]:void 0;function x(){c&&e.gullet.macros.set("\\@eqnsw","1",!0)}function w(){y&&(e.gullet.macros.get("\\df@tag")?(y.push(e.subparse([new tn("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(c)&&"1"===e.gullet.macros.get("\\@eqnsw")))}for(x(),b.push(rn(e));;){const t=e.parseExpression(!1,h?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup();let o={type:"ordgroup",mode:e.mode,body:t};r&&(o={type:"styling",mode:e.mode,style:r,resetFont:!0,body:[o]}),d.push(o);const s=e.fetch().text;if("&"===s){if(u&&d.length===u){if(h||l)throw new n("Too many tab characters: &",e.nextToken);e.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}e.consume()}else{if("\\end"===s){w(),1!==d.length||"styling"!==o.type||1!==o.body.length||"ordgroup"!==o.body[0].type||0!==o.body[0].body.length||!(g.length>1)&&m||Array.isArray(null==y?void 0:y[y.length-1])||g.pop(),b.length0&&(y+=.25),c.push({pos:y,isDashed:e[t]})}for(x(i[0]),r=0;r0&&(u+=b,ce))for(r=0;r=a)continue;var B,q;if(o>0||e.hskipBeforeAndAfter)i=null!=(B=null==(q=c)?void 0:q.pregap)?B:u,0!==i&&(z=Ye(["arraycolsep"],[]),z.style.width=N(i),k.push(z));const p=[];for(r=0;r0){const e=_e("katex-hline",t,h),r=_e("katex-hdashline",t,h),n=[{type:"elem",elem:O,shift:0}];for(;c.length>0;){const t=c.pop(),o=t.pos-w;t.isDashed?n.push({type:"elem",elem:r,shift:o}):n.push({type:"elem",elem:e,shift:o})}O=Ke({positionType:"individualShift",children:n})}if(0===A.length)return Ye(["mord"],[O],t);{const e=Ke({positionType:"individualShift",children:A}),r=Ye(["katex-tag"],[e],t);return $e([O,r])}},hn={c:"center ",l:"left ",r:"right "},mn=function(e,t){const r=[],n=new Bt("mtd",[],["mtr-glue"]),o=new Bt("mtd",[],["mml-eqn-num"]);for(let s=0;s0){const t=e.cols;let r="",n=!1,o=0,i=t.length;"separator"===t[0].type&&(a+="top ",o=1),"separator"===t[t.length-1].type&&(a+="bottom ",i-=1);for(let e=o;e0?"left ":"",a+=h[h.length-1].length>0?"right ":"";for(let e=1;e0&&c&&(n=1),r[e]={type:"align",align:t,pregap:n,postgap:0}}return s.colSeparationType=c?"align":"alignat",s};Kr({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){const r=(ir(t[0])?[t[0]]:or(t[0],"ordgroup").body).map(function(e){const t=sr(e).text;if("lcr".includes(t))return{type:"align",align:t};if("|"===t)return{type:"separator",separator:"|"};if(":"===t)return{type:"separator",separator:":"};throw new n("Unknown column alignment: "+t,e)}),o={cols:r,hskipBeforeAndAfter:!0,maxNumCols:r.length};return an(e.parser,o,ln(e.envName))},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){const t={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")];let r="c";const o={hskipBeforeAndAfter:!1,cols:[{type:"align",align:r}]};if("*"===e.envName.charAt(e.envName.length-1)){const t=e.parser;if(t.consumeSpaces(),"["===t.fetch().text){if(t.consume(),t.consumeSpaces(),r=t.fetch().text,!"lcr".includes(r))throw new n("Expected l or c or r",t.nextToken);t.consume(),t.consumeSpaces(),t.expect("]"),t.consume(),o.cols=[{type:"align",align:r}]}}const s=an(e.parser,o,ln(e.envName)),i=Math.max(0,...s.body.map(e=>e.length));return s.cols=new Array(i).fill({type:"align",align:r}),t?{type:"leftright",mode:e.mode,body:[s],left:t[0],right:t[1],rightColor:void 0}:s},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){const t=an(e.parser,{arraystretch:.5},"script");return t.colSeparationType="small",t},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){const r=(ir(t[0])?[t[0]]:or(t[0],"ordgroup").body).map(function(e){const t=sr(e).text;if("lc".includes(t))return{type:"align",align:t};throw new n("Unknown column alignment: "+t,e)});if(r.length>1)throw new n("{subarray} can contain only one column");const o={cols:r,hskipBeforeAndAfter:!1,arraystretch:.5},s=an(e.parser,o,"script");if(s.body.length>0&&s.body[0].length>1)throw new n("{subarray} can contain only one column");return s},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){const t=an(e.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},ln(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.includes("r")?".":"\\{",right:e.envName.includes("r")?"\\}":".",rightColor:void 0}},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:un,htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){on.has(e.envName)&&nn(e);const t={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:sn(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return an(e.parser,t,"display")},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:un,htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){nn(e);const t={autoTag:sn(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return an(e.parser,t,"display")},htmlBuilder:cn,mathmlBuilder:mn}),Kr({type:"array",names:["CD"],props:{numArgs:0},handler(e){return nn(e),function(e){const t=[];for(e.gullet.beginGroup(),e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,"\\\\")),e.gullet.endGroup(),e.gullet.beginGroup();const r=e.fetch().text;if("&"!==r&&"\\\\"!==r){if("\\end"===r){0===t[t.length-1].length&&t.pop();break}throw new n("Expected \\\\ or \\cr or \\end",e.nextToken)}e.consume()}let r=[];const o=[r];for(let s=0;sAV".includes(o))throw new n('Expected one of "<>AV=|." after @',i[t]);for(let e=0;e<2;e++){let r=!0;for(let a=t+1;a{let r=e.parser,n=e.funcName;const o=pt(t[0]),s=n in dn?dn[n]:n;return{type:"font",mode:r.mode,font:s.slice(1),body:o}},htmlBuilder:(e,t)=>{const r=e.font,n=t.withFont(r);return Mt(e.body,n)},mathmlBuilder:(e,t)=>{const r=e.font,n=t.withFont(r);return Vt(e.body,n)}}),mt({type:"mclass",names:["\\boldsymbol","\\bm"],numArgs:1,handler:(e,t)=>{let r=e.parser;const n=t[0];return{type:"mclass",mode:r.mode,mclass:ur(n),body:[{type:"font",mode:r.mode,font:"boldsymbol",body:n}],isCharacterBox:m(n)}}}),mt({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],numArgs:0,allowedInText:!0,handler:(e,t)=>{let r=e.parser,n=e.funcName,o=e.breakOnTokenText;const s=r.mode,i=r.parseExpression(!0,o);return{type:"font",mode:s,font:"math"+n.slice(1),body:{type:"ordgroup",mode:r.mode,body:i}}}});const gn=(e,t)=>{if(!t)return e;return{type:"styling",mode:e.mode,style:t,body:[e]}};mt({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{let r=e.parser,n=e.funcName;const o=t[0],s=t[1];let i,a=null,l=null;switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":i=!0;break;case"\\\\atopfrac":i=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":i=!1,a="(",l=")";break;case"\\\\bracefrac":i=!1,a="\\{",l="\\}";break;case"\\\\brackfrac":i=!1,a="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}const c="\\cfrac"===n;let h=null;return c||n.startsWith("\\d")?h="display":n.startsWith("\\t")&&(h="text"),gn({type:"genfrac",mode:r.mode,numer:o,denom:s,continued:c,hasBarLine:i,leftDelim:a,rightDelim:l,barSize:null},h)},htmlBuilder:(e,t)=>{const r=t.style,n=r.fracNum(),o=r.fracDen();let s;s=t.havingStyle(n);const i=Mt(e.numer,s,t);if(e.continued){const e=8.5/t.fontMetrics().ptPerEm,r=3.5/t.fontMetrics().ptPerEm;i.height=i.height0?3*h:7*h,p=t.fontMetrics().denom1):(c>0?(m=t.fontMetrics().num2,u=h):(m=t.fontMetrics().num3,u=3*h),p=t.fontMetrics().denom2),l){const e=t.fontMetrics().axisHeight;m-i.depth-(e+.5*c){const r=new Bt("mfrac",[Vt(e.numer,t),Vt(e.denom,t)]);if(e.hasBarLine){if(e.barSize){const n=H(e.barSize,t);r.setAttribute("linethickness",N(n))}}else r.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){const t=[];if(null!=e.leftDelim){const r=new Bt("mo",[new qt(e.leftDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}if(t.push(r),null!=e.rightDelim){const r=new Bt("mo",[new qt(e.rightDelim.replace("\\",""))]);r.setAttribute("fence","true"),t.push(r)}return Ht(t)}return r}}),mt({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],numArgs:0,infix:!0,handler(e){let t,r=e.parser,n=e.funcName,o=e.token;switch(n){case"\\over":t="\\frac";break;case"\\choose":t="\\binom";break;case"\\atop":t="\\\\atopfrac";break;case"\\brace":t="\\\\bracefrac";break;case"\\brack":t="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:r.mode,replaceWith:t,token:o}}});const fn=["display","text","script","scriptscript"],bn=function(e){let t=null;return e.length>0&&(t=e,t="."===t?null:t),t};mt({type:"genfrac",names:["\\genfrac"],numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"],handler(e,t){let r=e.parser;const n=t[4],o=t[5],s=pt(t[0]),i="atom"===s.type&&"open"===s.family?bn(s.text):null,a=pt(t[1]),l="atom"===a.type&&"close"===a.family?bn(a.text):null,c=or(t[2],"size");let h,m=null;c.isBlank?h=!0:(m=c.value,h=m.number>0);let u=null,p=t[3];if("ordgroup"===p.type){if(p.body.length>0){const e=or(p.body[0],"textord");u=fn[Number(e.text)]}}else p=or(p,"textord"),u=fn[Number(p.text)];return gn({type:"genfrac",mode:r.mode,numer:n,denom:o,continued:!1,hasBarLine:h,barSize:m,leftDelim:i,rightDelim:l},u)}}),mt({type:"infix",names:["\\above"],numArgs:1,argTypes:["size"],infix:!0,handler(e,t){let r=e.parser,n=(e.funcName,e.token);return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:or(t[0],"size").value,token:n}}}),mt({type:"genfrac",names:["\\\\abovefrac"],numArgs:3,argTypes:["math","size","math"],handler:(e,t)=>{let r=e.parser;e.funcName;const n=t[0],o=or(t[1],"infix").size;if(!o)throw new Error("\\\\abovefrac expected size, but got "+String(o));const s=t[2],i=o.number>0;return{type:"genfrac",mode:r.mode,numer:n,denom:s,continued:!1,hasBarLine:i,barSize:o,leftDelim:null,rightDelim:null}}});const yn=(e,t)=>{const r=t.style;let n,o;"supsub"===e.type?(n=e.sup?Mt(e.sup,t.havingStyle(r.sup()),t):Mt(e.sub,t.havingStyle(r.sub()),t),o=or(e.base,"horizBrace")):o=or(e,"horizBrace");const s=Mt(o.base,t.havingBaseStyle(S.DISPLAY)),i=tr(o,t);let a;if(a=o.isOver?Ke({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:i,wrapperClasses:["svg-align"]}]}):Ke({positionType:"bottom",positionData:s.depth+.1+i.height,children:[{type:"elem",elem:i,wrapperClasses:["svg-align"]},{type:"kern",size:.1},{type:"elem",elem:s}]}),n){const e=Ye(["minner",o.isOver?"mover":"munder"],[a],t);a=o.isOver?Ke({positionType:"firstBaseline",children:[{type:"elem",elem:e},{type:"kern",size:.2},{type:"elem",elem:n}]}):Ke({positionType:"bottom",positionData:e.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:e}]})}return Ye(["minner",o.isOver?"mover":"munder"],[a],t)};mt({type:"horizBrace",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],numArgs:1,handler(e,t){let r=e.parser,n=e.funcName;return{type:"horizBrace",mode:r.mode,label:n,isOver:n.includes("\\over"),base:t[0]}},htmlBuilder:yn,mathmlBuilder:(e,t)=>{const r=Jt(e.label);return new Bt(e.isOver?"mover":"munder",[Vt(e.base,t),r])}}),mt({type:"href",names:["\\href"],numArgs:2,argTypes:["url","original"],allowedInText:!0,handler:(e,t)=>{let r=e.parser;const n=t[1],o=or(t[0],"url").url;return r.settings.isTrusted({command:"\\href",url:o})?{type:"href",mode:r.mode,href:o,body:dt(n)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:(e,t)=>{const r=xt(e.body,t,!1);return function(e,t,r,n){const o=new U(e,t,r,n);return Xe(o),o}(e.href,[],r,t)},mathmlBuilder:(e,t)=>{let r=Pt(e.body,t);return r instanceof Bt||(r=new Bt("mrow",[r])),r.setAttribute("href",e.href),r}}),mt({type:"href",names:["\\url"],numArgs:1,argTypes:["url"],allowedInText:!0,handler:(e,t)=>{let r=e.parser;const n=or(t[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:n}))return r.formatUnsupportedCmd("\\url");const o=[];for(let e=0;e{let r=e.parser,o=e.funcName;e.token;const s=or(t[0],"raw").string,i=t[1];let a;r.settings.strict&&r.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");const l={};switch(o){case"\\htmlClass":l.class=s,a={command:"\\htmlClass",class:s};break;case"\\htmlId":l.id=s,a={command:"\\htmlId",id:s};break;case"\\htmlStyle":l.style=s,a={command:"\\htmlStyle",style:s};break;case"\\htmlData":{const e="{,}",t=[];let r="";for(let n=0;n{const r=xt(e.body,t,!1),n=["enclosing"];e.attributes.class&&n.push(...e.attributes.class.trim().split(/\s+/));const o=Ye(n,r,t);for(const t of Object.entries(e.attributes)){const e=t[0],r=t[1];"class"!==e&&o.setAttribute(e,r)}return o},mathmlBuilder:(e,t)=>Pt(e.body,t)}),mt({type:"htmlmathml",names:["\\html@mathml"],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:"htmlmathml",mode:e.parser.mode,html:dt(t[0]),mathml:dt(t[1])}),htmlBuilder:(e,t)=>{const r=xt(e.html,t,!1);return $e(r)},mathmlBuilder:(e,t)=>Pt(e.mathml,t)});const xn=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};{const t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new n("Invalid size: '"+e+"' in \\includegraphics");const r={number:+(t[1]+t[2]),unit:t[3]};if(!E(r))throw new n("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r}};mt({type:"includegraphics",names:["\\includegraphics"],numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1,handler:(e,t,r)=>{let o=e.parser,s={number:0,unit:"em"},i={number:.9,unit:"em"},a={number:0,unit:"em"},l="";if(r[0]){const e=or(r[0],"raw").string.split(",");for(let t=0;t{const r=H(e.height,t);let n=0;e.totalheight.number>0&&(n=H(e.totalheight,t)-r);let o=0;e.width.number>0&&(o=H(e.width,t));const s={height:N(r+n)};o>0&&(s.width=N(o)),n>0&&(s.verticalAlign=N(-n));const i=new X(e.src,e.alt,s);return i.height=r,i.depth=n,i},mathmlBuilder:(e,t)=>{const r=new Bt("mglyph",[]);r.setAttribute("alt",e.alt);const n=H(e.height,t);let o=0;if(e.totalheight.number>0&&(o=H(e.totalheight,t)-n,r.setAttribute("valign",N(-o))),r.setAttribute("height",N(n+o)),e.width.number>0){const n=H(e.width,t);r.setAttribute("width",N(n))}return r.setAttribute("src",e.src),r}}),mt({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0,handler(e,t){let r=e.parser,n=e.funcName;const o=or(t[0],"size");if(r.settings.strict){const e="m"===n[1],t="mu"===o.value.unit;e?(t||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, not "+o.value.unit+" units"),"math"!==r.mode&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):t&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:o.value}},htmlBuilder(e,t){return Je(e.dimension,t)},mathmlBuilder(e,t){const r=H(e.dimension,t);return new It(r)}}),mt({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],numArgs:1,allowedInText:!0,handler:(e,t)=>{let r=e.parser,n=e.funcName;const o=t[0];return{type:"lap",mode:r.mode,alignment:n.slice(5),body:o}},htmlBuilder:(e,t)=>{let r;"clap"===e.alignment?(r=Ye([],[Mt(e.body,t)]),r=Ye(["katex-inner"],[r],t)):r=Ye(["katex-inner"],[Mt(e.body,t)]);const n=Ye(["katex-fix"],[]);let o=Ye([e.alignment],[r,n],t);const s=Ye(["katex-strut"]);return s.style.height=N(o.height+o.depth),o.depth&&(s.style.verticalAlign=N(-o.depth)),o.children.unshift(s),o=Ye(["katex-thinbox"],[o],t),Ye(["mord","katex-vbox"],[o],t)},mathmlBuilder:(e,t)=>{const r=new Bt("mpadded",[Vt(e.body,t)]);if("rlap"!==e.alignment){const t="llap"===e.alignment?"-1":"-0.5";r.setAttribute("lspace",t+"width")}return r.setAttribute("width","0px"),r}}),mt({type:"styling",names:["\\(","$"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){let r=e.funcName,n=e.parser;const o=n.mode;n.switchMode("math");const s="\\("===r?"\\)":"$",i=n.parseExpression(!1,s);return n.expect(s),n.switchMode(o),{type:"styling",mode:n.mode,style:"text",resetFont:!0,body:i}}}),mt({type:"text",names:["\\)","\\]"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new n("Mismatched "+e.funcName)}});const wn=(e,t)=>{switch(t.style.size){case S.DISPLAY.size:return e.display;case S.TEXT.size:return e.text;case S.SCRIPT.size:return e.script;case S.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};mt({type:"mathchoice",names:["\\mathchoice"],numArgs:4,primitive:!0,handler:(e,t)=>({type:"mathchoice",mode:e.parser.mode,display:dt(t[0]),text:dt(t[1]),script:dt(t[2]),scriptscript:dt(t[3])}),htmlBuilder:(e,t)=>{const r=wn(e,t),n=xt(r,t,!1);return $e(n)},mathmlBuilder:(e,t)=>{const r=wn(e,t);return Pt(r,t)}});const vn=(e,t,r,n,o,s,i)=>{e=Ye([],[e]);const a=r&&m(r);let l,c,h;if(t){const e=Mt(t,n.havingStyle(o.sup()),n);c={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-e.depth)}}if(r){const e=Mt(r,n.havingStyle(o.sub()),n);l={elem:e,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-e.height)}}if(c&&l){const t=n.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+e.depth+i;h=Ke({positionType:"bottom",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:N(-s)},{type:"kern",size:l.kern},{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:N(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}else if(l){const t=e.height-i;h=Ke({positionType:"top",positionData:t,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:N(-s)},{type:"kern",size:l.kern},{type:"elem",elem:e}]})}else{if(!c)return e;{const t=e.depth+i;h=Ke({positionType:"bottom",positionData:t,children:[{type:"elem",elem:e},{type:"kern",size:c.kern},{type:"elem",elem:c.elem,marginLeft:N(s)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]})}}const u=[h];if(l&&0!==s&&!a){const e=Ye(["mspace"],[],n);e.style.marginRight=N(s),u.unshift(e)}return Ye(["mop","op-limits"],u,n)},kn=new Set(["\\smallint"]),zn=(e,t)=>{let r,n,o,s=!1;"supsub"===e.type?(r=e.sup,n=e.sub,o=or(e.base,"op"),s=!0):o=or(e,"op");const i=t.style;let a,l,c=!1;if(i.size===S.DISPLAY.size&&o.symbol&&!kn.has(o.name)&&(c=!0),o.symbol){const e=c?"Size2-Regular":"Size1-Regular";let r="";if("\\oiint"!==o.name&&"\\oiiint"!==o.name||(r=o.name.slice(1),o.name="oiint"===r?"\\iint":"\\iiint"),a=Pe(o.name,e,"math",t,["mop","op-symbol",c?"large-op":"small-op"]),l=a.italic,r.length>0){const e=rt(r+"Size"+(c?"2":"1"),t);a=Ke({positionType:"individualShift",children:[{type:"elem",elem:a,shift:0},{type:"elem",elem:e,shift:c?.08:0}]}),o.name="\\"+r,a.classes.unshift("mop"),a.italic=l}}else if(o.body){const e=xt(o.body,t,!0);1===e.length&&e[0]instanceof W?(a=e[0],a.classes[0]="mop"):a=Ye(["mop"],e,t)}else{const e=[];for(let r=1;r{let r=e.parser,n=e.funcName;return 1===n.length&&(n=Sn[n]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:zn,mathmlBuilder:(e,t)=>{let r;if(e.symbol)r=new Bt("mo",[Et(e.name,e.mode)]),kn.has(e.name)&&r.setAttribute("largeop","false");else if(e.body)r=new Bt("mo",Ft(e.body,t));else{r=new Bt("mi",[new qt(e.name.slice(1))]);const t=new Bt("mo",[Et("\u2061","text")]);r=e.parentIsSupSub?new Bt("mrow",[r,t]):Ct([r,t])}return r}}),mt({type:"op",names:["\\mathop"],numArgs:1,primitive:!0,handler:(e,t)=>{let r=e.parser;const n=t[0];return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:dt(n)}}});const Mn={"\u222b":"\\int","\u222c":"\\iint","\u222d":"\\iiint","\u222e":"\\oint","\u222f":"\\oiint","\u2230":"\\oiiint"};mt({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],numArgs:0,handler(e){let t=e.parser,r=e.funcName;return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:r}}}),mt({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],numArgs:0,handler(e){let t=e.parser,r=e.funcName;return{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:r}}}),mt({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222b","\u222c","\u222d","\u222e","\u222f","\u2230"],numArgs:0,allowedInArgument:!0,handler(e){let t=e.parser,r=e.funcName;return 1===r.length&&(r=Mn[r]),{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:r}}});const An=(e,t)=>{let r,n,o,s,i=!1;if("supsub"===e.type?(r=e.sup,n=e.sub,o=or(e.base,"operatorname"),i=!0):o=or(e,"operatorname"),o.body.length>0){const e=o.body.map(e=>{const t="text"in e?e.text:void 0;return"string"==typeof t?{type:"textord",mode:e.mode,text:t}:e}),r=xt(e,t.withFont("mathrm"),!0);for(let e=0;e{let r=e.parser,n=e.funcName;const o=t[0];return{type:"operatorname",mode:r.mode,body:dt(o),alwaysHandleSupSub:"\\operatornamewithlimits"===n,limits:!1,parentIsSupSub:!1}},htmlBuilder:An,mathmlBuilder:(e,t)=>{let r=Ft(e.body,t.withFont("mathrm")),n=!0;for(let e=0;ee.toText()).join("");r=[new qt(e)]}const o=new Bt("mi",r);o.setAttribute("mathvariant","normal");const s=new Bt("mo",[Et("\u2061","text")]);return e.parentIsSupSub?new Bt("mrow",[o,s]):Ct([o,s])}}),Qr("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),ut({type:"ordgroup",htmlBuilder(e,t){return e.semisimple?$e(xt(e.body,t,!1)):Ye(["mord"],xt(e.body,t,!0),t)},mathmlBuilder(e,t){return Pt(e.body,t,!0)}}),mt({type:"overline",names:["\\overline"],numArgs:1,handler(e,t){let r=e.parser;const n=t[0];return{type:"overline",mode:r.mode,body:n}},htmlBuilder(e,t){const r=Mt(e.body,t.havingCrampedStyle()),n=_e("overline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:r},{type:"kern",size:3*o},{type:"elem",elem:n},{type:"kern",size:o}]});return Ye(["mord","katex-overline"],[s],t)},mathmlBuilder(e,t){const r=new Bt("mo",[new qt("\u203e")]);r.setAttribute("stretchy","true");const n=new Bt("mover",[Vt(e.body,t),r]);return n.setAttribute("accent","true"),n}}),mt({type:"phantom",names:["\\phantom"],numArgs:1,allowedInText:!0,handler:(e,t)=>{let r=e.parser;const n=t[0];return{type:"phantom",mode:r.mode,body:dt(n)}},htmlBuilder:(e,t)=>{const r=xt(e.body,t.withPhantom(),!1);return $e(r)},mathmlBuilder:(e,t)=>{const r=Ft(e.body,t);return new Bt("mphantom",r)}}),Qr("\\hphantom","\\smash{\\phantom{#1}}"),mt({type:"vphantom",names:["\\vphantom"],numArgs:1,allowedInText:!0,handler:(e,t)=>{let r=e.parser;const n=t[0];return{type:"vphantom",mode:r.mode,body:n}},htmlBuilder:(e,t)=>{const r=Ye(["katex-inner"],[Mt(e.body,t.withPhantom())]),n=Ye(["katex-fix"],[]);return Ye(["mord","rlap"],[r,n],t)},mathmlBuilder:(e,t)=>{const r=Ft(dt(e.body),t),n=new Bt("mphantom",r),o=new Bt("mpadded",[n]);return o.setAttribute("width","0px"),o}}),mt({type:"raisebox",names:["\\raisebox"],numArgs:2,argTypes:["size","hbox"],allowedInText:!0,handler(e,t){let r=e.parser;const n=or(t[0],"size").value,o=t[1];return{type:"raisebox",mode:r.mode,dy:n,body:o}},htmlBuilder(e,t){const r=Mt(e.body,t),n=H(e.dy,t);return Ke({positionType:"shift",positionData:-n,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){const r=new Bt("mpadded",[Vt(e.body,t)]),n=e.dy.number+e.dy.unit;return r.setAttribute("voffset",n),r}});const Tn=(e,t)=>({type:"reflectbox",mode:e.parser.mode,body:t[0]});function Cn(e,t,r){const n=xt(e,t,!1),o=t.sizeMultiplier/r.sizeMultiplier;for(let e=0;e=0?a.setAttribute("height",N(o)):(a.setAttribute("height",N(o)),a.setAttribute("depth",N(-o))),a.setAttribute("voffset",N(o)),a}});const Bn=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];mt({type:"sizing",names:Bn,numArgs:0,allowedInText:!0,handler:(e,t)=>{let r=e.breakOnTokenText,n=e.funcName,o=e.parser;const s=o.parseExpression(!1,r);return{type:"sizing",mode:o.mode,size:Bn.indexOf(n)+1,body:s}},htmlBuilder:(e,t)=>{const r=t.havingSize(e.size);return Cn(e.body,r,t)},mathmlBuilder:(e,t)=>{const r=t.havingSize(e.size),n=Ft(e.body,r),o=new Bt("mstyle",n);return o.setAttribute("mathsize",N(r.sizeMultiplier)),o}}),mt({type:"smash",names:["\\smash"],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,r)=>{let n=e.parser,o=!1,s=!1;const i=r[0]&&or(r[0],"ordgroup");if(i){let e;for(let t=0;t{const r=Ye([],[Mt(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return r;if(e.smashHeight&&(r.height=0),e.smashDepth&&(r.depth=0),e.smashHeight&&e.smashDepth)return Ye(["mord","katex-smash"],[r],t);if(r.children)for(let t=0;t{const r=new Bt("mpadded",[Vt(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),mt({type:"sqrt",names:["\\sqrt"],numArgs:1,numOptionalArgs:1,handler(e,t,r){let n=e.parser;const o=r[0],s=t[0];return{type:"sqrt",mode:n.mode,body:s,index:o}},htmlBuilder(e,t){let r=Mt(e.body,t.havingCrampedStyle());0===r.height&&(r.height=t.fontMetrics().xHeight),r=Ze(r,t);const n=t.fontMetrics().defaultRuleThickness;let o=n;t.style.idr.height+r.depth+s&&(s=(s+h-r.height-r.depth)/2);const m=a.height-r.height-s-l;r.style.paddingLeft=N(c);const u=Ke({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+m)},{type:"elem",elem:a},{type:"kern",size:l}]});if(e.index){const r=t.havingStyle(S.SCRIPTSCRIPT),n=Mt(e.index,r,t),o=.6*(u.height-u.depth),s=Ke({positionType:"shift",positionData:-o,children:[{type:"elem",elem:n}]}),i=Ye(["katex-root"],[s]);return Ye(["mord","sqrt"],[i,u],t)}return Ye(["mord","sqrt"],[u],t)},mathmlBuilder(e,t){const r=e.body,n=e.index;return n?new Bt("mroot",[Vt(r,t),Vt(n,t)]):new Bt("msqrt",[Vt(r,t)])}});const qn={display:S.DISPLAY,text:S.TEXT,script:S.SCRIPT,scriptscript:S.SCRIPTSCRIPT};mt({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){let r=e.breakOnTokenText,n=e.funcName,o=e.parser;const s=o.parseExpression(!0,r),i=n.slice(1,n.length-5);if(!(i in qn))throw new Error("Unknown style: "+i);return{type:"styling",mode:o.mode,style:i,body:s}},htmlBuilder(e,t){const r=qn[e.style];let n=t.havingStyle(r);return e.resetFont&&(n=n.withFont("")),Cn(e.body,n,t)},mathmlBuilder(e,t){const r=qn[e.style];let n=t.havingStyle(r);e.resetFont&&(n=n.withFont(""));const o=Ft(e.body,n),s=new Bt("mstyle",o),i={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[e.style];return s.setAttribute("scriptlevel",i[0]),s.setAttribute("displaystyle",i[1]),s}});ut({type:"supsub",htmlBuilder(e,t){const r=function(e,t){const r=e.base;if(r)return"op"===r.type?r.limits&&(t.style.size===S.DISPLAY.size||r.alwaysHandleSupSub)?zn:null:"operatorname"===r.type?r.alwaysHandleSupSub&&(t.style.size===S.DISPLAY.size||r.limits)?An:null:"accent"===r.type?m(r.base)?cr:null:"horizBrace"===r.type&&!e.sub===r.isOver?yn:null;return null}(e,t);if(r)return r(e,t);const n=e.base,o=e.sup,s=e.sub,i=Mt(n,t);let a,l;const c=t.fontMetrics();let h=0,u=0;const p=n&&m(n);if(o){const e=t.havingStyle(t.style.sup());a=Mt(o,e,t),p||(h=i.height-e.fontMetrics().supDrop*e.sizeMultiplier/t.sizeMultiplier)}if(s){const e=t.havingStyle(t.style.sub());l=Mt(s,e,t),p||(u=i.depth+e.fontMetrics().subDrop*e.sizeMultiplier/t.sizeMultiplier)}let d;d=t.style===S.DISPLAY?c.sup1:t.style.cramped?c.sup3:c.sup2;const g=t.sizeMultiplier,f=N(.5/c.ptPerEm/g);let b,y=null;if(l){const t=e.base&&"op"===e.base.type&&e.base.name&&("\\oiint"===e.base.name||"\\oiiint"===e.base.name);var x;if(i instanceof W||t)y=N(-(null!=(x=i.italic)?x:0))}if(a&&l){h=Math.max(h,d,a.depth+.25*c.xHeight),u=Math.max(u,c.sub2);const e=4*c.defaultRuleThickness;if(h-a.depth-(l.height-u)0&&(h+=t,u-=t)}b=Ke({positionType:"individualShift",children:[{type:"elem",elem:l,shift:u,marginRight:f,marginLeft:y},{type:"elem",elem:a,shift:-h,marginRight:f}]})}else if(l){u=Math.max(u,c.sub1,l.height-.8*c.xHeight);b=Ke({positionType:"shift",positionData:u,children:[{type:"elem",elem:l,marginLeft:y,marginRight:f}]})}else{if(!a)throw new Error("supsub must have either sup or sub.");h=Math.max(h,d,a.depth+.25*c.xHeight),b=Ke({positionType:"shift",positionData:-h,children:[{type:"elem",elem:a,marginRight:f}]})}const w=zt(i,"right")||"mord";return Ye([w],[i,Ye(["msupsub"],[b])],t)},mathmlBuilder(e,t){let r,n,o=!1;e.base&&"horizBrace"===e.base.type&&(n=!!e.sup,n===e.base.isOver&&(o=!0,r=e.base.isOver)),!e.base||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0);const s=[Vt(e.base,t)];let i;if(e.sub&&s.push(Vt(e.sub,t)),e.sup&&s.push(Vt(e.sup,t)),o)i=r?"mover":"munder";else if(e.sub)if(e.sup){const r=e.base;i=r&&"op"===r.type&&r.limits&&t.style===S.DISPLAY||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(t.style===S.DISPLAY||r.limits)?"munderover":"msubsup"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===S.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===S.DISPLAY)?"munder":"msub"}else{const r=e.base;i=r&&"op"===r.type&&r.limits&&(t.style===S.DISPLAY||r.alwaysHandleSupSub)||r&&"operatorname"===r.type&&r.alwaysHandleSupSub&&(r.limits||t.style===S.DISPLAY)?"mover":"msup"}return new Bt(i,s)}}),ut({type:"atom",htmlBuilder(e,t){return Ve(e.text,e.mode,t,["m"+e.family])},mathmlBuilder(e,t){const r=new Bt("mo",[Et(e.text,e.mode)]);if("bin"===e.family){const n=Dt(e,t);"bold-italic"===n&&r.setAttribute("mathvariant",n)}else"punct"===e.family?r.setAttribute("separator","true"):"open"!==e.family&&"close"!==e.family||r.setAttribute("stretchy","false");return r}});const In={mi:"italic",mn:"normal",mtext:"normal"};ut({type:"mathord",htmlBuilder(e,t){return Ge(e,t)},mathmlBuilder(e,t){const r=new Bt("mi",[Et(e.text,e.mode,t)]),n=Dt(e,t)||"italic";return n!==In[r.type]&&r.setAttribute("mathvariant",n),r}}),ut({type:"textord",htmlBuilder(e,t){return Ge(e,t)},mathmlBuilder(e,t){const r=Et(e.text,e.mode,t),n=Dt(e,t)||"normal";let o;return o="text"===e.mode?new Bt("mtext",[r]):/[0-9]/.test(e.text)?new Bt("mn",[r]):"\\prime"===e.text?new Bt("mo",[r]):new Bt("mi",[r]),n!==In[o.type]&&o.setAttribute("mathvariant",n),o}});const Rn=new Map([["\\nobreak","nobreak"],["\\allowbreak","allowbreak"]]),On=new Map([[" ",{}],["\\ ",{}],["~",{className:"nobreak"}],["\\space",{}],["\\nobreakspace",{className:"nobreak"}]]);ut({type:"spacing",htmlBuilder(e,t){const r=On.get(e.text),o=Rn.get(e.text);if(r){const n=r.className||"";if("text"===e.mode){const r=Ge(e,t);return r.classes.push(n),r}return Ye(["mspace",n],[Ve(e.text,e.mode,t)],t)}if(o)return Ye(["mspace",o],[],t);throw new n('Unknown type of space "'+e.text+'"')},mathmlBuilder(e,t){let r;if(!On.has(e.text)){if(Rn.has(e.text))return new Bt("mspace");throw new n('Unknown type of space "'+e.text+'"')}return r=new Bt("mtext",[new qt("\xa0")]),r}});const En=()=>{const e=new Bt("mtd",[]);return e.setAttribute("width","50%"),e};ut({type:"tag",mathmlBuilder(e,t){const r=new Bt("mtable",[new Bt("mtr",[En(),new Bt("mtd",[Pt(e.body,t)]),En(),new Bt("mtd",[Pt(e.tag,t)])])]);return r.setAttribute("width","100%"),r}});const Hn={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},Nn={"\\textbf":"textbf","\\textmd":"textmd"},Dn={"\\textit":"textit","\\textup":"textup"},Ln=(e,t)=>{const r=e.font;return r?Hn[r]?t.withTextFontFamily(Hn[r]):Nn[r]?t.withTextFontWeight(Nn[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Dn[r]):t};mt({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0,handler(e,t){let r=e.parser,n=e.funcName;const o=t[0];return{type:"text",mode:r.mode,body:dt(o),font:n}},htmlBuilder(e,t){const r=Ln(e,t),n=xt(e.body,r,!0);return Ye(["mord","text"],n,r)},mathmlBuilder(e,t){const r=Ln(e,t);return Pt(e.body,r)}}),mt({type:"underline",names:["\\underline"],numArgs:1,allowedInText:!0,handler(e,t){return{type:"underline",mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){const r=Mt(e.body,t),n=_e("underline-line",t),o=t.fontMetrics().defaultRuleThickness,s=Ke({positionType:"top",positionData:r.height,children:[{type:"kern",size:o},{type:"elem",elem:n},{type:"kern",size:3*o},{type:"elem",elem:r}]});return Ye(["mord","katex-underline"],[s],t)},mathmlBuilder(e,t){const r=new Bt("mo",[new qt("\u203e")]);r.setAttribute("stretchy","true");const n=new Bt("munder",[Vt(e.body,t),r]);return n.setAttribute("accentunder","true"),n}}),mt({type:"vcenter",names:["\\vcenter"],numArgs:1,argTypes:["original"],allowedInText:!1,handler(e,t){return{type:"vcenter",mode:e.parser.mode,body:t[0]}},htmlBuilder(e,t){const r=Mt(e.body,t),n=t.fontMetrics().axisHeight,o=.5*(r.height-n-(r.depth+n));return Ke({positionType:"shift",positionData:o,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){const r=new Bt("mpadded",[Vt(e.body,t)],["vcenter"]);return new Bt("mrow",[r])}}),mt({type:"verb",names:["\\verb"],numArgs:0,allowedInText:!0,handler(e,t,r){throw new n("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(e,t){const r=Fn(e),n=[],o=t.havingStyle(t.style.text());for(let t=0;te.body.replace(/ /g,e.star?"\u2423":"\xa0");var Pn=lt;const Vn="[ \r\n\t]",Gn="(\\\\[a-zA-Z@]+)"+Vn+"*",jn="[\u0300-\u036f]",Un=new RegExp(jn+"+$"),Xn="("+Vn+"+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-\u2027\u202a-\ud7ff\uf900-\uffff]"+jn+"*|[\ud800-\udbff][\udc00-\udfff]"+jn+"*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|"+Gn+"|\\\\[^\ud800-\udfff])";class Yn{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Xn,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){const e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new tn("EOF",new en(this,t,t));const r=this.tokenRegex.exec(e);if(null===r||r.index!==t)throw new n("Unexpected character: '"+e[t]+"'",new tn(e[t],new en(this,t,t+1)));const o=r[6]||r[3]||(r[2]?"\\ ":" ");if(14===this.catcodes[o]){const t=e.indexOf("\n",this.tokenRegex.lastIndex);return-1===t?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=t+1,this.lex()}return new tn(o,new en(this,t,this.tokenRegex.lastIndex))}}class Wn{constructor(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(0===this.undefStack.length)throw new n("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");const e=this.undefStack.pop();for(const t of Object.keys(e))void 0===e[t]?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:Object.prototype.hasOwnProperty.call(this.builtins,e)?this.builtins[e]:void 0}set(e,t,r){if(void 0===r&&(r=!1),r){for(let t=0;t0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{const t=this.undefStack[this.undefStack.length-1];t&&!Object.prototype.hasOwnProperty.call(t,e)&&(t[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}null==t?delete this.current[e]:this.current[e]=t}}var _n=Jr;Qr("\\noexpand",function(e){const t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Qr("\\expandafter",function(e){const t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Qr("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Qr("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Qr("\\@ifnextchar",function(e){const t=e.consumeArgs(3);e.consumeSpaces();const r=e.future();return 1===t[0].length&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Qr("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Qr("\\TextOrMath",function(e){const t=e.consumeArgs(2);return"text"===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});const $n={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Qr("\\char",function(e){let t,r=e.popToken(),o=0;if("'"===r.text)t=8,r=e.popToken();else if('"'===r.text)t=16,r=e.popToken();else if("`"===r.text)if(r=e.popToken(),"\\"===r.text[0])o=r.text.charCodeAt(1);else{if("EOF"===r.text)throw new n("\\char` missing argument");o=r.text.charCodeAt(0)}else t=10;if(t){if(o=$n[r.text],null==o||o>=t)throw new n("Invalid base-"+t+" digit "+r.text);let s;for(;null!=(s=$n[e.future().text])&&s{let s=e.consumeArg().tokens;if(1!==s.length)throw new n("\\newcommand's first argument must be a macro name");const i=s[0].text,a=e.isDefined(i);if(a&&!t)throw new n("\\newcommand{"+i+"} attempting to redefine "+i+"; use \\renewcommand");if(!a&&!r)throw new n("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");let l=0;if(s=e.consumeArg().tokens,1===s.length&&"["===s[0].text){let t="",r=e.expandNextToken();for(;"]"!==r.text&&"EOF"!==r.text;)t+=r.text,r=e.expandNextToken();if(!t.match(/^\s*[0-9]+\s*$/))throw new n("Invalid number of arguments: "+t);l=parseInt(t),s=e.consumeArg().tokens}return a&&o||e.macros.set(i,{tokens:s,numArgs:l}),""};Qr("\\newcommand",e=>Zn(e,!1,!0,!1)),Qr("\\renewcommand",e=>Zn(e,!0,!1,!1)),Qr("\\providecommand",e=>Zn(e,!0,!0,!0)),Qr("\\message",e=>{const t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join("")),""}),Qr("\\errmessage",e=>{const t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join("")),""}),Qr("\\show",e=>{const t=e.popToken(),r=t.text;return console.log(t,e.macros.get(r),Pn[r],ne.math[r],ne.text[r]),""}),Qr("\\bgroup","{"),Qr("\\egroup","}"),Qr("~","\\nobreakspace"),Qr("\\lq","`"),Qr("\\rq","'"),Qr("\\aa","\\r a"),Qr("\\AA","\\r A"),Qr("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xa9}"),Qr("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),Qr("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xae}"),Qr("\u212c","\\mathscr{B}"),Qr("\u2130","\\mathscr{E}"),Qr("\u2131","\\mathscr{F}"),Qr("\u210b","\\mathscr{H}"),Qr("\u2110","\\mathscr{I}"),Qr("\u2112","\\mathscr{L}"),Qr("\u2133","\\mathscr{M}"),Qr("\u211b","\\mathscr{R}"),Qr("\u212d","\\mathfrak{C}"),Qr("\u210c","\\mathfrak{H}"),Qr("\u2128","\\mathfrak{Z}"),Qr("\\Bbbk","\\Bbb{k}"),Qr("\\llap","\\mathllap{\\textrm{#1}}"),Qr("\\rlap","\\mathrlap{\\textrm{#1}}"),Qr("\\clap","\\mathclap{\\textrm{#1}}"),Qr("\\mathstrut","\\vphantom{(}"),Qr("\\underbar","\\underline{\\text{#1}}"),Qr("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}'),Qr("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}"),Qr("\\ne","\\neq"),Qr("\u2260","\\neq"),Qr("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}"),Qr("\u2209","\\notin"),Qr("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}"),Qr("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"),Qr("\u225a","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225a}}"),Qr("\u225b","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225b}}"),Qr("\u225d","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225d}}"),Qr("\u225e","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225e}}"),Qr("\u225f","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225f}}"),Qr("\u27c2","\\perp"),Qr("\u203c","\\mathclose{!\\mkern-0.8mu!}"),Qr("\u220c","\\notni"),Qr("\u231c","\\ulcorner"),Qr("\u231d","\\urcorner"),Qr("\u231e","\\llcorner"),Qr("\u231f","\\lrcorner"),Qr("\xa9","\\copyright"),Qr("\xae","\\textregistered"),Qr("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),Qr("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),Qr("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),Qr("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),Qr("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),Qr("\u22ee","\\vdots"),Qr("\\varGamma","\\mathit{\\Gamma}"),Qr("\\varDelta","\\mathit{\\Delta}"),Qr("\\varTheta","\\mathit{\\Theta}"),Qr("\\varLambda","\\mathit{\\Lambda}"),Qr("\\varXi","\\mathit{\\Xi}"),Qr("\\varPi","\\mathit{\\Pi}"),Qr("\\varSigma","\\mathit{\\Sigma}"),Qr("\\varUpsilon","\\mathit{\\Upsilon}"),Qr("\\varPhi","\\mathit{\\Phi}"),Qr("\\varPsi","\\mathit{\\Psi}"),Qr("\\varOmega","\\mathit{\\Omega}"),Qr("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Qr("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),Qr("\\boxed","\\fbox{$\\displaystyle{#1}$}"),Qr("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Qr("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Qr("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;"),Qr("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"),Qr("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");const Kn={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"},Jn=new Set(["bin","rel"]);Qr("\\dots",function(e){let t="\\dotso";const r=e.expandAfterFuture().text;return r in Kn?t=Kn[r]:("\\not"===r.slice(0,4)||r in ne.math&&Jn.has(ne.math[r].group))&&(t="\\dotsb"),t});const Qn={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};Qr("\\dotso",function(e){return e.future().text in Qn?"\\ldots\\,":"\\ldots"}),Qr("\\dotsc",function(e){const t=e.future().text;return t in Qn&&","!==t?"\\ldots\\,":"\\ldots"}),Qr("\\cdots",function(e){return e.future().text in Qn?"\\@cdots\\,":"\\@cdots"}),Qr("\\dotsb","\\cdots"),Qr("\\dotsm","\\cdots"),Qr("\\dotsi","\\!\\cdots"),Qr("\\dotsx","\\ldots\\,"),Qr("\\DOTSI","\\relax"),Qr("\\DOTSB","\\relax"),Qr("\\DOTSX","\\relax"),Qr("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Qr("\\,","\\tmspace+{3mu}{.1667em}"),Qr("\\thinspace","\\,"),Qr("\\>","\\mskip{4mu}"),Qr("\\:","\\tmspace+{4mu}{.2222em}"),Qr("\\medspace","\\:"),Qr("\\;","\\tmspace+{5mu}{.2777em}"),Qr("\\thickspace","\\;"),Qr("\\!","\\tmspace-{3mu}{.1667em}"),Qr("\\negthinspace","\\!"),Qr("\\negmedspace","\\tmspace-{4mu}{.2222em}"),Qr("\\negthickspace","\\tmspace-{5mu}{.277em}"),Qr("\\enspace","\\kern.5em "),Qr("\\enskip","\\hskip.5em\\relax"),Qr("\\quad","\\hskip1em\\relax"),Qr("\\qquad","\\hskip2em\\relax"),Qr("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Qr("\\tag@paren","\\tag@literal{({#1})}"),Qr("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new n("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),Qr("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),Qr("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Qr("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Qr("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Qr("\\newline","\\\\\\relax"),Qr("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");const eo=N(K["Main-Regular"]["T".charCodeAt(0)][1]-.7*K["Main-Regular"]["A".charCodeAt(0)][1]);Qr("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+eo+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),Qr("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+eo+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),Qr("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Qr("\\@hspace","\\hskip #1\\relax"),Qr("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Qr("\\ordinarycolon",":"),Qr("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),Qr("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),Qr("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),Qr("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),Qr("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),Qr("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),Qr("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),Qr("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),Qr("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),Qr("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),Qr("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),Qr("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),Qr("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),Qr("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),Qr("\u2237","\\dblcolon"),Qr("\u2239","\\eqcolon"),Qr("\u2254","\\coloneqq"),Qr("\u2255","\\eqqcolon"),Qr("\u2a74","\\Coloneqq"),Qr("\\ratio","\\vcentcolon"),Qr("\\coloncolon","\\dblcolon"),Qr("\\colonequals","\\coloneqq"),Qr("\\coloncolonequals","\\Coloneqq"),Qr("\\equalscolon","\\eqqcolon"),Qr("\\equalscoloncolon","\\Eqqcolon"),Qr("\\colonminus","\\coloneq"),Qr("\\coloncolonminus","\\Coloneq"),Qr("\\minuscolon","\\eqcolon"),Qr("\\minuscoloncolon","\\Eqcolon"),Qr("\\coloncolonapprox","\\Colonapprox"),Qr("\\coloncolonsim","\\Colonsim"),Qr("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Qr("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Qr("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Qr("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Qr("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220c}}"),Qr("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Qr("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Qr("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Qr("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Qr("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),Qr("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),Qr("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),Qr("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),Qr("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}"),Qr("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}"),Qr("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}"),Qr("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}"),Qr("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}"),Qr("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}"),Qr("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}"),Qr("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}"),Qr("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}"),Qr("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}"),Qr("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228a}"),Qr("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2acb}"),Qr("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228b}"),Qr("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2acc}"),Qr("\\imath","\\html@mathml{\\@imath}{\u0131}"),Qr("\\jmath","\\html@mathml{\\@jmath}{\u0237}"),Qr("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27e6}}"),Qr("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27e7}}"),Qr("\u27e6","\\llbracket"),Qr("\u27e7","\\rrbracket"),Qr("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}"),Qr("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}"),Qr("\u21a4","\\mapsfrom"),Qr("\\mapsfrom","\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`\u21a4}}"),Qr("\u2983","\\lBrace"),Qr("\u2984","\\rBrace"),Qr("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29b5}}"),Qr("\u29b5","\\minuso"),Qr("\\darr","\\downarrow"),Qr("\\dArr","\\Downarrow"),Qr("\\Darr","\\Downarrow"),Qr("\\lang","\\langle"),Qr("\\rang","\\rangle"),Qr("\\uarr","\\uparrow"),Qr("\\uArr","\\Uparrow"),Qr("\\Uarr","\\Uparrow"),Qr("\\N","\\mathbb{N}"),Qr("\\R","\\mathbb{R}"),Qr("\\Z","\\mathbb{Z}"),Qr("\\alef","\\aleph"),Qr("\\alefsym","\\aleph"),Qr("\\Alpha","\\mathrm{A}"),Qr("\\Beta","\\mathrm{B}"),Qr("\\bull","\\bullet"),Qr("\\Chi","\\mathrm{X}"),Qr("\\clubs","\\clubsuit"),Qr("\\cnums","\\mathbb{C}"),Qr("\\Complex","\\mathbb{C}"),Qr("\\Dagger","\\ddagger"),Qr("\\diamonds","\\diamondsuit"),Qr("\\empty","\\emptyset"),Qr("\\Epsilon","\\mathrm{E}"),Qr("\\Eta","\\mathrm{H}"),Qr("\\exist","\\exists"),Qr("\\harr","\\leftrightarrow"),Qr("\\hArr","\\Leftrightarrow"),Qr("\\Harr","\\Leftrightarrow"),Qr("\\hearts","\\heartsuit"),Qr("\\image","\\Im"),Qr("\\infin","\\infty"),Qr("\\Iota","\\mathrm{I}"),Qr("\\isin","\\in"),Qr("\\Kappa","\\mathrm{K}"),Qr("\\larr","\\leftarrow"),Qr("\\lArr","\\Leftarrow"),Qr("\\Larr","\\Leftarrow"),Qr("\\lrarr","\\leftrightarrow"),Qr("\\lrArr","\\Leftrightarrow"),Qr("\\Lrarr","\\Leftrightarrow"),Qr("\\Mu","\\mathrm{M}"),Qr("\\natnums","\\mathbb{N}"),Qr("\\Nu","\\mathrm{N}"),Qr("\\Omicron","\\mathrm{O}"),Qr("\\plusmn","\\pm"),Qr("\\rarr","\\rightarrow"),Qr("\\rArr","\\Rightarrow"),Qr("\\Rarr","\\Rightarrow"),Qr("\\real","\\Re"),Qr("\\reals","\\mathbb{R}"),Qr("\\Reals","\\mathbb{R}"),Qr("\\Rho","\\mathrm{P}"),Qr("\\sdot","\\cdot"),Qr("\\sect","\\S"),Qr("\\spades","\\spadesuit"),Qr("\\sub","\\subset"),Qr("\\sube","\\subseteq"),Qr("\\supe","\\supseteq"),Qr("\\Tau","\\mathrm{T}"),Qr("\\thetasym","\\vartheta"),Qr("\\weierp","\\wp"),Qr("\\Zeta","\\mathrm{Z}"),Qr("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Qr("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Qr("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),Qr("\\bra","\\mathinner{\\langle{#1}|}"),Qr("\\ket","\\mathinner{|{#1}\\rangle}"),Qr("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Qr("\\Bra","\\left\\langle#1\\right|"),Qr("\\Ket","\\left|#1\\right\\rangle");const to=e=>t=>{const r=t.consumeArg().tokens,n=t.consumeArg().tokens,o=t.consumeArg().tokens,s=t.consumeArg().tokens,i=t.macros.get("|"),a=t.macros.get("\\|");t.macros.beginGroup();const l=t=>r=>{e&&(r.macros.set("|",i),o.length&&r.macros.set("\\|",a));let s=t;if(!t&&o.length){"|"===r.future().text&&(r.popToken(),s=!0)}return{tokens:s?o:n,numArgs:0}};t.macros.set("|",l(!1)),o.length&&t.macros.set("\\|",l(!0));const c=t.consumeArg().tokens,h=t.expandTokens([...s,...c,...r]);return t.macros.endGroup(),{tokens:h.reverse(),numArgs:0}};Qr("\\bra@ket",to(!1)),Qr("\\bra@set",to(!0)),Qr("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),Qr("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),Qr("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),Qr("\\angln","{\\angl n}"),Qr("\\blue","\\textcolor{##6495ed}{#1}"),Qr("\\orange","\\textcolor{##ffa500}{#1}"),Qr("\\pink","\\textcolor{##ff00af}{#1}"),Qr("\\red","\\textcolor{##df0030}{#1}"),Qr("\\green","\\textcolor{##28ae7b}{#1}"),Qr("\\gray","\\textcolor{gray}{#1}"),Qr("\\purple","\\textcolor{##9d38bd}{#1}"),Qr("\\blueA","\\textcolor{##ccfaff}{#1}"),Qr("\\blueB","\\textcolor{##80f6ff}{#1}"),Qr("\\blueC","\\textcolor{##63d9ea}{#1}"),Qr("\\blueD","\\textcolor{##11accd}{#1}"),Qr("\\blueE","\\textcolor{##0c7f99}{#1}"),Qr("\\tealA","\\textcolor{##94fff5}{#1}"),Qr("\\tealB","\\textcolor{##26edd5}{#1}"),Qr("\\tealC","\\textcolor{##01d1c1}{#1}"),Qr("\\tealD","\\textcolor{##01a995}{#1}"),Qr("\\tealE","\\textcolor{##208170}{#1}"),Qr("\\greenA","\\textcolor{##b6ffb0}{#1}"),Qr("\\greenB","\\textcolor{##8af281}{#1}"),Qr("\\greenC","\\textcolor{##74cf70}{#1}"),Qr("\\greenD","\\textcolor{##1fab54}{#1}"),Qr("\\greenE","\\textcolor{##0d923f}{#1}"),Qr("\\goldA","\\textcolor{##ffd0a9}{#1}"),Qr("\\goldB","\\textcolor{##ffbb71}{#1}"),Qr("\\goldC","\\textcolor{##ff9c39}{#1}"),Qr("\\goldD","\\textcolor{##e07d10}{#1}"),Qr("\\goldE","\\textcolor{##a75a05}{#1}"),Qr("\\redA","\\textcolor{##fca9a9}{#1}"),Qr("\\redB","\\textcolor{##ff8482}{#1}"),Qr("\\redC","\\textcolor{##f9685d}{#1}"),Qr("\\redD","\\textcolor{##e84d39}{#1}"),Qr("\\redE","\\textcolor{##bc2612}{#1}"),Qr("\\maroonA","\\textcolor{##ffbde0}{#1}"),Qr("\\maroonB","\\textcolor{##ff92c6}{#1}"),Qr("\\maroonC","\\textcolor{##ed5fa6}{#1}"),Qr("\\maroonD","\\textcolor{##ca337c}{#1}"),Qr("\\maroonE","\\textcolor{##9e034e}{#1}"),Qr("\\purpleA","\\textcolor{##ddd7ff}{#1}"),Qr("\\purpleB","\\textcolor{##c6b9fc}{#1}"),Qr("\\purpleC","\\textcolor{##aa87ff}{#1}"),Qr("\\purpleD","\\textcolor{##7854ab}{#1}"),Qr("\\purpleE","\\textcolor{##543b78}{#1}"),Qr("\\mintA","\\textcolor{##f5f9e8}{#1}"),Qr("\\mintB","\\textcolor{##edf2df}{#1}"),Qr("\\mintC","\\textcolor{##e0e5cc}{#1}"),Qr("\\grayA","\\textcolor{##f6f7f7}{#1}"),Qr("\\grayB","\\textcolor{##f0f1f2}{#1}"),Qr("\\grayC","\\textcolor{##e3e5e6}{#1}"),Qr("\\grayD","\\textcolor{##d6d8da}{#1}"),Qr("\\grayE","\\textcolor{##babec2}{#1}"),Qr("\\grayF","\\textcolor{##888d93}{#1}"),Qr("\\grayG","\\textcolor{##626569}{#1}"),Qr("\\grayH","\\textcolor{##3b3e40}{#1}"),Qr("\\grayI","\\textcolor{##21242c}{#1}"),Qr("\\kaBlue","\\textcolor{##314453}{#1}"),Qr("\\kaGreen","\\textcolor{##71B307}{#1}");const ro={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class no{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Wn(_n,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new Yn(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){let t,r,n;if(e){if(this.consumeSpaces(),"["!==this.future().text)return null;t=this.popToken();var o=this.consumeArg(["]"]);n=o.tokens,r=o.end}else{var s=this.consumeArg();n=s.tokens,t=s.start,r=s.end}return this.pushToken(new tn("EOF",r.loc)),this.pushTokens(n),new tn("",en.range(t,r))}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(e){const t=[],r=e&&e.length>0;r||this.consumeSpaces();const o=this.future();let s,i=0,a=0;do{if(s=this.popToken(),t.push(s),"{"===s.text)++i;else if("}"===s.text){if(--i,-1===i)throw new n("Extra }",s)}else if("EOF"===s.text)throw new n("Unexpected end of input in a macro argument, expected '"+(e&&r?e[a]:"}")+"'",s);if(e&&r)if((0===i||1===i&&"{"===e[a])&&s.text===e[a]){if(++a,a===e.length){t.splice(-a,a);break}}else a=0}while(0!==i||r);return"{"===o.text&&"}"===t[t.length-1].text&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:o,end:s}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new n("The length of delimiters doesn't match the number of args!");const r=t[0];for(let e=0;ethis.settings.maxExpand)throw new n("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){const t=this.popToken(),r=t.text,o=t.noexpand?null:this._getExpansion(r);if(null==o||e&&o.unexpandable){if(e&&null==o&&"\\"===r[0]&&!this.isDefined(r))throw new n("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);let s=o.tokens;const i=this.consumeArgs(o.numArgs,o.delimiters);if(o.numArgs){s=s.slice();for(let e=s.length-1;e>=0;--e){let t=s[e];if("#"===t.text){if(0===e)throw new n("Incomplete placeholder at end of macro body",t);if(t=s[--e],"#"===t.text)s.splice(e+1,1);else{if(!/^[1-9]$/.test(t.text))throw new n("Not a valid argument number",t);s.splice(e,2,...i[+t.text-1])}}}}return this.pushTokens(s),s.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){const e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new tn(e)]):void 0}expandTokens(e){const t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(!1===this.expandOnce(!0)){const e=this.stack.pop();e.treatAsRelax&&(e.noexpand=!1,e.treatAsRelax=!1),t.push(e)}return this.countExpansion(t.length),t}expandMacroAsText(e){const t=this.expandMacro(e);return t?t.map(e=>e.text).join(""):t}_getExpansion(e){const t=this.macros.get(e);if(null==t)return t;if(1===e.length){const t=this.lexer.catcodes[e];if(null!=t&&13!==t)return}const r="function"==typeof t?t(this):t;if("string"==typeof r){let e=0;if(r.includes("#")){const t=r.replace(/##/g,"");for(;t.includes("#"+(e+1));)++e}const t=new Yn(r,this.settings),n=[];let o=t.lex();for(;"EOF"!==o.text;)n.push(o),o=t.lex();n.reverse();return{tokens:n,numArgs:e}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Pn,e)||Object.prototype.hasOwnProperty.call(ne.math,e)||Object.prototype.hasOwnProperty.call(ne.text,e)||Object.prototype.hasOwnProperty.call(ro,e)}isExpandable(e){const t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(Pn,e)&&!Pn[e].primitive}}const oo=/^[\u208a\u208b\u208c\u208d\u208e\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u2090\u2091\u2095\u1d62\u2c7c\u2096\u2097\u2098\u2099\u2092\u209a\u1d63\u209b\u209c\u1d64\u1d65\u2093\u1d66\u1d67\u1d68\u1d69\u1d6a]/,so=Object.freeze({"\u208a":"+","\u208b":"-","\u208c":"=","\u208d":"(","\u208e":")","\u2080":"0","\u2081":"1","\u2082":"2","\u2083":"3","\u2084":"4","\u2085":"5","\u2086":"6","\u2087":"7","\u2088":"8","\u2089":"9","\u2090":"a","\u2091":"e","\u2095":"h","\u1d62":"i","\u2c7c":"j","\u2096":"k","\u2097":"l","\u2098":"m","\u2099":"n","\u2092":"o","\u209a":"p","\u1d63":"r","\u209b":"s","\u209c":"t","\u1d64":"u","\u1d65":"v","\u2093":"x","\u1d66":"\u03b2","\u1d67":"\u03b3","\u1d68":"\u03c1","\u1d69":"\u03d5","\u1d6a":"\u03c7","\u207a":"+","\u207b":"-","\u207c":"=","\u207d":"(","\u207e":")","\u2070":"0","\xb9":"1","\xb2":"2","\xb3":"3","\u2074":"4","\u2075":"5","\u2076":"6","\u2077":"7","\u2078":"8","\u2079":"9","\u1d2c":"A","\u1d2e":"B","\u1d30":"D","\u1d31":"E","\u1d33":"G","\u1d34":"H","\u1d35":"I","\u1d36":"J","\u1d37":"K","\u1d38":"L","\u1d39":"M","\u1d3a":"N","\u1d3c":"O","\u1d3e":"P","\u1d3f":"R","\u1d40":"T","\u1d41":"U","\u2c7d":"V","\u1d42":"W","\u1d43":"a","\u1d47":"b","\u1d9c":"c","\u1d48":"d","\u1d49":"e","\u1da0":"f","\u1d4d":"g","\u02b0":"h","\u2071":"i","\u02b2":"j","\u1d4f":"k","\u02e1":"l","\u1d50":"m","\u207f":"n","\u1d52":"o","\u1d56":"p","\u02b3":"r","\u02e2":"s","\u1d57":"t","\u1d58":"u","\u1d5b":"v","\u02b7":"w","\u02e3":"x","\u02b8":"y","\u1dbb":"z","\u1d5d":"\u03b2","\u1d5e":"\u03b3","\u1d5f":"\u03b4","\u1d60":"\u03d5","\u1d61":"\u03c7","\u1dbf":"\u03b8"}),io={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:'\\"',math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030c":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030a":{text:"\\r",math:"\\mathring"},"\u030b":{text:"\\H"},"\u0327":{text:"\\c"}},ao={"\xe1":"a\u0301","\xe0":"a\u0300","\xe4":"a\u0308","\u01df":"a\u0308\u0304","\xe3":"a\u0303","\u0101":"a\u0304","\u0103":"a\u0306","\u1eaf":"a\u0306\u0301","\u1eb1":"a\u0306\u0300","\u1eb5":"a\u0306\u0303","\u01ce":"a\u030c","\xe2":"a\u0302","\u1ea5":"a\u0302\u0301","\u1ea7":"a\u0302\u0300","\u1eab":"a\u0302\u0303","\u0227":"a\u0307","\u01e1":"a\u0307\u0304","\xe5":"a\u030a","\u01fb":"a\u030a\u0301","\u1e03":"b\u0307","\u0107":"c\u0301","\u1e09":"c\u0327\u0301","\u010d":"c\u030c","\u0109":"c\u0302","\u010b":"c\u0307","\xe7":"c\u0327","\u010f":"d\u030c","\u1e0b":"d\u0307","\u1e11":"d\u0327","\xe9":"e\u0301","\xe8":"e\u0300","\xeb":"e\u0308","\u1ebd":"e\u0303","\u0113":"e\u0304","\u1e17":"e\u0304\u0301","\u1e15":"e\u0304\u0300","\u0115":"e\u0306","\u1e1d":"e\u0327\u0306","\u011b":"e\u030c","\xea":"e\u0302","\u1ebf":"e\u0302\u0301","\u1ec1":"e\u0302\u0300","\u1ec5":"e\u0302\u0303","\u0117":"e\u0307","\u0229":"e\u0327","\u1e1f":"f\u0307","\u01f5":"g\u0301","\u1e21":"g\u0304","\u011f":"g\u0306","\u01e7":"g\u030c","\u011d":"g\u0302","\u0121":"g\u0307","\u0123":"g\u0327","\u1e27":"h\u0308","\u021f":"h\u030c","\u0125":"h\u0302","\u1e23":"h\u0307","\u1e29":"h\u0327","\xed":"i\u0301","\xec":"i\u0300","\xef":"i\u0308","\u1e2f":"i\u0308\u0301","\u0129":"i\u0303","\u012b":"i\u0304","\u012d":"i\u0306","\u01d0":"i\u030c","\xee":"i\u0302","\u01f0":"j\u030c","\u0135":"j\u0302","\u1e31":"k\u0301","\u01e9":"k\u030c","\u0137":"k\u0327","\u013a":"l\u0301","\u013e":"l\u030c","\u013c":"l\u0327","\u1e3f":"m\u0301","\u1e41":"m\u0307","\u0144":"n\u0301","\u01f9":"n\u0300","\xf1":"n\u0303","\u0148":"n\u030c","\u1e45":"n\u0307","\u0146":"n\u0327","\xf3":"o\u0301","\xf2":"o\u0300","\xf6":"o\u0308","\u022b":"o\u0308\u0304","\xf5":"o\u0303","\u1e4d":"o\u0303\u0301","\u1e4f":"o\u0303\u0308","\u022d":"o\u0303\u0304","\u014d":"o\u0304","\u1e53":"o\u0304\u0301","\u1e51":"o\u0304\u0300","\u014f":"o\u0306","\u01d2":"o\u030c","\xf4":"o\u0302","\u1ed1":"o\u0302\u0301","\u1ed3":"o\u0302\u0300","\u1ed7":"o\u0302\u0303","\u022f":"o\u0307","\u0231":"o\u0307\u0304","\u0151":"o\u030b","\u1e55":"p\u0301","\u1e57":"p\u0307","\u0155":"r\u0301","\u0159":"r\u030c","\u1e59":"r\u0307","\u0157":"r\u0327","\u015b":"s\u0301","\u1e65":"s\u0301\u0307","\u0161":"s\u030c","\u1e67":"s\u030c\u0307","\u015d":"s\u0302","\u1e61":"s\u0307","\u015f":"s\u0327","\u1e97":"t\u0308","\u0165":"t\u030c","\u1e6b":"t\u0307","\u0163":"t\u0327","\xfa":"u\u0301","\xf9":"u\u0300","\xfc":"u\u0308","\u01d8":"u\u0308\u0301","\u01dc":"u\u0308\u0300","\u01d6":"u\u0308\u0304","\u01da":"u\u0308\u030c","\u0169":"u\u0303","\u1e79":"u\u0303\u0301","\u016b":"u\u0304","\u1e7b":"u\u0304\u0308","\u016d":"u\u0306","\u01d4":"u\u030c","\xfb":"u\u0302","\u016f":"u\u030a","\u0171":"u\u030b","\u1e7d":"v\u0303","\u1e83":"w\u0301","\u1e81":"w\u0300","\u1e85":"w\u0308","\u0175":"w\u0302","\u1e87":"w\u0307","\u1e98":"w\u030a","\u1e8d":"x\u0308","\u1e8b":"x\u0307","\xfd":"y\u0301","\u1ef3":"y\u0300","\xff":"y\u0308","\u1ef9":"y\u0303","\u0233":"y\u0304","\u0177":"y\u0302","\u1e8f":"y\u0307","\u1e99":"y\u030a","\u017a":"z\u0301","\u017e":"z\u030c","\u1e91":"z\u0302","\u017c":"z\u0307","\xc1":"A\u0301","\xc0":"A\u0300","\xc4":"A\u0308","\u01de":"A\u0308\u0304","\xc3":"A\u0303","\u0100":"A\u0304","\u0102":"A\u0306","\u1eae":"A\u0306\u0301","\u1eb0":"A\u0306\u0300","\u1eb4":"A\u0306\u0303","\u01cd":"A\u030c","\xc2":"A\u0302","\u1ea4":"A\u0302\u0301","\u1ea6":"A\u0302\u0300","\u1eaa":"A\u0302\u0303","\u0226":"A\u0307","\u01e0":"A\u0307\u0304","\xc5":"A\u030a","\u01fa":"A\u030a\u0301","\u1e02":"B\u0307","\u0106":"C\u0301","\u1e08":"C\u0327\u0301","\u010c":"C\u030c","\u0108":"C\u0302","\u010a":"C\u0307","\xc7":"C\u0327","\u010e":"D\u030c","\u1e0a":"D\u0307","\u1e10":"D\u0327","\xc9":"E\u0301","\xc8":"E\u0300","\xcb":"E\u0308","\u1ebc":"E\u0303","\u0112":"E\u0304","\u1e16":"E\u0304\u0301","\u1e14":"E\u0304\u0300","\u0114":"E\u0306","\u1e1c":"E\u0327\u0306","\u011a":"E\u030c","\xca":"E\u0302","\u1ebe":"E\u0302\u0301","\u1ec0":"E\u0302\u0300","\u1ec4":"E\u0302\u0303","\u0116":"E\u0307","\u0228":"E\u0327","\u1e1e":"F\u0307","\u01f4":"G\u0301","\u1e20":"G\u0304","\u011e":"G\u0306","\u01e6":"G\u030c","\u011c":"G\u0302","\u0120":"G\u0307","\u0122":"G\u0327","\u1e26":"H\u0308","\u021e":"H\u030c","\u0124":"H\u0302","\u1e22":"H\u0307","\u1e28":"H\u0327","\xcd":"I\u0301","\xcc":"I\u0300","\xcf":"I\u0308","\u1e2e":"I\u0308\u0301","\u0128":"I\u0303","\u012a":"I\u0304","\u012c":"I\u0306","\u01cf":"I\u030c","\xce":"I\u0302","\u0130":"I\u0307","\u0134":"J\u0302","\u1e30":"K\u0301","\u01e8":"K\u030c","\u0136":"K\u0327","\u0139":"L\u0301","\u013d":"L\u030c","\u013b":"L\u0327","\u1e3e":"M\u0301","\u1e40":"M\u0307","\u0143":"N\u0301","\u01f8":"N\u0300","\xd1":"N\u0303","\u0147":"N\u030c","\u1e44":"N\u0307","\u0145":"N\u0327","\xd3":"O\u0301","\xd2":"O\u0300","\xd6":"O\u0308","\u022a":"O\u0308\u0304","\xd5":"O\u0303","\u1e4c":"O\u0303\u0301","\u1e4e":"O\u0303\u0308","\u022c":"O\u0303\u0304","\u014c":"O\u0304","\u1e52":"O\u0304\u0301","\u1e50":"O\u0304\u0300","\u014e":"O\u0306","\u01d1":"O\u030c","\xd4":"O\u0302","\u1ed0":"O\u0302\u0301","\u1ed2":"O\u0302\u0300","\u1ed6":"O\u0302\u0303","\u022e":"O\u0307","\u0230":"O\u0307\u0304","\u0150":"O\u030b","\u1e54":"P\u0301","\u1e56":"P\u0307","\u0154":"R\u0301","\u0158":"R\u030c","\u1e58":"R\u0307","\u0156":"R\u0327","\u015a":"S\u0301","\u1e64":"S\u0301\u0307","\u0160":"S\u030c","\u1e66":"S\u030c\u0307","\u015c":"S\u0302","\u1e60":"S\u0307","\u015e":"S\u0327","\u0164":"T\u030c","\u1e6a":"T\u0307","\u0162":"T\u0327","\xda":"U\u0301","\xd9":"U\u0300","\xdc":"U\u0308","\u01d7":"U\u0308\u0301","\u01db":"U\u0308\u0300","\u01d5":"U\u0308\u0304","\u01d9":"U\u0308\u030c","\u0168":"U\u0303","\u1e78":"U\u0303\u0301","\u016a":"U\u0304","\u1e7a":"U\u0304\u0308","\u016c":"U\u0306","\u01d3":"U\u030c","\xdb":"U\u0302","\u016e":"U\u030a","\u0170":"U\u030b","\u1e7c":"V\u0303","\u1e82":"W\u0301","\u1e80":"W\u0300","\u1e84":"W\u0308","\u0174":"W\u0302","\u1e86":"W\u0307","\u1e8c":"X\u0308","\u1e8a":"X\u0307","\xdd":"Y\u0301","\u1ef2":"Y\u0300","\u0178":"Y\u0308","\u1ef8":"Y\u0303","\u0232":"Y\u0304","\u0176":"Y\u0302","\u1e8e":"Y\u0307","\u0179":"Z\u0301","\u017d":"Z\u030c","\u1e90":"Z\u0302","\u017b":"Z\u0307","\u03ac":"\u03b1\u0301","\u1f70":"\u03b1\u0300","\u1fb1":"\u03b1\u0304","\u1fb0":"\u03b1\u0306","\u03ad":"\u03b5\u0301","\u1f72":"\u03b5\u0300","\u03ae":"\u03b7\u0301","\u1f74":"\u03b7\u0300","\u03af":"\u03b9\u0301","\u1f76":"\u03b9\u0300","\u03ca":"\u03b9\u0308","\u0390":"\u03b9\u0308\u0301","\u1fd2":"\u03b9\u0308\u0300","\u1fd1":"\u03b9\u0304","\u1fd0":"\u03b9\u0306","\u03cc":"\u03bf\u0301","\u1f78":"\u03bf\u0300","\u03cd":"\u03c5\u0301","\u1f7a":"\u03c5\u0300","\u03cb":"\u03c5\u0308","\u03b0":"\u03c5\u0308\u0301","\u1fe2":"\u03c5\u0308\u0300","\u1fe1":"\u03c5\u0304","\u1fe0":"\u03c5\u0306","\u03ce":"\u03c9\u0301","\u1f7c":"\u03c9\u0300","\u038e":"\u03a5\u0301","\u1fea":"\u03a5\u0300","\u03ab":"\u03a5\u0308","\u1fe9":"\u03a5\u0304","\u1fe8":"\u03a5\u0306","\u038f":"\u03a9\u0301","\u1ffa":"\u03a9\u0300"};class lo{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new no(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(void 0===t&&(t=!0),this.fetch().text!==e)throw new n("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{const e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){const t=this.nextToken;this.consume(),this.gullet.pushToken(new tn("}")),this.gullet.pushTokens(e);const r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){const r=[];for(;;){"math"===this.mode&&this.consumeSpaces();const n=this.fetch();if(lo.endOfExpression.has(n.text))break;if(t&&n.text===t)break;if(e&&Pn[n.text]&&Pn[n.text].infix)break;const o=this.parseAtom(t);if(!o)break;"internal"!==o.type&&r.push(o)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){let t,r=-1;for(let o=0;o=128))return null;this.settings.strict&&(T(t.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+t[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+t[0]+'" ('+t.charCodeAt(0)+")",e)),o={type:"textord",mode:"text",loc:en.range(e),text:t}}var s;if(this.consume(),r)for(let t=0;t Iterator[None]: + """Runs the test as if Node.js, which KaTeX is rendered with, were not installed. + + Only node is hidden: pandoc must still be found, or a conversion would fail for a + quite different reason. + """ + which = shutil.which + monkeypatch.setattr( + shutil, "which", lambda command: None if command == "node" else which(command) + ) + _node.cache_clear() + yield + _node.cache_clear() + + @pytest.fixture(scope="session") def filters_dir() -> str: """Absolute path to the packaged ``filters`` directory. diff --git a/tests/fixtures/problems/README.md b/tests/fixtures/problems/README.md index 59523b2..f735052 100644 --- a/tests/fixtures/problems/README.md +++ b/tests/fixtures/problems/README.md @@ -12,6 +12,9 @@ They are written by hand rather than exported by the platform, because the platf produce broken sets. Real exports live in `../exports`, and the same test suite checks that none of them is reported as having a problem. +A folder whose report says `KaTeX rejects it` needs Node.js, which KaTeX is rendered with, and is +skipped without it. + To cover a new check, add a folder. The set's `description` says what the folder is for. A folder is loaded by `Set.from_json`, the same loader real exports go through rather than a lenient copy, so it must carry every key that loader reads — they are listed in `../exports/README.md`. diff --git a/tests/fixtures/problems/degrees_beside_unbalanced_maths/expected.txt b/tests/fixtures/problems/degrees_beside_unbalanced_maths/expected.txt new file mode 100644 index 0000000..651c10f --- /dev/null +++ b/tests/fixtures/problems/degrees_beside_unbalanced_maths/expected.txt @@ -0,0 +1,2 @@ +Question 1 "Descent angle", part (a), worked solution: unclosed inline $ ... $ +Question 1 "Descent angle", part (a), worked solution: ^\circ does not display; write the degree sign ° instead diff --git a/tests/fixtures/problems/degrees_beside_unbalanced_maths/question_000_Descent_angle.json b/tests/fixtures/problems/degrees_beside_unbalanced_maths/question_000_Descent_angle.json new file mode 100644 index 0000000..6dd5ac0 --- /dev/null +++ b/tests/fixtures/problems/degrees_beside_unbalanced_maths/question_000_Descent_angle.json @@ -0,0 +1,22 @@ +{ + "orderNumber": 0, + "title": "Descent angle", + "masterContent": "", + "publish": true, + "displayFinalAnswer": true, + "displayStructuredTutorial": true, + "displayWorkedSolution": true, + "displayChatbot": true, + "parts": [ + { + "orderNumber": 0, + "content": "Show that the glider descends steadily.", + "answerContent": "", + "workedSolution": { + "content": "Turn through $90^\\circ$, then the fee is $5.", + "children": [] + }, + "responseAreas": [] + } + ] +} diff --git a/tests/fixtures/problems/degrees_beside_unbalanced_maths/set_Degrees_beside_unbalanced_maths.json b/tests/fixtures/problems/degrees_beside_unbalanced_maths/set_Degrees_beside_unbalanced_maths.json new file mode 100644 index 0000000..81312d5 --- /dev/null +++ b/tests/fixtures/problems/degrees_beside_unbalanced_maths/set_Degrees_beside_unbalanced_maths.json @@ -0,0 +1,7 @@ +{ + "name": "Degrees beside unbalanced maths", + "description": "A worked solution whose later dollar is unclosed, so that the degree sign in the expression before it must still be reported.", + "finalAnswerVisibility": "OPEN_WITH_WARNINGS", + "workedSolutionVisibility": "OPEN_WITH_WARNINGS", + "structuredTutorialVisibility": "OPEN" +} diff --git a/tests/fixtures/problems/katex_strict_unicode/expected.txt b/tests/fixtures/problems/katex_strict_unicode/expected.txt new file mode 100644 index 0000000..f90903b --- /dev/null +++ b/tests/fixtures/problems/katex_strict_unicode/expected.txt @@ -0,0 +1 @@ +Question 1 "Speed of the trolley", part (a), text, characters 24-46: KaTeX rejects it: LaTeX-incompatible input and strict mode is set to 'error': Unicode text character "с" used in math mode [unicodeTextInMathMode] at position 15: v = 5 \space с̲m/s diff --git a/tests/fixtures/problems/katex_strict_unicode/question_000_Speed_of_the_trolley.json b/tests/fixtures/problems/katex_strict_unicode/question_000_Speed_of_the_trolley.json new file mode 100644 index 0000000..1a82f43 --- /dev/null +++ b/tests/fixtures/problems/katex_strict_unicode/question_000_Speed_of_the_trolley.json @@ -0,0 +1,19 @@ +{ + "orderNumber": 0, + "title": "Speed of the trolley", + "masterContent": "", + "publish": true, + "displayFinalAnswer": true, + "displayStructuredTutorial": true, + "displayWorkedSolution": true, + "displayChatbot": true, + "parts": [ + { + "orderNumber": 0, + "content": "Show that the speed is\n$$\nv = 5 \\space сm/s\n$$\n", + "answerContent": "", + "workedSolution": {"content": "", "children": []}, + "responseAreas": [] + } + ] +} diff --git a/tests/fixtures/problems/katex_strict_unicode/set_Unicode_in_maths.json b/tests/fixtures/problems/katex_strict_unicode/set_Unicode_in_maths.json new file mode 100644 index 0000000..9b6d6f4 --- /dev/null +++ b/tests/fixtures/problems/katex_strict_unicode/set_Unicode_in_maths.json @@ -0,0 +1,7 @@ +{ + "name": "Unicode in maths", + "description": "Display maths with a Cyrillic letter pasted in for a Latin one, which KaTeX in strict mode refuses.", + "finalAnswerVisibility": "OPEN_WITH_WARNINGS", + "workedSolutionVisibility": "OPEN_WITH_WARNINGS", + "structuredTutorialVisibility": "OPEN" +} diff --git a/tests/fixtures/problems/katex_unclosed_brace/expected.txt b/tests/fixtures/problems/katex_unclosed_brace/expected.txt new file mode 100644 index 0000000..89093a7 --- /dev/null +++ b/tests/fixtures/problems/katex_unclosed_brace/expected.txt @@ -0,0 +1 @@ +Question 1 "Kinetic energy", part (a), text, characters 15-32: KaTeX rejects it: Unexpected end of input in a macro argument, expected '}' at end of input: …frac{1}{2 m v^2 diff --git a/tests/fixtures/problems/katex_unclosed_brace/question_000_Kinetic_energy.json b/tests/fixtures/problems/katex_unclosed_brace/question_000_Kinetic_energy.json new file mode 100644 index 0000000..fc67e14 --- /dev/null +++ b/tests/fixtures/problems/katex_unclosed_brace/question_000_Kinetic_energy.json @@ -0,0 +1,19 @@ +{ + "orderNumber": 0, + "title": "Kinetic energy", + "masterContent": "", + "publish": true, + "displayFinalAnswer": true, + "displayStructuredTutorial": true, + "displayWorkedSolution": true, + "displayChatbot": true, + "parts": [ + { + "orderNumber": 0, + "content": "The energy is $\\frac{1}{2 m v^2$.", + "answerContent": "", + "workedSolution": {"content": "", "children": []}, + "responseAreas": [] + } + ] +} diff --git a/tests/fixtures/problems/katex_unclosed_brace/set_Unclosed_brace.json b/tests/fixtures/problems/katex_unclosed_brace/set_Unclosed_brace.json new file mode 100644 index 0000000..81684d8 --- /dev/null +++ b/tests/fixtures/problems/katex_unclosed_brace/set_Unclosed_brace.json @@ -0,0 +1,7 @@ +{ + "name": "Unclosed brace", + "description": "Maths whose dollars balance but whose braces do not, so only rendering it finds the fault.", + "finalAnswerVisibility": "OPEN_WITH_WARNINGS", + "workedSolutionVisibility": "OPEN_WITH_WARNINGS", + "structuredTutorialVisibility": "OPEN" +} diff --git a/tests/fixtures/problems/katex_undefined_command/expected.txt b/tests/fixtures/problems/katex_undefined_command/expected.txt new file mode 100644 index 0000000..2f2af67 --- /dev/null +++ b/tests/fixtures/problems/katex_undefined_command/expected.txt @@ -0,0 +1,2 @@ +Question 1 "Velocity", part (a), text, characters 20-29: KaTeX rejects it: Undefined control sequence: \vect at position 1: \̲v̲e̲c̲t̲{v} +Question 1 "Velocity", part (a), text: the PDF generator cannot compile this: Undefined control sequence. diff --git a/tests/fixtures/problems/katex_undefined_command/question_000_Velocity.json b/tests/fixtures/problems/katex_undefined_command/question_000_Velocity.json new file mode 100644 index 0000000..38c1616 --- /dev/null +++ b/tests/fixtures/problems/katex_undefined_command/question_000_Velocity.json @@ -0,0 +1,19 @@ +{ + "orderNumber": 0, + "title": "Velocity", + "masterContent": "", + "publish": true, + "displayFinalAnswer": true, + "displayStructuredTutorial": true, + "displayWorkedSolution": true, + "displayChatbot": true, + "parts": [ + { + "orderNumber": 0, + "content": "State the velocity $\\vect{v}$ of the trolley.", + "answerContent": "", + "workedSolution": {"content": "", "children": []}, + "responseAreas": [] + } + ] +} diff --git a/tests/fixtures/problems/katex_undefined_command/set_Undefined_command.json b/tests/fixtures/problems/katex_undefined_command/set_Undefined_command.json new file mode 100644 index 0000000..cf6d055 --- /dev/null +++ b/tests/fixtures/problems/katex_undefined_command/set_Undefined_command.json @@ -0,0 +1,7 @@ +{ + "name": "Undefined command", + "description": "Maths using a command KaTeX has never heard of, which only KaTeX itself can tell us about.", + "finalAnswerVisibility": "OPEN_WITH_WARNINGS", + "workedSolutionVisibility": "OPEN_WITH_WARNINGS", + "structuredTutorialVisibility": "OPEN" +} diff --git a/tests/fixtures/problems/latex_fault/expected.txt b/tests/fixtures/problems/latex_fault/expected.txt index 12b65a2..d163e60 100644 --- a/tests/fixtures/problems/latex_fault/expected.txt +++ b/tests/fixtures/problems/latex_fault/expected.txt @@ -1 +1,2 @@ Question 1 "Undefined command", part (a), text: the PDF generator cannot compile this: Undefined control sequence. +Question 1 "Undefined command", part (a), text, characters 10-29: KaTeX rejects it: Undefined control sequence: \nosuchcommand at position 5: x = \̲n̲o̲s̲u̲c̲h̲c̲o̲m̲m̲a̲n̲d̲ diff --git a/tests/fixtures/problems/unbalanced_maths_not_rendered/expected.txt b/tests/fixtures/problems/unbalanced_maths_not_rendered/expected.txt new file mode 100644 index 0000000..17ecc19 --- /dev/null +++ b/tests/fixtures/problems/unbalanced_maths_not_rendered/expected.txt @@ -0,0 +1 @@ +Question 1 "Cost of the parts", part (a), text: unclosed inline $ ... $ diff --git a/tests/fixtures/problems/unbalanced_maths_not_rendered/question_000_Cost_of_the_parts.json b/tests/fixtures/problems/unbalanced_maths_not_rendered/question_000_Cost_of_the_parts.json new file mode 100644 index 0000000..baf10c0 --- /dev/null +++ b/tests/fixtures/problems/unbalanced_maths_not_rendered/question_000_Cost_of_the_parts.json @@ -0,0 +1,19 @@ +{ + "orderNumber": 0, + "title": "Cost of the parts", + "masterContent": "", + "publish": true, + "displayFinalAnswer": true, + "displayStructuredTutorial": true, + "displayWorkedSolution": true, + "displayChatbot": true, + "parts": [ + { + "orderNumber": 0, + "content": "Cost $5 & mass $m$.", + "answerContent": "", + "workedSolution": {"content": "", "children": []}, + "responseAreas": [] + } + ] +} diff --git a/tests/fixtures/problems/unbalanced_maths_not_rendered/set_Unbalanced_maths_is_not_rendered.json b/tests/fixtures/problems/unbalanced_maths_not_rendered/set_Unbalanced_maths_is_not_rendered.json new file mode 100644 index 0000000..088473e --- /dev/null +++ b/tests/fixtures/problems/unbalanced_maths_not_rendered/set_Unbalanced_maths_is_not_rendered.json @@ -0,0 +1,7 @@ +{ + "name": "Unbalanced maths is not rendered", + "description": "A price beside an expression, so that the dollars pair up wrongly and what lies between them is not maths at all: the unclosed dollar is the one thing to report, and KaTeX must not be asked what it makes of it.", + "finalAnswerVisibility": "OPEN_WITH_WARNINGS", + "workedSolutionVisibility": "OPEN_WITH_WARNINGS", + "structuredTutorialVisibility": "OPEN" +} diff --git a/tests/test_runner.py b/tests/test_runner.py index 5f728ac..7881981 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -81,3 +81,26 @@ def test_cli_reports_problems_and_exports_anyway(tmp_path) -> None: "the export will not contain the image absent.png" in result.output ) assert (out_dir / "set.zip").is_file() + + +def test_cli_says_when_the_maths_could_not_be_checked( + tmp_path, without_node: None +) -> None: + """Node.js is optional, so a check that could not run says so rather than passing.""" + question_file = tmp_path / "questions.tex" + question_file.write_text( + "\\documentclass{article}\n" + "\\begin{document}\n" + "\\section{Continuity}\n" + "Show that $\\rho v A$ is constant.\n" + "\\end{document}\n" + ) + + result = CliRunner().invoke( + cli, ["convert", str(question_file), "PartsOneSol", "-o", str(tmp_path / "out")] + ) + + assert result.exit_code == 0 + assert ( + "Warning: Maths was not checked against KaTeX: install Node.js" in result.output + ) diff --git a/tests/test_validation.py b/tests/test_validation.py index c37805f..f58ddfb 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -7,8 +7,12 @@ The markdown cases were ported from ``conversion2025/tools and testing/validator_tests.py`` on the ``Summer2025`` branch. + +The folders whose report says ``KaTeX rejects it`` need Node.js to render with, and skip +without it; CI always has it. """ +import json import os import shutil import subprocess @@ -16,10 +20,10 @@ from pathlib import Path import pytest -from conftest import EXPORTS, PROBLEM_SETS +from conftest import EXPORTS, PROBLEM_SETS, PROBLEMS_DIR from in2lambda.api.set import Set -from in2lambda.validation import MathDelimiterError, pdf, validate +from in2lambda.validation import MathDelimiterError, _node, pdf, validate E = MathDelimiterError @@ -101,6 +105,8 @@ def _messages(markdown: str) -> list[str]: def test_expected_problems_are_reported(problem_set: Path) -> None: """Each hand-written export produces exactly the report written beside it.""" expected = (problem_set / "expected.txt").read_text().splitlines() + if _node() is None and any("KaTeX rejects it" in line for line in expected): + pytest.skip("KaTeX needs Node.js to render with") found = validate(Set.from_json(str(problem_set))) assert sorted(str(problem) for problem in found) == sorted(expected) @@ -125,6 +131,69 @@ def test_invalid_markdown_is_reported( assert _messages(content) == [expected.value] +def test_without_node_the_maths_is_not_checked(without_node: None) -> None: + """Node.js being optional, its absence is said out loud rather than passed over.""" + question_set = Set.from_json( + str(PROBLEMS_DIR / "katex_undefined_command") + ) # $\vect{v}$, which only KaTeX itself objects to. + + with pytest.warns(UserWarning, match="nodejs.org"): + problems = validate(question_set, compile=False) + + assert problems == [] + + +def test_a_node_that_does_not_render_is_not_fatal( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """Anything named node may be on the PATH; the rest of the report must survive it. + + ``false`` stands in for it: on the PATH, runnable, and no use for rendering maths. + """ + monkeypatch.setattr("in2lambda.validation._node", lambda: shutil.which("false")) + question_set = Set.from_json(str(PROBLEMS_DIR / "degrees")) + + with pytest.warns(UserWarning, match="Maths was not checked against KaTeX"): + problems = validate(question_set, compile=False) + + assert [str(problem) for problem in problems] == ( + (PROBLEMS_DIR / "degrees" / "expected.txt").read_text().splitlines() + ) + + +@pytest.mark.skipif(_node() is None, reason="KaTeX needs Node.js to render with") +def test_katex_is_read_back_whatever_the_locale() -> None: + """KaTeX underlines where it stopped reading, so its messages are never ASCII. + + Run in a process of its own because the locale is read when Python starts. + """ + expected = [ + line + for line in (PROBLEMS_DIR / "katex_undefined_command" / "expected.txt") + .read_text() + .splitlines() + if "KaTeX rejects it" in line + ] + script = ( + "import json\n" + "from in2lambda.api.set import Set\n" + "from in2lambda.validation import validate\n" + f"question_set = Set.from_json({str(PROBLEMS_DIR / 'katex_undefined_command')!r})\n" + # ensure_ascii so that the child's own stdout cannot fail for a different reason. + "print(json.dumps([str(p) for p in validate(question_set, compile=False)]))\n" + ) + run = subprocess.run( + [sys.executable, "-c", script], + env=os.environ + | {"LC_ALL": "C", "LANG": "C", "PYTHONUTF8": "0", "PYTHONCOERCECLOCALE": "0"}, + capture_output=True, + encoding="utf-8", + ) + + assert run.returncode == 0, run.stderr + assert json.loads(run.stdout) == expected + + def test_image_that_is_not_on_disk_is_reported(tmp_path: Path) -> None: """An image a question lists but that is not there would break the export.""" question_set = Set()