diff --git a/.gitattributes b/.gitattributes
index 84c7add0..9277fc7e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
-/.gitattributes export-ignore
-/.gitignore export-ignore
+/Resources/views/Script/Mermaid/Makefile export-ignore
+/.git* export-ignore
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 00000000..4689c4da
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,8 @@
+Please do not submit any Pull Requests here. They will be closed.
+---
+
+Please submit your PR here instead:
+https://github.com/symfony/symfony
+
+This repository is what we call a "subtree split": a read-only subset of that main repository.
+We're looking forward to your PR there!
diff --git a/.github/workflows/close-pull-request.yml b/.github/workflows/close-pull-request.yml
new file mode 100644
index 00000000..e55b4781
--- /dev/null
+++ b/.github/workflows/close-pull-request.yml
@@ -0,0 +1,20 @@
+name: Close Pull Request
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Thanks for your Pull Request! We love contributions.
+
+ However, you should instead open your PR on the main repository:
+ https://github.com/symfony/symfony
+
+ This repository is what we call a "subtree split": a read-only subset of that main repository.
+ We're looking forward to your PR there!
diff --git a/.gitignore b/.gitignore
index c49a5d8d..431f2b65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
vendor/
composer.lock
phpunit.xml
+/Resources/views/Script/Mermaid/repo-*
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3a2d8c8..6d2f8eb5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,16 @@
CHANGELOG
=========
+7.2
+---
+
+ * Add support for displaying profiles of multiple serializer instances
+
+7.1
+---
+
+ * Set `XDEBUG_IGNORE` query parameter when sending toolbar XHR
+
6.4
---
diff --git a/Controller/ExceptionPanelController.php b/Controller/ExceptionPanelController.php
index a0704bb5..17c052da 100644
--- a/Controller/ExceptionPanelController.php
+++ b/Controller/ExceptionPanelController.php
@@ -25,13 +25,10 @@
*/
class ExceptionPanelController
{
- private HtmlErrorRenderer $errorRenderer;
- private ?Profiler $profiler;
-
- public function __construct(HtmlErrorRenderer $errorRenderer, ?Profiler $profiler = null)
- {
- $this->errorRenderer = $errorRenderer;
- $this->profiler = $profiler;
+ public function __construct(
+ private HtmlErrorRenderer $errorRenderer,
+ private ?Profiler $profiler = null,
+ ) {
}
/**
diff --git a/Controller/ProfilerController.php b/Controller/ProfilerController.php
index a7c0644f..0e0d4f89 100644
--- a/Controller/ProfilerController.php
+++ b/Controller/ProfilerController.php
@@ -34,21 +34,15 @@
class ProfilerController
{
private TemplateManager $templateManager;
- private UrlGeneratorInterface $generator;
- private ?Profiler $profiler;
- private Environment $twig;
- private array $templates;
- private ?ContentSecurityPolicyHandler $cspHandler;
- private ?string $baseDir;
-
- public function __construct(UrlGeneratorInterface $generator, ?Profiler $profiler, Environment $twig, array $templates, ?ContentSecurityPolicyHandler $cspHandler = null, ?string $baseDir = null)
- {
- $this->generator = $generator;
- $this->profiler = $profiler;
- $this->twig = $twig;
- $this->templates = $templates;
- $this->cspHandler = $cspHandler;
- $this->baseDir = $baseDir;
+
+ public function __construct(
+ private UrlGeneratorInterface $generator,
+ private ?Profiler $profiler,
+ private Environment $twig,
+ private array $templates,
+ private ?ContentSecurityPolicyHandler $cspHandler = null,
+ private ?string $baseDir = null,
+ ) {
}
/**
@@ -105,7 +99,7 @@ public function panelAction(Request $request, string $token): Response
}
if (!$profile->hasCollector($panel)) {
- throw new NotFoundHttpException(sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
+ throw new NotFoundHttpException(\sprintf('Panel "%s" is not available for token "%s".', $panel, $token));
}
return $this->renderWithCspNonces($request, $this->getTemplateManager()->getName($profile, $panel), [
@@ -168,6 +162,27 @@ public function toolbarAction(Request $request, ?string $token = null): Response
]);
}
+ /**
+ * Renders the Web Debug Toolbar stylesheet.
+ *
+ * @throws NotFoundHttpException
+ */
+ public function toolbarStylesheetAction(): Response
+ {
+ $this->denyAccessIfProfilerDisabled();
+
+ $this->cspHandler?->disableCsp();
+
+ return new Response(
+ $this->twig->render('@WebProfiler/Profiler/toolbar.css.twig'),
+ 200,
+ [
+ 'Content-Type' => 'text/css',
+ 'Cache-Control' => 'max-age=600, private',
+ ],
+ );
+ }
+
/**
* Renders the profiler search bar.
*
@@ -195,7 +210,6 @@ public function searchBarAction(Request $request): Response
'end' => $request->query->get('end', $session?->get('_profiler_search_end')),
'limit' => $request->query->get('limit', $session?->get('_profiler_search_limit')),
'request' => $request,
- 'render_hidden_by_default' => false,
'profile_type' => $request->query->get('type', $session?->get('_profiler_search_type', 'request')),
]),
200,
@@ -275,7 +289,7 @@ public function searchAction(Request $request): Response
$session->set('_profiler_search_type', $profileType);
}
- if (!empty($token)) {
+ if ($token) {
return new RedirectResponse($this->generator->generate('_profiler', ['token' => $token]), 302, ['Content-Type' => 'text/html']);
}
@@ -343,12 +357,12 @@ public function fontAction(string $fontName): Response
{
$this->denyAccessIfProfilerDisabled();
if ('JetBrainsMono' !== $fontName) {
- throw new NotFoundHttpException(sprintf('Font file "%s.woff2" not found.', $fontName));
+ throw new NotFoundHttpException(\sprintf('Font file "%s.woff2" not found.', $fontName));
}
$fontFile = \dirname(__DIR__).'/Resources/fonts/'.$fontName.'.woff2';
if (!is_file($fontFile) || !is_readable($fontFile)) {
- throw new NotFoundHttpException(sprintf('Cannot read font file "%s".', $fontFile));
+ throw new NotFoundHttpException(\sprintf('Cannot read font file "%s".', $fontFile));
}
$this->profiler?->disable();
@@ -375,7 +389,7 @@ public function openAction(Request $request): Response
$filename = $this->baseDir.\DIRECTORY_SEPARATOR.$file;
if (preg_match("'(^|[/\\\\])\.'", $file) || !is_readable($filename)) {
- throw new NotFoundHttpException(sprintf('The file "%s" cannot be opened.', $file));
+ throw new NotFoundHttpException(\sprintf('The file "%s" cannot be opened.', $file));
}
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/open.html.twig', [
@@ -390,6 +404,9 @@ protected function getTemplateManager(): TemplateManager
return $this->templateManager ??= new TemplateManager($this->profiler, $this->twig, $this->templates);
}
+ /**
+ * @throws NotFoundHttpException
+ */
private function denyAccessIfProfilerDisabled(): void
{
if (null === $this->profiler) {
diff --git a/Controller/RouterController.php b/Controller/RouterController.php
index f9f7686d..af8f80e1 100644
--- a/Controller/RouterController.php
+++ b/Controller/RouterController.php
@@ -30,23 +30,19 @@
*/
class RouterController
{
- private ?Profiler $profiler;
- private Environment $twig;
- private ?UrlMatcherInterface $matcher;
- private ?RouteCollection $routes;
-
/**
- * @var ExpressionFunctionProviderInterface[]
+ * @param ExpressionFunctionProviderInterface[] $expressionLanguageProviders
*/
- private iterable $expressionLanguageProviders;
-
- public function __construct(?Profiler $profiler, Environment $twig, ?UrlMatcherInterface $matcher = null, ?RouteCollection $routes = null, iterable $expressionLanguageProviders = [])
- {
- $this->profiler = $profiler;
- $this->twig = $twig;
- $this->matcher = $matcher;
- $this->routes = (null === $routes && $matcher instanceof RouterInterface) ? $matcher->getRouteCollection() : $routes;
- $this->expressionLanguageProviders = $expressionLanguageProviders;
+ public function __construct(
+ private ?Profiler $profiler,
+ private Environment $twig,
+ private ?UrlMatcherInterface $matcher = null,
+ private ?RouteCollection $routes = null,
+ private iterable $expressionLanguageProviders = [],
+ ) {
+ if ($this->matcher instanceof RouterInterface) {
+ $this->routes ??= $this->matcher->getRouteCollection();
+ }
}
/**
@@ -83,10 +79,10 @@ public function panelAction(string $token): Response
*/
private function getTraces(RequestDataCollector $request, string $method): array
{
- $traceRequest = Request::create(
- $request->getPathInfo(),
- $request->getRequestServer(true)->get('REQUEST_METHOD'),
- \in_array($request->getMethod(), ['DELETE', 'PATCH', 'POST', 'PUT'], true) ? $request->getRequestRequest()->all() : $request->getRequestQuery()->all(),
+ $traceRequest = new Request(
+ $request->getRequestQuery()->all(),
+ $request->getRequestRequest()->all(),
+ $request->getRequestAttributes()->all(),
$request->getRequestCookies(true)->all(),
[],
$request->getRequestServer(true)->all()
diff --git a/Csp/ContentSecurityPolicyHandler.php b/Csp/ContentSecurityPolicyHandler.php
index f7d8f5f1..3fca0b97 100644
--- a/Csp/ContentSecurityPolicyHandler.php
+++ b/Csp/ContentSecurityPolicyHandler.php
@@ -23,12 +23,11 @@
*/
class ContentSecurityPolicyHandler
{
- private NonceGenerator $nonceGenerator;
private bool $cspDisabled = false;
- public function __construct(NonceGenerator $nonceGenerator)
- {
- $this->nonceGenerator = $nonceGenerator;
+ public function __construct(
+ private NonceGenerator $nonceGenerator,
+ ) {
}
/**
@@ -124,10 +123,10 @@ private function updateCspHeaders(Response $response, array $nonces = []): array
$headers = $this->getCspHeaders($response);
$types = [
- 'script-src' => 'csp_script_nonce',
- 'script-src-elem' => 'csp_script_nonce',
- 'style-src' => 'csp_style_nonce',
- 'style-src-elem' => 'csp_style_nonce',
+ 'script-src' => 'csp_script_nonce',
+ 'script-src-elem' => 'csp_script_nonce',
+ 'style-src' => 'csp_style_nonce',
+ 'style-src-elem' => 'csp_style_nonce',
];
foreach ($headers as $header => $directives) {
@@ -152,7 +151,7 @@ private function updateCspHeaders(Response $response, array $nonces = []): array
if (!\in_array('\'unsafe-inline\'', $headers[$header][$type], true)) {
$headers[$header][$type][] = '\'unsafe-inline\'';
}
- $headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]);
+ $headers[$header][$type][] = \sprintf('\'nonce-%s\'', $nonces[$tokenName]);
}
}
@@ -180,7 +179,7 @@ private function generateNonce(): string
*/
private function generateCspHeader(array $directives): string
{
- return array_reduce(array_keys($directives), fn ($res, $name) => ('' !== $res ? $res.'; ' : '').sprintf('%s %s', $name, implode(' ', $directives[$name])), '');
+ return array_reduce(array_keys($directives), fn ($res, $name) => ('' !== $res ? $res.'; ' : '').\sprintf('%s %s', $name, implode(' ', $directives[$name])), '');
}
/**
diff --git a/EventListener/WebDebugToolbarListener.php b/EventListener/WebDebugToolbarListener.php
index c2b350ff..c51cf309 100644
--- a/EventListener/WebDebugToolbarListener.php
+++ b/EventListener/WebDebugToolbarListener.php
@@ -40,23 +40,15 @@ class WebDebugToolbarListener implements EventSubscriberInterface
public const DISABLED = 1;
public const ENABLED = 2;
- private Environment $twig;
- private ?UrlGeneratorInterface $urlGenerator;
- private bool $interceptRedirects;
- private int $mode;
- private string $excludedAjaxPaths;
- private ?ContentSecurityPolicyHandler $cspHandler;
- private ?DumpDataCollector $dumpDataCollector;
-
- public function __construct(Environment $twig, bool $interceptRedirects = false, int $mode = self::ENABLED, ?UrlGeneratorInterface $urlGenerator = null, string $excludedAjaxPaths = '^/bundles|^/_wdt', ?ContentSecurityPolicyHandler $cspHandler = null, ?DumpDataCollector $dumpDataCollector = null)
- {
- $this->twig = $twig;
- $this->urlGenerator = $urlGenerator;
- $this->interceptRedirects = $interceptRedirects;
- $this->mode = $mode;
- $this->excludedAjaxPaths = $excludedAjaxPaths;
- $this->cspHandler = $cspHandler;
- $this->dumpDataCollector = $dumpDataCollector;
+ public function __construct(
+ private Environment $twig,
+ private bool $interceptRedirects = false,
+ private int $mode = self::ENABLED,
+ private ?UrlGeneratorInterface $urlGenerator = null,
+ private string $excludedAjaxPaths = '^/bundles|^/_wdt',
+ private ?ContentSecurityPolicyHandler $cspHandler = null,
+ private ?DumpDataCollector $dumpDataCollector = null,
+ ) {
}
public function isEnabled(): bool
@@ -67,7 +59,7 @@ public function isEnabled(): bool
public function setMode(int $mode): void
{
if (self::DISABLED !== $mode && self::ENABLED !== $mode) {
- throw new \InvalidArgumentException(sprintf('Invalid value provided for mode, use one of "%s::DISABLED" or "%s::ENABLED".', self::class, self::class));
+ throw new \InvalidArgumentException(\sprintf('Invalid value provided for mode, use one of "%s::DISABLED" or "%s::ENABLED".', self::class, self::class));
}
$this->mode = $mode;
@@ -107,7 +99,7 @@ public function onKernelResponse(ResponseEvent $event): void
return;
}
- if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) {
+ if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat() && $response->headers->has('Location')) {
if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
diff --git a/Profiler/CodeExtension.php b/Profiler/CodeExtension.php
index b8d9091d..332a5d6c 100644
--- a/Profiler/CodeExtension.php
+++ b/Profiler/CodeExtension.php
@@ -26,14 +26,14 @@
final class CodeExtension extends AbstractExtension
{
private string|FileLinkFormatter|array|false $fileLinkFormat;
- private string $charset;
- private string $projectDir;
- public function __construct(string|FileLinkFormatter $fileLinkFormat, string $projectDir, string $charset)
- {
+ public function __construct(
+ string|FileLinkFormatter $fileLinkFormat,
+ private string $projectDir,
+ private string $charset,
+ ) {
$this->fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->projectDir = str_replace('\\', '/', $projectDir).'/';
- $this->charset = $charset;
}
public function getFilters(): array
@@ -57,18 +57,18 @@ public function abbrClass(string $class): string
$parts = explode('\\', $class);
$short = array_pop($parts);
- return sprintf('%s', $class, $short);
+ return \sprintf('%s', $class, $short);
}
public function abbrMethod(string $method): string
{
if (str_contains($method, '::')) {
[$class, $method] = explode('::', $method, 2);
- $result = sprintf('%s::%s()', $this->abbrClass($class), $method);
+ $result = \sprintf('%s::%s()', $this->abbrClass($class), $method);
} elseif ('Closure' === $method) {
- $result = sprintf('%1$s', $method);
+ $result = \sprintf('%1$s', $method);
} else {
- $result = sprintf('%1$s()', $method);
+ $result = \sprintf('%1$s()', $method);
}
return $result;
@@ -85,9 +85,9 @@ public function formatArgs(array $args): string
$item[1] = htmlspecialchars($item[1], \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
$parts = explode('\\', $item[1]);
$short = array_pop($parts);
- $formattedValue = sprintf('object(%s)', $item[1], $short);
+ $formattedValue = \sprintf('object(%s)', $item[1], $short);
} elseif ('array' === $item[0]) {
- $formattedValue = sprintf('array(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
+ $formattedValue = \sprintf('array(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
} elseif ('null' === $item[0]) {
$formattedValue = 'null';
} elseif ('boolean' === $item[0]) {
@@ -100,7 +100,7 @@ public function formatArgs(array $args): string
$formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
}
- $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", htmlspecialchars($key, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $formattedValue);
+ $result[] = \is_int($key) ? $formattedValue : \sprintf("'%s' => %s", htmlspecialchars($key, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $formattedValue);
}
return implode(', ', $result);
@@ -164,7 +164,7 @@ public function formatFile(string $file, int $line, ?string $text = null): strin
if (null === $text) {
if (null !== $rel = $this->getFileRelative($file)) {
$rel = explode('/', htmlspecialchars($rel, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), 2);
- $text = sprintf('%s%s', htmlspecialchars($this->projectDir, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $rel[0], '/'.($rel[1] ?? ''));
+ $text = \sprintf('%s%s', htmlspecialchars($this->projectDir, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $rel[0], '/'.($rel[1] ?? ''));
} else {
$text = htmlspecialchars($file, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
}
@@ -177,7 +177,7 @@ public function formatFile(string $file, int $line, ?string $text = null): strin
}
if (false !== $link = $this->getFileLink($file, $line)) {
- return sprintf('%s', htmlspecialchars($link, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $text);
+ return \sprintf('%s', htmlspecialchars($link, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $text);
}
return $text;
diff --git a/Profiler/TemplateManager.php b/Profiler/TemplateManager.php
index c75158c9..23b88b1d 100644
--- a/Profiler/TemplateManager.php
+++ b/Profiler/TemplateManager.php
@@ -24,15 +24,11 @@
*/
class TemplateManager
{
- protected Environment $twig;
- protected array $templates;
- protected Profiler $profiler;
-
- public function __construct(Profiler $profiler, Environment $twig, array $templates)
- {
- $this->profiler = $profiler;
- $this->twig = $twig;
- $this->templates = $templates;
+ public function __construct(
+ protected Profiler $profiler,
+ protected Environment $twig,
+ protected array $templates,
+ ) {
}
/**
@@ -45,7 +41,7 @@ public function getName(Profile $profile, string $panel): mixed
$templates = $this->getNames($profile);
if (!isset($templates[$panel])) {
- throw new NotFoundHttpException(sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel));
+ throw new NotFoundHttpException(\sprintf('Panel "%s" is not registered in profiler or is not present in viewed profile.', $panel));
}
return $templates[$panel];
@@ -77,7 +73,7 @@ public function getNames(Profile $profile): array
}
if (!$loader->exists($template.'.html.twig')) {
- throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
+ throw new \UnexpectedValueException(\sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
}
$templates[$name] = $template.'.html.twig';
diff --git a/Resources/config/routing/wdt.xml b/Resources/config/routing/wdt.xml
index 0f7e960c..9f45f1b7 100644
--- a/Resources/config/routing/wdt.xml
+++ b/Resources/config/routing/wdt.xml
@@ -4,6 +4,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
+
${n.children.map(r).join("")}
`:`Unsupported markdown: ${n.type}`}return e.map(r).join("")}function FS(t){return Intl.Segmenter?[...new Intl.Segmenter().segment(t)].map(e=>e.segment):[...t]}function LS(t,e){const r=FS(e.content);return a2(t,[],r,e.type)}function a2(t,e,r,n){if(r.length===0)return[{content:e.join(""),type:n},{content:"",type:n}];const[i,...a]=r,s=[...e,i];return t([{content:s.join(""),type:n}])?a2(t,s,a,n):(e.length===0&&i&&(e.push(i),r.shift()),[{content:e.join(""),type:n},{content:r.join(""),type:n}])}function MS(t,e){if(t.some(({content:r})=>r.includes(` +`)))throw new Error("splitLineToFitWidth does not support newlines in the line");return yu(t,e)}function yu(t,e,r=[],n=[]){if(t.length===0)return n.length>0&&r.push(n),r.length>0?r:[];let i="";t[0].content===" "&&(i=" ",t.shift());const a=t.shift()??{content:" ",type:"normal"},s=[...n];if(i!==""&&s.push({content:i,type:"normal"}),s.push(a),e(s))return yu(t,e,r,s);if(n.length>0)r.push(n),t.unshift(a);else if(a.content){const[o,l]=LS(e,a);r.push([o]),l.content&&t.unshift(l)}return yu(t,e,r)}function DS(t,e){e&&t.attr("style",e)}function IS(t,e,r,n,i=!1){const a=t.append("foreignObject"),s=a.append("xhtml:div"),o=e.label,l=e.isNode?"nodeLabel":"edgeLabel";s.html(` + "+o+""),DS(s,e.labelStyle),s.style("display","table-cell"),s.style("white-space","nowrap"),s.style("max-width",r+"px"),s.attr("xmlns","http://www.w3.org/1999/xhtml"),i&&s.attr("class","labelBkg");let u=s.node().getBoundingClientRect();return u.width===r&&(s.style("display","table"),s.style("white-space","break-spaces"),s.style("width",r+"px"),u=s.node().getBoundingClientRect()),a.style("width",u.width),a.style("height",u.height),a.node()}function s2(t,e,r){return t.append("tspan").attr("class","text-outer-tspan").attr("x",0).attr("y",e*r-.1+"em").attr("dy",r+"em")}function zS(t,e,r){const n=t.append("text"),i=s2(n,1,e);o2(i,r);const a=i.node().getComputedTextLength();return n.remove(),a}function OS(t,e,r,n=!1){const a=e.append("g"),s=a.insert("rect").attr("class","background"),o=a.append("text").attr("y","-10.1");let l=0;for(const u of r){const c=f=>zS(a,1.1,f)<=t,h=c(u)?[u]:MS(u,c);for(const f of h){const p=s2(o,l,1.1);o2(p,f),l++}}if(n){const u=o.node().getBBox(),c=2;return s.attr("x",-c).attr("y",-c).attr("width",u.width+2*c).attr("height",u.height+2*c),a.node()}else return o.node()}function o2(t,e){t.text(""),e.forEach((r,n)=>{const i=t.append("tspan").attr("font-style",r.type==="emphasis"?"italic":"normal").attr("class","text-inner-tspan").attr("font-weight",r.type==="strong"?"bold":"normal");n===0?i.text(r.content):i.text(" "+r.content)})}const bu=(t,e="",{style:r="",isTitle:n=!1,classes:i="",useHtmlLabels:a=!0,isNode:s=!0,width:o=200,addSvgBackground:l=!1}={})=>{if(E.info("createText",e,r,n,i,a,s,l),a){const u=ES(e),c={isNode:s,label:Va(u).replace(/fa[blrs]?:fa-[\w-]+/g,f=>``),labelStyle:r.replace("fill:","color:")};return IS(t,c,o,i,l)}else{const u=BS(e);return OS(o,t,u,l)}},Ee=async(t,e,r,n)=>{let i;const a=e.useHtmlLabels||De(Et().flowchart.htmlLabels);r?i=r:i="node default";const s=t.insert("g").attr("class",i).attr("id",e.domId||e.id),o=s.insert("g").attr("class","label").attr("style",e.labelStyle);let l;e.labelText===void 0?l="":l=typeof e.labelText=="string"?e.labelText:e.labelText[0];const u=o.node();let c;e.labelType==="markdown"?c=bu(o,li(Va(l),Et()),{useHtmlLabels:a,width:e.width||Et().flowchart.wrappingWidth,classes:"markdown-node-label"}):c=u.appendChild(Qe(li(Va(l),Et()),e.labelStyle,!1,n));let h=c.getBBox();const f=e.padding/2;if(De(Et().flowchart.htmlLabels)){const p=c.children[0],y=Dt(c),b=p.getElementsByTagName("img");if(b){const A=l.replace(/0&&(i.style.minWidth=nt(a)),i},kF=function(e,r,n,i,a){var s,o=e.height+e.depth+n+i;if(/fbox|color|angl/.test(r)){if(s=z.makeSpan(["stretchy",r],[],a),r==="fbox"){var l=a.color&&a.getColor();l&&(s.style.borderColor=l)}}else{var u=[];/^[bx]cancel$/.test(r)&&u.push(new Nu({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(r)&&u.push(new Nu({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var c=new Bn(u,{width:"100%",height:nt(o)});s=z.makeSvgSpan([],[c],a)}return s.height=o,s.style.height=nt(o),s},Mn={encloseSpan:kF,mathMLnode:xF,svgSpan:CF};function Bt(t,e){if(!t||t.type!==e)throw new Error("Expected node of type "+e+", but got "+(t?"node of type "+t.type:String(t)));return t}function Yu(t){var e=vo(t);if(!e)throw new Error("Expected node of symbol group type, but got "+(t?"node of type "+t.type:String(t)));return e}function vo(t){return t&&(t.type==="atom"||YE.hasOwnProperty(t.type))?t:null}var Xu=(t,e)=>{var r,n,i;t&&t.type==="supsub"?(n=Bt(t.base,"accent"),r=n.base,t.base=r,i=GE($t(t,e)),t.base=n):(n=Bt(t,"accent"),r=n.base);var a=$t(r,e.havingCrampedStyle()),s=n.isShifty&&Ct.isCharacterBox(r),o=0;if(s){var l=Ct.getBaseElem(r),u=$t(l,e.havingCrampedStyle());o=yp(u).skew}var c=n.label==="\\c",h=c?a.height+a.depth:Math.min(a.height,e.fontMetrics().xHeight),f;if(n.isStretchy)f=Mn.svgSpan(n,e),f=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:a},{type:"elem",elem:f,wrapperClasses:["svg-align"],wrapperStyle:o>0?{width:"calc(100% - "+nt(2*o)+")",marginLeft:nt(2*o)}:void 0}]},e);else{var p,y;n.label==="\\vec"?(p=z.staticSvg("vec",e),y=z.svgData.vec[1]):(p=z.makeOrd({mode:n.mode,text:n.label},e,"textord"),p=yp(p),p.italic=0,y=p.width,c&&(h+=p.depth)),f=z.makeSpan(["accent-body"],[p]);var b=n.label==="\\textcircled";b&&(f.classes.push("accent-full"),h=a.height);var A=o;b||(A-=y/2),f.style.left=nt(A),n.label==="\\textcircled"&&(f.style.top=".2em"),f=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:a},{type:"kern",size:-h},{type:"elem",elem:f}]},e)}var _=z.makeSpan(["mord","accent"],[f],e);return i?(i.children[0]=_,i.height=Math.max(_.height,i.height),i.classes[0]="mord",i):_},zp=(t,e)=>{var r=t.isStretchy?Mn.mathMLnode(t.label):new Z.MathNode("mo",[Ar(t.label,t.mode)]),n=new Z.MathNode("mover",[Qt(t.base,e),r]);return n.setAttribute("accent","true"),n},_F=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(t=>"\\"+t).join("|"));ot({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"],props:{numArgs:1},handler:(t,e)=>{var r=bo(e[0]),n=!_F.test(t.funcName),i=!n||t.funcName==="\\widehat"||t.funcName==="\\widetilde"||t.funcName==="\\widecheck";return{type:"accent",mode:t.parser.mode,label:t.funcName,isStretchy:n,isShifty:i,base:r}},htmlBuilder:Xu,mathmlBuilder:zp}),ot({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],props:{numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"]},handler:(t,e)=>{var r=e[0],n=t.parser.mode;return n==="math"&&(t.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+t.funcName+" works only in text mode"),n="text"),{type:"accent",mode:n,label:t.funcName,isStretchy:!1,isShifty:!0,base:r}},htmlBuilder:Xu,mathmlBuilder:zp}),ot({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],props:{numArgs:1},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=e[0];return{type:"accentUnder",mode:r.mode,label:n,base:i}},htmlBuilder:(t,e)=>{var r=$t(t.base,e),n=Mn.svgSpan(t,e),i=t.label==="\\utilde"?.12:0,a=z.makeVList({positionType:"top",positionData:r.height,children:[{type:"elem",elem:n,wrapperClasses:["svg-align"]},{type:"kern",size:i},{type:"elem",elem:r}]},e);return z.makeSpan(["mord","accentunder"],[a],e)},mathmlBuilder:(t,e)=>{var r=Mn.mathMLnode(t.label),n=new Z.MathNode("munder",[Qt(t.base,e),r]);return n.setAttribute("accentunder","true"),n}});var wo=t=>{var e=new Z.MathNode("mpadded",t?[t]:[]);return e.setAttribute("width","+0.6em"),e.setAttribute("lspace","0.3em"),e};ot({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"],props:{numArgs:1,numOptionalArgs:1},handler(t,e,r){var{parser:n,funcName:i}=t;return{type:"xArrow",mode:n.mode,label:i,body:e[0],below:r[0]}},htmlBuilder(t,e){var r=e.style,n=e.havingStyle(r.sup()),i=z.wrapFragment($t(t.body,n,e),e),a=t.label.slice(0,2)==="\\x"?"x":"cd";i.classes.push(a+"-arrow-pad");var s;t.below&&(n=e.havingStyle(r.sub()),s=z.wrapFragment($t(t.below,n,e),e),s.classes.push(a+"-arrow-pad"));var o=Mn.svgSpan(t,e),l=-e.fontMetrics().axisHeight+.5*o.height,u=-e.fontMetrics().axisHeight-.5*o.height-.111;(i.depth>.25||t.label==="\\xleftequilibrium")&&(u-=i.depth);var c;if(s){var h=-e.fontMetrics().axisHeight+s.height+.5*o.height+.111;c=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:i,shift:u},{type:"elem",elem:o,shift:l},{type:"elem",elem:s,shift:h}]},e)}else c=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:i,shift:u},{type:"elem",elem:o,shift:l}]},e);return c.children[0].children[0].children[1].classes.push("svg-align"),z.makeSpan(["mrel","x-arrow"],[c],e)},mathmlBuilder(t,e){var r=Mn.mathMLnode(t.label);r.setAttribute("minsize",t.label.charAt(0)==="x"?"1.75em":"3.0em");var n;if(t.body){var i=wo(Qt(t.body,e));if(t.below){var a=wo(Qt(t.below,e));n=new Z.MathNode("munderover",[r,a,i])}else n=new Z.MathNode("mover",[r,i])}else if(t.below){var s=wo(Qt(t.below,e));n=new Z.MathNode("munder",[r,s])}else n=wo(),n=new Z.MathNode("mover",[r,n]);return n}});var SF=z.makeSpan;function Op(t,e){var r=Se(t.body,e,!0);return SF([t.mclass],r,e)}function Np(t,e){var r,n=nr(t.body,e);return t.mclass==="minner"?r=new Z.MathNode("mpadded",n):t.mclass==="mord"?t.isCharacterBox?(r=n[0],r.type="mi"):r=new Z.MathNode("mi",n):(t.isCharacterBox?(r=n[0],r.type="mo"):r=new Z.MathNode("mo",n),t.mclass==="mbin"?(r.attributes.lspace="0.22em",r.attributes.rspace="0.22em"):t.mclass==="mpunct"?(r.attributes.lspace="0em",r.attributes.rspace="0.17em"):t.mclass==="mopen"||t.mclass==="mclose"?(r.attributes.lspace="0em",r.attributes.rspace="0em"):t.mclass==="minner"&&(r.attributes.lspace="0.0556em",r.attributes.width="+0.1111em")),r}ot({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],props:{numArgs:1,primitive:!0},handler(t,e){var{parser:r,funcName:n}=t,i=e[0];return{type:"mclass",mode:r.mode,mclass:"m"+n.slice(5),body:ge(i),isCharacterBox:Ct.isCharacterBox(i)}},htmlBuilder:Op,mathmlBuilder:Np});var Co=t=>{var e=t.type==="ordgroup"&&t.body.length?t.body[0]:t;return e.type==="atom"&&(e.family==="bin"||e.family==="rel")?"m"+e.family:"mord"};ot({type:"mclass",names:["\\@binrel"],props:{numArgs:2},handler(t,e){var{parser:r}=t;return{type:"mclass",mode:r.mode,mclass:Co(e[0]),body:ge(e[1]),isCharacterBox:Ct.isCharacterBox(e[1])}}}),ot({type:"mclass",names:["\\stackrel","\\overset","\\underset"],props:{numArgs:2},handler(t,e){var{parser:r,funcName:n}=t,i=e[1],a=e[0],s;n!=="\\stackrel"?s=Co(i):s="mrel";var o={type:"op",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:n!=="\\stackrel",body:ge(i)},l={type:"supsub",mode:a.mode,base:o,sup:n==="\\underset"?null:a,sub:n==="\\underset"?a:null};return{type:"mclass",mode:r.mode,mclass:s,body:[l],isCharacterBox:Ct.isCharacterBox(l)}},htmlBuilder:Op,mathmlBuilder:Np}),ot({type:"pmb",names:["\\pmb"],props:{numArgs:1,allowedInText:!0},handler(t,e){var{parser:r}=t;return{type:"pmb",mode:r.mode,mclass:Co(e[0]),body:ge(e[0])}},htmlBuilder(t,e){var r=Se(t.body,e,!0),n=z.makeSpan([t.mclass],r,e);return n.style.textShadow="0.02em 0.01em 0.04px",n},mathmlBuilder(t,e){var r=nr(t.body,e),n=new Z.MathNode("mstyle",r);return n.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),n}});var TF={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Rp=()=>({type:"styling",body:[],mode:"math",style:"display"}),Pp=t=>t.type==="textord"&&t.text==="@",AF=(t,e)=>(t.type==="mathord"||t.type==="atom")&&t.text===e;function BF(t,e,r){var n=TF[t];switch(n){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(n,[e[0]],[e[1]]);case"\\uparrow":case"\\downarrow":{var i=r.callFunction("\\\\cdleft",[e[0]],[]),a={type:"atom",text:n,mode:"math",family:"rel"},s=r.callFunction("\\Big",[a],[]),o=r.callFunction("\\\\cdright",[e[1]],[]),l={type:"ordgroup",mode:"math",body:[i,s,o]};return r.callFunction("\\\\cdparent",[l],[])}case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":{var u={type:"textord",text:"\\Vert",mode:"math"};return r.callFunction("\\Big",[u],[])}default:return{type:"textord",text:" ",mode:"math"}}}function EF(t){var e=[];for(t.gullet.beginGroup(),t.gullet.macros.set("\\cr","\\\\\\relax"),t.gullet.beginGroup();;){e.push(t.parseExpression(!1,"\\\\")),t.gullet.endGroup(),t.gullet.beginGroup();var r=t.fetch().text;if(r==="&"||r==="\\\\")t.consume();else if(r==="\\end"){e[e.length-1].length===0&&e.pop();break}else throw new tt("Expected \\\\ or \\cr or \\end",t.nextToken)}for(var n=[],i=[n],a=0;a-1))if("<>AV".indexOf(u)>-1)for(var h=0;h<2;h++){for(var f=!0,p=l+1;p AV=|." after @',s[l]);var y=BF(u,c,t),b={type:"styling",body:[y],mode:"math",style:"display"};n.push(b),o=Rp()}a%2===0?n.push(o):n.shift(),n=[],i.push(n)}t.gullet.endGroup(),t.gullet.endGroup();var A=new Array(i[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25});return{type:"array",mode:"math",body:i,arraystretch:1,addJot:!0,rowGaps:[null],cols:A,colSeparationType:"CD",hLinesBeforeRow:new Array(i.length+1).fill([])}}ot({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],props:{numArgs:1},handler(t,e){var{parser:r,funcName:n}=t;return{type:"cdlabel",mode:r.mode,side:n.slice(4),label:e[0]}},htmlBuilder(t,e){var r=e.havingStyle(e.style.sup()),n=z.wrapFragment($t(t.label,r,e),e);return n.classes.push("cd-label-"+t.side),n.style.bottom=nt(.8-n.depth),n.height=0,n.depth=0,n},mathmlBuilder(t,e){var r=new Z.MathNode("mrow",[Qt(t.label,e)]);return r=new Z.MathNode("mpadded",[r]),r.setAttribute("width","0"),t.side==="left"&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),r=new Z.MathNode("mstyle",[r]),r.setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),ot({type:"cdlabelparent",names:["\\\\cdparent"],props:{numArgs:1},handler(t,e){var{parser:r}=t;return{type:"cdlabelparent",mode:r.mode,fragment:e[0]}},htmlBuilder(t,e){var r=z.wrapFragment($t(t.fragment,e),e);return r.classes.push("cd-vert-arrow"),r},mathmlBuilder(t,e){return new Z.MathNode("mrow",[Qt(t.fragment,e)])}}),ot({type:"textord",names:["\\@char"],props:{numArgs:1,allowedInText:!0},handler(t,e){for(var{parser:r}=t,n=Bt(e[0],"ordgroup"),i=n.body,a="",s=0;s =1114111)throw new tt("\\@char with invalid code point "+a);return l<=65535?u=String.fromCharCode(l):(l-=65536,u=String.fromCharCode((l>>10)+55296,(l&1023)+56320)),{type:"textord",mode:r.mode,text:u}}});var qp=(t,e)=>{var r=Se(t.body,e.withColor(t.color),!1);return z.makeFragment(r)},$p=(t,e)=>{var r=nr(t.body,e.withColor(t.color)),n=new Z.MathNode("mstyle",r);return n.setAttribute("mathcolor",t.color),n};ot({type:"color",names:["\\textcolor"],props:{numArgs:2,allowedInText:!0,argTypes:["color","original"]},handler(t,e){var{parser:r}=t,n=Bt(e[0],"color-token").color,i=e[1];return{type:"color",mode:r.mode,color:n,body:ge(i)}},htmlBuilder:qp,mathmlBuilder:$p}),ot({type:"color",names:["\\color"],props:{numArgs:1,allowedInText:!0,argTypes:["color"]},handler(t,e){var{parser:r,breakOnTokenText:n}=t,i=Bt(e[0],"color-token").color;r.gullet.macros.set("\\current@color",i);var a=r.parseExpression(!0,n);return{type:"color",mode:r.mode,color:i,body:a}},htmlBuilder:qp,mathmlBuilder:$p}),ot({type:"cr",names:["\\\\"],props:{numArgs:0,numOptionalArgs:0,allowedInText:!0},handler(t,e,r){var{parser:n}=t,i=n.gullet.future().text==="["?n.parseSizeGroup(!0):null,a=!n.settings.displayMode||!n.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:n.mode,newLine:a,size:i&&Bt(i,"size").value}},htmlBuilder(t,e){var r=z.makeSpan(["mspace"],[],e);return t.newLine&&(r.classes.push("newline"),t.size&&(r.style.marginTop=nt(ce(t.size,e)))),r},mathmlBuilder(t,e){var r=new Z.MathNode("mspace");return t.newLine&&(r.setAttribute("linebreak","newline"),t.size&&r.setAttribute("height",nt(ce(t.size,e)))),r}});var Ku={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},Hp=t=>{var e=t.text;if(/^(?:[\\{}$^_]|EOF)$/.test(e))throw new tt("Expected a control sequence",t);return e},FF=t=>{var e=t.gullet.popToken();return e.text==="="&&(e=t.gullet.popToken(),e.text===" "&&(e=t.gullet.popToken())),e},Vp=(t,e,r,n)=>{var i=t.gullet.macros.get(r.text);i==null&&(r.noexpand=!0,i={tokens:[r],numArgs:0,unexpandable:!t.gullet.isExpandable(r.text)}),t.gullet.macros.set(e,i,n)};ot({type:"internal",names:["\\global","\\long","\\\\globallong"],props:{numArgs:0,allowedInText:!0},handler(t){var{parser:e,funcName:r}=t;e.consumeSpaces();var n=e.fetch();if(Ku[n.text])return(r==="\\global"||r==="\\\\globallong")&&(n.text=Ku[n.text]),Bt(e.parseFunction(),"internal");throw new tt("Invalid token after macro prefix",n)}}),ot({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(t){var{parser:e,funcName:r}=t,n=e.gullet.popToken(),i=n.text;if(/^(?:[\\{}$^_]|EOF)$/.test(i))throw new tt("Expected a control sequence",n);for(var a=0,s,o=[[]];e.gullet.future().text!=="{";)if(n=e.gullet.popToken(),n.text==="#"){if(e.gullet.future().text==="{"){s=e.gullet.future(),o[a].push("{");break}if(n=e.gullet.popToken(),!/^[1-9]$/.test(n.text))throw new tt('Invalid argument number "'+n.text+'"');if(parseInt(n.text)!==a+1)throw new tt('Argument number "'+n.text+'" out of order');a++,o.push([])}else{if(n.text==="EOF")throw new tt("Expected a macro definition");o[a].push(n.text)}var{tokens:l}=e.gullet.consumeArg();return s&&l.unshift(s),(r==="\\edef"||r==="\\xdef")&&(l=e.gullet.expandTokens(l),l.reverse()),e.gullet.macros.set(i,{tokens:l,numArgs:a,delimiters:o},r===Ku[r]),{type:"internal",mode:e.mode}}}),ot({type:"internal",names:["\\let","\\\\globallet"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(t){var{parser:e,funcName:r}=t,n=Hp(e.gullet.popToken());e.gullet.consumeSpaces();var i=FF(e);return Vp(e,n,i,r==="\\\\globallet"),{type:"internal",mode:e.mode}}}),ot({type:"internal",names:["\\futurelet","\\\\globalfuture"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(t){var{parser:e,funcName:r}=t,n=Hp(e.gullet.popToken()),i=e.gullet.popToken(),a=e.gullet.popToken();return Vp(e,n,a,r==="\\\\globalfuture"),e.gullet.pushToken(a),e.gullet.pushToken(i),{type:"internal",mode:e.mode}}});var fs=function(e,r,n){var i=re.math[e]&&re.math[e].replace,a=Du(i||e,r,n);if(!a)throw new Error("Unsupported symbol "+e+" and font size "+r+".");return a},Zu=function(e,r,n,i){var a=n.havingBaseStyle(r),s=z.makeSpan(i.concat(a.sizingClasses(n)),[e],n),o=a.sizeMultiplier/n.sizeMultiplier;return s.height*=o,s.depth*=o,s.maxFontSize=a.sizeMultiplier,s},Wp=function(e,r,n){var i=r.havingBaseStyle(n),a=(1-r.sizeMultiplier/i.sizeMultiplier)*r.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=nt(a),e.height-=a,e.depth+=a},LF=function(e,r,n,i,a,s){var o=z.makeSymbol(e,"Main-Regular",a,i),l=Zu(o,r,i,s);return n&&Wp(l,i,r),l},MF=function(e,r,n,i){return z.makeSymbol(e,"Size"+r+"-Regular",n,i)},Up=function(e,r,n,i,a,s){var o=MF(e,r,a,i),l=Zu(z.makeSpan(["delimsizing","size"+r],[o],i),xt.TEXT,i,s);return n&&Wp(l,i,xt.TEXT),l},Qu=function(e,r,n){var i;r==="Size1-Regular"?i="delim-size1":i="delim-size4";var a=z.makeSpan(["delimsizinginner",i],[z.makeSpan([],[z.makeSymbol(e,r,n)])]);return{type:"elem",elem:a}},Ju=function(e,r,n){var i=ln["Size4-Regular"][e.charCodeAt(0)]?ln["Size4-Regular"][e.charCodeAt(0)][4]:ln["Size1-Regular"][e.charCodeAt(0)][4],a=new Zn("inner",RE(e,Math.round(1e3*r))),s=new Bn([a],{width:nt(i),height:nt(r),style:"width:"+nt(i),viewBox:"0 0 "+1e3*i+" "+Math.round(1e3*r),preserveAspectRatio:"xMinYMin"}),o=z.makeSvgSpan([],[s],n);return o.height=r,o.style.height=nt(r),o.style.width=nt(i),{type:"elem",elem:o}},tc=.008,ko={type:"kern",size:-1*tc},DF=["|","\\lvert","\\rvert","\\vert"],IF=["\\|","\\lVert","\\rVert","\\Vert"],Gp=function(e,r,n,i,a,s){var o,l,u,c,h="",f=0;o=u=c=e,l=null;var p="Size1-Regular";e==="\\uparrow"?u=c="⏐":e==="\\Uparrow"?u=c="‖":e==="\\downarrow"?o=u="⏐":e==="\\Downarrow"?o=u="‖":e==="\\updownarrow"?(o="\\uparrow",u="⏐",c="\\downarrow"):e==="\\Updownarrow"?(o="\\Uparrow",u="‖",c="\\Downarrow"):Ct.contains(DF,e)?(u="∣",h="vert",f=333):Ct.contains(IF,e)?(u="∥",h="doublevert",f=556):e==="["||e==="\\lbrack"?(o="⎡",u="⎢",c="⎣",p="Size4-Regular",h="lbrack",f=667):e==="]"||e==="\\rbrack"?(o="⎤",u="⎥",c="⎦",p="Size4-Regular",h="rbrack",f=667):e==="\\lfloor"||e==="⌊"?(u=o="⎢",c="⎣",p="Size4-Regular",h="lfloor",f=667):e==="\\lceil"||e==="⌈"?(o="⎡",u=c="⎢",p="Size4-Regular",h="lceil",f=667):e==="\\rfloor"||e==="⌋"?(u=o="⎥",c="⎦",p="Size4-Regular",h="rfloor",f=667):e==="\\rceil"||e==="⌉"?(o="⎤",u=c="⎥",p="Size4-Regular",h="rceil",f=667):e==="("||e==="\\lparen"?(o="⎛",u="⎜",c="⎝",p="Size4-Regular",h="lparen",f=875):e===")"||e==="\\rparen"?(o="⎞",u="⎟",c="⎠",p="Size4-Regular",h="rparen",f=875):e==="\\{"||e==="\\lbrace"?(o="⎧",l="⎨",c="⎩",u="⎪",p="Size4-Regular"):e==="\\}"||e==="\\rbrace"?(o="⎫",l="⎬",c="⎭",u="⎪",p="Size4-Regular"):e==="\\lgroup"||e==="⟮"?(o="⎧",c="⎩",u="⎪",p="Size4-Regular"):e==="\\rgroup"||e==="⟯"?(o="⎫",c="⎭",u="⎪",p="Size4-Regular"):e==="\\lmoustache"||e==="⎰"?(o="⎧",c="⎭",u="⎪",p="Size4-Regular"):(e==="\\rmoustache"||e==="⎱")&&(o="⎫",c="⎩",u="⎪",p="Size4-Regular");var y=fs(o,p,a),b=y.height+y.depth,A=fs(u,p,a),_=A.height+A.depth,M=fs(c,p,a),I=M.height+M.depth,V=0,N=1;if(l!==null){var L=fs(l,p,a);V=L.height+L.depth,N=2}var q=b+I+V,G=Math.max(0,Math.ceil((r-q)/(N*_))),Y=q+G*N*_,J=i.fontMetrics().axisHeight;n&&(J*=i.sizeMultiplier);var O=Y/2-J,P=[];if(h.length>0){var ft=Y-b-I,X=Math.round(Y*1e3),$=PE(h,Math.round(ft*1e3)),U=new Zn(h,$),et=(f/1e3).toFixed(3)+"em",K=(X/1e3).toFixed(3)+"em",W=new Bn([U],{width:et,height:K,viewBox:"0 0 "+f+" "+X}),v=z.makeSvgSpan([],[W],i);v.height=X/1e3,v.style.width=et,v.style.height=K,P.push({type:"elem",elem:v})}else{if(P.push(Qu(c,p,a)),P.push(ko),l===null){var st=Y-b-I+2*tc;P.push(Ju(u,st,i))}else{var dt=(Y-b-I-V)/2+2*tc;P.push(Ju(u,dt,i)),P.push(ko),P.push(Qu(l,p,a)),P.push(ko),P.push(Ju(u,dt,i))}P.push(ko),P.push(Qu(o,p,a))}var w=i.havingBaseStyle(xt.TEXT),St=z.makeVList({positionType:"bottom",positionData:O,children:P},w);return Zu(z.makeSpan(["delimsizing","mult"],[St],w),xt.TEXT,i,s)},ec=80,rc=.08,nc=function(e,r,n,i,a){var s=NE(e,i,n),o=new Zn(e,s),l=new Bn([o],{width:"400em",height:nt(r),viewBox:"0 0 400000 "+n,preserveAspectRatio:"xMinYMin slice"});return z.makeSvgSpan(["hide-tail"],[l],a)},zF=function(e,r){var n=r.havingBaseSizing(),i=Kp("\\surd",e*n.sizeMultiplier,Xp,n),a=n.sizeMultiplier,s=Math.max(0,r.minRuleThickness-r.fontMetrics().sqrtRuleThickness),o,l=0,u=0,c=0,h;return i.type==="small"?(c=1e3+1e3*s+ec,e<1?a=1:e<1.4&&(a=.7),l=(1+s+rc)/a,u=(1+s)/a,o=nc("sqrtMain",l,c,s,r),o.style.minWidth="0.853em",h=.833/a):i.type==="large"?(c=(1e3+ec)*ds[i.size],u=(ds[i.size]+s)/a,l=(ds[i.size]+s+rc)/a,o=nc("sqrtSize"+i.size,l,c,s,r),o.style.minWidth="1.02em",h=1/a):(l=e+s+rc,u=e+s,c=Math.floor(1e3*e+s)+ec,o=nc("sqrtTall",l,c,s,r),o.style.minWidth="0.742em",h=1.056),o.height=u,o.style.height=nt(l),{span:o,advanceWidth:h,ruleWidth:(r.fontMetrics().sqrtRuleThickness+s)*a}},jp=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","\\surd"],OF=["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱"],Yp=["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"],ds=[0,1.2,1.8,2.4,3],NF=function(e,r,n,i,a){if(e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle"),Ct.contains(jp,e)||Ct.contains(Yp,e))return Up(e,r,!1,n,i,a);if(Ct.contains(OF,e))return Gp(e,ds[r],!1,n,i,a);throw new tt("Illegal delimiter: '"+e+"'")},RF=[{type:"small",style:xt.SCRIPTSCRIPT},{type:"small",style:xt.SCRIPT},{type:"small",style:xt.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],PF=[{type:"small",style:xt.SCRIPTSCRIPT},{type:"small",style:xt.SCRIPT},{type:"small",style:xt.TEXT},{type:"stack"}],Xp=[{type:"small",style:xt.SCRIPTSCRIPT},{type:"small",style:xt.SCRIPT},{type:"small",style:xt.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],qF=function(e){if(e.type==="small")return"Main-Regular";if(e.type==="large")return"Size"+e.size+"-Regular";if(e.type==="stack")return"Size4-Regular";throw new Error("Add support for delim type '"+e.type+"' here.")},Kp=function(e,r,n,i){for(var a=Math.min(2,3-i.style.size),s=a;s r)return n[s]}return n[n.length-1]},Zp=function(e,r,n,i,a,s){e==="<"||e==="\\lt"||e==="⟨"?e="\\langle":(e===">"||e==="\\gt"||e==="⟩")&&(e="\\rangle");var o;Ct.contains(Yp,e)?o=RF:Ct.contains(jp,e)?o=Xp:o=PF;var l=Kp(e,r,o,i);return l.type==="small"?LF(e,l.style,n,i,a,s):l.type==="large"?Up(e,l.size,n,i,a,s):Gp(e,r,n,i,a,s)},$F=function(e,r,n,i,a,s){var o=i.fontMetrics().axisHeight*i.sizeMultiplier,l=901,u=5/i.fontMetrics().ptPerEm,c=Math.max(r-o,n+o),h=Math.max(c/500*l,2*c-u);return Zp(e,h,!0,i,a,s)},Dn={sqrtImage:zF,sizedDelim:NF,sizeToMaxHeight:ds,customSizedDelim:Zp,leftRightDelim:$F},Qp={"\\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}},HF=["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","⌊","⌋","\\lceil","\\rceil","⌈","⌉","<",">","\\langle","⟨","\\rangle","⟩","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","⟮","⟯","\\lmoustache","\\rmoustache","⎰","⎱","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."];function _o(t,e){var r=vo(t);if(r&&Ct.contains(HF,r.text))return r;throw r?new tt("Invalid delimiter '"+r.text+"' after '"+e.funcName+"'",t):new tt("Invalid delimiter type '"+t.type+"'",t)}ot({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],props:{numArgs:1,argTypes:["primitive"]},handler:(t,e)=>{var r=_o(e[0],t);return{type:"delimsizing",mode:t.parser.mode,size:Qp[t.funcName].size,mclass:Qp[t.funcName].mclass,delim:r.text}},htmlBuilder:(t,e)=>t.delim==="."?z.makeSpan([t.mclass]):Dn.sizedDelim(t.delim,t.size,e,t.mode,[t.mclass]),mathmlBuilder:t=>{var e=[];t.delim!=="."&&e.push(Ar(t.delim,t.mode));var r=new Z.MathNode("mo",e);t.mclass==="mopen"||t.mclass==="mclose"?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r.setAttribute("stretchy","true");var n=nt(Dn.sizeToMaxHeight[t.size]);return r.setAttribute("minsize",n),r.setAttribute("maxsize",n),r}});function Jp(t){if(!t.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}ot({type:"leftright-right",names:["\\right"],props:{numArgs:1,primitive:!0},handler:(t,e)=>{var r=t.parser.gullet.macros.get("\\current@color");if(r&&typeof r!="string")throw new tt("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:t.parser.mode,delim:_o(e[0],t).text,color:r}}}),ot({type:"leftright",names:["\\left"],props:{numArgs:1,primitive:!0},handler:(t,e)=>{var r=_o(e[0],t),n=t.parser;++n.leftrightDepth;var i=n.parseExpression(!1);--n.leftrightDepth,n.expect("\\right",!1);var a=Bt(n.parseFunction(),"leftright-right");return{type:"leftright",mode:n.mode,body:i,left:r.text,right:a.delim,rightColor:a.color}},htmlBuilder:(t,e)=>{Jp(t);for(var r=Se(t.body,e,!0,["mopen","mclose"]),n=0,i=0,a=!1,s=0;s {Jp(t);var r=nr(t.body,e);if(t.left!=="."){var n=new Z.MathNode("mo",[Ar(t.left,t.mode)]);n.setAttribute("fence","true"),r.unshift(n)}if(t.right!=="."){var i=new Z.MathNode("mo",[Ar(t.right,t.mode)]);i.setAttribute("fence","true"),t.rightColor&&i.setAttribute("mathcolor",t.rightColor),r.push(i)}return Gu(r)}}),ot({type:"middle",names:["\\middle"],props:{numArgs:1,primitive:!0},handler:(t,e)=>{var r=_o(e[0],t);if(!t.parser.leftrightDepth)throw new tt("\\middle without preceding \\left",r);return{type:"middle",mode:t.parser.mode,delim:r.text}},htmlBuilder:(t,e)=>{var r;if(t.delim===".")r=cs(e,[]);else{r=Dn.sizedDelim(t.delim,1,e,t.mode,[]);var n={delim:t.delim,options:e};r.isMiddle=n}return r},mathmlBuilder:(t,e)=>{var r=t.delim==="\\vert"||t.delim==="|"?Ar("|","text"):Ar(t.delim,t.mode),n=new Z.MathNode("mo",[r]);return n.setAttribute("fence","true"),n.setAttribute("lspace","0.05em"),n.setAttribute("rspace","0.05em"),n}});var ic=(t,e)=>{var r=z.wrapFragment($t(t.body,e),e),n=t.label.slice(1),i=e.sizeMultiplier,a,s=0,o=Ct.isCharacterBox(t.body);if(n==="sout")a=z.makeSpan(["stretchy","sout"]),a.height=e.fontMetrics().defaultRuleThickness/i,s=-.5*e.fontMetrics().xHeight;else if(n==="phase"){var l=ce({number:.6,unit:"pt"},e),u=ce({number:.35,unit:"ex"},e),c=e.havingBaseSizing();i=i/c.sizeMultiplier;var h=r.height+r.depth+l+u;r.style.paddingLeft=nt(h/2+l);var f=Math.floor(1e3*h*i),p=zE(f),y=new Bn([new Zn("phase",p)],{width:"400em",height:nt(f/1e3),viewBox:"0 0 400000 "+f,preserveAspectRatio:"xMinYMin slice"});a=z.makeSvgSpan(["hide-tail"],[y],e),a.style.height=nt(h),s=r.depth+l+u}else{/cancel/.test(n)?o||r.classes.push("cancel-pad"):n==="angl"?r.classes.push("anglpad"):r.classes.push("boxpad");var b=0,A=0,_=0;/box/.test(n)?(_=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness),b=e.fontMetrics().fboxsep+(n==="colorbox"?0:_),A=b):n==="angl"?(_=Math.max(e.fontMetrics().defaultRuleThickness,e.minRuleThickness),b=4*_,A=Math.max(0,.25-r.depth)):(b=o?.2:0,A=b),a=Mn.encloseSpan(r,n,b,A,e),/fbox|boxed|fcolorbox/.test(n)?(a.style.borderStyle="solid",a.style.borderWidth=nt(_)):n==="angl"&&_!==.049&&(a.style.borderTopWidth=nt(_),a.style.borderRightWidth=nt(_)),s=r.depth+A,t.backgroundColor&&(a.style.backgroundColor=t.backgroundColor,t.borderColor&&(a.style.borderColor=t.borderColor))}var M;if(t.backgroundColor)M=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:a,shift:s},{type:"elem",elem:r,shift:0}]},e);else{var I=/cancel|phase/.test(n)?["svg-align"]:[];M=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:r,shift:0},{type:"elem",elem:a,shift:s,wrapperClasses:I}]},e)}return/cancel/.test(n)&&(M.height=r.height,M.depth=r.depth),/cancel/.test(n)&&!o?z.makeSpan(["mord","cancel-lap"],[M],e):z.makeSpan(["mord"],[M],e)},ac=(t,e)=>{var r=0,n=new Z.MathNode(t.label.indexOf("colorbox")>-1?"mpadded":"menclose",[Qt(t.body,e)]);switch(t.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=e.fontMetrics().fboxsep*e.fontMetrics().ptPerEm,n.setAttribute("width","+"+2*r+"pt"),n.setAttribute("height","+"+2*r+"pt"),n.setAttribute("lspace",r+"pt"),n.setAttribute("voffset",r+"pt"),t.label==="\\fcolorbox"){var i=Math.max(e.fontMetrics().fboxrule,e.minRuleThickness);n.setAttribute("style","border: "+i+"em solid "+String(t.borderColor))}break;case"\\xcancel":n.setAttribute("notation","updiagonalstrike downdiagonalstrike");break}return t.backgroundColor&&n.setAttribute("mathbackground",t.backgroundColor),n};ot({type:"enclose",names:["\\colorbox"],props:{numArgs:2,allowedInText:!0,argTypes:["color","text"]},handler(t,e,r){var{parser:n,funcName:i}=t,a=Bt(e[0],"color-token").color,s=e[1];return{type:"enclose",mode:n.mode,label:i,backgroundColor:a,body:s}},htmlBuilder:ic,mathmlBuilder:ac}),ot({type:"enclose",names:["\\fcolorbox"],props:{numArgs:3,allowedInText:!0,argTypes:["color","color","text"]},handler(t,e,r){var{parser:n,funcName:i}=t,a=Bt(e[0],"color-token").color,s=Bt(e[1],"color-token").color,o=e[2];return{type:"enclose",mode:n.mode,label:i,backgroundColor:s,borderColor:a,body:o}},htmlBuilder:ic,mathmlBuilder:ac}),ot({type:"enclose",names:["\\fbox"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!0},handler(t,e){var{parser:r}=t;return{type:"enclose",mode:r.mode,label:"\\fbox",body:e[0]}}}),ot({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\sout","\\phase"],props:{numArgs:1},handler(t,e){var{parser:r,funcName:n}=t,i=e[0];return{type:"enclose",mode:r.mode,label:n,body:i}},htmlBuilder:ic,mathmlBuilder:ac}),ot({type:"enclose",names:["\\angl"],props:{numArgs:1,argTypes:["hbox"],allowedInText:!1},handler(t,e){var{parser:r}=t;return{type:"enclose",mode:r.mode,label:"\\angl",body:e[0]}}});var tm={};function un(t){for(var{type:e,names:r,props:n,handler:i,htmlBuilder:a,mathmlBuilder:s}=t,o={type:e,numArgs:n.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:i},l=0;l {var e=t.parser.settings;if(!e.displayMode)throw new tt("{"+t.envName+"} can be used only in display mode.")};function sc(t){if(t.indexOf("ed")===-1)return t.indexOf("*")===-1}function ti(t,e,r){var{hskipBeforeAndAfter:n,addJot:i,cols:a,arraystretch:s,colSeparationType:o,autoTag:l,singleRow:u,emptySingleRow:c,maxNumCols:h,leqno:f}=e;if(t.gullet.beginGroup(),u||t.gullet.macros.set("\\cr","\\\\\\relax"),!s){var p=t.gullet.expandMacroAsText("\\arraystretch");if(p==null)s=1;else if(s=parseFloat(p),!s||s<0)throw new tt("Invalid \\arraystretch: "+p)}t.gullet.beginGroup();var y=[],b=[y],A=[],_=[],M=l!=null?[]:void 0;function I(){l&&t.gullet.macros.set("\\@eqnsw","1",!0)}function V(){M&&(t.gullet.macros.get("\\df@tag")?(M.push(t.subparse([new sn("\\df@tag")])),t.gullet.macros.set("\\df@tag",void 0,!0)):M.push(!!l&&t.gullet.macros.get("\\@eqnsw")==="1"))}for(I(),_.push(rm(t));;){var N=t.parseExpression(!1,u?"\\end":"\\\\");t.gullet.endGroup(),t.gullet.beginGroup(),N={type:"ordgroup",mode:t.mode,body:N},r&&(N={type:"styling",mode:t.mode,style:r,body:[N]}),y.push(N);var L=t.fetch().text;if(L==="&"){if(h&&y.length===h){if(u||o)throw new tt("Too many tab characters: &",t.nextToken);t.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}t.consume()}else if(L==="\\end"){V(),y.length===1&&N.type==="styling"&&N.body[0].body.length===0&&(b.length>1||!c)&&b.pop(),_.length 0&&(I+=.25),u.push({pos:I,isDashed:yr[ar]})}for(V(s[0]),n=0;n 0&&(O+=M,q yr))for(n=0;n=o)){var Ht=void 0;(i>0||e.hskipBeforeAndAfter)&&(Ht=Ct.deflt(dt.pregap,f),Ht!==0&&($=z.makeSpan(["arraycolsep"],[]),$.style.width=nt(Ht),X.push($)));var Wt=[];for(n=0;n0){for(var ye=z.makeLineSpan("hline",r,c),Te=z.makeLineSpan("hdashline",r,c),Ae=[{type:"elem",elem:l,shift:0}];u.length>0;){var ir=u.pop(),Kt=ir.pos-P;ir.isDashed?Ae.push({type:"elem",elem:Te,shift:Kt}):Ae.push({type:"elem",elem:ye,shift:Kt})}l=z.makeVList({positionType:"individualShift",children:Ae},r)}if(et.length===0)return z.makeSpan(["mord"],[l],r);var fe=z.makeVList({positionType:"individualShift",children:et},r);return fe=z.makeSpan(["tag"],[fe],r),z.makeFragment([l,fe])},VF={c:"center ",l:"left ",r:"right "},hn=function(e,r){for(var n=[],i=new Z.MathNode("mtd",[],["mtr-glue"]),a=new Z.MathNode("mtd",[],["mml-eqn-num"]),s=0;s 0){var y=e.cols,b="",A=!1,_=0,M=y.length;y[0].type==="separator"&&(f+="top ",_=1),y[y.length-1].type==="separator"&&(f+="bottom ",M-=1);for(var I=_;I 0?"left ":"",f+=G[G.length-1].length>0?"right ":"";for(var Y=1;Y -1?"alignat":"align",a=e.envName==="split",s=ti(e.parser,{cols:n,addJot:!0,autoTag:a?void 0:sc(e.envName),emptySingleRow:!0,colSeparationType:i,maxNumCols:a?2:void 0,leqno:e.parser.settings.leqno},"display"),o,l=0,u={type:"ordgroup",mode:e.mode,body:[]};if(r[0]&&r[0].type==="ordgroup"){for(var c="",h=0;h 0&&p&&(A=1),n[y]={type:"align",align:b,pregap:A,postgap:0}}return s.colSeparationType=p?"align":"alignat",s};un({type:"array",names:["array","darray"],props:{numArgs:1},handler(t,e){var r=vo(e[0]),n=r?[e[0]]:Bt(e[0],"ordgroup").body,i=n.map(function(s){var o=Yu(s),l=o.text;if("lcr".indexOf(l)!==-1)return{type:"align",align:l};if(l==="|")return{type:"separator",separator:"|"};if(l===":")return{type:"separator",separator:":"};throw new tt("Unknown column alignment: "+l,s)}),a={cols:i,hskipBeforeAndAfter:!0,maxNumCols:i.length};return ti(t.parser,a,oc(t.envName))},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(t){var e={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[t.envName.replace("*","")],r="c",n={hskipBeforeAndAfter:!1,cols:[{type:"align",align:r}]};if(t.envName.charAt(t.envName.length-1)==="*"){var i=t.parser;if(i.consumeSpaces(),i.fetch().text==="["){if(i.consume(),i.consumeSpaces(),r=i.fetch().text,"lcr".indexOf(r)===-1)throw new tt("Expected l or c or r",i.nextToken);i.consume(),i.consumeSpaces(),i.expect("]"),i.consume(),n.cols=[{type:"align",align:r}]}}var a=ti(t.parser,n,oc(t.envName)),s=Math.max(0,...a.body.map(o=>o.length));return a.cols=new Array(s).fill({type:"align",align:r}),e?{type:"leftright",mode:t.mode,body:[a],left:e[0],right:e[1],rightColor:void 0}:a},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(t){var e={arraystretch:.5},r=ti(t.parser,e,"script");return r.colSeparationType="small",r},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["subarray"],props:{numArgs:1},handler(t,e){var r=vo(e[0]),n=r?[e[0]]:Bt(e[0],"ordgroup").body,i=n.map(function(s){var o=Yu(s),l=o.text;if("lc".indexOf(l)!==-1)return{type:"align",align:l};throw new tt("Unknown column alignment: "+l,s)});if(i.length>1)throw new tt("{subarray} can contain only one column");var a={cols:i,hskipBeforeAndAfter:!1,arraystretch:.5};if(a=ti(t.parser,a,"script"),a.body.length>0&&a.body[0].length>1)throw new tt("{subarray} can contain only one column");return a},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(t){var e={arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},r=ti(t.parser,e,oc(t.envName));return{type:"leftright",mode:t.mode,body:[r],left:t.envName.indexOf("r")>-1?".":"\\{",right:t.envName.indexOf("r")>-1?"\\}":".",rightColor:void 0}},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:nm,htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(t){Ct.contains(["gather","gather*"],t.envName)&&So(t);var e={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:sc(t.envName),emptySingleRow:!0,leqno:t.parser.settings.leqno};return ti(t.parser,e,"display")},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:nm,htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(t){So(t);var e={autoTag:sc(t.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:t.parser.settings.leqno};return ti(t.parser,e,"display")},htmlBuilder:cn,mathmlBuilder:hn}),un({type:"array",names:["CD"],props:{numArgs:0},handler(t){return So(t),EF(t.parser)},htmlBuilder:cn,mathmlBuilder:hn}),x("\\nonumber","\\gdef\\@eqnsw{0}"),x("\\notag","\\nonumber"),ot({type:"text",names:["\\hline","\\hdashline"],props:{numArgs:0,allowedInText:!0,allowedInMath:!0},handler(t,e){throw new tt(t.funcName+" valid only within array environment")}});var im=tm;ot({type:"environment",names:["\\begin","\\end"],props:{numArgs:1,argTypes:["text"]},handler(t,e){var{parser:r,funcName:n}=t,i=e[0];if(i.type!=="ordgroup")throw new tt("Invalid environment name",i);for(var a="",s=0;s {var r=t.font,n=e.withFont(r);return $t(t.body,n)},sm=(t,e)=>{var r=t.font,n=e.withFont(r);return Qt(t.body,n)},om={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak","\\bm":"\\boldsymbol"};ot({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],props:{numArgs:1,allowedInArgument:!0},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=bo(e[0]),a=n;return a in om&&(a=om[a]),{type:"font",mode:r.mode,font:a.slice(1),body:i}},htmlBuilder:am,mathmlBuilder:sm}),ot({type:"mclass",names:["\\boldsymbol","\\bm"],props:{numArgs:1},handler:(t,e)=>{var{parser:r}=t,n=e[0],i=Ct.isCharacterBox(n);return{type:"mclass",mode:r.mode,mclass:Co(n),body:[{type:"font",mode:r.mode,font:"boldsymbol",body:n}],isCharacterBox:i}}}),ot({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],props:{numArgs:0,allowedInText:!0},handler:(t,e)=>{var{parser:r,funcName:n,breakOnTokenText:i}=t,{mode:a}=r,s=r.parseExpression(!0,i),o="math"+n.slice(1);return{type:"font",mode:a,font:o,body:{type:"ordgroup",mode:r.mode,body:s}}},htmlBuilder:am,mathmlBuilder:sm});var lm=(t,e)=>{var r=e;return t==="display"?r=r.id>=xt.SCRIPT.id?r.text():xt.DISPLAY:t==="text"&&r.size===xt.DISPLAY.size?r=xt.TEXT:t==="script"?r=xt.SCRIPT:t==="scriptscript"&&(r=xt.SCRIPTSCRIPT),r},lc=(t,e)=>{var r=lm(t.size,e.style),n=r.fracNum(),i=r.fracDen(),a;a=e.havingStyle(n);var s=$t(t.numer,a,e);if(t.continued){var o=8.5/e.fontMetrics().ptPerEm,l=3.5/e.fontMetrics().ptPerEm;s.height=s.height 0?y=3*f:y=7*f,b=e.fontMetrics().denom1):(h>0?(p=e.fontMetrics().num2,y=f):(p=e.fontMetrics().num3,y=3*f),b=e.fontMetrics().denom2);var A;if(c){var M=e.fontMetrics().axisHeight;p-s.depth-(M+.5*h) {var r=new Z.MathNode("mfrac",[Qt(t.numer,e),Qt(t.denom,e)]);if(!t.hasBarLine)r.setAttribute("linethickness","0px");else if(t.barSize){var n=ce(t.barSize,e);r.setAttribute("linethickness",nt(n))}var i=lm(t.size,e.style);if(i.size!==e.style.size){r=new Z.MathNode("mstyle",[r]);var a=i.size===xt.DISPLAY.size?"true":"false";r.setAttribute("displaystyle",a),r.setAttribute("scriptlevel","0")}if(t.leftDelim!=null||t.rightDelim!=null){var s=[];if(t.leftDelim!=null){var o=new Z.MathNode("mo",[new Z.TextNode(t.leftDelim.replace("\\",""))]);o.setAttribute("fence","true"),s.push(o)}if(s.push(r),t.rightDelim!=null){var l=new Z.MathNode("mo",[new Z.TextNode(t.rightDelim.replace("\\",""))]);l.setAttribute("fence","true"),s.push(l)}return Gu(s)}return r};ot({type:"genfrac",names:["\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],props:{numArgs:2,allowedInArgument:!0},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=e[0],a=e[1],s,o=null,l=null,u="auto";switch(n){case"\\dfrac":case"\\frac":case"\\tfrac":s=!0;break;case"\\\\atopfrac":s=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":s=!1,o="(",l=")";break;case"\\\\bracefrac":s=!1,o="\\{",l="\\}";break;case"\\\\brackfrac":s=!1,o="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}switch(n){case"\\dfrac":case"\\dbinom":u="display";break;case"\\tfrac":case"\\tbinom":u="text";break}return{type:"genfrac",mode:r.mode,continued:!1,numer:i,denom:a,hasBarLine:s,leftDelim:o,rightDelim:l,size:u,barSize:null}},htmlBuilder:lc,mathmlBuilder:uc}),ot({type:"genfrac",names:["\\cfrac"],props:{numArgs:2},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=e[0],a=e[1];return{type:"genfrac",mode:r.mode,continued:!0,numer:i,denom:a,hasBarLine:!0,leftDelim:null,rightDelim:null,size:"display",barSize:null}}}),ot({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],props:{numArgs:0,infix:!0},handler(t){var{parser:e,funcName:r,token:n}=t,i;switch(r){case"\\over":i="\\frac";break;case"\\choose":i="\\binom";break;case"\\atop":i="\\\\atopfrac";break;case"\\brace":i="\\\\bracefrac";break;case"\\brack":i="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:e.mode,replaceWith:i,token:n}}});var um=["display","text","script","scriptscript"],cm=function(e){var r=null;return e.length>0&&(r=e,r=r==="."?null:r),r};ot({type:"genfrac",names:["\\genfrac"],props:{numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"]},handler(t,e){var{parser:r}=t,n=e[4],i=e[5],a=bo(e[0]),s=a.type==="atom"&&a.family==="open"?cm(a.text):null,o=bo(e[1]),l=o.type==="atom"&&o.family==="close"?cm(o.text):null,u=Bt(e[2],"size"),c,h=null;u.isBlank?c=!0:(h=u.value,c=h.number>0);var f="auto",p=e[3];if(p.type==="ordgroup"){if(p.body.length>0){var y=Bt(p.body[0],"textord");f=um[Number(y.text)]}}else p=Bt(p,"textord"),f=um[Number(p.text)];return{type:"genfrac",mode:r.mode,numer:n,denom:i,continued:!1,hasBarLine:c,barSize:h,leftDelim:s,rightDelim:l,size:f}},htmlBuilder:lc,mathmlBuilder:uc}),ot({type:"infix",names:["\\above"],props:{numArgs:1,argTypes:["size"],infix:!0},handler(t,e){var{parser:r,funcName:n,token:i}=t;return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:Bt(e[0],"size").value,token:i}}}),ot({type:"genfrac",names:["\\\\abovefrac"],props:{numArgs:3,argTypes:["math","size","math"]},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=e[0],a=vE(Bt(e[1],"infix").size),s=e[2],o=a.number>0;return{type:"genfrac",mode:r.mode,numer:i,denom:s,continued:!1,hasBarLine:o,barSize:a,leftDelim:null,rightDelim:null,size:"auto"}},htmlBuilder:lc,mathmlBuilder:uc});var hm=(t,e)=>{var r=e.style,n,i;t.type==="supsub"?(n=t.sup?$t(t.sup,e.havingStyle(r.sup()),e):$t(t.sub,e.havingStyle(r.sub()),e),i=Bt(t.base,"horizBrace")):i=Bt(t,"horizBrace");var a=$t(i.base,e.havingBaseStyle(xt.DISPLAY)),s=Mn.svgSpan(i,e),o;if(i.isOver?(o=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:a},{type:"kern",size:.1},{type:"elem",elem:s}]},e),o.children[0].children[0].children[1].classes.push("svg-align")):(o=z.makeVList({positionType:"bottom",positionData:a.depth+.1+s.height,children:[{type:"elem",elem:s},{type:"kern",size:.1},{type:"elem",elem:a}]},e),o.children[0].children[0].children[0].classes.push("svg-align")),n){var l=z.makeSpan(["mord",i.isOver?"mover":"munder"],[o],e);i.isOver?o=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:n}]},e):o=z.makeVList({positionType:"bottom",positionData:l.depth+.2+n.height+n.depth,children:[{type:"elem",elem:n},{type:"kern",size:.2},{type:"elem",elem:l}]},e)}return z.makeSpan(["mord",i.isOver?"mover":"munder"],[o],e)},WF=(t,e)=>{var r=Mn.mathMLnode(t.label);return new Z.MathNode(t.isOver?"mover":"munder",[Qt(t.base,e),r])};ot({type:"horizBrace",names:["\\overbrace","\\underbrace"],props:{numArgs:1},handler(t,e){var{parser:r,funcName:n}=t;return{type:"horizBrace",mode:r.mode,label:n,isOver:/^\\over/.test(n),base:e[0]}},htmlBuilder:hm,mathmlBuilder:WF}),ot({type:"href",names:["\\href"],props:{numArgs:2,argTypes:["url","original"],allowedInText:!0},handler:(t,e)=>{var{parser:r}=t,n=e[1],i=Bt(e[0],"url").url;return r.settings.isTrusted({command:"\\href",url:i})?{type:"href",mode:r.mode,href:i,body:ge(n)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:(t,e)=>{var r=Se(t.body,e,!1);return z.makeAnchor(t.href,[],r,e)},mathmlBuilder:(t,e)=>{var r=Jn(t.body,e);return r instanceof Tr||(r=new Tr("mrow",[r])),r.setAttribute("href",t.href),r}}),ot({type:"href",names:["\\url"],props:{numArgs:1,argTypes:["url"],allowedInText:!0},handler:(t,e)=>{var{parser:r}=t,n=Bt(e[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:n}))return r.formatUnsupportedCmd("\\url");for(var i=[],a=0;a {var{parser:r,funcName:n,token:i}=t,a=Bt(e[0],"raw").string,s=e[1];r.settings.strict&&r.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var o,l={};switch(n){case"\\htmlClass":l.class=a,o={command:"\\htmlClass",class:a};break;case"\\htmlId":l.id=a,o={command:"\\htmlId",id:a};break;case"\\htmlStyle":l.style=a,o={command:"\\htmlStyle",style:a};break;case"\\htmlData":{for(var u=a.split(","),c=0;c {var r=Se(t.body,e,!1),n=["enclosing"];t.attributes.class&&n.push(...t.attributes.class.trim().split(/\s+/));var i=z.makeSpan(n,r,e);for(var a in t.attributes)a!=="class"&&t.attributes.hasOwnProperty(a)&&i.setAttribute(a,t.attributes[a]);return i},mathmlBuilder:(t,e)=>Jn(t.body,e)}),ot({type:"htmlmathml",names:["\\html@mathml"],props:{numArgs:2,allowedInText:!0},handler:(t,e)=>{var{parser:r}=t;return{type:"htmlmathml",mode:r.mode,html:ge(e[0]),mathml:ge(e[1])}},htmlBuilder:(t,e)=>{var r=Se(t.html,e,!1);return z.makeFragment(r)},mathmlBuilder:(t,e)=>Jn(t.mathml,e)});var cc=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!r)throw new tt("Invalid size: '"+e+"' in \\includegraphics");var n={number:+(r[1]+r[2]),unit:r[3]};if(!dp(n))throw new tt("Invalid unit: '"+n.unit+"' in \\includegraphics.");return n};ot({type:"includegraphics",names:["\\includegraphics"],props:{numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1},handler:(t,e,r)=>{var{parser:n}=t,i={number:0,unit:"em"},a={number:.9,unit:"em"},s={number:0,unit:"em"},o="";if(r[0])for(var l=Bt(r[0],"raw").string,u=l.split(","),c=0;c {var r=ce(t.height,e),n=0;t.totalheight.number>0&&(n=ce(t.totalheight,e)-r);var i=0;t.width.number>0&&(i=ce(t.width,e));var a={height:nt(r+n)};i>0&&(a.width=nt(i)),n>0&&(a.verticalAlign=nt(-n));var s=new WE(t.src,t.alt,a);return s.height=r,s.depth=n,s},mathmlBuilder:(t,e)=>{var r=new Z.MathNode("mglyph",[]);r.setAttribute("alt",t.alt);var n=ce(t.height,e),i=0;if(t.totalheight.number>0&&(i=ce(t.totalheight,e)-n,r.setAttribute("valign",nt(-i))),r.setAttribute("height",nt(n+i)),t.width.number>0){var a=ce(t.width,e);r.setAttribute("width",nt(a))}return r.setAttribute("src",t.src),r}}),ot({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],props:{numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0},handler(t,e){var{parser:r,funcName:n}=t,i=Bt(e[0],"size");if(r.settings.strict){var a=n[1]==="m",s=i.value.unit==="mu";a?(s||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" supports only mu units, "+("not "+i.value.unit+" units")),r.mode!=="math"&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" works only in math mode")):s&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+n+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:i.value}},htmlBuilder(t,e){return z.makeGlue(t.dimension,e)},mathmlBuilder(t,e){var r=ce(t.dimension,e);return new Z.SpaceNode(r)}}),ot({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],props:{numArgs:1,allowedInText:!0},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=e[0];return{type:"lap",mode:r.mode,alignment:n.slice(5),body:i}},htmlBuilder:(t,e)=>{var r;t.alignment==="clap"?(r=z.makeSpan([],[$t(t.body,e)]),r=z.makeSpan(["inner"],[r],e)):r=z.makeSpan(["inner"],[$t(t.body,e)]);var n=z.makeSpan(["fix"],[]),i=z.makeSpan([t.alignment],[r,n],e),a=z.makeSpan(["strut"]);return a.style.height=nt(i.height+i.depth),i.depth&&(a.style.verticalAlign=nt(-i.depth)),i.children.unshift(a),i=z.makeSpan(["thinbox"],[i],e),z.makeSpan(["mord","vbox"],[i],e)},mathmlBuilder:(t,e)=>{var r=new Z.MathNode("mpadded",[Qt(t.body,e)]);if(t.alignment!=="rlap"){var n=t.alignment==="llap"?"-1":"-0.5";r.setAttribute("lspace",n+"width")}return r.setAttribute("width","0px"),r}}),ot({type:"styling",names:["\\(","$"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,e){var{funcName:r,parser:n}=t,i=n.mode;n.switchMode("math");var a=r==="\\("?"\\)":"$",s=n.parseExpression(!1,a);return n.expect(a),n.switchMode(i),{type:"styling",mode:n.mode,style:"text",body:s}}}),ot({type:"text",names:["\\)","\\]"],props:{numArgs:0,allowedInText:!0,allowedInMath:!1},handler(t,e){throw new tt("Mismatched "+t.funcName)}});var fm=(t,e)=>{switch(e.style.size){case xt.DISPLAY.size:return t.display;case xt.TEXT.size:return t.text;case xt.SCRIPT.size:return t.script;case xt.SCRIPTSCRIPT.size:return t.scriptscript;default:return t.text}};ot({type:"mathchoice",names:["\\mathchoice"],props:{numArgs:4,primitive:!0},handler:(t,e)=>{var{parser:r}=t;return{type:"mathchoice",mode:r.mode,display:ge(e[0]),text:ge(e[1]),script:ge(e[2]),scriptscript:ge(e[3])}},htmlBuilder:(t,e)=>{var r=fm(t,e),n=Se(r,e,!1);return z.makeFragment(n)},mathmlBuilder:(t,e)=>{var r=fm(t,e);return Jn(r,e)}});var dm=(t,e,r,n,i,a,s)=>{t=z.makeSpan([],[t]);var o=r&&Ct.isCharacterBox(r),l,u;if(e){var c=$t(e,n.havingStyle(i.sup()),n);u={elem:c,kern:Math.max(n.fontMetrics().bigOpSpacing1,n.fontMetrics().bigOpSpacing3-c.depth)}}if(r){var h=$t(r,n.havingStyle(i.sub()),n);l={elem:h,kern:Math.max(n.fontMetrics().bigOpSpacing2,n.fontMetrics().bigOpSpacing4-h.height)}}var f;if(u&&l){var p=n.fontMetrics().bigOpSpacing5+l.elem.height+l.elem.depth+l.kern+t.depth+s;f=z.makeVList({positionType:"bottom",positionData:p,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:nt(-a)},{type:"kern",size:l.kern},{type:"elem",elem:t},{type:"kern",size:u.kern},{type:"elem",elem:u.elem,marginLeft:nt(a)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else if(l){var y=t.height-s;f=z.makeVList({positionType:"top",positionData:y,children:[{type:"kern",size:n.fontMetrics().bigOpSpacing5},{type:"elem",elem:l.elem,marginLeft:nt(-a)},{type:"kern",size:l.kern},{type:"elem",elem:t}]},n)}else if(u){var b=t.depth+s;f=z.makeVList({positionType:"bottom",positionData:b,children:[{type:"elem",elem:t},{type:"kern",size:u.kern},{type:"elem",elem:u.elem,marginLeft:nt(a)},{type:"kern",size:n.fontMetrics().bigOpSpacing5}]},n)}else return t;var A=[f];if(l&&a!==0&&!o){var _=z.makeSpan(["mspace"],[],n);_.style.marginRight=nt(a),A.unshift(_)}return z.makeSpan(["mop","op-limits"],A,n)},pm=["\\smallint"],ma=(t,e)=>{var r,n,i=!1,a;t.type==="supsub"?(r=t.sup,n=t.sub,a=Bt(t.base,"op"),i=!0):a=Bt(t,"op");var s=e.style,o=!1;s.size===xt.DISPLAY.size&&a.symbol&&!Ct.contains(pm,a.name)&&(o=!0);var l;if(a.symbol){var u=o?"Size2-Regular":"Size1-Regular",c="";if((a.name==="\\oiint"||a.name==="\\oiiint")&&(c=a.name.slice(1),a.name=c==="oiint"?"\\iint":"\\iiint"),l=z.makeSymbol(a.name,u,"math",e,["mop","op-symbol",o?"large-op":"small-op"]),c.length>0){var h=l.italic,f=z.staticSvg(c+"Size"+(o?"2":"1"),e);l=z.makeVList({positionType:"individualShift",children:[{type:"elem",elem:l,shift:0},{type:"elem",elem:f,shift:o?.08:0}]},e),a.name="\\"+c,l.classes.unshift("mop"),l.italic=h}}else if(a.body){var p=Se(a.body,e,!0);p.length===1&&p[0]instanceof Sr?(l=p[0],l.classes[0]="mop"):l=z.makeSpan(["mop"],p,e)}else{for(var y=[],b=1;b {var r;if(t.symbol)r=new Tr("mo",[Ar(t.name,t.mode)]),Ct.contains(pm,t.name)&&r.setAttribute("largeop","false");else if(t.body)r=new Tr("mo",nr(t.body,e));else{r=new Tr("mi",[new hs(t.name.slice(1))]);var n=new Tr("mo",[Ar("","text")]);t.parentIsSupSub?r=new Tr("mrow",[r,n]):r=Lp([r,n])}return r},UF={"∏":"\\prod","∐":"\\coprod","∑":"\\sum","⋀":"\\bigwedge","⋁":"\\bigvee","⋂":"\\bigcap","⋃":"\\bigcup","⨀":"\\bigodot","⨁":"\\bigoplus","⨂":"\\bigotimes","⨄":"\\biguplus","⨆":"\\bigsqcup"};ot({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","∏","∐","∑","⋀","⋁","⋂","⋃","⨀","⨁","⨂","⨄","⨆"],props:{numArgs:0},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=n;return i.length===1&&(i=UF[i]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:i}},htmlBuilder:ma,mathmlBuilder:ps}),ot({type:"op",names:["\\mathop"],props:{numArgs:1,primitive:!0},handler:(t,e)=>{var{parser:r}=t,n=e[0];return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:ge(n)}},htmlBuilder:ma,mathmlBuilder:ps});var GF={"∫":"\\int","∬":"\\iint","∭":"\\iiint","∮":"\\oint","∯":"\\oiint","∰":"\\oiiint"};ot({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"],props:{numArgs:0},handler(t){var{parser:e,funcName:r}=t;return{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:r}},htmlBuilder:ma,mathmlBuilder:ps}),ot({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],props:{numArgs:0},handler(t){var{parser:e,funcName:r}=t;return{type:"op",mode:e.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:r}},htmlBuilder:ma,mathmlBuilder:ps}),ot({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","∫","∬","∭","∮","∯","∰"],props:{numArgs:0},handler(t){var{parser:e,funcName:r}=t,n=r;return n.length===1&&(n=GF[n]),{type:"op",mode:e.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:n}},htmlBuilder:ma,mathmlBuilder:ps});var mm=(t,e)=>{var r,n,i=!1,a;t.type==="supsub"?(r=t.sup,n=t.sub,a=Bt(t.base,"operatorname"),i=!0):a=Bt(t,"operatorname");var s;if(a.body.length>0){for(var o=a.body.map(h=>{var f=h.text;return typeof f=="string"?{type:"textord",mode:h.mode,text:f}:h}),l=Se(o,e.withFont("mathrm"),!0),u=0;u {for(var r=nr(t.body,e.withFont("mathrm")),n=!0,i=0;i c.toText()).join("");r=[new Z.TextNode(o)]}var l=new Z.MathNode("mi",r);l.setAttribute("mathvariant","normal");var u=new Z.MathNode("mo",[Ar("","text")]);return t.parentIsSupSub?new Z.MathNode("mrow",[l,u]):Z.newDocumentFragment([l,u])};ot({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],props:{numArgs:1},handler:(t,e)=>{var{parser:r,funcName:n}=t,i=e[0];return{type:"operatorname",mode:r.mode,body:ge(i),alwaysHandleSupSub:n==="\\operatornamewithlimits",limits:!1,parentIsSupSub:!1}},htmlBuilder:mm,mathmlBuilder:jF}),x("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),Si({type:"ordgroup",htmlBuilder(t,e){return t.semisimple?z.makeFragment(Se(t.body,e,!1)):z.makeSpan(["mord"],Se(t.body,e,!0),e)},mathmlBuilder(t,e){return Jn(t.body,e,!0)}}),ot({type:"overline",names:["\\overline"],props:{numArgs:1},handler(t,e){var{parser:r}=t,n=e[0];return{type:"overline",mode:r.mode,body:n}},htmlBuilder(t,e){var r=$t(t.body,e.havingCrampedStyle()),n=z.makeLineSpan("overline-line",e),i=e.fontMetrics().defaultRuleThickness,a=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:r},{type:"kern",size:3*i},{type:"elem",elem:n},{type:"kern",size:i}]},e);return z.makeSpan(["mord","overline"],[a],e)},mathmlBuilder(t,e){var r=new Z.MathNode("mo",[new Z.TextNode("‾")]);r.setAttribute("stretchy","true");var n=new Z.MathNode("mover",[Qt(t.body,e),r]);return n.setAttribute("accent","true"),n}}),ot({type:"phantom",names:["\\phantom"],props:{numArgs:1,allowedInText:!0},handler:(t,e)=>{var{parser:r}=t,n=e[0];return{type:"phantom",mode:r.mode,body:ge(n)}},htmlBuilder:(t,e)=>{var r=Se(t.body,e.withPhantom(),!1);return z.makeFragment(r)},mathmlBuilder:(t,e)=>{var r=nr(t.body,e);return new Z.MathNode("mphantom",r)}}),ot({type:"hphantom",names:["\\hphantom"],props:{numArgs:1,allowedInText:!0},handler:(t,e)=>{var{parser:r}=t,n=e[0];return{type:"hphantom",mode:r.mode,body:n}},htmlBuilder:(t,e)=>{var r=z.makeSpan([],[$t(t.body,e.withPhantom())]);if(r.height=0,r.depth=0,r.children)for(var n=0;n {var r=nr(ge(t.body),e),n=new Z.MathNode("mphantom",r),i=new Z.MathNode("mpadded",[n]);return i.setAttribute("height","0px"),i.setAttribute("depth","0px"),i}}),ot({type:"vphantom",names:["\\vphantom"],props:{numArgs:1,allowedInText:!0},handler:(t,e)=>{var{parser:r}=t,n=e[0];return{type:"vphantom",mode:r.mode,body:n}},htmlBuilder:(t,e)=>{var r=z.makeSpan(["inner"],[$t(t.body,e.withPhantom())]),n=z.makeSpan(["fix"],[]);return z.makeSpan(["mord","rlap"],[r,n],e)},mathmlBuilder:(t,e)=>{var r=nr(ge(t.body),e),n=new Z.MathNode("mphantom",r),i=new Z.MathNode("mpadded",[n]);return i.setAttribute("width","0px"),i}}),ot({type:"raisebox",names:["\\raisebox"],props:{numArgs:2,argTypes:["size","hbox"],allowedInText:!0},handler(t,e){var{parser:r}=t,n=Bt(e[0],"size").value,i=e[1];return{type:"raisebox",mode:r.mode,dy:n,body:i}},htmlBuilder(t,e){var r=$t(t.body,e),n=ce(t.dy,e);return z.makeVList({positionType:"shift",positionData:-n,children:[{type:"elem",elem:r}]},e)},mathmlBuilder(t,e){var r=new Z.MathNode("mpadded",[Qt(t.body,e)]),n=t.dy.number+t.dy.unit;return r.setAttribute("voffset",n),r}}),ot({type:"internal",names:["\\relax"],props:{numArgs:0,allowedInText:!0},handler(t){var{parser:e}=t;return{type:"internal",mode:e.mode}}}),ot({type:"rule",names:["\\rule"],props:{numArgs:2,numOptionalArgs:1,argTypes:["size","size","size"]},handler(t,e,r){var{parser:n}=t,i=r[0],a=Bt(e[0],"size"),s=Bt(e[1],"size");return{type:"rule",mode:n.mode,shift:i&&Bt(i,"size").value,width:a.value,height:s.value}},htmlBuilder(t,e){var r=z.makeSpan(["mord","rule"],[],e),n=ce(t.width,e),i=ce(t.height,e),a=t.shift?ce(t.shift,e):0;return r.style.borderRightWidth=nt(n),r.style.borderTopWidth=nt(i),r.style.bottom=nt(a),r.width=n,r.height=i+a,r.depth=-a,r.maxFontSize=i*1.125*e.sizeMultiplier,r},mathmlBuilder(t,e){var r=ce(t.width,e),n=ce(t.height,e),i=t.shift?ce(t.shift,e):0,a=e.color&&e.getColor()||"black",s=new Z.MathNode("mspace");s.setAttribute("mathbackground",a),s.setAttribute("width",nt(r)),s.setAttribute("height",nt(n));var o=new Z.MathNode("mpadded",[s]);return i>=0?o.setAttribute("height",nt(i)):(o.setAttribute("height",nt(i)),o.setAttribute("depth",nt(-i))),o.setAttribute("voffset",nt(i)),o}});function gm(t,e,r){for(var n=Se(t,e,!1),i=e.sizeMultiplier/r.sizeMultiplier,a=0;a {var r=e.havingSize(t.size);return gm(t.body,r,e)};ot({type:"sizing",names:ym,props:{numArgs:0,allowedInText:!0},handler:(t,e)=>{var{breakOnTokenText:r,funcName:n,parser:i}=t,a=i.parseExpression(!1,r);return{type:"sizing",mode:i.mode,size:ym.indexOf(n)+1,body:a}},htmlBuilder:YF,mathmlBuilder:(t,e)=>{var r=e.havingSize(t.size),n=nr(t.body,r),i=new Z.MathNode("mstyle",n);return i.setAttribute("mathsize",nt(r.sizeMultiplier)),i}}),ot({type:"smash",names:["\\smash"],props:{numArgs:1,numOptionalArgs:1,allowedInText:!0},handler:(t,e,r)=>{var{parser:n}=t,i=!1,a=!1,s=r[0]&&Bt(r[0],"ordgroup");if(s)for(var o="",l=0;l {var r=z.makeSpan([],[$t(t.body,e)]);if(!t.smashHeight&&!t.smashDepth)return r;if(t.smashHeight&&(r.height=0,r.children))for(var n=0;n {var r=new Z.MathNode("mpadded",[Qt(t.body,e)]);return t.smashHeight&&r.setAttribute("height","0px"),t.smashDepth&&r.setAttribute("depth","0px"),r}}),ot({type:"sqrt",names:["\\sqrt"],props:{numArgs:1,numOptionalArgs:1},handler(t,e,r){var{parser:n}=t,i=r[0],a=e[0];return{type:"sqrt",mode:n.mode,body:a,index:i}},htmlBuilder(t,e){var r=$t(t.body,e.havingCrampedStyle());r.height===0&&(r.height=e.fontMetrics().xHeight),r=z.wrapFragment(r,e);var n=e.fontMetrics(),i=n.defaultRuleThickness,a=i;e.style.id r.height+r.depth+s&&(s=(s+h-r.height-r.depth)/2);var f=l.height-r.height-s-u;r.style.paddingLeft=nt(c);var p=z.makeVList({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+f)},{type:"elem",elem:l},{type:"kern",size:u}]},e);if(t.index){var y=e.havingStyle(xt.SCRIPTSCRIPT),b=$t(t.index,y,e),A=.6*(p.height-p.depth),_=z.makeVList({positionType:"shift",positionData:-A,children:[{type:"elem",elem:b}]},e),M=z.makeSpan(["root"],[_]);return z.makeSpan(["mord","sqrt"],[M,p],e)}else return z.makeSpan(["mord","sqrt"],[p],e)},mathmlBuilder(t,e){var{body:r,index:n}=t;return n?new Z.MathNode("mroot",[Qt(r,e),Qt(n,e)]):new Z.MathNode("msqrt",[Qt(r,e)])}});var bm={display:xt.DISPLAY,text:xt.TEXT,script:xt.SCRIPT,scriptscript:xt.SCRIPTSCRIPT};ot({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],props:{numArgs:0,allowedInText:!0,primitive:!0},handler(t,e){var{breakOnTokenText:r,funcName:n,parser:i}=t,a=i.parseExpression(!0,r),s=n.slice(1,n.length-5);return{type:"styling",mode:i.mode,style:s,body:a}},htmlBuilder(t,e){var r=bm[t.style],n=e.havingStyle(r).withFont("");return gm(t.body,n,e)},mathmlBuilder(t,e){var r=bm[t.style],n=e.havingStyle(r),i=nr(t.body,n),a=new Z.MathNode("mstyle",i),s={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]},o=s[t.style];return a.setAttribute("scriptlevel",o[0]),a.setAttribute("displaystyle",o[1]),a}});var XF=function(e,r){var n=e.base;if(n)if(n.type==="op"){var i=n.limits&&(r.style.size===xt.DISPLAY.size||n.alwaysHandleSupSub);return i?ma:null}else if(n.type==="operatorname"){var a=n.alwaysHandleSupSub&&(r.style.size===xt.DISPLAY.size||n.limits);return a?mm:null}else{if(n.type==="accent")return Ct.isCharacterBox(n.base)?Xu:null;if(n.type==="horizBrace"){var s=!e.sub;return s===n.isOver?hm:null}else return null}else return null};Si({type:"supsub",htmlBuilder(t,e){var r=XF(t,e);if(r)return r(t,e);var{base:n,sup:i,sub:a}=t,s=$t(n,e),o,l,u=e.fontMetrics(),c=0,h=0,f=n&&Ct.isCharacterBox(n);if(i){var p=e.havingStyle(e.style.sup());o=$t(i,p,e),f||(c=s.height-p.fontMetrics().supDrop*p.sizeMultiplier/e.sizeMultiplier)}if(a){var y=e.havingStyle(e.style.sub());l=$t(a,y,e),f||(h=s.depth+y.fontMetrics().subDrop*y.sizeMultiplier/e.sizeMultiplier)}var b;e.style===xt.DISPLAY?b=u.sup1:e.style.cramped?b=u.sup3:b=u.sup2;var A=e.sizeMultiplier,_=nt(.5/u.ptPerEm/A),M=null;if(l){var I=t.base&&t.base.type==="op"&&t.base.name&&(t.base.name==="\\oiint"||t.base.name==="\\oiiint");(s instanceof Sr||I)&&(M=nt(-s.italic))}var V;if(o&&l){c=Math.max(c,b,o.depth+.25*u.xHeight),h=Math.max(h,u.sub2);var N=u.defaultRuleThickness,L=4*N;if(c-o.depth-(l.height-h) 0&&(c+=q,h-=q)}var G=[{type:"elem",elem:l,shift:h,marginRight:_,marginLeft:M},{type:"elem",elem:o,shift:-c,marginRight:_}];V=z.makeVList({positionType:"individualShift",children:G},e)}else if(l){h=Math.max(h,u.sub1,l.height-.8*u.xHeight);var Y=[{type:"elem",elem:l,marginLeft:M,marginRight:_}];V=z.makeVList({positionType:"shift",positionData:h,children:Y},e)}else if(o)c=Math.max(c,b,o.depth+.25*u.xHeight),V=z.makeVList({positionType:"shift",positionData:-c,children:[{type:"elem",elem:o,marginRight:_}]},e);else throw new Error("supsub must have either sup or sub.");var J=Wu(s,"right")||"mord";return z.makeSpan([J],[s,z.makeSpan(["msupsub"],[V])],e)},mathmlBuilder(t,e){var r=!1,n,i;t.base&&t.base.type==="horizBrace"&&(i=!!t.sup,i===t.base.isOver&&(r=!0,n=t.base.isOver)),t.base&&(t.base.type==="op"||t.base.type==="operatorname")&&(t.base.parentIsSupSub=!0);var a=[Qt(t.base,e)];t.sub&&a.push(Qt(t.sub,e)),t.sup&&a.push(Qt(t.sup,e));var s;if(r)s=n?"mover":"munder";else if(t.sub)if(t.sup){var u=t.base;u&&u.type==="op"&&u.limits&&e.style===xt.DISPLAY||u&&u.type==="operatorname"&&u.alwaysHandleSupSub&&(e.style===xt.DISPLAY||u.limits)?s="munderover":s="msubsup"}else{var l=t.base;l&&l.type==="op"&&l.limits&&(e.style===xt.DISPLAY||l.alwaysHandleSupSub)||l&&l.type==="operatorname"&&l.alwaysHandleSupSub&&(l.limits||e.style===xt.DISPLAY)?s="munder":s="msub"}else{var o=t.base;o&&o.type==="op"&&o.limits&&(e.style===xt.DISPLAY||o.alwaysHandleSupSub)||o&&o.type==="operatorname"&&o.alwaysHandleSupSub&&(o.limits||e.style===xt.DISPLAY)?s="mover":s="msup"}return new Z.MathNode(s,a)}}),Si({type:"atom",htmlBuilder(t,e){return z.mathsym(t.text,t.mode,e,["m"+t.family])},mathmlBuilder(t,e){var r=new Z.MathNode("mo",[Ar(t.text,t.mode)]);if(t.family==="bin"){var n=ju(t,e);n==="bold-italic"&&r.setAttribute("mathvariant",n)}else t.family==="punct"?r.setAttribute("separator","true"):(t.family==="open"||t.family==="close")&&r.setAttribute("stretchy","false");return r}});var xm={mi:"italic",mn:"normal",mtext:"normal"};Si({type:"mathord",htmlBuilder(t,e){return z.makeOrd(t,e,"mathord")},mathmlBuilder(t,e){var r=new Z.MathNode("mi",[Ar(t.text,t.mode,e)]),n=ju(t,e)||"italic";return n!==xm[r.type]&&r.setAttribute("mathvariant",n),r}}),Si({type:"textord",htmlBuilder(t,e){return z.makeOrd(t,e,"textord")},mathmlBuilder(t,e){var r=Ar(t.text,t.mode,e),n=ju(t,e)||"normal",i;return t.mode==="text"?i=new Z.MathNode("mtext",[r]):/[0-9]/.test(t.text)?i=new Z.MathNode("mn",[r]):t.text==="\\prime"?i=new Z.MathNode("mo",[r]):i=new Z.MathNode("mi",[r]),n!==xm[i.type]&&i.setAttribute("mathvariant",n),i}});var hc={"\\nobreak":"nobreak","\\allowbreak":"allowbreak"},fc={" ":{},"\\ ":{},"~":{className:"nobreak"},"\\space":{},"\\nobreakspace":{className:"nobreak"}};Si({type:"spacing",htmlBuilder(t,e){if(fc.hasOwnProperty(t.text)){var r=fc[t.text].className||"";if(t.mode==="text"){var n=z.makeOrd(t,e,"textord");return n.classes.push(r),n}else return z.makeSpan(["mspace",r],[z.mathsym(t.text,t.mode,e)],e)}else{if(hc.hasOwnProperty(t.text))return z.makeSpan(["mspace",hc[t.text]],[],e);throw new tt('Unknown type of space "'+t.text+'"')}},mathmlBuilder(t,e){var r;if(fc.hasOwnProperty(t.text))r=new Z.MathNode("mtext",[new Z.TextNode(" ")]);else{if(hc.hasOwnProperty(t.text))return new Z.MathNode("mspace");throw new tt('Unknown type of space "'+t.text+'"')}return r}});var vm=()=>{var t=new Z.MathNode("mtd",[]);return t.setAttribute("width","50%"),t};Si({type:"tag",mathmlBuilder(t,e){var r=new Z.MathNode("mtable",[new Z.MathNode("mtr",[vm(),new Z.MathNode("mtd",[Jn(t.body,e)]),vm(),new Z.MathNode("mtd",[Jn(t.tag,e)])])]);return r.setAttribute("width","100%"),r}});var wm={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},Cm={"\\textbf":"textbf","\\textmd":"textmd"},KF={"\\textit":"textit","\\textup":"textup"},km=(t,e)=>{var r=t.font;return r?wm[r]?e.withTextFontFamily(wm[r]):Cm[r]?e.withTextFontWeight(Cm[r]):e.withTextFontShape(KF[r]):e};ot({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup"],props:{numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0},handler(t,e){var{parser:r,funcName:n}=t,i=e[0];return{type:"text",mode:r.mode,body:ge(i),font:n}},htmlBuilder(t,e){var r=km(t,e),n=Se(t.body,r,!0);return z.makeSpan(["mord","text"],n,r)},mathmlBuilder(t,e){var r=km(t,e);return Jn(t.body,r)}}),ot({type:"underline",names:["\\underline"],props:{numArgs:1,allowedInText:!0},handler(t,e){var{parser:r}=t;return{type:"underline",mode:r.mode,body:e[0]}},htmlBuilder(t,e){var r=$t(t.body,e),n=z.makeLineSpan("underline-line",e),i=e.fontMetrics().defaultRuleThickness,a=z.makeVList({positionType:"top",positionData:r.height,children:[{type:"kern",size:i},{type:"elem",elem:n},{type:"kern",size:3*i},{type:"elem",elem:r}]},e);return z.makeSpan(["mord","underline"],[a],e)},mathmlBuilder(t,e){var r=new Z.MathNode("mo",[new Z.TextNode("‾")]);r.setAttribute("stretchy","true");var n=new Z.MathNode("munder",[Qt(t.body,e),r]);return n.setAttribute("accentunder","true"),n}}),ot({type:"vcenter",names:["\\vcenter"],props:{numArgs:1,argTypes:["original"],allowedInText:!1},handler(t,e){var{parser:r}=t;return{type:"vcenter",mode:r.mode,body:e[0]}},htmlBuilder(t,e){var r=$t(t.body,e),n=e.fontMetrics().axisHeight,i=.5*(r.height-n-(r.depth+n));return z.makeVList({positionType:"shift",positionData:i,children:[{type:"elem",elem:r}]},e)},mathmlBuilder(t,e){return new Z.MathNode("mpadded",[Qt(t.body,e)],["vcenter"])}}),ot({type:"verb",names:["\\verb"],props:{numArgs:0,allowedInText:!0},handler(t,e,r){throw new tt("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(t,e){for(var r=_m(t),n=[],i=e.havingStyle(e.style.text()),a=0;a t.body.replace(/ /g,t.star?"␣":" "),ei=Bp,Sm=`[ \r + ]`,ZF="\\\\[a-zA-Z@]+",QF="\\\\[^\uD800-\uDFFF]",JF="("+ZF+")"+Sm+"*",tL=`\\\\( +|[ \r ]+ +?)[ \r ]*`,dc="[̀-ͯ]",eL=new RegExp(dc+"+$"),rL="("+Sm+"+)|"+(tL+"|")+"([!-\\[\\]-‧-豈-]"+(dc+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(dc+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+JF)+("|"+QF+")");class Tm{constructor(e,r){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=r,this.tokenRegex=new RegExp(rL,"g"),this.catcodes={"%":14,"~":13}}setCatcode(e,r){this.catcodes[e]=r}lex(){var e=this.input,r=this.tokenRegex.lastIndex;if(r===e.length)return new sn("EOF",new mr(this,r,r));var n=this.tokenRegex.exec(e);if(n===null||n.index!==r)throw new tt("Unexpected character: '"+e[r]+"'",new sn(e[r],new mr(this,r,r+1)));var i=n[6]||n[3]||(n[2]?"\\ ":" ");if(this.catcodes[i]===14){var a=e.indexOf(` +`,this.tokenRegex.lastIndex);return a===-1?(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=a+1,this.lex()}return new sn(i,new mr(this,r,this.tokenRegex.lastIndex))}}class nL{constructor(e,r){e===void 0&&(e={}),r===void 0&&(r={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=r,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new tt("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var r in e)e.hasOwnProperty(r)&&(e[r]==null?delete this.current[r]:this.current[r]=e[r])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return this.current.hasOwnProperty(e)||this.builtins.hasOwnProperty(e)}get(e){return this.current.hasOwnProperty(e)?this.current[e]:this.builtins[e]}set(e,r,n){if(n===void 0&&(n=!1),n){for(var i=0;i 0&&(this.undefStack[this.undefStack.length-1][e]=r)}else{var a=this.undefStack[this.undefStack.length-1];a&&!a.hasOwnProperty(e)&&(a[e]=this.current[e])}r==null?delete this.current[e]:this.current[e]=r}}var iL=em;x("\\noexpand",function(t){var e=t.popToken();return t.isExpandable(e.text)&&(e.noexpand=!0,e.treatAsRelax=!0),{tokens:[e],numArgs:0}}),x("\\expandafter",function(t){var e=t.popToken();return t.expandOnce(!0),{tokens:[e],numArgs:0}}),x("\\@firstoftwo",function(t){var e=t.consumeArgs(2);return{tokens:e[0],numArgs:0}}),x("\\@secondoftwo",function(t){var e=t.consumeArgs(2);return{tokens:e[1],numArgs:0}}),x("\\@ifnextchar",function(t){var e=t.consumeArgs(3);t.consumeSpaces();var r=t.future();return e[0].length===1&&e[0][0].text===r.text?{tokens:e[1],numArgs:0}:{tokens:e[2],numArgs:0}}),x("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),x("\\TextOrMath",function(t){var e=t.consumeArgs(2);return t.mode==="text"?{tokens:e[0],numArgs:0}:{tokens:e[1],numArgs:0}});var Am={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};x("\\char",function(t){var e=t.popToken(),r,n="";if(e.text==="'")r=8,e=t.popToken();else if(e.text==='"')r=16,e=t.popToken();else if(e.text==="`")if(e=t.popToken(),e.text[0]==="\\")n=e.text.charCodeAt(1);else{if(e.text==="EOF")throw new tt("\\char` missing argument");n=e.text.charCodeAt(0)}else r=10;if(r){if(n=Am[e.text],n==null||n>=r)throw new tt("Invalid base-"+r+" digit "+e.text);for(var i;(i=Am[t.future().text])!=null&&i {var n=t.consumeArg().tokens;if(n.length!==1)throw new tt("\\newcommand's first argument must be a macro name");var i=n[0].text,a=t.isDefined(i);if(a&&!e)throw new tt("\\newcommand{"+i+"} attempting to redefine "+(i+"; use \\renewcommand"));if(!a&&!r)throw new tt("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");var s=0;if(n=t.consumeArg().tokens,n.length===1&&n[0].text==="["){for(var o="",l=t.expandNextToken();l.text!=="]"&&l.text!=="EOF";)o+=l.text,l=t.expandNextToken();if(!o.match(/^\s*[0-9]+\s*$/))throw new tt("Invalid number of arguments: "+o);s=parseInt(o),n=t.consumeArg().tokens}return t.macros.set(i,{tokens:n,numArgs:s}),""};x("\\newcommand",t=>pc(t,!1,!0)),x("\\renewcommand",t=>pc(t,!0,!1)),x("\\providecommand",t=>pc(t,!0,!0)),x("\\message",t=>{var e=t.consumeArgs(1)[0];return console.log(e.reverse().map(r=>r.text).join("")),""}),x("\\errmessage",t=>{var e=t.consumeArgs(1)[0];return console.error(e.reverse().map(r=>r.text).join("")),""}),x("\\show",t=>{var e=t.popToken(),r=e.text;return console.log(e,t.macros.get(r),ei[r],re.math[r],re.text[r]),""}),x("\\bgroup","{"),x("\\egroup","}"),x("~","\\nobreakspace"),x("\\lq","`"),x("\\rq","'"),x("\\aa","\\r a"),x("\\AA","\\r A"),x("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}"),x("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),x("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),x("ℬ","\\mathscr{B}"),x("ℰ","\\mathscr{E}"),x("ℱ","\\mathscr{F}"),x("ℋ","\\mathscr{H}"),x("ℐ","\\mathscr{I}"),x("ℒ","\\mathscr{L}"),x("ℳ","\\mathscr{M}"),x("ℛ","\\mathscr{R}"),x("ℭ","\\mathfrak{C}"),x("ℌ","\\mathfrak{H}"),x("ℨ","\\mathfrak{Z}"),x("\\Bbbk","\\Bbb{k}"),x("·","\\cdotp"),x("\\llap","\\mathllap{\\textrm{#1}}"),x("\\rlap","\\mathrlap{\\textrm{#1}}"),x("\\clap","\\mathclap{\\textrm{#1}}"),x("\\mathstrut","\\vphantom{(}"),x("\\underbar","\\underline{\\text{#1}}"),x("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}'),x("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),x("\\ne","\\neq"),x("≠","\\neq"),x("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),x("∉","\\notin"),x("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),x("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),x("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),x("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),x("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),x("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),x("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),x("⟂","\\perp"),x("‼","\\mathclose{!\\mkern-0.8mu!}"),x("∌","\\notni"),x("⌜","\\ulcorner"),x("⌝","\\urcorner"),x("⌞","\\llcorner"),x("⌟","\\lrcorner"),x("©","\\copyright"),x("®","\\textregistered"),x("️","\\textregistered"),x("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}'),x("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}'),x("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}'),x("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}'),x("\\vdots","\\mathord{\\varvdots\\rule{0pt}{15pt}}"),x("⋮","\\vdots"),x("\\varGamma","\\mathit{\\Gamma}"),x("\\varDelta","\\mathit{\\Delta}"),x("\\varTheta","\\mathit{\\Theta}"),x("\\varLambda","\\mathit{\\Lambda}"),x("\\varXi","\\mathit{\\Xi}"),x("\\varPi","\\mathit{\\Pi}"),x("\\varSigma","\\mathit{\\Sigma}"),x("\\varUpsilon","\\mathit{\\Upsilon}"),x("\\varPhi","\\mathit{\\Phi}"),x("\\varPsi","\\mathit{\\Psi}"),x("\\varOmega","\\mathit{\\Omega}"),x("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),x("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),x("\\boxed","\\fbox{$\\displaystyle{#1}$}"),x("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),x("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),x("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");var Bm={",":"\\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"};x("\\dots",function(t){var e="\\dotso",r=t.expandAfterFuture().text;return r in Bm?e=Bm[r]:(r.slice(0,4)==="\\not"||r in re.math&&Ct.contains(["bin","rel"],re.math[r].group))&&(e="\\dotsb"),e});var mc={")":!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};x("\\dotso",function(t){var e=t.future().text;return e in mc?"\\ldots\\,":"\\ldots"}),x("\\dotsc",function(t){var e=t.future().text;return e in mc&&e!==","?"\\ldots\\,":"\\ldots"}),x("\\cdots",function(t){var e=t.future().text;return e in mc?"\\@cdots\\,":"\\@cdots"}),x("\\dotsb","\\cdots"),x("\\dotsm","\\cdots"),x("\\dotsi","\\!\\cdots"),x("\\dotsx","\\ldots\\,"),x("\\DOTSI","\\relax"),x("\\DOTSB","\\relax"),x("\\DOTSX","\\relax"),x("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),x("\\,","\\tmspace+{3mu}{.1667em}"),x("\\thinspace","\\,"),x("\\>","\\mskip{4mu}"),x("\\:","\\tmspace+{4mu}{.2222em}"),x("\\medspace","\\:"),x("\\;","\\tmspace+{5mu}{.2777em}"),x("\\thickspace","\\;"),x("\\!","\\tmspace-{3mu}{.1667em}"),x("\\negthinspace","\\!"),x("\\negmedspace","\\tmspace-{4mu}{.2222em}"),x("\\negthickspace","\\tmspace-{5mu}{.277em}"),x("\\enspace","\\kern.5em "),x("\\enskip","\\hskip.5em\\relax"),x("\\quad","\\hskip1em\\relax"),x("\\qquad","\\hskip2em\\relax"),x("\\tag","\\@ifstar\\tag@literal\\tag@paren"),x("\\tag@paren","\\tag@literal{({#1})}"),x("\\tag@literal",t=>{if(t.macros.get("\\df@tag"))throw new tt("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),x("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),x("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),x("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),x("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),x("\\newline","\\\\\\relax"),x("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var Em=nt(ln["Main-Regular"]["T".charCodeAt(0)][1]-.7*ln["Main-Regular"]["A".charCodeAt(0)][1]);x("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+Em+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}"),x("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+Em+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}"),x("\\hspace","\\@ifstar\\@hspacer\\@hspace"),x("\\@hspace","\\hskip #1\\relax"),x("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),x("\\ordinarycolon",":"),x("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),x("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}'),x("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}'),x("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}'),x("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}'),x("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}'),x("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}'),x("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}'),x("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}'),x("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}'),x("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}'),x("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}'),x("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}'),x("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}'),x("∷","\\dblcolon"),x("∹","\\eqcolon"),x("≔","\\coloneqq"),x("≕","\\eqqcolon"),x("⩴","\\Coloneqq"),x("\\ratio","\\vcentcolon"),x("\\coloncolon","\\dblcolon"),x("\\colonequals","\\coloneqq"),x("\\coloncolonequals","\\Coloneqq"),x("\\equalscolon","\\eqqcolon"),x("\\equalscoloncolon","\\Eqqcolon"),x("\\colonminus","\\coloneq"),x("\\coloncolonminus","\\Coloneq"),x("\\minuscolon","\\eqcolon"),x("\\minuscoloncolon","\\Eqcolon"),x("\\coloncolonapprox","\\Colonapprox"),x("\\coloncolonsim","\\Colonsim"),x("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),x("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),x("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),x("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),x("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),x("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),x("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),x("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),x("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),x("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),x("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),x("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),x("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),x("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}"),x("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}"),x("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}"),x("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}"),x("\\nleqq","\\html@mathml{\\@nleqq}{≰}"),x("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}"),x("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}"),x("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}"),x("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}"),x("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}"),x("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}"),x("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}"),x("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}"),x("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}"),x("\\imath","\\html@mathml{\\@imath}{ı}"),x("\\jmath","\\html@mathml{\\@jmath}{ȷ}"),x("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),x("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),x("⟦","\\llbracket"),x("⟧","\\rrbracket"),x("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),x("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),x("⦃","\\lBrace"),x("⦄","\\rBrace"),x("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),x("⦵","\\minuso"),x("\\darr","\\downarrow"),x("\\dArr","\\Downarrow"),x("\\Darr","\\Downarrow"),x("\\lang","\\langle"),x("\\rang","\\rangle"),x("\\uarr","\\uparrow"),x("\\uArr","\\Uparrow"),x("\\Uarr","\\Uparrow"),x("\\N","\\mathbb{N}"),x("\\R","\\mathbb{R}"),x("\\Z","\\mathbb{Z}"),x("\\alef","\\aleph"),x("\\alefsym","\\aleph"),x("\\Alpha","\\mathrm{A}"),x("\\Beta","\\mathrm{B}"),x("\\bull","\\bullet"),x("\\Chi","\\mathrm{X}"),x("\\clubs","\\clubsuit"),x("\\cnums","\\mathbb{C}"),x("\\Complex","\\mathbb{C}"),x("\\Dagger","\\ddagger"),x("\\diamonds","\\diamondsuit"),x("\\empty","\\emptyset"),x("\\Epsilon","\\mathrm{E}"),x("\\Eta","\\mathrm{H}"),x("\\exist","\\exists"),x("\\harr","\\leftrightarrow"),x("\\hArr","\\Leftrightarrow"),x("\\Harr","\\Leftrightarrow"),x("\\hearts","\\heartsuit"),x("\\image","\\Im"),x("\\infin","\\infty"),x("\\Iota","\\mathrm{I}"),x("\\isin","\\in"),x("\\Kappa","\\mathrm{K}"),x("\\larr","\\leftarrow"),x("\\lArr","\\Leftarrow"),x("\\Larr","\\Leftarrow"),x("\\lrarr","\\leftrightarrow"),x("\\lrArr","\\Leftrightarrow"),x("\\Lrarr","\\Leftrightarrow"),x("\\Mu","\\mathrm{M}"),x("\\natnums","\\mathbb{N}"),x("\\Nu","\\mathrm{N}"),x("\\Omicron","\\mathrm{O}"),x("\\plusmn","\\pm"),x("\\rarr","\\rightarrow"),x("\\rArr","\\Rightarrow"),x("\\Rarr","\\Rightarrow"),x("\\real","\\Re"),x("\\reals","\\mathbb{R}"),x("\\Reals","\\mathbb{R}"),x("\\Rho","\\mathrm{P}"),x("\\sdot","\\cdot"),x("\\sect","\\S"),x("\\spades","\\spadesuit"),x("\\sub","\\subset"),x("\\sube","\\subseteq"),x("\\supe","\\supseteq"),x("\\Tau","\\mathrm{T}"),x("\\thetasym","\\vartheta"),x("\\weierp","\\wp"),x("\\Zeta","\\mathrm{Z}"),x("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),x("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),x("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),x("\\bra","\\mathinner{\\langle{#1}|}"),x("\\ket","\\mathinner{|{#1}\\rangle}"),x("\\braket","\\mathinner{\\langle{#1}\\rangle}"),x("\\Bra","\\left\\langle#1\\right|"),x("\\Ket","\\left|#1\\right\\rangle");var Fm=t=>e=>{var r=e.consumeArg().tokens,n=e.consumeArg().tokens,i=e.consumeArg().tokens,a=e.consumeArg().tokens,s=e.macros.get("|"),o=e.macros.get("\\|");e.macros.beginGroup();var l=h=>f=>{t&&(f.macros.set("|",s),i.length&&f.macros.set("\\|",o));var p=h;if(!h&&i.length){var y=f.future();y.text==="|"&&(f.popToken(),p=!0)}return{tokens:p?i:n,numArgs:0}};e.macros.set("|",l(!1)),i.length&&e.macros.set("\\|",l(!0));var u=e.consumeArg().tokens,c=e.expandTokens([...a,...u,...r]);return e.macros.endGroup(),{tokens:c.reverse(),numArgs:0}};x("\\bra@ket",Fm(!1)),x("\\bra@set",Fm(!0)),x("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),x("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),x("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),x("\\angln","{\\angl n}"),x("\\blue","\\textcolor{##6495ed}{#1}"),x("\\orange","\\textcolor{##ffa500}{#1}"),x("\\pink","\\textcolor{##ff00af}{#1}"),x("\\red","\\textcolor{##df0030}{#1}"),x("\\green","\\textcolor{##28ae7b}{#1}"),x("\\gray","\\textcolor{gray}{#1}"),x("\\purple","\\textcolor{##9d38bd}{#1}"),x("\\blueA","\\textcolor{##ccfaff}{#1}"),x("\\blueB","\\textcolor{##80f6ff}{#1}"),x("\\blueC","\\textcolor{##63d9ea}{#1}"),x("\\blueD","\\textcolor{##11accd}{#1}"),x("\\blueE","\\textcolor{##0c7f99}{#1}"),x("\\tealA","\\textcolor{##94fff5}{#1}"),x("\\tealB","\\textcolor{##26edd5}{#1}"),x("\\tealC","\\textcolor{##01d1c1}{#1}"),x("\\tealD","\\textcolor{##01a995}{#1}"),x("\\tealE","\\textcolor{##208170}{#1}"),x("\\greenA","\\textcolor{##b6ffb0}{#1}"),x("\\greenB","\\textcolor{##8af281}{#1}"),x("\\greenC","\\textcolor{##74cf70}{#1}"),x("\\greenD","\\textcolor{##1fab54}{#1}"),x("\\greenE","\\textcolor{##0d923f}{#1}"),x("\\goldA","\\textcolor{##ffd0a9}{#1}"),x("\\goldB","\\textcolor{##ffbb71}{#1}"),x("\\goldC","\\textcolor{##ff9c39}{#1}"),x("\\goldD","\\textcolor{##e07d10}{#1}"),x("\\goldE","\\textcolor{##a75a05}{#1}"),x("\\redA","\\textcolor{##fca9a9}{#1}"),x("\\redB","\\textcolor{##ff8482}{#1}"),x("\\redC","\\textcolor{##f9685d}{#1}"),x("\\redD","\\textcolor{##e84d39}{#1}"),x("\\redE","\\textcolor{##bc2612}{#1}"),x("\\maroonA","\\textcolor{##ffbde0}{#1}"),x("\\maroonB","\\textcolor{##ff92c6}{#1}"),x("\\maroonC","\\textcolor{##ed5fa6}{#1}"),x("\\maroonD","\\textcolor{##ca337c}{#1}"),x("\\maroonE","\\textcolor{##9e034e}{#1}"),x("\\purpleA","\\textcolor{##ddd7ff}{#1}"),x("\\purpleB","\\textcolor{##c6b9fc}{#1}"),x("\\purpleC","\\textcolor{##aa87ff}{#1}"),x("\\purpleD","\\textcolor{##7854ab}{#1}"),x("\\purpleE","\\textcolor{##543b78}{#1}"),x("\\mintA","\\textcolor{##f5f9e8}{#1}"),x("\\mintB","\\textcolor{##edf2df}{#1}"),x("\\mintC","\\textcolor{##e0e5cc}{#1}"),x("\\grayA","\\textcolor{##f6f7f7}{#1}"),x("\\grayB","\\textcolor{##f0f1f2}{#1}"),x("\\grayC","\\textcolor{##e3e5e6}{#1}"),x("\\grayD","\\textcolor{##d6d8da}{#1}"),x("\\grayE","\\textcolor{##babec2}{#1}"),x("\\grayF","\\textcolor{##888d93}{#1}"),x("\\grayG","\\textcolor{##626569}{#1}"),x("\\grayH","\\textcolor{##3b3e40}{#1}"),x("\\grayI","\\textcolor{##21242c}{#1}"),x("\\kaBlue","\\textcolor{##314453}{#1}"),x("\\kaGreen","\\textcolor{##71B307}{#1}");var Lm={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class aL{constructor(e,r,n){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=r,this.expansionCount=0,this.feed(e),this.macros=new nL(iL,r.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Tm(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&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){var r,n,i;if(e){if(this.consumeSpaces(),this.future().text!=="[")return null;r=this.popToken(),{tokens:i,end:n}=this.consumeArg(["]"])}else({tokens:i,start:r,end:n}=this.consumeArg());return this.pushToken(new sn("EOF",n.loc)),this.pushTokens(i),r.range(n,"")}consumeSpaces(){for(;;){var e=this.future();if(e.text===" ")this.stack.pop();else break}}consumeArg(e){var r=[],n=e&&e.length>0;n||this.consumeSpaces();var i=this.future(),a,s=0,o=0;do{if(a=this.popToken(),r.push(a),a.text==="{")++s;else if(a.text==="}"){if(--s,s===-1)throw new tt("Extra }",a)}else if(a.text==="EOF")throw new tt("Unexpected end of input in a macro argument, expected '"+(e&&n?e[o]:"}")+"'",a);if(e&&n)if((s===0||s===1&&e[o]==="{")&&a.text===e[o]){if(++o,o===e.length){r.splice(-o,o);break}}else o=0}while(s!==0||n);return i.text==="{"&&r[r.length-1].text==="}"&&(r.pop(),r.shift()),r.reverse(),{tokens:r,start:i,end:a}}consumeArgs(e,r){if(r){if(r.length!==e+1)throw new tt("The length of delimiters doesn't match the number of args!");for(var n=r[0],i=0;i this.settings.maxExpand)throw new tt("Too many expansions: infinite loop or need to increase maxExpand setting");var a=i.tokens,s=this.consumeArgs(i.numArgs,i.delimiters);if(i.numArgs){a=a.slice();for(var o=a.length-1;o>=0;--o){var l=a[o];if(l.text==="#"){if(o===0)throw new tt("Incomplete placeholder at end of macro body",l);if(l=a[--o],l.text==="#")a.splice(o+1,1);else if(/^[1-9]$/.test(l.text))a.splice(o,2,...s[+l.text-1]);else throw new tt("Not a valid argument number",l)}}}return this.pushTokens(a),a.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}throw new Error}expandMacro(e){return this.macros.has(e)?this.expandTokens([new sn(e)]):void 0}expandTokens(e){var r=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var i=this.stack.pop();i.treatAsRelax&&(i.noexpand=!1,i.treatAsRelax=!1),r.push(i)}return r}expandMacroAsText(e){var r=this.expandMacro(e);return r&&r.map(n=>n.text).join("")}_getExpansion(e){var r=this.macros.get(e);if(r==null)return r;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var i=typeof r=="function"?r(this):r;if(typeof i=="string"){var a=0;if(i.indexOf("#")!==-1)for(var s=i.replace(/##/g,"");s.indexOf("#"+(a+1))!==-1;)++a;for(var o=new Tm(i,this.settings),l=[],u=o.lex();u.text!=="EOF";)l.push(u),u=o.lex();l.reverse();var c={tokens:l,numArgs:a};return c}return i}isDefined(e){return this.macros.has(e)||ei.hasOwnProperty(e)||re.math.hasOwnProperty(e)||re.text.hasOwnProperty(e)||Lm.hasOwnProperty(e)}isExpandable(e){var r=this.macros.get(e);return r!=null?typeof r=="string"||typeof r=="function"||!r.unexpandable:ei.hasOwnProperty(e)&&!ei[e].primitive}}var Mm=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,To=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),gc={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},Dm={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};class ms{constructor(e,r){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 aL(e,r,this.mode),this.settings=r,this.leftrightDepth=0}expect(e,r){if(r===void 0&&(r=!0),this.fetch().text!==e)throw new tt("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());r&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(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{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var r=this.nextToken;this.consume(),this.gullet.pushToken(new sn("}")),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect("}"),this.nextToken=r,n}parseExpression(e,r){for(var n=[];;){this.mode==="math"&&this.consumeSpaces();var i=this.fetch();if(ms.endOfExpression.indexOf(i.text)!==-1||r&&i.text===r||e&&ei[i.text]&&ei[i.text].infix)break;var a=this.parseAtom(r);if(a){if(a.type==="internal")continue}else break;n.push(a)}return this.mode==="text"&&this.formLigatures(n),this.handleInfixNodes(n)}handleInfixNodes(e){for(var r=-1,n,i=0;i =0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+r[0]+'" used in math mode',e);var o=re[this.mode][r].group,l=mr.range(e),u;if(jE.hasOwnProperty(o)){var c=o;u={type:"atom",mode:this.mode,family:c,loc:l,text:r}}else u={type:o,mode:this.mode,loc:l,text:r};s=u}else if(r.charCodeAt(0)>=128)this.settings.strict&&(lp(r.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+r[0]+'" used in math mode',e):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+r[0]+'"'+(" ("+r.charCodeAt(0)+")"),e)),s={type:"textord",mode:"text",loc:mr.range(e),text:r};else return null;if(this.consume(),a)for(var h=0;hassertEquals(200, $response->getStatusCode()); } + public function testToolbarStylesheetActionWithProfilerDisabled() + { + $urlGenerator = $this->createMock(UrlGeneratorInterface::class); + $twig = $this->createMock(Environment::class); + + $controller = new ProfilerController($urlGenerator, null, $twig, []); + + $this->expectException(NotFoundHttpException::class); + $this->expectExceptionMessage('The profiler must be enabled.'); + + $controller->toolbarStylesheetAction(); + } + + public function testToolbarStylesheetAction() + { + $kernel = new WebProfilerBundleKernel(); + $client = new KernelBrowser($kernel); + + $client->request('GET', '/_wdt/styles'); + + $response = $client->getResponse(); + + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('text/css; charset=UTF-8', $response->headers->get('Content-Type')); + $this->assertSame('max-age=600, private', $response->headers->get('Cache-Control')); + } + public static function getEmptyTokenCases() { return [ @@ -225,7 +252,7 @@ public function testSearchBarActionDefaultPage() $this->assertSame(200, $client->getResponse()->getStatusCode()); foreach (['ip', 'status_code', 'url', 'token', 'start', 'end'] as $searchCriteria) { - $this->assertSame('', $crawler->filter(sprintf('form input[name="%s"]', $searchCriteria))->text()); + $this->assertSame('', $crawler->filter(\sprintf('form input[name="%s"]', $searchCriteria))->text()); } } @@ -334,7 +361,7 @@ public function testSearchActionWithoutToken() $client->request('GET', '/_profiler/search?ip=&method=GET&status_code=&url=&token=&start=&end=&limit=10'); $this->assertStringContainsString('results found', $client->getResponse()->getContent()); - $this->assertStringContainsString(sprintf('%s', $token, $token), $client->getResponse()->getContent()); + $this->assertStringContainsString(\sprintf('%s', $token, $token), $client->getResponse()->getContent()); } public function testPhpinfoActionWithProfilerDisabled() diff --git a/Tests/Controller/RouterControllerTest.php b/Tests/Controller/RouterControllerTest.php new file mode 100644 index 00000000..07d5a073 --- /dev/null +++ b/Tests/Controller/RouterControllerTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\KernelBrowser; +use Symfony\Bundle\FrameworkBundle\Routing\Router; +use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Bundle\WebProfilerBundle\Tests\Functional\WebProfilerBundleKernel; +use Symfony\Component\DomCrawler\Crawler; +use Symfony\Component\Routing\Route; + +class RouterControllerTest extends WebTestCase +{ + public function testFalseNegativeTrace() + { + $path = '/foo/bar:123/baz'; + + $kernel = new WebProfilerBundleKernel(); + $client = new KernelBrowser($kernel); + $client->disableReboot(); + $client->getKernel()->boot(); + + /** @var Router $router */ + $router = $client->getContainer()->get('router'); + $router->getRouteCollection()->add('route1', new Route($path)); + + $client->request('GET', $path); + + $crawler = $client->request('GET', '/_profiler/latest?panel=router&type=request'); + + $matchedRouteCell = $crawler + ->filter('#router-logs .status-success td') + ->reduce(function (Crawler $td) use ($path): bool { + return $td->text() === $path; + }); + + $this->assertSame(1, $matchedRouteCell->count()); + } +} diff --git a/Tests/DependencyInjection/WebProfilerExtensionTest.php b/Tests/DependencyInjection/WebProfilerExtensionTest.php index 3ec1756d..490bc91e 100644 --- a/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -23,8 +23,11 @@ use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector; use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\HttpKernel\Profiler\ProfilerStorageInterface; +use Symfony\Component\Routing\RequestContext; +use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouterInterface; use Twig\Environment; use Twig\Loader\ArrayLoader; @@ -54,19 +57,13 @@ public static function assertSaneContainer(Container $container) protected function setUp(): void { - parent::setUp(); - $this->kernel = $this->createMock(KernelInterface::class); - $profiler = $this->createMock(Profiler::class); - $profilerStorage = $this->createMock(ProfilerStorageInterface::class); - $router = $this->createMock(RouterInterface::class); - $this->container = new ContainerBuilder(); $this->container->register('data_collector.dump', DumpDataCollector::class)->setPublic(true); $this->container->register('error_handler.error_renderer.html', HtmlErrorRenderer::class)->setPublic(true); $this->container->register('event_dispatcher', EventDispatcher::class)->setPublic(true); - $this->container->register('router', $router::class)->setPublic(true); + $this->container->register('router', Router::class)->setPublic(true); $this->container->register('twig', Environment::class)->setPublic(true); $this->container->register('twig_loader', ArrayLoader::class)->addArgument([])->setPublic(true); $this->container->register('twig', Environment::class)->addArgument(new Reference('twig_loader'))->setPublic(true); @@ -78,9 +75,9 @@ protected function setUp(): void $this->container->setParameter('kernel.charset', 'UTF-8'); $this->container->setParameter('debug.file_link_format', null); $this->container->setParameter('profiler.class', [Profiler::class]); - $this->container->register('profiler', $profiler::class) + $this->container->register('profiler', Profiler::class) ->setPublic(true) - ->addArgument(new Definition($profilerStorage::class)); + ->addArgument(new Definition(NullProfilerStorage::class)); $this->container->setParameter('data_collector.templates', []); $this->container->set('kernel', $this->kernel); $this->container->addCompilerPass(new RegisterListenersPass()); @@ -88,8 +85,6 @@ protected function setUp(): void protected function tearDown(): void { - parent::tearDown(); - $this->container = null; } @@ -158,7 +153,7 @@ public function testToolbarConfigUsingInterceptRedirects( bool $toolbarEnabled, bool $interceptRedirects, bool $listenerInjected, - bool $listenerEnabled + bool $listenerEnabled, ) { $extension = new WebProfilerExtension(); $extension->load( @@ -179,11 +174,11 @@ public function testToolbarConfigUsingInterceptRedirects( public static function getInterceptRedirectsToolbarConfig() { return [ - [ - 'toolbarEnabled' => false, - 'interceptRedirects' => true, - 'listenerInjected' => true, - 'listenerEnabled' => false, + [ + 'toolbarEnabled' => false, + 'interceptRedirects' => true, + 'listenerInjected' => true, + 'listenerEnabled' => false, ], [ 'toolbarEnabled' => false, @@ -211,3 +206,54 @@ private function getCompiledContainer() return $this->container; } } + +class Router implements RouterInterface +{ + private $context; + + public function setContext(RequestContext $context): void + { + $this->context = $context; + } + + public function getContext(): RequestContext + { + return $this->context; + } + + public function getRouteCollection(): RouteCollection + { + return new RouteCollection(); + } + + public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string + { + } + + public function match(string $pathinfo): array + { + return []; + } +} + +class NullProfilerStorage implements ProfilerStorageInterface +{ + public function find(?string $ip, ?string $url, ?int $limit, ?string $method, ?int $start = null, ?int $end = null, ?string $statusCode = null, ?\Closure $filter = null): array + { + return []; + } + + public function read(string $token): ?Profile + { + return null; + } + + public function write(Profile $profile): bool + { + return true; + } + + public function purge(): void + { + } +} diff --git a/Tests/EventListener/WebDebugToolbarListenerTest.php b/Tests/EventListener/WebDebugToolbarListenerTest.php index 33bf1a32..cf3c1892 100644 --- a/Tests/EventListener/WebDebugToolbarListenerTest.php +++ b/Tests/EventListener/WebDebugToolbarListenerTest.php @@ -63,6 +63,7 @@ public static function getInjectToolbarTests() public function testHtmlRedirectionIsIntercepted($statusCode) { $response = new Response('Some content', $statusCode); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response); @@ -76,6 +77,7 @@ public function testHtmlRedirectionIsIntercepted($statusCode) public function testNonHtmlRedirectionIsNotIntercepted() { $response = new Response('Some content', '301'); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response); @@ -139,6 +141,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment() public function testToolbarIsNotInjectedOnRedirection($statusCode) { $response = new Response('', $statusCode); + $response->headers->set('Location', 'https://example.com/'); $response->headers->set('X-Debug-Token', 'xxxxxxxx'); $event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response); diff --git a/Tests/Profiler/CodeExtensionTest.php b/Tests/Profiler/CodeExtensionTest.php index e10c01f6..7cdedfe8 100644 --- a/Tests/Profiler/CodeExtensionTest.php +++ b/Tests/Profiler/CodeExtensionTest.php @@ -21,7 +21,7 @@ class CodeExtensionTest extends TestCase { public function testFormatFile() { - $expected = sprintf('%s at line 25', substr(__FILE__, 5), __FILE__); + $expected = \sprintf('%s at line 25', substr(__FILE__, 5), __FILE__); $this->assertEquals($expected, $this->getExtension()->formatFile(__FILE__, 25)); } @@ -116,7 +116,6 @@ public function testFormatArgsIntegration() $this->assertEquals($expected, $this->render($template, $data)); } - public function testFormatFileIntegration() { $template = <<<'TWIG' diff --git a/Tests/Profiler/TemplateManagerTest.php b/Tests/Profiler/TemplateManagerTest.php index b837fc66..e5bf05b3 100644 --- a/Tests/Profiler/TemplateManagerTest.php +++ b/Tests/Profiler/TemplateManagerTest.php @@ -30,8 +30,6 @@ class TemplateManagerTest extends TestCase protected function setUp(): void { - parent::setUp(); - $this->profiler = $this->createMock(Profiler::class); $twigEnvironment = $this->mockTwigEnvironment(); $templates = [ diff --git a/Tests/Resources/IconTest.php b/Tests/Resources/IconTest.php index 8b9cf721..4cddbe0f 100644 --- a/Tests/Resources/IconTest.php +++ b/Tests/Resources/IconTest.php @@ -23,13 +23,13 @@ public function testIconFileContents($iconFilePath) $iconFilePath = realpath($iconFilePath); $svgFileContents = file_get_contents($iconFilePath); - $this->assertStringContainsString('xmlns="http://www.w3.org/2000/svg"', $svgFileContents, sprintf('The SVG metadata of the "%s" icon must use "http://www.w3.org/2000/svg" as its "xmlns" value.', $iconFilePath)); + $this->assertStringContainsString('xmlns="http://www.w3.org/2000/svg"', $svgFileContents, \sprintf('The SVG metadata of the "%s" icon must use "http://www.w3.org/2000/svg" as its "xmlns" value.', $iconFilePath)); - $this->assertMatchesRegularExpression('~~s', file_get_contents($iconFilePath), sprintf('The SVG file of the "%s" icon must include a "width" attribute.', $iconFilePath)); + $this->assertMatchesRegularExpression('~~s', file_get_contents($iconFilePath), \sprintf('The SVG file of the "%s" icon must include a "width" attribute.', $iconFilePath)); - $this->assertMatchesRegularExpression('~~s', file_get_contents($iconFilePath), sprintf('The SVG file of the "%s" icon must include a "height" attribute.', $iconFilePath)); + $this->assertMatchesRegularExpression('~~s', file_get_contents($iconFilePath), \sprintf('The SVG file of the "%s" icon must include a "height" attribute.', $iconFilePath)); - $this->assertMatchesRegularExpression('~~s', file_get_contents($iconFilePath), sprintf('The SVG file of the "%s" icon must include a "viewBox" attribute.', $iconFilePath)); + $this->assertMatchesRegularExpression('~~s', file_get_contents($iconFilePath), \sprintf('The SVG file of the "%s" icon must include a "viewBox" attribute.', $iconFilePath)); } public static function provideIconFilePaths(): array diff --git a/Twig/WebProfilerExtension.php b/Twig/WebProfilerExtension.php index 014e326b..6515d4ca 100644 --- a/Twig/WebProfilerExtension.php +++ b/Twig/WebProfilerExtension.php @@ -14,7 +14,6 @@ use Symfony\Component\VarDumper\Cloner\Data; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Twig\Environment; -use Twig\Extension\EscaperExtension; use Twig\Extension\ProfilerExtension; use Twig\Profiler\Profile; use Twig\Runtime\EscaperRuntime; @@ -109,17 +108,6 @@ public function getName(): string private static function escape(Environment $env, string $s): string { - // Twig 3.10 and above - if (class_exists(EscaperRuntime::class)) { - return $env->getRuntime(EscaperRuntime::class)->escape($s); - } - - // Twig 3.9 - if (method_exists(EscaperExtension::class, 'escape')) { - return EscaperExtension::escape($env, $s); - } - - // to be removed when support for Twig 3 is dropped - return twig_escape_filter($env, $s); + return $env->getRuntime(EscaperRuntime::class)->escape($s); } } diff --git a/composer.json b/composer.json index 2de2677c..ce94b4b6 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "symfony/http-kernel": "^6.4|^7.0", "symfony/routing": "^6.4|^7.0", "symfony/twig-bundle": "^6.4|^7.0", - "twig/twig": "^3.0.4" + "twig/twig": "^3.12" }, "require-dev": { "symfony/browser-kit": "^6.4|^7.0", @@ -33,7 +33,8 @@ "conflict": { "symfony/form": "<6.4", "symfony/mailer": "<6.4", - "symfony/messenger": "<6.4" + "symfony/messenger": "<6.4", + "symfony/serializer": "<7.2" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebProfilerBundle\\": "" },