@peeekpage/viewer 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +319 -337
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as y, jsx as r, Fragment as
|
|
2
|
-
import { useState as v, useRef as E, useEffect as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as y, jsx as r, Fragment as Je } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useRef as E, useEffect as P, useCallback as D, useMemo as Qe } from "react";
|
|
3
|
+
const et = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
4
4
|
function G(t) {
|
|
5
5
|
if (typeof t != "string") return null;
|
|
6
6
|
const e = t.trim();
|
|
@@ -12,23 +12,23 @@ function G(t) {
|
|
|
12
12
|
} catch {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return et.has(a.protocol) ? a.href : null;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
17
|
+
const tt = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, nt = /^rgba?\([ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*(?:,[ \t]*(?:0|1|0?\.\d+)[ \t]*)?\)$/;
|
|
18
|
+
function ue(t) {
|
|
19
19
|
if (typeof t != "string") return null;
|
|
20
20
|
const e = t.trim();
|
|
21
|
-
return
|
|
21
|
+
return tt.test(e) || nt.test(e) ? e : null;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
function
|
|
23
|
+
const at = /url\(|image\(|image-set\(|element\(|expression|@|\/\*|;|\{|\}|<|>|\\/i, rt = /^(repeating-)?(linear|radial|conic)-gradient\([a-z0-9#.,%()\/\s-]*\)$/i, ot = /^hsla?\([a-z0-9.,%\/\s-]*\)$/i;
|
|
24
|
+
function lt(t) {
|
|
25
25
|
if (typeof t != "string") return null;
|
|
26
26
|
const e = t.trim();
|
|
27
|
-
if (e === "" ||
|
|
28
|
-
const n =
|
|
29
|
-
return n !== null ? n :
|
|
27
|
+
if (e === "" || at.test(e)) return null;
|
|
28
|
+
const n = ue(e);
|
|
29
|
+
return n !== null ? n : ot.test(e) || rt.test(e) ? e : null;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const it = ["en", "pt-BR"], Ne = {
|
|
32
32
|
prev: "Previous page",
|
|
33
33
|
next: "Next page",
|
|
34
34
|
zoom: "Zoom level",
|
|
@@ -50,7 +50,7 @@ const st = ["en", "pt-BR"], Ne = {
|
|
|
50
50
|
rotate: "Rotate page",
|
|
51
51
|
singlePage: "Single page",
|
|
52
52
|
doublePage: "Two pages"
|
|
53
|
-
},
|
|
53
|
+
}, st = {
|
|
54
54
|
prev: "Página anterior",
|
|
55
55
|
next: "Próxima página",
|
|
56
56
|
zoom: "Nível de zoom",
|
|
@@ -72,26 +72,26 @@ const st = ["en", "pt-BR"], Ne = {
|
|
|
72
72
|
rotate: "Girar página",
|
|
73
73
|
singlePage: "Página única",
|
|
74
74
|
doublePage: "Duas páginas"
|
|
75
|
-
},
|
|
76
|
-
function
|
|
77
|
-
return
|
|
75
|
+
}, ct = { en: Ne, "pt-BR": st };
|
|
76
|
+
function ut(t) {
|
|
77
|
+
return ct[t] ?? Ne;
|
|
78
78
|
}
|
|
79
|
-
const
|
|
79
|
+
const dt = "#6E79D6";
|
|
80
80
|
function I(t, e) {
|
|
81
81
|
return typeof t == "boolean" ? t : e;
|
|
82
82
|
}
|
|
83
83
|
function J(t, e, n) {
|
|
84
84
|
return e.includes(t) ? t : n;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function ft(t) {
|
|
87
87
|
return {
|
|
88
88
|
src: typeof t.src == "string" ? t.src : "",
|
|
89
89
|
mode: J(t.mode, ["flip", "coverflow"], "flip"),
|
|
90
90
|
logo: G(t.logo),
|
|
91
91
|
logoLink: G(t.logoLink),
|
|
92
|
-
accentColor:
|
|
92
|
+
accentColor: ue(t.accentColor) ?? dt,
|
|
93
93
|
background: J(t.background, ["color", "image", "transparent"], "color"),
|
|
94
|
-
backgroundColor:
|
|
94
|
+
backgroundColor: lt(t.backgroundColor),
|
|
95
95
|
backgroundImage: G(t.backgroundImage),
|
|
96
96
|
layout: J(t.layout, ["single", "double"], "double"),
|
|
97
97
|
fillHeight: I(t.fillHeight, !1),
|
|
@@ -99,7 +99,7 @@ function gt(t) {
|
|
|
99
99
|
rtl: I(t.rtl, !1),
|
|
100
100
|
animateInteractions: I(t.animateInteractions, !0),
|
|
101
101
|
skin: J(t.skin, ["classic", "minimal", "showcase"], "classic"),
|
|
102
|
-
language: J(t.language,
|
|
102
|
+
language: J(t.language, it, "en"),
|
|
103
103
|
autoTransition: I(t.autoTransition, !1),
|
|
104
104
|
autoTransitionInterval: typeof t.autoTransitionInterval == "number" && t.autoTransitionInterval > 0 ? t.autoTransitionInterval : 5e3,
|
|
105
105
|
navigationControls: I(t.navigationControls, !0),
|
|
@@ -111,38 +111,37 @@ function gt(t) {
|
|
|
111
111
|
aboutButton: I(t.aboutButton, !0),
|
|
112
112
|
goToPage: I(t.goToPage, !0),
|
|
113
113
|
rotateControl: I(t.rotateControl, !0),
|
|
114
|
-
layoutToggle: I(t.layoutToggle, !0),
|
|
115
114
|
loadingImage: G(t.loadingImage),
|
|
116
115
|
loadingCaption: typeof t.loadingCaption == "string" && t.loadingCaption.length > 0 ? t.loadingCaption : null,
|
|
117
|
-
loadingColor:
|
|
116
|
+
loadingColor: ue(t.loadingColor),
|
|
118
117
|
pollInterval: typeof t.pollInterval == "number" && t.pollInterval > 0 ? t.pollInterval : 2e3,
|
|
119
118
|
className: typeof t.className == "string" ? t.className : ""
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
|
-
const
|
|
121
|
+
const de = 5e3;
|
|
123
122
|
function Q(t) {
|
|
124
123
|
return typeof t == "string" ? t : "";
|
|
125
124
|
}
|
|
126
|
-
function
|
|
125
|
+
function gt(t) {
|
|
127
126
|
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
128
127
|
return { ok: !1, error: "manifest is not an object" };
|
|
129
128
|
const e = t;
|
|
130
129
|
if (!Array.isArray(e.pages))
|
|
131
130
|
return { ok: !1, error: "manifest.pages is missing or not an array" };
|
|
132
|
-
if (e.pages.length >
|
|
131
|
+
if (e.pages.length > de)
|
|
133
132
|
return { ok: !1, error: "manifest.pages exceeds the maximum" };
|
|
134
133
|
const n = e.total_pages, a = typeof n == "number" && Number.isFinite(n) && n >= 0 ? n : e.pages.length;
|
|
135
|
-
if (a >
|
|
134
|
+
if (a > de)
|
|
136
135
|
return { ok: !1, error: "manifest.total_pages exceeds the maximum" };
|
|
137
136
|
const i = [];
|
|
138
137
|
for (const g of e.pages) {
|
|
139
138
|
if (g === null || typeof g != "object") continue;
|
|
140
|
-
const
|
|
141
|
-
|
|
139
|
+
const d = G(g.url);
|
|
140
|
+
d && i.push(d);
|
|
142
141
|
}
|
|
143
142
|
if (i.length === 0)
|
|
144
143
|
return { ok: !1, error: "manifest has no usable pages" };
|
|
145
|
-
const
|
|
144
|
+
const u = e.status === "wip" ? "wip" : "done", h = e.metadata && typeof e.metadata == "object" ? e.metadata : {}, k = {
|
|
146
145
|
fileId: Q(h.file_id),
|
|
147
146
|
filename: Q(h.filename),
|
|
148
147
|
creationDate: Q(h.creation_date),
|
|
@@ -151,15 +150,15 @@ function mt(t) {
|
|
|
151
150
|
};
|
|
152
151
|
return {
|
|
153
152
|
ok: !0,
|
|
154
|
-
value: { status:
|
|
153
|
+
value: { status: u, totalPages: a, pages: i, metadata: k }
|
|
155
154
|
};
|
|
156
155
|
}
|
|
157
|
-
function
|
|
158
|
-
if (!Array.isArray(t) || t.length >
|
|
156
|
+
function mt(t, e) {
|
|
157
|
+
if (!Array.isArray(t) || t.length > de) return null;
|
|
159
158
|
const n = [];
|
|
160
159
|
for (const i of t) {
|
|
161
|
-
const
|
|
162
|
-
|
|
160
|
+
const u = G(i);
|
|
161
|
+
u && n.push(u);
|
|
163
162
|
}
|
|
164
163
|
return n.length === 0 ? null : {
|
|
165
164
|
status: "done",
|
|
@@ -174,44 +173,44 @@ function pt(t, e) {
|
|
|
174
173
|
}
|
|
175
174
|
};
|
|
176
175
|
}
|
|
177
|
-
function
|
|
178
|
-
const [n, a] = v("loading"), [i,
|
|
179
|
-
return
|
|
180
|
-
let
|
|
181
|
-
if (a("loading"),
|
|
176
|
+
function pt(t, e) {
|
|
177
|
+
const [n, a] = v("loading"), [i, u] = v(null), [h, k] = v(null), g = E(null);
|
|
178
|
+
return P(() => {
|
|
179
|
+
let d = !1;
|
|
180
|
+
if (a("loading"), u(null), k(null), !t) return;
|
|
182
181
|
const w = () => {
|
|
183
182
|
g.current !== null && (clearTimeout(g.current), g.current = null);
|
|
184
183
|
}, _ = async () => {
|
|
185
|
-
let
|
|
184
|
+
let s;
|
|
186
185
|
try {
|
|
187
186
|
const l = await fetch(t);
|
|
188
187
|
if (!l.ok) throw new Error(`HTTP ${l.status}`);
|
|
189
|
-
|
|
188
|
+
s = await l.json();
|
|
190
189
|
} catch (l) {
|
|
191
|
-
if (
|
|
190
|
+
if (d) return;
|
|
192
191
|
k(l instanceof Error ? l.message : "fetch failed"), a("error");
|
|
193
192
|
return;
|
|
194
193
|
}
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
198
|
-
k(
|
|
194
|
+
if (d) return;
|
|
195
|
+
const f = gt(s);
|
|
196
|
+
if (!f.ok) {
|
|
197
|
+
k(f.error), a("error");
|
|
199
198
|
return;
|
|
200
199
|
}
|
|
201
|
-
|
|
200
|
+
u(f.value), a("ready"), f.value.status === "wip" && (g.current = setTimeout(_, e));
|
|
202
201
|
};
|
|
203
202
|
return _(), () => {
|
|
204
|
-
|
|
203
|
+
d = !0, w();
|
|
205
204
|
};
|
|
206
205
|
}, [t, e]), { state: n, manifest: i, error: h };
|
|
207
206
|
}
|
|
208
|
-
function
|
|
207
|
+
function bt(t) {
|
|
209
208
|
const [e, n] = v(!1);
|
|
210
|
-
|
|
209
|
+
P(() => {
|
|
211
210
|
const i = () => n(document.fullscreenElement != null);
|
|
212
211
|
return document.addEventListener("fullscreenchange", i), () => document.removeEventListener("fullscreenchange", i);
|
|
213
212
|
}, []);
|
|
214
|
-
const a =
|
|
213
|
+
const a = D(async () => {
|
|
215
214
|
const i = t.current;
|
|
216
215
|
if (i)
|
|
217
216
|
try {
|
|
@@ -221,23 +220,23 @@ function ht(t) {
|
|
|
221
220
|
}, [t]);
|
|
222
221
|
return { isFullscreen: e, toggle: a };
|
|
223
222
|
}
|
|
224
|
-
const
|
|
223
|
+
const ve = "(prefers-reduced-motion: reduce)";
|
|
225
224
|
function Ce() {
|
|
226
225
|
const [t, e] = v(() => {
|
|
227
226
|
var n;
|
|
228
|
-
return ((n = matchMedia == null ? void 0 : matchMedia(
|
|
227
|
+
return ((n = matchMedia == null ? void 0 : matchMedia(ve)) == null ? void 0 : n.matches) ?? !1;
|
|
229
228
|
});
|
|
230
|
-
return
|
|
231
|
-
const n = typeof matchMedia == "function" ? matchMedia(
|
|
229
|
+
return P(() => {
|
|
230
|
+
const n = typeof matchMedia == "function" ? matchMedia(ve) : void 0;
|
|
232
231
|
if (!(n != null && n.addEventListener)) return;
|
|
233
232
|
const a = () => e(n.matches);
|
|
234
233
|
return n.addEventListener("change", a), () => n.removeEventListener("change", a);
|
|
235
234
|
}, []), t;
|
|
236
235
|
}
|
|
237
|
-
function
|
|
238
|
-
return { onKeyDown:
|
|
239
|
-
(
|
|
240
|
-
switch (
|
|
236
|
+
function Te({ go: t, jump: e, total: n, rtl: a }) {
|
|
237
|
+
return { onKeyDown: D(
|
|
238
|
+
(u) => {
|
|
239
|
+
switch (u.key) {
|
|
241
240
|
case "ArrowRight":
|
|
242
241
|
t(a ? -1 : 1);
|
|
243
242
|
break;
|
|
@@ -245,55 +244,55 @@ function Pe({ go: t, jump: e, total: n, rtl: a }) {
|
|
|
245
244
|
t(a ? 1 : -1);
|
|
246
245
|
break;
|
|
247
246
|
case "Home":
|
|
248
|
-
|
|
247
|
+
u.preventDefault(), n > 0 && e(0);
|
|
249
248
|
break;
|
|
250
249
|
case "End":
|
|
251
|
-
|
|
250
|
+
u.preventDefault(), n > 0 && e(n - 1);
|
|
252
251
|
break;
|
|
253
252
|
case " ":
|
|
254
253
|
case "Spacebar":
|
|
255
|
-
|
|
254
|
+
u.preventDefault(), t(u.shiftKey ? -1 : 1);
|
|
256
255
|
break;
|
|
257
256
|
case "PageDown":
|
|
258
|
-
|
|
257
|
+
u.preventDefault(), t(1);
|
|
259
258
|
break;
|
|
260
259
|
case "PageUp":
|
|
261
|
-
|
|
260
|
+
u.preventDefault(), t(-1);
|
|
262
261
|
break;
|
|
263
262
|
}
|
|
264
263
|
},
|
|
265
264
|
[t, e, n, a]
|
|
266
265
|
) };
|
|
267
266
|
}
|
|
268
|
-
function
|
|
267
|
+
function Pe(t, e) {
|
|
269
268
|
if (e <= 0) return null;
|
|
270
269
|
const n = t.trim();
|
|
271
270
|
if (!/^\d+$/.test(n)) return null;
|
|
272
271
|
const a = Number(n);
|
|
273
272
|
return Number.isFinite(a) ? Math.max(1, Math.min(e, a)) - 1 : null;
|
|
274
273
|
}
|
|
275
|
-
const
|
|
276
|
-
function
|
|
277
|
-
const [n, a] = v("auto"), [i,
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
274
|
+
const ht = 640;
|
|
275
|
+
function kt(t, e) {
|
|
276
|
+
const [n, a] = v("auto"), [i, u] = v(null);
|
|
277
|
+
P(() => {
|
|
278
|
+
const d = t.current;
|
|
279
|
+
if (!d || (d.clientWidth > 0 && u(d.clientWidth), typeof ResizeObserver > "u")) return;
|
|
281
280
|
const w = new ResizeObserver((_) => {
|
|
282
|
-
var
|
|
283
|
-
const
|
|
284
|
-
typeof
|
|
281
|
+
var f;
|
|
282
|
+
const s = (f = _[0]) == null ? void 0 : f.contentRect.width;
|
|
283
|
+
typeof s == "number" && s > 0 && u(s);
|
|
285
284
|
});
|
|
286
|
-
return w.observe(
|
|
285
|
+
return w.observe(d), () => w.disconnect();
|
|
287
286
|
}, [t]);
|
|
288
|
-
const h = i != null && i <
|
|
287
|
+
const h = i != null && i < ht ? "single" : e, k = n === "auto" ? h : n, g = D(() => {
|
|
289
288
|
a(k === "single" ? "double" : "single");
|
|
290
289
|
}, [k]);
|
|
291
290
|
return { layout: k, toggle: g };
|
|
292
291
|
}
|
|
293
|
-
function
|
|
292
|
+
function ge(t, e) {
|
|
294
293
|
return t <= 0 ? 0 : e === "single" ? t : 1 + Math.ceil((t - 1) / 2);
|
|
295
294
|
}
|
|
296
|
-
function
|
|
295
|
+
function _t(t, e) {
|
|
297
296
|
return e === "single" ? t : t <= 0 ? 0 : Math.floor((t - 1) / 2) + 1;
|
|
298
297
|
}
|
|
299
298
|
function re(t, e, n) {
|
|
@@ -305,47 +304,45 @@ function re(t, e, n) {
|
|
|
305
304
|
const a = 2 * t - 1, i = 2 * t;
|
|
306
305
|
return { left: a < e ? a : -1, right: i < e ? i : -1 };
|
|
307
306
|
}
|
|
308
|
-
function
|
|
309
|
-
const { left: a, right: i } = re(t, e, n),
|
|
310
|
-
return a >= 0 &&
|
|
307
|
+
function fe(t, e, n) {
|
|
308
|
+
const { left: a, right: i } = re(t, e, n), u = [];
|
|
309
|
+
return a >= 0 && u.push(a), i >= 0 && u.push(i), u;
|
|
311
310
|
}
|
|
312
311
|
function ne(t, e, n) {
|
|
313
|
-
const a =
|
|
312
|
+
const a = ge(e, n) - 1;
|
|
314
313
|
return t < 0 ? 0 : t > a ? a : t;
|
|
315
314
|
}
|
|
316
|
-
function
|
|
315
|
+
function yt(t) {
|
|
317
316
|
const {
|
|
318
317
|
strings: e,
|
|
319
318
|
label: n,
|
|
320
319
|
progress: a,
|
|
321
320
|
zoom: i,
|
|
322
|
-
minZoom:
|
|
321
|
+
minZoom: u,
|
|
323
322
|
maxZoom: h,
|
|
324
323
|
total: k,
|
|
325
324
|
currentPage: g,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
downloadUrl: f,
|
|
325
|
+
thumbsOpen: d,
|
|
326
|
+
isFullscreen: w,
|
|
327
|
+
downloadUrl: _,
|
|
330
328
|
show: s,
|
|
331
|
-
onZoomIn:
|
|
332
|
-
onZoomOut:
|
|
333
|
-
onZoomSet:
|
|
334
|
-
onJump:
|
|
335
|
-
onRotate:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
z(String(g));
|
|
329
|
+
onZoomIn: f,
|
|
330
|
+
onZoomOut: l,
|
|
331
|
+
onZoomSet: L,
|
|
332
|
+
onJump: O,
|
|
333
|
+
onRotate: A,
|
|
334
|
+
onToggleThumbs: R,
|
|
335
|
+
onToggleFullscreen: x,
|
|
336
|
+
onAbout: z
|
|
337
|
+
} = t, [B, F] = v(String(g));
|
|
338
|
+
P(() => F(String(g)), [g]);
|
|
339
|
+
const M = () => {
|
|
340
|
+
const T = Pe(B, k);
|
|
341
|
+
if (T === null) {
|
|
342
|
+
F(String(g));
|
|
346
343
|
return;
|
|
347
344
|
}
|
|
348
|
-
|
|
345
|
+
O(T), F(String(T + 1));
|
|
349
346
|
};
|
|
350
347
|
return /* @__PURE__ */ y("div", { className: "peeek__toolbar", children: [
|
|
351
348
|
!s.goto && /* @__PURE__ */ r("span", { className: "peeek__label", children: n }),
|
|
@@ -357,11 +354,11 @@ function vt(t) {
|
|
|
357
354
|
type: "text",
|
|
358
355
|
inputMode: "numeric",
|
|
359
356
|
"aria-label": e.goToPage,
|
|
360
|
-
value:
|
|
361
|
-
onChange: (
|
|
362
|
-
onBlur:
|
|
363
|
-
onKeyDown: (
|
|
364
|
-
|
|
357
|
+
value: B,
|
|
358
|
+
onChange: (T) => F(T.target.value),
|
|
359
|
+
onBlur: M,
|
|
360
|
+
onKeyDown: (T) => {
|
|
361
|
+
T.key === "Enter" && (T.preventDefault(), M());
|
|
365
362
|
}
|
|
366
363
|
}
|
|
367
364
|
),
|
|
@@ -371,8 +368,8 @@ function vt(t) {
|
|
|
371
368
|
type: "button",
|
|
372
369
|
className: "peeek__btn",
|
|
373
370
|
"aria-label": e.zoomOut,
|
|
374
|
-
disabled: i <=
|
|
375
|
-
onClick:
|
|
371
|
+
disabled: i <= u,
|
|
372
|
+
onClick: l,
|
|
376
373
|
children: "−"
|
|
377
374
|
}
|
|
378
375
|
),
|
|
@@ -381,11 +378,11 @@ function vt(t) {
|
|
|
381
378
|
{
|
|
382
379
|
type: "range",
|
|
383
380
|
"aria-label": e.zoom,
|
|
384
|
-
min:
|
|
381
|
+
min: u,
|
|
385
382
|
max: h,
|
|
386
383
|
step: 0.25,
|
|
387
384
|
value: i,
|
|
388
|
-
onChange: (
|
|
385
|
+
onChange: (T) => L(Number(T.target.value))
|
|
389
386
|
}
|
|
390
387
|
),
|
|
391
388
|
/* @__PURE__ */ r(
|
|
@@ -395,7 +392,7 @@ function vt(t) {
|
|
|
395
392
|
className: "peeek__btn",
|
|
396
393
|
"aria-label": e.zoomIn,
|
|
397
394
|
disabled: i >= h,
|
|
398
|
-
onClick:
|
|
395
|
+
onClick: f,
|
|
399
396
|
children: "+"
|
|
400
397
|
}
|
|
401
398
|
),
|
|
@@ -405,37 +402,26 @@ function vt(t) {
|
|
|
405
402
|
type: "button",
|
|
406
403
|
className: "peeek__btn",
|
|
407
404
|
"aria-label": e.rotate,
|
|
408
|
-
onClick:
|
|
405
|
+
onClick: A,
|
|
409
406
|
children: "⟳"
|
|
410
407
|
}
|
|
411
408
|
),
|
|
412
|
-
s.layoutToggle && /* @__PURE__ */ r(
|
|
413
|
-
"button",
|
|
414
|
-
{
|
|
415
|
-
type: "button",
|
|
416
|
-
className: "peeek__btn",
|
|
417
|
-
"aria-label": u === "single" ? e.doublePage : e.singlePage,
|
|
418
|
-
"aria-pressed": u === "double",
|
|
419
|
-
onClick: x,
|
|
420
|
-
children: u === "single" ? "▭" : "▥"
|
|
421
|
-
}
|
|
422
|
-
),
|
|
423
409
|
s.thumbnails && /* @__PURE__ */ r(
|
|
424
410
|
"button",
|
|
425
411
|
{
|
|
426
412
|
type: "button",
|
|
427
|
-
className: `peeek__btn${
|
|
413
|
+
className: `peeek__btn${d ? " peeek__btn--active" : ""}`,
|
|
428
414
|
"aria-label": e.thumbnails,
|
|
429
|
-
"aria-pressed":
|
|
430
|
-
onClick:
|
|
415
|
+
"aria-pressed": d,
|
|
416
|
+
onClick: R,
|
|
431
417
|
children: "▦"
|
|
432
418
|
}
|
|
433
419
|
),
|
|
434
|
-
|
|
420
|
+
_ && /* @__PURE__ */ r(
|
|
435
421
|
"a",
|
|
436
422
|
{
|
|
437
423
|
className: "peeek__btn",
|
|
438
|
-
href:
|
|
424
|
+
href: _,
|
|
439
425
|
"aria-label": e.download,
|
|
440
426
|
target: "_blank",
|
|
441
427
|
rel: "noopener noreferrer",
|
|
@@ -447,10 +433,10 @@ function vt(t) {
|
|
|
447
433
|
"button",
|
|
448
434
|
{
|
|
449
435
|
type: "button",
|
|
450
|
-
className: `peeek__btn${
|
|
436
|
+
className: `peeek__btn${w ? " peeek__btn--active" : ""}`,
|
|
451
437
|
"aria-label": e.fullscreen,
|
|
452
|
-
"aria-pressed":
|
|
453
|
-
onClick:
|
|
438
|
+
"aria-pressed": w,
|
|
439
|
+
onClick: x,
|
|
454
440
|
children: "⛶"
|
|
455
441
|
}
|
|
456
442
|
),
|
|
@@ -460,140 +446,140 @@ function vt(t) {
|
|
|
460
446
|
type: "button",
|
|
461
447
|
className: "peeek__btn",
|
|
462
448
|
"aria-label": e.about,
|
|
463
|
-
onClick:
|
|
449
|
+
onClick: z,
|
|
464
450
|
children: "?"
|
|
465
451
|
}
|
|
466
452
|
)
|
|
467
453
|
] });
|
|
468
454
|
}
|
|
469
|
-
function
|
|
470
|
-
const
|
|
471
|
-
return /* @__PURE__ */ r("div", { className: "peeek__thumbs", role: "group", "aria-label": "Pages", children: Array.from({ length: k }, (g,
|
|
472
|
-
const w =
|
|
455
|
+
function vt({ pages: t, layout: e, rtl: n, activePages: a, onJump: i }) {
|
|
456
|
+
const u = t.length, h = new Set(a), k = ge(u, e);
|
|
457
|
+
return /* @__PURE__ */ r("div", { className: "peeek__thumbs", role: "group", "aria-label": "Pages", children: Array.from({ length: k }, (g, d) => {
|
|
458
|
+
const w = fe(d, u, e), _ = w.length === 2;
|
|
473
459
|
return /* @__PURE__ */ y("div", { className: "peeek__thumb-group", children: [
|
|
474
|
-
w.map((
|
|
460
|
+
w.map((s, f) => {
|
|
475
461
|
let l = "";
|
|
476
|
-
return _ && (l = (n ?
|
|
462
|
+
return _ && (l = (n ? f === 1 : f === 0) ? " peeek__thumb--flat-right" : " peeek__thumb--flat-left"), /* @__PURE__ */ r(
|
|
477
463
|
"button",
|
|
478
464
|
{
|
|
479
465
|
type: "button",
|
|
480
|
-
"aria-label": `Go to page ${
|
|
481
|
-
"aria-current": h.has(
|
|
482
|
-
className: `peeek__thumb${h.has(
|
|
483
|
-
onClick: () => i(
|
|
484
|
-
children: /* @__PURE__ */ r("img", { src: t[
|
|
466
|
+
"aria-label": `Go to page ${s + 1}`,
|
|
467
|
+
"aria-current": h.has(s),
|
|
468
|
+
className: `peeek__thumb${h.has(s) ? " peeek__thumb--active" : ""}${l}`,
|
|
469
|
+
onClick: () => i(s),
|
|
470
|
+
children: /* @__PURE__ */ r("img", { src: t[s], alt: "", loading: "lazy", referrerPolicy: "no-referrer" })
|
|
485
471
|
},
|
|
486
|
-
|
|
472
|
+
s
|
|
487
473
|
);
|
|
488
474
|
}),
|
|
489
|
-
/* @__PURE__ */ r("span", { className: "peeek__thumb-badge", "aria-hidden": !0, children: w.map((
|
|
490
|
-
] },
|
|
475
|
+
/* @__PURE__ */ r("span", { className: "peeek__thumb-badge", "aria-hidden": !0, children: w.map((s) => s + 1).join("-") })
|
|
476
|
+
] }, d);
|
|
491
477
|
}) });
|
|
492
478
|
}
|
|
493
|
-
const ee = 1, ae = 4,
|
|
494
|
-
function
|
|
479
|
+
const ee = 1, ae = 4, we = 0.5;
|
|
480
|
+
function wt(t) {
|
|
495
481
|
const {
|
|
496
482
|
pages: e,
|
|
497
483
|
strings: n,
|
|
498
484
|
layout: a,
|
|
499
485
|
rtl: i,
|
|
500
|
-
pageShadows:
|
|
486
|
+
pageShadows: u,
|
|
501
487
|
animateInteractions: h,
|
|
502
488
|
autoTransition: k,
|
|
503
489
|
autoTransitionInterval: g,
|
|
504
|
-
show:
|
|
490
|
+
show: d,
|
|
505
491
|
downloadUrl: w,
|
|
506
492
|
isFullscreen: _,
|
|
507
|
-
onToggleFullscreen:
|
|
508
|
-
onAbout:
|
|
509
|
-
} = t, l = e.length, O = Ce() || !h, [
|
|
510
|
-
|
|
493
|
+
onToggleFullscreen: s,
|
|
494
|
+
onAbout: f
|
|
495
|
+
} = t, l = e.length, O = Ce() || !h, [A, R] = v(0), [x, z] = v(1), [B, F] = v(!1), [M, T] = v({ x: 0, y: 0 }), [V, X] = v(!1), [K, m] = v(0), p = E(null), S = E(null), { layout: b } = kt(S, a), Z = ge(l, b), [N, oe] = v(null), [Ie, me] = v(!1), le = E(null), [pe, xe] = v(0.707);
|
|
496
|
+
P(() => {
|
|
511
497
|
if (!e[0]) return;
|
|
512
498
|
const o = new globalThis.Image();
|
|
513
499
|
o.onload = () => {
|
|
514
|
-
o.naturalWidth && o.naturalHeight &&
|
|
500
|
+
o.naturalWidth && o.naturalHeight && xe(o.naturalWidth / o.naturalHeight);
|
|
515
501
|
}, o.src = e[0];
|
|
516
502
|
}, [e]);
|
|
517
|
-
const $ = ne(
|
|
518
|
-
|
|
519
|
-
const o = [$ - 1, $ + 1, $ + 2].map((c) => ne(c, l, b)).flatMap((c) =>
|
|
503
|
+
const $ = ne(A, l, b), Se = $ <= 0, ie = $ >= Z - 1, be = E(/* @__PURE__ */ new Set());
|
|
504
|
+
P(() => {
|
|
505
|
+
const o = [$ - 1, $ + 1, $ + 2].map((c) => ne(c, l, b)).flatMap((c) => fe(c, l, b)).filter((c) => c >= 0);
|
|
520
506
|
for (const c of o) {
|
|
521
|
-
const
|
|
522
|
-
if (!
|
|
523
|
-
|
|
507
|
+
const C = e[c];
|
|
508
|
+
if (!C || be.current.has(C)) continue;
|
|
509
|
+
be.current.add(C);
|
|
524
510
|
const q = new globalThis.Image();
|
|
525
|
-
q.src =
|
|
511
|
+
q.src = C;
|
|
526
512
|
}
|
|
527
513
|
}, [$, l, b, e]);
|
|
528
|
-
const W =
|
|
514
|
+
const W = D(
|
|
529
515
|
(o) => {
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
return
|
|
516
|
+
N || R((c) => {
|
|
517
|
+
const C = ne(c + o, l, b);
|
|
518
|
+
return C === c ? c : O ? C : (oe({ dir: o, to: C }), c);
|
|
533
519
|
});
|
|
534
520
|
},
|
|
535
|
-
[l, b, O,
|
|
536
|
-
),
|
|
537
|
-
o.target ===
|
|
521
|
+
[l, b, O, N]
|
|
522
|
+
), $e = D((o) => {
|
|
523
|
+
o.target === le.current && (o.propertyName && o.propertyName !== "transform" || oe((c) => c && (R(c.to), me(!0), requestAnimationFrame(
|
|
538
524
|
() => requestAnimationFrame(() => {
|
|
539
|
-
|
|
525
|
+
oe(null), me(!1);
|
|
540
526
|
})
|
|
541
527
|
), c)));
|
|
542
528
|
}, []);
|
|
543
|
-
|
|
544
|
-
if (!
|
|
545
|
-
const o =
|
|
529
|
+
P(() => {
|
|
530
|
+
if (!N) return;
|
|
531
|
+
const o = le.current;
|
|
546
532
|
if (!o) return;
|
|
547
533
|
o.style.transform = "rotateY(0deg)";
|
|
548
534
|
let c = 0;
|
|
549
|
-
const
|
|
535
|
+
const C = requestAnimationFrame(() => {
|
|
550
536
|
c = requestAnimationFrame(() => {
|
|
551
|
-
o.style.transform = `rotateY(${
|
|
537
|
+
o.style.transform = `rotateY(${N.dir === 1 ? -180 : 180}deg)`;
|
|
552
538
|
});
|
|
553
539
|
});
|
|
554
540
|
return () => {
|
|
555
|
-
cancelAnimationFrame(
|
|
541
|
+
cancelAnimationFrame(C), cancelAnimationFrame(c);
|
|
556
542
|
};
|
|
557
|
-
}, [
|
|
558
|
-
const
|
|
543
|
+
}, [N]);
|
|
544
|
+
const se = D(
|
|
559
545
|
(o) => {
|
|
560
|
-
R(ne(
|
|
546
|
+
R(ne(_t(o, b), l, b));
|
|
561
547
|
},
|
|
562
548
|
[l, b]
|
|
563
|
-
), { onKeyDown:
|
|
564
|
-
|
|
565
|
-
if (!k ||
|
|
549
|
+
), { onKeyDown: ze } = Te({ go: W, jump: se, total: l, rtl: i });
|
|
550
|
+
P(() => {
|
|
551
|
+
if (!k || ie) return;
|
|
566
552
|
const o = setTimeout(() => W(1), g);
|
|
567
553
|
return () => clearTimeout(o);
|
|
568
|
-
}, [k, g,
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
},
|
|
554
|
+
}, [k, g, ie, $, W]);
|
|
555
|
+
const Ae = () => z((o) => Math.min(ae, o + we)), Fe = () => z((o) => Math.max(ee, o - we)), Me = () => {
|
|
556
|
+
N || z((o) => o > ee ? ee : ae);
|
|
557
|
+
}, Ee = () => m((o) => (o + 90) % 360), De = K === 90 || K === 270 ? pe : 1, ce = D((o, c, C) => {
|
|
572
558
|
const q = S.current;
|
|
573
|
-
if (!q ||
|
|
574
|
-
const
|
|
575
|
-
return { x: Math.max(-
|
|
559
|
+
if (!q || C <= 1) return { x: 0, y: 0 };
|
|
560
|
+
const _e = (C - 1) * q.clientWidth / 2, ye = (C - 1) * q.clientHeight / 2;
|
|
561
|
+
return { x: Math.max(-_e, Math.min(_e, o)), y: Math.max(-ye, Math.min(ye, c)) };
|
|
576
562
|
}, []);
|
|
577
|
-
|
|
578
|
-
const
|
|
579
|
-
var c,
|
|
580
|
-
x <= 1 || (p.current = { x: o.clientX, y: o.clientY, px: M.x, py: M.y },
|
|
581
|
-
},
|
|
563
|
+
P(() => T((o) => ce(o.x, o.y, x)), [x, ce]), P(() => T({ x: 0, y: 0 }), [$]);
|
|
564
|
+
const Le = (o) => {
|
|
565
|
+
var c, C;
|
|
566
|
+
x <= 1 || (p.current = { x: o.clientX, y: o.clientY, px: M.x, py: M.y }, X(!0), (C = (c = o.currentTarget).setPointerCapture) == null || C.call(c, o.pointerId));
|
|
567
|
+
}, Oe = (o) => {
|
|
582
568
|
const c = p.current;
|
|
583
|
-
c &&
|
|
584
|
-
},
|
|
569
|
+
c && T(ce(c.px + (o.clientX - c.x), c.py + (o.clientY - c.y), x));
|
|
570
|
+
}, he = (o) => {
|
|
585
571
|
if (p.current) {
|
|
586
|
-
p.current = null,
|
|
572
|
+
p.current = null, X(!1);
|
|
587
573
|
try {
|
|
588
574
|
o.currentTarget.releasePointerCapture(o.pointerId);
|
|
589
575
|
} catch {
|
|
590
576
|
}
|
|
591
577
|
}
|
|
592
|
-
}, Y =
|
|
593
|
-
["left",
|
|
594
|
-
["right",
|
|
578
|
+
}, Y = fe($, l, b), te = Y[0] ?? 0, Re = b === "double" && Y.length === 2 ? `${Y[0] + 1} - ${Y[1] + 1} / ${l}` : `${te + 1} / ${l}`, Be = Z <= 1 ? 100 : $ / (Z - 1) * 100, Ue = n.prev, Ze = n.next, He = N ? N.to : $, H = re(He, l, b), Ge = H.left < 0 && H.right >= 0, je = H.left >= 0 && H.right < 0, Ve = H.left >= 0 && H.right >= 0, Xe = Ge ? "-25%" : je ? "25%" : "0%", U = re($, l, b), j = N ? re(N.to, l, b) : U, Ke = N ? N.dir === 1 ? U.right >= 0 ? U.right : U.left : U.left >= 0 ? U.left : U.right : te, We = N ? N.dir === 1 ? j.left >= 0 ? j.left : j.right : j.right >= 0 ? j.right : j.left : te, Ye = N ? N.dir === 1 ? "left" : "right" : null, ke = (o) => o === Ye && !Ie ? U[o] : H[o], qe = [
|
|
579
|
+
["left", ke("left")],
|
|
580
|
+
["right", ke("right")]
|
|
595
581
|
];
|
|
596
|
-
return /* @__PURE__ */ y(
|
|
582
|
+
return /* @__PURE__ */ y(Je, { children: [
|
|
597
583
|
/* @__PURE__ */ y(
|
|
598
584
|
"div",
|
|
599
585
|
{
|
|
@@ -601,16 +587,16 @@ function Tt(t) {
|
|
|
601
587
|
className: "peeek__stage",
|
|
602
588
|
"data-layout": b,
|
|
603
589
|
tabIndex: 0,
|
|
604
|
-
onKeyDown:
|
|
605
|
-
style: { "--peeek-aspect": `${
|
|
590
|
+
onKeyDown: ze,
|
|
591
|
+
style: { "--peeek-aspect": `${pe}` },
|
|
606
592
|
children: [
|
|
607
|
-
|
|
593
|
+
d.arrows && /* @__PURE__ */ r(
|
|
608
594
|
"button",
|
|
609
595
|
{
|
|
610
596
|
type: "button",
|
|
611
597
|
className: "peeek__arrow peeek__arrow--prev",
|
|
612
|
-
"aria-label":
|
|
613
|
-
disabled:
|
|
598
|
+
"aria-label": Ue,
|
|
599
|
+
disabled: Se,
|
|
614
600
|
onClick: () => W(-1),
|
|
615
601
|
children: "‹"
|
|
616
602
|
}
|
|
@@ -620,33 +606,33 @@ function Tt(t) {
|
|
|
620
606
|
{
|
|
621
607
|
className: `peeek__zoom${x > 1 ? " peeek__zoom--pannable" : ""}`,
|
|
622
608
|
style: {
|
|
623
|
-
transform: `translate(${M.x}px, ${M.y}px) scale(${x * De}) rotate(${
|
|
624
|
-
transition: O ||
|
|
609
|
+
transform: `translate(${M.x}px, ${M.y}px) scale(${x * De}) rotate(${K}deg)`,
|
|
610
|
+
transition: O || V ? "none" : void 0
|
|
625
611
|
},
|
|
626
|
-
onDoubleClick:
|
|
627
|
-
onPointerDown:
|
|
628
|
-
onPointerMove:
|
|
629
|
-
onPointerUp:
|
|
630
|
-
onPointerCancel:
|
|
612
|
+
onDoubleClick: Me,
|
|
613
|
+
onPointerDown: Le,
|
|
614
|
+
onPointerMove: Oe,
|
|
615
|
+
onPointerUp: he,
|
|
616
|
+
onPointerCancel: he,
|
|
631
617
|
children: /* @__PURE__ */ y(
|
|
632
618
|
"div",
|
|
633
619
|
{
|
|
634
|
-
className: `peeek__spread${
|
|
635
|
-
style: { transform: `translateX(${
|
|
620
|
+
className: `peeek__spread${u ? " peeek--shadows" : ""}${Ve ? " peeek__spread--pair" : ""}`,
|
|
621
|
+
style: { transform: `translateX(${Xe})` },
|
|
636
622
|
children: [
|
|
637
|
-
|
|
638
|
-
const
|
|
623
|
+
qe.map(([o, c]) => {
|
|
624
|
+
const C = c >= 0 && d.fullscreen && !_ && !N && x === 1;
|
|
639
625
|
return /* @__PURE__ */ r(
|
|
640
626
|
"div",
|
|
641
627
|
{
|
|
642
628
|
className: `peeek__page peeek__page--${o}${c < 0 ? " peeek__page--empty" : ""}`,
|
|
643
|
-
children: c >= 0 && (
|
|
629
|
+
children: c >= 0 && (C ? /* @__PURE__ */ r(
|
|
644
630
|
"button",
|
|
645
631
|
{
|
|
646
632
|
type: "button",
|
|
647
633
|
className: "peeek__page-btn",
|
|
648
634
|
"aria-label": n.openFullscreen,
|
|
649
|
-
onClick:
|
|
635
|
+
onClick: s,
|
|
650
636
|
children: /* @__PURE__ */ r("img", { src: e[c], alt: `Page ${c + 1}`, referrerPolicy: "no-referrer" })
|
|
651
637
|
}
|
|
652
638
|
) : /* @__PURE__ */ r("img", { src: e[c], alt: `Page ${c + 1}`, referrerPolicy: "no-referrer" }))
|
|
@@ -654,15 +640,15 @@ function Tt(t) {
|
|
|
654
640
|
o
|
|
655
641
|
);
|
|
656
642
|
}),
|
|
657
|
-
|
|
643
|
+
N && /* @__PURE__ */ y(
|
|
658
644
|
"div",
|
|
659
645
|
{
|
|
660
|
-
ref:
|
|
661
|
-
className: `peeek__leaf peeek__leaf--${
|
|
662
|
-
onTransitionEnd:
|
|
646
|
+
ref: le,
|
|
647
|
+
className: `peeek__leaf peeek__leaf--${N.dir === 1 ? "fwd" : "back"}`,
|
|
648
|
+
onTransitionEnd: $e,
|
|
663
649
|
children: [
|
|
664
|
-
/* @__PURE__ */ r("div", { className: "peeek__leaf-face peeek__leaf-face--front", children: /* @__PURE__ */ r("img", { src: e[
|
|
665
|
-
/* @__PURE__ */ r("div", { className: "peeek__leaf-face peeek__leaf-face--back", children: /* @__PURE__ */ r("img", { src: e[
|
|
650
|
+
/* @__PURE__ */ r("div", { className: "peeek__leaf-face peeek__leaf-face--front", children: /* @__PURE__ */ r("img", { src: e[Ke], alt: "", referrerPolicy: "no-referrer" }) }),
|
|
651
|
+
/* @__PURE__ */ r("div", { className: "peeek__leaf-face peeek__leaf-face--back", children: /* @__PURE__ */ r("img", { src: e[We], alt: "", referrerPolicy: "no-referrer" }) })
|
|
666
652
|
]
|
|
667
653
|
}
|
|
668
654
|
)
|
|
@@ -671,13 +657,13 @@ function Tt(t) {
|
|
|
671
657
|
)
|
|
672
658
|
}
|
|
673
659
|
),
|
|
674
|
-
|
|
660
|
+
d.arrows && /* @__PURE__ */ r(
|
|
675
661
|
"button",
|
|
676
662
|
{
|
|
677
663
|
type: "button",
|
|
678
664
|
className: "peeek__arrow peeek__arrow--next",
|
|
679
|
-
"aria-label":
|
|
680
|
-
disabled:
|
|
665
|
+
"aria-label": Ze,
|
|
666
|
+
disabled: ie,
|
|
681
667
|
onClick: () => W(1),
|
|
682
668
|
children: "›"
|
|
683
669
|
}
|
|
@@ -685,42 +671,39 @@ function Tt(t) {
|
|
|
685
671
|
]
|
|
686
672
|
}
|
|
687
673
|
),
|
|
688
|
-
|
|
689
|
-
|
|
674
|
+
d.toolbar && /* @__PURE__ */ r(
|
|
675
|
+
yt,
|
|
690
676
|
{
|
|
691
677
|
strings: n,
|
|
692
|
-
label:
|
|
693
|
-
progress:
|
|
678
|
+
label: Re,
|
|
679
|
+
progress: Be,
|
|
694
680
|
zoom: x,
|
|
695
681
|
minZoom: ee,
|
|
696
682
|
maxZoom: ae,
|
|
697
683
|
total: l,
|
|
698
684
|
currentPage: te + 1,
|
|
699
|
-
|
|
700
|
-
thumbsOpen: Z,
|
|
685
|
+
thumbsOpen: B,
|
|
701
686
|
isFullscreen: _,
|
|
702
687
|
downloadUrl: w,
|
|
703
688
|
show: {
|
|
704
|
-
bar:
|
|
705
|
-
fullscreen:
|
|
706
|
-
thumbnails:
|
|
707
|
-
about:
|
|
708
|
-
goto:
|
|
709
|
-
rotate:
|
|
710
|
-
layoutToggle: u.layoutToggle
|
|
689
|
+
bar: d.bar,
|
|
690
|
+
fullscreen: d.fullscreen,
|
|
691
|
+
thumbnails: d.thumbnails && d.overview,
|
|
692
|
+
about: d.about,
|
|
693
|
+
goto: d.goto,
|
|
694
|
+
rotate: d.rotate
|
|
711
695
|
},
|
|
712
|
-
onZoomIn:
|
|
713
|
-
onZoomOut:
|
|
714
|
-
onZoomSet: (o) =>
|
|
715
|
-
onJump:
|
|
716
|
-
onRotate:
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
onAbout: s
|
|
696
|
+
onZoomIn: Ae,
|
|
697
|
+
onZoomOut: Fe,
|
|
698
|
+
onZoomSet: (o) => z(Math.min(ae, Math.max(ee, o))),
|
|
699
|
+
onJump: se,
|
|
700
|
+
onRotate: Ee,
|
|
701
|
+
onToggleThumbs: () => F((o) => !o),
|
|
702
|
+
onToggleFullscreen: s,
|
|
703
|
+
onAbout: f
|
|
721
704
|
}
|
|
722
705
|
),
|
|
723
|
-
|
|
706
|
+
d.overview && B && /* @__PURE__ */ r(vt, { pages: e, layout: b, rtl: i, activePages: Y, onJump: se })
|
|
724
707
|
] });
|
|
725
708
|
}
|
|
726
709
|
function Nt(t, e) {
|
|
@@ -740,83 +723,83 @@ function Ct(t, e) {
|
|
|
740
723
|
opacity: 0.55
|
|
741
724
|
};
|
|
742
725
|
}
|
|
743
|
-
function
|
|
726
|
+
function Tt(t) {
|
|
744
727
|
const {
|
|
745
728
|
pages: e,
|
|
746
729
|
strings: n,
|
|
747
730
|
filename: a,
|
|
748
731
|
mimeType: i,
|
|
749
|
-
rtl:
|
|
732
|
+
rtl: u,
|
|
750
733
|
autoTransition: h,
|
|
751
734
|
autoTransitionInterval: k,
|
|
752
735
|
downloadUrl: g,
|
|
753
|
-
isFullscreen:
|
|
736
|
+
isFullscreen: d,
|
|
754
737
|
onToggleFullscreen: w,
|
|
755
738
|
onAbout: _,
|
|
756
|
-
show:
|
|
757
|
-
} = t,
|
|
758
|
-
(m) =>
|
|
759
|
-
[
|
|
760
|
-
), R =
|
|
761
|
-
(m) =>
|
|
762
|
-
[
|
|
763
|
-
), x = l <= 0,
|
|
764
|
-
|
|
739
|
+
show: s
|
|
740
|
+
} = t, f = e.length, [l, L] = v(0), O = Ce(), A = D(
|
|
741
|
+
(m) => L((p) => Math.max(0, Math.min(f - 1, p + m))),
|
|
742
|
+
[f]
|
|
743
|
+
), R = D(
|
|
744
|
+
(m) => L(Math.max(0, Math.min(f - 1, m))),
|
|
745
|
+
[f]
|
|
746
|
+
), x = l <= 0, z = l >= f - 1, B = E(/* @__PURE__ */ new Set());
|
|
747
|
+
P(() => {
|
|
765
748
|
for (const m of [l - 2, l - 1, l + 1, l + 2]) {
|
|
766
|
-
const p = m >= 0 && m <
|
|
767
|
-
if (!p ||
|
|
768
|
-
|
|
749
|
+
const p = m >= 0 && m < f ? e[m] : void 0;
|
|
750
|
+
if (!p || B.current.has(p)) continue;
|
|
751
|
+
B.current.add(p);
|
|
769
752
|
const S = new globalThis.Image();
|
|
770
753
|
S.src = p;
|
|
771
754
|
}
|
|
772
|
-
}, [l,
|
|
773
|
-
const
|
|
774
|
-
|
|
755
|
+
}, [l, f, e]);
|
|
756
|
+
const F = E([]);
|
|
757
|
+
P(() => {
|
|
775
758
|
var m, p;
|
|
776
|
-
(p = (m =
|
|
777
|
-
}, [l]),
|
|
778
|
-
if (!h || O ||
|
|
779
|
-
const m = setTimeout(() =>
|
|
759
|
+
(p = (m = F.current[l]) == null ? void 0 : m.scrollIntoView) == null || p.call(m, { behavior: "smooth", inline: "center", block: "nearest" });
|
|
760
|
+
}, [l]), P(() => {
|
|
761
|
+
if (!h || O || z) return;
|
|
762
|
+
const m = setTimeout(() => A(1), k);
|
|
780
763
|
return () => clearTimeout(m);
|
|
781
|
-
}, [h, k, O,
|
|
782
|
-
const { onKeyDown: M } =
|
|
783
|
-
|
|
784
|
-
const
|
|
785
|
-
const m =
|
|
764
|
+
}, [h, k, O, z, l, A]);
|
|
765
|
+
const { onKeyDown: M } = Te({ go: A, jump: R, total: f, rtl: u }), [T, V] = v(String(l + 1));
|
|
766
|
+
P(() => V(String(l + 1)), [l]);
|
|
767
|
+
const X = () => {
|
|
768
|
+
const m = Pe(T, f);
|
|
786
769
|
if (m === null) {
|
|
787
|
-
|
|
770
|
+
V(String(l + 1));
|
|
788
771
|
return;
|
|
789
772
|
}
|
|
790
773
|
R(m);
|
|
791
|
-
},
|
|
774
|
+
}, K = Nt(a, i);
|
|
792
775
|
return /* @__PURE__ */ y("div", { className: "peeek__cf", children: [
|
|
793
776
|
/* @__PURE__ */ y("div", { className: "peeek__cf-header", children: [
|
|
794
|
-
/* @__PURE__ */ r("span", { className: "peeek__cf-badge", children:
|
|
777
|
+
/* @__PURE__ */ r("span", { className: "peeek__cf-badge", children: K }),
|
|
795
778
|
/* @__PURE__ */ y("div", { className: "peeek__cf-meta", children: [
|
|
796
779
|
/* @__PURE__ */ r("span", { className: "peeek__cf-name", children: a }),
|
|
797
780
|
/* @__PURE__ */ y("span", { className: "peeek__cf-count", children: [
|
|
798
|
-
|
|
781
|
+
f,
|
|
799
782
|
" ",
|
|
800
|
-
|
|
783
|
+
f === 1 ? n.page : n.pages
|
|
801
784
|
] })
|
|
802
785
|
] }),
|
|
803
786
|
/* @__PURE__ */ y("span", { className: "peeek__cf-indicator", children: [
|
|
804
787
|
l + 1,
|
|
805
788
|
" / ",
|
|
806
|
-
|
|
789
|
+
f
|
|
807
790
|
] }),
|
|
808
|
-
|
|
791
|
+
s.goto && /* @__PURE__ */ r(
|
|
809
792
|
"input",
|
|
810
793
|
{
|
|
811
794
|
className: "peeek__goto",
|
|
812
795
|
type: "text",
|
|
813
796
|
inputMode: "numeric",
|
|
814
797
|
"aria-label": n.goToPage,
|
|
815
|
-
value:
|
|
816
|
-
onChange: (m) =>
|
|
817
|
-
onBlur:
|
|
798
|
+
value: T,
|
|
799
|
+
onChange: (m) => V(m.target.value),
|
|
800
|
+
onBlur: X,
|
|
818
801
|
onKeyDown: (m) => {
|
|
819
|
-
m.key === "Enter" && (m.preventDefault(),
|
|
802
|
+
m.key === "Enter" && (m.preventDefault(), X());
|
|
820
803
|
}
|
|
821
804
|
}
|
|
822
805
|
),
|
|
@@ -832,18 +815,18 @@ function Pt(t) {
|
|
|
832
815
|
children: "↓"
|
|
833
816
|
}
|
|
834
817
|
),
|
|
835
|
-
|
|
818
|
+
s.fullscreen && /* @__PURE__ */ r(
|
|
836
819
|
"button",
|
|
837
820
|
{
|
|
838
821
|
type: "button",
|
|
839
|
-
className: `peeek__btn${
|
|
822
|
+
className: `peeek__btn${d ? " peeek__btn--active" : ""}`,
|
|
840
823
|
"aria-label": n.fullscreen,
|
|
841
|
-
"aria-pressed":
|
|
824
|
+
"aria-pressed": d,
|
|
842
825
|
onClick: w,
|
|
843
826
|
children: "⛶"
|
|
844
827
|
}
|
|
845
828
|
),
|
|
846
|
-
|
|
829
|
+
s.about && /* @__PURE__ */ r(
|
|
847
830
|
"button",
|
|
848
831
|
{
|
|
849
832
|
type: "button",
|
|
@@ -861,62 +844,62 @@ function Pt(t) {
|
|
|
861
844
|
tabIndex: 0,
|
|
862
845
|
onKeyDown: M,
|
|
863
846
|
children: [
|
|
864
|
-
|
|
847
|
+
s.arrows && /* @__PURE__ */ r(
|
|
865
848
|
"button",
|
|
866
849
|
{
|
|
867
850
|
type: "button",
|
|
868
851
|
className: "peeek__arrow peeek__arrow--prev",
|
|
869
852
|
"aria-label": n.prev,
|
|
870
853
|
disabled: x,
|
|
871
|
-
onClick: () =>
|
|
854
|
+
onClick: () => A(-1),
|
|
872
855
|
children: "‹"
|
|
873
856
|
}
|
|
874
857
|
),
|
|
875
858
|
e.map((m, p) => {
|
|
876
859
|
const S = p - l;
|
|
877
860
|
if (Math.abs(S) > 1) return null;
|
|
878
|
-
const b = S === 0,
|
|
861
|
+
const b = S === 0, Z = b && s.fullscreen;
|
|
879
862
|
return /* @__PURE__ */ r(
|
|
880
863
|
"button",
|
|
881
864
|
{
|
|
882
865
|
type: "button",
|
|
883
|
-
className: `peeek__cf-card${b ? " peeek__cf-card--center" : ""}${
|
|
884
|
-
style: Ct(S,
|
|
866
|
+
className: `peeek__cf-card${b ? " peeek__cf-card--center" : ""}${Z ? " peeek__cf-card--zoom" : ""}`,
|
|
867
|
+
style: Ct(S, u),
|
|
885
868
|
tabIndex: b ? 0 : -1,
|
|
886
|
-
"aria-label":
|
|
887
|
-
onClick: () =>
|
|
869
|
+
"aria-label": Z ? n.openFullscreen : `Go to page ${p + 1}`,
|
|
870
|
+
onClick: () => Z ? w() : L(p),
|
|
888
871
|
children: /* @__PURE__ */ r("img", { src: m, alt: b ? `Page ${p + 1}` : "", referrerPolicy: "no-referrer" })
|
|
889
872
|
},
|
|
890
873
|
p
|
|
891
874
|
);
|
|
892
875
|
}),
|
|
893
|
-
|
|
876
|
+
s.arrows && /* @__PURE__ */ r(
|
|
894
877
|
"button",
|
|
895
878
|
{
|
|
896
879
|
type: "button",
|
|
897
880
|
className: "peeek__arrow peeek__arrow--next",
|
|
898
881
|
"aria-label": n.next,
|
|
899
|
-
disabled:
|
|
900
|
-
onClick: () =>
|
|
882
|
+
disabled: z,
|
|
883
|
+
onClick: () => A(1),
|
|
901
884
|
children: "›"
|
|
902
885
|
}
|
|
903
886
|
)
|
|
904
887
|
]
|
|
905
888
|
}
|
|
906
889
|
),
|
|
907
|
-
|
|
890
|
+
s.thumbnails && /* @__PURE__ */ r("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((m, p) => {
|
|
908
891
|
const S = p === l;
|
|
909
892
|
return /* @__PURE__ */ y(
|
|
910
893
|
"button",
|
|
911
894
|
{
|
|
912
895
|
ref: (b) => {
|
|
913
|
-
|
|
896
|
+
F.current[p] = b;
|
|
914
897
|
},
|
|
915
898
|
type: "button",
|
|
916
899
|
className: `peeek__cf-thumb${S ? " peeek__cf-thumb--active" : ""}`,
|
|
917
900
|
"aria-label": `Go to page ${p + 1}`,
|
|
918
901
|
"aria-current": S ? "page" : void 0,
|
|
919
|
-
onClick: () =>
|
|
902
|
+
onClick: () => L(p),
|
|
920
903
|
children: [
|
|
921
904
|
/* @__PURE__ */ r("img", { src: m, alt: "", loading: "lazy", referrerPolicy: "no-referrer" }),
|
|
922
905
|
/* @__PURE__ */ r("span", { className: "peeek__cf-thumb-num", children: String(p + 1).padStart(2, "0") })
|
|
@@ -927,12 +910,12 @@ function Pt(t) {
|
|
|
927
910
|
}) })
|
|
928
911
|
] });
|
|
929
912
|
}
|
|
930
|
-
function
|
|
913
|
+
function Pt({ logo: t, logoLink: e }) {
|
|
931
914
|
if (!t) return null;
|
|
932
915
|
const n = /* @__PURE__ */ r("img", { src: t, alt: "Logo", loading: "lazy", referrerPolicy: "no-referrer" });
|
|
933
916
|
return /* @__PURE__ */ r("div", { className: "peeek__branding", children: e ? /* @__PURE__ */ r("a", { href: e, target: "_blank", rel: "noopener noreferrer", children: n }) : n });
|
|
934
917
|
}
|
|
935
|
-
const
|
|
918
|
+
const It = [
|
|
936
919
|
{ top: "12%", left: "10%", size: 3, v: "A", dur: 13, delay: 0 },
|
|
937
920
|
{ top: "22%", left: "82%", size: 2, v: "B", dur: 16, delay: 2 },
|
|
938
921
|
{ top: "40%", left: "16%", size: 2, v: "C", dur: 12, delay: 1 },
|
|
@@ -946,12 +929,12 @@ const xt = [
|
|
|
946
929
|
{ top: "16%", left: "50%", size: 2, v: "B", dur: 14, delay: 3 },
|
|
947
930
|
{ top: "62%", left: "34%", size: 2, v: "C", dur: 12, delay: 2 }
|
|
948
931
|
];
|
|
949
|
-
function
|
|
932
|
+
function xt({ strings: t, onClose: e }) {
|
|
950
933
|
const n = E(null);
|
|
951
|
-
return
|
|
934
|
+
return P(() => {
|
|
952
935
|
var a;
|
|
953
936
|
(a = n.current) == null || a.focus();
|
|
954
|
-
}, []),
|
|
937
|
+
}, []), P(() => {
|
|
955
938
|
const a = (i) => {
|
|
956
939
|
i.key === "Escape" && e();
|
|
957
940
|
};
|
|
@@ -965,7 +948,7 @@ function St({ strings: t, onClose: e }) {
|
|
|
965
948
|
className: "peeek__about",
|
|
966
949
|
onClick: (a) => a.stopPropagation(),
|
|
967
950
|
children: [
|
|
968
|
-
/* @__PURE__ */ r("span", { className: "peeek__about-particles", "aria-hidden": "true", children:
|
|
951
|
+
/* @__PURE__ */ r("span", { className: "peeek__about-particles", "aria-hidden": "true", children: It.map((a, i) => /* @__PURE__ */ r(
|
|
969
952
|
"span",
|
|
970
953
|
{
|
|
971
954
|
className: "peeek__about-particle",
|
|
@@ -1027,7 +1010,7 @@ function St({ strings: t, onClose: e }) {
|
|
|
1027
1010
|
/* @__PURE__ */ r("div", { className: "peeek__about-tagline", children: t.aboutTagline }),
|
|
1028
1011
|
/* @__PURE__ */ y("div", { className: "peeek__about-version", children: [
|
|
1029
1012
|
"v",
|
|
1030
|
-
"0.4.
|
|
1013
|
+
"0.4.10"
|
|
1031
1014
|
] }),
|
|
1032
1015
|
/* @__PURE__ */ r("p", { className: "peeek__about-desc", children: t.aboutDescription }),
|
|
1033
1016
|
/* @__PURE__ */ r(
|
|
@@ -1045,14 +1028,14 @@ function St({ strings: t, onClose: e }) {
|
|
|
1045
1028
|
}
|
|
1046
1029
|
) });
|
|
1047
1030
|
}
|
|
1048
|
-
function
|
|
1049
|
-
const e =
|
|
1050
|
-
() => g ?
|
|
1031
|
+
function At(t) {
|
|
1032
|
+
const e = ft(t), n = ut(e.language), a = E(null), { isFullscreen: i, toggle: u } = bt(a), [h, k] = v(!1), g = t.pages !== void 0, d = Qe(
|
|
1033
|
+
() => g ? mt(t.pages, { filename: t.filename, mimeType: t.mimeType }) : null,
|
|
1051
1034
|
[g, t.pages, t.filename, t.mimeType]
|
|
1052
|
-
), w =
|
|
1035
|
+
), w = pt(g ? null : e.src, e.pollInterval), _ = g ? d : w.manifest, s = g ? d ? "ready" : "loading" : w.state, f = {
|
|
1053
1036
|
"--peeek-accent": e.accentColor
|
|
1054
1037
|
};
|
|
1055
|
-
e.background === "transparent" ?
|
|
1038
|
+
e.background === "transparent" ? f["--peeek-bg"] = "transparent" : e.background === "color" && e.backgroundColor ? f["--peeek-bg"] = e.backgroundColor : e.background === "image" && e.backgroundImage && (f["--peeek-bg"] = `center / cover no-repeat url("${e.backgroundImage}")`);
|
|
1056
1039
|
const l = {
|
|
1057
1040
|
toolbar: e.navigationControls,
|
|
1058
1041
|
bar: e.navigationBar,
|
|
@@ -1062,8 +1045,7 @@ function Ft(t) {
|
|
|
1062
1045
|
overview: e.pagesOverview,
|
|
1063
1046
|
about: e.aboutButton,
|
|
1064
1047
|
goto: e.goToPage,
|
|
1065
|
-
rotate: e.rotateControl
|
|
1066
|
-
layoutToggle: e.layoutToggle
|
|
1048
|
+
rotate: e.rotateControl
|
|
1067
1049
|
};
|
|
1068
1050
|
return /* @__PURE__ */ y(
|
|
1069
1051
|
"div",
|
|
@@ -1073,16 +1055,16 @@ function Ft(t) {
|
|
|
1073
1055
|
"data-skin": e.skin,
|
|
1074
1056
|
"data-layout": e.layout,
|
|
1075
1057
|
dir: e.rtl ? "rtl" : void 0,
|
|
1076
|
-
style:
|
|
1058
|
+
style: f,
|
|
1077
1059
|
children: [
|
|
1078
|
-
/* @__PURE__ */ r(
|
|
1079
|
-
|
|
1060
|
+
/* @__PURE__ */ r(Pt, { logo: e.logo, logoLink: e.logoLink }),
|
|
1061
|
+
s === "loading" && /* @__PURE__ */ y("div", { className: "peeek__state", style: e.loadingColor ? { color: e.loadingColor } : void 0, children: [
|
|
1080
1062
|
e.loadingImage && /* @__PURE__ */ r("img", { className: "peeek__state-img", src: e.loadingImage, alt: "", referrerPolicy: "no-referrer" }),
|
|
1081
1063
|
/* @__PURE__ */ r("span", { children: e.loadingCaption ?? n.loading })
|
|
1082
1064
|
] }),
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1065
|
+
s === "error" && /* @__PURE__ */ r("div", { className: "peeek__state", children: n.error }),
|
|
1066
|
+
s === "ready" && _ && e.mode === "coverflow" && /* @__PURE__ */ r(
|
|
1067
|
+
Tt,
|
|
1086
1068
|
{
|
|
1087
1069
|
pages: _.pages,
|
|
1088
1070
|
strings: n,
|
|
@@ -1093,13 +1075,13 @@ function Ft(t) {
|
|
|
1093
1075
|
autoTransitionInterval: e.autoTransitionInterval,
|
|
1094
1076
|
downloadUrl: e.downloadUrl,
|
|
1095
1077
|
isFullscreen: i,
|
|
1096
|
-
onToggleFullscreen:
|
|
1078
|
+
onToggleFullscreen: u,
|
|
1097
1079
|
onAbout: () => k(!0),
|
|
1098
1080
|
show: { arrows: e.arrows, thumbnails: e.pagesOverview, fullscreen: e.fullscreen, about: e.aboutButton, goto: e.goToPage }
|
|
1099
1081
|
}
|
|
1100
1082
|
),
|
|
1101
|
-
|
|
1102
|
-
|
|
1083
|
+
s === "ready" && _ && e.mode === "flip" && /* @__PURE__ */ r(
|
|
1084
|
+
wt,
|
|
1103
1085
|
{
|
|
1104
1086
|
pages: _.pages,
|
|
1105
1087
|
strings: n,
|
|
@@ -1112,15 +1094,15 @@ function Ft(t) {
|
|
|
1112
1094
|
show: l,
|
|
1113
1095
|
downloadUrl: e.downloadUrl,
|
|
1114
1096
|
isFullscreen: i,
|
|
1115
|
-
onToggleFullscreen:
|
|
1097
|
+
onToggleFullscreen: u,
|
|
1116
1098
|
onAbout: () => k(!0)
|
|
1117
1099
|
}
|
|
1118
1100
|
),
|
|
1119
|
-
h && /* @__PURE__ */ r(
|
|
1101
|
+
h && /* @__PURE__ */ r(xt, { strings: n, onClose: () => k(!1) })
|
|
1120
1102
|
]
|
|
1121
1103
|
}
|
|
1122
1104
|
);
|
|
1123
1105
|
}
|
|
1124
1106
|
export {
|
|
1125
|
-
|
|
1107
|
+
At as PeeekViewer
|
|
1126
1108
|
};
|