@turinhub/atomix-common-ui 0.2.0 → 0.2.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.
Files changed (38) hide show
  1. package/README.md +9 -0
  2. package/dist/components/PDFReader.d.ts +149 -0
  3. package/dist/components/PDFReader.d.ts.map +1 -0
  4. package/dist/components/PDFSidebar.d.ts +87 -0
  5. package/dist/components/PDFSidebar.d.ts.map +1 -0
  6. package/dist/components/SimplePDFReader.d.ts +12 -11
  7. package/dist/components/SimplePDFReader.d.ts.map +1 -1
  8. package/dist/components/ui/scroll-area.d.ts +6 -0
  9. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  10. package/dist/components/ui/tabs.d.ts +8 -0
  11. package/dist/components/ui/tabs.d.ts.map +1 -0
  12. package/dist/index-0y7GsdPm.js +18821 -0
  13. package/dist/index-0y7GsdPm.js.map +1 -0
  14. package/dist/index-BTZUO0o2.cjs +23 -0
  15. package/dist/index-BTZUO0o2.cjs.map +1 -0
  16. package/dist/index-Ct6imo1i.cjs +13 -0
  17. package/dist/index-Ct6imo1i.cjs.map +1 -0
  18. package/dist/index-DaMRZoHB.js +1810 -0
  19. package/dist/index-DaMRZoHB.js.map +1 -0
  20. package/dist/index.c.js +1 -1
  21. package/dist/index.d.ts +5 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +10 -8
  24. package/dist/types/component-types.d.ts +22 -1
  25. package/dist/types/component-types.d.ts.map +1 -1
  26. package/package.json +5 -3
  27. package/dist/__vite-browser-external-BcPniuRQ.cjs +0 -2
  28. package/dist/__vite-browser-external-BcPniuRQ.cjs.map +0 -1
  29. package/dist/__vite-browser-external-DYxpcVy9.js +0 -5
  30. package/dist/__vite-browser-external-DYxpcVy9.js.map +0 -1
  31. package/dist/index-BYKrRClM.js +0 -15033
  32. package/dist/index-BYKrRClM.js.map +0 -1
  33. package/dist/index-Bn7sjSSa.cjs +0 -13
  34. package/dist/index-Bn7sjSSa.cjs.map +0 -1
  35. package/dist/index-DocNZVXn.cjs +0 -23
  36. package/dist/index-DocNZVXn.cjs.map +0 -1
  37. package/dist/index-DruzjpTS.js +0 -1293
  38. package/dist/index-DruzjpTS.js.map +0 -1
@@ -0,0 +1,1810 @@
1
+ import { clsx as Qe } from "clsx";
2
+ import { twMerge as et } from "tailwind-merge";
3
+ import tt, { useState as M, useEffect as ee, useRef as ge, useMemo as Oe, useCallback as ne, memo as st } from "react";
4
+ import { MoreVertical as rt, Plus as nt, Search as lt, ChevronLeft as we, ChevronRight as ke, ZoomOut as Ie, ZoomIn as Fe, Minimize2 as Se, Maximize2 as $e, PanelLeft as at, RotateCw as it, ScrollText as ct, FileText as ot } from "lucide-react";
5
+ function yt(...s) {
6
+ return et(Qe(s));
7
+ }
8
+ var Ne = { exports: {} }, je = {};
9
+ /**
10
+ * @license React
11
+ * react-jsx-runtime.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+ var Ce;
19
+ function ut() {
20
+ if (Ce) return je;
21
+ Ce = 1;
22
+ var s = Symbol.for("react.transitional.element"), j = Symbol.for("react.fragment");
23
+ function c(u, a, x) {
24
+ var p = null;
25
+ if (x !== void 0 && (p = "" + x), a.key !== void 0 && (p = "" + a.key), "key" in a) {
26
+ x = {};
27
+ for (var o in a)
28
+ o !== "key" && (x[o] = a[o]);
29
+ } else x = a;
30
+ return a = x.ref, {
31
+ $$typeof: s,
32
+ type: u,
33
+ key: p,
34
+ ref: a !== void 0 ? a : null,
35
+ props: x
36
+ };
37
+ }
38
+ return je.Fragment = j, je.jsx = c, je.jsxs = c, je;
39
+ }
40
+ var ve = {};
41
+ /**
42
+ * @license React
43
+ * react-jsx-runtime.development.js
44
+ *
45
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */
50
+ var Me;
51
+ function dt() {
52
+ return Me || (Me = 1, process.env.NODE_ENV !== "production" && (function() {
53
+ function s(t) {
54
+ if (t == null) return null;
55
+ if (typeof t == "function")
56
+ return t.$$typeof === K ? null : t.displayName || t.name || null;
57
+ if (typeof t == "string") return t;
58
+ switch (t) {
59
+ case V:
60
+ return "Fragment";
61
+ case w:
62
+ return "Profiler";
63
+ case B:
64
+ return "StrictMode";
65
+ case q:
66
+ return "Suspense";
67
+ case O:
68
+ return "SuspenseList";
69
+ case U:
70
+ return "Activity";
71
+ }
72
+ if (typeof t == "object")
73
+ switch (typeof t.tag == "number" && console.error(
74
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
75
+ ), t.$$typeof) {
76
+ case J:
77
+ return "Portal";
78
+ case d:
79
+ return t.displayName || "Context";
80
+ case b:
81
+ return (t._context.displayName || "Context") + ".Consumer";
82
+ case G:
83
+ var r = t.render;
84
+ return t = t.displayName, t || (t = r.displayName || r.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
85
+ case I:
86
+ return r = t.displayName || null, r !== null ? r : s(t.type) || "Memo";
87
+ case S:
88
+ r = t._payload, t = t._init;
89
+ try {
90
+ return s(t(r));
91
+ } catch {
92
+ }
93
+ }
94
+ return null;
95
+ }
96
+ function j(t) {
97
+ return "" + t;
98
+ }
99
+ function c(t) {
100
+ try {
101
+ j(t);
102
+ var r = !1;
103
+ } catch {
104
+ r = !0;
105
+ }
106
+ if (r) {
107
+ r = console;
108
+ var h = r.error, C = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
109
+ return h.call(
110
+ r,
111
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
112
+ C
113
+ ), j(t);
114
+ }
115
+ }
116
+ function u(t) {
117
+ if (t === V) return "<>";
118
+ if (typeof t == "object" && t !== null && t.$$typeof === S)
119
+ return "<...>";
120
+ try {
121
+ var r = s(t);
122
+ return r ? "<" + r + ">" : "<...>";
123
+ } catch {
124
+ return "<...>";
125
+ }
126
+ }
127
+ function a() {
128
+ var t = i.A;
129
+ return t === null ? null : t.getOwner();
130
+ }
131
+ function x() {
132
+ return Error("react-stack-top-frame");
133
+ }
134
+ function p(t) {
135
+ if (R.call(t, "key")) {
136
+ var r = Object.getOwnPropertyDescriptor(t, "key").get;
137
+ if (r && r.isReactWarning) return !1;
138
+ }
139
+ return t.key !== void 0;
140
+ }
141
+ function o(t, r) {
142
+ function h() {
143
+ H || (H = !0, console.error(
144
+ "%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)",
145
+ r
146
+ ));
147
+ }
148
+ h.isReactWarning = !0, Object.defineProperty(t, "key", {
149
+ get: h,
150
+ configurable: !0
151
+ });
152
+ }
153
+ function D() {
154
+ var t = s(this.type);
155
+ return ue[t] || (ue[t] = !0, console.error(
156
+ "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."
157
+ )), t = this.props.ref, t !== void 0 ? t : null;
158
+ }
159
+ function g(t, r, h, C, Q, le) {
160
+ var T = h.ref;
161
+ return t = {
162
+ $$typeof: W,
163
+ type: t,
164
+ key: r,
165
+ props: h,
166
+ _owner: C
167
+ }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(t, "ref", {
168
+ enumerable: !1,
169
+ get: D
170
+ }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
171
+ configurable: !1,
172
+ enumerable: !1,
173
+ writable: !0,
174
+ value: 0
175
+ }), Object.defineProperty(t, "_debugInfo", {
176
+ configurable: !1,
177
+ enumerable: !1,
178
+ writable: !0,
179
+ value: null
180
+ }), Object.defineProperty(t, "_debugStack", {
181
+ configurable: !1,
182
+ enumerable: !1,
183
+ writable: !0,
184
+ value: Q
185
+ }), Object.defineProperty(t, "_debugTask", {
186
+ configurable: !1,
187
+ enumerable: !1,
188
+ writable: !0,
189
+ value: le
190
+ }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
191
+ }
192
+ function l(t, r, h, C, Q, le) {
193
+ var T = r.children;
194
+ if (T !== void 0)
195
+ if (C)
196
+ if (y(T)) {
197
+ for (C = 0; C < T.length; C++)
198
+ E(T[C]);
199
+ Object.freeze && Object.freeze(T);
200
+ } else
201
+ console.error(
202
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
203
+ );
204
+ else E(T);
205
+ if (R.call(r, "key")) {
206
+ T = s(t);
207
+ var L = Object.keys(r).filter(function(_) {
208
+ return _ !== "key";
209
+ });
210
+ C = 0 < L.length ? "{key: someKey, " + L.join(": ..., ") + ": ...}" : "{key: someKey}", re[T + C] || (L = 0 < L.length ? "{" + L.join(": ..., ") + ": ...}" : "{}", console.error(
211
+ `A props object containing a "key" prop is being spread into JSX:
212
+ let props = %s;
213
+ <%s {...props} />
214
+ React keys must be passed directly to JSX without using spread:
215
+ let props = %s;
216
+ <%s key={someKey} {...props} />`,
217
+ C,
218
+ T,
219
+ L,
220
+ T
221
+ ), re[T + C] = !0);
222
+ }
223
+ if (T = null, h !== void 0 && (c(h), T = "" + h), p(r) && (c(r.key), T = "" + r.key), "key" in r) {
224
+ h = {};
225
+ for (var m in r)
226
+ m !== "key" && (h[m] = r[m]);
227
+ } else h = r;
228
+ return T && o(
229
+ h,
230
+ typeof t == "function" ? t.displayName || t.name || "Unknown" : t
231
+ ), g(
232
+ t,
233
+ T,
234
+ h,
235
+ a(),
236
+ Q,
237
+ le
238
+ );
239
+ }
240
+ function E(t) {
241
+ A(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === S && (t._payload.status === "fulfilled" ? A(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
242
+ }
243
+ function A(t) {
244
+ return typeof t == "object" && t !== null && t.$$typeof === W;
245
+ }
246
+ var N = tt, W = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), V = Symbol.for("react.fragment"), B = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), d = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), O = Symbol.for("react.suspense_list"), I = Symbol.for("react.memo"), S = Symbol.for("react.lazy"), U = Symbol.for("react.activity"), K = Symbol.for("react.client.reference"), i = N.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, y = Array.isArray, $ = console.createTask ? console.createTask : function() {
247
+ return null;
248
+ };
249
+ N = {
250
+ react_stack_bottom_frame: function(t) {
251
+ return t();
252
+ }
253
+ };
254
+ var H, ue = {}, se = N.react_stack_bottom_frame.bind(
255
+ N,
256
+ x
257
+ )(), Z = $(u(x)), re = {};
258
+ ve.Fragment = V, ve.jsx = function(t, r, h) {
259
+ var C = 1e4 > i.recentlyCreatedOwnerStacks++;
260
+ return l(
261
+ t,
262
+ r,
263
+ h,
264
+ !1,
265
+ C ? Error("react-stack-top-frame") : se,
266
+ C ? $(u(t)) : Z
267
+ );
268
+ }, ve.jsxs = function(t, r, h) {
269
+ var C = 1e4 > i.recentlyCreatedOwnerStacks++;
270
+ return l(
271
+ t,
272
+ r,
273
+ h,
274
+ !0,
275
+ C ? Error("react-stack-top-frame") : se,
276
+ C ? $(u(t)) : Z
277
+ );
278
+ };
279
+ })()), ve;
280
+ }
281
+ var Ae;
282
+ function mt() {
283
+ return Ae || (Ae = 1, process.env.NODE_ENV === "production" ? Ne.exports = ut() : Ne.exports = dt()), Ne.exports;
284
+ }
285
+ var e = mt();
286
+ function Nt({
287
+ data: s,
288
+ loading: j = !1,
289
+ columns: c,
290
+ rowKey: u,
291
+ emptyText: a = "暂无数据",
292
+ searchActiveEmptyText: x = "未找到匹配的记录",
293
+ header: p,
294
+ pagination: o,
295
+ rowClassName: D,
296
+ onRow: g,
297
+ actions: l,
298
+ components: E,
299
+ renderCard: A,
300
+ renderTable: N,
301
+ renderActions: W
302
+ }) {
303
+ var T, L;
304
+ if (!E)
305
+ return /* @__PURE__ */ e.jsxs("div", { className: "p-4 text-center text-destructive", children: [
306
+ "错误:请通过 components prop 注入 UI 组件",
307
+ /* @__PURE__ */ e.jsx("br", {}),
308
+ /* @__PURE__ */ e.jsx("code", { className: "text-sm", children: 'import { Card, Table, Button, ... } from "@/components/ui"' })
309
+ ] });
310
+ const {
311
+ Card: J,
312
+ CardContent: V,
313
+ CardFooter: B,
314
+ Table: w,
315
+ TableBody: b,
316
+ TableCell: d,
317
+ TableHead: G,
318
+ TableHeader: q,
319
+ TableRow: O,
320
+ Button: I,
321
+ DropdownMenu: S,
322
+ DropdownMenuTrigger: U,
323
+ DropdownMenuContent: K,
324
+ DropdownMenuItem: i,
325
+ DropdownMenuSeparator: R,
326
+ Skeleton: y,
327
+ TableHeaderComponent: $,
328
+ TablePaginationComponent: H
329
+ } = E, ue = (m, _) => {
330
+ if (typeof u == "function")
331
+ return u(m);
332
+ const Y = m[u];
333
+ return Y != null ? String(Y) : `row-${_}`;
334
+ }, se = !!(p != null && p.searchValue && p.searchValue.trim().length > 0), Z = !!(l != null && l.render || (T = l == null ? void 0 : l.items) != null && T.length), re = (l == null ? void 0 : l.mode) ?? ((L = l == null ? void 0 : l.items) != null && L.length ? "collapsed" : "expanded"), t = (m) => m.separator === !0, r = (m, _) => !l || !Z ? null : re === "collapsed" && l.items && l.items.length > 0 ? /* @__PURE__ */ e.jsxs(S, { children: [
335
+ /* @__PURE__ */ e.jsx(U, { asChild: !0, children: /* @__PURE__ */ e.jsx(
336
+ I,
337
+ {
338
+ variant: "ghost",
339
+ className: "h-8 w-8 p-0",
340
+ "aria-label": "打开行操作菜单",
341
+ children: /* @__PURE__ */ e.jsx(rt, { className: "h-4 w-4" })
342
+ }
343
+ ) }),
344
+ /* @__PURE__ */ e.jsx(K, { align: "end", children: l.items.map(
345
+ (Y, de) => t(Y) ? /* @__PURE__ */ e.jsx(R, {}, `separator-${de}`) : /* @__PURE__ */ e.jsxs(
346
+ i,
347
+ {
348
+ onClick: () => Y.onClick(m, _),
349
+ className: Y.className,
350
+ children: [
351
+ Y.icon && /* @__PURE__ */ e.jsx("span", { className: "mr-2 h-4 w-4", children: Y.icon }),
352
+ Y.label
353
+ ]
354
+ },
355
+ `action-${de}`
356
+ )
357
+ ) })
358
+ ] }) : l.render ? l.render(m, _) : null, h = () => /* @__PURE__ */ e.jsx(q, { children: /* @__PURE__ */ e.jsxs(O, { className: "bg-muted/50 hover:bg-muted/50", children: [
359
+ c.map((m) => /* @__PURE__ */ e.jsx(
360
+ G,
361
+ {
362
+ className: `font-semibold text-foreground ${m.align === "center" ? "text-center" : m.align === "right" ? "text-right" : "text-left"}`,
363
+ style: { width: m.width },
364
+ children: m.title
365
+ },
366
+ String(m.key)
367
+ )),
368
+ Z && /* @__PURE__ */ e.jsx(G, { className: "text-right font-semibold text-foreground", children: (l == null ? void 0 : l.title) || "操作" })
369
+ ] }) }), C = () => j ? /* @__PURE__ */ e.jsx(b, { children: Array.from({ length: 5 }).map((m, _) => /* @__PURE__ */ e.jsxs(O, { children: [
370
+ c.map((Y) => /* @__PURE__ */ e.jsx(
371
+ d,
372
+ {
373
+ style: { width: Y.width },
374
+ className: Y.align === "center" ? "text-center" : Y.align === "right" ? "text-right" : "",
375
+ children: /* @__PURE__ */ e.jsx(y, { className: "h-4 w-full" })
376
+ },
377
+ String(Y.key)
378
+ )),
379
+ Z && /* @__PURE__ */ e.jsx(d, { children: /* @__PURE__ */ e.jsx(y, { className: "ml-auto h-4 w-8" }) })
380
+ ] }, _)) }) : s.length === 0 ? /* @__PURE__ */ e.jsx(b, { children: /* @__PURE__ */ e.jsx(O, { children: /* @__PURE__ */ e.jsx(
381
+ d,
382
+ {
383
+ colSpan: c.length + (Z ? 1 : 0),
384
+ className: "py-8 text-center text-muted-foreground",
385
+ children: se ? x : a
386
+ }
387
+ ) }) }) : /* @__PURE__ */ e.jsx(b, { children: s.map((m, _) => {
388
+ const Y = ue(m, _), de = g == null ? void 0 : g(m, _), ie = D == null ? void 0 : D(m, _);
389
+ return /* @__PURE__ */ e.jsxs(
390
+ O,
391
+ {
392
+ className: `${ie || ""} hover:bg-muted/50`,
393
+ ...de,
394
+ children: [
395
+ c.map((te) => {
396
+ const me = m[te.key], he = te.render ? te.render(me, m, _) : me;
397
+ return /* @__PURE__ */ e.jsx(
398
+ d,
399
+ {
400
+ className: te.align === "center" ? "text-center" : te.align === "right" ? "text-right" : "",
401
+ children: he
402
+ },
403
+ String(te.key)
404
+ );
405
+ }),
406
+ Z && /* @__PURE__ */ e.jsx(d, { className: "text-right", children: W ? W(m, _) : r(m, _) })
407
+ ]
408
+ },
409
+ Y
410
+ );
411
+ }) }), Q = (m) => /* @__PURE__ */ e.jsxs(J, { children: [
412
+ p && /* @__PURE__ */ e.jsx("div", { className: "p-6 pb-0", children: /* @__PURE__ */ e.jsx($, { ...p }) }),
413
+ /* @__PURE__ */ e.jsx(V, { className: "p-0", children: m }),
414
+ (o == null ? void 0 : o.show) !== !1 && o && /* @__PURE__ */ e.jsx(B, { className: "border-t py-4", children: /* @__PURE__ */ e.jsx(
415
+ H,
416
+ {
417
+ currentPage: o.currentPage,
418
+ pageSize: o.pageSize,
419
+ total: o.total,
420
+ onPageChange: o.onPageChange,
421
+ onPageSizeChange: o.onPageSizeChange,
422
+ pageSizeOptions: o.pageSizeOptions,
423
+ showPageSizeSelector: o.showPageSizeSelector,
424
+ showJumpToPage: o.showJumpToPage,
425
+ showTotal: o.showTotal,
426
+ searchActive: se
427
+ }
428
+ ) })
429
+ ] }), le = (m, _) => /* @__PURE__ */ e.jsxs(w, { children: [
430
+ m,
431
+ _
432
+ ] });
433
+ return A ? A(
434
+ N ? N(h(), C()) : le(h(), C())
435
+ ) : Q(
436
+ N ? N(h(), C()) : le(h(), C())
437
+ );
438
+ }
439
+ function wt({
440
+ open: s,
441
+ onOpenChange: j,
442
+ title: c,
443
+ description: u,
444
+ onConfirm: a,
445
+ loading: x = !1,
446
+ confirmText: p = "确认删除",
447
+ cancelText: o = "取消",
448
+ confirmButtonVariant: D = "destructive",
449
+ verification: g,
450
+ components: l,
451
+ loadingIcon: E
452
+ }) {
453
+ const [A, N] = M("");
454
+ if (ee(() => {
455
+ s && N("");
456
+ }, [s, g == null ? void 0 : g.targetValue]), !l)
457
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
458
+ const {
459
+ Dialog: W,
460
+ DialogContent: J,
461
+ DialogHeader: V,
462
+ DialogFooter: B,
463
+ DialogTitle: w,
464
+ DialogDescription: b,
465
+ Button: d,
466
+ Input: G,
467
+ Label: q
468
+ } = l, O = g ? A !== g.targetValue : !1, I = () => {
469
+ O || a();
470
+ };
471
+ return /* @__PURE__ */ e.jsx(W, { open: s, onOpenChange: j, children: /* @__PURE__ */ e.jsxs(J, { children: [
472
+ /* @__PURE__ */ e.jsxs(V, { children: [
473
+ /* @__PURE__ */ e.jsx(w, { asChild: !0, children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: c }) }),
474
+ /* @__PURE__ */ e.jsx(b, { asChild: !0, children: /* @__PURE__ */ e.jsx("div", { children: u }) })
475
+ ] }),
476
+ g && /* @__PURE__ */ e.jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
477
+ /* @__PURE__ */ e.jsx(q, { htmlFor: "confirm-input", children: g.label || "请输入以确认" }),
478
+ /* @__PURE__ */ e.jsx(
479
+ G,
480
+ {
481
+ id: "confirm-input",
482
+ value: A,
483
+ onChange: (S) => N(S.target.value),
484
+ placeholder: g.placeholder,
485
+ disabled: x
486
+ }
487
+ )
488
+ ] }) }),
489
+ /* @__PURE__ */ e.jsxs(B, { children: [
490
+ /* @__PURE__ */ e.jsx(
491
+ d,
492
+ {
493
+ variant: "outline",
494
+ onClick: () => j(!1),
495
+ disabled: x,
496
+ children: o
497
+ }
498
+ ),
499
+ /* @__PURE__ */ e.jsxs(
500
+ d,
501
+ {
502
+ variant: D,
503
+ onClick: I,
504
+ disabled: O || x,
505
+ children: [
506
+ x && /* @__PURE__ */ e.jsx("span", { className: "mr-2", children: E || /* @__PURE__ */ e.jsxs(
507
+ "svg",
508
+ {
509
+ className: "h-4 w-4 animate-spin",
510
+ fill: "none",
511
+ viewBox: "0 0 24 24",
512
+ children: [
513
+ /* @__PURE__ */ e.jsx(
514
+ "circle",
515
+ {
516
+ className: "opacity-25",
517
+ cx: "12",
518
+ cy: "12",
519
+ r: "10",
520
+ stroke: "currentColor",
521
+ strokeWidth: "4"
522
+ }
523
+ ),
524
+ /* @__PURE__ */ e.jsx(
525
+ "path",
526
+ {
527
+ className: "opacity-75",
528
+ fill: "currentColor",
529
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
530
+ }
531
+ )
532
+ ]
533
+ }
534
+ ) }),
535
+ p
536
+ ]
537
+ }
538
+ )
539
+ ] })
540
+ ] }) });
541
+ }
542
+ function kt({
543
+ title: s,
544
+ searchPlaceholder: j = "搜索...",
545
+ searchValue: c = "",
546
+ onSearchChange: u,
547
+ onSearch: a,
548
+ showSearch: x = !0,
549
+ action: p,
550
+ actionLabel: o,
551
+ onActionClick: D,
552
+ loading: g = !1,
553
+ components: l
554
+ }) {
555
+ if (!l)
556
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
557
+ const { Input: E, Button: A } = l, N = (W) => {
558
+ W.key === "Enter" && a && a();
559
+ };
560
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4 p-1", children: [
561
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
562
+ /* @__PURE__ */ e.jsx("div", { className: "text-lg font-semibold leading-none tracking-tight", children: s }),
563
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
564
+ p && /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: p }),
565
+ !p && o && D && /* @__PURE__ */ e.jsxs(A, { onClick: D, disabled: g, size: "sm", children: [
566
+ /* @__PURE__ */ e.jsx(nt, { className: "mr-2 h-4 w-4" }),
567
+ o
568
+ ] })
569
+ ] })
570
+ ] }),
571
+ x && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
572
+ /* @__PURE__ */ e.jsxs("div", { className: "relative max-w-sm flex-1", children: [
573
+ /* @__PURE__ */ e.jsx(lt, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
574
+ /* @__PURE__ */ e.jsx(
575
+ E,
576
+ {
577
+ placeholder: j,
578
+ value: c,
579
+ onChange: (W) => u == null ? void 0 : u(W.target.value),
580
+ onKeyPress: N,
581
+ className: "h-9 pl-8",
582
+ disabled: g
583
+ }
584
+ )
585
+ ] }),
586
+ a && /* @__PURE__ */ e.jsx(
587
+ A,
588
+ {
589
+ onClick: a,
590
+ disabled: g,
591
+ variant: "secondary",
592
+ size: "sm",
593
+ children: "搜索"
594
+ }
595
+ )
596
+ ] })
597
+ ] });
598
+ }
599
+ function Tt({
600
+ currentPage: s,
601
+ pageSize: j,
602
+ total: c,
603
+ onPageChange: u,
604
+ onPageSizeChange: a,
605
+ pageSizeOptions: x = [10, 20, 50],
606
+ showPageSizeSelector: p = !0,
607
+ showJumpToPage: o = !0,
608
+ showTotal: D = !0,
609
+ searchActive: g = !1,
610
+ components: l
611
+ }) {
612
+ const [E, A] = M(String(s + 1));
613
+ if (ee(() => {
614
+ A(String(s + 1));
615
+ }, [s]), !l)
616
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
617
+ const {
618
+ Button: N,
619
+ Select: W,
620
+ SelectTrigger: J,
621
+ SelectContent: V,
622
+ SelectItem: B,
623
+ SelectValue: w
624
+ } = l, b = Math.ceil(c / j), d = Math.max(b, 1), G = s * j + 1, q = Math.min((s + 1) * j, c), O = Array.from(
625
+ /* @__PURE__ */ new Set([...x, j])
626
+ ).sort((i, R) => i - R), I = p && !!a, S = d > 1, U = (i) => {
627
+ const R = Math.max(0, Math.min(i, d - 1));
628
+ R !== s && u(R);
629
+ }, K = (() => {
630
+ if (d <= 7)
631
+ return Array.from({ length: d }, ($, H) => H);
632
+ const i = /* @__PURE__ */ new Set([
633
+ 0,
634
+ 1,
635
+ d - 2,
636
+ d - 1,
637
+ s - 1,
638
+ s,
639
+ s + 1
640
+ ]), R = Array.from(i).filter(($) => $ >= 0 && $ < d).sort(($, H) => $ - H), y = [];
641
+ for (const $ of R) {
642
+ const H = y[y.length - 1];
643
+ typeof H == "number" && $ - H > 1 && y.push("ellipsis"), y.push($);
644
+ }
645
+ return y;
646
+ })();
647
+ return c === 0 ? null : /* @__PURE__ */ e.jsxs(
648
+ "div",
649
+ {
650
+ className: `flex w-full items-center gap-3 ${D ? "justify-between" : "justify-end"}`,
651
+ children: [
652
+ D && /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: g ? `找到 ${c} 条匹配记录` : c > 0 ? `显示 ${G} - ${q} 条,共 ${c} 条记录` : "暂无数据" }),
653
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [
654
+ I && /* @__PURE__ */ e.jsxs("div", { className: "mr-2 flex items-center gap-2", children: [
655
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "每页" }),
656
+ /* @__PURE__ */ e.jsxs(
657
+ W,
658
+ {
659
+ value: String(j),
660
+ onValueChange: (i) => {
661
+ const R = Number(i);
662
+ Number.isNaN(R) || R === j || !a || a(R);
663
+ },
664
+ children: [
665
+ /* @__PURE__ */ e.jsx(J, { className: "h-8 w-[90px]", children: /* @__PURE__ */ e.jsx(w, {}) }),
666
+ /* @__PURE__ */ e.jsx(V, { children: O.map((i) => /* @__PURE__ */ e.jsx(B, { value: String(i), children: i }, i)) })
667
+ ]
668
+ }
669
+ ),
670
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "条" })
671
+ ] }),
672
+ /* @__PURE__ */ e.jsxs("div", { className: "mr-4 text-sm text-muted-foreground", children: [
673
+ "第 ",
674
+ s + 1,
675
+ " 页,共 ",
676
+ d,
677
+ " 页"
678
+ ] }),
679
+ /* @__PURE__ */ e.jsx(
680
+ N,
681
+ {
682
+ variant: "outline",
683
+ size: "icon",
684
+ onClick: () => U(s - 1),
685
+ disabled: s === 0 || !S,
686
+ "aria-label": "上一页",
687
+ children: /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4" })
688
+ }
689
+ ),
690
+ /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-1", children: K.map(
691
+ (i, R) => i === "ellipsis" ? /* @__PURE__ */ e.jsx(
692
+ "span",
693
+ {
694
+ className: "inline-flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",
695
+ children: "..."
696
+ },
697
+ `ellipsis-${R}`
698
+ ) : /* @__PURE__ */ e.jsx(
699
+ N,
700
+ {
701
+ variant: i === s ? "default" : "outline",
702
+ size: "sm",
703
+ onClick: () => U(i),
704
+ disabled: i === s,
705
+ "aria-current": i === s ? "page" : void 0,
706
+ children: i + 1
707
+ },
708
+ i
709
+ )
710
+ ) }),
711
+ /* @__PURE__ */ e.jsx(
712
+ N,
713
+ {
714
+ variant: "outline",
715
+ size: "icon",
716
+ onClick: () => U(s + 1),
717
+ disabled: s >= d - 1 || !S,
718
+ "aria-label": "下一页",
719
+ children: /* @__PURE__ */ e.jsx(ke, { className: "h-4 w-4" })
720
+ }
721
+ ),
722
+ o && /* @__PURE__ */ e.jsxs(
723
+ "form",
724
+ {
725
+ className: "ml-1 flex items-center gap-2",
726
+ onSubmit: (i) => {
727
+ i.preventDefault();
728
+ const R = Number.parseInt(E, 10);
729
+ Number.isNaN(R) || U(R - 1);
730
+ },
731
+ children: [
732
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "跳至" }),
733
+ /* @__PURE__ */ e.jsx(
734
+ "input",
735
+ {
736
+ type: "number",
737
+ min: 1,
738
+ max: d,
739
+ value: E,
740
+ disabled: !S,
741
+ onChange: (i) => A(i.target.value),
742
+ className: "h-8 w-16 rounded-md border border-input bg-background px-2 text-sm",
743
+ "aria-label": "跳转页码"
744
+ }
745
+ ),
746
+ /* @__PURE__ */ e.jsx(
747
+ N,
748
+ {
749
+ type: "submit",
750
+ variant: "outline",
751
+ size: "sm",
752
+ disabled: !S,
753
+ children: "跳转"
754
+ }
755
+ )
756
+ ]
757
+ }
758
+ )
759
+ ] })
760
+ ]
761
+ }
762
+ );
763
+ }
764
+ const ft = [
765
+ {
766
+ value: "light",
767
+ label: "浅色",
768
+ icon: /* @__PURE__ */ e.jsxs(
769
+ "svg",
770
+ {
771
+ className: "h-4 w-4",
772
+ fill: "none",
773
+ viewBox: "0 0 24 24",
774
+ stroke: "currentColor",
775
+ children: [
776
+ /* @__PURE__ */ e.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
777
+ /* @__PURE__ */ e.jsx(
778
+ "path",
779
+ {
780
+ className: "opacity-75",
781
+ d: "M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41",
782
+ strokeWidth: "2",
783
+ strokeLinecap: "round"
784
+ }
785
+ )
786
+ ]
787
+ }
788
+ )
789
+ },
790
+ {
791
+ value: "dark",
792
+ label: "深色",
793
+ icon: /* @__PURE__ */ e.jsx(
794
+ "svg",
795
+ {
796
+ className: "h-4 w-4",
797
+ fill: "none",
798
+ viewBox: "0 0 24 24",
799
+ stroke: "currentColor",
800
+ children: /* @__PURE__ */ e.jsx(
801
+ "path",
802
+ {
803
+ d: "M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",
804
+ strokeWidth: "2",
805
+ strokeLinecap: "round",
806
+ strokeLinejoin: "round"
807
+ }
808
+ )
809
+ }
810
+ )
811
+ },
812
+ {
813
+ value: "system",
814
+ label: "跟随系统",
815
+ icon: /* @__PURE__ */ e.jsxs(
816
+ "svg",
817
+ {
818
+ className: "h-4 w-4",
819
+ fill: "none",
820
+ viewBox: "0 0 24 24",
821
+ stroke: "currentColor",
822
+ children: [
823
+ /* @__PURE__ */ e.jsx(
824
+ "rect",
825
+ {
826
+ x: "2",
827
+ y: "3",
828
+ width: "20",
829
+ height: "14",
830
+ rx: "2",
831
+ ry: "2",
832
+ strokeWidth: "2"
833
+ }
834
+ ),
835
+ /* @__PURE__ */ e.jsx("path", { d: "M8 21h8m-4-4v4", strokeWidth: "2", strokeLinecap: "round" })
836
+ ]
837
+ }
838
+ )
839
+ }
840
+ ];
841
+ function Pt({
842
+ value: s,
843
+ onValueChange: j,
844
+ themes: c = ft,
845
+ triggerVariant: u = "ghost",
846
+ triggerSize: a = "icon",
847
+ triggerClassName: x,
848
+ iconSize: p = 16,
849
+ showCurrentIcon: o = !0,
850
+ enableSSRHandling: D = !0,
851
+ triggerContent: g,
852
+ components: l,
853
+ themeIcons: E
854
+ }) {
855
+ const [A, N] = M(!1);
856
+ if (ee(() => {
857
+ N(!0);
858
+ }, []), D && !A)
859
+ return null;
860
+ if (!l)
861
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
862
+ const {
863
+ DropdownMenu: W,
864
+ DropdownMenuTrigger: J,
865
+ DropdownMenuContent: V,
866
+ DropdownMenuRadioGroup: B,
867
+ DropdownMenuRadioItem: w,
868
+ Button: b
869
+ } = l, d = (I) => {
870
+ if (E && E[I])
871
+ return E[I];
872
+ const S = c.find((U) => U.value === I);
873
+ return S == null ? void 0 : S.icon;
874
+ }, G = d(s), q = o ? G : null, O = p ? { width: p, height: p } : {};
875
+ return /* @__PURE__ */ e.jsxs(W, { children: [
876
+ /* @__PURE__ */ e.jsx(J, { asChild: !0, children: /* @__PURE__ */ e.jsx(
877
+ b,
878
+ {
879
+ variant: u,
880
+ size: a,
881
+ className: x,
882
+ children: g || /* @__PURE__ */ e.jsx(
883
+ "span",
884
+ {
885
+ style: O,
886
+ className: "inline-flex items-center justify-center",
887
+ children: q
888
+ }
889
+ )
890
+ }
891
+ ) }),
892
+ /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsx(B, { value: s, onValueChange: j, children: c.map((I) => /* @__PURE__ */ e.jsxs(w, { value: I.value, children: [
893
+ /* @__PURE__ */ e.jsx("span", { className: "mr-2 inline-flex items-center", children: d(I.value) }),
894
+ /* @__PURE__ */ e.jsx("span", { children: I.label })
895
+ ] }, I.value)) }) })
896
+ ] });
897
+ }
898
+ const xt = [
899
+ {
900
+ value: "light",
901
+ label: "浅色",
902
+ icon: /* @__PURE__ */ e.jsxs(
903
+ "svg",
904
+ {
905
+ className: "h-4 w-4",
906
+ fill: "none",
907
+ viewBox: "0 0 24 24",
908
+ stroke: "currentColor",
909
+ children: [
910
+ /* @__PURE__ */ e.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
911
+ /* @__PURE__ */ e.jsx(
912
+ "path",
913
+ {
914
+ className: "opacity-75",
915
+ d: "M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41",
916
+ strokeWidth: "2",
917
+ strokeLinecap: "round"
918
+ }
919
+ )
920
+ ]
921
+ }
922
+ )
923
+ },
924
+ {
925
+ value: "dark",
926
+ label: "深色",
927
+ icon: /* @__PURE__ */ e.jsx(
928
+ "svg",
929
+ {
930
+ className: "h-4 w-4",
931
+ fill: "none",
932
+ viewBox: "0 0 24 24",
933
+ stroke: "currentColor",
934
+ children: /* @__PURE__ */ e.jsx(
935
+ "path",
936
+ {
937
+ d: "M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",
938
+ strokeWidth: "2",
939
+ strokeLinecap: "round",
940
+ strokeLinejoin: "round"
941
+ }
942
+ )
943
+ }
944
+ )
945
+ },
946
+ {
947
+ value: "system",
948
+ label: "跟随系统",
949
+ icon: /* @__PURE__ */ e.jsxs(
950
+ "svg",
951
+ {
952
+ className: "h-4 w-4",
953
+ fill: "none",
954
+ viewBox: "0 0 24 24",
955
+ stroke: "currentColor",
956
+ children: [
957
+ /* @__PURE__ */ e.jsx(
958
+ "rect",
959
+ {
960
+ x: "2",
961
+ y: "3",
962
+ width: "20",
963
+ height: "14",
964
+ rx: "2",
965
+ ry: "2",
966
+ strokeWidth: "2"
967
+ }
968
+ ),
969
+ /* @__PURE__ */ e.jsx("path", { d: "M8 21h8m-4-4v4", strokeWidth: "2", strokeLinecap: "round" })
970
+ ]
971
+ }
972
+ )
973
+ }
974
+ ];
975
+ function Et({
976
+ value: s,
977
+ onValueChange: j,
978
+ themes: c = xt,
979
+ iconSize: u = 16,
980
+ components: a,
981
+ themeIcons: x
982
+ }) {
983
+ if (!a)
984
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
985
+ const { DropdownMenuRadioGroup: p, DropdownMenuRadioItem: o } = a, D = (l) => {
986
+ if (x && x[l])
987
+ return x[l];
988
+ const E = c.find((A) => A.value === l);
989
+ return E == null ? void 0 : E.icon;
990
+ }, g = u ? { width: u, height: u } : {};
991
+ return /* @__PURE__ */ e.jsx(p, { value: s, onValueChange: j, children: c.map((l) => /* @__PURE__ */ e.jsxs(o, { value: l.value, children: [
992
+ /* @__PURE__ */ e.jsx("span", { className: "mr-2 inline-flex items-center", style: g, children: D(l.value) }),
993
+ /* @__PURE__ */ e.jsx("span", { children: l.label })
994
+ ] }, l.value)) });
995
+ }
996
+ function Rt({
997
+ url: s,
998
+ initialPage: j = 1,
999
+ initialScale: c = 1,
1000
+ scale: u,
1001
+ onScaleChange: a,
1002
+ minScale: x = 0.5,
1003
+ maxScale: p = 3,
1004
+ currentPage: o,
1005
+ onPageChange: D,
1006
+ showToolbar: g = !0,
1007
+ showPagination: l = !0,
1008
+ enableHotkeys: E = !0,
1009
+ className: A,
1010
+ containerClassName: N,
1011
+ pageClassName: W,
1012
+ components: J,
1013
+ onLoadSuccess: V,
1014
+ onLoadError: B,
1015
+ loadingText: w = "加载中...",
1016
+ errorText: b = "加载失败"
1017
+ }) {
1018
+ const [d, G] = M(null), [q, O] = M(j), [I, S] = M(c), [U, K] = M(!0), [i, R] = M(null), [y, $] = M(0), [H, ue] = M(!1), se = ge(null), Z = ge(null), [re, t] = M(null), r = o ?? q, h = u ?? I, C = Oe(() => {
1019
+ const f = [r];
1020
+ return r > 1 && f.push(r - 1), r < y && f.push(r + 1), f;
1021
+ }, [r, y]), Q = ne(
1022
+ (f) => {
1023
+ const P = Math.max(y, 1), v = Math.min(Math.max(f, 1), P);
1024
+ o === void 0 && O(v), D == null || D(v);
1025
+ },
1026
+ [y, o, D]
1027
+ ), le = ne(() => {
1028
+ r > 1 && Q(r - 1);
1029
+ }, [r, Q]), T = ne(() => {
1030
+ r < y && Q(r + 1);
1031
+ }, [r, y, Q]), L = ne(() => {
1032
+ const f = Math.min(h + 0.25, p);
1033
+ u === void 0 && S(f), a == null || a(f);
1034
+ }, [h, p, u, a]), m = ne(() => {
1035
+ const f = Math.max(h - 0.25, x);
1036
+ u === void 0 && S(f), a == null || a(f);
1037
+ }, [h, x, u, a]), _ = ne(async () => {
1038
+ var f, P, v;
1039
+ if (!(typeof document > "u")) {
1040
+ if (!document.fullscreenElement) {
1041
+ await ((P = (f = se.current) == null ? void 0 : f.requestFullscreen) == null ? void 0 : P.call(f));
1042
+ return;
1043
+ }
1044
+ await ((v = document.exitFullscreen) == null ? void 0 : v.call(document));
1045
+ }
1046
+ }, []);
1047
+ if (ee(() => {
1048
+ let f = !0;
1049
+ return (async () => {
1050
+ try {
1051
+ const v = await import("./index-0y7GsdPm.js");
1052
+ if (typeof window < "u") {
1053
+ const F = v.pdfjs, ae = F == null ? void 0 : F.version;
1054
+ F != null && F.GlobalWorkerOptions && ae && (F.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${ae}/build/pdf.worker.min.mjs`);
1055
+ }
1056
+ f && t(v);
1057
+ } catch (v) {
1058
+ if (f) {
1059
+ const F = v instanceof Error ? v : new Error("无法加载 react-pdf 库");
1060
+ R(F), K(!1), B == null || B(F);
1061
+ }
1062
+ }
1063
+ })(), () => {
1064
+ f = !1;
1065
+ };
1066
+ }, []), ee(() => {
1067
+ if (!re || !s) return;
1068
+ let f = !0;
1069
+ return (async () => {
1070
+ K(!0), R(null);
1071
+ try {
1072
+ const { Document: v } = re;
1073
+ if (!v)
1074
+ throw new Error("react-pdf Document 组件不可用");
1075
+ const F = re.pdfjs.getDocument(s);
1076
+ Z.current = F;
1077
+ const ae = await F.promise;
1078
+ f && (G(ae), $(ae.numPages), o === void 0 && O(
1079
+ (Ee) => Math.max(1, Math.min(Ee, ae.numPages))
1080
+ ), K(!1), V == null || V(ae));
1081
+ } catch (v) {
1082
+ if (f) {
1083
+ const F = v instanceof Error ? v : new Error("PDF 加载失败");
1084
+ R(F), K(!1), B == null || B(F);
1085
+ }
1086
+ }
1087
+ })(), () => {
1088
+ f = !1, Z.current && typeof Z.current.destroy == "function" && (Z.current.destroy(), Z.current = null);
1089
+ };
1090
+ }, [re, s, V, B]), ee(() => {
1091
+ if (typeof document > "u") return;
1092
+ const f = () => {
1093
+ ue(document.fullscreenElement === se.current);
1094
+ };
1095
+ return document.addEventListener("fullscreenchange", f), () => {
1096
+ document.removeEventListener("fullscreenchange", f);
1097
+ };
1098
+ }, []), ee(() => {
1099
+ if (!E) return;
1100
+ const f = (P) => {
1101
+ const v = document.activeElement;
1102
+ v && (v.tagName === "INPUT" || v.getAttribute("role") === "input") || ((P.ctrlKey || P.metaKey) && (P.key === "=" || P.key === "+") ? (P.preventDefault(), L()) : (P.ctrlKey || P.metaKey) && P.key === "-" ? (P.preventDefault(), m()) : P.key === "ArrowLeft" ? (P.preventDefault(), le()) : P.key === "ArrowRight" ? (P.preventDefault(), T()) : (P.key === "f" || P.key === "F") && (P.preventDefault(), _()));
1103
+ };
1104
+ return document.addEventListener("keydown", f), () => {
1105
+ document.removeEventListener("keydown", f);
1106
+ };
1107
+ }, [
1108
+ E,
1109
+ L,
1110
+ m,
1111
+ le,
1112
+ T,
1113
+ _
1114
+ ]), !J)
1115
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
1116
+ const {
1117
+ Card: Y,
1118
+ CardContent: de,
1119
+ Button: ie,
1120
+ Input: te,
1121
+ Skeleton: me
1122
+ } = J, he = () => g ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1123
+ /* @__PURE__ */ e.jsx(
1124
+ ie,
1125
+ {
1126
+ variant: "outline",
1127
+ size: "sm",
1128
+ onClick: m,
1129
+ disabled: h <= x,
1130
+ children: /* @__PURE__ */ e.jsx(Ie, {})
1131
+ }
1132
+ ),
1133
+ /* @__PURE__ */ e.jsxs("span", { className: "text-sm", children: [
1134
+ Math.round(h * 100),
1135
+ "%"
1136
+ ] }),
1137
+ /* @__PURE__ */ e.jsx(
1138
+ ie,
1139
+ {
1140
+ variant: "outline",
1141
+ size: "sm",
1142
+ onClick: L,
1143
+ disabled: h >= p,
1144
+ children: /* @__PURE__ */ e.jsx(Fe, {})
1145
+ }
1146
+ ),
1147
+ /* @__PURE__ */ e.jsx(
1148
+ ie,
1149
+ {
1150
+ variant: "outline",
1151
+ size: "icon",
1152
+ onClick: () => {
1153
+ _();
1154
+ },
1155
+ children: H ? /* @__PURE__ */ e.jsx(Se, {}) : /* @__PURE__ */ e.jsx($e, {})
1156
+ }
1157
+ )
1158
+ ] }) : null, be = () => l ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1159
+ /* @__PURE__ */ e.jsx(
1160
+ ie,
1161
+ {
1162
+ variant: "outline",
1163
+ size: "icon",
1164
+ onClick: le,
1165
+ disabled: r <= 1,
1166
+ children: /* @__PURE__ */ e.jsx(we, {})
1167
+ }
1168
+ ),
1169
+ te ? /* @__PURE__ */ e.jsx(
1170
+ te,
1171
+ {
1172
+ type: "number",
1173
+ min: 1,
1174
+ max: Math.max(y, 1),
1175
+ value: r,
1176
+ onChange: (f) => Q(parseInt(f.target.value, 10) || 1),
1177
+ className: "w-16 text-center"
1178
+ }
1179
+ ) : /* @__PURE__ */ e.jsx(
1180
+ "input",
1181
+ {
1182
+ type: "number",
1183
+ min: 1,
1184
+ max: Math.max(y, 1),
1185
+ value: r,
1186
+ onChange: (f) => Q(parseInt(f.target.value, 10) || 1),
1187
+ className: "w-16 rounded-md border border-input bg-background px-2 text-center text-sm"
1188
+ }
1189
+ ),
1190
+ /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-muted-foreground", children: [
1191
+ "/ ",
1192
+ y
1193
+ ] }),
1194
+ /* @__PURE__ */ e.jsx(
1195
+ ie,
1196
+ {
1197
+ variant: "outline",
1198
+ size: "icon",
1199
+ onClick: T,
1200
+ disabled: r >= y,
1201
+ children: /* @__PURE__ */ e.jsx(ke, {})
1202
+ }
1203
+ )
1204
+ ] }) : null, ye = () => !g && !l ? null : /* @__PURE__ */ e.jsxs(
1205
+ "div",
1206
+ {
1207
+ "data-testid": "pdf-operations-bar",
1208
+ className: "flex items-center justify-between gap-4 border-b px-4 py-2",
1209
+ children: [
1210
+ he(),
1211
+ be()
1212
+ ]
1213
+ }
1214
+ ), Te = () => /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center space-y-4 p-8", children: [
1215
+ /* @__PURE__ */ e.jsx(me, { className: "h-8 w-32" }),
1216
+ /* @__PURE__ */ e.jsx(me, { className: "h-64 w-full max-w-2xl" }),
1217
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: w })
1218
+ ] }), fe = () => /* @__PURE__ */ e.jsx("div", { className: "flex flex-col items-center justify-center space-y-4 p-8", children: /* @__PURE__ */ e.jsxs("div", { className: "text-center text-destructive", children: [
1219
+ /* @__PURE__ */ e.jsx("p", { className: "font-medium", children: b }),
1220
+ i && /* @__PURE__ */ e.jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: i.message })
1221
+ ] }) }), Pe = () => {
1222
+ if (!re || !d) return null;
1223
+ const { Page: f } = re;
1224
+ return /* @__PURE__ */ e.jsx(
1225
+ "div",
1226
+ {
1227
+ className: `flex flex-col items-center justify-center ${H ? "h-[calc(100vh-56px)] overflow-auto" : "overflow-visible"}`,
1228
+ children: C.map((P) => /* @__PURE__ */ e.jsx(
1229
+ "div",
1230
+ {
1231
+ className: W,
1232
+ style: {
1233
+ display: P === r ? "block" : "none"
1234
+ },
1235
+ children: /* @__PURE__ */ e.jsx(
1236
+ f,
1237
+ {
1238
+ pdf: d,
1239
+ pageNumber: P,
1240
+ scale: h,
1241
+ renderTextLayer: !1,
1242
+ renderAnnotationLayer: !1,
1243
+ className: "shadow-md"
1244
+ }
1245
+ )
1246
+ },
1247
+ P
1248
+ ))
1249
+ }
1250
+ );
1251
+ };
1252
+ return /* @__PURE__ */ e.jsx("div", { ref: se, children: /* @__PURE__ */ e.jsxs(Y, { className: A, children: [
1253
+ ye(),
1254
+ /* @__PURE__ */ e.jsx(de, { className: N, children: U ? Te() : i ? fe() : Pe() })
1255
+ ] }) });
1256
+ }
1257
+ const ze = st(
1258
+ ({
1259
+ thumbnail: s,
1260
+ isCurrentPage: j,
1261
+ onClick: c
1262
+ }) => /* @__PURE__ */ e.jsxs(
1263
+ "div",
1264
+ {
1265
+ className: `flex w-full flex-col items-center rounded p-1 ${j ? "bg-primary/10" : ""}`,
1266
+ children: [
1267
+ /* @__PURE__ */ e.jsx(
1268
+ "img",
1269
+ {
1270
+ src: s.url,
1271
+ alt: `Page ${s.pageNumber}`,
1272
+ className: "w-48 cursor-pointer border transition-opacity hover:opacity-80",
1273
+ onClick: c,
1274
+ onKeyDown: (u) => {
1275
+ (u.key === "Enter" || u.key === " ") && (u.preventDefault(), c());
1276
+ },
1277
+ role: "button",
1278
+ tabIndex: 0
1279
+ }
1280
+ ),
1281
+ /* @__PURE__ */ e.jsxs("span", { className: "mt-1 text-sm", children: [
1282
+ "第 ",
1283
+ s.pageNumber,
1284
+ " 页"
1285
+ ] })
1286
+ ]
1287
+ }
1288
+ )
1289
+ );
1290
+ ze.displayName = "PDFThumbnail";
1291
+ const We = ({
1292
+ bookmark: s,
1293
+ depth: j,
1294
+ onClick: c
1295
+ }) => /* @__PURE__ */ e.jsxs("div", { style: { paddingLeft: `${j * 16}px` }, children: [
1296
+ /* @__PURE__ */ e.jsx(
1297
+ "button",
1298
+ {
1299
+ onClick: () => c(s),
1300
+ className: "w-full rounded px-2 py-1 text-left text-sm hover:bg-primary/10 hover:text-primary",
1301
+ children: s.title
1302
+ }
1303
+ ),
1304
+ s.items && s.items.map((u, a) => /* @__PURE__ */ e.jsx(
1305
+ We,
1306
+ {
1307
+ bookmark: u,
1308
+ depth: j + 1,
1309
+ onClick: c
1310
+ },
1311
+ `${s.title}-${a}`
1312
+ ))
1313
+ ] });
1314
+ function ht({
1315
+ pdfDocument: s,
1316
+ currentPage: j,
1317
+ onPageClick: c,
1318
+ components: u
1319
+ }) {
1320
+ const [a, x] = M([]), [p, o] = M([]), [D, g] = M(!0), { Tabs: l, TabsList: E, TabsTrigger: A, TabsContent: N, ScrollArea: W, Skeleton: J } = u;
1321
+ ee(() => {
1322
+ (async () => {
1323
+ if (!s) return;
1324
+ g(!0);
1325
+ const b = [];
1326
+ for (let d = 1; d <= s.numPages; d++)
1327
+ try {
1328
+ const G = await s.getPage(d), q = G.getViewport({ scale: 0.2 }), O = document.createElement("canvas"), I = O.getContext("2d");
1329
+ if (!I) continue;
1330
+ O.width = q.width, O.height = q.height, await G.render({
1331
+ canvasContext: I,
1332
+ viewport: q,
1333
+ canvas: O
1334
+ }).promise, b.push({
1335
+ pageNumber: d,
1336
+ url: O.toDataURL()
1337
+ });
1338
+ } catch (G) {
1339
+ console.error(`Error loading thumbnail for page ${d}:`, G);
1340
+ }
1341
+ x(b), g(!1);
1342
+ })();
1343
+ }, [s]), ee(() => {
1344
+ (async () => {
1345
+ if (s)
1346
+ try {
1347
+ const b = await s.getOutline();
1348
+ o(b || []);
1349
+ } catch (b) {
1350
+ console.error("Error loading bookmarks:", b), o([]);
1351
+ }
1352
+ })();
1353
+ }, [s]);
1354
+ const V = async (w) => {
1355
+ if (s)
1356
+ try {
1357
+ let b;
1358
+ if (w.dest)
1359
+ if (typeof w.dest == "string") {
1360
+ const d = await s.getDestination(w.dest);
1361
+ d && d[0] && (b = await s.getPageIndex(d[0]));
1362
+ } else Array.isArray(w.dest) && w.dest[0] && (b = await s.getPageIndex(w.dest[0]));
1363
+ else w.pageNumber && (b = w.pageNumber - 1);
1364
+ typeof b == "number" && c(b + 1);
1365
+ } catch (b) {
1366
+ console.error("Error navigating to bookmark:", b);
1367
+ }
1368
+ }, B = () => /* @__PURE__ */ e.jsx("div", { className: "space-y-2 p-4", children: Array.from({ length: (s == null ? void 0 : s.numPages) || 5 }, (w, b) => /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center p-1", children: [
1369
+ /* @__PURE__ */ e.jsx(J, { className: "h-32 w-48" }),
1370
+ /* @__PURE__ */ e.jsx(J, { className: "mt-1 h-4 w-16" })
1371
+ ] }, b)) });
1372
+ return /* @__PURE__ */ e.jsx("div", { className: "w-64 border-r bg-muted", children: /* @__PURE__ */ e.jsxs(l, { defaultValue: "thumbnails", children: [
1373
+ /* @__PURE__ */ e.jsxs(E, { className: "w-full p-2", children: [
1374
+ /* @__PURE__ */ e.jsx(A, { value: "thumbnails", className: "flex-1 bg-transparent", children: "缩略图" }),
1375
+ /* @__PURE__ */ e.jsx(A, { value: "bookmarks", className: "flex-1 bg-transparent", children: "书签" })
1376
+ ] }),
1377
+ /* @__PURE__ */ e.jsx(N, { value: "thumbnails", children: /* @__PURE__ */ e.jsx(W, { className: "h-[calc(100vh-8rem)]", children: D ? B() : /* @__PURE__ */ e.jsx("div", { className: "space-y-2 p-4", children: a.map((w) => /* @__PURE__ */ e.jsx(
1378
+ ze,
1379
+ {
1380
+ thumbnail: w,
1381
+ isCurrentPage: j === w.pageNumber,
1382
+ onClick: () => c(w.pageNumber)
1383
+ },
1384
+ w.pageNumber
1385
+ )) }) }) }),
1386
+ /* @__PURE__ */ e.jsx(N, { value: "bookmarks", children: /* @__PURE__ */ e.jsx(W, { className: "h-[calc(100vh-8rem)]", children: /* @__PURE__ */ e.jsx("div", { className: "p-4", children: p.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "py-4 text-center text-sm text-muted-foreground", children: "没有可用的书签" }) : /* @__PURE__ */ e.jsx("div", { className: "space-y-2", children: p.map((w, b) => /* @__PURE__ */ e.jsx(
1387
+ We,
1388
+ {
1389
+ bookmark: w,
1390
+ depth: 0,
1391
+ onClick: V
1392
+ },
1393
+ `${w.title}-${b}`
1394
+ )) }) }) }) })
1395
+ ] }) });
1396
+ }
1397
+ function pt(s, j) {
1398
+ const c = ge(
1399
+ void 0
1400
+ );
1401
+ return ne(
1402
+ (...u) => {
1403
+ c.current && clearTimeout(c.current), c.current = setTimeout(() => s(...u), j);
1404
+ },
1405
+ [s, j]
1406
+ );
1407
+ }
1408
+ function _t({
1409
+ url: s,
1410
+ initialPage: j = 1,
1411
+ initialScale: c = 1,
1412
+ initialRotation: u = 0,
1413
+ currentPage: a,
1414
+ onPageChange: x,
1415
+ scale: p,
1416
+ onScaleChange: o,
1417
+ rotation: D,
1418
+ onRotationChange: g,
1419
+ minScale: l = 0.5,
1420
+ maxScale: E = 2.5,
1421
+ showToolbar: A = !0,
1422
+ showSidebar: N = !0,
1423
+ showRotation: W = !0,
1424
+ showModeToggle: J = !0,
1425
+ showFullscreen: V = !0,
1426
+ enableHotkeys: B = !0,
1427
+ enableMobileNav: w = !0,
1428
+ displayMode: b = "scroll",
1429
+ className: d,
1430
+ toolbarClassName: G,
1431
+ contentClassName: q,
1432
+ contentHeight: O = "80vh",
1433
+ pageClassName: I,
1434
+ workerUrl: S,
1435
+ cMapUrl: U,
1436
+ standardFontDataUrl: K,
1437
+ components: i,
1438
+ onLoadSuccess: R,
1439
+ onLoadError: y,
1440
+ onPageRender: $,
1441
+ loadingText: H = "正在加载PDF文档...",
1442
+ errorText: ue = "PDF加载失败"
1443
+ }) {
1444
+ const [se, Z] = M(null), [re, t] = M(j), [r, h] = M(c), [C, Q] = M(u), [le, T] = M(!0), [L, m] = M(null), [_, Y] = M(0), [de, ie] = M(!1), [te, me] = M(
1445
+ b === "scroll"
1446
+ ), [he, be] = M(N);
1447
+ ee(() => {
1448
+ be(N);
1449
+ }, [N]);
1450
+ const [ye, Te] = M(void 0), [fe, Pe] = M(null), f = ge(null), P = ge(null), v = a ?? re, F = p ?? r, ae = D ?? C, { Card: Ee, CardContent: Be, Button: ce, Input: Ye, Skeleton: Ve } = i || {}, Ge = Oe(() => {
1451
+ const n = {
1452
+ withCredentials: !1
1453
+ };
1454
+ return U && (n.cMapUrl = U, n.cMapPacked = !0), K && (n.standardFontDataUrl = K), n;
1455
+ }, [U, K]);
1456
+ ee(() => {
1457
+ let n = !0;
1458
+ return (async () => {
1459
+ try {
1460
+ const X = await import("./index-0y7GsdPm.js");
1461
+ if (typeof window < "u") {
1462
+ const z = X.pdfjs, xe = z == null ? void 0 : z.version;
1463
+ z != null && z.GlobalWorkerOptions && xe && (S ? z.GlobalWorkerOptions.workerSrc = S : z.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${xe}/build/pdf.worker.min.mjs`, !U && z.GlobalWorkerOptions && (z.GlobalWorkerOptions.cMapUrl = `https://unpkg.com/pdfjs-dist@${xe}/cmaps/`), !K && z.GlobalWorkerOptions && (z.GlobalWorkerOptions.standardFontDataUrl = `https://unpkg.com/pdfjs-dist@${xe}/standard_fonts/`));
1464
+ }
1465
+ n && Pe(X);
1466
+ } catch (X) {
1467
+ if (n) {
1468
+ const z = X instanceof Error ? X : new Error("无法加载 react-pdf 库");
1469
+ m(z), T(!1), y == null || y(z);
1470
+ }
1471
+ }
1472
+ })(), () => {
1473
+ n = !1;
1474
+ };
1475
+ }, [S, U, K, y]), ee(() => {
1476
+ if (!fe || !s) return;
1477
+ let n = !0;
1478
+ return (async () => {
1479
+ T(!0), m(null);
1480
+ try {
1481
+ const { Document: X } = fe;
1482
+ if (!X)
1483
+ throw new Error("react-pdf Document 组件不可用");
1484
+ const xe = await fe.pdfjs.getDocument(s).promise;
1485
+ n && (Z(xe), Y(xe.numPages), T(!1), R == null || R(xe));
1486
+ } catch (X) {
1487
+ if (n) {
1488
+ const z = X instanceof Error ? X : new Error("PDF 加载失败");
1489
+ m(z), T(!1), y == null || y(z);
1490
+ }
1491
+ }
1492
+ })(), () => {
1493
+ n = !1;
1494
+ };
1495
+ }, [fe, s, R, y]);
1496
+ const Le = ne(
1497
+ (n) => {
1498
+ console.error("PDF加载失败:", n), console.error("PDF URL:", s), m(
1499
+ new Error(`${ue}: ${n.message || "请检查文件路径或网络连接"}`)
1500
+ ), y == null || y(n);
1501
+ },
1502
+ [s, ue, y]
1503
+ ), oe = ne(
1504
+ (n) => {
1505
+ const k = Math.max(1, Math.min(n, _));
1506
+ a === void 0 && t(k), x == null || x(k);
1507
+ },
1508
+ [_, a, x]
1509
+ ), pe = ne(
1510
+ (n) => {
1511
+ const k = Math.max(l, Math.min(E, F + n));
1512
+ p === void 0 && h(k), o == null || o(k);
1513
+ },
1514
+ [F, l, E, p, o]
1515
+ ), Ue = ne(() => {
1516
+ const n = (ae + 90) % 360;
1517
+ D === void 0 && Q(n), g == null || g(n);
1518
+ }, [ae, D, g]), _e = pt((n) => {
1519
+ Te(n);
1520
+ }, 100);
1521
+ ee(() => {
1522
+ if (!P.current) return;
1523
+ const n = P.current, k = () => {
1524
+ _e(n.clientWidth);
1525
+ };
1526
+ k();
1527
+ const X = new ResizeObserver(() => {
1528
+ k();
1529
+ });
1530
+ return X.observe(n), () => {
1531
+ X.disconnect();
1532
+ };
1533
+ }, [_e]), ee(() => {
1534
+ if (!B) return;
1535
+ const n = (k) => {
1536
+ (k.ctrlKey || k.metaKey) && (k.key === "=" || k.key === "+") ? (k.preventDefault(), pe(0.1)) : (k.ctrlKey || k.metaKey) && k.key === "-" ? (k.preventDefault(), pe(-0.1)) : k.key === "ArrowLeft" ? (k.preventDefault(), oe(v - 1)) : k.key === "ArrowRight" && (k.preventDefault(), oe(v + 1));
1537
+ };
1538
+ return document.addEventListener("keydown", n), () => {
1539
+ document.removeEventListener("keydown", n);
1540
+ };
1541
+ }, [B, v, oe, pe]);
1542
+ const Je = ne(async () => {
1543
+ var n, k;
1544
+ if (!(typeof document > "u"))
1545
+ if (document.fullscreenElement)
1546
+ document.exitFullscreen && (await document.exitFullscreen(), ie(!1));
1547
+ else
1548
+ try {
1549
+ await ((k = (n = f.current) == null ? void 0 : n.requestFullscreen) == null ? void 0 : k.call(n)), ie(!0);
1550
+ } catch (X) {
1551
+ console.error("Error attempting to enable fullscreen:", X);
1552
+ }
1553
+ }, []);
1554
+ ee(() => {
1555
+ if (typeof document > "u") return;
1556
+ const n = () => {
1557
+ ie(!!document.fullscreenElement);
1558
+ };
1559
+ return document.addEventListener("fullscreenchange", n), () => {
1560
+ document.removeEventListener("fullscreenchange", n);
1561
+ };
1562
+ }, []);
1563
+ const qe = ne(
1564
+ (n) => {
1565
+ oe(n), me(!1);
1566
+ },
1567
+ [oe]
1568
+ ), Ke = () => A ? /* @__PURE__ */ e.jsxs(
1569
+ "div",
1570
+ {
1571
+ className: `flex items-center justify-between gap-4 border-b px-4 py-2 ${G || ""}`,
1572
+ children: [
1573
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1574
+ N && /* @__PURE__ */ e.jsx(
1575
+ ce,
1576
+ {
1577
+ variant: "outline",
1578
+ size: "icon",
1579
+ onClick: () => be(!he),
1580
+ title: he ? "隐藏侧边栏" : "显示侧边栏",
1581
+ children: /* @__PURE__ */ e.jsx(at, {})
1582
+ }
1583
+ ),
1584
+ /* @__PURE__ */ e.jsx(
1585
+ ce,
1586
+ {
1587
+ variant: "outline",
1588
+ size: "icon",
1589
+ onClick: () => pe(-0.1),
1590
+ disabled: F <= l,
1591
+ children: /* @__PURE__ */ e.jsx(Ie, {})
1592
+ }
1593
+ ),
1594
+ /* @__PURE__ */ e.jsxs("span", { className: "min-w-[3rem] text-center text-sm", children: [
1595
+ Math.round(F * 100),
1596
+ "%"
1597
+ ] }),
1598
+ /* @__PURE__ */ e.jsx(
1599
+ ce,
1600
+ {
1601
+ variant: "outline",
1602
+ size: "icon",
1603
+ onClick: () => pe(0.1),
1604
+ disabled: F >= E,
1605
+ children: /* @__PURE__ */ e.jsx(Fe, {})
1606
+ }
1607
+ ),
1608
+ W && /* @__PURE__ */ e.jsx(ce, { variant: "outline", size: "icon", onClick: Ue, children: /* @__PURE__ */ e.jsx(it, {}) }),
1609
+ J && /* @__PURE__ */ e.jsx(
1610
+ ce,
1611
+ {
1612
+ variant: "outline",
1613
+ size: "icon",
1614
+ onClick: () => me(!te),
1615
+ title: te ? "单页模式" : "滚动模式",
1616
+ children: te ? /* @__PURE__ */ e.jsx(ct, {}) : /* @__PURE__ */ e.jsx(ot, {})
1617
+ }
1618
+ ),
1619
+ V && /* @__PURE__ */ e.jsx(ce, { variant: "outline", size: "icon", onClick: Je, children: de ? /* @__PURE__ */ e.jsx(Se, {}) : /* @__PURE__ */ e.jsx($e, {}) })
1620
+ ] }),
1621
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1622
+ /* @__PURE__ */ e.jsx(
1623
+ ce,
1624
+ {
1625
+ variant: "outline",
1626
+ size: "icon",
1627
+ onClick: () => oe(v - 1),
1628
+ disabled: v <= 1,
1629
+ children: /* @__PURE__ */ e.jsx(we, {})
1630
+ }
1631
+ ),
1632
+ /* @__PURE__ */ e.jsx(
1633
+ Ye,
1634
+ {
1635
+ type: "number",
1636
+ min: 1,
1637
+ max: _,
1638
+ value: v,
1639
+ onChange: (n) => oe(parseInt(n.target.value) || 1),
1640
+ className: "w-16 text-center"
1641
+ }
1642
+ ),
1643
+ /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-muted-foreground", children: [
1644
+ "/ ",
1645
+ _
1646
+ ] }),
1647
+ /* @__PURE__ */ e.jsx(
1648
+ ce,
1649
+ {
1650
+ variant: "outline",
1651
+ size: "icon",
1652
+ onClick: () => oe(v + 1),
1653
+ disabled: v >= _,
1654
+ children: /* @__PURE__ */ e.jsx(ke, {})
1655
+ }
1656
+ )
1657
+ ] })
1658
+ ]
1659
+ }
1660
+ ) : null, De = () => /* @__PURE__ */ e.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground", children: H }) }), Re = () => /* @__PURE__ */ e.jsx("div", { className: "flex h-full min-h-[400px] items-center justify-center px-4 text-center text-destructive", children: /* @__PURE__ */ e.jsxs("div", { className: "max-w-md", children: [
1661
+ /* @__PURE__ */ e.jsx("p", { className: "mb-2 text-lg font-medium", children: "文件加载失败" }),
1662
+ /* @__PURE__ */ e.jsx("p", { className: "text-sm opacity-80", children: L == null ? void 0 : L.message })
1663
+ ] }) }), He = () => {
1664
+ if (!fe) return null;
1665
+ const { Document: n, Page: k } = fe;
1666
+ return /* @__PURE__ */ e.jsx(
1667
+ "div",
1668
+ {
1669
+ ref: P,
1670
+ className: `pdf-container flex-1 overflow-y-auto ${q || ""}`,
1671
+ children: /* @__PURE__ */ e.jsx("div", { className: "flex min-h-full justify-center px-4", children: /* @__PURE__ */ e.jsx(
1672
+ n,
1673
+ {
1674
+ pdf: se ?? void 0,
1675
+ onLoadError: Le,
1676
+ options: Ge,
1677
+ loading: De(),
1678
+ error: Re(),
1679
+ children: L ? Re() : te ? (
1680
+ // 显示所有页面模式
1681
+ Array.from(new Array(_), (X, z) => /* @__PURE__ */ e.jsx(
1682
+ "div",
1683
+ {
1684
+ className: `mb-4 ${I || ""}`,
1685
+ children: /* @__PURE__ */ e.jsx(
1686
+ k,
1687
+ {
1688
+ pageNumber: z + 1,
1689
+ renderTextLayer: !1,
1690
+ renderAnnotationLayer: !1,
1691
+ width: ye,
1692
+ scale: F,
1693
+ rotate: ae,
1694
+ onRenderSuccess: () => $ == null ? void 0 : $(z + 1)
1695
+ }
1696
+ )
1697
+ },
1698
+ `page_${z + 1}`
1699
+ ))
1700
+ ) : (
1701
+ // 单页模式
1702
+ /* @__PURE__ */ e.jsx("div", { className: I || "", children: /* @__PURE__ */ e.jsx(
1703
+ k,
1704
+ {
1705
+ pageNumber: v,
1706
+ renderTextLayer: !1,
1707
+ renderAnnotationLayer: !1,
1708
+ width: ye,
1709
+ scale: F,
1710
+ rotate: ae,
1711
+ onRenderSuccess: () => $ == null ? void 0 : $(v)
1712
+ }
1713
+ ) })
1714
+ )
1715
+ }
1716
+ ) })
1717
+ }
1718
+ );
1719
+ }, Ze = () => {
1720
+ if (!N || !he || !se) return null;
1721
+ const n = ht;
1722
+ return /* @__PURE__ */ e.jsx(
1723
+ n,
1724
+ {
1725
+ pdfDocument: se,
1726
+ currentPage: v,
1727
+ onPageClick: qe,
1728
+ components: {
1729
+ Tabs: i.Tabs,
1730
+ TabsList: i.TabsList,
1731
+ TabsTrigger: i.TabsTrigger,
1732
+ TabsContent: i.TabsContent,
1733
+ ScrollArea: i.ScrollArea,
1734
+ Skeleton: Ve
1735
+ }
1736
+ }
1737
+ );
1738
+ }, Xe = () => w ? /* @__PURE__ */ e.jsxs("div", { className: "fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 gap-2 md:hidden", children: [
1739
+ /* @__PURE__ */ e.jsxs(
1740
+ ce,
1741
+ {
1742
+ variant: "secondary",
1743
+ size: "sm",
1744
+ onClick: () => oe(v - 1),
1745
+ disabled: v <= 1,
1746
+ children: [
1747
+ /* @__PURE__ */ e.jsx(we, {}),
1748
+ /* @__PURE__ */ e.jsx("span", { className: "ml-1", children: "上一页" })
1749
+ ]
1750
+ }
1751
+ ),
1752
+ /* @__PURE__ */ e.jsxs(
1753
+ ce,
1754
+ {
1755
+ variant: "secondary",
1756
+ size: "sm",
1757
+ onClick: () => oe(v + 1),
1758
+ disabled: v >= _,
1759
+ children: [
1760
+ /* @__PURE__ */ e.jsx("span", { className: "mr-1", children: "下一页" }),
1761
+ /* @__PURE__ */ e.jsx(ke, {})
1762
+ ]
1763
+ }
1764
+ )
1765
+ ] }) : null;
1766
+ if (!i)
1767
+ return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
1768
+ if (N) {
1769
+ const n = [];
1770
+ if (i.Tabs || n.push("Tabs"), i.TabsList || n.push("TabsList"), i.TabsTrigger || n.push("TabsTrigger"), i.TabsContent || n.push("TabsContent"), i.ScrollArea || n.push("ScrollArea"), n.length > 0) {
1771
+ const k = n.length === 1 ? n[0] : `${n.slice(0, -1).join("、")} 和 ${n[n.length - 1]}`;
1772
+ return /* @__PURE__ */ e.jsxs("div", { className: "p-4 text-center text-destructive", children: [
1773
+ "错误:侧边栏功能需要注入 ",
1774
+ k,
1775
+ " 组件"
1776
+ ] });
1777
+ }
1778
+ }
1779
+ return /* @__PURE__ */ e.jsxs("div", { ref: f, children: [
1780
+ /* @__PURE__ */ e.jsxs(Ee, { className: d, children: [
1781
+ Ke(),
1782
+ /* @__PURE__ */ e.jsx(
1783
+ Be,
1784
+ {
1785
+ className: "p-0",
1786
+ style: { height: de ? "100vh" : O },
1787
+ children: /* @__PURE__ */ e.jsx("div", { className: "flex h-full flex-col", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [
1788
+ Ze(),
1789
+ le ? De() : L ? Re() : He()
1790
+ ] }) })
1791
+ }
1792
+ )
1793
+ ] }),
1794
+ Xe()
1795
+ ] });
1796
+ }
1797
+ export {
1798
+ Nt as D,
1799
+ _t as P,
1800
+ Rt as S,
1801
+ kt as T,
1802
+ wt as a,
1803
+ ht as b,
1804
+ Tt as c,
1805
+ Pt as d,
1806
+ Et as e,
1807
+ yt as f,
1808
+ e as j
1809
+ };
1810
+ //# sourceMappingURL=index-DaMRZoHB.js.map