@parcility/kennel
Version:
A comprehensive, easy-to-use native depiction renderer.
1,196 lines • 500 kB
JavaScript
var ti = Object.defineProperty;
var ni = (r, t, e) => t in r ? ti(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
var o = (r, t, e) => (ni(r, typeof t != "symbol" ? t + "" : t, e), e);
/*! @license DOMPurify 2.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.0/LICENSE */
function oe(r) {
return oe = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
return typeof t;
} : function(t) {
return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, oe(r);
}
function ft(r, t) {
return ft = Object.setPrototypeOf || function(n, i) {
return n.__proto__ = i, n;
}, ft(r, t);
}
function ii() {
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
return !1;
if (typeof Proxy == "function")
return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch {
return !1;
}
}
function Pe(r, t, e) {
return ii() ? Pe = Reflect.construct : Pe = function(i, s, l) {
var c = [null];
c.push.apply(c, s);
var h = Function.bind.apply(i, c), w = new h();
return l && ft(w, l.prototype), w;
}, Pe.apply(null, arguments);
}
function Z(r) {
return ri(r) || si(r) || ai(r) || li();
}
function ri(r) {
if (Array.isArray(r))
return mt(r);
}
function si(r) {
if (typeof Symbol < "u" && r[Symbol.iterator] != null || r["@@iterator"] != null)
return Array.from(r);
}
function ai(r, t) {
if (!!r) {
if (typeof r == "string")
return mt(r, t);
var e = Object.prototype.toString.call(r).slice(8, -1);
if (e === "Object" && r.constructor && (e = r.constructor.name), e === "Map" || e === "Set")
return Array.from(r);
if (e === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))
return mt(r, t);
}
}
function mt(r, t) {
(t == null || t > r.length) && (t = r.length);
for (var e = 0, n = new Array(t); e < t; e++)
n[e] = r[e];
return n;
}
function li() {
throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var oi = Object.hasOwnProperty, Xt = Object.setPrototypeOf, ci = Object.isFrozen, ui = Object.getPrototypeOf, hi = Object.getOwnPropertyDescriptor, H = Object.freeze, te = Object.seal, pi = Object.create, pn = typeof Reflect < "u" && Reflect, Be = pn.apply, gt = pn.construct;
Be || (Be = function(t, e, n) {
return t.apply(e, n);
});
H || (H = function(t) {
return t;
});
te || (te = function(t) {
return t;
});
gt || (gt = function(t, e) {
return Pe(t, Z(e));
});
var fi = Y(Array.prototype.forEach), Kt = Y(Array.prototype.pop), Ae = Y(Array.prototype.push), Ue = Y(String.prototype.toLowerCase), mi = Y(String.prototype.match), le = Y(String.prototype.replace), gi = Y(String.prototype.indexOf), di = Y(String.prototype.trim), B = Y(RegExp.prototype.test), ot = bi(TypeError);
function Y(r) {
return function(t) {
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), i = 1; i < e; i++)
n[i - 1] = arguments[i];
return Be(r, t, n);
};
}
function bi(r) {
return function() {
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
e[n] = arguments[n];
return gt(r, e);
};
}
function x(r, t, e) {
e = e || Ue, Xt && Xt(r, null);
for (var n = t.length; n--; ) {
var i = t[n];
if (typeof i == "string") {
var s = e(i);
s !== i && (ci(t) || (t[n] = s), i = s);
}
r[i] = !0;
}
return r;
}
function he(r) {
var t = pi(null), e;
for (e in r)
Be(oi, r, [e]) && (t[e] = r[e]);
return t;
}
function Oe(r, t) {
for (; r !== null; ) {
var e = hi(r, t);
if (e) {
if (e.get)
return Y(e.get);
if (typeof e.value == "function")
return Y(e.value);
}
r = ui(r);
}
function n(i) {
return console.warn("fallback value for", i), null;
}
return n;
}
var Jt = H(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), ct = H(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), ut = H(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), wi = H(["animate", "color-profile", "cursor", "discard", "fedropshadow", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), ht = H(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover"]), ki = H(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), en = H(["#text"]), tn = H(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "xmlns", "slot"]), pt = H(["accent-height", "accumulate", "additive", "alignment-baseline", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), nn = H(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), ze = H(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), xi = te(/\{\{[\w\W]*|[\w\W]*\}\}/gm), yi = te(/<%[\w\W]*|[\w\W]*%>/gm), vi = te(/^data-[\-\w.\u00B7-\uFFFF]/), _i = te(/^aria-[\-\w]+$/), Ti = te(
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
), Ai = te(/^(?:\w+script|data):/i), Ei = te(
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
), Si = te(/^html$/i), Ri = function() {
return typeof window > "u" ? null : window;
}, Di = function(t, e) {
if (oe(t) !== "object" || typeof t.createPolicy != "function")
return null;
var n = null, i = "data-tt-policy-suffix";
e.currentScript && e.currentScript.hasAttribute(i) && (n = e.currentScript.getAttribute(i));
var s = "dompurify" + (n ? "#" + n : "");
try {
return t.createPolicy(s, {
createHTML: function(c) {
return c;
},
createScriptURL: function(c) {
return c;
}
});
} catch {
return console.warn("TrustedTypes policy " + s + " could not be created."), null;
}
};
function fn() {
var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Ri(), t = function(a) {
return fn(a);
};
if (t.version = "2.4.0", t.removed = [], !r || !r.document || r.document.nodeType !== 9)
return t.isSupported = !1, t;
var e = r.document, n = r.document, i = r.DocumentFragment, s = r.HTMLTemplateElement, l = r.Node, c = r.Element, h = r.NodeFilter, w = r.NamedNodeMap, b = w === void 0 ? r.NamedNodeMap || r.MozNamedAttrMap : w, F = r.HTMLFormElement, T = r.DOMParser, g = r.trustedTypes, j = c.prototype, G = Oe(j, "cloneNode"), X = Oe(j, "nextSibling"), S = Oe(j, "childNodes"), R = Oe(j, "parentNode");
if (typeof s == "function") {
var ne = n.createElement("template");
ne.content && ne.content.ownerDocument && (n = ne.content.ownerDocument);
}
var I = Di(g, e), q = I ? I.createHTML("") : "", V = n, K = V.implementation, ce = V.createNodeIterator, Ge = V.createDocumentFragment, Hn = V.getElementsByTagName, Vn = e.importNode, Dt = {};
try {
Dt = he(n).documentMode ? n.documentMode : {};
} catch {
}
var J = {};
t.isSupported = typeof R == "function" && K && typeof K.createHTMLDocument < "u" && Dt !== 9;
var qe = xi, je = yi, Wn = vi, Gn = _i, qn = Ai, Ct = Ei, Ze = Ti, L = null, It = x({}, [].concat(Z(Jt), Z(ct), Z(ut), Z(ht), Z(en))), O = null, Lt = x({}, [].concat(Z(tn), Z(pt), Z(nn), Z(ze))), C = Object.seal(Object.create(null, {
tagNameCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
attributeNameCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
allowCustomizedBuiltInElements: {
writable: !0,
configurable: !1,
enumerable: !0,
value: !1
}
})), ve = null, Ye = null, Nt = !0, Qe = !0, Mt = !1, pe = !1, ue = !1, Xe = !1, Ke = !1, fe = !1, Ce = !1, Ie = !1, Ot = !0, zt = !1, jn = "user-content-", Je = !0, _e = !1, me = {}, ge = null, $t = x({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]), Pt = null, Ut = x({}, ["audio", "video", "img", "source", "image", "track"]), et = null, Ft = x({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), tt = "http://www.w3.org/1998/Math/MathML", nt = "http://www.w3.org/2000/svg", ae = "http://www.w3.org/1999/xhtml", Le = ae, it = !1, de, Zn = ["application/xhtml+xml", "text/html"], Yn = "text/html", N, be = null, Qn = n.createElement("form"), Bt = function(a) {
return a instanceof RegExp || a instanceof Function;
}, rt = function(a) {
be && be === a || ((!a || oe(a) !== "object") && (a = {}), a = he(a), de = Zn.indexOf(a.PARSER_MEDIA_TYPE) === -1 ? de = Yn : de = a.PARSER_MEDIA_TYPE, N = de === "application/xhtml+xml" ? function(u) {
return u;
} : Ue, L = "ALLOWED_TAGS" in a ? x({}, a.ALLOWED_TAGS, N) : It, O = "ALLOWED_ATTR" in a ? x({}, a.ALLOWED_ATTR, N) : Lt, et = "ADD_URI_SAFE_ATTR" in a ? x(
he(Ft),
a.ADD_URI_SAFE_ATTR,
N
) : Ft, Pt = "ADD_DATA_URI_TAGS" in a ? x(
he(Ut),
a.ADD_DATA_URI_TAGS,
N
) : Ut, ge = "FORBID_CONTENTS" in a ? x({}, a.FORBID_CONTENTS, N) : $t, ve = "FORBID_TAGS" in a ? x({}, a.FORBID_TAGS, N) : {}, Ye = "FORBID_ATTR" in a ? x({}, a.FORBID_ATTR, N) : {}, me = "USE_PROFILES" in a ? a.USE_PROFILES : !1, Nt = a.ALLOW_ARIA_ATTR !== !1, Qe = a.ALLOW_DATA_ATTR !== !1, Mt = a.ALLOW_UNKNOWN_PROTOCOLS || !1, pe = a.SAFE_FOR_TEMPLATES || !1, ue = a.WHOLE_DOCUMENT || !1, fe = a.RETURN_DOM || !1, Ce = a.RETURN_DOM_FRAGMENT || !1, Ie = a.RETURN_TRUSTED_TYPE || !1, Ke = a.FORCE_BODY || !1, Ot = a.SANITIZE_DOM !== !1, zt = a.SANITIZE_NAMED_PROPS || !1, Je = a.KEEP_CONTENT !== !1, _e = a.IN_PLACE || !1, Ze = a.ALLOWED_URI_REGEXP || Ze, Le = a.NAMESPACE || ae, a.CUSTOM_ELEMENT_HANDLING && Bt(a.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (C.tagNameCheck = a.CUSTOM_ELEMENT_HANDLING.tagNameCheck), a.CUSTOM_ELEMENT_HANDLING && Bt(a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (C.attributeNameCheck = a.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), a.CUSTOM_ELEMENT_HANDLING && typeof a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (C.allowCustomizedBuiltInElements = a.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), pe && (Qe = !1), Ce && (fe = !0), me && (L = x({}, Z(en)), O = [], me.html === !0 && (x(L, Jt), x(O, tn)), me.svg === !0 && (x(L, ct), x(O, pt), x(O, ze)), me.svgFilters === !0 && (x(L, ut), x(O, pt), x(O, ze)), me.mathMl === !0 && (x(L, ht), x(O, nn), x(O, ze))), a.ADD_TAGS && (L === It && (L = he(L)), x(L, a.ADD_TAGS, N)), a.ADD_ATTR && (O === Lt && (O = he(O)), x(O, a.ADD_ATTR, N)), a.ADD_URI_SAFE_ATTR && x(et, a.ADD_URI_SAFE_ATTR, N), a.FORBID_CONTENTS && (ge === $t && (ge = he(ge)), x(ge, a.FORBID_CONTENTS, N)), Je && (L["#text"] = !0), ue && x(L, ["html", "head", "body"]), L.table && (x(L, ["tbody"]), delete ve.tbody), H && H(a), be = a);
}, Ht = x({}, ["mi", "mo", "mn", "ms", "mtext"]), Vt = x({}, ["foreignobject", "desc", "title", "annotation-xml"]), Xn = x({}, ["title", "style", "font", "a", "script"]), Ne = x({}, ct);
x(Ne, ut), x(Ne, wi);
var st = x({}, ht);
x(st, ki);
var Kn = function(a) {
var u = R(a);
(!u || !u.tagName) && (u = {
namespaceURI: ae,
tagName: "template"
});
var p = Ue(a.tagName), v = Ue(u.tagName);
return a.namespaceURI === nt ? u.namespaceURI === ae ? p === "svg" : u.namespaceURI === tt ? p === "svg" && (v === "annotation-xml" || Ht[v]) : Boolean(Ne[p]) : a.namespaceURI === tt ? u.namespaceURI === ae ? p === "math" : u.namespaceURI === nt ? p === "math" && Vt[v] : Boolean(st[p]) : a.namespaceURI === ae ? u.namespaceURI === nt && !Vt[v] || u.namespaceURI === tt && !Ht[v] ? !1 : !st[p] && (Xn[p] || !Ne[p]) : !1;
}, ie = function(a) {
Ae(t.removed, {
element: a
});
try {
a.parentNode.removeChild(a);
} catch {
try {
a.outerHTML = q;
} catch {
a.remove();
}
}
}, at = function(a, u) {
try {
Ae(t.removed, {
attribute: u.getAttributeNode(a),
from: u
});
} catch {
Ae(t.removed, {
attribute: null,
from: u
});
}
if (u.removeAttribute(a), a === "is" && !O[a])
if (fe || Ce)
try {
ie(u);
} catch {
}
else
try {
u.setAttribute(a, "");
} catch {
}
}, Wt = function(a) {
var u, p;
if (Ke)
a = "<remove></remove>" + a;
else {
var v = mi(a, /^[\r\n\t ]+/);
p = v && v[0];
}
de === "application/xhtml+xml" && (a = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + a + "</body></html>");
var W = I ? I.createHTML(a) : a;
if (Le === ae)
try {
u = new T().parseFromString(W, de);
} catch {
}
if (!u || !u.documentElement) {
u = K.createDocument(Le, "template", null);
try {
u.documentElement.innerHTML = it ? "" : W;
} catch {
}
}
var P = u.body || u.documentElement;
return a && p && P.insertBefore(n.createTextNode(p), P.childNodes[0] || null), Le === ae ? Hn.call(u, ue ? "html" : "body")[0] : ue ? u.documentElement : P;
}, Gt = function(a) {
return ce.call(
a.ownerDocument || a,
a,
h.SHOW_ELEMENT | h.SHOW_COMMENT | h.SHOW_TEXT,
null,
!1
);
}, Jn = function(a) {
return a instanceof F && (typeof a.nodeName != "string" || typeof a.textContent != "string" || typeof a.removeChild != "function" || !(a.attributes instanceof b) || typeof a.removeAttribute != "function" || typeof a.setAttribute != "function" || typeof a.namespaceURI != "string" || typeof a.insertBefore != "function");
}, Te = function(a) {
return oe(l) === "object" ? a instanceof l : a && oe(a) === "object" && typeof a.nodeType == "number" && typeof a.nodeName == "string";
}, re = function(a, u, p) {
!J[a] || fi(J[a], function(v) {
v.call(t, u, p, be);
});
}, qt = function(a) {
var u;
if (re("beforeSanitizeElements", a, null), Jn(a) || B(/[\u0080-\uFFFF]/, a.nodeName))
return ie(a), !0;
var p = N(a.nodeName);
if (re("uponSanitizeElement", a, {
tagName: p,
allowedTags: L
}), a.hasChildNodes() && !Te(a.firstElementChild) && (!Te(a.content) || !Te(a.content.firstElementChild)) && B(/<[/\w]/g, a.innerHTML) && B(/<[/\w]/g, a.textContent) || p === "select" && B(/<template/i, a.innerHTML))
return ie(a), !0;
if (!L[p] || ve[p]) {
if (!ve[p] && Zt(p) && (C.tagNameCheck instanceof RegExp && B(C.tagNameCheck, p) || C.tagNameCheck instanceof Function && C.tagNameCheck(p)))
return !1;
if (Je && !ge[p]) {
var v = R(a) || a.parentNode, W = S(a) || a.childNodes;
if (W && v)
for (var P = W.length, z = P - 1; z >= 0; --z)
v.insertBefore(G(W[z], !0), X(a));
}
return ie(a), !0;
}
return a instanceof c && !Kn(a) || (p === "noscript" || p === "noembed") && B(/<\/no(script|embed)/i, a.innerHTML) ? (ie(a), !0) : (pe && a.nodeType === 3 && (u = a.textContent, u = le(u, qe, " "), u = le(u, je, " "), a.textContent !== u && (Ae(t.removed, {
element: a.cloneNode()
}), a.textContent = u)), re("afterSanitizeElements", a, null), !1);
}, jt = function(a, u, p) {
if (Ot && (u === "id" || u === "name") && (p in n || p in Qn))
return !1;
if (!(Qe && !Ye[u] && B(Wn, u))) {
if (!(Nt && B(Gn, u))) {
if (!O[u] || Ye[u]) {
if (!(Zt(a) && (C.tagNameCheck instanceof RegExp && B(C.tagNameCheck, a) || C.tagNameCheck instanceof Function && C.tagNameCheck(a)) && (C.attributeNameCheck instanceof RegExp && B(C.attributeNameCheck, u) || C.attributeNameCheck instanceof Function && C.attributeNameCheck(u)) || u === "is" && C.allowCustomizedBuiltInElements && (C.tagNameCheck instanceof RegExp && B(C.tagNameCheck, p) || C.tagNameCheck instanceof Function && C.tagNameCheck(p))))
return !1;
} else if (!et[u]) {
if (!B(Ze, le(p, Ct, ""))) {
if (!((u === "src" || u === "xlink:href" || u === "href") && a !== "script" && gi(p, "data:") === 0 && Pt[a])) {
if (!(Mt && !B(qn, le(p, Ct, "")))) {
if (p)
return !1;
}
}
}
}
}
}
return !0;
}, Zt = function(a) {
return a.indexOf("-") > 0;
}, Yt = function(a) {
var u, p, v, W;
re("beforeSanitizeAttributes", a, null);
var P = a.attributes;
if (!!P) {
var z = {
attrName: "",
attrValue: "",
keepAttr: !0,
allowedAttributes: O
};
for (W = P.length; W--; ) {
u = P[W];
var Me = u, U = Me.name, lt = Me.namespaceURI;
if (p = U === "value" ? u.value : di(u.value), v = N(U), z.attrName = v, z.attrValue = p, z.keepAttr = !0, z.forceKeepAttr = void 0, re("uponSanitizeAttribute", a, z), p = z.attrValue, !z.forceKeepAttr && (at(U, a), !!z.keepAttr)) {
if (B(/\/>/i, p)) {
at(U, a);
continue;
}
pe && (p = le(p, qe, " "), p = le(p, je, " "));
var Qt = N(a.nodeName);
if (!!jt(Qt, v, p)) {
if (zt && (v === "id" || v === "name") && (at(U, a), p = jn + p), I && oe(g) === "object" && typeof g.getAttributeType == "function" && !lt)
switch (g.getAttributeType(Qt, v)) {
case "TrustedHTML":
p = I.createHTML(p);
break;
case "TrustedScriptURL":
p = I.createScriptURL(p);
break;
}
try {
lt ? a.setAttributeNS(lt, U, p) : a.setAttribute(U, p), Kt(t.removed);
} catch {
}
}
}
}
re("afterSanitizeAttributes", a, null);
}
}, ei = function m(a) {
var u, p = Gt(a);
for (re("beforeSanitizeShadowDOM", a, null); u = p.nextNode(); )
re("uponSanitizeShadowNode", u, null), !qt(u) && (u.content instanceof i && m(u.content), Yt(u));
re("afterSanitizeShadowDOM", a, null);
};
return t.sanitize = function(m) {
var a = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, u, p, v, W, P;
if (it = !m, it && (m = "<!-->"), typeof m != "string" && !Te(m)) {
if (typeof m.toString != "function")
throw ot("toString is not a function");
if (m = m.toString(), typeof m != "string")
throw ot("dirty is not a string, aborting");
}
if (!t.isSupported) {
if (oe(r.toStaticHTML) === "object" || typeof r.toStaticHTML == "function") {
if (typeof m == "string")
return r.toStaticHTML(m);
if (Te(m))
return r.toStaticHTML(m.outerHTML);
}
return m;
}
if (Xe || rt(a), t.removed = [], typeof m == "string" && (_e = !1), _e) {
if (m.nodeName) {
var z = N(m.nodeName);
if (!L[z] || ve[z])
throw ot("root node is forbidden and cannot be sanitized in-place");
}
} else if (m instanceof l)
u = Wt("<!---->"), p = u.ownerDocument.importNode(m, !0), p.nodeType === 1 && p.nodeName === "BODY" || p.nodeName === "HTML" ? u = p : u.appendChild(p);
else {
if (!fe && !pe && !ue && m.indexOf("<") === -1)
return I && Ie ? I.createHTML(m) : m;
if (u = Wt(m), !u)
return fe ? null : Ie ? q : "";
}
u && Ke && ie(u.firstChild);
for (var Me = Gt(_e ? m : u); v = Me.nextNode(); )
v.nodeType === 3 && v === W || qt(v) || (v.content instanceof i && ei(v.content), Yt(v), W = v);
if (W = null, _e)
return m;
if (fe) {
if (Ce)
for (P = Ge.call(u.ownerDocument); u.firstChild; )
P.appendChild(u.firstChild);
else
P = u;
return O.shadowroot && (P = Vn.call(e, P, !0)), P;
}
var U = ue ? u.outerHTML : u.innerHTML;
return ue && L["!doctype"] && u.ownerDocument && u.ownerDocument.doctype && u.ownerDocument.doctype.name && B(Si, u.ownerDocument.doctype.name) && (U = "<!DOCTYPE " + u.ownerDocument.doctype.name + `>
` + U), pe && (U = le(U, qe, " "), U = le(U, je, " ")), I && Ie ? I.createHTML(U) : U;
}, t.setConfig = function(m) {
rt(m), Xe = !0;
}, t.clearConfig = function() {
be = null, Xe = !1;
}, t.isValidAttribute = function(m, a, u) {
be || rt({});
var p = N(m), v = N(a);
return jt(p, v, u);
}, t.addHook = function(m, a) {
typeof a == "function" && (J[m] = J[m] || [], Ae(J[m], a));
}, t.removeHook = function(m) {
if (J[m])
return Kt(J[m]);
}, t.removeHooks = function(m) {
J[m] && (J[m] = []);
}, t.removeAllHooks = function() {
J = {};
}, t;
}
var rn = fn();
class D {
constructor(t) {
o(this, "tintColor");
t && (this.tintColor = ye(t.tintColor, "color"));
}
}
o(D, "viewName", "DepictionBaseView");
class mn extends D {
constructor(e) {
super(e);
o(this, "views", []);
o(this, "viewWidths");
o(this, "horizontalSpacing");
o(this, "backgroundColor");
let n = _(e.views, "array");
this.horizontalSpacing = _(e.horizontalSpacing, "number");
for (let i of n) {
_(i.class, "string"), _(i.preferredWidth, "number");
let s = ke(i);
if (!s)
throw new Error("Invalid view");
this.views.push(s);
}
this.viewWidths = n.map((i) => i.preferredWidth), this.backgroundColor = ye(e.backgroundColor, "color");
}
async make() {
let e = await De(this.views), n = y("div", { class: "nd-auto-stack" }, e), i = {
"grid-template-columns": this.viewWidths.map((s) => s + "px").join(" "),
"column-gap": this.horizontalSpacing
};
return this.backgroundColor && (i["background-color"] = this.backgroundColor), $(n, i), n;
}
}
o(mn, "viewName", "DepictionAutoStackView");
class gn extends D {
constructor(e) {
super(e);
o(this, "text");
o(this, "children");
o(this, "action");
o(this, "isLink");
o(this, "yPadding");
o(this, "openExternal");
this.isLink = A(e.isLink, "boolean", !1), this.yPadding = A(e.yPadding, "number", 0), this.action = _(e.action, "string"), this.openExternal = A(e.openExternal, "boolean", !1);
let n = e.view;
if (typeof n == "object" && (this.children = ke(n)), !this.children) {
let i = e.text;
typeof i == "string" && (this.text = i);
}
}
async make() {
let e = y("a");
We(e, ["nd-button", this.isLink ? "nd-button-link" : "nd-button-not-link"]);
let n = {};
if (this.tintColor && (n["--kennel-tint-color"] = this.tintColor), Pn(e, this.action, this.text), this.isLink ? n.color = "var(--kennel-tint-color)" : (n["background-color"] = "var(--kennel-tint-color)", n.color = "white"), this.openExternal && (e.attributes.target = "_blank"), this.children) {
this.children;
let i = await xe(this.children);
i.attributes.pointerEvents = "none", e.children = [i];
} else
this.text && (e.children = [this.text]);
return $(e, n), e;
}
}
o(gn, "viewName", "DepictionButtonView");
class dt extends D {
constructor(e) {
super(e);
o(this, "title");
o(this, "useMargins");
o(this, "useBottomMargin");
o(this, "bold");
o(this, "textColor");
o(this, "alignment");
typeof e.title == "string" && (this.title = e.title), this.useMargins = A(e.useMargins, "boolean", !0), this.useBottomMargin = A(e.useBottomMargin, "boolean", !0), this.bold = A(e.useBoldText, "boolean", !0), this.bold || (this.textColor = "rgb(175, 175, 175)"), this.alignment = vt(e.alignment);
}
async make() {
const e = y("p", {}, [this.title]);
We(e, [
"nd-header",
this.bold && "nd-header-bold",
this.useMargins && "nd-header-margins",
this.useBottomMargin && "nd-header-bottom-margin"
]);
let n = { "text-align": this.alignment };
return this.textColor && (n.color = this.textColor), $(e, n), e;
}
}
o(dt, "viewName", "DepictionHeaderView");
class dn extends D {
constructor(e) {
super(e);
o(this, "alignment");
o(this, "url");
o(this, "width");
o(this, "height");
o(this, "xPadding");
o(this, "borderRadius");
if (this.url = _(e.URL, "string"), this.width = A(e.width, "number", 0), this.height = A(e.height, "number", 0), this.width === 0 || this.height === 0)
throw new Re("Invalid image size");
this.borderRadius = _(e.cornerRadius, "number"), this.alignment = yt(A(e.alignment, "number", 0)), this.xPadding = A(e.xPadding, "number", 0);
}
async make() {
const e = y("img", { class: "nd-image", src: this.url, loading: "lazy" });
return $(e, {
width: `${this.width}px`,
height: `${this.height}px`,
"border-radius": `${this.borderRadius}px`,
"object-fit": "cover",
padding: `0 ${this.xPadding}px`
}), _t(e, this.alignment), e;
}
}
o(dn, "viewName", "DepictionImageView");
class bn extends D {
constructor(e) {
super(e);
o(this, "text");
o(this, "margins", { left: 0, right: 0, top: 0, bottom: 0 });
o(this, "textColor");
o(this, "weight");
o(this, "alignment");
o(this, "isActionable");
o(this, "isHighlighted");
o(this, "fontSize");
typeof e.text == "string" && (this.text = e.text);
let n = e.margins;
if (typeof n == "string") {
let [c, h, w, b] = $n(n);
this.margins = { left: h, right: b, top: c, bottom: w };
}
this.margins.left === 0 && (this.margins.left = 16), this.margins.right === 0 && (this.margins.right = 16);
let i = A(e.useMargins, "boolean", !0), s = A(e.usePadding, "boolean", !0);
i ? s || (this.margins.top = 0, this.margins.bottom = 0) : this.margins = { left: 0, right: 0, top: 0, bottom: 0 };
let l = A(e.fontWeight, "string", "normal");
this.fontSize = A(e.fontSize, "number", 14), this.textColor = ye(e.textColor, "color"), this.weight = tr(l), this.alignment = vt(e.alignment);
}
async make() {
const e = y("p", { class: "nd-label" }, [this.text]);
let n = {
"text-align": this.alignment,
"font-weight": this.weight,
"font-size": `${this.fontSize}px`,
"margin-top": this.margins.top + "px",
"margin-right": this.margins.right + "px",
"margin-left": this.margins.left + "px",
"margin-bottom": this.margins.bottom + "px"
};
return this.textColor && (n.color = this.textColor), this.tintColor && (n["--kennel-tint-color"] = this.tintColor), this.textColor || this.isActionable && (this.isHighlighted ? n.filter = "saturation(75%)" : n.color = "var(--kennel-tint-color)"), $(e, n), e;
}
}
o(bn, "viewName", "DepictionLabelView");
class wn extends D {
constructor(e) {
super(e);
o(this, "views");
let n = _(e.views, "array");
this.views = Tt(n);
}
async make() {
const e = y("div", { class: "nd-layer" });
return e.children = await De(this.views), e;
}
static hydrate(e) {
let i = Array.from(e.children).reduce((s, l) => {
let c = l.getBoundingClientRect().height;
return c > s ? c : s;
}, 0);
e.style.height = i + "px";
}
}
o(wn, "viewName", "DepictionLayerView");
function kn() {
return {
async: !1,
baseUrl: null,
breaks: !1,
extensions: null,
gfm: !0,
headerIds: !0,
headerPrefix: "",
highlight: null,
langPrefix: "language-",
mangle: !0,
pedantic: !1,
renderer: null,
sanitize: !1,
sanitizer: null,
silent: !1,
smartLists: !1,
smartypants: !1,
tokenizer: null,
walkTokens: null,
xhtml: !1
};
}
let we = kn();
function Ci(r) {
we = r;
}
const Ii = /[&<>"']/, Li = /[&<>"']/g, Ni = /[<>"']|&(?!#?\w+;)/, Mi = /[<>"']|&(?!#?\w+;)/g, Oi = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
}, sn = (r) => Oi[r];
function M(r, t) {
if (t) {
if (Ii.test(r))
return r.replace(Li, sn);
} else if (Ni.test(r))
return r.replace(Mi, sn);
return r;
}
const zi = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
function xn(r) {
return r.replace(zi, (t, e) => (e = e.toLowerCase(), e === "colon" ? ":" : e.charAt(0) === "#" ? e.charAt(1) === "x" ? String.fromCharCode(parseInt(e.substring(2), 16)) : String.fromCharCode(+e.substring(1)) : ""));
}
const $i = /(^|[^\[])\^/g;
function E(r, t) {
r = typeof r == "string" ? r : r.source, t = t || "";
const e = {
replace: (n, i) => (i = i.source || i, i = i.replace($i, "$1"), r = r.replace(n, i), e),
getRegex: () => new RegExp(r, t)
};
return e;
}
const Pi = /[^\w:]/g, Ui = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
function an(r, t, e) {
if (r) {
let n;
try {
n = decodeURIComponent(xn(e)).replace(Pi, "").toLowerCase();
} catch {
return null;
}
if (n.indexOf("javascript:") === 0 || n.indexOf("vbscript:") === 0 || n.indexOf("data:") === 0)
return null;
}
t && !Ui.test(e) && (e = Vi(t, e));
try {
e = encodeURI(e).replace(/%25/g, "%");
} catch {
return null;
}
return e;
}
const $e = {}, Fi = /^[^:]+:\/*[^/]*$/, Bi = /^([^:]+:)[\s\S]*$/, Hi = /^([^:]+:\/*[^/]*)[\s\S]*$/;
function Vi(r, t) {
$e[" " + r] || (Fi.test(r) ? $e[" " + r] = r + "/" : $e[" " + r] = Fe(r, "/", !0)), r = $e[" " + r];
const e = r.indexOf(":") === -1;
return t.substring(0, 2) === "//" ? e ? t : r.replace(Bi, "$1") + t : t.charAt(0) === "/" ? e ? t : r.replace(Hi, "$1") + t : r + t;
}
const He = { exec: function() {
} };
function Q(r) {
let t = 1, e, n;
for (; t < arguments.length; t++) {
e = arguments[t];
for (n in e)
Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n]);
}
return r;
}
function ln(r, t) {
const e = r.replace(/\|/g, (s, l, c) => {
let h = !1, w = l;
for (; --w >= 0 && c[w] === "\\"; )
h = !h;
return h ? "|" : " |";
}), n = e.split(/ \|/);
let i = 0;
if (n[0].trim() || n.shift(), n.length > 0 && !n[n.length - 1].trim() && n.pop(), n.length > t)
n.splice(t);
else
for (; n.length < t; )
n.push("");
for (; i < n.length; i++)
n[i] = n[i].trim().replace(/\\\|/g, "|");
return n;
}
function Fe(r, t, e) {
const n = r.length;
if (n === 0)
return "";
let i = 0;
for (; i < n; ) {
const s = r.charAt(n - i - 1);
if (s === t && !e)
i++;
else if (s !== t && e)
i++;
else
break;
}
return r.slice(0, n - i);
}
function Wi(r, t) {
if (r.indexOf(t[1]) === -1)
return -1;
const e = r.length;
let n = 0, i = 0;
for (; i < e; i++)
if (r[i] === "\\")
i++;
else if (r[i] === t[0])
n++;
else if (r[i] === t[1] && (n--, n < 0))
return i;
return -1;
}
function yn(r) {
r && r.sanitize && !r.silent && console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options");
}
function on(r, t) {
if (t < 1)
return "";
let e = "";
for (; t > 1; )
t & 1 && (e += r), t >>= 1, r += r;
return e + r;
}
function cn(r, t, e, n) {
const i = t.href, s = t.title ? M(t.title) : null, l = r[1].replace(/\\([\[\]])/g, "$1");
if (r[0].charAt(0) !== "!") {
n.state.inLink = !0;
const c = {
type: "link",
raw: e,
href: i,
title: s,
text: l,
tokens: n.inlineTokens(l)
};
return n.state.inLink = !1, c;
}
return {
type: "image",
raw: e,
href: i,
title: s,
text: M(l)
};
}
function Gi(r, t) {
const e = r.match(/^(\s+)(?:```)/);
if (e === null)
return t;
const n = e[1];
return t.split(`
`).map((i) => {
const s = i.match(/^\s+/);
if (s === null)
return i;
const [l] = s;
return l.length >= n.length ? i.slice(n.length) : i;
}).join(`
`);
}
class bt {
constructor(t) {
this.options = t || we;
}
space(t) {
const e = this.rules.block.newline.exec(t);
if (e && e[0].length > 0)
return {
type: "space",
raw: e[0]
};
}
code(t) {
const e = this.rules.block.code.exec(t);
if (e) {
const n = e[0].replace(/^ {1,4}/gm, "");
return {
type: "code",
raw: e[0],
codeBlockStyle: "indented",
text: this.options.pedantic ? n : Fe(n, `
`)
};
}
}
fences(t) {
const e = this.rules.block.fences.exec(t);
if (e) {
const n = e[0], i = Gi(n, e[3] || "");
return {
type: "code",
raw: n,
lang: e[2] ? e[2].trim() : e[2],
text: i
};
}
}
heading(t) {
const e = this.rules.block.heading.exec(t);
if (e) {
let n = e[2].trim();
if (/#$/.test(n)) {
const i = Fe(n, "#");
(this.options.pedantic || !i || / $/.test(i)) && (n = i.trim());
}
return {
type: "heading",
raw: e[0],
depth: e[1].length,
text: n,
tokens: this.lexer.inline(n)
};
}
}
hr(t) {
const e = this.rules.block.hr.exec(t);
if (e)
return {
type: "hr",
raw: e[0]
};
}
blockquote(t) {
const e = this.rules.block.blockquote.exec(t);
if (e) {
const n = e[0].replace(/^ *>[ \t]?/gm, "");
return {
type: "blockquote",
raw: e[0],
tokens: this.lexer.blockTokens(n, []),
text: n
};
}
}
list(t) {
let e = this.rules.block.list.exec(t);
if (e) {
let n, i, s, l, c, h, w, b, F, T, g, j, G = e[1].trim();
const X = G.length > 1, S = {
type: "list",
raw: "",
ordered: X,
start: X ? +G.slice(0, -1) : "",
loose: !1,
items: []
};
G = X ? `\\d{1,9}\\${G.slice(-1)}` : `\\${G}`, this.options.pedantic && (G = X ? G : "[*+-]");
const R = new RegExp(`^( {0,3}${G})((?:[ ][^\\n]*)?(?:\\n|$))`);
for (; t && (j = !1, !(!(e = R.exec(t)) || this.rules.block.hr.test(t))); ) {
if (n = e[0], t = t.substring(n.length), b = e[2].split(`
`, 1)[0], F = t.split(`
`, 1)[0], this.options.pedantic ? (l = 2, g = b.trimLeft()) : (l = e[2].search(/[^ ]/), l = l > 4 ? 1 : l, g = b.slice(l), l += e[1].length), h = !1, !b && /^ *$/.test(F) && (n += F + `
`, t = t.substring(F.length + 1), j = !0), !j) {
const I = new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`), q = new RegExp(`^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), V = new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`), K = new RegExp(`^ {0,${Math.min(3, l - 1)}}#`);
for (; t && (T = t.split(`
`, 1)[0], b = T, this.options.pedantic && (b = b.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ")), !(V.test(b) || K.test(b) || I.test(b) || q.test(t))); ) {
if (b.search(/[^ ]/) >= l || !b.trim())
g += `
` + b.slice(l);
else if (!h)
g += `
` + b;
else
break;
!h && !b.trim() && (h = !0), n += T + `
`, t = t.substring(T.length + 1);
}
}
S.loose || (w ? S.loose = !0 : /\n *\n *$/.test(n) && (w = !0)), this.options.gfm && (i = /^\[[ xX]\] /.exec(g), i && (s = i[0] !== "[ ] ", g = g.replace(/^\[[ xX]\] +/, ""))), S.items.push({
type: "list_item",
raw: n,
task: !!i,
checked: s,
loose: !1,
text: g
}), S.raw += n;
}
S.items[S.items.length - 1].raw = n.trimRight(), S.items[S.items.length - 1].text = g.trimRight(), S.raw = S.raw.trimRight();
const ne = S.items.length;
for (c = 0; c < ne; c++) {
this.lexer.state.top = !1, S.items[c].tokens = this.lexer.blockTokens(S.items[c].text, []);
const I = S.items[c].tokens.filter((V) => V.type === "space"), q = I.every((V) => {
const K = V.raw.split("");
let ce = 0;
for (const Ge of K)
if (Ge === `
` && (ce += 1), ce > 1)
return !0;
return !1;
});
!S.loose && I.length && q && (S.loose = !0, S.items[c].loose = !0);
}
return S;
}
}
html(t) {
const e = this.rules.block.html.exec(t);
if (e) {
const n = {
type: "html",
raw: e[0],
pre: !this.options.sanitizer && (e[1] === "pre" || e[1] === "script" || e[1] === "style"),
text: e[0]
};
if (this.options.sanitize) {
const i = this.options.sanitizer ? this.options.sanitizer(e[0]) : M(e[0]);
n.type = "paragraph", n.text = i, n.tokens = this.lexer.inline(i);
}
return n;
}
}
def(t) {
const e = this.rules.block.def.exec(t);
if (e) {
e[3] && (e[3] = e[3].substring(1, e[3].length - 1));
const n = e[1].toLowerCase().replace(/\s+/g, " ");
return {
type: "def",
tag: n,
raw: e[0],
href: e[2],
title: e[3]
};
}
}
table(t) {
const e = this.rules.block.table.exec(t);
if (e) {
const n = {
type: "table",
header: ln(e[1]).map((i) => ({ text: i })),
align: e[2].replace(/^ *|\| *$/g, "").split(/ *\| */),
rows: e[3] && e[3].trim() ? e[3].replace(/\n[ \t]*$/, "").split(`
`) : []
};
if (n.header.length === n.align.length) {
n.raw = e[0];
let i = n.align.length, s, l, c, h;
for (s = 0; s < i; s++)
/^ *-+: *$/.test(n.align[s]) ? n.align[s] = "right" : /^ *:-+: *$/.test(n.align[s]) ? n.align[s] = "center" : /^ *:-+ *$/.test(n.align[s]) ? n.align[s] = "left" : n.align[s] = null;
for (i = n.rows.length, s = 0; s < i; s++)
n.rows[s] = ln(n.rows[s], n.header.length).map((w) => ({ text: w }));
for (i = n.header.length, l = 0; l < i; l++)
n.header[l].tokens = this.lexer.inline(n.header[l].text);
for (i = n.rows.length, l = 0; l < i; l++)
for (h = n.rows[l], c = 0; c < h.length; c++)
h[c].tokens = this.lexer.inline(h[c].text);
return n;
}
}
}
lheading(t) {
const e = this.rules.block.lheading.exec(t);
if (e)
return {
type: "heading",
raw: e[0],
depth: e[2].charAt(0) === "=" ? 1 : 2,
text: e[1],
tokens: this.lexer.inline(e[1])
};
}
paragraph(t) {
const e = this.rules.block.paragraph.exec(t);
if (e) {
const n = e[1].charAt(e[1].length - 1) === `
` ? e[1].slice(0, -1) : e[1];
return {
type: "paragraph",
raw: e[0],
text: n,
tokens: this.lexer.inline(n)
};
}
}
text(t) {
const e = this.rules.block.text.exec(t);
if (e)
return {
type: "text",
raw: e[0],
text: e[0],
tokens: this.lexer.inline(e[0])
};
}
escape(t) {
const e = this.rules.inline.escape.exec(t);
if (e)
return {
type: "escape",
raw: e[0],
text: M(e[1])
};
}
tag(t) {
const e = this.rules.inline.tag.exec(t);
if (e)
return !this.lexer.state.inLink && /^<a /i.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && /^<\/a>/i.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0]) && (this.lexer.state.inRawBlock = !1), {
type: this.options.sanitize ? "text" : "html",
raw: e[0],
inLink: this.lexer.state.inLink,
inRawBlock: this.lexer.state.inRawBlock,
text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(e[0]) : M(e[0]) : e[0]
};
}
link(t) {
const e = this.rules.inline.link.exec(t);
if (e) {
const n = e[2].trim();
if (!this.options.pedantic && /^</.test(n)) {
if (!/>$/.test(n))
return;
const l = Fe(n.slice(0, -1), "\\");
if ((n.length - l.length) % 2 === 0)
return;
} else {
const l = Wi(e[2], "()");
if (l > -1) {
const h = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + l;
e[2] = e[2].substring(0, l), e[0] = e[0].substring(0, h).trim(), e[3] = "";
}
}
let i = e[2], s = "";
if (this.options.pedantic) {
const l = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);
l && (i = l[1], s = l[3]);
} else
s = e[3] ? e[3].slice(1, -1) : "";
return i = i.trim(), /^</.test(i) && (this.options.pedantic && !/>$/.test(n) ? i = i.slice(1) : i = i.slice(1, -1)), cn(e, {
href: i && i.replace(this.rules.inline._escapes, "$1"),
title: s && s.replace(this.rules.inline._escapes, "$1")
}, e[0], this.lexer);
}
}
reflink(t, e) {
let n;
if ((n = this.rules.inline.reflink.exec(t)) || (n = this.rules.inline.nolink.exec(t))) {
let i = (n[2] || n[1]).replace(/\s+/g, " ");
if (i = e[i.toLowerCase()], !i || !i.href) {
const s = n[0].charAt(0);
return {
type: "text",
raw: s,
text: s
};
}
return cn(n, i, n[0], this.lexer);
}
}
emStrong(t, e, n = "") {
let i = this.rules.inline.emStrong.lDelim.exec(t);
if (!i || i[3] && n.match(/[\p{L}\p{N}]/u))
return;
const s = i[1] || i[2] || "";
if (!s || s && (n === "" || this.rules.inline.punctuation.exec(n))) {
const l = i[0].length - 1;
let c, h, w = l, b = 0;
const F = i[0][0] === "*" ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
for (F.lastIndex = 0, e = e.slice(-1 * t.length + l); (i = F.exec(e)) != null; ) {
if (c = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !c)
continue;
if (h = c.length, i[3] || i[4]) {
w += h;
continue;
} else if ((i[5] || i[6]) && l % 3 && !((l + h) % 3)) {
b += h;
continue;
}
if (w -= h, w > 0)
continue;
if (h = Math.min(h, h + w + b), Math.min(l, h) % 2) {
const g = t.slice(1, l + i.index + h);
return {
type: "em",
raw: t.slice(0, l + i.index + h + 1),
text: g,
tokens: this.lexer.inlineTokens(g)
};
}
const T = t.slice(2, l + i.index + h - 1);
return {
type: "strong",
raw: t.slice(0, l + i.index + h + 1),
text: T,
tokens: this.lexer.inlineTokens(T)
};
}
}
}
codespan(t) {
const e = this.rules.inline.code.exec(t);
if (e) {
let n = e[2].replace(/\n/g, " ");
const i = /[^ ]/.test(n), s = /^ /.test(n) && / $/.test(n);
return i && s && (n = n.substring(1, n.length - 1)), n = M(n, !0), {
type: "codespan",
raw: e[0],
text: n
};
}
}
br(t) {
const e = this.rules.inline.br.exec(t);
if (e)
return {
type: "br",
raw: e[0]
};
}
del(t) {
const e = this.rules.inline.del.exec(t);
if (e)
return {
type: "del",
raw: e[0],
text: e[2],
tokens: this.lexer.inlineTokens(e[2])
};
}
autolink(t, e) {
const n = this.rules.inline.autolink.exec(t);
if (n) {
let i, s;
return n[2] === "@" ? (i = M(this.options.mangle ? e(n[1]) : n[1]), s = "mailto:" + i) : (i = M(n[1]), s = i), {
type: "link",
raw: n[0],
text: i,
href: s,
tokens: [
{
type: "text",
raw: i,
text: i
}
]
};
}
}
url(t, e) {
let n;
if (n = this.rules.inline.url.exec(t)) {
let i, s;
if (n