@kaktos/flipbook-react 1.0.1 → 1.0.3

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.
@@ -1,6 +1,6 @@
1
- import { jsxs as oe, jsx as tt } from "react/jsx-runtime";
2
- import { useState as T, useEffect as N, useRef as u, useCallback as f, useMemo as Ve, forwardRef as En, useImperativeHandle as Zn } from "react";
3
- function be(c) {
1
+ import { jsxs as re, jsx as nt } from "react/jsx-runtime";
2
+ import { useState as S, useEffect as X, useRef as l, useCallback as u, useMemo as Ve, forwardRef as En, useImperativeHandle as Cn } from "react";
3
+ function ve(c) {
4
4
  if (c && c.constructor === Array) {
5
5
  var r = c.filter(function(b) {
6
6
  return typeof b == "number";
@@ -8,53 +8,53 @@ function be(c) {
8
8
  return !isNaN(b);
9
9
  });
10
10
  if (c.length === 6 && r.length === 6) {
11
- var o = Bt();
11
+ var o = Yt();
12
12
  return o[0] = r[0], o[1] = r[1], o[4] = r[2], o[5] = r[3], o[12] = r[4], o[13] = r[5], o;
13
13
  } else if (c.length === 16 && r.length === 16)
14
14
  return c;
15
15
  }
16
16
  throw new TypeError("Expected a `number[]` with length 6 or 16.");
17
17
  }
18
- function Bt() {
18
+ function Yt() {
19
19
  for (var c = [], r = 0; r < 16; r++)
20
20
  r % 5 == 0 ? c.push(1) : c.push(0);
21
21
  return c;
22
22
  }
23
- function On(c, r) {
24
- for (var o = be(c), b = be(r), _ = [], M = 0; M < 4; M++)
25
- for (var O = [o[M], o[M + 4], o[M + 8], o[M + 12]], R = 0; R < 4; R++) {
26
- var L = R * 4, C = [b[L], b[L + 1], b[L + 2], b[L + 3]], F = O[0] * C[0] + O[1] * C[1] + O[2] * C[2] + O[3] * C[3];
27
- _[M + L] = F;
23
+ function Zn(c, r) {
24
+ for (var o = ve(c), b = ve(r), R = [], M = 0; M < 4; M++)
25
+ for (var O = [o[M], o[M + 4], o[M + 8], o[M + 12]], T = 0; T < 4; T++) {
26
+ var L = T * 4, C = [b[L], b[L + 1], b[L + 2], b[L + 3]], j = O[0] * C[0] + O[1] * C[1] + O[2] * C[2] + O[3] * C[3];
27
+ R[M + L] = j;
28
28
  }
29
- return _;
29
+ return R;
30
30
  }
31
- function Wn(c) {
32
- var r = Bt();
31
+ function On(c) {
32
+ var r = Yt();
33
33
  return r[11] = -1 / c, r;
34
34
  }
35
- function jn(c) {
36
- var r = Math.PI / 180 * c, o = Bt();
35
+ function $n(c) {
36
+ var r = Math.PI / 180 * c, o = Yt();
37
37
  return o[0] = o[10] = Math.cos(r), o[2] = o[8] = Math.sin(r), o[2] *= -1, o;
38
38
  }
39
- function Nn(c) {
40
- return "matrix3d(" + be(c).join(", ") + ")";
39
+ function Wn(c) {
40
+ return "matrix3d(" + ve(c).join(", ") + ")";
41
41
  }
42
42
  function qe(c, r, o) {
43
- var b = Bt();
43
+ var b = Yt();
44
44
  return c !== void 0 && r !== void 0 && o !== void 0 && (b[12] = c, b[13] = r, b[14] = o), b;
45
45
  }
46
- class ie {
46
+ class oe {
47
47
  constructor(r) {
48
- r ? r instanceof ie ? this.m = [...r.m] : this.m = [...r] : this.m = Bt();
48
+ r ? r instanceof oe ? this.m = [...r.m] : this.m = [...r] : this.m = Yt();
49
49
  }
50
50
  clone() {
51
- return new ie(this);
51
+ return new oe(this);
52
52
  }
53
53
  multiply(r) {
54
- this.m = On(this.m, r);
54
+ this.m = Zn(this.m, r);
55
55
  }
56
56
  perspective(r) {
57
- this.multiply(Wn(r));
57
+ this.multiply(On(r));
58
58
  }
59
59
  transformX(r) {
60
60
  return (r * this.m[0] + this.m[12]) / (r * this.m[3] + this.m[15]);
@@ -66,101 +66,101 @@ class ie {
66
66
  this.multiply(qe(r, o, b));
67
67
  }
68
68
  rotateY(r) {
69
- this.multiply(jn(r));
69
+ this.multiply($n(r));
70
70
  }
71
71
  toString() {
72
- return Nn(this.m);
72
+ return Wn(this.m);
73
73
  }
74
74
  }
75
- function $n(c, r, o) {
76
- const [b, _] = T(0), [M, O] = T(0), [R, L] = T(1), [C, F] = T(0);
77
- return N(() => {
78
- const S = () => {
79
- const H = c.current;
80
- if (!H) return;
81
- _(H.clientWidth), O(H.clientHeight);
82
- const d = H.clientWidth > H.clientHeight && !r ? 2 : 1;
83
- L(d), d === 2 && F((et) => et + 1);
75
+ function Nn(c, r, o) {
76
+ const [b, R] = S(0), [M, O] = S(0), [T, L] = S(1), [C, j] = S(0);
77
+ return X(() => {
78
+ const D = () => {
79
+ const U = c.current;
80
+ if (!U) return;
81
+ R(U.clientWidth), O(U.clientHeight);
82
+ const g = U.clientWidth > U.clientHeight && !r ? 2 : 1;
83
+ L(g), g === 2 && j((rt) => rt + 1);
84
84
  };
85
- return window.addEventListener("resize", S, { passive: !0 }), S(), () => window.removeEventListener("resize", S);
85
+ return window.addEventListener("resize", D, { passive: !0 }), D(), () => window.removeEventListener("resize", D);
86
86
  }, [r, c]), {
87
87
  viewWidth: b,
88
88
  viewHeight: M,
89
- rawDisplayedPages: R,
89
+ rawDisplayedPages: T,
90
90
  pageAlignmentTick: C
91
91
  };
92
92
  }
93
- function Xn(c, r, o, b, _, M, O) {
94
- const [R, L] = T(null), [C, F] = T(null), [S, H] = T({}), d = u({}), et = u({ count: 0, target: 0, cb: null }), ct = u(/* @__PURE__ */ new Set()), at = f(
95
- (g, h = !1) => {
96
- if (h && _ > 1 && !M) {
97
- const a = r[g];
93
+ function Xn(c, r, o, b, R, M, O) {
94
+ const [T, L] = S(null), [C, j] = S(null), [D, U] = S({}), g = l({}), rt = l({ count: 0, target: 0, cb: null }), at = l(/* @__PURE__ */ new Set()), st = u(
95
+ (f, d = !1) => {
96
+ if (d && R > 1 && !M) {
97
+ const a = r[f];
98
98
  if (a) return a;
99
99
  }
100
- return c[g] ?? null;
100
+ return c[f] ?? null;
101
101
  },
102
- [c, r, _, M]
103
- ), A = f(
104
- (g) => R === null || S[g] ? g : (d.current[g] || (d.current[g] = null, ct.current.add(g)), O),
105
- [R, S, O]
102
+ [c, r, R, M]
103
+ ), A = u(
104
+ (f) => T === null || D[f] ? f : (g.current[f] || (g.current[f] = null, at.current.add(f)), O),
105
+ [T, D, O]
106
106
  );
107
- N(() => {
108
- const g = ct.current;
109
- g.size !== 0 && (g.forEach((h) => {
110
- if (d.current[h]) return;
107
+ X(() => {
108
+ const f = at.current;
109
+ f.size !== 0 && (f.forEach((d) => {
110
+ if (g.current[d]) return;
111
111
  const a = new Image();
112
- d.current[h] = a, a.onload = () => {
113
- H((D) => ({ ...D, [h]: !0 }));
114
- }, a.src = h;
115
- }), g.clear());
112
+ g.current[d] = a, a.onload = () => {
113
+ U((z) => ({ ...z, [d]: !0 }));
114
+ }, a.src = d;
115
+ }), f.clear());
116
116
  });
117
- const B = f(
118
- (g, h = !1) => {
119
- const a = at(g, h);
120
- return h && _ > 1 && !M ? a : a ? A(a) : null;
117
+ const $ = u(
118
+ (f, d = !1) => {
119
+ const a = st(f, d);
120
+ return d && R > 1 && !M ? a : a ? A(a) : null;
121
121
  },
122
- [at, A, _, M]
123
- ), st = f(
124
- (g = !1) => {
125
- for (let h = o - 3; h <= o + 3; h++)
126
- B(h);
127
- if (g)
128
- for (let h = o; h < o + b; h++) {
129
- const a = r[h];
130
- if (a && !d.current[a]) {
131
- const D = new Image();
132
- d.current[a] = D, D.src = a;
122
+ [st, A, R, M]
123
+ ), lt = u(
124
+ (f = !1) => {
125
+ for (let d = o - 3; d <= o + 3; d++)
126
+ $(d);
127
+ if (f)
128
+ for (let d = o; d < o + b; d++) {
129
+ const a = r[d];
130
+ if (a && !g.current[a]) {
131
+ const z = new Image();
132
+ g.current[a] = z, z.src = a;
133
133
  }
134
134
  }
135
135
  },
136
- [o, b, r, B]
137
- ), nt = f(
138
- (g) => {
139
- const h = g.target;
140
- R === null && (L(h.naturalWidth), F(h.naturalHeight));
141
- const a = et.current;
136
+ [o, b, r, $]
137
+ ), J = u(
138
+ (f) => {
139
+ const d = f.target;
140
+ T === null && (L(d.naturalWidth), j(d.naturalHeight));
141
+ const a = rt.current;
142
142
  a.cb && (a.count++, a.count >= a.target && (a.cb(), a.cb = null));
143
143
  },
144
- [R]
145
- ), rt = f(
146
- (g, h) => {
147
- et.current = { count: 0, target: g, cb: h };
144
+ [T]
145
+ ), ot = u(
146
+ (f, d) => {
147
+ rt.current = { count: 0, target: f, cb: d };
148
148
  },
149
149
  []
150
150
  );
151
151
  return {
152
- imageWidth: R,
152
+ imageWidth: T,
153
153
  imageHeight: C,
154
- loadedImages: S,
155
- pageUrl: at,
154
+ loadedImages: D,
155
+ pageUrl: st,
156
156
  loadImage: A,
157
- pageUrlLoading: B,
158
- preloadImages: st,
159
- onImageLoad: nt,
160
- setImageLoadCallback: rt
157
+ pageUrlLoading: $,
158
+ preloadImages: lt,
159
+ onImageLoad: J,
160
+ setImageLoadCallback: ot
161
161
  };
162
162
  }
163
- const Hn = "data:image/svg+xml,%3c?xml%20version='1.0'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='500'%20height='500'%20viewBox='0%200%20500%20500'%20fill='transparent'%20style='background-color:%20%23fff'%3e%3ccircle%20cx='250'%20cy='250'%20r='48'%20stroke='%23333'%20stroke-width='2'%20stroke-dasharray='271%2030'%20%3e%3canimateTransform%20attributeName='transform'%20attributeType='XML'%20type='rotate'%20from='0%20250%20250'%20to='360%20250%20250'%20dur='1s'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e", Bn = "_root_1ydjt_1", Un = "_viewport_1ydjt_8", Yn = "_viewportZoom_1ydjt_14 _viewport_1ydjt_8", An = "_viewportZoomDragToScroll_1ydjt_19 _viewportZoom_1ydjt_14 _viewport_1ydjt_8", Gn = "_container_1ydjt_24", Kn = "_clickLeft_1ydjt_40 _clickToFlip_1ydjt_32", Vn = "_clickRight_1ydjt_45 _clickToFlip_1ydjt_32", qn = "_boundingBox_1ydjt_50", Qn = "_page_1ydjt_55", Jn = "_polygon_1ydjt_60", tr = "_polygonBlank_1ydjt_69 _polygon_1ydjt_60", er = "_lighting_1ydjt_74", nr = "_srOnly_1ydjt_79", z = {
163
+ const Hn = "data:image/svg+xml,%3c?xml%20version='1.0'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='500'%20height='500'%20viewBox='0%200%20500%20500'%20fill='transparent'%20style='background-color:%20%23fff'%3e%3ccircle%20cx='250'%20cy='250'%20r='48'%20stroke='%23333'%20stroke-width='2'%20stroke-dasharray='271%2030'%20%3e%3canimateTransform%20attributeName='transform'%20attributeType='XML'%20type='rotate'%20from='0%20250%20250'%20to='360%20250%20250'%20dur='1s'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e", Bn = "_root_jjdx8_1", Un = "_viewport_jjdx8_8", Yn = "_viewportZoom_jjdx8_16 _viewport_jjdx8_8", An = "_viewportZoomDragToScroll_jjdx8_22 _viewportZoom_jjdx8_16 _viewport_jjdx8_8", Gn = "_container_jjdx8_27", Kn = "_clickLeft_jjdx8_43 _clickToFlip_jjdx8_35", Vn = "_clickRight_jjdx8_48 _clickToFlip_jjdx8_35", qn = "_boundingBox_jjdx8_53", Qn = "_page_jjdx8_58", Jn = "_polygon_jjdx8_63", tr = "_polygonBlank_jjdx8_72 _polygon_jjdx8_63", er = "_lighting_jjdx8_77", nr = "_srOnly_jjdx8_82", F = {
164
164
  root: Bn,
165
165
  viewport: Un,
166
166
  viewportZoom: Yn,
@@ -184,7 +184,7 @@ function rr(c) {
184
184
  function Qe(c) {
185
185
  return c < 0.5 ? Je(c * 2) / 2 : 0.5 + rr((c - 0.5) * 2) / 2;
186
186
  }
187
- const Ht = {
187
+ const Ut = {
188
188
  progress: 0,
189
189
  direction: null,
190
190
  frontImage: null,
@@ -195,474 +195,478 @@ function or(c, r) {
195
195
  const {
196
196
  pages: o,
197
197
  pagesHiRes: b = [],
198
- flipDuration: _ = 1e3,
198
+ flipDuration: R = 1e3,
199
199
  zoomDuration: M = 500,
200
200
  zooms: O = [1, 2, 4],
201
- perspective: R = 2400,
201
+ perspective: T = 2400,
202
202
  nPolygons: L = 10,
203
203
  ambient: C = 0.4,
204
- gloss: F = 0.6,
205
- swipeMin: S = 3,
206
- singlePage: H = !1,
207
- forwardDirection: d = "right",
208
- centering: et = !0,
209
- startPage: ct = null,
210
- loadingImage: at = Hn,
204
+ gloss: j = 0.6,
205
+ swipeMin: D = 3,
206
+ singlePage: U = !1,
207
+ forwardDirection: g = "right",
208
+ centering: rt = !0,
209
+ startPage: at = null,
210
+ loadingImage: st = Hn,
211
211
  clickToZoom: A = !0,
212
- dragToFlip: B = !0,
213
- wheel: st = "scroll",
214
- page: nt,
215
- onPageChange: rt
216
- } = c, g = O ?? [1], h = o[0] === null, { viewWidth: a, viewHeight: D, rawDisplayedPages: bt, pageAlignmentTick: ce } = $n(
212
+ dragToFlip: $ = !0,
213
+ wheel: lt = "scroll",
214
+ page: J,
215
+ onPageChange: ot
216
+ } = c, f = O ?? [1], d = o[0] === null, { viewWidth: a, viewHeight: z, rawDisplayedPages: It, pageAlignmentTick: ie } = Nn(
217
217
  r,
218
- H
219
- ), [ae, Ut] = T(0), _t = nt !== void 0, E = _t ? nt : ae, U = f(
218
+ U
219
+ ), [ce, ae] = S(0), St = J !== void 0, E = St ? J : ce, G = u(
220
220
  (t) => {
221
- if (_t) {
222
- const n = typeof t == "function" ? t(nt) : t;
223
- rt?.(n);
221
+ if (St) {
222
+ const n = typeof t == "function" ? t(J) : t;
223
+ ot?.(n);
224
224
  } else
225
- Ut(t);
225
+ ae(t);
226
226
  },
227
- [_t, nt, rt]
228
- ), [Yt, e] = T(0), [Rt, Tt] = T(1), [s, se] = T(g[0]), [At, le] = T(0), [Ft, ve] = T(!1), [x, Y] = T(Ht), [Gt, ue] = T(null), [, Pe] = T(0), p = bt === 2 && (h && (E === 0 || E === 1)) ? 1 : bt, tn = Xn(
227
+ [St, J, ot]
228
+ ), [jt, ut] = S(0), [se, e] = S(1), [x, Dt] = S(f[0]), [v, le] = S(0), [zt, Pe] = S(!1), [k, Y] = S(Ut), [At, ue] = S(null), [, Ie] = S(0), h = It === 2 && (d && (E === 0 || E === 1)) ? 1 : It, tn = Xn(
229
229
  o,
230
230
  b,
231
231
  E,
232
- p,
233
- s,
234
- Ft,
235
- at
236
- ), { imageWidth: vt, imageHeight: Kt, pageUrl: St, loadImage: en, pageUrlLoading: nn, preloadImages: Vt, onImageLoad: rn, setImageLoadCallback: qt } = tn, Dt = u(null), Ie = u(null), Pt = u(0), It = u(null), G = u(!1), Qt = u(!1), lt = u(1 / 0), ut = u(-1 / 0), Me = u(0), we = u(0), zt = u(0), Ct = u(0), Et = u(!1), Q = u(x);
237
- Q.current = x;
238
- const Mt = u(E);
239
- Mt.current = E;
240
- const Jt = u(p);
241
- Jt.current = p;
242
- const Zt = u(s);
243
- Zt.current = s;
244
- const te = u(At);
245
- te.current = At;
246
- const Le = u(c.onFlipLeftStart);
247
- Le.current = c.onFlipLeftStart;
248
- const xe = u(c.onFlipLeftEnd);
249
- xe.current = c.onFlipLeftEnd;
250
- const ke = u(c.onFlipRightStart);
232
+ h,
233
+ x,
234
+ zt,
235
+ st
236
+ ), { imageWidth: xt, imageHeight: Gt, pageUrl: Et, loadImage: en, pageUrlLoading: nn, preloadImages: Kt, onImageLoad: rn, setImageLoadCallback: Vt } = tn, yt = l(null), xe = l(null), Mt = l(0), wt = l(null), K = l(!1), qt = l(!1), ft = l(1 / 0), gt = l(-1 / 0), ye = l(0), Me = l(0), Ct = l(0), Zt = l(0), Ot = l(!1), tt = l(k);
237
+ tt.current = k;
238
+ const Lt = l(E);
239
+ Lt.current = E;
240
+ const Qt = l(h);
241
+ Qt.current = h;
242
+ const kt = l(x);
243
+ kt.current = x;
244
+ const Jt = l(v);
245
+ Jt.current = v;
246
+ const we = l(c.onFlipLeftStart);
247
+ we.current = c.onFlipLeftStart;
248
+ const Le = l(c.onFlipLeftEnd);
249
+ Le.current = c.onFlipLeftEnd;
250
+ const ke = l(c.onFlipRightStart);
251
251
  ke.current = c.onFlipRightStart;
252
- const _e = u(c.onFlipRightEnd);
252
+ const _e = l(c.onFlipRightEnd);
253
253
  _e.current = c.onFlipRightEnd;
254
- const Re = u(c.onZoomStart);
254
+ const Re = l(c.onZoomStart);
255
255
  Re.current = c.onZoomStart;
256
- const Te = u(c.onZoomEnd);
256
+ const Te = l(c.onZoomEnd);
257
257
  Te.current = c.onZoomEnd;
258
- const on = u(rt);
259
- on.current = rt;
260
- const Fe = u(U);
261
- Fe.current = U;
262
- const fe = u(/* @__PURE__ */ new Set()), Z = f((t) => {
258
+ const on = l(ot);
259
+ on.current = ot;
260
+ const Fe = l(G);
261
+ Fe.current = G;
262
+ const fe = l(/* @__PURE__ */ new Set()), Z = u((t) => {
263
263
  const n = requestAnimationFrame((i) => {
264
264
  fe.current.delete(n), t(i);
265
265
  });
266
266
  return fe.current.add(n), n;
267
- }, []), Se = h ? o.length - 1 : o.length, ee = h ? Math.max(1, E) : E + 1, De = u({
267
+ }, []), Se = d ? o.length - 1 : o.length, te = d ? Math.max(1, E) : E + 1, je = l({
268
268
  canFlipLeft: !1,
269
269
  canFlipRight: !1,
270
270
  canZoomIn: !1,
271
271
  canZoomOut: !1,
272
272
  page: 0,
273
273
  numPages: 0
274
- }), ze = f(() => {
275
- U((t) => p === 1 && t === 0 && o.length > 0 && !o[0] ? 1 : t);
276
- }, [p, o, U]), Ce = !x.direction && E < o.length - p, Ee = !x.direction && E >= p && !(p === 1 && !St(Yt - 1)), ot = d === "left" ? Ce : Ee, it = d === "right" ? Ce : Ee, ft = !Ft && At < g.length - 1, gt = !Ft && At > 0;
277
- De.current = { canFlipLeft: ot, canFlipRight: it, canZoomIn: ft, canZoomOut: gt, page: ee, numPages: Se };
278
- const ge = d === "right" || p === 1 ? Yt : Rt, de = d === "left" ? Yt : Rt, cn = !!St(ge), an = !!St(de) && p === 2, Ze = vt && Kt ? Math.min(a / p / vt, D / Kt, 1) : 1, w = vt ? Math.round(vt * Ze) : 0, dt = Kt ? Math.round(Kt * Ze) : 0, K = (a - w * p) / 2, ht = (D - dt) / 2, sn = Math.ceil(w / L + 1 / s) + "px", ln = dt + "px", un = `${w}px ${dt}px`, fn = Ve(() => {
279
- if (!x.direction || p !== 1) return 1;
280
- let t = x.progress;
281
- return x.direction !== d && (t = 1 - t), t > 0.7 ? 1 - (t - 0.7) / 0.3 : 1;
282
- }, [x.direction, x.progress, p, d]), pt = (() => {
283
- if (p === 1) return K;
284
- const t = St(ge) ? K : a / 2;
285
- return x.direction ? t < lt.current ? t : lt.current : t;
286
- })(), Ot = (() => {
287
- if (p === 1) return a - K;
288
- const t = St(de) ? a - K : a / 2;
289
- return x.direction ? t > ut.current ? t : ut.current : t;
290
- })(), mt = et ? Math.round(a / 2 - (pt + Ot) / 2) : 0, Oe = u(mt);
291
- Oe.current = mt;
292
- const We = u(p);
293
- N(() => {
294
- Gt === null && vt !== null && ue(mt);
295
- }, [Gt, vt, mt]), N(() => {
296
- We.current !== p && (We.current = p, ue(mt), Et.current = !1);
297
- }, [p, mt]);
298
- const Wt = Math.round(Gt ?? 0), gn = It.current ? It.current : A && ft ? "zoom-in" : A && gt ? "zoom-out" : B ? "grab" : "auto", dn = !G.current, hn = (Ft || s > 1) && dn ? z.viewportZoomDragToScroll : Ft || s > 1 ? z.viewportZoom : z.viewport, pn = (() => {
299
- const t = (Ot - pt) * s;
300
- return t < a ? (pt + Wt) * s - (a - t) / 2 : (pt + Wt) * s;
274
+ }), De = u(() => {
275
+ G((t) => h === 1 && t === 0 && o.length > 0 && !o[0] ? 1 : t);
276
+ }, [h, o, G]), ze = !k.direction && E < o.length - h, Ee = !k.direction && E >= h && !(h === 1 && !Et(jt - 1)), it = g === "left" ? ze : Ee, ct = g === "right" ? ze : Ee, dt = !zt && v < f.length - 1, ht = !zt && v > 0;
277
+ je.current = { canFlipLeft: it, canFlipRight: ct, canZoomIn: dt, canZoomOut: ht, page: te, numPages: Se };
278
+ const ge = g === "right" || h === 1 ? jt : se, de = g === "left" ? jt : se, cn = !!Et(ge), an = !!Et(de) && h === 2, Ce = xt && Gt ? Math.min(a / h / xt, z / Gt, 1) : 1, w = xt ? Math.round(xt * Ce) : 0, pt = Gt ? Math.round(Gt * Ce) : 0, V = (a - w * h) / 2, mt = (z - pt) / 2, sn = Math.ceil(w / L + 1 / x) + "px", ln = pt + "px", un = `${w}px ${pt}px`, fn = Ve(() => {
279
+ if (!k.direction || h !== 1) return 1;
280
+ let t = k.progress;
281
+ return k.direction !== g && (t = 1 - t), t > 0.7 ? 1 - (t - 0.7) / 0.3 : 1;
282
+ }, [k.direction, k.progress, h, g]), bt = (() => {
283
+ if (h === 1) return V;
284
+ const t = Et(ge) ? V : a / 2;
285
+ return k.direction ? t < ft.current ? t : ft.current : t;
286
+ })(), $t = (() => {
287
+ if (h === 1) return a - V;
288
+ const t = Et(de) ? a - V : a / 2;
289
+ return k.direction ? t > gt.current ? t : gt.current : t;
290
+ })(), vt = rt ? Math.round(a / 2 - (bt + $t) / 2) : 0, Ze = l(vt);
291
+ Ze.current = vt;
292
+ const Oe = l(h);
293
+ X(() => {
294
+ At === null && xt !== null && ue(vt);
295
+ }, [At, xt, vt]), X(() => {
296
+ Oe.current !== h && (Oe.current = h, ue(vt), Ot.current = !1);
297
+ }, [h, vt]);
298
+ const Wt = Math.round(At ?? 0), gn = wt.current ? wt.current : A && dt ? "zoom-in" : A && ht ? "zoom-out" : $ ? "grab" : "auto", dn = !K.current, hn = (zt || x > 1) && dn ? F.viewportZoomDragToScroll : zt || x > 1 ? F.viewportZoom : F.viewport, pn = (() => {
299
+ const t = ($t - bt) * x;
300
+ return t < a ? (bt + Wt) * x - (a - t) / 2 : (bt + Wt) * x;
301
301
  })(), mn = (() => {
302
- const t = (Ot - pt) * s;
303
- return t < a ? (pt + Wt) * s - (a - t) / 2 : (Ot + Wt) * s - a;
304
- })(), yn = (() => {
305
- const t = dt * s;
306
- return t < D ? ht * s - (D - t) / 2 : ht * s;
302
+ const t = ($t - bt) * x;
303
+ return t < a ? (bt + Wt) * x - (a - t) / 2 : ($t + Wt) * x - a;
307
304
  })(), bn = (() => {
308
- const t = dt * s;
309
- return t < D ? ht * s - (D - t) / 2 : (ht + dt) * s - D;
310
- })(), je = Math.min(mn, Math.max(pn, zt.current)), Ne = Math.min(bn, Math.max(yn, Ct.current)), $e = f(
305
+ const t = pt * x;
306
+ return t < z ? mt * x - (z - t) / 2 : mt * x;
307
+ })(), vn = (() => {
308
+ const t = pt * x;
309
+ return t < z ? mt * x - (z - t) / 2 : (mt + pt) * x - z;
310
+ })(), $e = Math.min(mn, Math.max(pn, Ct.current)), We = Math.min(vn, Math.max(bn, Zt.current)), Ne = u(
311
311
  (t, n) => {
312
- const i = [], l = [-0.5, -0.25, 0, 0.25, 0.5];
312
+ const i = [], s = [-0.5, -0.25, 0, 0.25, 0.5];
313
313
  if (C < 1) {
314
- const m = 1 - C, y = l.map((v) => (1 - Math.cos((t - n * v) / 180 * Math.PI)) * m);
314
+ const p = 1 - C, m = s.map((P) => (1 - Math.cos((t - n * P) / 180 * Math.PI)) * p);
315
315
  i.push(
316
- `linear-gradient(to right,rgba(0,0,0,${y[0]}),rgba(0,0,0,${y[1]}) 25%,rgba(0,0,0,${y[2]}) 50%,rgba(0,0,0,${y[3]}) 75%,rgba(0,0,0,${y[4]}))`
316
+ `linear-gradient(to right,rgba(0,0,0,${m[0]}),rgba(0,0,0,${m[1]}) 25%,rgba(0,0,0,${m[2]}) 50%,rgba(0,0,0,${m[3]}) 75%,rgba(0,0,0,${m[4]}))`
317
317
  );
318
318
  }
319
- if (F > 0) {
320
- const v = l.map(
321
- (P) => Math.max(
322
- Math.pow(Math.cos((t + 30 - n * P) / 180 * Math.PI), 200),
323
- Math.pow(Math.cos((t - 30 - n * P) / 180 * Math.PI), 200)
319
+ if (j > 0) {
320
+ const P = s.map(
321
+ (I) => Math.max(
322
+ Math.pow(Math.cos((t + 30 - n * I) / 180 * Math.PI), 200),
323
+ Math.pow(Math.cos((t - 30 - n * I) / 180 * Math.PI), 200)
324
324
  )
325
325
  );
326
326
  i.push(
327
- `linear-gradient(to right,rgba(255,255,255,${v[0] * F}),rgba(255,255,255,${v[1] * F}) 25%,rgba(255,255,255,${v[2] * F}) 50%,rgba(255,255,255,${v[3] * F}) 75%,rgba(255,255,255,${v[4] * F}))`
327
+ `linear-gradient(to right,rgba(255,255,255,${P[0] * j}),rgba(255,255,255,${P[1] * j}) 25%,rgba(255,255,255,${P[2] * j}) 50%,rgba(255,255,255,${P[3] * j}) 75%,rgba(255,255,255,${P[4] * j}))`
328
328
  );
329
329
  }
330
330
  return i.join(",");
331
331
  },
332
- [C, F]
333
- ), he = f(
332
+ [C, j]
333
+ ), he = u(
334
334
  (t) => {
335
- const n = Q.current;
335
+ const n = tt.current;
336
336
  if (!n.direction) return [];
337
337
  if (!Number.isFinite(w) || w <= 0 || L <= 0)
338
338
  return [];
339
- let i = n.progress, l = n.direction;
339
+ let i = n.progress, s = n.direction;
340
340
  if (!Number.isFinite(i)) return [];
341
- i < 0 && (i = 0), i > 1 && (i = 1), p === 1 && l !== d && (i = 1 - i, l = d);
342
- const m = t === "front" ? n.frontImage : n.backImage, y = w / L;
343
- let v = K, P = !1;
344
- p === 1 ? d === "right" ? t === "back" && (P = !0, v = K - w) : l === "left" ? t === "back" ? v = w - K : P = !0 : t === "front" ? v = w - K : P = !0 : l === "left" ? t === "back" ? v = a / 2 : P = !0 : t === "front" ? v = a / 2 : P = !0;
345
- const I = new ie();
346
- I.translate(a / 2), I.perspective(R), I.translate(-a / 2), I.translate(v, ht);
341
+ i < 0 && (i = 0), i > 1 && (i = 1), h === 1 && s !== g && (i = 1 - i, s = g);
342
+ const p = t === "front" ? n.frontImage : n.backImage, m = w / L;
343
+ let P = V, I = !1;
344
+ h === 1 ? g === "right" ? t === "back" && (I = !0, P = V - w) : s === "left" ? t === "back" ? P = w - V : I = !0 : t === "front" ? P = w - V : I = !0 : s === "left" ? t === "back" ? P = a / 2 : I = !0 : t === "front" ? P = a / 2 : I = !0;
345
+ const y = new oe();
346
+ y.translate(a / 2), y.perspective(T), y.translate(-a / 2), y.translate(P, mt);
347
347
  let W = 0;
348
- i > 0.5 && (W = -(i - 0.5) * 2 * 180), l === "left" && (W = -W), t === "back" && (W += 180), W && (P && I.translate(w), I.rotateY(W), P && I.translate(-w));
349
- let k;
350
- i < 0.5 ? k = i * 2 * Math.PI : k = (1 - (i - 0.5) * 2) * Math.PI, k === 0 && (k = 1e-9);
351
- const yt = w / k;
352
- let $ = 0;
353
- const j = k / L;
354
- let X = j / 2 / Math.PI * 180;
355
- const J = j / Math.PI * 180;
356
- P && (X = -k / Math.PI * 180 + J / 2), t === "back" && (X = -X);
357
- const $t = t === "back" ? -J : J;
358
- lt.current = 1 / 0, ut.current = -1 / 0;
359
- const q = [];
360
- for (let ne = 0; ne < L; ne++) {
361
- const zn = `${ne / (L - 1) * 100}% 0px`, Xt = I.clone(), Ae = P ? k - $ : $;
362
- let ye = Math.sin(Ae) * yt;
363
- P && (ye = w - ye);
364
- let re = (1 - Math.cos(Ae)) * yt;
365
- t === "back" && (re = -re), Xt.translate3d(ye, 0, re), Xt.rotateY(-X);
366
- const Ge = Xt.transformX(0), Ke = Xt.transformX(y);
367
- ut.current = Math.max(Math.max(Ge, Ke), ut.current), lt.current = Math.min(Math.min(Ge, Ke), lt.current);
368
- const Cn = $e(W - X, $t);
369
- $ += j, X += $t, q.push({
370
- key: t + ne,
371
- bgImage: m,
372
- lighting: Cn,
373
- bgPos: zn,
374
- transform: Xt.toString(),
375
- z: Math.abs(Math.round(re))
348
+ i > 0.5 && (W = -(i - 0.5) * 2 * 180), s === "left" && (W = -W), t === "back" && (W += 180), W && (I && y.translate(w), y.rotateY(W), I && y.translate(-w));
349
+ let _;
350
+ i < 0.5 ? _ = i * 2 * Math.PI : _ = (1 - (i - 0.5) * 2) * Math.PI, _ === 0 && (_ = 1e-9);
351
+ const Pt = w / _;
352
+ let H = 0;
353
+ const N = _ / L;
354
+ let B = N / 2 / Math.PI * 180;
355
+ const et = N / Math.PI * 180;
356
+ I && (B = -_ / Math.PI * 180 + et / 2), t === "back" && (B = -B);
357
+ const Ht = t === "back" ? -et : et;
358
+ ft.current = 1 / 0, gt.current = -1 / 0;
359
+ const Q = [];
360
+ for (let ee = 0; ee < L; ee++) {
361
+ const Dn = `${ee / (L - 1) * 100}% 0px`, Bt = y.clone(), Ae = I ? _ - H : H;
362
+ let be = Math.sin(Ae) * Pt;
363
+ I && (be = w - be);
364
+ let ne = (1 - Math.cos(Ae)) * Pt;
365
+ t === "back" && (ne = -ne), Bt.translate3d(be, 0, ne), Bt.rotateY(-B);
366
+ const Ge = Bt.transformX(0), Ke = Bt.transformX(m);
367
+ gt.current = Math.max(Math.max(Ge, Ke), gt.current), ft.current = Math.min(Math.min(Ge, Ke), ft.current);
368
+ const zn = Ne(W - B, Ht);
369
+ H += N, B += Ht, Q.push({
370
+ key: t + ee,
371
+ bgImage: p,
372
+ lighting: zn,
373
+ bgPos: Dn,
374
+ transform: Bt.toString(),
375
+ z: Math.abs(Math.round(ne))
376
376
  });
377
377
  }
378
- return q;
378
+ return Q;
379
379
  },
380
- [p, d, w, K, ht, a, R, L, $e]
381
- ), vn = Ve(() => x.direction ? [...he("front"), ...he("back")] : [], [x.direction, x.progress, x.frontImage, x.backImage, he]), V = f(
380
+ [h, g, w, V, mt, a, T, L, Ne]
381
+ ), Pn = Ve(() => k.direction ? [...he("front"), ...he("back")] : [], [k.direction, k.progress, k.frontImage, k.backImage, he]), q = u(
382
382
  (t, n) => {
383
- const i = Mt.current, l = Jt.current;
384
- let m = null, y = null;
385
- t !== d ? l === 1 ? (m = o[i - 1] ?? null, y = null) : (m = o[d === "right" || l === 1 ? i : i + 1] ?? null, y = o[i - l + 1] ?? null) : l === 1 ? (m = o[i] ?? null, y = null) : (m = o[d === "left" ? i : i + 1] ?? null, y = o[i + l] ?? null), Y({
383
+ const i = Lt.current, s = Qt.current;
384
+ let p = null, m = null;
385
+ t !== g ? s === 1 ? (p = o[i - 1] ?? null, m = null) : (p = o[g === "right" || s === 1 ? i : i + 1] ?? null, m = o[i - s + 1] ?? null) : s === 1 ? (p = o[i] ?? null, m = null) : (p = o[g === "left" ? i : i + 1] ?? null, m = o[i + s] ?? null), Y({
386
386
  progress: 0,
387
387
  direction: t,
388
- frontImage: m,
389
- backImage: y,
388
+ frontImage: p,
389
+ backImage: m,
390
390
  auto: !1
391
391
  }), Z(() => {
392
392
  Z(() => {
393
- t !== d ? l === 2 && e(i - l) : l === 1 ? e(i + l) : Tt(i + 1 + l), n && pe(t);
393
+ t !== g ? s === 2 && ut(i - s) : s === 1 ? ut(i + s) : e(i + 1 + s), n && pe(t);
394
394
  });
395
395
  });
396
396
  },
397
- [d, o, Z]
398
- ), pe = f(
397
+ [g, o, Z]
398
+ ), pe = u(
399
399
  (t) => {
400
- const n = Q.current, i = _ * (1 - n.progress), l = n.progress;
401
- Y((I) => ({ ...I, auto: !0 }));
402
- const m = Mt.current, y = o[0] !== null ? m + 1 : Math.max(1, m);
403
- t === "left" ? Le.current?.(y) : ke.current?.(y);
404
- let v = null;
405
- const P = (I) => {
406
- v === null && (v = I);
407
- const W = I - v;
408
- let k = l + W / i;
409
- k > 1 && (k = 1);
410
- const yt = Qe(k);
411
- if (Y(($) => ({ ...$, progress: yt })), k < 1)
412
- Z(P);
400
+ const n = tt.current, i = R * (1 - n.progress), s = n.progress;
401
+ Y((y) => ({ ...y, auto: !0 }));
402
+ const p = Lt.current, m = o[0] !== null ? p + 1 : Math.max(1, p);
403
+ t === "left" ? we.current?.(m) : ke.current?.(m);
404
+ let P = null;
405
+ const I = (y) => {
406
+ P === null && (P = y);
407
+ const W = y - P;
408
+ let _ = s + W / i;
409
+ _ > 1 && (_ = 1);
410
+ const Pt = Qe(_);
411
+ if (Y((H) => ({ ...H, progress: Pt })), _ < 1)
412
+ Z(I);
413
413
  else {
414
- const $ = Jt.current;
415
- let j;
416
- t !== d ? j = Mt.current - $ : j = Mt.current + $, Fe.current(j);
417
- const X = o[0] !== null ? j + 1 : Math.max(1, j);
418
- t === "left" ? xe.current?.(X) : _e.current?.(X), $ === 1 && t === d ? Y(Ht) : qt(1, () => {
419
- Y(Ht);
414
+ const H = Qt.current;
415
+ let N;
416
+ t !== g ? N = Lt.current - H : N = Lt.current + H, Fe.current(N);
417
+ const B = o[0] !== null ? N + 1 : Math.max(1, N);
418
+ t === "left" ? Le.current?.(B) : _e.current?.(B), H === 1 && t === g ? Y(Ut) : Vt(1, () => {
419
+ Y(Ut);
420
420
  });
421
421
  }
422
422
  };
423
- Z(P);
423
+ Z(I);
424
424
  },
425
- [_, d, o, qt, Z]
426
- ), Xe = f(() => {
427
- const t = Q.current, n = _ * t.progress, i = t.progress;
428
- Y((y) => ({ ...y, auto: !0 }));
429
- let l = null;
430
- const m = (y) => {
431
- l === null && (l = y);
432
- const v = y - l;
433
- let P = i - i * v / n;
434
- if (P < 0 && (P = 0), Y((I) => ({ ...I, progress: P })), P > 0)
435
- Z(m);
425
+ [R, g, o, Vt, Z]
426
+ ), Xe = u(() => {
427
+ const t = tt.current, n = R * t.progress, i = t.progress;
428
+ Y((m) => ({ ...m, auto: !0 }));
429
+ let s = null;
430
+ const p = (m) => {
431
+ s === null && (s = m);
432
+ const P = m - s;
433
+ let I = i - i * P / n;
434
+ if (I < 0 && (I = 0), Y((y) => ({ ...y, progress: I })), I > 0)
435
+ Z(p);
436
436
  else {
437
- const I = Mt.current;
438
- e(I), Tt(I + 1);
439
- const W = Jt.current, k = Q.current.direction;
440
- W === 1 && k !== d ? Y(Ht) : qt(1, () => {
441
- Y(Ht);
437
+ const y = Lt.current;
438
+ ut(y), e(y + 1);
439
+ const W = Qt.current, _ = tt.current.direction;
440
+ W === 1 && _ !== g ? Y(Ut) : Vt(1, () => {
441
+ Y(Ut);
442
442
  });
443
443
  }
444
444
  };
445
- Z(m);
446
- }, [_, d, qt, Z]), Pn = f(() => {
447
- ot && V("left", !0);
448
- }, [ot, V]), In = f(() => {
449
- it && V("right", !0);
450
- }, [it, V]), wt = f(
445
+ Z(p);
446
+ }, [R, g, Vt, Z]), In = u(() => {
447
+ it && q("left", !0);
448
+ }, [it, q]), xn = u(() => {
449
+ ct && q("right", !0);
450
+ }, [ct, q]), _t = u(
451
451
  (t, n) => {
452
452
  const i = r.current;
453
453
  if (!i) return;
454
- let l, m;
454
+ let s, p;
455
455
  if (n) {
456
- const J = i.getBoundingClientRect();
457
- l = n.pageX - J.left, m = n.pageY - J.top;
456
+ const et = i.getBoundingClientRect();
457
+ s = n.pageX - et.left, p = n.pageY - et.top;
458
458
  } else
459
- l = i.clientWidth / 2, m = i.clientHeight / 2;
460
- const y = Zt.current, v = t, P = i.scrollLeft, I = i.scrollTop, W = l + P, k = m + I, yt = W / y * v - l, $ = k / y * v - m;
461
- ve(!0), Re.current?.(t);
462
- let j = null;
463
- const X = (J) => {
464
- j === null && (j = J);
465
- const $t = J - j;
466
- let q = $t / M;
467
- q > 1 && (q = 1), q = Qe(q), se(y + (v - y) * q), zt.current = P + (yt - P) * q, Ct.current = I + ($ - I) * q, $t < M ? Z(X) : (Te.current?.(t), ve(!1), se(t), zt.current = yt, Ct.current = $);
459
+ s = i.clientWidth / 2, p = i.clientHeight / 2;
460
+ const m = kt.current, P = t, I = i.scrollLeft, y = i.scrollTop, W = s + I, _ = p + y, Pt = W / m * P - s, H = _ / m * P - p;
461
+ Pe(!0), Re.current?.(t);
462
+ let N = null;
463
+ const B = (et) => {
464
+ N === null && (N = et);
465
+ const Ht = et - N;
466
+ let Q = Ht / M;
467
+ Q > 1 && (Q = 1), Q = Qe(Q), Dt(m + (P - m) * Q), Ct.current = I + (Pt - I) * Q, Zt.current = y + (H - y) * Q, Ht < M ? Z(B) : (Te.current?.(t), Pe(!1), Dt(t), Ct.current = Pt, Zt.current = H);
468
468
  };
469
- Z(X), v > 1 && Vt(!0);
469
+ Z(B), P > 1 && Kt(!0);
470
470
  },
471
- [M, r, Vt, Z]
472
- ), jt = f(
471
+ [M, r, Kt, Z]
472
+ ), Nt = u(
473
473
  (t) => {
474
- if (!ft) return;
475
- const n = te.current + 1;
476
- le(n), wt(g[n], t);
474
+ if (!dt) return;
475
+ const n = Jt.current + 1;
476
+ le(n), _t(f[n], t);
477
477
  },
478
- [ft, g, wt]
479
- ), Nt = f(
478
+ [dt, f, _t]
479
+ ), Xt = u(
480
480
  (t) => {
481
- if (!gt) return;
482
- const n = te.current - 1;
483
- le(n), wt(g[n], t);
481
+ if (!ht) return;
482
+ const n = Jt.current - 1;
483
+ le(n), _t(f[n], t);
484
484
  },
485
- [gt, g, wt]
486
- ), He = f(
485
+ [ht, f, _t]
486
+ ), He = u(
487
487
  (t) => {
488
- const n = (te.current + 1) % g.length;
489
- le(n), wt(g[n], t);
488
+ const n = (Jt.current + 1) % f.length;
489
+ le(n), _t(f[n], t);
490
490
  },
491
- [g, wt]
492
- ), me = f(
491
+ [f, _t]
492
+ ), me = u(
493
493
  (t) => {
494
- if (t === null || t === ee) return;
494
+ if (t === null || t === te) return;
495
495
  let n;
496
- o[0] === null ? p === 2 && t === 1 ? n = 0 : n = t : n = t - 1, (p === 2 && n > 0 && o[0] === null || p === 2 && o[0] !== null) && (n = n & -2), U(n), lt.current = 1 / 0, ut.current = -1 / 0;
496
+ o[0] === null ? h === 2 && t === 1 ? n = 0 : n = t : n = t - 1, (h === 2 && n > 0 && o[0] === null || h === 2 && o[0] !== null) && (n = n & -2), G(n), ft.current = 1 / 0, gt.current = -1 / 0;
497
497
  },
498
- [ee, o, p, U]
499
- ), Be = u(me);
498
+ [te, o, h, G]
499
+ ), Be = l(me);
500
500
  Be.current = me;
501
- const Ue = f(
501
+ const Ue = u(
502
502
  (t, n) => {
503
503
  const i = r.current;
504
- i && (i.scrollLeft = Me.current - t, i.scrollTop = we.current - n, zt.current = i.scrollLeft, Ct.current = i.scrollTop);
504
+ i && (i.scrollLeft = ye.current - t, i.scrollTop = Me.current - n, Ct.current = i.scrollLeft, Zt.current = i.scrollTop);
505
505
  },
506
506
  [r]
507
- ), Lt = f(
507
+ ), Rt = u(
508
508
  (t) => {
509
- if (Dt.current = t.pageX, Ie.current = t.pageY, Pt.current = 0, Zt.current <= 1)
510
- B && (It.current = "grab");
509
+ if (yt.current = t.pageX, xe.current = t.pageY, Mt.current = 0, kt.current <= 1)
510
+ $ && (wt.current = "grab");
511
511
  else {
512
512
  const n = r.current;
513
- n && (Me.current = n.scrollLeft, we.current = n.scrollTop), It.current = "all-scroll";
513
+ n && (ye.current = n.scrollLeft, Me.current = n.scrollTop), wt.current = "all-scroll";
514
514
  }
515
515
  },
516
- [B, r]
517
- ), xt = f(
516
+ [$, r]
517
+ ), Tt = u(
518
518
  (t) => {
519
- if (Dt.current === null) return !1;
520
- const n = t.pageX - Dt.current, i = t.pageY - Ie.current;
521
- if (Pt.current = Math.max(Pt.current, Math.abs(n)), Pt.current = Math.max(Pt.current, Math.abs(i)), Zt.current > 1)
522
- return G.current || Ue(n, i), !1;
523
- if (!B || Math.abs(i) > Math.abs(n) || !Number.isFinite(w) || w <= 0) return !1;
524
- It.current = "grabbing", Pe((m) => m + 1);
525
- const l = Q.current;
526
- return n > 0 ? (l.direction === null && ot && n >= S && V("left", !1), Q.current.direction === "left" && Y((m) => ({
527
- ...m,
519
+ if (yt.current === null) return !1;
520
+ const n = t.pageX - yt.current, i = t.pageY - xe.current;
521
+ if (Mt.current = Math.max(Mt.current, Math.abs(n)), Mt.current = Math.max(Mt.current, Math.abs(i)), kt.current > 1)
522
+ return K.current || Ue(n, i), !1;
523
+ if (!$ || Math.abs(i) > Math.abs(n) || !Number.isFinite(w) || w <= 0) return !1;
524
+ wt.current = "grabbing", Ie((p) => p + 1);
525
+ const s = tt.current;
526
+ return n > 0 ? (s.direction === null && it && n >= D && q("left", !1), tt.current.direction === "left" && Y((p) => ({
527
+ ...p,
528
528
  progress: Math.min(n / w, 1)
529
- }))) : (l.direction === null && it && n <= -S && V("right", !1), Q.current.direction === "right" && Y((m) => ({
530
- ...m,
529
+ }))) : (s.direction === null && ct && n <= -D && q("right", !1), tt.current.direction === "right" && Y((p) => ({
530
+ ...p,
531
531
  progress: Math.min(-n / w, 1)
532
532
  }))), !0;
533
533
  },
534
- [B, ot, it, S, V, w, Ue]
535
- ), kt = f(
534
+ [$, it, ct, D, q, w, Ue]
535
+ ), Ft = u(
536
536
  (t) => {
537
- if (Dt.current === null) return;
538
- A && Pt.current < S && He(t);
539
- const n = Q.current;
540
- n.direction !== null && !n.auto && (n.progress > 1 / 4 ? pe(n.direction) : Xe()), Dt.current = null, It.current = null, Pe((i) => i + 1);
537
+ if (yt.current === null) return;
538
+ A && Mt.current < D && He(t);
539
+ const n = tt.current;
540
+ n.direction !== null && !n.auto && (n.progress > 1 / 4 ? pe(n.direction) : Xe()), yt.current = null, wt.current = null, Ie((i) => i + 1);
541
541
  },
542
- [A, S, He, pe, Xe]
543
- ), Mn = f(
542
+ [A, D, He, pe, Xe]
543
+ ), yn = u(
544
544
  (t) => {
545
- G.current = !0, Lt(t.changedTouches[0]);
545
+ K.current = !0, Rt(t.changedTouches[0]);
546
546
  },
547
- [Lt]
548
- ), wn = f(
547
+ [Rt]
548
+ ), Mn = u(
549
549
  (t) => {
550
- xt(t.changedTouches[0]) && t.cancelable && t.preventDefault();
550
+ if (Tt(t.changedTouches[0])) {
551
+ t.cancelable && t.preventDefault();
552
+ return;
553
+ }
554
+ $ && kt.current <= 1 && yt.current !== null && t.cancelable && t.preventDefault();
551
555
  },
552
- [xt]
553
- ), Ln = f(
556
+ [$, Tt]
557
+ ), wn = u(
554
558
  (t) => {
555
- kt(t.changedTouches[0]);
559
+ Ft(t.changedTouches[0]);
556
560
  },
557
- [kt]
558
- ), xn = f(
561
+ [Ft]
562
+ ), Ln = u(
559
563
  (t) => {
560
- if (Qt.current = !0, !G.current && t.button === 0) {
561
- Lt(t);
564
+ if (qt.current = !0, !K.current && t.button === 0) {
565
+ Rt(t);
562
566
  try {
563
567
  t.target.setPointerCapture(t.pointerId);
564
568
  } catch {
565
569
  }
566
570
  }
567
571
  },
568
- [Lt]
569
- ), kn = f(
572
+ [Rt]
573
+ ), kn = u(
570
574
  (t) => {
571
- G.current || xt(t);
575
+ K.current || Tt(t);
572
576
  },
573
- [xt]
574
- ), _n = f(
577
+ [Tt]
578
+ ), _n = u(
575
579
  (t) => {
576
- if (!G.current) {
577
- kt(t);
580
+ if (!K.current) {
581
+ Ft(t);
578
582
  try {
579
583
  t.target.releasePointerCapture(t.pointerId);
580
584
  } catch {
581
585
  }
582
586
  }
583
587
  },
584
- [kt]
585
- ), Rn = f(
588
+ [Ft]
589
+ ), Rn = u(
586
590
  (t) => {
587
- G.current || Qt.current || t.button === 0 && Lt(t);
591
+ K.current || qt.current || t.button === 0 && Rt(t);
588
592
  },
589
- [Lt]
590
- ), Tn = f(
593
+ [Rt]
594
+ ), Tn = u(
591
595
  (t) => {
592
- G.current || Qt.current || xt(t);
596
+ K.current || qt.current || Tt(t);
593
597
  },
594
- [xt]
595
- ), Fn = f(
598
+ [Tt]
599
+ ), Fn = u(
596
600
  (t) => {
597
- G.current || Qt.current || kt(t);
601
+ K.current || qt.current || Ft(t);
598
602
  },
599
- [kt]
600
- ), Sn = f(
603
+ [Ft]
604
+ ), Sn = u(
601
605
  (t) => {
602
- if (st === "scroll" && Zt.current > 1 && !G.current) {
606
+ if (lt === "scroll" && kt.current > 1 && !K.current) {
603
607
  const n = r.current;
604
- n && (n.scrollLeft += t.deltaX, n.scrollTop += t.deltaY, zt.current = n.scrollLeft, Ct.current = n.scrollTop), t.cancelable && t.preventDefault();
608
+ n && (n.scrollLeft += t.deltaX, n.scrollTop += t.deltaY, Ct.current = n.scrollLeft, Zt.current = n.scrollTop), t.cancelable && t.preventDefault();
605
609
  }
606
- st === "zoom" && (t.deltaY >= 100 ? (Nt(t), t.cancelable && t.preventDefault()) : t.deltaY <= -100 && (jt(t), t.cancelable && t.preventDefault()));
610
+ lt === "zoom" && (t.deltaY >= 100 ? (Xt(t), t.cancelable && t.preventDefault()) : t.deltaY <= -100 && (Nt(t), t.cancelable && t.preventDefault()));
607
611
  },
608
- [st, r, Nt, jt]
609
- ), Dn = f(
612
+ [lt, r, Xt, Nt]
613
+ ), jn = u(
610
614
  (t) => {
611
615
  switch (t.key) {
612
616
  case "ArrowLeft":
613
- t.preventDefault(), ot && V("left", !0);
617
+ t.preventDefault(), it && q("left", !0);
614
618
  break;
615
619
  case "ArrowRight":
616
- t.preventDefault(), it && V("right", !0);
620
+ t.preventDefault(), ct && q("right", !0);
617
621
  break;
618
622
  case "+":
619
623
  case "=":
620
- t.preventDefault(), ft && jt();
624
+ t.preventDefault(), dt && Nt();
621
625
  break;
622
626
  case "-":
623
- t.preventDefault(), gt && Nt();
627
+ t.preventDefault(), ht && Xt();
624
628
  break;
625
629
  }
626
630
  },
627
- [ot, it, ft, gt, V, jt, Nt]
631
+ [it, ct, dt, ht, q, Nt, Xt]
628
632
  );
629
- N(() => {
630
- bt === 2 && U((t) => {
633
+ X(() => {
634
+ It === 2 && G((t) => {
631
635
  const n = t & -2;
632
- return n === 0 && h ? t : n;
633
- }), lt.current = 1 / 0, ut.current = -1 / 0;
634
- }, [ce, bt, h, U]);
635
- const Ye = u(Vt);
636
- return Ye.current = Vt, N(() => {
637
- e(E), Tt(E + 1), Ye.current();
638
- }, [E]), N(() => {
639
- if (Et.current || Gt === null) return;
640
- Et.current = !0;
636
+ return n === 0 && d ? t : n;
637
+ }), ft.current = 1 / 0, gt.current = -1 / 0;
638
+ }, [ie, It, d, G]);
639
+ const Ye = l(Kt);
640
+ return Ye.current = Kt, X(() => {
641
+ ut(E), e(E + 1), Ye.current();
642
+ }, [E]), X(() => {
643
+ if (Ot.current || At === null) return;
644
+ Ot.current = !0;
641
645
  const t = () => {
642
646
  Z(() => {
643
647
  ue((n) => {
644
- const i = Oe.current;
648
+ const i = Ze.current;
645
649
  if (n === null)
646
- return Et.current = !1, i;
647
- const l = i - n;
648
- return Math.abs(l) < 0.5 ? (Et.current = !1, i) : (t(), n + l * 0.1);
650
+ return Ot.current = !1, i;
651
+ const s = i - n;
652
+ return Math.abs(s) < 0.5 ? (Ot.current = !1, i) : (t(), n + s * 0.1);
649
653
  });
650
654
  });
651
655
  };
652
656
  t();
653
- }, [mt, Z]), N(() => {
657
+ }, [vt, Z]), X(() => {
654
658
  const t = r.current;
655
- t && (t.scrollLeft = je);
656
- }, [je, r]), N(() => {
659
+ t && (t.scrollLeft = $e);
660
+ }, [$e, r]), X(() => {
657
661
  const t = r.current;
658
- t && (t.scrollTop = Ne);
659
- }, [Ne, r]), N(() => {
660
- ze();
661
- }, [o, ze]), N(() => {
662
- Be.current(ct);
663
- }, [ct]), N(() => {
664
- se(g[0]);
665
- }, []), N(() => {
662
+ t && (t.scrollTop = We);
663
+ }, [We, r]), X(() => {
664
+ De();
665
+ }, [o, De]), X(() => {
666
+ Be.current(at);
667
+ }, [at]), X(() => {
668
+ Dt(f[0]);
669
+ }, []), X(() => {
666
670
  const t = fe.current;
667
671
  return () => {
668
672
  t.forEach(cancelAnimationFrame), t.clear();
@@ -670,16 +674,16 @@ function or(c, r) {
670
674
  }, []), {
671
675
  // Layout
672
676
  viewWidth: a,
673
- viewHeight: D,
677
+ viewHeight: z,
674
678
  pageWidth: w,
675
- pageHeight: dt,
676
- xMargin: K,
677
- yMargin: ht,
678
- displayedPages: p,
679
- zoom: s,
679
+ pageHeight: pt,
680
+ xMargin: V,
681
+ yMargin: mt,
682
+ displayedPages: h,
683
+ zoom: x,
680
684
  centerOffsetSmoothed: Wt,
681
685
  // Pages
682
- page: ee,
686
+ page: te,
683
687
  numPages: Se,
684
688
  leftPage: ge,
685
689
  rightPage: de,
@@ -688,44 +692,44 @@ function or(c, r) {
688
692
  pageUrlLoading: nn,
689
693
  loadImage: en,
690
694
  // Flip
691
- flip: x,
695
+ flip: k,
692
696
  flipOpacity: fn,
693
- polygonArray: vn,
697
+ polygonArray: Pn,
694
698
  polygonWidth: sn,
695
699
  polygonHeight: ln,
696
700
  polygonBgSize: un,
697
701
  // Navigation
698
- canFlipLeft: ot,
699
- canFlipRight: it,
700
- canZoomIn: ft,
701
- canZoomOut: gt,
702
+ canFlipLeft: it,
703
+ canFlipRight: ct,
704
+ canZoomIn: dt,
705
+ canZoomOut: ht,
702
706
  // Bounds
703
- boundingLeft: pt,
704
- boundingRight: Ot,
707
+ boundingLeft: bt,
708
+ boundingRight: $t,
705
709
  // Cursor
706
710
  cursor: gn,
707
711
  viewportClass: hn,
708
712
  // Actions
709
- flipLeft: Pn,
710
- flipRight: In,
711
- zoomIn: jt,
712
- zoomOut: Nt,
713
+ flipLeft: In,
714
+ flipRight: xn,
715
+ zoomIn: Nt,
716
+ zoomOut: Xt,
713
717
  goToPage: me,
714
718
  // Stable ref for imperative API
715
- apiRef: De,
719
+ apiRef: je,
716
720
  // Event handlers
717
721
  handlers: {
718
- onTouchStart: Mn,
719
- onTouchMove: wn,
720
- onTouchEnd: Ln,
721
- onPointerDown: xn,
722
+ onTouchStart: yn,
723
+ onTouchMove: Mn,
724
+ onTouchEnd: wn,
725
+ onPointerDown: Ln,
722
726
  onPointerMove: kn,
723
727
  onPointerUp: _n,
724
728
  onMouseDown: Rn,
725
729
  onMouseMove: Tn,
726
730
  onMouseUp: Fn,
727
731
  onWheel: Sn,
728
- onKeyDown: Dn
732
+ onKeyDown: jn
729
733
  },
730
734
  onImageLoad: rn
731
735
  };
@@ -735,64 +739,66 @@ const sr = En(
735
739
  pages: r,
736
740
  pagesHiRes: o,
737
741
  pageLabels: b,
738
- flipDuration: _,
742
+ flipDuration: R,
739
743
  zoomDuration: M,
740
744
  zooms: O,
741
- perspective: R,
745
+ perspective: T,
742
746
  nPolygons: L,
743
747
  ambient: C,
744
- gloss: F,
745
- swipeMin: S,
746
- singlePage: H,
747
- forwardDirection: d,
748
- centering: et,
749
- startPage: ct,
750
- loadingImage: at,
748
+ gloss: j,
749
+ swipeMin: D,
750
+ singlePage: U,
751
+ forwardDirection: g,
752
+ centering: rt,
753
+ startPage: at,
754
+ loadingImage: st,
751
755
  clickToZoom: A,
752
- dragToFlip: B,
753
- wheel: st,
754
- page: nt,
755
- onPageChange: rt,
756
- onFlipLeftStart: g,
757
- onFlipLeftEnd: h,
758
- onFlipRightStart: a,
759
- onFlipRightEnd: D,
760
- onZoomStart: bt,
761
- onZoomEnd: ce,
762
- children: ae,
763
- className: Ut,
764
- ..._t
765
- }, E) {
766
- const U = u(null), e = or({
756
+ dragToFlip: $,
757
+ wheel: lt,
758
+ bookClassName: J,
759
+ bookStyle: ot,
760
+ page: f,
761
+ onPageChange: d,
762
+ onFlipLeftStart: a,
763
+ onFlipLeftEnd: z,
764
+ onFlipRightStart: It,
765
+ onFlipRightEnd: ie,
766
+ onZoomStart: ce,
767
+ onZoomEnd: ae,
768
+ children: St,
769
+ className: E,
770
+ ...G
771
+ }, jt) {
772
+ const ut = l(null), e = or({
767
773
  pages: r,
768
774
  pagesHiRes: o,
769
- flipDuration: _,
775
+ flipDuration: R,
770
776
  zoomDuration: M,
771
777
  zooms: O,
772
- perspective: R,
778
+ perspective: T,
773
779
  nPolygons: L,
774
780
  ambient: C,
775
- gloss: F,
776
- swipeMin: S,
777
- singlePage: H,
778
- forwardDirection: d,
779
- centering: et,
780
- startPage: ct,
781
- loadingImage: at,
781
+ gloss: j,
782
+ swipeMin: D,
783
+ singlePage: U,
784
+ forwardDirection: g,
785
+ centering: rt,
786
+ startPage: at,
787
+ loadingImage: st,
782
788
  clickToZoom: A,
783
- dragToFlip: B,
784
- wheel: st,
785
- page: nt,
786
- onPageChange: rt,
787
- onFlipLeftStart: g,
788
- onFlipLeftEnd: h,
789
- onFlipRightStart: a,
790
- onFlipRightEnd: D,
791
- onZoomStart: bt,
792
- onZoomEnd: ce
793
- }, U);
794
- Zn(
795
- E,
789
+ dragToFlip: $,
790
+ wheel: lt,
791
+ page: f,
792
+ onPageChange: d,
793
+ onFlipLeftStart: a,
794
+ onFlipLeftEnd: z,
795
+ onFlipRightStart: It,
796
+ onFlipRightEnd: ie,
797
+ onZoomStart: ce,
798
+ onZoomEnd: ae
799
+ }, ut);
800
+ Cn(
801
+ jt,
796
802
  () => ({
797
803
  get flipLeft() {
798
804
  return e.flipLeft;
@@ -832,17 +838,17 @@ const sr = En(
832
838
  // only rebuild when action functions change
833
839
  [e.flipLeft, e.flipRight, e.zoomIn, e.zoomOut, e.goToPage, e.apiRef]
834
840
  );
835
- const Rt = (s) => b && b[s] ? b[s] : `Page ${s + 1}`, Tt = Ut ? `${z.root} ${Ut}` : z.root;
836
- return /* @__PURE__ */ oe(
841
+ const x = (v) => b && b[v] ? b[v] : `Page ${v + 1}`, Dt = E ? `${F.root} ${E}` : F.root;
842
+ return /* @__PURE__ */ re(
837
843
  "div",
838
844
  {
839
- ..._t,
840
- className: Tt,
845
+ ...G,
846
+ className: Dt,
841
847
  role: "document",
842
848
  "aria-label": `Book viewer, page ${e.page} of ${e.numPages}`,
843
849
  "aria-roledescription": "flipbook",
844
850
  children: [
845
- ae?.({
851
+ St?.({
846
852
  canFlipLeft: e.canFlipLeft,
847
853
  canFlipRight: e.canFlipRight,
848
854
  canZoomIn: e.canZoomIn,
@@ -855,10 +861,10 @@ const sr = En(
855
861
  zoomOut: e.zoomOut,
856
862
  goToPage: e.goToPage
857
863
  }),
858
- /* @__PURE__ */ tt(
864
+ /* @__PURE__ */ nt(
859
865
  "div",
860
866
  {
861
- ref: U,
867
+ ref: ut,
862
868
  className: e.viewportClass,
863
869
  style: {
864
870
  cursor: e.cursor === "grabbing" ? "grabbing" : "auto"
@@ -874,57 +880,57 @@ const sr = En(
874
880
  onPointerCancel: e.handlers.onPointerUp,
875
881
  onMouseUp: e.handlers.onMouseUp,
876
882
  onWheel: e.handlers.onWheel,
877
- children: /* @__PURE__ */ oe(
883
+ children: /* @__PURE__ */ re(
878
884
  "div",
879
885
  {
880
- className: z.container,
881
- style: { transform: `scale(${e.zoom})` },
886
+ className: J ? `${F.container} ${J}` : F.container,
887
+ style: { ...ot, transform: `scale(${e.zoom})` },
882
888
  children: [
883
- /* @__PURE__ */ tt(
889
+ /* @__PURE__ */ nt(
884
890
  "div",
885
891
  {
886
892
  role: "button",
887
893
  tabIndex: e.canFlipLeft ? 0 : -1,
888
894
  "aria-label": "Previous page",
889
895
  "aria-disabled": !e.canFlipLeft,
890
- className: z.clickLeft,
896
+ className: F.clickLeft,
891
897
  style: {
892
898
  cursor: e.canFlipLeft ? "pointer" : "auto"
893
899
  },
894
900
  onClick: e.flipLeft,
895
- onKeyDown: (s) => {
896
- (s.key === "Enter" || s.key === " ") && (s.preventDefault(), e.flipLeft());
901
+ onKeyDown: (v) => {
902
+ (v.key === "Enter" || v.key === " ") && (v.preventDefault(), e.flipLeft());
897
903
  }
898
904
  }
899
905
  ),
900
- /* @__PURE__ */ tt(
906
+ /* @__PURE__ */ nt(
901
907
  "div",
902
908
  {
903
909
  role: "button",
904
910
  tabIndex: e.canFlipRight ? 0 : -1,
905
911
  "aria-label": "Next page",
906
912
  "aria-disabled": !e.canFlipRight,
907
- className: z.clickRight,
913
+ className: F.clickRight,
908
914
  style: {
909
915
  cursor: e.canFlipRight ? "pointer" : "auto"
910
916
  },
911
917
  onClick: e.flipRight,
912
- onKeyDown: (s) => {
913
- (s.key === "Enter" || s.key === " ") && (s.preventDefault(), e.flipRight());
918
+ onKeyDown: (v) => {
919
+ (v.key === "Enter" || v.key === " ") && (v.preventDefault(), e.flipRight());
914
920
  }
915
921
  }
916
922
  ),
917
- /* @__PURE__ */ oe(
923
+ /* @__PURE__ */ re(
918
924
  "div",
919
925
  {
920
926
  style: {
921
927
  transform: `translateX(${e.centerOffsetSmoothed}px)`
922
928
  },
923
929
  children: [
924
- e.showLeftPage && /* @__PURE__ */ tt(
930
+ e.showLeftPage && /* @__PURE__ */ nt(
925
931
  "img",
926
932
  {
927
- className: z.page,
933
+ className: F.page,
928
934
  style: {
929
935
  width: e.pageWidth + "px",
930
936
  height: e.pageHeight + "px",
@@ -932,14 +938,14 @@ const sr = En(
932
938
  top: e.yMargin + "px"
933
939
  },
934
940
  src: e.pageUrlLoading(e.leftPage, !0) ?? void 0,
935
- alt: Rt(e.leftPage),
941
+ alt: x(e.leftPage),
936
942
  onLoad: e.onImageLoad
937
943
  }
938
944
  ),
939
- e.showRightPage && /* @__PURE__ */ tt(
945
+ e.showRightPage && /* @__PURE__ */ nt(
940
946
  "img",
941
947
  {
942
- className: z.page,
948
+ className: F.page,
943
949
  style: {
944
950
  width: e.pageWidth + "px",
945
951
  height: e.pageHeight + "px",
@@ -947,37 +953,37 @@ const sr = En(
947
953
  top: e.yMargin + "px"
948
954
  },
949
955
  src: e.pageUrlLoading(e.rightPage, !0) ?? void 0,
950
- alt: Rt(e.rightPage),
956
+ alt: x(e.rightPage),
951
957
  onLoad: e.onImageLoad
952
958
  }
953
959
  ),
954
- /* @__PURE__ */ tt("div", { style: { opacity: e.flipOpacity }, children: e.polygonArray.map((s) => /* @__PURE__ */ tt(
960
+ /* @__PURE__ */ nt("div", { style: { opacity: e.flipOpacity }, children: e.polygonArray.map((v) => /* @__PURE__ */ nt(
955
961
  "div",
956
962
  {
957
- className: s.bgImage ? z.polygon : z.polygonBlank,
963
+ className: v.bgImage ? F.polygon : F.polygonBlank,
958
964
  style: {
959
- backgroundImage: s.bgImage ? `url(${e.loadImage(s.bgImage)})` : void 0,
965
+ backgroundImage: v.bgImage ? `url(${e.loadImage(v.bgImage)})` : void 0,
960
966
  backgroundSize: e.polygonBgSize,
961
- backgroundPosition: s.bgPos,
967
+ backgroundPosition: v.bgPos,
962
968
  width: e.polygonWidth,
963
969
  height: e.polygonHeight,
964
- transform: s.transform,
965
- zIndex: s.z
970
+ transform: v.transform,
971
+ zIndex: v.z
966
972
  },
967
- children: s.lighting && /* @__PURE__ */ tt(
973
+ children: v.lighting && /* @__PURE__ */ nt(
968
974
  "div",
969
975
  {
970
- className: z.lighting,
971
- style: { backgroundImage: s.lighting }
976
+ className: F.lighting,
977
+ style: { backgroundImage: v.lighting }
972
978
  }
973
979
  )
974
980
  },
975
- s.key
981
+ v.key
976
982
  )) }),
977
- /* @__PURE__ */ tt(
983
+ /* @__PURE__ */ nt(
978
984
  "div",
979
985
  {
980
- className: z.boundingBox,
986
+ className: F.boundingBox,
981
987
  style: {
982
988
  left: e.boundingLeft + "px",
983
989
  top: e.yMargin + "px",
@@ -998,13 +1004,13 @@ const sr = En(
998
1004
  )
999
1005
  }
1000
1006
  ),
1001
- /* @__PURE__ */ oe(
1007
+ /* @__PURE__ */ re(
1002
1008
  "div",
1003
1009
  {
1004
1010
  role: "status",
1005
1011
  "aria-live": "polite",
1006
1012
  "aria-atomic": "true",
1007
- className: z.srOnly,
1013
+ className: F.srOnly,
1008
1014
  children: [
1009
1015
  "Page ",
1010
1016
  e.page,