@pretextbook/import 0.8.0 → 0.10.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.
Files changed (48) hide show
  1. package/README.md +37 -0
  2. package/dist/convert-worker.cjs +1 -1
  3. package/dist/convert-worker.js +1 -1
  4. package/dist/import-mode-CV7gCDzF.cjs +3 -0
  5. package/dist/import-mode-DQ8g5P8P.js +122 -0
  6. package/dist/import.css +1 -1
  7. package/dist/index.cjs +3 -3
  8. package/dist/index.d.ts +10 -6
  9. package/dist/index.js +524 -214
  10. package/dist/lib/assets/images.d.ts +49 -0
  11. package/dist/lib/detect-snippet-format.d.ts +32 -0
  12. package/dist/lib/import-mode.d.ts +22 -0
  13. package/dist/lib/insert/dedupe-ids.d.ts +36 -0
  14. package/dist/lib/insert/destination.d.ts +21 -0
  15. package/dist/lib/insert/index.d.ts +4 -0
  16. package/dist/lib/insert/prepare.d.ts +44 -0
  17. package/dist/lib/insert/retarget.d.ts +35 -0
  18. package/dist/lib/layout/xml-scan.d.ts +28 -0
  19. package/dist/lib/pandoc/formats.d.ts +40 -0
  20. package/dist/lib/pandoc/index.d.ts +3 -0
  21. package/dist/lib/pandoc/pandoc-engine.d.ts +24 -0
  22. package/dist/lib/pandoc/remote-pandoc.d.ts +74 -0
  23. package/dist/lib/pool/division-pool.d.ts +5 -0
  24. package/dist/lib/pool/index.d.ts +5 -1
  25. package/dist/lib/pool/place-divisions.d.ts +25 -0
  26. package/dist/lib/pool/placeholders.d.ts +4 -0
  27. package/dist/lib/pool/refs.d.ts +8 -0
  28. package/dist/lib/pool/serialize-destination.d.ts +24 -0
  29. package/dist/lib/pool/serialize-files.d.ts +1 -2
  30. package/dist/lib/pool/serialize-insert-records.d.ts +22 -0
  31. package/dist/lib/pool/serialize-insert.d.ts +44 -0
  32. package/dist/lib/pool/serialize-plus.d.ts +4 -4
  33. package/dist/lib/pool/serialize-records.d.ts +11 -0
  34. package/dist/lib/pretext-divisions.d.ts +25 -0
  35. package/dist/lib/select/divisions.d.ts +44 -0
  36. package/dist/lib/types.d.ts +82 -2
  37. package/dist/lib/upload.d.ts +56 -4
  38. package/dist/react/import-wizard.d.ts +45 -1
  39. package/dist/react/index.d.ts +1 -1
  40. package/dist/react.cjs +2 -2
  41. package/dist/react.js +655 -498
  42. package/dist/upload-BnRj1gU1.cjs +135 -0
  43. package/dist/upload-H_OCZBBn.js +7648 -0
  44. package/package.json +1 -1
  45. package/dist/import-mode-BCGuSwkM.js +0 -112
  46. package/dist/import-mode-D1gOJw3N.cjs +0 -3
  47. package/dist/upload-BmErkg8I.js +0 -7140
  48. package/dist/upload-BtS22hIH.cjs +0 -135
package/dist/react.js CHANGED
@@ -1,150 +1,150 @@
1
- import Te, { useState as h, useRef as ue, useEffect as ke, useMemo as ae } from "react";
2
- import { S as Ne, $ as Se, j as Pe, T as Ce, g as Re, h as ye, E as _e, A as Ae } from "./upload-BmErkg8I.js";
3
- import { f as Fe, e as he } from "./import-mode-BCGuSwkM.js";
4
- var de = { exports: {} }, re = {};
5
- var be;
6
- function Oe() {
7
- if (be) return re;
8
- be = 1;
9
- var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.fragment");
10
- function x(b, g, c) {
11
- var v = null;
12
- if (c !== void 0 && (v = "" + c), g.key !== void 0 && (v = "" + g.key), "key" in g) {
1
+ import Be, { useState as g, useRef as pe, useEffect as We, useMemo as K } from "react";
2
+ import { Y as Fe, a8 as Ke, a3 as Ve, D as qe, m as Ge, j as Je, g as He, h as De, K as Ze, G as Qe } from "./upload-H_OCZBBn.js";
3
+ import { D as et, f as tt, h as Se, r as st, e as Pe } from "./import-mode-DQ8g5P8P.js";
4
+ var xe = { exports: {} }, ae = {};
5
+ var Ce;
6
+ function rt() {
7
+ if (Ce) return ae;
8
+ Ce = 1;
9
+ var r = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function d(u, x, c) {
11
+ var N = null;
12
+ if (c !== void 0 && (N = "" + c), x.key !== void 0 && (N = "" + x.key), "key" in x) {
13
13
  c = {};
14
- for (var N in g)
15
- N !== "key" && (c[N] = g[N]);
16
- } else c = g;
17
- return g = c.ref, {
18
- $$typeof: s,
19
- type: b,
20
- key: v,
21
- ref: g !== void 0 ? g : null,
14
+ for (var C in x)
15
+ C !== "key" && (c[C] = x[C]);
16
+ } else c = x;
17
+ return x = c.ref, {
18
+ $$typeof: r,
19
+ type: u,
20
+ key: N,
21
+ ref: x !== void 0 ? x : null,
22
22
  props: c
23
23
  };
24
24
  }
25
- return re.Fragment = d, re.jsx = x, re.jsxs = x, re;
25
+ return ae.Fragment = o, ae.jsx = d, ae.jsxs = d, ae;
26
26
  }
27
- var se = {};
28
- var ge;
29
- function Le() {
30
- return ge || (ge = 1, process.env.NODE_ENV !== "production" && (function() {
31
- function s(t) {
27
+ var le = {};
28
+ var Re;
29
+ function nt() {
30
+ return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
31
+ function r(t) {
32
32
  if (t == null) return null;
33
33
  if (typeof t == "function")
34
- return t.$$typeof === Y ? null : t.displayName || t.name || null;
34
+ return t.$$typeof === fe ? null : t.displayName || t.name || null;
35
35
  if (typeof t == "string") return t;
36
36
  switch (t) {
37
- case L:
37
+ case Y:
38
38
  return "Fragment";
39
- case W:
39
+ case z:
40
40
  return "Profiler";
41
- case P:
41
+ case R:
42
42
  return "StrictMode";
43
- case ne:
43
+ case ee:
44
44
  return "Suspense";
45
- case me:
45
+ case oe:
46
46
  return "SuspenseList";
47
- case le:
47
+ case he:
48
48
  return "Activity";
49
49
  }
50
50
  if (typeof t == "object")
51
51
  switch (typeof t.tag == "number" && console.error(
52
52
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
53
53
  ), t.$$typeof) {
54
- case A:
54
+ case D:
55
55
  return "Portal";
56
- case S:
56
+ case _:
57
57
  return t.displayName || "Context";
58
- case p:
58
+ case j:
59
59
  return (t._context.displayName || "Context") + ".Consumer";
60
- case F:
61
- var a = t.render;
62
- return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
63
- case H:
64
- return a = t.displayName || null, a !== null ? a : s(t.type) || "Memo";
65
- case z:
66
- a = t._payload, t = t._init;
60
+ case A:
61
+ var l = t.render;
62
+ return t = t.displayName, t || (t = l.displayName || l.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
63
+ case ce:
64
+ return l = t.displayName || null, l !== null ? l : r(t.type) || "Memo";
65
+ case V:
66
+ l = t._payload, t = t._init;
67
67
  try {
68
- return s(t(a));
68
+ return r(t(l));
69
69
  } catch {
70
70
  }
71
71
  }
72
72
  return null;
73
73
  }
74
- function d(t) {
74
+ function o(t) {
75
75
  return "" + t;
76
76
  }
77
- function x(t) {
77
+ function d(t) {
78
78
  try {
79
- d(t);
80
- var a = !1;
79
+ o(t);
80
+ var l = !1;
81
81
  } catch {
82
- a = !0;
82
+ l = !0;
83
83
  }
84
- if (a) {
85
- a = console;
86
- var m = a.error, u = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
87
- return m.call(
88
- a,
84
+ if (l) {
85
+ l = console;
86
+ var h = l.error, f = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
87
+ return h.call(
88
+ l,
89
89
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
90
- u
91
- ), d(t);
90
+ f
91
+ ), o(t);
92
92
  }
93
93
  }
94
- function b(t) {
95
- if (t === L) return "<>";
96
- if (typeof t == "object" && t !== null && t.$$typeof === z)
94
+ function u(t) {
95
+ if (t === Y) return "<>";
96
+ if (typeof t == "object" && t !== null && t.$$typeof === V)
97
97
  return "<...>";
98
98
  try {
99
- var a = s(t);
100
- return a ? "<" + a + ">" : "<...>";
99
+ var l = r(t);
100
+ return l ? "<" + l + ">" : "<...>";
101
101
  } catch {
102
102
  return "<...>";
103
103
  }
104
104
  }
105
- function g() {
106
- var t = K.A;
105
+ function x() {
106
+ var t = q.A;
107
107
  return t === null ? null : t.getOwner();
108
108
  }
109
109
  function c() {
110
110
  return Error("react-stack-top-frame");
111
111
  }
112
- function v(t) {
113
- if (Z.call(t, "key")) {
114
- var a = Object.getOwnPropertyDescriptor(t, "key").get;
115
- if (a && a.isReactWarning) return !1;
112
+ function N(t) {
113
+ if (B.call(t, "key")) {
114
+ var l = Object.getOwnPropertyDescriptor(t, "key").get;
115
+ if (l && l.isReactWarning) return !1;
116
116
  }
117
117
  return t.key !== void 0;
118
118
  }
119
- function N(t, a) {
120
- function m() {
121
- D || (D = !0, console.error(
119
+ function C(t, l) {
120
+ function h() {
121
+ G || (G = !0, console.error(
122
122
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
123
- a
123
+ l
124
124
  ));
125
125
  }
126
- m.isReactWarning = !0, Object.defineProperty(t, "key", {
127
- get: m,
126
+ h.isReactWarning = !0, Object.defineProperty(t, "key", {
127
+ get: h,
128
128
  configurable: !0
129
129
  });
130
130
  }
131
- function f() {
132
- var t = s(this.type);
133
- return q[t] || (q[t] = !0, console.error(
131
+ function p() {
132
+ var t = r(this.type);
133
+ return J[t] || (J[t] = !0, console.error(
134
134
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
135
135
  )), t = this.props.ref, t !== void 0 ? t : null;
136
136
  }
137
- function _(t, a, m, u, $, V) {
138
- var j = m.ref;
137
+ function S(t, l, h, f, X, H) {
138
+ var b = h.ref;
139
139
  return t = {
140
- $$typeof: k,
140
+ $$typeof: P,
141
141
  type: t,
142
- key: a,
143
- props: m,
144
- _owner: u
145
- }, (j !== void 0 ? j : null) !== null ? Object.defineProperty(t, "ref", {
142
+ key: l,
143
+ props: h,
144
+ _owner: f
145
+ }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(t, "ref", {
146
146
  enumerable: !1,
147
- get: f
147
+ get: p
148
148
  }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
149
149
  configurable: !1,
150
150
  enumerable: !1,
@@ -159,125 +159,125 @@ function Le() {
159
159
  configurable: !1,
160
160
  enumerable: !1,
161
161
  writable: !0,
162
- value: $
162
+ value: X
163
163
  }), Object.defineProperty(t, "_debugTask", {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
- value: V
167
+ value: H
168
168
  }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
169
169
  }
170
- function w(t, a, m, u, $, V) {
171
- var j = a.children;
172
- if (j !== void 0)
173
- if (u)
174
- if (Q(j)) {
175
- for (u = 0; u < j.length; u++)
176
- R(j[u]);
177
- Object.freeze && Object.freeze(j);
170
+ function T(t, l, h, f, X, H) {
171
+ var b = l.children;
172
+ if (b !== void 0)
173
+ if (f)
174
+ if (ie(b)) {
175
+ for (f = 0; f < b.length; f++)
176
+ y(b[f]);
177
+ Object.freeze && Object.freeze(b);
178
178
  } else
179
179
  console.error(
180
180
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
181
181
  );
182
- else R(j);
183
- if (Z.call(a, "key")) {
184
- j = s(t);
185
- var M = Object.keys(a).filter(function(te) {
186
- return te !== "key";
182
+ else y(b);
183
+ if (B.call(l, "key")) {
184
+ b = r(t);
185
+ var E = Object.keys(l).filter(function(O) {
186
+ return O !== "key";
187
187
  });
188
- u = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", C[j + u] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ f = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", re[b + f] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
189
189
  `A props object containing a "key" prop is being spread into JSX:
190
190
  let props = %s;
191
191
  <%s {...props} />
192
192
  React keys must be passed directly to JSX without using spread:
193
193
  let props = %s;
194
194
  <%s key={someKey} {...props} />`,
195
- u,
196
- j,
197
- M,
198
- j
199
- ), C[j + u] = !0);
195
+ f,
196
+ b,
197
+ E,
198
+ b
199
+ ), re[b + f] = !0);
200
200
  }
201
- if (j = null, m !== void 0 && (x(m), j = "" + m), v(a) && (x(a.key), j = "" + a.key), "key" in a) {
202
- m = {};
203
- for (var G in a)
204
- G !== "key" && (m[G] = a[G]);
205
- } else m = a;
206
- return j && N(
207
- m,
201
+ if (b = null, h !== void 0 && (d(h), b = "" + h), N(l) && (d(l.key), b = "" + l.key), "key" in l) {
202
+ h = {};
203
+ for (var Z in l)
204
+ Z !== "key" && (h[Z] = l[Z]);
205
+ } else h = l;
206
+ return b && C(
207
+ h,
208
208
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
209
- ), _(
209
+ ), S(
210
210
  t,
211
- j,
212
- m,
213
- g(),
214
- $,
215
- V
211
+ b,
212
+ h,
213
+ x(),
214
+ X,
215
+ H
216
216
  );
217
217
  }
218
- function R(t) {
219
- O(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === z && (t._payload.status === "fulfilled" ? O(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
218
+ function y(t) {
219
+ v(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === V && (t._payload.status === "fulfilled" ? v(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
220
220
  }
221
- function O(t) {
222
- return typeof t == "object" && t !== null && t.$$typeof === k;
221
+ function v(t) {
222
+ return typeof t == "object" && t !== null && t.$$typeof === P;
223
223
  }
224
- var E = Te, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), L = /* @__PURE__ */ Symbol.for("react.fragment"), P = /* @__PURE__ */ Symbol.for("react.strict_mode"), W = /* @__PURE__ */ Symbol.for("react.profiler"), p = /* @__PURE__ */ Symbol.for("react.consumer"), S = /* @__PURE__ */ Symbol.for("react.context"), F = /* @__PURE__ */ Symbol.for("react.forward_ref"), ne = /* @__PURE__ */ Symbol.for("react.suspense"), me = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), le = /* @__PURE__ */ Symbol.for("react.activity"), Y = /* @__PURE__ */ Symbol.for("react.client.reference"), K = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, Q = Array.isArray, U = console.createTask ? console.createTask : function() {
224
+ var F = Be, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), D = /* @__PURE__ */ Symbol.for("react.portal"), Y = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), _ = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), ee = /* @__PURE__ */ Symbol.for("react.suspense"), oe = /* @__PURE__ */ Symbol.for("react.suspense_list"), ce = /* @__PURE__ */ Symbol.for("react.memo"), V = /* @__PURE__ */ Symbol.for("react.lazy"), he = /* @__PURE__ */ Symbol.for("react.activity"), fe = /* @__PURE__ */ Symbol.for("react.client.reference"), q = F.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, ie = Array.isArray, te = console.createTask ? console.createTask : function() {
225
225
  return null;
226
226
  };
227
- E = {
227
+ F = {
228
228
  react_stack_bottom_frame: function(t) {
229
229
  return t();
230
230
  }
231
231
  };
232
- var D, q = {}, ee = E.react_stack_bottom_frame.bind(
233
- E,
232
+ var G, J = {}, se = F.react_stack_bottom_frame.bind(
233
+ F,
234
234
  c
235
- )(), I = U(b(c)), C = {};
236
- se.Fragment = L, se.jsx = function(t, a, m) {
237
- var u = 1e4 > K.recentlyCreatedOwnerStacks++;
238
- return w(
235
+ )(), M = te(u(c)), re = {};
236
+ le.Fragment = Y, le.jsx = function(t, l, h) {
237
+ var f = 1e4 > q.recentlyCreatedOwnerStacks++;
238
+ return T(
239
239
  t,
240
- a,
241
- m,
240
+ l,
241
+ h,
242
242
  !1,
243
- u ? Error("react-stack-top-frame") : ee,
244
- u ? U(b(t)) : I
243
+ f ? Error("react-stack-top-frame") : se,
244
+ f ? te(u(t)) : M
245
245
  );
246
- }, se.jsxs = function(t, a, m) {
247
- var u = 1e4 > K.recentlyCreatedOwnerStacks++;
248
- return w(
246
+ }, le.jsxs = function(t, l, h) {
247
+ var f = 1e4 > q.recentlyCreatedOwnerStacks++;
248
+ return T(
249
249
  t,
250
- a,
251
- m,
250
+ l,
251
+ h,
252
252
  !0,
253
- u ? Error("react-stack-top-frame") : ee,
254
- u ? U(b(t)) : I
253
+ f ? Error("react-stack-top-frame") : se,
254
+ f ? te(u(t)) : M
255
255
  );
256
256
  };
257
- })()), se;
257
+ })()), le;
258
258
  }
259
- var je;
260
- function De() {
261
- return je || (je = 1, process.env.NODE_ENV === "production" ? de.exports = Oe() : de.exports = Le()), de.exports;
259
+ var _e;
260
+ function at() {
261
+ return _e || (_e = 1, process.env.NODE_ENV === "production" ? xe.exports = rt() : xe.exports = nt()), xe.exports;
262
262
  }
263
- var e = De();
264
- function Ie() {
265
- const [s, d] = h(0), x = ue(Date.now());
266
- return ke(() => {
267
- const b = setInterval(() => {
268
- d(Math.floor((Date.now() - x.current) / 1e3));
263
+ var e = at();
264
+ function lt() {
265
+ const [r, o] = g(0), d = pe(Date.now());
266
+ return We(() => {
267
+ const u = setInterval(() => {
268
+ o(Math.floor((Date.now() - d.current) / 1e3));
269
269
  }, 1e3);
270
- return () => clearInterval(b);
271
- }, []), s;
270
+ return () => clearInterval(u);
271
+ }, []), r;
272
272
  }
273
- function $e(s) {
274
- return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
273
+ function ot(r) {
274
+ return `${Math.floor(r / 60)}:${String(r % 60).padStart(2, "0")}`;
275
275
  }
276
- function Me({
277
- message: s = "Processing your file…",
278
- onCancel: d
276
+ function ct({
277
+ message: r = "Processing your file…",
278
+ onCancel: o
279
279
  }) {
280
- const x = Ie();
280
+ const d = lt();
281
281
  return /* @__PURE__ */ e.jsxs(
282
282
  "div",
283
283
  {
@@ -286,14 +286,14 @@ function Me({
286
286
  "aria-live": "polite",
287
287
  children: [
288
288
  /* @__PURE__ */ e.jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-2 border-blue-700 border-t-transparent" }),
289
- /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: s }),
290
- /* @__PURE__ */ e.jsx("p", { className: "text-xs tabular-nums text-slate-500", children: $e(x) }),
291
- x >= 10 ? /* @__PURE__ */ e.jsx("p", { className: "max-w-xs text-center text-xs text-slate-500", children: "Large documents can take a while. You can keep working in other tabs." }) : null,
292
- d ? /* @__PURE__ */ e.jsx(
289
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: r }),
290
+ /* @__PURE__ */ e.jsx("p", { className: "text-xs tabular-nums text-slate-500", children: ot(d) }),
291
+ d >= 10 ? /* @__PURE__ */ e.jsx("p", { className: "max-w-xs text-center text-xs text-slate-500", children: "Large documents can take a while. You can keep working in other tabs." }) : null,
292
+ o ? /* @__PURE__ */ e.jsx(
293
293
  "button",
294
294
  {
295
295
  type: "button",
296
- onClick: d,
296
+ onClick: o,
297
297
  className: "mt-2 rounded border border-slate-300 px-3 py-1.5 text-xs font-medium text-slate-700 hover:bg-slate-50",
298
298
  children: "Cancel"
299
299
  }
@@ -302,7 +302,7 @@ function Me({
302
302
  }
303
303
  );
304
304
  }
305
- const we = [
305
+ const Oe = [
306
306
  ".tex",
307
307
  ".md",
308
308
  ".markdown",
@@ -312,185 +312,208 @@ const we = [
312
312
  ".gz",
313
313
  ".tar.gz",
314
314
  ".tgz"
315
- ], Xe = {
315
+ ], it = {
316
316
  id: "builtin",
317
317
  label: "Built-in converter",
318
318
  description: "Create a new project starting with LaTeX, Markdown, or PreTeXt files.",
319
- acceptExtensions: we,
320
- convertFile: Ne,
321
- prepare: async (s) => {
322
- const { files: d, assets: x } = await Re(s);
319
+ acceptExtensions: Oe,
320
+ convertFile: Fe,
321
+ prepare: async (r) => {
322
+ const { files: o, assets: d } = await He(r);
323
323
  return {
324
- fileName: s.name,
325
- files: d,
326
- assets: x,
327
- analysis: ye(d)
324
+ fileName: r.name,
325
+ files: o,
326
+ assets: d,
327
+ analysis: De(o)
328
328
  };
329
329
  },
330
- convertPrepared: (s, d) => Ce(s.files, {
331
- ...d,
332
- assets: s.assets
330
+ convertPrepared: (r, o) => Je(r.files, {
331
+ ...o,
332
+ assets: r.assets
333
333
  })
334
334
  };
335
- function xe() {
336
- return new Promise((s) => {
335
+ function Ne() {
336
+ return new Promise((r) => {
337
337
  if (typeof requestAnimationFrame != "function") {
338
- setTimeout(s, 0);
338
+ setTimeout(r, 0);
339
339
  return;
340
340
  }
341
- requestAnimationFrame(() => setTimeout(s, 0));
341
+ requestAnimationFrame(() => setTimeout(r, 0));
342
342
  });
343
343
  }
344
- const ve = {
344
+ const Ae = {
345
345
  pretext: "PreTeXt",
346
346
  latex: "LaTeX",
347
347
  markdown: "Markdown"
348
348
  };
349
- function ze(s) {
350
- const d = s.reason === "manifest-target" ? `project.ptx target “${s.targetName}”` : s.reason === "latex-root" ? "LaTeX document" : s.reason === "pretext-root" ? "PreTeXt document" : s.reason === "markdown-root" ? "Markdown document" : "possible document";
351
- return s.title ? `${s.title} — ${d}` : d;
349
+ function dt(r) {
350
+ const o = r.reason === "manifest-target" ? `project.ptx target “${r.targetName}”` : r.reason === "latex-root" ? "LaTeX document" : r.reason === "pretext-root" ? "PreTeXt document" : r.reason === "markdown-root" ? "Markdown document" : "possible document";
351
+ return r.title ? `${r.title} — ${o}` : o;
352
352
  }
353
- function Ye(s) {
354
- return s.candidates.filter(
355
- (x) => x.reason === "manifest-target"
356
- ).length > 1 ? !0 : s.manifest && s.primary?.reason === "manifest-target" ? !1 : s.formats.length > 1 || s.candidates.length > 1 || s.extraRoots.length > 0;
353
+ function ut(r) {
354
+ return r.candidates.filter(
355
+ (d) => d.reason === "manifest-target"
356
+ ).length > 1 ? !0 : r.manifest && r.primary?.reason === "manifest-target" ? !1 : r.formats.length > 1 || r.candidates.length > 1 || r.extraRoots.length > 0;
357
357
  }
358
- function Ge({
359
- onConfirm: s,
360
- onCancel: d,
361
- importOptions: x,
362
- defaultDocumentKind: b = "auto",
363
- engines: g
358
+ function jt({
359
+ onConfirm: r,
360
+ onCancel: o,
361
+ importOptions: d,
362
+ defaultDocumentKind: u = "auto",
363
+ defaultImportMode: x = et,
364
+ lockImportMode: c = !1,
365
+ onImportModeChange: N,
366
+ engines: C,
367
+ insertTarget: p
364
368
  }) {
365
- const c = g && g.length > 0 ? g : [Xe], v = ue(null), [N, f] = h({ name: "upload" }), [_, w] = h(!1), [R, O] = h(b), [E, k] = h(null), [A, L] = h(/* @__PURE__ */ new Set()), [P, W] = h(c[0].id), [p, S] = h("converted"), [F, ne] = h(!1), [me, H] = h(/* @__PURE__ */ new Set()), [z, le] = h(null), [Y, K] = h(
369
+ const S = C && C.length > 0 ? C : [it], T = pe(null), [y, v] = g({ name: "upload" }), [F, P] = g(!1), [D, Y] = g(u), [R, z] = g(null), [j, _] = g(null), [A, ee] = g([]), [oe, ce] = g(/* @__PURE__ */ new Set()), [V, he] = g(S[0].id), [fe, q] = g(x), [B, ie] = g(!1), [te, G] = g(/* @__PURE__ */ new Set()), [J, se] = g(null), [M, re] = g(
366
370
  "auto"
367
- ), [Z, Q] = h(null), [U, D] = h({}), [q, ee] = h(!1), I = ue(!1), C = c.find((r) => r.id === P) ?? c[0], t = C.acceptExtensions ?? we, a = N.name === "review" ? N.result : null, m = ae(
368
- () => a && E !== null ? Se(a, E) : a,
369
- [a, E]
370
- ), u = ae(
371
+ ), [t, l] = g(null), [h, f] = g({}), [X, H] = g(!1), b = pe(!1), E = S.find((n) => n.id === V) ?? S[0], Z = E.acceptExtensions ?? Oe, O = y.name === "review" ? y.result : null, de = K(
372
+ () => O && (R !== null || j !== null || A.length > 0) ? Ke(O, {
373
+ splitLevel: R ?? void 0,
374
+ targetTag: j ?? void 0,
375
+ selection: A
376
+ }) : O,
377
+ [O, R, j, A]
378
+ ), be = K(
379
+ () => O ? Ve(O.pretextSource) : [],
380
+ [O]
381
+ ), U = K(
371
382
  () => new Map(
372
- m ? Fe(m).map((r) => [r.path, r]) : []
383
+ de ? tt(de).map((n) => [n.path, n]) : []
373
384
  ),
374
- [m]
375
- ), $ = () => x ?? {
376
- documentKind: R === "auto" ? void 0 : R
377
- }, V = (r) => ye(r.files, {
378
- sourceFormat: Y === "auto" ? void 0 : Y,
379
- mainFile: Z ?? void 0
380
- }), j = (r) => {
381
- I.current = !0, C.cancel?.(), f(
382
- r ? { name: "sources", prepared: r } : { name: "upload" }
385
+ [de]
386
+ ), ye = K(
387
+ () => p ? {
388
+ kind: "insert",
389
+ targetTag: j ?? p.defaultTargetTag,
390
+ takenIds: new Set(p.takenIds),
391
+ hrefBase: p.hrefBase
392
+ } : void 0,
393
+ [p, j]
394
+ ), ge = () => ({
395
+ ...d ?? {
396
+ documentKind: D === "auto" ? void 0 : D
397
+ },
398
+ ...ye ? { destination: ye } : {},
399
+ ...p?.externalDir ? { externalDir: p.externalDir } : {}
400
+ }), we = (n) => De(n.files, {
401
+ sourceFormat: M === "auto" ? void 0 : M,
402
+ mainFile: t ?? void 0
403
+ }), $e = (n) => {
404
+ b.current = !0, E.cancel?.(), v(
405
+ n ? { name: "sources", prepared: n } : { name: "upload" }
383
406
  );
384
- }, M = async (r) => {
385
- I.current = !1, f({ name: "processing" }), await xe();
407
+ }, Me = async (n) => {
408
+ b.current = !1, v({ name: "processing" }), await Ne();
386
409
  try {
387
- const l = V(r).extraRoots.map((i) => ({
388
- path: i.path,
389
- include: U[i.path]?.include ?? !0,
390
- level: U[i.path]?.level
391
- })), y = await C.convertPrepared(r, {
392
- ...$(),
393
- sourceFormat: Y === "auto" ? void 0 : Y,
394
- mainFile: Z ?? void 0,
395
- attachRoots: l
410
+ const a = we(n).extraRoots.map((m) => ({
411
+ path: m.path,
412
+ include: h[m.path]?.include ?? !0,
413
+ level: h[m.path]?.level
414
+ })), k = await E.convertPrepared(n, {
415
+ ...ge(),
416
+ sourceFormat: M === "auto" ? void 0 : M,
417
+ mainFile: t ?? void 0,
418
+ attachRoots: a
396
419
  });
397
- "pretextError" in y ? f({ name: "error", message: y.pretextError }) : f({ name: "review", result: y });
398
- } catch (o) {
399
- if (I.current)
420
+ "pretextError" in k ? v({ name: "error", message: k.pretextError }) : v({ name: "review", result: k });
421
+ } catch (i) {
422
+ if (b.current)
400
423
  return;
401
- f({
424
+ v({
402
425
  name: "error",
403
- message: o instanceof Error ? o.message : "An unexpected error occurred."
426
+ message: i instanceof Error ? i.message : "An unexpected error occurred."
404
427
  });
405
428
  }
406
- }, G = async (r) => {
407
- I.current = !1, f({ name: "processing" }), await xe();
429
+ }, ke = async (n) => {
430
+ b.current = !1, v({ name: "processing" }), await Ne();
408
431
  try {
409
- if (C.prepare && C.convertPrepared) {
410
- const l = await C.prepare(r);
411
- if (le(l), K("auto"), Q(null), D({}), Ye(l.analysis)) {
412
- f({ name: "sources", prepared: l });
432
+ if (E.prepare && E.convertPrepared) {
433
+ const a = await E.prepare(n);
434
+ if (se(a), re("auto"), l(null), f({}), ut(a.analysis)) {
435
+ v({ name: "sources", prepared: a });
413
436
  return;
414
437
  }
415
- await xe();
416
- const y = await C.convertPrepared(
417
- l,
418
- $()
438
+ await Ne();
439
+ const k = await E.convertPrepared(
440
+ a,
441
+ ge()
419
442
  );
420
- f(
421
- "pretextError" in y ? { name: "error", message: y.pretextError } : { name: "review", result: y }
443
+ v(
444
+ "pretextError" in k ? { name: "error", message: k.pretextError } : { name: "review", result: k }
422
445
  );
423
446
  return;
424
447
  }
425
- const o = await C.convertFile(r, $());
426
- "pretextError" in o ? f({ name: "error", message: o.pretextError }) : f({ name: "review", result: o });
427
- } catch (o) {
428
- if (I.current)
448
+ const i = await E.convertFile(n, ge());
449
+ "pretextError" in i ? v({ name: "error", message: i.pretextError }) : v({ name: "review", result: i });
450
+ } catch (i) {
451
+ if (b.current)
429
452
  return;
430
- f({
453
+ v({
431
454
  name: "error",
432
- message: o instanceof Error ? o.message : "An unexpected error occurred."
455
+ message: i instanceof Error ? i.message : "An unexpected error occurred."
433
456
  });
434
457
  }
435
- }, te = () => {
436
- f({ name: "upload" }), S("converted"), ne(!1), H(/* @__PURE__ */ new Set()), L(/* @__PURE__ */ new Set()), k(null), le(null);
458
+ }, je = () => {
459
+ v({ name: "upload" }), q(x), ie(!1), G(/* @__PURE__ */ new Set()), ce(/* @__PURE__ */ new Set()), z(null), _(null), ee([]), se(null);
437
460
  };
438
- function pe(r, o) {
439
- return [...r].sort((l, y) => l === o ? -1 : y === o ? 1 : l.localeCompare(y));
461
+ function Ee(n, i) {
462
+ return [...n].sort((a, k) => a === i ? -1 : k === i ? 1 : a.localeCompare(k));
440
463
  }
441
- function fe(r, o) {
442
- const l = he(r, o), y = o === "converted" ? r.projectLayout.mainSourcePath : r.sourcePath, i = pe(Object.keys(l), y)[0];
443
- H(i ? /* @__PURE__ */ new Set([i]) : /* @__PURE__ */ new Set());
464
+ function Te(n, i) {
465
+ const a = Pe(n, i), k = i === "converted" ? n.projectLayout.mainSourcePath : n.sourcePath, m = Ee(Object.keys(a), k)[0];
466
+ G(m ? /* @__PURE__ */ new Set([m]) : /* @__PURE__ */ new Set());
444
467
  }
445
- function Ee(r) {
446
- H((o) => {
447
- const l = new Set(o);
448
- return l.has(r) ? l.delete(r) : l.add(r), l;
468
+ function Xe(n) {
469
+ G((i) => {
470
+ const a = new Set(i);
471
+ return a.has(n) ? a.delete(n) : a.add(n), a;
449
472
  });
450
473
  }
451
- if (N.name === "processing")
474
+ if (y.name === "processing")
452
475
  return /* @__PURE__ */ e.jsx(
453
- Me,
476
+ ct,
454
477
  {
455
- onCancel: C.cancel ? () => j(z) : void 0
478
+ onCancel: E.cancel ? () => $e(J) : void 0
456
479
  }
457
480
  );
458
- if (N.name === "error")
481
+ if (y.name === "error")
459
482
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
460
483
  /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800", children: [
461
484
  /* @__PURE__ */ e.jsx("p", { className: "font-semibold", children: "Import failed" }),
462
- /* @__PURE__ */ e.jsx("p", { className: "mt-1", children: N.message })
485
+ /* @__PURE__ */ e.jsx("p", { className: "mt-1", children: y.message })
463
486
  ] }),
464
487
  /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ e.jsx(
465
488
  "button",
466
489
  {
467
490
  type: "button",
468
- onClick: te,
491
+ onClick: je,
469
492
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
470
493
  children: "Try Another File"
471
494
  }
472
495
  ) })
473
496
  ] });
474
- if (N.name === "sources") {
475
- const r = N.prepared, o = V(r), l = o.manifest, y = o.primary?.path ?? "";
497
+ if (y.name === "sources") {
498
+ const n = y.prepared, i = we(n), a = i.manifest, k = i.primary?.path ?? "";
476
499
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
477
500
  /* @__PURE__ */ e.jsxs("div", { children: [
478
501
  /* @__PURE__ */ e.jsx("h3", { className: "text-sm font-semibold text-slate-700", children: "Choose what to import" }),
479
502
  /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-sm text-slate-500", children: [
480
- r.fileName,
503
+ n.fileName,
481
504
  " contains more than one possible starting point."
482
505
  ] })
483
506
  ] }),
484
- l ? /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900", children: [
507
+ a ? /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-blue-200 bg-blue-50 p-4 text-sm text-blue-900", children: [
485
508
  /* @__PURE__ */ e.jsxs("p", { className: "font-medium", children: [
486
509
  "Found ",
487
- l.manifestPath,
510
+ a.manifestPath,
488
511
  " — an existing PreTeXt project."
489
512
  ] }),
490
513
  /* @__PURE__ */ e.jsxs("p", { className: "mt-1 text-blue-800", children: [
491
514
  "Its publication file, assets, and directory layout will be kept as they are. Targets:",
492
515
  " ",
493
- l.targets.map((i) => i.name).join(", "),
516
+ a.targets.map((m) => m.name).join(", "),
494
517
  "."
495
518
  ] })
496
519
  ] }) : null,
@@ -499,24 +522,24 @@ function Ge({
499
522
  /* @__PURE__ */ e.jsxs(
500
523
  "select",
501
524
  {
502
- value: Y,
503
- onChange: (i) => {
504
- K(i.currentTarget.value), Q(null), D({});
525
+ value: M,
526
+ onChange: (m) => {
527
+ re(m.currentTarget.value), l(null), f({});
505
528
  },
506
529
  className: "rounded border border-slate-300 px-2 py-1 text-sm",
507
530
  children: [
508
531
  /* @__PURE__ */ e.jsxs("option", { value: "auto", children: [
509
532
  "Auto detect",
510
- o.primary ? ` (${ve[o.primary.format]})` : ""
533
+ i.primary ? ` (${Ae[i.primary.format]})` : ""
511
534
  ] }),
512
- o.formats.map((i) => /* @__PURE__ */ e.jsx("option", { value: i, children: ve[i] }, i))
535
+ i.formats.map((m) => /* @__PURE__ */ e.jsx("option", { value: m, children: Ae[m] }, m))
513
536
  ]
514
537
  }
515
538
  )
516
539
  ] }) }),
517
- o.candidates.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
540
+ i.candidates.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
518
541
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Main document" }),
519
- /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-2", children: o.candidates.map((i) => /* @__PURE__ */ e.jsxs(
542
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-2", children: i.candidates.map((m) => /* @__PURE__ */ e.jsxs(
520
543
  "label",
521
544
  {
522
545
  className: "flex cursor-pointer items-start gap-3 text-sm",
@@ -526,28 +549,28 @@ function Ge({
526
549
  {
527
550
  type: "radio",
528
551
  name: "main-file",
529
- value: i.path,
530
- checked: y === i.path,
552
+ value: m.path,
553
+ checked: k === m.path,
531
554
  onChange: () => {
532
- Q(i.path), D({});
555
+ l(m.path), f({});
533
556
  },
534
557
  className: "mt-0.5"
535
558
  }
536
559
  ),
537
560
  /* @__PURE__ */ e.jsxs("span", { children: [
538
- /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: i.path }),
539
- /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: ze(i) })
561
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: m.path }),
562
+ /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: dt(m) })
540
563
  ] })
541
564
  ]
542
565
  },
543
- i.path
566
+ m.path
544
567
  )) })
545
568
  ] }) : null,
546
- o.extraRoots.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
569
+ i.extraRoots.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
547
570
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Other documents" }),
548
571
  /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-sm text-slate-500", children: "These files also stand on their own. Attach them to the main document, or leave them out." }),
549
- /* @__PURE__ */ e.jsx("div", { className: "mt-3 flex flex-col gap-2", children: o.extraRoots.map((i) => {
550
- const J = U[i.path], oe = J?.include ?? !0;
572
+ /* @__PURE__ */ e.jsx("div", { className: "mt-3 flex flex-col gap-2", children: i.extraRoots.map((m) => {
573
+ const ne = h[m.path], L = ne?.include ?? !0;
551
574
  return /* @__PURE__ */ e.jsxs(
552
575
  "div",
553
576
  {
@@ -558,20 +581,20 @@ function Ge({
558
581
  "input",
559
582
  {
560
583
  type: "checkbox",
561
- checked: oe,
562
- onChange: (X) => D((B) => ({
563
- ...B,
564
- [i.path]: {
565
- ...B[i.path],
566
- include: X.currentTarget.checked
584
+ checked: L,
585
+ onChange: (W) => f((I) => ({
586
+ ...I,
587
+ [m.path]: {
588
+ ...I[m.path],
589
+ include: W.currentTarget.checked
567
590
  }
568
591
  }))
569
592
  }
570
593
  ),
571
- /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: i.path }),
572
- i.title ? /* @__PURE__ */ e.jsxs("span", { className: "text-slate-500", children: [
594
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs text-slate-900", children: m.path }),
595
+ m.title ? /* @__PURE__ */ e.jsxs("span", { className: "text-slate-500", children: [
573
596
  "— ",
574
- i.title
597
+ m.title
575
598
  ] }) : null
576
599
  ] }),
577
600
  /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
@@ -579,13 +602,13 @@ function Ge({
579
602
  /* @__PURE__ */ e.jsxs(
580
603
  "select",
581
604
  {
582
- value: J?.level ?? "auto",
583
- disabled: !oe,
584
- onChange: (X) => D((B) => ({
585
- ...B,
586
- [i.path]: {
587
- include: B[i.path]?.include ?? !0,
588
- level: X.currentTarget.value === "auto" ? void 0 : X.currentTarget.value
605
+ value: ne?.level ?? "auto",
606
+ disabled: !L,
607
+ onChange: (W) => f((I) => ({
608
+ ...I,
609
+ [m.path]: {
610
+ include: I[m.path]?.include ?? !0,
611
+ level: W.currentTarget.value === "auto" ? void 0 : W.currentTarget.value
589
612
  }
590
613
  })),
591
614
  className: "rounded border border-slate-300 px-2 py-1 text-sm disabled:opacity-50",
@@ -599,7 +622,7 @@ function Ge({
599
622
  ] })
600
623
  ]
601
624
  },
602
- i.path
625
+ m.path
603
626
  );
604
627
  }) })
605
628
  ] }) : null,
@@ -608,7 +631,7 @@ function Ge({
608
631
  "button",
609
632
  {
610
633
  type: "button",
611
- onClick: te,
634
+ onClick: je,
612
635
  className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
613
636
  children: "Start Over"
614
637
  }
@@ -617,7 +640,7 @@ function Ge({
617
640
  "button",
618
641
  {
619
642
  type: "button",
620
- onClick: () => M(r),
643
+ onClick: () => Me(n),
621
644
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
622
645
  children: "Continue"
623
646
  }
@@ -625,56 +648,63 @@ function Ge({
625
648
  ] })
626
649
  ] });
627
650
  }
628
- if (N.name === "review") {
629
- let r = function(n) {
630
- S(n), F && fe(l, n);
631
- }, o = function(n) {
632
- L((T) => {
633
- const ie = new Set(T);
634
- return ie.has(n) ? ie.delete(n) : ie.add(n), ie;
651
+ if (y.name === "review") {
652
+ let n = function(s) {
653
+ q(s), N?.(s), B && Te(a, s);
654
+ }, i = function(s) {
655
+ ce((w) => {
656
+ const Q = new Set(w);
657
+ return Q.has(s) ? Q.delete(s) : Q.add(s), Q;
635
658
  });
636
659
  };
637
- const l = m ?? N.result, y = l.splitLevel, i = l.detectedSourceFormat === "latex", J = l.warnings.length, oe = Object.keys(l.outputFiles).length, X = he(l, p), B = p === "converted" ? l.projectLayout.mainSourcePath : l.sourcePath, ce = pe(
638
- Object.keys(X),
639
- B
660
+ const a = de ?? y.result, k = a.splitLevel, m = A.length > 0, ne = Se(a) && !m, L = ne ? st(a, fe) : "converted", W = a.detectedSourceFormat === "markdown" ? "Markdown" : "LaTeX", I = a.warnings.length, Ue = Object.keys(a.outputFiles).length, $ = a.insert, ue = a.destination.kind === "insert" ? a.destination.targetTag : void 0, Ye = p?.targetTags ?? [...qe], ve = Pe(a, L), ze = L === "converted" ? a.projectLayout.mainSourcePath : a.sourcePath, me = Ee(
661
+ Object.keys(ve),
662
+ ze
640
663
  );
641
664
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
642
665
  /* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-slate-200 bg-slate-50 p-4", children: [
643
666
  /* @__PURE__ */ e.jsx("h3", { className: "mb-3 text-sm font-semibold text-slate-700", children: "Import Summary" }),
644
667
  /* @__PURE__ */ e.jsxs("dl", { className: "grid grid-cols-2 gap-x-6 gap-y-2 text-sm", children: [
645
668
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Source" }),
646
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: l.sourceName }),
669
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: a.sourceName }),
647
670
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Detected format" }),
648
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: l.detectedSourceFormat }),
671
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: a.detectedSourceFormat }),
649
672
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Document kind" }),
650
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: l.documentKind }),
673
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: a.documentKind }),
651
674
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Output files" }),
652
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: oe }),
653
- l.projectLayout.preserved ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
675
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: Ue }),
676
+ p ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
677
+ /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Destination" }),
678
+ /* @__PURE__ */ e.jsxs("dd", { className: "font-medium text-slate-900", children: [
679
+ "Inserted into ",
680
+ p.documentLabel
681
+ ] })
682
+ ] }) : null,
683
+ a.projectLayout.preserved ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
654
684
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Existing project" }),
655
685
  /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: "Kept publication file, assets, and layout" })
656
686
  ] }) : null,
657
- l.attachedRoots.length > 0 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
687
+ a.attachedRoots.length > 0 ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
658
688
  /* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Attached" }),
659
- /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: l.attachedRoots.map((n) => `${n.title} (${n.level})`).join(", ") })
689
+ /* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: a.attachedRoots.map((s) => `${s.title} (${s.level})`).join(", ") })
660
690
  ] }) : null
661
691
  ] })
662
692
  ] }),
663
- J > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
693
+ I > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
664
694
  /* @__PURE__ */ e.jsxs("summary", { className: "cursor-pointer font-semibold text-amber-800", children: [
665
- J,
695
+ I,
666
696
  " conversion",
667
697
  " ",
668
- J === 1 ? "warning" : "warnings"
698
+ I === 1 ? "warning" : "warnings"
669
699
  ] }),
670
- /* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: l.warnings.map((n, T) => /* @__PURE__ */ e.jsxs("li", { children: [
671
- /* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: n.macro }),
700
+ /* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: a.warnings.map((s, w) => /* @__PURE__ */ e.jsxs("li", { children: [
701
+ /* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: s.macro }),
672
702
  " — ",
673
- n.action === "replace" || n.action === "rewrite" ? `replaced with \`${n.replacement}\`` : n.message ?? n.action,
674
- n.occurrences > 1 ? ` (×${n.occurrences})` : null
675
- ] }, T)) })
703
+ s.action === "replace" || s.action === "rewrite" ? `replaced with \`${s.replacement}\`` : s.message ?? s.action,
704
+ s.occurrences > 1 ? ` (×${s.occurrences})` : null
705
+ ] }, w)) })
676
706
  ] }) : /* @__PURE__ */ e.jsx("p", { className: "text-sm text-green-700", children: "No conversion warnings." }),
677
- i ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
707
+ ne && !c ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
678
708
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Import mode" }),
679
709
  /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-col gap-3", children: [
680
710
  /* @__PURE__ */ e.jsxs("label", { className: "flex cursor-pointer items-start gap-3 text-sm", children: [
@@ -684,8 +714,8 @@ function Ge({
684
714
  type: "radio",
685
715
  name: "import-mode",
686
716
  value: "converted",
687
- checked: p === "converted",
688
- onChange: () => r("converted"),
717
+ checked: L === "converted",
718
+ onChange: () => n("converted"),
689
719
  className: "mt-0.5"
690
720
  }
691
721
  ),
@@ -701,52 +731,124 @@ function Ge({
701
731
  type: "radio",
702
732
  name: "import-mode",
703
733
  value: "native",
704
- checked: p === "native",
705
- onChange: () => r("native"),
734
+ checked: L === "native",
735
+ onChange: () => n("native"),
706
736
  className: "mt-0.5"
707
737
  }
708
738
  ),
709
739
  /* @__PURE__ */ e.jsxs("span", { children: [
710
- /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: "Keep as LaTeX" }),
711
- /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: "Preserve the original LaTeX source. The conversion will not be applied." })
740
+ /* @__PURE__ */ e.jsxs("span", { className: "font-medium text-slate-900", children: [
741
+ "Keep as ",
742
+ W
743
+ ] }),
744
+ /* @__PURE__ */ e.jsxs("span", { className: "block text-slate-500", children: [
745
+ "Preserve the original ",
746
+ W,
747
+ " source. The conversion will not be applied."
748
+ ] })
712
749
  ] })
713
750
  ] })
714
751
  ] })
715
752
  ] }) : null,
716
- !x && l.cleanChunks.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
753
+ be.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
754
+ /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Divisions to import" }),
755
+ /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2 text-sm", children: [
756
+ /* @__PURE__ */ e.jsx(
757
+ "button",
758
+ {
759
+ type: "button",
760
+ onClick: () => ee([]),
761
+ className: "rounded border border-slate-300 px-3 py-1 text-slate-700 hover:bg-slate-50",
762
+ children: "Everything"
763
+ }
764
+ ),
765
+ /* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: A.length === 0 ? "The whole document" : `${A.length} of ${Le(be)} divisions` })
766
+ ] }),
767
+ /* @__PURE__ */ e.jsx("div", { className: "mt-3 max-h-56 overflow-auto", children: /* @__PURE__ */ e.jsx(
768
+ Ie,
769
+ {
770
+ items: be,
771
+ selection: A,
772
+ onToggle: (s) => ee(
773
+ (w) => w.includes(s) ? w.filter((Q) => Q !== s) : [...w, s].sort(mt)
774
+ )
775
+ }
776
+ ) }),
777
+ A.length > 0 ? /* @__PURE__ */ e.jsxs("p", { className: "mt-2 text-sm text-slate-500", children: [
778
+ "A selected division is imported whole, with everything inside it. Divisions above one you selected are kept as structure.",
779
+ Se(y.result) ? " Selecting divisions imports the converted PreTeXt; keeping the original source imports the document whole." : ""
780
+ ] }) : null
781
+ ] }) : null,
782
+ $ && p ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
783
+ /* @__PURE__ */ e.jsxs("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: [
784
+ "Attach to ",
785
+ p.documentLabel
786
+ ] }),
787
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: Ye.map((s) => /* @__PURE__ */ e.jsxs(
788
+ "button",
789
+ {
790
+ type: "button",
791
+ onClick: () => _(s),
792
+ "aria-pressed": ue === s,
793
+ className: ue === s ? "rounded bg-blue-700 px-3 py-1 text-sm font-medium text-white" : "rounded border border-slate-300 px-3 py-1 text-sm text-slate-700 hover:bg-slate-50",
794
+ children: [
795
+ "<",
796
+ s,
797
+ ">"
798
+ ]
799
+ },
800
+ s
801
+ )) }),
802
+ /* @__PURE__ */ e.jsxs("p", { className: "mt-3 text-sm text-slate-600", children: [
803
+ $.includes.length === 1 ? `One <${ue}> is added to ${p.documentLabel}, ` : `${$.includes.length} <${ue}> divisions are added to ${p.documentLabel}, `,
804
+ $.includes.length === 1 ? "included from a new file beside it." : "each included from a new file beside it."
805
+ ] }),
806
+ $.renamed.length > 0 ? /* @__PURE__ */ e.jsxs("p", { className: "mt-2 text-sm text-amber-700", children: [
807
+ $.renamed.length,
808
+ " id",
809
+ $.renamed.length === 1 ? "" : "s",
810
+ " already used in this project",
811
+ " ",
812
+ $.renamed.length === 1 ? "was" : "were",
813
+ " renamed:",
814
+ " ",
815
+ /* @__PURE__ */ e.jsx("span", { className: "font-mono text-xs", children: $.renamed.map((s) => `${s.from} → ${s.to}`).join(", ") })
816
+ ] }) : null
817
+ ] }) : null,
818
+ !d && a.cleanChunks.length > 0 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
717
819
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Split into files" }),
718
820
  /* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [
719
821
  Array.from(
720
- { length: Pe + 1 },
721
- (n, T) => /* @__PURE__ */ e.jsx(
822
+ { length: Ge + 1 },
823
+ (s, w) => /* @__PURE__ */ e.jsx(
722
824
  "button",
723
825
  {
724
826
  type: "button",
725
- onClick: () => k(T),
726
- "aria-pressed": y === T,
727
- className: y === T ? "rounded bg-blue-700 px-3 py-1 text-sm font-medium text-white" : "rounded border border-slate-300 px-3 py-1 text-sm text-slate-700 hover:bg-slate-50",
728
- children: T === 0 ? "One file" : `${T} level${T === 1 ? "" : "s"}`
827
+ onClick: () => z(w),
828
+ "aria-pressed": k === w,
829
+ className: k === w ? "rounded bg-blue-700 px-3 py-1 text-sm font-medium text-white" : "rounded border border-slate-300 px-3 py-1 text-sm text-slate-700 hover:bg-slate-50",
830
+ children: w === 0 ? "One file" : `${w} level${w === 1 ? "" : "s"}`
729
831
  },
730
- T
832
+ w
731
833
  )
732
834
  ),
733
835
  /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-sm text-slate-500", children: [
734
- ce.length,
836
+ me.length,
735
837
  " file",
736
- ce.length === 1 ? "" : "s"
838
+ me.length === 1 ? "" : "s"
737
839
  ] })
738
840
  ] }),
739
- /* @__PURE__ */ e.jsx("ul", { className: "mt-3 max-h-48 overflow-auto font-mono text-xs text-slate-600", children: ce.map((n) => /* @__PURE__ */ e.jsxs("li", { className: "truncate py-0.5", children: [
740
- n,
741
- u.get(n)?.fixCount ? /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-amber-700", children: [
742
- u.get(n).fixCount,
841
+ /* @__PURE__ */ e.jsx("ul", { className: "mt-3 max-h-48 overflow-auto font-mono text-xs text-slate-600", children: me.map((s) => /* @__PURE__ */ e.jsxs("li", { className: "truncate py-0.5", children: [
842
+ s,
843
+ U.get(s)?.fixCount ? /* @__PURE__ */ e.jsxs("span", { className: "ml-2 text-amber-700", children: [
844
+ U.get(s).fixCount,
743
845
  " change",
744
- u.get(n).fixCount === 1 ? "" : "s"
846
+ U.get(s).fixCount === 1 ? "" : "s"
745
847
  ] }) : null
746
- ] }, n)) })
848
+ ] }, s)) })
747
849
  ] }) : null,
748
- F ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: ce.map((n) => {
749
- const T = me.has(n);
850
+ B ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: me.map((s) => {
851
+ const w = te.has(s);
750
852
  return /* @__PURE__ */ e.jsxs(
751
853
  "div",
752
854
  {
@@ -756,42 +858,42 @@ function Ge({
756
858
  "button",
757
859
  {
758
860
  type: "button",
759
- onClick: () => Ee(n),
861
+ onClick: () => Xe(s),
760
862
  className: "flex w-full items-center gap-2 bg-slate-100 px-4 py-2 text-left font-mono text-xs text-slate-700 hover:bg-slate-200",
761
863
  children: [
762
- /* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: T ? "▾" : "▸" }),
763
- /* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: n }),
864
+ /* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: w ? "▾" : "▸" }),
865
+ /* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: s }),
764
866
  /* @__PURE__ */ e.jsxs("span", { className: "shrink-0 text-slate-400", children: [
765
- (X[n].length / 1024).toFixed(1),
867
+ (ve[s].length / 1024).toFixed(1),
766
868
  " KB"
767
869
  ] })
768
870
  ]
769
871
  }
770
872
  ),
771
- T ? /* @__PURE__ */ e.jsxs("div", { className: "bg-white", children: [
772
- u.get(n)?.hunks.length ? /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 border-b border-slate-200 px-4 py-2", children: [
873
+ w ? /* @__PURE__ */ e.jsxs("div", { className: "bg-white", children: [
874
+ U.get(s)?.hunks.length ? /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 border-b border-slate-200 px-4 py-2", children: [
773
875
  /* @__PURE__ */ e.jsx(
774
876
  "button",
775
877
  {
776
878
  type: "button",
777
- onClick: () => o(n),
879
+ onClick: () => i(s),
778
880
  className: "rounded border border-slate-300 px-2 py-0.5 text-xs text-slate-700 hover:bg-slate-50",
779
- children: A.has(n) ? "Show converted file" : "Show what changed"
881
+ children: oe.has(s) ? "Show converted file" : "Show what changed"
780
882
  }
781
883
  ),
782
884
  /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-slate-500", children: [
783
885
  "+",
784
- u.get(n).stats.added,
886
+ U.get(s).stats.added,
785
887
  " −",
786
- u.get(n).stats.removed,
888
+ U.get(s).stats.removed,
787
889
  " in the LaTeX source"
788
890
  ] })
789
891
  ] }) : null,
790
- A.has(n) && u.has(n) ? /* @__PURE__ */ e.jsx(Ue, { hunks: u.get(n).hunks }) : /* @__PURE__ */ e.jsx("pre", { className: "m-0 max-h-72 overflow-auto p-4 font-mono text-xs leading-relaxed text-slate-800", children: X[n] })
892
+ oe.has(s) && U.has(s) ? /* @__PURE__ */ e.jsx(xt, { hunks: U.get(s).hunks }) : /* @__PURE__ */ e.jsx("pre", { className: "m-0 max-h-72 overflow-auto p-4 font-mono text-xs leading-relaxed text-slate-800", children: ve[s] })
791
893
  ] }) : null
792
894
  ]
793
895
  },
794
- n
896
+ s
795
897
  );
796
898
  }) }) : null,
797
899
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-3 pt-1", children: [
@@ -799,17 +901,17 @@ function Ge({
799
901
  "button",
800
902
  {
801
903
  type: "button",
802
- onClick: d ?? te,
904
+ onClick: o ?? je,
803
905
  className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
804
- children: d ? "Cancel" : "Start Over"
906
+ children: o ? "Cancel" : "Start Over"
805
907
  }
806
908
  ),
807
909
  /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
808
- z ? /* @__PURE__ */ e.jsx(
910
+ J ? /* @__PURE__ */ e.jsx(
809
911
  "button",
810
912
  {
811
913
  type: "button",
812
- onClick: () => f({ name: "sources", prepared: z }),
914
+ onClick: () => v({ name: "sources", prepared: J }),
813
915
  className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
814
916
  children: "Change Sources"
815
917
  }
@@ -819,29 +921,29 @@ function Ge({
819
921
  {
820
922
  type: "button",
821
923
  onClick: () => {
822
- F || fe(l, p), ne((n) => !n);
924
+ B || Te(a, L), ie((s) => !s);
823
925
  },
824
926
  className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
825
- children: F ? "Hide Preview" : "Preview"
927
+ children: B ? "Hide Preview" : "Preview"
826
928
  }
827
929
  ),
828
930
  /* @__PURE__ */ e.jsxs(
829
931
  "button",
830
932
  {
831
933
  type: "button",
832
- disabled: q,
934
+ disabled: X,
833
935
  onClick: async () => {
834
- ee(!0);
936
+ H(!0);
835
937
  try {
836
- await s(l, p);
938
+ await r(a, L);
837
939
  } finally {
838
- ee(!1);
940
+ H(!1);
839
941
  }
840
942
  },
841
943
  className: "flex items-center gap-2 rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600 disabled:opacity-60",
842
944
  children: [
843
- q ? /* @__PURE__ */ e.jsx("span", { className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-white border-t-transparent" }) : null,
844
- q ? "Importing…" : "Confirm Import"
945
+ X ? /* @__PURE__ */ e.jsx("span", { className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-white border-t-transparent" }) : null,
946
+ X ? p ? "Inserting…" : "Importing…" : p ? "Confirm Insert" : "Confirm Import"
845
947
  ]
846
948
  }
847
949
  )
@@ -850,9 +952,9 @@ function Ge({
850
952
  ] });
851
953
  }
852
954
  return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
853
- c.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
955
+ S.length > 1 ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
854
956
  /* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Converter" }),
855
- /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-3", children: c.map((r) => /* @__PURE__ */ e.jsxs(
957
+ /* @__PURE__ */ e.jsx("div", { className: "mt-2 flex flex-col gap-3", children: S.map((n) => /* @__PURE__ */ e.jsxs(
856
958
  "label",
857
959
  {
858
960
  className: "flex cursor-pointer items-start gap-3 text-sm",
@@ -862,29 +964,29 @@ function Ge({
862
964
  {
863
965
  type: "radio",
864
966
  name: "import-engine",
865
- value: r.id,
866
- checked: P === r.id,
867
- onChange: () => W(r.id),
967
+ value: n.id,
968
+ checked: V === n.id,
969
+ onChange: () => he(n.id),
868
970
  className: "mt-0.5"
869
971
  }
870
972
  ),
871
973
  /* @__PURE__ */ e.jsxs("span", { children: [
872
- /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: r.label }),
873
- r.description ? /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: r.description }) : null
974
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: n.label }),
975
+ n.description ? /* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: n.description }) : null
874
976
  ] })
875
977
  ]
876
978
  },
877
- r.id
979
+ n.id
878
980
  )) })
879
981
  ] }) : null,
880
- x ? null : /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-4 text-sm", children: /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
982
+ d ? null : /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-4 text-sm", children: /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
881
983
  /* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: "Document kind" }),
882
984
  /* @__PURE__ */ e.jsxs(
883
985
  "select",
884
986
  {
885
- value: R,
886
- onChange: (r) => O(
887
- r.currentTarget.value
987
+ value: D,
988
+ onChange: (n) => Y(
989
+ n.currentTarget.value
888
990
  ),
889
991
  className: "rounded border border-slate-300 px-2 py-1 text-sm",
890
992
  children: [
@@ -900,26 +1002,26 @@ function Ge({
900
1002
  {
901
1003
  role: "button",
902
1004
  tabIndex: 0,
903
- onKeyDown: (r) => r.key === "Enter" && v.current?.click(),
904
- onClick: () => v.current?.click(),
905
- onDragOver: (r) => {
906
- r.preventDefault(), w(!0);
1005
+ onKeyDown: (n) => n.key === "Enter" && T.current?.click(),
1006
+ onClick: () => T.current?.click(),
1007
+ onDragOver: (n) => {
1008
+ n.preventDefault(), P(!0);
907
1009
  },
908
- onDragLeave: () => w(!1),
909
- onDrop: (r) => {
910
- r.preventDefault(), w(!1);
911
- const o = r.dataTransfer.files?.[0];
912
- o && G(o);
1010
+ onDragLeave: () => P(!1),
1011
+ onDrop: (n) => {
1012
+ n.preventDefault(), P(!1);
1013
+ const i = n.dataTransfer.files?.[0];
1014
+ i && ke(i);
913
1015
  },
914
- className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${_ ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
1016
+ className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${F ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
915
1017
  children: [
916
1018
  /* @__PURE__ */ e.jsx("p", { className: "text-slate-600", children: "Drop a file here, or click to select." }),
917
1019
  /* @__PURE__ */ e.jsx(
918
1020
  "button",
919
1021
  {
920
1022
  type: "button",
921
- onClick: (r) => {
922
- r.stopPropagation(), v.current?.click();
1023
+ onClick: (n) => {
1024
+ n.stopPropagation(), T.current?.click();
923
1025
  },
924
1026
  className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
925
1027
  children: "Select File"
@@ -927,18 +1029,18 @@ function Ge({
927
1029
  ),
928
1030
  /* @__PURE__ */ e.jsxs("p", { className: "text-xs text-slate-400", children: [
929
1031
  "Supports ",
930
- t.join(", ")
1032
+ Z.join(", ")
931
1033
  ] }),
932
1034
  /* @__PURE__ */ e.jsx(
933
1035
  "input",
934
1036
  {
935
- ref: v,
1037
+ ref: T,
936
1038
  type: "file",
937
1039
  hidden: !0,
938
- accept: t.join(","),
939
- onChange: (r) => {
940
- const o = r.currentTarget.files?.[0];
941
- o && G(o), r.currentTarget.value = "";
1040
+ accept: Z.join(","),
1041
+ onChange: (n) => {
1042
+ const i = n.currentTarget.files?.[0];
1043
+ i && ke(i), n.currentTarget.value = "";
942
1044
  }
943
1045
  }
944
1046
  )
@@ -947,23 +1049,78 @@ function Ge({
947
1049
  )
948
1050
  ] });
949
1051
  }
950
- function Ue({ hunks: s }) {
951
- return s.length === 0 ? /* @__PURE__ */ e.jsx("p", { className: "m-0 px-4 py-3 text-xs text-slate-500", children: "Nothing was changed in this file." }) : /* @__PURE__ */ e.jsx("div", { className: "max-h-72 overflow-auto bg-white font-mono text-xs leading-relaxed", children: s.map((d, x) => /* @__PURE__ */ e.jsxs("div", { className: "border-b border-slate-100 last:border-b-0", children: [
952
- x > 0 ? /* @__PURE__ */ e.jsx("div", { className: "bg-slate-50 px-4 py-1 text-slate-400", children: "⋯" }) : null,
953
- d.lines.map((b, g) => /* @__PURE__ */ e.jsxs(
1052
+ function Le(r) {
1053
+ return r.reduce(
1054
+ (o, d) => o + 1 + Le(d.children),
1055
+ 0
1056
+ );
1057
+ }
1058
+ function mt(r, o) {
1059
+ const d = r.split(".").map(Number), u = o.split(".").map(Number);
1060
+ for (let x = 0; x < Math.max(d.length, u.length); x++) {
1061
+ const c = (d[x] ?? -1) - (u[x] ?? -1);
1062
+ if (c !== 0)
1063
+ return c;
1064
+ }
1065
+ return 0;
1066
+ }
1067
+ function Ie({
1068
+ items: r,
1069
+ selection: o,
1070
+ onToggle: d
1071
+ }) {
1072
+ return /* @__PURE__ */ e.jsx("ul", { className: "space-y-0.5 text-sm", children: r.map((u) => {
1073
+ const x = o.includes(u.path), c = o.some(
1074
+ (N) => u.path.startsWith(`${N}.`)
1075
+ );
1076
+ return /* @__PURE__ */ e.jsxs("li", { children: [
1077
+ /* @__PURE__ */ e.jsxs("label", { className: "flex items-baseline gap-2", children: [
1078
+ /* @__PURE__ */ e.jsx(
1079
+ "input",
1080
+ {
1081
+ type: "checkbox",
1082
+ checked: x || c,
1083
+ disabled: c,
1084
+ onChange: () => d(u.path)
1085
+ }
1086
+ ),
1087
+ /* @__PURE__ */ e.jsxs("span", { className: c ? "text-slate-400" : "text-slate-700", children: [
1088
+ u.title || /* @__PURE__ */ e.jsx("em", { children: "Untitled" }),
1089
+ /* @__PURE__ */ e.jsxs("span", { className: "ml-2 font-mono text-xs text-slate-400", children: [
1090
+ "<",
1091
+ u.tag,
1092
+ ">"
1093
+ ] })
1094
+ ] })
1095
+ ] }),
1096
+ u.children.length > 0 ? /* @__PURE__ */ e.jsx("div", { className: "ml-5 border-l border-slate-200 pl-3", children: /* @__PURE__ */ e.jsx(
1097
+ Ie,
1098
+ {
1099
+ items: u.children,
1100
+ selection: o,
1101
+ onToggle: d
1102
+ }
1103
+ ) }) : null
1104
+ ] }, u.path);
1105
+ }) });
1106
+ }
1107
+ function xt({ hunks: r }) {
1108
+ return r.length === 0 ? /* @__PURE__ */ e.jsx("p", { className: "m-0 px-4 py-3 text-xs text-slate-500", children: "Nothing was changed in this file." }) : /* @__PURE__ */ e.jsx("div", { className: "max-h-72 overflow-auto bg-white font-mono text-xs leading-relaxed", children: r.map((o, d) => /* @__PURE__ */ e.jsxs("div", { className: "border-b border-slate-100 last:border-b-0", children: [
1109
+ d > 0 ? /* @__PURE__ */ e.jsx("div", { className: "bg-slate-50 px-4 py-1 text-slate-400", children: "⋯" }) : null,
1110
+ o.lines.map((u, x) => /* @__PURE__ */ e.jsxs(
954
1111
  "div",
955
1112
  {
956
- className: b.op === "add" ? "bg-green-50 px-4 text-green-900" : b.op === "remove" ? "bg-red-50 px-4 text-red-900" : "px-4 text-slate-600",
1113
+ className: u.op === "add" ? "bg-green-50 px-4 text-green-900" : u.op === "remove" ? "bg-red-50 px-4 text-red-900" : "px-4 text-slate-600",
957
1114
  children: [
958
- /* @__PURE__ */ e.jsx("span", { className: "mr-2 select-none text-slate-400", children: b.op === "add" ? "+" : b.op === "remove" ? "−" : " " }),
959
- b.text || " "
1115
+ /* @__PURE__ */ e.jsx("span", { className: "mr-2 select-none text-slate-400", children: u.op === "add" ? "+" : u.op === "remove" ? "−" : " " }),
1116
+ u.text || " "
960
1117
  ]
961
1118
  },
962
- g
1119
+ x
963
1120
  ))
964
- ] }, x)) });
1121
+ ] }, d)) });
965
1122
  }
966
- const Be = {
1123
+ const pt = {
967
1124
  title: "Import Source Content",
968
1125
  description: "Paste LaTeX, Markdown, or PreTeXt source to convert into PreTeXt.",
969
1126
  sourceLabel: "Source",
@@ -974,37 +1131,37 @@ const Be = {
974
1131
  successPrefix: "Ready",
975
1132
  errorPrefix: "Error"
976
1133
  };
977
- function Je({
978
- initialSource: s = "",
979
- initialSourceFormat: d,
980
- labels: x,
981
- disabled: b = !1,
982
- onImport: g
1134
+ function vt({
1135
+ initialSource: r = "",
1136
+ initialSourceFormat: o,
1137
+ labels: d,
1138
+ disabled: u = !1,
1139
+ onImport: x
983
1140
  }) {
984
- const c = ae(
985
- () => ({ ...Be, ...x ?? {} }),
986
- [x]
987
- ), [v, N] = h(s), [f, _] = h(
988
- d ?? "auto"
989
- ), [w, R] = h(
1141
+ const c = K(
1142
+ () => ({ ...pt, ...d ?? {} }),
1143
+ [d]
1144
+ ), [N, C] = g(r), [p, S] = g(
1145
+ o ?? "auto"
1146
+ ), [T, y] = g(
990
1147
  null
991
- ), O = ae(
992
- () => _e(v),
993
- [v]
994
- ), E = b || !v.trim();
1148
+ ), v = K(
1149
+ () => Ze(N),
1150
+ [N]
1151
+ ), F = u || !N.trim();
995
1152
  return /* @__PURE__ */ e.jsx(
996
1153
  "form",
997
1154
  {
998
- onSubmit: (k) => {
999
- k.preventDefault();
1000
- const A = Ae(
1001
- v,
1002
- f === "auto" ? void 0 : f
1155
+ onSubmit: (P) => {
1156
+ P.preventDefault();
1157
+ const D = Qe(
1158
+ N,
1159
+ p === "auto" ? void 0 : p
1003
1160
  );
1004
- R(A), g(A);
1161
+ y(D), x(D);
1005
1162
  },
1006
1163
  "aria-label": "Import source form",
1007
- children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: b, children: [
1164
+ children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: u, children: [
1008
1165
  /* @__PURE__ */ e.jsx("legend", { children: c.title }),
1009
1166
  /* @__PURE__ */ e.jsx("p", { children: c.description }),
1010
1167
  /* @__PURE__ */ e.jsxs("label", { children: [
@@ -1012,8 +1169,8 @@ function Je({
1012
1169
  /* @__PURE__ */ e.jsx(
1013
1170
  "textarea",
1014
1171
  {
1015
- value: v,
1016
- onChange: (k) => N(k.currentTarget.value),
1172
+ value: N,
1173
+ onChange: (P) => C(P.currentTarget.value),
1017
1174
  placeholder: c.sourcePlaceholder,
1018
1175
  rows: 12
1019
1176
  }
@@ -1024,9 +1181,9 @@ function Je({
1024
1181
  /* @__PURE__ */ e.jsxs(
1025
1182
  "select",
1026
1183
  {
1027
- value: f,
1028
- onChange: (k) => _(
1029
- k.currentTarget.value
1184
+ value: p,
1185
+ onChange: (P) => S(
1186
+ P.currentTarget.value
1030
1187
  ),
1031
1188
  children: [
1032
1189
  /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
@@ -1040,24 +1197,24 @@ function Je({
1040
1197
  /* @__PURE__ */ e.jsxs("p", { children: [
1041
1198
  c.detectedFormatPrefix,
1042
1199
  ": ",
1043
- /* @__PURE__ */ e.jsx("strong", { children: O })
1200
+ /* @__PURE__ */ e.jsx("strong", { children: v })
1044
1201
  ] }),
1045
- /* @__PURE__ */ e.jsx("button", { type: "submit", disabled: E, children: c.convertButton }),
1046
- w ? "pretextError" in w ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
1202
+ /* @__PURE__ */ e.jsx("button", { type: "submit", disabled: F, children: c.convertButton }),
1203
+ T ? "pretextError" in T ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
1047
1204
  c.errorPrefix,
1048
1205
  ": ",
1049
- w.pretextError
1206
+ T.pretextError
1050
1207
  ] }) : /* @__PURE__ */ e.jsxs("p", { children: [
1051
1208
  c.successPrefix,
1052
1209
  ": ",
1053
- w.pretextSource.length,
1210
+ T.pretextSource.length,
1054
1211
  " characters of PreTeXt generated."
1055
1212
  ] }) : null
1056
1213
  ] })
1057
1214
  }
1058
1215
  );
1059
1216
  }
1060
- const We = {
1217
+ const ht = {
1061
1218
  title: "Upload Source File",
1062
1219
  hint: "Supports .tex, .md, .ptx, .xml, .zip, and .tar.gz files.",
1063
1220
  selectButton: "Select File",
@@ -1065,43 +1222,43 @@ const We = {
1065
1222
  documentKindLabel: "Document kind",
1066
1223
  splitSectionsLabel: "Split each chapter into sections"
1067
1224
  };
1068
- function He({
1069
- labels: s,
1070
- disabled: d = !1,
1071
- defaultDocumentKind: x = "auto",
1072
- importOptions: b,
1073
- onImport: g
1225
+ function Nt({
1226
+ labels: r,
1227
+ disabled: o = !1,
1228
+ defaultDocumentKind: d = "auto",
1229
+ importOptions: u,
1230
+ onImport: x
1074
1231
  }) {
1075
- const c = ae(
1076
- () => ({ ...We, ...s ?? {} }),
1077
- [s]
1078
- ), v = ue(null), [N, f] = h(!1), [_, w] = h(!1), [R, O] = h(
1232
+ const c = K(
1233
+ () => ({ ...ht, ...r ?? {} }),
1234
+ [r]
1235
+ ), N = pe(null), [C, p] = g(!1), [S, T] = g(!1), [y, v] = g(
1079
1236
  []
1080
- ), [E, k] = h(x), [A, L] = h(!1), P = d || _, W = async (p) => {
1081
- w(!0);
1237
+ ), [F, P] = g(d), [D, Y] = g(!1), R = o || S, z = async (j) => {
1238
+ T(!0);
1082
1239
  try {
1083
- const F = await Ne(p, b ?? {
1084
- documentKind: E === "auto" ? void 0 : E,
1085
- splitSections: A
1240
+ const A = await Fe(j, u ?? {
1241
+ documentKind: F === "auto" ? void 0 : F,
1242
+ splitSections: D
1086
1243
  });
1087
- O(F.statusMessages), g(F);
1244
+ v(A.statusMessages), x(A);
1088
1245
  } finally {
1089
- w(!1);
1246
+ T(!1);
1090
1247
  }
1091
1248
  };
1092
1249
  return /* @__PURE__ */ e.jsxs("section", { "aria-label": "Import upload panel", children: [
1093
1250
  /* @__PURE__ */ e.jsx("h3", { children: c.title }),
1094
1251
  /* @__PURE__ */ e.jsx("p", { children: c.hint }),
1095
- b ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
1252
+ u ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
1096
1253
  /* @__PURE__ */ e.jsxs("label", { children: [
1097
1254
  c.documentKindLabel,
1098
1255
  /* @__PURE__ */ e.jsxs(
1099
1256
  "select",
1100
1257
  {
1101
- value: E,
1102
- disabled: P,
1103
- onChange: (p) => k(
1104
- p.currentTarget.value
1258
+ value: F,
1259
+ disabled: R,
1260
+ onChange: (j) => P(
1261
+ j.currentTarget.value
1105
1262
  ),
1106
1263
  children: [
1107
1264
  /* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
@@ -1116,9 +1273,9 @@ function He({
1116
1273
  "input",
1117
1274
  {
1118
1275
  type: "checkbox",
1119
- checked: A,
1120
- disabled: P,
1121
- onChange: (p) => L(p.currentTarget.checked)
1276
+ checked: D,
1277
+ disabled: R,
1278
+ onChange: (j) => Y(j.currentTarget.checked)
1122
1279
  }
1123
1280
  ),
1124
1281
  c.splitSectionsLabel
@@ -1127,15 +1284,15 @@ function He({
1127
1284
  /* @__PURE__ */ e.jsxs(
1128
1285
  "div",
1129
1286
  {
1130
- onDragOver: (p) => {
1131
- p.preventDefault(), P || f(!0);
1287
+ onDragOver: (j) => {
1288
+ j.preventDefault(), R || p(!0);
1132
1289
  },
1133
- onDragLeave: () => f(!1),
1134
- onDrop: (p) => {
1135
- if (p.preventDefault(), f(!1), P)
1290
+ onDragLeave: () => p(!1),
1291
+ onDrop: (j) => {
1292
+ if (j.preventDefault(), p(!1), R)
1136
1293
  return;
1137
- const S = p.dataTransfer.files?.[0];
1138
- S && W(S);
1294
+ const _ = j.dataTransfer.files?.[0];
1295
+ _ && z(_);
1139
1296
  },
1140
1297
  children: [
1141
1298
  /* @__PURE__ */ e.jsx("p", { children: c.dropHint }),
@@ -1143,46 +1300,46 @@ function He({
1143
1300
  "button",
1144
1301
  {
1145
1302
  type: "button",
1146
- disabled: P,
1147
- onClick: () => v.current?.click(),
1303
+ disabled: R,
1304
+ onClick: () => N.current?.click(),
1148
1305
  className: "inline-flex items-center gap-2",
1149
1306
  children: [
1150
- _ ? /* @__PURE__ */ e.jsx(
1307
+ S ? /* @__PURE__ */ e.jsx(
1151
1308
  "span",
1152
1309
  {
1153
1310
  className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent",
1154
1311
  "aria-hidden": "true"
1155
1312
  }
1156
1313
  ) : null,
1157
- _ ? "Processing…" : c.selectButton
1314
+ S ? "Processing…" : c.selectButton
1158
1315
  ]
1159
1316
  }
1160
1317
  ),
1161
1318
  /* @__PURE__ */ e.jsx(
1162
1319
  "input",
1163
1320
  {
1164
- ref: v,
1321
+ ref: N,
1165
1322
  type: "file",
1166
1323
  hidden: !0,
1167
- disabled: P,
1324
+ disabled: R,
1168
1325
  accept: ".tex,.md,.markdown,.ptx,.xml,.zip,.gz,.tar.gz,.tgz",
1169
- onChange: (p) => {
1170
- const S = p.currentTarget.files?.[0];
1171
- S && W(S), p.currentTarget.value = "";
1326
+ onChange: (j) => {
1327
+ const _ = j.currentTarget.files?.[0];
1328
+ _ && z(_), j.currentTarget.value = "";
1172
1329
  }
1173
1330
  }
1174
1331
  )
1175
1332
  ]
1176
1333
  }
1177
1334
  ),
1178
- _ ? /* @__PURE__ */ e.jsx("p", { role: "status", "aria-live": "polite", children: "Converting your file — this can take a while for a long document." }) : null,
1179
- R.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: R.map((p, S) => /* @__PURE__ */ e.jsx("li", { children: p.message }, `${p.type}-${S}`)) }) : null,
1180
- N && !P ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
1335
+ S ? /* @__PURE__ */ e.jsx("p", { role: "status", "aria-live": "polite", children: "Converting your file — this can take a while for a long document." }) : null,
1336
+ y.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: y.map((j, _) => /* @__PURE__ */ e.jsx("li", { children: j.message }, `${j.type}-${_}`)) }) : null,
1337
+ C && !R ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
1181
1338
  ] });
1182
1339
  }
1183
1340
  export {
1184
- Je as ImportSourceForm,
1185
- He as ImportUploadPanel,
1186
- Ge as ImportWizard,
1187
- Me as ProcessingPanel
1341
+ vt as ImportSourceForm,
1342
+ Nt as ImportUploadPanel,
1343
+ jt as ImportWizard,
1344
+ ct as ProcessingPanel
1188
1345
  };