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