flipbookengine 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3378 @@
1
+ var ve = Object.defineProperty;
2
+ var Nt = (e) => {
3
+ throw TypeError(e);
4
+ };
5
+ var ye = (e, t, s) => t in e ? ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
6
+ var m = (e, t, s) => ye(e, typeof t != "symbol" ? t + "" : t, s), yt = (e, t, s) => t.has(e) || Nt("Cannot " + s);
7
+ var B = (e, t, s) => (yt(e, t, "read from private field"), s ? s.call(e) : t.get(e)), rt = (e, t, s) => t.has(e) ? Nt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), at = (e, t, s, o) => (yt(e, t, "write to private field"), o ? o.call(e, s) : t.set(e, s), s), J = (e, t, s) => (yt(e, t, "access private method"), s);
8
+ import * as Bt from "pdfjs-dist";
9
+ var be = Symbol.for("preact-signals");
10
+ function It() {
11
+ if (j > 1)
12
+ j--;
13
+ else {
14
+ var e, t = !1;
15
+ for (function() {
16
+ var r = ct;
17
+ for (ct = void 0; r !== void 0; )
18
+ r.S.v === r.v && (r.S.i = r.i), r = r.o;
19
+ }(); tt !== void 0; ) {
20
+ var s = tt;
21
+ for (tt = void 0, lt++; s !== void 0; ) {
22
+ var o = s.u;
23
+ if (s.u = void 0, s.f &= -3, !(8 & s.f) && ee(s)) try {
24
+ s.c();
25
+ } catch (r) {
26
+ t || (e = r, t = !0);
27
+ }
28
+ s = o;
29
+ }
30
+ }
31
+ if (lt = 0, j--, t) throw e;
32
+ }
33
+ }
34
+ var C = void 0;
35
+ function wt(e) {
36
+ var t = C;
37
+ C = void 0;
38
+ try {
39
+ return e();
40
+ } finally {
41
+ C = t;
42
+ }
43
+ }
44
+ var tt = void 0, j = 0, lt = 0, _t = 0, ct = void 0, dt = 0;
45
+ function te(e) {
46
+ if (C !== void 0) {
47
+ var t = e.n;
48
+ if (t === void 0 || t.t !== C)
49
+ return t = { i: 0, S: e, p: C.s, n: void 0, t: C, e: void 0, x: void 0, r: t }, C.s !== void 0 && (C.s.n = t), C.s = t, e.n = t, 32 & C.f && e.S(t), t;
50
+ if (t.i === -1)
51
+ return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = C.s, t.n = void 0, C.s.n = t, C.s = t), t;
52
+ }
53
+ }
54
+ function I(e, t) {
55
+ this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = t == null ? void 0 : t.watched, this.Z = t == null ? void 0 : t.unwatched, this.name = t == null ? void 0 : t.name;
56
+ }
57
+ I.prototype.brand = be;
58
+ I.prototype.h = function() {
59
+ return !0;
60
+ };
61
+ I.prototype.S = function(e) {
62
+ var t = this, s = this.t;
63
+ s !== e && e.e === void 0 && (e.x = s, this.t = e, s !== void 0 ? s.e = e : wt(function() {
64
+ var o;
65
+ (o = t.W) == null || o.call(t);
66
+ }));
67
+ };
68
+ I.prototype.U = function(e) {
69
+ var t = this;
70
+ if (this.t !== void 0) {
71
+ var s = e.e, o = e.x;
72
+ s !== void 0 && (s.x = o, e.e = void 0), o !== void 0 && (o.e = s, e.x = void 0), e === this.t && (this.t = o, o === void 0 && wt(function() {
73
+ var r;
74
+ (r = t.Z) == null || r.call(t);
75
+ }));
76
+ }
77
+ };
78
+ I.prototype.subscribe = function(e) {
79
+ var t = this;
80
+ return _(function() {
81
+ var s = t.value;
82
+ wt(function() {
83
+ return e(s);
84
+ });
85
+ }, { name: "sub" });
86
+ };
87
+ I.prototype.valueOf = function() {
88
+ return this.value;
89
+ };
90
+ I.prototype.toString = function() {
91
+ return this.value + "";
92
+ };
93
+ I.prototype.toJSON = function() {
94
+ return this.value;
95
+ };
96
+ I.prototype.peek = function() {
97
+ var e = this;
98
+ return wt(function() {
99
+ return e.value;
100
+ });
101
+ };
102
+ Object.defineProperty(I.prototype, "value", { get: function() {
103
+ var e = te(this);
104
+ return e !== void 0 && (e.i = this.i), this.v;
105
+ }, set: function(e) {
106
+ if (e !== this.v) {
107
+ if (lt > 100) throw new Error("Cycle detected");
108
+ (function(s) {
109
+ j !== 0 && lt === 0 && s.l !== _t && (s.l = _t, ct = { S: s, v: s.v, i: s.i, o: ct });
110
+ })(this), this.v = e, this.i++, dt++, j++;
111
+ try {
112
+ for (var t = this.t; t !== void 0; t = t.x) t.t.N();
113
+ } finally {
114
+ It();
115
+ }
116
+ }
117
+ } });
118
+ function M(e, t) {
119
+ return new I(e, t);
120
+ }
121
+ function ee(e) {
122
+ for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
123
+ return !1;
124
+ }
125
+ function ie(e) {
126
+ for (var t = e.s; t !== void 0; t = t.n) {
127
+ var s = t.S.n;
128
+ if (s !== void 0 && (t.r = s), t.S.n = t, t.i = -1, t.n === void 0) {
129
+ e.s = t;
130
+ break;
131
+ }
132
+ }
133
+ }
134
+ function se(e) {
135
+ for (var t = e.s, s = void 0; t !== void 0; ) {
136
+ var o = t.p;
137
+ t.i === -1 ? (t.S.U(t), o !== void 0 && (o.n = t.n), t.n !== void 0 && (t.n.p = o)) : s = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = o;
138
+ }
139
+ e.s = s;
140
+ }
141
+ function q(e, t) {
142
+ I.call(this, void 0, t), this.x = e, this.s = void 0, this.g = dt - 1, this.f = 4;
143
+ }
144
+ q.prototype = new I();
145
+ q.prototype.h = function() {
146
+ if (this.f &= -3, 1 & this.f) return !1;
147
+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === dt)) return !0;
148
+ if (this.g = dt, this.f |= 1, this.i > 0 && !ee(this))
149
+ return this.f &= -2, !0;
150
+ var e = C;
151
+ try {
152
+ ie(this), C = this;
153
+ var t = this.x();
154
+ (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
155
+ } catch (s) {
156
+ this.v = s, this.f |= 16, this.i++;
157
+ }
158
+ return C = e, se(this), this.f &= -2, !0;
159
+ };
160
+ q.prototype.S = function(e) {
161
+ if (this.t === void 0) {
162
+ this.f |= 36;
163
+ for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
164
+ }
165
+ I.prototype.S.call(this, e);
166
+ };
167
+ q.prototype.U = function(e) {
168
+ if (this.t !== void 0 && (I.prototype.U.call(this, e), this.t === void 0)) {
169
+ this.f &= -33;
170
+ for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
171
+ }
172
+ };
173
+ q.prototype.N = function() {
174
+ if (!(2 & this.f)) {
175
+ this.f |= 6;
176
+ for (var e = this.t; e !== void 0; e = e.x) e.t.N();
177
+ }
178
+ };
179
+ Object.defineProperty(q.prototype, "value", { get: function() {
180
+ if (1 & this.f) throw new Error("Cycle detected");
181
+ var e = te(this);
182
+ if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
183
+ return this.v;
184
+ } });
185
+ function w(e, t) {
186
+ return new q(e, t);
187
+ }
188
+ function ne(e) {
189
+ var t = e.m;
190
+ if (e.m = void 0, typeof t == "function") {
191
+ j++;
192
+ var s = C;
193
+ C = void 0;
194
+ try {
195
+ t();
196
+ } catch (o) {
197
+ throw e.f &= -2, e.f |= 8, Lt(e), o;
198
+ } finally {
199
+ C = s, It();
200
+ }
201
+ }
202
+ }
203
+ function Lt(e) {
204
+ for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
205
+ e.x = void 0, e.s = void 0, ne(e);
206
+ }
207
+ function xe(e) {
208
+ if (C !== this) throw new Error("Out-of-order effect");
209
+ se(this), C = e, this.f &= -2, 8 & this.f && Lt(this), It();
210
+ }
211
+ function X(e, t) {
212
+ this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t == null ? void 0 : t.name;
213
+ }
214
+ X.prototype.c = function() {
215
+ var e = this.S();
216
+ try {
217
+ if (8 & this.f || this.x === void 0) return;
218
+ var t = this.x();
219
+ typeof t == "function" && (this.m = t);
220
+ } finally {
221
+ e();
222
+ }
223
+ };
224
+ X.prototype.S = function() {
225
+ if (1 & this.f) throw new Error("Cycle detected");
226
+ this.f |= 1, this.f &= -9, ne(this), ie(this), j++;
227
+ var e = C;
228
+ return C = this, xe.bind(this, e);
229
+ };
230
+ X.prototype.N = function() {
231
+ 2 & this.f || (this.f |= 2, this.u = tt, tt = this);
232
+ };
233
+ X.prototype.d = function() {
234
+ this.f |= 8, 1 & this.f || Lt(this);
235
+ };
236
+ X.prototype.dispose = function() {
237
+ this.d();
238
+ };
239
+ function _(e, t) {
240
+ var s = new X(e, t);
241
+ try {
242
+ s.c();
243
+ } catch (r) {
244
+ throw s.d(), r;
245
+ }
246
+ var o = s.d.bind(s);
247
+ return o[Symbol.dispose] = o, o;
248
+ }
249
+ var oe = /* @__PURE__ */ Symbol.for("Serenity.initPropHook");
250
+ function Pe(e) {
251
+ return !!(e && typeof e.nodeType == "number");
252
+ }
253
+ function vt(e) {
254
+ return typeof e == "string";
255
+ }
256
+ function re(e) {
257
+ return typeof e == "number";
258
+ }
259
+ function z(e) {
260
+ return typeof e == "object" && e !== null;
261
+ }
262
+ function Se(e) {
263
+ return !!(e && e.isComponent);
264
+ }
265
+ function zt(e) {
266
+ return z(e) && typeof e.length == "number" && typeof e.nodeType != "number";
267
+ }
268
+ function Ce(e) {
269
+ return typeof e == "function" && typeof e[oe] == "function";
270
+ }
271
+ function it(e) {
272
+ return e != null && typeof e != "boolean";
273
+ }
274
+ function st(e) {
275
+ return Array.isArray(e) ? e.map(st).filter(Boolean).join(" ") : z(e) ? Symbol.iterator in e ? st(Array.from(e)) : Object.keys(e).filter((t) => e[t]).join(" ") : it(e) ? "" + e : "";
276
+ }
277
+ function ke(e) {
278
+ return e != null && typeof e == "object" && "current" in e;
279
+ }
280
+ function Ft(e, t) {
281
+ ke(e) ? e.current = t : typeof e == "function" && e(t);
282
+ }
283
+ function Te(e, t, s) {
284
+ t = { ...t, children: s };
285
+ const o = new e(t), r = o.render();
286
+ return "ref" in t && Ft(t.ref, o), r;
287
+ }
288
+ var Ae = "http://www.w3.org/1998/Math/MathML", Ee = /* @__PURE__ */ new Set(["math", "annotation", "annotation-xml", "maction", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics", "menclose", "mfenced"]), Me = /* @__PURE__ */ new Set([
289
+ // "a",
290
+ "animate",
291
+ "animateMotion",
292
+ "animateTransform",
293
+ "circle",
294
+ "clipPath",
295
+ "defs",
296
+ "desc",
297
+ "ellipse",
298
+ "feBlend",
299
+ "feColorMatrix",
300
+ "feComponentTransfer",
301
+ "feComposite",
302
+ "feConvolveMatrix",
303
+ "feDiffuseLighting",
304
+ "feDisplacementMap",
305
+ "feDistantLight",
306
+ "feDropShadow",
307
+ "feFlood",
308
+ "feFuncA",
309
+ "feFuncB",
310
+ "feFuncG",
311
+ "feFuncR",
312
+ "feGaussianBlur",
313
+ "feImage",
314
+ "feMerge",
315
+ "feMergeNode",
316
+ "feMorphology",
317
+ "feOffset",
318
+ "fePointLight",
319
+ "feSpecularLighting",
320
+ "feSpotLight",
321
+ "feTile",
322
+ "feTurbulence",
323
+ "filter",
324
+ "foreignObject",
325
+ "g",
326
+ "image",
327
+ "line",
328
+ "linearGradient",
329
+ "marker",
330
+ "mask",
331
+ "metadata",
332
+ "mpath",
333
+ "path",
334
+ "pattern",
335
+ "polygon",
336
+ "polyline",
337
+ "radialGradient",
338
+ "rect",
339
+ // "script",
340
+ "set",
341
+ "stop",
342
+ // "style",
343
+ "svg",
344
+ "switch",
345
+ "symbol",
346
+ "text",
347
+ "textPath",
348
+ // "title",
349
+ "tref",
350
+ "tspan",
351
+ "use",
352
+ "view"
353
+ ]), Gt = /^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/, De = "http://www.w3.org/2000/svg", Ut = /* @__PURE__ */ Symbol.for("Serenity.jsxNamespaceURI");
354
+ function Re(e) {
355
+ const t = globalThis[Ut];
356
+ return arguments.length && (globalThis[Ut] = e), t;
357
+ }
358
+ var Ie = /* @__PURE__ */ Symbol.for("Serenity.jsxTypeKey"), Le = "ShadowRoot";
359
+ function ze(e) {
360
+ return e != null && e[Ie] === Le;
361
+ }
362
+ var bt = /* @__PURE__ */ Symbol.for("Serenity.disposingListeners"), xt = /* @__PURE__ */ Symbol.for("Serenity.lifecycleRoot");
363
+ function Ot() {
364
+ return globalThis[bt] || (globalThis[bt] = /* @__PURE__ */ new WeakMap());
365
+ }
366
+ function Wt(e) {
367
+ e && e.target && (!e.currentTarget || e.currentTarget === e.target) && Fe(e == null ? void 0 : e.target);
368
+ }
369
+ function Fe(e, t) {
370
+ if (!e)
371
+ return;
372
+ const s = Ot();
373
+ function o(r) {
374
+ const l = s.get(r);
375
+ if (l) {
376
+ s.delete(r), r.removeEventListener("disposing", Wt);
377
+ for (const d of l)
378
+ try {
379
+ d.callback(r);
380
+ } catch {
381
+ }
382
+ }
383
+ }
384
+ o(e);
385
+ }
386
+ function kt(e, t, s) {
387
+ if (!e || !t)
388
+ return e;
389
+ const o = Ot();
390
+ let r = o.get(e);
391
+ if (!r)
392
+ return typeof e.addEventListener != "function" || (o.set(e, r = [{
393
+ callback: t,
394
+ regKey: s
395
+ }]), e.addEventListener("disposing", Wt, { once: !0 })), e;
396
+ const l = r.find((d) => d.callback === t);
397
+ return l ? (l.regKey, e) : (r.push({ callback: t, regKey: s }), e);
398
+ }
399
+ function jt(e, t, s) {
400
+ if (!e || !t)
401
+ return e;
402
+ const o = Ot(), r = o.get(e);
403
+ if (r) {
404
+ for (let l = r.length - 1; l >= 0; l--) {
405
+ const d = r[l];
406
+ t && t === d.callback && r.splice(l, 1);
407
+ }
408
+ r.length === 0 && (o.delete(e), typeof e.removeEventListener == "function" && e.removeEventListener("disposing", Wt));
409
+ }
410
+ return e;
411
+ }
412
+ function Oe(...e) {
413
+ if (e.length > 0) {
414
+ const t = globalThis[xt] || null;
415
+ return globalThis[xt] = e[0] || null, t;
416
+ }
417
+ return globalThis[xt] || null;
418
+ }
419
+ function Z(e) {
420
+ return e != null && typeof e == "object" && typeof e.subscribe == "function" && typeof e.peek == "function" && "value" in e;
421
+ }
422
+ var ot, F, G, Tt, At, Jt, We = (Jt = class {
423
+ constructor(e, t, s) {
424
+ rt(this, G);
425
+ rt(this, ot);
426
+ rt(this, F);
427
+ this.signal = e, this.isInitial = !0, this.hasChanged = !1, this.lifecycleRoot = t, at(this, F, s);
428
+ }
429
+ get lifecycleNode() {
430
+ return B(this, F);
431
+ }
432
+ get effectDisposer() {
433
+ return B(this, ot);
434
+ }
435
+ set effectDisposer(e) {
436
+ J(this, G, Tt).call(this), at(this, ot, e), J(this, G, At).call(this);
437
+ }
438
+ set lifecycleNode(e) {
439
+ e !== B(this, F) && (J(this, G, Tt).call(this), at(this, F, e), J(this, G, At).call(this));
440
+ }
441
+ }, ot = new WeakMap(), F = new WeakMap(), G = new WeakSet(), Tt = function() {
442
+ var e;
443
+ jt(B(this, F), this.effectDisposer), jt(B(this, F), (e = this.signal) == null ? void 0 : e.derivedDisposer);
444
+ }, At = function() {
445
+ var e;
446
+ kt(B(this, F), this.effectDisposer), kt(B(this, F), (e = this.signal) == null ? void 0 : e.derivedDisposer);
447
+ }, Jt);
448
+ function nt(e, t, s) {
449
+ const o = s != null && s.useLifecycleRoot ? Oe() : void 0, r = new We(e, o, s == null ? void 0 : s.lifecycleNode), l = r.signal.subscribe(function(d) {
450
+ r.newValue = d, r.isInitial && (this != null && this.dispose) && (r.effectDisposer = this.dispose.bind(this)), r.hasChanged = !r.isInitial && r.prevValue !== r.newValue;
451
+ try {
452
+ t(r);
453
+ } finally {
454
+ r.prevValue = r.newValue, r.isInitial = !1;
455
+ }
456
+ });
457
+ return l && !r.effectDisposer && (r.effectDisposer = l), r.effectDisposer;
458
+ }
459
+ function Vt(e, t) {
460
+ e instanceof window.HTMLTemplateElement ? e.content.appendChild(t) : e.appendChild(t);
461
+ }
462
+ var Pt = 0, Et = "__domwisefrag_";
463
+ function ae(e) {
464
+ return e instanceof Comment && e.data.startsWith(Et);
465
+ }
466
+ function Zt(e) {
467
+ return e instanceof DocumentFragment && ae(e.firstChild);
468
+ }
469
+ function $e(e, t) {
470
+ var s;
471
+ typeof e.replaceWith == "function" ? e.replaceWith(t) : (s = e.parentNode) == null || s.replaceChild(t, e);
472
+ }
473
+ function qt(e) {
474
+ return e instanceof DocumentFragment ? (++Pt, e.prepend(document.createComment(Et + Pt)), e.append(document.createComment(Et + Pt)), e) : e instanceof Node ? e : it(e) ? document.createTextNode(e) : document.createComment("");
475
+ }
476
+ function He(e, t) {
477
+ let s;
478
+ nt(t, (o) => {
479
+ var d;
480
+ if (o.isInitial) {
481
+ s = qt(o.newValue);
482
+ let p = Zt(s) ? s.firstChild : s;
483
+ ut(e, s), o.lifecycleNode = (s = p) ?? e;
484
+ return;
485
+ }
486
+ if (!o.hasChanged)
487
+ return;
488
+ const r = qt(o.newValue);
489
+ if (ae(s)) {
490
+ let p;
491
+ for (; (p = s.nextSibling) && ((d = p.parentNode) == null || d.removeChild(p), !(p instanceof Comment && p.data === s.data)); )
492
+ ;
493
+ }
494
+ let l = Zt(r) ? r.firstChild : r;
495
+ $e(s, r), o.lifecycleNode = (s = l) ?? e;
496
+ });
497
+ }
498
+ function ut(e, t) {
499
+ if (it(t))
500
+ if (zt(t))
501
+ for (const s of [...t])
502
+ ut(e, s);
503
+ else if (vt(t) || re(t))
504
+ Vt(e, document.createTextNode(t));
505
+ else if (Pe(t))
506
+ Vt(e, t);
507
+ else if (ze(t)) {
508
+ const s = e.attachShadow(t.attr);
509
+ ut(s, t.children), Ft(t.ref, s);
510
+ } else Z(t) && He(e, t);
511
+ }
512
+ function he(e) {
513
+ return e == null || (zt(e) ? e = Array.from(e).map((t) => Z(t) ? t.peek() : t) : z(e) && (e = { ...e }, Object.entries(e).forEach(([t, s]) => {
514
+ Z(s) && (e[t] = s.peek());
515
+ }))), e;
516
+ }
517
+ function Ne(e, t) {
518
+ if (t == null || t === !1 || t === !0)
519
+ return;
520
+ t = he(t);
521
+ const s = (st(t) ?? "").split(" ");
522
+ for (let o of s)
523
+ o && e.classList.remove(o);
524
+ }
525
+ function Be(e, t, s) {
526
+ if (t == null || t === !1) {
527
+ Ne(e, s);
528
+ return;
529
+ }
530
+ s = he(s), zt(t) ? t = Array.from(t).map((o) => {
531
+ let r = o;
532
+ return Z(o) && nt(o, (l) => {
533
+ if (l.isInitial) {
534
+ r = l.newValue;
535
+ return;
536
+ }
537
+ St(e, l.newValue, l.prevValue);
538
+ }, {
539
+ lifecycleNode: e
540
+ }), r;
541
+ }) : z(t) && (t = { ...t }, Object.entries(t).forEach(([o, r]) => {
542
+ Z(r) && nt(r, (l) => {
543
+ if (l.isInitial) {
544
+ t[o] = l.newValue;
545
+ return;
546
+ }
547
+ St(e, !!l.newValue && o, !!l.prevValue && o);
548
+ }, {
549
+ lifecycleNode: e
550
+ });
551
+ })), St(e, t, s);
552
+ }
553
+ function St(e, t, s) {
554
+ const o = (st(t) ?? "").split(" ");
555
+ if (s) {
556
+ const r = (st(s) ?? "").split(" ");
557
+ for (let l of r)
558
+ l && !o.includes(l) && e.classList.remove(l);
559
+ }
560
+ for (let r of o)
561
+ r && e.classList.add(r);
562
+ }
563
+ function _e(e, t) {
564
+ return e + t.charAt(0).toUpperCase() + t.substring(1);
565
+ }
566
+ var Ge = /* @__PURE__ */ (() => {
567
+ let e = {
568
+ animationIterationCount: 0,
569
+ borderImageOutset: 0,
570
+ borderImageSlice: 0,
571
+ borderImageWidth: 0,
572
+ boxFlex: 0,
573
+ boxFlexGroup: 0,
574
+ boxOrdinalGroup: 0,
575
+ columnCount: 0,
576
+ columns: 0,
577
+ flex: 0,
578
+ flexGrow: 0,
579
+ flexPositive: 0,
580
+ flexShrink: 0,
581
+ flexNegative: 0,
582
+ flexOrder: 0,
583
+ gridArea: 0,
584
+ gridRow: 0,
585
+ gridRowEnd: 0,
586
+ gridRowSpan: 0,
587
+ gridRowStart: 0,
588
+ gridColumn: 0,
589
+ gridColumnEnd: 0,
590
+ gridColumnSpan: 0,
591
+ gridColumnStart: 0,
592
+ fontWeight: 0,
593
+ lineClamp: 0,
594
+ lineHeight: 0,
595
+ opacity: 0,
596
+ order: 0,
597
+ orphans: 0,
598
+ tabSize: 0,
599
+ widows: 0,
600
+ zIndex: 0,
601
+ zoom: 0,
602
+ // SVG-related properties
603
+ fillOpacity: 0,
604
+ floodOpacity: 0,
605
+ stopOpacity: 0,
606
+ strokeDasharray: 0,
607
+ strokeDashoffset: 0,
608
+ strokeMiterlimit: 0,
609
+ strokeOpacity: 0,
610
+ strokeWidth: 0
611
+ };
612
+ const t = ["Webkit", "ms", "Moz", "O"];
613
+ return Object.keys(e).forEach((s) => {
614
+ t.forEach((o) => {
615
+ e[_e(o, s)] = 0;
616
+ });
617
+ }), e;
618
+ })();
619
+ function Mt(e, t, s) {
620
+ t.indexOf("-") === 0 ? e.style.setProperty(t, s) : re(s) && Ge[t] !== 0 ? e.style[t] = s + "px" : e.style[t] = s;
621
+ }
622
+ function Xt(e, t) {
623
+ if (!(t == null || t === !1 || t === !0)) {
624
+ if (vt(t)) {
625
+ e.removeAttribute("style");
626
+ return;
627
+ }
628
+ z(t) && Object.keys(t).forEach((s) => {
629
+ Mt(e, s, "");
630
+ });
631
+ }
632
+ }
633
+ function Ue(e, t, s) {
634
+ if (t == null || t === !1 || t === !0) {
635
+ Xt(e, s);
636
+ return;
637
+ }
638
+ if (vt(t)) {
639
+ e.setAttribute("style", t);
640
+ return;
641
+ }
642
+ if (z(t)) {
643
+ z(s) ? (t = { ...t }, Object.keys(s).forEach((o) => {
644
+ o in t || (t[o] = "");
645
+ })) : Xt(e, s), Object.entries(t).forEach(([o, r]) => {
646
+ Z(r) ? nt(r, (l) => Mt(e, o, l.newValue), {
647
+ lifecycleNode: e
648
+ }) : Mt(e, o, r);
649
+ });
650
+ return;
651
+ }
652
+ }
653
+ var je = "http://www.w3.org/1999/xlink", Ve = "http://www.w3.org/XML/1998/namespace";
654
+ function ht(e, t) {
655
+ return e.replace(/[A-Z]/g, (s) => t + s.toLowerCase());
656
+ }
657
+ var Ze = /* @__PURE__ */ new Map([
658
+ ["autoComplete", "autocomplete"],
659
+ ["autoFocus", "autofocus"],
660
+ ["className", "class"],
661
+ ["colSpan", "colspan"],
662
+ ["contentEditable", "contenteditable"],
663
+ ["formNoValidate", "formnovalidate"],
664
+ ["htmlFor", "for"],
665
+ ["innerText", "textContent"],
666
+ ["minLength", "minlength"],
667
+ ["maxLength", "maxlength"],
668
+ ["readOnly", "readonly"],
669
+ ["reffererPolicy", "referrerpolicy"],
670
+ ["rowSpan", "rowspan"],
671
+ ["spellCheck", "spellcheck"],
672
+ ["tabIndex", "tabindex"],
673
+ ["onDoubleClick", "onDblClick"],
674
+ ["onDoubleClickCapture", "onDblClickCapture"]
675
+ ]);
676
+ function Yt(e, t, s, o) {
677
+ switch (t) {
678
+ case "dataset":
679
+ o != null && Object.entries(o).forEach(([l, d]) => {
680
+ d != null && delete e.dataset[l];
681
+ }), Object.entries(s).forEach(([l, d]) => {
682
+ d != null && (e.dataset[l] = d);
683
+ });
684
+ return;
685
+ case "textContent":
686
+ it(s) ? e[t] = s : it(o) && (e[t] = "");
687
+ return;
688
+ case "dangerouslySetInnerHTML":
689
+ z(s) ? e.innerHTML = s.__html : z(o) && (e.innerHTML = "");
690
+ return;
691
+ case "value":
692
+ if (s == null) {
693
+ o != null && (e[t] = null);
694
+ return;
695
+ } else {
696
+ if (e instanceof window.HTMLSelectElement)
697
+ return;
698
+ if (e instanceof window.HTMLTextAreaElement) {
699
+ e.value = s;
700
+ return;
701
+ }
702
+ }
703
+ break;
704
+ case "class":
705
+ Be(e, s, o);
706
+ return;
707
+ case "spellcheck":
708
+ e.spellcheck = s === "" || s === !0 || s === "true" ? !0 : s === !1 || s === "false" ? !1 : s;
709
+ return;
710
+ case "draggable":
711
+ s === !1 || s === "false" ? s = "false" : s === "" ? s = null : (s === !0 || s === "true") && (s = "true");
712
+ break;
713
+ case "contenteditable":
714
+ s === !1 ? s = "false" : (s === "" || s === !0) && (s = "true");
715
+ break;
716
+ case "ref":
717
+ case "namespaceURI":
718
+ return;
719
+ case "style":
720
+ Ue(e, s, o);
721
+ return;
722
+ case "on":
723
+ case "onCapture":
724
+ const r = t === "onCapture";
725
+ o != null && Object.entries(o).forEach(([l, d]) => {
726
+ (s == null || s[l] !== d) && e.removeEventListener(l, d, r);
727
+ }), Object.entries(s).forEach(([l, d]) => {
728
+ (o == null || o[l] !== d) && e.addEventListener(l, d, r);
729
+ });
730
+ return;
731
+ case "xlinkActuate":
732
+ case "xlinkArcrole":
733
+ case "xlinkHref":
734
+ case "xlinkRole":
735
+ case "xlinkShow":
736
+ case "xlinkTitle":
737
+ case "xlinkType":
738
+ e.setAttributeNS(je, ht(t, ":"), s);
739
+ return;
740
+ case "xmlnsXlink":
741
+ e.setAttribute("xmlns:xlink", s);
742
+ return;
743
+ case "xmlBase":
744
+ case "xmlLang":
745
+ case "xmlSpace":
746
+ e.setAttributeNS(Ve, ht(t, ":"), s);
747
+ return;
748
+ }
749
+ if (typeof s == "function") {
750
+ if (t[0] === "o" && t[1] === "n") {
751
+ if (o != null && o === s)
752
+ return;
753
+ let r = t.toLowerCase();
754
+ const l = r.endsWith("capture");
755
+ let d;
756
+ !l && (e[r] === null || o != null && e[r] === o) ? (e[r] = s, kt(e, Xe.bind(e, r))) : l ? (d = r.substring(2, r.length - 7), o != null && e.removeEventListener(d, o, !0), e.addEventListener(d, s, !0)) : (r in window ? d = r.substring(2) : d = r[2] + t.slice(3), o != null && e.removeEventListener(d, o), e.addEventListener(d, s));
757
+ } else
758
+ console.warn(`A function was provided for JSX ${e.tagName} element ${t} which does not start with "on":`, s, e.tagName);
759
+ return;
760
+ }
761
+ if (z(o)) {
762
+ if (o === s)
763
+ return;
764
+ delete e[t];
765
+ }
766
+ if (o === !0) {
767
+ if (o === s)
768
+ return;
769
+ e.removeAttribute(t);
770
+ }
771
+ if (o !== !1 && o != null) {
772
+ if (o === s)
773
+ return;
774
+ e instanceof SVGElement && !Gt.test(t) ? e.removeAttributeNS(ht(t, "-"), s) : e.removeAttribute(t);
775
+ }
776
+ if (z(s)) {
777
+ e[t] = s;
778
+ return;
779
+ }
780
+ if (s === !0) {
781
+ e.setAttribute(t, "");
782
+ return;
783
+ }
784
+ s !== !1 && s != null && (e instanceof SVGElement && !Gt.test(t) ? e.setAttribute(ht(t, "-"), s) : e.setAttribute(t, s));
785
+ }
786
+ function qe(e, t) {
787
+ for (let [s, o] of Object.entries(t))
788
+ s = Ze.get(s) ?? s, Z(o) ? nt(o, (r) => Yt(e, s, r.newValue, r.prevValue), {
789
+ lifecycleNode: e
790
+ }) : Ce(o) ? o[oe](e, s) : Yt(e, s, o);
791
+ return e;
792
+ }
793
+ function Xe(e) {
794
+ this[e] = null;
795
+ }
796
+ function g(e, t) {
797
+ let { children: s, ...o } = t || {}, r = o.namespaceURI;
798
+ r || (Me.has(e) ? r = De : Ee.has(e) ? r = Ae : r = Re());
799
+ let l;
800
+ if (vt(e)) {
801
+ if (l = r ? document.createElementNS(r, e) : document.createElement(e), qe(l, o), ut(l, s), l instanceof window.HTMLSelectElement && o.value != null)
802
+ if (o.multiple === !0 && Array.isArray(o.value)) {
803
+ const d = o.value.map((p) => String(p));
804
+ l.querySelectorAll("option").forEach((p) => p.selected = d.includes(p.value));
805
+ } else
806
+ l.value = o.value;
807
+ Ft(o.ref, l);
808
+ } else if (typeof e == "function")
809
+ z(e.defaultProps) && (o = { ...e.defaultProps, ...o }), l = Se(e) ? Te(e, o, s) : e({ ...o, children: s });
810
+ else
811
+ throw new TypeError(`Invalid JSX element type: ${e}`);
812
+ return l;
813
+ }
814
+ var Ye = /* @__PURE__ */ Symbol.for("preact-signals");
815
+ function $t() {
816
+ if (V > 1)
817
+ V--;
818
+ else {
819
+ var e, t = !1;
820
+ for (function() {
821
+ var r = pt;
822
+ for (pt = void 0; r !== void 0; )
823
+ r.S.v === r.v && (r.S.i = r.i), r = r.o;
824
+ }(); et !== void 0; ) {
825
+ var s = et;
826
+ for (et = void 0, gt++; s !== void 0; ) {
827
+ var o = s.u;
828
+ if (s.u = void 0, s.f &= -3, !(8 & s.f) && de(s)) try {
829
+ s.c();
830
+ } catch (r) {
831
+ t || (e = r, t = !0);
832
+ }
833
+ s = o;
834
+ }
835
+ }
836
+ if (gt = 0, V--, t) throw e;
837
+ }
838
+ }
839
+ var P = void 0;
840
+ function le(e) {
841
+ var t = P;
842
+ P = void 0;
843
+ try {
844
+ return e();
845
+ } finally {
846
+ P = t;
847
+ }
848
+ }
849
+ var et = void 0, V = 0, gt = 0, Qt = 0, pt = void 0, ft = 0;
850
+ function ce(e) {
851
+ if (P !== void 0) {
852
+ var t = e.n;
853
+ if (t === void 0 || t.t !== P)
854
+ return t = { i: 0, S: e, p: P.s, n: void 0, t: P, e: void 0, x: void 0, r: t }, P.s !== void 0 && (P.s.n = t), P.s = t, e.n = t, 32 & P.f && e.S(t), t;
855
+ if (t.i === -1)
856
+ return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = P.s, t.n = void 0, P.s.n = t, P.s = t), t;
857
+ }
858
+ }
859
+ function L(e, t) {
860
+ this.v = e, this.i = 0, this.n = void 0, this.t = void 0, this.l = 0, this.W = t == null ? void 0 : t.watched, this.Z = t == null ? void 0 : t.unwatched, this.name = t == null ? void 0 : t.name;
861
+ }
862
+ L.prototype.brand = Ye;
863
+ L.prototype.h = function() {
864
+ return !0;
865
+ };
866
+ L.prototype.S = function(e) {
867
+ var t = this, s = this.t;
868
+ s !== e && e.e === void 0 && (e.x = s, this.t = e, s !== void 0 ? s.e = e : le(function() {
869
+ var o;
870
+ (o = t.W) == null || o.call(t);
871
+ }));
872
+ };
873
+ L.prototype.U = function(e) {
874
+ var t = this;
875
+ if (this.t !== void 0) {
876
+ var s = e.e, o = e.x;
877
+ s !== void 0 && (s.x = o, e.e = void 0), o !== void 0 && (o.e = s, e.x = void 0), e === this.t && (this.t = o, o === void 0 && le(function() {
878
+ var r;
879
+ (r = t.Z) == null || r.call(t);
880
+ }));
881
+ }
882
+ };
883
+ L.prototype.subscribe = function(e) {
884
+ var t = this;
885
+ return Ke(function() {
886
+ var s = t.value, o = P;
887
+ P = void 0;
888
+ try {
889
+ e(s);
890
+ } finally {
891
+ P = o;
892
+ }
893
+ }, { name: "sub" });
894
+ };
895
+ L.prototype.valueOf = function() {
896
+ return this.value;
897
+ };
898
+ L.prototype.toString = function() {
899
+ return this.value + "";
900
+ };
901
+ L.prototype.toJSON = function() {
902
+ return this.value;
903
+ };
904
+ L.prototype.peek = function() {
905
+ var e = P;
906
+ P = void 0;
907
+ try {
908
+ return this.value;
909
+ } finally {
910
+ P = e;
911
+ }
912
+ };
913
+ Object.defineProperty(L.prototype, "value", { get: function() {
914
+ var e = ce(this);
915
+ return e !== void 0 && (e.i = this.i), this.v;
916
+ }, set: function(e) {
917
+ if (e !== this.v) {
918
+ if (gt > 100) throw new Error("Cycle detected");
919
+ (function(s) {
920
+ V !== 0 && gt === 0 && s.l !== Qt && (s.l = Qt, pt = { S: s, v: s.v, i: s.i, o: pt });
921
+ })(this), this.v = e, this.i++, ft++, V++;
922
+ try {
923
+ for (var t = this.t; t !== void 0; t = t.x) t.t.N();
924
+ } finally {
925
+ $t();
926
+ }
927
+ }
928
+ } });
929
+ function de(e) {
930
+ for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
931
+ return !1;
932
+ }
933
+ function ue(e) {
934
+ for (var t = e.s; t !== void 0; t = t.n) {
935
+ var s = t.S.n;
936
+ if (s !== void 0 && (t.r = s), t.S.n = t, t.i = -1, t.n === void 0) {
937
+ e.s = t;
938
+ break;
939
+ }
940
+ }
941
+ }
942
+ function ge(e) {
943
+ for (var t = e.s, s = void 0; t !== void 0; ) {
944
+ var o = t.p;
945
+ t.i === -1 ? (t.S.U(t), o !== void 0 && (o.n = t.n), t.n !== void 0 && (t.n.p = o)) : s = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = o;
946
+ }
947
+ e.s = s;
948
+ }
949
+ function Y(e, t) {
950
+ L.call(this, void 0), this.x = e, this.s = void 0, this.g = ft - 1, this.f = 4, this.W = t == null ? void 0 : t.watched, this.Z = t == null ? void 0 : t.unwatched, this.name = t == null ? void 0 : t.name;
951
+ }
952
+ Y.prototype = new L();
953
+ Y.prototype.h = function() {
954
+ if (this.f &= -3, 1 & this.f) return !1;
955
+ if ((36 & this.f) == 32 || (this.f &= -5, this.g === ft)) return !0;
956
+ if (this.g = ft, this.f |= 1, this.i > 0 && !de(this))
957
+ return this.f &= -2, !0;
958
+ var e = P;
959
+ try {
960
+ ue(this), P = this;
961
+ var t = this.x();
962
+ (16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
963
+ } catch (s) {
964
+ this.v = s, this.f |= 16, this.i++;
965
+ }
966
+ return P = e, ge(this), this.f &= -2, !0;
967
+ };
968
+ Y.prototype.S = function(e) {
969
+ if (this.t === void 0) {
970
+ this.f |= 36;
971
+ for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
972
+ }
973
+ L.prototype.S.call(this, e);
974
+ };
975
+ Y.prototype.U = function(e) {
976
+ if (this.t !== void 0 && (L.prototype.U.call(this, e), this.t === void 0)) {
977
+ this.f &= -33;
978
+ for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
979
+ }
980
+ };
981
+ Y.prototype.N = function() {
982
+ if (!(2 & this.f)) {
983
+ this.f |= 6;
984
+ for (var e = this.t; e !== void 0; e = e.x) e.t.N();
985
+ }
986
+ };
987
+ Object.defineProperty(Y.prototype, "value", { get: function() {
988
+ if (1 & this.f) throw new Error("Cycle detected");
989
+ var e = ce(this);
990
+ if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
991
+ return this.v;
992
+ } });
993
+ function pe(e) {
994
+ var t = e.m;
995
+ if (e.m = void 0, typeof t == "function") {
996
+ V++;
997
+ var s = P;
998
+ P = void 0;
999
+ try {
1000
+ t();
1001
+ } catch (o) {
1002
+ throw e.f &= -2, e.f |= 8, Ht(e), o;
1003
+ } finally {
1004
+ P = s, $t();
1005
+ }
1006
+ }
1007
+ }
1008
+ function Ht(e) {
1009
+ for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
1010
+ e.x = void 0, e.s = void 0, pe(e);
1011
+ }
1012
+ function Qe(e) {
1013
+ if (P !== this) throw new Error("Out-of-order effect");
1014
+ ge(this), P = e, this.f &= -2, 8 & this.f && Ht(this), $t();
1015
+ }
1016
+ function Q(e, t) {
1017
+ this.x = e, this.m = void 0, this.s = void 0, this.u = void 0, this.f = 32, this.name = t == null ? void 0 : t.name;
1018
+ }
1019
+ Q.prototype.c = function() {
1020
+ var e = this.S();
1021
+ try {
1022
+ if (8 & this.f || this.x === void 0) return;
1023
+ var t = this.x();
1024
+ typeof t == "function" && (this.m = t);
1025
+ } finally {
1026
+ e();
1027
+ }
1028
+ };
1029
+ Q.prototype.S = function() {
1030
+ if (1 & this.f) throw new Error("Cycle detected");
1031
+ this.f |= 1, this.f &= -9, pe(this), ue(this), V++;
1032
+ var e = P;
1033
+ return P = this, Qe.bind(this, e);
1034
+ };
1035
+ Q.prototype.N = function() {
1036
+ 2 & this.f || (this.f |= 2, this.u = et, et = this);
1037
+ };
1038
+ Q.prototype.d = function() {
1039
+ this.f |= 8, 1 & this.f || Ht(this);
1040
+ };
1041
+ Q.prototype.dispose = function() {
1042
+ this.d();
1043
+ };
1044
+ function Ke(e, t) {
1045
+ var s = new Q(e, t);
1046
+ try {
1047
+ s.c();
1048
+ } catch (r) {
1049
+ throw s.d(), r;
1050
+ }
1051
+ var o = s.d.bind(s);
1052
+ return o[Symbol.dispose] = o, o;
1053
+ }
1054
+ const Je = {
1055
+ emptyStateTitle: "No data available.",
1056
+ thumbnails: "Thumbnails",
1057
+ singlePageMode: "Single Page Mode",
1058
+ pages: "Pages",
1059
+ previous: "Previous",
1060
+ next: "Next",
1061
+ zoomOut: "Zoom Out",
1062
+ zoomIn: "Zoom In",
1063
+ fullscreen: "Fullscreen",
1064
+ settings: "Settings",
1065
+ downloadCatalog: "Download Catalog",
1066
+ play: "Play",
1067
+ pause: "Pause"
1068
+ }, ti = {
1069
+ emptyStateTitle: "Veri bulunamadi.",
1070
+ thumbnails: "Küçük Resimler",
1071
+ singlePageMode: "Tek Sayfa Modu",
1072
+ pages: "Sayfalar",
1073
+ previous: "Önceki",
1074
+ next: "Sonraki",
1075
+ zoomOut: "Uzaklaş",
1076
+ zoomIn: "Yaklaş",
1077
+ fullscreen: "Tam Ekran",
1078
+ settings: "Ayarlar",
1079
+ downloadCatalog: "Kataloğu İndir",
1080
+ play: "Otomatik Oynat",
1081
+ pause: "Duraklat"
1082
+ }, Ct = {
1083
+ en: Je,
1084
+ tr: ti
1085
+ };
1086
+ function ei(e = {}) {
1087
+ var r;
1088
+ const t = e.locale ?? "en", s = Ct[t] ?? Ct.en, o = ((r = e.messages) == null ? void 0 : r[t]) ?? {};
1089
+ return {
1090
+ ...Ct.en,
1091
+ ...s,
1092
+ ...o
1093
+ };
1094
+ }
1095
+ function ii(e) {
1096
+ const t = w(() => ei({ locale: e.store.locale.value, messages: e.store.messages.value }));
1097
+ return /* @__PURE__ */ g("div", { class: "bk-toolbar", role: "toolbar", "aria-label": "Flipbook controls", children: [
1098
+ /* @__PURE__ */ g("div", { class: "bk-btn-group", children: [
1099
+ /* @__PURE__ */ g(
1100
+ "button",
1101
+ {
1102
+ type: "button",
1103
+ class: w(() => `bk-btn ${e.store.showThumbs.value ? "active" : ""}`),
1104
+ onClick: e.onToggleThumbs,
1105
+ "aria-label": w(() => t.value.thumbnails || "Thumbnails"),
1106
+ "aria-pressed": w(() => e.store.showThumbs.value ? "true" : "false"),
1107
+ title: w(() => t.value.thumbnails || "Thumbnails"),
1108
+ children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1109
+ /* @__PURE__ */ g("rect", { x: "3", y: "3", width: "7", height: "7" }),
1110
+ /* @__PURE__ */ g("rect", { x: "14", y: "3", width: "7", height: "7" }),
1111
+ /* @__PURE__ */ g("rect", { x: "14", y: "14", width: "7", height: "7" }),
1112
+ /* @__PURE__ */ g("rect", { x: "3", y: "14", width: "7", height: "7" })
1113
+ ] })
1114
+ }
1115
+ ),
1116
+ /* @__PURE__ */ g(
1117
+ "button",
1118
+ {
1119
+ type: "button",
1120
+ class: w(() => `bk-btn bz-hide-mobile ${e.store.isSingleMode.value ? "active" : ""}`),
1121
+ onClick: e.onToggleSingleMode,
1122
+ "aria-label": w(() => t.value.singlePageMode || "Single Page"),
1123
+ "aria-pressed": w(() => e.store.isSingleMode.value ? "true" : "false"),
1124
+ title: w(() => t.value.singlePageMode || "Single Page"),
1125
+ children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1126
+ /* @__PURE__ */ g("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1127
+ /* @__PURE__ */ g("polyline", { points: "14 2 14 8 20 8" }),
1128
+ /* @__PURE__ */ g("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
1129
+ /* @__PURE__ */ g("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
1130
+ /* @__PURE__ */ g("polyline", { points: "10 9 9 9 8 9" })
1131
+ ] })
1132
+ }
1133
+ ),
1134
+ /* @__PURE__ */ g(
1135
+ "button",
1136
+ {
1137
+ type: "button",
1138
+ class: w(() => `bk-btn ${e.store.isAutoPlaying.value ? "active" : ""}`),
1139
+ onClick: e.onToggleAutoPlay,
1140
+ "aria-label": w(() => e.store.isAutoPlaying.value ? t.value.pause || "Pause" : t.value.play || "Play"),
1141
+ "aria-pressed": w(() => e.store.isAutoPlaying.value ? "true" : "false"),
1142
+ title: w(() => e.store.isAutoPlaying.value ? t.value.pause || "Pause" : t.value.play || "Play"),
1143
+ children: [
1144
+ /* @__PURE__ */ g("svg", { style: { display: w(() => e.store.isAutoPlaying.value ? "block" : "none") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1145
+ /* @__PURE__ */ g("rect", { x: "6", y: "4", width: "4", height: "16" }),
1146
+ /* @__PURE__ */ g("rect", { x: "14", y: "4", width: "4", height: "16" })
1147
+ ] }),
1148
+ /* @__PURE__ */ g("svg", { style: { display: w(() => e.store.isAutoPlaying.value ? "none" : "block") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ g("polygon", { points: "5 3 19 12 5 21 5 3" }) })
1149
+ ]
1150
+ }
1151
+ )
1152
+ ] }),
1153
+ /* @__PURE__ */ g("div", { class: "bk-btn-group bk-btn-group--center", children: [
1154
+ /* @__PURE__ */ g("button", { type: "button", class: "bk-btn", onClick: e.onPrevPage, "aria-label": w(() => t.value.previous || "Previous"), title: w(() => t.value.previous || "Previous"), children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ g("polyline", { points: "15 18 9 12 15 6" }) }) }),
1155
+ /* @__PURE__ */ g("span", { class: "bz-page-info", "aria-live": "polite", "aria-atomic": "true", children: w(() => {
1156
+ const s = e.store.currentPage.value, o = e.store.totalPages.value;
1157
+ if (e.store.isSingleMode.value || s === 0 || s >= o - 1)
1158
+ return `${s + 1} / ${o}`;
1159
+ const r = s % 2 === 1 ? s : s - 1;
1160
+ return `${r + 1}-${r + 2} / ${o}`;
1161
+ }) }),
1162
+ /* @__PURE__ */ g("button", { type: "button", class: "bk-btn", onClick: e.onNextPage, "aria-label": w(() => t.value.next || "Next"), title: w(() => t.value.next || "Next"), children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ g("polyline", { points: "9 18 15 12 9 6" }) }) })
1163
+ ] }),
1164
+ /* @__PURE__ */ g("div", { class: "bk-btn-group", children: [
1165
+ /* @__PURE__ */ g("button", { type: "button", class: "bk-btn", onClick: e.onZoomIn, "aria-label": w(() => t.value.zoomIn || "Zoom In"), title: w(() => t.value.zoomIn || "Zoom In"), children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1166
+ /* @__PURE__ */ g("circle", { cx: "11", cy: "11", r: "8" }),
1167
+ /* @__PURE__ */ g("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
1168
+ /* @__PURE__ */ g("line", { x1: "11", y1: "8", x2: "11", y2: "14" }),
1169
+ /* @__PURE__ */ g("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
1170
+ ] }) }),
1171
+ /* @__PURE__ */ g(
1172
+ "button",
1173
+ {
1174
+ type: "button",
1175
+ class: w(() => `bk-btn ${e.store.isZoomed.value ? "active" : ""}`),
1176
+ onClick: e.onZoomOut,
1177
+ "aria-label": w(() => t.value.zoomOut || "Zoom Out"),
1178
+ title: w(() => t.value.zoomOut || "Zoom Out"),
1179
+ children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1180
+ /* @__PURE__ */ g("circle", { cx: "11", cy: "11", r: "8" }),
1181
+ /* @__PURE__ */ g("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }),
1182
+ /* @__PURE__ */ g("line", { x1: "8", y1: "11", x2: "14", y2: "11" })
1183
+ ] })
1184
+ }
1185
+ ),
1186
+ /* @__PURE__ */ g("button", { type: "button", class: "bk-btn bk-btn--fullscreen", onClick: e.onToggleFullscreen, "aria-label": w(() => t.value.fullscreen || "Fullscreen"), title: w(() => t.value.fullscreen || "Fullscreen"), children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: /* @__PURE__ */ g("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" }) }) }),
1187
+ w(() => e.store.allowDownload.value && e.store.hasDownloadUrl.value && e.onDownload ? /* @__PURE__ */ g("button", { type: "button", class: "bk-btn bk-btn--download", onClick: e.onDownload, "aria-label": w(() => t.value.downloadCatalog || "Download"), title: w(() => t.value.downloadCatalog || "Download"), children: /* @__PURE__ */ g("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1188
+ /* @__PURE__ */ g("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
1189
+ /* @__PURE__ */ g("polyline", { points: "7 10 12 15 17 10" }),
1190
+ /* @__PURE__ */ g("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
1191
+ ] }) }) : null),
1192
+ /* @__PURE__ */ g(
1193
+ "button",
1194
+ {
1195
+ type: "button",
1196
+ class: w(() => `bk-btn ${e.store.soundEnabled.value ? "" : "muted"}`),
1197
+ onClick: e.onSoundToggle,
1198
+ "aria-label": "Sound",
1199
+ "aria-pressed": w(() => e.store.soundEnabled.value ? "true" : "false"),
1200
+ title: "Sound",
1201
+ children: [
1202
+ /* @__PURE__ */ g("svg", { style: { display: w(() => e.store.soundEnabled.value ? "block" : "none") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1203
+ /* @__PURE__ */ g("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1204
+ /* @__PURE__ */ g("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" }),
1205
+ /* @__PURE__ */ g("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" })
1206
+ ] }),
1207
+ /* @__PURE__ */ g("svg", { style: { display: w(() => e.store.soundEnabled.value ? "none" : "block") }, xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", children: [
1208
+ /* @__PURE__ */ g("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1209
+ /* @__PURE__ */ g("line", { x1: "23", y1: "9", x2: "17", y2: "15" }),
1210
+ /* @__PURE__ */ g("line", { x1: "17", y1: "9", x2: "23", y2: "15" })
1211
+ ] })
1212
+ ]
1213
+ }
1214
+ )
1215
+ ] })
1216
+ ] });
1217
+ }
1218
+ function si(e) {
1219
+ return /* @__PURE__ */ g("div", { class: "bk-thumbs", style: w(() => e.store.showThumbs.value ? "display:flex;" : "display:none;"), children: e.store.pages.value.map((t, s) => {
1220
+ const o = () => {
1221
+ const r = e.store.currentPage.value;
1222
+ if (e.store.isSingleMode.value || r === 0 || r >= e.store.pages.value.length - 1)
1223
+ return r === s;
1224
+ const l = r % 2 === 1 ? r : r - 1;
1225
+ return s === l || s === l + 1;
1226
+ };
1227
+ return /* @__PURE__ */ g(
1228
+ "div",
1229
+ {
1230
+ class: w(() => `thumb-item ${o() ? "active" : ""}`),
1231
+ role: "button",
1232
+ tabindex: "0",
1233
+ "aria-label": `Go to page ${s + 1}`,
1234
+ "aria-current": w(() => o() ? "page" : void 0),
1235
+ onClick: () => e.onThumbClick(s),
1236
+ onKeyDown: (r) => {
1237
+ (r.key === "Enter" || r.key === " ") && (r.preventDefault(), e.onThumbClick(s));
1238
+ },
1239
+ children: [
1240
+ /* @__PURE__ */ g("div", { class: "thumb-img-wrapper", children: /* @__PURE__ */ g(
1241
+ "img",
1242
+ {
1243
+ "data-pdf-page": t.assetId.startsWith("pdf-page-") ? t.pageNumber : void 0,
1244
+ class: "thumb-img",
1245
+ src: t.thumb || t.low || t.normal,
1246
+ alt: `Page ${s + 1}`,
1247
+ loading: "lazy",
1248
+ onError: (r) => {
1249
+ r.currentTarget.style.display = "none";
1250
+ }
1251
+ }
1252
+ ) }),
1253
+ /* @__PURE__ */ g("span", { children: s + 1 })
1254
+ ]
1255
+ }
1256
+ );
1257
+ }) });
1258
+ }
1259
+ function ni(e) {
1260
+ return /* @__PURE__ */ g(
1261
+ "div",
1262
+ {
1263
+ role: "region",
1264
+ "aria-label": "Flipbook viewer",
1265
+ class: w(() => {
1266
+ let t = "bk-book-wrapper ";
1267
+ return e.store.isDoublePageLayout.value && (t += "double-mode "), e.store.isFrontCover.value && (t += "bk-is-cover "), e.store.isBackCover.value && (t += "bk-is-back-cover "), e.store.zoomState.value.isActive && (t += "zoomed "), t.trim();
1268
+ }),
1269
+ ref: e.bookWrapperRef,
1270
+ children: /* @__PURE__ */ g(
1271
+ "div",
1272
+ {
1273
+ class: "bk-book-sizer",
1274
+ ref: e.bookSizerRef,
1275
+ children: [
1276
+ /* @__PURE__ */ g(
1277
+ "div",
1278
+ {
1279
+ ref: e.bookContainerRef,
1280
+ class: w(() => "bk-book " + (e.store.flipState.value !== "read" ? "is-flipping" : "")),
1281
+ style: w(() => `display: ${e.store.isSingleMode.value ? "none" : "block"};`),
1282
+ children: e.store.pages.value.map((t, s) => {
1283
+ const o = s === 0 || s === e.store.pages.value.length - 1;
1284
+ return /* @__PURE__ */ g(
1285
+ "div",
1286
+ {
1287
+ class: `bz-page ${s === 0 ? "bz-page--cover" : ""} ${s === e.store.pages.value.length - 1 ? "bz-page--back" : ""}`,
1288
+ "data-density": o ? "hard" : "soft",
1289
+ "data-idx": s,
1290
+ children: /* @__PURE__ */ g("div", { class: "bz-page-content", style: "position:relative; width:100%; height:100%; overflow:hidden;", children: [
1291
+ /* @__PURE__ */ g(
1292
+ "img",
1293
+ {
1294
+ "data-pdf-page": t.assetId.startsWith("pdf-page-") ? t.pageNumber : void 0,
1295
+ src: t.low || t.normal,
1296
+ "data-src": t.normal,
1297
+ class: `page-content ${t.cropMode !== "full" ? "page-content--split page-content--" + t.cropMode : ""}`,
1298
+ alt: `Page ${s + 1}`,
1299
+ loading: "lazy"
1300
+ }
1301
+ ),
1302
+ /* @__PURE__ */ g("div", { class: "page-shadow" })
1303
+ ] })
1304
+ }
1305
+ );
1306
+ })
1307
+ }
1308
+ ),
1309
+ /* @__PURE__ */ g(
1310
+ "div",
1311
+ {
1312
+ class: "bk-single-view",
1313
+ style: w(() => `display: ${e.store.isSingleMode.value ? "flex" : "none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),
1314
+ children: w(() => {
1315
+ const t = e.store.pages.value[e.store.currentPage.value];
1316
+ return t ? /* @__PURE__ */ g(
1317
+ "img",
1318
+ {
1319
+ "data-pdf-page": t.assetId.startsWith("pdf-page-") ? t.pageNumber : void 0,
1320
+ class: `bk-single-img page-content ${t.cropMode !== "full" ? "page-content--split page-content--" + t.cropMode : ""}`,
1321
+ src: e.store.zoomState.value.isActive ? t.normal : t.low || t.normal,
1322
+ alt: `Page ${e.store.currentPage.value + 1}`,
1323
+ style: "opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"
1324
+ }
1325
+ ) : null;
1326
+ })
1327
+ }
1328
+ )
1329
+ ]
1330
+ }
1331
+ )
1332
+ }
1333
+ );
1334
+ }
1335
+ function oi(e) {
1336
+ const t = w(() => e.store.showArrows.value && e.store.currentPage.value > 0), s = w(() => !e.store.showArrows.value || e.store.totalPages.value <= 1 ? !1 : e.store.currentPage.value < e.store.totalPages.value - 1);
1337
+ return /* @__PURE__ */ g("div", { class: "bk-nav-arrows", style: w(() => e.store.showArrows.value ? "display: flex;" : "display: none;"), children: [
1338
+ /* @__PURE__ */ g(
1339
+ "button",
1340
+ {
1341
+ type: "button",
1342
+ class: "bk-nav-arrow bk-nav-prev",
1343
+ style: w(() => t.value ? "visibility: visible;" : "visibility: hidden;"),
1344
+ onClick: (o) => {
1345
+ o.preventDefault(), e.onPrevPage();
1346
+ },
1347
+ "aria-label": "Previous Page",
1348
+ children: /* @__PURE__ */ g("div", { class: "bk-arrow-icon bk-arrow-left" })
1349
+ }
1350
+ ),
1351
+ /* @__PURE__ */ g(
1352
+ "button",
1353
+ {
1354
+ type: "button",
1355
+ class: "bk-nav-arrow bk-nav-next",
1356
+ style: w(() => s.value ? "visibility: visible;" : "visibility: hidden;"),
1357
+ onClick: (o) => {
1358
+ o.preventDefault(), e.onNextPage();
1359
+ },
1360
+ "aria-label": "Next Page",
1361
+ children: /* @__PURE__ */ g("div", { class: "bk-arrow-icon bk-arrow-right" })
1362
+ }
1363
+ )
1364
+ ] });
1365
+ }
1366
+ function ri(e) {
1367
+ const t = () => {
1368
+ e.store.showThumbs.value = !e.store.showThumbs.value;
1369
+ }, s = () => {
1370
+ e.store.isSingleMode.value = !e.store.isSingleMode.value;
1371
+ }, o = () => {
1372
+ e.store.isAutoPlaying.value = !e.store.isAutoPlaying.value;
1373
+ }, r = () => {
1374
+ var b;
1375
+ (b = e.interactionManagerRef.current) == null || b.zoomIn();
1376
+ }, l = () => {
1377
+ var b;
1378
+ (b = e.interactionManagerRef.current) == null || b.zoomOut();
1379
+ }, d = () => e.onToggleFullscreen(), p = (b) => {
1380
+ var D;
1381
+ e.store.currentPage.value !== b && (e.store.currentPage.value = b, (D = e.pageFlipAdapterRef.current) == null || D.playSound());
1382
+ }, x = () => {
1383
+ var b;
1384
+ (b = e.pageFlipAdapterRef.current) == null || b.turnToNextPage();
1385
+ }, S = () => {
1386
+ var b;
1387
+ (b = e.pageFlipAdapterRef.current) == null || b.turnToPrevPage();
1388
+ };
1389
+ return /* @__PURE__ */ g(
1390
+ "div",
1391
+ {
1392
+ class: w(() => `bk-wrapper bk-theme-${e.store.themeMode.value} ${e.className || ""}`),
1393
+ children: [
1394
+ /* @__PURE__ */ g("div", { class: "bk-main-area", children: [
1395
+ /* @__PURE__ */ g(
1396
+ ni,
1397
+ {
1398
+ store: e.store,
1399
+ bookWrapperRef: e.bookWrapperRef,
1400
+ bookSizerRef: e.bookSizerRef,
1401
+ bookContainerRef: e.bookContainerRef
1402
+ }
1403
+ ),
1404
+ /* @__PURE__ */ g(
1405
+ oi,
1406
+ {
1407
+ store: e.store,
1408
+ onPrevPage: S,
1409
+ onNextPage: x
1410
+ }
1411
+ ),
1412
+ e.store.whiteLabel.value ? null : /* @__PURE__ */ g("div", { class: "bk-watermark", children: [
1413
+ "Powered by ",
1414
+ /* @__PURE__ */ g("a", { href: "https://flipbookengine.com", target: "_blank", rel: "noopener", style: "text-decoration: underline;", children: "FlipbookEngine" })
1415
+ ] })
1416
+ ] }),
1417
+ /* @__PURE__ */ g(
1418
+ ii,
1419
+ {
1420
+ store: e.store,
1421
+ onToggleThumbs: t,
1422
+ onToggleSingleMode: s,
1423
+ onZoomIn: r,
1424
+ onZoomOut: l,
1425
+ onDownload: e.onDownload,
1426
+ onNextPage: x,
1427
+ onPrevPage: S,
1428
+ onSoundToggle: () => e.store.soundEnabled.value = !e.store.soundEnabled.value,
1429
+ onToggleAutoPlay: o,
1430
+ onToggleFullscreen: d
1431
+ }
1432
+ ),
1433
+ /* @__PURE__ */ g(
1434
+ si,
1435
+ {
1436
+ store: e.store,
1437
+ onThumbClick: p
1438
+ }
1439
+ )
1440
+ ]
1441
+ }
1442
+ );
1443
+ }
1444
+ var ai = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Dt = { exports: {} };
1445
+ (function(e, t) {
1446
+ (function(s, o) {
1447
+ o(t);
1448
+ })(ai, function(s) {
1449
+ class o {
1450
+ constructor(i, n) {
1451
+ this.state = { angle: 0, area: [], position: { x: 0, y: 0 }, hardAngle: 0, hardDrawingAngle: 0 }, this.createdDensity = n, this.nowDrawingDensity = this.createdDensity, this.render = i;
1452
+ }
1453
+ setDensity(i) {
1454
+ this.createdDensity = i, this.nowDrawingDensity = i;
1455
+ }
1456
+ setDrawingDensity(i) {
1457
+ this.nowDrawingDensity = i;
1458
+ }
1459
+ setPosition(i) {
1460
+ this.state.position = i;
1461
+ }
1462
+ setAngle(i) {
1463
+ this.state.angle = i;
1464
+ }
1465
+ setArea(i) {
1466
+ this.state.area = i;
1467
+ }
1468
+ setHardDrawingAngle(i) {
1469
+ this.state.hardDrawingAngle = i;
1470
+ }
1471
+ setHardAngle(i) {
1472
+ this.state.hardAngle = i, this.state.hardDrawingAngle = i;
1473
+ }
1474
+ setOrientation(i) {
1475
+ this.orientation = i;
1476
+ }
1477
+ getDrawingDensity() {
1478
+ return this.nowDrawingDensity;
1479
+ }
1480
+ getDensity() {
1481
+ return this.createdDensity;
1482
+ }
1483
+ getHardAngle() {
1484
+ return this.state.hardAngle;
1485
+ }
1486
+ }
1487
+ class r extends o {
1488
+ constructor(i, n, a) {
1489
+ super(i, a), this.image = null, this.isLoad = !1, this.loadingAngle = 0, this.image = new Image(), this.image.src = n;
1490
+ }
1491
+ draw(i) {
1492
+ const n = this.render.getContext(), a = this.render.convertToGlobal(this.state.position), c = this.render.getRect().pageWidth, h = this.render.getRect().height;
1493
+ n.save(), n.translate(a.x, a.y), n.beginPath();
1494
+ for (let u of this.state.area) u !== null && (u = this.render.convertToGlobal(u), n.lineTo(u.x - a.x, u.y - a.y));
1495
+ n.rotate(this.state.angle), n.clip(), this.isLoad ? n.drawImage(this.image, 0, 0, c, h) : this.drawLoader(n, { x: 0, y: 0 }, c, h), n.restore();
1496
+ }
1497
+ simpleDraw(i) {
1498
+ const n = this.render.getRect(), a = this.render.getContext(), c = n.pageWidth, h = n.height, u = i === 1 ? n.left + n.pageWidth : n.left, v = n.top;
1499
+ this.isLoad ? a.drawImage(this.image, u, v, c, h) : this.drawLoader(a, { x: u, y: v }, c, h);
1500
+ }
1501
+ drawLoader(i, n, a, c) {
1502
+ i.beginPath(), i.strokeStyle = "rgb(200, 200, 200)", i.fillStyle = "rgb(255, 255, 255)", i.lineWidth = 1, i.rect(n.x + 1, n.y + 1, a - 1, c - 1), i.stroke(), i.fill();
1503
+ const h = { x: n.x + a / 2, y: n.y + c / 2 };
1504
+ i.beginPath(), i.lineWidth = 10, i.arc(h.x, h.y, 20, this.loadingAngle, 3 * Math.PI / 2 + this.loadingAngle), i.stroke(), i.closePath(), this.loadingAngle += 0.07, this.loadingAngle >= 2 * Math.PI && (this.loadingAngle = 0);
1505
+ }
1506
+ load() {
1507
+ this.isLoad || (this.image.onload = () => {
1508
+ this.isLoad = !0;
1509
+ });
1510
+ }
1511
+ newTemporaryCopy() {
1512
+ return this;
1513
+ }
1514
+ getTemporaryCopy() {
1515
+ return this;
1516
+ }
1517
+ hideTemporaryCopy() {
1518
+ }
1519
+ }
1520
+ class l {
1521
+ constructor(i, n) {
1522
+ this.pages = [], this.currentPageIndex = 0, this.currentSpreadIndex = 0, this.landscapeSpread = [], this.portraitSpread = [], this.render = n, this.app = i, this.currentPageIndex = 0, this.isShowCover = this.app.getSettings().showCover;
1523
+ }
1524
+ destroy() {
1525
+ this.pages = [];
1526
+ }
1527
+ createSpread() {
1528
+ this.landscapeSpread = [], this.portraitSpread = [];
1529
+ for (let n = 0; n < this.pages.length; n++) this.portraitSpread.push([n]);
1530
+ let i = 0;
1531
+ this.isShowCover && (this.pages[0].setDensity("hard"), this.landscapeSpread.push([i]), i++);
1532
+ for (let n = i; n < this.pages.length; n += 2) n < this.pages.length - 1 ? this.landscapeSpread.push([n, n + 1]) : (this.landscapeSpread.push([n]), this.pages[n].setDensity("hard"));
1533
+ }
1534
+ getSpread() {
1535
+ return this.render.getOrientation() === "landscape" ? this.landscapeSpread : this.portraitSpread;
1536
+ }
1537
+ getSpreadIndexByPage(i) {
1538
+ const n = this.getSpread();
1539
+ for (let a = 0; a < n.length; a++) if (i === n[a][0] || i === n[a][1]) return a;
1540
+ return null;
1541
+ }
1542
+ getPageCount() {
1543
+ return this.pages.length;
1544
+ }
1545
+ getPages() {
1546
+ return this.pages;
1547
+ }
1548
+ getPage(i) {
1549
+ if (i >= 0 && i < this.pages.length) return this.pages[i];
1550
+ throw new Error("Invalid page number");
1551
+ }
1552
+ nextBy(i) {
1553
+ const n = this.pages.indexOf(i);
1554
+ return n < this.pages.length - 1 ? this.pages[n + 1] : null;
1555
+ }
1556
+ prevBy(i) {
1557
+ const n = this.pages.indexOf(i);
1558
+ return n > 0 ? this.pages[n - 1] : null;
1559
+ }
1560
+ getFlippingPage(i) {
1561
+ const n = this.currentSpreadIndex;
1562
+ if (this.render.getOrientation() === "portrait") return i === 0 ? this.pages[n].newTemporaryCopy() : this.pages[n - 1];
1563
+ {
1564
+ const a = i === 0 ? this.getSpread()[n + 1] : this.getSpread()[n - 1];
1565
+ return a.length === 1 || i === 0 ? this.pages[a[0]] : this.pages[a[1]];
1566
+ }
1567
+ }
1568
+ getBottomPage(i) {
1569
+ const n = this.currentSpreadIndex;
1570
+ if (this.render.getOrientation() === "portrait") return i === 0 ? this.pages[n + 1] : this.pages[n - 1];
1571
+ {
1572
+ const a = i === 0 ? this.getSpread()[n + 1] : this.getSpread()[n - 1];
1573
+ return a.length === 1 ? this.pages[a[0]] : i === 0 ? this.pages[a[1]] : this.pages[a[0]];
1574
+ }
1575
+ }
1576
+ showNext() {
1577
+ this.currentSpreadIndex < this.getSpread().length && (this.currentSpreadIndex++, this.showSpread());
1578
+ }
1579
+ showPrev() {
1580
+ this.currentSpreadIndex > 0 && (this.currentSpreadIndex--, this.showSpread());
1581
+ }
1582
+ getCurrentPageIndex() {
1583
+ return this.currentPageIndex;
1584
+ }
1585
+ show(i = null) {
1586
+ if (i === null && (i = this.currentPageIndex), i < 0 || i >= this.pages.length) return;
1587
+ const n = this.getSpreadIndexByPage(i);
1588
+ n !== null && (this.currentSpreadIndex = n, this.showSpread());
1589
+ }
1590
+ getCurrentSpreadIndex() {
1591
+ return this.currentSpreadIndex;
1592
+ }
1593
+ setCurrentSpreadIndex(i) {
1594
+ if (!(i >= 0 && i < this.getSpread().length)) throw new Error("Invalid page");
1595
+ this.currentSpreadIndex = i;
1596
+ }
1597
+ showSpread() {
1598
+ const i = this.getSpread()[this.currentSpreadIndex];
1599
+ i.length === 2 ? (this.render.setLeftPage(this.pages[i[0]]), this.render.setRightPage(this.pages[i[1]])) : this.render.getOrientation() === "landscape" && i[0] === this.pages.length - 1 ? (this.render.setLeftPage(this.pages[i[0]]), this.render.setRightPage(null)) : (this.render.setLeftPage(null), this.render.setRightPage(this.pages[i[0]])), this.currentPageIndex = i[0], this.app.updatePageIndex(this.currentPageIndex);
1600
+ }
1601
+ }
1602
+ class d extends l {
1603
+ constructor(i, n, a) {
1604
+ super(i, n), this.imagesHref = a;
1605
+ }
1606
+ load() {
1607
+ for (const i of this.imagesHref) {
1608
+ const n = new r(this.render, i, "soft");
1609
+ n.load(), this.pages.push(n);
1610
+ }
1611
+ this.createSpread();
1612
+ }
1613
+ }
1614
+ class p {
1615
+ static GetDistanceBetweenTwoPoint(i, n) {
1616
+ return i === null || n === null ? 1 / 0 : Math.sqrt(Math.pow(n.x - i.x, 2) + Math.pow(n.y - i.y, 2));
1617
+ }
1618
+ static GetSegmentLength(i) {
1619
+ return p.GetDistanceBetweenTwoPoint(i[0], i[1]);
1620
+ }
1621
+ static GetAngleBetweenTwoLine(i, n) {
1622
+ const a = i[0].y - i[1].y, c = n[0].y - n[1].y, h = i[1].x - i[0].x, u = n[1].x - n[0].x;
1623
+ return Math.acos((a * c + h * u) / (Math.sqrt(a * a + h * h) * Math.sqrt(c * c + u * u)));
1624
+ }
1625
+ static PointInRect(i, n) {
1626
+ return n === null ? null : n.x >= i.left && n.x <= i.width + i.left && n.y >= i.top && n.y <= i.top + i.height ? n : null;
1627
+ }
1628
+ static GetRotatedPoint(i, n, a) {
1629
+ return { x: i.x * Math.cos(a) + i.y * Math.sin(a) + n.x, y: i.y * Math.cos(a) - i.x * Math.sin(a) + n.y };
1630
+ }
1631
+ static LimitPointToCircle(i, n, a) {
1632
+ if (p.GetDistanceBetweenTwoPoint(i, a) <= n) return a;
1633
+ const c = i.x, h = i.y, u = a.x, v = a.y;
1634
+ let y = Math.sqrt(Math.pow(n, 2) * Math.pow(c - u, 2) / (Math.pow(c - u, 2) + Math.pow(h - v, 2))) + c;
1635
+ a.x < 0 && (y *= -1);
1636
+ let E = (y - c) * (h - v) / (c - u) + h;
1637
+ return c - u + h === 0 && (E = n), { x: y, y: E };
1638
+ }
1639
+ static GetIntersectBetweenTwoSegment(i, n, a) {
1640
+ return p.PointInRect(i, p.GetIntersectBeetwenTwoLine(n, a));
1641
+ }
1642
+ static GetIntersectBeetwenTwoLine(i, n) {
1643
+ const a = i[0].y - i[1].y, c = n[0].y - n[1].y, h = i[1].x - i[0].x, u = n[1].x - n[0].x, v = i[0].x * i[1].y - i[1].x * i[0].y, y = n[0].x * n[1].y - n[1].x * n[0].y, E = a * y - c * v, R = h * y - u * v, W = -(v * u - y * h) / (a * u - c * h), K = -(a * y - c * v) / (a * u - c * h);
1644
+ if (isFinite(W) && isFinite(K)) return { x: W, y: K };
1645
+ if (Math.abs(E - R) < 0.1) throw new Error("Segment included");
1646
+ return null;
1647
+ }
1648
+ static GetCordsFromTwoPoint(i, n) {
1649
+ const a = Math.abs(i.x - n.x), c = Math.abs(i.y - n.y), h = Math.max(a, c), u = [i];
1650
+ function v(y, E, R, W, K) {
1651
+ return E > y ? y + K * (R / W) : E < y ? y - K * (R / W) : y;
1652
+ }
1653
+ for (let y = 1; y <= h; y += 1) u.push({ x: v(i.x, n.x, a, h, y), y: v(i.y, n.y, c, h, y) });
1654
+ return u;
1655
+ }
1656
+ }
1657
+ class x extends o {
1658
+ constructor(i, n, a) {
1659
+ super(i, a), this.copiedElement = null, this.temporaryCopy = null, this.isLoad = !1, this.element = n, this.element.classList.add("stf__item"), this.element.classList.add("--" + a);
1660
+ }
1661
+ newTemporaryCopy() {
1662
+ return this.nowDrawingDensity === "hard" ? this : (this.temporaryCopy === null && (this.copiedElement = this.element.cloneNode(!0), this.element.parentElement.appendChild(this.copiedElement), this.temporaryCopy = new x(this.render, this.copiedElement, this.nowDrawingDensity)), this.getTemporaryCopy());
1663
+ }
1664
+ getTemporaryCopy() {
1665
+ return this.temporaryCopy;
1666
+ }
1667
+ hideTemporaryCopy() {
1668
+ this.temporaryCopy !== null && (this.copiedElement.remove(), this.copiedElement = null, this.temporaryCopy = null);
1669
+ }
1670
+ draw(i) {
1671
+ const n = i || this.nowDrawingDensity, a = this.render.convertToGlobal(this.state.position), c = this.render.getRect().pageWidth, h = this.render.getRect().height;
1672
+ this.element.classList.remove("--simple");
1673
+ const u = `
1674
+ display: block;
1675
+ z-index: ${this.element.style.zIndex};
1676
+ left: 0;
1677
+ top: 0;
1678
+ width: ${c}px;
1679
+ height: ${h}px;
1680
+ `;
1681
+ n === "hard" ? this.drawHard(u) : this.drawSoft(a, u);
1682
+ }
1683
+ drawHard(i = "") {
1684
+ const n = this.render.getRect().left + this.render.getRect().width / 2, a = this.state.hardDrawingAngle, c = i + `
1685
+ backface-visibility: hidden;
1686
+ -webkit-backface-visibility: hidden;
1687
+ clip-path: none;
1688
+ -webkit-clip-path: none;
1689
+ ` + (this.orientation === 0 ? `transform-origin: ${this.render.getRect().pageWidth}px 0;
1690
+ transform: translate3d(0, 0, 0) rotateY(${a}deg);` : `transform-origin: 0 0;
1691
+ transform: translate3d(${n}px, 0, 0) rotateY(${a}deg);`);
1692
+ this.element.style.cssText = c;
1693
+ }
1694
+ drawSoft(i, n = "") {
1695
+ let a = "polygon( ";
1696
+ for (const h of this.state.area) if (h !== null) {
1697
+ let u = this.render.getDirection() === 1 ? { x: -h.x + this.state.position.x, y: h.y - this.state.position.y } : { x: h.x - this.state.position.x, y: h.y - this.state.position.y };
1698
+ u = p.GetRotatedPoint(u, { x: 0, y: 0 }, this.state.angle), a += u.x + "px " + u.y + "px, ";
1699
+ }
1700
+ a = a.slice(0, -2), a += ")";
1701
+ const c = n + `transform-origin: 0 0; clip-path: ${a}; -webkit-clip-path: ${a};` + (this.render.isSafari() && this.state.angle === 0 ? `transform: translate(${i.x}px, ${i.y}px);` : `transform: translate3d(${i.x}px, ${i.y}px, 0) rotate(${this.state.angle}rad);`);
1702
+ this.element.style.cssText = c;
1703
+ }
1704
+ simpleDraw(i) {
1705
+ const n = this.render.getRect(), a = n.pageWidth, c = n.height, h = i === 1 ? n.left + n.pageWidth : n.left, u = n.top;
1706
+ this.element.classList.add("--simple"), this.element.style.cssText = `
1707
+ position: absolute;
1708
+ display: block;
1709
+ height: ${c}px;
1710
+ left: ${h}px;
1711
+ top: ${u}px;
1712
+ width: ${a}px;
1713
+ z-index: ${this.render.getSettings().startZIndex + 1};`;
1714
+ }
1715
+ getElement() {
1716
+ return this.element;
1717
+ }
1718
+ load() {
1719
+ this.isLoad = !0;
1720
+ }
1721
+ setOrientation(i) {
1722
+ super.setOrientation(i), this.element.classList.remove("--left", "--right"), this.element.classList.add(i === 1 ? "--right" : "--left");
1723
+ }
1724
+ setDrawingDensity(i) {
1725
+ this.element.classList.remove("--soft", "--hard"), this.element.classList.add("--" + i), super.setDrawingDensity(i);
1726
+ }
1727
+ }
1728
+ class S extends l {
1729
+ constructor(i, n, a, c) {
1730
+ super(i, n), this.element = a, this.pagesElement = c;
1731
+ }
1732
+ load() {
1733
+ for (const i of this.pagesElement) {
1734
+ const n = new x(this.render, i, i.dataset.density === "hard" ? "hard" : "soft");
1735
+ n.load(), this.pages.push(n);
1736
+ }
1737
+ this.createSpread();
1738
+ }
1739
+ }
1740
+ class b {
1741
+ constructor(i, n, a, c) {
1742
+ this.direction = i, this.corner = n, this.topIntersectPoint = null, this.sideIntersectPoint = null, this.bottomIntersectPoint = null, this.pageWidth = parseInt(a, 10), this.pageHeight = parseInt(c, 10);
1743
+ }
1744
+ calc(i) {
1745
+ try {
1746
+ return this.position = this.calcAngleAndPosition(i), this.calculateIntersectPoint(this.position), !0;
1747
+ } catch {
1748
+ return !1;
1749
+ }
1750
+ }
1751
+ getFlippingClipArea() {
1752
+ const i = [];
1753
+ let n = !1;
1754
+ return i.push(this.rect.topLeft), i.push(this.topIntersectPoint), this.sideIntersectPoint === null ? n = !0 : (i.push(this.sideIntersectPoint), this.bottomIntersectPoint === null && (n = !1)), i.push(this.bottomIntersectPoint), (n || this.corner === "bottom") && i.push(this.rect.bottomLeft), i;
1755
+ }
1756
+ getBottomClipArea() {
1757
+ const i = [];
1758
+ return i.push(this.topIntersectPoint), this.corner === "top" ? i.push({ x: this.pageWidth, y: 0 }) : (this.topIntersectPoint !== null && i.push({ x: this.pageWidth, y: 0 }), i.push({ x: this.pageWidth, y: this.pageHeight })), this.sideIntersectPoint !== null ? p.GetDistanceBetweenTwoPoint(this.sideIntersectPoint, this.topIntersectPoint) >= 10 && i.push(this.sideIntersectPoint) : this.corner === "top" && i.push({ x: this.pageWidth, y: this.pageHeight }), i.push(this.bottomIntersectPoint), i.push(this.topIntersectPoint), i;
1759
+ }
1760
+ getAngle() {
1761
+ return this.direction === 0 ? -this.angle : this.angle;
1762
+ }
1763
+ getRect() {
1764
+ return this.rect;
1765
+ }
1766
+ getPosition() {
1767
+ return this.position;
1768
+ }
1769
+ getActiveCorner() {
1770
+ return this.direction === 0 ? this.rect.topLeft : this.rect.topRight;
1771
+ }
1772
+ getDirection() {
1773
+ return this.direction;
1774
+ }
1775
+ getFlippingProgress() {
1776
+ return Math.abs((this.position.x - this.pageWidth) / (2 * this.pageWidth) * 100);
1777
+ }
1778
+ getCorner() {
1779
+ return this.corner;
1780
+ }
1781
+ getBottomPagePosition() {
1782
+ return this.direction === 1 ? { x: this.pageWidth, y: 0 } : { x: 0, y: 0 };
1783
+ }
1784
+ getShadowStartPoint() {
1785
+ return this.corner === "top" ? this.topIntersectPoint : this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.topIntersectPoint;
1786
+ }
1787
+ getShadowAngle() {
1788
+ const i = p.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(), [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]);
1789
+ return this.direction === 0 ? i : Math.PI - i;
1790
+ }
1791
+ calcAngleAndPosition(i) {
1792
+ let n = i;
1793
+ if (this.updateAngleAndGeometry(n), n = this.corner === "top" ? this.checkPositionAtCenterLine(n, { x: 0, y: 0 }, { x: 0, y: this.pageHeight }) : this.checkPositionAtCenterLine(n, { x: 0, y: this.pageHeight }, { x: 0, y: 0 }), Math.abs(n.x - this.pageWidth) < 1 && Math.abs(n.y) < 1) throw new Error("Point is too small");
1794
+ return n;
1795
+ }
1796
+ updateAngleAndGeometry(i) {
1797
+ this.angle = this.calculateAngle(i), this.rect = this.getPageRect(i);
1798
+ }
1799
+ calculateAngle(i) {
1800
+ const n = this.pageWidth - i.x + 1, a = this.corner === "bottom" ? this.pageHeight - i.y : i.y;
1801
+ let c = 2 * Math.acos(n / Math.sqrt(a * a + n * n));
1802
+ a < 0 && (c = -c);
1803
+ const h = Math.PI - c;
1804
+ if (!isFinite(c) || h >= 0 && h < 3e-3) throw new Error("The G point is too small");
1805
+ return this.corner === "bottom" && (c = -c), c;
1806
+ }
1807
+ getPageRect(i) {
1808
+ return this.corner === "top" ? this.getRectFromBasePoint([{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }, { x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }], i) : this.getRectFromBasePoint([{ x: 0, y: -this.pageHeight }, { x: this.pageWidth, y: -this.pageHeight }, { x: 0, y: 0 }, { x: this.pageWidth, y: 0 }], i);
1809
+ }
1810
+ getRectFromBasePoint(i, n) {
1811
+ return { topLeft: this.getRotatedPoint(i[0], n), topRight: this.getRotatedPoint(i[1], n), bottomLeft: this.getRotatedPoint(i[2], n), bottomRight: this.getRotatedPoint(i[3], n) };
1812
+ }
1813
+ getRotatedPoint(i, n) {
1814
+ return { x: i.x * Math.cos(this.angle) + i.y * Math.sin(this.angle) + n.x, y: i.y * Math.cos(this.angle) - i.x * Math.sin(this.angle) + n.y };
1815
+ }
1816
+ calculateIntersectPoint(i) {
1817
+ const n = { left: -1, top: -1, width: this.pageWidth + 2, height: this.pageHeight + 2 };
1818
+ this.corner === "top" ? (this.topIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [i, this.rect.topRight], [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]), this.sideIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [i, this.rect.bottomLeft], [{ x: this.pageWidth, y: 0 }, { x: this.pageWidth, y: this.pageHeight }]), this.bottomIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [this.rect.bottomLeft, this.rect.bottomRight], [{ x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }])) : (this.topIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [this.rect.topLeft, this.rect.topRight], [{ x: 0, y: 0 }, { x: this.pageWidth, y: 0 }]), this.sideIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [i, this.rect.topLeft], [{ x: this.pageWidth, y: 0 }, { x: this.pageWidth, y: this.pageHeight }]), this.bottomIntersectPoint = p.GetIntersectBetweenTwoSegment(n, [this.rect.bottomLeft, this.rect.bottomRight], [{ x: 0, y: this.pageHeight }, { x: this.pageWidth, y: this.pageHeight }]));
1819
+ }
1820
+ checkPositionAtCenterLine(i, n, a) {
1821
+ let c = i;
1822
+ const h = p.LimitPointToCircle(n, this.pageWidth, c);
1823
+ c !== h && (c = h, this.updateAngleAndGeometry(c));
1824
+ const u = Math.sqrt(Math.pow(this.pageWidth, 2) + Math.pow(this.pageHeight, 2));
1825
+ let v = this.rect.bottomRight, y = this.rect.topLeft;
1826
+ if (this.corner === "bottom" && (v = this.rect.topRight, y = this.rect.bottomLeft), v.x <= 0) {
1827
+ const E = p.LimitPointToCircle(a, u, y);
1828
+ E !== c && (c = E, this.updateAngleAndGeometry(c));
1829
+ }
1830
+ return c;
1831
+ }
1832
+ getSegmentToShadowLine() {
1833
+ const i = this.getShadowStartPoint();
1834
+ return [i, i !== this.sideIntersectPoint && this.sideIntersectPoint !== null ? this.sideIntersectPoint : this.bottomIntersectPoint];
1835
+ }
1836
+ }
1837
+ class D {
1838
+ constructor(i, n) {
1839
+ this.flippingPage = null, this.bottomPage = null, this.calc = null, this.state = "read", this.render = i, this.app = n;
1840
+ }
1841
+ fold(i) {
1842
+ this.setState("user_fold"), this.calc === null && this.start(i), this.do(this.render.convertToPage(i));
1843
+ }
1844
+ flip(i) {
1845
+ if (this.app.getSettings().disableFlipByClick && !this.isPointOnCorners(i) || (this.calc !== null && this.render.finishAnimation(), !this.start(i))) return;
1846
+ const n = this.getBoundsRect();
1847
+ this.setState("flipping");
1848
+ const a = n.height / 10, c = this.calc.getCorner() === "bottom" ? n.height - a : a, h = this.calc.getCorner() === "bottom" ? n.height : 0;
1849
+ this.calc.calc({ x: n.pageWidth - a, y: c }), this.animateFlippingTo({ x: n.pageWidth - a, y: c }, { x: -n.pageWidth, y: h }, !0);
1850
+ }
1851
+ start(i) {
1852
+ this.reset();
1853
+ const n = this.render.convertToBook(i), a = this.getBoundsRect(), c = this.getDirectionByPoint(n), h = n.y >= a.height / 2 ? "bottom" : "top";
1854
+ if (!this.checkDirection(c)) return !1;
1855
+ try {
1856
+ if (this.flippingPage = this.app.getPageCollection().getFlippingPage(c), this.bottomPage = this.app.getPageCollection().getBottomPage(c), this.render.getOrientation() === "landscape") if (c === 1) {
1857
+ const u = this.app.getPageCollection().nextBy(this.flippingPage);
1858
+ u !== null && this.flippingPage.getDensity() !== u.getDensity() && (this.flippingPage.setDrawingDensity("hard"), u.setDrawingDensity("hard"));
1859
+ } else {
1860
+ const u = this.app.getPageCollection().prevBy(this.flippingPage);
1861
+ u !== null && this.flippingPage.getDensity() !== u.getDensity() && (this.flippingPage.setDrawingDensity("hard"), u.setDrawingDensity("hard"));
1862
+ }
1863
+ return this.render.setDirection(c), this.calc = new b(c, h, a.pageWidth.toString(10), a.height.toString(10)), !0;
1864
+ } catch {
1865
+ return !1;
1866
+ }
1867
+ }
1868
+ do(i) {
1869
+ if (this.calc !== null && this.calc.calc(i)) {
1870
+ const n = this.calc.getFlippingProgress();
1871
+ this.bottomPage.setArea(this.calc.getBottomClipArea()), this.bottomPage.setPosition(this.calc.getBottomPagePosition()), this.bottomPage.setAngle(0), this.bottomPage.setHardAngle(0), this.flippingPage.setArea(this.calc.getFlippingClipArea()), this.flippingPage.setPosition(this.calc.getActiveCorner()), this.flippingPage.setAngle(this.calc.getAngle()), this.calc.getDirection() === 0 ? this.flippingPage.setHardAngle(90 * (200 - 2 * n) / 100) : this.flippingPage.setHardAngle(-90 * (200 - 2 * n) / 100), this.render.setPageRect(this.calc.getRect()), this.render.setBottomPage(this.bottomPage), this.render.setFlippingPage(this.flippingPage), this.render.setShadowData(this.calc.getShadowStartPoint(), this.calc.getShadowAngle(), n, this.calc.getDirection());
1872
+ }
1873
+ }
1874
+ flipToPage(i, n) {
1875
+ const a = this.app.getPageCollection().getCurrentSpreadIndex(), c = this.app.getPageCollection().getSpreadIndexByPage(i);
1876
+ try {
1877
+ c > a && (this.app.getPageCollection().setCurrentSpreadIndex(c - 1), this.flipNext(n)), c < a && (this.app.getPageCollection().setCurrentSpreadIndex(c + 1), this.flipPrev(n));
1878
+ } catch {
1879
+ }
1880
+ }
1881
+ flipNext(i) {
1882
+ this.flip({ x: this.render.getRect().left + 2 * this.render.getRect().pageWidth - 10, y: i === "top" ? 1 : this.render.getRect().height - 2 });
1883
+ }
1884
+ flipPrev(i) {
1885
+ this.flip({ x: 10, y: i === "top" ? 1 : this.render.getRect().height - 2 });
1886
+ }
1887
+ stopMove() {
1888
+ if (this.calc === null) return;
1889
+ const i = this.calc.getPosition(), n = this.getBoundsRect(), a = this.calc.getCorner() === "bottom" ? n.height : 0;
1890
+ i.x <= 0 ? this.animateFlippingTo(i, { x: -n.pageWidth, y: a }, !0) : this.animateFlippingTo(i, { x: n.pageWidth, y: a }, !1);
1891
+ }
1892
+ showCorner(i) {
1893
+ if (!this.checkState("read", "fold_corner")) return;
1894
+ const n = this.getBoundsRect(), a = n.pageWidth;
1895
+ if (this.isPointOnCorners(i)) if (this.calc === null) {
1896
+ if (!this.start(i)) return;
1897
+ this.setState("fold_corner"), this.calc.calc({ x: a - 1, y: 1 });
1898
+ const c = 50, h = this.calc.getCorner() === "bottom" ? n.height - 1 : 1, u = this.calc.getCorner() === "bottom" ? n.height - c : c;
1899
+ this.animateFlippingTo({ x: a - 1, y: h }, { x: a - c, y: u }, !1, !1);
1900
+ } else this.do(this.render.convertToPage(i));
1901
+ else this.setState("read"), this.render.finishAnimation(), this.stopMove();
1902
+ }
1903
+ animateFlippingTo(i, n, a, c = !0) {
1904
+ const h = p.GetCordsFromTwoPoint(i, n), u = [];
1905
+ for (const y of h) u.push(() => this.do(y));
1906
+ const v = this.getAnimationDuration(h.length);
1907
+ this.render.startAnimation(u, v, () => {
1908
+ this.calc && (a && (this.calc.getDirection() === 1 ? this.app.turnToPrevPage() : this.app.turnToNextPage()), c && (this.render.setBottomPage(null), this.render.setFlippingPage(null), this.render.clearShadow(), this.setState("read"), this.reset()));
1909
+ });
1910
+ }
1911
+ getCalculation() {
1912
+ return this.calc;
1913
+ }
1914
+ getState() {
1915
+ return this.state;
1916
+ }
1917
+ setState(i) {
1918
+ this.state !== i && (this.app.updateState(i), this.state = i);
1919
+ }
1920
+ getDirectionByPoint(i) {
1921
+ const n = this.getBoundsRect();
1922
+ if (this.render.getOrientation() === "portrait") {
1923
+ if (i.x - n.pageWidth <= n.width / 5) return 1;
1924
+ } else if (i.x < n.width / 2) return 1;
1925
+ return 0;
1926
+ }
1927
+ getAnimationDuration(i) {
1928
+ const n = this.app.getSettings().flippingTime;
1929
+ return i >= 1e3 ? n : i / 1e3 * n;
1930
+ }
1931
+ checkDirection(i) {
1932
+ return i === 0 ? this.app.getCurrentPageIndex() < this.app.getPageCount() - 1 : this.app.getCurrentPageIndex() >= 1;
1933
+ }
1934
+ reset() {
1935
+ this.calc = null, this.flippingPage = null, this.bottomPage = null;
1936
+ }
1937
+ getBoundsRect() {
1938
+ return this.render.getRect();
1939
+ }
1940
+ checkState(...i) {
1941
+ for (const n of i) if (this.state === n) return !0;
1942
+ return !1;
1943
+ }
1944
+ isPointOnCorners(i) {
1945
+ const n = this.getBoundsRect(), a = n.pageWidth, c = Math.sqrt(Math.pow(a, 2) + Math.pow(n.height, 2)) / 5, h = this.render.convertToBook(i);
1946
+ return h.x > 0 && h.y > 0 && h.x < n.width && h.y < n.height && (h.x < c || h.x > n.width - c) && (h.y < c || h.y > n.height - c);
1947
+ }
1948
+ }
1949
+ class $ {
1950
+ constructor(i, n) {
1951
+ this.leftPage = null, this.rightPage = null, this.flippingPage = null, this.bottomPage = null, this.direction = null, this.orientation = null, this.shadow = null, this.animation = null, this.pageRect = null, this.boundsRect = null, this.timer = 0, this.safari = !1, this.setting = n, this.app = i;
1952
+ const a = new RegExp("Version\\/[\\d\\.]+.*Safari/");
1953
+ this.safari = a.exec(window.navigator.userAgent) !== null;
1954
+ }
1955
+ render(i) {
1956
+ if (this.animation !== null) {
1957
+ const n = Math.round((i - this.animation.startedAt) / this.animation.durationFrame);
1958
+ n < this.animation.frames.length ? this.animation.frames[n]() : (this.animation.onAnimateEnd(), this.animation = null);
1959
+ }
1960
+ this.timer = i, this.drawFrame();
1961
+ }
1962
+ start() {
1963
+ this.update();
1964
+ const i = (n) => {
1965
+ this.render(n), requestAnimationFrame(i);
1966
+ };
1967
+ requestAnimationFrame(i);
1968
+ }
1969
+ startAnimation(i, n, a) {
1970
+ this.finishAnimation(), this.animation = { frames: i, duration: n, durationFrame: n / i.length, onAnimateEnd: a, startedAt: this.timer };
1971
+ }
1972
+ finishAnimation() {
1973
+ this.animation !== null && (this.animation.frames[this.animation.frames.length - 1](), this.animation.onAnimateEnd !== null && this.animation.onAnimateEnd()), this.animation = null;
1974
+ }
1975
+ update() {
1976
+ this.boundsRect = null;
1977
+ const i = this.calculateBoundsRect();
1978
+ this.orientation !== i && (this.orientation = i, this.app.updateOrientation(i));
1979
+ }
1980
+ calculateBoundsRect() {
1981
+ let i = "landscape";
1982
+ const n = this.getBlockWidth(), a = n / 2, c = this.getBlockHeight() / 2, h = this.setting.width / this.setting.height;
1983
+ let u = this.setting.width, v = this.setting.height, y = a - u;
1984
+ return this.setting.size === "stretch" ? (n < 2 * this.setting.minWidth && this.app.getSettings().usePortrait && (i = "portrait"), u = i === "portrait" ? this.getBlockWidth() : this.getBlockWidth() / 2, u > this.setting.maxWidth && (u = this.setting.maxWidth), v = u / h, v > this.getBlockHeight() && (v = this.getBlockHeight(), u = v * h), y = i === "portrait" ? a - u / 2 - u : a - u) : n < 2 * u && this.app.getSettings().usePortrait && (i = "portrait", y = a - u / 2 - u), this.boundsRect = { left: y, top: c - v / 2, width: 2 * u, height: v, pageWidth: u }, i;
1985
+ }
1986
+ setShadowData(i, n, a, c) {
1987
+ if (!this.app.getSettings().drawShadow) return;
1988
+ const h = 100 * this.getSettings().maxShadowOpacity;
1989
+ this.shadow = { pos: i, angle: n, width: 3 * this.getRect().pageWidth / 4 * a / 100, opacity: (100 - a) * h / 100 / 100, direction: c, progress: 2 * a };
1990
+ }
1991
+ clearShadow() {
1992
+ this.shadow = null;
1993
+ }
1994
+ getBlockWidth() {
1995
+ return this.app.getUI().getDistElement().offsetWidth;
1996
+ }
1997
+ getBlockHeight() {
1998
+ return this.app.getUI().getDistElement().offsetHeight;
1999
+ }
2000
+ getDirection() {
2001
+ return this.direction;
2002
+ }
2003
+ getRect() {
2004
+ return this.boundsRect === null && this.calculateBoundsRect(), this.boundsRect;
2005
+ }
2006
+ getSettings() {
2007
+ return this.app.getSettings();
2008
+ }
2009
+ getOrientation() {
2010
+ return this.orientation;
2011
+ }
2012
+ setPageRect(i) {
2013
+ this.pageRect = i;
2014
+ }
2015
+ setDirection(i) {
2016
+ this.direction = i;
2017
+ }
2018
+ setRightPage(i) {
2019
+ i !== null && i.setOrientation(1), this.rightPage = i;
2020
+ }
2021
+ setLeftPage(i) {
2022
+ i !== null && i.setOrientation(0), this.leftPage = i;
2023
+ }
2024
+ setBottomPage(i) {
2025
+ i !== null && i.setOrientation(this.direction === 1 ? 0 : 1), this.bottomPage = i;
2026
+ }
2027
+ setFlippingPage(i) {
2028
+ i !== null && i.setOrientation(this.direction === 0 && this.orientation !== "portrait" ? 0 : 1), this.flippingPage = i;
2029
+ }
2030
+ convertToBook(i) {
2031
+ const n = this.getRect();
2032
+ return { x: i.x - n.left, y: i.y - n.top };
2033
+ }
2034
+ isSafari() {
2035
+ return this.safari;
2036
+ }
2037
+ convertToPage(i, n) {
2038
+ n || (n = this.direction);
2039
+ const a = this.getRect();
2040
+ return { x: n === 0 ? i.x - a.left - a.width / 2 : a.width / 2 - i.x + a.left, y: i.y - a.top };
2041
+ }
2042
+ convertToGlobal(i, n) {
2043
+ if (n || (n = this.direction), i == null) return null;
2044
+ const a = this.getRect();
2045
+ return { x: n === 0 ? i.x + a.left + a.width / 2 : a.width / 2 - i.x + a.left, y: i.y + a.top };
2046
+ }
2047
+ convertRectToGlobal(i, n) {
2048
+ return n || (n = this.direction), { topLeft: this.convertToGlobal(i.topLeft, n), topRight: this.convertToGlobal(i.topRight, n), bottomLeft: this.convertToGlobal(i.bottomLeft, n), bottomRight: this.convertToGlobal(i.bottomRight, n) };
2049
+ }
2050
+ }
2051
+ class k extends $ {
2052
+ constructor(i, n, a) {
2053
+ super(i, n), this.canvas = a, this.ctx = a.getContext("2d");
2054
+ }
2055
+ getContext() {
2056
+ return this.ctx;
2057
+ }
2058
+ reload() {
2059
+ }
2060
+ drawFrame() {
2061
+ this.clear(), this.orientation !== "portrait" && this.leftPage != null && this.leftPage.simpleDraw(0), this.rightPage != null && this.rightPage.simpleDraw(1), this.bottomPage != null && this.bottomPage.draw(), this.drawBookShadow(), this.flippingPage != null && this.flippingPage.draw(), this.shadow != null && (this.drawOuterShadow(), this.drawInnerShadow());
2062
+ const i = this.getRect();
2063
+ this.orientation === "portrait" && (this.ctx.beginPath(), this.ctx.rect(i.left + i.pageWidth, i.top, i.width, i.height), this.ctx.clip());
2064
+ }
2065
+ drawBookShadow() {
2066
+ const i = this.getRect();
2067
+ this.ctx.save(), this.ctx.beginPath();
2068
+ const n = i.width / 20;
2069
+ this.ctx.rect(i.left, i.top, i.width, i.height);
2070
+ const a = { x: i.left + i.width / 2 - n / 2, y: 0 };
2071
+ this.ctx.translate(a.x, a.y);
2072
+ const c = this.ctx.createLinearGradient(0, 0, n, 0);
2073
+ c.addColorStop(0, "rgba(0, 0, 0, 0)"), c.addColorStop(0.4, "rgba(0, 0, 0, 0.2)"), c.addColorStop(0.49, "rgba(0, 0, 0, 0.1)"), c.addColorStop(0.5, "rgba(0, 0, 0, 0.5)"), c.addColorStop(0.51, "rgba(0, 0, 0, 0.4)"), c.addColorStop(1, "rgba(0, 0, 0, 0)"), this.ctx.clip(), this.ctx.fillStyle = c, this.ctx.fillRect(0, 0, n, 2 * i.height), this.ctx.restore();
2074
+ }
2075
+ drawOuterShadow() {
2076
+ const i = this.getRect();
2077
+ this.ctx.save(), this.ctx.beginPath(), this.ctx.rect(i.left, i.top, i.width, i.height);
2078
+ const n = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y });
2079
+ this.ctx.translate(n.x, n.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
2080
+ const a = this.ctx.createLinearGradient(0, 0, this.shadow.width, 0);
2081
+ this.shadow.direction === 0 ? (this.ctx.translate(0, -100), a.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), a.addColorStop(1, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(-this.shadow.width, -100), a.addColorStop(0, "rgba(0, 0, 0, 0)"), a.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")")), this.ctx.clip(), this.ctx.fillStyle = a, this.ctx.fillRect(0, 0, this.shadow.width, 2 * i.height), this.ctx.restore();
2082
+ }
2083
+ drawInnerShadow() {
2084
+ const i = this.getRect();
2085
+ this.ctx.save(), this.ctx.beginPath();
2086
+ const n = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y }), a = this.convertRectToGlobal(this.pageRect);
2087
+ this.ctx.moveTo(a.topLeft.x, a.topLeft.y), this.ctx.lineTo(a.topRight.x, a.topRight.y), this.ctx.lineTo(a.bottomRight.x, a.bottomRight.y), this.ctx.lineTo(a.bottomLeft.x, a.bottomLeft.y), this.ctx.translate(n.x, n.y), this.ctx.rotate(Math.PI + this.shadow.angle + Math.PI / 2);
2088
+ const c = 3 * this.shadow.width / 4, h = this.ctx.createLinearGradient(0, 0, c, 0);
2089
+ this.shadow.direction === 0 ? (this.ctx.translate(-c, -100), h.addColorStop(1, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), h.addColorStop(0.9, "rgba(0, 0, 0, 0.05)"), h.addColorStop(0.7, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), h.addColorStop(0, "rgba(0, 0, 0, 0)")) : (this.ctx.translate(0, -100), h.addColorStop(0, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), h.addColorStop(0.1, "rgba(0, 0, 0, 0.05)"), h.addColorStop(0.3, "rgba(0, 0, 0, " + this.shadow.opacity + ")"), h.addColorStop(1, "rgba(0, 0, 0, 0)")), this.ctx.clip(), this.ctx.fillStyle = h, this.ctx.fillRect(0, 0, c, 2 * i.height), this.ctx.restore();
2090
+ }
2091
+ clear() {
2092
+ this.ctx.fillStyle = "white", this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
2093
+ }
2094
+ }
2095
+ class A {
2096
+ constructor(i, n, a) {
2097
+ this.touchPoint = null, this.swipeTimeout = 250, this.onResize = () => {
2098
+ this.update();
2099
+ }, this.onMouseDown = (h) => {
2100
+ if (this.checkTarget(h.target)) {
2101
+ const u = this.getMousePos(h.clientX, h.clientY);
2102
+ this.app.startUserTouch(u), h.preventDefault();
2103
+ }
2104
+ }, this.onTouchStart = (h) => {
2105
+ if (this.checkTarget(h.target) && h.changedTouches.length > 0) {
2106
+ const u = h.changedTouches[0], v = this.getMousePos(u.clientX, u.clientY);
2107
+ this.touchPoint = { point: v, time: Date.now() }, setTimeout(() => {
2108
+ this.touchPoint !== null && this.app.startUserTouch(v);
2109
+ }, this.swipeTimeout), this.app.getSettings().mobileScrollSupport || h.preventDefault();
2110
+ }
2111
+ }, this.onMouseUp = (h) => {
2112
+ const u = this.getMousePos(h.clientX, h.clientY);
2113
+ this.app.userStop(u);
2114
+ }, this.onMouseMove = (h) => {
2115
+ const u = this.getMousePos(h.clientX, h.clientY);
2116
+ this.app.userMove(u, !1);
2117
+ }, this.onTouchMove = (h) => {
2118
+ if (h.changedTouches.length > 0) {
2119
+ const u = h.changedTouches[0], v = this.getMousePos(u.clientX, u.clientY);
2120
+ this.app.getSettings().mobileScrollSupport ? (this.touchPoint !== null && (Math.abs(this.touchPoint.point.x - v.x) > 10 || this.app.getState() !== "read") && h.cancelable && this.app.userMove(v, !0), this.app.getState() !== "read" && h.preventDefault()) : this.app.userMove(v, !0);
2121
+ }
2122
+ }, this.onTouchEnd = (h) => {
2123
+ if (h.changedTouches.length > 0) {
2124
+ const u = h.changedTouches[0], v = this.getMousePos(u.clientX, u.clientY);
2125
+ let y = !1;
2126
+ if (this.touchPoint !== null) {
2127
+ const E = v.x - this.touchPoint.point.x, R = Math.abs(v.y - this.touchPoint.point.y);
2128
+ Math.abs(E) > this.swipeDistance && R < 2 * this.swipeDistance && Date.now() - this.touchPoint.time < this.swipeTimeout && (E > 0 ? this.app.flipPrev(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom") : this.app.flipNext(this.touchPoint.point.y < this.app.getRender().getRect().height / 2 ? "top" : "bottom"), y = !0), this.touchPoint = null;
2129
+ }
2130
+ this.app.userStop(v, y);
2131
+ }
2132
+ }, this.parentElement = i, i.classList.add("stf__parent"), i.insertAdjacentHTML("afterbegin", '<div class="stf__wrapper"></div>'), this.wrapper = i.querySelector(".stf__wrapper"), this.app = n;
2133
+ const c = this.app.getSettings().usePortrait ? 1 : 2;
2134
+ i.style.minWidth = a.minWidth * c + "px", i.style.minHeight = a.minHeight + "px", a.size === "fixed" && (i.style.minWidth = a.width * c + "px", i.style.minHeight = a.height + "px"), a.autoSize && (i.style.width = "100%", i.style.maxWidth = 2 * a.maxWidth + "px"), i.style.display = "block", window.addEventListener("resize", this.onResize, !1), this.swipeDistance = a.swipeDistance;
2135
+ }
2136
+ destroy() {
2137
+ this.app.getSettings().useMouseEvents && this.removeHandlers(), this.distElement.remove(), this.wrapper.remove();
2138
+ }
2139
+ getDistElement() {
2140
+ return this.distElement;
2141
+ }
2142
+ getWrapper() {
2143
+ return this.wrapper;
2144
+ }
2145
+ setOrientationStyle(i) {
2146
+ this.wrapper.classList.remove("--portrait", "--landscape"), i === "portrait" ? (this.app.getSettings().autoSize && (this.wrapper.style.paddingBottom = this.app.getSettings().height / this.app.getSettings().width * 100 + "%"), this.wrapper.classList.add("--portrait")) : (this.app.getSettings().autoSize && (this.wrapper.style.paddingBottom = this.app.getSettings().height / (2 * this.app.getSettings().width) * 100 + "%"), this.wrapper.classList.add("--landscape")), this.update();
2147
+ }
2148
+ removeHandlers() {
2149
+ window.removeEventListener("resize", this.onResize), this.distElement.removeEventListener("mousedown", this.onMouseDown), this.distElement.removeEventListener("touchstart", this.onTouchStart), window.removeEventListener("mousemove", this.onMouseMove), window.removeEventListener("touchmove", this.onTouchMove), window.removeEventListener("mouseup", this.onMouseUp), window.removeEventListener("touchend", this.onTouchEnd);
2150
+ }
2151
+ setHandlers() {
2152
+ window.addEventListener("resize", this.onResize, !1), this.app.getSettings().useMouseEvents && (this.distElement.addEventListener("mousedown", this.onMouseDown), this.distElement.addEventListener("touchstart", this.onTouchStart), window.addEventListener("mousemove", this.onMouseMove), window.addEventListener("touchmove", this.onTouchMove, { passive: !this.app.getSettings().mobileScrollSupport }), window.addEventListener("mouseup", this.onMouseUp), window.addEventListener("touchend", this.onTouchEnd));
2153
+ }
2154
+ getMousePos(i, n) {
2155
+ const a = this.distElement.getBoundingClientRect();
2156
+ return { x: i - a.left, y: n - a.top };
2157
+ }
2158
+ checkTarget(i) {
2159
+ return !this.app.getSettings().clickEventForward || !["a", "button"].includes(i.tagName.toLowerCase());
2160
+ }
2161
+ }
2162
+ class O extends A {
2163
+ constructor(i, n, a, c) {
2164
+ super(i, n, a), this.wrapper.insertAdjacentHTML("afterbegin", '<div class="stf__block"></div>'), this.distElement = i.querySelector(".stf__block"), this.items = c;
2165
+ for (const h of c) this.distElement.appendChild(h);
2166
+ this.setHandlers();
2167
+ }
2168
+ clear() {
2169
+ for (const i of this.items) this.parentElement.appendChild(i);
2170
+ }
2171
+ updateItems(i) {
2172
+ this.removeHandlers(), this.distElement.innerHTML = "";
2173
+ for (const n of i) this.distElement.appendChild(n);
2174
+ this.items = i, this.setHandlers();
2175
+ }
2176
+ update() {
2177
+ this.app.getRender().update();
2178
+ }
2179
+ }
2180
+ class U extends A {
2181
+ constructor(i, n, a) {
2182
+ super(i, n, a), this.wrapper.innerHTML = '<canvas class="stf__canvas"></canvas>', this.canvas = i.querySelectorAll("canvas")[0], this.distElement = this.canvas, this.resizeCanvas(), this.setHandlers();
2183
+ }
2184
+ resizeCanvas() {
2185
+ const i = getComputedStyle(this.canvas), n = parseInt(i.getPropertyValue("width"), 10), a = parseInt(i.getPropertyValue("height"), 10);
2186
+ this.canvas.width = n, this.canvas.height = a;
2187
+ }
2188
+ getCanvas() {
2189
+ return this.canvas;
2190
+ }
2191
+ update() {
2192
+ this.resizeCanvas(), this.app.getRender().update();
2193
+ }
2194
+ }
2195
+ class H extends $ {
2196
+ constructor(i, n, a) {
2197
+ super(i, n), this.outerShadow = null, this.innerShadow = null, this.hardShadow = null, this.hardInnerShadow = null, this.element = a, this.createShadows();
2198
+ }
2199
+ createShadows() {
2200
+ this.element.insertAdjacentHTML("beforeend", `<div class="stf__outerShadow"></div>
2201
+ <div class="stf__innerShadow"></div>
2202
+ <div class="stf__hardShadow"></div>
2203
+ <div class="stf__hardInnerShadow"></div>`), this.outerShadow = this.element.querySelector(".stf__outerShadow"), this.innerShadow = this.element.querySelector(".stf__innerShadow"), this.hardShadow = this.element.querySelector(".stf__hardShadow"), this.hardInnerShadow = this.element.querySelector(".stf__hardInnerShadow");
2204
+ }
2205
+ clearShadow() {
2206
+ super.clearShadow(), this.outerShadow.style.cssText = "display: none", this.innerShadow.style.cssText = "display: none", this.hardShadow.style.cssText = "display: none", this.hardInnerShadow.style.cssText = "display: none";
2207
+ }
2208
+ reload() {
2209
+ this.element.querySelector(".stf__outerShadow") || this.createShadows();
2210
+ }
2211
+ drawHardInnerShadow() {
2212
+ const i = this.getRect(), n = this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress;
2213
+ let a = (100 - n) * (2.5 * i.pageWidth) / 100 + 20;
2214
+ a > i.pageWidth && (a = i.pageWidth);
2215
+ let c = `
2216
+ display: block;
2217
+ z-index: ${(this.getSettings().startZIndex + 5).toString(10)};
2218
+ width: ${a}px;
2219
+ height: ${i.height}px;
2220
+ background: linear-gradient(to right,
2221
+ rgba(0, 0, 0, ${this.shadow.opacity * n / 100}) 5%,
2222
+ rgba(0, 0, 0, 0) 100%);
2223
+ left: ${i.left + i.width / 2}px;
2224
+ transform-origin: 0 0;
2225
+ `;
2226
+ c += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? "transform: translate3d(0, 0, 0);" : "transform: translate3d(0, 0, 0) rotateY(180deg);", this.hardInnerShadow.style.cssText = c;
2227
+ }
2228
+ drawHardOuterShadow() {
2229
+ const i = this.getRect();
2230
+ let n = (100 - (this.shadow.progress > 100 ? 200 - this.shadow.progress : this.shadow.progress)) * (2.5 * i.pageWidth) / 100 + 20;
2231
+ n > i.pageWidth && (n = i.pageWidth);
2232
+ let a = `
2233
+ display: block;
2234
+ z-index: ${(this.getSettings().startZIndex + 4).toString(10)};
2235
+ width: ${n}px;
2236
+ height: ${i.height}px;
2237
+ background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
2238
+ left: ${i.left + i.width / 2}px;
2239
+ transform-origin: 0 0;
2240
+ `;
2241
+ a += this.getDirection() === 0 && this.shadow.progress > 100 || this.getDirection() === 1 && this.shadow.progress <= 100 ? "transform: translate3d(0, 0, 0) rotateY(180deg);" : "transform: translate3d(0, 0, 0);", this.hardShadow.style.cssText = a;
2242
+ }
2243
+ drawInnerShadow() {
2244
+ const i = this.getRect(), n = 3 * this.shadow.width / 4, a = this.getDirection() === 0 ? n : 0, c = this.getDirection() === 0 ? "to left" : "to right", h = this.convertToGlobal(this.shadow.pos), u = this.shadow.angle + 3 * Math.PI / 2, v = [this.pageRect.topLeft, this.pageRect.topRight, this.pageRect.bottomRight, this.pageRect.bottomLeft];
2245
+ let y = "polygon( ";
2246
+ for (const R of v) {
2247
+ let W = this.getDirection() === 1 ? { x: -R.x + this.shadow.pos.x, y: R.y - this.shadow.pos.y } : { x: R.x - this.shadow.pos.x, y: R.y - this.shadow.pos.y };
2248
+ W = p.GetRotatedPoint(W, { x: a, y: 100 }, u), y += W.x + "px " + W.y + "px, ";
2249
+ }
2250
+ y = y.slice(0, -2), y += ")";
2251
+ const E = `
2252
+ display: block;
2253
+ z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
2254
+ width: ${n}px;
2255
+ height: ${2 * i.height}px;
2256
+ background: linear-gradient(${c},
2257
+ rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
2258
+ rgba(0, 0, 0, 0.05) 15%,
2259
+ rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
2260
+ rgba(0, 0, 0, 0) 100%);
2261
+ transform-origin: ${a}px 100px;
2262
+ transform: translate3d(${h.x - a}px, ${h.y - 100}px, 0) rotate(${u}rad);
2263
+ clip-path: ${y};
2264
+ -webkit-clip-path: ${y};
2265
+ `;
2266
+ this.innerShadow.style.cssText = E;
2267
+ }
2268
+ drawOuterShadow() {
2269
+ const i = this.getRect(), n = this.convertToGlobal({ x: this.shadow.pos.x, y: this.shadow.pos.y }), a = this.shadow.angle + 3 * Math.PI / 2, c = this.getDirection() === 1 ? this.shadow.width : 0, h = this.getDirection() === 0 ? "to right" : "to left", u = [{ x: 0, y: 0 }, { x: i.pageWidth, y: 0 }, { x: i.pageWidth, y: i.height }, { x: 0, y: i.height }];
2270
+ let v = "polygon( ";
2271
+ for (const E of u) if (E !== null) {
2272
+ let R = this.getDirection() === 1 ? { x: -E.x + this.shadow.pos.x, y: E.y - this.shadow.pos.y } : { x: E.x - this.shadow.pos.x, y: E.y - this.shadow.pos.y };
2273
+ R = p.GetRotatedPoint(R, { x: c, y: 100 }, a), v += R.x + "px " + R.y + "px, ";
2274
+ }
2275
+ v = v.slice(0, -2), v += ")";
2276
+ const y = `
2277
+ display: block;
2278
+ z-index: ${(this.getSettings().startZIndex + 10).toString(10)};
2279
+ width: ${this.shadow.width}px;
2280
+ height: ${2 * i.height}px;
2281
+ background: linear-gradient(${h}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
2282
+ transform-origin: ${c}px 100px;
2283
+ transform: translate3d(${n.x - c}px, ${n.y - 100}px, 0) rotate(${a}rad);
2284
+ clip-path: ${v};
2285
+ -webkit-clip-path: ${v};
2286
+ `;
2287
+ this.outerShadow.style.cssText = y;
2288
+ }
2289
+ drawLeftPage() {
2290
+ this.orientation !== "portrait" && this.leftPage !== null && (this.direction === 1 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard" ? (this.leftPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.leftPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle()), this.leftPage.draw(this.flippingPage.getDrawingDensity())) : this.leftPage.simpleDraw(0));
2291
+ }
2292
+ drawRightPage() {
2293
+ this.rightPage !== null && (this.direction === 0 && this.flippingPage !== null && this.flippingPage.getDrawingDensity() === "hard" ? (this.rightPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.rightPage.setHardDrawingAngle(180 + this.flippingPage.getHardAngle()), this.rightPage.draw(this.flippingPage.getDrawingDensity())) : this.rightPage.simpleDraw(1));
2294
+ }
2295
+ drawBottomPage() {
2296
+ if (this.bottomPage === null) return;
2297
+ const i = this.flippingPage != null ? this.flippingPage.getDrawingDensity() : null;
2298
+ this.orientation === "portrait" && this.direction === 1 || (this.bottomPage.getElement().style.zIndex = (this.getSettings().startZIndex + 3).toString(10), this.bottomPage.draw(i));
2299
+ }
2300
+ drawFrame() {
2301
+ this.clear(), this.drawLeftPage(), this.drawRightPage(), this.drawBottomPage(), this.flippingPage != null && (this.flippingPage.getElement().style.zIndex = (this.getSettings().startZIndex + 5).toString(10), this.flippingPage.draw()), this.shadow != null && this.flippingPage !== null && (this.flippingPage.getDrawingDensity() === "soft" ? (this.drawOuterShadow(), this.drawInnerShadow()) : (this.drawHardOuterShadow(), this.drawHardInnerShadow()));
2302
+ }
2303
+ clear() {
2304
+ for (const i of this.app.getPageCollection().getPages()) i !== this.leftPage && i !== this.rightPage && i !== this.flippingPage && i !== this.bottomPage && (i.getElement().style.cssText = "display: none"), i.getTemporaryCopy() !== this.flippingPage && i.hideTemporaryCopy();
2305
+ }
2306
+ update() {
2307
+ super.update(), this.rightPage !== null && this.rightPage.setOrientation(1), this.leftPage !== null && this.leftPage.setOrientation(0);
2308
+ }
2309
+ }
2310
+ class N {
2311
+ constructor() {
2312
+ this._default = { startPage: 0, size: "fixed", width: 0, height: 0, minWidth: 0, maxWidth: 0, minHeight: 0, maxHeight: 0, drawShadow: !0, flippingTime: 1e3, usePortrait: !0, startZIndex: 0, autoSize: !0, maxShadowOpacity: 1, showCover: !1, mobileScrollSupport: !0, swipeDistance: 30, clickEventForward: !0, useMouseEvents: !0, showPageCorners: !0, disableFlipByClick: !1 };
2313
+ }
2314
+ getSettings(i) {
2315
+ const n = this._default;
2316
+ if (Object.assign(n, i), n.size !== "stretch" && n.size !== "fixed") throw new Error('Invalid size type. Available only "fixed" and "stretch" value');
2317
+ if (n.width <= 0 || n.height <= 0) throw new Error("Invalid width or height");
2318
+ if (n.flippingTime <= 0) throw new Error("Invalid flipping time");
2319
+ return n.size === "stretch" ? (n.minWidth <= 0 && (n.minWidth = 100), n.maxWidth < n.minWidth && (n.maxWidth = 2e3), n.minHeight <= 0 && (n.minHeight = 100), n.maxHeight < n.minHeight && (n.maxHeight = 2e3)) : (n.minWidth = n.width, n.maxWidth = n.width, n.minHeight = n.height, n.maxHeight = n.height), n;
2320
+ }
2321
+ }
2322
+ (function(f, i) {
2323
+ i === void 0 && (i = {});
2324
+ var n = i.insertAt;
2325
+ if (typeof document < "u") {
2326
+ var a = document.head || document.getElementsByTagName("head")[0], c = document.createElement("style");
2327
+ c.type = "text/css", n === "top" && a.firstChild ? a.insertBefore(c, a.firstChild) : a.appendChild(c), c.styleSheet ? c.styleSheet.cssText = f : c.appendChild(document.createTextNode(f));
2328
+ }
2329
+ })(`.stf__parent {
2330
+ position: relative;
2331
+ display: block;
2332
+ box-sizing: border-box;
2333
+ transform: translateZ(0);
2334
+
2335
+ -ms-touch-action: pan-y;
2336
+ touch-action: pan-y;
2337
+ }
2338
+
2339
+ .sft__wrapper {
2340
+ position: relative;
2341
+ width: 100%;
2342
+ box-sizing: border-box;
2343
+ }
2344
+
2345
+ .stf__parent canvas {
2346
+ position: absolute;
2347
+ width: 100%;
2348
+ height: 100%;
2349
+ left: 0;
2350
+ top: 0;
2351
+ }
2352
+
2353
+ .stf__block {
2354
+ position: absolute;
2355
+ width: 100%;
2356
+ height: 100%;
2357
+ box-sizing: border-box;
2358
+ perspective: 2000px;
2359
+ }
2360
+
2361
+ .stf__item {
2362
+ display: none;
2363
+ position: absolute;
2364
+ transform-style: preserve-3d;
2365
+ }
2366
+
2367
+ .stf__outerShadow {
2368
+ position: absolute;
2369
+ left: 0;
2370
+ top: 0;
2371
+ }
2372
+
2373
+ .stf__innerShadow {
2374
+ position: absolute;
2375
+ left: 0;
2376
+ top: 0;
2377
+ }
2378
+
2379
+ .stf__hardShadow {
2380
+ position: absolute;
2381
+ left: 0;
2382
+ top: 0;
2383
+ }
2384
+
2385
+ .stf__hardInnerShadow {
2386
+ position: absolute;
2387
+ left: 0;
2388
+ top: 0;
2389
+ }`), s.PageFlip = class extends class {
2390
+ constructor() {
2391
+ this.events = /* @__PURE__ */ new Map();
2392
+ }
2393
+ on(f, i) {
2394
+ return this.events.has(f) ? this.events.get(f).push(i) : this.events.set(f, [i]), this;
2395
+ }
2396
+ off(f) {
2397
+ this.events.delete(f);
2398
+ }
2399
+ trigger(f, i, n = null) {
2400
+ if (this.events.has(f)) for (const a of this.events.get(f)) a({ data: n, object: i });
2401
+ }
2402
+ } {
2403
+ constructor(f, i) {
2404
+ super(), this.isUserTouch = !1, this.isUserMove = !1, this.setting = null, this.pages = null, this.setting = new N().getSettings(i), this.block = f;
2405
+ }
2406
+ destroy() {
2407
+ this.ui.destroy(), this.block.remove();
2408
+ }
2409
+ update() {
2410
+ this.render.update(), this.pages.show();
2411
+ }
2412
+ loadFromImages(f) {
2413
+ this.ui = new U(this.block, this, this.setting);
2414
+ const i = this.ui.getCanvas();
2415
+ this.render = new k(this, this.setting, i), this.flipController = new D(this.render, this), this.pages = new d(this, this.render, f), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
2416
+ this.ui.update(), this.trigger("init", this, { page: this.setting.startPage, mode: this.render.getOrientation() });
2417
+ }, 1);
2418
+ }
2419
+ loadFromHTML(f) {
2420
+ this.ui = new O(this.block, this, this.setting, f), this.render = new H(this, this.setting, this.ui.getDistElement()), this.flipController = new D(this.render, this), this.pages = new S(this, this.render, this.ui.getDistElement(), f), this.pages.load(), this.render.start(), this.pages.show(this.setting.startPage), setTimeout(() => {
2421
+ this.ui.update(), this.trigger("init", this, { page: this.setting.startPage, mode: this.render.getOrientation() });
2422
+ }, 1);
2423
+ }
2424
+ updateFromImages(f) {
2425
+ const i = this.pages.getCurrentPageIndex();
2426
+ this.pages.destroy(), this.pages = new d(this, this.render, f), this.pages.load(), this.pages.show(i), this.trigger("update", this, { page: i, mode: this.render.getOrientation() });
2427
+ }
2428
+ updateFromHtml(f) {
2429
+ const i = this.pages.getCurrentPageIndex();
2430
+ this.pages.destroy(), this.pages = new S(this, this.render, this.ui.getDistElement(), f), this.pages.load(), this.ui.updateItems(f), this.render.reload(), this.pages.show(i), this.trigger("update", this, { page: i, mode: this.render.getOrientation() });
2431
+ }
2432
+ clear() {
2433
+ this.pages.destroy(), this.ui.clear();
2434
+ }
2435
+ turnToPrevPage() {
2436
+ this.pages.showPrev();
2437
+ }
2438
+ turnToNextPage() {
2439
+ this.pages.showNext();
2440
+ }
2441
+ turnToPage(f) {
2442
+ this.pages.show(f);
2443
+ }
2444
+ flipNext(f = "top") {
2445
+ this.flipController.flipNext(f);
2446
+ }
2447
+ flipPrev(f = "top") {
2448
+ this.flipController.flipPrev(f);
2449
+ }
2450
+ flip(f, i = "top") {
2451
+ this.flipController.flipToPage(f, i);
2452
+ }
2453
+ updateState(f) {
2454
+ this.trigger("changeState", this, f);
2455
+ }
2456
+ updatePageIndex(f) {
2457
+ this.trigger("flip", this, f);
2458
+ }
2459
+ updateOrientation(f) {
2460
+ this.ui.setOrientationStyle(f), this.update(), this.trigger("changeOrientation", this, f);
2461
+ }
2462
+ getPageCount() {
2463
+ return this.pages.getPageCount();
2464
+ }
2465
+ getCurrentPageIndex() {
2466
+ return this.pages.getCurrentPageIndex();
2467
+ }
2468
+ getPage(f) {
2469
+ return this.pages.getPage(f);
2470
+ }
2471
+ getRender() {
2472
+ return this.render;
2473
+ }
2474
+ getFlipController() {
2475
+ return this.flipController;
2476
+ }
2477
+ getOrientation() {
2478
+ return this.render.getOrientation();
2479
+ }
2480
+ getBoundsRect() {
2481
+ return this.render.getRect();
2482
+ }
2483
+ getSettings() {
2484
+ return this.setting;
2485
+ }
2486
+ getUI() {
2487
+ return this.ui;
2488
+ }
2489
+ getState() {
2490
+ return this.flipController.getState();
2491
+ }
2492
+ getPageCollection() {
2493
+ return this.pages;
2494
+ }
2495
+ startUserTouch(f) {
2496
+ this.mousePosition = f, this.isUserTouch = !0, this.isUserMove = !1;
2497
+ }
2498
+ userMove(f, i) {
2499
+ this.isUserTouch || i || !this.setting.showPageCorners ? this.isUserTouch && p.GetDistanceBetweenTwoPoint(this.mousePosition, f) > 5 && (this.isUserMove = !0, this.flipController.fold(f)) : this.flipController.showCorner(f);
2500
+ }
2501
+ userStop(f, i = !1) {
2502
+ this.isUserTouch && (this.isUserTouch = !1, i || (this.isUserMove ? this.flipController.stopMove() : this.flipController.flip(f)));
2503
+ }
2504
+ }, Object.defineProperty(s, "__esModule", { value: !0 });
2505
+ });
2506
+ })(Dt, Dt.exports);
2507
+ var hi = Dt.exports;
2508
+ /**
2509
+ * @license FlipbookEngine v0.2.4
2510
+ * Copyright (c) 2026 Murat Dogan
2511
+ *
2512
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2513
+ *
2514
+ * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
2515
+ * under the terms of the GNU Affero General Public License v3.0.
2516
+ *
2517
+ * 2. Commercial License: If you wish to use this software in commercial,
2518
+ * closed-source, or SaaS products without the AGPLv3 obligations,
2519
+ * you must purchase a Commercial License from:
2520
+ * https://flipbookengine.com/pricing
2521
+ */
2522
+ function li() {
2523
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2524
+ }
2525
+ function ci(e, t = li()) {
2526
+ return t ? 0 : typeof e == "number" && e >= 0 ? e : 1e3;
2527
+ }
2528
+ class di {
2529
+ constructor(t, s, o) {
2530
+ m(this, "pageFlip", null);
2531
+ m(this, "bookContainer");
2532
+ m(this, "options");
2533
+ m(this, "store");
2534
+ m(this, "unsubs", []);
2535
+ m(this, "audioEl", null);
2536
+ m(this, "audioUnlockHandler", null);
2537
+ m(this, "isLibraryFlipping", !1);
2538
+ m(this, "autoPlayTimer", null);
2539
+ this.bookContainer = t, this.options = s, this.store = o, s.soundUrl && (this.audioEl = new Audio(s.soundUrl), this.unlockAudio());
2540
+ }
2541
+ unlockAudio() {
2542
+ if (!this.audioEl) return;
2543
+ const t = () => {
2544
+ if (this.audioEl) {
2545
+ const s = this.audioEl.play();
2546
+ s && typeof s.then == "function" && s.then(() => {
2547
+ this.audioEl.pause(), this.audioEl.currentTime = 0;
2548
+ }).catch(() => {
2549
+ });
2550
+ }
2551
+ document.removeEventListener("touchstart", t), document.removeEventListener("click", t), this.audioUnlockHandler = null;
2552
+ };
2553
+ this.audioUnlockHandler = t, document.addEventListener("touchstart", t, { once: !0 }), document.addEventListener("click", t, { once: !0 });
2554
+ }
2555
+ init(t, s) {
2556
+ this.pageFlip = new hi.PageFlip(this.bookContainer, {
2557
+ width: t,
2558
+ height: s,
2559
+ size: "stretch",
2560
+ minWidth: 100,
2561
+ maxWidth: 3e3,
2562
+ minHeight: 100,
2563
+ maxHeight: 3e3,
2564
+ drawShadow: !0,
2565
+ showCover: !0,
2566
+ usePortrait: !0,
2567
+ mobileScrollSupport: !1,
2568
+ maxShadowOpacity: this.options.maxShadowOpacity || 0.5,
2569
+ flippingTime: ci(this.options.flippingTime)
2570
+ });
2571
+ const o = this.bookContainer.querySelectorAll(".bz-page");
2572
+ this.pageFlip.loadFromHTML(Array.from(o)), this.bindEvents(), this.setupSignalSync();
2573
+ }
2574
+ bindEvents() {
2575
+ this.pageFlip.on("flip", (t) => {
2576
+ this.store.currentPage.value !== t.data && (this.isLibraryFlipping = !0, this.store.currentPage.value = t.data, this.playSound(), this.isLibraryFlipping = !1);
2577
+ }), this.pageFlip.on("changeState", (t) => {
2578
+ this.store.flipState.value = t.data;
2579
+ }), this.pageFlip.on("changeOrientation", (t) => {
2580
+ this.store.orientation.value !== t.data && (this.store.orientation.value = t.data);
2581
+ });
2582
+ }
2583
+ setupSignalSync() {
2584
+ this.unsubs.push(
2585
+ _(() => {
2586
+ const t = this.store.currentPage.value, s = this.store.flipState.peek();
2587
+ if (!this.pageFlip || this.isLibraryFlipping || s !== "read") return;
2588
+ const o = this.pageFlip.getCurrentPageIndex();
2589
+ if (o !== t && !this.store.isSingleMode.value) {
2590
+ const r = (p) => p === 0 ? 0 : Math.ceil(p / 2), l = r(t), d = r(o);
2591
+ l === d + 1 ? this.pageFlip.flipNext() : l === d - 1 ? this.pageFlip.flipPrev() : l !== d && this.pageFlip.turnToPage(t);
2592
+ }
2593
+ })
2594
+ ), this.unsubs.push(
2595
+ _(() => {
2596
+ this.store.isSingleMode.value, this.pageFlip && setTimeout(() => {
2597
+ this.pageFlip && this.pageFlip.update(), window.dispatchEvent(new Event("resize"));
2598
+ }, 50);
2599
+ })
2600
+ ), this.unsubs.push(
2601
+ _(() => {
2602
+ const t = this.store.isAutoPlaying.value, s = this.store.autoPlayInterval.value || 3e3;
2603
+ this.autoPlayTimer && (clearInterval(this.autoPlayTimer), this.autoPlayTimer = null), t && (this.autoPlayTimer = setInterval(() => {
2604
+ const o = this.store.pages.value.length - 1;
2605
+ if (this.store.currentPage.peek() >= o || this.store.currentPage.peek() >= o - 1 && !this.store.isSingleMode.peek()) {
2606
+ this.store.isAutoPlaying.value = !1;
2607
+ return;
2608
+ }
2609
+ this.turnToNextPage();
2610
+ }, s));
2611
+ })
2612
+ );
2613
+ }
2614
+ turnToNextPage() {
2615
+ if (this.store.isSingleMode.value) {
2616
+ const t = this.store.currentPage.value + 1;
2617
+ t < this.store.pages.value.length && (this.store.currentPage.value = t, this.playSound());
2618
+ } else this.pageFlip && this.pageFlip.flipNext();
2619
+ }
2620
+ turnToPrevPage() {
2621
+ if (this.store.isSingleMode.value) {
2622
+ const t = this.store.currentPage.value - 1;
2623
+ t >= 0 && (this.store.currentPage.value = t, this.playSound());
2624
+ } else this.pageFlip && this.pageFlip.flipPrev();
2625
+ }
2626
+ playSound() {
2627
+ if (this.store.soundEnabled.value && this.audioEl) {
2628
+ this.audioEl.currentTime = 0;
2629
+ const t = this.audioEl.play();
2630
+ t && typeof t.catch == "function" && t.catch((s) => console.warn("Flipbook Audio Play Error:", s));
2631
+ }
2632
+ }
2633
+ update() {
2634
+ this.pageFlip && this.pageFlip.update();
2635
+ }
2636
+ destroy() {
2637
+ this.autoPlayTimer && (clearInterval(this.autoPlayTimer), this.autoPlayTimer = null), this.audioUnlockHandler && (document.removeEventListener("touchstart", this.audioUnlockHandler), document.removeEventListener("click", this.audioUnlockHandler), this.audioUnlockHandler = null), this.unsubs.forEach((t) => t()), this.unsubs = [], this.pageFlip && (this.pageFlip.destroy(), this.pageFlip = null);
2638
+ }
2639
+ }
2640
+ /**
2641
+ * @license FlipbookEngine v0.2.4
2642
+ * Copyright (c) 2026 Murat Dogan
2643
+ *
2644
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2645
+ *
2646
+ * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
2647
+ * under the terms of the GNU Affero General Public License v3.0.
2648
+ *
2649
+ * 2. Commercial License: If you wish to use this software in commercial,
2650
+ * closed-source, or SaaS products without the AGPLv3 obligations,
2651
+ * you must purchase a Commercial License from:
2652
+ * https://flipbookengine.com/pricing
2653
+ */
2654
+ class ui {
2655
+ constructor(t, s) {
2656
+ m(this, "wrapperElement", null);
2657
+ m(this, "sizerElement", null);
2658
+ m(this, "pageViewport");
2659
+ m(this, "store");
2660
+ m(this, "resizeObserver", null);
2661
+ m(this, "orientationMediaQuery", null);
2662
+ m(this, "orientationChangeHandler", null);
2663
+ m(this, "unsubs", []);
2664
+ m(this, "onResizeCallback");
2665
+ this.pageViewport = t, this.store = s;
2666
+ }
2667
+ init(t, s) {
2668
+ this.wrapperElement = t, this.sizerElement = s, this.setupResizeObserver(), this.setupOrientationMedia(), this.setupStateSync(), this.updateBookAspectRatio();
2669
+ }
2670
+ setupStateSync() {
2671
+ this.unsubs.push(
2672
+ _(() => {
2673
+ this.store.isSingleMode.value, this.store.orientation.value, setTimeout(() => this.updateBookAspectRatio(), 10);
2674
+ })
2675
+ );
2676
+ }
2677
+ setupResizeObserver() {
2678
+ typeof ResizeObserver < "u" && this.wrapperElement && (this.resizeObserver = new ResizeObserver(() => {
2679
+ this.updateBookAspectRatio();
2680
+ }), this.resizeObserver.observe(this.wrapperElement));
2681
+ }
2682
+ setupOrientationMedia() {
2683
+ if (typeof window < "u" && window.matchMedia) {
2684
+ this.orientationMediaQuery = window.matchMedia("(orientation: portrait)");
2685
+ const t = (s) => {
2686
+ s.matches, this.updateBookAspectRatio();
2687
+ };
2688
+ this.orientationChangeHandler = t, this.orientationMediaQuery.addEventListener ? this.orientationMediaQuery.addEventListener("change", t) : this.orientationMediaQuery.addListener(t), t(this.orientationMediaQuery);
2689
+ }
2690
+ }
2691
+ updateBookAspectRatio() {
2692
+ if (!this.wrapperElement || !this.sizerElement) return;
2693
+ const t = this.wrapperElement.clientWidth, s = this.wrapperElement.clientHeight;
2694
+ if (t === 0 || s === 0) return;
2695
+ const o = this.pageViewport.width, r = this.pageViewport.height, d = this.store.isDoublePageLayout.value ? o * 2 / r : o / r;
2696
+ let p = t, x = t / d;
2697
+ x > s && (x = s, p = s * d);
2698
+ let S = Math.ceil(p);
2699
+ S % 2 !== 0 && (S += 1), this.sizerElement.style.width = `${S}px`, this.sizerElement.style.height = `${Math.floor(x)}px`, this.sizerElement.style.aspectRatio = "", this.onResizeCallback && this.onResizeCallback();
2700
+ }
2701
+ destroy() {
2702
+ this.unsubs.forEach((t) => t()), this.unsubs = [], this.resizeObserver && this.wrapperElement && (this.resizeObserver.unobserve(this.wrapperElement), this.resizeObserver.disconnect(), this.resizeObserver = null), this.orientationMediaQuery && (this.orientationChangeHandler && (this.orientationMediaQuery.removeEventListener ? this.orientationMediaQuery.removeEventListener("change", this.orientationChangeHandler) : this.orientationMediaQuery.removeListener(this.orientationChangeHandler)), this.orientationChangeHandler = null, this.orientationMediaQuery = null);
2703
+ }
2704
+ }
2705
+ /**
2706
+ * @license FlipbookEngine v0.2.4
2707
+ * Copyright (c) 2026 Murat Dogan
2708
+ *
2709
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2710
+ *
2711
+ * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
2712
+ * under the terms of the GNU Affero General Public License v3.0.
2713
+ *
2714
+ * 2. Commercial License: If you wish to use this software in commercial,
2715
+ * closed-source, or SaaS products without the AGPLv3 obligations,
2716
+ * you must purchase a Commercial License from:
2717
+ * https://flipbookengine.com/pricing
2718
+ */
2719
+ class gi {
2720
+ constructor(t, s, o) {
2721
+ m(this, "container");
2722
+ m(this, "pageFlipAdapter");
2723
+ m(this, "store");
2724
+ m(this, "touchStartX", null);
2725
+ m(this, "unsubs", []);
2726
+ m(this, "listenerAbortController");
2727
+ var l;
2728
+ this.container = t, this.pageFlipAdapter = s, this.store = o;
2729
+ const r = ((l = t.ownerDocument.defaultView) == null ? void 0 : l.AbortController) ?? globalThis.AbortController;
2730
+ this.listenerAbortController = new r();
2731
+ }
2732
+ init() {
2733
+ this.bindWheel(), this.bindMouseDrag(), this.bindTouch(), this.setupStateSync();
2734
+ }
2735
+ setupStateSync() {
2736
+ this.unsubs.push(
2737
+ _(() => {
2738
+ this.store.isZoomed.value = this.store.zoomState.value.isActive, this.store.zoomState.value.isActive ? (this.container.style.transform = `translate(${this.store.zoomState.value.translateX}px, ${this.store.zoomState.value.translateY}px) scale(${this.store.zoomState.value.scale})`, this.container.style.transition = "none") : (this.container.style.transform = "", this.container.style.transition = "transform 0.3s ease");
2739
+ })
2740
+ );
2741
+ }
2742
+ bindWheel() {
2743
+ this.container.addEventListener("wheel", (t) => {
2744
+ this.store.zoomState.value.isActive && (t.preventDefault(), this.updateZoomPan(
2745
+ this.store.zoomState.value.translateX - t.deltaX,
2746
+ this.store.zoomState.value.translateY - t.deltaY
2747
+ ));
2748
+ }, { passive: !1, signal: this.listenerAbortController.signal });
2749
+ }
2750
+ bindMouseDrag() {
2751
+ let t = !1, s = 0, o = 0, r = 0, l = 0;
2752
+ this.container.addEventListener("mousedown", (d) => {
2753
+ this.store.zoomState.value.isActive && (t = !0, s = d.clientX, o = d.clientY, r = this.store.zoomState.value.translateX, l = this.store.zoomState.value.translateY, this.container.style.cursor = "grabbing");
2754
+ }, { signal: this.listenerAbortController.signal }), window.addEventListener("mousemove", (d) => {
2755
+ if (!t || !this.store.zoomState.value.isActive) return;
2756
+ const p = d.clientX - s, x = d.clientY - o;
2757
+ this.updateZoomPan(r + p, l + x);
2758
+ }, { signal: this.listenerAbortController.signal }), window.addEventListener("mouseup", () => {
2759
+ t && (t = !1, this.container.style.cursor = this.store.zoomState.value.isActive ? "grab" : "");
2760
+ }, { signal: this.listenerAbortController.signal });
2761
+ }
2762
+ bindTouch() {
2763
+ let t = !1, s = 0, o = 0;
2764
+ this.container.addEventListener("touchstart", (r) => {
2765
+ if (r.touches.length === 1)
2766
+ if (!this.store.zoomState.value.isActive)
2767
+ this.touchStartX = r.touches[0].clientX;
2768
+ else {
2769
+ t = !0, this.touchStartX = r.touches[0].clientX;
2770
+ const l = r.touches[0].clientY;
2771
+ s = this.store.zoomState.value.translateX, o = this.store.zoomState.value.translateY, this.container._touchStartY = l;
2772
+ }
2773
+ }, { passive: !0, signal: this.listenerAbortController.signal }), this.container.addEventListener("touchmove", (r) => {
2774
+ if (t && this.store.zoomState.value.isActive && r.touches.length === 1 && this.touchStartX !== null) {
2775
+ r.preventDefault();
2776
+ const l = r.touches[0].clientX - this.touchStartX, d = r.touches[0].clientY - this.container._touchStartY;
2777
+ this.updateZoomPan(s + l, o + d);
2778
+ }
2779
+ }, { passive: !1, signal: this.listenerAbortController.signal }), this.container.addEventListener("touchend", (r) => {
2780
+ if (this.touchStartX !== null && !this.store.zoomState.value.isActive && this.store.isSingleMode.value && r.changedTouches.length === 1) {
2781
+ const l = r.changedTouches[0].clientX - this.touchStartX;
2782
+ l > 50 && this.store.currentPage.value > 0 ? this.pageFlipAdapter.turnToPrevPage() : l < -50 && this.store.currentPage.value < this.store.totalPages.value - 1 && this.pageFlipAdapter.turnToNextPage();
2783
+ }
2784
+ this.touchStartX = null, t = !1;
2785
+ }, { passive: !0, signal: this.listenerAbortController.signal });
2786
+ }
2787
+ zoomIn() {
2788
+ let t = this.store.zoomState.value.scale + 0.5;
2789
+ t > 5 && (t = 5), this.store.zoomState.value = {
2790
+ ...this.store.zoomState.value,
2791
+ isActive: t > 1,
2792
+ scale: t
2793
+ }, t > 1 && (this.container.style.cursor = "grab");
2794
+ }
2795
+ zoomOut() {
2796
+ let t = this.store.zoomState.value.scale - 0.5;
2797
+ t <= 1 ? (t = 1, this.store.zoomState.value = { ...this.store.zoomState.value, isActive: !1, translateX: 0, translateY: 0, scale: 1 }, this.container.style.cursor = "") : this.store.zoomState.value = { ...this.store.zoomState.value, isActive: !0, scale: t };
2798
+ }
2799
+ updateZoomPan(t, s) {
2800
+ this.store.zoomState.value = {
2801
+ ...this.store.zoomState.value,
2802
+ translateX: t,
2803
+ translateY: s
2804
+ };
2805
+ }
2806
+ destroy() {
2807
+ this.listenerAbortController.abort(), this.unsubs.forEach((t) => t()), this.unsubs = [];
2808
+ }
2809
+ }
2810
+ /**
2811
+ * @license FlipbookEngine v0.2.4
2812
+ * Copyright (c) 2026 Murat Dogan
2813
+ *
2814
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
2815
+ */
2816
+ const pi = () => ({ isActive: !1, translateX: 0, translateY: 0, isDragging: !1, scale: 1 });
2817
+ function fe() {
2818
+ const e = M(0), t = M(0), s = M(!1), o = M(!0), r = M(!0), l = M("landscape"), d = M("read"), p = M("auto"), x = M(!0), S = M(!1), b = M("#7367f0"), D = M(!1), $ = M(!1), k = M(!1), A = M(3e3), O = M(!0), U = M("en"), H = M({}), N = M(pi()), f = M([]), i = w(() => !s.value && l.value === "landscape"), n = w(() => i.value && e.value === 0), a = w(() => i.value && e.value >= t.value - 1);
2819
+ return { currentPage: e, totalPages: t, isSingleMode: s, showThumbs: o, showArrows: r, orientation: l, flipState: d, themeMode: p, allowDownload: x, hasDownloadUrl: S, primaryColor: b, whiteLabel: D, isZoomed: $, isAutoPlaying: k, autoPlayInterval: A, soundEnabled: O, locale: U, messages: H, zoomState: N, pages: f, isDoublePageLayout: i, isFrontCover: n, isBackCover: a, init: (h, u, v, y) => {
2820
+ t.value = u, f.value = v, S.value = y, h.theme !== void 0 && (p.value = h.theme), h.primaryColor !== void 0 && (b.value = h.primaryColor), h.showThumbs !== void 0 && (o.value = h.showThumbs), h.showArrows !== void 0 && (r.value = h.showArrows), h.allowDownload !== void 0 && (x.value = h.allowDownload), h.whiteLabel !== void 0 && (D.value = h.whiteLabel), h.soundEnabled !== void 0 && (O.value = h.soundEnabled), h.locale !== void 0 && (U.value = h.locale), h.messages !== void 0 && (H.value = h.messages), h.isSingleMode !== void 0 && (s.value = h.isSingleMode), h.singleMode !== void 0 && (s.value = h.singleMode), h.autoPlay !== void 0 && (k.value = h.autoPlay), h.autoPlayInterval !== void 0 && (A.value = h.autoPlayInterval), e.value = 0;
2821
+ } };
2822
+ }
2823
+ const T = fe();
2824
+ T.currentPage;
2825
+ T.totalPages;
2826
+ T.isSingleMode;
2827
+ T.showThumbs;
2828
+ T.showArrows;
2829
+ T.orientation;
2830
+ T.flipState;
2831
+ T.themeMode;
2832
+ T.allowDownload;
2833
+ T.hasDownloadUrl;
2834
+ T.primaryColor;
2835
+ T.whiteLabel;
2836
+ T.isZoomed;
2837
+ T.isAutoPlaying;
2838
+ T.autoPlayInterval;
2839
+ T.soundEnabled;
2840
+ T.locale;
2841
+ T.messages;
2842
+ T.zoomState;
2843
+ T.pages;
2844
+ T.isDoublePageLayout;
2845
+ T.isFrontCover;
2846
+ T.isBackCover;
2847
+ function fi(e) {
2848
+ if (!e || typeof e != "object") return !1;
2849
+ const t = e;
2850
+ return typeof t.normal == "string" && typeof t.low == "string" && typeof t.thumb == "string";
2851
+ }
2852
+ function mi(e) {
2853
+ return Array.isArray(e.pageNumbers) && e.pageNumbers.length > 0 ? e.pageNumbers : typeof e.pageNumber == "number" ? e.kind === "spread" ? [e.pageNumber, e.pageNumber + 1] : [e.pageNumber] : [];
2854
+ }
2855
+ function wi(e) {
2856
+ return e === "rtl" ? ["right", "left"] : ["left", "right"];
2857
+ }
2858
+ function vi(e) {
2859
+ const t = [];
2860
+ let s = 1;
2861
+ return e.forEach((o, r) => {
2862
+ const l = o.kind ?? "single", d = o.id ?? `asset-${r}`, p = o.splitDirection ?? "ltr", x = mi(o);
2863
+ if (l === "spread") {
2864
+ const b = x.length >= 2 ? x.slice(0, 2) : [s, s + 1], D = wi(p);
2865
+ b.forEach(($, k) => {
2866
+ t.push({
2867
+ index: t.length,
2868
+ assetId: d,
2869
+ pageNumber: $,
2870
+ cropMode: D[k] ?? "full",
2871
+ normal: o.normal,
2872
+ low: o.low,
2873
+ thumb: o.thumb
2874
+ });
2875
+ }), s = b[b.length - 1] + 1;
2876
+ return;
2877
+ }
2878
+ const S = x[0] ?? s;
2879
+ t.push({
2880
+ index: t.length,
2881
+ assetId: d,
2882
+ pageNumber: S,
2883
+ cropMode: "full",
2884
+ normal: o.normal,
2885
+ low: o.low,
2886
+ thumb: o.thumb
2887
+ }), s = S + 1;
2888
+ }), t;
2889
+ }
2890
+ function Kt(e, t) {
2891
+ e.classList.add("bk-container"), e.classList.remove("bk-theme-light", "bk-theme-dark"), t.theme === "light" && e.classList.add("bk-theme-light"), t.theme === "dark" && e.classList.add("bk-theme-dark"), t.primaryColor && e.style.setProperty("--flipbook-accent", t.primaryColor);
2892
+ const s = t.cssVariables ?? {};
2893
+ Object.entries(s).forEach(([o, r]) => {
2894
+ const l = o.startsWith("--") ? o : `--${o}`;
2895
+ e.style.setProperty(l, r);
2896
+ });
2897
+ }
2898
+ class yi {
2899
+ constructor(t = 32) {
2900
+ m(this, "entries", /* @__PURE__ */ new Map());
2901
+ m(this, "hits", 0);
2902
+ m(this, "misses", 0);
2903
+ if (this.maxEntries = t, !Number.isInteger(t) || t < 0)
2904
+ throw new RangeError("PDF render cache size must be a non-negative integer.");
2905
+ }
2906
+ get(t) {
2907
+ const s = this.entries.get(t);
2908
+ if (s === void 0) {
2909
+ this.misses++;
2910
+ return;
2911
+ }
2912
+ return this.hits++, this.entries.delete(t), this.entries.set(t, s), s;
2913
+ }
2914
+ set(t, s) {
2915
+ if (!(this.maxEntries === 0 || !s))
2916
+ for (this.entries.delete(t), this.entries.set(t, s); this.entries.size > this.maxEntries; ) {
2917
+ const o = this.entries.keys().next().value;
2918
+ if (o === void 0) break;
2919
+ this.entries.delete(o);
2920
+ }
2921
+ }
2922
+ clear() {
2923
+ this.entries.clear(), this.hits = 0, this.misses = 0;
2924
+ }
2925
+ get size() {
2926
+ return this.entries.size;
2927
+ }
2928
+ getStats() {
2929
+ return { size: this.size, maxEntries: this.maxEntries, hits: this.hits, misses: this.misses };
2930
+ }
2931
+ }
2932
+ class bi {
2933
+ constructor(t = {}) {
2934
+ m(this, "pdfDoc", null);
2935
+ m(this, "loadingTask", null);
2936
+ m(this, "options");
2937
+ m(this, "cache");
2938
+ const s = Number.isFinite(t.cacheSize) ? Math.max(0, Math.floor(t.cacheSize)) : 32;
2939
+ this.options = {
2940
+ scale: t.scale || 1.5,
2941
+ quality: t.quality || 0.85,
2942
+ format: t.format || "image/webp",
2943
+ workerSrc: t.workerSrc || "",
2944
+ concurrency: Math.max(1, Math.floor(t.concurrency || 3)),
2945
+ cacheSize: s
2946
+ }, this.cache = new yi(this.options.cacheSize), this.options.workerSrc && (Bt.GlobalWorkerOptions.workerSrc = this.options.workerSrc);
2947
+ }
2948
+ /** Loads a PDF document and cancels PDF.js loading when the signal aborts. */
2949
+ async loadDocument(t, s) {
2950
+ this.throwIfAborted(s), this.cache.clear();
2951
+ const o = Bt.getDocument(t);
2952
+ this.loadingTask = o;
2953
+ const r = () => {
2954
+ var l;
2955
+ return (l = o.destroy) == null ? void 0 : l.call(o);
2956
+ };
2957
+ s == null || s.addEventListener("abort", r, { once: !0 });
2958
+ try {
2959
+ return this.pdfDoc = await o.promise, this.throwIfAborted(s), this.pdfDoc.numPages;
2960
+ } catch (l) {
2961
+ throw s != null && s.aborted ? this.createAbortError() : l;
2962
+ } finally {
2963
+ s == null || s.removeEventListener("abort", r), this.loadingTask === o && (this.loadingTask = null);
2964
+ }
2965
+ }
2966
+ /** Renders a specific page to a Data URL. The page index is 1-based. */
2967
+ async renderPageToDataUrl(t, s) {
2968
+ if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
2969
+ this.throwIfAborted(s);
2970
+ const o = this.cache.get(t);
2971
+ if (o !== void 0) return o;
2972
+ try {
2973
+ const r = await this.pdfDoc.getPage(t);
2974
+ this.throwIfAborted(s);
2975
+ const l = r.getViewport({ scale: this.options.scale }), d = document.createElement("canvas");
2976
+ d.width = l.width, d.height = l.height;
2977
+ const p = d.getContext("2d");
2978
+ if (p) {
2979
+ const x = r.render({ canvasContext: p, viewport: l }), S = () => {
2980
+ var D;
2981
+ return (D = x.cancel) == null ? void 0 : D.call(x);
2982
+ };
2983
+ s == null || s.addEventListener("abort", S, { once: !0 });
2984
+ try {
2985
+ await x.promise, this.throwIfAborted(s);
2986
+ } finally {
2987
+ s == null || s.removeEventListener("abort", S);
2988
+ }
2989
+ const b = d.toDataURL(this.options.format, this.options.quality);
2990
+ return this.cache.set(t, b), b;
2991
+ }
2992
+ } catch (r) {
2993
+ if (s != null && s.aborted) throw this.createAbortError();
2994
+ console.error(`PDF page ${t} render error:`, r);
2995
+ }
2996
+ return "";
2997
+ }
2998
+ /** Calculates the best viewport dimensions based on the first page. */
2999
+ async calculateViewportDimensions(t = 420) {
3000
+ if (!this.pdfDoc) throw new Error("PDF document is not loaded.");
3001
+ const o = (await this.pdfDoc.getPage(1)).getViewport({ scale: 1 }), r = o.width / o.height;
3002
+ return r >= 1 ? { width: Math.round(t * r), height: t } : { width: t, height: Math.round(t / r) };
3003
+ }
3004
+ /** Renders pages concurrently with a bounded worker pool and preserves page order. */
3005
+ async renderAllPages(t, s) {
3006
+ if (!this.pdfDoc) return [];
3007
+ this.throwIfAborted(t);
3008
+ const o = this.pdfDoc.numPages, r = new Array(o);
3009
+ let l = 1, d = 0;
3010
+ const p = async () => {
3011
+ for (; ; ) {
3012
+ this.throwIfAborted(t);
3013
+ const S = l++;
3014
+ if (S > o) return;
3015
+ const b = await this.renderPageToDataUrl(S, t);
3016
+ r[S - 1] = {
3017
+ index: S - 1,
3018
+ assetId: `pdf-page-${S}`,
3019
+ pageNumber: S,
3020
+ cropMode: "full",
3021
+ normal: b,
3022
+ low: b,
3023
+ thumb: b
3024
+ }, d++, s == null || s({ completed: d, total: o });
3025
+ }
3026
+ }, x = Math.min(this.options.concurrency, o);
3027
+ return await Promise.all(Array.from({ length: x }, () => p())), this.throwIfAborted(t), r;
3028
+ }
3029
+ getCacheStats() {
3030
+ return this.cache.getStats();
3031
+ }
3032
+ throwIfAborted(t) {
3033
+ if (t != null && t.aborted) throw this.createAbortError();
3034
+ }
3035
+ createAbortError() {
3036
+ const t = new Error("PDF rendering was aborted.");
3037
+ return t.name = "AbortError", t;
3038
+ }
3039
+ destroy() {
3040
+ var t, s, o, r;
3041
+ (s = (t = this.loadingTask) == null ? void 0 : t.destroy) == null || s.call(t), this.loadingTask = null, this.pdfDoc && ((r = (o = this.pdfDoc).destroy) == null || r.call(o), this.pdfDoc = null), this.cache.clear();
3042
+ }
3043
+ }
3044
+ /**
3045
+ * @license FlipbookEngine v0.2.4
3046
+ * Copyright (c) 2026 Murat Dogan
3047
+ *
3048
+ * This source code is dual-licensed under the AGPLv3 and a Commercial License.
3049
+ *
3050
+ * 1. Open Source (AGPLv3): You may use, modify, and distribute this software
3051
+ * under the terms of the GNU Affero General Public License v3.0.
3052
+ *
3053
+ * 2. Commercial License: If you wish to use this software in commercial,
3054
+ * closed-source, or SaaS products without the AGPLv3 obligations,
3055
+ * you must purchase a Commercial License from:
3056
+ * https://flipbookengine.com/pricing
3057
+ */
3058
+ const mt = class mt {
3059
+ constructor(t, s = {}) {
3060
+ m(this, "container", null);
3061
+ m(this, "options");
3062
+ m(this, "store", fe());
3063
+ // Core Managers
3064
+ m(this, "pageFlipAdapter", null);
3065
+ m(this, "layoutManager", null);
3066
+ m(this, "interactionManager", null);
3067
+ m(this, "pdfRenderer", null);
3068
+ m(this, "listeners", {});
3069
+ m(this, "initializationTimer", null);
3070
+ m(this, "initGeneration", 0);
3071
+ m(this, "initAbortController", null);
3072
+ m(this, "eventsReady", !1);
3073
+ m(this, "lastEventState", { currentPage: 0, zoom: 1, zoomActive: !1, showThumbs: !0, isSingle: !1, orientation: "" });
3074
+ m(this, "eventSyncStop", null);
3075
+ m(this, "qualityObserver", null);
3076
+ m(this, "pdfLazyStop", null);
3077
+ m(this, "pdfPageRequests", /* @__PURE__ */ new Map());
3078
+ m(this, "pdfRenderedPages", /* @__PURE__ */ new Set());
3079
+ this.selector = t, this.options = {
3080
+ allowDownload: !0,
3081
+ showThumbs: !0,
3082
+ primaryColor: "#7367f0",
3083
+ theme: "auto",
3084
+ soundUrl: "https://flipbookengine.com/Content/page-flip.mp3",
3085
+ autoPlayInterval: 3e3,
3086
+ pdfRenderScale: 1.5,
3087
+ pdfRenderQuality: 0.85,
3088
+ pdfRenderFormat: "image/webp",
3089
+ pdfRenderConcurrency: 3,
3090
+ pdfRenderCacheSize: 32,
3091
+ ...s
3092
+ }, this.setupEventSync();
3093
+ }
3094
+ async init(t, s) {
3095
+ if (typeof this.selector == "string" ? this.container = document.querySelector(this.selector) : this.container = this.selector, !this.container) return;
3096
+ this.destroy(!0), this.eventsReady = !1;
3097
+ const o = this.initGeneration, r = new AbortController();
3098
+ this.initAbortController = r;
3099
+ let l = [], d = { ...mt.DEFAULT_PAGE_VIEWPORT };
3100
+ if (s && s.length > 0) {
3101
+ if (r.signal.aborted) return;
3102
+ const k = s.filter(fi);
3103
+ l = vi(k);
3104
+ const A = l[0];
3105
+ if (A) {
3106
+ const O = await this.loadImageSize(A.low || A.normal);
3107
+ if (O) {
3108
+ const H = (A.cropMode !== "full" ? O.width / 2 : O.width) / O.height, N = 420;
3109
+ d = H >= 1 ? { width: Math.round(N * H), height: N } : { width: N, height: Math.round(N / H) };
3110
+ }
3111
+ }
3112
+ } else if (t) {
3113
+ if (r.signal.aborted) return;
3114
+ let k = "load";
3115
+ try {
3116
+ this.pdfRenderer = new bi({
3117
+ scale: this.options.pdfRenderScale,
3118
+ quality: this.options.pdfRenderQuality,
3119
+ format: this.options.pdfRenderFormat,
3120
+ concurrency: this.options.pdfRenderConcurrency,
3121
+ cacheSize: this.options.pdfRenderCacheSize,
3122
+ workerSrc: this.options.pdfWorkerSrc
3123
+ }), this.emit("progress", { phase: "loading", completed: 0, total: 0 });
3124
+ const A = await this.pdfRenderer.loadDocument(t, r.signal);
3125
+ k = "render", this.emit("progress", { phase: "loading", completed: 1, total: A }), d = await this.pdfRenderer.calculateViewportDimensions(), l = Array.from({ length: A }, (O, U) => this.createPdfPlaceholder(U + 1));
3126
+ } catch (A) {
3127
+ r.signal.aborted || (console.error("PDF load failed:", A), this.emit("error", {
3128
+ code: k === "load" ? "PDF_LOAD_FAILED" : "PDF_RENDER_FAILED",
3129
+ message: A instanceof Error ? A.message : "Unable to load PDF.",
3130
+ cause: A
3131
+ }));
3132
+ return;
3133
+ }
3134
+ }
3135
+ if (r.signal.aborted || o !== this.initGeneration || !l.length) return;
3136
+ this.store.init(this.options, l.length, l, !!t), Kt(this.container, this.options), this.container.innerHTML = "";
3137
+ let p, x, S;
3138
+ const b = { current: null }, D = { current: null }, $ = ri({
3139
+ pageFlipAdapterRef: b,
3140
+ interactionManagerRef: D,
3141
+ bookWrapperRef: (k) => p = k,
3142
+ bookSizerRef: (k) => x = k,
3143
+ bookContainerRef: (k) => S = k,
3144
+ className: this.options.className,
3145
+ store: this.store,
3146
+ onToggleFullscreen: () => this.toggleFullscreen(),
3147
+ onDownload: () => {
3148
+ t && (this.options.onDownload ? this.options.onDownload(t) : window.open(t, "_blank"));
3149
+ }
3150
+ });
3151
+ this.container.appendChild($), this.setupQualityLoading(), this.layoutManager = new ui(d, this.store), this.layoutManager.onResizeCallback = () => {
3152
+ this.pageFlipAdapter && this.pageFlipAdapter.update();
3153
+ }, this.layoutManager.init(p, x), this.pageFlipAdapter = new di(S, this.options, this.store), b.current = this.pageFlipAdapter, await new Promise((k) => {
3154
+ const A = () => {
3155
+ r.signal.removeEventListener("abort", A), k();
3156
+ };
3157
+ r.signal.addEventListener("abort", A, { once: !0 }), this.initializationTimer = setTimeout(async () => {
3158
+ if (this.initializationTimer = null, r.signal.removeEventListener("abort", A), r.signal.aborted || o !== this.initGeneration || !this.pageFlipAdapter) {
3159
+ k();
3160
+ return;
3161
+ }
3162
+ if (this.pageFlipAdapter.init(d.width, d.height), this.interactionManager = new gi(p, this.pageFlipAdapter, this.store), this.interactionManager.init(), D.current = this.interactionManager, this.setupPdfLazyLoading(), this.pdfRenderer && t)
3163
+ try {
3164
+ await this.renderPdfPage(1, r.signal);
3165
+ } catch {
3166
+ k();
3167
+ return;
3168
+ }
3169
+ if (r.signal.aborted || o !== this.initGeneration) {
3170
+ k();
3171
+ return;
3172
+ }
3173
+ this.eventsReady = !0, this.captureEventState(), this.emit("init", { totalPages: l.length }), k();
3174
+ }, 10);
3175
+ }), this.initAbortController === r && (this.initAbortController = null);
3176
+ }
3177
+ createPdfPlaceholder(t) {
3178
+ const s = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
3179
+ return {
3180
+ index: t - 1,
3181
+ assetId: "pdf-page-" + t,
3182
+ pageNumber: t,
3183
+ cropMode: "full",
3184
+ normal: s,
3185
+ low: s,
3186
+ thumb: s
3187
+ };
3188
+ }
3189
+ renderPdfPage(t, s) {
3190
+ const o = this.pdfRenderer;
3191
+ if (!o) return Promise.resolve("");
3192
+ const r = this.pdfPageRequests.get(t);
3193
+ if (r) return r;
3194
+ if (this.pdfRenderedPages.has(t)) return Promise.resolve("");
3195
+ const l = o.renderPageToDataUrl(t, s).then((d) => {
3196
+ var p;
3197
+ if (!d) throw new Error("PDF page " + t + " produced no image.");
3198
+ return this.pdfRenderedPages.add(t), (p = this.container) == null || p.querySelectorAll('img[data-pdf-page="' + t + '"]').forEach((x) => {
3199
+ x.src = d, delete x.dataset.pdfPage;
3200
+ }), this.emit("progress", {
3201
+ phase: "rendering",
3202
+ completed: this.pdfRenderedPages.size,
3203
+ total: this.store.totalPages.value
3204
+ }), d;
3205
+ }).catch((d) => {
3206
+ throw (d == null ? void 0 : d.name) === "AbortError" || this.emit("error", {
3207
+ code: "PDF_RENDER_FAILED",
3208
+ message: d instanceof Error ? d.message : "Unable to render PDF page.",
3209
+ cause: d
3210
+ }), d;
3211
+ }).finally(() => {
3212
+ this.pdfPageRequests.get(t) === l && this.pdfPageRequests.delete(t);
3213
+ });
3214
+ return this.pdfPageRequests.set(t, l), l;
3215
+ }
3216
+ setupPdfLazyLoading() {
3217
+ var t;
3218
+ (t = this.pdfLazyStop) == null || t.call(this), this.pdfLazyStop = null, this.pdfRenderer && (this.pdfLazyStop = _(() => {
3219
+ const s = this.store.currentPage.value + 1, o = this.store.totalPages.value;
3220
+ [s, s + 1].filter((r) => r <= o).forEach((r) => {
3221
+ this.renderPdfPage(r).catch(() => {
3222
+ });
3223
+ });
3224
+ }));
3225
+ }
3226
+ loadImageSize(t) {
3227
+ return new Promise((s) => {
3228
+ const o = new Image();
3229
+ o.onload = () => s({ width: o.naturalWidth || o.width, height: o.naturalHeight || o.height }), o.onerror = () => s(null), o.src = t;
3230
+ });
3231
+ }
3232
+ goToPage(t) {
3233
+ const s = Math.max(0, this.store.totalPages.value - 1);
3234
+ this.store.currentPage.value = Math.max(0, Math.min(s, Math.trunc(t)));
3235
+ }
3236
+ getTotalPages() {
3237
+ return this.store.totalPages.value;
3238
+ }
3239
+ getCurrentPage() {
3240
+ return this.store.currentPage.value;
3241
+ }
3242
+ getZoom() {
3243
+ return this.store.zoomState.value.scale;
3244
+ }
3245
+ setZoom(t) {
3246
+ const s = Number.isFinite(t) ? t : 1, o = Math.max(0.5, Math.min(5, s));
3247
+ this.store.zoomState.value = {
3248
+ ...this.store.zoomState.value,
3249
+ scale: o,
3250
+ isActive: o > 1,
3251
+ ...o <= 1 ? { translateX: 0, translateY: 0 } : {}
3252
+ }, this.store.isZoomed.value = o > 1;
3253
+ }
3254
+ nextPage() {
3255
+ this.pageFlipAdapter && this.pageFlipAdapter.turnToNextPage();
3256
+ }
3257
+ toggleFullscreen() {
3258
+ var s, o;
3259
+ const t = this.container;
3260
+ t && (document.fullscreenElement ? (o = document.exitFullscreen) == null || o.call(document).catch((r) => console.warn("Exit fullscreen err:", r)) : (s = t.requestFullscreen) == null || s.call(t).catch((r) => console.warn("Fullscreen err:", r)));
3261
+ }
3262
+ setLocale(t, s) {
3263
+ const o = s ? { ...this.options.messages, [t]: s[t] ?? s } : this.options.messages;
3264
+ this.options = { ...this.options, locale: t, messages: o }, this.store.locale.value = t, o && (this.store.messages.value = o);
3265
+ }
3266
+ prevPage() {
3267
+ this.pageFlipAdapter && this.pageFlipAdapter.turnToPrevPage();
3268
+ }
3269
+ setSingleMode(t) {
3270
+ this.store.isSingleMode.value = t;
3271
+ }
3272
+ updateOptions(t) {
3273
+ this.options = { ...this.options, ...t }, t.theme !== void 0 && (this.store.themeMode.value = t.theme), t.primaryColor !== void 0 && (this.store.primaryColor.value = t.primaryColor), t.showThumbs !== void 0 && (this.store.showThumbs.value = t.showThumbs), t.showArrows !== void 0 && (this.store.showArrows.value = t.showArrows), t.allowDownload !== void 0 && (this.store.allowDownload.value = t.allowDownload), t.whiteLabel !== void 0 && (this.store.whiteLabel.value = t.whiteLabel), t.soundEnabled !== void 0 && (this.store.soundEnabled.value = t.soundEnabled), t.locale !== void 0 && (this.store.locale.value = t.locale), t.messages !== void 0 && (this.store.messages.value = t.messages), t.singleMode !== void 0 && (this.store.isSingleMode.value = t.singleMode), t.isSingleMode !== void 0 && (this.store.isSingleMode.value = t.isSingleMode), t.autoPlay !== void 0 && (this.store.isAutoPlaying.value = t.autoPlay), t.autoPlayInterval !== void 0 && (this.store.autoPlayInterval.value = t.autoPlayInterval), this.container && Kt(this.container, this.options);
3274
+ }
3275
+ async setPages(t, s) {
3276
+ if (!(t != null && t.length)) {
3277
+ s && await this.init(s);
3278
+ return;
3279
+ }
3280
+ await this.init(s || "", t);
3281
+ }
3282
+ setupQualityLoading() {
3283
+ var r;
3284
+ if (this.teardownQualityLoading(), !this.container) return;
3285
+ const t = Array.from(this.container.querySelectorAll("img[data-src], img[data-pdf-page]")), s = (l) => {
3286
+ const d = Number(l.dataset.pdfPage);
3287
+ if (Number.isInteger(d) && d > 0) {
3288
+ this.renderPdfPage(d).catch(() => {
3289
+ });
3290
+ return;
3291
+ }
3292
+ const p = l.dataset.src;
3293
+ p && (l.src = p, delete l.dataset.src);
3294
+ }, o = (r = this.container.ownerDocument.defaultView) == null ? void 0 : r.IntersectionObserver;
3295
+ if (!o) {
3296
+ const l = /* @__PURE__ */ new Set();
3297
+ t.forEach((d) => {
3298
+ const p = Number(d.dataset.pdfPage);
3299
+ Number.isInteger(p) && p > 0 ? l.size < 2 && (l.add(p), s(d)) : s(d);
3300
+ });
3301
+ return;
3302
+ }
3303
+ this.qualityObserver = new o((l) => {
3304
+ l.forEach((d) => {
3305
+ var p;
3306
+ d.isIntersecting && (s(d.target), (p = this.qualityObserver) == null || p.unobserve(d.target));
3307
+ });
3308
+ }, { root: this.container, rootMargin: "240px" }), t.forEach((l) => {
3309
+ var d;
3310
+ return (d = this.qualityObserver) == null ? void 0 : d.observe(l);
3311
+ });
3312
+ }
3313
+ teardownQualityLoading() {
3314
+ var t;
3315
+ (t = this.qualityObserver) == null || t.disconnect(), this.qualityObserver = null;
3316
+ }
3317
+ setupEventSync() {
3318
+ this.eventSyncStop = _(() => {
3319
+ const t = {
3320
+ currentPage: this.store.currentPage.value,
3321
+ zoom: this.store.zoomState.value.scale,
3322
+ zoomActive: this.store.zoomState.value.isActive,
3323
+ showThumbs: this.store.showThumbs.value,
3324
+ isSingle: this.store.isSingleMode.value,
3325
+ orientation: this.store.orientation.value
3326
+ };
3327
+ if (!this.eventsReady) {
3328
+ this.lastEventState = t;
3329
+ return;
3330
+ }
3331
+ t.currentPage !== this.lastEventState.currentPage && this.emit("pageChange", {
3332
+ currentPage: t.currentPage,
3333
+ pageNumber: t.currentPage + 1,
3334
+ totalPages: this.store.totalPages.value,
3335
+ isSingle: t.isSingle
3336
+ }), (t.zoom !== this.lastEventState.zoom || t.zoomActive !== this.lastEventState.zoomActive) && this.emit("zoomChange", { zoom: t.zoom, isActive: t.zoomActive }), t.showThumbs !== this.lastEventState.showThumbs && this.emit("thumbsToggle", { showThumbs: t.showThumbs }), t.isSingle !== this.lastEventState.isSingle && this.emit("singlePageModeChange", { isSingle: t.isSingle }), t.orientation !== this.lastEventState.orientation && this.emit("orientationChange", { orientation: t.orientation }), this.lastEventState = t;
3337
+ });
3338
+ }
3339
+ captureEventState() {
3340
+ this.lastEventState = {
3341
+ currentPage: this.store.currentPage.value,
3342
+ zoom: this.store.zoomState.value.scale,
3343
+ zoomActive: this.store.zoomState.value.isActive,
3344
+ showThumbs: this.store.showThumbs.value,
3345
+ isSingle: this.store.isSingleMode.value,
3346
+ orientation: this.store.orientation.value
3347
+ };
3348
+ }
3349
+ destroy(t = !1) {
3350
+ var s, o;
3351
+ this.initGeneration++, (s = this.initAbortController) == null || s.abort(), this.initAbortController = null, this.initializationTimer && (clearTimeout(this.initializationTimer), this.initializationTimer = null), this.pageFlipAdapter && this.pageFlipAdapter.destroy(), this.layoutManager && this.layoutManager.destroy(), this.interactionManager && this.interactionManager.destroy(), this.teardownQualityLoading(), (o = this.pdfLazyStop) == null || o.call(this), this.pdfLazyStop = null, this.pdfPageRequests.clear(), this.pdfRenderedPages.clear(), this.pdfRenderer && this.pdfRenderer.destroy(), this.pageFlipAdapter = null, this.layoutManager = null, this.interactionManager = null, this.pdfRenderer = null, !t && this.container && (this.container.innerHTML = ""), this.emit("destroy", void 0);
3352
+ }
3353
+ on(t, s) {
3354
+ const o = this.listeners[t] ?? /* @__PURE__ */ new Set();
3355
+ return o.add(s), this.listeners[t] = o, () => this.off(t, s);
3356
+ }
3357
+ off(t, s) {
3358
+ var o;
3359
+ (o = this.listeners[t]) == null || o.delete(s);
3360
+ }
3361
+ emit(t, s) {
3362
+ var o;
3363
+ (o = this.listeners[t]) == null || o.forEach((r) => {
3364
+ r(s);
3365
+ });
3366
+ }
3367
+ };
3368
+ m(mt, "DEFAULT_PAGE_VIEWPORT", { width: 420, height: 594 });
3369
+ let Rt = mt;
3370
+ const me = globalThis, we = me.FlipbookEngine || {};
3371
+ we.FlipbookEngine = Rt;
3372
+ me.FlipbookEngine = we;
3373
+ export {
3374
+ Rt as F,
3375
+ fi as i,
3376
+ vi as n
3377
+ };
3378
+ //# sourceMappingURL=engine-BuVkDIh-.js.map