@mdsvex/parse 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.js CHANGED
@@ -1,44 +1,44 @@
1
- var j;
2
- const $ = new Uint32Array(0), W = Object.freeze([]), L = 48, H = [], R = globalThis.Buffer, tt = R !== void 0 && typeof R.allocUnsafeSlow == "function";
3
- function K(n) {
4
- return tt ? R.allocUnsafeSlow(n).buffer : new ArrayBuffer(n);
1
+ var Q;
2
+ const et = new Uint32Array(0), X = Object.freeze([]), N = 48, j = [], D = globalThis.Buffer, it = D !== void 0 && typeof D.allocUnsafeSlow == "function";
3
+ function q(r) {
4
+ return it ? D.allocUnsafeSlow(r).buffer : new ArrayBuffer(r);
5
5
  }
6
- const N = 512;
7
- function S(n, t, f) {
6
+ const O = 512;
7
+ function m(r, t, f) {
8
8
  const s = f - t <= 64 ? f : t + 64;
9
9
  for (let i = t * 12; i < s * 12; )
10
- n[
10
+ r[
11
11
  i + 2
12
12
  /* NodeField.end */
13
- ] = 4294967295, n[
13
+ ] = 4294967295, r[
14
14
  i + 3
15
15
  /* NodeField.value_start */
16
- ] = 0, n[
16
+ ] = 0, r[
17
17
  i + 4
18
18
  /* NodeField.value_end */
19
- ] = 0, n[
19
+ ] = 0, r[
20
20
  i + 6
21
21
  /* NodeField.next */
22
- ] = 4294967295, n[
22
+ ] = 4294967295, r[
23
23
  i + 7
24
24
  /* NodeField.prev */
25
- ] = 4294967295, n[
25
+ ] = 4294967295, r[
26
26
  i + 8
27
27
  /* NodeField.first_child */
28
- ] = 4294967295, n[
28
+ ] = 4294967295, r[
29
29
  i + 9
30
30
  /* NodeField.last_child */
31
- ] = 4294967295, n[
31
+ ] = 4294967295, r[
32
32
  i + 10
33
33
  /* NodeField.pending */
34
- ] = 0, n[
34
+ ] = 0, r[
35
35
  i + 11
36
36
  /* NodeField.meta */
37
37
  ] = 0, i += 12;
38
38
  let e = s;
39
39
  for (; e < f; ) {
40
40
  let i = e - t;
41
- i > N && (i = N), i > f - e && (i = f - e), n.copyWithin(
41
+ i > O && (i = O), i > f - e && (i = f - e), r.copyWithin(
42
42
  e * 12,
43
43
  t * 12,
44
44
  (t + i) * 12
@@ -46,17 +46,17 @@ function S(n, t, f) {
46
46
  ), e += i;
47
47
  }
48
48
  }
49
- const ft = 1048576 / L | 0, V = 4096;
50
- let y = new ArrayBuffer(0), w = 1048576, m = null;
51
- const st = 32;
52
- function q(n) {
49
+ const rt = 1048576 / N | 0, G = 4096;
50
+ let y = new ArrayBuffer(0), A = 1048576, B = null;
51
+ const nt = 32;
52
+ function Z(r) {
53
53
  let t = 1;
54
- for (; t < n; )
54
+ for (; t < r; )
55
55
  t <<= 1;
56
56
  return t;
57
57
  }
58
- const G = (n) => {
59
- switch (n) {
58
+ const $ = (r) => {
59
+ switch (r) {
60
60
  case 0:
61
61
  return "root";
62
62
  case 1:
@@ -136,140 +136,156 @@ const G = (n) => {
136
136
  case 38:
137
137
  return "definition";
138
138
  }
139
- }, J = /* @__PURE__ */ new Map();
140
- for (let n = 0; n <= 38; n++)
141
- J.set(G(n), n);
142
- const at = (n) => J.get(n), et = (n) => {
143
- switch (n) {
139
+ }, tt = /* @__PURE__ */ new Map();
140
+ for (let r = 0; r <= 38; r++)
141
+ tt.set($(r), r);
142
+ const ut = (r) => tt.get(r), _t = (r) => {
143
+ switch (r) {
144
144
  case 3:
145
145
  return "depth";
146
146
  }
147
147
  };
148
- let O = !1;
149
- function ct() {
150
- return O ? (O = !1, !0) : !1;
148
+ let I = !1;
149
+ function pt() {
150
+ return I ? (I = !1, !0) : !1;
151
151
  }
152
- let M = !1;
153
- function lt() {
154
- M = !0;
152
+ let U = !1, P = 1;
153
+ function E() {
154
+ P = P + 1 | 1;
155
155
  }
156
- function ot() {
157
- return M ? (M = !1, !0) : !1;
156
+ function dt() {
157
+ return P;
158
158
  }
159
- let D = !1;
160
- function ut() {
161
- D = !0;
159
+ function K(r) {
160
+ return typeof r == "string" && r.length === 2 && r.charCodeAt(0) === 104 && r.charCodeAt(1) >= 49 && r.charCodeAt(1) <= 54;
162
161
  }
163
- function pt() {
164
- return D ? (D = !1, !0) : !1;
162
+ function gt() {
163
+ U = !0, E();
164
+ }
165
+ function bt() {
166
+ return U ? (U = !1, !0) : !1;
167
+ }
168
+ let F = !1;
169
+ function xt() {
170
+ F = !0, U = !0;
171
+ }
172
+ function At() {
173
+ return F ? (F = !1, !0) : !1;
174
+ }
175
+ let W = !1;
176
+ function wt() {
177
+ W = !0;
165
178
  }
166
- const P = 128, z = [];
179
+ function kt() {
180
+ return W ? (W = !1, !0) : !1;
181
+ }
182
+ const H = 128, z = [];
167
183
  let x = 0;
168
- function Q(n, t) {
169
- x < P ? (z[x] = n, z[x + 1] = t, x += 2) : x = P + 2;
184
+ function ft(r, t) {
185
+ x < H ? (z[x] = r, z[x + 1] = t, x += 2) : x = H + 2;
170
186
  }
171
- function dt(n, t, f) {
172
- return x !== 0 && it(n, t, f);
187
+ function vt(r, t, f) {
188
+ return x !== 0 && ht(r, t, f);
173
189
  }
174
- function it(n, t, f) {
190
+ function ht(r, t, f) {
175
191
  const s = x;
176
- if (x = 0, s > P)
192
+ if (x = 0, s > H)
177
193
  return !0;
178
194
  for (let e = 0; e < s; e += 2) {
179
- const i = z[e + 1], r = i - t.length;
180
- for (let h = z[e]; h <= r; h++)
181
- if (n.startsWith(t, h))
195
+ const i = z[e + 1], n = i - t.length;
196
+ for (let h = z[e]; h <= n; h++)
197
+ if (r.startsWith(t, h))
182
198
  return !0;
183
199
  if (f === void 0)
184
200
  continue;
185
201
  const _ = i - f.length;
186
202
  for (let h = z[e]; h <= _; h++)
187
- if (n.startsWith(f, h))
203
+ if (r.startsWith(f, h))
188
204
  return !0;
189
205
  }
190
206
  return !1;
191
207
  }
192
- const rt = 0, nt = 1, _t = 2;
193
- class I {
194
- constructor(t, f, s, e, i, r, _, h, a, c) {
195
- this.source = t, this.base = f, this.rec = s, this.at = e, this.n = i, this.name_start = r, this.attrs_end = _, this.open_end = h, this.attrs_start = a, this.canonical = c, this.text = void 0;
208
+ const at = 0, ct = 1, lt = 2;
209
+ class Y {
210
+ constructor(t, f, s, e, i, n, _, h, a, c) {
211
+ this.source = t, this.base = f, this.rec = s, this.at = e, this.n = i, this.name_start = n, this.attrs_end = _, this.open_end = h, this.attrs_start = a, this.canonical = c, this.text = void 0;
196
212
  }
197
213
  }
198
- function gt(n) {
199
- return n.text ?? (n.text = n.source.slice(n.attrs_start - n.base, n.attrs_end - n.base));
214
+ function yt(r) {
215
+ return r.text ?? (r.text = r.source.slice(r.attrs_start - r.base, r.attrs_end - r.base));
200
216
  }
201
- let Y = new Int32Array(8192), B = 0, Z = 0;
202
- function bt(n, t) {
203
- B + t > Y.length && (Y = new Int32Array(t > 8192 ? t : 8192), B = 0);
204
- const f = Y, s = Z = B;
217
+ let M = new Int32Array(8192), C = 0, st = 0;
218
+ function zt(r, t) {
219
+ C + t > M.length && (M = new Int32Array(t > 8192 ? t : 8192), C = 0);
220
+ const f = M, s = st = C;
205
221
  for (let e = 0; e < t; e++)
206
- f[s + e] = n[e];
207
- return B = s + t, f;
222
+ f[s + e] = r[e];
223
+ return C = s + t, f;
208
224
  }
209
- function xt() {
210
- return Z;
225
+ function Tt() {
226
+ return st;
211
227
  }
212
- function F(n) {
213
- const t = n.source, f = n.base, s = n.rec, e = n.at + n.n, i = {};
214
- for (let r = n.at; r < e; r += 5) {
215
- const _ = s[r], h = t.slice(s[r + 1] - f, s[r + 2] - f);
216
- if (_ === rt)
228
+ function V(r) {
229
+ const t = r.source, f = r.base, s = r.rec, e = r.at + r.n, i = {};
230
+ for (let n = r.at; n < e; n += 5) {
231
+ const _ = s[n], h = t.slice(s[n + 1] - f, s[n + 2] - f);
232
+ if (_ === at)
217
233
  i[h] = !0;
218
- else if (_ === _t)
234
+ else if (_ === lt)
219
235
  i[h] = { type: "expression", value: h };
220
236
  else {
221
- const a = t.slice(s[r + 3] - f, s[r + 4] - f);
222
- i[h] = _ === nt ? a : { type: "expression", value: a };
237
+ const a = t.slice(s[n + 3] - f, s[n + 4] - f);
238
+ i[h] = _ === ct ? a : { type: "expression", value: a };
223
239
  }
224
240
  }
225
241
  return i;
226
242
  }
227
- function wt(n, t) {
228
- const f = n.source, s = n.base, e = n.rec, i = n.at + n.n;
229
- for (let r = n.at; r < i; r += 5) {
230
- const _ = e[r + 1] - s;
231
- if (e[r + 2] - s - _ === t.length && f.startsWith(t, _))
243
+ function Et(r, t) {
244
+ const f = r.source, s = r.base, e = r.rec, i = r.at + r.n;
245
+ for (let n = r.at; n < i; n += 5) {
246
+ const _ = e[n + 1] - s;
247
+ if (e[n + 2] - s - _ === t.length && f.startsWith(t, _))
232
248
  return !0;
233
249
  }
234
250
  return !1;
235
251
  }
236
252
  const T = Symbol("attributes");
237
- class U {
253
+ class R {
238
254
  constructor(t) {
239
- this[j] = void 0, this.tag = t;
255
+ this[Q] = void 0, this.tag = t;
240
256
  }
241
257
  get attributes() {
242
258
  const t = this[T];
243
- return t instanceof I ? this[T] = F(t) : t;
259
+ return t instanceof Y ? this[T] = V(t) : t;
244
260
  }
245
261
  set attributes(t) {
246
262
  this[T] = t;
247
263
  }
248
264
  }
249
- j = T;
250
- function ht(n) {
251
- if (!(n instanceof U))
252
- return n;
253
- const t = { tag: n.tag }, f = n.attributes;
265
+ Q = T;
266
+ function ot(r) {
267
+ if (!(r instanceof R))
268
+ return r;
269
+ const t = { tag: r.tag }, f = r.attributes;
254
270
  f !== void 0 && (t.attributes = f);
255
- for (const s in n)
256
- t[s] = n[s];
271
+ for (const s in r)
272
+ t[s] = r[s];
257
273
  return t;
258
274
  }
259
- function At(n) {
260
- if (!(n instanceof U))
275
+ function St(r) {
276
+ if (!(r instanceof R))
261
277
  return;
262
- const t = n[T];
263
- return t instanceof I ? t : void 0;
278
+ const t = r[T];
279
+ return t instanceof Y ? t : void 0;
264
280
  }
265
- function kt(n, t) {
266
- switch (n) {
281
+ function mt(r, t) {
282
+ switch (r) {
267
283
  case "tag":
268
- return new U(t);
284
+ return K(t) && E(), new R(t);
269
285
  case "href":
270
286
  return { href: t };
271
287
  case "src":
272
- return O = !0, { src: t };
288
+ return I = !0, { src: t };
273
289
  case "ordered":
274
290
  return { ordered: t };
275
291
  case "info_start":
@@ -280,7 +296,7 @@ function kt(n, t) {
280
296
  return { alignments: t };
281
297
  case "attributes":
282
298
  return {
283
- attributes: t instanceof I ? F(t) : t
299
+ attributes: t instanceof Y ? V(t) : t
284
300
  };
285
301
  case "self_closing":
286
302
  return { self_closing: t };
@@ -291,7 +307,7 @@ function kt(n, t) {
291
307
  case "tight":
292
308
  return { tight: t };
293
309
  case "info_end":
294
- return Q(0, t), { info_end: t };
310
+ return ft(0, t), { info_end: t };
295
311
  case "args":
296
312
  return { name: void 0, args: t };
297
313
  case "col_count":
@@ -299,69 +315,69 @@ function kt(n, t) {
299
315
  case "checked":
300
316
  return { checked: t };
301
317
  default: {
302
- if (n === "__proto__")
303
- return { [n]: t };
318
+ if (r === "__proto__")
319
+ return { [r]: t };
304
320
  const f = {};
305
- return f[n] = t, f;
321
+ return f[r] = t, f;
306
322
  }
307
323
  }
308
324
  }
309
- function vt(n, t, f) {
325
+ function Bt(r, t, f) {
310
326
  switch (t) {
311
327
  case "attributes":
312
- n.attributes = f instanceof I && !(n instanceof U) ? F(f) : f;
328
+ r.attributes = f instanceof Y && !(r instanceof R) ? V(f) : f;
313
329
  return;
314
330
  case "start":
315
- n.start = f;
331
+ r.start = f;
316
332
  return;
317
333
  case "tight":
318
- n.tight = f;
334
+ r.tight = f;
319
335
  return;
320
336
  case "title":
321
- n.title = f;
337
+ r.title = f;
322
338
  return;
323
339
  case "self_closing":
324
- n.self_closing = f;
340
+ r.self_closing = f;
325
341
  return;
326
342
  case "info_end":
327
- f !== n.info_start && Q(n.info_start, f), n.info_end = f;
343
+ f !== r.info_start && ft(r.info_start, f), r.info_end = f;
328
344
  return;
329
345
  case "col_count":
330
- n.col_count = f;
346
+ r.col_count = f;
331
347
  return;
332
348
  case "args":
333
- n.args = f;
349
+ r.args = f;
334
350
  return;
335
351
  case "tag":
336
- n.tag = f;
352
+ K(f) && E(), r.tag = f;
337
353
  return;
338
354
  case "href":
339
- n.href = f;
355
+ r.href = f;
340
356
  return;
341
357
  case "src":
342
- O = !0, n.src = f;
358
+ I = !0, r.src = f;
343
359
  return;
344
360
  case "ordered":
345
- n.ordered = f;
361
+ r.ordered = f;
346
362
  return;
347
363
  case "info_start":
348
- n.info_start = f;
364
+ r.info_start = f;
349
365
  return;
350
366
  case "name":
351
- n.name = f;
367
+ r.name = f;
352
368
  return;
353
369
  case "alignments":
354
- n.alignments = f;
370
+ r.alignments = f;
355
371
  return;
356
372
  case "checked":
357
- n.checked = f;
373
+ r.checked = f;
358
374
  return;
359
375
  default:
360
- n[t] = f;
376
+ r[t] = f;
361
377
  }
362
378
  }
363
- function C(n) {
364
- switch (n) {
379
+ function L(r) {
380
+ switch (r) {
365
381
  case 7:
366
382
  return 1;
367
383
  case 1:
@@ -387,17 +403,17 @@ function C(n) {
387
403
  return 0;
388
404
  }
389
405
  }
390
- function X(n, t) {
406
+ function J(r, t) {
391
407
  for (let f = 0; f < t.length; f++)
392
- n.push(t[f]);
408
+ r.push(t[f]);
393
409
  }
394
- function yt(n) {
395
- return n === "script" || n === "style" || n === "pre" || n === "textarea";
410
+ function Ct(r) {
411
+ return r === "script" || r === "style" || r === "pre" || r === "textarea";
396
412
  }
397
- class zt {
413
+ class Lt {
398
414
  constructor(t = 128) {
399
- this._capacity = 0, this._n = $, this._meta = W, this._strings = H, this._size = 0, this._filled = 0;
400
- let f = this.alloc(q(t > 32 ? t : 32));
415
+ this._capacity = 0, this._n = et, this._meta = X, this._strings = j, this._size = 0, this._filled = 0;
416
+ let f = this.alloc(Z(t > 32 ? t : 32));
401
417
  this._filled === 0 && (f = this.fill(0)), f[0] = 0, f[
402
418
  1
403
419
  /* NodeField.start */
@@ -407,25 +423,25 @@ class zt {
407
423
  ] = 4294967295, this._size = 1;
408
424
  }
409
425
  alloc(t) {
410
- const f = t * L;
426
+ const f = t * N;
411
427
  let s, e = 0;
412
- f <= 262144 ? (w + f > 1048576 && (y = K(1048576), w = 0, S(new Uint32Array(y), 0, ft)), s = y, e = w, w = e + f) : s = K(f);
428
+ f <= 262144 ? (A + f > 1048576 && (y = q(1048576), A = 0, m(new Uint32Array(y), 0, rt)), s = y, e = A, A = e + f) : s = q(f);
413
429
  const i = new Uint32Array(
414
430
  s,
415
431
  e,
416
432
  t * 12
417
433
  /* NodeField.stride */
418
434
  );
419
- return s === y ? (m = i, this._filled = t) : this._filled = 0, this._capacity = t, this._n = i, i;
435
+ return s === y ? (B = i, this._filled = t) : this._filled = 0, this._capacity = t, this._n = i, i;
420
436
  }
421
437
  /** @internal */
422
438
  own_strings() {
423
439
  const t = this._strings;
424
- return t === H ? this._strings = [] : t;
440
+ return t === j ? this._strings = [] : t;
425
441
  }
426
442
  /** gives the unused tail of the last slab carve back, a later push resizes */
427
443
  trim() {
428
- this._n === m && (w -= (this._capacity - this._size) * L, this._capacity = this._size, this._filled = this._size);
444
+ this._n === B && (A -= (this._capacity - this._size) * N, this._capacity = this._size, this._filled = this._size);
429
445
  }
430
446
  /** clear nodes without reallocating storage */
431
447
  reset() {
@@ -436,7 +452,7 @@ class zt {
436
452
  const f = this._n;
437
453
  for (let s = 0; s < t; ) {
438
454
  let e = t - s;
439
- e > N && (e = N), f.copyWithin(
455
+ e > O && (e = O), f.copyWithin(
440
456
  s * 12,
441
457
  t * 12,
442
458
  (t + e) * 12
@@ -444,7 +460,7 @@ class zt {
444
460
  ), s += e;
445
461
  }
446
462
  } else
447
- S(this._n, 0, t);
463
+ m(this._n, 0, t);
448
464
  this._size = 0;
449
465
  }
450
466
  }
@@ -460,19 +476,19 @@ class zt {
460
476
  * @param metadata optional metadata associated with the node.
461
477
  */
462
478
  push(t, f, s = 4294967295, e = 0, i) {
463
- const r = this.push_node(t, f, s, e, !1);
464
- return i !== void 0 && this.set_metadata(r, i), r;
479
+ const n = this.push_node(t, f, s, e, !1);
480
+ return i !== void 0 && this.set_metadata(n, i), n;
465
481
  }
466
482
  push_pending(t, f, s = 4294967295, e = 0, i) {
467
- const r = this.push_node(t, f, s, e, !0);
468
- return i !== void 0 && this.set_metadata(r, i), r;
483
+ const n = this.push_node(t, f, s, e, !0);
484
+ return i !== void 0 && this.set_metadata(n, i), n;
469
485
  }
470
486
  /** one body for every open so the builder inlines a single copy */
471
487
  push_node(t, f, s, e, i) {
472
- const r = this._size;
488
+ const n = this._size;
473
489
  let _ = this._n;
474
- r >= this._filled && (_ = this.fill(r));
475
- const h = r * 12;
490
+ n >= this._filled && (_ = this.fill(n));
491
+ const h = n * 12;
476
492
  if (_[h] = t & 255 | (e & 65535) << 8, _[
477
493
  h + 1
478
494
  /* NodeField.start */
@@ -482,7 +498,7 @@ class zt {
482
498
  ] = s, i && (_[
483
499
  h + 10
484
500
  /* NodeField.pending */
485
- ] = 1), this._size = r + 1, s !== 4294967295) {
501
+ ] = 1), this._size = n + 1, s !== 4294967295) {
486
502
  const a = s * 12, c = _[
487
503
  a + 9
488
504
  /* NodeField.last_child */
@@ -490,39 +506,39 @@ class zt {
490
506
  c === 4294967295 ? _[
491
507
  a + 8
492
508
  /* NodeField.first_child */
493
- ] = r : (_[
509
+ ] = n : (_[
494
510
  c * 12 + 6
495
511
  /* NodeField.next */
496
- ] = r, _[
512
+ ] = n, _[
497
513
  h + 7
498
514
  /* NodeField.prev */
499
515
  ] = c), _[
500
516
  a + 9
501
517
  /* NodeField.last_child */
502
- ] = r;
518
+ ] = n;
503
519
  }
504
- return r;
520
+ return n;
505
521
  }
506
522
  /** parent must be a node, not 0xffffffff */
507
523
  push_text(t, f, s) {
508
524
  const e = this._size;
509
525
  let i = this._n;
510
526
  e >= this._filled && (i = this.fill(e));
511
- const r = e * 12;
512
- i[r] = 1, i[
513
- r + 1
527
+ const n = e * 12;
528
+ i[n] = 1, i[
529
+ n + 1
514
530
  /* NodeField.start */
515
531
  ] = t, i[
516
- r + 2
532
+ n + 2
517
533
  /* NodeField.end */
518
534
  ] = f, i[
519
- r + 3
535
+ n + 3
520
536
  /* NodeField.value_start */
521
537
  ] = t, i[
522
- r + 4
538
+ n + 4
523
539
  /* NodeField.value_end */
524
540
  ] = f, i[
525
- r + 5
541
+ n + 5
526
542
  /* NodeField.parent */
527
543
  ] = s, this._size = e + 1;
528
544
  const _ = s * 12, h = i[
@@ -536,7 +552,7 @@ class zt {
536
552
  h * 12 + 6
537
553
  /* NodeField.next */
538
554
  ] = e, i[
539
- r + 7
555
+ n + 7
540
556
  /* NodeField.prev */
541
557
  ] = h), i[
542
558
  _ + 9
@@ -544,7 +560,7 @@ class zt {
544
560
  ] = e, e;
545
561
  }
546
562
  /** a closed node with no extra and a value range, as open, value and close would leave it */
547
- push_leaf(t, f, s, e, i, r) {
563
+ push_leaf(t, f, s, e, i, n) {
548
564
  const _ = this._size;
549
565
  let h = this._n;
550
566
  _ >= this._filled && (h = this.fill(_));
@@ -564,8 +580,8 @@ class zt {
564
580
  ] = e, h[
565
581
  a + 5
566
582
  /* NodeField.parent */
567
- ] = r, this._size = _ + 1;
568
- const c = r * 12, o = h[
583
+ ] = n, this._size = _ + 1;
584
+ const c = n * 12, o = h[
569
585
  c + 9
570
586
  /* NodeField.last_child */
571
587
  ];
@@ -588,18 +604,18 @@ class zt {
588
604
  t >= this._capacity && (f = this.grow());
589
605
  let s = this._filled;
590
606
  if (t >= s) {
591
- let e = s + (s > V ? s : V);
592
- e > this._capacity && (e = this._capacity), S(f, s, e), this._filled = s = e;
607
+ let e = s + (s > G ? s : G);
608
+ e > this._capacity && (e = this._capacity), m(f, s, e), this._filled = s = e;
593
609
  }
594
610
  return f;
595
611
  }
596
612
  /** a node a plugin made, the flag tells it from one the author typed whatever its span */
597
613
  push_synthetic(t, f, s, e = 0, i) {
598
- const r = this.push_node(t, f, s, e, !1);
614
+ const n = this.push_node(t, f, s, e, !1);
599
615
  return this._n[
600
- r * 12 + 10
616
+ n * 12 + 10
601
617
  /* NodeField.pending */
602
- ] = 2, i !== void 0 && this.set_metadata(r, i), r;
618
+ ] = 2, (t === 36 || t === 37 || i !== void 0 && K(i.tag)) && E(), i !== void 0 && this.set_metadata(n, i), n;
603
619
  }
604
620
  synthetic_at(t) {
605
621
  return (this._n[
@@ -632,11 +648,11 @@ class zt {
632
648
  * @returns buffer index of the new wrapper node.
633
649
  */
634
650
  wrap_children(t, f, s = 0, e) {
635
- const i = this.first_child_at(t), r = this.last_child_at(t);
651
+ const i = this.first_child_at(t), n = this.last_child_at(t);
636
652
  this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
637
653
  const _ = this.push_synthetic(f, 0, t, s, e);
638
654
  if (i !== 4294967295) {
639
- this.set_first_child(_, i), this.set_last_child(_, r);
655
+ this.set_first_child(_, i), this.set_last_child(_, n);
640
656
  let h = i;
641
657
  for (; h !== 4294967295 && this.parent_at(h) === t; )
642
658
  this.set_parent(h, _), h = this.next_at(h);
@@ -648,19 +664,19 @@ class zt {
648
664
  * @returns buffer index of the wrapper
649
665
  */
650
666
  wrap_node(t, f, s = 0, e = 0, i) {
651
- const r = this.parent_at(t), _ = r !== 4294967295 && this.first_child_at(r) === t, h = _ ? 4294967295 : this.prev_at(t);
667
+ const n = this.parent_at(t), _ = n !== 4294967295 && this.first_child_at(n) === t, h = _ ? 4294967295 : this.prev_at(t);
652
668
  let a = this.next_at(t);
653
- a !== 4294967295 && this.parent_at(a) !== r && (a = 4294967295);
669
+ a !== 4294967295 && this.parent_at(a) !== n && (a = 4294967295);
654
670
  const c = this.push_synthetic(f, s, 4294967295, e, i);
655
- return this.set_parent(c, r), this.set_prev(c, h), this.set_next(c, a), _ ? this.set_first_child(r, c) : h !== 4294967295 && this.set_next(h, c), a !== 4294967295 && this.set_prev(a, c), r !== 4294967295 && this.last_child_at(r) === t && this.set_last_child(r, c), this.set_parent(t, c), this.set_prev(t, 4294967295), this.set_next(t, 4294967295), this.set_first_child(c, t), this.set_last_child(c, t), c;
671
+ return this.set_parent(c, n), this.set_prev(c, h), this.set_next(c, a), _ ? this.set_first_child(n, c) : h !== 4294967295 && this.set_next(h, c), a !== 4294967295 && this.set_prev(a, c), n !== 4294967295 && this.last_child_at(n) === t && this.set_last_child(n, c), this.set_parent(t, c), this.set_prev(t, 4294967295), this.set_next(t, 4294967295), this.set_first_child(c, t), this.set_last_child(c, t), c;
656
672
  }
657
673
  /** unlink a node, subtree and all, and make it the last child of another parent */
658
674
  move_to_end(t, f) {
659
675
  const s = this.parent_at(t);
660
676
  if (s !== 4294967295) {
661
- const i = this.first_child_at(s) === t, r = i ? 4294967295 : this.prev_at(t);
677
+ const i = this.first_child_at(s) === t, n = i ? 4294967295 : this.prev_at(t);
662
678
  let _ = this.next_at(t);
663
- _ !== 4294967295 && this.parent_at(_) !== s && (_ = 4294967295), i ? this.set_first_child(s, _) : r !== 4294967295 && this.set_next(r, _), _ !== 4294967295 && this.set_prev(_, r), this.last_child_at(s) === t && this.set_last_child(s, r);
679
+ _ !== 4294967295 && this.parent_at(_) !== s && (_ = 4294967295), i ? this.set_first_child(s, _) : n !== 4294967295 && this.set_next(n, _), _ !== 4294967295 && this.set_prev(_, n), this.last_child_at(s) === t && this.set_last_child(s, n);
664
680
  }
665
681
  const e = this.last_child_at(f);
666
682
  this.set_parent(t, f), this.set_next(t, 4294967295), this.set_prev(t, e), e === 4294967295 ? this.set_first_child(f, t) : this.set_next(e, t), this.set_last_child(f, t);
@@ -668,8 +684,8 @@ class zt {
668
684
  /** link a node that has no parent in as a child of one, ahead of ref, last when ref is 0xffffffff */
669
685
  insert_before(t, f, s) {
670
686
  if (this.set_parent(t, f), s === 4294967295) {
671
- const r = this.last_child_at(f);
672
- this.set_prev(t, r), this.set_next(t, 4294967295), r === 4294967295 ? this.set_first_child(f, t) : this.set_next(r, t), this.set_last_child(f, t);
687
+ const n = this.last_child_at(f);
688
+ this.set_prev(t, n), this.set_next(t, 4294967295), n === 4294967295 ? this.set_first_child(f, t) : this.set_next(n, t), this.set_last_child(f, t);
673
689
  return;
674
690
  }
675
691
  const e = this.first_child_at(f) === s, i = e ? 4294967295 : this.prev_at(s);
@@ -681,8 +697,8 @@ class zt {
681
697
  if (f === 4294967295 || s === 4294967295 || this.parent_at(s) !== f)
682
698
  return;
683
699
  let e = s;
684
- for (let r = s; r !== 4294967295 && this.parent_at(r) === f; r = this.next_at(r))
685
- this.set_parent(r, t), e = r;
700
+ for (let n = s; n !== 4294967295 && this.parent_at(n) === f; n = this.next_at(n))
701
+ this.set_parent(n, t), e = n;
686
702
  const i = this.last_child_at(t);
687
703
  i === 4294967295 ? (this.set_first_child(t, s), this.set_prev(s, 4294967295)) : (this.set_next(i, s), this.set_prev(s, i)), this.set_last_child(t, e), this.set_next(e, 4294967295), this.set_next(t, 4294967295), this.set_last_child(f, t);
688
704
  }
@@ -724,10 +740,10 @@ class zt {
724
740
  */
725
741
  handle_repair(t, f, s) {
726
742
  const e = this.parent_at(t), i = this.kind_at(t);
727
- let r = e;
728
- for (; r !== 4294967295 && this.synthetic_at(r); )
729
- r = this.parent_at(r);
730
- const _ = r !== 4294967295 ? this.kind_at(r) : void 0;
743
+ let n = e;
744
+ for (; n !== 4294967295 && this.synthetic_at(n); )
745
+ n = this.parent_at(n);
746
+ const _ = n !== 4294967295 ? this.kind_at(n) : void 0;
731
747
  if (i === 7 || i === 25) {
732
748
  this.unwrap_node(t);
733
749
  return;
@@ -754,11 +770,11 @@ class zt {
754
770
  this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
755
771
  return;
756
772
  }
757
- let A = a, v = a;
758
- for (; A !== 4294967295 && this.parent_at(A) === t; )
759
- this.set_parent(A, e), v = A, A = this.next_at(A);
760
- const E = this.next_at(t);
761
- this.set_next(t, a), this.set_prev(a, t), E !== 4294967295 && this.parent_at(E) === e ? (this.set_next(v, E), this.set_prev(E, v)) : this.set_next(v, 4294967295), this.last_child_at(e) === t && this.set_last_child(e, v), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
773
+ let w = a, v = a;
774
+ for (; w !== 4294967295 && this.parent_at(w) === t; )
775
+ this.set_parent(w, e), v = w, w = this.next_at(w);
776
+ const S = this.next_at(t);
777
+ this.set_next(t, a), this.set_prev(a, t), S !== 4294967295 && this.parent_at(S) === e ? (this.set_next(v, S), this.set_prev(S, v)) : this.set_next(v, 4294967295), this.last_child_at(e) === t && this.set_last_child(e, v), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
762
778
  return;
763
779
  }
764
780
  const c = this.delimiter_end_at(t, i);
@@ -797,16 +813,16 @@ class zt {
797
813
  * element, it gets one again when it holds text
798
814
  */
799
815
  repair_block_html(t, f, s) {
800
- const e = this.parent_at(t), i = this.start_at(t), r = this.first_child_at(t);
816
+ const e = this.parent_at(t), i = this.start_at(t), n = this.first_child_at(t);
801
817
  let _;
802
818
  if (f !== void 0)
803
819
  _ = i + f.length;
804
- else if (_ = r !== 4294967295 ? this.start_at(r) : this.end_at(t), _ === 4294967295 || _ <= i) {
820
+ else if (_ = n !== 4294967295 ? this.start_at(n) : this.end_at(t), _ === 4294967295 || _ <= i) {
805
821
  this.unwrap_node(t);
806
822
  return;
807
823
  }
808
824
  let h = [], a = this.sibling(t, e, !1);
809
- for (; a !== 4294967295 && C(this.kind_at(a)) >= 2; )
825
+ for (; a !== 4294967295 && L(this.kind_at(a)) >= 2; )
810
826
  h.push(a), a = this.sibling(a, e, !1);
811
827
  h.reverse();
812
828
  const c = h.length;
@@ -815,14 +831,14 @@ class zt {
815
831
  const u = [];
816
832
  let p = this.sibling(t, e, !0);
817
833
  this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295), this.delete_metadata(t);
818
- let g = r;
834
+ let g = n;
819
835
  for (; g !== 4294967295 && this.parent_at(g) === t; ) {
820
- const l = this.next_at(g), d = C(this.kind_at(g));
821
- d >= 2 ? (h.push(g), d === 3 && (o = !0)) : (d === 1 && h.length !== 0 ? (b && this.tag_text(t, i, _, f, s), this.set_start(g, this.start_at(h[0])), this.adopt(g, h, !0)) : (b ? this.tag_paragraph(h, c, _, f, s) : this.run_paragraph(h, o), X(u, h)), u.push(g), h = [], o = !1, b = !1), g = l;
836
+ const l = this.next_at(g), d = L(this.kind_at(g));
837
+ d >= 2 ? (h.push(g), d === 3 && (o = !0)) : (d === 1 && h.length !== 0 ? (b && this.tag_text(t, i, _, f, s), this.set_start(g, this.start_at(h[0])), this.adopt(g, h, !0)) : (b ? this.tag_paragraph(h, c, _, f, s) : this.run_paragraph(h, o), J(u, h)), u.push(g), h = [], o = !1, b = !1), g = l;
822
838
  }
823
- for (; p !== 4294967295 && C(this.kind_at(p)) >= 2; )
824
- C(this.kind_at(p)) === 3 && (o = !0), h.push(p), p = this.sibling(p, e, !0);
825
- b ? this.tag_paragraph(h, c, _, f, s) : this.run_paragraph(h, o), X(u, h);
839
+ for (; p !== 4294967295 && L(this.kind_at(p)) >= 2; )
840
+ L(this.kind_at(p)) === 3 && (o = !0), h.push(p), p = this.sibling(p, e, !0);
841
+ b ? this.tag_paragraph(h, c, _, f, s) : this.run_paragraph(h, o), J(u, h);
826
842
  for (let l = 0; l < u.length; l++) {
827
843
  const d = u[l];
828
844
  this.set_parent(d, e), this.set_prev(d, l === 0 ? a : u[l - 1]), this.set_next(d, l + 1 < u.length ? u[l + 1] : p);
@@ -846,14 +862,14 @@ class zt {
846
862
  * node holds its tag text, on return the run is that paragraph
847
863
  */
848
864
  tag_paragraph(t, f, s, e, i) {
849
- const r = t[f], _ = this.start_at(r);
865
+ const n = t[f], _ = this.start_at(n);
850
866
  this.set_kind(
851
- r,
867
+ n,
852
868
  7
853
869
  /* NodeKind.paragraph */
854
- ), this.set_start(r, this.start_at(t[0]));
870
+ ), this.set_start(n, this.start_at(t[0]));
855
871
  const h = this.push(1, _);
856
- this.tag_text(h, _, s, e, i), t[f] = h, this.wrap_run(r, t);
872
+ this.tag_text(h, _, s, e, i), t[f] = h, this.wrap_run(n, t);
857
873
  }
858
874
  /** a run with text gets a paragraph, on return it is what goes under the parent */
859
875
  run_paragraph(t, f) {
@@ -881,12 +897,12 @@ class zt {
881
897
  const e = f.length;
882
898
  if (e === 0)
883
899
  return;
884
- const i = s ? 4294967295 : this.last_child_at(t), r = s ? this.first_child_at(t) : 4294967295;
900
+ const i = s ? 4294967295 : this.last_child_at(t), n = s ? this.first_child_at(t) : 4294967295;
885
901
  for (let _ = 0; _ < e; _++) {
886
902
  const h = f[_];
887
- this.set_parent(h, t), this.set_prev(h, _ === 0 ? i : f[_ - 1]), this.set_next(h, _ + 1 < e ? f[_ + 1] : r);
903
+ this.set_parent(h, t), this.set_prev(h, _ === 0 ? i : f[_ - 1]), this.set_next(h, _ + 1 < e ? f[_ + 1] : n);
888
904
  }
889
- i === 4294967295 ? this.set_first_child(t, f[0]) : this.set_next(i, f[0]), r === 4294967295 ? this.set_last_child(t, f[e - 1]) : this.set_prev(r, f[e - 1]);
905
+ i === 4294967295 ? this.set_first_child(t, f[0]) : this.set_next(i, f[0]), n === 4294967295 ? this.set_last_child(t, f[e - 1]) : this.set_prev(n, f[e - 1]);
890
906
  }
891
907
  repair() {
892
908
  const t = this._n;
@@ -898,7 +914,7 @@ class zt {
898
914
  }
899
915
  pop() {
900
916
  const t = --this._size;
901
- S(this._n, t, t + 1);
917
+ m(this._n, t, t + 1);
902
918
  }
903
919
  /**
904
920
  * remove a node from the tree and reparent its children to its parent.
@@ -915,8 +931,8 @@ class zt {
915
931
  let e = s, i = s;
916
932
  for (; e !== 4294967295 && this.parent_at(e) === t; )
917
933
  this.set_parent(e, f), i = e, e = this.next_at(e);
918
- const r = this.prev_at(t), _ = this.next_at(t);
919
- r !== 4294967295 ? (this.set_next(r, s), this.set_prev(s, r)) : f !== 4294967295 && (this.set_first_child(f, s), this.set_prev(s, 4294967295)), _ !== 4294967295 && _ !== s ? (this.set_next(i, _), this.set_prev(_, i)) : this.set_next(i, 4294967295), f !== 4294967295 && this.last_child_at(f) === t && this.set_last_child(f, i), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
934
+ const n = this.prev_at(t), _ = this.next_at(t);
935
+ n !== 4294967295 ? (this.set_next(n, s), this.set_prev(s, n)) : f !== 4294967295 && (this.set_first_child(f, s), this.set_prev(s, 4294967295)), _ !== 4294967295 && _ !== s ? (this.set_next(i, _), this.set_prev(_, i)) : this.set_next(i, 4294967295), f !== 4294967295 && this.last_child_at(f) === t && this.set_last_child(f, i), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
920
936
  }
921
937
  set_parent_kind(t, f) {
922
938
  const s = this.parent_at(t);
@@ -944,6 +960,7 @@ class zt {
944
960
  * @param kind new kind
945
961
  */
946
962
  set_kind(t, f) {
963
+ (f === 2 || f === 36 || f === 37) && E();
947
964
  const s = this._n, e = t * 12;
948
965
  s[e] = s[e] & 16776960 | f & 255;
949
966
  }
@@ -1115,16 +1132,16 @@ class zt {
1115
1132
  }
1116
1133
  resize(t) {
1117
1134
  const f = this._n, s = this._capacity * 12;
1118
- if (f === m) {
1119
- const r = w - s * 4, _ = t * L;
1120
- if (_ <= 262144 && r + _ <= 1048576) {
1135
+ if (f === B) {
1136
+ const n = A - s * 4, _ = t * N;
1137
+ if (_ <= 262144 && n + _ <= 1048576) {
1121
1138
  const h = new Uint32Array(
1122
1139
  y,
1123
- r,
1140
+ n,
1124
1141
  t * 12
1125
1142
  /* NodeField.stride */
1126
1143
  );
1127
- return w = r + _, m = h, this._capacity = t, this._filled = t, this._n = h, h;
1144
+ return A = n + _, B = h, this._capacity = t, this._filled = t, this._n = h, h;
1128
1145
  }
1129
1146
  }
1130
1147
  const e = this.alloc(t), i = this._size;
@@ -1139,8 +1156,8 @@ class zt {
1139
1156
  if (i !== 0)
1140
1157
  this._meta[i - 1] = f;
1141
1158
  else {
1142
- const r = this._meta;
1143
- r === W ? (this._meta = [f], s[e] = 1) : s[e] = r.push(f);
1159
+ const n = this._meta;
1160
+ n === X ? (this._meta = [f], s[e] = 1) : s[e] = n.push(f);
1144
1161
  }
1145
1162
  }
1146
1163
  metadata_at(t) {
@@ -1162,17 +1179,17 @@ class zt {
1162
1179
  * @returns node
1163
1180
  */
1164
1181
  get_node(t = 0) {
1165
- const f = this.kind_at(t), s = et(f), e = s ? { [s]: this.extra_at(t) } : f === 8 && this.extra_at(t) === 1 ? { math: !0 } : {}, i = [];
1166
- let r = this.first_child_at(t);
1167
- for (; r !== 4294967295 && this.parent_at(r) === t; )
1168
- i.push(r), r = this.next_at(r);
1182
+ const f = this.kind_at(t), s = _t(f), e = s ? { [s]: this.extra_at(t) } : f === 8 && this.extra_at(t) === 1 ? { math: !0 } : {}, i = [];
1183
+ let n = this.first_child_at(t);
1184
+ for (; n !== 4294967295 && this.parent_at(n) === t; )
1185
+ i.push(n), n = this.next_at(n);
1169
1186
  const _ = this.parent_at(t), h = this.next_at(t), a = this.prev_at(t);
1170
1187
  return {
1171
- kind: G(f),
1188
+ kind: $(f),
1172
1189
  start: this.start_at(t),
1173
1190
  end: this.end_at(t),
1174
1191
  metadata: {
1175
- ...ht(this.metadata_at(t)),
1192
+ ...ot(this.metadata_at(t)),
1176
1193
  ...e
1177
1194
  },
1178
1195
  parent: _ === 4294967295 ? null : _,
@@ -1184,13 +1201,13 @@ class zt {
1184
1201
  };
1185
1202
  }
1186
1203
  }
1187
- class Tt {
1204
+ class Nt {
1188
1205
  /**
1189
1206
  * create a collector that records error indices encountered while parsing.
1190
1207
  * @param initial_capacity requested starting capacity for error indices.
1191
1208
  */
1192
- constructor(t = st) {
1193
- const f = q(t);
1209
+ constructor(t = nt) {
1210
+ const f = Z(t);
1194
1211
  this.capacity = f, this.indices = new Uint32Array(f), this._size = 0;
1195
1212
  }
1196
1213
  /** clear previously stored errors. */
@@ -1227,26 +1244,31 @@ class Tt {
1227
1244
  }
1228
1245
  }
1229
1246
  export {
1230
- I as AttrSpans,
1231
- Tt as ErrorCollector,
1232
- U as HtmlMeta,
1233
- zt as NodeBuffer,
1234
- F as build_attrs,
1235
- yt as is_raw_text_tag,
1236
- G as kind_to_string,
1237
- kt as make_meta,
1238
- vt as merge_meta,
1239
- lt as note_footnote,
1240
- ut as note_math,
1241
- ht as plain_meta,
1242
- wt as spans_have,
1243
- gt as spans_text,
1244
- bt as store_attr_rec,
1245
- xt as stored_attr_at,
1246
- at as string_to_kind,
1247
- ot as take_footnote,
1248
- dt as take_info,
1249
- pt as take_math,
1250
- ct as take_src,
1251
- At as unread_spans
1247
+ Y as AttrSpans,
1248
+ Nt as ErrorCollector,
1249
+ R as HtmlMeta,
1250
+ Lt as NodeBuffer,
1251
+ V as build_attrs,
1252
+ E as bump_id_scan,
1253
+ dt as get_id_scan,
1254
+ K as is_html_heading,
1255
+ Ct as is_raw_text_tag,
1256
+ $ as kind_to_string,
1257
+ mt as make_meta,
1258
+ Bt as merge_meta,
1259
+ gt as note_footnote,
1260
+ wt as note_math,
1261
+ xt as note_reference,
1262
+ ot as plain_meta,
1263
+ Et as spans_have,
1264
+ yt as spans_text,
1265
+ zt as store_attr_rec,
1266
+ Tt as stored_attr_at,
1267
+ ut as string_to_kind,
1268
+ bt as take_footnote,
1269
+ vt as take_info,
1270
+ kt as take_math,
1271
+ At as take_reference,
1272
+ pt as take_src,
1273
+ St as unread_spans
1252
1274
  };