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