@altmd/runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/index.js +1098 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Iwugo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @altmd/runtime
|
|
2
|
+
|
|
3
|
+
The zero-build browser runtime for
|
|
4
|
+
[alt-markdown](https://github.com/elementmerc/alt-markdown): a strict CommonMark
|
|
5
|
+
superset that renders charts, diagrams, maths, and other components, and still
|
|
6
|
+
reads as plain markdown when the runtime is not there.
|
|
7
|
+
|
|
8
|
+
This package is the small (~15 kB gzipped) script that upgrades a rendered
|
|
9
|
+
alt-markdown page in the browser. It registers the `alt-*` custom elements, so
|
|
10
|
+
the static fallbacks already baked into the HTML turn into live charts, diagrams,
|
|
11
|
+
and maths. No build step, no server.
|
|
12
|
+
|
|
13
|
+
## Use it from a CDN
|
|
14
|
+
|
|
15
|
+
Render your document to HTML once with the `altmd` CLI, host the result, then add
|
|
16
|
+
one script tag. The easiest way to get a complete page is `altmd render
|
|
17
|
+
--standalone doc.alt`, which emits a self-contained HTML file with the tag
|
|
18
|
+
already wired. To upgrade a page you assemble yourself:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script type="module">
|
|
22
|
+
import { bootstrap } from "https://cdn.jsdelivr.net/npm/@altmd/runtime@0.1.0/dist/index.js";
|
|
23
|
+
bootstrap();
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The graphics libraries (uPlot, KaTeX, Mermaid) load lazily, and only when a
|
|
28
|
+
document actually uses them, so a page with no charts pays nothing for the chart
|
|
29
|
+
code.
|
|
30
|
+
|
|
31
|
+
## What it does
|
|
32
|
+
|
|
33
|
+
- Registers the `alt-*` components: callouts, tabs, accordions, columns, charts,
|
|
34
|
+
maths, diagrams, embeds, and a table of contents.
|
|
35
|
+
- Renders diagrams in a script-disabled, origin-isolated iframe.
|
|
36
|
+
- Leaves plain CommonMark untouched, so the document still reads without the
|
|
37
|
+
runtime.
|
|
38
|
+
|
|
39
|
+
## Links
|
|
40
|
+
|
|
41
|
+
- Repository and full documentation: https://github.com/elementmerc/alt-markdown
|
|
42
|
+
- Live playground: https://elementmerc.github.io/alt-markdown/
|
|
43
|
+
|
|
44
|
+
## Licence
|
|
45
|
+
|
|
46
|
+
MIT. See [LICENSE](./LICENSE).
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,1098 @@
|
|
|
1
|
+
var Be = (e) => {
|
|
2
|
+
throw TypeError(e);
|
|
3
|
+
};
|
|
4
|
+
var ae = (e, o, r) => o.has(e) || Be("Cannot " + r);
|
|
5
|
+
var rt = (e, o, r) => (ae(e, o, "read from private field"), r ? r.call(e) : o.get(e)), Ot = (e, o, r) => o.has(e) ? Be("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(e) : o.set(e, r), Z = (e, o, r, s) => (ae(e, o, "write to private field"), s ? s.call(e, r) : o.set(e, r), r), Ye = (e, o, r) => (ae(e, o, "access private method"), r);
|
|
6
|
+
function Yn(e, o) {
|
|
7
|
+
return [
|
|
8
|
+
"<!doctype html>",
|
|
9
|
+
"<html><head>",
|
|
10
|
+
`<meta http-equiv="Content-Security-Policy" content="${[
|
|
11
|
+
"default-src 'none'",
|
|
12
|
+
"img-src data:",
|
|
13
|
+
"style-src 'unsafe-inline'",
|
|
14
|
+
o ? "script-src 'unsafe-inline'" : "script-src 'none'",
|
|
15
|
+
"connect-src 'none'"
|
|
16
|
+
].join("; ")}">`,
|
|
17
|
+
"</head><body>",
|
|
18
|
+
e,
|
|
19
|
+
"</body></html>"
|
|
20
|
+
].join("");
|
|
21
|
+
}
|
|
22
|
+
function cn(e) {
|
|
23
|
+
const o = document.createElement("iframe");
|
|
24
|
+
return o.setAttribute("sandbox", e.allowScripts ? "allow-scripts" : ""), o.setAttribute("referrerpolicy", "no-referrer"), e.title !== void 0 && o.setAttribute("title", e.title), o.style.border = "0", o.style.width = "100%", e.height !== void 0 && (o.style.height = `${e.height}px`), o.srcdoc = Yn(e.html, e.allowScripts ?? !1), o;
|
|
25
|
+
}
|
|
26
|
+
/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
|
|
27
|
+
function je(e, o) {
|
|
28
|
+
(o == null || o > e.length) && (o = e.length);
|
|
29
|
+
for (var r = 0, s = Array(o); r < o; r++) s[r] = e[r];
|
|
30
|
+
return s;
|
|
31
|
+
}
|
|
32
|
+
function jn(e) {
|
|
33
|
+
if (Array.isArray(e)) return e;
|
|
34
|
+
}
|
|
35
|
+
function $n(e, o) {
|
|
36
|
+
var r = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
|
|
37
|
+
if (r != null) {
|
|
38
|
+
var s, c, u, d, v = [], w = !0, H = !1;
|
|
39
|
+
try {
|
|
40
|
+
if (u = (r = r.call(e)).next, o !== 0) for (; !(w = (s = u.call(r)).done) && (v.push(s.value), v.length !== o); w = !0) ;
|
|
41
|
+
} catch (j) {
|
|
42
|
+
H = !0, c = j;
|
|
43
|
+
} finally {
|
|
44
|
+
try {
|
|
45
|
+
if (!w && r.return != null && (d = r.return(), Object(d) !== d)) return;
|
|
46
|
+
} finally {
|
|
47
|
+
if (H) throw c;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return v;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function qn() {
|
|
54
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
55
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
56
|
+
}
|
|
57
|
+
function Xn(e, o) {
|
|
58
|
+
return jn(e) || $n(e, o) || Vn(e, o) || qn();
|
|
59
|
+
}
|
|
60
|
+
function Vn(e, o) {
|
|
61
|
+
if (e) {
|
|
62
|
+
if (typeof e == "string") return je(e, o);
|
|
63
|
+
var r = {}.toString.call(e).slice(8, -1);
|
|
64
|
+
return r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set" ? Array.from(e) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? je(e, o) : void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const un = Object.entries, $e = Object.setPrototypeOf, Kn = Object.isFrozen, Zn = Object.getPrototypeOf, Jn = Object.getOwnPropertyDescriptor;
|
|
68
|
+
let R = Object.freeze, N = Object.seal, dt = Object.create, fn = typeof Reflect < "u" && Reflect, me = fn.apply, pe = fn.construct;
|
|
69
|
+
R || (R = function(o) {
|
|
70
|
+
return o;
|
|
71
|
+
});
|
|
72
|
+
N || (N = function(o) {
|
|
73
|
+
return o;
|
|
74
|
+
});
|
|
75
|
+
me || (me = function(o, r) {
|
|
76
|
+
for (var s = arguments.length, c = new Array(s > 2 ? s - 2 : 0), u = 2; u < s; u++)
|
|
77
|
+
c[u - 2] = arguments[u];
|
|
78
|
+
return o.apply(r, c);
|
|
79
|
+
});
|
|
80
|
+
pe || (pe = function(o) {
|
|
81
|
+
for (var r = arguments.length, s = new Array(r > 1 ? r - 1 : 0), c = 1; c < r; c++)
|
|
82
|
+
s[c - 1] = arguments[c];
|
|
83
|
+
return new o(...s);
|
|
84
|
+
});
|
|
85
|
+
const Rt = y(Array.prototype.forEach), Qn = y(Array.prototype.lastIndexOf), qe = y(Array.prototype.pop), pt = y(Array.prototype.push), to = y(Array.prototype.splice), Q = Array.isArray, It = y(String.prototype.toLowerCase), se = y(String.prototype.toString), Xe = y(String.prototype.match), Nt = y(String.prototype.replace), Ve = y(String.prototype.indexOf), eo = y(String.prototype.trim), no = y(Number.prototype.toString), oo = y(Boolean.prototype.toString), Ke = typeof BigInt > "u" ? null : y(BigInt.prototype.toString), Ze = typeof Symbol > "u" ? null : y(Symbol.prototype.toString), S = y(Object.prototype.hasOwnProperty), wt = y(Object.prototype.toString), O = y(RegExp.prototype.test), it = ro(TypeError);
|
|
86
|
+
function y(e) {
|
|
87
|
+
return function(o) {
|
|
88
|
+
o instanceof RegExp && (o.lastIndex = 0);
|
|
89
|
+
for (var r = arguments.length, s = new Array(r > 1 ? r - 1 : 0), c = 1; c < r; c++)
|
|
90
|
+
s[c - 1] = arguments[c];
|
|
91
|
+
return me(e, o, s);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function ro(e) {
|
|
95
|
+
return function() {
|
|
96
|
+
for (var o = arguments.length, r = new Array(o), s = 0; s < o; s++)
|
|
97
|
+
r[s] = arguments[s];
|
|
98
|
+
return pe(e, r);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function m(e, o) {
|
|
102
|
+
let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : It;
|
|
103
|
+
if ($e && $e(e, null), !Q(o))
|
|
104
|
+
return e;
|
|
105
|
+
let s = o.length;
|
|
106
|
+
for (; s--; ) {
|
|
107
|
+
let c = o[s];
|
|
108
|
+
if (typeof c == "string") {
|
|
109
|
+
const u = r(c);
|
|
110
|
+
u !== c && (Kn(o) || (o[s] = u), c = u);
|
|
111
|
+
}
|
|
112
|
+
e[c] = !0;
|
|
113
|
+
}
|
|
114
|
+
return e;
|
|
115
|
+
}
|
|
116
|
+
function io(e) {
|
|
117
|
+
for (let o = 0; o < e.length; o++)
|
|
118
|
+
S(e, o) || (e[o] = null);
|
|
119
|
+
return e;
|
|
120
|
+
}
|
|
121
|
+
function L(e) {
|
|
122
|
+
const o = dt(null);
|
|
123
|
+
for (const s of un(e)) {
|
|
124
|
+
var r = Xn(s, 2);
|
|
125
|
+
const c = r[0], u = r[1];
|
|
126
|
+
S(e, c) && (Q(u) ? o[c] = io(u) : u && typeof u == "object" && u.constructor === Object ? o[c] = L(u) : o[c] = u);
|
|
127
|
+
}
|
|
128
|
+
return o;
|
|
129
|
+
}
|
|
130
|
+
function ao(e) {
|
|
131
|
+
switch (typeof e) {
|
|
132
|
+
case "string":
|
|
133
|
+
return e;
|
|
134
|
+
case "number":
|
|
135
|
+
return no(e);
|
|
136
|
+
case "boolean":
|
|
137
|
+
return oo(e);
|
|
138
|
+
case "bigint":
|
|
139
|
+
return Ke ? Ke(e) : "0";
|
|
140
|
+
case "symbol":
|
|
141
|
+
return Ze ? Ze(e) : "Symbol()";
|
|
142
|
+
case "undefined":
|
|
143
|
+
return wt(e);
|
|
144
|
+
case "function":
|
|
145
|
+
case "object": {
|
|
146
|
+
if (e === null)
|
|
147
|
+
return wt(e);
|
|
148
|
+
const o = e, r = z(o, "toString");
|
|
149
|
+
if (typeof r == "function") {
|
|
150
|
+
const s = r(o);
|
|
151
|
+
return typeof s == "string" ? s : wt(s);
|
|
152
|
+
}
|
|
153
|
+
return wt(e);
|
|
154
|
+
}
|
|
155
|
+
default:
|
|
156
|
+
return wt(e);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function z(e, o) {
|
|
160
|
+
for (; e !== null; ) {
|
|
161
|
+
const s = Jn(e, o);
|
|
162
|
+
if (s) {
|
|
163
|
+
if (s.get)
|
|
164
|
+
return y(s.get);
|
|
165
|
+
if (typeof s.value == "function")
|
|
166
|
+
return y(s.value);
|
|
167
|
+
}
|
|
168
|
+
e = Zn(e);
|
|
169
|
+
}
|
|
170
|
+
function r() {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return r;
|
|
174
|
+
}
|
|
175
|
+
function so(e) {
|
|
176
|
+
try {
|
|
177
|
+
return O(e, ""), !0;
|
|
178
|
+
} catch {
|
|
179
|
+
return !1;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const Je = R(["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", "search", "section", "select", "shadow", "slot", "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"]), le = R(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), ce = R(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), lo = R(["animate", "color-profile", "cursor", "discard", "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"]), ue = R(["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", "mprescripts"]), co = R(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Qe = R(["#text"]), tn = R(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "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", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]), fe = R(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "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", "exponent", "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", "intercept", "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", "mask-type", "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", "slope", "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", "tablevalues", "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"]), en = R(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "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"]), Ft = R(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), uo = N(/{{[\w\W]*|^[\w\W]*}}/g), fo = N(/<%[\w\W]*|^[\w\W]*%>/g), mo = N(/\${[\w\W]*/g), po = N(/^data-[\-\w.\u00B7-\uFFFF]+$/), ho = N(/^aria-[\-\w]+$/), nn = N(
|
|
183
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
184
|
+
// eslint-disable-line no-useless-escape
|
|
185
|
+
), To = N(/^(?:\w+script|data):/i), _o = N(
|
|
186
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
187
|
+
// eslint-disable-line no-control-regex
|
|
188
|
+
), go = N(/^html$/i), Eo = N(/^[a-z][.\w]*(-[.\w]+)+$/i), on = N(/<[/\w!]/g), Ao = N(/<[/\w]/g), yo = N(/<\/no(script|embed|frames)/i), bo = N(/\/>/i), U = {
|
|
189
|
+
element: 1,
|
|
190
|
+
attribute: 2,
|
|
191
|
+
text: 3,
|
|
192
|
+
cdataSection: 4,
|
|
193
|
+
entityReference: 5,
|
|
194
|
+
// Deprecated
|
|
195
|
+
entityNode: 6,
|
|
196
|
+
// Deprecated
|
|
197
|
+
processingInstruction: 7,
|
|
198
|
+
comment: 8,
|
|
199
|
+
document: 9,
|
|
200
|
+
documentType: 10,
|
|
201
|
+
documentFragment: 11,
|
|
202
|
+
notation: 12
|
|
203
|
+
// Deprecated
|
|
204
|
+
}, So = function() {
|
|
205
|
+
return typeof window > "u" ? null : window;
|
|
206
|
+
}, Oo = function(o, r) {
|
|
207
|
+
if (typeof o != "object" || typeof o.createPolicy != "function")
|
|
208
|
+
return null;
|
|
209
|
+
let s = null;
|
|
210
|
+
const c = "data-tt-policy-suffix";
|
|
211
|
+
r && r.hasAttribute(c) && (s = r.getAttribute(c));
|
|
212
|
+
const u = "dompurify" + (s ? "#" + s : "");
|
|
213
|
+
try {
|
|
214
|
+
return o.createPolicy(u, {
|
|
215
|
+
createHTML(d) {
|
|
216
|
+
return d;
|
|
217
|
+
},
|
|
218
|
+
createScriptURL(d) {
|
|
219
|
+
return d;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
} catch {
|
|
223
|
+
return console.warn("TrustedTypes policy " + u + " could not be created."), null;
|
|
224
|
+
}
|
|
225
|
+
}, rn = function() {
|
|
226
|
+
return {
|
|
227
|
+
afterSanitizeAttributes: [],
|
|
228
|
+
afterSanitizeElements: [],
|
|
229
|
+
afterSanitizeShadowDOM: [],
|
|
230
|
+
beforeSanitizeAttributes: [],
|
|
231
|
+
beforeSanitizeElements: [],
|
|
232
|
+
beforeSanitizeShadowDOM: [],
|
|
233
|
+
uponSanitizeAttribute: [],
|
|
234
|
+
uponSanitizeElement: [],
|
|
235
|
+
uponSanitizeShadowNode: []
|
|
236
|
+
};
|
|
237
|
+
}, J = function(o, r, s, c) {
|
|
238
|
+
return S(o, r) && Q(o[r]) ? m(c.base ? L(c.base) : {}, o[r], c.transform) : s;
|
|
239
|
+
};
|
|
240
|
+
function mn() {
|
|
241
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : So();
|
|
242
|
+
const o = (a) => mn(a);
|
|
243
|
+
if (o.version = "3.4.11", o.removed = [], !e || !e.document || e.document.nodeType !== U.document || !e.Element)
|
|
244
|
+
return o.isSupported = !1, o;
|
|
245
|
+
let r = e.document;
|
|
246
|
+
const s = r, c = s.currentScript;
|
|
247
|
+
e.DocumentFragment;
|
|
248
|
+
const u = e.HTMLTemplateElement, d = e.Node, v = e.Element, w = e.NodeFilter, H = e.NamedNodeMap;
|
|
249
|
+
H === void 0 && (e.NamedNodeMap || e.MozNamedAttrMap), e.HTMLFormElement;
|
|
250
|
+
const j = e.DOMParser, _t = e.trustedTypes, G = v.prototype, zt = z(G, "cloneNode"), W = z(G, "remove"), tt = z(G, "nextSibling"), x = z(G, "childNodes"), $ = z(G, "parentNode"), gt = z(G, "shadowRoot"), Ht = z(G, "attributes"), C = d && d.prototype ? z(d.prototype, "nodeType") : null, q = d && d.prototype ? z(d.prototype, "nodeName") : null;
|
|
251
|
+
if (typeof u == "function") {
|
|
252
|
+
const a = r.createElement("template");
|
|
253
|
+
a.content && a.content.ownerDocument && (r = a.content.ownerDocument);
|
|
254
|
+
}
|
|
255
|
+
let D, et = "", Gt, de = !1, Et = 0;
|
|
256
|
+
const he = function() {
|
|
257
|
+
if (Et > 0)
|
|
258
|
+
throw it('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
|
|
259
|
+
}, st = function(t) {
|
|
260
|
+
he(), Et++;
|
|
261
|
+
try {
|
|
262
|
+
return D.createHTML(t);
|
|
263
|
+
} finally {
|
|
264
|
+
Et--;
|
|
265
|
+
}
|
|
266
|
+
}, Tn = function(t) {
|
|
267
|
+
he(), Et++;
|
|
268
|
+
try {
|
|
269
|
+
return D.createScriptURL(t);
|
|
270
|
+
} finally {
|
|
271
|
+
Et--;
|
|
272
|
+
}
|
|
273
|
+
}, _n = function() {
|
|
274
|
+
return de || (Gt = Oo(_t, c), de = !0), Gt;
|
|
275
|
+
}, Lt = r, Wt = Lt.implementation, Te = Lt.createNodeIterator, gn = Lt.createDocumentFragment, En = Lt.getElementsByTagName, An = s.importNode;
|
|
276
|
+
let E = rn();
|
|
277
|
+
o.isSupported = typeof un == "function" && typeof $ == "function" && Wt && Wt.createHTMLDocument !== void 0;
|
|
278
|
+
const yn = uo, bn = fo, Sn = mo, On = po, Rn = ho, Nn = To, _e = _o, wn = Eo;
|
|
279
|
+
let ge = nn, h = null;
|
|
280
|
+
const Ee = m({}, [...Je, ...le, ...ce, ...ue, ...Qe]);
|
|
281
|
+
let T = null;
|
|
282
|
+
const Ae = m({}, [...tn, ...fe, ...en, ...Ft]);
|
|
283
|
+
let _ = Object.seal(dt(null, {
|
|
284
|
+
tagNameCheck: {
|
|
285
|
+
writable: !0,
|
|
286
|
+
configurable: !1,
|
|
287
|
+
enumerable: !0,
|
|
288
|
+
value: null
|
|
289
|
+
},
|
|
290
|
+
attributeNameCheck: {
|
|
291
|
+
writable: !0,
|
|
292
|
+
configurable: !1,
|
|
293
|
+
enumerable: !0,
|
|
294
|
+
value: null
|
|
295
|
+
},
|
|
296
|
+
allowCustomizedBuiltInElements: {
|
|
297
|
+
writable: !0,
|
|
298
|
+
configurable: !1,
|
|
299
|
+
enumerable: !0,
|
|
300
|
+
value: !1
|
|
301
|
+
}
|
|
302
|
+
})), At = null, ye = null;
|
|
303
|
+
const X = Object.seal(dt(null, {
|
|
304
|
+
tagCheck: {
|
|
305
|
+
writable: !0,
|
|
306
|
+
configurable: !1,
|
|
307
|
+
enumerable: !0,
|
|
308
|
+
value: null
|
|
309
|
+
},
|
|
310
|
+
attributeCheck: {
|
|
311
|
+
writable: !0,
|
|
312
|
+
configurable: !1,
|
|
313
|
+
enumerable: !0,
|
|
314
|
+
value: null
|
|
315
|
+
}
|
|
316
|
+
}));
|
|
317
|
+
let be = !0, Bt = !0, Se = !1, Oe = !0, V = !1, yt = !0, nt = !1, Yt = !1, jt = null, $t = null, qt = !1, lt = !1, Dt = !1, Ct = !1, Re = !0, Ne = !1;
|
|
318
|
+
const we = "user-content-";
|
|
319
|
+
let Xt = !0, Vt = !1, ct = {}, k = null;
|
|
320
|
+
const Kt = m({}, [
|
|
321
|
+
"annotation-xml",
|
|
322
|
+
"audio",
|
|
323
|
+
"colgroup",
|
|
324
|
+
"desc",
|
|
325
|
+
"foreignobject",
|
|
326
|
+
"head",
|
|
327
|
+
"iframe",
|
|
328
|
+
"math",
|
|
329
|
+
"mi",
|
|
330
|
+
"mn",
|
|
331
|
+
"mo",
|
|
332
|
+
"ms",
|
|
333
|
+
"mtext",
|
|
334
|
+
"noembed",
|
|
335
|
+
"noframes",
|
|
336
|
+
"noscript",
|
|
337
|
+
"plaintext",
|
|
338
|
+
"script",
|
|
339
|
+
// <selectedcontent> mirrors the selected <option>'s subtree, cloned by
|
|
340
|
+
// the UA (customizable <select>) — including any on* handlers — and the
|
|
341
|
+
// engine re-mirrors synchronously whenever a removal changes which
|
|
342
|
+
// option/selectedcontent is current, even inside DOMPurify's inert
|
|
343
|
+
// DOMParser document. Hoisting its children on removal re-inserts a fresh
|
|
344
|
+
// mirror target ahead of the walk, which the engine refills, looping
|
|
345
|
+
// forever (DoS) and amplifying output. Dropping its content on removal
|
|
346
|
+
// (rather than hoisting) breaks that cascade; the content is a duplicate
|
|
347
|
+
// of the option, which is sanitized on its own. See campaign-3 F1/F6.
|
|
348
|
+
"selectedcontent",
|
|
349
|
+
"style",
|
|
350
|
+
"svg",
|
|
351
|
+
"template",
|
|
352
|
+
"thead",
|
|
353
|
+
"title",
|
|
354
|
+
"video",
|
|
355
|
+
"xmp"
|
|
356
|
+
]);
|
|
357
|
+
let Ie = null;
|
|
358
|
+
const Le = m({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
359
|
+
let Zt = null;
|
|
360
|
+
const De = m({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Mt = "http://www.w3.org/1998/Math/MathML", xt = "http://www.w3.org/2000/svg", F = "http://www.w3.org/1999/xhtml";
|
|
361
|
+
let ut = F, Jt = !1, Qt = null;
|
|
362
|
+
const In = m({}, [Mt, xt, F], se), Ce = R(["mi", "mo", "mn", "ms", "mtext"]);
|
|
363
|
+
let te = m({}, Ce);
|
|
364
|
+
const Me = R(["annotation-xml"]);
|
|
365
|
+
let ee = m({}, Me);
|
|
366
|
+
const Ln = m({}, ["title", "style", "font", "a", "script"]);
|
|
367
|
+
let bt = null;
|
|
368
|
+
const Dn = ["application/xhtml+xml", "text/html"], Cn = "text/html";
|
|
369
|
+
let g = null, ft = null;
|
|
370
|
+
const Mn = r.createElement("form"), xe = function(t) {
|
|
371
|
+
return t instanceof RegExp || t instanceof Function;
|
|
372
|
+
}, ne = function() {
|
|
373
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
374
|
+
if (ft && ft === t)
|
|
375
|
+
return;
|
|
376
|
+
(!t || typeof t != "object") && (t = {}), t = L(t), bt = // eslint-disable-next-line unicorn/prefer-includes
|
|
377
|
+
Dn.indexOf(t.PARSER_MEDIA_TYPE) === -1 ? Cn : t.PARSER_MEDIA_TYPE, g = bt === "application/xhtml+xml" ? se : It, h = J(t, "ALLOWED_TAGS", Ee, {
|
|
378
|
+
transform: g
|
|
379
|
+
}), T = J(t, "ALLOWED_ATTR", Ae, {
|
|
380
|
+
transform: g
|
|
381
|
+
}), Qt = J(t, "ALLOWED_NAMESPACES", In, {
|
|
382
|
+
transform: se
|
|
383
|
+
}), Zt = J(t, "ADD_URI_SAFE_ATTR", De, {
|
|
384
|
+
transform: g,
|
|
385
|
+
base: De
|
|
386
|
+
}), Ie = J(t, "ADD_DATA_URI_TAGS", Le, {
|
|
387
|
+
transform: g,
|
|
388
|
+
base: Le
|
|
389
|
+
}), k = J(t, "FORBID_CONTENTS", Kt, {
|
|
390
|
+
transform: g
|
|
391
|
+
}), At = J(t, "FORBID_TAGS", L({}), {
|
|
392
|
+
transform: g
|
|
393
|
+
}), ye = J(t, "FORBID_ATTR", L({}), {
|
|
394
|
+
transform: g
|
|
395
|
+
}), ct = S(t, "USE_PROFILES") ? t.USE_PROFILES && typeof t.USE_PROFILES == "object" ? L(t.USE_PROFILES) : t.USE_PROFILES : !1, be = t.ALLOW_ARIA_ATTR !== !1, Bt = t.ALLOW_DATA_ATTR !== !1, Se = t.ALLOW_UNKNOWN_PROTOCOLS || !1, Oe = t.ALLOW_SELF_CLOSE_IN_ATTR !== !1, V = t.SAFE_FOR_TEMPLATES || !1, yt = t.SAFE_FOR_XML !== !1, nt = t.WHOLE_DOCUMENT || !1, lt = t.RETURN_DOM || !1, Dt = t.RETURN_DOM_FRAGMENT || !1, Ct = t.RETURN_TRUSTED_TYPE || !1, qt = t.FORCE_BODY || !1, Re = t.SANITIZE_DOM !== !1, Ne = t.SANITIZE_NAMED_PROPS || !1, Xt = t.KEEP_CONTENT !== !1, Vt = t.IN_PLACE || !1, ge = so(t.ALLOWED_URI_REGEXP) ? t.ALLOWED_URI_REGEXP : nn, ut = typeof t.NAMESPACE == "string" ? t.NAMESPACE : F, te = S(t, "MATHML_TEXT_INTEGRATION_POINTS") && t.MATHML_TEXT_INTEGRATION_POINTS && typeof t.MATHML_TEXT_INTEGRATION_POINTS == "object" ? L(t.MATHML_TEXT_INTEGRATION_POINTS) : m({}, Ce), ee = S(t, "HTML_INTEGRATION_POINTS") && t.HTML_INTEGRATION_POINTS && typeof t.HTML_INTEGRATION_POINTS == "object" ? L(t.HTML_INTEGRATION_POINTS) : m({}, Me);
|
|
396
|
+
const n = S(t, "CUSTOM_ELEMENT_HANDLING") && t.CUSTOM_ELEMENT_HANDLING && typeof t.CUSTOM_ELEMENT_HANDLING == "object" ? L(t.CUSTOM_ELEMENT_HANDLING) : dt(null);
|
|
397
|
+
if (_ = dt(null), S(n, "tagNameCheck") && xe(n.tagNameCheck) && (_.tagNameCheck = n.tagNameCheck), S(n, "attributeNameCheck") && xe(n.attributeNameCheck) && (_.attributeNameCheck = n.attributeNameCheck), S(n, "allowCustomizedBuiltInElements") && typeof n.allowCustomizedBuiltInElements == "boolean" && (_.allowCustomizedBuiltInElements = n.allowCustomizedBuiltInElements), N(_), V && (Bt = !1), Dt && (lt = !0), ct && (h = m({}, Qe), T = dt(null), ct.html === !0 && (m(h, Je), m(T, tn)), ct.svg === !0 && (m(h, le), m(T, fe), m(T, Ft)), ct.svgFilters === !0 && (m(h, ce), m(T, fe), m(T, Ft)), ct.mathMl === !0 && (m(h, ue), m(T, en), m(T, Ft))), X.tagCheck = null, X.attributeCheck = null, S(t, "ADD_TAGS") && (typeof t.ADD_TAGS == "function" ? X.tagCheck = t.ADD_TAGS : Q(t.ADD_TAGS) && (h === Ee && (h = L(h)), m(h, t.ADD_TAGS, g))), S(t, "ADD_ATTR") && (typeof t.ADD_ATTR == "function" ? X.attributeCheck = t.ADD_ATTR : Q(t.ADD_ATTR) && (T === Ae && (T = L(T)), m(T, t.ADD_ATTR, g))), S(t, "ADD_URI_SAFE_ATTR") && Q(t.ADD_URI_SAFE_ATTR) && m(Zt, t.ADD_URI_SAFE_ATTR, g), S(t, "FORBID_CONTENTS") && Q(t.FORBID_CONTENTS) && (k === Kt && (k = L(k)), m(k, t.FORBID_CONTENTS, g)), S(t, "ADD_FORBID_CONTENTS") && Q(t.ADD_FORBID_CONTENTS) && (k === Kt && (k = L(k)), m(k, t.ADD_FORBID_CONTENTS, g)), Xt && (h["#text"] = !0), nt && m(h, ["html", "head", "body"]), h.table && (m(h, ["tbody"]), delete At.tbody), t.TRUSTED_TYPES_POLICY) {
|
|
398
|
+
if (typeof t.TRUSTED_TYPES_POLICY.createHTML != "function")
|
|
399
|
+
throw it('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
400
|
+
if (typeof t.TRUSTED_TYPES_POLICY.createScriptURL != "function")
|
|
401
|
+
throw it('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
402
|
+
const i = D;
|
|
403
|
+
D = t.TRUSTED_TYPES_POLICY;
|
|
404
|
+
try {
|
|
405
|
+
et = st("");
|
|
406
|
+
} catch (l) {
|
|
407
|
+
throw D = i, l;
|
|
408
|
+
}
|
|
409
|
+
} else t.TRUSTED_TYPES_POLICY === null ? (D = void 0, et = "") : (D === void 0 && (D = _n()), D && typeof et == "string" && (et = st("")));
|
|
410
|
+
R && R(t), ft = t;
|
|
411
|
+
}, Pe = m({}, [...le, ...ce, ...lo]), ve = m({}, [...ue, ...co]), xn = function(t, n, i) {
|
|
412
|
+
return n.namespaceURI === F ? t === "svg" : n.namespaceURI === Mt ? t === "svg" && (i === "annotation-xml" || te[i]) : !!Pe[t];
|
|
413
|
+
}, Pn = function(t, n, i) {
|
|
414
|
+
return n.namespaceURI === F ? t === "math" : n.namespaceURI === xt ? t === "math" && ee[i] : !!ve[t];
|
|
415
|
+
}, vn = function(t, n, i) {
|
|
416
|
+
return n.namespaceURI === xt && !ee[i] || n.namespaceURI === Mt && !te[i] ? !1 : !ve[t] && (Ln[t] || !Pe[t]);
|
|
417
|
+
}, kn = function(t) {
|
|
418
|
+
let n = $(t);
|
|
419
|
+
(!n || !n.tagName) && (n = {
|
|
420
|
+
namespaceURI: ut,
|
|
421
|
+
tagName: "template"
|
|
422
|
+
});
|
|
423
|
+
const i = It(t.tagName), l = It(n.tagName);
|
|
424
|
+
return Qt[t.namespaceURI] ? t.namespaceURI === xt ? xn(i, n, l) : t.namespaceURI === Mt ? Pn(i, n, l) : t.namespaceURI === F ? vn(i, n, l) : !!(bt === "application/xhtml+xml" && Qt[t.namespaceURI]) : !1;
|
|
425
|
+
}, K = function(t) {
|
|
426
|
+
pt(o.removed, {
|
|
427
|
+
element: t
|
|
428
|
+
});
|
|
429
|
+
try {
|
|
430
|
+
$(t).removeChild(t);
|
|
431
|
+
} catch {
|
|
432
|
+
if (W(t), !$(t))
|
|
433
|
+
throw it("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
|
|
434
|
+
}
|
|
435
|
+
}, ke = function(t) {
|
|
436
|
+
const n = x(t);
|
|
437
|
+
if (n) {
|
|
438
|
+
const l = [];
|
|
439
|
+
Rt(n, (f) => {
|
|
440
|
+
pt(l, f);
|
|
441
|
+
}), Rt(l, (f) => {
|
|
442
|
+
try {
|
|
443
|
+
W(f);
|
|
444
|
+
} catch {
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const i = Ht(t);
|
|
449
|
+
if (i)
|
|
450
|
+
for (let l = i.length - 1; l >= 0; --l) {
|
|
451
|
+
const f = i[l], p = f && f.name;
|
|
452
|
+
if (typeof p == "string")
|
|
453
|
+
try {
|
|
454
|
+
t.removeAttribute(p);
|
|
455
|
+
} catch {
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}, ot = function(t, n) {
|
|
459
|
+
try {
|
|
460
|
+
pt(o.removed, {
|
|
461
|
+
attribute: n.getAttributeNode(t),
|
|
462
|
+
from: n
|
|
463
|
+
});
|
|
464
|
+
} catch {
|
|
465
|
+
pt(o.removed, {
|
|
466
|
+
attribute: null,
|
|
467
|
+
from: n
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
if (n.removeAttribute(t), t === "is")
|
|
471
|
+
if (lt || Dt)
|
|
472
|
+
try {
|
|
473
|
+
K(n);
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
else
|
|
477
|
+
try {
|
|
478
|
+
n.setAttribute(t, "");
|
|
479
|
+
} catch {
|
|
480
|
+
}
|
|
481
|
+
}, Fn = function(t) {
|
|
482
|
+
const n = Ht(t);
|
|
483
|
+
if (n)
|
|
484
|
+
for (let i = n.length - 1; i >= 0; --i) {
|
|
485
|
+
const l = n[i], f = l && l.name;
|
|
486
|
+
if (!(typeof f != "string" || T[g(f)]))
|
|
487
|
+
try {
|
|
488
|
+
t.removeAttribute(f);
|
|
489
|
+
} catch {
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}, Un = function(t) {
|
|
493
|
+
const n = [t];
|
|
494
|
+
for (; n.length > 0; ) {
|
|
495
|
+
const i = n.pop();
|
|
496
|
+
(C ? C(i) : i.nodeType) === U.element && Fn(i);
|
|
497
|
+
const f = x(i);
|
|
498
|
+
if (f)
|
|
499
|
+
for (let p = f.length - 1; p >= 0; --p)
|
|
500
|
+
n.push(f[p]);
|
|
501
|
+
}
|
|
502
|
+
}, Fe = function(t) {
|
|
503
|
+
let n = null, i = null;
|
|
504
|
+
if (qt)
|
|
505
|
+
t = "<remove></remove>" + t;
|
|
506
|
+
else {
|
|
507
|
+
const p = Xe(t, /^[\r\n\t ]+/);
|
|
508
|
+
i = p && p[0];
|
|
509
|
+
}
|
|
510
|
+
bt === "application/xhtml+xml" && ut === F && (t = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + t + "</body></html>");
|
|
511
|
+
const l = D ? st(t) : t;
|
|
512
|
+
if (ut === F)
|
|
513
|
+
try {
|
|
514
|
+
n = new j().parseFromString(l, bt);
|
|
515
|
+
} catch {
|
|
516
|
+
}
|
|
517
|
+
if (!n || !n.documentElement) {
|
|
518
|
+
n = Wt.createDocument(ut, "template", null);
|
|
519
|
+
try {
|
|
520
|
+
n.documentElement.innerHTML = Jt ? et : l;
|
|
521
|
+
} catch {
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const f = n.body || n.documentElement;
|
|
525
|
+
return t && i && f.insertBefore(r.createTextNode(i), f.childNodes[0] || null), ut === F ? En.call(n, nt ? "html" : "body")[0] : nt ? n.documentElement : f;
|
|
526
|
+
}, Ue = function(t) {
|
|
527
|
+
return Te.call(
|
|
528
|
+
t.ownerDocument || t,
|
|
529
|
+
t,
|
|
530
|
+
// eslint-disable-next-line no-bitwise
|
|
531
|
+
w.SHOW_ELEMENT | w.SHOW_COMMENT | w.SHOW_TEXT | w.SHOW_PROCESSING_INSTRUCTION | w.SHOW_CDATA_SECTION,
|
|
532
|
+
null
|
|
533
|
+
);
|
|
534
|
+
}, Pt = function(t) {
|
|
535
|
+
return t = Nt(t, yn, " "), t = Nt(t, bn, " "), t = Nt(t, Sn, " "), t;
|
|
536
|
+
}, oe = function(t) {
|
|
537
|
+
var n;
|
|
538
|
+
t.normalize();
|
|
539
|
+
const i = Te.call(
|
|
540
|
+
t.ownerDocument || t,
|
|
541
|
+
t,
|
|
542
|
+
// eslint-disable-next-line no-bitwise
|
|
543
|
+
w.SHOW_TEXT | w.SHOW_COMMENT | w.SHOW_CDATA_SECTION | w.SHOW_PROCESSING_INSTRUCTION,
|
|
544
|
+
null
|
|
545
|
+
);
|
|
546
|
+
let l = i.nextNode();
|
|
547
|
+
for (; l; )
|
|
548
|
+
l.data = Pt(l.data), l = i.nextNode();
|
|
549
|
+
const f = (n = t.querySelectorAll) === null || n === void 0 ? void 0 : n.call(t, "template");
|
|
550
|
+
f && Rt(f, (p) => {
|
|
551
|
+
mt(p.content) && oe(p.content);
|
|
552
|
+
});
|
|
553
|
+
}, vt = function(t) {
|
|
554
|
+
const n = q ? q(t) : null;
|
|
555
|
+
return typeof n != "string" || g(n) !== "form" ? !1 : typeof t.nodeName != "string" || typeof t.textContent != "string" || typeof t.removeChild != "function" || // Realm-safe NamedNodeMap detection: equality against the cached
|
|
556
|
+
// prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
|
|
557
|
+
// makes the direct read diverge from the cached read; a clean form
|
|
558
|
+
// (same-realm OR foreign-realm) has both reads pointing at the same
|
|
559
|
+
// canonical NamedNodeMap.
|
|
560
|
+
t.attributes !== Ht(t) || typeof t.removeAttribute != "function" || typeof t.setAttribute != "function" || typeof t.namespaceURI != "string" || typeof t.insertBefore != "function" || typeof t.hasChildNodes != "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
|
|
561
|
+
// returns the integer 1 for any Element regardless of realm; direct
|
|
562
|
+
// read on a clobbered form (e.g. <input name="nodeType">) returns
|
|
563
|
+
// the named child element. Cheap addition — nodeType is read from
|
|
564
|
+
// an internal slot, no serialization cost — and removes a residual
|
|
565
|
+
// clobbering surface used by several mXSS / PI / comment branches
|
|
566
|
+
// in _sanitizeElements that compare currentNode.nodeType directly.
|
|
567
|
+
t.nodeType !== C(t) || // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
|
|
568
|
+
// "childNodes" shadows the prototype getter. Direct reads of
|
|
569
|
+
// form.childNodes from a clobbered form return the named child
|
|
570
|
+
// instead of the real NodeList, so any walk that reads it directly
|
|
571
|
+
// skips the form's real children. Compare the direct read to the
|
|
572
|
+
// cached Node.prototype getter — when the form's named-property
|
|
573
|
+
// getter intercepts the read, the two values differ and we flag
|
|
574
|
+
// the form. This catches every clobbering child type (input,
|
|
575
|
+
// select, etc.) regardless of whether the named child happens to
|
|
576
|
+
// carry a numeric .length, which a typeof-based probe would miss
|
|
577
|
+
// (e.g. HTMLSelectElement.length is a defined unsigned-long).
|
|
578
|
+
t.childNodes !== x(t);
|
|
579
|
+
}, mt = function(t) {
|
|
580
|
+
if (!C || typeof t != "object" || t === null)
|
|
581
|
+
return !1;
|
|
582
|
+
try {
|
|
583
|
+
return C(t) === U.documentFragment;
|
|
584
|
+
} catch {
|
|
585
|
+
return !1;
|
|
586
|
+
}
|
|
587
|
+
}, St = function(t) {
|
|
588
|
+
if (!C || typeof t != "object" || t === null)
|
|
589
|
+
return !1;
|
|
590
|
+
try {
|
|
591
|
+
return typeof C(t) == "number";
|
|
592
|
+
} catch {
|
|
593
|
+
return !1;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
function B(a, t, n) {
|
|
597
|
+
a.length !== 0 && Rt(a, (i) => {
|
|
598
|
+
i.call(o, t, n, ft);
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
const zn = function(t, n) {
|
|
602
|
+
return !!(yt && t.hasChildNodes() && !St(t.firstElementChild) && O(on, t.textContent) && O(on, t.innerHTML) || yt && t.namespaceURI === F && n === "style" && St(t.firstElementChild) || t.nodeType === U.processingInstruction || yt && t.nodeType === U.comment && O(Ao, t.data));
|
|
603
|
+
}, Hn = function(t, n) {
|
|
604
|
+
if (!At[n] && Ge(n) && (_.tagNameCheck instanceof RegExp && O(_.tagNameCheck, n) || _.tagNameCheck instanceof Function && _.tagNameCheck(n)))
|
|
605
|
+
return !1;
|
|
606
|
+
if (Xt && !k[n]) {
|
|
607
|
+
const i = $(t), l = x(t);
|
|
608
|
+
if (l && i) {
|
|
609
|
+
const f = l.length;
|
|
610
|
+
for (let p = f - 1; p >= 0; --p) {
|
|
611
|
+
const b = Vt ? l[p] : zt(l[p], !0);
|
|
612
|
+
i.insertBefore(b, tt(t));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return K(t), !0;
|
|
617
|
+
}, ze = function(t) {
|
|
618
|
+
if (B(E.beforeSanitizeElements, t, null), vt(t))
|
|
619
|
+
return K(t), !0;
|
|
620
|
+
const n = g(q ? q(t) : t.nodeName);
|
|
621
|
+
if (B(E.uponSanitizeElement, t, {
|
|
622
|
+
tagName: n,
|
|
623
|
+
allowedTags: h
|
|
624
|
+
}), zn(t, n))
|
|
625
|
+
return K(t), !0;
|
|
626
|
+
if (At[n] || !(X.tagCheck instanceof Function && X.tagCheck(n)) && !h[n])
|
|
627
|
+
return Hn(t, n);
|
|
628
|
+
if ((C ? C(t) : t.nodeType) === U.element && !kn(t) || (n === "noscript" || n === "noembed" || n === "noframes") && O(yo, t.innerHTML))
|
|
629
|
+
return K(t), !0;
|
|
630
|
+
if (V && t.nodeType === U.text) {
|
|
631
|
+
const l = Pt(t.textContent);
|
|
632
|
+
t.textContent !== l && (pt(o.removed, {
|
|
633
|
+
element: t.cloneNode()
|
|
634
|
+
}), t.textContent = l);
|
|
635
|
+
}
|
|
636
|
+
return B(E.afterSanitizeElements, t, null), !1;
|
|
637
|
+
}, He = function(t, n, i) {
|
|
638
|
+
if (ye[n] || Re && (n === "id" || n === "name") && (i in r || i in Mn))
|
|
639
|
+
return !1;
|
|
640
|
+
const l = T[n] || X.attributeCheck instanceof Function && X.attributeCheck(n, t);
|
|
641
|
+
if (!(Bt && O(On, n))) {
|
|
642
|
+
if (!(be && O(Rn, n))) {
|
|
643
|
+
if (l) {
|
|
644
|
+
if (!Zt[n]) {
|
|
645
|
+
if (!O(ge, Nt(i, _e, ""))) {
|
|
646
|
+
if (!((n === "src" || n === "xlink:href" || n === "href") && t !== "script" && Ve(i, "data:") === 0 && Ie[t])) {
|
|
647
|
+
if (!(Se && !O(Nn, Nt(i, _e, "")))) {
|
|
648
|
+
if (i)
|
|
649
|
+
return !1;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
} else if (
|
|
655
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
656
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
657
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
658
|
+
!(Ge(t) && (_.tagNameCheck instanceof RegExp && O(_.tagNameCheck, t) || _.tagNameCheck instanceof Function && _.tagNameCheck(t)) && (_.attributeNameCheck instanceof RegExp && O(_.attributeNameCheck, n) || _.attributeNameCheck instanceof Function && _.attributeNameCheck(n, t)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
659
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
660
|
+
n === "is" && _.allowCustomizedBuiltInElements && (_.tagNameCheck instanceof RegExp && O(_.tagNameCheck, i) || _.tagNameCheck instanceof Function && _.tagNameCheck(i)))
|
|
661
|
+
) return !1;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return !0;
|
|
665
|
+
}, Gn = m({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), Ge = function(t) {
|
|
666
|
+
return !Gn[It(t)] && O(wn, t);
|
|
667
|
+
}, Wn = function(t, n, i, l) {
|
|
668
|
+
if (D && typeof _t == "object" && typeof _t.getAttributeType == "function" && !i)
|
|
669
|
+
switch (_t.getAttributeType(t, n)) {
|
|
670
|
+
case "TrustedHTML":
|
|
671
|
+
return st(l);
|
|
672
|
+
case "TrustedScriptURL":
|
|
673
|
+
return Tn(l);
|
|
674
|
+
}
|
|
675
|
+
return l;
|
|
676
|
+
}, Bn = function(t, n, i, l) {
|
|
677
|
+
try {
|
|
678
|
+
i ? t.setAttributeNS(i, n, l) : t.setAttribute(n, l), vt(t) ? K(t) : qe(o.removed);
|
|
679
|
+
} catch {
|
|
680
|
+
ot(n, t);
|
|
681
|
+
}
|
|
682
|
+
}, We = function(t) {
|
|
683
|
+
B(E.beforeSanitizeAttributes, t, null);
|
|
684
|
+
const n = t.attributes;
|
|
685
|
+
if (!n || vt(t))
|
|
686
|
+
return;
|
|
687
|
+
const i = {
|
|
688
|
+
attrName: "",
|
|
689
|
+
attrValue: "",
|
|
690
|
+
keepAttr: !0,
|
|
691
|
+
allowedAttributes: T,
|
|
692
|
+
forceKeepAttr: void 0
|
|
693
|
+
};
|
|
694
|
+
let l = n.length;
|
|
695
|
+
const f = g(t.nodeName);
|
|
696
|
+
for (; l--; ) {
|
|
697
|
+
const p = n[l], b = p.name, A = p.namespaceURI, M = p.value, P = g(b), ie = M;
|
|
698
|
+
let I = b === "value" ? ie : eo(ie);
|
|
699
|
+
if (i.attrName = P, i.attrValue = I, i.keepAttr = !0, i.forceKeepAttr = void 0, B(E.uponSanitizeAttribute, t, i), I = i.attrValue, Ne && (P === "id" || P === "name") && Ve(I, we) !== 0 && (ot(b, t), I = we + I), yt && O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, I)) {
|
|
700
|
+
ot(b, t);
|
|
701
|
+
continue;
|
|
702
|
+
}
|
|
703
|
+
if (P === "attributename" && Xe(I, "href")) {
|
|
704
|
+
ot(b, t);
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (!i.forceKeepAttr) {
|
|
708
|
+
if (!i.keepAttr) {
|
|
709
|
+
ot(b, t);
|
|
710
|
+
continue;
|
|
711
|
+
}
|
|
712
|
+
if (!Oe && O(bo, I)) {
|
|
713
|
+
ot(b, t);
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (V && (I = Pt(I)), !He(f, P, I)) {
|
|
717
|
+
ot(b, t);
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
I = Wn(f, P, A, I), I !== ie && Bn(t, b, A, I);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
B(E.afterSanitizeAttributes, t, null);
|
|
724
|
+
}, kt = function(t) {
|
|
725
|
+
let n = null;
|
|
726
|
+
const i = Ue(t);
|
|
727
|
+
for (B(E.beforeSanitizeShadowDOM, t, null); n = i.nextNode(); )
|
|
728
|
+
if (B(E.uponSanitizeShadowNode, n, null), ze(n), We(n), mt(n.content) && kt(n.content), (C ? C(n) : n.nodeType) === U.element) {
|
|
729
|
+
const f = gt(n);
|
|
730
|
+
mt(f) && (re(f), kt(f));
|
|
731
|
+
}
|
|
732
|
+
B(E.afterSanitizeShadowDOM, t, null);
|
|
733
|
+
}, re = function(t) {
|
|
734
|
+
const n = [{
|
|
735
|
+
node: t,
|
|
736
|
+
shadow: null
|
|
737
|
+
}];
|
|
738
|
+
for (; n.length > 0; ) {
|
|
739
|
+
const i = n.pop();
|
|
740
|
+
if (i.shadow) {
|
|
741
|
+
kt(i.shadow);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
const l = i.node, p = (C ? C(l) : l.nodeType) === U.element, b = x(l);
|
|
745
|
+
if (b)
|
|
746
|
+
for (let A = b.length - 1; A >= 0; --A)
|
|
747
|
+
n.push({
|
|
748
|
+
node: b[A],
|
|
749
|
+
shadow: null
|
|
750
|
+
});
|
|
751
|
+
if (p) {
|
|
752
|
+
const A = q ? q(l) : null;
|
|
753
|
+
if (typeof A == "string" && g(A) === "template") {
|
|
754
|
+
const M = l.content;
|
|
755
|
+
mt(M) && n.push({
|
|
756
|
+
node: M,
|
|
757
|
+
shadow: null
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (p) {
|
|
762
|
+
const A = gt(l);
|
|
763
|
+
mt(A) && n.push({
|
|
764
|
+
node: null,
|
|
765
|
+
shadow: A
|
|
766
|
+
}, {
|
|
767
|
+
node: A,
|
|
768
|
+
shadow: null
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
return o.sanitize = function(a) {
|
|
774
|
+
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = null, i = null, l = null, f = null;
|
|
775
|
+
if (Jt = !a, Jt && (a = "<!-->"), typeof a != "string" && !St(a) && (a = ao(a), typeof a != "string"))
|
|
776
|
+
throw it("dirty is not a string, aborting");
|
|
777
|
+
if (!o.isSupported)
|
|
778
|
+
return a;
|
|
779
|
+
Yt ? (h = jt, T = $t) : ne(t), (E.uponSanitizeElement.length > 0 || E.uponSanitizeAttribute.length > 0) && (h = L(h)), E.uponSanitizeAttribute.length > 0 && (T = L(T)), o.removed = [];
|
|
780
|
+
const p = Vt && typeof a != "string" && St(a);
|
|
781
|
+
if (p) {
|
|
782
|
+
const M = q ? q(a) : a.nodeName;
|
|
783
|
+
if (typeof M == "string") {
|
|
784
|
+
const P = g(M);
|
|
785
|
+
if (!h[P] || At[P])
|
|
786
|
+
throw it("root node is forbidden and cannot be sanitized in-place");
|
|
787
|
+
}
|
|
788
|
+
if (vt(a))
|
|
789
|
+
throw it("root node is clobbered and cannot be sanitized in-place");
|
|
790
|
+
try {
|
|
791
|
+
re(a);
|
|
792
|
+
} catch (P) {
|
|
793
|
+
throw ke(a), P;
|
|
794
|
+
}
|
|
795
|
+
} else if (St(a))
|
|
796
|
+
n = Fe("<!---->"), i = n.ownerDocument.importNode(a, !0), i.nodeType === U.element && i.nodeName === "BODY" || i.nodeName === "HTML" ? n = i : n.appendChild(i), re(i);
|
|
797
|
+
else {
|
|
798
|
+
if (!lt && !V && !nt && // eslint-disable-next-line unicorn/prefer-includes
|
|
799
|
+
a.indexOf("<") === -1)
|
|
800
|
+
return D && Ct ? st(a) : a;
|
|
801
|
+
if (n = Fe(a), !n)
|
|
802
|
+
return lt ? null : Ct ? et : "";
|
|
803
|
+
}
|
|
804
|
+
n && qt && K(n.firstChild);
|
|
805
|
+
const b = Ue(p ? a : n);
|
|
806
|
+
try {
|
|
807
|
+
for (; l = b.nextNode(); )
|
|
808
|
+
ze(l), We(l), mt(l.content) && kt(l.content);
|
|
809
|
+
} catch (M) {
|
|
810
|
+
throw p && ke(a), M;
|
|
811
|
+
}
|
|
812
|
+
if (p)
|
|
813
|
+
return Rt(o.removed, (M) => {
|
|
814
|
+
M.element && Un(M.element);
|
|
815
|
+
}), V && oe(a), a;
|
|
816
|
+
if (lt) {
|
|
817
|
+
if (V && oe(n), Dt)
|
|
818
|
+
for (f = gn.call(n.ownerDocument); n.firstChild; )
|
|
819
|
+
f.appendChild(n.firstChild);
|
|
820
|
+
else
|
|
821
|
+
f = n;
|
|
822
|
+
return (T.shadowroot || T.shadowrootmode) && (f = An.call(s, f, !0)), f;
|
|
823
|
+
}
|
|
824
|
+
let A = nt ? n.outerHTML : n.innerHTML;
|
|
825
|
+
return nt && h["!doctype"] && n.ownerDocument && n.ownerDocument.doctype && n.ownerDocument.doctype.name && O(go, n.ownerDocument.doctype.name) && (A = "<!DOCTYPE " + n.ownerDocument.doctype.name + `>
|
|
826
|
+
` + A), V && (A = Pt(A)), D && Ct ? st(A) : A;
|
|
827
|
+
}, o.setConfig = function() {
|
|
828
|
+
let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
829
|
+
ne(a), Yt = !0, jt = h, $t = T;
|
|
830
|
+
}, o.clearConfig = function() {
|
|
831
|
+
ft = null, Yt = !1, jt = null, $t = null, D = Gt, et = "";
|
|
832
|
+
}, o.isValidAttribute = function(a, t, n) {
|
|
833
|
+
ft || ne({});
|
|
834
|
+
const i = g(a), l = g(t);
|
|
835
|
+
return He(i, l, n);
|
|
836
|
+
}, o.addHook = function(a, t) {
|
|
837
|
+
typeof t == "function" && S(E, a) && pt(E[a], t);
|
|
838
|
+
}, o.removeHook = function(a, t) {
|
|
839
|
+
if (S(E, a)) {
|
|
840
|
+
if (t !== void 0) {
|
|
841
|
+
const n = Qn(E[a], t);
|
|
842
|
+
return n === -1 ? void 0 : to(E[a], n, 1)[0];
|
|
843
|
+
}
|
|
844
|
+
return qe(E[a]);
|
|
845
|
+
}
|
|
846
|
+
}, o.removeHooks = function(a) {
|
|
847
|
+
S(E, a) && (E[a] = []);
|
|
848
|
+
}, o.removeAllHooks = function() {
|
|
849
|
+
E = rn();
|
|
850
|
+
}, o;
|
|
851
|
+
}
|
|
852
|
+
var Ro = mn();
|
|
853
|
+
function Bo(e) {
|
|
854
|
+
return Ro.sanitize(e);
|
|
855
|
+
}
|
|
856
|
+
const pn = 320;
|
|
857
|
+
function No(e) {
|
|
858
|
+
const o = Array.from(e.querySelectorAll("thead th")).map(
|
|
859
|
+
(u) => u.textContent ?? ""
|
|
860
|
+
), r = Array.from(e.querySelectorAll("tbody tr")).map(
|
|
861
|
+
(u) => Array.from(u.querySelectorAll("td")).map((d) => d.textContent ?? "")
|
|
862
|
+
);
|
|
863
|
+
if (o.length < 2 || r.length === 0)
|
|
864
|
+
return null;
|
|
865
|
+
const s = r.map((u) => u[0] ?? ""), c = o.slice(1).map((u, d) => ({
|
|
866
|
+
name: u,
|
|
867
|
+
values: r.map((v) => Number(v[d + 1] ?? ""))
|
|
868
|
+
}));
|
|
869
|
+
return { labels: s, series: c };
|
|
870
|
+
}
|
|
871
|
+
const an = ["#2563eb", "#dc2626", "#16a34a", "#d97706", "#7c3aed"];
|
|
872
|
+
async function wo(e) {
|
|
873
|
+
const o = No(e);
|
|
874
|
+
if (!o)
|
|
875
|
+
return null;
|
|
876
|
+
const { default: r } = await import("uplot"), s = e.getAttribute("data-kind") ?? "line", u = [o.labels.map((W, tt) => tt), ...o.series.map((W) => W.values)], d = getComputedStyle(e).color || "#1a1a2e", v = "rgba(128, 128, 128, 0.18)", w = {
|
|
877
|
+
stroke: d,
|
|
878
|
+
grid: { stroke: v, width: 1 },
|
|
879
|
+
ticks: { stroke: v, width: 1 }
|
|
880
|
+
}, H = e.querySelector("table"), j = document.createElement("div");
|
|
881
|
+
j.className = "alt-chart-canvas", e.prepend(j);
|
|
882
|
+
const G = {
|
|
883
|
+
width: j.clientWidth || e.clientWidth || 640,
|
|
884
|
+
height: pn,
|
|
885
|
+
scales: { x: { time: !1 } },
|
|
886
|
+
// A crosshair cursor that highlights the nearest series, and drag to zoom the
|
|
887
|
+
// x-axis (double-click resets). The legend below the chart tracks the value
|
|
888
|
+
// under the cursor.
|
|
889
|
+
cursor: { drag: { x: !0, y: !1 }, focus: { prox: 30 } },
|
|
890
|
+
axes: [
|
|
891
|
+
{ ...w, values: (W, tt) => tt.map((x) => o.labels[x] ?? "") },
|
|
892
|
+
{ ...w }
|
|
893
|
+
],
|
|
894
|
+
series: [
|
|
895
|
+
{},
|
|
896
|
+
...o.series.map((W, tt) => {
|
|
897
|
+
var $, gt;
|
|
898
|
+
const x = an[tt % an.length];
|
|
899
|
+
return s === "bar" ? { label: W.name, stroke: x, fill: x, paths: (gt = ($ = r.paths).bars) == null ? void 0 : gt.call($, { size: [0.6] }) } : { label: W.name, stroke: x, width: 2, points: { show: !0 } };
|
|
900
|
+
})
|
|
901
|
+
]
|
|
902
|
+
}, zt = new r(G, u, j);
|
|
903
|
+
return H == null || H.classList.add("alt-visually-hidden"), zt;
|
|
904
|
+
}
|
|
905
|
+
async function Io(e) {
|
|
906
|
+
const o = e.querySelector("code"), r = ((o == null ? void 0 : o.textContent) ?? e.textContent ?? "").trim();
|
|
907
|
+
if (!r)
|
|
908
|
+
return;
|
|
909
|
+
const { default: s } = await import("katex"), c = document.createElement("div");
|
|
910
|
+
c.className = "alt-math-rendered", s.render(r, c, { throwOnError: !1, displayMode: !0 }), e.prepend(c), o == null || o.classList.add("alt-visually-hidden");
|
|
911
|
+
}
|
|
912
|
+
let sn = 0, ln = null;
|
|
913
|
+
function Lo() {
|
|
914
|
+
return ln ?? (ln = import("mermaid").then(({ default: e }) => (e.initialize({ startOnLoad: !1, securityLevel: "strict" }), e))), ln;
|
|
915
|
+
}
|
|
916
|
+
function Do(e) {
|
|
917
|
+
const o = e.match(/viewBox="[\d.-]+ [\d.-]+ [\d.-]+ ([\d.]+)"/);
|
|
918
|
+
return o ? Math.min(Math.max(Math.round(Number(o[1])) + 24, 80), 800) : 320;
|
|
919
|
+
}
|
|
920
|
+
async function Co(e) {
|
|
921
|
+
var u;
|
|
922
|
+
const o = (((u = e.querySelector("pre")) == null ? void 0 : u.textContent) ?? e.textContent ?? "").trim();
|
|
923
|
+
if (!o)
|
|
924
|
+
return;
|
|
925
|
+
const r = await Lo();
|
|
926
|
+
sn += 1;
|
|
927
|
+
let s;
|
|
928
|
+
try {
|
|
929
|
+
({ svg: s } = await r.render(`altmd-diagram-${String(sn)}`, o));
|
|
930
|
+
} catch {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const c = cn({
|
|
934
|
+
html: s,
|
|
935
|
+
allowScripts: !1,
|
|
936
|
+
height: Do(s),
|
|
937
|
+
title: "diagram"
|
|
938
|
+
});
|
|
939
|
+
e.replaceChildren(c);
|
|
940
|
+
}
|
|
941
|
+
const Mo = [
|
|
942
|
+
"callout",
|
|
943
|
+
"tabs",
|
|
944
|
+
"accordion",
|
|
945
|
+
"columns",
|
|
946
|
+
"chart",
|
|
947
|
+
"math",
|
|
948
|
+
"table",
|
|
949
|
+
"diagram",
|
|
950
|
+
"embed"
|
|
951
|
+
], xo = [...Mo, "tab", "column", "sandbox"];
|
|
952
|
+
class Tt extends HTMLElement {
|
|
953
|
+
connectedCallback() {
|
|
954
|
+
this.setAttribute("data-altmd-upgraded", ""), this.enhance();
|
|
955
|
+
}
|
|
956
|
+
// Overridden by components that enhance their fallback.
|
|
957
|
+
enhance() {
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
class Po extends Tt {
|
|
961
|
+
enhance() {
|
|
962
|
+
const o = this.ownTabs();
|
|
963
|
+
if (o.length === 0)
|
|
964
|
+
return;
|
|
965
|
+
const r = document.createElement("div");
|
|
966
|
+
r.className = "alt-tablist", r.setAttribute("role", "tablist"), o.forEach((s, c) => {
|
|
967
|
+
const u = document.createElement("button");
|
|
968
|
+
u.type = "button", u.setAttribute("role", "tab"), u.textContent = s.getAttribute("data-title") ?? `Tab ${String(c + 1)}`, u.addEventListener("click", () => {
|
|
969
|
+
this.select(c);
|
|
970
|
+
}), r.appendChild(u);
|
|
971
|
+
}), this.prepend(r), this.select(0);
|
|
972
|
+
}
|
|
973
|
+
ownTabs() {
|
|
974
|
+
return Array.from(this.querySelectorAll("alt-tab")).filter(
|
|
975
|
+
(o) => o.closest("alt-tabs") === this
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
select(o) {
|
|
979
|
+
this.ownTabs().forEach((s, c) => {
|
|
980
|
+
s.hidden = c !== o;
|
|
981
|
+
}), Array.from(this.querySelectorAll(".alt-tablist > button")).forEach((s, c) => {
|
|
982
|
+
s.setAttribute("aria-selected", c === o ? "true" : "false");
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
var ht, at, Y, Ut, dn;
|
|
987
|
+
class vo extends Tt {
|
|
988
|
+
constructor() {
|
|
989
|
+
super(...arguments);
|
|
990
|
+
Ot(this, Ut);
|
|
991
|
+
Ot(this, ht, null);
|
|
992
|
+
Ot(this, at, null);
|
|
993
|
+
Ot(this, Y, 0);
|
|
994
|
+
}
|
|
995
|
+
enhance() {
|
|
996
|
+
wo(this).then((r) => {
|
|
997
|
+
if (!r || !this.isConnected) {
|
|
998
|
+
r == null || r.destroy();
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
Z(this, ht, r), Ye(this, Ut, dn).call(this, r);
|
|
1002
|
+
}).catch(() => {
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
disconnectedCallback() {
|
|
1006
|
+
var r, s;
|
|
1007
|
+
(r = rt(this, at)) == null || r.disconnect(), Z(this, at, null), rt(this, Y) && (cancelAnimationFrame(rt(this, Y)), Z(this, Y, 0)), (s = rt(this, ht)) == null || s.destroy(), Z(this, ht, null);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
ht = new WeakMap(), at = new WeakMap(), Y = new WeakMap(), Ut = new WeakSet(), /**
|
|
1011
|
+
* Reflow the chart to the container width whenever it changes, so a split or
|
|
1012
|
+
* resized pane never leaves a fixed-width canvas spilling past its column.
|
|
1013
|
+
* uPlot draws to a pixel canvas with no intrinsic responsiveness, so the width
|
|
1014
|
+
* has to be pushed in explicitly.
|
|
1015
|
+
*/
|
|
1016
|
+
dn = function(r) {
|
|
1017
|
+
const s = this.querySelector(".alt-chart-canvas") ?? this, c = () => {
|
|
1018
|
+
const u = s.clientWidth;
|
|
1019
|
+
u > 0 && Math.abs(u - r.width) > 1 && r.setSize({ width: u, height: pn });
|
|
1020
|
+
};
|
|
1021
|
+
c(), !(typeof ResizeObserver > "u") && (Z(this, at, new ResizeObserver(() => {
|
|
1022
|
+
rt(this, Y) || Z(this, Y, requestAnimationFrame(() => {
|
|
1023
|
+
Z(this, Y, 0), c();
|
|
1024
|
+
}));
|
|
1025
|
+
})), rt(this, at).observe(s));
|
|
1026
|
+
};
|
|
1027
|
+
class ko extends Tt {
|
|
1028
|
+
enhance() {
|
|
1029
|
+
Io(this).catch(() => {
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
class Fo extends Tt {
|
|
1034
|
+
enhance() {
|
|
1035
|
+
Co(this).catch(() => {
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
class Uo extends Tt {
|
|
1040
|
+
enhance() {
|
|
1041
|
+
const o = cn({
|
|
1042
|
+
html: this.innerHTML,
|
|
1043
|
+
allowScripts: !0,
|
|
1044
|
+
title: this.localName
|
|
1045
|
+
});
|
|
1046
|
+
this.replaceChildren(o);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
function zo(e) {
|
|
1050
|
+
return e === "tabs" ? Po : e === "chart" ? vo : e === "math" ? ko : e === "diagram" ? Fo : e === "sandbox" ? Uo : Tt;
|
|
1051
|
+
}
|
|
1052
|
+
function Ho(e) {
|
|
1053
|
+
e.querySelectorAll(
|
|
1054
|
+
"li.task-list-item > input[type='checkbox']"
|
|
1055
|
+
).forEach((r, s) => {
|
|
1056
|
+
r.disabled = !1, r.addEventListener("change", () => {
|
|
1057
|
+
r.dispatchEvent(
|
|
1058
|
+
new CustomEvent("altmd:taskchange", {
|
|
1059
|
+
bubbles: !0,
|
|
1060
|
+
detail: { index: s, checked: r.checked }
|
|
1061
|
+
})
|
|
1062
|
+
);
|
|
1063
|
+
});
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
function hn() {
|
|
1067
|
+
for (const e of xo) {
|
|
1068
|
+
const o = `alt-${e}`;
|
|
1069
|
+
if (customElements.get(o) === void 0) {
|
|
1070
|
+
const r = zo(e);
|
|
1071
|
+
customElements.define(o, class extends r {
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
function Go(e, o) {
|
|
1077
|
+
hn(), e.innerHTML = o, Ho(e);
|
|
1078
|
+
}
|
|
1079
|
+
function Yo(e, o, r) {
|
|
1080
|
+
Go(e, r(o));
|
|
1081
|
+
}
|
|
1082
|
+
const jo = "0.1.0";
|
|
1083
|
+
function $o() {
|
|
1084
|
+
hn();
|
|
1085
|
+
}
|
|
1086
|
+
export {
|
|
1087
|
+
Tt as AltElement,
|
|
1088
|
+
Mo as V1_COMPONENTS,
|
|
1089
|
+
jo as VERSION,
|
|
1090
|
+
$o as bootstrap,
|
|
1091
|
+
Yn as buildSrcdoc,
|
|
1092
|
+
cn as createSandboxedFrame,
|
|
1093
|
+
Ho as enhanceTaskLists,
|
|
1094
|
+
Go as mount,
|
|
1095
|
+
hn as registerComponents,
|
|
1096
|
+
Yo as renderInto,
|
|
1097
|
+
Bo as sanitizeHtml
|
|
1098
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@altmd/runtime",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The zero-build alt-markdown CDN runtime (loads the WASM core, upgrades components).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Daniel Iwugo",
|
|
7
|
+
"homepage": "https://github.com/elementmerc/alt-markdown#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/elementmerc/alt-markdown.git",
|
|
11
|
+
"directory": "js/packages/runtime"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/elementmerc/alt-markdown/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"markdown",
|
|
18
|
+
"commonmark",
|
|
19
|
+
"web-components",
|
|
20
|
+
"charts",
|
|
21
|
+
"diagrams",
|
|
22
|
+
"katex",
|
|
23
|
+
"mermaid",
|
|
24
|
+
"zero-build",
|
|
25
|
+
"alt-markdown"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./dist/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"dompurify": "^3.4.11"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"katex": "^0.16",
|
|
46
|
+
"mermaid": "^11",
|
|
47
|
+
"uplot": "^1.6"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"katex": { "optional": true },
|
|
51
|
+
"mermaid": { "optional": true },
|
|
52
|
+
"uplot": { "optional": true }
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "vite build",
|
|
56
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
57
|
+
}
|
|
58
|
+
}
|