@pretextbook/import 0.0.1
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/README.md +121 -0
- package/dist/import-mode-CSZlmUxw.cjs +66 -0
- package/dist/import-mode-iBDd9oQY.js +3862 -0
- package/dist/import.css +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +164 -0
- package/dist/lib/clean/clean-latex.d.ts +6 -0
- package/dist/lib/clean/latex-clean.d.ts +10 -0
- package/dist/lib/clean/latex-data.d.ts +38 -0
- package/dist/lib/clean/latex-preamble.d.ts +27 -0
- package/dist/lib/clean/latex-scan.d.ts +11 -0
- package/dist/lib/clean/latex-utils.d.ts +4 -0
- package/dist/lib/clean/pretext-includes.d.ts +7 -0
- package/dist/lib/clean/warnings.d.ts +13 -0
- package/dist/lib/convert.d.ts +16 -0
- package/dist/lib/detect-source-format.d.ts +4 -0
- package/dist/lib/import-mode.d.ts +13 -0
- package/dist/lib/layout/build-project-files.d.ts +17 -0
- package/dist/lib/layout/document-kind.d.ts +2 -0
- package/dist/lib/layout/index.d.ts +4 -0
- package/dist/lib/layout/shared.d.ts +12 -0
- package/dist/lib/layout/templates.d.ts +8 -0
- package/dist/lib/layout/xml-scan.d.ts +13 -0
- package/dist/lib/pool/division-pool.d.ts +34 -0
- package/dist/lib/pool/index.d.ts +3 -0
- package/dist/lib/pool/serialize-files.d.ts +19 -0
- package/dist/lib/pool/serialize-plus.d.ts +10 -0
- package/dist/lib/types.d.ts +124 -0
- package/dist/lib/upload.d.ts +10 -0
- package/dist/react/import-source-form.d.ts +20 -0
- package/dist/react/import-upload-panel.d.ts +21 -0
- package/dist/react/import-wizard.d.ts +15 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react.cjs +6 -0
- package/dist/react.js +735 -0
- package/index.cjs +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +63 -0
package/dist/react.js
ADDED
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
import ae, { useRef as re, useState as p, useMemo as J } from "react";
|
|
2
|
+
import { q as Z, v as se, m as oe, l as le } from "./import-mode-iBDd9oQY.js";
|
|
3
|
+
var U = { exports: {} }, z = {};
|
|
4
|
+
var Q;
|
|
5
|
+
function ce() {
|
|
6
|
+
if (Q) return z;
|
|
7
|
+
Q = 1;
|
|
8
|
+
var h = /* @__PURE__ */ Symbol.for("react.transitional.element"), T = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
9
|
+
function b(v, i, n) {
|
|
10
|
+
var u = null;
|
|
11
|
+
if (n !== void 0 && (u = "" + n), i.key !== void 0 && (u = "" + i.key), "key" in i) {
|
|
12
|
+
n = {};
|
|
13
|
+
for (var y in i)
|
|
14
|
+
y !== "key" && (n[y] = i[y]);
|
|
15
|
+
} else n = i;
|
|
16
|
+
return i = n.ref, {
|
|
17
|
+
$$typeof: h,
|
|
18
|
+
type: v,
|
|
19
|
+
key: u,
|
|
20
|
+
ref: i !== void 0 ? i : null,
|
|
21
|
+
props: n
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return z.Fragment = T, z.jsx = b, z.jsxs = b, z;
|
|
25
|
+
}
|
|
26
|
+
var Y = {};
|
|
27
|
+
var ee;
|
|
28
|
+
function ie() {
|
|
29
|
+
return ee || (ee = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
30
|
+
function h(t) {
|
|
31
|
+
if (t == null) return null;
|
|
32
|
+
if (typeof t == "function")
|
|
33
|
+
return t.$$typeof === P ? null : t.displayName || t.name || null;
|
|
34
|
+
if (typeof t == "string") return t;
|
|
35
|
+
switch (t) {
|
|
36
|
+
case A:
|
|
37
|
+
return "Fragment";
|
|
38
|
+
case C:
|
|
39
|
+
return "Profiler";
|
|
40
|
+
case S:
|
|
41
|
+
return "StrictMode";
|
|
42
|
+
case M:
|
|
43
|
+
return "Suspense";
|
|
44
|
+
case B:
|
|
45
|
+
return "SuspenseList";
|
|
46
|
+
case f:
|
|
47
|
+
return "Activity";
|
|
48
|
+
}
|
|
49
|
+
if (typeof t == "object")
|
|
50
|
+
switch (typeof t.tag == "number" && console.error(
|
|
51
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
52
|
+
), t.$$typeof) {
|
|
53
|
+
case E:
|
|
54
|
+
return "Portal";
|
|
55
|
+
case N:
|
|
56
|
+
return t.displayName || "Context";
|
|
57
|
+
case c:
|
|
58
|
+
return (t._context.displayName || "Context") + ".Consumer";
|
|
59
|
+
case F:
|
|
60
|
+
var r = t.render;
|
|
61
|
+
return t = t.displayName, t || (t = r.displayName || r.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
62
|
+
case a:
|
|
63
|
+
return r = t.displayName || null, r !== null ? r : h(t.type) || "Memo";
|
|
64
|
+
case s:
|
|
65
|
+
r = t._payload, t = t._init;
|
|
66
|
+
try {
|
|
67
|
+
return h(t(r));
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function T(t) {
|
|
74
|
+
return "" + t;
|
|
75
|
+
}
|
|
76
|
+
function b(t) {
|
|
77
|
+
try {
|
|
78
|
+
T(t);
|
|
79
|
+
var r = !1;
|
|
80
|
+
} catch {
|
|
81
|
+
r = !0;
|
|
82
|
+
}
|
|
83
|
+
if (r) {
|
|
84
|
+
r = console;
|
|
85
|
+
var l = r.error, d = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
86
|
+
return l.call(
|
|
87
|
+
r,
|
|
88
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
89
|
+
d
|
|
90
|
+
), T(t);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function v(t) {
|
|
94
|
+
if (t === A) return "<>";
|
|
95
|
+
if (typeof t == "object" && t !== null && t.$$typeof === s)
|
|
96
|
+
return "<...>";
|
|
97
|
+
try {
|
|
98
|
+
var r = h(t);
|
|
99
|
+
return r ? "<" + r + ">" : "<...>";
|
|
100
|
+
} catch {
|
|
101
|
+
return "<...>";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function i() {
|
|
105
|
+
var t = O.A;
|
|
106
|
+
return t === null ? null : t.getOwner();
|
|
107
|
+
}
|
|
108
|
+
function n() {
|
|
109
|
+
return Error("react-stack-top-frame");
|
|
110
|
+
}
|
|
111
|
+
function u(t) {
|
|
112
|
+
if (L.call(t, "key")) {
|
|
113
|
+
var r = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
114
|
+
if (r && r.isReactWarning) return !1;
|
|
115
|
+
}
|
|
116
|
+
return t.key !== void 0;
|
|
117
|
+
}
|
|
118
|
+
function y(t, r) {
|
|
119
|
+
function l() {
|
|
120
|
+
o || (o = !0, console.error(
|
|
121
|
+
"%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
|
+
r
|
|
123
|
+
));
|
|
124
|
+
}
|
|
125
|
+
l.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
126
|
+
get: l,
|
|
127
|
+
configurable: !0
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function g() {
|
|
131
|
+
var t = h(this.type);
|
|
132
|
+
return D[t] || (D[t] = !0, console.error(
|
|
133
|
+
"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
|
+
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
135
|
+
}
|
|
136
|
+
function _(t, r, l, d, X, K) {
|
|
137
|
+
var m = l.ref;
|
|
138
|
+
return t = {
|
|
139
|
+
$$typeof: j,
|
|
140
|
+
type: t,
|
|
141
|
+
key: r,
|
|
142
|
+
props: l,
|
|
143
|
+
_owner: d
|
|
144
|
+
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(t, "ref", {
|
|
145
|
+
enumerable: !1,
|
|
146
|
+
get: g
|
|
147
|
+
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
148
|
+
configurable: !1,
|
|
149
|
+
enumerable: !1,
|
|
150
|
+
writable: !0,
|
|
151
|
+
value: 0
|
|
152
|
+
}), Object.defineProperty(t, "_debugInfo", {
|
|
153
|
+
configurable: !1,
|
|
154
|
+
enumerable: !1,
|
|
155
|
+
writable: !0,
|
|
156
|
+
value: null
|
|
157
|
+
}), Object.defineProperty(t, "_debugStack", {
|
|
158
|
+
configurable: !1,
|
|
159
|
+
enumerable: !1,
|
|
160
|
+
writable: !0,
|
|
161
|
+
value: X
|
|
162
|
+
}), Object.defineProperty(t, "_debugTask", {
|
|
163
|
+
configurable: !1,
|
|
164
|
+
enumerable: !1,
|
|
165
|
+
writable: !0,
|
|
166
|
+
value: K
|
|
167
|
+
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
168
|
+
}
|
|
169
|
+
function k(t, r, l, d, X, K) {
|
|
170
|
+
var m = r.children;
|
|
171
|
+
if (m !== void 0)
|
|
172
|
+
if (d)
|
|
173
|
+
if (W(m)) {
|
|
174
|
+
for (d = 0; d < m.length; d++)
|
|
175
|
+
R(m[d]);
|
|
176
|
+
Object.freeze && Object.freeze(m);
|
|
177
|
+
} else
|
|
178
|
+
console.error(
|
|
179
|
+
"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
|
+
else R(m);
|
|
182
|
+
if (L.call(r, "key")) {
|
|
183
|
+
m = h(t);
|
|
184
|
+
var I = Object.keys(r).filter(function(ne) {
|
|
185
|
+
return ne !== "key";
|
|
186
|
+
});
|
|
187
|
+
d = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", H[m + d] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
188
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
189
|
+
let props = %s;
|
|
190
|
+
<%s {...props} />
|
|
191
|
+
React keys must be passed directly to JSX without using spread:
|
|
192
|
+
let props = %s;
|
|
193
|
+
<%s key={someKey} {...props} />`,
|
|
194
|
+
d,
|
|
195
|
+
m,
|
|
196
|
+
I,
|
|
197
|
+
m
|
|
198
|
+
), H[m + d] = !0);
|
|
199
|
+
}
|
|
200
|
+
if (m = null, l !== void 0 && (b(l), m = "" + l), u(r) && (b(r.key), m = "" + r.key), "key" in r) {
|
|
201
|
+
l = {};
|
|
202
|
+
for (var q in r)
|
|
203
|
+
q !== "key" && (l[q] = r[q]);
|
|
204
|
+
} else l = r;
|
|
205
|
+
return m && y(
|
|
206
|
+
l,
|
|
207
|
+
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
208
|
+
), _(
|
|
209
|
+
t,
|
|
210
|
+
m,
|
|
211
|
+
l,
|
|
212
|
+
i(),
|
|
213
|
+
X,
|
|
214
|
+
K
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function R(t) {
|
|
218
|
+
w(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === s && (t._payload.status === "fulfilled" ? w(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
|
|
219
|
+
}
|
|
220
|
+
function w(t) {
|
|
221
|
+
return typeof t == "object" && t !== null && t.$$typeof === j;
|
|
222
|
+
}
|
|
223
|
+
var x = ae, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), E = /* @__PURE__ */ Symbol.for("react.portal"), A = /* @__PURE__ */ Symbol.for("react.fragment"), S = /* @__PURE__ */ Symbol.for("react.strict_mode"), C = /* @__PURE__ */ Symbol.for("react.profiler"), c = /* @__PURE__ */ Symbol.for("react.consumer"), N = /* @__PURE__ */ Symbol.for("react.context"), F = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), a = /* @__PURE__ */ Symbol.for("react.memo"), s = /* @__PURE__ */ Symbol.for("react.lazy"), f = /* @__PURE__ */ Symbol.for("react.activity"), P = /* @__PURE__ */ Symbol.for("react.client.reference"), O = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, W = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
224
|
+
return null;
|
|
225
|
+
};
|
|
226
|
+
x = {
|
|
227
|
+
react_stack_bottom_frame: function(t) {
|
|
228
|
+
return t();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var o, D = {}, V = x.react_stack_bottom_frame.bind(
|
|
232
|
+
x,
|
|
233
|
+
n
|
|
234
|
+
)(), G = $(v(n)), H = {};
|
|
235
|
+
Y.Fragment = A, Y.jsx = function(t, r, l) {
|
|
236
|
+
var d = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
237
|
+
return k(
|
|
238
|
+
t,
|
|
239
|
+
r,
|
|
240
|
+
l,
|
|
241
|
+
!1,
|
|
242
|
+
d ? Error("react-stack-top-frame") : V,
|
|
243
|
+
d ? $(v(t)) : G
|
|
244
|
+
);
|
|
245
|
+
}, Y.jsxs = function(t, r, l) {
|
|
246
|
+
var d = 1e4 > O.recentlyCreatedOwnerStacks++;
|
|
247
|
+
return k(
|
|
248
|
+
t,
|
|
249
|
+
r,
|
|
250
|
+
l,
|
|
251
|
+
!0,
|
|
252
|
+
d ? Error("react-stack-top-frame") : V,
|
|
253
|
+
d ? $(v(t)) : G
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
})()), Y;
|
|
257
|
+
}
|
|
258
|
+
var te;
|
|
259
|
+
function ue() {
|
|
260
|
+
return te || (te = 1, process.env.NODE_ENV === "production" ? U.exports = ce() : U.exports = ie()), U.exports;
|
|
261
|
+
}
|
|
262
|
+
var e = ue();
|
|
263
|
+
function pe({
|
|
264
|
+
onConfirm: h,
|
|
265
|
+
onCancel: T,
|
|
266
|
+
importOptions: b,
|
|
267
|
+
defaultDocumentKind: v = "auto"
|
|
268
|
+
}) {
|
|
269
|
+
const i = re(null), [n, u] = p({ name: "upload" }), [y, g] = p(!1), [_, k] = p(v), [R, w] = p(!1), [x, j] = p("converted"), [E, A] = p(!1), [S, C] = p(/* @__PURE__ */ new Set()), c = async (a) => {
|
|
270
|
+
u({ name: "processing" });
|
|
271
|
+
try {
|
|
272
|
+
const f = await se(a, b ?? {
|
|
273
|
+
documentKind: _ === "auto" ? void 0 : _,
|
|
274
|
+
splitSections: R
|
|
275
|
+
});
|
|
276
|
+
"pretextError" in f ? u({ name: "error", message: f.pretextError }) : u({ name: "review", result: f });
|
|
277
|
+
} catch (s) {
|
|
278
|
+
u({
|
|
279
|
+
name: "error",
|
|
280
|
+
message: s instanceof Error ? s.message : "An unexpected error occurred."
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}, N = () => {
|
|
284
|
+
u({ name: "upload" }), j("converted"), A(!1), C(/* @__PURE__ */ new Set());
|
|
285
|
+
};
|
|
286
|
+
function F(a, s) {
|
|
287
|
+
return [...a].sort((f, P) => f === s ? -1 : P === s ? 1 : f.localeCompare(P));
|
|
288
|
+
}
|
|
289
|
+
function M(a, s) {
|
|
290
|
+
const f = Z(a, s), P = s === "converted" ? "source/main.ptx" : a.sourcePath, O = F(Object.keys(f), P)[0];
|
|
291
|
+
C(O ? /* @__PURE__ */ new Set([O]) : /* @__PURE__ */ new Set());
|
|
292
|
+
}
|
|
293
|
+
function B(a) {
|
|
294
|
+
C((s) => {
|
|
295
|
+
const f = new Set(s);
|
|
296
|
+
return f.has(a) ? f.delete(a) : f.add(a), f;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
if (n.name === "processing")
|
|
300
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center gap-3 py-16 text-slate-600", children: [
|
|
301
|
+
/* @__PURE__ */ e.jsx("div", { className: "h-8 w-8 animate-spin rounded-full border-2 border-blue-700 border-t-transparent" }),
|
|
302
|
+
/* @__PURE__ */ e.jsx("p", { className: "text-sm", children: "Processing your file…" })
|
|
303
|
+
] });
|
|
304
|
+
if (n.name === "error")
|
|
305
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
306
|
+
/* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-800", children: [
|
|
307
|
+
/* @__PURE__ */ e.jsx("p", { className: "font-semibold", children: "Import failed" }),
|
|
308
|
+
/* @__PURE__ */ e.jsx("p", { className: "mt-1", children: n.message })
|
|
309
|
+
] }),
|
|
310
|
+
/* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ e.jsx(
|
|
311
|
+
"button",
|
|
312
|
+
{
|
|
313
|
+
type: "button",
|
|
314
|
+
onClick: N,
|
|
315
|
+
className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
|
|
316
|
+
children: "Try Another File"
|
|
317
|
+
}
|
|
318
|
+
) })
|
|
319
|
+
] });
|
|
320
|
+
if (n.name === "review") {
|
|
321
|
+
let a = function(o) {
|
|
322
|
+
j(o), E && M(s, o);
|
|
323
|
+
};
|
|
324
|
+
const { result: s } = n, f = s.detectedSourceFormat === "latex", P = s.warnings.length, O = Object.keys(s.outputFiles).length, L = Z(s, x), W = x === "converted" ? "source/main.ptx" : s.sourcePath, $ = F(Object.keys(L), W);
|
|
325
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
326
|
+
/* @__PURE__ */ e.jsxs("div", { className: "rounded-lg border border-slate-200 bg-slate-50 p-4", children: [
|
|
327
|
+
/* @__PURE__ */ e.jsx("h3", { className: "mb-3 text-sm font-semibold text-slate-700", children: "Import Summary" }),
|
|
328
|
+
/* @__PURE__ */ e.jsxs("dl", { className: "grid grid-cols-2 gap-x-6 gap-y-2 text-sm", children: [
|
|
329
|
+
/* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Source" }),
|
|
330
|
+
/* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: s.sourceName }),
|
|
331
|
+
/* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Detected format" }),
|
|
332
|
+
/* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: s.detectedSourceFormat }),
|
|
333
|
+
/* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Document kind" }),
|
|
334
|
+
/* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900 capitalize", children: s.documentKind }),
|
|
335
|
+
/* @__PURE__ */ e.jsx("dt", { className: "text-slate-500", children: "Output files" }),
|
|
336
|
+
/* @__PURE__ */ e.jsx("dd", { className: "font-medium text-slate-900", children: O })
|
|
337
|
+
] })
|
|
338
|
+
] }),
|
|
339
|
+
P > 0 ? /* @__PURE__ */ e.jsxs("details", { className: "rounded-lg border border-amber-200 bg-amber-50 p-4 text-sm", children: [
|
|
340
|
+
/* @__PURE__ */ e.jsxs("summary", { className: "cursor-pointer font-semibold text-amber-800", children: [
|
|
341
|
+
P,
|
|
342
|
+
" conversion ",
|
|
343
|
+
P === 1 ? "warning" : "warnings"
|
|
344
|
+
] }),
|
|
345
|
+
/* @__PURE__ */ e.jsx("ul", { className: "mt-3 space-y-1.5 text-amber-700", children: s.warnings.map((o, D) => /* @__PURE__ */ e.jsxs("li", { children: [
|
|
346
|
+
/* @__PURE__ */ e.jsx("code", { className: "rounded bg-amber-100 px-1 py-0.5 text-xs", children: o.macro }),
|
|
347
|
+
" — ",
|
|
348
|
+
o.action === "replace" || o.action === "rewrite" ? `replaced with \`${o.replacement}\`` : o.message ?? o.action,
|
|
349
|
+
o.occurrences > 1 ? ` (×${o.occurrences})` : null
|
|
350
|
+
] }, D)) })
|
|
351
|
+
] }) : /* @__PURE__ */ e.jsx("p", { className: "text-sm text-green-700", children: "No conversion warnings." }),
|
|
352
|
+
f ? /* @__PURE__ */ e.jsxs("fieldset", { className: "rounded-lg border border-slate-200 p-4", children: [
|
|
353
|
+
/* @__PURE__ */ e.jsx("legend", { className: "px-1 text-sm font-semibold text-slate-700", children: "Import mode" }),
|
|
354
|
+
/* @__PURE__ */ e.jsxs("div", { className: "mt-2 flex flex-col gap-3", children: [
|
|
355
|
+
/* @__PURE__ */ e.jsxs("label", { className: "flex cursor-pointer items-start gap-3 text-sm", children: [
|
|
356
|
+
/* @__PURE__ */ e.jsx(
|
|
357
|
+
"input",
|
|
358
|
+
{
|
|
359
|
+
type: "radio",
|
|
360
|
+
name: "import-mode",
|
|
361
|
+
value: "converted",
|
|
362
|
+
checked: x === "converted",
|
|
363
|
+
onChange: () => a("converted"),
|
|
364
|
+
className: "mt-0.5"
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
368
|
+
/* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: "Convert to PreTeXt" }),
|
|
369
|
+
/* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: "Use the converted PreTeXt output. Recommended for new PreTeXt projects." })
|
|
370
|
+
] })
|
|
371
|
+
] }),
|
|
372
|
+
/* @__PURE__ */ e.jsxs("label", { className: "flex cursor-pointer items-start gap-3 text-sm", children: [
|
|
373
|
+
/* @__PURE__ */ e.jsx(
|
|
374
|
+
"input",
|
|
375
|
+
{
|
|
376
|
+
type: "radio",
|
|
377
|
+
name: "import-mode",
|
|
378
|
+
value: "native",
|
|
379
|
+
checked: x === "native",
|
|
380
|
+
onChange: () => a("native"),
|
|
381
|
+
className: "mt-0.5"
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
/* @__PURE__ */ e.jsxs("span", { children: [
|
|
385
|
+
/* @__PURE__ */ e.jsx("span", { className: "font-medium text-slate-900", children: "Keep as LaTeX" }),
|
|
386
|
+
/* @__PURE__ */ e.jsx("span", { className: "block text-slate-500", children: "Preserve the original LaTeX source. The conversion will not be applied." })
|
|
387
|
+
] })
|
|
388
|
+
] })
|
|
389
|
+
] })
|
|
390
|
+
] }) : null,
|
|
391
|
+
E ? /* @__PURE__ */ e.jsx("div", { className: "overflow-hidden rounded-lg border border-slate-200 text-sm", children: $.map((o) => {
|
|
392
|
+
const D = S.has(o);
|
|
393
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "border-b border-slate-200 last:border-b-0", children: [
|
|
394
|
+
/* @__PURE__ */ e.jsxs(
|
|
395
|
+
"button",
|
|
396
|
+
{
|
|
397
|
+
type: "button",
|
|
398
|
+
onClick: () => B(o),
|
|
399
|
+
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",
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ e.jsx("span", { className: "shrink-0 text-slate-400", children: D ? "▾" : "▸" }),
|
|
402
|
+
/* @__PURE__ */ e.jsx("span", { className: "flex-1 truncate", children: o }),
|
|
403
|
+
/* @__PURE__ */ e.jsxs("span", { className: "shrink-0 text-slate-400", children: [
|
|
404
|
+
(L[o].length / 1024).toFixed(1),
|
|
405
|
+
" KB"
|
|
406
|
+
] })
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
),
|
|
410
|
+
D ? /* @__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: L[o] }) : null
|
|
411
|
+
] }, o);
|
|
412
|
+
}) }) : null,
|
|
413
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-3 pt-1", children: [
|
|
414
|
+
/* @__PURE__ */ e.jsx(
|
|
415
|
+
"button",
|
|
416
|
+
{
|
|
417
|
+
type: "button",
|
|
418
|
+
onClick: T ?? N,
|
|
419
|
+
className: "px-4 py-2 text-sm text-slate-600 hover:text-slate-900",
|
|
420
|
+
children: T ? "Cancel" : "Start Over"
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
|
|
424
|
+
/* @__PURE__ */ e.jsx(
|
|
425
|
+
"button",
|
|
426
|
+
{
|
|
427
|
+
type: "button",
|
|
428
|
+
onClick: () => {
|
|
429
|
+
E || M(s, x), A((o) => !o);
|
|
430
|
+
},
|
|
431
|
+
className: "rounded border border-slate-300 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",
|
|
432
|
+
children: E ? "Hide Preview" : "Preview"
|
|
433
|
+
}
|
|
434
|
+
),
|
|
435
|
+
/* @__PURE__ */ e.jsx(
|
|
436
|
+
"button",
|
|
437
|
+
{
|
|
438
|
+
type: "button",
|
|
439
|
+
onClick: () => h(s, x),
|
|
440
|
+
className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
|
|
441
|
+
children: "Confirm Import"
|
|
442
|
+
}
|
|
443
|
+
)
|
|
444
|
+
] })
|
|
445
|
+
] })
|
|
446
|
+
] });
|
|
447
|
+
}
|
|
448
|
+
return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
449
|
+
b ? null : /* @__PURE__ */ e.jsxs("div", { className: "flex flex-wrap gap-4 text-sm", children: [
|
|
450
|
+
/* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-slate-700", children: [
|
|
451
|
+
/* @__PURE__ */ e.jsx("span", { className: "text-slate-500", children: "Document kind" }),
|
|
452
|
+
/* @__PURE__ */ e.jsxs(
|
|
453
|
+
"select",
|
|
454
|
+
{
|
|
455
|
+
value: _,
|
|
456
|
+
onChange: (a) => k(a.currentTarget.value),
|
|
457
|
+
className: "rounded border border-slate-300 px-2 py-1 text-sm",
|
|
458
|
+
children: [
|
|
459
|
+
/* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
|
|
460
|
+
/* @__PURE__ */ e.jsx("option", { value: "article", children: "Article" }),
|
|
461
|
+
/* @__PURE__ */ e.jsx("option", { value: "book", children: "Book" })
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
)
|
|
465
|
+
] }),
|
|
466
|
+
/* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2 text-sm text-slate-700", children: [
|
|
467
|
+
/* @__PURE__ */ e.jsx(
|
|
468
|
+
"input",
|
|
469
|
+
{
|
|
470
|
+
type: "checkbox",
|
|
471
|
+
checked: R,
|
|
472
|
+
onChange: (a) => w(a.currentTarget.checked)
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
"Split sections into separate files"
|
|
476
|
+
] })
|
|
477
|
+
] }),
|
|
478
|
+
/* @__PURE__ */ e.jsxs(
|
|
479
|
+
"div",
|
|
480
|
+
{
|
|
481
|
+
role: "button",
|
|
482
|
+
tabIndex: 0,
|
|
483
|
+
onKeyDown: (a) => a.key === "Enter" && i.current?.click(),
|
|
484
|
+
onClick: () => i.current?.click(),
|
|
485
|
+
onDragOver: (a) => {
|
|
486
|
+
a.preventDefault(), g(!0);
|
|
487
|
+
},
|
|
488
|
+
onDragLeave: () => g(!1),
|
|
489
|
+
onDrop: (a) => {
|
|
490
|
+
a.preventDefault(), g(!1);
|
|
491
|
+
const s = a.dataTransfer.files?.[0];
|
|
492
|
+
s && c(s);
|
|
493
|
+
},
|
|
494
|
+
className: `flex cursor-pointer flex-col items-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${y ? "border-blue-500 bg-blue-50" : "border-slate-300 bg-slate-50 hover:border-slate-400"}`,
|
|
495
|
+
children: [
|
|
496
|
+
/* @__PURE__ */ e.jsx("p", { className: "text-slate-600", children: "Drop a file here, or click to select." }),
|
|
497
|
+
/* @__PURE__ */ e.jsx(
|
|
498
|
+
"button",
|
|
499
|
+
{
|
|
500
|
+
type: "button",
|
|
501
|
+
onClick: (a) => {
|
|
502
|
+
a.stopPropagation(), i.current?.click();
|
|
503
|
+
},
|
|
504
|
+
className: "rounded bg-blue-700 px-4 py-2 text-sm font-medium text-white hover:bg-blue-600",
|
|
505
|
+
children: "Select File"
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
/* @__PURE__ */ e.jsx("p", { className: "text-xs text-slate-400", children: "Supports .tex, .md, .ptx, .xml, .zip, .tar.gz" }),
|
|
509
|
+
/* @__PURE__ */ e.jsx(
|
|
510
|
+
"input",
|
|
511
|
+
{
|
|
512
|
+
ref: i,
|
|
513
|
+
type: "file",
|
|
514
|
+
hidden: !0,
|
|
515
|
+
accept: ".tex,.md,.markdown,.ptx,.xml,.zip,.gz,.tar.gz,.tgz",
|
|
516
|
+
onChange: (a) => {
|
|
517
|
+
const s = a.currentTarget.files?.[0];
|
|
518
|
+
s && c(s), a.currentTarget.value = "";
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
)
|
|
525
|
+
] });
|
|
526
|
+
}
|
|
527
|
+
const de = {
|
|
528
|
+
title: "Import Source Content",
|
|
529
|
+
description: "Paste LaTeX, Markdown, or PreTeXt source to convert into PreTeXt.",
|
|
530
|
+
sourceLabel: "Source",
|
|
531
|
+
sourcePlaceholder: "Paste source content here...",
|
|
532
|
+
formatLabel: "Source format",
|
|
533
|
+
convertButton: "Convert to PreTeXt",
|
|
534
|
+
detectedFormatPrefix: "Detected",
|
|
535
|
+
successPrefix: "Ready",
|
|
536
|
+
errorPrefix: "Error"
|
|
537
|
+
};
|
|
538
|
+
function he({
|
|
539
|
+
initialSource: h = "",
|
|
540
|
+
initialSourceFormat: T,
|
|
541
|
+
labels: b,
|
|
542
|
+
disabled: v = !1,
|
|
543
|
+
onImport: i
|
|
544
|
+
}) {
|
|
545
|
+
const n = J(
|
|
546
|
+
() => ({ ...de, ...b ?? {} }),
|
|
547
|
+
[b]
|
|
548
|
+
), [u, y] = p(h), [g, _] = p(
|
|
549
|
+
T ?? "auto"
|
|
550
|
+
), [k, R] = p(null), w = J(
|
|
551
|
+
() => oe(u),
|
|
552
|
+
[u]
|
|
553
|
+
), x = v || !u.trim();
|
|
554
|
+
return /* @__PURE__ */ e.jsx(
|
|
555
|
+
"form",
|
|
556
|
+
{
|
|
557
|
+
onSubmit: (j) => {
|
|
558
|
+
j.preventDefault();
|
|
559
|
+
const E = le(
|
|
560
|
+
u,
|
|
561
|
+
g === "auto" ? void 0 : g
|
|
562
|
+
);
|
|
563
|
+
R(E), i(E);
|
|
564
|
+
},
|
|
565
|
+
"aria-label": "Import source form",
|
|
566
|
+
children: /* @__PURE__ */ e.jsxs("fieldset", { disabled: v, children: [
|
|
567
|
+
/* @__PURE__ */ e.jsx("legend", { children: n.title }),
|
|
568
|
+
/* @__PURE__ */ e.jsx("p", { children: n.description }),
|
|
569
|
+
/* @__PURE__ */ e.jsxs("label", { children: [
|
|
570
|
+
n.sourceLabel,
|
|
571
|
+
/* @__PURE__ */ e.jsx(
|
|
572
|
+
"textarea",
|
|
573
|
+
{
|
|
574
|
+
value: u,
|
|
575
|
+
onChange: (j) => y(j.currentTarget.value),
|
|
576
|
+
placeholder: n.sourcePlaceholder,
|
|
577
|
+
rows: 12
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
] }),
|
|
581
|
+
/* @__PURE__ */ e.jsxs("label", { children: [
|
|
582
|
+
n.formatLabel,
|
|
583
|
+
/* @__PURE__ */ e.jsxs(
|
|
584
|
+
"select",
|
|
585
|
+
{
|
|
586
|
+
value: g,
|
|
587
|
+
onChange: (j) => _(
|
|
588
|
+
j.currentTarget.value
|
|
589
|
+
),
|
|
590
|
+
children: [
|
|
591
|
+
/* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
|
|
592
|
+
/* @__PURE__ */ e.jsx("option", { value: "latex", children: "LaTeX" }),
|
|
593
|
+
/* @__PURE__ */ e.jsx("option", { value: "markdown", children: "Markdown" }),
|
|
594
|
+
/* @__PURE__ */ e.jsx("option", { value: "pretext", children: "PreTeXt" })
|
|
595
|
+
]
|
|
596
|
+
}
|
|
597
|
+
)
|
|
598
|
+
] }),
|
|
599
|
+
/* @__PURE__ */ e.jsxs("p", { children: [
|
|
600
|
+
n.detectedFormatPrefix,
|
|
601
|
+
": ",
|
|
602
|
+
/* @__PURE__ */ e.jsx("strong", { children: w })
|
|
603
|
+
] }),
|
|
604
|
+
/* @__PURE__ */ e.jsx("button", { type: "submit", disabled: x, children: n.convertButton }),
|
|
605
|
+
k ? "pretextError" in k ? /* @__PURE__ */ e.jsxs("p", { role: "alert", children: [
|
|
606
|
+
n.errorPrefix,
|
|
607
|
+
": ",
|
|
608
|
+
k.pretextError
|
|
609
|
+
] }) : /* @__PURE__ */ e.jsxs("p", { children: [
|
|
610
|
+
n.successPrefix,
|
|
611
|
+
": ",
|
|
612
|
+
k.pretextSource.length,
|
|
613
|
+
" characters of PreTeXt generated."
|
|
614
|
+
] }) : null
|
|
615
|
+
] })
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
const me = {
|
|
620
|
+
title: "Upload Source File",
|
|
621
|
+
hint: "Supports .tex, .md, .ptx, .xml, .zip, and .tar.gz files.",
|
|
622
|
+
selectButton: "Select File",
|
|
623
|
+
dropHint: "Drop a file here, or click Select File.",
|
|
624
|
+
documentKindLabel: "Document kind",
|
|
625
|
+
splitSectionsLabel: "Split each chapter into sections"
|
|
626
|
+
};
|
|
627
|
+
function be({
|
|
628
|
+
labels: h,
|
|
629
|
+
disabled: T = !1,
|
|
630
|
+
defaultDocumentKind: b = "auto",
|
|
631
|
+
importOptions: v,
|
|
632
|
+
onImport: i
|
|
633
|
+
}) {
|
|
634
|
+
const n = J(
|
|
635
|
+
() => ({ ...me, ...h ?? {} }),
|
|
636
|
+
[h]
|
|
637
|
+
), u = re(null), [y, g] = p(!1), [_, k] = p(!1), [R, w] = p(
|
|
638
|
+
[]
|
|
639
|
+
), [x, j] = p(b), [E, A] = p(!1), S = T || _, C = async (c) => {
|
|
640
|
+
k(!0);
|
|
641
|
+
try {
|
|
642
|
+
const F = await se(c, v ?? {
|
|
643
|
+
documentKind: x === "auto" ? void 0 : x,
|
|
644
|
+
splitSections: E
|
|
645
|
+
});
|
|
646
|
+
w(F.statusMessages), i(F);
|
|
647
|
+
} finally {
|
|
648
|
+
k(!1);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
return /* @__PURE__ */ e.jsxs("section", { "aria-label": "Import upload panel", children: [
|
|
652
|
+
/* @__PURE__ */ e.jsx("h3", { children: n.title }),
|
|
653
|
+
/* @__PURE__ */ e.jsx("p", { children: n.hint }),
|
|
654
|
+
v ? null : /* @__PURE__ */ e.jsxs("div", { className: "import-options", children: [
|
|
655
|
+
/* @__PURE__ */ e.jsxs("label", { children: [
|
|
656
|
+
n.documentKindLabel,
|
|
657
|
+
/* @__PURE__ */ e.jsxs(
|
|
658
|
+
"select",
|
|
659
|
+
{
|
|
660
|
+
value: x,
|
|
661
|
+
disabled: S,
|
|
662
|
+
onChange: (c) => j(
|
|
663
|
+
c.currentTarget.value
|
|
664
|
+
),
|
|
665
|
+
children: [
|
|
666
|
+
/* @__PURE__ */ e.jsx("option", { value: "auto", children: "Auto detect" }),
|
|
667
|
+
/* @__PURE__ */ e.jsx("option", { value: "article", children: "Article" }),
|
|
668
|
+
/* @__PURE__ */ e.jsx("option", { value: "book", children: "Book" })
|
|
669
|
+
]
|
|
670
|
+
}
|
|
671
|
+
)
|
|
672
|
+
] }),
|
|
673
|
+
/* @__PURE__ */ e.jsxs("label", { children: [
|
|
674
|
+
/* @__PURE__ */ e.jsx(
|
|
675
|
+
"input",
|
|
676
|
+
{
|
|
677
|
+
type: "checkbox",
|
|
678
|
+
checked: E,
|
|
679
|
+
disabled: S,
|
|
680
|
+
onChange: (c) => A(c.currentTarget.checked)
|
|
681
|
+
}
|
|
682
|
+
),
|
|
683
|
+
n.splitSectionsLabel
|
|
684
|
+
] })
|
|
685
|
+
] }),
|
|
686
|
+
/* @__PURE__ */ e.jsxs(
|
|
687
|
+
"div",
|
|
688
|
+
{
|
|
689
|
+
onDragOver: (c) => {
|
|
690
|
+
c.preventDefault(), S || g(!0);
|
|
691
|
+
},
|
|
692
|
+
onDragLeave: () => g(!1),
|
|
693
|
+
onDrop: (c) => {
|
|
694
|
+
if (c.preventDefault(), g(!1), S)
|
|
695
|
+
return;
|
|
696
|
+
const N = c.dataTransfer.files?.[0];
|
|
697
|
+
N && C(N);
|
|
698
|
+
},
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ e.jsx("p", { children: n.dropHint }),
|
|
701
|
+
/* @__PURE__ */ e.jsx(
|
|
702
|
+
"button",
|
|
703
|
+
{
|
|
704
|
+
type: "button",
|
|
705
|
+
disabled: S,
|
|
706
|
+
onClick: () => u.current?.click(),
|
|
707
|
+
children: _ ? "Processing..." : n.selectButton
|
|
708
|
+
}
|
|
709
|
+
),
|
|
710
|
+
/* @__PURE__ */ e.jsx(
|
|
711
|
+
"input",
|
|
712
|
+
{
|
|
713
|
+
ref: u,
|
|
714
|
+
type: "file",
|
|
715
|
+
hidden: !0,
|
|
716
|
+
disabled: S,
|
|
717
|
+
accept: ".tex,.md,.markdown,.ptx,.xml,.zip,.gz,.tar.gz,.tgz",
|
|
718
|
+
onChange: (c) => {
|
|
719
|
+
const N = c.currentTarget.files?.[0];
|
|
720
|
+
N && C(N), c.currentTarget.value = "";
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
]
|
|
725
|
+
}
|
|
726
|
+
),
|
|
727
|
+
R.length > 0 ? /* @__PURE__ */ e.jsx("ul", { "aria-live": "polite", children: R.map((c, N) => /* @__PURE__ */ e.jsx("li", { children: c.message }, `${c.type}-${N}`)) }) : null,
|
|
728
|
+
y && !S ? /* @__PURE__ */ e.jsx("p", { children: "Release to upload the file." }) : null
|
|
729
|
+
] });
|
|
730
|
+
}
|
|
731
|
+
export {
|
|
732
|
+
he as ImportSourceForm,
|
|
733
|
+
be as ImportUploadPanel,
|
|
734
|
+
pe as ImportWizard
|
|
735
|
+
};
|