turnish 1.5.0 → 1.6.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/dist/index.mjs CHANGED
@@ -1,18 +1,489 @@
1
- function H(t, e) {
1
+ class ae extends Error {
2
+ reason;
3
+ filename;
4
+ line;
5
+ column;
6
+ source;
7
+ constructor(e, n, i, r, s) {
8
+ super(`${e}:${i}:${r}: ${n}`), this.reason = n, this.filename = e, this.line = i, this.column = r, this.source = s;
9
+ }
10
+ }
11
+ class ce {
12
+ start;
13
+ end;
14
+ source;
15
+ constructor(e, n, i) {
16
+ this.start = e, this.end = n, this.source = i;
17
+ }
18
+ }
19
+ var f;
20
+ (function(t) {
21
+ t.stylesheet = "stylesheet", t.rule = "rule", t.declaration = "declaration", t.comment = "comment", t.container = "container", t.charset = "charset", t.document = "document", t.customMedia = "custom-media", t.fontFace = "font-face", t.host = "host", t.import = "import", t.keyframes = "keyframes", t.keyframe = "keyframe", t.layer = "layer", t.media = "media", t.namespace = "namespace", t.page = "page", t.startingStyle = "starting-style", t.supports = "supports";
22
+ })(f || (f = {}));
23
+ const U = (t, e, n) => {
24
+ let i = n, r = 1e4;
25
+ do {
26
+ const s = e.map((c) => t.indexOf(c, i));
27
+ s.push(t.indexOf("\\", i));
28
+ const l = s.filter((c) => c !== -1);
29
+ if (l.length === 0) return -1;
30
+ const u = Math.min(...l);
31
+ if (t[u] !== "\\") return u;
32
+ i = u + 2, r--;
33
+ } while (r > 0);
34
+ throw new Error("Too many escaping");
35
+ }, M = (t, e, n) => {
36
+ let i = n, r = 1e4;
37
+ do {
38
+ const s = e.map((c) => t.indexOf(c, i));
39
+ s.push(t.indexOf("(", i)), s.push(t.indexOf('"', i)), s.push(t.indexOf("'", i)), s.push(t.indexOf("\\", i));
40
+ const l = s.filter((c) => c !== -1);
41
+ if (l.length === 0) return -1;
42
+ const u = Math.min(...l);
43
+ switch (t[u]) {
44
+ case "\\":
45
+ i = u + 2;
46
+ break;
47
+ case "(":
48
+ {
49
+ const c = M(t, [")"], u + 1);
50
+ if (c === -1) return -1;
51
+ i = c + 1;
52
+ }
53
+ break;
54
+ case '"':
55
+ {
56
+ const c = U(t, ['"'], u + 1);
57
+ if (c === -1) return -1;
58
+ i = c + 1;
59
+ }
60
+ break;
61
+ case "'":
62
+ {
63
+ const c = U(t, ["'"], u + 1);
64
+ if (c === -1) return -1;
65
+ i = c + 1;
66
+ }
67
+ break;
68
+ default:
69
+ return u;
70
+ }
71
+ r--;
72
+ } while (r > 0);
73
+ throw new Error("Too many escaping");
74
+ }, w = /\/\*[^]*?(?:\*\/|$)/g;
75
+ function T(t) {
76
+ return t ? t.trim() : "";
77
+ }
78
+ function L(t, e) {
79
+ const n = t && typeof t.type == "string", i = n ? t : e;
80
+ for (const r in t) {
81
+ const s = t[r];
82
+ Array.isArray(s) ? s.forEach((l) => {
83
+ L(l, i);
84
+ }) : s && typeof s == "object" && L(s, i);
85
+ }
86
+ return n && Object.defineProperty(t, "parent", { configurable: !0, writable: !0, enumerable: !1, value: e || null }), t;
87
+ }
88
+ class le {
89
+ level = 0;
90
+ indentation = " ";
91
+ compress = !1;
92
+ constructor(e) {
93
+ typeof e?.indent == "string" && (this.indentation = e?.indent), e?.compress && (this.compress = !0);
94
+ }
95
+ emit(e, n) {
96
+ return e;
97
+ }
98
+ indent(e) {
99
+ return this.level = this.level || 1, e ? (this.level += e, "") : Array(this.level).join(this.indentation);
100
+ }
101
+ visit(e) {
102
+ switch (e.type) {
103
+ case f.stylesheet:
104
+ return this.stylesheet(e);
105
+ case f.rule:
106
+ return this.rule(e);
107
+ case f.declaration:
108
+ return this.declaration(e);
109
+ case f.comment:
110
+ return this.comment(e);
111
+ case f.container:
112
+ return this.container(e);
113
+ case f.charset:
114
+ return this.charset(e);
115
+ case f.document:
116
+ return this.document(e);
117
+ case f.customMedia:
118
+ return this.customMedia(e);
119
+ case f.fontFace:
120
+ return this.fontFace(e);
121
+ case f.host:
122
+ return this.host(e);
123
+ case f.import:
124
+ return this.import(e);
125
+ case f.keyframes:
126
+ return this.keyframes(e);
127
+ case f.keyframe:
128
+ return this.keyframe(e);
129
+ case f.layer:
130
+ return this.layer(e);
131
+ case f.media:
132
+ return this.media(e);
133
+ case f.namespace:
134
+ return this.namespace(e);
135
+ case f.page:
136
+ return this.page(e);
137
+ case f.startingStyle:
138
+ return this.startingStyle(e);
139
+ case f.supports:
140
+ return this.supports(e);
141
+ }
142
+ }
143
+ mapVisit(e, n) {
144
+ let i = "";
145
+ n = n || "";
146
+ for (let r = 0, s = e.length; r < s; r++) i += this.visit(e[r]), n && r < s - 1 && (i += this.emit(n));
147
+ return i;
148
+ }
149
+ compile(e) {
150
+ return this.compress ? e.stylesheet.rules.map(this.visit, this).join("") : this.stylesheet(e);
151
+ }
152
+ stylesheet(e) {
153
+ return this.mapVisit(e.stylesheet.rules, `
154
+
155
+ `);
156
+ }
157
+ comment(e) {
158
+ return this.compress ? this.emit("", e.position) : this.emit(`${this.indent()}/*${e.comment}*/`, e.position);
159
+ }
160
+ container(e) {
161
+ return this.compress ? this.emit(`@container ${e.container}`, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@container ${e.container}`, e.position) + this.emit(` {
162
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
163
+
164
+ `) + this.emit(`
165
+ ${this.indent(-1)}${this.indent()}}`);
166
+ }
167
+ layer(e) {
168
+ return this.compress ? this.emit(`@layer ${e.layer}`, e.position) + (e.rules ? this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : ";") : this.emit(`${this.indent()}@layer ${e.layer}`, e.position) + (e.rules ? this.emit(` {
169
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
170
+
171
+ `) + this.emit(`
172
+ ${this.indent(-1)}${this.indent()}}`) : ";");
173
+ }
174
+ import(e) {
175
+ return this.emit(`@import ${e.import};`, e.position);
176
+ }
177
+ media(e) {
178
+ return this.compress ? this.emit(`@media ${e.media}`, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@media ${e.media}`, e.position) + this.emit(` {
179
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
180
+
181
+ `) + this.emit(`
182
+ ${this.indent(-1)}${this.indent()}}`);
183
+ }
184
+ document(e) {
185
+ const n = `@${e.vendor || ""}document ${e.document}`;
186
+ return this.compress ? this.emit(n, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(n, e.position) + this.emit(` {
187
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
188
+
189
+ `) + this.emit(`${this.indent(-1)}
190
+ }`);
191
+ }
192
+ charset(e) {
193
+ return this.emit(`@charset ${e.charset};`, e.position);
194
+ }
195
+ namespace(e) {
196
+ return this.emit(`@namespace ${e.namespace};`, e.position);
197
+ }
198
+ startingStyle(e) {
199
+ return this.compress ? this.emit("@starting-style", e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@starting-style`, e.position) + this.emit(` {
200
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
201
+
202
+ `) + this.emit(`
203
+ ${this.indent(-1)}${this.indent()}}`);
204
+ }
205
+ supports(e) {
206
+ return this.compress ? this.emit(`@supports ${e.supports}`, e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit(`${this.indent()}@supports ${e.supports}`, e.position) + this.emit(` {
207
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
208
+
209
+ `) + this.emit(`
210
+ ${this.indent(-1)}${this.indent()}}`);
211
+ }
212
+ keyframes(e) {
213
+ return this.compress ? this.emit(`@${e.vendor || ""}keyframes ${e.name}`, e.position) + this.emit("{") + this.mapVisit(e.keyframes) + this.emit("}") : this.emit(`@${e.vendor || ""}keyframes ${e.name}`, e.position) + this.emit(` {
214
+ ${this.indent(1)}`) + this.mapVisit(e.keyframes, `
215
+ `) + this.emit(`${this.indent(-1)}}`);
216
+ }
217
+ keyframe(e) {
218
+ const n = e.declarations;
219
+ return this.compress ? this.emit(e.values.join(","), e.position) + this.emit("{") + this.mapVisit(n) + this.emit("}") : this.emit(this.indent()) + this.emit(e.values.join(", "), e.position) + this.emit(` {
220
+ ${this.indent(1)}`) + this.mapVisit(n, `
221
+ `) + this.emit(`${this.indent(-1)}
222
+ ${this.indent()}}
223
+ `);
224
+ }
225
+ page(e) {
226
+ if (this.compress) {
227
+ const i = e.selectors.length ? e.selectors.join(", ") : "";
228
+ return this.emit(`@page ${i}`, e.position) + this.emit("{") + this.mapVisit(e.declarations) + this.emit("}");
229
+ }
230
+ const n = e.selectors.length ? `${e.selectors.join(", ")} ` : "";
231
+ return this.emit(`@page ${n}`, e.position) + this.emit(`{
232
+ `) + this.emit(this.indent(1)) + this.mapVisit(e.declarations, `
233
+ `) + this.emit(this.indent(-1)) + this.emit(`
234
+ }`);
235
+ }
236
+ fontFace(e) {
237
+ return this.compress ? this.emit("@font-face", e.position) + this.emit("{") + this.mapVisit(e.declarations) + this.emit("}") : this.emit("@font-face ", e.position) + this.emit(`{
238
+ `) + this.emit(this.indent(1)) + this.mapVisit(e.declarations, `
239
+ `) + this.emit(this.indent(-1)) + this.emit(`
240
+ }`);
241
+ }
242
+ host(e) {
243
+ return this.compress ? this.emit("@host", e.position) + this.emit("{") + this.mapVisit(e.rules) + this.emit("}") : this.emit("@host", e.position) + this.emit(` {
244
+ ${this.indent(1)}`) + this.mapVisit(e.rules, `
245
+
246
+ `) + this.emit(`${this.indent(-1)}
247
+ }`);
248
+ }
249
+ customMedia(e) {
250
+ return this.emit(`@custom-media ${e.name} ${e.media};`, e.position);
251
+ }
252
+ rule(e) {
253
+ const n = e.declarations;
254
+ if (!n.length) return "";
255
+ if (this.compress) return this.emit(e.selectors.join(","), e.position) + this.emit("{") + this.mapVisit(n) + this.emit("}");
256
+ const i = this.indent();
257
+ return this.emit(e.selectors.map((r) => i + r).join(`,
258
+ `), e.position) + this.emit(` {
259
+ `) + this.emit(this.indent(1)) + this.mapVisit(n, `
260
+ `) + this.emit(this.indent(-1)) + this.emit(`
261
+ ${this.indent()}}`);
262
+ }
263
+ declaration(e) {
264
+ return this.compress ? this.emit(`${e.property}:${e.value}`, e.position) + this.emit(";") : e.property === "grid-template-areas" ? this.emit(this.indent()) + this.emit(e.property + ": " + e.value.split(`
265
+ `).join(`
266
+ `.padEnd(22) + this.indent()), e.position) + this.emit(";") : this.emit(this.indent()) + this.emit(`${e.property}: ${e.value}`, e.position) + this.emit(";");
267
+ }
268
+ }
269
+ const ue = (t, e) => {
270
+ e = e || {};
271
+ let n = 1, i = 1;
272
+ function r() {
273
+ const a = { line: n, column: i };
274
+ return (o) => (o.position = new ce(a, { line: n, column: i }, e?.source || ""), E(), o);
275
+ }
276
+ const s = [];
277
+ function l(a) {
278
+ const o = new ae(e?.source || "", a, n, i, t);
279
+ if (!e?.silent) throw o;
280
+ s.push(o);
281
+ }
282
+ function u() {
283
+ const a = /^{\s*/.exec(t);
284
+ return !!a && (m(a), !0);
285
+ }
286
+ function c() {
287
+ const a = /^}/.exec(t);
288
+ return !!a && (m(a), !0);
289
+ }
290
+ function g() {
291
+ let a;
292
+ const o = [];
293
+ for (E(), d(o); t.length && t.charAt(0) !== "}" && (a = se() || oe(), a); ) o.push(a), d(o);
294
+ return o;
295
+ }
296
+ function m(a) {
297
+ const o = a[0];
298
+ return (function(h) {
299
+ const p = h.match(/\n/g);
300
+ p && (n += p.length);
301
+ const y = h.lastIndexOf(`
302
+ `);
303
+ i = ~y ? h.length - y : i + h.length;
304
+ })(o), t = t.slice(o.length), a;
305
+ }
306
+ function E() {
307
+ const a = /^\s*/.exec(t);
308
+ a && m(a);
309
+ }
310
+ function d(a) {
311
+ a = a || [];
312
+ let o = $();
313
+ for (; o; ) a.push(o), o = $();
314
+ return a;
315
+ }
316
+ function $() {
317
+ const a = r();
318
+ if (t.charAt(0) !== "/" || t.charAt(1) !== "*") return;
319
+ const o = /^\/\*[^]*?\*\//.exec(t);
320
+ return o ? (m(o), a({ type: f.comment, comment: o[0].slice(2, -2) })) : l("End of comment missing");
321
+ }
322
+ function V() {
323
+ const a = /^([^{]+)/.exec(t);
324
+ if (a)
325
+ return m(a), ((o, h) => {
326
+ const p = [];
327
+ let y = 0;
328
+ for (; y < o.length; ) {
329
+ const k = M(o, h, y);
330
+ if (k === -1) return p.push(o.substring(y)), p;
331
+ p.push(o.substring(y, k)), y = k + 1;
332
+ }
333
+ return p;
334
+ })(T(a[0]).replace(w, ""), [","]).map((o) => T(o));
335
+ }
336
+ function A() {
337
+ const a = r(), o = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(t);
338
+ if (!o) return;
339
+ m(o);
340
+ const h = T(o[0]), p = /^:\s*/.exec(t);
341
+ if (!p) return l("property missing ':'");
342
+ m(p);
343
+ let y = "";
344
+ const k = M(t, [";", "}"]);
345
+ k !== -1 && (y = t.substring(0, k), m([y]), y = T(y).replace(w, ""));
346
+ const R = a({ type: f.declaration, property: h.replace(w, ""), value: y }), _ = /^[;\s]*/.exec(t);
347
+ return _ && m(_), R;
348
+ }
349
+ function H() {
350
+ const a = [];
351
+ if (!u()) return l("missing '{'");
352
+ d(a);
353
+ let o = A();
354
+ for (; o; ) a.push(o), d(a), o = A();
355
+ return c() ? a : l("missing '}'");
356
+ }
357
+ function F() {
358
+ const a = [], o = r();
359
+ let h = /^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(t);
360
+ for (; h; ) {
361
+ const p = m(h);
362
+ a.push(p[1]);
363
+ const y = /^,\s*/.exec(t);
364
+ y && m(y), h = /^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(t);
365
+ }
366
+ if (a.length) return o({ type: f.keyframe, values: a, declarations: H() || [] });
367
+ }
368
+ const ne = C("import"), ie = C("charset"), re = C("namespace");
369
+ function C(a) {
370
+ const o = new RegExp("^@" + a + `\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);
371
+ return () => {
372
+ const h = r(), p = o.exec(t);
373
+ if (!p) return;
374
+ const y = m(p), k = { type: a };
375
+ return k[a] = y[1].trim(), h(k);
376
+ };
377
+ }
378
+ function se() {
379
+ if (t[0] === "@") return (function() {
380
+ const a = r(), o = /^@([-\w]+)?keyframes\s*/.exec(t);
381
+ if (!o) return;
382
+ const h = m(o)[1], p = /^([-\w]+)\s*/.exec(t);
383
+ if (!p) return l("@keyframes missing name");
384
+ const y = m(p)[1];
385
+ if (!u()) return l("@keyframes missing '{'");
386
+ let k = d(), R = F();
387
+ for (; R; ) k.push(R), k = k.concat(d()), R = F();
388
+ return c() ? a({ type: f.keyframes, name: y, vendor: h, keyframes: k }) : l("@keyframes missing '}'");
389
+ })() || (function() {
390
+ const a = r(), o = /^@media *([^{]+)/.exec(t);
391
+ if (!o) return;
392
+ const h = T(m(o)[1]);
393
+ if (!u()) return l("@media missing '{'");
394
+ const p = d().concat(g());
395
+ return c() ? a({ type: f.media, media: h, rules: p }) : l("@media missing '}'");
396
+ })() || (function() {
397
+ const a = r(), o = /^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(t);
398
+ if (!o) return;
399
+ const h = m(o);
400
+ return a({ type: f.customMedia, name: T(h[1]), media: T(h[2]) });
401
+ })() || (function() {
402
+ const a = r(), o = /^@supports *([^{]+)/.exec(t);
403
+ if (!o) return;
404
+ const h = T(m(o)[1]);
405
+ if (!u()) return l("@supports missing '{'");
406
+ const p = d().concat(g());
407
+ return c() ? a({ type: f.supports, supports: h, rules: p }) : l("@supports missing '}'");
408
+ })() || ne() || ie() || re() || (function() {
409
+ const a = r(), o = /^@([-\w]+)?document *([^{]+)/.exec(t);
410
+ if (!o) return;
411
+ const h = m(o), p = T(h[1]), y = T(h[2]);
412
+ if (!u()) return l("@document missing '{'");
413
+ const k = d().concat(g());
414
+ return c() ? a({ type: f.document, document: y, vendor: p, rules: k }) : l("@document missing '}'");
415
+ })() || (function() {
416
+ const a = r(), o = /^@page */.exec(t);
417
+ if (!o) return;
418
+ m(o);
419
+ const h = V() || [];
420
+ if (!u()) return l("@page missing '{'");
421
+ let p = d(), y = A();
422
+ for (; y; ) p.push(y), p = p.concat(d()), y = A();
423
+ return c() ? a({ type: f.page, selectors: h, declarations: p }) : l("@page missing '}'");
424
+ })() || (function() {
425
+ const a = r(), o = /^@host\s*/.exec(t);
426
+ if (!o) return;
427
+ if (m(o), !u()) return l("@host missing '{'");
428
+ const h = d().concat(g());
429
+ return c() ? a({ type: f.host, rules: h }) : l("@host missing '}'");
430
+ })() || (function() {
431
+ const a = r(), o = /^@font-face\s*/.exec(t);
432
+ if (!o) return;
433
+ if (m(o), !u()) return l("@font-face missing '{'");
434
+ let h = d(), p = A();
435
+ for (; p; ) h.push(p), h = h.concat(d()), p = A();
436
+ return c() ? a({ type: f.fontFace, declarations: h }) : l("@font-face missing '}'");
437
+ })() || (function() {
438
+ const a = r(), o = /^@container *([^{]+)/.exec(t);
439
+ if (!o) return;
440
+ const h = T(m(o)[1]);
441
+ if (!u()) return l("@container missing '{'");
442
+ const p = d().concat(g());
443
+ return c() ? a({ type: f.container, container: h, rules: p }) : l("@container missing '}'");
444
+ })() || (function() {
445
+ const a = r(), o = /^@starting-style\s*/.exec(t);
446
+ if (!o) return;
447
+ if (m(o), !u()) return l("@starting-style missing '{'");
448
+ const h = d().concat(g());
449
+ return c() ? a({ type: f.startingStyle, rules: h }) : l("@starting-style missing '}'");
450
+ })() || (function() {
451
+ const a = r(), o = /^@layer *([^{;@]+)/.exec(t);
452
+ if (!o) return;
453
+ const h = T(m(o)[1]);
454
+ if (!u()) {
455
+ const y = /^[;\s]*/.exec(t);
456
+ return y && m(y), a({ type: f.layer, layer: h });
457
+ }
458
+ const p = d().concat(g());
459
+ return c() ? a({ type: f.layer, layer: h, rules: p }) : l("@layer missing '}'");
460
+ })();
461
+ }
462
+ function oe() {
463
+ const a = r(), o = V();
464
+ return o ? (d(), a({ type: f.rule, selectors: o, declarations: H() || [] })) : l("selector missing");
465
+ }
466
+ return L((function() {
467
+ const a = g();
468
+ return { type: f.stylesheet, stylesheet: { source: e?.source, rules: a, parsingErrors: s } };
469
+ })());
470
+ }, me = (t, e) => new le(e || {}).compile(t);
471
+ var he = { parse: ue, stringify: me };
472
+ function fe(t, e) {
2
473
  const n = t;
3
- return n.isBlock = A(n), n.isCode = n.nodeName === "CODE" || n.parentNode?.isCode, n.isBlank = v(n), n.flankingWhitespace = _(n, e), n;
474
+ return n.isBlock = B(n), n.isCode = n.nodeName === "CODE" || n.parentNode?.isCode, n.isBlank = pe(n), n.flankingWhitespace = de(n, e), n;
4
475
  }
5
- function v(t) {
6
- return !L(t) && !V(t) && /^\s*$/i.test(t.textContent || "") && !U(t) && !W(t);
476
+ function pe(t) {
477
+ return !X(t) && !Ee(t) && /^\s*$/i.test(t.textContent || "") && !ke(t) && !Te(t);
7
478
  }
8
- function _(t, e) {
479
+ function de(t, e) {
9
480
  const n = t;
10
481
  if (n.isBlock || e.preformattedCode && n.isCode)
11
482
  return { leading: "", trailing: "" };
12
- const r = $(t.textContent || "");
13
- return r.leadingAscii && b("left", t, e) && (r.leading = r.leadingNonAscii), r.trailingAscii && b("right", t, e) && (r.trailing = r.trailingNonAscii), { leading: r.leading, trailing: r.trailing };
483
+ const i = ge(t.textContent || "");
484
+ return i.leadingAscii && j("left", t, e) && (i.leading = i.leadingNonAscii), i.trailingAscii && j("right", t, e) && (i.trailing = i.trailingNonAscii), { leading: i.leading, trailing: i.trailing };
14
485
  }
15
- function $(t) {
486
+ function ge(t) {
16
487
  const e = t.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
17
488
  return e ? {
18
489
  leading: e[1],
@@ -32,31 +503,31 @@ function $(t) {
32
503
  trailingAscii: ""
33
504
  };
34
505
  }
35
- function b(t, e, n) {
36
- let r, i, l;
37
- return t === "left" ? (r = e.previousSibling, i = / $/) : (r = e.nextSibling, i = /^ /), r && (r.nodeType === 3 ? l = i.test(r.nodeValue || "") : n.preformattedCode && r.nodeName === "CODE" ? l = !1 : r.nodeType === 1 && !A(r) && (l = i.test(r.textContent || ""))), l || !1;
506
+ function j(t, e, n) {
507
+ let i, r, s;
508
+ return t === "left" ? (i = e.previousSibling, r = / $/) : (i = e.nextSibling, r = /^ /), i && (i.nodeType === 3 ? s = r.test(i.nodeValue || "") : n.preformattedCode && i.nodeName === "CODE" ? s = !1 : i.nodeType === 1 && !B(i) && (s = r.test(i.textContent || ""))), s || !1;
38
509
  }
39
- const p = {
510
+ const x = {
40
511
  Element: 1,
41
512
  Text: 3,
42
513
  CDATASection: 4
43
514
  };
44
- function k(t, e) {
515
+ function v(t, e) {
45
516
  return Array(e + 1).join(t);
46
517
  }
47
- function I(t) {
518
+ function K(t) {
48
519
  return t.replace(/^\n*/, "");
49
520
  }
50
- function O(t) {
521
+ function Y(t) {
51
522
  let e = t.length;
52
523
  for (; e > 0 && t[e - 1] === `
53
524
  `; ) e--;
54
525
  return t.substring(0, e);
55
526
  }
56
- function w(t) {
57
- return O(I(t));
527
+ function q(t) {
528
+ return Y(K(t));
58
529
  }
59
- const F = [
530
+ const ye = [
60
531
  "ADDRESS",
61
532
  "ARTICLE",
62
533
  "ASIDE",
@@ -107,10 +578,10 @@ const F = [
107
578
  "TR",
108
579
  "UL"
109
580
  ];
110
- function A(t) {
111
- return y(t, F);
581
+ function B(t) {
582
+ return P(t, ye);
112
583
  }
113
- const D = [
584
+ const Q = [
114
585
  "AREA",
115
586
  "BASE",
116
587
  "BR",
@@ -128,13 +599,13 @@ const D = [
128
599
  "TRACK",
129
600
  "WBR"
130
601
  ];
131
- function L(t) {
132
- return y(t, D);
602
+ function X(t) {
603
+ return P(t, Q);
133
604
  }
134
- function U(t) {
135
- return B(t, D);
605
+ function ke(t) {
606
+ return Z(t, Q);
136
607
  }
137
- const M = [
608
+ const J = [
138
609
  "A",
139
610
  "TABLE",
140
611
  "THEAD",
@@ -146,7 +617,7 @@ const M = [
146
617
  "SCRIPT",
147
618
  "AUDIO",
148
619
  "VIDEO"
149
- ], z = [
620
+ ], Ne = [
150
621
  "P",
151
622
  "BR",
152
623
  "H1",
@@ -177,32 +648,54 @@ const M = [
177
648
  "TH",
178
649
  "TD"
179
650
  ];
180
- function V(t) {
181
- return y(t, M);
651
+ function Ee(t) {
652
+ return P(t, J);
182
653
  }
183
- function W(t) {
184
- return B(t, M);
654
+ function Te(t) {
655
+ return Z(t, J);
185
656
  }
186
- function y(t, e) {
657
+ function P(t, e) {
187
658
  return e.indexOf(t.nodeName) >= 0;
188
659
  }
189
- function B(t, e) {
660
+ function Z(t, e) {
190
661
  return e.some(function(n) {
191
- return t.nodeType !== p.Element ? !1 : t.getElementsByTagName(n).length;
662
+ return t.nodeType !== x.Element ? !1 : t.getElementsByTagName(n).length;
192
663
  });
193
664
  }
194
- function P(t) {
665
+ function ee(t) {
195
666
  return t ? t.replace(/(\n+\s*)+/g, `
196
667
  `) : "";
197
668
  }
198
- function G(t) {
199
- return P(t).replace(/[\t\r\n]+/g, " ").replace(/ {2,}/g, " ").trim();
669
+ function xe(t) {
670
+ return ee(t).replace(/[\t\r\n]+/g, " ").replace(/ {2,}/g, " ").trim();
671
+ }
672
+ function b(t) {
673
+ return ee(t).replace(/[\t\r\n]+/g, " ");
674
+ }
675
+ function $e(t) {
676
+ const e = t.parentNode;
677
+ return e ? e.nodeType === x.Element && e.classList && e.classList.contains("code") && e.nodeName === "TD" && t.nodeName === "PRE" : !1;
200
678
  }
201
- function g(t) {
202
- return P(t).replace(/[\t\r\n]+/g, " ");
679
+ function Ae(t) {
680
+ if (t.nodeName !== "PRE" || t.nodeType !== x.Element)
681
+ return !1;
682
+ const e = t.getAttribute("style");
683
+ if (!e)
684
+ return !1;
685
+ const n = he.parse("pre {" + e + "}");
686
+ if (!n.stylesheet.rules.length)
687
+ return !1;
688
+ const i = n.stylesheet.rules[0];
689
+ if (!("declarations" in i) || !i.declarations)
690
+ return !1;
691
+ const r = i.declarations.find((l) => "property" in l ? l.property.toLowerCase() === "font-family" : !1);
692
+ return !r || "value" in r && !r.value ? !1 : "value" in r && r.value.split(",").map((l) => l.trim().toLowerCase()).indexOf("monospace") >= 0;
203
693
  }
204
- const f = {};
205
- f.paragraph = {
694
+ function te(t) {
695
+ return $e(t) || Ae(t) ? !0 : t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE" || !1;
696
+ }
697
+ const N = {};
698
+ N.paragraph = {
206
699
  filter: "p",
207
700
  replacement: function(t) {
208
701
  return `
@@ -212,44 +705,44 @@ f.paragraph = {
212
705
  `;
213
706
  }
214
707
  };
215
- f.lineBreak = {
708
+ N.lineBreak = {
216
709
  filter: "br",
217
710
  replacement: function(t, e, n) {
218
711
  return n.br + `
219
712
  `;
220
713
  }
221
714
  };
222
- f.heading = {
715
+ N.heading = {
223
716
  filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
224
717
  replacement: function(t, e, n) {
225
- const r = Number(e.nodeName.charAt(1));
226
- if (n.headingStyle === "setext" && r < 3) {
227
- const i = k(r === 1 ? "=" : "-", t.length);
718
+ const i = Number(e.nodeName.charAt(1));
719
+ if (n.headingStyle === "setext" && i < 3) {
720
+ const r = v(i === 1 ? "=" : "-", t.length);
228
721
  return `
229
722
 
230
723
  ` + t + `
231
- ` + i + `
724
+ ` + r + `
232
725
 
233
726
  `;
234
727
  } else
235
728
  return `
236
729
 
237
- ` + k("#", r) + " " + t + `
730
+ ` + v("#", i) + " " + t + `
238
731
 
239
732
  `;
240
733
  }
241
734
  };
242
- f.blockquote = {
735
+ N.blockquote = {
243
736
  filter: "blockquote",
244
737
  replacement: function(t) {
245
- return t = w(t).replace(/^/gm, "> "), `
738
+ return t = q(t).replace(/^/gm, "> "), `
246
739
 
247
740
  ` + t + `
248
741
 
249
742
  `;
250
743
  }
251
744
  };
252
- f.list = {
745
+ N.list = {
253
746
  filter: ["ul", "ol"],
254
747
  replacement: function(t, e) {
255
748
  const n = e.parentNode;
@@ -261,36 +754,36 @@ f.list = {
261
754
  `;
262
755
  }
263
756
  };
264
- f.listItem = {
757
+ N.listItem = {
265
758
  filter: "li",
266
759
  replacement: function(t, e, n) {
267
- let r = n.bulletListMarker + " ".repeat(n.listMarkerSpaceCount);
268
- const i = e.parentNode;
269
- if (i.nodeName === "OL") {
270
- const d = i.getAttribute("start"), h = Array.prototype.indexOf.call(i.children, e);
271
- r = (d ? Number(d) + h : h + 1) + "." + " ".repeat(n.listMarkerSpaceCount);
760
+ let i = n.bulletListMarker + " ".repeat(n.listMarkerSpaceCount);
761
+ const r = e.parentNode;
762
+ if (r.nodeName === "OL") {
763
+ const d = r.getAttribute("start"), $ = Array.prototype.indexOf.call(r.children, e);
764
+ i = (d ? Number(d) + $ : $ + 1) + "." + " ".repeat(n.listMarkerSpaceCount);
272
765
  }
273
- const l = /\n$/.test(t);
274
- if (t = w(t) + (l ? `
275
- ` : ""), e.childNodes.length > 0 && Array.from(e.childNodes).every((d) => d.nodeType === p.Text && /^\s*$/.test(d.nodeValue || "") || d.nodeType === p.Element && ["UL", "OL"].includes(d.nodeName)) && t.trim() !== "")
766
+ const s = /\n$/.test(t);
767
+ if (t = q(t) + (s ? `
768
+ ` : ""), e.childNodes.length > 0 && Array.from(e.childNodes).every((d) => d.nodeType === x.Text && /^\s*$/.test(d.nodeValue || "") || d.nodeType === x.Element && ["UL", "OL"].includes(d.nodeName)) && t.trim() !== "")
276
769
  return t + (e.nextSibling ? `
277
770
  ` : "");
278
- let a = 0, s = i;
279
- for (; s; ) {
280
- if (s.nodeName === "UL" || s.nodeName === "OL") {
281
- const d = s.parentNode;
282
- d && d.nodeName === "LI" && a++;
771
+ let u = 0, c = r;
772
+ for (; c; ) {
773
+ if (c.nodeName === "UL" || c.nodeName === "OL") {
774
+ const d = c.parentNode;
775
+ d && d.nodeName === "LI" && u++;
283
776
  }
284
- s = s.parentNode;
777
+ c = c.parentNode;
285
778
  }
286
- let o = n.listItemIndent === "tab" ? " " : " ".repeat(n.listItemIndentSpaceCount), u = o.repeat(a);
287
- const m = /\n(?!\s*(?:\d+\.\s|[-+*]\s))/gm;
288
- return t = t.replace(m, `
289
- ` + o), u + r + t + (e.nextSibling ? `
779
+ let g = n.listItemIndent === "tab" ? " " : " ".repeat(n.listItemIndentSpaceCount), m = g.repeat(u);
780
+ const E = /\n(?!\s*(?:\d+\.\s|[-+*]\s))/gm;
781
+ return t = t.replace(E, `
782
+ ` + g), m + i + t + (e.nextSibling ? `
290
783
  ` : "");
291
784
  }
292
785
  };
293
- f.indentedCodeBlock = {
786
+ N.indentedCodeBlock = {
294
787
  filter: function(t, e) {
295
788
  return !!(e && e.codeBlockStyle === "indented" && t.nodeName === "PRE" && t.firstChild && t.firstChild.nodeName === "CODE");
296
789
  },
@@ -303,28 +796,28 @@ f.indentedCodeBlock = {
303
796
  `;
304
797
  }
305
798
  };
306
- f.fencedCodeBlock = {
799
+ N.fencedCodeBlock = {
307
800
  filter: function(t, e) {
308
801
  return !!(e && e.codeBlockStyle === "fenced" && t.nodeName === "PRE");
309
802
  },
310
803
  replacement: function(t, e, n) {
311
- const r = e, i = r.firstChild, l = i && i.nodeName === "CODE" ? i : r, a = ((l.getAttribute("class") || "").match(/(?:lang|language)-(\S+)/) || [null, ""])[1], s = l.textContent || "", o = n.fence?.charAt(0) || "`";
312
- let u = 3;
313
- const m = new RegExp("^" + o + "{3,}", "gm");
804
+ const i = e, r = i.firstChild, s = r && r.nodeName === "CODE" ? r : i, u = ((s.getAttribute("class") || "").match(/(?:lang|language)-(\S+)/) || [null, ""])[1], c = s.textContent || "", g = n.fence?.charAt(0) || "`";
805
+ let m = 3;
806
+ const E = new RegExp("^" + g + "{3,}", "gm");
314
807
  let d;
315
- for (; d = m.exec(s); )
316
- d[0].length >= u && (u = d[0].length + 1);
317
- const h = k(o, u);
808
+ for (; d = E.exec(c); )
809
+ d[0].length >= m && (m = d[0].length + 1);
810
+ const $ = v(g, m);
318
811
  return `
319
812
 
320
- ` + h + a + `
321
- ` + s.replace(/\n$/, "") + `
322
- ` + h + `
813
+ ` + $ + u + `
814
+ ` + c.replace(/\n$/, "") + `
815
+ ` + $ + `
323
816
 
324
817
  `;
325
818
  }
326
819
  };
327
- f.horizontalRule = {
820
+ N.horizontalRule = {
328
821
  filter: "hr",
329
822
  replacement: function(t, e, n) {
330
823
  return `
@@ -334,48 +827,48 @@ f.horizontalRule = {
334
827
  `;
335
828
  }
336
829
  };
337
- f.inlineLink = {
830
+ N.inlineLink = {
338
831
  filter: function(t, e) {
339
832
  return !!(e?.linkStyle === "inlined" && t.nodeName === "A" && t.getAttribute("href"));
340
833
  },
341
834
  replacement: function(t, e) {
342
- const n = G(t);
343
- let r = e.getAttribute("href")?.replace(/([()])/g, "\\$1"), i;
344
- const l = e.getAttribute("title");
345
- return l ? i = ' "' + g(l).replace(/"/g, '\\"') + '"' : i = "", "[" + n + "](" + r + i + ")";
835
+ const n = xe(t);
836
+ let i = e.getAttribute("href")?.replace(/([()])/g, "\\$1"), r;
837
+ const s = e.getAttribute("title");
838
+ return s ? r = ' "' + b(s).replace(/"/g, '\\"') + '"' : r = "", "[" + n + "](" + i + r + ")";
346
839
  }
347
840
  };
348
- const R = {
841
+ const D = {
349
842
  filter: function(t, e) {
350
843
  return !!(e && e.linkStyle === "referenced" && t.nodeName === "A" && t.getAttribute("href"));
351
844
  },
352
845
  replacement: function(t, e, n) {
353
- const r = R, i = e.getAttribute("href");
354
- let l;
355
- const c = e.getAttribute("title");
356
- c ? l = ' "' + g(c) + '"' : l = "";
357
- const a = i + l;
358
- let s, o;
846
+ const i = D, r = e.getAttribute("href");
847
+ let s;
848
+ const l = e.getAttribute("title");
849
+ l ? s = ' "' + b(l) + '"' : s = "";
850
+ const u = r + s;
851
+ let c, g;
359
852
  switch (n.linkReferenceStyle) {
360
853
  case "collapsed":
361
- s = "[" + t + "][]", o = "[" + t + "]: " + a;
854
+ c = "[" + t + "][]", g = "[" + t + "]: " + u;
362
855
  break;
363
856
  case "shortcut":
364
- s = "[" + t + "]", o = "[" + t + "]: " + a;
857
+ c = "[" + t + "]", g = "[" + t + "]: " + u;
365
858
  break;
366
859
  default: {
367
- let u;
368
- const m = r.urlReferenceIdMap.get(a);
369
- n.linkReferenceDeduplication === "full" && m ? (u = m, o = "[" + u + "]: " + i + l) : (u = r.references.length + 1, r.urlReferenceIdMap.set(a, u), o = "[" + u + "]: " + i + l, r.references.push(o)), s = "[" + t + "][" + u + "]";
860
+ let m;
861
+ const E = i.urlReferenceIdMap.get(u);
862
+ n.linkReferenceDeduplication === "full" && E ? (m = E, g = "[" + m + "]: " + r + s) : (m = i.references.length + 1, i.urlReferenceIdMap.set(u, m), g = "[" + m + "]: " + r + s, i.references.push(g)), c = "[" + t + "][" + m + "]";
370
863
  break;
371
864
  }
372
865
  }
373
- return n.linkReferenceStyle !== "full" && (n.linkReferenceDeduplication === "full" ? r.urlReferenceIdMap.has(a) || (r.urlReferenceIdMap.set(a, 1), r.references.push(o)) : r.references.push(o)), s;
866
+ return n.linkReferenceStyle !== "full" && (n.linkReferenceDeduplication === "full" ? i.urlReferenceIdMap.has(u) || (i.urlReferenceIdMap.set(u, 1), i.references.push(g)) : i.references.push(g)), c;
374
867
  },
375
868
  references: [],
376
869
  urlReferenceIdMap: /* @__PURE__ */ new Map(),
377
870
  append: () => {
378
- const t = R;
871
+ const t = D;
379
872
  let e = "";
380
873
  return t.references && t.references.length && (e = `
381
874
 
@@ -385,36 +878,36 @@ const R = {
385
878
  `, t.references = [], t.urlReferenceIdMap = /* @__PURE__ */ new Map()), e;
386
879
  }
387
880
  };
388
- f.referenceLink = R;
389
- f.emphasis = {
881
+ N.referenceLink = D;
882
+ N.emphasis = {
390
883
  filter: ["em", "i"],
391
884
  replacement: (t, e, n) => (t = t.trim(), t ? n.emDelimiter + t + n.emDelimiter : "")
392
885
  };
393
- f.strong = {
886
+ N.strong = {
394
887
  filter: ["strong", "b"],
395
888
  replacement: (t, e, n) => (t = t.trim(), t ? n.strongDelimiter + t + n.strongDelimiter : "")
396
889
  };
397
- f.code = {
890
+ N.code = {
398
891
  filter: (t) => {
399
- const e = t.previousSibling || t.nextSibling, r = t.parentNode.nodeName === "PRE" && !e;
400
- return t.nodeName === "CODE" && !r;
892
+ const e = t.parentNode, n = te(e);
893
+ return t.nodeName === "CODE" && !n;
401
894
  },
402
895
  replacement: (t) => {
403
896
  const e = t.replace(/\r?\n|\r/g, " "), n = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "";
404
- let r = "`";
405
- const i = e.match(/`+/gm) || [];
406
- for (; i.includes(r); ) r = r + "`";
407
- return r + n + e + n + r;
897
+ let i = "`";
898
+ const r = e.match(/`+/gm) || [];
899
+ for (; r.includes(i); ) i = i + "`";
900
+ return i + n + e + n + i;
408
901
  }
409
902
  };
410
- f.image = {
903
+ N.image = {
411
904
  filter: "img",
412
905
  replacement: function(t, e) {
413
- const n = e.getAttribute("alt"), r = n ? g(n) : "", i = e.getAttribute("src") || "", l = e.getAttribute("title"), c = l ? g(l) : "", a = c ? ' "' + c + '"' : "";
414
- return i ? "![" + r + "](" + i + a + ")" : "";
906
+ const n = e.getAttribute("alt"), i = n ? b(n) : "", r = e.getAttribute("src") || "", s = e.getAttribute("title"), l = s ? b(s) : "", u = l ? ' "' + l + '"' : "";
907
+ return r ? "![" + i + "](" + r + u + ")" : "";
415
908
  }
416
909
  };
417
- class K {
910
+ class Re {
418
911
  options;
419
912
  _keep;
420
913
  _remove;
@@ -461,110 +954,110 @@ class K {
461
954
  replacement: this.markdownIncludingHtmlReplacement
462
955
  };
463
956
  let n;
464
- return (n = N(this.array, e, this.options)) || (n = N(this._keep, e, this.options)) || (n = N(this._remove, e, this.options)) ? n : this.defaultRule;
957
+ return (n = O(this.array, e, this.options)) || (n = O(this._keep, e, this.options)) || (n = O(this._remove, e, this.options)) ? n : this.defaultRule;
465
958
  }
466
959
  /// Check if an element is unsupported for Markdown conversion.
467
960
  isUnsupportedElement(e) {
468
961
  const n = e.nodeName;
469
962
  if (n === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE") {
470
- const r = e.firstChild;
471
- if (r.attributes && r.attributes.length > 0) {
472
- for (let i = 0; i < r.attributes.length; i++)
473
- if (r.attributes[i].name.toLowerCase() !== "class")
963
+ const i = e.firstChild;
964
+ if (i.attributes && i.attributes.length > 0) {
965
+ for (let r = 0; r < i.attributes.length; r++)
966
+ if (i.attributes[r].name.toLowerCase() !== "class")
474
967
  return !0;
475
968
  }
476
969
  }
477
970
  if (e.attributes && e.attributes.length > 0)
478
971
  switch (n) {
479
972
  case "IMG":
480
- for (let i = 0; i < e.attributes.length; i++) {
481
- const l = e.attributes[i].name.toLowerCase();
482
- if (l !== "src" && l !== "alt" && l !== "title")
973
+ for (let r = 0; r < e.attributes.length; r++) {
974
+ const s = e.attributes[r].name.toLowerCase();
975
+ if (s !== "src" && s !== "alt" && s !== "title")
483
976
  return !0;
484
977
  }
485
978
  return !1;
486
979
  case "A":
487
- for (let i = 0; i < e.attributes.length; i++) {
488
- const l = e.attributes[i].name.toLowerCase();
489
- if (l !== "href" && l !== "title")
980
+ for (let r = 0; r < e.attributes.length; r++) {
981
+ const s = e.attributes[r].name.toLowerCase();
982
+ if (s !== "href" && s !== "title")
490
983
  return !0;
491
984
  }
492
985
  return !1;
493
986
  case "CODE":
494
- const r = e.parentNode;
495
- if (r && r.nodeName === "PRE") {
496
- for (let i = 0; i < e.attributes.length; i++)
497
- if (e.attributes[i].name.toLowerCase() !== "class")
987
+ const i = e.parentNode;
988
+ if (i && i.nodeName === "PRE") {
989
+ for (let r = 0; r < e.attributes.length; r++)
990
+ if (e.attributes[r].name.toLowerCase() !== "class")
498
991
  return !0;
499
992
  return !1;
500
993
  }
501
994
  default:
502
995
  return !0;
503
996
  }
504
- return z.indexOf(n) === -1;
997
+ return Ne.indexOf(n) === -1;
505
998
  }
506
999
  forEach(e) {
507
1000
  for (let n = 0; n < this.array.length; n++)
508
1001
  e(this.array[n], n);
509
1002
  }
510
1003
  }
511
- function N(t, e, n) {
512
- for (let r = 0; r < t.length; r++) {
513
- const i = t[r];
514
- if (j(i, e, n)) return i;
1004
+ function O(t, e, n) {
1005
+ for (let i = 0; i < t.length; i++) {
1006
+ const r = t[i];
1007
+ if (be(r, e, n)) return r;
515
1008
  }
516
1009
  }
517
- function j(t, e, n) {
518
- const r = t.filter;
519
- if (typeof r == "string") {
520
- if (r === e.nodeName.toLowerCase())
1010
+ function be(t, e, n) {
1011
+ const i = t.filter;
1012
+ if (typeof i == "string") {
1013
+ if (i === e.nodeName.toLowerCase())
521
1014
  return !0;
522
- } else if (Array.isArray(r)) {
523
- if (r.indexOf(e.nodeName.toLowerCase()) > -1)
1015
+ } else if (Array.isArray(i)) {
1016
+ if (i.indexOf(e.nodeName.toLowerCase()) > -1)
524
1017
  return !0;
525
- } else if (typeof r == "function") {
526
- if (r(e, n))
1018
+ } else if (typeof i == "function") {
1019
+ if (i(e, n))
527
1020
  return !0;
528
1021
  } else
529
1022
  throw new TypeError("`filter` needs to be a string, array, or function");
530
1023
  return !1;
531
1024
  }
532
- function Y(t) {
533
- const e = t.element, n = t.isBlock, r = t.isVoid, i = t.isPre || function(o) {
534
- return o.nodeName === "PRE";
1025
+ function Ce(t) {
1026
+ const e = t.element, n = t.isBlock, i = t.isVoid, r = t.isPre || function(g) {
1027
+ return g.nodeName === "PRE";
535
1028
  };
536
- if (!e.firstChild || i(e)) return;
537
- let l = null, c = !1, a = null, s = C(a, e, i);
538
- for (; s !== e; ) {
539
- if (s.nodeType === p.Text || s.nodeType === p.CDATASection) {
540
- const u = s;
541
- let m = u.data.replace(/[ \r\n\t]+/g, " ");
542
- if ((!l || / $/.test(l.data)) && !c && m[0] === " " && (m = m.substr(1)), !m) {
543
- s = T(s);
1029
+ if (!e.firstChild || r(e)) return;
1030
+ let s = null, l = !1, u = null, c = z(u, e, r);
1031
+ for (; c !== e; ) {
1032
+ if (c.nodeType === x.Text || c.nodeType === x.CDATASection) {
1033
+ const m = c;
1034
+ let E = m.data.replace(/[ \r\n\t]+/g, " ");
1035
+ if ((!s || / $/.test(s.data)) && !l && E[0] === " " && (E = E.substr(1)), !E) {
1036
+ c = S(c);
544
1037
  continue;
545
1038
  }
546
- u.data = m, l = u;
547
- } else if (s.nodeType === p.Element)
548
- n(s) || s.nodeName === "BR" ? (l && (l.data = l.data.replace(/ $/, "")), l = null, c = !1) : r(s) || i(s) ? (l = null, c = !0) : l && (c = !1);
1039
+ m.data = E, s = m;
1040
+ } else if (c.nodeType === x.Element)
1041
+ n(c) || c.nodeName === "BR" ? (s && (s.data = s.data.replace(/ $/, "")), s = null, l = !1) : i(c) || r(c) ? (s = null, l = !0) : s && (l = !1);
549
1042
  else {
550
- s = T(s);
1043
+ c = S(c);
551
1044
  continue;
552
1045
  }
553
- const o = C(a, s, i);
554
- a = s, s = o;
1046
+ const g = z(u, c, r);
1047
+ u = c, c = g;
555
1048
  }
556
- l && (l.data = l.data.replace(/ $/, ""), l.data || T(l));
1049
+ s && (s.data = s.data.replace(/ $/, ""), s.data || S(s));
557
1050
  }
558
- function T(t) {
1051
+ function S(t) {
559
1052
  const e = t.nextSibling ?? t.parentNode;
560
1053
  return t.parentNode && t.parentNode.removeChild(t), e;
561
1054
  }
562
- function C(t, e, n) {
1055
+ function z(t, e, n) {
563
1056
  return t && t.parentNode === e || n(e) ? e.nextSibling ?? e.parentNode : e.firstChild ?? e.nextSibling ?? e.parentNode;
564
1057
  }
565
- const E = typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
566
- function q() {
567
- const t = typeof E.DOMParser < "u" ? E.DOMParser : void 0;
1058
+ const I = typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : {};
1059
+ function we() {
1060
+ const t = typeof I.DOMParser < "u" ? I.DOMParser : void 0;
568
1061
  let e = !1;
569
1062
  if (!t) return !1;
570
1063
  try {
@@ -573,55 +1066,55 @@ function q() {
573
1066
  }
574
1067
  return e;
575
1068
  }
576
- class S {
1069
+ class W {
577
1070
  // This will be assigned per environment below
578
1071
  parseFromString(e, n) {
579
1072
  throw new Error("Not implemented");
580
1073
  }
581
1074
  }
582
- function Q() {
1075
+ function Oe() {
583
1076
  if (typeof window < "u" && typeof document < "u" && (typeof process > "u" || process.browser), typeof window < "u") {
584
- class t extends S {
585
- parseFromString(n, r) {
586
- const i = document.implementation.createHTMLDocument("");
587
- return i.open(), i.write(n), i.close(), i;
1077
+ class t extends W {
1078
+ parseFromString(n, i) {
1079
+ const r = document.implementation.createHTMLDocument("");
1080
+ return r.open(), r.write(n), r.close(), r;
588
1081
  }
589
1082
  }
590
1083
  return new t();
591
1084
  } else {
592
1085
  const t = require("@mixmark-io/domino");
593
- class e extends S {
594
- parseFromString(r, i) {
595
- return t.createDocument(r);
1086
+ class e extends W {
1087
+ parseFromString(i, r) {
1088
+ return t.createDocument(i);
596
1089
  }
597
1090
  }
598
1091
  return new e();
599
1092
  }
600
1093
  }
601
- const X = () => q() ? new E.DOMParser() : Q();
602
- function J(t, { preformattedCode: e }) {
1094
+ const Se = () => we() ? new I.DOMParser() : Oe();
1095
+ function Me(t, { preformattedCode: e }) {
603
1096
  let n;
604
- return typeof t == "string" ? n = ee().parseFromString(
1097
+ return typeof t == "string" ? n = ve().parseFromString(
605
1098
  // DOM parsers arrange elements in the <head> and <body>.
606
1099
  // Wrapping in a custom element ensures elements are reliably arranged in
607
1100
  // a single element.
608
1101
  '<x-turnish id="turnish-root">' + t + "</x-turnish>",
609
1102
  "text/html"
610
- ).getElementById("turnish-root") : n = t.cloneNode(!0), Y({
1103
+ ).getElementById("turnish-root") : n = t.cloneNode(!0), Ce({
611
1104
  element: n,
612
- isBlock: A,
613
- isVoid: L,
614
- isPre: e ? te : void 0
1105
+ isBlock: B,
1106
+ isVoid: X,
1107
+ isPre: e ? De : void 0
615
1108
  }), n;
616
1109
  }
617
- let Z;
618
- function ee() {
619
- return Z ??= X();
1110
+ let Le;
1111
+ function ve() {
1112
+ return Le ??= Se();
620
1113
  }
621
- function te(t) {
1114
+ function De(t) {
622
1115
  return t.nodeName === "PRE" || t.nodeName === "CODE";
623
1116
  }
624
- const ne = [
1117
+ const Ie = [
625
1118
  [/\\/g, "\\\\"],
626
1119
  [/\*/g, "\\*"],
627
1120
  [/_/g, "\\_"],
@@ -636,8 +1129,8 @@ const ne = [
636
1129
  [/<([^>]*)>/g, "\\<$1\\>"],
637
1130
  [/^>/g, "\\>"],
638
1131
  [/^(\d+)\. /g, "$1\\. "]
639
- ], re = {
640
- rules: f,
1132
+ ], Be = {
1133
+ rules: N,
641
1134
  headingStyle: "atx",
642
1135
  hr: "---",
643
1136
  bulletListMarker: "-",
@@ -664,24 +1157,24 @@ const ne = [
664
1157
  ` : e.outerHTML,
665
1158
  markdownIncludingHtmlReplacement: (t, e) => {
666
1159
  const n = e.nodeName.toLowerCase();
667
- let r = "";
1160
+ let i = "";
668
1161
  if (e.attributes && e.attributes.length > 0) {
669
- const s = [];
670
- for (let o = 0; o < e.attributes.length; o++) {
671
- const u = e.attributes[o];
672
- s.push(`${u.name}="${u.value}"`);
1162
+ const c = [];
1163
+ for (let g = 0; g < e.attributes.length; g++) {
1164
+ const m = e.attributes[g];
1165
+ c.push(`${m.name}="${m.value}"`);
673
1166
  }
674
- r = " " + s.join(" ");
1167
+ i = " " + c.join(" ");
675
1168
  }
676
- r += ' markdown="1"';
677
- const i = `<${n}${r}>`, l = `</${n}>`, c = t.trim(), a = i + `
678
- ` + c + `
679
- ` + l;
1169
+ i += ' markdown="1"';
1170
+ const r = `<${n}${i}>`, s = `</${n}>`, l = t.trim(), u = r + `
1171
+ ` + l + `
1172
+ ` + s;
680
1173
  return e.isBlock ? `
681
1174
 
682
- ` + a + `
1175
+ ` + u + `
683
1176
 
684
- ` : a;
1177
+ ` : u;
685
1178
  },
686
1179
  defaultReplacement: function(t, e) {
687
1180
  return e.isBlock ? `
@@ -691,11 +1184,11 @@ const ne = [
691
1184
  ` : t;
692
1185
  }
693
1186
  };
694
- class le {
1187
+ class Ve {
695
1188
  options;
696
1189
  rules;
697
1190
  constructor(e) {
698
- this.options = Object.assign({}, re, e), this.rules = new K(this.options);
1191
+ this.options = Object.assign({}, Be, e), this.rules = new Re(this.options);
699
1192
  }
700
1193
  /**
701
1194
  * The entry point for converting a string or DOM node to Markdown
@@ -705,13 +1198,13 @@ class le {
705
1198
  * @type string
706
1199
  */
707
1200
  render(e) {
708
- if (!ie(e))
1201
+ if (!Pe(e))
709
1202
  throw new TypeError(
710
1203
  e + " is not a string, or an element/document/fragment node."
711
1204
  );
712
1205
  if (e === "")
713
1206
  return "";
714
- const n = this.process(J(e, this.options));
1207
+ const n = this.process(Me(e, this.options));
715
1208
  return this.postProcess(n);
716
1209
  }
717
1210
  /**
@@ -769,8 +1262,8 @@ class le {
769
1262
  * @type string
770
1263
  */
771
1264
  escape(e) {
772
- return ne.reduce(function(n, r) {
773
- return n.replace(r[0], r[1]);
1265
+ return Ie.reduce(function(n, i) {
1266
+ return n.replace(i[0], i[1]);
774
1267
  }, e);
775
1268
  }
776
1269
  /**
@@ -781,18 +1274,18 @@ class le {
781
1274
  * @type string
782
1275
  */
783
1276
  process(e) {
784
- return Array.from(e.childNodes).reduce((n, r) => {
785
- const i = H(r, this.options);
786
- let l = "";
787
- if (i.nodeType === p.Text) {
788
- let c = i.nodeValue ?? "";
789
- if (r.previousSibling && r.previousSibling.nodeType === p.Element) {
790
- const a = r.previousSibling;
791
- a.nodeName === "INPUT" && a.getAttribute("type") === "checkbox" && (c = c.replace(/^\s+/, ""));
1277
+ return Array.from(e.childNodes).reduce((n, i) => {
1278
+ const r = fe(i, this.options);
1279
+ let s = "";
1280
+ if (r.nodeType === x.Text) {
1281
+ let l = r.nodeValue ?? "";
1282
+ if (i.previousSibling && i.previousSibling.nodeType === x.Element) {
1283
+ const u = i.previousSibling;
1284
+ u.nodeName === "INPUT" && u.getAttribute("type") === "checkbox" && (l = l.replace(/^\s+/, ""));
792
1285
  }
793
- l = i.isCode ? c : this.escape(c);
794
- } else i.nodeType === p.Element && (l = this.replacementForNode(i));
795
- return x(n, l);
1286
+ s = r.isCode ? l : this.escape(l);
1287
+ } else r.nodeType === x.Element && (s = this.replacementForNode(r));
1288
+ return G(n, s);
796
1289
  }, "");
797
1290
  }
798
1291
  /**
@@ -804,7 +1297,7 @@ class le {
804
1297
  */
805
1298
  postProcess(e) {
806
1299
  for (const n of this.rules.array)
807
- n.append && (e = x(e, n.append(this.options)));
1300
+ n.append && (e = G(e, n.append(this.options)));
808
1301
  return e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
809
1302
  }
810
1303
  /**
@@ -816,21 +1309,24 @@ class le {
816
1309
  */
817
1310
  replacementForNode(e) {
818
1311
  const n = this.rules.forNode(e);
819
- let r = this.process(e);
820
- const i = e.flankingWhitespace;
821
- return (i.leading || i.trailing) && (r = r.trim()), i.leading + n.replacement(r, e, this.options) + i.trailing;
1312
+ let i = this.process(e);
1313
+ const r = e.flankingWhitespace;
1314
+ return (r.leading || r.trailing) && (i = i.trim()), r.leading + n.replacement(i, e, this.options) + r.trailing;
1315
+ }
1316
+ isCodeBlock(e) {
1317
+ return te(e);
822
1318
  }
823
1319
  }
824
- function x(t, e) {
825
- const n = O(t), r = I(e), i = Math.max(t.length - n.length, e.length - r.length), l = `
1320
+ function G(t, e) {
1321
+ const n = Y(t), i = K(e), r = Math.max(t.length - n.length, e.length - i.length), s = `
826
1322
 
827
- `.substring(0, i);
828
- return n + l + r;
1323
+ `.substring(0, r);
1324
+ return n + s + i;
829
1325
  }
830
- function ie(t) {
1326
+ function Pe(t) {
831
1327
  return t != null && (typeof t == "string" || t.nodeType && (t.nodeType === 1 || t.nodeType === 9 || t.nodeType === 11));
832
1328
  }
833
1329
  export {
834
- le as default
1330
+ Ve as default
835
1331
  };
836
1332
  //# sourceMappingURL=index.mjs.map