@peeekpage/viewer 0.4.8 → 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 CHANGED
@@ -48,7 +48,6 @@ export declare interface PeeekViewerProps {
48
48
  aboutButton?: boolean;
49
49
  goToPage?: boolean;
50
50
  rotateControl?: boolean;
51
- layoutToggle?: boolean;
52
51
  loadingImage?: string;
53
52
  loadingCaption?: string;
54
53
  loadingColor?: string;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsxs as y, jsx as r, Fragment as Qe } from "react/jsx-runtime";
2
- import { useState as v, useRef as E, useEffect as C, useCallback as L, useMemo as et } from "react";
3
- const tt = /* @__PURE__ */ new Set(["http:", "https:"]);
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 tt.has(a.protocol) ? a.href : null;
15
+ return et.has(a.protocol) ? a.href : null;
16
16
  }
17
- const nt = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, at = /^rgba?\([ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*(?:,[ \t]*(?:0|1|0?\.\d+)[ \t]*)?\)$/;
18
- function de(t) {
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 nt.test(e) || at.test(e) ? e : null;
21
+ return tt.test(e) || nt.test(e) ? e : null;
22
22
  }
23
- const rt = /url\(|image\(|image-set\(|element\(|expression|@|\/\*|;|\{|\}|<|>|\\/i, ot = /^(repeating-)?(linear|radial|conic)-gradient\([a-z0-9#.,%()\/\s-]*\)$/i, lt = /^hsla?\([a-z0-9.,%\/\s-]*\)$/i;
24
- function it(t) {
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 === "" || rt.test(e)) return null;
28
- const n = de(e);
29
- return n !== null ? n : lt.test(e) || ot.test(e) ? e : null;
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 st = ["en", "pt-BR"], Ne = {
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
- }, ct = {
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
- }, ut = { en: Ne, "pt-BR": ct };
76
- function dt(t) {
77
- return ut[t] ?? Ne;
75
+ }, ct = { en: Ne, "pt-BR": st };
76
+ function ut(t) {
77
+ return ct[t] ?? Ne;
78
78
  }
79
- const ft = "#6E79D6";
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 gt(t) {
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: de(t.accentColor) ?? ft,
92
+ accentColor: ue(t.accentColor) ?? dt,
93
93
  background: J(t.background, ["color", "image", "transparent"], "color"),
94
- backgroundColor: it(t.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, st, "en"),
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: de(t.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 fe = 5e3;
121
+ const de = 5e3;
123
122
  function Q(t) {
124
123
  return typeof t == "string" ? t : "";
125
124
  }
126
- function mt(t) {
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 > fe)
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 > fe)
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 c = G(g.url);
141
- c && i.push(c);
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 d = e.status === "wip" ? "wip" : "done", h = e.metadata && typeof e.metadata == "object" ? e.metadata : {}, k = {
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: d, totalPages: a, pages: i, metadata: k }
153
+ value: { status: u, totalPages: a, pages: i, metadata: k }
155
154
  };
156
155
  }
157
- function pt(t, e) {
158
- if (!Array.isArray(t) || t.length > fe) return null;
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 d = G(i);
162
- d && n.push(d);
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 bt(t, e) {
178
- const [n, a] = v("loading"), [i, d] = v(null), [h, k] = v(null), g = E(null);
179
- return C(() => {
180
- let c = !1;
181
- if (a("loading"), d(null), k(null), !t) return;
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 f;
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
- f = await l.json();
188
+ s = await l.json();
190
189
  } catch (l) {
191
- if (c) return;
190
+ if (d) return;
192
191
  k(l instanceof Error ? l.message : "fetch failed"), a("error");
193
192
  return;
194
193
  }
195
- if (c) return;
196
- const u = mt(f);
197
- if (!u.ok) {
198
- k(u.error), a("error");
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
- d(u.value), a("ready"), u.value.status === "wip" && (g.current = setTimeout(_, e));
200
+ u(f.value), a("ready"), f.value.status === "wip" && (g.current = setTimeout(_, e));
202
201
  };
203
202
  return _(), () => {
204
- c = !0, w();
203
+ d = !0, w();
205
204
  };
206
205
  }, [t, e]), { state: n, manifest: i, error: h };
207
206
  }
208
- function ht(t) {
207
+ function bt(t) {
209
208
  const [e, n] = v(!1);
210
- C(() => {
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 = L(async () => {
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 we = "(prefers-reduced-motion: reduce)";
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(we)) == null ? void 0 : n.matches) ?? !1;
227
+ return ((n = matchMedia == null ? void 0 : matchMedia(ve)) == null ? void 0 : n.matches) ?? !1;
229
228
  });
230
- return C(() => {
231
- const n = typeof matchMedia == "function" ? matchMedia(we) : void 0;
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 Pe({ go: t, jump: e, total: n, rtl: a }) {
238
- return { onKeyDown: L(
239
- (d) => {
240
- switch (d.key) {
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
- d.preventDefault(), n > 0 && e(0);
247
+ u.preventDefault(), n > 0 && e(0);
249
248
  break;
250
249
  case "End":
251
- d.preventDefault(), n > 0 && e(n - 1);
250
+ u.preventDefault(), n > 0 && e(n - 1);
252
251
  break;
253
252
  case " ":
254
253
  case "Spacebar":
255
- d.preventDefault(), t(d.shiftKey ? -1 : 1);
254
+ u.preventDefault(), t(u.shiftKey ? -1 : 1);
256
255
  break;
257
256
  case "PageDown":
258
- d.preventDefault(), t(1);
257
+ u.preventDefault(), t(1);
259
258
  break;
260
259
  case "PageUp":
261
- d.preventDefault(), t(-1);
260
+ u.preventDefault(), t(-1);
262
261
  break;
263
262
  }
264
263
  },
265
264
  [t, e, n, a]
266
265
  ) };
267
266
  }
268
- function Ie(t, e) {
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 kt = 640;
276
- function _t(t, e) {
277
- const [n, a] = v("auto"), [i, d] = v(null);
278
- C(() => {
279
- const c = t.current;
280
- if (!c || (c.clientWidth > 0 && d(c.clientWidth), typeof ResizeObserver > "u")) return;
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 u;
283
- const f = (u = _[0]) == null ? void 0 : u.contentRect.width;
284
- typeof f == "number" && f > 0 && d(f);
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(c), () => w.disconnect();
285
+ return w.observe(d), () => w.disconnect();
287
286
  }, [t]);
288
- const h = i != null && i < kt ? "single" : e, k = n === "auto" ? h : n, g = L(() => {
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 me(t, e) {
292
+ function ge(t, e) {
294
293
  return t <= 0 ? 0 : e === "single" ? t : 1 + Math.ceil((t - 1) / 2);
295
294
  }
296
- function yt(t, e) {
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,63 +304,61 @@ 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 ge(t, e, n) {
309
- const { left: a, right: i } = re(t, e, n), d = [];
310
- return a >= 0 && d.push(a), i >= 0 && d.push(i), d;
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 = me(e, n) - 1;
312
+ const a = ge(e, n) - 1;
314
313
  return t < 0 ? 0 : t > a ? a : t;
315
314
  }
316
- function vt(t) {
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: d,
321
+ minZoom: u,
323
322
  maxZoom: h,
324
323
  total: k,
325
324
  currentPage: g,
326
- layout: c,
327
- thumbsOpen: w,
328
- isFullscreen: _,
329
- downloadUrl: f,
330
- show: u,
331
- onZoomIn: l,
332
- onZoomOut: D,
333
- onZoomSet: O,
334
- onJump: F,
335
- onRotate: R,
336
- onToggleLayout: x,
337
- onToggleThumbs: A,
338
- onToggleFullscreen: Z,
339
- onAbout: j
340
- } = t, [M, z] = v(String(g));
341
- C(() => z(String(g)), [g]);
342
- const B = () => {
343
- const P = Ie(M, k);
344
- if (P === null) {
345
- z(String(g));
325
+ thumbsOpen: d,
326
+ isFullscreen: w,
327
+ downloadUrl: _,
328
+ show: s,
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
- F(P), z(String(P + 1));
345
+ O(T), F(String(T + 1));
349
346
  };
350
347
  return /* @__PURE__ */ y("div", { className: "peeek__toolbar", children: [
351
- /* @__PURE__ */ r("span", { className: "peeek__label", children: n }),
352
- u.bar && /* @__PURE__ */ r("div", { className: "peeek__scrubber", "aria-hidden": !0, children: /* @__PURE__ */ r("div", { className: "peeek__scrubber-fill", style: { width: `${a}%` } }) }),
353
- u.goto && /* @__PURE__ */ r(
348
+ !s.goto && /* @__PURE__ */ r("span", { className: "peeek__label", children: n }),
349
+ s.bar && /* @__PURE__ */ r("div", { className: "peeek__scrubber", "aria-hidden": !0, children: /* @__PURE__ */ r("div", { className: "peeek__scrubber-fill", style: { width: `${a}%` } }) }),
350
+ s.goto && /* @__PURE__ */ r(
354
351
  "input",
355
352
  {
356
353
  className: "peeek__goto",
357
354
  type: "text",
358
355
  inputMode: "numeric",
359
356
  "aria-label": e.goToPage,
360
- value: M,
361
- onChange: (P) => z(P.target.value),
362
- onBlur: B,
363
- onKeyDown: (P) => {
364
- P.key === "Enter" && (P.preventDefault(), B());
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 <= d,
375
- onClick: D,
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: d,
381
+ min: u,
385
382
  max: h,
386
383
  step: 0.25,
387
384
  value: i,
388
- onChange: (P) => O(Number(P.target.value))
385
+ onChange: (T) => L(Number(T.target.value))
389
386
  }
390
387
  ),
391
388
  /* @__PURE__ */ r(
@@ -395,47 +392,36 @@ function vt(t) {
395
392
  className: "peeek__btn",
396
393
  "aria-label": e.zoomIn,
397
394
  disabled: i >= h,
398
- onClick: l,
395
+ onClick: f,
399
396
  children: "+"
400
397
  }
401
398
  ),
402
- u.rotate && /* @__PURE__ */ r(
399
+ s.rotate && /* @__PURE__ */ r(
403
400
  "button",
404
401
  {
405
402
  type: "button",
406
403
  className: "peeek__btn",
407
404
  "aria-label": e.rotate,
408
- onClick: R,
405
+ onClick: A,
409
406
  children: "⟳"
410
407
  }
411
408
  ),
412
- u.layoutToggle && /* @__PURE__ */ r(
409
+ s.thumbnails && /* @__PURE__ */ r(
413
410
  "button",
414
411
  {
415
412
  type: "button",
416
- className: "peeek__btn",
417
- "aria-label": c === "single" ? e.doublePage : e.singlePage,
418
- "aria-pressed": c === "double",
419
- onClick: x,
420
- children: c === "single" ? "▭" : "▥"
421
- }
422
- ),
423
- u.thumbnails && /* @__PURE__ */ r(
424
- "button",
425
- {
426
- type: "button",
427
- className: `peeek__btn${w ? " peeek__btn--active" : ""}`,
413
+ className: `peeek__btn${d ? " peeek__btn--active" : ""}`,
428
414
  "aria-label": e.thumbnails,
429
- "aria-pressed": w,
430
- onClick: A,
415
+ "aria-pressed": d,
416
+ onClick: R,
431
417
  children: "▦"
432
418
  }
433
419
  ),
434
- f && /* @__PURE__ */ r(
420
+ _ && /* @__PURE__ */ r(
435
421
  "a",
436
422
  {
437
423
  className: "peeek__btn",
438
- href: f,
424
+ href: _,
439
425
  "aria-label": e.download,
440
426
  target: "_blank",
441
427
  rel: "noopener noreferrer",
@@ -443,157 +429,157 @@ function vt(t) {
443
429
  children: "↓"
444
430
  }
445
431
  ),
446
- u.fullscreen && /* @__PURE__ */ r(
432
+ s.fullscreen && /* @__PURE__ */ r(
447
433
  "button",
448
434
  {
449
435
  type: "button",
450
- className: `peeek__btn${_ ? " peeek__btn--active" : ""}`,
436
+ className: `peeek__btn${w ? " peeek__btn--active" : ""}`,
451
437
  "aria-label": e.fullscreen,
452
- "aria-pressed": _,
453
- onClick: Z,
438
+ "aria-pressed": w,
439
+ onClick: x,
454
440
  children: "⛶"
455
441
  }
456
442
  ),
457
- u.about && /* @__PURE__ */ r(
443
+ s.about && /* @__PURE__ */ r(
458
444
  "button",
459
445
  {
460
446
  type: "button",
461
447
  className: "peeek__btn",
462
448
  "aria-label": e.about,
463
- onClick: j,
449
+ onClick: z,
464
450
  children: "?"
465
451
  }
466
452
  )
467
453
  ] });
468
454
  }
469
- function wt({ pages: t, layout: e, rtl: n, activePages: a, onJump: i }) {
470
- const d = t.length, h = new Set(a), k = me(d, e);
471
- return /* @__PURE__ */ r("div", { className: "peeek__thumbs", role: "group", "aria-label": "Pages", children: Array.from({ length: k }, (g, c) => {
472
- const w = ge(c, d, e), _ = w.length === 2;
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((f, u) => {
460
+ w.map((s, f) => {
475
461
  let l = "";
476
- return _ && (l = (n ? u === 1 : u === 0) ? " peeek__thumb--flat-right" : " peeek__thumb--flat-left"), /* @__PURE__ */ r(
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 ${f + 1}`,
481
- "aria-current": h.has(f),
482
- className: `peeek__thumb${h.has(f) ? " peeek__thumb--active" : ""}${l}`,
483
- onClick: () => i(f),
484
- children: /* @__PURE__ */ r("img", { src: t[f], alt: "", loading: "lazy", referrerPolicy: "no-referrer" })
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
- f
472
+ s
487
473
  );
488
474
  }),
489
- /* @__PURE__ */ r("span", { className: "peeek__thumb-badge", "aria-hidden": !0, children: w.map((f) => f + 1).join("-") })
490
- ] }, c);
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, Te = 0.5;
494
- function Tt(t) {
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: d,
486
+ pageShadows: u,
501
487
  animateInteractions: h,
502
488
  autoTransition: k,
503
489
  autoTransitionInterval: g,
504
- show: c,
490
+ show: d,
505
491
  downloadUrl: w,
506
492
  isFullscreen: _,
507
- onToggleFullscreen: f,
508
- onAbout: u
509
- } = t, l = e.length, O = Ce() || !h, [F, R] = v(0), [x, A] = v(1), [Z, j] = v(!1), [M, z] = v({ x: 0, y: 0 }), [B, P] = v(!1), [X, m] = v(0), p = E(null), S = E(null), { layout: b, toggle: K } = _t(S, a), oe = me(l, b), [T, le] = v(null), [xe, pe] = v(!1), ie = E(null), [be, Se] = v(0.707);
510
- C(() => {
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 && Se(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(F, l, b), $e = $ <= 0, se = $ >= oe - 1, he = E(/* @__PURE__ */ new Set());
518
- C(() => {
519
- const o = [$ - 1, $ + 1, $ + 2].map((s) => ne(s, l, b)).flatMap((s) => ge(s, l, b)).filter((s) => s >= 0);
520
- for (const s of o) {
521
- const N = e[s];
522
- if (!N || he.current.has(N)) continue;
523
- he.current.add(N);
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);
506
+ for (const c of o) {
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 = N;
511
+ q.src = C;
526
512
  }
527
513
  }, [$, l, b, e]);
528
- const W = L(
514
+ const W = D(
529
515
  (o) => {
530
- T || R((s) => {
531
- const N = ne(s + o, l, b);
532
- return N === s ? s : O ? N : (le({ dir: o, to: N }), s);
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, T]
536
- ), ze = L((o) => {
537
- o.target === ie.current && (o.propertyName && o.propertyName !== "transform" || le((s) => s && (R(s.to), pe(!0), requestAnimationFrame(
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
- le(null), pe(!1);
525
+ oe(null), me(!1);
540
526
  })
541
- ), s)));
527
+ ), c)));
542
528
  }, []);
543
- C(() => {
544
- if (!T) return;
545
- const o = ie.current;
529
+ P(() => {
530
+ if (!N) return;
531
+ const o = le.current;
546
532
  if (!o) return;
547
533
  o.style.transform = "rotateY(0deg)";
548
- let s = 0;
549
- const N = requestAnimationFrame(() => {
550
- s = requestAnimationFrame(() => {
551
- o.style.transform = `rotateY(${T.dir === 1 ? -180 : 180}deg)`;
534
+ let c = 0;
535
+ const C = requestAnimationFrame(() => {
536
+ c = requestAnimationFrame(() => {
537
+ o.style.transform = `rotateY(${N.dir === 1 ? -180 : 180}deg)`;
552
538
  });
553
539
  });
554
540
  return () => {
555
- cancelAnimationFrame(N), cancelAnimationFrame(s);
541
+ cancelAnimationFrame(C), cancelAnimationFrame(c);
556
542
  };
557
- }, [T]);
558
- const ce = L(
543
+ }, [N]);
544
+ const se = D(
559
545
  (o) => {
560
- R(ne(yt(o, b), l, b));
546
+ R(ne(_t(o, b), l, b));
561
547
  },
562
548
  [l, b]
563
- ), { onKeyDown: Ae } = Pe({ go: W, jump: ce, total: l, rtl: i });
564
- C(() => {
565
- if (!k || se) return;
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, se, $, W]);
569
- const Fe = () => A((o) => Math.min(ae, o + Te)), Me = () => A((o) => Math.max(ee, o - Te)), Ee = () => {
570
- T || A((o) => o > ee ? ee : ae);
571
- }, Le = () => m((o) => (o + 90) % 360), De = X === 90 || X === 270 ? be : 1, ue = L((o, s, N) => {
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 || N <= 1) return { x: 0, y: 0 };
574
- const ye = (N - 1) * q.clientWidth / 2, ve = (N - 1) * q.clientHeight / 2;
575
- return { x: Math.max(-ye, Math.min(ye, o)), y: Math.max(-ve, Math.min(ve, s)) };
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
- C(() => z((o) => ue(o.x, o.y, x)), [x, ue]), C(() => z({ x: 0, y: 0 }), [$]);
578
- const Oe = (o) => {
579
- var s, N;
580
- x <= 1 || (p.current = { x: o.clientX, y: o.clientY, px: M.x, py: M.y }, P(!0), (N = (s = o.currentTarget).setPointerCapture) == null || N.call(s, o.pointerId));
581
- }, Re = (o) => {
582
- const s = p.current;
583
- s && z(ue(s.px + (o.clientX - s.x), s.py + (o.clientY - s.y), x));
584
- }, ke = (o) => {
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) => {
568
+ const c = p.current;
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, P(!1);
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 = ge($, l, b), te = Y[0] ?? 0, Be = b === "double" && Y.length === 2 ? `${Y[0] + 1} - ${Y[1] + 1} / ${l}` : `${te + 1} / ${l}`, Ue = oe <= 1 ? 100 : $ / (oe - 1) * 100, Ze = n.prev, He = n.next, Ge = T ? T.to : $, H = re(Ge, l, b), je = H.left < 0 && H.right >= 0, Ve = H.left >= 0 && H.right < 0, Xe = H.left >= 0 && H.right >= 0, Ke = je ? "-25%" : Ve ? "25%" : "0%", U = re($, l, b), V = T ? re(T.to, l, b) : U, We = T ? T.dir === 1 ? U.right >= 0 ? U.right : U.left : U.left >= 0 ? U.left : U.right : te, Ye = T ? T.dir === 1 ? V.left >= 0 ? V.left : V.right : V.right >= 0 ? V.right : V.left : te, qe = T ? T.dir === 1 ? "left" : "right" : null, _e = (o) => o === qe && !xe ? U[o] : H[o], Je = [
593
- ["left", _e("left")],
594
- ["right", _e("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(Qe, { children: [
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: Ae,
605
- style: { "--peeek-aspect": `${be}` },
590
+ onKeyDown: ze,
591
+ style: { "--peeek-aspect": `${pe}` },
606
592
  children: [
607
- c.arrows && /* @__PURE__ */ r(
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": Ze,
613
- disabled: $e,
598
+ "aria-label": Ue,
599
+ disabled: Se,
614
600
  onClick: () => W(-1),
615
601
  children: "‹"
616
602
  }
@@ -620,49 +606,49 @@ 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(${X}deg)`,
624
- transition: O || B ? "none" : void 0
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: Ee,
627
- onPointerDown: Oe,
628
- onPointerMove: Re,
629
- onPointerUp: ke,
630
- onPointerCancel: ke,
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${d ? " peeek--shadows" : ""}${Xe ? " peeek__spread--pair" : ""}`,
635
- style: { transform: `translateX(${Ke})` },
620
+ className: `peeek__spread${u ? " peeek--shadows" : ""}${Ve ? " peeek__spread--pair" : ""}`,
621
+ style: { transform: `translateX(${Xe})` },
636
622
  children: [
637
- Je.map(([o, s]) => {
638
- const N = s >= 0 && c.fullscreen && !_ && !T && x === 1;
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
- className: `peeek__page peeek__page--${o}${s < 0 ? " peeek__page--empty" : ""}`,
643
- children: s >= 0 && (N ? /* @__PURE__ */ r(
628
+ className: `peeek__page peeek__page--${o}${c < 0 ? " peeek__page--empty" : ""}`,
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: f,
650
- children: /* @__PURE__ */ r("img", { src: e[s], alt: `Page ${s + 1}`, referrerPolicy: "no-referrer" })
635
+ onClick: s,
636
+ children: /* @__PURE__ */ r("img", { src: e[c], alt: `Page ${c + 1}`, referrerPolicy: "no-referrer" })
651
637
  }
652
- ) : /* @__PURE__ */ r("img", { src: e[s], alt: `Page ${s + 1}`, referrerPolicy: "no-referrer" }))
638
+ ) : /* @__PURE__ */ r("img", { src: e[c], alt: `Page ${c + 1}`, referrerPolicy: "no-referrer" }))
653
639
  },
654
640
  o
655
641
  );
656
642
  }),
657
- T && /* @__PURE__ */ y(
643
+ N && /* @__PURE__ */ y(
658
644
  "div",
659
645
  {
660
- ref: ie,
661
- className: `peeek__leaf peeek__leaf--${T.dir === 1 ? "fwd" : "back"}`,
662
- onTransitionEnd: ze,
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[We], alt: "", referrerPolicy: "no-referrer" }) }),
665
- /* @__PURE__ */ r("div", { className: "peeek__leaf-face peeek__leaf-face--back", children: /* @__PURE__ */ r("img", { src: e[Ye], alt: "", referrerPolicy: "no-referrer" }) })
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
- c.arrows && /* @__PURE__ */ r(
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": He,
680
- disabled: se,
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
- c.toolbar && /* @__PURE__ */ r(
689
- vt,
674
+ d.toolbar && /* @__PURE__ */ r(
675
+ yt,
690
676
  {
691
677
  strings: n,
692
- label: Be,
693
- progress: Ue,
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
- layout: b,
700
- thumbsOpen: Z,
685
+ thumbsOpen: B,
701
686
  isFullscreen: _,
702
687
  downloadUrl: w,
703
688
  show: {
704
- bar: c.bar,
705
- fullscreen: c.fullscreen,
706
- thumbnails: c.thumbnails && c.overview,
707
- about: c.about,
708
- goto: c.goto,
709
- rotate: c.rotate,
710
- layoutToggle: c.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: Fe,
713
- onZoomOut: Me,
714
- onZoomSet: (o) => A(Math.min(ae, Math.max(ee, o))),
715
- onJump: ce,
716
- onRotate: Le,
717
- onToggleLayout: K,
718
- onToggleThumbs: () => j((o) => !o),
719
- onToggleFullscreen: f,
720
- onAbout: u
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
- c.overview && Z && /* @__PURE__ */ r(wt, { pages: e, layout: b, rtl: i, activePages: Y, onJump: ce })
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 Pt(t) {
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: d,
732
+ rtl: u,
750
733
  autoTransition: h,
751
734
  autoTransitionInterval: k,
752
735
  downloadUrl: g,
753
- isFullscreen: c,
736
+ isFullscreen: d,
754
737
  onToggleFullscreen: w,
755
738
  onAbout: _,
756
- show: f
757
- } = t, u = e.length, [l, D] = v(0), O = Ce(), F = L(
758
- (m) => D((p) => Math.max(0, Math.min(u - 1, p + m))),
759
- [u]
760
- ), R = L(
761
- (m) => D(Math.max(0, Math.min(u - 1, m))),
762
- [u]
763
- ), x = l <= 0, A = l >= u - 1, Z = E(/* @__PURE__ */ new Set());
764
- C(() => {
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 < u ? e[m] : void 0;
767
- if (!p || Z.current.has(p)) continue;
768
- Z.current.add(p);
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, u, e]);
773
- const j = E([]);
774
- C(() => {
755
+ }, [l, f, e]);
756
+ const F = E([]);
757
+ P(() => {
775
758
  var m, p;
776
- (p = (m = j.current[l]) == null ? void 0 : m.scrollIntoView) == null || p.call(m, { behavior: "smooth", inline: "center", block: "nearest" });
777
- }, [l]), C(() => {
778
- if (!h || O || A) return;
779
- const m = setTimeout(() => F(1), k);
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, A, l, F]);
782
- const { onKeyDown: M } = Pe({ go: F, jump: R, total: u, rtl: d }), [z, B] = v(String(l + 1));
783
- C(() => B(String(l + 1)), [l]);
784
- const P = () => {
785
- const m = Ie(z, u);
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
- B(String(l + 1));
770
+ V(String(l + 1));
788
771
  return;
789
772
  }
790
773
  R(m);
791
- }, X = Nt(a, i);
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: X }),
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
- u,
781
+ f,
799
782
  " ",
800
- u === 1 ? n.page : n.pages
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
- u
789
+ f
807
790
  ] }),
808
- f.goto && /* @__PURE__ */ r(
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: z,
816
- onChange: (m) => B(m.target.value),
817
- onBlur: P,
798
+ value: T,
799
+ onChange: (m) => V(m.target.value),
800
+ onBlur: X,
818
801
  onKeyDown: (m) => {
819
- m.key === "Enter" && (m.preventDefault(), P());
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
- f.fullscreen && /* @__PURE__ */ r(
818
+ s.fullscreen && /* @__PURE__ */ r(
836
819
  "button",
837
820
  {
838
821
  type: "button",
839
- className: `peeek__btn${c ? " peeek__btn--active" : ""}`,
822
+ className: `peeek__btn${d ? " peeek__btn--active" : ""}`,
840
823
  "aria-label": n.fullscreen,
841
- "aria-pressed": c,
824
+ "aria-pressed": d,
842
825
  onClick: w,
843
826
  children: "⛶"
844
827
  }
845
828
  ),
846
- f.about && /* @__PURE__ */ r(
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
- f.arrows && /* @__PURE__ */ r(
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: () => F(-1),
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, K = b && f.fullscreen;
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" : ""}${K ? " peeek__cf-card--zoom" : ""}`,
884
- style: Ct(S, d),
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": K ? n.openFullscreen : `Go to page ${p + 1}`,
887
- onClick: () => K ? w() : D(p),
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
- f.arrows && /* @__PURE__ */ r(
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: A,
900
- onClick: () => F(1),
882
+ disabled: z,
883
+ onClick: () => A(1),
901
884
  children: "›"
902
885
  }
903
886
  )
904
887
  ]
905
888
  }
906
889
  ),
907
- f.thumbnails && /* @__PURE__ */ r("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((m, p) => {
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
- j.current[p] = b;
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: () => D(p),
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 It({ logo: t, logoLink: e }) {
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 xt = [
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 St({ strings: t, onClose: e }) {
932
+ function xt({ strings: t, onClose: e }) {
950
933
  const n = E(null);
951
- return C(() => {
934
+ return P(() => {
952
935
  var a;
953
936
  (a = n.current) == null || a.focus();
954
- }, []), C(() => {
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: xt.map((a, i) => /* @__PURE__ */ r(
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.8"
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 Ft(t) {
1049
- const e = gt(t), n = dt(e.language), a = E(null), { isFullscreen: i, toggle: d } = ht(a), [h, k] = v(!1), g = t.pages !== void 0, c = et(
1050
- () => g ? pt(t.pages, { filename: t.filename, mimeType: t.mimeType }) : null,
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 = bt(g ? null : e.src, e.pollInterval), _ = g ? c : w.manifest, f = g ? c ? "ready" : "loading" : w.state, u = {
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" ? u["--peeek-bg"] = "transparent" : e.background === "color" && e.backgroundColor ? u["--peeek-bg"] = e.backgroundColor : e.background === "image" && e.backgroundImage && (u["--peeek-bg"] = `center / cover no-repeat url("${e.backgroundImage}")`);
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: u,
1058
+ style: f,
1077
1059
  children: [
1078
- /* @__PURE__ */ r(It, { logo: e.logo, logoLink: e.logoLink }),
1079
- f === "loading" && /* @__PURE__ */ y("div", { className: "peeek__state", style: e.loadingColor ? { color: e.loadingColor } : void 0, children: [
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
- f === "error" && /* @__PURE__ */ r("div", { className: "peeek__state", children: n.error }),
1084
- f === "ready" && _ && e.mode === "coverflow" && /* @__PURE__ */ r(
1085
- Pt,
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: d,
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
- f === "ready" && _ && e.mode === "flip" && /* @__PURE__ */ r(
1102
- Tt,
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: d,
1097
+ onToggleFullscreen: u,
1116
1098
  onAbout: () => k(!0)
1117
1099
  }
1118
1100
  ),
1119
- h && /* @__PURE__ */ r(St, { strings: n, onClose: () => k(!1) })
1101
+ h && /* @__PURE__ */ r(xt, { strings: n, onClose: () => k(!1) })
1120
1102
  ]
1121
1103
  }
1122
1104
  );
1123
1105
  }
1124
1106
  export {
1125
- Ft as PeeekViewer
1107
+ At as PeeekViewer
1126
1108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peeekpage/viewer",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "PeeekViewer: embeddable document viewer (flip and coverflow) for peeek.page.",
5
5
  "type": "module",
6
6
  "license": "MIT",