@clevertask/scribe 0.0.11 → 0.0.12

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.
Files changed (32) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/components/Menu/BubbleMenu.js +1 -1
  3. package/dist/components/Menu/Mobile/ListOptionBar.d.ts +6 -0
  4. package/dist/components/Menu/Mobile/ListOptionBar.js +40 -0
  5. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  6. package/dist/components/Scribe/extension/extension-link.js +240 -244
  7. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  8. package/dist/components/Scribe/extension/index.d.ts +1 -1
  9. package/dist/components/Scribe/extension/index.js +24 -25
  10. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +5 -5
  11. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  12. package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
  13. package/dist/components/Scribe/index.d.ts +1 -0
  14. package/dist/components/Scribe/index.js +83 -60
  15. package/dist/index-B0pieAxt.js +160 -0
  16. package/dist/{index-CasgquAq.js → index-CCS9HOYd.js} +16838 -5188
  17. package/dist/{index-DeZ8laak.js → index-DoNRu1rY.js} +1573 -1513
  18. package/dist/index-VneQGVTd.js +2385 -0
  19. package/dist/main.css +4 -4
  20. package/dist/marked.esm-BS_MmRZC.js +1566 -0
  21. package/dist/purify.es-BGaRrCfO.js +553 -0
  22. package/dist/turndown.browser.es-RmA_HBaI.js +649 -0
  23. package/dist/utils/create-scribe-editor.js +7 -6
  24. package/dist/utils/html-to-markdown.js +7 -6
  25. package/dist/utils/markdown-to-html.js +4 -3
  26. package/package.json +13 -12
  27. package/dist/browser-BJWkU9cc.js +0 -2106
  28. package/dist/components/Scribe/extension/math-extension.d.ts +0 -2
  29. package/dist/components/Scribe/extension/math-extension.js +0 -11770
  30. package/dist/index-BqFHWqw6.js +0 -156
  31. package/dist/index-C_aWB8qt.js +0 -2291
  32. package/dist/turndown.browser.es-C1wFFc_i.js +0 -1172
@@ -1,1172 +0,0 @@
1
- /*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */
2
- const {
3
- entries: Dt,
4
- setPrototypeOf: Et,
5
- isFrozen: cn,
6
- getPrototypeOf: fn,
7
- getOwnPropertyDescriptor: un
8
- } = Object;
9
- let {
10
- freeze: v,
11
- seal: C,
12
- create: Ct
13
- } = Object, {
14
- apply: Be,
15
- construct: ze
16
- } = typeof Reflect < "u" && Reflect;
17
- v || (v = function(t) {
18
- return t;
19
- });
20
- C || (C = function(t) {
21
- return t;
22
- });
23
- Be || (Be = function(t, r, i) {
24
- return t.apply(r, i);
25
- });
26
- ze || (ze = function(t, r) {
27
- return new t(...r);
28
- });
29
- const me = b(Array.prototype.forEach), mn = b(Array.prototype.lastIndexOf), At = b(Array.prototype.pop), Q = b(Array.prototype.push), pn = b(Array.prototype.splice), de = b(String.prototype.toLowerCase), Me = b(String.prototype.toString), _t = b(String.prototype.match), J = b(String.prototype.replace), dn = b(String.prototype.indexOf), hn = b(String.prototype.trim), I = b(Object.prototype.hasOwnProperty), O = b(RegExp.prototype.test), ee = gn(TypeError);
30
- function b(e) {
31
- return function(t) {
32
- t instanceof RegExp && (t.lastIndex = 0);
33
- for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), s = 1; s < r; s++)
34
- i[s - 1] = arguments[s];
35
- return Be(e, t, i);
36
- };
37
- }
38
- function gn(e) {
39
- return function() {
40
- for (var t = arguments.length, r = new Array(t), i = 0; i < t; i++)
41
- r[i] = arguments[i];
42
- return ze(e, r);
43
- };
44
- }
45
- function f(e, t) {
46
- let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : de;
47
- Et && Et(e, null);
48
- let i = t.length;
49
- for (; i--; ) {
50
- let s = t[i];
51
- if (typeof s == "string") {
52
- const c = r(s);
53
- c !== s && (cn(t) || (t[i] = c), s = c);
54
- }
55
- e[s] = !0;
56
- }
57
- return e;
58
- }
59
- function Tn(e) {
60
- for (let t = 0; t < e.length; t++)
61
- I(e, t) || (e[t] = null);
62
- return e;
63
- }
64
- function P(e) {
65
- const t = Ct(null);
66
- for (const [r, i] of Dt(e))
67
- I(e, r) && (Array.isArray(i) ? t[r] = Tn(i) : i && typeof i == "object" && i.constructor === Object ? t[r] = P(i) : t[r] = i);
68
- return t;
69
- }
70
- function te(e, t) {
71
- for (; e !== null; ) {
72
- const i = un(e, t);
73
- if (i) {
74
- if (i.get)
75
- return b(i.get);
76
- if (typeof i.value == "function")
77
- return b(i.value);
78
- }
79
- e = fn(e);
80
- }
81
- function r() {
82
- return null;
83
- }
84
- return r;
85
- }
86
- const St = v(["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"]), we = v(["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"]), ke = v(["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"]), En = v(["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"]), xe = v(["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"]), An = v(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Rt = v(["#text"]), yt = v(["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", "popover", "popovertarget", "popovertargetaction", "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", "wrap", "xmlns", "slot"]), Pe = v(["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", "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"]), Nt = v(["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"]), pe = v(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), _n = C(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Sn = C(/<%[\w\W]*|[\w\W]*%>/gm), Rn = C(/\$\{[\w\W]*/gm), yn = C(/^data-[\-\w.\u00B7-\uFFFF]+$/), Nn = C(/^aria-[\-\w]+$/), It = C(
87
- /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
88
- // eslint-disable-line no-useless-escape
89
- ), On = C(/^(?:\w+script|data):/i), vn = C(
90
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
91
- // eslint-disable-line no-control-regex
92
- ), Mt = C(/^html$/i), bn = C(/^[a-z][.\w]*(-[.\w]+)+$/i);
93
- var Ot = /* @__PURE__ */ Object.freeze({
94
- __proto__: null,
95
- ARIA_ATTR: Nn,
96
- ATTR_WHITESPACE: vn,
97
- CUSTOM_ELEMENT: bn,
98
- DATA_ATTR: yn,
99
- DOCTYPE_NAME: Mt,
100
- ERB_EXPR: Sn,
101
- IS_ALLOWED_URI: It,
102
- IS_SCRIPT_OR_DATA: On,
103
- MUSTACHE_EXPR: _n,
104
- TMPLIT_EXPR: Rn
105
- });
106
- const ne = {
107
- element: 1,
108
- text: 3,
109
- // Deprecated
110
- progressingInstruction: 7,
111
- comment: 8,
112
- document: 9
113
- }, Ln = function() {
114
- return typeof window > "u" ? null : window;
115
- }, Dn = function(t, r) {
116
- if (typeof t != "object" || typeof t.createPolicy != "function")
117
- return null;
118
- let i = null;
119
- const s = "data-tt-policy-suffix";
120
- r && r.hasAttribute(s) && (i = r.getAttribute(s));
121
- const c = "dompurify" + (i ? "#" + i : "");
122
- try {
123
- return t.createPolicy(c, {
124
- createHTML(p) {
125
- return p;
126
- },
127
- createScriptURL(p) {
128
- return p;
129
- }
130
- });
131
- } catch {
132
- return console.warn("TrustedTypes policy " + c + " could not be created."), null;
133
- }
134
- }, vt = function() {
135
- return {
136
- afterSanitizeAttributes: [],
137
- afterSanitizeElements: [],
138
- afterSanitizeShadowDOM: [],
139
- beforeSanitizeAttributes: [],
140
- beforeSanitizeElements: [],
141
- beforeSanitizeShadowDOM: [],
142
- uponSanitizeAttribute: [],
143
- uponSanitizeElement: [],
144
- uponSanitizeShadowNode: []
145
- };
146
- };
147
- function wt() {
148
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Ln();
149
- const t = (l) => wt(l);
150
- if (t.version = "3.2.6", t.removed = [], !e || !e.document || e.document.nodeType !== ne.document || !e.Element)
151
- return t.isSupported = !1, t;
152
- let {
153
- document: r
154
- } = e;
155
- const i = r, s = i.currentScript, {
156
- DocumentFragment: c,
157
- HTMLTemplateElement: p,
158
- Node: L,
159
- Element: m,
160
- NodeFilter: R,
161
- NamedNodeMap: F = e.NamedNodeMap || e.MozNamedAttrMap,
162
- HTMLFormElement: ge,
163
- DOMParser: zt,
164
- trustedTypes: re
165
- } = e, V = m.prototype, Wt = te(V, "cloneNode"), Gt = te(V, "remove"), Yt = te(V, "nextSibling"), $t = te(V, "childNodes"), ie = te(V, "parentNode");
166
- if (typeof p == "function") {
167
- const l = r.createElement("template");
168
- l.content && l.content.ownerDocument && (r = l.content.ownerDocument);
169
- }
170
- let y, X = "";
171
- const {
172
- implementation: Te,
173
- createNodeIterator: Vt,
174
- createDocumentFragment: Xt,
175
- getElementsByTagName: jt
176
- } = r, {
177
- importNode: Kt
178
- } = i;
179
- let N = vt();
180
- t.isSupported = typeof Dt == "function" && typeof ie == "function" && Te && Te.createHTMLDocument !== void 0;
181
- const {
182
- MUSTACHE_EXPR: Ee,
183
- ERB_EXPR: Ae,
184
- TMPLIT_EXPR: _e,
185
- DATA_ATTR: qt,
186
- ARIA_ATTR: Zt,
187
- IS_SCRIPT_OR_DATA: Qt,
188
- ATTR_WHITESPACE: Xe,
189
- CUSTOM_ELEMENT: Jt
190
- } = Ot;
191
- let {
192
- IS_ALLOWED_URI: je
193
- } = Ot, g = null;
194
- const Ke = f({}, [...St, ...we, ...ke, ...xe, ...Rt]);
195
- let E = null;
196
- const qe = f({}, [...yt, ...Pe, ...Nt, ...pe]);
197
- let d = Object.seal(Ct(null, {
198
- tagNameCheck: {
199
- writable: !0,
200
- configurable: !1,
201
- enumerable: !0,
202
- value: null
203
- },
204
- attributeNameCheck: {
205
- writable: !0,
206
- configurable: !1,
207
- enumerable: !0,
208
- value: null
209
- },
210
- allowCustomizedBuiltInElements: {
211
- writable: !0,
212
- configurable: !1,
213
- enumerable: !0,
214
- value: !1
215
- }
216
- })), j = null, Se = null, Ze = !0, Re = !0, Qe = !1, Je = !0, H = !1, ae = !0, U = !1, ye = !1, Ne = !1, B = !1, oe = !1, le = !1, et = !0, tt = !1;
217
- const en = "user-content-";
218
- let Oe = !0, K = !1, z = {}, W = null;
219
- const nt = f({}, ["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"]);
220
- let rt = null;
221
- const it = f({}, ["audio", "video", "img", "source", "image", "track"]);
222
- let ve = null;
223
- const at = f({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), se = "http://www.w3.org/1998/Math/MathML", ce = "http://www.w3.org/2000/svg", w = "http://www.w3.org/1999/xhtml";
224
- let G = w, be = !1, Le = null;
225
- const tn = f({}, [se, ce, w], Me);
226
- let fe = f({}, ["mi", "mo", "mn", "ms", "mtext"]), ue = f({}, ["annotation-xml"]);
227
- const nn = f({}, ["title", "style", "font", "a", "script"]);
228
- let q = null;
229
- const rn = ["application/xhtml+xml", "text/html"], an = "text/html";
230
- let T = null, Y = null;
231
- const on = r.createElement("form"), ot = function(n) {
232
- return n instanceof RegExp || n instanceof Function;
233
- }, De = function() {
234
- let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
235
- if (!(Y && Y === n)) {
236
- if ((!n || typeof n != "object") && (n = {}), n = P(n), q = // eslint-disable-next-line unicorn/prefer-includes
237
- rn.indexOf(n.PARSER_MEDIA_TYPE) === -1 ? an : n.PARSER_MEDIA_TYPE, T = q === "application/xhtml+xml" ? Me : de, g = I(n, "ALLOWED_TAGS") ? f({}, n.ALLOWED_TAGS, T) : Ke, E = I(n, "ALLOWED_ATTR") ? f({}, n.ALLOWED_ATTR, T) : qe, Le = I(n, "ALLOWED_NAMESPACES") ? f({}, n.ALLOWED_NAMESPACES, Me) : tn, ve = I(n, "ADD_URI_SAFE_ATTR") ? f(P(at), n.ADD_URI_SAFE_ATTR, T) : at, rt = I(n, "ADD_DATA_URI_TAGS") ? f(P(it), n.ADD_DATA_URI_TAGS, T) : it, W = I(n, "FORBID_CONTENTS") ? f({}, n.FORBID_CONTENTS, T) : nt, j = I(n, "FORBID_TAGS") ? f({}, n.FORBID_TAGS, T) : P({}), Se = I(n, "FORBID_ATTR") ? f({}, n.FORBID_ATTR, T) : P({}), z = I(n, "USE_PROFILES") ? n.USE_PROFILES : !1, Ze = n.ALLOW_ARIA_ATTR !== !1, Re = n.ALLOW_DATA_ATTR !== !1, Qe = n.ALLOW_UNKNOWN_PROTOCOLS || !1, Je = n.ALLOW_SELF_CLOSE_IN_ATTR !== !1, H = n.SAFE_FOR_TEMPLATES || !1, ae = n.SAFE_FOR_XML !== !1, U = n.WHOLE_DOCUMENT || !1, B = n.RETURN_DOM || !1, oe = n.RETURN_DOM_FRAGMENT || !1, le = n.RETURN_TRUSTED_TYPE || !1, Ne = n.FORCE_BODY || !1, et = n.SANITIZE_DOM !== !1, tt = n.SANITIZE_NAMED_PROPS || !1, Oe = n.KEEP_CONTENT !== !1, K = n.IN_PLACE || !1, je = n.ALLOWED_URI_REGEXP || It, G = n.NAMESPACE || w, fe = n.MATHML_TEXT_INTEGRATION_POINTS || fe, ue = n.HTML_INTEGRATION_POINTS || ue, d = n.CUSTOM_ELEMENT_HANDLING || {}, n.CUSTOM_ELEMENT_HANDLING && ot(n.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (d.tagNameCheck = n.CUSTOM_ELEMENT_HANDLING.tagNameCheck), n.CUSTOM_ELEMENT_HANDLING && ot(n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (d.attributeNameCheck = n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), n.CUSTOM_ELEMENT_HANDLING && typeof n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (d.allowCustomizedBuiltInElements = n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), H && (Re = !1), oe && (B = !0), z && (g = f({}, Rt), E = [], z.html === !0 && (f(g, St), f(E, yt)), z.svg === !0 && (f(g, we), f(E, Pe), f(E, pe)), z.svgFilters === !0 && (f(g, ke), f(E, Pe), f(E, pe)), z.mathMl === !0 && (f(g, xe), f(E, Nt), f(E, pe))), n.ADD_TAGS && (g === Ke && (g = P(g)), f(g, n.ADD_TAGS, T)), n.ADD_ATTR && (E === qe && (E = P(E)), f(E, n.ADD_ATTR, T)), n.ADD_URI_SAFE_ATTR && f(ve, n.ADD_URI_SAFE_ATTR, T), n.FORBID_CONTENTS && (W === nt && (W = P(W)), f(W, n.FORBID_CONTENTS, T)), Oe && (g["#text"] = !0), U && f(g, ["html", "head", "body"]), g.table && (f(g, ["tbody"]), delete j.tbody), n.TRUSTED_TYPES_POLICY) {
238
- if (typeof n.TRUSTED_TYPES_POLICY.createHTML != "function")
239
- throw ee('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
240
- if (typeof n.TRUSTED_TYPES_POLICY.createScriptURL != "function")
241
- throw ee('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
242
- y = n.TRUSTED_TYPES_POLICY, X = y.createHTML("");
243
- } else
244
- y === void 0 && (y = Dn(re, s)), y !== null && typeof X == "string" && (X = y.createHTML(""));
245
- v && v(n), Y = n;
246
- }
247
- }, lt = f({}, [...we, ...ke, ...En]), st = f({}, [...xe, ...An]), ln = function(n) {
248
- let a = ie(n);
249
- (!a || !a.tagName) && (a = {
250
- namespaceURI: G,
251
- tagName: "template"
252
- });
253
- const o = de(n.tagName), u = de(a.tagName);
254
- return Le[n.namespaceURI] ? n.namespaceURI === ce ? a.namespaceURI === w ? o === "svg" : a.namespaceURI === se ? o === "svg" && (u === "annotation-xml" || fe[u]) : !!lt[o] : n.namespaceURI === se ? a.namespaceURI === w ? o === "math" : a.namespaceURI === ce ? o === "math" && ue[u] : !!st[o] : n.namespaceURI === w ? a.namespaceURI === ce && !ue[u] || a.namespaceURI === se && !fe[u] ? !1 : !st[o] && (nn[o] || !lt[o]) : !!(q === "application/xhtml+xml" && Le[n.namespaceURI]) : !1;
255
- }, M = function(n) {
256
- Q(t.removed, {
257
- element: n
258
- });
259
- try {
260
- ie(n).removeChild(n);
261
- } catch {
262
- Gt(n);
263
- }
264
- }, $ = function(n, a) {
265
- try {
266
- Q(t.removed, {
267
- attribute: a.getAttributeNode(n),
268
- from: a
269
- });
270
- } catch {
271
- Q(t.removed, {
272
- attribute: null,
273
- from: a
274
- });
275
- }
276
- if (a.removeAttribute(n), n === "is")
277
- if (B || oe)
278
- try {
279
- M(a);
280
- } catch {
281
- }
282
- else
283
- try {
284
- a.setAttribute(n, "");
285
- } catch {
286
- }
287
- }, ct = function(n) {
288
- let a = null, o = null;
289
- if (Ne)
290
- n = "<remove></remove>" + n;
291
- else {
292
- const h = _t(n, /^[\r\n\t ]+/);
293
- o = h && h[0];
294
- }
295
- q === "application/xhtml+xml" && G === w && (n = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + n + "</body></html>");
296
- const u = y ? y.createHTML(n) : n;
297
- if (G === w)
298
- try {
299
- a = new zt().parseFromString(u, q);
300
- } catch {
301
- }
302
- if (!a || !a.documentElement) {
303
- a = Te.createDocument(G, "template", null);
304
- try {
305
- a.documentElement.innerHTML = be ? X : u;
306
- } catch {
307
- }
308
- }
309
- const A = a.body || a.documentElement;
310
- return n && o && A.insertBefore(r.createTextNode(o), A.childNodes[0] || null), G === w ? jt.call(a, U ? "html" : "body")[0] : U ? a.documentElement : A;
311
- }, ft = function(n) {
312
- return Vt.call(
313
- n.ownerDocument || n,
314
- n,
315
- // eslint-disable-next-line no-bitwise
316
- R.SHOW_ELEMENT | R.SHOW_COMMENT | R.SHOW_TEXT | R.SHOW_PROCESSING_INSTRUCTION | R.SHOW_CDATA_SECTION,
317
- null
318
- );
319
- }, Ce = function(n) {
320
- return n instanceof ge && (typeof n.nodeName != "string" || typeof n.textContent != "string" || typeof n.removeChild != "function" || !(n.attributes instanceof F) || typeof n.removeAttribute != "function" || typeof n.setAttribute != "function" || typeof n.namespaceURI != "string" || typeof n.insertBefore != "function" || typeof n.hasChildNodes != "function");
321
- }, ut = function(n) {
322
- return typeof L == "function" && n instanceof L;
323
- };
324
- function k(l, n, a) {
325
- me(l, (o) => {
326
- o.call(t, n, a, Y);
327
- });
328
- }
329
- const mt = function(n) {
330
- let a = null;
331
- if (k(N.beforeSanitizeElements, n, null), Ce(n))
332
- return M(n), !0;
333
- const o = T(n.nodeName);
334
- if (k(N.uponSanitizeElement, n, {
335
- tagName: o,
336
- allowedTags: g
337
- }), ae && n.hasChildNodes() && !ut(n.firstElementChild) && O(/<[/\w!]/g, n.innerHTML) && O(/<[/\w!]/g, n.textContent) || n.nodeType === ne.progressingInstruction || ae && n.nodeType === ne.comment && O(/<[/\w]/g, n.data))
338
- return M(n), !0;
339
- if (!g[o] || j[o]) {
340
- if (!j[o] && dt(o) && (d.tagNameCheck instanceof RegExp && O(d.tagNameCheck, o) || d.tagNameCheck instanceof Function && d.tagNameCheck(o)))
341
- return !1;
342
- if (Oe && !W[o]) {
343
- const u = ie(n) || n.parentNode, A = $t(n) || n.childNodes;
344
- if (A && u) {
345
- const h = A.length;
346
- for (let D = h - 1; D >= 0; --D) {
347
- const x = Wt(A[D], !0);
348
- x.__removalCount = (n.__removalCount || 0) + 1, u.insertBefore(x, Yt(n));
349
- }
350
- }
351
- }
352
- return M(n), !0;
353
- }
354
- return n instanceof m && !ln(n) || (o === "noscript" || o === "noembed" || o === "noframes") && O(/<\/no(script|embed|frames)/i, n.innerHTML) ? (M(n), !0) : (H && n.nodeType === ne.text && (a = n.textContent, me([Ee, Ae, _e], (u) => {
355
- a = J(a, u, " ");
356
- }), n.textContent !== a && (Q(t.removed, {
357
- element: n.cloneNode()
358
- }), n.textContent = a)), k(N.afterSanitizeElements, n, null), !1);
359
- }, pt = function(n, a, o) {
360
- if (et && (a === "id" || a === "name") && (o in r || o in on))
361
- return !1;
362
- if (!(Re && !Se[a] && O(qt, a))) {
363
- if (!(Ze && O(Zt, a))) {
364
- if (!E[a] || Se[a]) {
365
- if (
366
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
367
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
368
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
369
- !(dt(n) && (d.tagNameCheck instanceof RegExp && O(d.tagNameCheck, n) || d.tagNameCheck instanceof Function && d.tagNameCheck(n)) && (d.attributeNameCheck instanceof RegExp && O(d.attributeNameCheck, a) || d.attributeNameCheck instanceof Function && d.attributeNameCheck(a)) || // Alternative, second condition checks if it's an `is`-attribute, AND
370
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
371
- a === "is" && d.allowCustomizedBuiltInElements && (d.tagNameCheck instanceof RegExp && O(d.tagNameCheck, o) || d.tagNameCheck instanceof Function && d.tagNameCheck(o)))
372
- ) return !1;
373
- } else if (!ve[a]) {
374
- if (!O(je, J(o, Xe, ""))) {
375
- if (!((a === "src" || a === "xlink:href" || a === "href") && n !== "script" && dn(o, "data:") === 0 && rt[n])) {
376
- if (!(Qe && !O(Qt, J(o, Xe, "")))) {
377
- if (o)
378
- return !1;
379
- }
380
- }
381
- }
382
- }
383
- }
384
- }
385
- return !0;
386
- }, dt = function(n) {
387
- return n !== "annotation-xml" && _t(n, Jt);
388
- }, ht = function(n) {
389
- k(N.beforeSanitizeAttributes, n, null);
390
- const {
391
- attributes: a
392
- } = n;
393
- if (!a || Ce(n))
394
- return;
395
- const o = {
396
- attrName: "",
397
- attrValue: "",
398
- keepAttr: !0,
399
- allowedAttributes: E,
400
- forceKeepAttr: void 0
401
- };
402
- let u = a.length;
403
- for (; u--; ) {
404
- const A = a[u], {
405
- name: h,
406
- namespaceURI: D,
407
- value: x
408
- } = A, Z = T(h), Ie = x;
409
- let _ = h === "value" ? Ie : hn(Ie);
410
- if (o.attrName = Z, o.attrValue = _, o.keepAttr = !0, o.forceKeepAttr = void 0, k(N.uponSanitizeAttribute, n, o), _ = o.attrValue, tt && (Z === "id" || Z === "name") && ($(h, n), _ = en + _), ae && O(/((--!?|])>)|<\/(style|title)/i, _)) {
411
- $(h, n);
412
- continue;
413
- }
414
- if (o.forceKeepAttr)
415
- continue;
416
- if (!o.keepAttr) {
417
- $(h, n);
418
- continue;
419
- }
420
- if (!Je && O(/\/>/i, _)) {
421
- $(h, n);
422
- continue;
423
- }
424
- H && me([Ee, Ae, _e], (Tt) => {
425
- _ = J(_, Tt, " ");
426
- });
427
- const gt = T(n.nodeName);
428
- if (!pt(gt, Z, _)) {
429
- $(h, n);
430
- continue;
431
- }
432
- if (y && typeof re == "object" && typeof re.getAttributeType == "function" && !D)
433
- switch (re.getAttributeType(gt, Z)) {
434
- case "TrustedHTML": {
435
- _ = y.createHTML(_);
436
- break;
437
- }
438
- case "TrustedScriptURL": {
439
- _ = y.createScriptURL(_);
440
- break;
441
- }
442
- }
443
- if (_ !== Ie)
444
- try {
445
- D ? n.setAttributeNS(D, h, _) : n.setAttribute(h, _), Ce(n) ? M(n) : At(t.removed);
446
- } catch {
447
- $(h, n);
448
- }
449
- }
450
- k(N.afterSanitizeAttributes, n, null);
451
- }, sn = function l(n) {
452
- let a = null;
453
- const o = ft(n);
454
- for (k(N.beforeSanitizeShadowDOM, n, null); a = o.nextNode(); )
455
- k(N.uponSanitizeShadowNode, a, null), mt(a), ht(a), a.content instanceof c && l(a.content);
456
- k(N.afterSanitizeShadowDOM, n, null);
457
- };
458
- return t.sanitize = function(l) {
459
- let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = null, o = null, u = null, A = null;
460
- if (be = !l, be && (l = "<!-->"), typeof l != "string" && !ut(l))
461
- if (typeof l.toString == "function") {
462
- if (l = l.toString(), typeof l != "string")
463
- throw ee("dirty is not a string, aborting");
464
- } else
465
- throw ee("toString is not a function");
466
- if (!t.isSupported)
467
- return l;
468
- if (ye || De(n), t.removed = [], typeof l == "string" && (K = !1), K) {
469
- if (l.nodeName) {
470
- const x = T(l.nodeName);
471
- if (!g[x] || j[x])
472
- throw ee("root node is forbidden and cannot be sanitized in-place");
473
- }
474
- } else if (l instanceof L)
475
- a = ct("<!---->"), o = a.ownerDocument.importNode(l, !0), o.nodeType === ne.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? a = o : a.appendChild(o);
476
- else {
477
- if (!B && !H && !U && // eslint-disable-next-line unicorn/prefer-includes
478
- l.indexOf("<") === -1)
479
- return y && le ? y.createHTML(l) : l;
480
- if (a = ct(l), !a)
481
- return B ? null : le ? X : "";
482
- }
483
- a && Ne && M(a.firstChild);
484
- const h = ft(K ? l : a);
485
- for (; u = h.nextNode(); )
486
- mt(u), ht(u), u.content instanceof c && sn(u.content);
487
- if (K)
488
- return l;
489
- if (B) {
490
- if (oe)
491
- for (A = Xt.call(a.ownerDocument); a.firstChild; )
492
- A.appendChild(a.firstChild);
493
- else
494
- A = a;
495
- return (E.shadowroot || E.shadowrootmode) && (A = Kt.call(i, A, !0)), A;
496
- }
497
- let D = U ? a.outerHTML : a.innerHTML;
498
- return U && g["!doctype"] && a.ownerDocument && a.ownerDocument.doctype && a.ownerDocument.doctype.name && O(Mt, a.ownerDocument.doctype.name) && (D = "<!DOCTYPE " + a.ownerDocument.doctype.name + `>
499
- ` + D), H && me([Ee, Ae, _e], (x) => {
500
- D = J(D, x, " ");
501
- }), y && le ? y.createHTML(D) : D;
502
- }, t.setConfig = function() {
503
- let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
504
- De(l), ye = !0;
505
- }, t.clearConfig = function() {
506
- Y = null, ye = !1;
507
- }, t.isValidAttribute = function(l, n, a) {
508
- Y || De({});
509
- const o = T(l), u = T(n);
510
- return pt(o, u, a);
511
- }, t.addHook = function(l, n) {
512
- typeof n == "function" && Q(N[l], n);
513
- }, t.removeHook = function(l, n) {
514
- if (n !== void 0) {
515
- const a = mn(N[l], n);
516
- return a === -1 ? void 0 : pn(N[l], a, 1)[0];
517
- }
518
- return At(N[l]);
519
- }, t.removeHooks = function(l) {
520
- N[l] = [];
521
- }, t.removeAllHooks = function() {
522
- N = vt();
523
- }, t;
524
- }
525
- var tr = wt();
526
- function Cn(e) {
527
- for (var t = 1; t < arguments.length; t++) {
528
- var r = arguments[t];
529
- for (var i in r)
530
- r.hasOwnProperty(i) && (e[i] = r[i]);
531
- }
532
- return e;
533
- }
534
- function We(e, t) {
535
- return Array(t + 1).join(e);
536
- }
537
- function In(e) {
538
- return e.replace(/^\n*/, "");
539
- }
540
- function Mn(e) {
541
- for (var t = e.length; t > 0 && e[t - 1] === `
542
- `; ) t--;
543
- return e.substring(0, t);
544
- }
545
- var wn = [
546
- "ADDRESS",
547
- "ARTICLE",
548
- "ASIDE",
549
- "AUDIO",
550
- "BLOCKQUOTE",
551
- "BODY",
552
- "CANVAS",
553
- "CENTER",
554
- "DD",
555
- "DIR",
556
- "DIV",
557
- "DL",
558
- "DT",
559
- "FIELDSET",
560
- "FIGCAPTION",
561
- "FIGURE",
562
- "FOOTER",
563
- "FORM",
564
- "FRAMESET",
565
- "H1",
566
- "H2",
567
- "H3",
568
- "H4",
569
- "H5",
570
- "H6",
571
- "HEADER",
572
- "HGROUP",
573
- "HR",
574
- "HTML",
575
- "ISINDEX",
576
- "LI",
577
- "MAIN",
578
- "MENU",
579
- "NAV",
580
- "NOFRAMES",
581
- "NOSCRIPT",
582
- "OL",
583
- "OUTPUT",
584
- "P",
585
- "PRE",
586
- "SECTION",
587
- "TABLE",
588
- "TBODY",
589
- "TD",
590
- "TFOOT",
591
- "TH",
592
- "THEAD",
593
- "TR",
594
- "UL"
595
- ];
596
- function Ye(e) {
597
- return $e(e, wn);
598
- }
599
- var kt = [
600
- "AREA",
601
- "BASE",
602
- "BR",
603
- "COL",
604
- "COMMAND",
605
- "EMBED",
606
- "HR",
607
- "IMG",
608
- "INPUT",
609
- "KEYGEN",
610
- "LINK",
611
- "META",
612
- "PARAM",
613
- "SOURCE",
614
- "TRACK",
615
- "WBR"
616
- ];
617
- function xt(e) {
618
- return $e(e, kt);
619
- }
620
- function kn(e) {
621
- return Ut(e, kt);
622
- }
623
- var Pt = [
624
- "A",
625
- "TABLE",
626
- "THEAD",
627
- "TBODY",
628
- "TFOOT",
629
- "TH",
630
- "TD",
631
- "IFRAME",
632
- "SCRIPT",
633
- "AUDIO",
634
- "VIDEO"
635
- ];
636
- function xn(e) {
637
- return $e(e, Pt);
638
- }
639
- function Pn(e) {
640
- return Ut(e, Pt);
641
- }
642
- function $e(e, t) {
643
- return t.indexOf(e.nodeName) >= 0;
644
- }
645
- function Ut(e, t) {
646
- return e.getElementsByTagName && t.some(function(r) {
647
- return e.getElementsByTagName(r).length;
648
- });
649
- }
650
- var S = {};
651
- S.paragraph = {
652
- filter: "p",
653
- replacement: function(e) {
654
- return `
655
-
656
- ` + e + `
657
-
658
- `;
659
- }
660
- };
661
- S.lineBreak = {
662
- filter: "br",
663
- replacement: function(e, t, r) {
664
- return r.br + `
665
- `;
666
- }
667
- };
668
- S.heading = {
669
- filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
670
- replacement: function(e, t, r) {
671
- var i = Number(t.nodeName.charAt(1));
672
- if (r.headingStyle === "setext" && i < 3) {
673
- var s = We(i === 1 ? "=" : "-", e.length);
674
- return `
675
-
676
- ` + e + `
677
- ` + s + `
678
-
679
- `;
680
- } else
681
- return `
682
-
683
- ` + We("#", i) + " " + e + `
684
-
685
- `;
686
- }
687
- };
688
- S.blockquote = {
689
- filter: "blockquote",
690
- replacement: function(e) {
691
- return e = e.replace(/^\n+|\n+$/g, ""), e = e.replace(/^/gm, "> "), `
692
-
693
- ` + e + `
694
-
695
- `;
696
- }
697
- };
698
- S.list = {
699
- filter: ["ul", "ol"],
700
- replacement: function(e, t) {
701
- var r = t.parentNode;
702
- return r.nodeName === "LI" && r.lastElementChild === t ? `
703
- ` + e : `
704
-
705
- ` + e + `
706
-
707
- `;
708
- }
709
- };
710
- S.listItem = {
711
- filter: "li",
712
- replacement: function(e, t, r) {
713
- e = e.replace(/^\n+/, "").replace(/\n+$/, `
714
- `).replace(/\n/gm, `
715
- `);
716
- var i = r.bulletListMarker + " ", s = t.parentNode;
717
- if (s.nodeName === "OL") {
718
- var c = s.getAttribute("start"), p = Array.prototype.indexOf.call(s.children, t);
719
- i = (c ? Number(c) + p : p + 1) + ". ";
720
- }
721
- return i + e + (t.nextSibling && !/\n$/.test(e) ? `
722
- ` : "");
723
- }
724
- };
725
- S.indentedCodeBlock = {
726
- filter: function(e, t) {
727
- return t.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
728
- },
729
- replacement: function(e, t, r) {
730
- return `
731
-
732
- ` + t.firstChild.textContent.replace(/\n/g, `
733
- `) + `
734
-
735
- `;
736
- }
737
- };
738
- S.fencedCodeBlock = {
739
- filter: function(e, t) {
740
- return t.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
741
- },
742
- replacement: function(e, t, r) {
743
- for (var i = t.firstChild.getAttribute("class") || "", s = (i.match(/language-(\S+)/) || [null, ""])[1], c = t.firstChild.textContent, p = r.fence.charAt(0), L = 3, m = new RegExp("^" + p + "{3,}", "gm"), R; R = m.exec(c); )
744
- R[0].length >= L && (L = R[0].length + 1);
745
- var F = We(p, L);
746
- return `
747
-
748
- ` + F + s + `
749
- ` + c.replace(/\n$/, "") + `
750
- ` + F + `
751
-
752
- `;
753
- }
754
- };
755
- S.horizontalRule = {
756
- filter: "hr",
757
- replacement: function(e, t, r) {
758
- return `
759
-
760
- ` + r.hr + `
761
-
762
- `;
763
- }
764
- };
765
- S.inlineLink = {
766
- filter: function(e, t) {
767
- return t.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
768
- },
769
- replacement: function(e, t) {
770
- var r = t.getAttribute("href");
771
- r && (r = r.replace(/([()])/g, "\\$1"));
772
- var i = he(t.getAttribute("title"));
773
- return i && (i = ' "' + i.replace(/"/g, '\\"') + '"'), "[" + e + "](" + r + i + ")";
774
- }
775
- };
776
- S.referenceLink = {
777
- filter: function(e, t) {
778
- return t.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
779
- },
780
- replacement: function(e, t, r) {
781
- var i = t.getAttribute("href"), s = he(t.getAttribute("title"));
782
- s && (s = ' "' + s + '"');
783
- var c, p;
784
- switch (r.linkReferenceStyle) {
785
- case "collapsed":
786
- c = "[" + e + "][]", p = "[" + e + "]: " + i + s;
787
- break;
788
- case "shortcut":
789
- c = "[" + e + "]", p = "[" + e + "]: " + i + s;
790
- break;
791
- default:
792
- var L = this.references.length + 1;
793
- c = "[" + e + "][" + L + "]", p = "[" + L + "]: " + i + s;
794
- }
795
- return this.references.push(p), c;
796
- },
797
- references: [],
798
- append: function(e) {
799
- var t = "";
800
- return this.references.length && (t = `
801
-
802
- ` + this.references.join(`
803
- `) + `
804
-
805
- `, this.references = []), t;
806
- }
807
- };
808
- S.emphasis = {
809
- filter: ["em", "i"],
810
- replacement: function(e, t, r) {
811
- return e.trim() ? r.emDelimiter + e + r.emDelimiter : "";
812
- }
813
- };
814
- S.strong = {
815
- filter: ["strong", "b"],
816
- replacement: function(e, t, r) {
817
- return e.trim() ? r.strongDelimiter + e + r.strongDelimiter : "";
818
- }
819
- };
820
- S.code = {
821
- filter: function(e) {
822
- var t = e.previousSibling || e.nextSibling, r = e.parentNode.nodeName === "PRE" && !t;
823
- return e.nodeName === "CODE" && !r;
824
- },
825
- replacement: function(e) {
826
- if (!e) return "";
827
- e = e.replace(/\r?\n|\r/g, " ");
828
- for (var t = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", r = "`", i = e.match(/`+/gm) || []; i.indexOf(r) !== -1; ) r = r + "`";
829
- return r + t + e + t + r;
830
- }
831
- };
832
- S.image = {
833
- filter: "img",
834
- replacement: function(e, t) {
835
- var r = he(t.getAttribute("alt")), i = t.getAttribute("src") || "", s = he(t.getAttribute("title")), c = s ? ' "' + s + '"' : "";
836
- return i ? "![" + r + "](" + i + c + ")" : "";
837
- }
838
- };
839
- function he(e) {
840
- return e ? e.replace(/(\n+\s*)+/g, `
841
- `) : "";
842
- }
843
- function Ft(e) {
844
- this.options = e, this._keep = [], this._remove = [], this.blankRule = {
845
- replacement: e.blankReplacement
846
- }, this.keepReplacement = e.keepReplacement, this.defaultRule = {
847
- replacement: e.defaultReplacement
848
- }, this.array = [];
849
- for (var t in e.rules) this.array.push(e.rules[t]);
850
- }
851
- Ft.prototype = {
852
- add: function(e, t) {
853
- this.array.unshift(t);
854
- },
855
- keep: function(e) {
856
- this._keep.unshift({
857
- filter: e,
858
- replacement: this.keepReplacement
859
- });
860
- },
861
- remove: function(e) {
862
- this._remove.unshift({
863
- filter: e,
864
- replacement: function() {
865
- return "";
866
- }
867
- });
868
- },
869
- forNode: function(e) {
870
- if (e.isBlank) return this.blankRule;
871
- var t;
872
- return (t = Ue(this.array, e, this.options)) || (t = Ue(this._keep, e, this.options)) || (t = Ue(this._remove, e, this.options)) ? t : this.defaultRule;
873
- },
874
- forEach: function(e) {
875
- for (var t = 0; t < this.array.length; t++) e(this.array[t], t);
876
- }
877
- };
878
- function Ue(e, t, r) {
879
- for (var i = 0; i < e.length; i++) {
880
- var s = e[i];
881
- if (Un(s, t, r)) return s;
882
- }
883
- }
884
- function Un(e, t, r) {
885
- var i = e.filter;
886
- if (typeof i == "string") {
887
- if (i === t.nodeName.toLowerCase()) return !0;
888
- } else if (Array.isArray(i)) {
889
- if (i.indexOf(t.nodeName.toLowerCase()) > -1) return !0;
890
- } else if (typeof i == "function") {
891
- if (i.call(e, t, r)) return !0;
892
- } else
893
- throw new TypeError("`filter` needs to be a string, array, or function");
894
- }
895
- function Fn(e) {
896
- var t = e.element, r = e.isBlock, i = e.isVoid, s = e.isPre || function(ge) {
897
- return ge.nodeName === "PRE";
898
- };
899
- if (!(!t.firstChild || s(t))) {
900
- for (var c = null, p = !1, L = null, m = bt(L, t, s); m !== t; ) {
901
- if (m.nodeType === 3 || m.nodeType === 4) {
902
- var R = m.data.replace(/[ \r\n\t]+/g, " ");
903
- if ((!c || / $/.test(c.data)) && !p && R[0] === " " && (R = R.substr(1)), !R) {
904
- m = Fe(m);
905
- continue;
906
- }
907
- m.data = R, c = m;
908
- } else if (m.nodeType === 1)
909
- r(m) || m.nodeName === "BR" ? (c && (c.data = c.data.replace(/ $/, "")), c = null, p = !1) : i(m) || s(m) ? (c = null, p = !0) : c && (p = !1);
910
- else {
911
- m = Fe(m);
912
- continue;
913
- }
914
- var F = bt(L, m, s);
915
- L = m, m = F;
916
- }
917
- c && (c.data = c.data.replace(/ $/, ""), c.data || Fe(c));
918
- }
919
- }
920
- function Fe(e) {
921
- var t = e.nextSibling || e.parentNode;
922
- return e.parentNode.removeChild(e), t;
923
- }
924
- function bt(e, t, r) {
925
- return e && e.parentNode === t || r(t) ? t.nextSibling || t.parentNode : t.firstChild || t.nextSibling || t.parentNode;
926
- }
927
- var Ve = typeof window < "u" ? window : {};
928
- function Hn() {
929
- var e = Ve.DOMParser, t = !1;
930
- try {
931
- new e().parseFromString("", "text/html") && (t = !0);
932
- } catch {
933
- }
934
- return t;
935
- }
936
- function Bn() {
937
- var e = function() {
938
- };
939
- return zn() ? e.prototype.parseFromString = function(t) {
940
- var r = new window.ActiveXObject("htmlfile");
941
- return r.designMode = "on", r.open(), r.write(t), r.close(), r;
942
- } : e.prototype.parseFromString = function(t) {
943
- var r = document.implementation.createHTMLDocument("");
944
- return r.open(), r.write(t), r.close(), r;
945
- }, e;
946
- }
947
- function zn() {
948
- var e = !1;
949
- try {
950
- document.implementation.createHTMLDocument("").open();
951
- } catch {
952
- Ve.ActiveXObject && (e = !0);
953
- }
954
- return e;
955
- }
956
- var Wn = Hn() ? Ve.DOMParser : Bn();
957
- function Gn(e, t) {
958
- var r;
959
- if (typeof e == "string") {
960
- var i = Yn().parseFromString(
961
- // DOM parsers arrange elements in the <head> and <body>.
962
- // Wrapping in a custom element ensures elements are reliably arranged in
963
- // a single element.
964
- '<x-turndown id="turndown-root">' + e + "</x-turndown>",
965
- "text/html"
966
- );
967
- r = i.getElementById("turndown-root");
968
- } else
969
- r = e.cloneNode(!0);
970
- return Fn({
971
- element: r,
972
- isBlock: Ye,
973
- isVoid: xt,
974
- isPre: t.preformattedCode ? $n : null
975
- }), r;
976
- }
977
- var He;
978
- function Yn() {
979
- return He = He || new Wn(), He;
980
- }
981
- function $n(e) {
982
- return e.nodeName === "PRE" || e.nodeName === "CODE";
983
- }
984
- function Vn(e, t) {
985
- return e.isBlock = Ye(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = Xn(e), e.flankingWhitespace = jn(e, t), e;
986
- }
987
- function Xn(e) {
988
- return !xt(e) && !xn(e) && /^\s*$/i.test(e.textContent) && !kn(e) && !Pn(e);
989
- }
990
- function jn(e, t) {
991
- if (e.isBlock || t.preformattedCode && e.isCode)
992
- return { leading: "", trailing: "" };
993
- var r = Kn(e.textContent);
994
- return r.leadingAscii && Lt("left", e, t) && (r.leading = r.leadingNonAscii), r.trailingAscii && Lt("right", e, t) && (r.trailing = r.trailingNonAscii), { leading: r.leading, trailing: r.trailing };
995
- }
996
- function Kn(e) {
997
- var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
998
- return {
999
- leading: t[1],
1000
- // whole string for whitespace-only strings
1001
- leadingAscii: t[2],
1002
- leadingNonAscii: t[3],
1003
- trailing: t[4],
1004
- // empty for whitespace-only strings
1005
- trailingNonAscii: t[5],
1006
- trailingAscii: t[6]
1007
- };
1008
- }
1009
- function Lt(e, t, r) {
1010
- var i, s, c;
1011
- return e === "left" ? (i = t.previousSibling, s = / $/) : (i = t.nextSibling, s = /^ /), i && (i.nodeType === 3 ? c = s.test(i.nodeValue) : r.preformattedCode && i.nodeName === "CODE" ? c = !1 : i.nodeType === 1 && !Ye(i) && (c = s.test(i.textContent))), c;
1012
- }
1013
- var qn = Array.prototype.reduce, Zn = [
1014
- [/\\/g, "\\\\"],
1015
- [/\*/g, "\\*"],
1016
- [/^-/g, "\\-"],
1017
- [/^\+ /g, "\\+ "],
1018
- [/^(=+)/g, "\\$1"],
1019
- [/^(#{1,6}) /g, "\\$1 "],
1020
- [/`/g, "\\`"],
1021
- [/^~~~/g, "\\~~~"],
1022
- [/\[/g, "\\["],
1023
- [/\]/g, "\\]"],
1024
- [/^>/g, "\\>"],
1025
- [/_/g, "\\_"],
1026
- [/^(\d+)\. /g, "$1\\. "]
1027
- ];
1028
- function Ge(e) {
1029
- if (!(this instanceof Ge)) return new Ge(e);
1030
- var t = {
1031
- rules: S,
1032
- headingStyle: "setext",
1033
- hr: "* * *",
1034
- bulletListMarker: "*",
1035
- codeBlockStyle: "indented",
1036
- fence: "```",
1037
- emDelimiter: "_",
1038
- strongDelimiter: "**",
1039
- linkStyle: "inlined",
1040
- linkReferenceStyle: "full",
1041
- br: " ",
1042
- preformattedCode: !1,
1043
- blankReplacement: function(r, i) {
1044
- return i.isBlock ? `
1045
-
1046
- ` : "";
1047
- },
1048
- keepReplacement: function(r, i) {
1049
- return i.isBlock ? `
1050
-
1051
- ` + i.outerHTML + `
1052
-
1053
- ` : i.outerHTML;
1054
- },
1055
- defaultReplacement: function(r, i) {
1056
- return i.isBlock ? `
1057
-
1058
- ` + r + `
1059
-
1060
- ` : r;
1061
- }
1062
- };
1063
- this.options = Cn({}, t, e), this.rules = new Ft(this.options);
1064
- }
1065
- Ge.prototype = {
1066
- /**
1067
- * The entry point for converting a string or DOM node to Markdown
1068
- * @public
1069
- * @param {String|HTMLElement} input The string or DOM node to convert
1070
- * @returns A Markdown representation of the input
1071
- * @type String
1072
- */
1073
- turndown: function(e) {
1074
- if (!er(e))
1075
- throw new TypeError(
1076
- e + " is not a string, or an element/document/fragment node."
1077
- );
1078
- if (e === "") return "";
1079
- var t = Ht.call(this, new Gn(e, this.options));
1080
- return Qn.call(this, t);
1081
- },
1082
- /**
1083
- * Add one or more plugins
1084
- * @public
1085
- * @param {Function|Array} plugin The plugin or array of plugins to add
1086
- * @returns The Turndown instance for chaining
1087
- * @type Object
1088
- */
1089
- use: function(e) {
1090
- if (Array.isArray(e))
1091
- for (var t = 0; t < e.length; t++) this.use(e[t]);
1092
- else if (typeof e == "function")
1093
- e(this);
1094
- else
1095
- throw new TypeError("plugin must be a Function or an Array of Functions");
1096
- return this;
1097
- },
1098
- /**
1099
- * Adds a rule
1100
- * @public
1101
- * @param {String} key The unique key of the rule
1102
- * @param {Object} rule The rule
1103
- * @returns The Turndown instance for chaining
1104
- * @type Object
1105
- */
1106
- addRule: function(e, t) {
1107
- return this.rules.add(e, t), this;
1108
- },
1109
- /**
1110
- * Keep a node (as HTML) that matches the filter
1111
- * @public
1112
- * @param {String|Array|Function} filter The unique key of the rule
1113
- * @returns The Turndown instance for chaining
1114
- * @type Object
1115
- */
1116
- keep: function(e) {
1117
- return this.rules.keep(e), this;
1118
- },
1119
- /**
1120
- * Remove a node that matches the filter
1121
- * @public
1122
- * @param {String|Array|Function} filter The unique key of the rule
1123
- * @returns The Turndown instance for chaining
1124
- * @type Object
1125
- */
1126
- remove: function(e) {
1127
- return this.rules.remove(e), this;
1128
- },
1129
- /**
1130
- * Escapes Markdown syntax
1131
- * @public
1132
- * @param {String} string The string to escape
1133
- * @returns A string with Markdown syntax escaped
1134
- * @type String
1135
- */
1136
- escape: function(e) {
1137
- return Zn.reduce(function(t, r) {
1138
- return t.replace(r[0], r[1]);
1139
- }, e);
1140
- }
1141
- };
1142
- function Ht(e) {
1143
- var t = this;
1144
- return qn.call(e.childNodes, function(r, i) {
1145
- i = new Vn(i, t.options);
1146
- var s = "";
1147
- return i.nodeType === 3 ? s = i.isCode ? i.nodeValue : t.escape(i.nodeValue) : i.nodeType === 1 && (s = Jn.call(t, i)), Bt(r, s);
1148
- }, "");
1149
- }
1150
- function Qn(e) {
1151
- var t = this;
1152
- return this.rules.forEach(function(r) {
1153
- typeof r.append == "function" && (e = Bt(e, r.append(t.options)));
1154
- }), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
1155
- }
1156
- function Jn(e) {
1157
- var t = this.rules.forNode(e), r = Ht.call(this, e), i = e.flankingWhitespace;
1158
- return (i.leading || i.trailing) && (r = r.trim()), i.leading + t.replacement(r, e, this.options) + i.trailing;
1159
- }
1160
- function Bt(e, t) {
1161
- var r = Mn(e), i = In(t), s = Math.max(e.length - r.length, t.length - i.length), c = `
1162
-
1163
- `.substring(0, s);
1164
- return r + c + i;
1165
- }
1166
- function er(e) {
1167
- return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
1168
- }
1169
- export {
1170
- Ge as T,
1171
- tr as p
1172
- };