"use strict";
exports.id = 9924;
exports.ids = [9924];
exports.modules = {

/***/ 838176:
/***/ ((__unused_webpack_module, exports) => {


/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.macros = void 0;
// get these from sage/misc/latex.py
// Similar info is **also** embedded in packages/util/mathjax-config.js
exports.macros = {
    "\\Bold": "\\mathbb{#1}",
    "\\ZZ": "\\Bold{Z}",
    "\\NN": "\\Bold{N}",
    "\\RR": "\\Bold{R}",
    "\\CC": "\\Bold{C}",
    "\\FF": "\\Bold{F}",
    "\\QQ": "\\Bold{Q}",
    "\\QQbar": "\\overline{\\QQ}",
    "\\CDF": "\\Bold{C}",
    "\\CIF": "\\Bold{C}",
    "\\CLF": "\\Bold{C}",
    "\\RDF": "\\Bold{R}",
    "\\RIF": "\\Bold{I} \\Bold{R}",
    "\\RLF": "\\Bold{R}",
    "\\CFF": "\\Bold{CFF}",
    "\\GF": "\\Bold{F}_{#1}",
    "\\Zp": "\\ZZ_{#1}",
    "\\Qp": "\\QQ_{#1}",
    "\\Zmod": "\\ZZ/#1\\ZZ",
    "\\mbox": "\\text",
    "\\DeclareMathOperator": "\\providecommand{#1}{\\operatorname{#2}}", // see https://github.com/sagemathinc/cocalc/issues/6179#issuecomment-1280002052
};
//# sourceMappingURL=math-katex.js.map

/***/ }),

/***/ 496780:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {


/*
Unfortunately KaTeX doesn't support everything people are used to using
with MathJax, even if they "shouldn't use it".   See the long list at

https://katex.org/docs/support_table.html

In some cases we can work around this by defining macros, e.g., \mbox = \text,
which we do at

    src/packages/frontend/jquery-plugins/math-katex.ts

This file below contains horrible hacks to add additional functionality.
They could lead to breakage in weird edge cases, in theory.
*/
Object.defineProperty(exports, "__esModule", ({ value: true }));
const misc_1 = __webpack_require__(477389);
function KaTeXCompatHacks(math) {
    math = eqnarray(math);
    return math;
}
exports["default"] = KaTeXCompatHacks;
// Support eqnarray: https://github.com/KaTeX/KaTeX/issues/3643
// This is very close: "\begin{darray}{rcl} ... \end{darray}"
function eqnarray(math) {
    if (!math.includes("\\begin{eqnarray"))
        return math;
    // Note that darray never has equation numbers in katex as far as i can tell...
    math = (0, misc_1.replace_all)(math, "\\begin{eqnarray}", "\\begin{darray}{rcl}");
    math = (0, misc_1.replace_all)(math, "\\end{eqnarray}", "\\end{darray}");
    math = (0, misc_1.replace_all)(math, "\\begin{eqnarray*}", "\\begin{darray}{rcl}");
    math = (0, misc_1.replace_all)(math, "\\end{eqnarray*}", "\\end{darray}");
    return math;
}
//# sourceMappingURL=katex-compat-hacks.js.map

/***/ }),

/***/ 749924:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.latexMathToHtmlOrError = exports.latexMathToHtml = void 0;
const math_katex_1 = __webpack_require__(838176);
const katex_1 = __importDefault(__webpack_require__(775654));
const katex_compat_hacks_1 = __importDefault(__webpack_require__(496780));
function mathToHtml(math, // latex expression
isInline, _ignore = undefined // used internally to avoid infinite recursion.
) {
    if (!math.trim()) {
        // don't let it be empty, since then it is not possible to see/select.
        math = "\\LaTeX";
    }
    // Apply some hacks to deal with missing functionality in katex.
    math = (0, katex_compat_hacks_1.default)(math);
    let err = undefined;
    let html = undefined;
    try {
        html = katex_1.default.renderToString(math, {
            displayMode: !isInline,
            macros: math_katex_1.macros,
            globalGroup: true, // See https://github.com/sagemathinc/cocalc/issues/5750
        });
    }
    catch (error) {
        // If you are working interactively, e.g., in a notebook or md file, you might change a macro
        // you have already defined.  Unfortunately, katex/latex assumes you're processing the whole document
        // top to bottom from a clean slate every time.  For iterative work that makes no sense.  Thus we
        // automate changing newcommand into renewcommand, as needed, with an escape hatch to avoid an
        // infinite loop.  NOTE: if you redefine a macro, all other formulas that depend on it do not automatically
        // get rerendered, so you do have to edit them slightly or close/open the document to see the changes.
        // But at least this is a good first step.  Also, with this approach you still do see an error if
        // try to define something like \lt that is built in!  There you should use \renewcommand explicitly.
        // Parsing this also helps with opening files in separate tabs, where the same macros get defined.
        // TODO: See https://github.com/KaTeX/KaTeX/blob/main/src/macros.js for how to do this much better!
        // We can probably just slightly monkey patch how newcommand works... or something.
        err = error.toString();
        if (err?.endsWith("use \\renewcommand")) {
            const i = err.indexOf("redefine ");
            const j = err.lastIndexOf(";");
            const name = err.slice(i + "redefine ".length, j);
            if (!_ignore?.has(name) && math_katex_1.macros[name] != null) {
                math = math.replace("\\newcommand{" + name, "\\renewcommand{" + name);
                return mathToHtml(math, isInline, _ignore != null ? _ignore.add(name) : new Set([name]));
            }
        }
    }
    return { __html: html ?? "", err };
}
exports["default"] = mathToHtml;
function latexMathToHtml(s) {
    const { __html, err } = s.startsWith("$$")
        ? mathToHtml(s.slice(2, s.length - 2), false)
        : s.startsWith("$")
            ? mathToHtml(s.slice(1, s.length - 1), true)
            : mathToHtml(s, false);
    if (err) {
        return `<span style="color:#ff6666">${err}</span>`;
    }
    else {
        return __html;
    }
}
exports.latexMathToHtml = latexMathToHtml;
function latexMathToHtmlOrError(s) {
    return s.startsWith("$$")
        ? mathToHtml(s.slice(2, s.length - 2), false)
        : s.startsWith("$")
            ? mathToHtml(s.slice(1, s.length - 1), true)
            : mathToHtml(s, false);
}
exports.latexMathToHtmlOrError = latexMathToHtmlOrError;
//# sourceMappingURL=math-to-html.js.map

/***/ })

};
;