@pretextbook/import 0.10.0 → 0.12.0

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