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