@pretextbook/import 0.13.0 → 0.14.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.
@@ -776,7 +776,7 @@ function Ci(t, r) {
776
776
  const n = t.indexOf("}", r + 1);
777
777
  return n === -1 ? null : { content: t.slice(r + 1, n), end: n + 1 };
778
778
  }
779
- function Vt(t, r, n) {
779
+ function Gt(t, r, n) {
780
780
  const i = Ri(t, r, "\\" + n);
781
781
  if (i === -1 || be(t[i] ?? "")) return null;
782
782
  let e = i;
@@ -793,7 +793,7 @@ function Oi(t) {
793
793
  });
794
794
  for (; o < s; ) {
795
795
  if (f !== null) {
796
- const d = Vt(t, o, "end");
796
+ const d = Gt(t, o, "end");
797
797
  d && d.group === f ? (e.push({
798
798
  name: d.group,
799
799
  type: "end",
@@ -828,7 +828,7 @@ function Oi(t) {
828
828
  o += 2;
829
829
  continue;
830
830
  }
831
- const d = Vt(t, o, "begin");
831
+ const d = Gt(t, o, "begin");
832
832
  if (d) {
833
833
  const v = p(d.group);
834
834
  e.push({
@@ -840,7 +840,7 @@ function Oi(t) {
840
840
  }), v.isVerbatim && (f = d.group), o = d.end;
841
841
  continue;
842
842
  }
843
- const w = Vt(t, o, "end");
843
+ const w = Gt(t, o, "end");
844
844
  if (w) {
845
845
  e.push({
846
846
  name: w.group,
@@ -851,7 +851,7 @@ function Oi(t) {
851
851
  }), o = w.end;
852
852
  continue;
853
853
  }
854
- const h = Vt(t, o, "label");
854
+ const h = Gt(t, o, "label");
855
855
  if (h) {
856
856
  r.push({ name: h.group, offset: h.groupStart }), o = h.end;
857
857
  continue;
@@ -1014,7 +1014,7 @@ var ln;
1014
1014
  t.create = r;
1015
1015
  function n(i) {
1016
1016
  const e = i;
1017
- return T.objectLiteral(e) && T.string(e.label) && (T.undefined(e.textEdit) || Tt.is(e)) && (T.undefined(e.additionalTextEdits) || T.typedArray(e.additionalTextEdits, Tt.is));
1017
+ return T.objectLiteral(e) && T.string(e.label) && (T.undefined(e.textEdit) || Rt.is(e)) && (T.undefined(e.additionalTextEdits) || T.typedArray(e.additionalTextEdits, Rt.is));
1018
1018
  }
1019
1019
  t.is = n;
1020
1020
  })(ln || (ln = {}));
@@ -1053,10 +1053,10 @@ var ye;
1053
1053
  }
1054
1054
  t.is = n;
1055
1055
  })(ye || (ye = {}));
1056
- var Pt;
1056
+ var jt;
1057
1057
  (function(t) {
1058
1058
  t.Error = 1, t.Warning = 2, t.Information = 3, t.Hint = 4;
1059
- })(Pt || (Pt = {}));
1059
+ })(jt || (jt = {}));
1060
1060
  var fn;
1061
1061
  (function(t) {
1062
1062
  t.Unnecessary = 1, t.Deprecated = 2;
@@ -1083,7 +1083,7 @@ var ne;
1083
1083
  }
1084
1084
  t.is = n;
1085
1085
  })(ne || (ne = {}));
1086
- var It;
1086
+ var Tt;
1087
1087
  (function(t) {
1088
1088
  function r(i, e, ...a) {
1089
1089
  let s = { title: i, command: e };
@@ -1095,8 +1095,8 @@ var It;
1095
1095
  return T.defined(e) && T.string(e.title) && T.string(e.command);
1096
1096
  }
1097
1097
  t.is = n;
1098
- })(It || (It = {}));
1099
- var Tt;
1098
+ })(Tt || (Tt = {}));
1099
+ var Rt;
1100
1100
  (function(t) {
1101
1101
  function r(a, s) {
1102
1102
  return { range: a, newText: s };
@@ -1115,7 +1115,7 @@ var Tt;
1115
1115
  return T.objectLiteral(s) && T.string(s.newText) && ft.is(s.range);
1116
1116
  }
1117
1117
  t.is = e;
1118
- })(Tt || (Tt = {}));
1118
+ })(Rt || (Rt = {}));
1119
1119
  var xe;
1120
1120
  (function(t) {
1121
1121
  function r(i, e, a) {
@@ -1129,14 +1129,14 @@ var xe;
1129
1129
  }
1130
1130
  t.is = n;
1131
1131
  })(xe || (xe = {}));
1132
- var Rt;
1132
+ var Ct;
1133
1133
  (function(t) {
1134
1134
  function r(n) {
1135
1135
  const i = n;
1136
1136
  return T.string(i);
1137
1137
  }
1138
1138
  t.is = r;
1139
- })(Rt || (Rt = {}));
1139
+ })(Ct || (Ct = {}));
1140
1140
  var pn;
1141
1141
  (function(t) {
1142
1142
  function r(a, s, o) {
@@ -1153,7 +1153,7 @@ var pn;
1153
1153
  t.del = i;
1154
1154
  function e(a) {
1155
1155
  const s = a;
1156
- return Tt.is(s) && (xe.is(s.annotationId) || Rt.is(s.annotationId));
1156
+ return Rt.is(s) && (xe.is(s.annotationId) || Ct.is(s.annotationId));
1157
1157
  }
1158
1158
  t.is = e;
1159
1159
  })(pn || (pn = {}));
@@ -1181,7 +1181,7 @@ var Se;
1181
1181
  t.create = r;
1182
1182
  function n(i) {
1183
1183
  let e = i;
1184
- return e && e.kind === "create" && T.string(e.uri) && (e.options === void 0 || (e.options.overwrite === void 0 || T.boolean(e.options.overwrite)) && (e.options.ignoreIfExists === void 0 || T.boolean(e.options.ignoreIfExists))) && (e.annotationId === void 0 || Rt.is(e.annotationId));
1184
+ return e && e.kind === "create" && T.string(e.uri) && (e.options === void 0 || (e.options.overwrite === void 0 || T.boolean(e.options.overwrite)) && (e.options.ignoreIfExists === void 0 || T.boolean(e.options.ignoreIfExists))) && (e.annotationId === void 0 || Ct.is(e.annotationId));
1185
1185
  }
1186
1186
  t.is = n;
1187
1187
  })(Se || (Se = {}));
@@ -1198,7 +1198,7 @@ var Ee;
1198
1198
  t.create = r;
1199
1199
  function n(i) {
1200
1200
  let e = i;
1201
- return e && e.kind === "rename" && T.string(e.oldUri) && T.string(e.newUri) && (e.options === void 0 || (e.options.overwrite === void 0 || T.boolean(e.options.overwrite)) && (e.options.ignoreIfExists === void 0 || T.boolean(e.options.ignoreIfExists))) && (e.annotationId === void 0 || Rt.is(e.annotationId));
1201
+ return e && e.kind === "rename" && T.string(e.oldUri) && T.string(e.newUri) && (e.options === void 0 || (e.options.overwrite === void 0 || T.boolean(e.options.overwrite)) && (e.options.ignoreIfExists === void 0 || T.boolean(e.options.ignoreIfExists))) && (e.annotationId === void 0 || Ct.is(e.annotationId));
1202
1202
  }
1203
1203
  t.is = n;
1204
1204
  })(Ee || (Ee = {}));
@@ -1214,7 +1214,7 @@ var Ae;
1214
1214
  t.create = r;
1215
1215
  function n(i) {
1216
1216
  let e = i;
1217
- return e && e.kind === "delete" && T.string(e.uri) && (e.options === void 0 || (e.options.recursive === void 0 || T.boolean(e.options.recursive)) && (e.options.ignoreIfNotExists === void 0 || T.boolean(e.options.ignoreIfNotExists))) && (e.annotationId === void 0 || Rt.is(e.annotationId));
1217
+ return e && e.kind === "delete" && T.string(e.uri) && (e.options === void 0 || (e.options.recursive === void 0 || T.boolean(e.options.recursive)) && (e.options.ignoreIfNotExists === void 0 || T.boolean(e.options.ignoreIfNotExists))) && (e.annotationId === void 0 || Ct.is(e.annotationId));
1218
1218
  }
1219
1219
  t.is = n;
1220
1220
  })(Ae || (Ae = {}));
@@ -1283,14 +1283,14 @@ var Re;
1283
1283
  }
1284
1284
  t.is = r;
1285
1285
  })(Re || (Re = {}));
1286
- var Ft;
1286
+ var qt;
1287
1287
  (function(t) {
1288
1288
  function r(n) {
1289
1289
  const i = n;
1290
1290
  return T.objectLiteral(n) && Re.is(i.kind) && T.string(i.value);
1291
1291
  }
1292
1292
  t.is = r;
1293
- })(Ft || (Ft = {}));
1293
+ })(qt || (qt = {}));
1294
1294
  var vn;
1295
1295
  (function(t) {
1296
1296
  t.Text = 1, t.Method = 2, t.Function = 3, t.Constructor = 4, t.Field = 5, t.Variable = 6, t.Class = 7, t.Interface = 8, t.Module = 9, t.Property = 10, t.Unit = 11, t.Value = 12, t.Enum = 13, t.Keyword = 14, t.Snippet = 15, t.Color = 16, t.File = 17, t.Reference = 18, t.Folder = 19, t.EnumMember = 20, t.Constant = 21, t.Struct = 22, t.Event = 23, t.Operator = 24, t.TypeParameter = 25;
@@ -1357,7 +1357,7 @@ var An;
1357
1357
  (function(t) {
1358
1358
  function r(n) {
1359
1359
  let i = n;
1360
- return !!i && T.objectLiteral(i) && (Ft.is(i.contents) || re.is(i.contents) || T.typedArray(i.contents, re.is)) && (n.range === void 0 || ft.is(n.range));
1360
+ return !!i && T.objectLiteral(i) && (qt.is(i.contents) || re.is(i.contents) || T.typedArray(i.contents, re.is)) && (n.range === void 0 || ft.is(n.range));
1361
1361
  }
1362
1362
  t.is = r;
1363
1363
  })(An || (An = {}));
@@ -1434,10 +1434,10 @@ var Dn;
1434
1434
  }
1435
1435
  t.is = n;
1436
1436
  })(Dn || (Dn = {}));
1437
- var Ct;
1437
+ var Ot;
1438
1438
  (function(t) {
1439
1439
  t.Empty = "", t.QuickFix = "quickfix", t.Refactor = "refactor", t.RefactorExtract = "refactor.extract", t.RefactorInline = "refactor.inline", t.RefactorRewrite = "refactor.rewrite", t.Source = "source", t.SourceOrganizeImports = "source.organizeImports", t.SourceFixAll = "source.fixAll";
1440
- })(Ct || (Ct = {}));
1440
+ })(Ot || (Ot = {}));
1441
1441
  var ie;
1442
1442
  (function(t) {
1443
1443
  t.Invoked = 1, t.Automatic = 2;
@@ -1459,12 +1459,12 @@ var jn;
1459
1459
  (function(t) {
1460
1460
  function r(i, e, a) {
1461
1461
  let s = { title: i }, o = !0;
1462
- return typeof e == "string" ? (o = !1, s.kind = e) : It.is(e) ? s.command = e : s.edit = e, o && a !== void 0 && (s.kind = a), s;
1462
+ return typeof e == "string" ? (o = !1, s.kind = e) : Tt.is(e) ? s.command = e : s.edit = e, o && a !== void 0 && (s.kind = a), s;
1463
1463
  }
1464
1464
  t.create = r;
1465
1465
  function n(i) {
1466
1466
  let e = i;
1467
- return e && T.string(e.title) && (e.diagnostics === void 0 || T.typedArray(e.diagnostics, ne.is)) && (e.kind === void 0 || T.string(e.kind)) && (e.edit !== void 0 || e.command !== void 0) && (e.command === void 0 || It.is(e.command)) && (e.isPreferred === void 0 || T.boolean(e.isPreferred)) && (e.edit === void 0 || Ie.is(e.edit));
1467
+ return e && T.string(e.title) && (e.diagnostics === void 0 || T.typedArray(e.diagnostics, ne.is)) && (e.kind === void 0 || T.string(e.kind)) && (e.edit !== void 0 || e.command !== void 0) && (e.command === void 0 || Tt.is(e.command)) && (e.isPreferred === void 0 || T.boolean(e.isPreferred)) && (e.edit === void 0 || Ie.is(e.edit));
1468
1468
  }
1469
1469
  t.is = n;
1470
1470
  })(jn || (jn = {}));
@@ -1477,7 +1477,7 @@ var Fn;
1477
1477
  t.create = r;
1478
1478
  function n(i) {
1479
1479
  let e = i;
1480
- return T.defined(e) && ft.is(e.range) && (T.undefined(e.command) || It.is(e.command));
1480
+ return T.defined(e) && ft.is(e.range) && (T.undefined(e.command) || Tt.is(e.command));
1481
1481
  }
1482
1482
  t.is = n;
1483
1483
  })(Fn || (Fn = {}));
@@ -1597,7 +1597,7 @@ var Oe;
1597
1597
  t.create = r;
1598
1598
  function n(i) {
1599
1599
  const e = i;
1600
- return T.objectLiteral(e) && (e.tooltip === void 0 || T.string(e.tooltip) || Ft.is(e.tooltip)) && (e.location === void 0 || ee.is(e.location)) && (e.command === void 0 || It.is(e.command));
1600
+ return T.objectLiteral(e) && (e.tooltip === void 0 || T.string(e.tooltip) || qt.is(e.tooltip)) && (e.location === void 0 || ee.is(e.location)) && (e.command === void 0 || Tt.is(e.command));
1601
1601
  }
1602
1602
  t.is = n;
1603
1603
  })(Oe || (Oe = {}));
@@ -1610,7 +1610,7 @@ var Hn;
1610
1610
  t.create = r;
1611
1611
  function n(i) {
1612
1612
  const e = i;
1613
- return T.objectLiteral(e) && wt.is(e.position) && (T.string(e.label) || T.typedArray(e.label, Oe.is)) && (e.kind === void 0 || Ce.is(e.kind)) && e.textEdits === void 0 || T.typedArray(e.textEdits, Tt.is) && (e.tooltip === void 0 || T.string(e.tooltip) || Ft.is(e.tooltip)) && (e.paddingLeft === void 0 || T.boolean(e.paddingLeft)) && (e.paddingRight === void 0 || T.boolean(e.paddingRight));
1613
+ return T.objectLiteral(e) && wt.is(e.position) && (T.string(e.label) || T.typedArray(e.label, Oe.is)) && (e.kind === void 0 || Ce.is(e.kind)) && e.textEdits === void 0 || T.typedArray(e.textEdits, Rt.is) && (e.tooltip === void 0 || T.string(e.tooltip) || qt.is(e.tooltip)) && (e.paddingLeft === void 0 || T.boolean(e.paddingLeft)) && (e.paddingRight === void 0 || T.boolean(e.paddingRight));
1614
1614
  }
1615
1615
  t.is = n;
1616
1616
  })(Hn || (Hn = {}));
@@ -2203,7 +2203,7 @@ function Zi(t, r) {
2203
2203
  (n, i) => r[Number(i)] ?? ""
2204
2204
  );
2205
2205
  }
2206
- function jt(t, r = {}) {
2206
+ function Ft(t, r = {}) {
2207
2207
  const { scope: n = "auto", disable: i, only: e } = r, a = xr(t, n), s = Bi(t), o = new Set(i ?? []), c = e ? new Set(e) : null, l = [];
2208
2208
  return qi.forEach((f, p) => {
2209
2209
  if (o.has(f.id) || c && !c.has(f.id)) return;
@@ -2316,24 +2316,24 @@ function Ne(t, r = {}) {
2316
2316
  const { maxPasses: n = 5, ...i } = r, e = [];
2317
2317
  let a = t, s = 0, o = !1;
2318
2318
  for (; s < n; s += 1) {
2319
- const l = jt(a, i).filter((g) => g.replacement !== void 0);
2319
+ const l = Ft(a, i).filter((g) => g.replacement !== void 0);
2320
2320
  if (l.length === 0) break;
2321
2321
  const { output: f, applied: p } = Ji(a, l);
2322
2322
  if (f === a) break;
2323
- e.push(...p), a = f, s === n - 1 && (o = jt(a, i).some(
2323
+ e.push(...p), a = f, s === n - 1 && (o = Ft(a, i).some(
2324
2324
  (g) => g.replacement !== void 0
2325
2325
  ));
2326
2326
  }
2327
2327
  return e.push(
2328
- ...jt(a, i).filter(
2328
+ ...Ft(a, i).filter(
2329
2329
  (c) => c.replacement === void 0
2330
2330
  )
2331
2331
  ), { output: a, fixes: e, passes: s, truncated: o };
2332
2332
  }
2333
2333
  const Ki = "pretext-latex-clean", Qi = {
2334
- info: Pt.Information,
2335
- warning: Pt.Warning,
2336
- error: Pt.Error
2334
+ info: jt.Information,
2335
+ warning: jt.Warning,
2336
+ error: jt.Error
2337
2337
  };
2338
2338
  function ta(t) {
2339
2339
  if (t.message) return t.message;
@@ -2363,8 +2363,8 @@ function Ue(t, r) {
2363
2363
  }
2364
2364
  }));
2365
2365
  }
2366
- function vo(t, r) {
2367
- return Ue(t, jt(t, r));
2366
+ function yo(t, r) {
2367
+ return Ue(t, Ft(t, r));
2368
2368
  }
2369
2369
  function sr(t, r, n) {
2370
2370
  let i = 0;
@@ -2380,8 +2380,8 @@ function ea(t, r, n) {
2380
2380
  const i = sr(t, n.start.line, n.start.character), e = sr(t, n.end.line, n.end.character);
2381
2381
  return i === e ? r.start <= i && i <= r.end : r.start < e && r.end > i;
2382
2382
  }
2383
- function wo(t, r, n) {
2384
- const { uri: i, includeCleanAll: e = !0, ...a } = n, s = jt(t, a), o = [];
2383
+ function xo(t, r, n) {
2384
+ const { uri: i, includeCleanAll: e = !0, ...a } = n, s = Ft(t, a), o = [];
2385
2385
  for (const c of s)
2386
2386
  if (ea(t, c, r)) {
2387
2387
  if (c.replacement !== void 0) {
@@ -2391,7 +2391,7 @@ function wo(t, r, n) {
2391
2391
  };
2392
2392
  o.push({
2393
2393
  title: ra(c),
2394
- kind: Ct.QuickFix,
2394
+ kind: Ot.QuickFix,
2395
2395
  diagnostics: Ue(t, [c]),
2396
2396
  edit: { changes: { [i]: [l] } }
2397
2397
  });
@@ -2407,7 +2407,7 @@ function wo(t, r, n) {
2407
2407
  ).length;
2408
2408
  o.push({
2409
2409
  title: `Clean up LaTeX (${l} change${l === 1 ? "" : "s"})`,
2410
- kind: Ct.SourceFixAll,
2410
+ kind: Ot.SourceFixAll,
2411
2411
  // One whole-document edit: the fixpoint loop's intermediate offsets do
2412
2412
  // not map back onto the original text, so per-fix edits would be wrong.
2413
2413
  edit: {
@@ -2433,7 +2433,7 @@ function na(t, r, n, i) {
2433
2433
  const d = g(n);
2434
2434
  if (!d || (s.push({
2435
2435
  title: f,
2436
- kind: Ct.QuickFix,
2436
+ kind: Ot.QuickFix,
2437
2437
  diagnostics: e,
2438
2438
  edit: {
2439
2439
  changes: {
@@ -2449,7 +2449,7 @@ function na(t, r, n, i) {
2449
2449
  const w = a.map(g).filter((h) => h !== null);
2450
2450
  w.length < 2 || s.push({
2451
2451
  title: p.replace("{n}", String(w.length)),
2452
- kind: Ct.QuickFix,
2452
+ kind: Ot.QuickFix,
2453
2453
  diagnostics: e,
2454
2454
  edit: {
2455
2455
  changes: {
@@ -2541,7 +2541,7 @@ function ue(t, r) {
2541
2541
  const n = String(r).length;
2542
2542
  return String(t).padStart(Math.max(n, 2), "0");
2543
2543
  }
2544
- function Mt(t, r) {
2544
+ function Wt(t, r) {
2545
2545
  const n = [...r].sort((a, s) => a.start - s.start);
2546
2546
  let i = "", e = 0;
2547
2547
  for (const a of n)
@@ -2723,7 +2723,7 @@ function or(t, r = 0, n = "{", i = "}") {
2723
2723
  }
2724
2724
  return o === 0 ? [s, e] : ["", s.substring(1)];
2725
2725
  }
2726
- function _o(t, r = {}) {
2726
+ function ko(t, r = {}) {
2727
2727
  const n = Ar(t).replace(/(\n *){3,}/g, `
2728
2728
 
2729
2729
  `), { output: i, fixes: e } = Ne(n, {
@@ -2775,7 +2775,7 @@ function va(t) {
2775
2775
 
2776
2776
  `), n = xr(r, "auto"), i = [], e = r.slice(n.preamble.start, n.preamble.end);
2777
2777
  e && i.push(
2778
- Yt(
2778
+ Jt(
2779
2779
  e,
2780
2780
  {
2781
2781
  path: [],
@@ -2793,7 +2793,7 @@ function va(t) {
2793
2793
  `), p = i.flatMap((g) => g.fixes);
2794
2794
  return { output: f, chunks: i, warnings: Ir(p), fixes: p };
2795
2795
  }
2796
- function Yt(t, r, n) {
2796
+ function Jt(t, r, n) {
2797
2797
  const { output: i, fixes: e } = Ne(t, { scope: n });
2798
2798
  return { ...r, before: t, after: i, fixes: e };
2799
2799
  }
@@ -2801,7 +2801,7 @@ function wa(t) {
2801
2801
  const r = We(t), n = Ze(t), i = new Map(n.map((c, l) => [c, l + 1]));
2802
2802
  if (r.length === 0)
2803
2803
  return t ? [
2804
- Yt(
2804
+ Jt(
2805
2805
  t,
2806
2806
  { path: [], title: "", kind: "lead", level: 0 },
2807
2807
  "body"
@@ -2810,7 +2810,7 @@ function wa(t) {
2810
2810
  const e = [], a = t.slice(0, r[0].start);
2811
2811
  let s = "";
2812
2812
  a.trim() ? e.push(
2813
- Yt(a, { path: [], title: "", kind: "lead", level: 0 }, "body")
2813
+ Jt(a, { path: [], title: "", kind: "lead", level: 0 }, "body")
2814
2814
  ) : s = a;
2815
2815
  const o = [];
2816
2816
  return r.forEach((c, l) => {
@@ -2818,7 +2818,7 @@ function wa(t) {
2818
2818
  o.length = f - 1, o[f - 1] = p;
2819
2819
  const g = r[l + 1]?.start ?? t.length, d = (l === 0 ? s : "") + t.slice(c.start, g);
2820
2820
  e.push(
2821
- Yt(
2821
+ Jt(
2822
2822
  d,
2823
2823
  {
2824
2824
  path: [...o],
@@ -2835,7 +2835,7 @@ function wa(t) {
2835
2835
  function _a(t) {
2836
2836
  return t.replace(/\\[a-zA-Z]+\{([^{}]*)\}/g, "$1").replace(/\\[a-zA-Z]+/g, "").replace(/[{}]/g, "").replace(/\s+/g, " ").trim();
2837
2837
  }
2838
- function yo(t, r) {
2838
+ function So(t, r) {
2839
2839
  const n = [];
2840
2840
  for (const i of t) {
2841
2841
  if (i.kind === "preamble") {
@@ -2856,7 +2856,7 @@ function yo(t, r) {
2856
2856
  }
2857
2857
  return n;
2858
2858
  }
2859
- function qt(t) {
2859
+ function Bt(t) {
2860
2860
  const r = "\\begin{document}", n = "\\end{document}", i = t.indexOf(r);
2861
2861
  if (i === -1)
2862
2862
  return { preamble: "", body: t };
@@ -2922,6 +2922,15 @@ function ka(t) {
2922
2922
  return r ? r[1].trim() : "article";
2923
2923
  }
2924
2924
  function Sa(t) {
2925
+ return Ea.has(t.trim().toLowerCase());
2926
+ }
2927
+ const Ea = /* @__PURE__ */ new Set([
2928
+ "beamer",
2929
+ "powerdot",
2930
+ "seminar",
2931
+ "slides"
2932
+ ]);
2933
+ function Aa(t) {
2925
2934
  const r = t.replace(/(^|[^\\])%[^\n]*/gm, "$1"), { macros: n, warnings: i } = Tr(r);
2926
2935
  return {
2927
2936
  info: {
@@ -2933,7 +2942,7 @@ function Sa(t) {
2933
2942
  warnings: i
2934
2943
  };
2935
2944
  }
2936
- function Ea(t) {
2945
+ function Ia(t) {
2937
2946
  if (typeof t == "string")
2938
2947
  return t;
2939
2948
  if (typeof t == "object" && t !== null && "value" in t) {
@@ -2951,7 +2960,7 @@ function De(t) {
2951
2960
  function Rr(t) {
2952
2961
  return t.replace(/\\LaTeX\b/g, "LaTeX").replace(/\\TeX\b/g, "TeX").replace(/\\thanks\{[^{}]*(?:\{[^{}]*\}[^{}]*)?\}/g, "").replace(/\\inst\{[^{}]*\}/g, "").replace(/\\email\{[^{}]*\}/g, "").replace(/\\[a-zA-Z]+\{([^{}]*)\}/g, "$1").replace(/\\\s/g, " ").replace(/~/g, " ").replace(/\s+/g, " ").trim();
2953
2962
  }
2954
- function Aa(t) {
2963
+ function Ta(t) {
2955
2964
  const r = [];
2956
2965
  if (t.macros) {
2957
2966
  const n = De(t.macros).split(`
@@ -2974,15 +2983,18 @@ ${r.join(`
2974
2983
  `)}
2975
2984
  </docinfo>`;
2976
2985
  }
2977
- function Ia(t, r) {
2986
+ function Ra(t, r) {
2987
+ return /<slide[\s/>]/.test(t) || Sa(r.documentClass) ? "slideshow" : /<chapter[\s>]/.test(t) ? "book" : "article";
2988
+ }
2989
+ function Ca(t, r) {
2978
2990
  const n = t.replace(/^\s*<p\s*\/>\s*/g, "").replace(/^\s*<p>\s*<\/p>\s*/g, "").trim();
2979
2991
  if (!n) return "";
2980
- const e = /<chapter[\s>]/.test(n) ? "book" : "article", a = Aa(r), s = r.title ? ` <title>${De(Rr(r.title))}</title>
2981
- ` : "", o = `<${e}>
2982
- ${s}${n}
2983
- </${e}>`;
2992
+ const i = Ra(n, r), e = Ta(r), a = r.title ? ` <title>${De(Rr(r.title))}</title>
2993
+ ` : "", s = `<${i}>
2994
+ ${a}${n}
2995
+ </${i}>`;
2984
2996
  return `<pretext>
2985
- ${[a, o].filter(Boolean).join(`
2997
+ ${[e, s].filter(Boolean).join(`
2986
2998
  `)}
2987
2999
  </pretext>`;
2988
3000
  }
@@ -2990,11 +3002,11 @@ function Xe(t) {
2990
3002
  const r = t.trim();
2991
3003
  return r ? si(r) : "";
2992
3004
  }
2993
- function Ta(t) {
3005
+ function Oa(t) {
2994
3006
  const r = t.trim();
2995
3007
  if (!r)
2996
3008
  return { pretext: "", cleanedLatex: "", warnings: [], cleanChunks: [] };
2997
- const { preamble: n, body: i } = qt(r), { info: e, warnings: a } = Sa(n), s = i ? [
3009
+ const { preamble: n, body: i } = Bt(r), { info: e, warnings: a } = Aa(n), s = i ? [
2998
3010
  `\\documentclass{${e.documentClass}}`,
2999
3011
  e.macros,
3000
3012
  "\\begin{document}",
@@ -3009,72 +3021,80 @@ function Ta(t) {
3009
3021
  if (!o.trim())
3010
3022
  return { pretext: "", cleanedLatex: o, warnings: f, cleanChunks: l };
3011
3023
  const p = i ? o + `
3012
- \\end{document}` : o, g = Ea(
3024
+ \\end{document}` : o, g = Ia(
3013
3025
  oi(p)
3014
3026
  ).trim();
3015
3027
  if (!g)
3016
3028
  return { pretext: "", cleanedLatex: o, warnings: f, cleanChunks: l };
3017
- const d = Ia(g, e);
3029
+ const d = Ca(g, e);
3018
3030
  return { pretext: d ? Xe(d) : "", cleanedLatex: o, warnings: f, cleanChunks: l };
3019
3031
  }
3020
- function Ra(t) {
3021
- const r = t.trim();
3022
- if (!r)
3032
+ function za(t, r) {
3033
+ const n = t.trim();
3034
+ if (!n)
3023
3035
  return { pretext: "", cleanedMarkdown: "" };
3024
- const n = String(ci(r)).trim();
3025
- return { pretext: n ? Xe(n) : "", cleanedMarkdown: r };
3036
+ const i = String(
3037
+ ci(
3038
+ n,
3039
+ r ? { documentRoot: r } : void 0
3040
+ )
3041
+ ).trim();
3042
+ return { pretext: i ? Xe(i) : "", cleanedMarkdown: n };
3026
3043
  }
3027
- function Ca(t) {
3044
+ function $a(t) {
3028
3045
  return t instanceof Error && t.message.trim() ? t.message.trim() : "Could not convert source content to PreTeXt.";
3029
3046
  }
3030
- function Oa(t, r) {
3031
- const n = ge(t), i = r ?? n;
3047
+ function La(t, r, n) {
3048
+ const i = ge(t), e = r ?? i;
3032
3049
  try {
3033
- if (i === "pretext")
3050
+ if (e === "pretext")
3034
3051
  return {
3035
- sourceFormat: i,
3036
- detectedSourceFormat: n,
3052
+ sourceFormat: e,
3053
+ detectedSourceFormat: i,
3037
3054
  pretextSource: Xe(t),
3038
3055
  warnings: []
3039
3056
  };
3040
- if (i === "markdown") {
3041
- const { pretext: c, cleanedMarkdown: l } = Ra(t);
3057
+ if (e === "markdown") {
3058
+ const { pretext: l, cleanedMarkdown: f } = za(
3059
+ t,
3060
+ n
3061
+ );
3042
3062
  return {
3043
- sourceFormat: i,
3044
- detectedSourceFormat: n,
3045
- pretextSource: c,
3046
- cleanedNativeSource: l,
3063
+ sourceFormat: e,
3064
+ detectedSourceFormat: i,
3065
+ pretextSource: l,
3066
+ cleanedNativeSource: f,
3047
3067
  warnings: []
3048
3068
  };
3049
3069
  }
3050
- const { pretext: e, cleanedLatex: a, warnings: s, cleanChunks: o } = Ta(t);
3070
+ const { pretext: a, cleanedLatex: s, warnings: o, cleanChunks: c } = Oa(t);
3051
3071
  return {
3052
- sourceFormat: i,
3053
- detectedSourceFormat: n,
3054
- pretextSource: e,
3055
- cleanedNativeSource: a,
3056
- warnings: s,
3057
- cleanChunks: o
3072
+ sourceFormat: e,
3073
+ detectedSourceFormat: i,
3074
+ pretextSource: a,
3075
+ cleanedNativeSource: s,
3076
+ warnings: o,
3077
+ cleanChunks: c
3058
3078
  };
3059
- } catch (e) {
3079
+ } catch (a) {
3060
3080
  return {
3061
- sourceFormat: i,
3062
- detectedSourceFormat: n,
3063
- pretextError: Ca(e),
3081
+ sourceFormat: e,
3082
+ detectedSourceFormat: i,
3083
+ pretextError: $a(a),
3064
3084
  warnings: []
3065
3085
  };
3066
3086
  }
3067
3087
  }
3068
- var Gt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3069
- function za(t) {
3088
+ var Ht = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3089
+ function Da(t) {
3070
3090
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3071
3091
  }
3072
- function Ht(t) {
3092
+ function Yt(t) {
3073
3093
  throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
3074
3094
  }
3075
3095
  var he = { exports: {} };
3076
3096
  var lr;
3077
- function $a() {
3097
+ function Pa() {
3078
3098
  return lr || (lr = 1, (function(t, r) {
3079
3099
  (function(n) {
3080
3100
  t.exports = n();
@@ -3083,7 +3103,7 @@ function $a() {
3083
3103
  function s(l, f) {
3084
3104
  if (!e[l]) {
3085
3105
  if (!i[l]) {
3086
- var p = typeof Ht == "function" && Ht;
3106
+ var p = typeof Yt == "function" && Yt;
3087
3107
  if (!f && p) return p(l, !0);
3088
3108
  if (o) return o(l, !0);
3089
3109
  var g = new Error("Cannot find module '" + l + "'");
@@ -3097,7 +3117,7 @@ function $a() {
3097
3117
  }
3098
3118
  return e[l].exports;
3099
3119
  }
3100
- for (var o = typeof Ht == "function" && Ht, c = 0; c < a.length; c++) s(a[c]);
3120
+ for (var o = typeof Yt == "function" && Yt, c = 0; c < a.length; c++) s(a[c]);
3101
3121
  return s;
3102
3122
  })({ 1: [function(n, i, e) {
3103
3123
  var a = n("./utils"), s = n("./support"), o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@@ -4132,7 +4152,7 @@ function $a() {
4132
4152
  i.exports = function(h) {
4133
4153
  d.push(h) !== 1 || o || s();
4134
4154
  };
4135
- }).call(this, typeof Gt < "u" ? Gt : typeof self < "u" ? self : typeof window < "u" ? window : {});
4155
+ }).call(this, typeof Ht < "u" ? Ht : typeof self < "u" ? self : typeof window < "u" ? window : {});
4136
4156
  }, {}], 37: [function(n, i, e) {
4137
4157
  var a = n("immediate");
4138
4158
  function s() {
@@ -5222,15 +5242,15 @@ function $a() {
5222
5242
  for (E.max_code = ot, q = _.heap_len >> 1; 1 <= q; q--) st(_, Z, q);
5223
5243
  for (R = tt; q = _.heap[1], _.heap[1] = _.heap[_.heap_len--], st(_, Z, 1), N = _.heap[1], _.heap[--_.heap_max] = q, _.heap[--_.heap_max] = N, Z[2 * R] = Z[2 * q] + Z[2 * N], _.depth[R] = (_.depth[q] >= _.depth[N] ? _.depth[q] : _.depth[N]) + 1, Z[2 * q + 1] = Z[2 * N + 1] = R, _.heap[1] = R++, st(_, Z, 1), 2 <= _.heap_len; ) ;
5224
5244
  _.heap[--_.heap_max] = _.heap[1], (function(at, gt) {
5225
- var zt, _t, $t, dt, Zt, de, xt = gt.dyn_tree, nn = gt.max_code, ri = gt.stat_desc.static_tree, ii = gt.stat_desc.has_stree, ai = gt.stat_desc.extra_bits, rn = gt.stat_desc.extra_base, Lt = gt.stat_desc.max_length, Xt = 0;
5245
+ var $t, _t, Lt, dt, Xt, de, xt = gt.dyn_tree, nn = gt.max_code, ri = gt.stat_desc.static_tree, ii = gt.stat_desc.has_stree, ai = gt.stat_desc.extra_bits, rn = gt.stat_desc.extra_base, Dt = gt.stat_desc.max_length, Vt = 0;
5226
5246
  for (dt = 0; dt <= v; dt++) at.bl_count[dt] = 0;
5227
- for (xt[2 * at.heap[at.heap_max] + 1] = 0, zt = at.heap_max + 1; zt < h; zt++) Lt < (dt = xt[2 * xt[2 * (_t = at.heap[zt]) + 1] + 1] + 1) && (dt = Lt, Xt++), xt[2 * _t + 1] = dt, nn < _t || (at.bl_count[dt]++, Zt = 0, rn <= _t && (Zt = ai[_t - rn]), de = xt[2 * _t], at.opt_len += de * (dt + Zt), ii && (at.static_len += de * (ri[2 * _t + 1] + Zt)));
5228
- if (Xt !== 0) {
5247
+ for (xt[2 * at.heap[at.heap_max] + 1] = 0, $t = at.heap_max + 1; $t < h; $t++) Dt < (dt = xt[2 * xt[2 * (_t = at.heap[$t]) + 1] + 1] + 1) && (dt = Dt, Vt++), xt[2 * _t + 1] = dt, nn < _t || (at.bl_count[dt]++, Xt = 0, rn <= _t && (Xt = ai[_t - rn]), de = xt[2 * _t], at.opt_len += de * (dt + Xt), ii && (at.static_len += de * (ri[2 * _t + 1] + Xt)));
5248
+ if (Vt !== 0) {
5229
5249
  do {
5230
- for (dt = Lt - 1; at.bl_count[dt] === 0; ) dt--;
5231
- at.bl_count[dt]--, at.bl_count[dt + 1] += 2, at.bl_count[Lt]--, Xt -= 2;
5232
- } while (0 < Xt);
5233
- for (dt = Lt; dt !== 0; dt--) for (_t = at.bl_count[dt]; _t !== 0; ) nn < ($t = at.heap[--zt]) || (xt[2 * $t + 1] !== dt && (at.opt_len += (dt - xt[2 * $t + 1]) * xt[2 * $t], xt[2 * $t + 1] = dt), _t--);
5250
+ for (dt = Dt - 1; at.bl_count[dt] === 0; ) dt--;
5251
+ at.bl_count[dt]--, at.bl_count[dt + 1] += 2, at.bl_count[Dt]--, Vt -= 2;
5252
+ } while (0 < Vt);
5253
+ for (dt = Dt; dt !== 0; dt--) for (_t = at.bl_count[dt]; _t !== 0; ) nn < (Lt = at.heap[--$t]) || (xt[2 * Lt + 1] !== dt && (at.opt_len += (dt - xt[2 * Lt + 1]) * xt[2 * Lt], xt[2 * Lt + 1] = dt), _t--);
5234
5254
  }
5235
5255
  })(_, E), Q(Z, ot, _.bl_count);
5236
5256
  }
@@ -5370,14 +5390,14 @@ function $a() {
5370
5390
  I.source === s && typeof I.data == "string" && I.data.indexOf(p) === 0 && x(+I.data.slice(p.length));
5371
5391
  }
5372
5392
  })(typeof self > "u" ? a === void 0 ? this : a : self);
5373
- }).call(this, typeof Gt < "u" ? Gt : typeof self < "u" ? self : typeof window < "u" ? window : {});
5393
+ }).call(this, typeof Ht < "u" ? Ht : typeof self < "u" ? self : typeof window < "u" ? window : {});
5374
5394
  }, {}] }, {}, [10])(10);
5375
5395
  });
5376
5396
  })(he)), he.exports;
5377
5397
  }
5378
- var La = $a();
5379
- const Da = /* @__PURE__ */ za(La), ur = /([a-zA-Z_:][\w:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
5380
- function Bt(t) {
5398
+ var ja = Pa();
5399
+ const Fa = /* @__PURE__ */ Da(ja), ur = /([a-zA-Z_:][\w:.-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
5400
+ function Nt(t) {
5381
5401
  const r = {};
5382
5402
  let n;
5383
5403
  for (ur.lastIndex = 0; (n = ur.exec(t)) !== null; )
@@ -5457,7 +5477,7 @@ function At(t, r) {
5457
5477
  end: s.end,
5458
5478
  inner: "",
5459
5479
  outer: t.slice(s.pos, s.end),
5460
- attributes: Bt(s.attrs)
5480
+ attributes: Nt(s.attrs)
5461
5481
  });
5462
5482
  continue;
5463
5483
  }
@@ -5473,7 +5493,7 @@ function At(t, r) {
5473
5493
  end: s.end,
5474
5494
  inner: t.slice(a.end, s.pos),
5475
5495
  outer: t.slice(a.pos, s.end),
5476
- attributes: Bt(a.attrs)
5496
+ attributes: Nt(a.attrs)
5477
5497
  }), a = null);
5478
5498
  }
5479
5499
  return i;
@@ -5481,7 +5501,7 @@ function At(t, r) {
5481
5501
  function lt(t, r) {
5482
5502
  return Cr(t, r)[0] ?? null;
5483
5503
  }
5484
- function Jt(t, r) {
5504
+ function It(t, r) {
5485
5505
  const n = Ve(t);
5486
5506
  let i = 0, e = null, a = -1;
5487
5507
  for (const s of n) {
@@ -5495,7 +5515,7 @@ function Jt(t, r) {
5495
5515
  end: s.end,
5496
5516
  inner: "",
5497
5517
  outer: t.slice(s.pos, s.end),
5498
- attributes: Bt(s.attrs)
5518
+ attributes: Nt(s.attrs)
5499
5519
  };
5500
5520
  continue;
5501
5521
  }
@@ -5513,7 +5533,7 @@ function Jt(t, r) {
5513
5533
  end: s.end,
5514
5534
  inner: t.slice(e.end, s.pos),
5515
5535
  outer: t.slice(e.pos, s.end),
5516
- attributes: Bt(o)
5536
+ attributes: Nt(o)
5517
5537
  };
5518
5538
  }
5519
5539
  }
@@ -5525,7 +5545,7 @@ function Or(t) {
5525
5545
  kind: r.kind,
5526
5546
  start: r.pos,
5527
5547
  end: r.end,
5528
- attributes: r.kind === "close" ? {} : Bt(r.attrs)
5548
+ attributes: r.kind === "close" ? {} : Nt(r.attrs)
5529
5549
  }));
5530
5550
  }
5531
5551
  function Ge(t) {
@@ -5533,7 +5553,7 @@ function Ge(t) {
5533
5553
  return r ? r.inner.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim() : "";
5534
5554
  }
5535
5555
  function zr(t) {
5536
- return Jt(t, "book") ? "book" : Jt(t, "article") ? "article" : Jt(t, "chapter") ? "book" : "article";
5556
+ return It(t, "slideshow") ? "slideshow" : It(t, "book") ? "book" : It(t, "article") ? "article" : It(t, "chapter") ? "book" : It(t, "slide") ? "slideshow" : "article";
5537
5557
  }
5538
5558
  function mt(t) {
5539
5559
  const r = t.replace(/\\/g, "/"), n = r.startsWith("/"), i = [];
@@ -5564,7 +5584,7 @@ function se(t) {
5564
5584
  function kt(...t) {
5565
5585
  return mt(t.filter((r) => !!r).join("/"));
5566
5586
  }
5567
- function Pa(t, r) {
5587
+ function qa(t, r) {
5568
5588
  if (!t)
5569
5589
  return r;
5570
5590
  const n = t.endsWith("/") ? t : `${t}/`;
@@ -5605,7 +5625,7 @@ function dr(t, r, n, i = 3) {
5605
5625
  consumedPaths: [...s]
5606
5626
  };
5607
5627
  }
5608
- function ja(t) {
5628
+ function Ba(t) {
5609
5629
  const r = /* @__PURE__ */ new Set();
5610
5630
  for (const [n, i] of Object.entries(t)) {
5611
5631
  Pe.lastIndex = 0;
@@ -5634,10 +5654,10 @@ function Lr(t, r, n) {
5634
5654
  }
5635
5655
  return null;
5636
5656
  }
5637
- function Fa(t) {
5657
+ function Na(t) {
5638
5658
  return t.replace(/^\s*<\?xml[^?]*\?>\s*/, "");
5639
5659
  }
5640
- function qa(t, r, n, i = 5) {
5660
+ function Ua(t, r, n, i = 5) {
5641
5661
  let e = 0;
5642
5662
  const a = [], s = [r], o = /* @__PURE__ */ new Set(), c = (f, p) => f.replace(
5643
5663
  new RegExp($r, "g"),
@@ -5648,7 +5668,7 @@ function qa(t, r, n, i = 5) {
5648
5668
  if (s.includes(b) || p >= i)
5649
5669
  return g;
5650
5670
  e += 1, o.add(b), s.push(b);
5651
- const x = c(Fa(n[b]), p + 1);
5671
+ const x = c(Na(n[b]), p + 1);
5652
5672
  return s.pop(), x;
5653
5673
  }
5654
5674
  );
@@ -5659,7 +5679,7 @@ function qa(t, r, n, i = 5) {
5659
5679
  consumedPaths: [...o]
5660
5680
  };
5661
5681
  }
5662
- function Ba(t) {
5682
+ function Ma(t) {
5663
5683
  const r = /* @__PURE__ */ new Set();
5664
5684
  for (const [n, i] of Object.entries(t)) {
5665
5685
  fr.lastIndex = 0;
@@ -5671,7 +5691,7 @@ function Ba(t) {
5671
5691
  }
5672
5692
  return r;
5673
5693
  }
5674
- const xo = ["book", "article"], Na = [
5694
+ const Eo = ["book", "article", "slideshow"], Wa = [
5675
5695
  "frontmatter",
5676
5696
  "preface",
5677
5697
  "acknowledgement",
@@ -5696,11 +5716,11 @@ const xo = ["book", "article"], Na = [
5696
5716
  "appendix",
5697
5717
  "index",
5698
5718
  "colophon"
5699
- ], Ua = new Set(Na);
5700
- function Ot(t) {
5701
- return Ua.has(t);
5719
+ ], Za = new Set(Wa);
5720
+ function zt(t) {
5721
+ return Za.has(t);
5702
5722
  }
5703
- const Ma = {
5723
+ const Xa = {
5704
5724
  chapter: "ch",
5705
5725
  section: "sec",
5706
5726
  subsection: "subsec",
@@ -5708,9 +5728,9 @@ const Ma = {
5708
5728
  appendix: "app"
5709
5729
  };
5710
5730
  function Je(t) {
5711
- return Ma[t] ?? t;
5731
+ return Xa[t] ?? t;
5712
5732
  }
5713
- const Wa = /* @__PURE__ */ new Set([
5733
+ const Va = /* @__PURE__ */ new Set([
5714
5734
  "frontmatter",
5715
5735
  "backmatter",
5716
5736
  "preface",
@@ -5722,26 +5742,26 @@ const Wa = /* @__PURE__ */ new Set([
5722
5742
  "glossary",
5723
5743
  "index"
5724
5744
  ]);
5725
- function Za(t) {
5726
- return Wa.has(t);
5745
+ function Ga(t) {
5746
+ return Va.has(t);
5727
5747
  }
5728
- const Nt = [
5748
+ const Ut = [
5729
5749
  "part",
5730
5750
  "chapter",
5731
5751
  "section",
5732
5752
  "subsection",
5733
5753
  "subsubsection"
5734
5754
  ], Dr = "paragraphs";
5735
- function Ut(t) {
5736
- return Nt.indexOf(t);
5755
+ function Mt(t) {
5756
+ return Ut.indexOf(t);
5737
5757
  }
5738
- function Xa(t, r) {
5739
- const n = Ut(t);
5758
+ function Ha(t, r) {
5759
+ const n = Mt(t);
5740
5760
  if (n < 0) return t;
5741
5761
  const i = n + r;
5742
- return i >= Nt.length ? Dr : Nt[Math.max(0, i)];
5762
+ return i >= Ut.length ? Dr : Ut[Math.max(0, i)];
5743
5763
  }
5744
- function Wt(t) {
5764
+ function Zt(t) {
5745
5765
  return t.trim().replace(/[^a-zA-Z0-9\-_]+/g, "-").replace(/^[^a-zA-Z_]+/, "").replace(/-+$/, "");
5746
5766
  }
5747
5767
  class Ke {
@@ -5768,7 +5788,7 @@ class Ke {
5768
5788
  }
5769
5789
  function je(t, r, n) {
5770
5790
  if (t) {
5771
- const i = Wt(t) || n, e = r.claim(i);
5791
+ const i = Zt(t) || n, e = r.claim(i);
5772
5792
  return e !== t ? { ref: e, renamedFrom: t, generated: !1 } : { ref: e, generated: !1 };
5773
5793
  }
5774
5794
  return { ref: r.claim(n), generated: !0 };
@@ -5795,7 +5815,7 @@ function oe(t, r, n, i) {
5795
5815
  function ce(t, r) {
5796
5816
  return Object.entries(t).map(([n, i]) => {
5797
5817
  const e = n.split("/").pop() ?? n, a = e.replace(/\.[^.]+$/, "");
5798
- return { ref: r.claim(Wt(a) || "asset"), fileName: e, data: i };
5818
+ return { ref: r.claim(Zt(a) || "asset"), fileName: e, data: i };
5799
5819
  });
5800
5820
  }
5801
5821
  function Pr(t, r) {
@@ -5818,7 +5838,7 @@ function qr(t, r) {
5818
5838
  function Br(t, r, n, i) {
5819
5839
  if (n > i.maxDepth)
5820
5840
  return t;
5821
- const e = At(t, Ot);
5841
+ const e = At(t, zt);
5822
5842
  if (e.length === 0)
5823
5843
  return t;
5824
5844
  const a = e.map((s, o) => {
@@ -5847,10 +5867,10 @@ function Br(t, r, n, i) {
5847
5867
  replacement: `<plus:${s.name} ref="${g.ref}"/>`
5848
5868
  };
5849
5869
  });
5850
- return Mt(t, a);
5870
+ return Wt(t, a);
5851
5871
  }
5852
5872
  function Nr(t, r = {}) {
5853
- const n = [], i = r.documentKind ?? zr(t), e = Pr(r, i), a = Jt(t, "pretext"), s = a ? a.inner : t, o = lt(s, "docinfo"), c = o?.outer.trim() ?? "";
5873
+ const n = [], i = r.documentKind ?? zr(t), e = Pr(r, i), a = It(t, "pretext"), s = a ? a.inner : t, o = lt(s, "docinfo"), c = o?.outer.trim() ?? "";
5854
5874
  let l = lt(s, "book") ?? lt(s, "article");
5855
5875
  if (!l) {
5856
5876
  const b = i === "book" ? "book" : "article", x = (o ? s.slice(0, o.start) + s.slice(o.end) : s).trim();
@@ -5905,10 +5925,10 @@ ${x}
5905
5925
  };
5906
5926
  }
5907
5927
  function Ur(t, r, n = {}) {
5908
- return r === "latex" ? Va(t, n) : Ga(t, n);
5928
+ return r === "latex" ? Ya(t, n) : Ja(t, n);
5909
5929
  }
5910
5930
  function hr(t) {
5911
- return Wt(Me(t));
5931
+ return Zt(Me(t));
5912
5932
  }
5913
5933
  function Qe(t, r, n, i, e, a, s) {
5914
5934
  if (t) {
@@ -5925,8 +5945,8 @@ function Qe(t, r, n, i, e, a, s) {
5925
5945
  const c = je(void 0, n, i);
5926
5946
  return oe(s, c, e, a), c.ref;
5927
5947
  }
5928
- function Va(t, r) {
5929
- const n = [], { body: i } = qt(t), e = (i || t).trim(), a = Er(e), s = Ze(e), o = r.documentKind ?? (s.includes("chapter") || s.includes("part") ? "book" : "article"), c = Pr(r, o), l = new Ke(), f = l.claim("document"), p = [], g = Mr(e, a, 0, e.length, 1, {
5948
+ function Ya(t, r) {
5949
+ const n = [], { body: i } = Bt(t), e = (i || t).trim(), a = Er(e), s = Ze(e), o = r.documentKind ?? (s.includes("chapter") || s.includes("part") ? "book" : "article"), c = Pr(r, o), l = new Ke(), f = l.claim("document"), p = [], g = Mr(e, a, 0, e.length, 1, {
5930
5950
  maxDepth: c,
5931
5951
  refs: l,
5932
5952
  divisions: p,
@@ -6016,7 +6036,7 @@ ${Object.entries(t).map(([n, i]) => `${n}: ${i}`).join(`
6016
6036
  `)}
6017
6037
  ---`;
6018
6038
  }
6019
- function Ga(t, r) {
6039
+ function Ja(t, r) {
6020
6040
  const n = [], i = t.trim(), e = r.documentKind ?? "article", a = r.splitChapters ?? e === "book", s = r.splitSections ?? !1, o = new Ke(), c = o.claim("document"), l = [];
6021
6041
  if (!(a && e === "book"))
6022
6042
  return l.push({
@@ -6054,7 +6074,7 @@ ${i}`.trim(),
6054
6074
  n
6055
6075
  );
6056
6076
  let v = d.body;
6057
- s && (v = Ha(
6077
+ s && (v = Ka(
6058
6078
  d.body,
6059
6079
  h,
6060
6080
  o,
@@ -6102,7 +6122,7 @@ ${g.join(`
6102
6122
  warnings: n
6103
6123
  };
6104
6124
  }
6105
- function Ha(t, r, n, i, e) {
6125
+ function Ka(t, r, n, i, e) {
6106
6126
  const { preamble: a, sections: s } = Wr(t, 2);
6107
6127
  if (s.length === 0) return t;
6108
6128
  const o = a ? [a] : [];
@@ -6154,17 +6174,17 @@ function qe(t, r) {
6154
6174
  }
6155
6175
  );
6156
6176
  }
6157
- function Ya(t, r) {
6177
+ function Qa(t, r) {
6158
6178
  const n = Me(t) || "division";
6159
6179
  return n.startsWith(`${r}-`) ? n : `${r}-${n}`;
6160
6180
  }
6161
- function Ja(t, r) {
6181
+ function ts(t, r) {
6162
6182
  let n = r, i = 2;
6163
6183
  for (; t.has(n); )
6164
6184
  n = `${r}-${i}`, i += 1;
6165
6185
  return t.add(n), n;
6166
6186
  }
6167
- function Ka(t, r) {
6187
+ function es(t, r) {
6168
6188
  const n = `${r}-`;
6169
6189
  return t.startsWith(n) ? t.slice(n.length) : t;
6170
6190
  }
@@ -6174,7 +6194,7 @@ function Zr(t, r) {
6174
6194
  ), i = [], e = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
6175
6195
  function o(f, p) {
6176
6196
  let g = s.get(f);
6177
- return g || (g = /* @__PURE__ */ new Set(), s.set(f, g)), Ja(g, p);
6197
+ return g || (g = /* @__PURE__ */ new Set(), s.set(f, g)), ts(g, p);
6178
6198
  }
6179
6199
  function c(f, p, g, d) {
6180
6200
  if (e.has(f.xmlId))
@@ -6182,8 +6202,8 @@ function Zr(t, r) {
6182
6202
  e.add(f.xmlId);
6183
6203
  const w = o(
6184
6204
  p,
6185
- Za(f.type) ? f.type : Ya(
6186
- Ka(f.xmlId, d),
6205
+ Ga(f.type) ? f.type : Qa(
6206
+ es(f.xmlId, d),
6187
6207
  Je(f.type)
6188
6208
  )
6189
6209
  );
@@ -6208,7 +6228,7 @@ const pe = {
6208
6228
  publicationPath: "publication/publication.ptx",
6209
6229
  projectFilePath: "project.ptx"
6210
6230
  };
6211
- function Qa(t, r = {}) {
6231
+ function ns(t, r = {}) {
6212
6232
  const n = r.mainSourcePath ?? pe.mainSourcePath, i = r.publicationPath ?? pe.publicationPath, e = r.projectFilePath ?? pe.projectFilePath, a = r.includeScaffold ?? !0, s = {}, o = new Map(t.divisions.map((v) => [v.xmlId, v])), c = t.divisions.find((v) => v.isRoot);
6213
6233
  if (!c)
6214
6234
  throw new Error("Division pool has no root division.");
@@ -6236,13 +6256,13 @@ ${t.docinfo ? `${t.docinfo}
6236
6256
  h[v.xmlId] = b;
6237
6257
  return { files: s, pathByRef: h };
6238
6258
  }
6239
- function ts(t, r, n) {
6259
+ function rs(t, r, n) {
6240
6260
  const i = lt(t, r);
6241
6261
  if (!i) return t;
6242
6262
  const e = t.slice(i.start, i.startTagEnd).replace(/^<\s*[^\s>/]+/, `<${n}`), a = t.slice(i.contentEnd, i.end).replace(/^<\/\s*[^\s>]+/, `</${n}`);
6243
6263
  return t.slice(0, i.start) + e + t.slice(i.startTagEnd, i.contentEnd) + a + t.slice(i.end);
6244
6264
  }
6245
- function es(t, r) {
6265
+ function is(t, r) {
6246
6266
  const n = new Map(t.divisions.map((a) => [a.xmlId, a])), i = t.divisions.find((a) => a.isRoot);
6247
6267
  if (!i)
6248
6268
  throw new Error("Division pool has no root division.");
@@ -6250,7 +6270,7 @@ function es(t, r) {
6250
6270
  {
6251
6271
  ...i,
6252
6272
  type: r.targetTag,
6253
- content: ts(
6273
+ content: rs(
6254
6274
  i.content,
6255
6275
  i.type,
6256
6276
  r.targetTag
@@ -6259,8 +6279,8 @@ function es(t, r) {
6259
6279
  ];
6260
6280
  return { root: i, entries: e };
6261
6281
  }
6262
- function ns(t, r) {
6263
- const { root: n, entries: i } = es(t, r), { placed: e, hrefByRef: a } = Zr(t, {
6282
+ function as(t, r) {
6283
+ const { root: n, entries: i } = is(t, r), { placed: e, hrefByRef: a } = Zr(t, {
6264
6284
  entries: i,
6265
6285
  directory: r.hrefBase,
6266
6286
  parentXmlId: n.xmlId
@@ -6274,35 +6294,35 @@ function ns(t, r) {
6274
6294
  }
6275
6295
  function Xr(t, r, n = {}) {
6276
6296
  if (r.kind === "insert")
6277
- return ns(t, {
6297
+ return as(t, {
6278
6298
  targetTag: r.targetTag,
6279
6299
  hrefBase: r.hrefBase,
6280
6300
  unwrapRoot: n.unwrapRoot ?? !1
6281
6301
  });
6282
- const { files: i, pathByRef: e } = Qa(t, n.layout);
6302
+ const { files: i, pathByRef: e } = ns(t, n.layout);
6283
6303
  return { files: i, includes: [], pathByRef: e };
6284
6304
  }
6285
- const rs = { kind: "project" }, is = ["ref", "first", "last"];
6286
- function as(t) {
6305
+ const ss = { kind: "project" }, os = ["ref", "first", "last"];
6306
+ function cs(t) {
6287
6307
  let r = t.base, n = 2;
6288
6308
  for (; t.isTaken(r) || r === ""; )
6289
6309
  r = `${t.base || "id"}-${n}`, n += 1;
6290
6310
  return r;
6291
6311
  }
6292
- function ss(t) {
6312
+ function ls(t) {
6293
6313
  return t.split(/([\s,]+)/);
6294
6314
  }
6295
- function os(t, r) {
6315
+ function us(t, r) {
6296
6316
  const n = Or(t), i = new Set(r.takenIds), e = (c) => i.has(c), a = /* @__PURE__ */ new Map(), s = [];
6297
6317
  for (const c of n) {
6298
6318
  const l = c.attributes["xml:id"];
6299
6319
  if (l === void 0 || a.has(l)) continue;
6300
- const f = Wt(l);
6320
+ const f = Zt(l);
6301
6321
  if (f === l && !i.has(l)) {
6302
6322
  i.add(l);
6303
6323
  continue;
6304
6324
  }
6305
- const p = as({
6325
+ const p = cs({
6306
6326
  original: l,
6307
6327
  base: f,
6308
6328
  isTaken: e,
@@ -6320,10 +6340,10 @@ function os(t, r) {
6320
6340
  /\bxml:id\s*=\s*(["'])[^"']*\1/,
6321
6341
  (d, w) => `xml:id=${w}${g}${w}`
6322
6342
  ));
6323
- for (const d of is) {
6343
+ for (const d of os) {
6324
6344
  const w = c.attributes[d];
6325
6345
  if (w === void 0) continue;
6326
- const h = ss(w).map((v) => a.get(v) ?? v).join("");
6346
+ const h = ls(w).map((v) => a.get(v) ?? v).join("");
6327
6347
  h !== w && (f = f.replace(
6328
6348
  new RegExp(`\\b${d}\\s*=\\s*(["'])[^"']*\\1`),
6329
6349
  (v, b) => `${d}=${b}${h}${b}`
@@ -6335,7 +6355,7 @@ function os(t, r) {
6335
6355
  replacement: f
6336
6356
  });
6337
6357
  }
6338
- return { source: Mt(t, o), renamed: s };
6358
+ return { source: Wt(t, o), renamed: s };
6339
6359
  }
6340
6360
  function pr(t) {
6341
6361
  const r = t.indexOf(":");
@@ -6344,53 +6364,53 @@ function pr(t) {
6344
6364
  local: t.slice(r + 1)
6345
6365
  };
6346
6366
  }
6347
- function ko(t, r) {
6348
- return Vr(t, Ut(r));
6367
+ function Ao(t, r) {
6368
+ return Vr(t, Mt(r));
6349
6369
  }
6350
6370
  function Vr(t, r) {
6351
6371
  const n = Or(t);
6352
6372
  let i = -1;
6353
6373
  for (const l of n) {
6354
- const f = Ut(pr(l.name).local);
6374
+ const f = Mt(pr(l.name).local);
6355
6375
  f >= 0 && (i < 0 || f < i) && (i = f);
6356
6376
  }
6357
6377
  if (i < 0 || r < 0)
6358
6378
  return { source: t, delta: 0, overflowed: [] };
6359
- const e = r - i, a = Nt[i];
6379
+ const e = r - i, a = Ut[i];
6360
6380
  if (e === 0)
6361
6381
  return { source: t, delta: 0, topTag: a, overflowed: [] };
6362
6382
  const s = /* @__PURE__ */ new Set(), o = [];
6363
6383
  for (const l of n) {
6364
- const { prefix: f, local: p } = pr(l.name), g = Ut(p);
6384
+ const { prefix: f, local: p } = pr(l.name), g = Mt(p);
6365
6385
  if (g < 0) continue;
6366
- const d = Xa(p, e);
6386
+ const d = Ha(p, e);
6367
6387
  if (d === p) continue;
6368
6388
  d === Dr && s.add(g);
6369
6389
  const w = t.slice(l.start, l.end), h = l.kind === "close" ? w.replace(/^<\/\s*[^\s>/]+/, `</${f}${d}`) : w.replace(/^<\s*[^\s>/]+/, `<${f}${d}`);
6370
6390
  o.push({ start: l.start, end: l.end, replacement: h });
6371
6391
  }
6372
- const c = [...s].sort((l, f) => l - f).map((l) => Nt[l]);
6392
+ const c = [...s].sort((l, f) => l - f).map((l) => Ut[l]);
6373
6393
  return {
6374
- source: Mt(t, o),
6394
+ source: Wt(t, o),
6375
6395
  delta: e,
6376
6396
  topTag: a,
6377
6397
  overflowed: c
6378
6398
  };
6379
6399
  }
6380
- function cs(t) {
6400
+ function ds(t) {
6381
6401
  if (lt(t, "title"))
6382
6402
  return !1;
6383
6403
  const r = At(t, () => !0);
6384
- return r.length === 0 || !r.every((n) => Ot(n.name)) ? !1 : !Gr(t);
6404
+ return r.length === 0 || !r.every((n) => zt(n.name)) ? !1 : !Gr(t);
6385
6405
  }
6386
6406
  function Gr(t) {
6387
- const r = At(t, Ot);
6407
+ const r = At(t, zt);
6388
6408
  let n = "", i = 0;
6389
6409
  for (const e of r)
6390
6410
  n += t.slice(i, e.start), i = e.end;
6391
6411
  return n += t.slice(i), n.replace(/<!--[\s\S]*?-->/g, "").trim() !== "";
6392
6412
  }
6393
- function ls(t) {
6413
+ function fs(t) {
6394
6414
  const r = lt(t, "pretext"), n = r ? r.inner : t, i = r ? r.startTagEnd : 0, e = lt(n, "book") ?? lt(n, "article");
6395
6415
  return e ? {
6396
6416
  ...e,
@@ -6400,11 +6420,11 @@ function ls(t) {
6400
6420
  end: e.end + i
6401
6421
  } : null;
6402
6422
  }
6403
- function us(t) {
6423
+ function hs(t) {
6404
6424
  const r = lt(t, "title");
6405
6425
  return r ? r.inner.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim() : "";
6406
6426
  }
6407
- function ds(t, r, n) {
6427
+ function ps(t, r, n) {
6408
6428
  const i = new Set(n), e = [];
6409
6429
  for (const a of r) {
6410
6430
  const s = a.attributes["xml:id"];
@@ -6412,7 +6432,7 @@ function ds(t, r, n) {
6412
6432
  i.add(s);
6413
6433
  continue;
6414
6434
  }
6415
- const o = Wt(Me(us(a.inner))) || "imported";
6435
+ const o = Zt(Me(hs(a.inner))) || "imported";
6416
6436
  let c = o, l = 2;
6417
6437
  for (; i.has(c); )
6418
6438
  c = `${o}-${l}`, l += 1;
@@ -6422,10 +6442,10 @@ function ds(t, r, n) {
6422
6442
  replacement: t.slice(a.start, a.startTagEnd).replace(/^<([a-zA-Z_:][\w:.-]*)/, `<$1 xml:id="${c}"`)
6423
6443
  });
6424
6444
  }
6425
- return e.length === 0 ? t : Mt(t, e);
6445
+ return e.length === 0 ? t : Wt(t, e);
6426
6446
  }
6427
- function fs(t, r) {
6428
- return r ? At(t.inner, Ot).map(
6447
+ function ms(t, r) {
6448
+ return r ? At(t.inner, zt).map(
6429
6449
  (n) => ({
6430
6450
  ...n,
6431
6451
  start: n.start + t.startTagEnd,
@@ -6439,7 +6459,7 @@ function Hr(t) {
6439
6459
  return t ? 1 : 0;
6440
6460
  }
6441
6461
  function Yr(t, r, n = {}) {
6442
- const i = [], e = ls(t), a = e?.inner ?? null, s = a !== null && cs(a), o = a !== null && (n.hasSelection || s);
6462
+ const i = [], e = fs(t), a = e?.inner ?? null, s = a !== null && ds(a), o = a !== null && (n.hasSelection || s);
6443
6463
  o && !s && a !== null && Gr(a) && i.push({
6444
6464
  action: "delete",
6445
6465
  severity: "warning",
@@ -6449,14 +6469,14 @@ function Yr(t, r, n = {}) {
6449
6469
  occurrences: 1,
6450
6470
  message: "The selected divisions are inserted on their own, so the document's title and any text outside them are not carried across."
6451
6471
  });
6452
- const c = e ? ds(
6472
+ const c = e ? ps(
6453
6473
  t,
6454
- fs(e, o),
6474
+ ms(e, o),
6455
6475
  r.takenIds
6456
- ) : t, l = Ut(r.targetTag), f = Vr(
6476
+ ) : t, l = Mt(r.targetTag), f = Vr(
6457
6477
  c,
6458
6478
  l < 0 ? -1 : o ? l : l + 1
6459
- ), { source: p, renamed: g } = os(f.source, {
6479
+ ), { source: p, renamed: g } = us(f.source, {
6460
6480
  takenIds: r.takenIds
6461
6481
  });
6462
6482
  return f.overflowed.length > 0 && i.push({
@@ -6485,8 +6505,8 @@ function Yr(t, r, n = {}) {
6485
6505
  message: `The imported document has no title, so the <${r.targetTag}> it becomes has none either. PreTeXt divisions need a title; add one before building.`
6486
6506
  }), { source: p, unwrapRoot: o, retarget: f, renamed: g, warnings: i };
6487
6507
  }
6488
- const hs = "source", ps = "publication", mr = "main.ptx";
6489
- function Dt(t, r) {
6508
+ const gs = "source", bs = "publication", mr = "main.ptx";
6509
+ function Pt(t, r) {
6490
6510
  const n = lt(t.inner, r);
6491
6511
  if (!n)
6492
6512
  return;
@@ -6494,18 +6514,18 @@ function Dt(t, r) {
6494
6514
  return i.length > 0 ? i : void 0;
6495
6515
  }
6496
6516
  function me(t, r, n) {
6497
- const i = Dt(t, r);
6517
+ const i = Pt(t, r);
6498
6518
  if (i !== void 0)
6499
6519
  return mt(i);
6500
6520
  const e = t.attributes[r];
6501
6521
  if (e !== void 0 && e.trim().length > 0)
6502
6522
  return kt(n, e.trim());
6503
6523
  }
6504
- function ms(t, r) {
6524
+ function vs(t, r) {
6505
6525
  const n = lt(t, "project");
6506
6526
  if (!n)
6507
6527
  return null;
6508
- const i = He(mt(r)), e = n.attributes.source?.trim() || hs, a = n.attributes.publication?.trim() || ps, s = n.attributes.output?.trim() || "output", o = {
6528
+ const i = He(mt(r)), e = n.attributes.source?.trim() || gs, a = n.attributes.publication?.trim() || bs, s = n.attributes.output?.trim() || "output", o = {
6509
6529
  manifestPath: mt(r),
6510
6530
  projectRoot: i,
6511
6531
  ptxVersion: n.attributes["ptx-version"],
@@ -6518,40 +6538,40 @@ function ms(t, r) {
6518
6538
  name: f.attributes.name ?? "",
6519
6539
  // v2 manifests carry the format as an attribute; legacy v1 manifests
6520
6540
  // use a `<format>` child element.
6521
- format: f.attributes.format ?? Dt(f, "format") ?? "",
6541
+ format: f.attributes.format ?? Pt(f, "format") ?? "",
6522
6542
  source: me(f, "source", e) ?? kt(e, mr),
6523
6543
  publication: me(f, "publication", a),
6524
6544
  outputDir: me(f, "output-dir", s),
6525
6545
  standalone: f.attributes.standalone !== void 0 && f.attributes.standalone !== "no"
6526
6546
  });
6527
6547
  if (o.targets.length === 0) {
6528
- const f = Dt(n, "source");
6548
+ const f = Pt(n, "source");
6529
6549
  o.targets.push({
6530
6550
  name: "default",
6531
- format: Dt(n, "format") ?? "",
6551
+ format: Pt(n, "format") ?? "",
6532
6552
  source: f ? mt(f) : kt(e, mr),
6533
- publication: Dt(n, "publication"),
6553
+ publication: Pt(n, "publication"),
6534
6554
  standalone: !1
6535
6555
  });
6536
6556
  }
6537
6557
  return o;
6538
6558
  }
6539
- function gs(t) {
6559
+ function ws(t) {
6540
6560
  const r = Object.keys(t).filter((n) => yt(n).toLowerCase() === "project.ptx").sort((n, i) => {
6541
6561
  const e = n.split("/").length - i.split("/").length;
6542
6562
  return e !== 0 ? e : n.localeCompare(i);
6543
6563
  });
6544
6564
  for (const n of r) {
6545
- const i = ms(t[n], n);
6565
+ const i = vs(t[n], n);
6546
6566
  if (i)
6547
6567
  return i;
6548
6568
  }
6549
6569
  return null;
6550
6570
  }
6551
- function bs(t) {
6571
+ function _s(t) {
6552
6572
  return t.targets.find((r) => !r.standalone) ?? t.targets[0];
6553
6573
  }
6554
- const vs = /* @__PURE__ */ new Set(["md", "markdown"]), ws = /* @__PURE__ */ new Set(["ptx", "xml"]), _s = /* @__PURE__ */ new Set([
6574
+ const ys = /* @__PURE__ */ new Set(["md", "markdown"]), xs = /* @__PURE__ */ new Set(["ptx", "xml"]), ks = /* @__PURE__ */ new Set([
6555
6575
  "readme",
6556
6576
  "changelog",
6557
6577
  "contributing",
@@ -6576,19 +6596,19 @@ function Jr(t) {
6576
6596
  const r = lt(t, "pretext") ?? lt(t, "book") ?? lt(t, "article"), n = r ? r.inner : t;
6577
6597
  return lt(n, "title")?.inner.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim() || void 0;
6578
6598
  }
6579
- function ys(t) {
6599
+ function Ss(t) {
6580
6600
  const r = /^#\s+(.+)$/m.exec(t);
6581
6601
  return r ? r[1].trim() : void 0;
6582
6602
  }
6583
6603
  function br(t) {
6584
6604
  return ae(t, "title") || void 0;
6585
6605
  }
6586
- function xs(t) {
6606
+ function Es(t) {
6587
6607
  return /\\documentclass\b/.test(t) || /\\begin *\{document\}/.test(t);
6588
6608
  }
6589
- const ks = /<(pretext|book|article)\b/;
6590
- function Ss(t, r) {
6591
- const n = bs(t), i = n ? [n, ...t.targets.filter((s) => s !== n)] : t.targets, e = /* @__PURE__ */ new Set(), a = [];
6609
+ const As = /<(pretext|book|article)\b/;
6610
+ function Is(t, r) {
6611
+ const n = _s(t), i = n ? [n, ...t.targets.filter((s) => s !== n)] : t.targets, e = /* @__PURE__ */ new Set(), a = [];
6592
6612
  for (const s of i) {
6593
6613
  const o = kt(t.projectRoot, s.source);
6594
6614
  e.has(o) || !(o in r) || (e.add(o), a.push({
@@ -6602,8 +6622,8 @@ function Ss(t, r) {
6602
6622
  }
6603
6623
  return a;
6604
6624
  }
6605
- function Es(t) {
6606
- const r = tn(t, /* @__PURE__ */ new Set(["tex", "ltx"])), n = ja(r), i = Object.keys(r).filter((c) => !n.has(c) && xs(r[c])).sort(), e = (c) => {
6625
+ function Ts(t) {
6626
+ const r = tn(t, /* @__PURE__ */ new Set(["tex", "ltx"])), n = Ba(r), i = Object.keys(r).filter((c) => !n.has(c) && Es(r[c])).sort(), e = (c) => {
6607
6627
  let l = 0;
6608
6628
  const f = r[c].match(/\\(input|include) *\{[^{}]+\}/g) ?? [];
6609
6629
  for (const p of f) {
@@ -6634,19 +6654,19 @@ function Es(t) {
6634
6654
  title: br(r[c])
6635
6655
  }));
6636
6656
  }
6637
- function As(t) {
6638
- const r = tn(t, vs), n = Object.keys(r).sort(), i = (s) => _s.has(se(s).toLowerCase()), e = ["main", "index", "book", "article"], a = (s) => i(s) ? 2 : e.indexOf(se(s).toLowerCase()) >= 0 ? 0 : 1;
6657
+ function Rs(t) {
6658
+ const r = tn(t, ys), n = Object.keys(r).sort(), i = (s) => ks.has(se(s).toLowerCase()), e = ["main", "index", "book", "article"], a = (s) => i(s) ? 2 : e.indexOf(se(s).toLowerCase()) >= 0 ? 0 : 1;
6639
6659
  return [...n].sort((s, o) => a(s) - a(o) || s.localeCompare(o)).map((s) => ({
6640
6660
  path: s,
6641
6661
  format: "markdown",
6642
6662
  reason: "markdown-root",
6643
- title: ys(r[s])
6663
+ title: Ss(r[s])
6644
6664
  }));
6645
6665
  }
6646
- function Is(t) {
6647
- const r = tn(t, ws), n = Ba(r);
6666
+ function Cs(t) {
6667
+ const r = tn(t, xs), n = Ma(r);
6648
6668
  return Object.keys(r).filter(
6649
- (e) => !n.has(e) && ks.test(r[e]) && yt(e).toLowerCase() !== "project.ptx" && yt(e).toLowerCase() !== "publication.ptx"
6669
+ (e) => !n.has(e) && As.test(r[e]) && yt(e).toLowerCase() !== "project.ptx" && yt(e).toLowerCase() !== "publication.ptx"
6650
6670
  ).sort().map((e) => ({
6651
6671
  path: e,
6652
6672
  format: "pretext",
@@ -6654,12 +6674,12 @@ function Is(t) {
6654
6674
  title: Jr(r[e])
6655
6675
  }));
6656
6676
  }
6657
- function Ts(t, r = {}) {
6658
- const n = gs(t), i = [
6659
- ...n ? Ss(n, t) : [],
6660
- ...Es(t),
6661
- ...As(t),
6662
- ...Is(t)
6677
+ function Os(t, r = {}) {
6678
+ const n = ws(t), i = [
6679
+ ...n ? Is(n, t) : [],
6680
+ ...Ts(t),
6681
+ ...Rs(t),
6682
+ ...Cs(t)
6663
6683
  ], e = [], a = /* @__PURE__ */ new Set();
6664
6684
  for (const p of i)
6665
6685
  a.has(p.path) || (a.add(p.path), e.push(p));
@@ -6688,7 +6708,7 @@ function Ts(t, r = {}) {
6688
6708
  ) : [];
6689
6709
  return { manifest: n, candidates: s, formats: o, primary: c, extraRoots: f };
6690
6710
  }
6691
- const vr = "\\begin{document}", Rs = "\\end{document}", Cs = /\\documentclass\s*(?:\[[^\]]*\])?\s*\{(book|report|memoir|scrbook|scrreprt|amsbook)\}/;
6711
+ const vr = "\\begin{document}", zs = "\\end{document}", $s = /\\documentclass\s*(?:\[[^\]]*\])?\s*\{(book|report|memoir|scrbook|scrreprt|amsbook)\}/;
6692
6712
  function Kr(t) {
6693
6713
  return se(t).replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (r) => r.toUpperCase()) || "Untitled";
6694
6714
  }
@@ -6703,19 +6723,19 @@ function Be(t, r) {
6703
6723
  message: r
6704
6724
  };
6705
6725
  }
6706
- function Os(t) {
6707
- const { preamble: r, body: n } = qt(t);
6708
- return Cs.test(r) || /\\chapter\b/.test(n) ? "chapter" : "section";
6726
+ function Ls(t) {
6727
+ const { preamble: r, body: n } = Bt(t);
6728
+ return $s.test(r) || /\\chapter\b/.test(n) ? "chapter" : "section";
6709
6729
  }
6710
- function zs(t, r) {
6730
+ function Ds(t, r) {
6711
6731
  const n = t.replace(/^\s*(%[^\n]*\n\s*)*/, "");
6712
6732
  return r === "chapter" ? /^\\(chapter|part)\b/.test(n) : /^\\(section|chapter|part)\b/.test(n);
6713
6733
  }
6714
- function $s(t, r, n) {
6734
+ function Ps(t, r, n) {
6715
6735
  const i = r.filter((w) => w.include !== !1);
6716
6736
  if (i.length === 0)
6717
6737
  return { source: t, attached: [], warnings: [] };
6718
- const e = t.includes(vr), { preamble: a, body: s } = qt(t), o = Os(t), c = [], l = [], f = [], p = [];
6738
+ const e = t.includes(vr), { preamble: a, body: s } = Bt(t), o = Ls(t), c = [], l = [], f = [], p = [];
6719
6739
  for (const w of i) {
6720
6740
  const h = n[w.path];
6721
6741
  if (h === void 0) {
@@ -6734,7 +6754,7 @@ function $s(t, r, n) {
6734
6754
  path: w.path,
6735
6755
  title: b,
6736
6756
  level: v
6737
- }, S = qt(h), { macros: I, warnings: A } = Tr(S.preamble);
6757
+ }, S = Bt(h), { macros: I, warnings: A } = Tr(S.preamble);
6738
6758
  I && f.push(I), l.push(...A);
6739
6759
  const P = S.body.trim();
6740
6760
  if (!P) {
@@ -6744,7 +6764,7 @@ function $s(t, r, n) {
6744
6764
  continue;
6745
6765
  }
6746
6766
  p.push(
6747
- zs(P, v) ? P : `\\${v}{${b}}
6767
+ Ds(P, v) ? P : `\\${v}{${b}}
6748
6768
 
6749
6769
  ${P}`
6750
6770
  ), c.push(x), l.push(
@@ -6764,7 +6784,7 @@ ${P}`
6764
6784
  `),
6765
6785
  vr,
6766
6786
  g,
6767
- Rs
6787
+ zs
6768
6788
  ].join(`
6769
6789
  `), attached: c, warnings: l } : {
6770
6790
  source: [a, ...f, g].filter(Boolean).join(`
@@ -6774,7 +6794,7 @@ ${P}`
6774
6794
  warnings: l
6775
6795
  };
6776
6796
  }
6777
- function Ls(t, r, n) {
6797
+ function js(t, r, n) {
6778
6798
  const i = r.filter((o) => o.include !== !1), e = [], a = [], s = [];
6779
6799
  for (const o of i) {
6780
6800
  const c = n[o.path];
@@ -6812,7 +6832,7 @@ ${l}`), e.push(g), a.push(
6812
6832
  warnings: a
6813
6833
  };
6814
6834
  }
6815
- const Ds = [
6835
+ const Fs = [
6816
6836
  "output",
6817
6837
  ".git",
6818
6838
  ".github/workflows/.cache",
@@ -6822,13 +6842,13 @@ const Ds = [
6822
6842
  ".venv",
6823
6843
  "__MACOSX"
6824
6844
  ];
6825
- function Ps(t, r) {
6845
+ function qs(t, r) {
6826
6846
  const n = t.toLowerCase();
6827
- return [...Ds, ...r].some(
6847
+ return [...Fs, ...r].some(
6828
6848
  (i) => i.length > 0 && n.startsWith(`${i.toLowerCase()}/`)
6829
6849
  );
6830
6850
  }
6831
- function js(t) {
6851
+ function Bs(t) {
6832
6852
  const { manifest: r, files: n, assets: i } = t, e = r.projectRoot, a = new Set(t.consumedPaths), s = [
6833
6853
  ...new Set(
6834
6854
  r.targets.map((l) => l.outputDir?.split("/")[0]).filter((l) => !!l)
@@ -6836,9 +6856,9 @@ function js(t) {
6836
6856
  ], o = { files: {}, assets: {}, skipped: [] }, c = (l, f) => {
6837
6857
  if (e && !l.startsWith(`${e}/`))
6838
6858
  return;
6839
- const p = Pa(e, l);
6859
+ const p = qa(e, l);
6840
6860
  if (!(a.has(l) || l === r.manifestPath)) {
6841
- if (Ps(p, s)) {
6861
+ if (qs(p, s)) {
6842
6862
  o.skipped.push(p);
6843
6863
  return;
6844
6864
  }
@@ -6855,7 +6875,7 @@ function js(t) {
6855
6875
  });
6856
6876
  return o;
6857
6877
  }
6858
- function Fs(t, r, n) {
6878
+ function Ns(t, r, n) {
6859
6879
  return `<?xml version="1.0" encoding="UTF-8"?>
6860
6880
  <project ptx-version="2">
6861
6881
  <targets>
@@ -6877,11 +6897,11 @@ ${t.targets.map((e) => {
6877
6897
  `;
6878
6898
  }
6879
6899
  const Qr = "external";
6880
- function qs(t, r, n) {
6900
+ function Us(t, r, n) {
6881
6901
  const i = r.replace(/\/+$/, "");
6882
6902
  return i ? `${t}${i}/${n}` : `${t}${n}`;
6883
6903
  }
6884
- function Bs(t, r, n = Qr) {
6904
+ function Ms(t, r, n = Qr) {
6885
6905
  const i = {}, e = {}, a = /* @__PURE__ */ new Set();
6886
6906
  for (const s of t) {
6887
6907
  const o = yt(s);
@@ -6893,18 +6913,18 @@ function Bs(t, r, n = Qr) {
6893
6913
  g += 1;
6894
6914
  c = `${f}-${g}${p}`;
6895
6915
  }
6896
- a.add(c), i[s] = qs(r, n, c), o in e || (e[o] = c);
6916
+ a.add(c), i[s] = Us(r, n, c), o in e || (e[o] = c);
6897
6917
  }
6898
6918
  return { pathByOriginal: i, sourceByBaseName: e };
6899
6919
  }
6900
- const Ns = ["image", "video", "audio"], Us = new RegExp(
6901
- `(<(?:${Ns.join("|")})\\b[^>]*?\\bsource\\s*=\\s*)(["'])([^"']*)\\2`,
6920
+ const Ws = ["image", "video", "audio"], Zs = new RegExp(
6921
+ `(<(?:${Ws.join("|")})\\b[^>]*?\\bsource\\s*=\\s*)(["'])([^"']*)\\2`,
6902
6922
  "g"
6903
6923
  );
6904
- function Ms(t, r) {
6924
+ function Xs(t, r) {
6905
6925
  const n = [], i = [];
6906
6926
  return { source: t.replace(
6907
- Us,
6927
+ Zs,
6908
6928
  (a, s, o, c) => {
6909
6929
  if (c === "" || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(c))
6910
6930
  return a;
@@ -6913,13 +6933,13 @@ function Ms(t, r) {
6913
6933
  }
6914
6934
  ), rewritten: n, unresolved: i };
6915
6935
  }
6916
- function Ws(t) {
6936
+ function Vs(t) {
6917
6937
  const r = lt(t, "pretext"), n = r ? r.inner : t, i = lt(n, "book") ?? lt(n, "article");
6918
6938
  return i ? i.inner : n;
6919
6939
  }
6920
- function So(t) {
6940
+ function Io(t) {
6921
6941
  function r(n, i) {
6922
- return At(n, Ot).map(
6942
+ return At(n, zt).map(
6923
6943
  (e, a) => {
6924
6944
  const s = i ? `${i}.${a}` : String(a);
6925
6945
  return {
@@ -6932,9 +6952,9 @@ function So(t) {
6932
6952
  }
6933
6953
  );
6934
6954
  }
6935
- return r(Ws(t), "");
6955
+ return r(Vs(t), "");
6936
6956
  }
6937
- function Zs(t, r) {
6957
+ function Gs(t, r) {
6938
6958
  if (r.has(t))
6939
6959
  return !0;
6940
6960
  for (const n of r)
@@ -6948,10 +6968,10 @@ function ti(t, r) {
6948
6968
  const n = new Set(r), i = [];
6949
6969
  function e(p, g, d) {
6950
6970
  const w = [];
6951
- return At(p, Ot).forEach(
6971
+ return At(p, zt).forEach(
6952
6972
  (h, v) => {
6953
6973
  const b = g ? `${g}.${v}` : String(v);
6954
- if (!Zs(b, n)) {
6974
+ if (!Gs(b, n)) {
6955
6975
  i.push(b), w.push({
6956
6976
  start: d + h.start,
6957
6977
  end: d + h.end,
@@ -6967,11 +6987,11 @@ function ti(t, r) {
6967
6987
  }
6968
6988
  const a = lt(t, "pretext"), s = a ? a.inner : t, o = a ? a.startTagEnd : 0, c = lt(s, "book") ?? lt(s, "article"), l = o + (c ? c.startTagEnd : 0), f = c ? c.inner : s;
6969
6989
  return {
6970
- source: Mt(t, e(f, "", l)),
6990
+ source: Wt(t, e(f, "", l)),
6971
6991
  removed: i
6972
6992
  };
6973
6993
  }
6974
- const Xs = /\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i, Vs = [
6994
+ const Hs = /\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i, Ys = [
6975
6995
  "tex",
6976
6996
  "md",
6977
6997
  "markdown",
@@ -6985,7 +7005,7 @@ const Xs = /\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i, Vs = [
6985
7005
  "png",
6986
7006
  "ps",
6987
7007
  "bbl"
6988
- ], Gs = /* @__PURE__ */ new Set([
7008
+ ], Js = /* @__PURE__ */ new Set([
6989
7009
  "png",
6990
7010
  "jpg",
6991
7011
  "jpeg",
@@ -6998,7 +7018,7 @@ const Xs = /\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i, Vs = [
6998
7018
  "tif",
6999
7019
  "webp",
7000
7020
  "ico"
7001
- ]), Hs = /* @__PURE__ */ new Set([
7021
+ ]), Ks = /* @__PURE__ */ new Set([
7002
7022
  "png",
7003
7023
  "jpg",
7004
7024
  "jpeg",
@@ -7014,12 +7034,12 @@ const Xs = /\.(tex|zip|md|markdown|ptx|xml|tar\.gz|tgz)$/i, Vs = [
7014
7034
  "ps"
7015
7035
  ]);
7016
7036
  function ei(t) {
7017
- return Gs.has(t.toLowerCase());
7037
+ return Js.has(t.toLowerCase());
7018
7038
  }
7019
- function Ys(t) {
7020
- return Hs.has(St(yt(t)));
7039
+ function Qs(t) {
7040
+ return Ks.has(St(yt(t)));
7021
7041
  }
7022
- function Js(t) {
7042
+ function to(t) {
7023
7043
  const r = yt(t);
7024
7044
  return St(r) === "bib" ? `source/${r}` : null;
7025
7045
  }
@@ -7029,11 +7049,11 @@ function Et(t) {
7029
7049
 
7030
7050
  `);
7031
7051
  }
7032
- function Ks(t) {
7052
+ function eo(t) {
7033
7053
  const r = t.toLowerCase();
7034
7054
  return r.endsWith(".tar.gz") || r.endsWith(".tgz") ? "tar.gz" : r.endsWith(".zip") ? "zip" : r.endsWith(".tex") ? "tex" : r.endsWith(".md") || r.endsWith(".markdown") ? "markdown" : r.endsWith(".ptx") || r.endsWith(".xml") ? "pretext" : null;
7035
7055
  }
7036
- function Qs(t) {
7056
+ function no(t) {
7037
7057
  const r = (n, i) => new TextDecoder().decode(t.slice(n, i)).split("\0")[0];
7038
7058
  return {
7039
7059
  name: r(0, 100),
@@ -7041,7 +7061,7 @@ function Qs(t) {
7041
7061
  type: r(156, 157)
7042
7062
  };
7043
7063
  }
7044
- async function to(t) {
7064
+ async function ro(t) {
7045
7065
  if (typeof DecompressionStream > "u")
7046
7066
  throw new Error("This runtime does not support gzip decompression.");
7047
7067
  const i = new ReadableStream({
@@ -7063,11 +7083,11 @@ async function to(t) {
7063
7083
  s.set(c, o), o += c.length;
7064
7084
  return s.buffer;
7065
7085
  }
7066
- function eo(t) {
7086
+ function io(t) {
7067
7087
  const r = {}, n = {};
7068
7088
  let i = 0;
7069
7089
  for (; i < t.length && !(i + 512 > t.length); ) {
7070
- const e = t.slice(i, i + 512), a = Qs(e);
7090
+ const e = t.slice(i, i + 512), a = no(e);
7071
7091
  if (!a.name)
7072
7092
  break;
7073
7093
  i += 512;
@@ -7085,8 +7105,8 @@ function eo(t) {
7085
7105
  }
7086
7106
  return { files: r, assets: n };
7087
7107
  }
7088
- async function no(t) {
7089
- const r = Ks(t.name);
7108
+ async function ao(t) {
7109
+ const r = eo(t.name);
7090
7110
  if (!r)
7091
7111
  throw new Error(
7092
7112
  "File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz."
@@ -7099,7 +7119,7 @@ async function no(t) {
7099
7119
  };
7100
7120
  }
7101
7121
  if (r === "zip") {
7102
- const a = await new Da().loadAsync(t), s = {}, o = {};
7122
+ const a = await new Fa().loadAsync(t), s = {}, o = {};
7103
7123
  for (const [c, l] of Object.entries(a.files)) {
7104
7124
  if (l.dir)
7105
7125
  continue;
@@ -7113,12 +7133,12 @@ async function no(t) {
7113
7133
  }
7114
7134
  return { files: s, assets: o };
7115
7135
  }
7116
- const n = await t.arrayBuffer(), i = await to(n);
7117
- return eo(new Uint8Array(i));
7136
+ const n = await t.arrayBuffer(), i = await ro(n);
7137
+ return io(new Uint8Array(i));
7118
7138
  }
7119
- function ro(t) {
7139
+ function so(t) {
7120
7140
  const r = { other: 0 };
7121
- for (const n of Vs)
7141
+ for (const n of Ys)
7122
7142
  r[n] = 0;
7123
7143
  for (const n of Object.keys(t)) {
7124
7144
  const i = St(n);
@@ -7126,32 +7146,32 @@ function ro(t) {
7126
7146
  }
7127
7147
  return r;
7128
7148
  }
7129
- function io(t, r) {
7130
- const n = ro(r);
7149
+ function oo(t, r) {
7150
+ const n = so(r);
7131
7151
  t.push({ type: "success", message: "File types:" });
7132
7152
  for (const i of Object.keys(n).sort())
7133
7153
  n[i] && t.push({ type: "success", message: `${i}: ${n[i]}` });
7134
7154
  }
7135
- function ao(t) {
7155
+ function co(t) {
7136
7156
  return t === "latex" ? "tex" : t === "markdown" ? "markdown" : "pretext";
7137
7157
  }
7138
- function so(t, r) {
7158
+ function lo(t, r) {
7139
7159
  return t.targets.find(
7140
7160
  (n) => n.source === r
7141
7161
  );
7142
7162
  }
7143
- function oo(t, r) {
7163
+ function uo(t, r) {
7144
7164
  return t === !1 ? [] : Array.isArray(t) ? t.filter((n) => n.include !== !1) : r.extraRoots.map((n) => ({ path: n.path }));
7145
7165
  }
7146
- function co(t) {
7166
+ function fo(t) {
7147
7167
  if (t.reason === "manifest-target") {
7148
7168
  const r = t.targetName ? ` (target \`${t.targetName}\`)` : "";
7149
7169
  return `Main source file: ${t.path}${r}`;
7150
7170
  }
7151
7171
  return `Main source file: ${t.path}`;
7152
7172
  }
7153
- function lo(t, r = {}) {
7154
- const n = [], i = r.destination ?? rs;
7173
+ function ho(t, r = {}) {
7174
+ const n = [], i = r.destination ?? ss;
7155
7175
  let e = [];
7156
7176
  try {
7157
7177
  const a = Object.fromEntries(
@@ -7163,14 +7183,14 @@ function lo(t, r = {}) {
7163
7183
  n.push({
7164
7184
  type: "success",
7165
7185
  message: `Found ${s} file${s === 1 ? "" : "s"}.`
7166
- }), io(n, a);
7167
- const o = Ts(a, {
7186
+ }), oo(n, a);
7187
+ const o = Os(a, {
7168
7188
  sourceFormat: r.sourceFormat,
7169
7189
  mainFile: r.mainFile ? mt(r.mainFile) : void 0
7170
7190
  }), c = o.primary;
7171
7191
  if (!c)
7172
7192
  throw new Error("No files were found in the uploaded source.");
7173
- const l = c.path, f = ao(c.format);
7193
+ const l = c.path, f = co(c.format);
7174
7194
  let p = a[l] ?? "";
7175
7195
  const g = /* @__PURE__ */ new Set([l]);
7176
7196
  if (o.manifest) {
@@ -7180,7 +7200,7 @@ function lo(t, r = {}) {
7180
7200
  message: `Found ${o.manifest.manifestPath} with ${Q} target${Q === 1 ? "" : "s"}: ${o.manifest.targets.map((Y) => Y.name).join(", ")}.`
7181
7201
  });
7182
7202
  }
7183
- const d = oo(r.attachRoots, o);
7203
+ const d = uo(r.attachRoots, o);
7184
7204
  let w = [];
7185
7205
  const h = [], v = [];
7186
7206
  if (c.format === "latex") {
@@ -7210,12 +7230,12 @@ function lo(t, r = {}) {
7210
7230
  (u) => g.add(u)
7211
7231
  ), g.add(st.path);
7212
7232
  }
7213
- const ct = $s(p, d, rt);
7233
+ const ct = Ps(p, d, rt);
7214
7234
  p = Et(ct.source), w = ct.attached, h.push(...ct.warnings);
7215
7235
  }
7216
7236
  } else if (c.format === "markdown") {
7217
7237
  if (d.length > 0) {
7218
- const Q = Ls(
7238
+ const Q = js(
7219
7239
  p,
7220
7240
  d,
7221
7241
  a
@@ -7228,7 +7248,7 @@ function lo(t, r = {}) {
7228
7248
  const ct = St(rt);
7229
7249
  return ct === "ptx" || ct === "xml";
7230
7250
  })
7231
- ), Y = qa(p, l, Q);
7251
+ ), Y = Ua(p, l, Q);
7232
7252
  p = Y.expandedText, Y.consumedPaths.forEach((rt) => g.add(rt)), Y.expandedCount > 0 && n.push({
7233
7253
  type: "success",
7234
7254
  message: `Expanded ${Y.expandedCount} xi:include reference${Y.expandedCount === 1 ? "" : "s"}.`
@@ -7246,13 +7266,17 @@ function lo(t, r = {}) {
7246
7266
  message: `Missing xi:include targets: ${Y.missingIncludes.join(", ")}. This content is missing from the import.`
7247
7267
  }));
7248
7268
  }
7249
- n.push({ type: "success", message: co(c) });
7269
+ n.push({ type: "success", message: fo(c) });
7250
7270
  for (const Q of w)
7251
7271
  n.push({
7252
7272
  type: "success",
7253
7273
  message: `Attached ${Q.path} as a ${Q.level}: ${Q.title}`
7254
7274
  });
7255
- const b = Oa(p, c.format);
7275
+ const b = La(
7276
+ p,
7277
+ c.format,
7278
+ r.documentKind
7279
+ );
7256
7280
  if ("pretextError" in b)
7257
7281
  return {
7258
7282
  pretextError: b.pretextError,
@@ -7267,7 +7291,7 @@ function lo(t, r = {}) {
7267
7291
  buildLayout: x = !0,
7268
7292
  assets: S = {},
7269
7293
  ...I
7270
- } = r, A = o.manifest, P = A && c.reason === "manifest-target" ? so(
7294
+ } = r, A = o.manifest, P = A && c.reason === "manifest-target" ? lo(
7271
7295
  A,
7272
7296
  c.path.slice(
7273
7297
  A.projectRoot ? A.projectRoot.length + 1 : 0
@@ -7280,7 +7304,7 @@ function lo(t, r = {}) {
7280
7304
  }, $ = {}, W = {}, J = {}, k = r.externalDir ?? Qr;
7281
7305
  let D;
7282
7306
  if (L && A && P) {
7283
- const Q = js({
7307
+ const Q = Bs({
7284
7308
  manifest: A,
7285
7309
  target: P,
7286
7310
  files: a,
@@ -7298,9 +7322,9 @@ function lo(t, r = {}) {
7298
7322
  message: `Skipped build output: ${Q.skipped.length} file${Q.skipped.length === 1 ? "" : "s"}.`
7299
7323
  });
7300
7324
  } else {
7301
- D = Bs(
7302
- Object.keys(S).filter(Ys),
7303
- fo(B.mainSourcePath),
7325
+ D = Ms(
7326
+ Object.keys(S).filter(Qs),
7327
+ mo(B.mainSourcePath),
7304
7328
  k
7305
7329
  );
7306
7330
  for (const [Q, Y] of Object.entries(
@@ -7308,13 +7332,13 @@ function lo(t, r = {}) {
7308
7332
  ))
7309
7333
  $[Y] = S[Q], W[Q] = S[Q];
7310
7334
  }
7311
- const m = I.documentKind ?? zr(b.pretextSource), F = D ? Ms(b.pretextSource, D.sourceByBaseName) : void 0, it = F?.source ?? b.pretextSource, U = ti(it, r.selection), nt = i.kind === "insert" ? Yr(U.source, i, {
7335
+ const m = I.documentKind ?? zr(b.pretextSource), F = D ? Xs(b.pretextSource, D.sourceByBaseName) : void 0, it = F?.source ?? b.pretextSource, U = ti(it, r.selection), nt = i.kind === "insert" ? Yr(U.source, i, {
7312
7336
  hasSelection: (r.selection?.length ?? 0) > 0
7313
7337
  }) : void 0, M = nt?.source ?? U.source, et = [
7314
7338
  ...ni(U),
7315
7339
  ...nt?.warnings ?? []
7316
7340
  ], O = x ? Math.max(
7317
- uo(I, {
7341
+ po(I, {
7318
7342
  format: b.sourceFormat,
7319
7343
  latexSource: b.cleanedNativeSource,
7320
7344
  documentKind: m
@@ -7338,21 +7362,21 @@ function lo(t, r = {}) {
7338
7362
  },
7339
7363
  unwrapRoot: nt?.unwrapRoot
7340
7364
  });
7341
- e = Q.includes, Object.assign(J, Q.files), i.kind === "project" && L && A && P && (J[B.projectFilePath] = Fs(A, P, {
7365
+ e = Q.includes, Object.assign(J, Q.files), i.kind === "project" && L && A && P && (J[B.projectFilePath] = Ns(A, P, {
7342
7366
  mainSource: B.mainSourcePath,
7343
7367
  publication: B.publicationPath
7344
7368
  }), B.publicationPath in J || (J[B.publicationPath] = kr()));
7345
7369
  } else
7346
7370
  J["source/main.ptx"] = b.pretextSource;
7347
7371
  for (const [Q, Y] of Object.entries(a)) {
7348
- const rt = Js(Q);
7372
+ const rt = to(Q);
7349
7373
  rt && !(rt in J) && (J[rt] = Y);
7350
7374
  }
7351
7375
  const K = C.project.documentKind, G = [
7352
7376
  ...b.warnings,
7353
7377
  ...h,
7354
7378
  ...v,
7355
- ...ho(F),
7379
+ ...go(F),
7356
7380
  ...et,
7357
7381
  ...C.warnings
7358
7382
  ];
@@ -7416,9 +7440,9 @@ function lo(t, r = {}) {
7416
7440
  };
7417
7441
  }
7418
7442
  }
7419
- async function Eo(t, r = {}) {
7443
+ async function To(t, r = {}) {
7420
7444
  const n = [], i = mt(t.name);
7421
- if (!Xs.test(i.toLowerCase()))
7445
+ if (!Hs.test(i.toLowerCase()))
7422
7446
  return {
7423
7447
  pretextError: "File format not supported: please upload .tex, .md, .ptx, .xml, .zip, or .tar.gz.",
7424
7448
  statusMessages: [
@@ -7434,7 +7458,7 @@ async function Eo(t, r = {}) {
7434
7458
  message: `Processing ${i}...`
7435
7459
  });
7436
7460
  try {
7437
- const { files: e, assets: a } = await no(t), s = lo(e, { ...r, assets: a });
7461
+ const { files: e, assets: a } = await ao(t), s = ho(e, { ...r, assets: a });
7438
7462
  return {
7439
7463
  ...s,
7440
7464
  statusMessages: [...n, ...s.statusMessages]
@@ -7448,17 +7472,17 @@ async function Eo(t, r = {}) {
7448
7472
  };
7449
7473
  }
7450
7474
  }
7451
- function uo(t, r) {
7452
- return t.splitLevel !== void 0 ? Math.max(0, t.splitLevel) : t.splitChapters === !1 ? 0 : t.splitSections ? r.documentKind === "book" ? 2 : 1 : t.splitChapters ? 1 : r.format === "latex" && r.latexSource ? pa(
7475
+ function po(t, r) {
7476
+ return t.splitLevel !== void 0 ? Math.max(0, t.splitLevel) : t.splitChapters === !1 || r.documentKind === "slideshow" ? 0 : t.splitSections ? r.documentKind === "book" ? 2 : 1 : t.splitChapters ? 1 : r.format === "latex" && r.latexSource ? pa(
7453
7477
  r.latexSource,
7454
7478
  r.documentKind ?? (r.latexSource.includes("\\chapter") ? "book" : "article")
7455
7479
  ) : r.documentKind === "book" ? 1 : 0;
7456
7480
  }
7457
- function fo(t) {
7481
+ function mo(t) {
7458
7482
  const r = t.lastIndexOf("/");
7459
7483
  return r < 0 ? "" : t.slice(0, r + 1);
7460
7484
  }
7461
- function ho(t) {
7485
+ function go(t) {
7462
7486
  if (!t || t.unresolved.length === 0)
7463
7487
  return [];
7464
7488
  const r = [...new Set(t.unresolved)];
@@ -7504,7 +7528,7 @@ function en(t, r = {}) {
7504
7528
  }), f = {};
7505
7529
  if (n.kind === "project")
7506
7530
  for (const [v, b] of Object.entries(t.outputFiles))
7507
- po(v, t.projectLayout.mainSourcePath) || (f[v] = b);
7531
+ bo(v, t.projectLayout.mainSourcePath) || (f[v] = b);
7508
7532
  const p = Xr(l.project, n, {
7509
7533
  layout: {
7510
7534
  mainSourcePath: t.projectLayout.mainSourcePath,
@@ -7553,97 +7577,97 @@ function en(t, r = {}) {
7553
7577
  } : t.insert
7554
7578
  };
7555
7579
  }
7556
- function Ao(t, r) {
7580
+ function Ro(t, r) {
7557
7581
  return en(t, { selection: r });
7558
7582
  }
7559
- function Io(t, r) {
7583
+ function Co(t, r) {
7560
7584
  return en(t, { splitLevel: r });
7561
7585
  }
7562
- function To(t, r) {
7586
+ function Oo(t, r) {
7563
7587
  return en(t, { targetTag: r });
7564
7588
  }
7565
- function po(t, r) {
7589
+ function bo(t, r) {
7566
7590
  if (t === r) return !0;
7567
7591
  const n = r.includes("/") ? r.slice(0, r.lastIndexOf("/") + 1) : "";
7568
7592
  return t.startsWith(n) && t.endsWith(".ptx");
7569
7593
  }
7570
7594
  export {
7571
- Ut as $,
7572
- _o as A,
7595
+ Mt as $,
7596
+ ko as A,
7573
7597
  va as B,
7574
7598
  qi as C,
7575
- Nt as D,
7599
+ Ut as D,
7576
7600
  Ne as E,
7577
- Ta as F,
7578
- Ra as G,
7579
- Oa as H,
7580
- os as I,
7581
- Os as J,
7582
- bs as K,
7601
+ Oa as F,
7602
+ za as G,
7603
+ La as H,
7604
+ us as I,
7605
+ Ls as J,
7606
+ _s as K,
7583
7607
  Dr as L,
7584
7608
  ui as M,
7585
7609
  ge as N,
7586
7610
  le as O,
7587
- Na as P,
7611
+ Wa as P,
7588
7612
  Le as Q,
7589
- qa as R,
7613
+ Ua as R,
7590
7614
  Je as S,
7591
- jt as T,
7615
+ Ft as T,
7592
7616
  We as U,
7593
- gs as V,
7617
+ ws as V,
7594
7618
  Ir as W,
7595
- Ca as X,
7596
- vo as Y,
7597
- Eo as Z,
7598
- Ot as _,
7619
+ $a as X,
7620
+ yo as Y,
7621
+ To as Z,
7622
+ zt as _,
7599
7623
  kr as a,
7600
7624
  Ze as a0,
7601
- wo as a1,
7602
- yo as a2,
7625
+ xo as a1,
7626
+ So as a2,
7603
7627
  Xe as a3,
7604
- So as a4,
7628
+ Io as a4,
7605
7629
  Er as a5,
7606
- ms as a6,
7630
+ vs as a6,
7607
7631
  Yr as a7,
7608
7632
  ti as a8,
7609
7633
  en as a9,
7610
- Io as aa,
7611
- Fs as ab,
7612
- Ao as ac,
7613
- uo as ad,
7634
+ Co as aa,
7635
+ Ns as ab,
7636
+ Ro as ac,
7637
+ po as ad,
7614
7638
  Pr as ae,
7615
- ko as af,
7639
+ Ao as af,
7616
7640
  Vr as ag,
7617
- To as ah,
7618
- Wt as ai,
7641
+ Oo as ah,
7642
+ Zt as ai,
7619
7643
  Xr as aj,
7620
- ns as ak,
7621
- Qa as al,
7622
- Xa as am,
7644
+ as as ak,
7645
+ ns as al,
7646
+ Ha as am,
7623
7647
  pa as an,
7624
- Jt as b,
7648
+ It as b,
7625
7649
  Cr as c,
7626
7650
  zr as d,
7627
7651
  ze as e,
7628
7652
  At as f,
7629
7653
  Me as g,
7630
- no as h,
7631
- es as i,
7632
- Ts as j,
7633
- lo as k,
7654
+ ao as h,
7655
+ is as i,
7656
+ Os as j,
7657
+ ho as k,
7634
7658
  Sr as l,
7635
7659
  li as m,
7636
7660
  ha as n,
7637
- xo as o,
7661
+ Eo as o,
7638
7662
  ue as p,
7639
- rs as q,
7663
+ ss as q,
7640
7664
  ia as r,
7641
- Mt as s,
7665
+ Wt as s,
7642
7666
  Ji as t,
7643
- $s as u,
7644
- Ls as v,
7667
+ Ps as u,
7668
+ js as v,
7645
7669
  $e as w,
7646
7670
  Nr as x,
7647
7671
  Ur as y,
7648
- js as z
7672
+ Bs as z
7649
7673
  };