PageSourceSearch

https://kompas.detinjarije.com/wp-content/plugins/3d-flipbook-dflip-lite/assets/js/dflip.min.js?ver=2.3.32

js detinjarije.com collected 2026-10-02 07:38:24 UTC 549,173 bytes, 11,493 lines download raw bytes

1/******/ (function() { // webpackBootstrap
2/******/ 	var __webpack_modules__ = ({
3
4/***/ 101:
5/***/ (function() {
6
7function _instanceof(left, right) {
8    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
9        return !!right[Symbol.hasInstance](left);
10    } else {
11        return left instanceof right;
12    }
13}
14//region TWEEN.js required for animation
15/**
16 * Tween.js - Licensed under the MIT license
17 * https://github.com/tweenjs/tween.js
18 */ (function TweenJs() {
19    var TWEEN = TWEEN || function() {
20        var _tweens = [];
21        return {
22            getAll: function getAll() {
23                return _tweens;
24            },
25            removeAll: function removeAll() {
26                _tweens = [];
27            },
28            add: function add(tween) {
29                _tweens.push(tween);
30            },
31            remove: function remove(tween) {
32                var i = _tweens.indexOf(tween);
33                if (i !== -1) {
34                    _tweens.splice(i, 1);
35                }
36            },
37            update: function update(time) {
38                if (_tweens.length === 0) {
39                    return false;
40                }
41                var i = 0;
42                //noinspection JSUnresolvedVariable
43                time = time != null ? time : window.performance.now();
44                while(i < _tweens.length){
45                    if (_tweens[i].update(time)) {
46                        i++;
47                    } else {
48                        _tweens.splice(i, 1);
49                    }
50                }
51                return true;
52            }
53        };
54    }();
55    TWEEN.Tween = function(object) {
56        var _object = object;
57        var _valuesStart = {};
58        var _valuesEnd = {};
59        var _valuesStartRepeat = {};
60        var _duration = 1000;
61        var _repeat = 0;
62        var _yoyo = false;
63        var _isPlaying = false;
64        var _reversed = false;
65        var _delayTime = 0;
66        var _startTime = null;
67        var _easingFunction = TWEEN.Easing.Linear.None;
68        var _interpolationFunction = TWEEN.Interpolation.Linear;
69        var _chainedTweens = [];
70        var _onStartCallback = null;
71        var _onStartCallbackFired = false;
72        var _onUpdateCallback = null;
73        var _onCompleteCallback = null;
74        var _onStopCallback = null;
75        // Set all starting values present on the target object
76        for(var field in object){
77            //noinspection JSUnfilteredForInLoop
78            _valuesStart[field] = parseFloat(object[field], 10);
79        }
80        this.to = function(properties, duration) {
81            if (duration != null) {
82                _duration = duration;
83            }
84            _valuesEnd = properties;
85            return this;
86        };
87        this.start = function(time) {
88            TWEEN.add(this);
89            _isPlaying = true;
90            _onStartCallbackFired = false;
91            _startTime = time != null ? time : window.performance.now();
92            _startTime += _delayTime;
93            for(var property in _valuesEnd){
94                // Check if an Array was provided as property value
95                if (_instanceof(_valuesEnd[property], Array)) {
96                    if (_valuesEnd[property].length === 0) {
97                        continue;
98                    }
99                    // Create a local copy of the Array with the start value at the front
100                    _valuesEnd[property] = [
101                        _object[property]
102                    ].concat(_valuesEnd[property]);
103                }
104                // If `to()` specifies a property that doesn't exist in the source object,
105                // we should not set that property in the object
106                if (_valuesStart[property] == null) {
107                    continue;
108                }
109                _valuesStart[property] = _object[property];
110                if (_instanceof(_valuesStart[property], Array) === false) {
111                    _valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
112                }
113                _valuesStartRepeat[property] = _valuesStart[property] || 0;
114            }
115            return this;
116        };
117        this.stop = function() {
118            if (!_isPlaying) {
119                return this;
120            }
121            TWEEN.remove(this);
122            _isPlaying = false;
123            if (_onStopCallback != null) {
124                _onStopCallback.call(_object);
125            }
126            this.stopChainedTweens();
127            return this;
128        };
129        this.stopChainedTweens = function() {
130            for(var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++){
131                _chainedTweens[i].stop();
132            }
133        };
134        this.complete = function() {
135            if (!_isPlaying) {
136                return this;
137            }
138            TWEEN.remove(this);
139            _isPlaying = false;
140            if (_onCompleteCallback != null) {
141                _onCompleteCallback.call(_object);
142            }
143            this.completeChainedTweens();
144            return this;
145        };
146        this.completeChainedTweens = function() {
147            for(var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++){
148                _chainedTweens[i].complete();
149            }
150        };
151        this.delay = function(amount) {
152            _delayTime = amount;
153            return this;
154        };
155        this.repeat = function(times) {
156            _repeat = times;
157            return this;
158        };
159        //noinspection JSUnusedGlobalSymbols
160        this.yoyo = function(yoyo) {
161            _yoyo = yoyo;
162            return this;
163        };
164        this.easing = function(easing) {
165            _easingFunction = easing == null ? _easingFunction : easing;
166            return this;
167        };
168        this.interpolation = function(interpolation) {
169            _interpolationFunction = interpolation;
170            return this;
171        };
172        //noinspection JSUnusedGlobalSymbols
173        this.chain = function() {
174            _chainedTweens = arguments;
175            return this;
176        };
177        this.onStart = function(callback) {
178            _onStartCallback = callback;
179            return this;
180        };
181        this.onUpdate = function(callback) {
182            _onUpdateCallback = callback;
183            return this;
184        };
185        this.onComplete = function(callback) {
186            _onCompleteCallback = callback;
187            return this;
188        };
189        //noinspection JSUnusedGlobalSymbols
190        this.onStop = function(callback) {
191            _onStopCallback = callback;
192            return this;
193        };
194        this.update = function(time) {
195            var property;
196            var elapsed;
197            var value;
198            if (time < _startTime) {
199                return true;
200            }
201            if (_onStartCallbackFired === false) {
202                if (_onStartCallback != null) {
203                    _onStartCallback.call(_object);
204                }
205                _onStartCallbackFired = true;
206            }
207            elapsed = (time - _startTime) / _duration;
208            elapsed = elapsed > 1 ? 1 : elapsed;
209            value = _easingFunction(elapsed);
210            for(property in _valuesEnd){
211                // Don't update properties that do not exist in the source object
212                if (_valuesStart[property] == null) {
213                    continue;
214                }
215                var start = _valuesStart[property] || 0;
216                var end = _valuesEnd[property];
217                if (_instanceof(end, Array)) {
218                    _object[property] = _interpolationFunction(end, value);
219                } else {
220                    // Parses relative end values with start as base (e.g.: +10, -3)
221                    if (typeof end === 'string') {
222                        if (end.startsWith('+') || end.startsWith('-')) {
223                            end = start + parseFloat(end, 10);
224                        } else {
225                            end = parseFloat(end, 10);
226                        }
227                    }
228                    // Protect against non-numeric properties.
229                    if (typeof end === 'number') {
230                        _object[property] = start + (end - start) * value;
231                    }
232                }
233            }
234            if (_onUpdateCallback != null) {
235                _onUpdateCallback.call(_object, value);
236            }
237            if (elapsed === 1) {
238                if (_repeat > 0) {
239                    if (isFinite(_repeat)) {
240                        _repeat--;
241                    }
242                    // Reassign starting values, restart by making startTime = now
243                    for(property in _valuesStartRepeat){
244                        if (typeof _valuesEnd[property] === 'string') {
245                            _valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property], 10);
246                        }
247                        if (_yoyo) {
248                            var tmp = _valuesStartRepeat[property];
249                            _valuesStartRepeat[property] = _valuesEnd[property];
250                            _valuesEnd[property] = tmp;
251                        }
252                        _valuesStart[property] = _valuesStartRepeat[property];
253                    }
254                    if (_yoyo) {
255                        _reversed = !_reversed;
256                    }
257                    _startTime = time + _delayTime;
258                    return true;
259                } else {
260                    if (_onCompleteCallback != null) {
261                        _onCompleteCallback.call(_object);
262                    }
263                    for(var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++){
264                        // Make the chained tweens start exactly at the time they should,
265                        // even if the `update()` method was called way past the duration of the tween
266                        _chainedTweens[i].start(_startTime + _duration);
267                    }
268                    return false;
269                }
270            }
271            return true;
272        };
273    };
274    TWEEN.Easing = {
275        Linear: {
276            None: function None(k) {
277                return k;
278            }
279        },
280        Quadratic: {
281            In: function In(k) {
282                return k * k;
283            },
284            Out: function Out(k) {
285                return k * (2 - k);
286            },
287            InOut: function InOut(k) {
288                if ((k *= 2) < 1) {
289                    return 0.5 * k * k;
290                }
291                return -0.5 * (--k * (k - 2) - 1);
292            }
293        },
294        Quartic: {
295            In: function In(k) {
296                return k * k * k * k;
297            },
298            Out: function Out(k) {
299                return 1 - --k * k * k * k;
300            },
301            InOut: function InOut(k) {
302                if ((k *= 2) < 1) {
303                    return 0.5 * k * k * k * k;
304                }
305                return -0.5 * ((k -= 2) * k * k * k - 2);
306            }
307        },
308        Sinusoidal: {
309            In: function In(k) {
310                return 1 - Math.cos(k * Math.PI / 2);
311            },
312            Out: function Out(k) {
313                return Math.sin(k * Math.PI / 2);
314            },
315            InOut: function InOut(k) {
316                return 0.5 * (1 - Math.cos(Math.PI * k));
317            }
318        },
319        Cubic: {
320            In: function In(k) {
321                return k * k * k;
322            },
323            Out: function Out(k) {
324                return --k * k * k + 1;
325            },
326            InOut: function InOut(k) {
327                if ((k *= 2) < 1) {
328                    return 0.5 * k * k * k;
329                }
330                return 0.5 * ((k -= 2) * k * k + 2);
331            }
332        }
333    };
334    //noinspection JSUnusedGlobalSymbols
335    TWEEN.Interpolation = {
336        Linear: function Linear(v, k) {
337            var m = v.length - 1;
338            var f = m * k;
339            var i = Math.floor(f);
340            var fn = TWEEN.Interpolation.Utils.Linear;
341            if (k < 0) {
342                return fn(v[0], v[1], f);
343            }
344            if (k > 1) {
345                return fn(v[m], v[m - 1], m - f);
346            }
347            return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
348        },
349        Bezier: function Bezier(v, k) {
350            var b = 0;
351            var n = v.length - 1;
352            var pw = Math.pow;
353            var bn = TWEEN.Interpolation.Utils.Bernstein;
354            for(var i = 0; i <= n; i++){
355                b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
356            }
357            return b;
358        },
359        Utils: {
360            Linear: function Linear(p0, p1, t) {
361                return (p1 - p0) * t + p0;
362            },
363            Bernstein: function Bernstein(n, i) {
364                var fc = TWEEN.Interpolation.Utils.Factorial;
365                return fc(n) / fc(i) / fc(n - i);
366            },
367            Factorial: function() {
368                var a = [
369                    1
370                ];
371                return function(n) {
372                    var s = 1;
373                    if (a[n]) {
374                        return a[n];
375                    }
376                    for(var i = n; i > 1; i--){
377                        s *= i;
378                    }
379                    a[n] = s;
380                    return s;
381                };
382            }(),
383            CatmullRom: function CatmullRom(p0, p1, p2, p3, t) {
384                var v0 = (p2 - p0) * 0.5;
385                var v1 = (p3 - p1) * 0.5;
386                var t2 = t * t;
387                var t3 = t * t2;
388                return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
389            }
390        }
391    };
392    window.TWEEN = TWEEN;
393})();
394
395
396/***/ })
397
398/******/ 	});
399/************************************************************************/
400/******/ 	// The module cache
401/******/ 	var __webpack_module_cache__ = {};
402/******/ 	
403/******/ 	// The require function
404/******/ 	function __webpack_require__(moduleId) {
405/******/ 		// Check if module is in cache
406/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
407/******/ 		if (cachedModule !== undefined) {
408/******/ 			return cachedModule.exports;
409/******/ 		}
410/******/ 		// Create a new module (and put it into the cache)
411/******/ 		var module = __webpack_module_cache__[moduleId] = {
412/******/ 			// no module.id needed
413/******/ 			// no module.loaded needed
414/******/ 			exports: {}
415/******/ 		};
416/******/ 	
417/******/ 		// Execute the module function
418/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
419/******/ 	
420/******/ 		// Return the exports of the module
421/******/ 		return module.exports;
422/******/ 	}
423/******/ 	
424/************************************************************************/
425/******/ 	/* webpack/runtime/amd options */
426/******/ 	!function() {
427/******/ 		__webpack_require__.amdO = {};
428/******/ 	}();
429/******/ 	
430/************************************************************************/
431// This entry need to be wrapped in an IIFE because it need to be in strict mode.
432!function() {
433"use strict";
434
435// UNUSED EXPORTS: default
436
437;// CONCATENATED MODULE: ./src/js/dearviewer/defaults.js
438/* globals jQuery */ var defaults_DEARVIEWER = {
439    jQuery: jQuery,
440    version: '2.3.32',
441    autoDetectLocation: true,
442    slug: undefined,
443    locationVar: "dearViewerLocation",
444    locationFile: undefined,
445    MOUSE_CLICK_ACTIONS: {
446        NONE: "none",
447        NAV: "nav"
448    },
449    ARROW_KEYS_ACTIONS: {
450        NONE: "none",
451        NAV: "nav"
452    },
453    MOUSE_DBL_CLICK_ACTIONS: {
454        NONE: "none",
455        ZOOM: "zoom"
456    },
457    MOUSE_SCROLL_ACTIONS: {
458        NONE: "none",
459        ZOOM: "zoom",
460        NAV: "nav"
461    },
462    PAGE_SCALE: {
463        PAGE_FIT: "fit",
464        PAGE_WIDTH: 'width',
465        AUTO: "auto",
466        ACTUAL: 'actual',
467        MANUAL: 'manual'
468    },
469    READ_DIRECTION: {
470        LTR: 'ltr',
471        RTL: 'rtl'
472    },
473    TURN_DIRECTION: {
474        LEFT: 'left',
475        RIGHT: 'right',
476        NONE: 'none'
477    },
478    INFO_TYPE: {
479        INFO: "info",
480        ERROR: "error"
481    },
482    FLIPBOOK_PAGE_MODE: {
483        SINGLE: "single",
484        DOUBLE: "double",
485        AUTO: "auto"
486    },
487    FLIPBOOK_SINGLE_PAGE_MODE: {
488        ZOOM: "zoom",
489        BOOKLET: "booklet",
490        AUTO: "auto"
491    },
492    FLIPBOOK_PAGE_SIZE: {
493        AUTO: "auto",
494        SINGLE: "single",
495        DOUBLE_INTERNAL: "dbl_int",
496        DOUBLE: "dbl",
497        DOUBLE_COVER_BACK: "dbl_cover_back" // |8-1|, |2-3|, |4-5|, |6-7| -- used in printing , cannot be autodetected
498    },
499    LINK_TARGET: {
500        NONE: 0,
501        SELF: 1,
502        BLANK: 2,
503        PARENT: 3,
504        TOP: 4
505    },
506    CONTROLS_POSITION: {
507        HIDDEN: 'hidden',
508        TOP: 'top',
509        BOTTOM: 'bottom'
510    },
511    //internals
512    TURN_CORNER: {
513        TL: "tl",
514        TR: "tr",
515        BL: "bl",
516        BR: "br",
517        L: "l",
518        R: "r",
519        NONE: "none"
520    },
521    REQUEST_STATUS: {
522        OFF: "none",
523        ON: "pending",
524        COUNT: "counting"
525    },
526    TEXTURE_TARGET: {
527        THUMB: 0,
528        VIEWER: 1,
529        ZOOM: 2
530    },
531    FLIPBOOK_CENTER_SHIFT: {
532        RIGHT: 1,
533        LEFT: -1,
534        NONE: 0
535    },
536    FLIPBOOK_COVER_TYPE: {
537        NONE: "none",
538        PLAIN: "plain",
539        BASIC: "basic",
540        RIDGE: "ridge"
541    }
542};
543//_defaults that can be referenced but should not be changed
544defaults_DEARVIEWER._defaults = {
545    // When viewer is set to flipbook
546    // use 3D flipbook(true) or normal CSS flipbook(false)
547    is3D: true,
548    // When viewer is set to flipbook, and 3D is on.
549    // if you want to turn off shadow in 3d set it to false
550    has3DShadow: true,
551    color3DCover: "#aaaaaa",
552    color3DSheets: "#fff",
553    cover3DType: defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.NONE,
554    flexibility: 0.9,
555    drag3D: false,
556    // height of the container
557    // value(eg: 320) or percentage (eg: '50%')
558    // calculation limit: minimum 320, max window height
559    height: 'auto',
560    // set to true to show outline on open (true|false)
561    autoOpenOutline: false,
562    // set to true to show thumbnail on open (true|false)
563    autoOpenThumbnail: false,
564    // enableDownload of PDF files (true|false)
565    showDownloadControl: true,
566    showSearchControl: true,
567    showPrintControl: true,
568    // if enable sound at start (true|false)
569    enableSound: true,
570    // duration of page turn in milliseconds
571    duration: 800,
572    pageRotation: 0,
573    flipbook3DTiltAngleUp: 0,
574    flipbook3DTiltAngleLeft: 0,
575    readDirection: defaults_DEARVIEWER.READ_DIRECTION.LTR,
576    pageMode: defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.AUTO,
577    singlePageMode: defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.AUTO,
578    //resizes the underlying pages to suit the top cover page after flip
579    flipbookFitPages: false,
580    //color value in hexadecimal
581    backgroundColor: "transparent",
582    flipbookHardPages: "none",
583    openPage: 1,
584    annotationClass: "",
585    // texture settings
586    maxTextureSize: 3200,
587    minTextureSize: 256,
588    rangeChunkSize: 524288,
589    //pdf related options
590    disableAutoFetch: true,
591    disableStream: true,
592    disableFontFace: false,
593    // icons for the buttons
594    icons: {
595        'altnext': 'df-icon-arrow-right1',
596        'altprev': 'df-icon-arrow-left1',
597        'next': 'df-icon-arrow-right1',
598        'prev': 'df-icon-arrow-left1',
599        'end': 'df-icon-last-page',
600        'start': 'df-icon-first-page',
601        'share': 'df-icon-share',
602        'outline-open': 'df-icon-arrow-right',
603        'outline-close': 'df-icon-arrow-down',
604        'help': 'df-icon-help',
605        'more': 'df-icon-more',
606        'download': 'df-icon-download',
607        'zoomin': 'df-icon-add-circle',
608        'zoomout': 'df-icon-minus-circle',
609        'resetzoom': 'df-icon-minus-circle',
610        'fullscreen': 'df-icon-fullscreen',
611        'fullscreen-off': 'df-icon-fit-screen',
612        'fitscreen': 'df-icon-fit-screen',
613        'thumbnail': 'df-icon-grid-view',
614        'outline': 'df-icon-list',
615        'close': 'df-icon-close',
616        'doublepage': 'df-icon-double-page',
617        'singlepage': 'df-icon-file',
618        'print': 'df-icon-print',
619        'play': 'df-icon-play',
620        'pause': 'df-icon-pause',
621        'search': 'df-icon-search',
622        'sound': 'df-icon-volume',
623        'sound-off': 'df-icon-volume',
624        'facebook': 'df-icon-facebook',
625        'google': 'df-icon-google',
626        'twitter': 'df-icon-twitter',
627        'whatsapp': 'df-icon-whatsapp',
628        'linkedin': 'df-icon-linkedin',
629        'pinterest': 'df-icon-pinterest',
630        'mail': 'df-icon-mail'
631    },
632    // TRANSLATION text to be displayed
633    text: {
634        toggleSound: "Turn on/off Sound",
635        toggleThumbnails: "Toggle Thumbnails",
636        toggleOutline: "Toggle Outline/Bookmark",
637        previousPage: "Previous Page",
638        nextPage: "Next Page",
639        toggleFullscreen: "Toggle Fullscreen",
640        zoomIn: "Zoom In",
641        zoomOut: "Zoom Out",
642        resetZoom: "Reset Zoom",
643        pageFit: 'Fit Page',
644        widthFit: 'Fit Width',
645        toggleHelp: "Toggle Help",
646        search: "Search in PDF",
647        singlePageMode: "Single Page Mode",
648        doublePageMode: "Double Page Mode",
649        downloadPDFFile: "Download PDF File",
650        gotoFirstPage: "Goto First Page",
651        gotoLastPage: "Goto Last Page",
652        print: "Print",
653        play: "Start AutoPlay",
654        pause: "Pause AutoPlay",
655        share: "Share",
656        close: "Close",
657        mailSubject: "Check out this FlipBook",
658        mailBody: "Check out this site {{url}}",
659        loading: "Loading",
660        thumbTitle: "Thumbnails",
661        outlineTitle: "Table of Contents",
662        searchTitle: "Search",
663        searchPlaceHolder: "Search",
664        analyticsEventCategory: "DearFlip",
665        analyticsViewerReady: "Document Ready",
666        analyticsViewerOpen: "Document Opened",
667        analyticsViewerClose: "Document Closed",
668        analyticsFirstPageChange: "First Page Changed"
669    },
670    share: {
671        'facebook': 'https://www.facebook.com/sharer/sharer.php?u={{url}}&t={{mailsubject}}',
672        'twitter': 'https://twitter.com/share?url={{url}}&text={{mailsubject}}',
673        'mail': undefined,
674        'whatsapp': 'https://api.whatsapp.com/send/?text={{mailsubject}}+{{url}}&type=custom_url&app_absent=0',
675        'linkedin': 'https://www.linkedin.com/shareArticle?url={{url}}&title={{mailsubject}}',
676        'pinterest': 'https://www.pinterest.com/pin/create/button/?url={{url}}&media=&description={{mailsubject}}'
677    },
678    //valid control-names:
679    //altPrev,pageNumber,altNext,outline,thumbnail,zoomIn,zoomOut,fullScreen,share
680    //more,download,pageMode,startPage,endPage,sound
681    allControls: "altPrev,pageNumber,altNext,play,outline,thumbnail,zoomIn,zoomOut,zoom,fullScreen",
682    moreControls: "download,pageMode,pageFit,startPage,endPage,sound",
683    leftControls: "outline,thumbnail",
684    rightControls: "fullScreen",
685    hideControls: "",
686    hideShareControls: "",
687    controlsPosition: defaults_DEARVIEWER.CONTROLS_POSITION.BOTTOM,
688    paddingTop: 20,
689    paddingLeft: 15,
690    paddingRight: 15,
691    paddingBottom: 20,
692    enableAnalytics: false,
693    zoomRatio: 2,
694    maxDPI: 2,
695    fakeZoom: 1,
696    pageScale: defaults_DEARVIEWER.PAGE_SCALE.PAGE_FIT,
697    controlsFloating: true,
698    sideMenuOverlay: true,
699    enableAnnotation: true,
700    enableAutoLinks: true,
701    //ACTIONS
702    arrowKeysAction: defaults_DEARVIEWER.ARROW_KEYS_ACTIONS.NAV,
703    clickAction: defaults_DEARVIEWER.MOUSE_CLICK_ACTIONS.NAV,
704    dblClickAction: defaults_DEARVIEWER.MOUSE_DBL_CLICK_ACTIONS.NONE,
705    mouseScrollAction: defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.NONE,
706    linkTarget: defaults_DEARVIEWER.LINK_TARGET.BLANK,
707    //Resources settings
708    soundFile: "sound/turn2.mp3",
709    imagesLocation: "images",
710    imageResourcesPath: "images/pdfjs/",
711    popupThumbPlaceholder: 'data:image/svg+xml,' + escape('<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210 297"><rect width="210" height="297" style="fill:#f1f2f2"/><circle cx="143" cy="95" r="12" style="fill:#e3e8ed"/><polygon points="131 138 120 149 95 124 34 184 176 185 131 138" style="fill:#e3e8ed"/></svg>'),
712    cMapUrl: "js/libs/cmaps/",
713    logo: "",
714    logoUrl: "",
715    sharePrefix: '',
716    pageSize: defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.AUTO,
717    // link to the images file that you want as background.
718    // supported files are jpgs,png. smaller files are preffered for performance
719    backgroundImage: "",
720    pixelRatio: window.devicePixelRatio || 1,
721    /*3D settings*/ spotLightIntensity: 0.22,
722    ambientLightColor: "#fff",
723    ambientLightIntensity: 0.8,
724    shadowOpacity: 0.1,
725    slug: undefined,
726    headerElementSelector: undefined,
727    //callbacks
728    onReady: function onReady(app) {
729    // after document and viewer is loaded
730    },
731    onPageChanged: function onPageChanged(app) {
732    // when page change is detected
733    },
734    beforePageChanged: function beforePageChanged(app) {
735    // when page change validated but before pages are changed
736    },
737    onCreate: function onCreate(app) {
738    // after app is created and initialized, viewer and document loading is not included
739    },
740    onCreateUI: function onCreateUI(app) {
741    // after UI is created
742    },
743    onFlip: function onFlip(app) {
744    // after flip event is fired
745    },
746    beforeFlip: function beforeFlip(app) {
747    // before flip event is fired
748    },
749    autoPDFLinktoViewer: false,
750    autoLightBoxFullscreen: false,
751    thumbLayout: 'book-title-hover',
752    cleanupAfterRender: true,
753    canvasWillReadFrequently: true,
754    providerType: 'pdf',
755    loadMoreCount: -1,
756    autoPlay: false,
757    autoPlayDuration: 1000,
758    autoPlayStart: false,
759    popupBackGroundColor: "#eee",
760    mockupMode: false,
761    instantTextureProcess: false,
762    cachePDFTexture: false,
763    pdfVersion: "default"
764};
765//options that can be changed by users
766//Needed for: When user changed text or icons and just changed one, it impacted all others.
767defaults_DEARVIEWER.defaults = {};
768defaults_DEARVIEWER.jQuery.extend(true, defaults_DEARVIEWER.defaults, defaults_DEARVIEWER._defaults);
769defaults_DEARVIEWER.viewers = {};
770defaults_DEARVIEWER.providers = {};
771defaults_DEARVIEWER.openFileOptions = {};
772defaults_DEARVIEWER.executeCallback = function() {};
773
774
775;// CONCATENATED MODULE: ./src/js/dearviewer/utils/utils.js
776/* globals requirejs, jQuery*/ function _array_like_to_array(arr, len) {
777    if (len == null || len > arr.length) len = arr.length;
778    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
779    return arr2;
780}
781function _array_without_holes(arr) {
782    if (Array.isArray(arr)) return _array_like_to_array(arr);
783}
784function _instanceof(left, right) {
785    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
786        return !!right[Symbol.hasInstance](left);
787    } else {
788        return left instanceof right;
789    }
790}
791function _iterable_to_array(iter) {
792    if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
793}
794function _non_iterable_spread() {
795    throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
796}
797function _to_consumable_array(arr) {
798    return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
799}
800function _type_of(obj) {
801    "@swc/helpers - typeof";
802    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
803}
804function _unsupported_iterable_to_array(o, minLen) {
805    if (!o) return;
806    if (typeof o === "string") return _array_like_to_array(o, minLen);
807    var n = Object.prototype.toString.call(o).slice(8, -1);
808    if (n === "Object" && o.constructor) n = o.constructor.name;
809    if (n === "Map" || n === "Set") return Array.from(n);
810    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
811}
812
813var DV = defaults_DEARVIEWER;
814var utils_jQuery = defaults_DEARVIEWER.jQuery;
815/*VARIABLES*/ var has3d = 'WebKitCSSMatrix' in window || document.body && 'MozPerspective' in document.body.style, hasMouse = 'onmousedown' in window;
816var utils = DV.utils = {
817    mouseEvents: hasMouse ? {
818        type: "mouse",
819        start: "mousedown",
820        move: "mousemove",
821        end: "mouseup"
822    } : {
823        type: "touch",
824        start: "touchstart",
825        move: "touchmove",
826        end: "touchend"
827    },
828    html: {
829        div: "<div></div>",
830        a: "<a>",
831        input: "<input type='text'/>",
832        select: "<select></select>"
833    },
834    //functions or so
835    getSharePrefix: function getSharePrefix() {
836        var prefixes = utils.getSharePrefixes();
837        return prefixes[0];
838    },
839    /**
840   *
841   * @returns {array}
842   */ getSharePrefixes: function getSharePrefixes() {
843        return (DV.defaults.sharePrefix + ',dflip-,flipbook-,dearflip-,dearpdf-').split(",").map(function(e) {
844            return e.trim();
845        });
846    },
847    toRad: function toRad(deg) {
848        return deg * Math.PI / 180;
849    },
850    toDeg: function toDeg(rad) {
851        return rad * 180 / Math.PI;
852    },
853    /**
854   * Object Fallback when empty
855   * @param {Object} checkVal Object to check if it's empty
856   * @param {Object} ifEmpty Object to use if checkVal is empty
857   * @returns {*}
858   */ ifdef: function ifdef(checkVal) {
859        var ifEmpty = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
860        if (checkVal === null || checkVal === void 0) {
861            return ifEmpty;
862        }
863        return checkVal;
864    },
865    createBtn: function createBtn(name, icon, text) {
866        // icon = options.icons[icon];
867        // text = options.text[text];
868        // noinspection CheckTagEmptyBody
869        var btn = utils_jQuery(utils.html.div, {
870            class: "df-ui-btn df-ui-" + name,
871            title: text,
872            html: text !== void 0 ? '<span>
872' + text + '</span>' : ''
873        });
874        if (icon !== void 0 && icon.indexOf('<svg') > -1) {
875            btn.html(icon.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg" '));
876        } else {
877            btn.addClass(icon);
878        }
879        return btn;
880    },
881    transition: function transition(hasTransition, duration) {
882        return hasTransition ? duration / 1000 + "s ease-out" : "0s none";
883    },
884    display: function display(hasDisplay) {
885        return hasDisplay ? "block" : "none";
886    },
887    resetTranslate: function resetTranslate() {
888        return utils.translateStr(0, 0);
889    },
890    bgImage: function bgImage(src) {
891        return src == null || src === "blank" ? '' : ' url("' + src + '")';
892    },
893    translateStr: function translateStr(x, y) {
894        return has3d ? ' translate3d(' + x + 'px,' + y + 'px, 0px) ' : ' translate(' + x + 'px, ' + y + 'px) ';
895    },
896    httpsCorrection: function httpsCorrection(url) {
897        try {
898            if (url === null || url === void 0) return null;
899            if (typeof url !== "string") return url;
900            var location = window.location;
901            if (location.href.split(".")[0] === url.split(".")[0]) return url;
902            var urlHostName = url.split("://")[1].split("/")[0];
903            var isSameDomain = urlHostName.replace("www.", "") === location.hostname.replace("www.", "");
904            if (isSameDomain && url.indexOf(location.hostname.replace("www.", "")) > -1) {
905                if (location.href.indexOf("https://") > -1) {
906                    url = url.replace("http://", "https://");
907                } else if (location.href.indexOf("http://") > -1) {
908                    url = url.replace("https://", "http://");
909                }
910                //correct www and non www
911                //match to www
912                if (location.href.indexOf("://www.") > -1 && url.indexOf("://www.") === -1) {
913                    url = url.replace("://", "://www.");
914                }
915                //match to non www
916                if (location.href.indexOf("://www.") === -1 && url.indexOf("://www.") > -1) {
917                    url = url.replace("://www.", "://");
918                }
919            }
920        } catch (e) {
921            console.log("Skipping URL correction: " + url);
922        }
923        return url;
924    },
925    rotateStr: function rotateStr(deg) {
926        return ' rotateZ(' + deg + 'deg) ';
927    },
928    lowerPowerOfTwo: function lowerPowerOfTwo(value) {
929        return Math.pow(2, Math.floor(Math.log(value) / Math.LN2));
930    },
931    nearestPowerOfTwo: function nearestPowerOfTwo(value, max) {
932        return Math.min(max || 2048, Math.pow(2, Math.ceil(Math.log(value) / Math.LN2)));
933    },
934    getFullscreenElement: function getFullscreenElement() {
935        //noinspection JSUnresolvedVariable
936        return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
937    },
938    hasFullscreenEnabled: function hasFullscreenEnabled() {
939        //noinspection JSUnresolvedVariable
940        return document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled || document.msFullscreenEnabled;
941    },
942    fixMouseEvent: function fixMouseEvent(event) {
943        if (event) {
944            var originalEvent = event.originalEvent || event;
945            //noinspection JSUnresolvedVariable
946            if (originalEvent.changedTouches && originalEvent.changedTouches.length > 0) {
947                var _event = utils_jQuery.event.fix(event);
948                //noinspection JSUnresolvedVariable
949                var touch = originalEvent.changedTouches[0];
950                _event.clientX = touch.clientX;
951                _event.clientY = touch.clientY;
952                _event.pageX = touch.pageX;
953                _event.touches = originalEvent.touches;
954                _event.pageY = touch.pageY;
955                _event.movementX = touch.movementX;
956                _event.movementY = touch.movementY;
957                return _event;
958            } else {
959                return event;
960            }
961        } else {
962            return event;
963        }
964    },
965    limitAt: function limitAt(x, min, max) {
966        return x < min ? min : x > max ? max : x;
967    },
968    distOrigin: function distOrigin(x, y) {
969        return utils.distPoints(0, 0, x, y);
970    },
971    distPoints: function distPoints(x1, y1, x2, y2) {
972        return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
973    },
974    angleByDistance: function angleByDistance(distance, fullWidth) {
975        var h = fullWidth / 2;
976        var d = utils.limitAt(distance, 0, fullWidth);
977        return d < h ? utils.toDeg(Math.asin(d / h)) : 90 + utils.toDeg(Math.asin((d - h) / h));
978    },
979    calculateScale: function calculateScale(startTouches, endTouches) {
980        var startDistance = utils.distPoints(startTouches[0].x, startTouches[0].y, startTouches[1].x, startTouches[1].y), endDistance = utils.distPoints(endTouches[0].x, endTouches[0].y, endTouches[1].x, endTouches[1].y);
981        return endDistance / startDistance;
982    },
983    /**
984   * Calculates the average of multiple vectors (x, y values)
985   */ getVectorAvg: function getVectorAvg(vectors) {
986        return {
987            x: vectors.map(function(v) {
988                return v.x;
989            }).reduce(utils.sum) / vectors.length,
990            y: vectors.map(function(v) {
991                return v.y;
992            }).reduce(utils.sum) / vectors.length
993        };
994    },
995    sum: function sum(a, b) {
996        return a + b;
997    },
998    /**
999   * Returns the touches of an event relative to the container offset
1000   * @param event
1001   * @param position
1002   * @return array touches
1003   */ getTouches: function getTouches(event, position) {
1004        position = position || {
1005            left: 0,
1006            top: 0
1007        };
1008        return Array.prototype.slice.call(event.touches).map(function(touch) {
1009            return {
1010                x: touch.pageX - position.left,
1011                y: touch.pageY - position.top
1012            };
1013        });
1014    },
1015    getScriptCallbacks: [],
1016    getScript: function getScript(source, callback, errorCallback, isModule) {
1017        var _callbacks = utils.getScriptCallbacks[source], script;
1018        function clean() {
1019            script.removeEventListener("load", load, false);
1020            script.removeEventListener("readystatechange", load, false);
1021            script.removeEventListener("complete", load, false);
1022            script.removeEventListener("error", onError, false);
1023            script.onload = script.onreadystatechange = null;
1024            script = null;
1025            script = null;
1026        }
1027        function load(_, isAbort) {
1028            if (script != null) {
1029                if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) {
1030                    //console.log("aborted loading :" + source);
1031                    if (!isAbort) {
1032                        for(var i = 0; i < _callbacks.length; i++){
1033                            if (_callbacks[i]) _callbacks[i]();
1034                            _callbacks[i] = null;
1035                        }
1036                        errorCallback = null;
1037                    }
1038                    clean();
1039                }
1040            }
1041        }
1042        function onError() {
1043            errorCallback();
1044            clean();
1045            errorCallback = null;
1046        }
1047        if (utils_jQuery("script[src='" + source + "']").length === 0) {
1048            _callbacks = utils.getScriptCallbacks[source] = [];
1049            _callbacks.push(callback);
1050            script = document.createElement('script');
1051            var prior = document.body.getElementsByTagName('script')[0];
1052            script.async = true;
1053            script.setAttribute("data-cfasync", "false");
1054            if (isModule === true) {
1055                script.setAttribute("type", "module");
1056            }
1057            if (prior != null) {
1058                prior.parentNode.insertBefore(script, prior);
1059                prior = null;
1060            } else {
1061                document.body.appendChild(script);
1062            }
1063            script.addEventListener("load", load, false);
1064            script.addEventListener("readystatechange", load, false);
1065            script.addEventListener("complete", load, false);
1066            if (errorCallback) {
1067                script.addEventListener("error", onError, false);
1068            }
1069            //Todo check if removing random(1) to random() has any effect
1070            script.src = source + (utils.prefix.dom === "MS" ? "?" + Math.random() : "");
1071        } else {
1072            _callbacks.push(callback);
1073        }
1074    },
1075    detectScriptLocation: function detectScriptLocation() {
1076        //Auto-detection if the folder structure is copied properly
1077        if (typeof window[defaults_DEARVIEWER.locationVar] == 'undefined') {
1078            utils_jQuery("script").each(function() {
1079                var src = utils_jQuery(this)[0].src;
1080                // noinspection HttpUrlsUsage
1081                if ((src.indexOf("/" + defaults_DEARVIEWER.locationFile + ".js") > -1 || src.indexOf("/" + defaults_DEARVIEWER.locationFile + ".min.js") > -1 || src.indexOf("js/" + defaults_DEARVIEWER.locationFile + ".") > -1) && (src.indexOf("https://") > -1 || src.indexOf("http://") > -1)) {
1082                    var splits = src.split("/");
1083                    window[defaults_DEARVIEWER.locationVar] = splits.slice(0, -2).join("/");
1084                }
1085            });
1086        } else if (window[defaults_DEARVIEWER.locationVar].indexOf(":") == -1) {
1087            var a = document.createElement("a");
1088            a.href = window[defaults_DEARVIEWER.locationVar];
1089            window[defaults_DEARVIEWER.locationVar] = a.href;
1090            a = null;
1091        }
1092        if (typeof window[defaults_DEARVIEWER.locationVar] !== 'undefined') {
1093            //add ending forward slash trail for safety
1094            if (window[defaults_DEARVIEWER.locationVar].length > 2 && window[defaults_DEARVIEWER.locationVar].slice(-1) !== "/") {
1095                window.window[defaults_DEARVIEWER.locationVar] += "/";
1096            }
1097        }
1098    },
1099    disposeObject: function disposeObject(object) {
1100        if (object && object.dispose) {
1101            object.dispose();
1102        }
1103        object = null;
1104        return object;
1105    },
1106    log: function log() {
1107        for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
1108            args[_key] = arguments[_key];
1109        }
1110        var _console;
1111        if (DV.defaults.enableDebugLog === true && window.console) (_console = console).log.a
1111pply(_console, _to_consumable_array(args));
1112    },
1113    color: {
1114        getBrightness: function getBrightness(hex) {
1115            var rgb = hex.replace("#", "").match(/.{1,2}/g).map(function(e) {
1116                return parseInt(e, 16);
1117            });
1118            return rgb[0] * .299 + rgb[1] * .587 + rgb[2] * .114;
1119        },
1120        isLight: function isLight(hex) {
1121            return !utils.color.isDark(hex);
1122        },
1123        isDark: function isDark(hex) {
1124            return utils.color.getBrightness(hex) < 128;
1125        }
1126    },
1127    isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
1128    isIOS: /(iPad|iPhone|iPod)/g.test(navigator.userAgent),
1129    isIPad: function() {
1130        return navigator.platform === "iPad" || typeof navigator.maxTouchPoints !== "undefined" && navigator.maxTouchPoints > 2 && /Mac/.test(navigator.platform);
1131    }(),
1132    isMac: navigator.platform.toUpperCase().indexOf('MAC') >= 0,
1133    isSafari: function() {
1134        // noinspection JSCheckFunctionSignatures
1135        return /constructor/i.test(window.HTMLElement) || function(p) {
1136            return p.toString() === "[object SafariRemoteNotification]";
1137        }(!window['safari'] || window['safari']['pushNotification']);
1138    }(),
1139    isIEUnsupported: !!navigator.userAgent.match(/(MSIE|Trident)/),
1140    isSafariWindows: function isSafariWindows() {
1141        return !utils.isMac && utils.isSafari;
1142    },
1143    //self Execution
1144    hasWebgl: function() {
1145        try {
1146            var canvas = document.createElement('canvas');
1147            //noinspection JSUnresolvedVariable
1148            return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));
1149        } catch (e) {
1150            return false;
1151        }
1152    }(),
1153    hasES2022: function() {
1154        return Array.prototype.at !== undefined;
1155    }(),
1156    canSupport3D: function canSupport3D() {
1157        var canSupport = true;
1158        try {
1159            if (utils.hasWebgl == false) {
1160                canSupport = false;
1161                console.log("Proper Support for Canvas webgl 3D not detected!");
1162            } else if (utils.hasES2022 == false) {
1163                canSupport = false;
1164                console.log("Proper Support for 3D not extpected in older browser!");
1165            } else if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
1166                canSupport = false;
1167                console.log("Proper Support for 3D not detected for IE!");
1168            } else if (utils.isSafariWindows()) {
1169                canSupport = false;
1170                console.log("Proper Support for 3D not detected for Safari!");
1171            } else {
1172                var android = navigator.userAgent.toString().toLowerCase().match(/android\s([0-9\.]*)/i);
1173                android = android ? android[1] : undefined;
1174                if (android) {
1175                    android = parseInt(android, 10);
1176                    if (!isNaN(android) && android < 9) {
1177                        canSupport = false;
1178                        console.log("Proper Support for 3D not detected for Android below 9.0!");
1179                    }
1180                }
1181            }
1182        } catch (error) {}
1183        return canSupport;
1184    },
1185    prefix: function() {
1186        var styles = window.getComputedStyle(document.documentElement, ''), pre = Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/)[1], dom = 'WebKit|Moz|MS'.match(new RegExp('(' + pre + ')', 'i'))[1];
1187        return {
1188            dom: dom,
1189            lowercase: pre,
1190            css: '-' + pre + '-',
1191            js: pre[0].toUpperCase() + pre.substr(1)
1192        };
1193    }(),
1194    scrollIntoView: function scrollIntoView(element, reference, align) {
1195        reference = reference || element.parentNode;
1196        reference.scrollTop = element.offsetTop + (align === false ? element.offsetHeight - reference.offsetHeight : 0);
1197        reference.scrollLeft = element.offsetLeft - reference.offsetLeft;
1198    },
1199    getVisibleElements: function getVisibleElements(options) {
1200        var container = options.container;
1201        var elements = options.elements;
1202        var visible = options.visible || [];
1203        var top = container.scrollTop, bottom = top + container.clientHeight;
1204        if (bottom == 0) return visible;
1205        var minIndex = 0, maxIndex = elements.length - 1;
1206        var element = elements[minIndex];
1207        var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
1208        if (elementBottom < top) {
1209            while(minIndex < maxIndex){
1210                var currentIndex = minIndex + maxIndex >> 1;
1211                element = elements[currentIndex];
1212                elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
1213                if (elementBottom > top) {
1214                    maxIndex = currentIndex;
1215                } else {
1216                    minIndex = currentIndex + 1;
1217                }
1218            }
1219        }
1220        for(var i = minIndex; i < elements.length; i++){
1221            element = elements[i];
1222            var elementTop = element.offsetTop + element.clientTop;
1223            if (elementTop <= bottom) {
1224                visible.push(i + 1);
1225            } else {
1226                break;
1227            }
1228        }
1229        return visible;
1230    },
1231    getMouseDelta: function getMouseDelta(event) {
1232        var delta = 0;
1233        if (event['wheelDelta'] != null) {
1234            delta = event['wheelDelta'];
1235        } else if (event.detail != null) {
1236            delta = -event.detail;
1237        }
1238        return delta;
1239    },
1240    pan: function pan(viewer, point) {
1241        var reset = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1242        var origin = viewer.startPoint;
1243        var scale = viewer.app.zoomValue;
1244        var left = viewer.left + (reset === true ? 0 : point.raw.x - origin.raw.x), top = viewer.top + (reset === true ? 0 : point.raw.y - origin.raw.y);
1245        //round removes blur due to decimal value in transform.
1246        viewer.left = Math.ceil(utils.limitAt(left, -viewer.shiftWidth, viewer.shiftWidth));
1247        viewer.top = Math.ceil(utils.limitAt(top, -viewer.shiftHeight, viewer.shiftHeight));
1248        if (scale === 1) {
1249            viewer.left = 0;
1250            viewer.top = 0;
1251        }
1252        if (reset === false) {
1253            viewer.startPoint = point;
1254        }
1255    //requires updatePan to update in DOM
1256    }
1257};
1258utils.isChromeExtension = function() {
1259    return window.location.href.indexOf("chrome-extension://") === 0;
1260};
1261var NullCharactersRegExp = /\x00+/g;
1262var InvisibleCharactersRegExp = /[\x01-\x1F]/g;
1263utils.removeNullCharacters = function(str) {
1264    var replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1265    if (typeof str !== "string") {
1266        warn("The argument for removeNullCharacters must be a string.");
1267        return str;
1268    }
1269    if (replaceInvisible) {
1270        str = str.replace(InvisibleCharactersRegExp, " ");
1271    }
1272    return str.replace(NullCharactersRegExp, "");
1273};
1274defaults_DEARVIEWER.hashFocusBookFound = false;
1275utils.detectHash = function() {
1276    defaults_DEARVIEWER.preParseHash = window.location.hash;
1277    //parse hash and check if any exists
1278    /**
1279   * @type {boolean} - Introduced due to a user case where the same hash was detected twice and clicked twice.
1280   */ var prefixes = utils.getSharePrefixes();
1281    if (prefixes.indexOf("") == -1) prefixes.push("");
1282    Array.prototype.forEach.call(prefixes, function(prefix) {
1283        var hash = defaults_DEARVIEWER.preParseHash;
1284        if (hash && hash.indexOf(prefix) >= 0 && defaults_DEARVIEWER.hashFocusBookFound === false) {
1285            if (prefix.length > 0) {
1286                hash = hash.split(prefix)[1];
1287            }
1288            var id = hash.split('/')[0].replace("#", "");
1289            if (id.length > 0) {
1290                var page = hash.split('/')[1];
1291                if (page != null) {
1292                    page = page.split('/')[0];
1293                }
1294                var book;
1295                //first check for slug pattern
1296                book = utils_jQuery("[data-df-slug=" + id + "]");
1297                //then check for old slug pattern
1298                if (book.length === 0) book = utils_jQuery("[data-slug=" + id + "]");
1299                //then id pattern
1300                if (book.length === 0) book = utils_jQuery('#df-' + id + ",#" + id);
1301                //then _slug pattern
1302                if (book.length === 0) book = utils_jQuery("[data-_slug=" + id + "]");
1303                if (book.length > 0 && book.is("._df_thumb,._df_button,._df_custom,._df_link,._df_book,.df-element,.dp-element")) {
1304                    book = utils_jQuery(book[0]);
1305                    defaults_DEARVIEWER.hashFocusBookFound = true;
1306                    page = parseInt(page, 10);
1307                    utils.focusHash(book);
1308                    //case : flipbook is already created, in-page links are clicked, thus link moves the page
1309                    var app = defaults_DEARVIEWER.activeLightBox && defaults_DEARVIEWER.activeLightBox.app || book.data("df-app");
1310                    if (app != null) {
1311                        app.gotoPage(page);
1312                        app.hashNavigationEnabled = true;
1313                        utils.focusHash(app.element);
1314                        return false;
1315                    } else if (page != null) {
1316                        book.attr("data-hash-page", page); //data-has-page shall be removed after it is used
1317                    //data added attribues cannot be searched or fetched using selectors annd attr()
1318                    //when shortcode specifies page 1, but url says page 5, page 1 is added using attr data-df-page
1319                    }
1320                    book.addClass("df-hash-focused", true);
1321                    if (book.data('lightbox') != null || book.data('df-lightbox') != null) {
1322                        book.trigger("click");
1323                    } else if (book.attr("href") != null && book.attr("href").indexOf(".pdf") > -1) {
1324                        book.trigger("click");
1325                    }
1326                }
1327            }
1328        }
1329    });
1330};
1331utils.focusHash = function(element) {
1332    var _element__scrollIntoView, _element_;
1333    (_element__scrollIntoView = (_element_ = element[0]).scrollIntoView) === null || _element__scrollIntoView === void 0 ? void 0 : _element__scrollIntoView.call(_element_, {
1334        behavior: "smooth",
1335        block: "nearest",
1336        inline: "nearest"
1337    });
1338};
1339/**
1340 * Conserve aspect ratio of the original region. Useful when shrinking/enlarging
1341 * images to fit into a certain area.
1342 *
1343 * @param {Number} srcWidth width of source image
1344 * @param {Number} srcHeight height of source image
1345 * @param {Number} maxWidth maximum available width
1346 * @param {Number} maxHeight maximum available height
1347 * @return {Object} { width, height }
1348 */ utils.contain = function(srcWidth, srcHeight, maxWidth, maxHeight) {
1349    var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
1350    return {
1351        width: srcWidth * ratio,
1352        height: srcHeight * ratio
1353    };
1354};
1355utils.containUnStretched = function(srcWidth, srcHeight, maxWidth, maxHeight) {
1356    var ratio = Math.min(1, maxWidth / srcWidth, maxHeight / srcHeight);
1357    return {
1358        width: srcWidth * ratio,
1359        height: srcHeight * ratio
1360    };
1361};
1362utils.fallbackOptions = function(options) {
1363    //todo this could work without fallback
1364    if (options.share['mail'] === undefined) {
1365        options.share['mail'] = 'mailto:?subject=' + options.text.mailSubject + '&body=' + options.text.mailBody;
1366    }
1367    if (options.openPage) {
1368        options.openPage = parseInt(options.openPage, 10);
1369    }
1370    return options;
1371};
1372var getAttributes = function getAttributes(element) {
1373    var attrOptions = {};
1374    var attrKeys = {
1375        'id': '',
1376        'thumb': '',
1377        'openPage': 'data-hash-page,df-page,data-df-page,data-page,page',
1378        'target': '',
1379        'height': '',
1380        'showDownloadControl': 'data-download',
1381        'source': 'pdf-source,df-source,source',
1382        'is3D': 'webgl,is3d',
1383        'viewerType': 'viewertype,viewer-type',
1384        'pagemode': ''
1385    };
1386    for(var key in attrKeys){
1387        var aliases = (key + "," + attrKeys[key]).split(",");
1388        for(var i = 0; i < aliases.length; i++){
1389            var alias = aliases[i];
1390            if (alias !== '') {
1391                var val = element.data(alias);
1392                if (val !== null && val != "" && val != void 0) {
1393                    attrOptions[key] = val;
1394                    break;
1395                }
1396                val = element.attr(alias);
1397                if (val !== null && val != "" && val != void 0) {
1398                    attrOptions[key] = val;
1399                    break;
1400                }
1401            }
1402        }
1403    }
1404    //clear temporary attributes
1405    element.removeAttr('data-hash-page');
1406    return attrOptions;
1407};
1408//getOptions of a specific book in DOM and merge with respective variable
1409utils.getOptions = function(element) {
1410    element = utils_jQuery(element);
1411    if (element.data("df-option") == void 0 & element.data("option") == void 0) {
1412        element.data("df-option", "option_" + element.attr("id"));
1413    }
1414    if (element.attr("source") !== void 0) {
1415        element.data("df-source", element.attr("source"));
1416    }
1417    //GetOption Variable
1418    var optionVar = element.data("df-option") || element.data("option");
1419    var options = void 0;
1420    if ((typeof optionVar === "undefined" ? "undefined" : _type_of(optionVar)) === "object") {
1421        options = optionVar;
1422    } else {
1423        options = optionVar == null || optionVar === "" || window[optionVar] == null ? {} : window[optionVar];
1424    }
1425    //get all options defined in attributes
1426    var attrOptions = getAttributes(element);
1427    //merge options, attribute options override variable options
1428    options = utils_jQuery.extend(true, {}, options, attrOptions);
1429    return options;
1430};
1431utils.isTrue = function(val) {
1432    return val === "true" || val === true;
1433};
1434utils.parseInt = function(option) {
1435    return parseInt(option, 10);
1436};
1437utils.parseFloat = function(option) {
1438    return parseFloat(option);
1439};
1440utils.parseIntIfExists = function(option) {
1441    if (option !== void 0) {
1442        option = parseInt(option, 10);
1443    }
1444    return option;
1445};
1446utils.parseFloatIfExists = function(option) {
1447    if (option !== void 0) {
1448        option = parseFloat(option);
1449    }
1450    return option;
1451};
1452utils.parseBoolIfExists = function(option) {
1453    if (option !== void 0) {
1454        option = utils.isTrue(option);
1455    }
1456    return option;
1457};
1458utils.getCurveAngle = function(isRight, angle) {
1459    var threshold = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
1460    var cangle;
1461    if (isRight) {
1462        if (angle > 135) cangle = 180 - (180 - angle) * 2;
1463        else if (angle > 45) cangle = angle - 45;
1464        else cangle = 0;
1465        cangle = utils.limitAt(cangle, threshold, 180);
1466    } else {
1467        if (angle < 45) cangle = angle * 2;
1468        else if (angle < 135) cangle = angle + 45;
1469        else cangle = 180;
1470        cangle = utils.limitAt(cangle, 0, 180 - threshold);
1471    }
1472    return cangle;
1473};
1474utils.sanitizeOptions = function(options) {
1475    options.showDownloadControl = utils.parseBoolIfExists(options.showDownloadControl);
1476    options.showSearchControl = utils.parseBoolIfExists(options.showSearchControl);
1477    options.showPrintControl = utils.parseBoolIfExists(options.showPrintControl);
1478    options.flipbook3DTiltAngleLeft = utils.parseIntIfExists(options.flipbook3DTiltAngleLeft);
1479    options.flipbook3DTiltAngleUp = utils.parseIntIfExists(options.flipbook3DTiltAngleUp);
1480    options.paddingLeft = utils.parseIntIfExists(options.paddingLeft);
1481    options.paddingRight = utils.parseIntIfExists(options.paddingRight);
1482    options.paddingTop = utils.parseIntIfExists(options.paddingTop);
1483    options.paddingBottom = utils.parseIntIfExists(options.paddingBottom);
1484    options.duration = utils.parseIntIfExists(options.duration);
1485    options.rangeChunkSize = utils.parseIntIfExists(options.rangeChunkSize);
1486    options.maxTextureSize = utils.parseIntIfExists(options.maxTextureSize);
1487    options.linkTarget = utils.parseIntIfExists(options.linkTarget);
1488    options.zoomRatio = utils.parseFloatIfExists(options.zoomRatio);
1489    options.is3D = utils.parseBoolIfExists(options.is3D);
1490    options.enableAnalytics = utils.parseBoolIfExists(options.enableAnalytics);
1491    options.autoPlay = utils.parseBoolIfExists(options.autoPlay);
1492    options.autoPlayStart = utils.parseBoolIfExists(options.autoPlayStart);
1493    options.autoPlayDuration = utils.parseIntIfExists(options.autoPlayDuration);
1494    if (options.loadMoreCount !== void 0) {
1495        options.loadMoreCount = utils.parseInt(options.loadMoreCount);
1496        if (isNaN(options.loadMoreCount) || options.loadMoreCount === 0) options.loadMoreCount = -1;
1497    }
1498    if (options.source != null && (Array === options.source.constructor || Array.isArray(options.source) || _instanceof(options.source, Array))) {
1499        for(var _correct = 0; _correct < options.source.length; _correct++){
1500            options.source[_correct] = utils.httpsCorrection(options.source[_correct]);
1501        }
1502    } else {
1503        options.source = utils.httpsCorrection(options.source);
1504    }
1505    return options;
1506};
1507utils.finalizeOptions = function(options) {
1508    return options;
1509};
1510//Possible improvements: https://www.npmjs.com/package/linkifyjs
1511utils.urlify = function(text) {
1512    var myRegexp = /[a-zA-Z0-9][^\s,]{3,}\.[^\s,]+[a-zA-Z0-9]/gi;
1513    var result, urlLowCase, hits = [];
1514    while(result = myRegexp.exec(text)){
1515        var url = result[0];
1516        if ((url.match(/@/g) || []).length == 1) {
1517            if (url.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+/gi)) {
1518                hits.push({
1519                    index: result.index,
1520                    length: url.length,
1521                    text: url
1522                });
1523            }
1524        } else if (url.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&//=]*/g)) {
1525            urlLowCase = url.toLowerCase();
1526            if (urlLowCase.indexOf('http:') === 0 || urlLowCase.indexOf('https:') === 0 || urlLowCase.indexOf('www.') === 0) {
1527                hits.push({
1528                    index: result.index,
1529                    length: url.length,
1530                    text: url
1531                });
1532            }
1533        }
1534    }
1535    return hits;
1536    //can have multiple match in a text
1537    return text.replace(myRegexp, function(url, a, b) {
1538        if (url.indexOf("@") > -1) {
1539            //this is a mail just verify if valid
1540            if (url.match(/^((?!\.)[\w_.-]*[^.])(@\w+)(\.\w+(\.\w+)?[^.\W])$/gi)) {
1541                var url2 = url.toLowerCase();
1542                if (url.indexOf("mailto:" === -1)) url2 = "mailto:" + url;
1543                utils.log("AutoLink: " + url2 + " for " + url);
1544                return '<a href="' + url2 + '" ' + 'class="df-autolink" target="_blank">' + url + '</a>';
1545            }
1546        } else {
1547            //this is a domain like just verify if valid
1548            if (url.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_\+.~#?&//=]*/g)) {
1549                var url2 = url;
1550                if (url.indexOf('www.') === 0) {
1551                    url2 = 'http://' + url;
1552                } else if (url2.indexOf('http:') === -1 && url2.indexOf('https:') === -1) {
1553                    return url;
1554                }
1555                utils.log("AutoLink: " + url2 + " for " + url);
1556                return '<a href="' + url2 + '" class="df-autolink" target="_blank">' + url + '</a>';
1557            }
1558        }
1559        return url;
1560    });
1561};
1562utils.oldurlify = function(text) {
1563    //https://regex101.com/r/cX0pJ8/1
1564    var urlRegex = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/g;
1565    // urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
1566    // noinspection HttpUrlsUsage
1567    return text.replace(urlRegex, function(url, b, c, d, e) {
1568        url = url.toLowerCase();
1569        var url2 = url;
1570        if (url.indexOf(':') > 0 && url.indexOf('http:') === -1 && url.indexOf('https:') === -1) {
1571            utils.log("AutoLink Rejected: " + url2 + " for " + url);
1572            return url;
1573        } else if (url.indexOf('www.') === 0) {
1574            url2 = 'http://' + url;
1575        } else if (url.indexOf('http://') === 0 || url.indexOf('https://') === 0) {} else if (url.indexOf('mailto:') === 0) {} else if (url.indexOf('@') > 0) {
1576            url2 = 'mailto:' + url;
1577            var mailformat = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
1578            if (url.match(mailformat) === null) {
1579                utils.log("AutoLink Rejected: " + url2 + " for " + url);
1580                return url;
1581            }
1582        }
1583        utils.log("AutoLink: " + url2 + " for " + url);
1584        return '<a href="' + url2 + '" class="df-autolink" target="_blank">' + url + '</a>';
1585    });
1586};
1587// Test via a getter in the options object to see if the passive property is accessed
1588utils.supportsPassive = false;
1589try {
1590    var opts = Object.defineProperty({}, 'passive', {
1591        get: function get() {
1592            utils.supportsPassive = true;
1593        }
1594    });
1595    window.addEventListener("testPassive", null, opts);
1596    window.removeEventListener("testPassive", null, opts);
1597} catch (e) {}
1598function getDataFromClass(el) {
1599    var prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "dvcss_e_";
1600    var classList = el.classList, className;
1601    for(var i = 0; i < classList.length; i++){
1602        className = classList[i];
1603        if (className.indexOf(prefix) === 0) return className;
1604    }
1605    return null;
1606}
1607defaults_DEARVIEWER.parseCSSElements = function() {
1608    utils_jQuery(".dvcss").each(function() {
1609        var el = utils_jQuery(this);
1610        var cssData = getDataFromClass(el[0]);
1611        el.removeClass(cssData).removeClass("dvcss");
1612        cssData = cssData.replace("dvcss_e_", "");
1613        var data;
1614        try {
1615            data = JSON.parse(atob(cssData));
1616        } catch (e) {}
1617        if (data) {
1618            var option_id = "df_option_" + data.id;
1619            window[option_id] = utils_jQuery.extend(true, {}, window[option_id], data);
1620            el.addClass("df-element");
1621            if (data.lightbox !== "none") {
1622                el.attr("data-df-lightbox", data.lightbox === void 0 ? "custom" : data.lightbox);
1623                if (data.lightbox == "thumb") el.attr("data-df-thumb", data.pdfThumb);
1624                if (data.thumbLayout) el.attr("data-df-thumb-layout", data.thumbLayout);
1625                if (data.apl) el.attr("apl", data.apl);
1626            }
1627            el.data("df-option", option_id);
1628            //attr is required, data("slug") cannot be used in selector
1629            el.attr("data-df-slug", data.slug);
1630            el.attr("id", "df_" + data.id);
1631        }
1632    });
1633};
1634defaults_DEARVIEWER.parseThumbs = function(args) {
1635    args.element.html("");
1636    if (args.thumbURL == null || args.thumbURL.toString().trim() == '') {
1637        args.element.addClass("df-thumb-not-found");
1638        args.thumbURL = defaults_DEARVIEWER.defaults.popupThumbPlaceholder;
1639    }
1640    var titleElement = utils_jQuery("<span class='df-book-title'>").html(args.title);
1641    var wrapperElement = utils_jQuery("<div class='df-book-wrapper'>").appendTo(args.element);
1642    wrapperElement.append(utils_jQuery("<div class='df-book-page1'>"));
1643    wrapperElement.append(utils_jQuery("<div class='df-book-page2'>"));
1644    var coverElement = utils_jQuery("<div class='df-book-cover'>").append(titleElement).appendTo(wrapperElement);
1645    var image = utils_jQuery('<img width="210px" height="297px" class="df-lazy" alt="' + args.title + '"/>');
1646    image.attr('data-src', args.thumbURL);
1647    image.attr('src', defaults_DEARVIEWER.defaults.popupThumbPlaceholder);
1648    coverElement.prepend(image);
1649    defaults_DEARVIEWER.addLazyElement(image[0]);
1650    if (defaults_DEARVIEWER.defaults.displayLightboxPlayIcon === true) coverElement.addClass("df-icon-play-popup");
1651    if (args.thumbLayout === "book-title-top") {
1652        titleElement.prependTo(args.element);
1653    } else if (args.thumbLayout === "book-title-bottom" || args.thumbLayout === "cover-title") {
1654        if (args.hasShelf) {
1655            args.thumbLayout = "book-title-fixed";
1656        } else {
1657            titleElement.appendTo(args.element);
1658        }
1659        if (defaults_DEARVIEWER.defaults.displayLightboxPlayIcon === true) {
1660            args.element.removeClass("df-icon-play-popup");
1661            wrapperElement.addClass("df-icon-play-popup");
1662        }
1663    }
1664    args.element.addClass("df-tl-" + args.thumbLayout);
1665    args.element.attr("title", args.title);
1666};
1667defaults_DEARVIEWER.initId = 10;
1668defaults_DEARVIEWER.embeds = [];
1669defaults_DEARVIEWER.removeEmbeds = [];
1670defaults_DEARVIEWER.removeEmbedsLimit = utils.isMobile ? 1 : 2;
1671defaults_DEARVIEWER.parseNormalElements = function() {
1672    utils_jQuery('.df-posts').each(function() {
1673        if (defaults_DEARVIEWER.defaults.loadMoreCount === false || defaults_DEARVIEWER.defaults.loadMoreCount === -1) return;
1674        var postsWrapper = utils_jQuery(this);
1675        var parsed = postsWrapper.data("df-parsed");
1676        //skip if already parsed or failed
1677        if (parsed !== "true") {
1678            postsWrapper.data("df-parsed", "true");
1679            postsWrapper.attr("df-parsed", "true"); //backward-compatibility - issue #374 https://github.com/deepak-ghimire/dearviewer/issues/374
1680            var count = 0;
1681            var books = postsWrapper.find('.df-element');
1682            var totalBooks = books.length;
1683            books.each(function() {
1684                //skip first n books
1685                count++;
1686                if (count > defaults_DEARVIEWER.defaults.loadMoreCount) utils_jQuery(this).attr("skip-parse", "true");
1687            });
1688            if (totalBooks > defaults_DEARVIEWER.defaults.loadMoreCount) {
1689                postsWrapper.append("<div class='df-load-more-button-wrapper'><div class='df-load-more-button'>Load More..</div></div>");
1690            }
1691        }
1692    });
1693    defaults_DEARVIEWER.triggerId = 10;
1694    utils_jQuery('.df-element').each(function() {
1695        var element = utils_jQuery(this);
1696        if (element.attr("skip-parse") === "true") return;
1697        var isParsed = element.data("df-parsed");
1698        if (isParsed !== "true") {
1699            element.data("df-parsed", "true");
1700            element.attr("df-parsed", "true"); //backward-compatibility
1701            var lightboxType = element.data("df-lightbox") || element.data("lightbox");
1702            if (lightboxType === void 0) {
1703                element.addClass("df-lazy-embed");
1704                defaults_DEARVIEWER.addLazyElement(element[0]);
1705            //element.dearviewer();
1706            } else {
1707                element.addClass("df-popup-" + lightboxType);
1708                if (lightboxType === "thumb") {
1709                    var thumbLayout = element.data("df-thumb-layout") || defaults_DEARVIEWER.defaults.thumbLayout;
1710                    var thumbURL = utils.httpsCorrection(element.data("df-thumb"));
1711                    element.removeAttr("data-thumb").removeAttr("data-thumb-layout");
1712                    var innerText = element.html().trim();
1713                    if (innerText === undefined || innerText === "") {
1714                        innerText = "Click to Open";
1715                    }
1716                    var hasShelf = element.parent().hasClass('df-has-shelf');
1717                    defaults_DEARVIEWER.parseThumbs({
1718                        element: element,
1719                        thumbURL: thumbURL,
1720                        title: innerText,
1721                        thumbLayout: thumbLayout,
1722                        hasShelf: hasShelf
1723                    });
1724                    if (hasShelf) element.after(utils_jQuery("<df-post-shelf>"));
1725                } else if (lightboxType === "button") {
1726                    if (defaults_DEARVIEWER.defaults.buttonClass) {
1727                        element.addClass(defaults_DEARVIEWER.defaults.buttonClass);
1728                    }
1729                }
1730            }
1731            var triggers = element.attr("data-trigger");
1732            if (triggers != null && triggers.length > 1) {
1733                triggers = triggers.split(",");
1734                defaults_DEARVIEWER.triggerId++;
1735                triggers.forEach(function(trigger) {
1736                    element.attr("df-trigger-id", defaults_DEARVIEWER.triggerId);
1737                    utils_jQuery("#" + trigger).addClass("df-trigger").attr("df-trigger", defaults_DEARVIEWER.triggerId);
1738                });
1739            }
1740        }
1741    });
1742    defaults_DEARVIEWER.handleLazy = function() {
1743        //remove removeembeds
1744        var appId;
1745        if (defaults_DEARVIEWER.removeEmbeds.length > defaults_DEARVIEWER.removeEmbedsLimit) {
1746            appId = defaults_DEARVIEWER.removeEmbeds.shift();
1747            if (appId) {
1748                var element = utils_jQuery("[initID='" + appId + "']");
1749                if (element.length > 0) {
1750                    var app = element.data("df-app");
1751                    if (app) {
1752                        element.attr("data-df-page", app.currentPageNumber);
1753                        utils.log("Removed app id " + appId);
1754                        app.dispose();
1755                        app = null;
1756                    }
1757                }
1758            }
1759        }
1760        //add embeds
1761        appId = defaults_DEARVIEWER.embeds.shift();
1762        if (appId) {
1763            var element1 = utils_jQuery("[initID='" + appId + "']");
1764            if (element1.length > 0) {
1765                if (element1.is("img")) {
1766                    if (element1.hasClass("df-lazy")) {
1767                        element1.attr("src", element1.attr("data-src"));
1768                        element1.removeAttr("data-src");
1769                        element1.removeClass("df-lazy");
1770                        defaults_DEARVIEWER.lazyObserver.unobserve(element1[0]);
1771                        defaults_DEARVIEWER.handleLazy();
1772                    } else {
1773                        utils.log("Prevent this");
1774                        defaults_DEARVIEWER.handleLazy();
1775                    }
1776                } else {
1777                    var app1 = element1.data("df-app");
1778                    if (app1 == null) {
1779                        element1.dearviewer();
1780                    } else {
1781                        app1.softInit();
1782                    }
1783                    utils.log("Created app id " + appId);
1784                }
1785            }
1786        }
1787        if (defaults_DEARVIEWER.removeEmbeds.length <= defaults_DEARVIEWER.removeEmbedsLimit && defaults_DEARVIEWER.embeds.length == 0) {
1788            defaults_DEARVIEWER.checkRequestQueue = null;
1789        }
1790    };
1791};
1792/** Then we set up an intersection observer watching over those images and whenever any of those becomes visible on the view then replace the placeholder image with actual one, remove the non-loaded class and then unobserve for that element **/ defaults_DEARVIEWER.lazyObserver = {
1793    observe: function observe(element) {
1794        element = utils_jQuery(element);
1795        if (element.is("img")) {
1796            if (element.hasClass("df-lazy")) {
1797                element.attr("src", element.attr("data-src"));
1798                element.removeAttr("data-src");
1799                element.removeClass("df-lazy");
1800            }
1801        } else {
1802            element.dearviewer();
1803        }
1804    }
1805};
1806if (typeof IntersectionObserver === 'function') {
1807    defaults_DEARVIEWER.lazyObserver = new IntersectionObserver(function(entries, observer) {
1808        entries.forEach(function(entry) {
1809            var lazyImage = utils_jQuery(entry.target);
1810            var initId = lazyImage.attr("initID"), index;
1811            if (entry.isIntersecting) {
1812                if (!lazyImage.attr("initID")) {
1813                    lazyImage.attr("initID", defaults_DEARVIEWER.initId);
1814                    initId = defaults_DEARVIEWER.initId.toString();
1815                    defaults_DEARVIEWER.initId++;
1816                }
1817                index = defaults_DEARVIEWER.removeEmbeds.indexOf(initId);
1818                if (index > -1) {
1819                    defaults_DEARVIEWER.removeEmbeds.splice(index, 1); // 2nd parameter means remove one item only
1820                    utils.log("Removed id " + initId + "from Removal list");
1821                } else {
1822                    index = defaults_DEARVIEWER.embeds.indexOf(initId);
1823                    if (index == -1) {
1824                        defaults_DEARVIEWER.embeds.push(initId);
1825                        utils.log("Added id " + initId + "to Add list");
1826                    }
1827                }
1828            } else {
1829                if (initId) {
1830                    index = defaults_DEARVIEWER.embeds.indexOf(initId);
1831                    if (index > -1) {
1832                        defaults_DEARVIEWER.embeds.splice(index, 1); // 2nd parameter means remove one item only
1833                        utils.log("Removed id " + initId + " from Add list");
1834                    } else {
1835                        index = defaults_DEARVIEWER.removeEmbeds.indexOf(initId);
1836                        if (index == -1) {
1837                            defaults_DEARVIEWER.removeEmbeds.push(initId);
1838                            utils.log("Added id " + initId + " to Removal list");
1839                        }
1840                    }
1841                }
1842            }
1843            requestCount = 0;
1844            if ((defaults_DEARVIEWER.removeEmbeds.length > defaults_DEARVIEWER.removeEmbedsLimit || defaults_DEARVIEWER.embeds.length > 0) && defaults_DEARVIEWER.checkRequestQueue == null) {
1845                //start the requestQueue
1846                defaults_DEARVIEWER.checkRequestQueue = function() {
1847                    requestCount++;
1848                    if (defaults_DEARVIEWER.checkRequestQueue) {
1849                        requestAnimationFrame(function() {
1850                            if (defaults_DEARVIEWER && defaults_DEARVIEWER.checkRequestQueue) defaults_DEARVIEWER.checkRequestQueue();
1851                        });
1852                    }
1853                    if (requestCount > 20) {
1854                        requestCount = 0;
1855                        defaults_DEARVIEWER.handleLazy();
1856                    }
1857                };
1858                defaults_DEARVIEWER.checkRequestQueue();
1859            }
1860        });
1861    });
1862}
1863var requestCount = 0;
1864defaults_DEARVIEWER.addLazyElement = function(element) {
1865    defaults_DEARVIEWER.lazyObserver.observe(element);
1866};
1867//scan the whole document for un-parsed PDFs and convert them to viewer and flipbooks
1868defaults_DEARVIEWER.parseElements = utils.parseElements = function() {
1869    defaults_DEARVIEWER.parseCSSElements();
1870    defaults_DEARVIEWER.parseNormalElements();
1871};
1872//jQuery events
1873defaults_DEARVIEWER.initUtils = function() {
1874    utils.detectScriptLocation();
1875    var body = utils_jQuery('body');
1876    //assign webkit so that thumbs and other functions can be optimized
1877    if (utils.isSafari || utils.isIOS) {
1878        body.addClass("df-ios");
1879    }
1880    body.on('click', function() {});
1881    body.on('click', '.df-posts .df-load-more-button', function() {
1882        var postsWrapper = utils_jQuery(this).closest(".df-posts");
1883        if (postsWrapper.length > 0) {
1884            var count = 0;
1885            var posts = postsWrapper.find('.df-element');
1886            posts.each(function() {
1887                var post = utils_jQuery(this);
1888                if (post.attr("skip-parse") === "true") {
1889                    //skip first 10
1890                    if (count < defaults_DEARVIEWER.defaults.loadM
1890oreCount) post.removeAttr("skip-parse");
1891                    count++;
1892                }
1893            });
1894            defaults_DEARVIEWER.parseNormalElements();
1895        }
1896    });
1897    if (defaults_DEARVIEWER.defaults.shelfImage && defaults_DEARVIEWER.defaults.shelfImage != '') {
1898        body.append("<style>.df-has-shelf df-post-shelf:before, .df-has-shelf df-post-shelf:after{background-image: url('" + defaults_DEARVIEWER.defaults.shelfImage + "');}</style>");
1899    }
1900};
1901
1902
1903;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/base-viewer.js
1904function _class_call_check(instance, Constructor) {
1905    if (!(instance instanceof Constructor)) {
1906        throw new TypeError("Cannot call a class as a function");
1907    }
1908}
1909function _defineProperties(target, props) {
1910    for(var i = 0; i < props.length; i++){
1911        var descriptor = props[i];
1912        descriptor.enumerable = descriptor.enumerable || false;
1913        descriptor.configurable = true;
1914        if ("value" in descriptor) descriptor.writable = true;
1915        Object.defineProperty(target, descriptor.key, descriptor);
1916    }
1917}
1918function _create_class(Constructor, protoProps, staticProps) {
1919    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1920    if (staticProps) _defineProperties(Constructor, staticProps);
1921    return Constructor;
1922}
1923
1924var base_viewer_DV = defaults_DEARVIEWER;
1925var base_viewer_utils = defaults_DEARVIEWER.utils;
1926var BaseViewer = /*#__PURE__*/ function() {
1927    "use strict";
1928    function BaseViewer(options, appContext) {
1929        _class_call_check(this, BaseViewer);
1930        this.pages = [];
1931        this.app = appContext;
1932        this.parentElement = this.app.viewerContainer;
1933        var viewerClass = "df-viewer " + (options.viewerClass || "");
1934        this.element = jQuery('<div>', {
1935            class: viewerClass
1936        });
1937        this.parentElement.append(this.element);
1938        this.wrapper = jQuery('<div>', {
1939            class: 'df-viewer-wrapper'
1940        });
1941        this.element.append(this.wrapper);
1942        this.oldBasePageNumber = 0;
1943        this.pages = [];
1944        this.minZoom = 1;
1945        this.maxZoom = 4;
1946        this.swipeThreshold = 20;
1947        this.stageDOM = null;
1948        this.events = {};
1949        this.arrowKeysAction = options.arrowKeysAction;
1950        this.clickAction = options.clickAction;
1951        this.scrollAction = options.scrollAction;
1952        this.dblClickAction = options.dblClickAction;
1953        this.pageBuffer = [];
1954        this.pageBufferSize = 10;
1955    }
1956    _create_class(BaseViewer, [
1957        {
1958            key: "init",
1959            value: function init() {}
1960        },
1961        {
1962            key: "softDispose",
1963            value: function softDispose() {}
1964        },
1965        {
1966            key: "updateBuffer",
1967            value: function updateBuffer(page) {}
1968        },
1969        {
1970            key: "pageResetCallback",
1971            value: function pageResetCallback(page) {}
1972        },
1973        {
1974            key: "initCustomControls",
1975            value: function initCustomControls() {}
1976        },
1977        {
1978            key: "_getInnerWidth",
1979            value: function _getInnerWidth() {
1980                return this.app.dimensions.containerWidth - this.app.dimensions.padding.width - this.app.dimensions.offset.width;
1981            }
1982        },
1983        {
1984            key: "_getInnerHeight",
1985            value: function _getInnerHeight() {
1986                //individual viewers don't calculate on maxHeight
1987                return this.app.dimensions.maxHeight - this.app.dimensions.padding.height;
1988            }
1989        },
1990        {
1991            key: "_getOuterHeight",
1992            value: function _getOuterHeight(height) {
1993                return height;
1994            }
1995        },
1996        {
1997            key: "dispose",
1998            value: function dispose() {
1999                if (this.stageDOM) {
2000                    this.stageDOM.removeEventListener("mousemove", this.events.mousemove, false);
2001                    this.stageDOM.removeEventListener("mousedown", this.events.mousedown, false);
2002                    this.stageDOM.removeEventListener("mouseup", this.events.mouseup, false);
2003                    this.stageDOM.removeEventListener("touchmove", this.events.mousemove, false);
2004                    this.stageDOM.removeEventListener("touchstart", this.events.mousedown, false);
2005                    this.stageDOM.removeEventListener("touchend", this.events.mouseup, false);
2006                    this.stageDOM.removeEventListener("dblclick", this.events.dblclick, false);
2007                    this.stageDOM.removeEventListener("scroll", this.events.scroll, false);
2008                    this.stageDOM.removeEventListener("mousewheel", this.events.mousewheel, false);
2009                    this.stageDOM.removeEventListener("DOMMouseScroll", this.events.mousewheel, false);
2010                }
2011                this.events = null;
2012                this.stageDOM = null;
2013                this.element.remove();
2014            }
2015        },
2016        {
2017            /**
2018   * Verify page size differences in the document
2019   */ key: "checkDocumentPageSizes",
2020            value: function checkDocumentPageSizes() {}
2021        },
2022        {
2023            /**
2024   * Determines which page to jump in viewer when a PDF link is clicked. Pagenumber passed from PDF provider.
2025   * Clicked link provides absolute number but a number relatiev to viewer is required.
2026   * @param pageNumber
2027   * @returns {number}
2028   */ key: "getViewerPageNumber",
2029            value: function getViewerPageNumber(pageNumber) {
2030                return pageNumber;
2031            }
2032        },
2033        {
2034            /**
2035   * Determines which page to render from PDF document. Pagenumber passed from viewer.
2036   * PDF document page and viewer page numbers are different in some cases.
2037   * @param pageNumber
2038   * @returns {number}
2039   */ key: "getDocumentPageNumber",
2040            value: function getDocumentPageNumber(pageNumber) {
2041                return pageNumber;
2042            }
2043        },
2044        {
2045            key: "getRenderContext",
2046            value: function getRenderContext(pdfPage, param) {
2047                var app = this.app, provider = app.provider, pageNumber = param.pageNumber, textureTarget = base_viewer_utils.ifdef(param.textureTarget, defaults_DEARVIEWER.TEXTURE_TARGET.VIEWER);
2048                var pageFit = app.dimensions.pageFit;
2049                var pageViewport = provider.viewPorts[pageNumber];
2050                var dimen = app.viewer.getTextureSize(param);
2051                var textureCacheIndex = null;
2052                if (textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) {
2053                    textureCacheIndex = app.thumbSize;
2054                } else {
2055                    textureCacheIndex = Math.floor(dimen.height);
2056                }
2057                if (provider.getCache(pageNumber, textureCacheIndex) !== undefined) {
2058                    return;
2059                }
2060                var scale = dimen.height / pageViewport.height;
2061                var canvas = document.createElement('canvas'), viewport = this.filterViewPort(pdfPage.getViewport({
2062                    scale: scale,
2063                    rotation: pdfPage._pageInfo.rotate + app.options.pageRotation
2064                }), pageNumber);
2065                if (textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) {
2066                    // in-case the thumb size is wider
2067                    if (viewport.width / viewport.height > 180 / app.thumbSize) {
2068                        scale = scale * 180 / viewport.width;
2069                    } else {
2070                        scale = scale * app.thumbSize / viewport.height;
2071                    }
2072                    viewport = this.filterViewPort(pdfPage.getViewport({
2073                        scale: scale,
2074                        rotation: pdfPage._pageInfo.rotate + app.options.pageRotation
2075                    }), pageNumber);
2076                }
2077                canvas.height = Math.floor(viewport.height);
2078                canvas.width = Math.floor(viewport.width);
2079                // if (app.pageScaling === DEARVIEWER.PAGE_SCALE.PAGE_FIT) {
2080                var error = Math.abs(canvas.width - dimen.width) / dimen.width * 100;
2081                if (error > 0.001 && error < 2) {
2082                    canvas.width = Math.floor(dimen.width);
2083                    canvas.height = Math.floor(dimen.height);
2084                }
2085                // }
2086                app.viewer.filterViewPortCanvas(viewport, canvas, pageNumber);
2087                return {
2088                    canvas: canvas,
2089                    canvasContext: canvas.getContext('2d', {
2090                        willReadFrequently: defaults_DEARVIEWER.defaults.canvasWillReadFrequently === true
2091                    }),
2092                    viewport: viewport
2093                };
2094            }
2095        },
2096        {
2097            key: "filterViewPort",
2098            value: function filterViewPort(viewport, pageNumber) {
2099                return viewport;
2100            }
2101        },
2102        {
2103            key: "getViewPort",
2104            value: function getViewPort(pageNumber) {
2105                var fallback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
2106                var viewPort = this.app.provider.viewPorts[pageNumber];
2107                if (fallback) return viewPort !== null && viewPort !== void 0 ? viewPort : this.app.provider.defaultPage.viewPort;
2108                return viewPort;
2109            }
2110        },
2111        {
2112            key: "pagesReady",
2113            value: function pagesReady() {}
2114        },
2115        {
2116            key: "onReady",
2117            value: function onReady() {}
2118        },
2119        {
2120            key: "filterViewPortCanvas",
2121            value: function filterViewPortCanvas(viewport) {}
2122        },
2123        {
2124            key: "finalizeAnnotations",
2125            value: function finalizeAnnotations() {}
2126        },
2127        {
2128            key: "finalizeTextContent",
2129            value: function finalizeTextContent() {}
2130        },
2131        {
2132            key: "updateTextContent",
2133            value: function updateTextContent(pageNumber) {
2134                if (pageNumber == void 0) {
2135                    pageNumber = this.getBasePage(pageNumber);
2136                }
2137                this.app.provider.processTextContent(pageNumber, this.getTextElement(pageNumber, true));
2138            }
2139        },
2140        {
2141            key: "isActivePage",
2142            value: function isActivePage(pageNumber) {
2143                return pageNumber === this.app.currentPageNumber;
2144            }
2145        },
2146        {
2147            key: "initEvents",
2148            value: function initEvents() {
2149                var viewer = this;
2150                var stageDOM = viewer.stageDOM = base_viewer_utils.ifdef(viewer.stageDOM, viewer.parentElement[0]);
2151                if (stageDOM) {
2152                    // Use our detect's results. passive applied if supported, capture will be false either way.
2153                    // let opts = utils.supportsPassive ? {passive: true} : false; //passive is not possible. like it's in https://www.google.com/maps/
2154                    var opts = false;
2155                    stageDOM.addEventListener("mousemove", viewer.events.mousemove = viewer.mouseMove.bind(viewer), false);
2156                    stageDOM.addEventListener("mousedown", viewer.events.mousedown = viewer.mouseDown.bind(viewer), false);
2157                    stageDOM.addEventListener("mouseup", viewer.events.mouseup = viewer.mouseUp.bind(viewer), false);
2158                    stageDOM.addEventListener("touchmove", viewer.events.mousemove = viewer.mouseMove.bind(viewer), opts);
2159                    stageDOM.addEventListener("touchstart", viewer.events.mousedown = viewer.mouseDown.bind(viewer), opts);
2160                    stageDOM.addEventListener("touchend", viewer.events.mouseup = viewer.mouseUp.bind(viewer), false);
2161                    stageDOM.addEventListener("dblclick", viewer.events.dblclick = viewer.dblclick.bind(viewer), false);
2162                    stageDOM.addEventListener("scroll", viewer.events.scroll = viewer.onScroll.bind(viewer), false);
2163                    stageDOM.addEventListener("mousewheel", viewer.events.mousewheel = viewer.mouseWheel.bind(viewer), opts);
2164                    stageDOM.addEventListener('DOMMouseScroll', viewer.events.mousewheel = viewer.mouseWheel.bind(viewer), false);
2165                }
2166                this.startTouches = null;
2167                this.lastScale = null;
2168                this.startPoint = null;
2169            }
2170        },
2171        {
2172            key: "refresh",
2173            value: function refresh() {}
2174        },
2175        {
2176            key: "reset",
2177            value: function reset() {}
2178        },
2179        {
2180            key: "eventToPoint",
2181            value: function eventToPoint(event) {
2182                var point = {
2183                    x: event.clientX,
2184                    y: event.clientY
2185                };
2186                point.x = point.x - this.app.viewerContainer[0].getBoundingClientRect().left;
2187                point.y = point.y - this.app.viewerContainer[0].getBoundingClientRect().top;
2188                return {
2189                    raw: point
2190                };
2191            }
2192        },
2193        {
2194            key: "mouseMove",
2195            value: function mouseMove(event) {
2196                event = base_viewer_utils.fixMouseEvent(event);
2197                this.pinchMove(event);
2198                if (this.pinchZoomDirty === true) {
2199                    event.preventDefault();
2200                }
2201                if (this.startPoint && this.pinchZoomDirty != true) {
2202                    this.pan(this.eventToPoint(event));
2203                    event.preventDefault();
2204                }
2205            }
2206        },
2207        {
2208            key: "mouseDown",
2209            value: function mouseDown(event) {
2210                event = base_viewer_utils.fixMouseEvent(event);
2211                this.pinchDown(event);
2212                this.startPoint = this.eventToPoint(event);
2213            }
2214        },
2215        {
2216            key: "mouseUp",
2217            value: function mouseUp(event) {
2218                event = base_viewer_utils.fixMouseEvent(event);
2219                var viewer = this;
2220                if (viewer.pinchZoomDirty === true) {
2221                    event.preventDefault();
2222                }
2223                var point = viewer.eventToPoint(event);
2224                var element = event.target || event.originalTarget; //check to see if the clicked element is a link, if so skip turn
2225                var isClick = viewer.startPoint && point.x === viewer.startPoint.x && point.y === viewer.startPoint.y && element.nodeName !== "A";
2226                if (event.ctrlKey === true && isClick) {
2227                    this.zoomOnPoint(point);
2228                }
2229                this.pinchUp(event);
2230                this.startPoint = null;
2231            }
2232        },
2233        {
2234            key: "pinchDown",
2235            value: function pinchDown(event) {
2236            //extened in pro
2237            }
2238        },
2239        {
2240            key: "pinchUp",
2241            value: function pinchUp(event) {
2242            //extened in pro
2243            }
2244        },
2245        {
2246            key: "pinchMove",
2247            value: function pinchMove(event) {
2248            //extened in pro
2249            }
2250        },
2251        {
2252            key: "updateTemporaryScale",
2253            value: function updateTemporaryScale() {
2254                var reset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
2255                // return;
2256                if (reset === true) {
2257                    this.parentElement[0].style.transform = "none";
2258                } else if (this.app.viewer.zoomCenter) {
2259                    var scale = this.app.viewer.pinchZoomUpdateScale;
2260                    this.parentElement[0].style.transformOrigin = this.app.viewer.zoomCenter.x + "px " + this.app.viewer.zoomCenter.y + "px";
2261                    this.parentElement[0].style.transform = "scale3d(" + scale + "," + scale + ",1)";
2262                }
2263            }
2264        },
2265        {
2266            key: "pan",
2267            value: function pan(point) {
2268                var reset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
2269                this.panRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
2270                base_viewer_utils.pan(this, point, reset);
2271            }
2272        },
2273        {
2274            key: "updatePan",
2275            value: function updatePan() {
2276                this.element.css({
2277                    transform: "translate3d(" + this.left + "px," + this.top + "px,0)"
2278                });
2279            }
2280        },
2281        {
2282            key: "dblclick",
2283            value: function dblclick(event) {}
2284        },
2285        {
2286            key: "onScroll",
2287            value: function onScroll(event) {}
2288        },
2289        {
2290            key: "mouseWheel",
2291            value: function mouseWheel(event) {
2292                var viewer = this, app = this.app, delta = base_viewer_utils.getMouseDelta(event);
2293                //detect trackpad or CTRL + mouse scroll zoom, both use CTRL + scroll method
2294                var isValidZoomKey = event.ctrlKey === true;
2295                var isValidZoomOption = app.options.mouseScrollAction === defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.ZOOM && (app.options.isLightBox === true || app.isFullscreen === true);
2296                //if it CTRL mousewheel. it is zoom.
2297                if (isValidZoomKey || isValidZoomOption) {
2298                    if (delta > 0 || delta < 0) {
2299                        event.preventDefault();
2300                        app.viewer.zoomCenter = this.eventToPoint(event).raw;
2301                        app.zoom(delta);
2302                        app.ui.update();
2303                    }
2304                } else if (app.options.mouseScrollAction === defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.NAV) {
2305                    if (delta > 0) {
2306                        app.next();
2307                    } else if (delta < 0) {
2308                        app.prev();
2309                    }
2310                }
2311            }
2312        },
2313        {
2314            key: "zoomOnPoint",
2315            value: function zoomOnPoint(point) {
2316                this.app.viewer.zoomCenter = point.raw;
2317                this.app.zoom(1);
2318            }
2319        },
2320        {
2321            key: "getVisiblePages",
2322            value: function getVisiblePages() {
2323                this.visiblePagesCache = [];
2324                return {
2325                    main: this.visiblePagesCache,
2326                    buffer: []
2327                };
2328            }
2329        },
2330        {
2331            key: "getBasePage",
2332            value: function getBasePage() {
2333                return this.app.currentPageNumber;
2334            }
2335        },
2336        {
2337            key: "isFirstPage",
2338            value: function isFirstPage(pageNumber) {
2339                if (pageNumber === void 0) pageNumber = this.app.currentPageNumber;
2340                return pageNumber === 1;
2341            }
2342        },
2343        {
2344            key: "isLastPage",
2345            value: function isLastPage(pageNumber) {
2346                if (pageNumber === void 0) pageNumber = this.app.currentPageNumber;
2347                return pageNumber === this.app.pageCount;
2348            }
2349        },
2350        {
2351            key: "isEdgePage",
2352            value: function isEdgePage(pageNumber) {
2353                if (pageNumber === void 0) pageNumber = this.app.currentPageNumber;
2354                return pageNumber === 1 || pageNumber === this.app.pageCount;
2355            }
2356        },
2357        {
2358            key: "checkRequestQueue",
2359            value: function checkRequestQueue() {
2360                var REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS;
2361                if (this.panRequestStatus === REQUEST_STATUS.ON) {
2362                    this.updatePan();
2363                    this.panRequestStatus = REQUEST_STATUS.OFF;
2364                }
2365                if (this.app.viewer.pinchZoomRequestStatus === REQUEST_STATUS.ON) {
2366                    this.app.viewer.updateTemporaryScale();
2367                    this.app.viewer.pinchZoomRequestStatus = REQUEST_STATUS.OFF;
2368                }
2369            }
2370        },
2371        {
2372            key: "isAnimating",
2373            value: function isAnimating() {
2374                return false;
2375            }
2376        },
2377        {
2378            key: "updatePendingStatusClass",
2379            value: function updatePendingStatusClass(status) {
2380                if (status === void 0) status = this.isAnimating();
2381                this.app.container.toggleClass("df-pending", status);
2382            }
2383        },
2384        {
2385            key: "initPages",
2386            value: function initPages() {}
2387        },
2388        {
2389            key: "resize",
2390            value: function resize() {}
2391        },
2392        {
2393            key: "determinePageMode",
2394            value: function determinePageMode() {}
2395        },
2396        {
2397            key: "zoom",
2398            value: function zoom() {}
2399        },
2400        {
2401            key: "gotoPageCallBack",
2402            value: function gotoPageCallBack() {
2403                this.requestRefresh();
2404            }
2405        },
2406        {
2407            key: "requestRefresh",
2408            value: function requestRefresh() {
2409                var status = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
2410                this.app.refreshRequestStatus = status === true ? base_viewer_DV.REQUEST_STATUS.ON : base_viewer_DV.REQUEST_STATUS.OFF;
2411            }
2412        },
2413        {
2414            key: "getPageByNumber",
2415            value: function getPageByNumber(pageNumber) {
2416                var pages = this.pages, page = undefined;
2417                if (this.app.isValidPage(pageNumber)) {
2418                    for(var count = 0; count < pages.length; count++){
2419                        if (pageNumber === pages[count].pageNumber) {
2420                            page = pages[count];
2421                            break;
2422                        }
2423                    }
2424                }
2425                return page;
2426            }
2427        },
2428        {
2429            key: "changeAnnotation",
2430            value: function changeAnnotation() {
2431                return false;
2432            }
2433        },
2434        {
2435            key: "getAnnotationElement",
2436            value: function getAnnotationElement(pageNumber) {
2437                var clean = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
2438                var page = this.getPageByNumber(pageNumber);
2439                if (page === undefined) return undefined;
2440                if (page.annotationElement === undefined) {
2441                    page.annotationElement = jQuery("<div class='df-link-content'>");
2442                    page.contentLayer.append(page.annotationElement);
2443                }
2444                if (clean === true) {
2445                    page.annotationElement.html("");
2446                }
2447                return page.annotationElement[0];
2448            }
2449        },
2450        {
2451            key: "getTextElement",
2452            value: function getTextElement(pageNumber) {
2453                var clean = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
2454                var page = this.getPageByNumber(pageNumber);
2455                if (page === undefined) return undefined;
2456                if (page.textElement === undefined) {
2457                    page.textElement = jQuery("<div class='df-text-content'>");
2458                    page.contentLayer.append(page.textElement);
2459                }
2460                if (clean === true) {
2461                    page.textElement.html("");
2462                    page.textElement.siblings(".df-auto-link-content").html("");
2463                }
2464                return page.textElement[0];
2465            }
2466        },
2467        {
2468            key: "render",
2469            value: function render() {}
2470        },
2471        {
2472            key: "textureLoadedCallback",
2473            value: function textureLoadedCallback(param) {}
2474        },
2475        {
2476            key: "handleZoom",
2477            value: function handleZoom() {}
2478        },
2479        {
2480            key: "getTextureSize",
2481            value: function getTextureSize(param) {
2482                console.error("Texture calculation missing!");
2483            }
2484        },
2485        {
2486            key: "textureHeightLimit",
2487            value: function textureHeightLimit(height) {
2488                return base_viewer_utils.limitAt(height, 1, this.app.dimensions.maxTextureHeight);
2489            }
2490        },
2491        {
2492            key: "textureWidthLimit",
2493            value: function textureWidthLimit(width) {
2494                return base_viewer_utils.limitAt(width, 1, this.app.dimensions.maxTextureWidth);
2495            }
2496        },
2497        {
2498            key: "setPage",
2499            value: function setPage(param) {
2500                base_viewer_utils.log("Set Page detected", param.pageNumber);
2501                var page = this.getPageByNumber(param.pageNumber);
2502                if (page) {
2503                    // page.texturePageNumber = param.pageNumber;
2504                    param.callback = this.textureLoadedCallback.bind(this);
2505                    page.loadTexture(param);
2506                    this.updateBuffer(page);
2507                    return true;
2508                }
2509                return false;
2510            }
2511        },
2512        {
2513            key: "cleanPage",
2514            value: function cleanPage(pageNumber) {
2515                return true;
2516            }
2517        },
2518        {
2519            /**
2520   * Check if the Page change request really makes a page change if not returns false
2521   * @param pageNumber
2522   * @returns {boolean}
2523   */ key: "validatePageChange",
2524            value: function validatePageChange(pageNumber) {
2525                //Fixes issue #40 - validates only if the pageNumber has changed
2526                return pageNumber !== this.app.currentPageNumber;
2527            }
2528        },
2529        {
2530            key: "afterControlUpdate",
2531            value: function afterControlUpdate() {}
2532        },
2533        {
2534            key: "searchPage",
2535            value: function searchPage(pageNumber) {
2536                return {
2537                    include: true,
2538                    label: this.app.provider.getLabelforPage(pageNumber)
2539                };
2540            }
2541        }
2542    ]);
2543    return BaseViewer;
2544}();
2545
2546
2547;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/page.js
2548/* globals jQuery, pdfjsLib,THREE  */ function _assert_this_initialized(self) {
2549    if (self === void 0) {
2550        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2551    }
2552    return self;
2553}
2554function page_class_call_check(instance, Constructor) {
2555    if (!(instance instanceof Constructor)) {
2556        throw new TypeError("Cannot call a class as a function");
2557    }
2558}
2559function page_defineProperties(target, props) {
2560    for(var i = 0; i < props.length; i++){
2561        var descriptor = props[i];
2562        descriptor.enumerable = descriptor.enumerable || false;
2563        descriptor.configurable = true;
2564        if ("value" in descriptor) descriptor.writable = true;
2565        Object.defineProperty(target, descriptor.key, descriptor);
2566    }
2567}
2568function page_create_class(Constructor, protoProps, staticProps) {
2569    if (protoProps) page_defineProperties(Constructor.prototype, protoProps);
2570    if (staticProps) page_defineProperties(Constructor, staticProps);
2571    return Constructor;
2572}
2573function _get_prototype_of(o) {
2574    _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
2575        return o.__proto__ || Object.getPrototypeOf(o);
2576    };
2577    return _get_prototype_of(o);
2578}
2579function _inherits(subClass, superClass) {
2580    if (typeof superClass !== "function" && superClass !== null) {
2581        throw new TypeError("Super expression must either be null or a function");
2582    }
2583    subClass.prototype = Object.create(superClass && superClass.prototype, {
2584        constructor: {
2585            value: subClass,
2586            writable: true,
2587            configurable: true
2588        }
2589    });
2590    if (superClass) _set_prototype_of(subClass, superClass);
2591}
2592function _possible_constructor_return(self, call) {
2593    if (call && (page_type_of(call) === "object" || typeof call === "function")) {
2594        return call;
2595    }
2596    return _assert_this_initialized(self);
2597}
2598function _set_prototype_of(o, p) {
2599    _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
2600        o.__proto__ = p;
2601        return o;
2602    };
2603    return _set_prototype_of(o, p);
2604}
2605function page_type_of(obj) {
2606    "@swc/helpers - typeof";
2607    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2608}
2609function _is_native_reflect_construct() {
2610    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
2611    if (Reflect.construct.sham) return false;
2612    if (typeof Proxy === "function") return true;
2613    try {
2614        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
2615        return true;
2616    } catch (e) {
2617        return false;
2618    }
2619}
2620function _create_super(Derived) {
2621    var hasNativeReflectConstruct = _is_native_reflect_construct();
2622    return function _createSuperInternal() {
2623        var Super = _get_prototype_of(Derived), result;
2624        if (hasNativeReflectConstruct) {
2625            var NewTarget = _get_prototype_of(this).constructor;
2626            result = Reflect.construct(Super, arguments, NewTarget);
2627        } else {
2628            result = Super.apply(this, arguments);
2629        }
2630        return _possible_constructor_return(this, result);
2631    };
2632}
2633
2634var page_DV = (/* unused pure expression or super */ null && (DEARVIEWER));
2635var page_utils = defaults_DEARVIEWER.utils;
2636var Page = /*#__PURE__*/ function() {
2637    "use strict";
2638    function Page() {
2639        page_class_call_check(this, Page);
2640        this.textureLoadFallback = "blank";
2641        this.textureStamp = "-1";
2642        this.textureLoaded = false;
2643        this.texture = "blank";
2644        this.textureSrc = "blank";
2645        this.pageNumber = undefined;
2646        this.contentLayer = jQuery('<div>', {
2647            class: "df-page-content"
2648        });
2649    }
2650    page_create_class(Page, [
2651        {
2652            key: "reset",
2653            value: function reset() {
2654                this.resetTexture();
2655                this.resetContent();
2656            }
2657        },
2658        {
2659            key: "resetTexture",
2660            value: function resetTexture() {
2661                this.textureLoaded = false;
2662                this.textureStamp = "-1";
2663                this.loadTexture({
2664                    texture: this.textureLoadFallback
2665                });
2666                this.contentLayer.removeClass("df-content-loaded");
2667            }
2668        },
2669        {
2670            key: "clearTexture",
2671            value: function clearTexture() {
2672                this.loadTexture({
2673                    texture: this.textureLoadFallback
2674                });
2675            }
2676        },
2677        {
2678            key: "resetContent",
2679            value: function resetContent() {}
2680        },
2681        {
2682            key: "loadTexture",
2683            value: function loadTexture(param) {}
2684        },
2685        {
2686            key: "getTexture",
2687            value: function getTexture() {
2688                var clone = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
2689                var texture = this.textureSrc;
2690                if (clone === true && texture && texture.cloneNode) {
2691                    texture = texture.cloneNode();
2692                    if (texture.getContext) texture.getContext('2d').drawImage(this.textureSrc, 0, 0);
2693                }
2694                return texture;
2695            }
2696        },
2697        {
2698            key: "setLoading",
2699            value: function setLoading() {}
2700        },
2701        {
2702            key: "updateTextureLoadStatus",
2703            value: function updateTextureLoadStatus(textureLoaded) {
2704                this.textureLoaded = textureLoaded === true;
2705                page_utils.log((this.textureLoaded === true ? "Loaded " : "Loading ") + this.textureStamp + " for " + this.pageNumber);
2706                this.contentLayer.toggleClass("df-content-loaded", textureLoaded === true);
2707                this.setLoading();
2708            }
2709        },
2710        {
2711            /**
2712   *
2713   * @param pageNumber
2714   * @param textureSize
2715   * @returns {boolean} true if new stamp is set
2716   */ key: "changeTexture",
2717            value: function changeTexture(pageNumber, textureSize) {
2718                var page = this;
2719                var reqStamp = pageNumber + "|" + textureSize;
2720                if (page.textureStamp !== reqStamp) {
2721                    page_utils.log("Page " + pageNumber + " : texture changed from - " + page.textureStamp + " to " + reqStamp);
2722                    page.textureLoaded = false;
2723                    // page.element.attr("stamp", reqStamp);
2724                    page.textureStamp = reqStamp;
2725                    page.updateTextureLoadStatus(false);
2726                    return true;
2727                }
2728                return false;
2729            }
2730        }
2731    ]);
2732    return Page;
2733}();
2734var Page2D = /*#__PURE__*/ function(Page) {
2735    "use strict";
2736    _inherits(Page2D, Page);
2737    var _super = _create_super(Page2D);
2738    function Page2D(options) {
2739        page_class_call_check(this, Page2D);
2740        var _this;
2741        _this = _super.call(this);
2742        _this.canvasMode = null;
2743        if (options && options.parentElement) _this.parentElement = options.parentElement;
2744        _this.init();
2745        return _this;
2746    }
2747    page_create_class(Page2D, [
2748        {
2749            key: "init",
2750            value: function init() {
2751                var element = this.element = jQuery('<div>', {
2752                    class: 'df-page'
2753                });
2754                element[0].appendChild(this.contentLayer[0]);
2755                this.texture = new Image();
2756                if (this.parentElement) this.parentElement[0].append(element[0]);
2757            }
2758        },
2759        {
2760            key: "resetContent",
2761            value: function resetContent() {
2762                if (this.annotationElement !== undefined) this.annotationElement.html("");
2763                if (this.textElement !== undefined) this.textElement.html("");
2764            }
2765        },
2766        {
2767            key: "setLoading",
2768            value: function setLoading() {
2769                this.element.toggleClass("df-loading", this.textureLoaded !== true);
2770            }
2771        },
2772        {
2773            key: "loadTexture",
2774            value: function loadTexture(param) {
2775                var page = this, texture = param.texture, callback = param.callback;
2776                function completed() {
2777                    page.textureSrc = texture;
2778                    page.element.css({
2779                        backgroundImage: page_utils.bgImage(texture)
2780                    });
2781                    page.updateTextureLoadStatus(true);
2782                    if (typeof callback == 'function') callback(param);
2783                }
2784                if (page.canvasMode === null && texture && texture.nodeName === "CANVAS") page.canvasMode = true;
2785                if (page.canvasMode === true) {
2786                    page.element.find(">canvas").remove();
2787                    if (texture !== page.textureLoadFallback) {
2788                        page.textureSrc = texture;
2789                        page.element.append(jQuery(texture));
2790                    // page.element.width(texture.width).height(texture.height);
2791                    }
2792                    page.updateTextureLoadStatus(true);
2793                    if (typeof callback == 'function') callback(param);
2794                } else {
2795                    if (texture === page.textureLoadFallback) {
2796                        completed();
2797                    } else {
2798                        page.texture.onload = completed;
2799                        page.texture.src = texture;
2800                    }
2801                }
2802            }
2803        },
2804        {
2805            key: "updateCSS",
2806            value: function updateCSS(css) {
2807                var page = this;
2808                page.element.css(css);
2809            }
2810        },
2811        {
2812            key: "resetCSS",
2813            value: function resetCSS() {
2814                var page = this;
2815                page.element.css({
2816                    transform: '',
2817                    boxShadow: '',
2818                    display: "block"
2819                });
2820            }
2821        }
2822    ]);
2823    return Page2D;
2824}(Page);
2825
2826
2827;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/reader.js
2828function reader_assert_this_initialized(self) {
2829    if (self === void 0) {
2830        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2831    }
2832    return self;
2833}
2834function reader_class_call_check(instance, Constructor) {
2835    if (!(instance instanceof Constructor)) {
2836        throw new TypeError("Cannot call a class as a function");
2837    }
2838}
2839function reader_defineProperties(target, props) {
2840    for(var i = 0; i < props.length; i++){
2841        var descriptor = props[i];
2842        descriptor.enumerable = descriptor.enumerable || false;
2843        descriptor.configurable = true;
2844        if ("value" in descriptor) descriptor.writable = true;
2845        Object.defineProperty(target, descriptor.key, descriptor);
2846    }
2847}
2848function reader_create_class(Constructor, protoProps, staticProps) {
2849    if (protoProps) reader_defineProperties(Constructor.prototype, protoProps);
2850    if (staticProps) reader_defineProperties(Constructor, staticProps);
2851    return Constructor;
2852}
2853function _get(target, property, receiver) {
2854    if (typeof Reflect !== "undefined" && Reflect.get) {
2855        _get = Reflect.get;
2856    } else {
2857        _get = function get(target, property, receiver) {
2858            var base = _super_prop_base(target, property);
2859            if (!base) return;
2860            var desc = Object.getOwnPropertyDescriptor(base, property);
2861            if (desc.get) {
2862                return desc.get.call(receiver || target);
2863            }
2864            return desc.value;
2865        };
2866    }
2867    return _get(target, property, receiver || target);
2868}
2869function reader_get_prototype_of(o) {
2870    reader_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o
2870) {
2871        return o.__proto__ || Object.getPrototypeOf(o);
2872    };
2873    return reader_get_prototype_of(o);
2874}
2875function reader_inherits(subClass, superClass) {
2876    if (typeof superClass !== "function" && superClass !== null) {
2877        throw new TypeError("Super expression must either be null or a function");
2878    }
2879    subClass.prototype = Object.create(superClass && superClass.prototype, {
2880        constructor: {
2881            value: subClass,
2882            writable: true,
2883            configurable: true
2884        }
2885    });
2886    if (superClass) reader_set_prototype_of(subClass, superClass);
2887}
2888function reader_possible_constructor_return(self, call) {
2889    if (call && (reader_type_of(call) === "object" || typeof call === "function")) {
2890        return call;
2891    }
2892    return reader_assert_this_initialized(self);
2893}
2894function reader_set_prototype_of(o, p) {
2895    reader_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
2896        o.__proto__ = p;
2897        return o;
2898    };
2899    return reader_set_prototype_of(o, p);
2900}
2901function _super_prop_base(object, property) {
2902    while(!Object.prototype.hasOwnProperty.call(object, property)){
2903        object = reader_get_prototype_of(object);
2904        if (object === null) break;
2905    }
2906    return object;
2907}
2908function reader_type_of(obj) {
2909    "@swc/helpers - typeof";
2910    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2911}
2912function reader_is_native_reflect_construct() {
2913    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
2914    if (Reflect.construct.sham) return false;
2915    if (typeof Proxy === "function") return true;
2916    try {
2917        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
2918        return true;
2919    } catch (e) {
2920        return false;
2921    }
2922}
2923function reader_create_super(Derived) {
2924    var hasNativeReflectConstruct = reader_is_native_reflect_construct();
2925    return function _createSuperInternal() {
2926        var Super = reader_get_prototype_of(Derived), result;
2927        if (hasNativeReflectConstruct) {
2928            var NewTarget = reader_get_prototype_of(this).constructor;
2929            result = Reflect.construct(Super, arguments, NewTarget);
2930        } else {
2931            result = Super.apply(this, arguments);
2932        }
2933        return reader_possible_constructor_return(this, result);
2934    };
2935}
2936
2937
2938
2939var reader_utils = defaults_DEARVIEWER.utils;
2940var Reader = /*#__PURE__*/ function(BaseViewer) {
2941    "use strict";
2942    reader_inherits(Reader, BaseViewer);
2943    var _super = reader_create_super(Reader);
2944    function Reader(options, appContext) {
2945        reader_class_call_check(this, Reader);
2946        var _this;
2947        options.viewerClass = "df-reader";
2948        appContext.options.mouseScrollAction = defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.NONE;
2949        _this = _super.call(this, options, appContext);
2950        _this.app.jumpStep = 1;
2951        _this.minZoom = 0.25;
2952        _this.stackCount = _this.app.pageCount;
2953        _this.app.options.paddingLeft = 0;
2954        _this.app.options.paddingRight = 0;
2955        _this.app.options.paddingTop = 10;
2956        _this.app.options.paddingBottom = _this.app.options.controlsFloating === true ? 20 : 10;
2957        _this.app.pageScaling = _this.app.options.pageScale;
2958        _this.acceptAppMouseEvents = true; //fixes #236 doublemouse events were passed
2959        _this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.OFF;
2960        _this.deltaPanX = 0;
2961        _this.deltaPanY = 0;
2962        // this.app.options.pageSize = DEARVIEWER.PAGE_
2963        // this.app.options.hideControls = "zoomIn,zoomOut";
2964        appContext._viewerPrepared();
2965        _this.zoomViewer = reader_assert_this_initialized(_this); //todo zoomviewer is a bad idea at base
2966        return _this;
2967    }
2968    reader_create_class(Reader, [
2969        {
2970            key: "init",
2971            value: function init() {
2972                _get(reader_get_prototype_of(Reader.prototype), "init", this).call(this);
2973                this.initEvents();
2974                this.initPages();
2975                this.initScrollBar();
2976            }
2977        },
2978        {
2979            key: "initEvents",
2980            value: function initEvents() {
2981                this.stageDOM = this.element[0];
2982                _get(reader_get_prototype_of(Reader.prototype), "initEvents", this).call(this);
2983            }
2984        },
2985        {
2986            key: "initPages",
2987            value: function initPages() {
2988                this.stackCount = this.app.pageCount;
2989                for(var count = 0; count < this.stackCount; count++){
2990                    var page = new Page2D({
2991                        parentElement: this.wrapper
2992                    });
2993                    page.index = count; //just reference for debugging
2994                    page.viewer = this;
2995                    this.pages.push(page);
2996                }
2997            }
2998        },
2999        {
3000            key: "initScrollBar",
3001            value: function initScrollBar() {
3002                this.scrollBar = jQuery("<div class='df-reader-scrollbar'>");
3003                //adding scrollbar to viewer.wrapper doesn't fit properly with mobile momentum scroll, shaky movement is detected
3004                this.scrollBar.appendTo(this.app.container);
3005                //solved #237
3006                this.scrollPageNumber = jQuery("<div class='df-reader-scroll-page-number'>").appendTo(this.app.container);
3007            }
3008        },
3009        {
3010            key: "afterControlUpdate",
3011            value: function afterControlUpdate() {
3012                if (this.scrollBar === void 0) return;
3013                this.scrollBar[0].innerHTML = this.app.getCurrentLabel();
3014                if (this.app.provider.pageLabels) {
3015                    this.scrollPageNumber[0].innerHTML = this.app.getCurrentLabel() + "<div>(" + this.app.currentPageNumber + " of " + this.app.pageCount + ")</div>";
3016                } else {
3017                    this.scrollPageNumber[0].innerHTML = this.app.getCurrentLabel() + "<div>of " + this.app.pageCount + "</div>";
3018                }
3019            }
3020        },
3021        {
3022            key: "updateBuffer",
3023            value: function updateBuffer(page) {
3024                if (page.textureStamp === "-1" || page.pageNumber === void 0) return;
3025                var index = page.pageNumber, farthest = page.pageNumber, farthestIndex = 0;
3026                for(var count = 0; count < this.pageBuffer.length; count++){
3027                    var _pageNumber = this.pageBuffer[count].pageNumber;
3028                    if (index === _pageNumber) {
3029                        reader_utils.log("Page " + index + " already in buffer, skipping");
3030                        return;
3031                    }
3032                    if (Math.abs(this.app.currentPageNumber - _pageNumber) > Math.abs(this.app.currentPageNumber - farthest)) {
3033                        farthest = _pageNumber;
3034                        farthestIndex = count;
3035                    }
3036                }
3037                this.pageBuffer.push(page);
3038                if (this.pageBuffer.length > this.pageBufferSize) {
3039                    reader_utils.log("Farthest buffer: " + farthest);
3040                    this.pageBuffer[farthestIndex].reset();
3041                    this.pageBuffer.splice(farthestIndex, 1);
3042                }
3043            }
3044        },
3045        {
3046            key: "initCustomControls",
3047            value: function initCustomControls() {
3048                var ui = this.app.ui;
3049                var controls = ui.controls;
3050                controls.openRight.hide();
3051                controls.openLeft.hide();
3052            }
3053        },
3054        {
3055            key: "dispose",
3056            value: function dispose() {
3057                _get(reader_get_prototype_of(Reader.prototype), "dispose", this).call(this);
3058                if (this.scrollBar) this.scrollBar.remove();
3059                if (this.scrollPageNumber) this.scrollPageNumber.remove();
3060                this.element.remove();
3061            }
3062        },
3063        {
3064            key: "_getInnerHeight",
3065            value: function _getInnerHeight() {
3066                var height = _get(reader_get_prototype_of(Reader.prototype), "_getInnerHeight", this).call(this), appHeight = this.app.dimensions.maxHeight - this.app.dimensions.padding.height;
3067                var viewPort = this.app.dimensions.defaultPage.viewPort;
3068                var maxWidth = this.app.dimensions.containerWidth - 20 - this.app.dimensions.padding.width;
3069                if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.ACTUAL) maxWidth = this.app.provider.defaultPage.viewPort.width * 1;
3070                //if it's page fit it's from the available height
3071                var maxHeight = appHeight;
3072                if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.PAGE_WIDTH) maxHeight = viewPort.height * 100;
3073                else if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.AUTO) maxHeight = viewPort.height * 1.5;
3074                else if (this.app.pageScaling === defaults_DEARVIEWER.PAGE_SCALE.ACTUAL) maxHeight = viewPort.height * 1;
3075                maxHeight = maxHeight - 2;
3076                this._containCover = reader_utils.contain(viewPort.width, viewPort.height, maxWidth, maxHeight);
3077                maxHeight = Math.min(appHeight, this._containCover.height + 2);
3078                this.app.pageScaleValue = this._containCover.height / viewPort.height;
3079                return this.app.dimensions.isFixedHeight ? appHeight : maxHeight;
3080            }
3081        },
3082        {
3083            key: "handleZoom",
3084            value: function handleZoom() {
3085                var app = this.app;
3086                var maxZoom = this.maxZoom = 4, // todo find a solution than can land properly in zoom value 1.
3087                zoomValue = app.zoomValue;
3088                if (app.pendingZoom === true && app.zoomDelta != null) {
3089                    var delta = app.zoomDelta;
3090                    zoomValue = delta >
3090 0 ? zoomValue * app.options.zoomRatio : zoomValue / app.options.zoomRatio;
3091                } else if (this.lastScale != null) {
3092                    zoomValue *= this.lastScale;
3093                    this.lastScale = null;
3094                }
3095                zoomValue = reader_utils.limitAt(zoomValue, this.minZoom, maxZoom);
3096                app.zoomValueChange = zoomValue / app.zoomValue;
3097                app.zoomChanged = app.zoomValue !== zoomValue;
3098                app.zoomValue = zoomValue;
3099            }
3100        },
3101        {
3102            key: "resize",
3103            value: function resize() {
3104                var viewer = this;
3105                var app = viewer.app;
3106                var dimensions = app.dimensions, padding = app.dimensions.padding;
3107                var shiftHeight = this.shiftHeight = 0, shiftWidth = 0;
3108                this.element.css({
3109                    top: -shiftHeight,
3110                    bottom: -shiftHeight,
3111                    right: -shiftWidth,
3112                    left: -shiftWidth,
3113                    paddingTop: padding.top,
3114                    paddingRight: padding.right,
3115                    paddingBottom: padding.bottom,
3116                    paddingLeft: padding.left
3117                });
3118                var topVisiblePage = viewer.getVisiblePages().main[0] - 1;
3119                topVisiblePage = viewer.pages[topVisiblePage].element[0];
3120                var rect = topVisiblePage.getBoundingClientRect();
3121                var rectParent = this.parentElement[0].getBoundingClientRect();
3122                for(var count = 0; count < viewer.pages.length; count++){
3123                    var page = viewer.pages[count];
3124                    var viewPort = viewer.getViewPort(count + 1, true);
3125                    // page.element
3126                    var els = page.element[0].style;
3127                    els.height = Math.floor(viewPort.height * app.pageScaleValue * app.zoomValue) + "px";
3128                    els.width = Math.floor(viewPort.width * app.pageScaleValue * app.zoomValue) + "px";
3129                }
3130                if (viewer.oldScrollHeight != viewer.element[0].scrollHeight && viewer.oldScrollHeight !== void 0) {
3131                    var delta = viewer.element[0].scrollHeight / viewer.oldScrollHeight;
3132                    viewer.skipScrollCheck = true;
3133                    var top = topVisiblePage.offsetTop + topVisiblePage.clientTop - (rect.top - rectParent.top + topVisiblePage.clientTop) * delta, left = topVisiblePage.offsetLeft + topVisiblePage.clientLeft - (rect.left - rectParent.left + topVisiblePage.clientLeft) * delta;
3134                    //10 is margin that zooms too and reset to 10
3135                    top += (delta - 1) * 10 / 2;
3136                    left += (delta - 1) * 10 / 2;
3137                    var _this_zoomCenter;
3138                    this.zoomCenter = (_this_zoomCenter = this.zoomCenter) !== null && _this_zoomCenter !== void 0 ? _this_zoomCenter : {
3139                        x: 0,
3140                        y: 0 //(viewer.element[0].offsetHeight) / 2
3141                    };
3142                    //if pinch zoom , then move to center
3143                    top += (delta - 1) * this.zoomCenter.y;
3144                    left += (delta - 1) * this.zoomCenter.x;
3145                    this.zoomCenter = null;
3146                    viewer.element[0].scrollTop = top;
3147                    viewer.element[0].scrollLeft = left;
3148                    viewer.skipScrollCheck = false;
3149                }
3150                viewer.oldScrollHeight = viewer.element[0].scrollHeight;
3151                // this.updatePendingStatusClass();
3152                this.scrollBar[0].style.transform = "none";
3153                this.updateScrollBar();
3154            }
3155        },
3156        {
3157            key: "onReady",
3158            value: function onReady() {
3159                this.gotoPageCallBack();
3160                this.oldScrollHeight = this.element[0].scrollHeight;
3161            }
3162        },
3163        {
3164            key: "refresh",
3165            value: function refresh() {
3166                var viewer = this;
3167                var app = this.app;
3168                var visible = viewer.getVisiblePages().main;
3169                for(var _pageCount = 0; _pageCount < visible.length; _pageCount++){
3170                    var page = void 0, _pageNumber = visible[_pageCount];
3171                    page = viewer.pages[_pageNumber - 1];
3172                    var pageChanged = _pageNumber !== page.pageNumber;
3173                    //Determine Page Situation
3174                    if (pageChanged) {
3175                        //texture reset
3176                        page.resetTexture();
3177                        this.app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
3178                    }
3179                    page.element.attr("number", _pageNumber);
3180                    page.pageNumber = _pageNumber;
3181                // page.name = _pageNumber.toString();
3182                }
3183                viewer.requestRefresh(false);
3184                app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
3185            // viewer.element.toggleClass("df-noscroll", !(viewer.element[0].scrollHeight > viewer.element[0].offsetHeight));
3186            }
3187        },
3188        {
3189            key: "isAnimating",
3190            value: function isAnimating() {
3191                // if (this.scrollStatus === DEARVIEWER.REQUEST_STATUS.ON) console.log("animating");
3192                return this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.ON || this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.COUNT;
3193            }
3194        },
3195        {
3196            key: "checkRequestQueue",
3197            value: function checkRequestQueue() {
3198                _get(reader_get_prototype_of(Reader.prototype), "checkRequestQueue", this).call(this);
3199                if (this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.ON) {
3200                    this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.OFF;
3201                }
3202                if (this.scrollStatus === defaults_DEARVIEWER.REQUEST_STATUS.COUNT) {
3203                    this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
3204                }
3205            }
3206        },
3207        {
3208            key: "isActivePage",
3209            value: function isActivePage(pageNumber) {
3210                return this.visiblePagesCache !== void 0 && this.visiblePagesCache.includes(pageNumber);
3211            }
3212        },
3213        {
3214            key: "getVisiblePages",
3215            value: function getVisiblePages() {
3216                var visiblePages = reader_utils.getVisibleElements({
3217                    container: this.element[0],
3218                    elements: this.wrapper[0].children
3219                });
3220                if (visiblePages.length === 0) {
3221                    visiblePages = [
3222                        this.app.currentPageNumber
3223                    ];
3224                } else {
3225                    visiblePages = visiblePages.splice(0, this.pageBufferSize);
3226                }
3227                this.visiblePagesCache = visiblePages;
3228                return {
3229                    main: visiblePages,
3230                    buffer: []
3231                };
3232            }
3233        },
3234        {
3235            key: "getPageByNumber",
3236            value: function getPageByNumber(pageNumber) {
3237                var page = this.pages[pageNumber - 1];
3238                if (page === undefined) {
3239                    reader_utils.log("Page Not found for: " + pageNumber);
3240                }
3241                return page;
3242            }
3243        },
3244        {
3245            key: "onScroll",
3246            value: function onScroll(event) {
3247                var viewer = this;
3248                var center = viewer.element[0].scrollTop + viewer.app.dimensions.containerHeight / 2; // Triggers reflow
3249                var visible = viewer.getVisiblePages().main;
3250                var pageIndex = visible[0];
3251                for(var i = 0; i < visible.length; i++){
3252                    pageIndex = visible[i];
3253                    var element = viewer.pages[pageIndex - 1].element[0];
3254                    var top = element.offsetTop + element.clientTop;
3255                    if (top <= center && element.clientHeight + top >= center) {
3256                        break;
3257                    } else if (i > 0 && top > center && element.clientHeight + top >= center) {
3258                        pageIndex = visible[i - 1];
3259                        break;
3260                    }
3261                }
3262                viewer.skipScrollIntoView = true;
3263                viewer.app.gotoPage(pageIndex);
3264                viewer.skipScrollIntoView = false;
3265                viewer.updateScrollBar();
3266                event.preventDefault && event.preventDefault();
3267                event.stopPropagation();
3268                viewer.requestRefresh();
3269                this.scrollStatus = defaults_DEARVIEWER.REQUEST_STATUS.COUNT;
3270                defaults_DEARVIEWER.handlePopup(viewer.element, false);
3271            }
3272        },
3273        {
3274            key: "updateScrollBar",
3275            value: function updateScrollBar() {
3276                var el = this.element[0], container = this.app.container[0], top = 60, bottom = 60, height = 40;
3277                // this.scrollBar[0].style.top = (el.scrollTop + ((el.offsetHeight - height) * el.scrollTop / (el.scrollHeight - el.offsetHeight))) + "px";
3278                // this.scrollBar[0].style.top = (el.scrollTop + top + ((el.offsetHeight - height - top - bottom) * el.scrollTop / (el.scrollHeight - el.offsetHeight))) + "px";
3279                // this.scrollBar[0].style.right = -el.scrollLeft + "px";
3280                var x = el.scrollLeft, y = top + (el.offsetHeight - height - top - bottom) * el.scrollTop / (el.scrollHeight - el.offsetHeight);
3281                if (isNaN(y)) {
3282                    y = top;
3283                }
3284                this.scrollBar.lastY = y;
3285                this.scrollBar[0].style.transform = 'translateY(' + y + 'px)';
3286            }
3287        },
3288        {
3289            key: "validatePageChange",
3290            value: function validatePageChange(pageNumber) {
3291                true;
3292            }
3293        },
3294        {
3295            key: "gotoPageCallBack",
3296            value: function gotoPageCallBack() {
3297                var viewer = this;
3298                if (viewer.skipScrollIntoView !== true) {
3299                    var page = viewer.getPageByNumber(viewer.app.currentPageNumber);
3300                    if (page != null) reader_utils.scrollIntoView(page.element[0], viewer.element[0]);
3301                }
3302                viewer.skipScrollIntoView = false;
3303                viewer.requestRefresh();
3304            }
3305        },
3306        {
3307            key: "getTextureSize",
3308            value: function getTextureSize(param) {
3309                var viewPort = this.app.provider.viewPorts[1];
3310                if (this.app.provider.viewPorts[param.pageNumber]) {
3311                    viewPort = this.app.provider.viewPorts[param.pageNumber];
3312                }
3313                var pixelRatio = this.app.options.pixelRatio;
3314                return {
3315                    height: viewPort.height * this.app.zoomValue * this.app.pageScaleValue * pixelRatio,
3316                    width: viewPort.width * this.app.zoomValue * this.app.pageScaleValue * pixelRatio
3317                };
3318            }
3319        },
3320        {
3321            key: "textureLoadedCallback",
3322            value: function textureLoadedCallback(param) {
3323                var page = this.getPageByNumber(param.pageNumber), app = this.app;
3324                var viewPort = this.getViewPort(param.pageNumber, true);
3325                page.element.height(Math.floor(viewPort.height * app.pageScaleValue * app.zoomValue)).width(Math.floor(viewPort.width * app.pageScaleValue * app.zoomValue));
3326            }
3327        },
3328        {
3329            key: "pan",
3330            value: function pan(point) {
3331                var reset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
3332                var viewer = this;
3333                var origin = viewer.startPoint;
3334                var deltay = point.raw.y - origin.raw.y, deltax = point.raw.x - origin.raw.x;
3335                viewer.deltaPanY += deltay;
3336                viewer.deltaPanX += deltax;
3337                viewer.panRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
3338                if (reset === false) {
3339                    viewer.startPoint = point;
3340                }
3341            }
3342        },
3343        {
3344            key: "updatePan",
3345            value: function updatePan() {
3346                this.element[0].scrollTop = this.element[0].scrollTop - this.deltaPanY;
3347                this.element[0].scrollLeft = this.element[0].scrollLeft - this.deltaPanX;
3348                this.deltaPanY = 0;
3349                this.deltaPanX = 0;
3350            }
3351        },
3352        {
3353            key: "mouseMove",
3354            value: function mouseMove(event) {
3355                // check if scroll bar is moved.
3356                if (this.startPoint && this.isScrollBarPressed) {
3357                    var _event = reader_utils.fixMouseEvent(event);
3358                    var point = this.eventToPoint(_event);
3359                    var el = this.element[0], top = 60, bottom = 60, height = 40, estY = this.scrollBar.lastY - (this.startPoint.raw.y - point.raw.y);
3360                    this.scrollBar.lastY = estY;
3361                    el.scrollTop = (estY - top) * (el.scrollHeight - el.offsetHeight) / (el.offsetHeight - height - top - bottom);
3362                    this.startPoint = point;
3363                    event.preventDefault();
3364                    return;
3365                }
3366                //if it's swipe scroll we need to leave goign further and use system swipe-scroll
3367                if (event.touches && event.touches.length < 2) return;
3368                _get(reader_get_prototype_of(Reader.prototype), "mouseMove", this).call(this, event);
3369            }
3370        },
3371        {
3372            key: "mouseDown",
3373            value: function mouseDown(event) {
3374                _get(reader_get_prototype_of(Reader.prototype), "mouseDown", this).call(this, event);
3375                if (event.srcElement === this.scrollBar[0]) {
3376                    this.isScrollBarPressed = true;
3377                    this.scrollBar.addClass("df-active");
3378                    this.scrollPageNumber.addClass("df-active");
3379                }
3380            }
3381        },
3382        {
3383            key: "mouseUp",
3384            value: function mouseUp(event) {
3385                _get(reader_get_prototype_of(Reader.prototype), "mouseUp", this).call(this, event);
3386                if (this.isScrollBarPressed =  true && this.scrollBar) {
3387                    this.isScrollBarPressed = false;
3388                    this.scrollBar.removeClass("df-active");
3389                    this.scrollPageNumber.removeClass("df-active");
3390                }
3391            }
3392        }
3393    ]);
3394    return Reader;
3395}(BaseViewer);
3396
3397
3398;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/flipbook.js
3399function flipbook_assert_this_initialized(self) {
3400    if (self === void 0) {
3401        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3402    }
3403    return self;
3404}
3405function flipbook_class_call_check(instance, Constructor) {
3406    if (!(instance instanceof Constructor)) {
3407        throw new TypeError("Cannot call a class as a function");
3408    }
3409}
3410function flipbook_defineProperties(target, props) {
3411    for(var i = 0; i < props.length; i++){
3412        var descriptor = props[i];
3413        descriptor.enumerable = descriptor.enumerable || false;
3414        descriptor.configurable = true;
3415        if ("value" in descriptor) descriptor.writable = true;
3416        Object.defineProperty(target, descriptor.key, descriptor);
3417    }
3418}
3419function flipbook_create_class(Constructor, protoProps, staticProps) {
3420    if (protoProps) flipbook_defineProperties(Constructor.prototype, protoProps);
3421    if (staticProps) flipbook_defineProperties(Constructor, staticProps);
3422    return Constructor;
3423}
3424function flipbook_get(target, property, receiver) {
3425    if (typeof Reflect !== "undefined" && Reflect.get) {
3426        flipbook_get = Reflect.get;
3427    } else {
3428        flipbook_get = function get(target, property, receiver) {
3429            var base = flipbook_super_prop_base(target, property);
3430            if (!base) return;
3431            var desc = Object.getOwnPropertyDescriptor(base, property);
3432            if (desc.get) {
3433                return desc.get.call(receiver || target);
3434            }
3435            return desc.value;
3436        };
3437    }
3438    return flipbook_get(target, property, receiver || target);
3439}
3440function flipbook_get_prototype_of(o) {
3441    flipbook_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o
3441) {
3442        return o.__proto__ || Object.getPrototypeOf(o);
3443    };
3444    return flipbook_get_prototype_of(o);
3445}
3446function flipbook_inherits(subClass, superClass) {
3447    if (typeof superClass !== "function" && superClass !== null) {
3448        throw new TypeError("Super expression must either be null or a function");
3449    }
3450    subClass.prototype = Object.create(superClass && superClass.prototype, {
3451        constructor: {
3452            value: subClass,
3453            writable: true,
3454            configurable: true
3455        }
3456    });
3457    if (superClass) flipbook_set_prototype_of(subClass, superClass);
3458}
3459function flipbook_possible_constructor_return(self, call) {
3460    if (call && (flipbook_type_of(call) === "object" || typeof call === "function")) {
3461        return call;
3462    }
3463    return flipbook_assert_this_initialized(self);
3464}
3465function flipbook_set_prototype_of(o, p) {
3466    flipbook_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
3467        o.__proto__ = p;
3468        return o;
3469    };
3470    return flipbook_set_prototype_of(o, p);
3471}
3472function flipbook_super_prop_base(object, property) {
3473    while(!Object.prototype.hasOwnProperty.call(object, property)){
3474        object = flipbook_get_prototype_of(object);
3475        if (object === null) break;
3476    }
3477    return object;
3478}
3479function flipbook_type_of(obj) {
3480    "@swc/helpers - typeof";
3481    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
3482}
3483function flipbook_is_native_reflect_construct() {
3484    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
3485    if (Reflect.construct.sham) return false;
3486    if (typeof Proxy === "function") return true;
3487    try {
3488        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
3489        return true;
3490    } catch (e) {
3491        return false;
3492    }
3493}
3494function flipbook_create_super(Derived) {
3495    var hasNativeReflectConstruct = flipbook_is_native_reflect_construct();
3496    return function _createSuperInternal() {
3497        var Super = flipbook_get_prototype_of(Derived), result;
3498        if (hasNativeReflectConstruct) {
3499            var NewTarget = flipbook_get_prototype_of(this).constructor;
3500            result = Reflect.construct(Super, arguments, NewTarget);
3501        } else {
3502            result = Super.apply(this, arguments);
3503        }
3504        return flipbook_possible_constructor_return(this, result);
3505    };
3506}
3507
3508
3509
3510var flipbook_utils = defaults_DEARVIEWER.utils;
3511var BaseFlipBookViewer = /*#__PURE__*/ function(BaseViewer) {
3512    "use strict";
3513    flipbook_inherits(BaseFlipBookViewer, BaseViewer);
3514    var _super = flipbook_create_super(BaseFlipBookViewer);
3515    function BaseFlipBookViewer(options, appContext) {
3516        flipbook_class_call_check(this, BaseFlipBookViewer);
3517        var _this;
3518        options.viewerClass = "df-flipbook " + (options.viewerClass || "");
3519        _this = _super.call(this, options, appContext);
3520        _this.isFlipBook = true;
3521        _this.sheets = [];
3522        _this.isRTL = _this.app.isRTL;
3523        _this.foldSense = 50;
3524        _this.isOneSided = false;
3525        var _options_stackCount;
3526        _this.stackCount = (_options_stackCount = options.stackCount) !== null && _options_stackCount !== void 0 ? _options_stackCount : 6;
3527        _this.annotedPage = null;
3528        _this.pendingAnnotations = [];
3529        _this.seamPosition = 0;
3530        _this.dragSheet = null;
3531        _this.drag = null;
3532        _this.soundOn = options.enableSound === true;
3533        _this.soundFile = null;
3534        _this.minZoom = 1;
3535        _this.maxZoom = 4;
3536        _this.pureMaxZoom = 4;
3537        if (_this.app.options.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.AUTO || _this.app.options.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL) {
3538            _this.app.checkSecondPage = true;
3539        }
3540        // if (this.app.options.pageScale === null) {
3541        _this.app.pageScaling = defaults_DEARVIEWER.PAGE_SCALE.PAGE_FIT;
3542        // }
3543        options.viewerClass = "";
3544        _this.zoomViewer = new ZoomViewer(options, appContext);
3545        return _this;
3546    }
3547    flipbook_create_class(BaseFlipBookViewer, [
3548        {
3549            key: "init",
3550            value: function init() {
3551                flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "init", this).call(this);
3552                this.initSound();
3553                var app = this.app;
3554                this.pageMode = app.options.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.AUTO ? flipbook_utils.isMobile || app.pageCount <= 2 ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE : app.options.pageMode;
3555                this.singlePageMode = app.options.singlePageMode || (flipbook_utils.isMobile ? defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET : defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.ZOOM);
3556                this.updatePageMode();
3557                this.rightSheetHeight = this.leftSheetHeight = this._defaultPageSize.height;
3558                this.leftSheetWidth = this.rightSheetWidth = this._defaultPageSize.width;
3559                this.leftSheetTop = this.rightSheetTop = (this.availablePageHeight() - this._defaultPageSize.height) / 2;
3560                this.zoomViewer.rightSheetHeight = this.zoomViewer.leftSheetHeight = this._defaultPageSize.height;
3561                this.zoomViewer.leftSheetWidth = this.zoomViewer.rightSheetWidth = this._defaultPageSize.width;
3562            }
3563        },
3564        {
3565            key: "determineHeight",
3566            value: function determineHeight() {}
3567        },
3568        {
3569            key: "initCustomControls",
3570            value: function initCustomControls() {
3571                flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "initCustomControls", this).call(this);
3572                var viewer = this;
3573                var app = this.app;
3574                var ui = app.ui;
3575                var controls = ui.controls;
3576                var text = app.options.text, icons = app.options.icons;
3577                //region Sound Button
3578                controls.sound = flipbook_utils.createBtn('sound', icons['sound'], text.toggleSound).on("click", function() {
3579                    viewer.soundOn = !viewer.soundOn;
3580                    ui.updateSound();
3581                });
3582                //Updates sound on click of sound button
3583                ui.updateSound = function() {
3584                    if (viewer.soundOn === false) controls.sound.addClass("disabled");
3585                    else controls.sound.removeClass("disabled");
3586                };
3587                //immediate check
3588                ui.updateSound();
3589            }
3590        },
3591        {
3592            key: "dispose",
3593            value: function dispose() {
3594                flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "dispose", this).call(this);
3595                for(var count = 0; count < this.sheets.length; count++){
3596                    var sheet = this.sheets[count];
3597                    if (sheet && sheet.currentTween) {
3598                        sheet.currentTween.stop();
3599                        sheet.currentTween = null;
3600                    }
3601                }
3602                this.zoomViewer.dispose();
3603                this.soundFile = null;
3604            }
3605        },
3606        {
3607            key: "determinePageMode",
3608            value: function determinePageMode() {
3609                var app = this.app;
3610                var oldPageMode = this.pageMode;
3611                if (this.app.pageCount < 3) {
3612                    this.pageMode = defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
3613                } else if (this.app.options.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.AUTO && this.pageModeChangedManually != true) {
3614                    if (flipbook_utils.isMobile === true) {
3615                        if (this.app.dimensions.isAutoHeight && this.app.dimensions.isFixedHeight == false) {
3616                            //when the flipbook is autoheight but the fullscreen mode is fixed height
3617                            var singlePageModeHeight = this._calculateInnerHeight(true);
3618                            var doublePageModeHeight = this._calculateInnerHeight(false);
3619                            var compareWidth = app.dimensions.stage.innerWidth + (app.options.sideMenuOverlay != true && app.isSideMenuOpen ? 220 : 0);
3620                            this.pageMode = singlePageModeHeight > doublePageModeHeight * 1.1 && compareWidth < 768 ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE;
3621                            //calculating innerheight affects other calculations, like this._defaultPageSize, so if the end result is not single page mode, calculate normally.
3622                            this._calculateInnerHeight();
3623                        } else {
3624                            var compareWidth1 = app.dimensions.stage.innerWidth + (app.options.sideMenuOverlay != true && app.isSideMenuOpen ? 220 : 0);
3625                            this.pageMode = app.dimensions.stage.innerHe
3625ight > compareWidth1 * 1.1 && compareWidth1 < 768 ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE;
3626                        }
3627                    }
3628                    if (this.pageMode != oldPageMode) {
3629                        this.setPageMode({
3630                            isSingle: this.pageMode == defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE
3631                        });
3632                    }
3633                }
3634            }
3635        },
3636        {
3637            key: "initSound",
3638            value: function initSound() {
3639                this.soundFile = document.createElement("audio");
3640                this.soundFile.setAttribute("src", this.app.options.soundFile + "?ver=" + defaults_DEARVIEWER.version);
3641                this.soundFile.setAttribute("type", "audio/mpeg");
3642            }
3643        },
3644        {
3645            key: "playSound",
3646            value: function playSound() {
3647                var viewer = this;
3648                try {
3649                    if (viewer.app.userHasInteracted === true && viewer.soundOn === true) {
3650                        viewer.soundFile.currentTime = 0;
3651                        viewer.soundFile.play();
3652                    }
3653                } catch (error) {}
3654            }
3655        },
3656        {
3657            key: "checkDocumentPageSizes",
3658            value: function checkDocumentPageSizes() {
3659                var provider = this.app.provider;
3660                if (provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.AUTO) {
3661                    if (provider._page2Ratio && provider._page2Ratio > provider.defaultPage.pageRatio * 1.5) {
3662                        provider.pageSize = defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL;
3663                    } else {
3664                        provider.pageSize = defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.SINGLE;
3665                    }
3666                }
3667                if (provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL) {
3668                    provider.pageCount = provider.numPages === 1 ? 1 : provider.numPages * 2 - 2;
3669                }
3670                if (provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK || provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE) {
3671                    provider.pageCount = provider.numPages * 2;
3672                }
3673            }
3674        },
3675        {
3676            key: "getViewerPageNumber",
3677            value: function getViewerPageNumber(pageNumber) {
3678                //case double internal
3679                if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL && pageNumber > 2) {
3680                    pageNumber = pageNumber * 2 - 1;
3681                }
3682                if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK && pageNumber > 2) {
3683                    pageNumber = pageNumber * 2 - 1; //todo not sure, we don't have a document yet with links. Since this layout is only intended with printing
3684                }
3685                return pageNumber;
3686            }
3687        },
3688        {
3689            key: "getDocumentPageNumber",
3690            value: function getDocumentPageNumber(pageNumber) {
3691                //case double internal
3692                if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL && pageNumber > 2) return Math.ceil((pageNumber - 1) / 2) + 1;
3693                //case double page
3694                if (this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK && pageNumber > 1) {
3695                    //case double page last page, it's on page 1
3696                    if (pageNumber === this.app.pageCount) return 1;
3697                    //case double page
3698                    return Math.ceil((pageNumber - 1) / 2) + 1;
3699                }
3700                return pageNumber;
3701            }
3702        },
3703        {
3704            key: "getViewPort",
3705            value: function getViewPort(pageNumber) {
3706                var fallback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, filter = arguments.length > 2 ? arguments[2] : void 0;
3707                return this.filterViewPort(flipbook_get(flipbook_get_prototype_of(BaseFl
3707ipBookViewer.prototype), "getViewPort", this).call(this, pageNumber, fallback), pageNumber, filter);
3708            }
3709        },
3710        {
3711            key: "isDoubleInternal",
3712            value: function isDoubleInternal() {
3713                return this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL;
3714            }
3715        },
3716        {
3717            key: "isDoubleCoverBack",
3718            value: function isDoubleCoverBack() {
3719                return this.app.provider.pageSize === defaults_DEARVIEWER.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK;
3720            }
3721        },
3722        {
3723            key: "isDoubleInternalPage",
3724            value: function isDoubleInternalPage(pageNumber) {
3725                return this.isDoubleInternal() && pageNumber > 1 && pageNumber < this.app.provider.pageCount;
3726            }
3727        },
3728        {
3729            key: "getDoublePageWidthFix",
3730            value: function getDoublePageWidthFix(pageNumber) {
3731                return this.isDoubleInternalPage(pageNumber) || this.isDoubleCoverBack() ? 2 : 1;
3732            }
3733        },
3734        {
3735            key: "isDoublePageFix",
3736            value: function isDoublePageFix(pageNumber) {
3737                var fix = false;
3738                if (this.isDoubleCoverBack() || this.isDoubleInternalPage(pageNumber)) {
3739                    if (this.app.isRTL) {
3740                        if (pageNumber % 2 === 0) {
3741                            fix = true;
3742                        }
3743                    } else {
3744                        // canvas.width = canvas.width / doublePageWidthFix;
3745                        if (pageNumber % 2 === 1) {
3746                            fix = true;
3747                        }
3748                    }
3749                }
3750                return fix;
3751            }
3752        },
3753        {
3754            key: "finalizeAnnotations",
3755            value: function finalizeAnnotations(element, pageNumber) {
3756            // element.parentNode.classList.toggle('df-double-internal', this.isDoubleInternalPage(pageNumber));
3757            // element.parentNode.classList.toggle('df-double-internal-fix', this.isDoublePageFix(pageNumber));
3758            }
3759        },
3760        {
3761            key: "finalizeTextContent",
3762            value: function finalizeTextContent(element, pageNumber) {
3763                // element.parentNode.classList.toggle('df-double-internal', this.isDoubleInternalPage(pageNumber));
3764                // element.parentNode.classList.toggle('df-double-internal-fix', this.isDoublePageFix(pageNumber));
3765                if (this.app.zoomValue > this.app.viewer.pureMaxZoom) {
3766                    if (this.zoomViewer.leftViewPort) this.zoomViewer.leftPage.contentLayer[0].style.setProperty('--scale-factor', this.zoomViewer.leftSheetHeight / this.zoomViewer.leftViewPort.height);
3767                    if (this.zoomViewer.rightViewPort) this.zoomViewer.rightPage.contentLayer[0].style.setProperty('--scale-factor', this.zoomViewer.rightSheetHeight / this.zoomViewer.rightViewPort.height);
3768                }
3769            }
3770        },
3771        {
3772            key: "isActivePage",
3773            value: function isActivePage(pageNumber) {
3774                return this.visiblePagesCache !== void 0 && this.visiblePagesCache.includes(pageNumber);
3775            }
3776        },
3777        {
3778            key: "isSheetCover",
3779            value: function isSheetCover(sheetNumber) {
3780                var isBooklet = this.isBooklet;
3781                return sheetNumber === 0 || isBooklet && sheetNumber === 1 //front cover is 0
3782                 || sheetNumber === Math.ceil(this.app.pageCount / (isBooklet ? 1 : 2)) - (isBooklet ? 0 : 1); //start with 0 so 1 minus
3783            }
3784        },
3785        {
3786            key: "isSheetHard",
3787            value: function isSheetHard(sheetNumber) {
3788                var config = this.app.options.flipbookHardPages, isBooklet = this.isBooklet;
3789                if (config === "cover") {
3790                    return this.isSheetCover(sheetNumber);
3791                } else if (config === "all") {
3792                    return true;
3793                } else {
3794                    var baseTest = ("," + config + ",").indexOf("," + (sheetNumber * 2 + 1) + ",") > -1;
3795                    var nextTest = ("," + config + ",").indexOf("," + (sheetNumber * 2 + 2) + ",") > -1;
3796                    return baseTest || nextTest;
3797                }
3798            }
3799        },
3800        {
3801            key: "sheetsIndexShift",
3802            value: function sheetsIndexShift(oldBasePageNumber, basePageNumber, stackCount) {
3803                if (oldBasePageNumber > basePageNumber) {
3804                    this.sheets[stackCount - 1].skipFlip = true;
3805                    this.sheets.unshift(this.sheets.pop());
3806                } else if (oldBasePageNumber < basePageNumber) {
3807                    this.sheets[0].skipFlip = true;
3808                    this.sheets.push(this.sheets.shift());
3809                }
3810            }
3811        },
3812        {
3813            key: "checkSwipe",
3814            value: function checkSwipe(point, event) {
3815                var viewer = this;
3816                if (viewer.pinchZoomDirty === true) return;
3817                if (viewer.app.zoomValue === 1 && viewer.canSwipe === true) {
3818                    var swipe_dist = viewer.orientation == 'vertical' ? point.y - viewer.lastPosY : point.x - viewer.lastPosX;
3819                    if (Math.abs(swipe_dist) > viewer.swipeThreshold) {
3820                        //swipe has triggered
3821                        if (swipe_dist < 0) {
3822                            viewer.app.openRight();
3823                        } else {
3824                            viewer.app.openLeft();
3825                        }
3826                        viewer.canSwipe = false;
3827                        event.preventDefault();
3828                    }
3829                    viewer.lastPosX = point.x;
3830                    viewer.lastPosY = point.y;
3831                }
3832            }
3833        },
3834        {
3835            key: "checkCenter",
3836            value: function checkCenter() {
3837                var flag = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3838                var viewer = this, app = this.app, SHIFT = defaults_DEARVIEWER.FLIPBOOK_CENTER_SHIFT;
3839                var centerShift, isEven = app.currentPageNumber % 2 === 0, basePage = viewer.getBasePage(), isRTL = viewer.isRTL, isSingle = viewer.isSingle;
3840                if (basePage === 0 || viewer.isBooklet) {
3841                    centerShift = viewer.isRTL ? SHIFT.RIGHT : SHIFT.LEFT;
3842                } else if (basePage === app.pageCount) {
3843                    centerShift = isRTL ? SHIFT.LEFT : SHIFT.RIGHT;
3844                } else {
3845                    centerShift = isSingle ? isRTL ? isEven ? SHIFT.LEFT : SHIFT.RIGHT : isEven ? SHIFT.RIGHT : SHIFT.LEFT : SHIFT.NONE;
3846                }
3847                if (viewer.centerNeedsUpdate !== true) {
3848                    viewer.centerNeedsUpdate = viewer.centerShift !== centerShift;
3849                }
3850                if (viewer.centerNeedsUpdate) {
3851                    viewer.centerShift = centerShift;
3852                    viewer.updateCenter(flag);
3853                    viewer.centerNeedsUpdate = false;
3854                }
3855            }
3856        },
3857        {
3858            key: "updateCenter",
3859            value: function updateCenter() {
3860                console.log("UpdateCenter: missing implementation.");
3861            }
3862        },
3863        {
3864            key: "reset",
3865            value: function reset() {
3866                var sheet;
3867                for(var count = 0; count < this.sheets.length; count++){
3868                    sheet = this.sheets[count];
3869                    sheet.reset();
3870                    sheet.pageNumber = -1;
3871                    if (sheet.frontPage) sheet.frontPage.pageNumber = -1;
3872                    if (sheet.backPage) sheet.backPage.pageNumber = -1;
3873                    sheet.resetTexture();
3874                }
3875                this.annotedPage = null;
3876                this.oldBasePageNumber = -1;
3877                this.centerShift = null;
3878                this.refresh();
3879            }
3880        },
3881        {
3882            key: "handleZoom",
3883            value: function handleZoom() {
3884                var app = this.app, dimensions = app.dimensions;
3885                //these dimension require raw values not the ones rouded up or newreast power of two, using isAnnnotation returns raw value.
3886                var leftDimen = this.getLeftPageTextureSize({
3887                    zoom: false,
3888                    isAnnotation: true
3889                }), rightDimen = this.getRightPageTextureSize({
3890                    zoom: false,
3891                    isAnnotation: true
3892                });
3893                var wasMaxZoomed = this.maxZoom === app.zoomValue;
3894                this.pureMaxZoom = app.dimensions.maxTextureSize / Math.max(leftDimen.height, leftDimen.width, rightDimen.height, rightDimen.width);
3895                var maxZoom = this.maxZoom = app.options.fakeZoom * this.pureMaxZoom, zoomValue = app.zoomValue, zoomChanged = false, exitZoom = false, enterZoom = false;
3896                if (maxZoom < this.minZoom) {
3897                    maxZoom = this.maxZoom = this.minZoom;
3898                }
3899                if (app.pendingZoom === true && app.zoomDelta != null) {
3900                    var delta = app.zoomDelta;
3901                    zoomValue = delta > 0 ? zoomValue * app.options.zoomRatio : zoomValue / app.options.zoomRatio;
3902                } else if (this.lastScale != null) {
3903                    zoomValue *= this.lastScale;
3904                    this.lastScale = null;
3905                }
3906                // else if (wasMaxZoomed === true) {
3907                //   zoomValue = app.zoomValue = maxZoom;
3908                //   console.log("Zoom value4: " + app.zoomValue);
3909                // }
3910                // While using maxZoomed, If the flipbook maxTexture is smaller than fullscreen page size. MaxZoomed is auto triggered and zoomValue is auto set to maxZoom value instead of original zoomValue 1
3911                zoomValue = flipbook_utils.limitAt(zoomValue, this.minZoom, maxZoom);
3912                app.zoomValueChange = zoomValue / app.zoomValue;
3913                zoomChanged = app.zoomChanged = app.zoomValue !== zoomValue;
3914                if (zoomChanged && (zoomValue === 1 || app.zoomValue === 1)) {
3915                    exitZoom = zoomValue === 1;
3916                    enterZoom = app.zoomValue === 1;
3917                }
3918                app.zoomValue = zoomValue;
3919                if (enterZoom || exitZoom) {
3920                    app.container.toggleClass("df-zoom-active", zoomValue !== 1);
3921                    enterZoom && this.enterZoom();
3922                    exitZoom && this.exitZoom();
3923                }
3924            }
3925        },
3926        {
3927            key: "refresh",
3928            value: function refresh() {
3929                var viewer = this, app = this.app;
3930                var stackCount = viewer.stackCount, isRTL = viewer.isRTL, isBooklet = viewer.isBooklet;
3931                var basePageNumber = viewer.getBasePage(), pageDivisor = isBooklet ? 1 : 2;
3932                if (isRTL) basePageNumber = app.pageCount - basePageNumber;
3933                var oldBasePageNumber = viewer.oldBasePageNumber, totalSheets = Math.ceil(app.pageCount / pageDivisor), _sheetCount, midPoint = Math.floor(stackCount / 2);
3934                if (basePageNumber !== viewer.oldBasePageNumber) {
3935                    viewer.pageNumberChanged = true;
3936                    this.updatePendingStatusClass(true);
3937                    viewer.zoomViewer.reset();
3938                }
3939                //Pages index shifting
3940                viewer.sheetsIndexShift(oldBasePageNumber, basePageNumber, stackCount);
3941                var baseSheetNumber = Math.ceil(basePageNumber / pageDivisor);
3942                for(_sheetCount = 0; _sheetCount < stackCount; _sheetCount++){
3943                    var _sheet = void 0, sheetNumber = baseSheetNumber - midPoint + _sheetCount;
3944                    if (isRTL) sheetNumber = totalSheets - sheetNumber - 1;
3945                    _sheet = viewer.sheets[_sheetCount];
3946                    if (_sheet == null) continue;
3947                    _sheet.targetSide = _sheetCount < midPoint ? defaults_DEARVIEWER.TURN_DIRECTION.LEFT : defaults_DEARVIEWER.TURN_DIRECTION.RIGHT;
3948                    var sideChanged = _sheet.side !== _sheet.targetSide, pageChanged = sheetNumber !== _sheet.pageNumber, needsFlip = sideChanged && _sheet.skipFlip === false && app.zoomValue === 1;
3949                    if (!sideChanged && pageChanged && _sheet.isFlipping && _sheet.currentTween) {
3950                        _sheet.currentTween.stop();
3951                    }
3952                    _sheet.isHard = viewer.isSheetHard(sheetNumber);
3953                    _sheet.isCover = viewer.isSheetCover(sheetNumber);
3954                    //Determine Page Situation
3955                    if (pageChanged) {
3956                        //texture reset
3957                        _sheet.resetTexture();
3958                        var firstPage = this.app.isRTL ? _sheet.backPage : _sheet.frontPage;
3959                        firstPage.pageNumber = this.isBooklet ? sheetNumber : sheetNumber * 2 + 1;
3960                        var secondPage = this.app.isRTL ? _sheet.frontPage : _sheet.backPage;
3961                        secondPage.pageNumber = this.isBooklet ? -1 : sheetNumber * 2 + 2;
3962                        app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
3963                    }
3964                    _sheet.pageNumber = sheetNumber;
3965                    viewer.refreshSheet({
3966                        sheet: _sheet,
3967                        sheetNumber: sheetNumber,
3968                        totalSheets: totalSheets,
3969                        zIndex: this.stackCount + (_sheetCount < midPoint ? _sheetCount - midPoint : midPoint - _sheetCount),
3970                        visible: isBooklet ? isRTL ? _sheetCount < midPoint || _sheet.isFlipping || needsFlip : _sheetCount >= midPoint || _sheet.isFlipping || needsFlip : sheetNumber >= 0 && sheetNumber < totalSheets || isBooklet && sheetNumber === totalSheets,
3971                        index: _sheetCount,
3972                        needsFlip: needsFlip,
3973                        midPoint: midPoint
3974                    });
3975                }
3976                viewer.requestRefresh(false);
3977                app.textureRequestStatus = defaults_DEARVIEWER.REQUEST_STATUS.ON;
3978                viewer.oldBasePageNumber = basePageNumber;
3979                this.checkCenter();
3980                this.zoomViewer.refresh();
3981                viewer.pageNumberChanged = false;
3982            }
3983        },
3984        {
3985            key: "validatePageChange",
3986            value: function validatePageChange(pageNumber) {
3987                if (pageNumber === this.app.currentPageNumber) return false;
3988                var app = this.app, valid = !this.isFlipping() || app.oldPageNumber === undefined;
3989                //for continuos same direction flip, even when flipping is not completed
3990                valid = valid || app.currentPageNumber < pageNumber && app.oldPageNumber < app.currentPageNumber;
3991                valid = valid || app.currentPageNumber > pageNumber && app.oldPageNumber > app.currentPageNumber;
3992                return valid;
3993            }
3994        },
3995        {
3996            key: "getVisiblePages",
3997            value: function getVisiblePages() {
3998                var viewer = this, visible = [];
3999                var page = viewer.getBasePage();
4000                var count = viewer.app.zoomValue > 1 ? 1 : viewer.isBooklet && flipbook_utils.isMobile ? Math.min(viewer.stackCount / 2, 2) : viewer.stackCount / 2;
4001                for(var _count = 0; _count < count; _count++){
4002                    visible.push(page - _count);
4003                    visible.push(page + _count + 1);
4004                }
4005                this.visiblePagesCache = visible;
4006                return {
4007                    main: visible,
4008                    buffer: []
4009                };
4010            }
4011        },
4012        {
4013            key: "getBasePage",
4014            value: function getBasePage(pageNumber) {
4015                if (pageNumber === void 0) pageNumber = this.app.currentPageNumber;
4016                if (this.isBooklet) return pageNumber;
4017                else return Math.floor(pageNumber / 2) * 2;
4018            }
4019        },
4020        {
4021            key: "getRightPageNumber",
4022            value: function getRightPageNumber() {
4023                return this.getBasePage() + (this.isBooklet ? 0 : this.isRTL ? 0 : 1);
4024            }
4025        },
4026        {
4027            key: "getLeftPageNumber",
4028            value: function getLeftPageNumber() {
4029                return this.getBasePage() + (this.isBooklet ? 0 : this.isRTL ? 1 : 0);
4030            }
4031        },
4032        {
4033            key: "afterFlip",
4034            value: function afterFlip() {
4035                var skip = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
4036                if (this.isAnimating() !== true) {
4037                    this.pagesReady();
4038                    this.updatePendingStatusClass();
4039                }
4040            }
4041        },
4042        {
4043            key: "isFlipping",
4044            value: function isFlipping() {
4045                var isFlipping = false;
4046                this.sheets.forEach(function(sheet) {
4047                    if (sheet.isFlipping === true) isFlipping = true;
4048                });
4049                return isFlipping;
4050            }
4051        },
4052        {
4053            key: "isAnimating",
4054            value: function isAnimating() {
4055                return this.isFlipping();
4056            }
4057        },
4058        {
4059            key: "mouseWheel",
4060            value: function mouseWheel(event) {
4061                if (this.app.options.mouseScrollAction === defaults_DEARVIEWER.MOUSE_SCROLL_ACTIONS.ZOOM) {
4062                    this.zoomViewer.mouseWheel(event);
4063                } else {
4064                    flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "mouseWheel", this).call(this, event);
4065                }
4066            }
4067        },
4068        {
4069            key: "checkRequestQueue",
4070            value: function checkRequestQueue() {
4071                if (this.app.zoomValue > 1) this.zoomViewer.checkRequestQueue();
4072                else flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "checkRequestQueue", this).call(this);
4073            }
4074        },
4075        {
4076            key: "updatePan",
4077            value: function updatePan() {}
4078        },
4079        {
4080            key: "resetPageTween",
4081            value: function resetPageTween() {}
4082        },
4083        {
4084            key: "gotoPageCallBack",
4085            value: function gotoPageCallBack() {
4086                this.resetPageTween();
4087                // this.app.options.resetZoomBeforeFlip = true;
4088                if (this.app.zoomValue !== 1 && this.app.options.resetZoomBeforeFlip === true) {
4089                    this.app.resetZoom();
4090                }
4091                this.beforeFlip();
4092                this.requestRefresh();
4093            }
4094        },
4095        {
4096            key: "beforeFlip",
4097            value: function beforeFlip() {
4098                var viewer = this;
4099                //callback for before flip
4100                viewer.app.executeCallback('beforeFlip');
4101                if (viewer.app.zoomValue === 1) viewer.playSound();
4102            }
4103        },
4104        {
4105            key: "onFlip",
4106            value: function onFlip() {
4107                var viewer = this;
4108                //callback for after flip
4109                viewer.app.executeCallback('onFlip');
4110            }
4111        },
4112        {
4113            //todo should be handled properly by zoomviewer directly
4114            key: "getAnnotationElement",
4115            value: function getAnnotationElement(pageNumber) {
4116                var clean = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, isZoomViewer = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
4117                var annotationEl = undefined;
4118                if (this.app.zoomValue > 1 || isZoomViewer === true) annotationEl = this.zoomViewer.getAnnotationElement(pageNumber, clean);
4119                else annotationEl = flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "getAnnotationElement", this).call(this, pageNumber, clean);
4120                if (annotationEl) {
4121                    annotationEl.parentNode.classList.toggle('df-double-internal', this.isDoubleInternalPage(pageNumber));
4122                    annotationEl.parentNode.classList.toggle('df-double-internal-fix', this.isDoublePageFix(pageNumber));
4123                }
4124                return annotationEl;
4125            }
4126        },
4127        {
4128            key: "getTextElement",
4129            value: function getTextElement(pageNumber) {
4130                var clean = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, isZoomViewer = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
4131                if (this.app.zoomValue > 1 || isZoomViewer === true) return this.zoomViewer.getTextElement(pageNumber, clean);
4132                else return flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "getTextElement", this).call(this, pageNumber, clean);
4133            }
4134        },
4135        {
4136            key: "enterZoom",
4137            value: function enterZoom() {
4138                this.exchangeTexture(this, this.zoomViewer);
4139            }
4140        },
4141        {
4142            key: "exitZoom",
4143            value: function exitZoom() {
4144                this.exchangeTexture(this.zoomViewer, this);
4145            }
4146        },
4147        {
4148            key: "exchangeTexture",
4149            value: function exchangeTexture(from, to) {
4150                var basePage = this.getBasePage();
4151                var fromPage = from.getPageByNumber(basePage);
4152                var toPage = to.getPageByNumber(basePage);
4153                if (toPage && toPage.textureStamp === "-1") {
4154                    toPage.textureStamp = fromPage.textureStamp;
4155                    toPage.loadTexture({
4156                        texture: fromPage.getTexture(true)
4157                    });
4158                    flipbook_utils.log("Texture Exchanging at " + basePage);
4159                } else {
4160                    flipbook_utils.log("Texture Exchanging Bypassed at " + basePage);
4161                }
4162                if (!this.isBooklet) {
4163                    var fromPage1 = from.getPageByNumber(basePage + 1);
4164                    var toPage1 = to.getPageByNumber(basePage + 1);
4165                    if (toPage1 && toPage1.textureStamp === "-1") {
4166                        toPage1.textureStamp = fromPage1.textureStamp;
4167                        toPage1.loadTexture({
4168                            texture: fromPage1.getTexture(true)
4169                        });
4170                        flipbook_utils.log("Texture Exchanging at " + (basePage + 1));
4171                    } else {
4172                        flipbook_utils.log("Texture Exchanging Bypassed at " + (basePage + 1));
4173                    }
4174                }
4175                to.pagesReady();
4176            }
4177        },
4178        {
4179            key: "setPageMode",
4180            value: function setPageMode(args) {
4181                var app = this.app;
4182                var isSingle = args.isSingle === true;
4183                this.pageMode = isSingle ? defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE : defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE;
4184                this.updatePageMode();
4185                app.resizeRequestStart();
4186                // this.requestRefresh();
4187                if (app.viewer.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.DOUBLE && app.ui.controls.pageMode) {
4188                    app.ui.controls.pageMode.removeClass(app.options.icons['doublepage']).addClass(app.options.icons['singlepage']).attr('title', app.options.text.singlePageMode).html('<span>' + app.options.text.singlePageMode + '</span>');
4189                } else {
4190                    app.ui.controls.pageMode.addClass(app.options.icons['doublepage']).removeClass(app.options.icons['singlepage']).attr('title', app.options.text.doublePageMode).html('<span>' + app.options.text.doublePageMode + '</span>');
4191                }
4192            }
4193        },
4194        {
4195            key: "updatePageMode",
4196            value: function updatePageMode() {
4197                if (this.app.pageCount < 3) this.pageMode = defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
4198                this.isSingle = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
4199                this.isBooklet = this.isSingle && this.singlePageMode === defaults_DEARVIEWER.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET;
4200                this.app.jumpStep = this.isSingle ? 1 : 2;
4201                this.totalSheets = Math.ceil(this.app.pageCount / (this.isBooklet ? 1 : 2));
4202                if (this.sheets.length > 0) this.reset();
4203            }
4204        },
4205        {
4206            key: "setPage",
4207            value: function setPage(param) {
4208                if (param.textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.ZOOM) {
4209                    return this.zoomViewer.setPage(param);
4210                } else {
4211                    return flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "setPage", this).call(this, param);
4212                }
4213            }
4214        },
4215        {
4216            key: "_calculateInnerHeight",
4217            value: function _calculateInnerHeight() {
4218                var singleMode = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : void 0;
4219                if (singleMode === void 0) {
4220                    singleMode = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
4221                }
4222                var viewPort = this.app.dimensions.defaultPage.viewPort;
4223                var appWidth = this.availablePageWidth(false, true, singleMode), appHeightMax = this.app.dimensions.maxHeight - this.app.dimensions.padding.height;
4224                if (this.orientation == 'vertical' && singleMode == false) {
4225                    appHeightMax /= 2;
4226                }
4227                this._defaultPageSize = flipbook_utils.contain(viewPort.width, viewPort.height, appWidth, appHeightMax);
4228                this._pageFitArea = {
4229                    width: appWidth,
4230                    height: appHeightMax
4231                }; //do not use this value as reference, it's a midvalue
4232                //_pageFitArea is not the size of flipbook. It the size of possible viewport inside a browser when auto height. In short, it's the restricted area iside which flipbook lies
4233                /// ------------
4234                /// |      |     |
4235                /// --------------  this is flibpok size
4236                /// ______________  this is pagefit area, flipbook cannot go beyond the pagefit area
4237                var innerHeight = this.app.dimensions.isFixedHeight ? appHeightMax : this._pageFitArea.height;
4238                if (this.app.dimensions.isAutoHeight && this.app.dimensions.isFixedHeight == false) {
4239                    //when the flipbook is autoheight but the fullscreen mode is fixed height
4240                    innerHeight = Math.floor(this._defaultPageSize.height);
4241                }
4242                return innerHeight;
4243            }
4244        },
4245        {
4246            key: "_getInnerHeight",
4247            value: function _getInnerHeight() {
4248                var innerHeight = this._calculateInnerHeight();
4249                this.app.dimensions.stage.width = this.app.dimensions.stage.innerWidth + this.app.dimensions.padding.width;
4250                this.app.dimensions.stage.height = innerHeight + this.app.dimensions.padding.height;
4251                return innerHeight;
4252            }
4253        },
4254        {
4255            key: "availablePageWidth",
4256            value: function availablePageWidth() {
4257                var zoom = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, ignoreSidemenuOverlay = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, singleMode = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : void 0;
4258                if (singleMode === void 0) {
4259                    singleMode = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
4260                }
4261                var extraWidth = ignoreSidemenuOverlay === true ? this.app.dimensions.offset.width : 0;
4262                var pageWidth = this.app.dimensions.stage.innerWidth + extraWidth;
4263                pageWidth /= singleMode === true || this.orientation == 'vertical' ? 1 : 2;
4264                return Math.floor(pageWidth * (zoom ? this.app.zoomValue : 1));
4265            }
4266        },
4267        {
4268            key: "availablePageHeight",
4269            value: function availablePageHeight() {
4270                var zoom = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, singleMode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : void 0;
4271                if (singleMode === void 0) {
4272                    singleMode = this.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
4273                }
4274                var pageHeight = this.app.dimensions.stage.innerHeight;
4275                if (singleMode === false && this.orientation == 'vertical') {
4276                    pageHeight /= 2;
4277                }
4278                return Math.floor(pageHeight * (zoom ? this.app.zoomValue : 1));
4279            }
4280        },
4281        {
4282            key: "getTextureSize",
4283            value: function getTextureSize(param) {
4284                var viewport = this.getViewPort(param.pageNumber, true);
4285                var pixelRatio = this.app.options.pixelRatio;
4286                var dimen = flipbook_utils.contain(viewport.width, viewport.height, pixelRatio * this.availablePageWidth(param.zoom), pixelRatio * this.availablePageHeight(param.zoom));
4287                dimen = flipbook_utils.containUnStretched(dimen.width, dimen.height, this.app.options.maxTextureSize, this.app.options.maxTextureSize);
4288                return {
4289                    height: dimen.height,
4290                    width: dimen.width
4291                };
4292            }
4293        },
4294        {
4295            key: "getLeftPageTextureSize",
4296            value: function getLeftPageTextureSize() {
4297                var param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
4298                param.pageNumber = this.getLeftPageNumber();
4299                return this.getTextureSize(param);
4300            }
4301        },
4302        {
4303            key: "getRightPageTextureSize",
4304            value: function getRightPageTextureSize() {
4305                var param = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
4306                param.pageNumber = this.getRightPageNumber();
4307                return this.getTextureSize(param);
4308            }
4309        },
4310        {
4311            key: "filterViewPort",
4312            value: function filterViewPort(viewport, pageNumber) {
4313                var filter = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
4314                if (viewport === undefined) return undefined;
4315                if (filter != true) return viewport;
4316                var _viewport = viewport.clone();
4317                _viewport.width = _viewport.width / this.getDoublePageWidthFix(pageNumber);
4318                return _viewport;
4319            }
4320        },
4321        {
4322            key: "filterViewPortCanvas",
4323            value: function filterViewPortCanvas(viewport, canvas, pageNumber) {
4324                if (this.isDoublePageFix(pageNumber)) {
4325                    viewport.transform[4] = viewport.transform[4] - Math.floor(Math.min(canvas.width, viewport.width * 2 - canvas.width));
4326                }
4327                viewport.widthFix = this.isDoubleInternalPage(pageNumber) ? 2 : 1;
4328            }
4329        },
4330        {
4331            key: "isClosedPage",
4332            value: function isClosedPage(pageNumber) {
4333                if (pageNumber === void 0) pageNumber = this.app.currentPageNumber;
4334                return pageNumber === 1 || pageNumber === this.app.jumpStep * Math.ceil(this.app.pageCount / this.app.jumpStep) && !this.isBooklet;
4335            //Booklets never close on the end
4336            }
4337        },
4338        {
4339            key: "isLeftPage",
4340            value: function isLeftPage(pageNumber) {
4341                if (pageNumber === void 0) pageNumber = this.app.currentPageNumber;
4342                if (this.isBooklet) {
4343                    return this.isRTL;
4344                } else {
4345                    return pageNumber % 2 === (this.isRTL ? 1 : 0);
4346                }
4347            }
4348        },
4349        {
4350            key: "cleanPage",
4351            value: function cleanPage(pageNumber) {
4352                if (this.isDoubleInternalPage(pageNumber)) {
4353                    var otherPage = pageNumber + (pageNumber % 2 === 1 ? -1 : 1);
4354                    return this.app.provider.requestedPages[pageNumber] === false && this.app.provider.requestedPages[otherPage] === false;
4355                } else {
4356                    return flipbook_get(flipbook_get_prototype_of(BaseFl
4356ipBookViewer.prototype), "cleanPage", this).call(this, pageNumber);
4357                }
4358            }
4359        },
4360        {
4361            key: "onReady",
4362            value: function onReady() {
4363                flipbook_get(flipbook_get_prototype_of(BaseFlipBookViewer.prototype), "onReady", this).call(this);
4364            }
4365        },
4366        {
4367            key: "searchPage",
4368            value: function searchPage(pageNumber) {
4369                return {
4370                    include: !this.isDoublePageFix(pageNumber),
4371                    label: this.app.provider.getLabelforPage(pageNumber) + (this.isDoubleInternalPage(pageNumber) ? "-" + this.app.provider.getLabelforPage(pageNumber + 1) : "")
4372                };
4373            }
4374        }
4375    ]);
4376    return BaseFlipBookViewer;
4377}(BaseViewer);
4378var ZoomViewer = /*#__PURE__*/ function(BaseViewer) {
4379    "use strict";
4380    flipbook_inherits(ZoomViewer, BaseViewer);
4381    var _super = flipbook_create_super(ZoomViewer);
4382    function ZoomViewer(options, appContext) {
4383        flipbook_class_call_check(this, ZoomViewer);
4384        var _this;
4385        options.viewerClass = "df-zoomview " + (options.viewerClass || "");
4386        _this = _super.call(this, options, appContext);
4387        _this.viewer = _this.app.viewer;
4388        _this.events = {};
4389        _this.init();
4390        _this.initEvents();
4391        _this.left = 0;
4392        _this.top = 0;
4393        return _this;
4394    }
4395    flipbook_create_class(ZoomViewer, [
4396        {
4397            key: "init",
4398            value: function init() {
4399                this.leftPage = new Page2D();
4400                this.rightPage = new Page2D();
4401                this.pages.push(this.leftPage);
4402                this.pages.push(this.rightPage);
4403                this.leftPage.element.addClass('df-page-back');
4404                this.rightPage.element.addClass('df-page-front');
4405                this.wrapper.append(this.leftPage.element);
4406                this.wrapper.append(this.rightPage.element);
4407                this.bookShadow = jQuery('<div>', {
4408                    class: 'df-book-shadow'
4409                });
4410                this.wrapper.append(this.bookShadow);
4411                this.wrapper.addClass("df-sheet");
4412            }
4413        },
4414        {
4415            key: "initEvents",
4416            value: function initEvents() {
4417                this.stageDOM = this.element[0];
4418                flipbook_get(flipbook_get_prototype_of(ZoomViewer.prototype), "initEvents", this).call(this);
4419            }
4420        },
4421        {
4422            key: "dispose",
4423            value: function dispose() {
4424                this.element.remove();
4425            }
4426        },
4427        {
4428            key: "resize",
4429            value: function resize() {
4430                var viewer = this;
4431                var dimensions = viewer.app.dimensions;
4432                var padding = dimensions.padding;
4433                var zoomHeight = this.app.viewer.availablePageHeight(), zoomWidth = this.app.viewer.availablePageWidth(), zoomFullWidth = viewer.fullWidth = zoomWidth * (this.app.viewer.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE ? 1 : 2), stageWidth = dimensions.stage.innerWidth, stageHeight = dimensions.stage.innerHeight;
4434                var shiftHeight = viewer.shiftHeight = Math.ceil(flipbook_utils.limitAt((zoomHeight - stageHeight) / 2, 0, zoomHeight)), shiftWidth = viewer.shiftWidth = Math.ceil(flipbook_utils.limitAt((zoomFullWidth - stageWidth) / 2, 0, zoomFullWidth));
4435                if (viewer.app.zoomValue === 1) {
4436                    viewer.left = 0;
4437                    viewer.top = 0;
4438                }
4439                viewer.element.css({
4440                    top: -shiftHeight,
4441                    bottom: -shiftHeight,
4442                    right: -shiftWidth,
4443                    left: -shiftWidth,
4444                    paddingTop: padding.top,
4445                    paddingRight: padding.right,
4446                    paddingBottom: padding.bottom,
4447                    paddingLeft: padding.left,
4448                    transform: "translate3d(" + viewer.left + "px," + viewer.top + "px,0)"
4449                });
4450                viewer.wrapper.css({
4451                    width: zoomFullWidth,
4452                    height: zoomHeight,
4453                    //marginTop when the flipbook is smaller than the ViewArea it has to center align vertically
4454                    marginTop: dimensions.height - zoomHeight - padding.height > 0 ? (dimensions.height - padding.height - zoomHeight) / 2 : 0
4455                });
4456                this.wrapper.height(zoomHeight).width(zoomFullWidth - zoomFullWidth % 2);
4457                if (viewer.app.pendingZoom === true) {
4458                    viewer.zoom();
4459                }
4460                this.app.viewer.annotedPage = null;
4461                this.pagesReady();
4462            }
4463        },
4464        {
4465            key: "zoom",
4466            value: function zoom() {
4467                var viewer = this, app = this.app;
4468                if (app.zoomChanged) {
4469                    var origin = app.dimensions.origin, dz = app.zoomValueChange;
4470                    //fix zoom to previous center
4471                    if (app.zoomValue === 1) {
4472                        viewer.left = 0;
4473                        viewer.top = 0;
4474                    } else {
4475                        viewer.left *= dz;
4476                        viewer.top *= dz;
4477                        if (!app.viewer.zoomCenter) {
4478                            app.viewer.zoomCenter = {
4479                                x: origin.x,
4480                                y: origin.y
4481                            };
4482                        }
4483                        var pointOld = {
4484                            raw: app.viewer.zoomCenter
4485                        }, pointNew = {
4486                            raw: {}
4487                        };
4488                        // pointOld.raw.x -= app.dimensions.offset.left / 2;
4489                        //fix zoom to previous pointer
4490                        var dx = (pointOld.raw.x - origin.x) * dz, dy = (pointOld.raw.y - origin.y) * dz;
4491                        pointNew.raw.x = origin.x + dx;
4492                        pointNew.raw.y = origin.y + dy;
4493                        viewer.startPoint = pointNew;
4494                        viewer.pan(pointOld);
4495                        viewer.startPoint = null;
4496                    }
4497                }
4498                app.viewer.zoomCenter = null;
4499            }
4500        },
4501        {
4502            key: "reset",
4503            value: function reset() {
4504                this.leftPage.resetTexture();
4505                this.rightPage.resetTexture();
4506            }
4507        },
4508        {
4509            key: "refresh",
4510            value: function refresh() {
4511                var app = this.app, viewer = app.viewer;
4512                var basePageNumber = viewer.getBasePage(), isLeftBase = viewer.isBooklet ? !app.isRTL : app.isRTL, basePage = isLeftBase ? this.rightPage : this.leftPage, nextPage = isLeftBase ? this.leftPage : this.rightPage;
4513                basePage.pageNumber = basePageNumber;
4514                nextPage.pageNumber = basePageNumber + 1;
4515                basePage.updateCSS({
4516                    display: basePageNumber === 0 ? "none" : "block"
4517                });
4518                nextPage.updateCSS({
4519                    display: nextPage.pageNumber > app.pageCount || viewer.isBooklet ? "none" : "block"
4520                });
4521            }
4522        },
4523        {
4524            key: "updateCenter",
4525            value: function updateCenter() {
4526                var viewer = this;
4527                if (viewer === null || viewer.app.viewer === null) return;
4528                var centerShift = viewer.app.viewer.centerShift, isRTL = viewer.app.viewer.isRTL, width = !isRTL && viewer.app.currentPageNumber > 1 || isRTL && viewer.app.currentPageNumber < viewer.app.pageCount ? viewer.leftSheetWidth : viewer.rightSheetWidth;
4529                var end = centerShift * width / 2;
4530                viewer.wrapper[0].style.left = end + "px";
4531            }
4532        },
4533        {
4534            key: "isDoubleInternalPage",
4535            value: function isDoubleInternalPage(pageNumber) {
4536                return this.app.viewer.isDoubleInternalPage(pageNumber);
4537            }
4538        },
4539        {
4540            key: "pagesReady",
4541            value: function pagesReady() {
4542                if (this.app.viewer.isFlipping()) return;
4543                if (this.app.zoomValue !== 1) this.app.viewer.updatePendingStatusClass(false);
4544                if (this.app.options.flipbookFitPages === false) {
4545                    var basePage = this.app.viewer.getBasePage();
4546                    var leftViewPort = this.leftViewPort = this.app.viewer.getViewPort(basePage + (this.app.viewer.isBooklet ? 0 : this.app.viewer.isRTL ? 1 : 0)), rightViewPort = this.rightViewPort = this.app.viewer.getViewPort(basePage + (this.app.viewer.isBooklet ? 0 : this.app.viewer.isRTL ? 0 : 1));
4547                    if (leftViewPort) {
4548                        var leftDimen = flipbook_utils.contain(leftViewPort.width, leftViewPort.height, this.app.viewer.availablePageWidth(), this.app.viewer.availablePageHeight());
4549                        this.leftSheetWidth = Math.floor(leftDimen.width);
4550                        this.leftSheetHeight = Math.floor(leftDimen.height);
4551                        this.leftSheetTop = (this.app.viewer.availablePageHeight() - this.leftSheetHeight) / 2;
4552                        if (this.app.zoomValue > this.app.viewer.pureMaxZoom) this.leftPage.contentLayer[0].style.setProperty('--scale-factor', this.leftSheetHeight / leftViewPort.height);
4553                    }
4554                    if (rightViewPort) {
4555                        var rightDimen = flipbook_utils.contain(rightViewPort.width, rightViewPort.height, this.app.viewer.availablePageWidth(), this.app.viewer.availablePageHeight());
4556                        this.rightSheetWidth = Math.floor(rightDimen.width);
4557                        this.rightSheetHeight = Math.floor(rightDimen.height);
4558                        this.rightSheetTop = (this.app.viewer.availablePageHeight() - this.rightSheetHeight) / 2;
4559                        if (this.app.zoomValue > this.app.viewer.pureMaxZoom) this.rightPage.contentLayer[0].style.setProperty('--scale-factor', this.rightSheetHeight / rightViewPort.height);
4560                    }
4561                    if (leftViewPort != void 0 || rightViewPort != void 0) {
4562                        this.totalSheetsWidth = this.leftSheetWidth + this.rightSheetWidth;
4563                        this.leftPage.element.height(Math.floor(this.leftSheetHeight)).width(Math.floor(this.leftSheetWidth)).css({
4564                            transform: 'translateY(' + Math.floor(this.leftSheetTop) + 'px)'
4565                        });
4566                        this.rightPage.element.height(Math.floor(this.rightSheetHeight)).width(Math.floor(this.rightSheetWidth)).css({
4567                            transform: 'translateY(' + Math.floor(this.rightSheetTop) + 'px)'
4568                        });
4569                    }
4570                }
4571            }
4572        },
4573        {
4574            key: "textureLoadedCallback",
4575            value: function textureLoadedCallback(param) {
4576                var page = this.getPageByNumber(param.pageNumber);
4577                //page.element.toggleClass("df-odd", param.oddPage === true);
4578                this.pagesReady();
4579            }
4580        }
4581    ]);
4582    return ZoomViewer;
4583}(BaseViewer);
4584var BookSheet = /*#__PURE__*/ function() {
4585    "use strict";
4586    function BookSheet(options) {
4587        flipbook_class_call_check(this, BookSheet);
4588        this.parentElement = options.parentElement;
4589        this.isFlipping = false;
4590        this.isOneSided = false;
4591        this.viewer = options.viewer;
4592        this.frontPage = null;
4593        this.backPage = null;
4594        this.pageNumber = void 0;
4595        this.animateToReset = null;
4596    }
4597    flipbook_create_class(BookSheet, [
4598        {
4599            key: "init",
4600            value: function init() {}
4601        },
4602        {
4603            key: "flip",
4604            value: function flip() {}
4605        },
4606        {
4607            key: "frontImage",
4608            value: function frontImage(param) {
4609                this.frontPage.loadTexture({
4610                    texture: param.texture,
4611                    callback: param.callback
4612                });
4613            }
4614        },
4615        {
4616            key: "backImage",
4617            value: function backImage(param) {
4618                this.backPage.loadTexture({
4619                    texture: param.texture,
4620                    callback: param.callback
4621                });
4622            }
4623        },
4624        {
4625            key: "resetTexture",
4626            value: function resetTexture() {
4627                this.frontPage.resetTexture();
4628                this.backPage.resetTexture();
4629            }
4630        },
4631        {
4632            key: "reset",
4633            value: function reset() {
4634                var sheet = this;
4635                sheet.animateToReset = null;
4636                sheet.isFlipping = false;
4637                // page.element[0].style.opacity = 1;
4638                sheet.currentTween = null;
4639                sheet.pendingPoint = null;
4640                sheet.magnetic = false;
4641                sheet.skipFlip = true;
4642                sheet.animateToReset = null;
4643                sheet.viewer.dragPage = null;
4644                sheet.viewer.flipPage = null;
4645                sheet.viewer.corner = defaults_DEARVIEWER.TURN_CORNER.NONE;
4646            }
4647        }
4648    ]);
4649    return BookSheet;
4650}();
vendor: 5,072 bytes, lines 4651-4780
4651
4652
4653;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/flipbook-2d.js
4654/*Stage collects events and passed to respective implementation*/ function flipbook_2d_assert_this_initialized(self) {
4655    if (self === void 0) {
4656        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
4657    }
4658    return self;
4659}
4660function flipbook_2d_class_call_check(instance, Constructor) {
4661    if (!(instance instanceof Constructor)) {
4662        throw new TypeError("Cannot call a class as a function");
4663    }
4664}
4665function flipbook_2d_defineProperties(target, props) {
4666    for(var i = 0; i < props.length; i++){
4667        var descriptor = props[i];
4668        descriptor.enumerable = descriptor.enumerable || false;
4669        descriptor.configurable = true;
4670        if ("value" in descriptor) descriptor.writable = true;
4671        Object.defineProperty(target, descriptor.key, descriptor);
4672    }
4673}
4674function flipbook_2d_create_class(Constructor, protoProps, staticProps) {
4675    if (protoProps) flipbook_2d_defineProperties(Constructor.prototype, protoProps);
4676    if (staticProps) flipbook_2d_defineProperties(Constructor, staticProps);
4677    return Constructor;
4678}
4679function flipbook_2d_get(target, property, receiver) {
4680    if (typeof Reflect !== "undefined" && Reflect.get) {
4681        flipbook_2d_get = Reflect.get;
4682    } else {
4683        flipbook_2d_get = function get(target, property, receiver) {
4684            var base = flipbook_2d_super_prop_base(target, property);
4685            if (!base) return;
4686            var desc = Object.getOwnPropertyDescriptor(base, property);
4687            if (desc.get) {
4688                return desc.get.call(receiver || target);
4689            }
4690            return desc.value;
4691        };
4692    }
4693    return flipbook_2d_get(target, property, receiver || target);
4694}
4695function flipbook_2d_get_prototype_of(o) {
4696    flipbook_2d_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
4697        return o.__proto__ || Object.getPrototypeOf(o);
4698    };
4699    return flipbook_2d_get_prototype_of(o);
4700}
4701function flipbook_2d_inherits(subClass, superClass) {
4702    if (typeof superClass !== "function" && superClass !== null) {
4703        throw new TypeError("Super expression must either be null or a function");
4704    }
4705    subClass.prototype = Object.create(superClass && superClass.prototype, {
4706        constructor: {
4707            value: subClass,
4708            writable: true,
4709            configurable: true
4710        }
4711    });
4712    if (superClass) flipbook_2d_set_prototype_of(subClass, superClass);
4713}
4714function flipbook_2d_possible_constructor_return(self, call) {
4715    if (call && (flipbook_2d_type_of(call) === "object" || typeof call === "function")) {
4716        return call;
4717    }
4718    return flipbook_2d_assert_this_initialized(self);
4719}
4720function flipbook_2d_set_prototype_of(o, p) {
4721    flipbook_2d_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
4722        o.__proto__ = p;
4723        return o;
4724    };
4725    return flipbook_2d_set_prototype_of(o, p);
4726}
4727function flipbook_2d_super_prop_base(object, property) {
4728    while(!Object.prototype.hasOwnProperty.call(object, property)){
4729        object = flipbook_2d_get_prototype_of(object);
4730        if (object === null) break;
4731    }
4732    return object;
4733}
4734function flipbook_2d_type_of(obj) {
4735    "@swc/helpers - typeof";
4736    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4737}
4738function flipbook_2d_is_native_reflect_construct() {
4739    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
4740    if (Reflect.construct.sham) return false;
4741    if (typeof Proxy === "function") return true;
4742    try {
4743        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
4744        return true;
4745    } catch (e) {
4746        return false;
4747    }
4748}
4749function flipbook_2d_create_super(Derived) {
4750    var hasNativeReflectConstruct = flipbook_2d_is_native_reflect_construct();
4751    return function _createSuperInternal() {
4752        var Super = flipbook_2d_get_prototype_of(Derived), result;
4753        if (hasNativeReflectConstruct) {
4754            var NewTarget = flipbook_2d_get_prototype_of(this).constructor;
4755            result = Reflect.construct(Super, arguments, NewTarget);
4756        } else {
4757            result = Super.apply(this, arguments);
4758        }
4759        return flipbook_2d_possible_constructor_return(this, result);
4760    };
4761}
4762
4763
4764
4765var flipbook_2d_DV = defaults_DEARVIEWER;
4766var flipbook_2d_utils = flipbook_2d_DV.utils;
4767var BookSheet2D = /*#__PURE__*/ function(BookSheet) {
4768    "use strict";
4769    flipbook_2d_inherits(BookSheet2D, BookSheet);
4770    var _super = flipbook_2d_create_super(BookSheet2D);
4771    function BookSheet2D(options) {
4772        flipbook_2d_class_call_check(this, BookSheet2D);
4773        var _this;
4774        _this = _super.call(this, options);
4775        _this.init();
4776        return _this;
4777    }
4778    flipbook_2d_create_class(BookSheet2D, [
4779        {
4780            key: "init",
4781            value: function init() {
4782                var sheet = this, div = '<div>';
4783                var element = sheet.element = jQuery(div, {
4784                    class: 'df-sheet'
4785                });
4786                var frontPage = sheet.frontPage = new Page2D();
4787                frontPage.element.addClass('df-page-front');
4788                var backPage = sheet.backPage = new Page2D();
4789                backPage.element.addClass('df-page-back');
4790                var wrapper = sheet.wrapper = jQuery(div, {
4791                    class: "df-sheet-wrapper"
4792                });
4793                var foldInnerShadow = sheet.foldInnerShadow = jQuery(div, {
4794                    class: "df-sheet-fold-inner-shadow"
4795                });
4796                var foldOuterShadow = sheet.foldOuterShadow = jQuery(div, {
4797                    class: "df-sheet-fold-outer-shadow"
4798                });
4799                this.parentElement.append(element);
4800                element.append(wrapper);
4801                element.append(foldOuterShadow);
4802                wrapper.append(frontPage.element);
4803                wrapper.append(backPage.element);
4804                wrapper.append(foldInnerShadow);
4805            }
4806        },
4807        {
4808            key: "updateCSS",
4809            value: function updateCSS(css) {
4810                var page = this;
4811                page.element.css(css);
4812            }
4813        },
4814        {
4815            key: "resetCSS",
4816            value: function resetCSS() {
4817                var sheet = this;
4818                sheet.wrapper.css({
4819                    transform: ''
4820                });
4821                sheet.frontPage.resetCSS();
4822                sheet.backPage.resetCSS();
4823            }
4824        },
4825        {
4826            key: "updateSize",
4827            value: function updateSize(width, height, top) {
4828                width = Math.floor(width);
4829                height = Math.floor(height);
4830                top = Math.floor(top);
4831                this.wrapper[0].style.height = this.wrapper[0].style.width = Math.ceil(flipbook_2d_utils.distOrigin(width, height) * this.viewer.app.zoomValue) + "px";
4832                this.element[0].style.height = this.frontPage.element[0].style.height = this.backPage.element[0].style.height = this.foldInnerShadow[0].style.height = height + "px";
4833                this.element[0].style.width = this.frontPage.element[0].style.width = this.backPage.element[0].style.width = this.foldInnerShadow[0].style.width = width + "px";
4834                this.element[0].style.transform = 'translateY(' + top + 'px)';
4835            }
4836        },
4837        {
4838            key: "flip",
4839            value: function flip(point) {
4840                var sheet = this;
4841                //point is usually null if the flip was made by next or previous without folding
4842                point = point || sheet.pendingPoint;
4843                if (sheet == null || sheet.viewer == null) return;
4844                sheet.isFlipping = true;
4845                sheet.viewer.flipPage = sheet;
4846                var isBooklet = sheet.viewer.isBooklet, isRight = sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.RIGHT, isRTL = sheet.viewer.isRTL, isBottom = sheet.viewer.corner === defaults_DEARVIEWER.TURN_CORNER.BL || sheet.viewer.corner === defaults_DEARVIEWER.TURN_CORNER.BR;
4847                var travelY = isBottom ? sheet.element.height() : 0;
4848                var fullWidth = sheet.viewer.leftSheetWidth + sheet.viewer.rightSheetWidth;
4849                var init, angle = 0, end; //stages of flip or fold cancel
4850                end = sheet.end = sheet && sheet.animateToReset === true ? {
4851                    x: isRight ? fullWidth : 0,
4852                    y: travelY
4853                } : {
4854                    x: isRight ? 0 : fullWidth,
4855                    y: travelY
4856                };
4857                sheet.flipEasing = sheet.isHard ? TWEEN.Easing.Quadratic.InOut : TWEEN.Easing.Linear.None;
4858                var flipDuration = sheet.viewer.app.options.duration; //duration that should take based on distance(calculated below)
4859                if (sheet.isHard === true) {
4860                    if (point != null) {
4861                        angle = flipbook_2d_utils.angleByDistance(point.distance, point.fullWidth);
4862                    }
4863                    init = sheet.init = {
4864                        angle: angle * (isRight ? -1 : 1)
4865                    };
4866                    end = sheet.end = sheet && sheet.animateToReset === true ? {
4867                        angle: isRight ? 0 : -0
4868                    } : {
4869                        angle: isRight ? -180 : 180
4870                    };
4871                } else {
4872                    if (point == null) {
4873                        init = sheet.init = sheet && sheet.animateToReset === true ? {
4874                            x: isRight ? 0 : fullWidth,
4875                            y: 0
4876                        } : {
4877                            x: isRight ? fullWidth : 0,
4878                            y: 0
4879                        };
4880                    } else {
4881                        init = sheet.init = {
4882                            x: point.x,
4883                            y: point.y,
4884                            opacity: 1
4885                        };
4886                        flipDuration = sheet.viewer.app.options.duration * flipbook_2d_utils.distPoints(init.x, init.y, end.x, end.y) / sheet.viewer.fullWidth;
4887                        flipDuration = flipbook_2d_utils.limitAt(flipDuration, sheet.viewer.app.options.duration / 3, sheet.viewer.duration);
4888                    }
4889                }
4890                init.index = 0;
4891                end.index = 1;
4892                sheet.isFlipping = true;
4893                if (isBooklet && (!isRight && !isRTL || isRight && isRTL)) sheet.element[0].style.opacity = 0;
4894                if (sheet.isHard === true) {
4895                    sheet.currentTween = new TWEEN.Tween(init).delay(0).to(end, sheet.viewer.app.options.duration).onUpdate(function() {
4896                        sheet.updateTween(this);
4897                    }).easing(sheet.flipEasing).onComplete(sheet.completeTween.bind(sheet)).start();
4898                } else {
4899                    if (point == null) {
4900                        sheet.currentTween = new TWEEN.Tween(init).delay(0).to(end, sheet.viewer.app.options.duration).onUpdate(function() {
4901                            sheet.updateTween(this);
4902                        }).easing(TWEEN.Easing.Sinusoidal.Out).onComplete(sheet.completeTween.bind(sheet)).start();
4903                    } else {
4904                        sheet.currentTween = new TWEEN.Tween(init).delay(0).to(end, flipDuration).onUpdate(function() {
4905                            sheet.updateTween(this);
4906                        }).easing(TWEEN.Easing.Sinusoidal.Out).onComplete(sheet.completeTween.bind(sheet)).start();
4907                    }
4908                }
4909            //page.currentTween.viewer= page;
4910            }
4911        },
4912        {
4913            key: "updatePoint",
4914            value: function updatePoint(point) {
4915                var sheet = this;
4916                if (point == null) return;
4917                //detect the current page
4918                // let page = page.viewer.dragPage != null ? page.viewer.dragPage
4919                //   : point.page != null ? point.page : this;
4920                //get the pageWidth and pageHeight
4921                var pageWidth = sheet.element.width(), pageHeight = sheet.element.height();
4922                //the corner where the drag started
4923                var corner = sheet.viewer.corner !== defaults_DEARVIEWER.TURN_CORNER.NONE ? sheet.viewer.corner : point.corner, corners = defaults_DEARVIEWER.TURN_CORNER;
4924                var isRight = sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.RIGHT, isBottom = corner === corners.BL || corner === corners.BR;
4925                point.rx = isRight === true ? sheet.viewer.leftSheetWidth + pageWidth - point.x : point.x;
4926                point.ry = isBottom === true ? pageHeight - point.y : point.y;
4927                var radAngle = Math.atan2(point.ry, point.rx);
4928                radAngle = Math.PI / 2 - flipbook_2d_utils.limitAt(radAngle, 0, flipbook_2d_utils.toRad(90));
4929                var correctionX = pageWidth - point.rx / 2, correctionY = point.ry / 2, refLength = Math.max(0, Math.sin(radAngle - Math.atan2(correctionY, correctionX)) * flipbook_2d_utils.distOrigin(correctionX, correctionY)), //the distance from where the fold starts
4930                foldLength = 0.5 * flipbook_2d_utils.distOrigin(point.rx, point.ry);
4931                var x = Math.ceil(pageWidth - refLength * Math.sin(radAngle)), y = Math.ceil(refLength * Math.cos(radAngle)), angle = flipbook_2d_utils.toDeg(radAngle);
4932                var angle1 = isBottom ? isRight ? 180 + (90 - angle) : 180 + angle : isRight ? angle : 90 - angle;
4933                var angle2 = isBottom ? isRight ? 180 + (90 - angle) : angle : isRight ? angle + 180 : angle1, angleS = isBottom ? isRight ? 90 - angle : angle + 90 : isRight ? angle1 - 90 : angle1 + 180, x1 = isRight ? pageWidth - x : x, y1 = isBottom ? pageHeight + y : -y, x2 = isRight ? -x : x - pageWidth, y2 = isBottom ? -pageHeight - y : y;
4934                var opacity = flipbook_2d_utils.limitAt(point.distance * 0.5 / pageWidth, 0, 0.5);
4935                var foldOpacity = flipbook_2d_utils.limitAt((sheet.viewer.leftSheetWidth + pageWidth - point.rx) * 0.5 / pageWidth, 0.05, 0.3);
4936                sheet.element.addClass("df-folding");
4937                var front = isRight ? sheet.backPage.element : sheet.frontPage.element;
4938                var back = isRight ? sheet.frontPage.element : sheet.backPage.element;
4939                var outerShadow = sheet.foldOuterShadow;
4940                var innerShadow = sheet.foldInnerShadow;
4941                sheet.wrapper.css({
4942                    transform: flipbook_2d_utils.translateStr(x1, y1) + flipbook_2d_utils.rotateStr(angle1)
4943                });
4944                back.css({
4945                    transform: flipbook_2d_utils.rotateStr(-angle1) + flipbook_2d_utils.translateStr(-x1, -y1)
4946                });
4947                front.css({
4948                    transform: flipbook_2d_utils.rotateStr(angle2) + flipbook_2d_utils.translateStr(x2, y2),
4949                    boxShadow: "rgba(0, 0, 0, " + opacity + ") 0px 0px 20px"
4950                });
4951                innerShadow.css({
4952                    transform: flipbook_2d_utils.rotateStr(angle2) + flipbook_2d_utils.translateStr(x2, y2),
4953                    opacity: foldOpacity / 2,
4954                    backgroundImage: flipbook_2d_utils.prefix.css + "linear-gradient( " + angleS + "deg, rgba(0, 0, 0, 0.25) , rgb(0, 0, 0) " + foldLength * 0.7 + "px, rgb(255, 255, 255) " + foldLength + "px)"
4955                });
4956                outerShadow.css({
4957                    opacity: foldOpacity / 2,
4958                    left: isRight ? "auto" : 0,
4959                    right: isRight ? 0 : "auto",
4960                    backgroundImage: flipbook_2d_utils.prefix.css + "linear-gradient( " + (-angleS + 180) + "deg, rgba(0, 0, 0,0) " + foldLength / 3 + "px, rgb(0, 0, 0) " + foldLength + "px)"
4961                });
4962            }
4963        },
4964        {
4965            key: "updateAngle",
4966            value: function updateAngle(angle, isRight) {
4967                var sheet = this;
4968                var width = sheet.element.width() * 5;
4969                sheet.wrapper.css({
4970                    perspective: width,
4971                    perspectiveOrigin: isRight === true ? "0% 50%" : "100% 50%"
4972                });
4973                sheet.element.addClass("df-folding");
4974                sheet.backPage.updateCSS({
4975                    display: isRight === true ? angle <= -90 ? 'block' : 'none' : angle < 90 ? 'block' : 'none',
4976                    transform: (flipbook_2d_utils.prefix.dom !== 'MfS' ? "" : "perspective(" + width + "px) ") + (isRight === true ? "translateX(-100%) " : "") + "rotateY(" + ((isRight === true ? 180 : 0) + angle) + "deg)"
4977                });
4978                sheet.frontPage.updateCSS({
4979                    display: isRight === true ? angle > -90 ? 'block' : 'none' : angle >= 90 ? 'block' : 'none',
4980                    transform: (flipbook_2d_utils.prefix.dom !== 'MSd' ? "" : "perspective(" + width + "px) ") + (isRight === false ? "translateX(100%) " : "") + "rotateY(" + ((isRight === false ? -180 : 0) + angle) + "deg)"
4981                });
4982            }
4983        },
4984        {
4985            key: "updateTween",
4986            value: function updateTween(tween) {
4987                var sheet = this;
4988                var isBooklet = sheet.viewer.isBooklet, isRight = sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.RIGHT, isRTL = sheet.viewer.isRTL;
4989                var isReset = sheet.animateToReset === true;
4990                if (sheet.isHard === true) {
4991                    sheet.updateAngle(tween.angle, isRight);
4992                    sheet.angle = tween.angle;
4993                } else {
4994                    sheet.updatePoint({
4995                        x: tween.x,
4996                        y: tween.y
4997                    });
4998                    sheet.x = tween.x;
4999                    sheet.y = tween.y;
5000                }
5001                if (isBooklet && !isReset) sheet.element[0].style.opacity = isRight && !isRTL || !isRight && isRTL ? tween.index > 0.5 ? 2 * (1 - tween.index) : 1 : tween.index < 0.5 ? 2 * tween.index : 1;
5002            }
5003        },
5004        {
5005            key: "completeTween",
5006            value: function completeTween() {
5007                var sheet = this;
5008                if (sheet.isHard === true) {
5009                    sheet.updateAngle(sheet.end.angle);
5010                    sheet.backPage.element.css({
5011                        display: "block"
5012                    });
5013                    sheet.frontPage.element.css({
5014                        display: "block"
5015                    });
5016                } else {
5017                    sheet.updatePoint({
5018                        x: sheet.end.x,
5019                        y: sheet.end.y
5020                    });
5021                }
5022                sheet.element[0].style.opacity = 1;
5023                if (sheet.animateToReset !== true) {
5024                    sheet.side = sheet.targetSide;
5025                }
5026                sheet.reset();
5027                sheet.viewer.onFlip();
5028                sheet.viewer.afterFlip();
5029                sheet.viewer.requestRefresh();
5030            }
5031        }
5032    ]);
5033    return BookSheet2D;
5034}(BookSheet);
5035var FlipBook2D = /*#__PURE__*/ function(BaseFlipBookViewer) {
5036    "use strict";
5037    flipbook_2d_inherits(FlipBook2D, BaseFlipBookViewer);
5038    var _super = flipbook_2d_create_super(FlipBook2D);
5039    function FlipBook2D(options, appContext) {
5040        flipbook_2d_class_call_check(this, FlipBook2D);
5041        var _this;
5042        var _options_viewerClass;
5043        options.viewerClass = (_options_viewerClass = options.viewerClass) !== null && _options_viewerClass !== void 0 ? _options_viewerClass : "df-flipbook-2d";
5044        options.skipViewerLoaded = true;
5045        _this = _super.call(this, options, appContext);
5046        _this.bookShadow = jQuery('<div>', {
5047            class: 'df-book-shadow'
5048        });
5049        _this.wrapper.append(_this.bookShadow);
5050        _this.corner = defaults_DEARVIEWER.TURN_CORNER.NONE;
5051        appContext._viewerPrepared();
5052        return _this;
5053    }
5054    flipbook_2d_create_class(FlipBook2D, [
5055        {
5056            key: "init",
5057            value: function init() {
5058                flipbook_2d_get(flipbook_2d_get_prototype_of(FlipBook2D.prototype), "init", this).call(this);
5059                this.initEvents();
5060                this.initPages();
5061            }
5062        },
5063        {
5064            key: "initEvents",
5065            value: function initEvents() {
5066                this.stageDOM = this.element[0];
5067                flipbook_2d_get(flipbook_2d_get_prototype_of(FlipBook2D.prototype), "initEvents", this).call(this);
5068            }
5069        },
5070        {
5071            key: "dispose",
5072            value: function dispose() {
5073                flipbook_2d_get(flipbook_2d_get_prototype_of(FlipBook2D.prototype), "dispose", this).call(this);
5074                this.element.remove();
5075            }
5076        },
5077        {
5078            key: "initPages",
5079            value: function initPages() {
5080                for(var count = 0; count < this.stackCount; count++){
5081                    var sheet = new BookSheet2D({
5082                        parentElement: this.wrapper
5083                    });
5084                    sheet.index = count; //just reference for debugging
5085                    sheet.viewer = this;
5086                    this.sheets.push(sheet);
5087                    this.pages.push(sheet.frontPage);
5088                    this.pages.push(sheet.backPage);
5089                }
5090            }
5091        },
5092        {
5093            key: "resize",
5094            value: function resize() {
5095                flipbook_2d_get(flipbook_2d_get_prototype_of(FlipBook2D.prototype), "resize", this).call(this);
5096                var viewer = this;
5097                var dimensions = viewer.app.dimensions;
5098                var padding = dimensions.padding;
5099                var zoomHeight = this.availablePageHeight(), zoomWidth = this.availablePageWidth(), zoomFullWidth = viewer.fullWidth = zoomWidth * 2, stageWidth = dimensions.width, stageHeight = dimensions.height;
5100                var shiftHeight = viewer.shiftHeight = Math.ceil(flipbook_2d_utils.limitAt((zoomHeight - stageHeight + padding.height) / 2, 0, zoomHeight)), shiftWidth = viewer.shiftWidth = Math.ceil(flipbook_2d_utils.limitAt((zoomFullWidth - stageWidth + padding.width) / 2, 0, zoomFullWidth));
5101                if (viewer.app.zoomValue === 1) {
5102                    viewer.left = 0;
5103                    viewer.top = 0;
5104                }
5105                viewer.element.css({
5106                    top: -shiftHeight,
5107                    bottom: -shiftHeight,
5108                    right: -shiftWidth,
5109                    left: -shiftWidth,
5110                    paddingTop: padding.top,
5111                    paddingRight: padding.right,
5112                    paddingBottom: padding.bottom,
5113                    paddingLeft: padding.left,
5114                    transform: "translate3d(" + viewer.left + "px," + viewer.top + "px,0)"
5115                });
5116                viewer.wrapper.css({
5117                    //marginTop when the flipbook is smaller than the ViewArea it has to center align vertically
5118                    marginTop: Math.max(dimensions.height - zoomHeight - padding.height) / 2,
5119                    height: zoomHeight,
5120                    width: zoomFullWidth - zoomFullWidth % 2
5121                });
5122                viewer.zoomViewer.resize();
5123                viewer.centerNeedsUpdate = true;
5124                viewer.checkCenter(true);
5125                viewer.pagesReady();
5126            }
5127        },
5128        {
5129            key: "updateCenter",
5130            value: function updateCenter() {
5131                var skipTransition = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
5132                var viewer = this;
5133                var centerShift = viewer.centerShift, isRTL = viewer.isRTL, width = this.isLeftPage() ? this.leftSheetWidth : this.rightSheetWidth;
5134                var end = centerShift * width / 2;
5135                viewer.seamPosition = (-viewer.app.dimensions.offset.width + viewer.app.dimensions.containerWidth) / 2 + end;
5136                viewer.wrapperShift = (viewer.isSingle ? -viewer.app.dimensions.stage.innerWidth / 2 : 0) + end;
5137                viewer.wrapper[0].style.left = viewer.wrapperShift + "px";
5138                viewer.wrapper[0].style.transition = skipTransition ? "none" : "";
5139                this.zoomViewer.updateCenter();
5140            }
5141        },
5142        {
5143            key: "refreshSheet",
5144            value: function refreshSheet(options) {
5145                var _sheet = options.sheet, sheetPageNumber = options.sheetNumber;
5146                //Render Pages & flip
5147                if (_sheet.isFlipping === false) {
5148                    if (options.needsFlip) {
5149                        //this.beforeFlip();
5150                        _sheet.element.addClass("df-flipping");
5151                        _sheet.flip();
5152                    } else {
5153                        // page.depth = depth;
5154                        _sheet.skipFlip = false;
5155                        _sheet.element.removeClass("df-flipping df-quick-turn df-folding df-left-side df-right-side");
5156                        _sheet.element.addClass(_sheet.targetSide === flipbook_2d_DV.TURN_DIRECTION.LEFT ? "df-left-side" : "df-right-side");
5157                        _sheet.side = _sheet.targetSide;
5158                        _sheet.targetSide === flipbook_2d_DV.TURN_DIRECTION.LEFT ? _sheet.updateSize(this.leftSheetWidth, this.leftSheetHeight, this.leftSheetTop) : _sheet.updateSize(this.rightSheetWidth, this.rightSheetHeight, this.rightSheetTop);
5159                    }
5160                }
5161                _sheet.visible = options.visible;
5162                if (_sheet.isHard) {
5163                    _sheet.element.addClass("df-hard-sheet");
5164                } else {
5165                    _sheet.element.removeClass("df-hard-sheet");
5166                    _sheet.frontPage.updateCSS({
5167                        display: "block"
5168                    });
5169                    _sheet.backPage.updateCSS({
5170                        display: "block"
5171                    });
5172                }
5173                _sheet.updateCSS({
5174                    display: _sheet.visible === true ? "block" : "none",
5175                    zIndex: options.zIndex
5176                });
5177                if (_sheet.pendingPoint == null && _sheet.isFlipping === false) {
5178                    _sheet.resetCSS();
5179                }
5180                if (sheetPageNumber !== _sheet.pageNumber) {
5181                    _sheet.element.attr("number", sheetPageNumber);
5182                    _sheet.backPage.element.attr("pagenumber", _sheet.backPage.pageNumber);
5183                    _sheet.frontPage.element.attr("pagenumber", _sheet.frontPage.pageNumber);
5184                }
5185            }
5186        },
5187        {
5188            key: "eventToPoint",
5189            value: function eventToPoint(event) {
5190                var viewer = this;
5191                event = flipbook_2d_utils.fixMouseEvent(event);
5192                // if(event.type==="mouseup"){
5193                //   let a = "mouseup";
5194                // }
5195                var wrapper = viewer.wrapper, bRect = wrapper[0].getBoundingClientRect(), webgl = viewer.is3D, sheets = viewer.sheets, dimen = viewer.app.dimensions, pageWidth, fullWidth, pageHeight, point = {
5196                    x: event.clientX,
5197                    y: event.clientY
5198                }, left, top, distance, sheet, sheetDrag, isRight;
5199                //calculate x and y relative to container
5200                var pRect = viewer.parentElement[0].getBoundingClientRect();
5201                point.x = point.x - pRect.left;
5202                point.y = point.y - pRect.top;
5203                if (viewer.dragSheet) isRight = viewer.dragSheet.side === flipbook_2d_DV.TURN_DIRECTION.RIGHT;
5204                else {
5205                    isRight = point.x > viewer.seamPosition;
5206                }
5207                pageWidth = isRight ? viewer.rightSheetWidth : viewer.leftSheetWidth;
5208                pageHeight = isRight ? viewer.rightSheetHeight : viewer.leftSheetHeight;
5209                fullWidth = viewer.rightSheetWidth + viewer.leftSheetWidth;
5210                top = isRight ? viewer.rightSheetTop : viewer.leftSheetTop;
5211                //region old
5212                //calculate x and y relative to wrapper
5213                left = point.x - (viewer.seamPosition - viewer.leftSheetWidth);
5214                top = point.y - (bRect.top - pRect.top) - top;
5215                distance = viewer.drag === flipbook_2d_DV.TURN_DIRECTION.NONE ? left < pageWidth ? left : fullWidth - left : viewer.drag === flipbook_2d_DV.TURN_DIRECTION.LEFT ? left : fullWidth - left;
5216                sheet = isRight ? sheets[viewer.stackCount / 2] : sheets[viewer.stackCount / 2 - 1];
5217                sheetDrag = left < viewer.foldSense ? flipbook_2d_DV.TURN_DIRECTION.LEFT : left > fullWidth - viewer.foldSense ? flipbook_2d_DV.TURN_DIRECTION.RIGHT : flipbook_2d_DV.TURN_DIRECTION.NONE;
5218                var x = left, y = top, h = pageHeight, w = fullWidth, delta = viewer.foldSense, corner;
5219                //determine the corner
5220                if (x >= 0 && x < delta) {
5221                    if (y >= 0 && y <= delta) corner = flipbook_2d_DV.TURN_CORNER.TL;
5222                    else if (y >= h - delta && y <= h) corner = flipbook_2d_DV.TURN_CORNER.BL;
5223                    else if (y > delta && y < h - delta) corner = flipbook_2d_DV.TURN_CORNER.L;
5224                    else corner = flipbook_2d_DV.TURN_CORNER.NONE;
5225                } else if (x >= w - delta && x <= w) {
5226                    if (y >= 0 && y <= delta) corner = flipbook_2d_DV.TURN_CORNER.TR;
5227                    else if (y >= h - delta && y <= h) corner = flipbook_2d_DV.TURN_CORNER.BR;
5228                    else if (y > delta && y < h - delta) corner = flipbook_2d_DV.TURN_CORNER.R;
5229                    else corner = flipbook_2d_DV.TURN_CORNER.NONE;
5230                } else corner = flipbook_2d_DV.TURN_CORNER.NONE;
5231                var returnPoint = {
5232                    isInsideSheet: x >= 0 && x <= w && y >= 0 && y <= h,
5233                    isInsideCorner: corner !== flipbook_2d_DV.TURN_CORNER.NONE && corner !== flipbook_2d_DV.TURN_CORNER.L && corner !== flipbook_2d_DV.TURN_CORNER.R,
5234                    x: webgl ? point.x : left,
5235                    y: webgl ? point.y : top,
5236                    fullWidth: fullWidth,
5237                    sheetWidth: pageWidth,
5238                    sheetHeight: pageHeight,
5239                    rawDistance: fullWidth - left,
5240                    distance: distance,
5241                    sheet: sheet,
5242                    drag: sheetDrag,
5243                    foldSense: viewer.foldSense,
5244                    event: event,
5245                    raw: point,
5246                    corner: corner
5247                };
5248                return returnPoint;
5249            }
5250        },
5251        {
5252            key: "pan",
5253            value: function pan(point) {
5254                var reset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
5255                flipbook_2d_utils.pan(this, point, reset);
5256            }
5257        },
5258        {
5259            key: "mouseMove",
5260            value: function mouseMove(event) {
5261                var viewer = this;
5262                var point = viewer.eventToPoint(event);
5263                if (event.touches != null && event.touches.length == 2) {
5264                    this.pinchMove(event);
5265                    return;
5266                }
5267                //PAN
5268                if (viewer.app.zoomValue !== 1 && viewer.startPoint != null && viewer.canSwipe === true) {
5269                    viewer.pan(point);
5270                    event.preventDefault();
5271                }
5272                /*Magnetic Pull*/ var targetSheet = viewer.dragSheet || point.sheet;
5273                if (viewer.flipPage == null && (viewer.dragSheet != null || point.isInsideCorner === true)) {
5274                    if (viewer.dragSheet != null) {
5275                    // utils.log("set mouse down move");
5276                    } else {
5277                        point.y = flipbook_2d_utils.limitAt(point.y, 1, viewer.availablePageHeight() - 1);
5278                        point.x = flipbook_2d_utils.limitAt(point.x, 1, point.fullWidth - 1);
5279                    }
5280                    var corner = viewer.dragSheet != null ? viewer.corner : point.corner;
5281                    if (targetSheet.isHard) {
5282                        var isRight = corner === flipbook_2d_DV.TURN_CORNER.BR || corner === flipbook_2d_DV.TURN_CORNER.TR;
5283                        var angle = flipbook_2d_utils.angleByDistance(point.distance, point.fullWidth);
5284                        targetSheet.updateAngle(angle * (isRight ? -1 : 1), isRight);
5285                    } else {
5286                        targetSheet.updatePoint(point);
5287                    }
5288                    targetSheet.magnetic = true;
5289                    targetSheet.magneticCorner = point.corner;
5290                    event.preventDefault();
5291                //point.sheet.updatePoint(point);
5292                }
5293                /*Magnetic Release*/ if (viewer.dragSheet == null && targetSheet != null && point.isInsideCorner === false && targetSheet.magnetic === true) {
5294                    targetSheet.pendingPoint = point;
5295                    targetSheet.animateToReset = true;
5296                    targetSheet.magnetic = false;
5297                    viewer.corner = targetSheet.magneticCorner;
5298                    targetSheet.flip(targetSheet.pendingPoint);
5299                    targetSheet.pendingPoint = null;
5300                }
5301                //SWIPE
5302                viewer.checkSwipe(point, event);
5303            }
5304        },
5305        {
5306            /**
5307   * Performs:
5308   * 1. If click is in inside the corner - flip the page
5309   * 2. If drag is active - complete the flip
5310   * 3. Clear any swipe flags
5311   * @param event
5312   */ key: "mouseUp",
5313            value: function mouseUp(event) {
5314                var viewer = this;
5315                if (viewer.startPoint == null) return;
5316                if (!event.touches && event.button !== 0) return;
5317                if (viewer.dragSheet == null && event.touches != null && event.touches.length == 0) {
5318                    this.pinchUp(event);
5319                    return;
5320                }
5321                var point = viewer.eventToPoint(event);
5322                //1 - 2 : if there is any page dragging - finish it
5323                var element = event.target || event.originalTarget; //check to see if the clicked element is a link, if so skip turn
5324                var isClick = viewer.app.zoomValue === 1 && point.x === viewer.startPoint.x && point.y === viewer.startPoint.y && element.nodeName !== "A";
5325                if (event.ctrlKey === true && isClick) {
5326                    this.zoomOnPoint(point);
5327                } else if (viewer.dragSheet) {
5328                    event.preventDefault();
5329                    var sheet = viewer.dragSheet;
5330                    sheet.pendingPoint = point;
5331                    viewer.drag = point.drag;
5332                    /*it was a valid CLICK and was inside the corner*/ if (isClick && (point.isInsideCorner === true || point.isInsideSheet && viewer.clickAction === flipbook_2d_DV.MOUSE_CLICK_ACTIONS.NAV)) {
5333                        if (point.corner.indexOf("l") > -1) {
5334                            viewer.app.openLeft();
5335                        } else {
5336                            viewer.app.openRight();
5337                        }
5338                    } else {
5339                        var _currentPage = this.getBasePage();
5340                        if (point.distance > point.sheetWidth / 2) {
5341                            if (point.sheet.side === defaults_DEARVIEWER.TURN_DIRECTION.LEFT) {
5342                                viewer.app.openLeft();
5343                            } else {
5344                                viewer.app.openRight();
5345                            }
5346                        }
5347                        //if no flip occurred reset the pages.
5348                        if (_currentPage === this.getBasePage()) {
5349                            sheet.animateToReset = true;
5350                            sheet.flip(point);
5351                        }
5352                    }
5353                    viewer.dragSheet = null;
5354                    sheet.magnetic = false;
5355                } else if (isClick && !point.sheet.isFlipping && point.isInsideSheet && viewer.clickAction === flipbook_2d_DV.MOUSE_CLICK_ACTIONS.NAV) {
5356                    if (point.sheet.side === "left") {
5357                        viewer.app.openLeft();
5358                    } else {
5359                        viewer.app.openRight();
5360                    }
5361                }
5362                /*3 if there is swipe - clean*/ viewer.startPoint = null;
5363                viewer.canSwipe = false;
5364                viewer.drag = flipbook_2d_DV.TURN_DIRECTION.NONE;
5365            }
5366        },
5367        {
5368            key: "mouseDown",
5369            value: function mouseDown(event) {
5370                if (!event.touches && event.button !== 0) return;
5371                if (event.touches != null && event.touches.length == 2) {
5372                    this.pinchDown(event);
5373                    return;
5374                }
5375                var viewer = this;
5376                var point = viewer.eventToPoint(event);
5377                viewer.startPoint = point;
5378                viewer.lastPosX = point.x;
5379                viewer.lastPosY = point.y;
5380                if (point.isInsideCorner && viewer.flipPage == null) {
5381                    viewer.dragSheet = point.sheet;
5382                    viewer.drag = point.drag;
5383                    viewer.corner = point.corner;
5384                    if (point.sheet.pageNumber === 0) {
5385                        viewer.bookShadow.css({
5386                            width: '50%',
5387                            left: viewer.app.isRTL ? 0 : '50%',
5388                            transitionDelay: ''
5389                        });
5390                    } else if (point.sheet.pageNumber === Math.ceil(viewer.app.pageCount / 2) - 1) {
5391                        viewer.bookShadow.css({
5392                            width: '50%',
5393                            left: viewer.app.isRTL ? '50%' : 0,
5394                            transitionDelay: ''
5395                        });
5396                    }
5397                } else {
5398                    viewer.canSwipe = true;
5399                }
5400            }
5401        },
5402        {
5403            key: "onScroll",
5404            value: function onScroll(event) {}
5405        },
5406        {
5407            key: "resetPageTween",
5408            value: function resetPageTween() {
5409                var viewer = this;
5410                for(var _pageCount = 0; _pageCount < viewer.stackCount; _pageCount++){
5411                    var sheets = viewer.sheets[_pageCount];
5412                    if (sheets.currentTween) {
5413                        sheets.currentTween.complete(true);
5414                    }
5415                }
5416                viewer.requestRefresh();
5417            }
5418        },
5419        {
5420            key: "pagesReady",
5421            value: function pagesReady() {
5422                if (this.isFlipping()) return;
5423                if (this.app.options.flipbookFitPages === false) {
5424                    var basePage = this.app.viewer.getBasePage();
5425                    var leftViewPort = this.leftViewport = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 1 : 0)), rightViewPort = this.rightViewPort = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 0 : 1));
5426                    if (leftViewPort) {
5427                        var leftDimen = flipbook_2d_utils.contain(leftViewPort.width, leftViewPort.height, this.availablePageWidth(), this.availablePageHeight());
5428                        this.leftSheetWidth = Math.floor(leftDimen.width);
5429                        this.leftSheetHeight = Math.floor(leftDimen.height);
5430                        this.leftSheetTop = (this.availablePageHeight() - this.leftSheetHeight) / 2;
5431                    }
5432                    if (rightViewPort) {
5433                        var rightDimen = flipbook_2d_utils.contain(rightViewPort.width, rightViewPort.height, this.availablePageWidth(), this.availablePageHeight());
5434                        this.rightSheetWidth = Math.floor(rightDimen.width);
5435                        this.rightSheetHeight = Math.floor(rightDimen.height);
5436                        this.rightSheetTop = (this.availablePageHeight() - this.rightSheetHeight) / 2;
5437                    }
5438                    this.totalSheetsWidth = this.leftSheetWidth + this.rightSheetWidth;
5439                    for(var i = 0; i < this.sheets.length; i++){
5440                        var sheet = this.sheets[i];
5441                        if (sheet.side === flipbook_2d_DV.TURN_DIRECTION.LEFT) {
5442                            sheet.updateSize(this.leftSheetWidth, this.leftSheetHeight, this.leftSheetTop);
5443                        } else {
5444                            sheet.updateSize(this.rightSheetWidth, this.rightSheetHeight, this.rightSheetTop);
5445                        }
5446                    }
5447                }
5448                this.updateCenter();
5449                this.updatePendingStatusClass();
5450            }
5451        },
5452        {
5453            key: "textureLoadedCallback",
5454            value: function textureLoadedCallback(param) {
5455                var page = this.getPageByNumber(param.pageNumber);
5456                this.pagesReady();
5457            }
5458        }
5459    ]);
5460    return FlipBook2D;
5461}(BaseFlipBookViewer);
5462
5463
5464;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/mockup.js
5465function mockup_assert_this_initialized(self) {
5466    if (self === void 0) {
5467        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5468    }
5469    return self;
5470}
5471function mockup_class_call_check(instance, Constructor) {
5472    if (!(instance instanceof Constructor)) {
5473        throw new TypeError("Cannot call a class as a function");
5474    }
5475}
5476function mockup_defineProperties(target, props) {
5477    for(var i = 0; i < props.length; i++){
5478        var descriptor = props[i];
5479        descriptor.enumerable = descriptor.enumerable || false;
5480        descriptor.configurable = true;
5481        if ("value" in descriptor) descriptor.writable = true;
5482        Object.defineProperty(target, descriptor.key, descriptor);
5483    }
5484}
5485function mockup_create_class(Constructor, protoProps, staticProps) {
5486    if (protoProps) mockup_defineProperties(Constructor.prototype, protoProps);
5487    if (staticProps) mockup_defineProperties(Constructor, staticProps);
5488    return Constructor;
5489}
5490function mockup_get_prototype_of(o) {
5491    mockup_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
5492        return o.__proto__ || Object.getPrototypeOf(o);
5493    };
5494    return mockup_get_prototype_of(o);
5495}
5496function mockup_inherits(subClass, superClass) {
5497    if (typeof superClass !== "function" && superClass !== null) {
5498        throw new TypeError("Super expression must either be null or a function");
5499    }
5500    subClass.prototype = Object.create(superClass && superClass.prototype, {
5501        constructor: {
5502            value: subClass,
5503            writable: true,
5504            configurable: true
5505        }
5506    });
5507    if (superClass) mockup_set_prototype_of(subClass, superClass);
5508}
5509function mockup_instanceof(left, right) {
5510    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
5511        return !!right[Symbol.hasInstance](left);
5512    } else {
5513        return left instanceof right;
5514    }
5515}
5516function mockup_possible_constructor_return(self, call) {
5517    if (call && (mockup_type_of(call) === "object" || typeof call === "function")) {
5518        return call;
5519    }
5520    return mockup_assert_this_initialized(self);
5521}
5522function mockup_set_prototype_of(o, p) {
5523    mockup_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
5524        o.__proto__ = p;
5525        return o;
5526    };
5527    return mockup_set_prototype_of(o, p);
5528}
5529function mockup_type_of(obj) {
5530    "@swc/helpers - typeof";
5531    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
5532}
5533function mockup_is_native_reflect_construct() {
5534    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
5535    if (Reflect.construct.sham) return false;
5536    if (typeof Proxy === "function") return true;
5537    try {
5538        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
5539        return true;
5540    } catch (e) {
5541        return false;
5542    }
5543}
5544function mockup_create_super(Derived) {
5545    var hasNativeReflectConstruct = mockup_is_native_reflect_construct();
5546    return function _createSuperInternal() {
5547        var Super = mockup_get_prototype_of(Derived), result;
5548        if (hasNativeReflectConstruct) {
5549            var NewTarget = mockup_get_prototype_of(this).constructor;
5550            result = Reflect.construct(Super, arguments, NewTarget);
5551        } else {
5552            result = Super.apply(this, arguments);
5553        }
5554        return mockup_possible_constructor_return(this, result);
5555    };
5556}
5557
5558var MOCKUP = {};
5559MOCKUP.init = function() {
5560    //region MOCKUP
5561    if (MOCKUP.initialized === true) return;
5562    var THREE = window.THREE;
5563    MOCKUP = {
5564        init: function init() {},
5565        initialized: true,
5566        GEOMETRY_TYPE: {
5567            PLANE: 0,
5568            BOX: 1,
5569            MODEL: 2
5570        },
5571        MATERIAL_FACE: {
5572            FRONT: 5,
5573            BACK: 4
5574        },
5575        WHITE_COLOR: new THREE.Color("white"),
5576        defaults: {
5577            anisotropy: 8,
5578            maxTextureSize: 2048,
5579            groundTexture: "blank",
5580            color: 0xffffff,
5581            shininess: 15,
5582            width: 210,
5583            height: 297,
5584            depth: 0.2,
5585            segments: 150,
5586            textureLoadFallback: "blank"
5587        },
5588        textureLoader: new THREE.TextureLoader(),
5589        clearChild: function clearChild(child) {
5590            var material = child.material;
5591            child.parent.remove(child);
5592            var texture;
5593            child = utils.disposeObject(child);
5594            if (material == null) return;
5595            if (material.length == null) {
5596                if (material.map) {
5597                    texture = material.map;
5598                    material.dispose();
5599                    texture.dispose();
5600                }
5601                if (material.bumpMap) {
5602                    texture = material.bumpMap;
5603                    material.dispose();
5604                    texture.dispose();
5605                }
5606                if (material.normalMap) {
5607                    texture = material.normalMap;
5608                    material.dispose();
5609                    texture.dispose();
5610                }
5611            } else {
5612                for(var matCount = 0; matCount < material.length; matCount++){
5613                    if (material[matCount]) {
5614                        if (material[matCount].map) {
5615                            texture = material[matCount].map;
5616                            material[matCount].dispose();
5617                            texture.dispose();
5618                        }
5619                        if (material[matCount].bumpMap) {
5620                            texture = material[matCount].bumpMap;
5621                            material[matCount].dispose();
5622                            texture.dispose();
5623                        }
5624                        if (material[matCount].normalMap) {
5625                            texture = material[matCount].normalMap;
5626                            material[matCount].dispose();
5627                            texture.dispose();
5628                        }
5629                    }
5630                    material[matCount] = null;
5631                }
5632            }
5633            material = null;
5634            texture = null;
5635        },
5636        /**
5637     * @param {Paper} object
5638     * @param image
5639     * @param faceNumber
5640     * @param mapType
5641     * @param callback
5642     * @returns {number|*}
5643     */ loadImage: function loadImage(object, image, faceNumber, mapType, callback) {
5644            if (image == null) {
5645                var value = object.material[faceNumber] == null ? null : object.material[faceNumber][mapType] ? object.material[faceNumber][mapType].sourceFile : null;
5646                return value == null ? null : value.indexOf("data:image") > -1 ? null : value;
5647            } else {
5648                var _texture = null;
5649                if (image.nodeName === "CANVAS" || image.nodeName === "IMG") {
5650                    _texture = new THREE.Texture(image);
5651                    _texture.needsUpdate = true;
5652                    MOCKUP.loadTexture(_texture, object, mapType, faceNumber);
5653                    if (typeof callback === "function") callback(object, _texture);
5654                } else {
5655                    if (image !== "blank") {
5656                        _texture = image == null ? null : MOCKUP.textureLoader.load(image, function textureOnLoad(texture) {
5657                            texture.sourceFile = image;
5658                            MOCKUP.loadTexture(texture, object, mapType, faceNumber);
5659                            if (typeof callback === "function") callback(object, texture);
5660                        }, void 0, function textureOnError() {
5661                            if (_texture.image == null) {
5662                                MOCKUP.loadImage(object, MOCKUP.defaults.textureLoadFallback, faceNumber, mapType);
5663                            }
5664                            MOCKUP.loadTextureFailed();
5665                        });
5666                        if (_texture) _texture.mapping = THREE.UVMapping;
5667                    } else {
5668                        MOCKUP.loadTexture(null, object, mapType, faceNumber);
5669                        if (typeof callback === "function") callback(object, _texture);
5670                    }
5671                }
5672                return 0;
5673            }
5674        },
5675        //load image to texture
5676        loadTexture: function loadTexture(texture, object, mapType, faceNumber) {
5677            if (texture) {
5678                var img = texture.image;
5679                texture.naturalWidth = img.naturalWidth;
5680                texture.naturalHeight = img.naturalHeight;
5681                texture.needsUpdate = true;
5682                if (object.textureRotation != void 0) {
5683                    texture.rotation = THREE.MathUtils.degToRad(object.textureRotation);
5684                    texture.center = object.textureCenter;
5685                }
5686            }
5687            if (texture !== null && mapType === "map") {
5688                texture.anisotropy = 0;
5689                if (MOCKUP.defaults.anisotropy > 0) texture.anisotropy = MOCKUP.defaults.anisotropy;
5690                if (THREE.skipPowerOfTwo === true) {
5691                    texture.minFilter = THREE.LinearFilter;
5692                    texture.magFilter = THREE.LinearFilter;
5693                }
5694                texture.name = new Date().toTimeString();
5695            }
5696            MOCKUP.clearTexture(object.material[faceNumber][mapType]);
5697            object.material[faceNumber][mapType] = texture;
5698            if (mapType === "bumpMap") object.material[faceNumber].bumpScale = object.sheet.getBumpScale(faceNumber);
5699            // if (mapType === "normalMap")
5700            //   object.material[faceNumber].normalScale = object.sheet.getBumpScale(faceNumber);
5701            object.material[faceNumber].needsUpdate = true;
5702        },
5703        //load image to texture
5704        loadTextureFailed: function loadTextureFailed() {
5705            //console.log("Failed to load texture:" + image);
5706            return null;
5707        },
5708        clearTexture: function clearTexture(texture) {
5709            if (texture) {
5710                if (texture.image) {
5711                    if (texture.image.nodeName === "CANVAS") {
5712                        if (texture.image.remove) texture.image.remove();
5713                        delete texture.image;
5714                    }
5715                }
5716                texture = utils.disposeObject(texture);
5717            }
5718        }
5719    };
5720    THREE.skipPowerOfTwo = true;
5721    /**
5722   * @typedef {Object} Paper
5723   * @property material
5724   */ var Paper = /*#__PURE__*/ function(_THREE_Mesh) {
5725        "use strict";
5726        mockup_inherits(Paper, _THREE_Mesh);
5727        var _super = mockup_create_super(Paper);
5728        function Paper(options) {
5729            mockup_class_call_check(this, Paper);
5730            var _this;
5731            var width = options.width || MOCKUP.defaults.width, height = options.height || MOCKUP.defaults.height, color = options.color || MOCKUP.defaults.color, segments = options.segments || MOCKUP.defaults.segments, depth = options.depth || MOCKUP.defaults.depth;
5732            var _matParameters = {
5733                color: color,
5734                flatShading: false,
5735                shininess: options.shininess || MOCKUP.defaults.shininess
5736            };
5737            var _material = new THREE.MeshPhongMaterial(_matParameters);
5738            // _matParameters.flatShading = false; smooth-shading causes shadow in the middle of books - solved with extra vertex in updateAngle()
5739            var _materials = [
5740                _material,
5741                _material,
5742                _material,
5743                _material,
5744                new THREE.MeshPhongMaterial(_matParameters),
5745                new THREE.MeshPhongMaterial(_matParameters)
5746            ];
5747            _this = _super.call(this, new THREE.BoxGeometry(width, height, depth, segments, 1, 1), _materials);
5748            _this.material[5].transparent = true;
5749            _this.material[4].transparent = true;
5750            _this.baseType = "Paper";
5751            _this.type = "Paper";
5752            _this.castShadow = true;
5753            _this.receiveShadow = true;
5754            options.parent3D.add(mockup_assert_this_initialized(_this));
5755            return _this;
5756        }
5757        mockup_create_class(Paper, [
5758            {
5759                key: "loadImage",
5760                value: function loadImage(texture, face, callback) {
5761                    MOCKUP.loadImage(this, texture, face, "map", callback);
5762                }
5763            },
5764            {
5765                key: "frontImage",
5766                value: function frontImage(texture, callback) {
5767                    MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.FRONT, "map", callback);
5768                }
5769            },
5770            {
5771                key: "backImage",
5772                value: function backImage(texture, callback) {
5773                    MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.BACK, "map", callback);
5774                }
5775            },
5776            {
5777                key: "loadBump",
5778                value: function loadBump(texture) {
5779                    MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.FRONT, "bumpMap", null);
5780                    MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.BACK, "bumpMap", null);
5781                }
5782            },
5783            {
5784                key: "loadNormalMap",
5785                value: function loadNormalMap(texture, face) {
5786                    if (face !== void 0) {
5787                        MOCKUP.loadImage(this, texture, face, "normalMap", null);
5788                        return;
5789                    }
5790                    MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.FRONT, "normalMap", null);
5791                    MOCKUP.loadImage(this, texture, MOCKUP.MATERIAL_FACE.BACK, "normalMap", null);
5792                }
5793            }
5794        ]);
5795        return Paper;
5796    }(THREE.Mesh);
5797    var Ground = /*#__PURE__*/ function(Paper) {
5798        "use strict";
5799        mockup_inherits(Ground, Paper);
5800        var _super = mockup_create_super(Ground);
5801        function Ground(options) {
5802            mockup_class_call_check(this, Ground);
5803            var _this;
5804            _this = _super.call(this, options);
5805            _this.receiveShadow = true;
5806            _this.frontImage(MOCKUP.defaults.groundTexture);
5807            _this.backImage(MOCKUP.defaults.groundTexture);
5808            _this.type = "Ground";
5809            return _this;
5810        }
5811        return Ground;
5812    }(Paper);
5813    var Stage = /*#__PURE__*/ function(_THREE_Scene) {
5814        "use strict";
5815        mockup_inherits(Stage, _THREE_Scene);
5816        var _super = mockup_create_super(Stage);
5817        function Stage(parameters) {
5818            mockup_class_call_check(this, Stage);
5819            var _this;
5820            _this = _super.call(this);
5821            var stage = mockup_assert_this_initialized(_this);
5822            //currently canvas is compulsory
5823            stage.canvas = parameters.canvas || document.createElement('canvas');
5824            stage.canvas = jQuery(_this.canvas);
5825            stage.camera = new THREE.PerspectiveCamera(20, stage.width / stage.height, 4, 50000);
5826            stage.renderer = new THREE.WebGLRenderer({
5827                canvas: stage.canvas[0],
5828                antialias: true,
5829                alpha: true
5830            });
5831            stage.renderer.setPixelRatio(parameters.pixelRatio);
5832            stage.renderer.setSize(stage.width, stage.height);
5833            stage.renderer.setClearColor(0xffffff, 0);
5834            // let orbitControl = stage.orbitControl = new THREE.SimpleOrbitControls(stage.renderer, stage, stage.camera);
5835            stage.renderer.shadowMap.enabled = true;
5836            stage.renderer.shadowMap.type = 1;
5837            stage.ground = new Ground({
5838                color: 0xffffff,
5839                height: stage.camera.far / 10,
5840                width: stage.camera.far / 10,
5841                segments: 2,
5842                parent3D: stage
5843            });
5844            stage.ambientLight = new THREE.AmbientLight(0x444444);
5845            stage.add(stage.ambientLight);
5846            var spotLight = stage.spotLight = new THREE.DirectionalLight(0xffffff, 0.25);
5847            spotLight.position.set(0, 1, 0);
5848            if (parameters.castShadow !== false) {
5849                spotLight.castShadow = true;
5850                spotLight.shadow.camera.near = 200;
5851                spotLight.shadow.camera.far = 2000;
5852                spotLight.shadow.camera.top = 1350;
5853                spotLight.shadow.camera.bottom = -1350;
5854                spotLight.shadow.camera.left = -1350;
5855                spotLight.shadow.camera.right = 1350;
5856                spotLight.shadow.radius = 2;
5857                spotLight.shadow.mapSize.width = 1024;
5858                spotLight.shadow.mapSize.height = 1024;
5859                spotLight.shadow.needsUpdate = true;
5860            }
5861            stage.add(spotLight);
5862            stage.animateCount = 0;
5863            stage.renderCount = 0;
5864            stage.camera.position.set(-300, 300, 300);
5865            stage.camera.lookAt(new THREE.Vector3(0, 0, 0));
5866            return _this;
5867        }
5868        mockup_create_class(Stage, [
5869            {
5870                key: "resizeCanvas",
5871                value: function resizeCanvas(width, height) {
5872                    this.renderer.setSize(width, height);
5873                    this.camera.aspect = width / height;
5874                    this.camera.updateProjectionMatrix();
5875                }
5876            },
5877            {
5878                key: "render",
5879                value: function render() {
5880                    this.animateCount++;
5881                    this.renderer.render(this, this.camera);
5882                    if (this.stats != null) this.stats.update();
5883                }
5884            },
5885            {
5886                key: "clearMaterials",
5887                value: function clearMaterials() {
5888                    var totalChild = this.children.length;
5889                    for(var count = totalChild - 1; count >= 0; count--){
5890                        var child = this.children[count];
5891                        if (child.baseType && child.baseType === "Paper") {
5892                            if (child.material) {
5893                                if (child.material.length) {
5894                                    for(var countMat = 0; countMat < child.material.length; countMat++)child.material[countMat].needsUpdate = true;
5895                                } else {
5896                                    child.material.needsUpdate = true;
5897                                }
5898                            }
5899                        }
5900                    }
5901                }
5902            },
5903            {
5904                key: "clearChild",
5905                value: function clearChild() {
5906                    this.spotLight.shadow.map = utils.disposeObject(this.spotLight.shadow.map);
5907                    this.spotLight.castShadow = false;
5908                    this.clearMaterials();
5909                    var totalChild = this.children.length;
5910                    for(var count = totalChild - 1; count >= 0; count--){
5911                        var child = this.children[count];
5912                        if (child.children && child.children.length > 0) {
5913                            for(var stackCount = child.children.length - 1; stackCount >= 0; stackCount--){
5914                                MOCKUP.clearChild(child.children[stackCount]);
5915                            }
5916                        }
5917                        MOCKUP.clearChild(child);
5918                        child = null;
5919                    }
5920                    this.render();
5921                }
5922            }
5923        ]);
5924        return Stage;
5925    }(THREE.Scene);
5926    MOCKUP.Paper = Paper;
5927    MOCKUP.Stage = Stage;
5928    //endregion
5929    //region CSS3DObject
5930    var CSS3DObject = /*#__PURE__*/ function(_THREE_Object3D) {
5931        "use strict";
5932        mockup_inherits(CSS3DObject, _THREE_Object3D);
5933        var _super = mockup_create_super(CSS3DObject);
5934        function CSS3DObject(e) {
5935            mockup_class_call_check(this, CSS3DObject);
5936            var _this;
5937            _this = _super.call(this);
5938            _this.element = e;
5939            _this.element.style.position = "absolute";
5940            _this.addEventListener("removed", function() {
5941                if (this.element.parentNode !== null) {
5942                    this.element.parentNode.removeChild(this.element);
5943                }
5944            });
5945            return _this;
5946        }
5947        return CSS3DObject;
5948    }(THREE.Object3D);
5949    THREE.CSS3DObject = CSS3DObject;
5950    var CSS3DSprite = /*#__PURE__*/ function(_THREE_CSS3DObject) {
5951        "use strict";
5952        mockup_inherits(CSS3DSprite, _THREE_CSS3DObject);
5953        var _super = mockup_create_super(CSS3DSprite);
5954        function CSS3DSprite(e) {
5955            mockup_class_call_check(this, CSS3DSprite);
5956            return _super.call(this, e);
5957        }
5958        return CSS3DSprite;
5959    }(THREE.CSS3DObject);
5960    THREE.CSS3DSprite = CSS3DSprite;
5961    if (THREE.MathUtils) THREE.Math = THREE.MathUtils;
5962    THREE.CSS3DRenderer = function() {
5963        utils.log("THREE.CSS3DRenderer", THREE.REVISION);
5964        var e, t;
5965        var r, i;
5966        var n = new THREE.Matrix4;
5967        var a = {
5968            camera: {
5969                fov: 0,
5970                style: ""
5971            },
5972            objects: {}
5973        };
5974        var o = document.createElement("div");
5975        o.style.overflow = "hidden";
5976        o.style.WebkitTransformStyle = "preserve-3d";
5977        o.style.MozTransformStyle = "preserve-3d";
5978        o.style.oTransformStyle = "preserve-3d";
5979        o.style.transformStyle = "preserve-3d";
5980        this.domElement = o;
5981        var s = document.createElement("div");
5982        s.style.WebkitTransformStyle = "preserve-3d";
5983        s.style.MozTransformStyle = "preserve-3d";
5984        s.style.oTransformStyle = "preserve-3d";
5985        s.style.transformStyle = "preserve-3d";
5986        o.appendChild(s);
5987        this.setClearColor = function() {};
5988        this.getSize = function() {
5989            return {
5990                width: e,
5991                height: t
5992            };
5993        };
5994        this.setSize = function(n, a) {
5995            e = n;
5996            t = a;
5997            r = e / 2;
5998            i = t / 2;
5999            o.style.width = n + "px";
6000            o.style.height = a + "px";
6001            s.style.width = n + "px";
6002            s.style.height = a + "px";
6003        };
6004        var h = function h(e) {
6005            return Math.abs(e) < Number.EPSILON ? 0 : e;
6006        };
6007        var u = function u(e) {
6008            var t = e.elements;
6009            return "matrix3d(" + h(t[0]) + "," + h(-t[1]) + "," + h(t[2]) + "," + h(t[3]) + "," + h(t[4]) + "," + h(-t[5]) + "," + h(t[6]) + "," + h(t[7]) + "," + h(t[8]) + "," + h(-t[9]) + "," + h(t[10]) + "," + h(t[11]) + "," + h(t[12]) + "," + h(-t[13]) + "," + h(t[14]) + "," + h(t[15]) + ")";
6010        };
6011        var c = function c(e) {
6012            var t = e.elements;
6013            return "translate3d(-50%,-50%,0) matrix3d(" + h(t[0]) + "," + h(t[1]) + "," + h(t[2]) + "," + h(t[3]) + "," + h(-t[4]) + "," + h(-t[5]) + "," + h(-t[6]) + "," + h(-t[7]) + "," + h(t[8]) + "," + h(t[9]) + "," + h(t[10]) + "," + h(t[11]) + "," + h(t[12]) + "," + h(t[13]) + "," + h(t[14]) + "," + h(t[15]) + ")";
6014        };
6015        var l = function l1(e, t) {
6016            if (mockup_instanceof(e, THREE.CSS3DObject)) {
6017                var r;
6018                if (mockup_instanceof(e, THREE.CSS3DSprite)) {
6019                    n.copy(t.matrixWorldInverse);
6020                    n.transpose();
6021                    n.copyPosition(e.matrixWorld);
6022                    n.scale(e.scale);
6023                    n.elements[3] = 0;
6024                    n.elements[7] = 0;
6025                    n.elements[11] = 0;
6026                    n.elements[15] = 1;
6027                    r = c(n);
6028                } else {
6029                    r = c(e.matrixWorld);
6030                }
6031                var i = e.element;
6032                var o = a.objects[e.id];
6033                if (o === undefined || o !== r) {
6034                    i.style.WebkitTransform = r;
6035                    i.style.MozTransform = r;
6036                    i.style.oTransform = r;
6037                    i.style.transform = r;
6038                    a.objects[e.id] = r;
6039                }
6040                if (i.parentNode !== s) {
6041                    s.appendChild(i);
6042                }
6043            }
6044            for(var h = 0, u = e.children.length; h < u; h++){
6045                l(e.children[h], t);
6046            }
6047        };
6048        this.render = function(e, n) {
6049            var h = .5 / Math.tan(THREE.Math.degToRad(n.fov * .5)) * t;
6050            if (a.camera.fov !== h) {
6051                o.style.WebkitPerspective = h + "px";
6052                o.style.MozPerspective = h + "px";
6053                o.style.oPerspective = h + "px";
6054                o.style.perspective = h + "px";
6055                a.camera.fov = h;
6056            }
6057            e.updateMatrixWorld();
6058            if (n.parent === null) n.updateMatrixWorld();
6059            if (n.matrixWorldInverse.invert) n.matrixWorldInverse.copy(n.matrixWorld).invert();
6060            else n.matrixWorldInverse.getInverse(n.matrixWorld);
6061            var c = "translate3d(0,0," + h + "px)" + u(n.matrixWorldInverse) + " translate3d(" + r + "px," + i + "px, 0)";
6062            if (a.camera.style !== c) {
6063                s.style.WebkitTransform = c;
6064                s.style.MozTransform = c;
6065                s.style.oTransform = c;
6066                s.style.transform = c;
6067                a.camera.style = c;
6068            }
6069            l(e, n);
6070        };
6071    };
6072//endregion
6073};
6074
6075
6076;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/flipbook-3d.js
6077/* globals jQuery, pdfjsLib,THREE  */ function flipbook_3d_assert_this_initialized(self) {
6078    if (self === void 0) {
6079        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
6080    }
6081    return self;
6082}
6083function flipbook_3d_class_call_check(instance, Constructor) {
6084    if (!(instance instanceof Constructor)) {
6085        throw new TypeError("Cannot call a class as a function");
6086    }
6087}
6088function flipbook_3d_defineProperties(target, props) {
6089    for(var i = 0; i < props.length; i++){
6090        var descriptor = props[i];
6091        descriptor.enumerable = descriptor.enumerable || false;
6092        descriptor.configurable = true;
6093        if ("value" in descriptor) descriptor.writable = true;
6094        Object.defineProperty(target, descriptor.key, descriptor);
6095    }
6096}
6097function flipbook_3d_create_class(Constructor, protoProps, staticProps) {
6098    if (protoProps) flipbook_3d_defineProperties(Constructor.prototype, protoProps);
6099    if (staticProps) flipbook_3d_defineProperties(Constructor, staticProps);
6100    return Constructor;
6101}
6102function flipbook_3d_get(target, property, receiver) {
6103    if (typeof Reflect !== "undefined" && Reflect.get) {
6104        flipbook_3d_get = Reflect.get;
6105    } else {
6106        flipbook_3d_get = function get(target, property, receiver) {
6107            var base = flipbook_3d_super_prop_base(target, property);
6108            if (!base) return;
6109            var desc = Object.getOwnPropertyDescriptor(base, property);
6110            if (desc.get) {
6111                return desc.get.call(receiver || target);
6112            }
6113            return desc.value;
6114        };
6115    }
6116    return flipbook_3d_get(target, property, receiver || target);
6117}
6118function flipbook_3d_get_prototype_of(o) {
6119    flipbook_3d_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o
6119) {
6120        return o.__proto__ || Object.getPrototypeOf(o);
6121    };
6122    return flipbook_3d_get_prototype_of(o);
6123}
6124function flipbook_3d_inherits(subClass, superClass) {
6125    if (typeof superClass !== "function" && superClass !== null) {
6126        throw new TypeError("Super expression must either be null or a function");
6127    }
6128    subClass.prototype = Object.create(superClass && superClass.prototype, {
6129        constructor: {
6130            value: subClass,
6131            writable: true,
6132            configurable: true
6133        }
6134    });
6135    if (superClass) flipbook_3d_set_prototype_of(subClass, superClass);
6136}
6137function flipbook_3d_possible_constructor_return(self, call) {
6138    if (call && (flipbook_3d_type_of(call) === "object" || typeof call === "function")) {
6139        return call;
6140    }
6141    return flipbook_3d_assert_this_initialized(self);
6142}
6143function flipbook_3d_set_prototype_of(o, p) {
6144    flipbook_3d_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
6145        o.__proto__ = p;
6146        return o;
6147    };
6148    return flipbook_3d_set_prototype_of(o, p);
6149}
6150function flipbook_3d_super_prop_base(object, property) {
6151    while(!Object.prototype.hasOwnProperty.call(object, property)){
6152        object = flipbook_3d_get_prototype_of(object);
6153        if (object === null) break;
6154    }
6155    return object;
6156}
6157function flipbook_3d_type_of(obj) {
6158    "@swc/helpers - typeof";
6159    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
6160}
6161function flipbook_3d_is_native_reflect_construct() {
6162    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
6163    if (Reflect.construct.sham) return false;
6164    if (typeof Proxy === "function") return true;
6165    try {
6166        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
6167        return true;
6168    } catch (e) {
6169        return false;
6170    }
6171}
6172function flipbook_3d_create_super(Derived) {
6173    var hasNativeReflectConstruct = flipbook_3d_is_native_reflect_construct();
6174    return function _createSuperInternal() {
6175        var Super = flipbook_3d_get_prototype_of(Derived), result;
6176        if (hasNativeReflectConstruct) {
6177            var NewTarget = flipbook_3d_get_prototype_of(this).constructor;
6178            result = Reflect.construct(Super, arguments, NewTarget);
6179        } else {
6180            result = Super.apply(this, arguments);
6181        }
6182        return flipbook_3d_possible_constructor_return(this, result);
6183    };
6184}
6185
6186
6187
6188
6189var flipbook_3d_DV = defaults_DEARVIEWER;
6190var flipbook_3d_utils = flipbook_3d_DV.utils;
6191var BookSheet3D = /*#__PURE__*/ function(BookSheet) {
6192    "use strict";
6193    flipbook_3d_inherits(BookSheet3D, BookSheet);
6194    var _super = flipbook_3d_create_super(BookSheet3D);
6195    function BookSheet3D(options) {
6196        flipbook_3d_class_call_check(this, BookSheet3D);
6197        var _this;
6198        _this = _super.call(this, options);
6199        _this.flexibility = options.flexibility;
6200        _this.sheetAngle = 180;
6201        _this.curveAngle = 0;
6202        _this.parent3D = options.parent3D;
6203        _this.segments = options.segments || 50;
6204        _this.width = options.width || 100;
6205        _this.height = options.height || 100;
6206        _this.depth = options.depth || 0.5; //is overridden from options
6207        _this.matColor = "white";
6208        _this.fallbackMatColor = MOCKUP.WHITE_COLOR;
6209        _this.init();
6210        _this.bumpScale = [
6211            0,
6212            0,
6213            0,
6214            0,
6215            1,
6216            1
6217        ];
6218        return _this;
6219    }
6220    flipbook_3d_create_class(BookSheet3D, [
6221        {
6222            key: "init",
6223            value: function init() {
6224                var sheet = this;
6225                sheet.element = new MOCKUP.Paper({
6226                    parent3D: sheet.parent3D,
6227                    segments: sheet.segments,
6228                    depth: sheet.depth,
6229                    height: sheet.height,
6230                    width: sheet.width,
6231                    flatShading: sheet.flexibility === 0 ? true : false
6232                });
6233                sheet.element.sheet = sheet;
6234                sheet.frontPage = new Page3D({
6235                    sheet: sheet,
6236                    face: 5
6237                });
6238                sheet.backPage = new Page3D({
6239                    sheet: sheet,
6240                    face: 4
6241                });
6242                sheet.reset();
6243                sheet.updateAngle();
6244            //sheet.element.loadBump("http://localhost/tmp/cardboard.png");
6245            }
6246        },
6247        {
6248            key: "setMatColor",
6249            value: function setMatColor(val, face) {
6250                this.matColor = new THREE.Color(val);
6251                if (face === void 0) {
6252                    for(var i = 0; i < 6; i++){
6253                        this.element.material[i].color = this.matColor;
6254                    }
6255                } else {
6256                    this.element.material[face].color = this.matColor;
6257                }
6258            }
6259        },
6260        {
6261            key: "getBumpScale",
6262            value: function getBumpScale(face) {
6263                return this.bumpScale[face];
6264            }
6265        },
6266        {
6267            key: "resetMatColor",
6268            value: function resetMatColor(face, applyMatColor) {
6269                this.element.material[face].color = applyMatColor ? this.matColor : this.fallbackMatColor;
6270            }
6271        },
6272        {
6273            key: "frontImage",
6274            value: function frontImage(texture, callback) {
6275                this.element.frontImage(texture, callback);
6276            }
6277        },
6278        {
6279            key: "backImage",
6280            value: function backImage(texture, callback) {
6281                this.element.backImage(texture, callback);
6282            }
6283        },
6284        {
6285            key: "updateAngle",
6286            value: function updateAngle() {
6287                var sheet = this;
6288                if (this.viewer === undefined || this.viewer === null) return;
6289                var flexibility = sheet.isHard === true ? 0 : sheet.flexibility;
6290                var width = (this.viewer.orientation === 'vertical' ? this.height : this.width) * (1 - Math.sin(flexibility / 2 * (flexibility / 2)) / 2 - flexibility / 20);
6291                this.element.scale.y = (this.viewer.orientation === 'vertical' ? this.width : this.height) / this.element.geometry.parameters.height;
6292                // this.element.scale.x = this.width / this.element.geometry.parameters.width;
6293                // this.element.scale.z = 1;
6294                var segments = sheet.segments;
6295                var foldCount = 1;
6296                var foldWidth = width / foldCount; //fold-width
6297                var curveHandlePoint = foldWidth * flexibility; //bend control point distance
6298                var curveWidth = foldWidth; //curve width still not perfect
6299                //control pointsFront are a list of at least (degree+1)
6300                var curvesFront = [];
6301                var curvesBack = [];
6302                var verticesFront = [];
6303                var verticesBack = [];
6304                var pointsFront = [];
6305                var pointsBack = [];
6306                var sheetDepth = sheet.depth; // distance Bias
6307                //calculate folds controls points
6308                var sum = 0, distances = [];
6309                distances.push(sum);
6310                // let test = false;
6311                // region CalcPoints
6312                pointsFront[0] = [];
6313                pointsBack[0] = [];
6314                var sheetAngle = sheet.sheetAngle * Math.PI / 180; // the angle at which the sheet will turn
6315                // if (this.viewer.pageOffset && this.viewer.hasSpiral) {
6316                if (this.viewer.orientation !== 'vertical') {
6317                    this.element.position.x = -Math.cos(sheetAngle) * this.viewer.pageOffset;
6318                }
6319                if (this.viewer.orientation === 'vertical') {
6320                    this.element.position.y = Math.cos(sheetAngle) * this.viewer.pageOffset;
6321                }
6322                // }
6323                var curveAngle = sheet.isHard === true ? sheetAngle : sheet.curveAngle * Math.PI / 180; // the angle at which curve will form due to curve handle point
6324                var pointAngle = sheet.sheetAngle * Math.PI / 180;
6325                var pointAngleB = pointAngle - Math.PI / 2, zShift = Math.sin(pointAngleB) * sheetDepth / 2;
6326                pointsFront[0][0] = pointsFront[0][1] = new THREE.Vector3(-curveWidth * Math.cos(sheetAngle), 0, Math.sin(sheetAngle) * curveWidth - zShift);
6327                pointsBack[0][0] = pointsBack[0][1] = new THREE.Vector3(pointsFront[0][0].x - Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][0].z + zShift * 2);
6328                pointsFront[0][1] = new THREE.Vector3(-curveWidth / 2 * Math.cos(curveAngle), 0, curveWidth / 2 * Math.sin(curveAngle) - zShift);
6329                pointsBack[0][1] = new THREE.Vector3(pointsFront[0][1].x - Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][1].z + zShift * 2);
6330                pointAngle = (45 + sheet.sheetAngle / 2) * Math.PI / 180;
6331                pointsFront[0][2] = new THREE.Vector3(-Math.cos(pointAngle) * curveHandlePoint / 2, 0, Math.sin(pointAngle) * curveHandlePoint - zShift);
6332                pointsBack[0][2] = new THREE.Vector3(pointsFront[0][2].x + Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][2].z + zShift * 2);
6333                if (Math.abs(pointsBack[0][2].x - 0) < 0.0005) pointsBack[0][2].x = 0;
6334                pointsFront[0][3] = new THREE.Vector3(0, 0, -zShift);
6335                pointsBack[0][3] = new THREE.Vector3(pointsFront[0][3].x - Math.cos(pointAngleB) * sheetDepth, 0, pointsFront[0][3].z + zShift * 2); //pointsFront[0][3];
6336                if (Math.abs(pointsBack[0][3].x - 0) < 0.0005) pointsBack[0][3].x = 0;
6337                //endregion
6338                for(var curveCount = 0; curveCount < foldCount; curveCount++){
6339                    var length = Math.max(sheet.segments - 1, 1);
6340                    curvesFront[curveCount] = new THREE.CubicBezierCurve3(pointsFront[curveCount][0], pointsFront[curveCount][1], pointsFront[curveCount][2], pointsFront[curveCount][3]);
6341                    verticesFront[curveCount] = curvesFront[curveCount].getPoints(length);
6342                    if (length > 2) {
6343                        verticesFront[curveCount].push(new THREE.Vector3().copy(verticesFront[curveCount][length]));
6344                    }
6345                    var current = void 0, last = verticesFront[curveCount][0];
6346                    for(var vcount = 1; vcount < verticesFront[curveCount].length; vcount++){
6347                        current = verticesFront[curveCount][vcount];
6348                        sum += current.distanceTo(last);
6349                        distances.push(sum);
6350                        last = current;
6351                    }
6352                    curvesBack[curveCount] = new THREE.CubicBezierCurve3(pointsBack[curveCount][0], pointsBack[curveCount][1], pointsBack[curveCount][2], pointsBack[curveCount][3]);
6353                    verticesBack[curveCount] = curvesBack[curveCount].getPoints(length);
6354                    if (length > 2) {
6355                        verticesBack[curveCount].push(new THREE.Vector3().copy(verticesBack[curveCount][length]));
6356                    }
6357                }
6358                /*var test = true;
6359    if (test === true) {
6360      if (sheet.handlesf === void 0) {
6361
6362        let material = new THREE.LineBasicMaterial({color: 0x00ff00});
6363
6364        let geometry = new THREE.Geometry();
6365        geometry.vertices.push(
6366          pointsFront[0][0], pointsFront[0][1], pointsFront[0][2], pointsFront[0][3]
6367        );
6368
6369        sheet.handlesf = new THREE.Line(geometry, material);
6370        sheet.element.add(sheet.handlesf);
6371
6372      }
6373      else {
6374        let hvs = sheet.handlesf.geometry.vertices;
6375        for (let hcount = 0; hcount < hvs.length; hcount++) {
6376          hvs[hcount] = pointsFront[0][hcount];
6377        }
6378        sheet.handlesf.geometry.verticesNeedUpdate = true;
6379      }
6380      if (sheet.handlesb === void 0) {
6381
6382        let material = new THREE.LineBasicMaterial({color: 0x0000ff});
6383
6384        let geometry = new THREE.Geometry();
6385        geometry.vertices.push(
6386          pointsBack[0][0], pointsBack[0][1], pointsBack[0][2], pointsBack[0][3]
6387        );
6388
6389        sheet.handlesb = new THREE.Line(geometry, material);
6390        sheet.element.add(sheet.handlesb);
6391
6392      }
6393      else {
6394        let hvs = sheet.handlesb.geometry.vertices;
6395        for (let hcount = 0; hcount < hvs.length; hcount++) {
6396          hvs[hcount] = pointsBack[0][hcount];
6397        }
6398        sheet.handlesb.geometry.verticesNeedUpdate = true;
6399      }
6400    }
6401
6402*/ var bodyG = sheet.element.geometry;
6403                if (bodyG.attributes !== void 0) {
6404                    //5 segments have 56 vertices
6405                    /*
6406      * 5 segments have 56 vertices
6407      * 8 are side vertices
6408      * remaining 48 in 4 faces
6409      * each 12 vertices
6410      *rowvertices = segments + 1
6411      * 1,7   -   2,8   -   3,9   -   4,10  -   5,11  -   6,12    x + rowvertices*0 + count, x + rowvertices*1 + count
6412      * 13,19 -   14,20 -   15,21 -   16,22 -   17,23 -   18,24   x + rowvertices*2 + 1, x + rowvertices*3 + 1
6413      * 25,31 -   26,32 -   27,33 -   28,34 -   29,35 -   30,36
6414      * 37,43 -   38,44 -   39,45 -   40,46 -   41,47 -   42,48
6415      *
6416      * */ var positions = bodyG.attributes.position;
6417                    var uvs = bodyG.attributes.uv;
6418                    var rowVertices = segments + 1;
6419                    var offset = 8;
6420                    //region basic side vertices
6421                    //Update the geometry based on angles
6422                    positions.setZ(0, verticesFront[0][segments].z);
6423                    positions.setZ(2, verticesFront[0][segments].z);
6424                    positions.setX(0, verticesFront[0][segments].x);
6425                    positions.setX(2, verticesFront[0][segments].x);
6426                    // verts[0].z = verts[2].z = verticesFront[0][segments].z;
6427                    // verts[0].x = verts[2].x = verticesFront[0][segments].x;
6428                    positions.setZ(1, verticesBack[0][segments].z);
6429                    positions.setZ(3, verticesBack[0][segments].z);
6430                    positions.setX(1, verticesBack[0][segments].x);
6431                    positions.setX(3, verticesBack[0][segments].x);
6432                    // verts[1].z = verts[3].z = verticesBack[0][segments].z;
6433                    // verts[1].x = verts[3].x = verticesBack[0][segments].x;
6434                    positions.setZ(5, verticesFront[0][0].z);
6435                    positions.setZ(7, verticesFront[0][0].z);
6436                    positions.setX(5, verticesFront[0][0].x);
6437                    positions.setX(7, verticesFront[0][0].x);
6438                    // verts[5].z = verts[7].z = verticesFront[0][0].z;
6439                    // verts[5].x = verts[7].x = verticesFront[0][0].x;
6440                    positions.setZ(4, verticesBack[0][0].z);
6441                    positions.setZ(6, verticesBack[0][0].z);
6442                    positions.setX(4, verticesBack[0][0].x);
6443                    positions.setX(6, verticesBack[0][0].x);
6444                    // verts[4].z = verts[6].z = verticesBack[0][0].z;
6445                    // verts[4].x = verts[6].x = verticesBack[0][0].x;
6446                    //endregion
6447                    for(var fold = 0; fold < foldCount; fold++){
6448                        for(var count = 0; count < rowVertices; count++){
6449                            positions.setZ(offset + rowVertices * 0 + count, verticesFront[0][count].z);
6450                            positions.setX(offset + rowVertices * 0 + count, verticesFront[0][count].x);
6451                            positions.setZ(offset + rowVertices * 1 + count, verticesBack[0][count].z);
6452                            positions.setX(offset + rowVertices * 1 + count, verticesBack[0][count].x);
6453                            positions.setZ(offset + rowVertices * 2 + count, verticesFront[0][count].z);
6454                            positions.setX(offset + rowVertices * 2 + count, verticesFront[0][count].x);
6455                            positions.setZ(offset + rowVertices * 3 + count, verticesBack[0][count].z);
6456                            positions.setX(offset + rowVertices * 3 + count, verticesBack[0][count].x);
6457                            positions.setZ(offset + rowVertices * 4 + count, verticesFront[0][count].z);
6458                            positions.setX(offset + rowVertices * 4 + count, verticesFront[0][count].x);
6459                            positions.setZ(offset + rowVertices * 5 + count, verticesFront[0][count].z);
6460                            positions.setX(offset + rowVertices * 5 + count, verticesFront[0][count].x);
6461                            uvs.setX(offset + rowVertices * 4 + count, distances[count] / sum);
6462                            uvs.setX(offset + rowVertices * 5 + count, distances[count] / sum);
6463                            positions.setZ(offset + rowVertices * 6 + count, verticesBack[0][segments - count].z);
6464                            positions.setX(offset + rowVertices * 6 + count, verticesBack[0][segments - count].x);
6465                            positions.setZ(offset + rowVertices * 7 + count, verticesBack[0][segments - count].z);
6466                            positions.setX(offset + rowVertices * 7 + count, verticesBack[0][segments - count].x);
6467                            uvs.setX(offset + rowVertices * 6 + count, 1 - distances[segments - count] / sum);
6468                            uvs.setX(offset + rowVertices * 7 + count, 1 - distances[segments - count] / sum);
6469                        // verts[offset].z = verts[offset + rowVertices * 3].z = verticesBack[0][count].z;
6470                        // verts[offset].x = verts[offset + rowVertices * 3].x = verticesBack[0][count].x;
6471                        // verts[offset + rowVertices].z = verts[offset + rowVertices * 2].z = verticesFront[0][count].z;
6472                        // verts[offset + rowVertices].x = verts[offset + rowVertices * 2].x = verticesFront[0][count].x;
6473                        // offset++;
6474                        }
6475                    }
6476                    bodyG.computeBoundingBox();
6477                    sheet.element.scale.x = curveWidth * foldCount / sum;
6478                    // sheet.element.scale.z = sheet.element.scale.x;//1 + (Math.cos(pointAngleB) * sheet.element.scale.x / sheet.element.scale.x);
6479                    bodyG.computeBoundingSphere();
6480                    positions.needsUpdate = true;
6481                    uvs.needsUpdate = true;
6482                    bodyG.computeVertexNormals();
6483                } else {
6484                    var verts = bodyG.vertices;
6485                    var rowVertices1 = segments - 1;
6486                    var offset1 = 8;
6487                    //Update the geometry based on angles
6488                    verts[0].z = verts[2].z = verticesFront[0][segments].z;
6489                    verts[0].x = verts[2].x = verticesFront[0][segments].x;
6490                    verts[1].z = verts[3].z = verticesBack[0][segments].z;
6491                    verts[1].x = verts[3].x = verticesBack[0][segments].x;
6492                    verts[5].z = verts[7].z = verticesFront[0][0].z;
6493                    verts[5].x = verts[7].x = verticesFront[0][0].x;
6494                    verts[4].z = verts[6].z = verticesBack[0][0].z;
6495                    verts[4].x = verts[6].x = verticesBack[0][0].x;
6496                    for(var fold1 = 0; fold1 < foldCount; fold1++){
6497                        for(var count1 = 1; count1 < segments; count1++){
6498                            verts[offset1].z = verts[offset1 + rowVertices1 * 3].z = verticesBack[0][count1].z;
6499                            verts[offset1].x = verts[offset1 + rowVertices1 * 3].x = verticesBack[0][count1].x;
6500                            verts[offset1 + rowVertices1].z = verts[offset1 + rowVertices1 * 2].z = verticesFront[0][count1].z;
6501                            verts[offset1 + rowVertices1].x = verts[offset1 + rowVertices1 * 2].x = verticesFront[0][count1].x;
6502                            offset1++;
6503                        }
6504                    }
6505                    var uvs1 = bodyG.faceVertexUvs[0];
6506                    var faces = bodyG.faces;
6507                    var uvIndexFront = 0;
6508                    for(var count2 = 0; count2 < uvs1.length; count2++){
6509                        if (faces[count2].materialIndex === MOCKUP.MATERIAL_FACE.BACK) {
6510                            var dist = distances[uvIndexFront] / sum;
6511                            if (count2 % 2 === 0) {
6512                                uvs1[count2][0].x = uvs1[count2][1].x = uvs1[count2 + 1][0].x = dist;
6513                                uvIndexFront++;
6514                            } else {
6515                                uvs1[count2 - 1][2].x = uvs1[count2][1].x = uvs1[count2][2].x = dist;
6516                            }
6517                        } else if (faces[count2].materialIndex === MOCKUP.MATERIAL_FACE.FRONT) {
6518                            var dist1 = 1 - distances[uvIndexFront] / sum;
6519                            //console.log(dist);
6520                            if (count2 % 2 === 0) {
6521                                uvs1[count2][0].x = uvs1[count2][1].x = uvs1[count2 + 1][0].x = dist1;
6522                                uvIndexFront--;
6523                            } else {
6524                                uvs1[count2 - 1][2].x = uvs1[count2][1].x = uvs1[count2][2].x = dist1;
6525                            }
6526                        }
6527                    }
6528                    bodyG.computeBoundingBox();
6529                    sheet.element.scale.x = curveWidth * foldCount / sum;
6530                    // sheet.element.scale.z = sheet.element.scale.x;//1 + (Math.cos(pointAngleB) * sheet.element.scale.x / sheet.element.scale.x);
6531                    bodyG.computeBoundingSphere();
6532                    bodyG.verticesNeedUpdate = true;
6533                    bodyG.computeFaceNormals();
6534                    bodyG.computeVertexNormals();
6535                    bodyG.uvsNeedUpdate = true;
6536                    bodyG.normalsNeedUpdate = true;
6537                }
6538                curvesFront.forEach(function(curveF) {
6539                    curveF = null;
6540                });
6541                curvesBack.forEach(function(curveB) {
6542                    curveB = null;
6543                });
6544                verticesBack.forEach(function(vertexB) {
6545                    vertexB = null;
6546                });
6547                verticesFront.forEach(function(vertexF) {
6548                    vertexF = null;
6549                });
6550            }
6551        },
6552        {
6553            key: "flip",
6554            value: function flip(oldAngle, newAngle) {
6555                var sheet = this;
6556                var isBooklet = sheet.viewer.isBooklet;
6557                //https://github.com/deepak-ghimire/dearviewer/issues/494
6558                if (sheet.isCover === true) {
6559                    if (oldAngle === 0) oldAngle = sheet.viewer.flexibility * 2.5;
6560                    if (oldAngle === 180) oldAngle = oldAngle - sheet.viewer.flexibility * 2.5;
6561                }
6562                var diff = newAngle - oldAngle; //170 -5 == 165 :  5-170 = -165
6563                var isRight = oldAngle > 90;
6564                var isRTL = sheet.viewer.isRTL;
6565                var pageNumber = isRight ? sheet.backPage.pageNumber : sheet.frontPage.pageNumber;
6566                var viewport = this.viewer.getViewPort(pageNumber);
6567                if (viewport) viewport = flipbook_3d_utils.contain(viewport.width, viewport.height, sheet.viewer.availablePageWidth(), sheet.viewer.availablePageHeight());
6568                var coverAdjustmentWidth = -(sheet.viewer.has3DCover && sheet.viewer.isClosedPage() ? sheet.viewer.coverExtraWidth : 0), coverAdjustmentHeight = -(sheet.viewer.has3DCover && sheet.viewer.isClosedPage() ? sheet.viewer.coverExtraHeight : 0);
6569                sheet.init = {
6570                    angle: oldAngle,
6571                    height: isRight ? sheet.viewer.rightSheetHeight : sheet.viewer.leftSheetHeight,
6572                    width: isRight ? sheet.viewer.rightSheetWidth : sheet.viewer.leftSheetWidth,
6573                    index: isRight && !isRTL || !isRight && isRTL ? 1 : 0,
6574                    _index: 0
6575                };
6576                sheet.first = {
6577                    angle: oldAngle + diff / 4,
6578                    index: isRight && !isRTL || !isRight && isRTL ? 1 : 0.25
6579                };
6580                sheet.mid = {
6581                    angle: oldAngle + diff * 2 / 4,
6582                    index: isRight && !isRTL || !isRight && isRTL ? 0.5 : 0.5
6583                };
6584                sheet.mid2 = {
6585                    angle: oldAngle + diff * 3 / 4,
6586                    index: isRight && !isRTL || !isRight && isRTL ? 0.25 : 1
6587                };
6588                sheet.end = {
6589                    angle: newAngle,
6590                    index: isRight && !isRTL || !isRight && isRTL ? 0 : 1,
6591                    height: coverAdjustmentHeight + (viewport ? viewport.height : sheet.height),
6592                    width: coverAdjustmentWidth + (viewport ? viewport.width : sheet.width)
6593                };
6594                //console.log(sheet.init, sheet.first, sheet.mid, sheet.end);
6595                sheet.isFlipping = true;
6596                var update = function update(tween) {
6597                    sheet.sheetAngle = tween.angle;
6598                    sheet.curveAngle = sheet.isHard ? tween.angle : flipbook_3d_utils.getCurveAngle(isRight, tween.angle);
6599                    if (sheet.isHard === true) {
6600                        sheet.flexibility = 0;
6601                        if (sheet.isCover) {
6602                            sheet.viewer.flipCover(sheet);
6603                        }
6604                    } else {
6605                        sheet.flexibility = tween.angle < 90 ? sheet.leftFlexibility : sheet.rightFlexibility;
6606                    }
6607                    sheet.element.position.z = (tween.angle < 90 ? sheet.leftPos : sheet.rightPos) + sheet.depth;
6608                    if (isBooklet) {
6609                        sheet.element.material[5].opacity = sheet.element.material[4].opacity = tween.index;
6610                        sheet.element.castShadow = isRight && !isRTL || !isRight && isRTL ? tween.index > 0.5 : tween.index > 0.5;
6611                    }
6612                    sheet.height = tween.height;
6613                    sheet.width = tween.width;
6614                    sheet.updateAngle(true);
6615                };
6616                if (isBooklet && (!isRight && !isRTL || isRight && isRTL)) {
6617                    sheet.element.material[5].opacity = sheet.element.material[4].opacity = 0;
6618                    sheet.element.castShadow = false;
6619                }
6620                sheet.currentTween = new TWEEN.Tween(sheet.init).to({
6621                    angle: [
6622                        sheet.first.angle,
6623                        sheet.mid.angle,
6624                        sheet.mid2.angle,
6625                        sheet.end.angle
6626                    ],
6627                    index: [
6628                        sheet.first.index,
6629                        sheet.mid.index,
6630                        sheet.mid2.index,
6631                        sheet.end.index
6632                    ],
6633                    _index: 1,
6634                    height: sheet.end.height,
6635                    width: sheet.end.width
6636                }, sheet.viewer.app.options.duration * Math.abs(diff) / 180).onUpdate(function(event) {
6637                    update(this, event);
6638                }).easing(TWEEN.Easing.Sinusoidal.Out).onStop(function() {
6639                    sheet.currentTween = null;
6640                    sheet.isFlipping = false;
6641                    if (sheet.isCover) {
6642                        sheet.viewer.leftCover.isFlipping = false;
6643                        sheet.viewer.rightCover.isFlipping = false;
6644                    }
6645                    sheet.element.material[5].opacity = sheet.element.material[4].opacity = 1;
6646                }).onComplete(function() {
6647                    sheet.updateAngle();
6648                    sheet.element.material[5].opacity = sheet.element.material[4].opacity = 1;
6649                    sheet.element.castShadow = true;
6650                    sheet.isFlipping = false;
6651                    if (sheet.isCover) {
6652                        sheet.viewer.leftCover.isFlipping = false;
6653                        sheet.viewer.rightCover.isFlipping = false;
6654                    }
6655                    sheet.side = sheet.targetSide;
6656                    sheet.viewer.onFlip();
6657                    sheet.viewer.afterFlip();
6658                    sheet.currentTween = null;
6659                    if (sheet.viewer && sheet.viewer.requestRefresh) sheet.viewer.requestRefresh();
6660                }).start();
6661                //calling instantly will fix the render and postioning update issue
6662                //https://github.com/deepak-ghimire/dearviewer/issues/494
6663                sheet.currentTween.update(window.performance.now());
6664            }
6665        }
6666    ]);
6667    return BookSheet3D;
6668}(BookSheet);
6669var FlipBook3D = /*#__PURE__*/ function(BaseFlipBookViewer) {
6670    "use strict";
6671    flipbook_3d_inherits(FlipBook3D, BaseFlipBookViewer);
6672    var _super = flipbook_3d_create_super(FlipBook3D);
6673    function FlipBook3D(options, appContext) {
6674        flipbook_3d_class_call_check(this, FlipBook3D);
6675        var _this;
6676        options.viewerClass = "df-flipbook-3d";
6677        _this = _super.call(this, options, appContext);
6678        _this.pageOffset = 5; //space between pages in spiral book
6679        _this.spiralCount = 20;
6680        var _options_groundDistance;
6681        _this.groundDistance = (_options_groundDistance = options.groundDistance) !== null && _options_groundDistance !== void 0 ? _options_groundDistance : 2; //relative sizing distance of ground from book when cover is closed.
6682        _this.hasSpiral = options.hasSpiral === "true" || options.hasSpiral === true;
6683        var _options_flexibility;
6684        _this.flexibility = flipbook_3d_utils.limitAt((_options_flexibility = options.flexibility) !== null && _options_flexibility !== void 0 ? _options_flexibility : 0.9, 0, 10);
6685        if (_this.hasSpiral) {
6686            _this.flexibility = 0;
6687        }
6688        if (_this.flexibility === 0) options.sheetSegments = 8;
6689        _this.drag3D = flipbook_3d_utils.isTrue(options.drag3D);
6690        var _options_texturePowerOfTwo;
6691        //if it's mobile do not use power of two to save, overhead and device resources
6692        _this.texturePowerOfTwo = flipbook_3d_utils.isMobile ? false : (_options_texturePowerOfTwo = options.texturePowerOfTwo) !== null && _options_texturePowerOfTwo !== void 0 ? _options_texturePowerOfTwo : true;
6693        var _this_app_options_color3DSheets;
6694        _this.color3DSheets = (_this_app_options_color3DSheets = _this.app.options.color3DSheets) !== null && _this_app_options_color3DSheets !== void 0 ? _this_app_options_color3DSheets : 'white';
6695        _this.midPosition = 0;
6696        _this.initMOCKUP(function() {
6697            appContext._viewerPrepared();
6698        });
6699        return _this;
6700    }
6701    flipbook_3d_create_class(FlipBook3D, [
6702        {
6703            key: "initMOCKUP",
6704            value: function initMOCKUP(callback) {
6705                var app = this.app;
6706                if (typeof THREE === "undefined") {
6707                    app.updateInfo(app.options.text.loading + " WEBGL 3D ...");
6708                    if (typeof window.define === 'function' && window.define.amd && window.requirejs) {
6709                        window.requirejs.config({
6710                            "paths": {
6711                                "three": app.options.threejsSrc.replace(".js", "")
6712                            },
6713                            shim: {
6714                                'three': {
6715                                    exports: 'THREE'
6716                                }
6717                            }
6718                        });
6719                        window.require([
6720                            'three'
6721                        ], function(THREE1) {
6722                            window.THREE = THREE1;
6723                            MOCKUP.init();
6724                            if (typeof callback === "function") callback();
6725                            return THREE1;
6726                        });
6727                    } else if (typeof window.define === 'function' && window.define.amd) {
6728                        window.require([
6729                            "three",
6730                            app.options.threejsSrc.replace(".js", "")
6731                        ], function(ready) {
6732                            ready(function() {
6733                                MOCKUP.init();
6734                                if (typeof callback === "function") callback();
6735                            });
6736                        });
6737                    } else {
6738                        flipbook_3d_utils.getScript(app.options.threejsSrc + "?ver=" + flipbook_3d_DV.version, function() {
6739                            MOCKUP.init();
6740                            if (typeof callback === "function") callback();
6741                        }, function() {
6742                            app.updateInfo("Unable to load THREE.js...");
6743                        });
6744                    }
6745                } else {
6746                    MOCKUP.init();
6747                    if (typeof callback === "function") callback();
6748                }
6749            }
6750        },
6751        {
6752            key: "init",
6753            value: function init() {
6754                var app = this.app;
6755                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "init", this).call(this);
6756                var _pageRatio = app.provider.defaultPage.pageRatio;
6757                this.pageScaleX = 1;
6758                this.initDepth();
6759                this.initStage();
6760                this.initPages();
6761                this.initEvents();
6762                this.render(); //until render is called none of the css pages are added.
6763            }
6764        },
6765        {
6766            key: "updatePageMode",
6767            value: function updatePageMode() {
6768                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "updatePageMode", this).call(this);
6769                var app = this.app;
6770                this.has3DCover = app.options.cover3DType !== defaults_DEARVIEWER.FLIPBOOK_COVER_TYPE.NONE && app.pageCount > 7 && !this.isBooklet;
6771                if (this.has3DCover && app.options.flipbookHardPages === "none") {
6772                    app.options.flipbookHardPages = "cover";
6773                }
6774            }
6775        },
6776        {
6777            key: "initDepth",
6778            value: function initDepth() {
6779                var _this_app_options_sheetDepth;
6780                this.sheetDepth = this.pageScaleX * ((_this_app_options_sheetDepth = this.app.options.sheetDepth) !== null && _this_app_options_sheetDepth !== void 0 ? _this_app_options_sheetDepth : 0.5);
6781                var _this_app_options_sheetSegments;
6782                this.sheetSegments = (_this_app_options_sheetSegments = this.app.options.sheetSegments) !== null && _this_app_options_sheetSegments !== void 0 ? _this_app_options_sheetSegments : 20;
6783                this.coverDepth = 2 * this.sheetDepth;
6784                this.sheetsDepth = Math.min(10, this.app.pageCount / 4) * this.sheetDepth;
6785            }
6786        },
6787        {
6788            key: "initStage",
6789            value: function initStage() {
6790                var viewer = this;
6791                var stage = viewer.stage = new MOCKUP.Stage({
6792                    pixelRatio: viewer.app.options.pixelRatio
6793                });
6794                var canvas = stage.canvas = jQuery(stage.renderer.domElement).addClass("df-3dcanvas");
6795                canvas.appendTo(this.element);
6796                stage.camera.position.set(0, 0, 600);
6797                stage.camera.lookAt(new THREE.Vector3(0, 0, 0));
6798                viewer.camera = stage.camera;
6799                //shadows are zigzag due to shadow camera position
6800                stage.spotLight.position.set(-220, 220, 550);
6801                stage.spotLight.castShadow = flipbook_3d_utils.isMobile ? false : viewer.app.options.has3DShadow;
6802                if (stage.spotLight.shadow) {
6803                    stage.spotLight.shadow.bias = -0.005; //-0.0035 has artifacts in smaller size;
6804                }
6805                // stage.spotLight.intensity = 0.22;
6806                stage.ambientLight.color = new THREE.Color("#fff");
6807                stage.ambientLight.intensity = 0.82;
6808                var material = new THREE.ShadowMaterial();
6809                material.opacity = viewer.app.options.shadowOpacity;
6810                stage.ground.oldMaterial = stage.ground.material;
6811                stage.ground.material = material;
6812                stage.ground.position.z = this.has3DCover ? -6 : -4;
6813                stage.selectiveRendering = true;
6814                var cssRenderer = stage.cssRenderer = new THREE.CSS3DRenderer();
6815                jQuery(cssRenderer.domElement).css({
6816                    position: "absolute",
6817                    top: 0,
6818                    pointerEvents: "none"
6819                }).addClass("df-3dcanvas df-csscanvas");
6820                viewer.element[0].appendChild(cssRenderer.domElement);
6821                stage.cssScene = new THREE.Scene();
6822                viewer.wrapper.remove();
6823                viewer.wrapper = new THREE.Group();
6824                viewer.stage.add(viewer.wrapper);
6825                viewer.wrapper.add(stage.ground);
6826                viewer.bookWrapper = new THREE.Group();
6827                viewer.bookWrapper.name = "bookwrapper";
6828                // stage.bookWrapper.add(stage.camera);
6829                viewer.wrapper.add(viewer.bookWrapper);
6830                viewer.bookHelper = stage.bookHelper = new THREE.BoxHelper(viewer.bookWrapper, 0xffff00);
6831                stage.add(viewer.bookHelper);
6832                viewer.bookHelper.visible = false;
6833                viewer.cameraWrapper = new THREE.Group();
6834                viewer.cameraWrapper.add(stage.camera);
6835                stage.add(viewer.cameraWrapper);
6836                // viewer.wrapper.add(stage.spotLight);
6837                viewer.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON;
6838            }
6839        },
6840        {
6841            key: "initPages",
6842            value: function initPages() {
6843                var options = {
6844                    parent3D: this.bookWrapper,
6845                    viewer: this,
6846                    segments: this.sheetSegments,
6847                    depth: this.sheetDepth,
6848                    flexibility: this.flexibility
6849                };
6850                for(var count = 0; count < this.stackCount; count++){
6851                    var sheet = new BookSheet3D(options);
6852                    sheet.index = count; //just reference for debugging
6853                    sheet.viewer = this;
6854                    this.sheets.push(sheet);
6855                    sheet.setMatColor(this.color3DSheets);
6856                    this.pages.push(sheet.frontPage);
6857                    this.pages.push(sheet.backPage);
6858                    this.stage.cssScene.add(sheet.frontPage.cssPage);
6859                    this.stage.cssScene.add(sheet.backPage.cssPage);
6860                }
6861                options.depth = this.sheetsDepth;
6862                options.segments = 1;
6863                options.flexibility = 0;
6864                this.leftSheets = new BookSheet3D(options); //to display sheet stack on left side of Realistic book
6865                this.rightSheets = new BookSheet3D(options); //to display sheet stack on right side of Realistic book
6866                this.leftSheets.setMatColor(this.color3DSheets);
6867                this.rightSheets.setMatColor(this.color3DSheets);
6868                options.depth = this.coverDepth;
6869                this.leftCover = new BookSheet3D(options);
6870                this.rightCover = new BookSheet3D(options);
6871                // this.leftCover.element.loadNormalMap(this.app.options.imagesLocation + "/book-cover-normal.jpg", MOCKUP.MATERIAL_FACE.FRONT);
6872                // this.rightCover.element.loadNormalMap(this.app.options.imagesLocation + "/book-cover-normal.jpg", MOCKUP.MATERIAL_FACE.BACK);
6873                this.leftCover.isHard = true;
6874                this.rightCover.isHard = true;
6875                this.set3DCoverNormal();
6876                this.setcolor3DCover(this.app.options.color3DCover);
6877                this.stage.cssScene.add(this.leftCover.frontPage.cssPage);
6878                this.stage.cssScene.add(this.rightCover.backPage.cssPage);
6879                this.zoomViewer.leftPage.element.css({
6880                    backgroundColor: this.color3DSheets
6881                });
6882                this.zoomViewer.rightPage.element.css({
6883                    backgroundColor: this.color3DSheets
6884                });
6885                if (this.orientation === 'vertical') {
6886                    this.bookWrapper.children.forEach(function(childPaper) {
6887                        childPaper.rotateZ(THREE.MathUtils.degToRad(-90));
6888                        childPaper.textureCenter = new THREE.Vector2(0.5, 0.5);
6889                        childPaper.textureRotation = 90;
6890                    });
6891                }
6892                this.initSpiral();
6893            }
6894        },
6895        {
6896            key: "initSpiral",
6897            value: function initSpiral() {
6898                this.hasSpiral = false;
6899            }
6900        },
6901        {
6902            key: "set3DCoverNormal",
6903            value: function set3DCoverNormal() {}
6904        },
6905        {
6906            key: "setcolor3DCover",
6907            value: function setcolor3DCover() {
6908                var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
6909            }
6910        },
6911        {
6912            key: "initEvents",
6913            value: function initEvents() {
6914                this.stageDOM = this.element[0];
6915                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "initEvents", this).call(this);
6916            }
6917        },
6918        {
6919            key: "dispose",
6920            value: function dispose() {
6921                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "dispose", this).call(this);
6922                var viewer = this;
6923                if (viewer.stage) {
6924                    viewer.stage.clearChild();
6925                    viewer.stage.cssRenderer.domElement.parentNode.removeChild(viewer.stage.cssRenderer.domElement);
6926                    viewer.stage.cssRenderer = null;
6927                    viewer.stage.orbitControl = flipbook_3d_utils.disposeObject(viewer.stage.orbitControl);
6928                    viewer.stage.renderer = flipbook_3d_utils.disposeObject(viewer.stage.renderer);
6929                    jQuery(viewer.stage.canvas).remove();
6930                    viewer.stage.canvas = null;
6931                    viewer.stage = flipbook_3d_utils.disposeObject(viewer.stage);
6932                }
6933                if (viewer.centerTween && viewer.centerTween.stop) viewer.centerTween.stop();
6934            }
6935        },
6936        {
6937            key: "render",
6938            value: function render() {
6939                this.stage.render();
6940                this.stage.cssRenderer.render(this.stage.cssScene, this.stage.camera);
6941            }
6942        },
6943        {
6944            key: "resize",
6945            value: function resize() {
6946                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "resize", this).call(this);
6947                var viewer = this;
6948                var app = viewer.app, stage = viewer.stage;
6949                var dimensions = app.dimensions;
6950                var padding = dimensions.padding;
6951                var isSingle = viewer.isSingle;
6952                var zoomWidth = this.availablePageWidth(), zoomHeight = this.availablePageHeight();
6953                stage.resizeCanvas(dimensions.stage.width, dimensions.stage.height);
6954                stage.cssRenderer.setSize(dimensions.stage.width, dimensions.stage.height);
6955                this.pageScaleX = Math.max(Math.max(zoomWidth, zoomHeight) / 400, 1);
6956                this.initDepth();
6957                this.sheets.forEach(function(sheet) {
6958                    sheet.depth = viewer.sheetDepth;
6959                });
6960                app.refreshRequestStart();
6961                var ref = this.refSize = Math.min(zoomHeight, zoomWidth);
6962                this.coverExtraWidth = (viewer.orientation == 'vertical' ? 2 : 1) * ref * .025;
6963                this.coverExtraHeight = (viewer.orientation == 'vertical' ? 1 : 2) * ref * .025;
6964                if (this.has3DCover !== true) {
6965                    this.coverExtraWidth = 0;
6966                    this.coverExtraHeight = 0;
6967                }
6968                //viewer.app.renderRequestStatus = DV.REQUEST_STATUS.ON;
6969                viewer.zoomViewer.resize();
6970                viewer.cameraPositionDirty = true;
6971                viewer.centerNeedsUpdate = true;
6972                viewer.checkCenter(true);
6973                viewer.pagesReady();
6974                this.pageOffset = (this.hasSpiral ? 6 : 0) * Math.min(this._defaultPageSize.width, this._defaultPageSize.height) / 1000;
6975            }
6976        },
6977        {
6978            key: "fitCameraToCenteredObject",
6979            value: function fitCameraToCenteredObject(camera, object, offset, orbitControls) {
6980                var boundingBox = new THREE.Box3();
6981                boundingBox.setFromObject(object);
6982                var middle = new THREE.Vector3();
6983                var size = new THREE.Vector3();
6984                boundingBox.getSize(size);
6985                var coverExtraHeight = this.coverExtraHeight;
6986                var coverExtraWidth = this.coverExtraWidth * 2;
6987                if (this.isClosedPage()) {
6988                    coverExtraWidth = 0;
6989                    coverExtraHeight = 0;
6990                }
6991                size.x = size.x - coverExtraWidth + this.app.dimensions.padding.width;
6992                size.y = size.y - coverExtraHeight + this.app.dimensions.padding.height;
6993                // figure out how to fit the box in the view:
6994                // 1. figure out horizontal FOV (on non-1.0 aspects)
6995                // 2. figure out distance from the object in X and Y planes
6996                // 3. select the max distance (to fit both sides in)
6997                //
6998                // The reason is as follows:
6999                //
7000                // Imagine a bounding box (BB) is centered at (0,0,0).
7001                // Camera has vertical FOV (camera.fov) and horizontal FOV
7002                // (camera.fov scaled by aspect, see fovh below)
7003                //
7004                // Therefore if you want to put the entire object into the field of view,
7005                // you have to compute the distance as: z/2 (half of Z size of the BB
7006                // protruding towards us) plus for both X and Y size of BB you have to
7007                // figure out the distance created by the appropriate FOV.
7008                //
7009                // The FOV is always a triangle:
7010                //
7011                //  (size/2)
7012                // +--------+
7013                // |       /
7014                // |      /
7015                // |     /
7016                // | F° /
7017                // |   /
7018                // |  /
7019                // | /
7020                // |/
7021                //
7022                // F° is half of respective FOV, so to compute the distance (the length
7023                // of the straight line) one has to: `size/2 / Math.tan(F)`.
7024                //
7025                // FTR, from https://threejs.org/docs/#api/en/cameras/PerspectiveCamera
7026                // the camera.fov is the vertical FOV.
7027                var fov = camera.fov * (Math.PI / 180);
7028                var fovh = 2 * Math.atan(Math.tan(fov / 2) * camera.aspect);
7029                var dx = size.z / 2 + Math.abs(size.x / 2 / Math.tan(fovh / 2));
7030                var dy = size.z / 2 + Math.abs(size.y / 2 / Math.tan(fov / 2));
7031                var cameraZ = Math.max(dx, dy);
7032                // offset the camera, if desired (to avoid filling the whole canvas)
7033                if (offset !== undefined && offset !== 0) cameraZ *= offset;
7034                camera.position.set(0, 0, cameraZ);
7035                // set the far plane of the camera so that it easily encompasses the whole object
7036                var minZ = boundingBox.min.z;
7037                var cameraToFarEdge = minZ < 0 ? -minZ + cameraZ : cameraZ - minZ;
7038                camera.far = cameraToFarEdge * 3;
7039                camera.updateProjectionMatrix();
7040                if (orbitControls !== undefined) {
7041                    // set camera to rotate around the center
7042                    orbitControls.target = new THREE.Vector3(0, 0, 0);
7043                    // prevent camera from zooming out far enough to create far plane cutoff
7044                    orbitControls.maxDistance = cameraToFarEdge * 2;
7045                }
7046            }
7047        },
7048        {
7049            key: "updateShadowSize",
7050            value: function updateShadowSize() {
7051                return;
7052                var shadowSize = this.pageScaleX > 2.5 ? 1024 : 512;
7053                var shadow = this.stage.spotLight.shadow;
7054                if (this.stage.spotLight.castShadow === true && shadow.mapSize.height != shadowSize) {
7055                    shadow.radius = shadowSize / 256;
7056                    shadow.mapSize.width = shadowSize;
7057                    shadow.mapSize.height = shadowSize;
7058                    shadow.needsUpdate = true;
7059                }
7060            }
7061        },
7062        {
7063            key: "refresh",
7064            value: function refresh() {
7065                var viewer = this, app = this.app, basePage = viewer.getBasePage();
7066                this.refreshRequested = true; //flag to check if refresh has beem requested
7067                var ratioStep = 1 / app.pageCount, ratio = ratioStep * basePage;
7068                var leftWeight = this.isRTL ? 1 - ratio : ratio, rightWeight = 1 - leftWeight;
7069                var minSheetStack = Math.min(viewer.stackCount, viewer.totalSheets);
7070                var maxSheetStack = flipbook_3d_utils.limitAt(viewer.totalSheets, viewer.stackCount, viewer.stackCount * 2);
7071                var midWeight = Math.max(leftWeight, rightWeight);
7072                var flexibilityFactor = this.isBooklet ? 0 : this.flexibility / maxSheetStack;
7073                viewer.leftFlexibility = flexibilityFactor * rightWeight;
7074                viewer.rightFlexibility = flexibilityFactor * leftWeight;
7075                viewer.midPosition = 0.5 * minSheetStack * viewer.sheetDepth;
7076                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "refresh", this).call(this);
7077                var displayCover = this.has3DCover === true;
7078                this.leftCover.element.visible = this.rightCover.element.visible = this.leftSheets.element.visible = this.rightSheets.element.visible = displayCover;
7079                this.wrapper.position.z = -this.midPosition;
7080                var depthLeft = 0, depthRight = 0, isRTL = viewer.isRTL;
7081                var isFrontPage = this.isFirstPage(), isLastPage = this.isLastPage();
7082                var isLeftClosed = this.isLeftClosed = this.isClosedPage() && (isRTL && isLastPage || !isRTL && isFrontPage), isRightClosed = this.isRightClosed = this.isClosedPage() && (!isRTL && isLastPage || isRTL && isFrontPage);
7083                if (displayCover) {
7084                    viewer.leftSheets.depth = isRTL ? viewer.sheetsDepth * (1 - viewer.getBasePage() / app.pageCount) : viewer.sheetsDepth * basePage / app.pageCount;
7085                    viewer.leftSheets.element.visible = isRTL ? app.pageCount - viewer.getBasePage() > 2 : basePage > 2;
7086                    depthLeft -= viewer.leftSheets.depth / 2;
7087                    viewer.leftSheets.element.position.z = depthLeft;
7088                    depthLeft -= viewer.coverDepth + (viewer.leftSheets.element.visible ? viewer.leftSheets.depth / 2 : 0) + viewer.coverDepth * 3;
7089                    viewer.leftCover.depth = viewer.rightCover.depth = viewer.coverDepth;
7090                    var maxSheetHeight = Math.max(this.leftSheetHeight, this.rightSheetHeight);
7091                    if (isRightClosed) maxSheetHeight = this.leftSheetHeight;
7092                    if (isLeftClosed) maxSheetHeight = this.rightSheetHeight;
7093                    if (viewer.leftCover.isFlipping !== true) {
7094                        viewer.leftCover.element.position.z = isLeftClosed ? viewer.midPosition + viewer.coverDepth : depthLeft + viewer.coverDepth / 2;
7095                        viewer.leftCover.element.position.z = Math.max(viewer.leftCover.element.position.z, -viewer.refSize * 0.05);
7096                        viewer.leftCover.element.position.x = 0;
7097                        viewer.leftSheets.sheetAngle = viewer.leftCover.sheetAngle = isLeftClosed ? 180 : 0;
7098                        viewer.leftSheets.curveAngle = viewer.leftCover.curveAngle = isLeftClosed ? 180 : 0;
7099                        if (viewer.rightCover.isFlipping !== true) {
7100                            viewer.leftCover.height = maxSheetHeight;
7101                            viewer.leftCover.width = viewer.leftCover.sheetAngle < 90 ? this.leftSheetWidth : this.rightSheetWidth;
7102                            if (!this.isClosedPage()) {
7103                                viewer.leftCover.width += this.coverExtraWidth;
7104                                viewer.leftCover.height += this.coverExtraHeight;
7105                            }
7106                        }
7107                        viewer.leftSheets.updateAngle();
7108                        viewer.leftCover.updateAngle();
7109                    }
7110                    viewer.rightSheets.depth = viewer.sheetsDepth - viewer.leftSheets.depth;
7111                    viewer.rightSheets.element.visible = isRTL ? basePage > 2 : app.pageCount - viewer.getBasePage() > 2;
7112                    depthRight -= viewer.rightSheets.depth / 2;
7113                    viewer.rightSheets.element.position.z = depthRight;
7114                    depthRight -= viewer.coverDepth + (viewer.rightSheets.element.visible ? viewer.rightSheets.depth / 2 : 0) + viewer.coverDepth * 3;
7115                    if (viewer.rightCover.isFlipping !== true) {
7116                        viewer.rightCover.element.position.z = isRightClosed ? viewer.midPosition + viewer.coverDepth : depthRight + viewer.coverDepth / 2;
7117                        viewer.rightCover.element.position.z = Math.max(viewer.rightCover.element.position.z, -viewer.refSize * 0.05);
7118                        viewer.rightCover.element.position.x = 0;
7119                        viewer.rightSheets.sheetAngle = viewer.rightCover.sheetAngle = isRightClosed ? 0 : 180;
7120                        viewer.rightSheets.curveAngle = viewer.rightCover.curveAngle = isRightClosed ? 0 : 180;
7121                        if (viewer.leftCover.isFlipping !== true) {
7122                            viewer.rightCover.height = maxSheetHeight;
7123                            viewer.rightCover.width = viewer.rightCover.sheetAngle < 90 ? this.leftSheetWidth : this.rightSheetWidth;
7124                            if (!this.isClosedPage()) {
7125                                viewer.rightCover.width += this.coverExtraWidth;
7126                                viewer.rightCover.height += this.coverExtraHeight;
7127                            }
7128                        }
7129                        viewer.rightSheets.updateAngle();
7130                        viewer.rightCover.updateAngle();
7131                    }
7132                    viewer.updateSheets();
7133                    viewer.stage.ground.position.z = Math.min(depthLeft, depthRight) - viewer.refSize * viewer.groundDistance / 100;
7134                    // if (this.isClosedPage()) {
7135                    //   viewer.stage.ground.position.z -= viewer.coverDepth * 2;
7136                    // }
7137                    viewer.stage.ground.position.z = Math.max(viewer.stage.ground.position.z, -viewer.refSize * 0.1);
7138                } else {
7139                    viewer.stage.ground.position.z = -viewer.midPosition - viewer.sheetDepth * 15;
7140                }
7141                if (viewer.cameraPositionDirty === true) {
7142                    viewer.updateCameraPosition();
7143                }
7144                this.refreshSpiral();
7145            }
7146        },
7147        {
7148            key: "refreshSpiral",
7149            value: function refreshSpiral() {}
7150        },
7151        {
7152            key: "updateCameraPosition",
7153            value: function updateCameraPosition() {
7154                var viewer = this;
7155                var app = viewer.app, stage = viewer.stage;
7156                var dimensions = app.dimensions;
7157                var padding = dimensions.padding;
7158                var cameraZ = 1 / (2 * Math.tan(Math.PI * stage.camera.fov * 0.5 / 180) / (dimensions.stage.height / app.zoomValue)) + 2.2;
7159                this.updateShadowSize();
7160                this.stage.spotLight.position.x = -this.pageScaleX * 440;
7161                this.stage.spotLight.position.y = this.pageScaleX * 440;
7162                this.stage.spotLight.position.z = this.pageScaleX * 660;
7163                this.stage.spotLight.shadow.camera.far = this.pageScaleX * 1200;
7164                this.stage.spotLight.shadow.camera.updateProjectionMatrix();
7165                var shiftY = (padding.top - padding.bottom) / app.zoomValue / 2, shiftX = -(padding.left - padding.right) / app.zoomValue / 2;
7166                if (stage.camera.position.z !== cameraZ && app.pendingZoom === true) {
7167                    stage.camera.position.z = cameraZ;
7168                }
7169                if (app.zoomValue === 1) {
7170                    viewer.bookWrapper.rotation.set(0, 0, 0);
7171                    viewer.bookHelper.rotation.set(0, 0, 0);
7172                    viewer.cameraWrapper.rotation.set(0, 0, 0);
7173                    if (app.options.flipbook3DTiltAngleUp !== 0 || app.options.flipbook3DTiltAngleLeft !== 0) {
7174                        stage.camera.aspect = dimensions.stage.width / dimensions.stage.height;
7175                        stage.camera.updateProjectionMatrix();
7176                        //upward rotation is on X axis and is done after left Rotation , Z axis.
7177                        //Since book need to rotate upwward, rotate X later works
7178                        viewer.bookWrapper.rotateZ(THREE.Math.degToRad(-app.options.flipbook3DTiltAngleLeft)); //negative goes left
7179                        viewer.bookWrapper.rotateX(THREE.Math.degToRad(-app.options.flipbook3DTiltAngleUp)); //negative goes upward
7180                        if (viewer.orientation == 'vertical') {
7181                            viewer.bookWrapper.scale.y = 1 / (this.isSingle ? 2 : 1);
7182                        } else {
7183                            viewer.bookWrapper.scale.x = 1 / (this.isSingle ? 2 : 1);
7184                        }
7185                        viewer.bookHelper.update();
7186                        viewer.fitCameraToCenteredObject(stage.camera, viewer.bookWrapper);
7187                        viewer.bookWrapper.rotation.set(0, 0, 0);
7188                        viewer.bookWrapper.scale.x = 1;
7189                        viewer.bookWrapper.scale.y = 1;
7190                        //upward rotation is on X axis and is done after left Rotation , Z axis.
7191                        //Since book need to rotate upwward, rotate X later works
7192                        // viewer.bookHelper.rotateZ(THREE.Math.degToRad(app.options.flipbook3DTiltAngleLeft)); //negative goes left
7193                        // viewer.bookHelper.rotateX(THREE.Math.degToRad(-app.options.flipbook3DTiltAngleUp)); //negative goes upward
7194                        stage.camera.position.set(shiftX, shiftY, stage.camera.position.z + stage.ground.position.z);
7195                        this.camera.aspect = dimensions.stage.width / dimensions.stage.height;
7196                        this.camera.updateProjectionMatrix();
7197                        //upward rotation is on X axis and is done after left Rotation , Z axis.
7198                        //Since book need to rotate upwward, rotate X later works
7199                        viewer.cameraWrapper.rotateX(THREE.Math.degToRad(app.options.flipbook3DTiltAngleUp)); //negative goes upward
7200                        viewer.cameraWrapper.rotateZ(THREE.Math.degToRad(app.options.flipbook3DTiltAngleLeft)); //positive goes left
7201                    } else {
7202                        stage.camera.position.set(shiftX, shiftY, cameraZ);
7203                    }
7204                }
7205                stage.camera.updateProjectionMatrix();
7206                viewer.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON;
7207                viewer.cameraPositionDirty = false;
7208            }
7209        },
7210        {
7211            key: "refreshSheet",
7212            value: function refreshSheet(options) {
7213                var viewer = this, _sheet = options.sheet, _sheetStackIndex = options.index;
7214                // region Determine Next Position, angle and Flexibility based on pageLocation
7215                var oldAngle = _sheet.sheetAngle, newAngle, isFlexible = !(_sheet.isHard || this.flexibility === 0);
7216                _sheet.leftFlexibility = !isFlexible ? 0 : viewer.leftFlexibility;
7217                _sheet.rightFlexibility = !isFlexible ? 0 : viewer.rightFlexibility;
7218                _sheet.leftPos = viewer.midPosition + (_sheetStackIndex - options.midPoint + 1) * viewer.sheetDepth - viewer.sheetDepth / 2;
7219                _sheet.rightPos = viewer.midPosition - (_sheetStackIndex - options.midPoint) * viewer.sheetDepth - viewer.sheetDepth / 2;
7220                newAngle = _sheet.targetSide === defaults_DEARVIEWER.TURN_DIRECTION.LEFT ? 0 : 180;
7221                //endregion
7222                if (_sheet.isFlipping === false) {
7223                    if (options.needsFlip) {
7224                        _sheet.isFlipping = true;
7225                        if (_sheet.isCover && options.sheetNumber === 0) if (viewer.isRTL) viewer.rightCover.isFlipping = true;
7226                        else viewer.leftCover.isFlipping = true;
7227                        if (_sheet.isCover && viewer.totalSheets - options.sheetNumber === 1) if (viewer.isRTL) viewer.leftCover.isFlipping = true;
7228                        else viewer.rightCover.isFlipping = true;
7229                        _sheet.element.position.z = Math.max(oldAngle < 90 ? _sheet.leftPos : _sheet.rightPos, viewer.midPosition) + viewer.sheetDepth;
7230                        //this.beforeFlip();
7231                        _sheet.flexibility = oldAngle < 90 ? _sheet.leftFlexibility : _sheet.rightFlexibility;
7232                        _sheet.flip(oldAngle, newAngle);
7233                    } else {
7234                        _sheet.skipFlip = false;
7235                        _sheet.sheetAngle = _sheet.curveAngle = newAngle;
7236                        _sheet.flexibility = newAngle < 90 ? _sheet.leftFlexibility : _sheet.rightFlexibility;
7237                        _sheet.element.position.z = newAngle < 90 ? _sheet.leftPos : _sheet.rightPos;
7238                        _sheet.side = _sheet.targetSide;
7239                        //sheets from left side coming to right should follow the right side dimension and vice versa
7240                        _sheet.height = newAngle < 90 ? this.leftSheetHeight : this.rightSheetHeight;
7241                        _sheet.width = newAngle < 90 ? this.leftSheetWidth : this.rightSheetWidth;
7242                    }
7243                    _sheet.updateAngle();
7244                    this.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON;
7245                } else {
7246                // _sheet.element.position.z = oldAngle < 90 ? _sheet.leftPos : _sheet.rightPos;
7247                }
7248                //determine visibility
7249                _sheet.element.visible = options.visible;
7250            }
7251        },
7252        {
7253            key: "updateCenter",
7254            value: function updateCenter() {
7255                var viewer = this, app = this.app;
7256                var init = this.orientation == 'vertical' ? viewer.wrapper.position.y : viewer.wrapper.position.x, centerShift = (this.orientation === 'vertical' ? -1 : 1) * viewer.centerShift, length = this.isLeftPage() ? this.orientation == 'vertical' ? this.leftSheetHeight : this.leftSheetWidth : this.orientation == 'vertical' ? this.rightSheetHeight : this.rightSheetWidth;
7257                var end = centerShift * length / 2;
7258                viewer.seamPosition = (-app.dimensions.offset.width + app.dimensions.containerWidth) / 2 + end;
7259                //create a centerTween
7260                if (end !== viewer.centerEnd) {
7261                    if (viewer.centerTween && viewer.centerTween.stop) viewer.centerTween.stop();
7262                    viewer.onCenterStartAnimation(this); //solves issue 301 - called early so that waiting doesn't cause flicker
7263                    viewer.centerTween = new TWEEN.Tween({
7264                        x: init
7265                    }).delay(0).to({
7266                        x: end
7267                    }, app.zoomValue === 1 && viewer.skipCenterAnimation !== true ? viewer.app.options.duration : 1).onStart(function() {
7268                    /*viewer.onCenterStartAnimation(this); //is delayed for some reason - maybe waiting for request frame and causes flicker - issue 301*/ }
7268).onUpdate(function() {
7269                        viewer.onCenterUpdateAnimation(this);
7270                    }).onComplete(function() {
7271                        viewer.onCenterCompleteAnimation(this);
7272                    }).onStop(function() {
7273                        viewer.onCenterStopAnimation(this);
7274                    }).easing(TWEEN.Easing.Cubic.InOut).start();
7275                    this.updatePendingStatusClass();
7276                    viewer.skipCenterAnimation = false;
7277                    viewer.centerEnd = end;
7278                }
7279                viewer.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON;
7280                this.zoomViewer.updateCenter();
7281            }
7282        },
7283        {
7284            key: "onCenterUpdateAnimation",
7285            value: function onCenterUpdateAnimation(tween) {
7286                if (this.orientation == 'vertical') {
7287                    this.wrapper.position.y = tween.x;
7288                    //noinspection JSUnresolvedVariable
7289                    if (this.stage && this.stage.cssScene) this.stage.cssScene.position.y = tween.x;
7290                } else {
7291                    this.wrapper.position.x = tween.x;
7292                    //noinspection JSUnresolvedVariable
7293                    if (this.stage && this.stage.cssScene) this.stage.cssScene.position.x = tween.x;
7294                }
7295            }
7296        },
7297        {
7298            key: "onCenterStartAnimation",
7299            value: function onCenterStartAnimation(tween) {}
7300        },
7301        {
7302            key: "onCenterStopAnimation",
7303            value: function onCenterStopAnimation(tween) {}
7304        },
7305        {
7306            key: "onCenterCompleteAnimation",
7307            value: function onCenterCompleteAnimation(tween) {}
7308        },
7309        {
7310            key: "flipCover",
7311            value: function flipCover(sheet) {
7312                var viewer = this, cover = null, multiplier, diff;
7313                if (sheet.pageNumber === 0 || this.isBooklet && sheet.pageNumber === 1) {
7314                    cover = this.isRTL ? this.rightCover : this.leftCover;
7315                    multiplier = this.isRTL ? 1 : -1;
7316                } else if (sheet.pageNumber === this.totalSheets - 1) {
7317                    cover = this.isRTL ? this.leftCover : this.rightCover;
7318                    multiplier = this.isRTL ? -1 : 1;
7319                }
7320                if (cover === null) return;
7321                diff = cover.depth + sheet.depth + 1;
7322                cover.sheetAngle = sheet.sheetAngle;
7323                cover.curveAngle = sheet.curveAngle;
7324                this.rightCover.height = this.leftCover.height = sheet.height + this.coverExtraHeight;
7325                this.rightCover.width = this.leftCover.width = sheet.width + this.coverExtraWidth;
7326                cover.flexibility = sheet.flexibility;
7327                this.rightCover.updateAngle();
7328                this.leftCover.updateAngle();
7329                cover.element.position.x = sheet.element.position.x + multiplier * Math.sin(sheet.sheetAngle * Math.PI / 180) * diff;
7330                cover.element.position.z = sheet.element.position.z + multiplier * Math.cos(sheet.sheetAngle * Math.PI / 180) * diff;
7331            }
7332        },
7333        {
7334            key: "pagesReady",
7335            value: function pagesReady() {
7336                if (this.isAnimating()) return;
7337                if (this.refreshRequested !== true) return;
7338                if (this.app.options.flipbookFitPages === false) {
7339                    var basePage = this.app.viewer.getBasePage();
7340                    var leftViewPort = this.leftViewport = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 1 : 0)), rightViewPort = this.rightViewPort = this.getViewPort(basePage + (this.isBooklet ? 0 : this.isRTL ? 0 : 1));
7341                    if (leftViewPort) {
7342                        var leftDimen = flipbook_3d_utils.contain(leftViewPort.width, leftViewPort.height, this.availablePageWidth(), this.availablePageHeight());
7343                        if (this.leftSheetWidth != Math.floor(leftDimen.width) || this.leftSheetHeight != Math.floor(leftDimen.height)) {
7344                            this.cameraPositionDirty = true;
7345                        }
7346                        this.leftSheetWidth = Math.floor(leftDimen.width);
7347                        this.leftSheetHeight = Math.floor(leftDimen.height);
7348                    }
7349                    if (rightViewPort) {
7350                        var rightDimen = flipbook_3d_utils.contain(rightViewPort.width, rightViewPort.height, this.availablePageWidth(), this.availablePageHeight());
7351                        if (this.rightSheetWidth != Math.floor(rightDimen.width) || this.rightSheetWidth != Math.floor(rightDimen.height)) {
7352                            this.cameraPositionDirty = true;
7353                        }
7354                        this.rightSheetWidth = Math.floor(rightDimen.width);
7355                        this.rightSheetHeight = Math.floor(rightDimen.height);
7356                    }
7357                    for(var i = 0; i < this.sheets.length; i++){
7358                        var sheet = this.sheets[i];
7359                        if (sheet.side === flipbook_3d_DV.TURN_DIRECTION.LEFT) {
7360                            sheet.height = this.leftSheetHeight;
7361                            sheet.width = this.leftSheetWidth;
7362                            sheet.updateAngle();
7363                        } else {
7364                            sheet.height = this.rightSheetHeight;
7365                            sheet.width = this.rightSheetWidth;
7366                            sheet.updateAngle();
7367                        }
7368                    }
7369                    if (this.isClosedPage()) {
7370                        var isClosedOnRight = this.isRTL && this.isLastPage() || !this.isRTL && this.isFirstPage();
7371                        this.leftCover.width = this.rightCover.width = isClosedOnRight ? this.rightSheetWidth : this.leftSheetWidth;
7372                        this.leftCover.height = this.rightCover.height = isClosedOnRight ? this.rightSheetHeight : this.leftSheetHeight;
7373                    } else {
7374                        this.leftCover.height = this.rightCover.height = this.coverExtraHeight + Math.max(this.leftSheetHeight, this.rightSheetHeight);
7375                        this.leftCover.width = this.coverExtraWidth + this.leftSheetWidth;
7376                        this.rightCover.width = this.coverExtraWidth + this.rightSheetWidth;
7377                    }
7378                    this.leftSheets.width = this.leftSheetWidth;
7379                    this.leftSheets.height = this.leftSheetHeight;
7380                    this.rightSheets.height = this.rightSheetHeight;
7381                    this.rightSheets.width = this.rightSheetWidth;
7382                    this.leftCover.updateAngle();
7383                    this.leftSheets.updateAngle();
7384                    this.rightCover.updateAngle();
7385                    this.rightSheets.updateAngle();
7386                    this.updateSheets(true);
7387                }
7388                this.updateCenter();
7389                this.updateCSSLayer();
7390                this.updatePendingStatusClass();
7391                this.refreshSpiral();
7392                if (this.cameraPositionDirty === true) {
7393                    this.updateCameraPosition();
7394                }
7395            }
7396        },
7397        {
7398            key: "updateSheets",
7399            value: function updateSheets(update) {
7400                if (this.isClosedPage() !== true) {
7401                    var rightPage = this.getPageByNumber(this.getRightPageNumber());
7402                    if (this.rightCover.isFlipping !== true && rightPage && rightPage.sheet.element.geometry.attributes) {
7403                        var pos = this.rightSheets.element.geometry.attributes.position, posX = update ? rightPage.sheet.element.geometry.boundingBox.max.x * rightPage.sheet.element.scale.x : this.rightSheets.lastSlopeX;
7404                        pos.setX(21, posX);
7405                        pos.setX(23, posX);
7406                        pos.setX(4, posX);
7407                        pos.setX(6, posX);
7408                        pos.setX(10, posX);
7409                        pos.setX(14, posX);
7410                        pos.needsUpdate = true;
7411                        this.rightSheets.element.geometry.attributes.uv.needsUpdate = true;
7412                        this.rightSheets.element.geometry.computeVertexNormals();
7413                        if (update) this.rightSheets.lastSlopeX = posX;
7414                    }
7415                    var leftPage = this.getPageByNumber(this.getLeftPageNumber());
7416                    if (this.leftCover.isFlipping !== true && leftPage && leftPage.sheet.element.geometry.attributes) {
7417                        var pos1 = this.leftSheets.element.geometry.attributes.position, posX1 = update ? leftPage.sheet.element.geometry.boundingBox.min.x * leftPage.sheet.element.scale.x : this.leftSheets.lastSlopeX;
7418                        pos1.setX(16, posX1);
7419                        pos1.setX(18, posX1);
7420                        pos1.setX(5, posX1);
7421                        pos1.setX(7, posX1);
7422                        pos1.setX(8, posX1);
7423                        pos1.setX(12, posX1);
7424                        pos1.needsUpdate = true;
7425                        this.leftSheets.element.geometry.attributes.uv.needsUpdate = true;
7426                        this.leftSheets.element.geometry.computeVertexNormals();
7427                        if (update) this.leftSheets.lastSlopeX = posX1;
7428                    }
7429                }
7430            }
7431        },
7432        {
7433            key: "updateCSSLayer",
7434            value: function updateCSSLayer() {}
7435        },
7436        {
7437            key: "mouseMove",
7438            value: function mouseMove(event) {
7439                event = flipbook_3d_utils.fixMouseEvent(event);
7440                this.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON;
7441                if (event.touches != null && event.touches.length === 2) {
7442                    this.pinchMove(event);
7443                    return;
7444                }
7445                var viewer = this;
7446                var point = viewer.eventToPoint(event);
7447                if (viewer.dragSheet !== null && viewer.drag3D !== false) {
7448                    if (Math.abs(point.x - viewer.startPoint.x) > 2) {
7449                        if (viewer.isDragging !== true) {
7450                            viewer.updatePendingStatusClass(true);
7451                            viewer.isDragging = true;
7452                        }
7453                        var width = viewer.dragSheet.width;
7454                        var x = point.x - (this.app.dimensions.origin.x + viewer.centerEnd - width);
7455                        var distance = flipbook_3d_utils.limitAt(1 - x / width, -1, 1);
7456                        var angle = flipbook_3d_utils.toDeg(Math.acos(distance));
7457                        // angle = utils.limitAt(angle, 0, 180);
7458                        var sheet = viewer.dragSheet;
7459                        var isLeftPage = viewer.drag === flipbook_3d_DV.TURN_DIRECTION.LEFT;
7460                        sheet.sheetAngle = angle;
7461                        var curveAngle = flipbook_3d_utils.getCurveAngle(isLeftPage, angle, 45);
7462                        if (sheet.isCover) {
7463                            sheet.viewer.flipCover(sheet);
7464                        }
7465                        sheet.curveAngle = sheet.isHard ? angle : curveAngle;
7466                        sheet.updateAngle();
7467                    }
7468                }
7469                viewer.checkSwipe(point, event);
7470            }
7471        },
7472        {
7473            /**
7474   * @param {MouseEvent & jQueryMouseEvent} event
7475   */ key: "mouseUp",
7476            value: function mouseUp(event) {
7477                var viewer = this;
7478                event = flipbook_3d_utils.fixMouseEvent(event);
7479                if (!event.touches && event.button !== 0) return;
7480                if (viewer.dragSheet == null && event.touches != null && event.touches.length === 0) {
7481                    this.pinchUp(event);
7482                    return;
7483                }
7484                var point = viewer.eventToPoint(event);
7485                if (viewer.app.zoomValue === 1) {
7486                    if (viewer.dragSheet !== null) {
7487                        var distance = point.x - viewer.startPoint.x;
7488                        if (Math.abs(distance) > viewer.swipeThreshold * 2) {
7489                            if (viewer.drag === flipbook_3d_DV.TURN_DIRECTION.LEFT && distance > 0) {
7490                                viewer.app.openLeft();
7491                            } else if (viewer.drag === flipbook_3d_DV.TURN_DIRECTION.RIGHT && distance < 0) {
7492                                viewer.app.openRight();
7493                            }
7494                        }
7495                        viewer.requestRefresh();
7496                        viewer.updatePendingStatusClass();
7497                    }
7498                    var element = event.target || event.originalTarget; //check to see if the clicked element is a link, if so skip turn
7499                    var isClick = viewer.startPoint && point.x === viewer.startPoint.x && point.y === viewer.startPoint.y && element.nodeName !== "A";
7500                    if (event.ctrlKey === true && isClick) {
7501                        this.zoomOnPoint(point);
7502                    } else if (isClick && point.sheet && viewer.clickAction === flipbook_3d_DV.MOUSE_CLICK_ACTIONS.NAV) {
7503                        if (point.sheet.sheetAngle > 90) {
7504                            viewer.app.openRight();
7505                        } else {
7506                            viewer.app.openLeft();
7507                        }
7508                    }
7509                }
7510                viewer.dragSheet = null;
7511                viewer.drag = null;
7512                if (viewer.isDragging === true) {
7513                    viewer.isDragging = false;
7514                }
7515                /*3 if there is swipe - clean*/ viewer.startPoint = null;
7516                viewer.canSwipe = false;
7517                viewer.app.renderRequestStatus = flipbook_3d_DV.REQUEST_STATUS.ON;
7518            }
7519        },
7520        {
7521            key: "raycastCLick",
7522            value: function raycastCLick(event) {
7523                var viewer = this;
7524                viewer.mouse = new THREE.Vector2();
7525                viewer.raycaster = new THREE.Raycaster();
7526                viewer.mouse.x = event.offsetX / viewer.app.dimensions.stage.width * 2 - 1;
7527                viewer.mouse.y = 1 - event.offsetY / viewer.app.dimensions.stage.height * 2;
7528                viewer.raycaster.setFromCamera(viewer.mouse, viewer.camera);
7529                var intersects = viewer.raycaster.intersectObjects(viewer.bookWrapper.children, true);
7530                if (intersects.length > 0) {
7531                    var object, objectCount = 0;
7532                    do {
7533                        object = intersects[objectCount] != null ? intersects[objectCount].object : null;
7534                        if (object.sheet && object.sheet.index) {
7535                            if (object.sheet.isFlipping !== true) {
7536                                return object;
7537                            }
7538                        }
7539                        objectCount++;
7540                    }while (objectCount < intersects.length);
7541                }
7542            }
7543        },
7544        {
7545            key: "mouseDown",
7546            value: function mouseDown(event) {
7547                event = flipbook_3d_utils.fixMouseEvent(event);
7548                if (!event.touches && event.button !== 0) return;
7549                if (event.touches != null && event.touches.length === 2) {
7550                    this.pinchDown(event);
7551                } else {
7552                    event = flipbook_3d_utils.fixMouseEvent(event);
7553                    var viewer = this;
7554                    var point = viewer.eventToPoint(event);
7555                    viewer.startPoint = point;
7556                    viewer.lastPosX = point.x;
7557                    viewer.lastPosY = point.y;
7558                    var object = viewer.raycastCLick(event);
7559                    var edgeDistance = point.sheet ? point.sheet.width - Math.abs(point.x - (this.app.dimensions.origin.x + viewer.centerEnd)) : 0;
7560                    if (point.sheet && object && point.isInsideSheet && edgeDistance < point.sheet.width / 2) {
7561                        viewer.dragSheet = object.sheet;
7562                        viewer.drag = point.sheet.sheetAngle < 90 ? flipbook_3d_DV.TURN_DIRECTION.LEFT : flipbook_3d_DV.TURN_DIRECTION.RIGHT;
7563                    } else {
7564                        viewer.canSwipe = true;
7565                    }
7566                }
7567            }
7568        },
7569        {
7570            key: "eventToPoint",
7571            value: function eventToPoint(event) {
7572                var viewer = this, dimensions = this.app.dimensions;
7573                event = flipbook_3d_utils.fixMouseEvent(event);
7574                var point = {
7575                    x: event.clientX,
7576                    y: event.clientY
7577                };
7578                //calculate x and y relative to container
7579                point.x = point.x - viewer.parentElement[0].getBoundingClientRect().left;
7580                point.y = point.y - viewer.parentElement[0].getBoundingClientRect().top;
7581                var left = (-dimensions.offset.width + dimensions.containerWidth) / 2 - dimensions.stage.width / 2, right = (-dimensions.offset.width + dimensions.containerWidth) / 2 + dimensions.stage.width / 2, top = dimensions.padding.top, bottom = dimensions.padding.top + viewer.availablePageHeight();
7582                var isLeftSheet = point.x < viewer.seamPosition;
7583                var pageNumber = viewer.getBasePage() + (isLeftSheet ? 0 : 1);
7584                var sheet = this.getPageByNumber(pageNumber);
7585                if (sheet) sheet = sheet.sheet;
7586                var isInsideSheet = point.x > left && point.x < right && point.y > top && point.y < bottom;
7587                return {
7588                    isInsideSheet: isInsideSheet,
7589                    isInsideDragZone: isInsideSheet && point.x - left < viewer.foldSense || right - point.x < viewer.foldSense,
7590                    x: point.x,
7591                    y: point.y,
7592                    left: left,
7593                    top: top,
7594                    right: right,
7595                    bottom: bottom,
7596                    raw: point,
7597                    isLeftSheet: isLeftSheet,
7598                    sheet: sheet
7599                };
7600            }
7601        },
7602        {
7603            key: "checkPageLoading",
7604            value: function checkPageLoading() {
7605                var isLoaded = true;
7606                var pages = this.getVisiblePages().main;
7607                for(var index = 0; index < (this.isBooklet ? 1 : 2); index++){
7608                    var page = this.getPageByNumber(pages[index]);
7609                    if (page) {
7610                        isLoaded = page.textureLoaded && isLoaded;
7611                    }
7612                }
7613                this.element.toggleClass("df-loading", !isLoaded);
7614            }
7615        },
7616        {
7617            key: "textureLoadedCallback",
7618            value: function textureLoadedCallback(param) {
7619                this.app.renderRequestStart();
7620                this.pagesReady();
7621            }
7622        },
7623        {
7624            key: "getTextureSize",
7625            value: function getTextureSize(param) {
7626                var size = flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "getTextureSize", this).call(this, param);
7627                if (this.app.zoomValue !== 1 || param.isAnnotation === true) return size;
7628                var height = flipbook_3d_utils.nearestPowerOfTwo(size.height);
7629                var width = size.width * height / size.height;
7630                return this.texturePowerOfTwo ? {
7631                    height: height,
7632                    width: width
7633                } : size;
7634            }
7635        },
7636        {
7637            key: "getPageByNumber",
7638            value: function getPageByNumber(pageNumber) {
7639                if (this.has3DCover) {
7640                    var isLastPage = !this.isBooklet && pageNumber === this.app.pageCount && pageNumber % 2 === 0, isFirstPage = pageNumber === 1;
7641                    if (!this.isRTL && isFirstPage || this.isRTL && isLastPage) return this.leftCover.frontPage;
7642                    if (!this.isRTL && isLastPage || this.isRTL && isFirstPage) return this.rightCover.backPage;
7643                }
7644                return flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "getPageByNumber", this).call(this, pageNumber);
7645            }
7646        },
7647        {
7648            key: "setPage",
7649            value: function setPage(param) {
7650                return flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "setPage", this).call(this, param);
7651            }
7652        },
7653        {
7654            key: "beforeFlip",
7655            value: function beforeFlip() {
7656                flipbook_3d_get(flipbook_3d_get_prototype_of(FlipBook3D.prototype), "beforeFlip", this).call(this);
7657            }
7658        }
7659    ]);
7660    return FlipBook3D;
7661}(BaseFlipBookViewer);
7662/**
7663 * Page3D represents only the material side of the booksheet
7664 */ var Page3D = /*#__PURE__*/ function(Page2D) {
7665    "use strict";
7666    flipbook_3d_inherits(Page3D, Page2D);
7667    var _super = flipbook_3d_create_super(Page3D);
7668    function Page3D(options) {
7669        flipbook_3d_class_call_check(this, Page3D);
7670        var _this;
7671        _this = _super.call(this, options);
7672        var page = flipbook_3d_assert_this_initialized(_this);
7673        page.element = null;
7674        page.face = options.face;
7675        page.parent3D = options.sheet;
7676        page.sheet = options.sheet;
7677        page.cssPage = new THREE.CSS3DObject(page.contentLayer[0]);
7678        return _this;
7679    }
7680    flipbook_3d_create_class(Page3D, [
7681        {
7682            key: "setLoading",
7683            value: function setLoading() {
7684                this.sheet.viewer.checkPageLoading();
7685            }
7686        },
7687        {
7688            key: "clearMap",
7689            value: function clearMap() {
7690                this.sheet.element.material[this.face].map = null;
7691                this.sheet.element.material[this.face].needsUpdate = true;
7692            }
7693        },
7694        {
7695            key: "loadTexture",
7696            value: function loadTexture(param) {
7697                var page = this, texture = param.texture, callback = param.callback;
7698                page.textureSrc = texture;
7699                function completed(object, texture3D) {
7700                    page.updateTextureLoadStatus(true);
7701                    page.sheet.resetMatColor(page.face, param.texture === page.textureLoadFallback);
7702                    if (typeof callback == 'function') callback(param);
7703                }
7704                if (typeof flipbook_3d_DV.defaults.beforeLoadTexture == 'function') flipbook_3d_DV.defaults.beforeLoadTexture({
7705                    texture: texture,
7706                    page: page
7707                });
7708                if (this.face === 4) {
7709                    this.sheet.backImage(texture, completed);
7710                } else {
7711                    this.sheet.frontImage(texture, completed);
7712                }
7713            }
7714        }
7715    ]);
7716    return Page3D;
7717}(Page2D);
7718
7719
7720;// CONCATENATED MODULE: ./src/js/dearviewer/viewers/viewers-lite.js
7721function viewers_lite_class_call_check(instance, Constructor) {
7722    if (!(instance instanceof Constructor)) {
7723        throw new TypeError("Cannot call a class as a function");
7724    }
7725}
7726
7727
7728
7729
7730defaults_DEARVIEWER.defaults.maxTextureSize = 2048;
7731var FlipBook = function FlipBook(options, appContext) {
7732    "use strict";
7733    viewers_lite_class_call_check(this, FlipBook);
7734    if (defaults_DEARVIEWER.utils.canSupport3D() == false) {
7735        options.is3D = false; //IE 11
7736    }
7737    if (options.is3D === true) {
7738        return new FlipBook3D(options, appContext);
7739    }
7740    return new FlipBook2D(options, appContext);
7741};
7742defaults_DEARVIEWER.viewers = {};
7743defaults_DEARVIEWER.viewers['flipbook'] = FlipBook;
7744defaults_DEARVIEWER.viewers['default'] = defaults_DEARVIEWER.viewers['reader'] = Reader;
7745
7746;
vendor: 5,841 bytes, lines 7746-7898
7746// CONCATENATED MODULE: ./src/js/dearviewer/utils/provider.js
7747/* globals requirejs, jQuery*/ function provider_assert_this_initialized(self) {
7748    if (self === void 0) {
7749        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7750    }
7751    return self;
7752}
7753function provider_class_call_check(instance, Constructor) {
7754    if (!(instance instanceof Constructor)) {
7755        throw new TypeError("Cannot call a class as a function");
7756    }
7757}
7758function provider_defineProperties(target, props) {
7759    for(var i = 0; i < props.length; i++){
7760        var descriptor = props[i];
7761        descriptor.enumerable = descriptor.enumerable || false;
7762        descriptor.configurable = true;
7763        if ("value" in descriptor) descriptor.writable = true;
7764        Object.defineProperty(target, descriptor.key, descriptor);
7765    }
7766}
7767function provider_create_class(Constructor, protoProps, staticProps) {
7768    if (protoProps) provider_defineProperties(Constructor.prototype, protoProps);
7769    if (staticProps) provider_defineProperties(Constructor, staticProps);
7770    return Constructor;
7771}
7772function provider_get_prototype_of(o) {
7773    provider_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
7774        return o.__proto__ || Object.getPrototypeOf(o);
7775    };
7776    return provider_get_prototype_of(o);
7777}
7778function provider_inherits(subClass, superClass) {
7779    if (typeof superClass !== "function" && superClass !== null) {
7780        throw new TypeError("Super expression must either be null or a function");
7781    }
7782    subClass.prototype = Object.create(superClass && superClass.prototype, {
7783        constructor: {
7784            value: subClass,
7785            writable: true,
7786            configurable: true
7787        }
7788    });
7789    if (superClass) provider_set_prototype_of(subClass, superClass);
7790}
7791function provider_instanceof(left, right) {
7792    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
7793        return !!right[Symbol.hasInstance](left);
7794    } else {
7795        return left instanceof right;
7796    }
7797}
7798function provider_possible_constructor_return(self, call) {
7799    if (call && (provider_type_of(call) === "object" || typeof call === "function")) {
7800        return call;
7801    }
7802    return provider_assert_this_initialized(self);
7803}
7804function provider_set_prototype_of(o, p) {
7805    provider_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
7806        o.__proto__ = p;
7807        return o;
7808    };
7809    return provider_set_prototype_of(o, p);
7810}
7811function provider_type_of(obj) {
7812    "@swc/helpers - typeof";
7813    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
7814}
7815function provider_is_native_reflect_construct() {
7816    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
7817    if (Reflect.construct.sham) return false;
7818    if (typeof Proxy === "function") return true;
7819    try {
7820        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
7821        return true;
7822    } catch (e) {
7823        return false;
7824    }
7825}
7826function provider_create_super(Derived) {
7827    var hasNativeReflectConstruct = provider_is_native_reflect_construct();
7828    return function _createSuperInternal() {
7829        var Super = provider_get_prototype_of(Derived), result;
7830        if (hasNativeReflectConstruct) {
7831            var NewTarget = provider_get_prototype_of(this).constructor;
7832            result = Reflect.construct(Super, arguments, NewTarget);
7833        } else {
7834            result = Super.apply(this, arguments);
7835        }
7836        return provider_possible_constructor_return(this, result);
7837    };
7838}
7839
7840var provider_utils = defaults_DEARVIEWER.utils;
7841/**
7842 * @typedef {Object} PDFDocument
7843 * @property {Function} getPage - Gets the Page
7844 * @property {Function} numPages - Total number of pages
7845 * @property {Function} getPageIndex - Gets the Page Index
7846 * @property {Function} getOutline - Gets the Outline
7847 * @property {Function} getDestination - Gets the Destination
7848 */ /**
7849 * @typedef {Object} PDFPage
7850 * @property {Function} getViewport - Gets the Viewport
7851 * @property {Function} getAnnotations - Gets the Annotation
7852 */ //region Link Service
7853/**
7854 * Performs navigation functions inside PDF, such as opening specified page,
7855 * or destination.
7856 * @class
7857 */ var PDFLinkService = /*#__PURE__*/ function() {
7858    "use strict";
7859    function PDFLinkService() {
7860        provider_class_call_check(this, PDFLinkService);
7861        this.baseUrl = null;
7862        this.pdfDocument = null;
7863        this.pdfApp = null;
7864        this.pdfHistory = null;
7865        this.externalLinkRel = null;
7866        this.externalLinkEnabled = true;
7867        this._pagesRefCache = null;
7868    }
7869    provider_create_class(PDFLinkService, [
7870        {
7871            key: "dispose",
7872            value: function dispose() {
7873                this.baseUrl = null;
7874                this.pdfDocument = null;
7875                this.pdfApp = null;
7876                this.pdfHistory = null;
7877                this._pagesRefCache = null;
7878            }
7879        },
7880        {
7881            key: "setDocument",
7882            value: function setDocument(pdfDocument, baseUrl) {
7883                this.baseUrl = baseUrl;
7884                this.pdfDocument = pdfDocument;
7885                this._pagesRefCache = Object.create(null);
7886            }
7887        },
7888        {
7889            key: "setViewer",
7890            value: function setViewer(pdfApp) {
7891                this.pdfApp = pdfApp;
7892                this.externalLinkTarget = pdfApp.options.linkTarget;
7893            }
7894        },
7895        {
7896            key: "setHistory",
7897            value: function setHistory(pdfHistory) {
7898                this.pdfHistory = pdfHistory;
7899            }
7900        },
7901        {
7902            key: "pagesCount",
7903            get: /**
7904   * @returns {number}
7905   */ function get() {
7906                return this.pdfDocument.numPages;
7907            }
7908        },
7909        {
7910            key: "page",
7911            get: /**
7912   * @returns {number}
7913   */ function get() {
7914                return this.pdfApp.currentPageNumber;
7915            },
7916            set: /**
7917   * @param {number} value
7918   */ function set(value) {
7919                this.pdfApp.gotoPage(value);
7920            }
7921        },
7922        {
7923            key: "navigateTo",
7924            value: function navigateTo(dest) {
7925                this.goToDestination(dest);
7926            }
7927        },
7928        {
7929            /**
7930   * Wrapper around the `addLinkAttributes`-function in the API.
7931   * @param {HTMLAnchorElement} link
7932   * @param {string} url
7933   * @param {boolean} [newWindow]
7934   */ key: "addLinkAttributes",
7935            value: function addLinkAttributes(link, url) {
7936                var newWindow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
7937                /*    pdfjsLib.addLinkAttributes(link, {
7938          url,
7939          target: this.externalLinkTarget,
7940          rel: this.externalLinkRel,
7941          enabled: this.externalLinkEnabled,
7942        });*/ var target = this.externalLinkTarget, rel = this.externalLinkRel, enabled = this.externalLinkEnabled;
7943                if (!url || typeof url !== "string") {
7944                    throw new Error('A valid "url" parameter must provided.');
7945                }
7946                var urlNullRemoved = (0, provider_utils.removeNullCharacters)(url);
7947                if (enabled) {
7948                    link.href = link.title = urlNullRemoved;
7949                } else {
7950                    link.href = "";
7951                    link.title = "Disabled: ".concat(urlNullRemoved);
7952                    link.onclick = function() {
7953                        return false;
7954                    };
7955                }
7956                var targetStr = "";
7957                switch(target){
7958                    case defaults_DEARVIEWER.LINK_TARGET.NONE:
7959                        break;
7960                    case defaults_DEARVIEWER.LINK_TARGET.SELF:
7961                        targetStr = "_self";
7962                        break;
7963                    case defaults_DEARVIEWER.LINK_TARGET.BLANK:
7964                        targetStr = "_blank";
7965                        break;
7966                    case defaults_DEARVIEWER.LINK_TARGET.PARENT:
7967                        targetStr = "_parent";
7968                        break;
7969                    case defaults_DEARVIEWER.LINK_TARGET.TOP:
7970                        targetStr = "_top";
7971                        break;
7972                }
7973                link.target = targetStr;
7974                link.rel = typeof rel === "string" ? rel : "noopener noreferrer nofollow";
7975            }
7976        },
7977        {
7978            /**
7979   * @param dest - The PDF destination object.
7980   */ key: "goToDestination",
7981            value: function goToDestination(dest) {
7982                var destString = '';
7983                var self = this;
7984                var goToDestination = function goToDestination1(destRef) {
7985                    provider_utils.log("Requested: ", destRef);
7986                    // dest array looks like that: <page-ref> </XYZ|FitXXX> <args..>
7987                    var pageNumber = provider_instanceof(destRef, Object) ? self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] : destRef + 1;
7988                    if (pageNumber) {
7989                        pageNumber = self.pdfApp.viewer.getViewerPageNumber(pageNumber);
7990                        if (pageNumber > self.pdfApp.pageCount) {
7991                            pageNumber = self.pdfApp.pageCount;
7992                        }
7993                        provider_utils.log("Loading for:", destRef, " at page ", pageNumber);
7994                        if (self.pdfApp.requestDestRefKey === destRef.num + ' ' + destRef.gen + ' R') {
7995                            self.pdfApp.gotoPage(pageNumber);
7996                            if (self.pdfHistory) {
7997                                // Update the browsing history.
7998                                self.pdfHistory.push({
7999                                    dest: dest,
8000                                    hash: destString,
8001                                    page: pageNumber
8002                                });
8003                            }
8004                        } else {
8005                            provider_utils.log("Expired Request for ", pageNumber, " with ", destRef);
8006                        }
8007                    } else {
8008                        self.pdfApp.container.addClass('df-fetch-pdf');
8009                        self.pdfDocument.getPageIndex(destRef).then(function(pageIndex) {
8010                            var pageNum = pageIndex + 1;
8011                            var cacheKey = destRef.num + ' ' + destRef.gen + ' R';
8012                            self._pagesRefCache[cacheKey] = pageNum;
8013                            goToDestination(destRef);
8014                        });
8015                    }
8016                };
8017                var destinationPromise;
8018                if (typeof dest === 'string') {
8019                    destString = dest;
8020                    destinationPromise = this.pdfDocument.getDestination(dest);
8021                } else {
8022                    destinationPromise = Promise.resolve(dest);
8023                }
8024                destinationPromise.then(function(destination) {
8025                    provider_utils.log("Started:", destination);
8026                    dest = destination;
8027                    if (!provider_instanceof(destination, Array)) {
8028                        return; // invalid destination
8029                    }
8030                    self.pdfApp.requestDestRefKey = destination[0].num + ' ' + destination[0].gen + ' R';
8031                    goToDestination(destination[0]);
8032                });
8033            }
8034        },
8035        {
8036            /**
8037   * @param dest - The PDF destination object.
8038   */ key: "customNavigateTo",
8039            value: function customNavigateTo(dest) {
8040                if (dest === '' || dest == null || dest === 'null') return;
8041                var pageNumber = null;
8042                if (!isNaN(Math.floor(dest))) {
8043                    pageNumber = dest;
8044                } else if (typeof dest === 'string') {
8045                    pageNumber = parseInt(dest.replace("#", ""), 10);
8046                    if (isNaN(pageNumber)) {
8047                        window.open(dest, this.pdfApp.options.linkTarget === defaults_DEARVIEWER.LINK_TARGET.SELF ? "_self" : "_blank");
8048                        return;
8049                    }
8050                }
8051                if (pageNumber != null) this.pdfApp.gotoPage(pageNumber);
8052            }
8053        },
8054        {
8055            /**
8056   * @param dest - The PDF destination object.
8057   * @returns {string} The hyperlink to the PDF object.
8058   */ key: "getDestinationHash",
8059            value: function getDestinationHash(dest) {
8060                if (typeof dest === 'string') {
8061                    return this.getAnchorUrl('#' + escape(dest));
8062                }
8063                if (provider_instanceof(dest, Array)) {
8064                    var destRef = dest[0]; // see navigateTo method for dest format
8065                    var pageNumber = provider_instanceof(destRef, Object) ? this._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] 
8065: destRef + 1;
8066                    if (pageNumber) {
8067                        var pdfOpenParams = this.getAnchorUrl('#page=' + pageNumber);
8068                        var destKind = dest[1];
8069                        if ((typeof destKind === "undefined" ? "undefined" : provider_type_of(destKind)) === 'object' && 'name' in destKind && destKind.name === 'XYZ') {
8070                            var scale = dest[4] || this.pdfApp.pageScaleValue;
8071                            var scaleNumber = parseFloat(scale);
8072                            if (scaleNumber) {
8073                                scale = scaleNumber * 100;
8074                            }
8075                            pdfOpenParams += '&zoom=' + scale;
8076                            if (dest[2] || dest[3]) {
8077                                pdfOpenParams += ',' + (dest[2] || 0) + ',' + (dest[3] || 0);
8078                            }
8079                        }
8080                        return pdfOpenParams;
8081                    }
8082                }
8083                return this.getAnchorUrl('');
8084            }
8085        },
8086        {
8087            /**
8088   * @param dest - The PDF destination object.
8089   * @returns {string} The hyperlink to the PDF object.
8090   */ key: "getCustomDestinationHash",
8091            value: function getCustomDestinationHash(dest) {
8092                //if (typeof dest === 'string') {
8093                return '#' + escape(dest);
8094            //}
8095            //return this.getAnchorUrl('');
8096            }
8097        },
8098        {
8099            /**
8100   * Prefix the full url on anchor links to make sure that links are resolved
8101   * relative to the current URL instead of the one defined in <base href>.
8102   * @param {String} anchor The anchor hash, including the #.
8103   * @returns {string} The hyperlink to the PDF object.
8104   */ key: "getAnchorUrl",
8105            value: function getAnchorUrl(anchor) {
8106                return (this.baseUrl || '') + anchor;
8107            }
8108        },
8109        {
8110            /**
8111   * @param {string} action
8112   */ key: "executeNamedAction",
8113            value: function executeNamedAction(action) {
8114                // See PDF reference, table 8.45 - Named action
8115                switch(action){
8116                    case 'GoBack':
8117                        if (this.pdfHistory) {
8118                            this.pdfHistory.back();
8119                        }
8120                        break;
8121                    case 'GoForward':
8122                        if (this.pdfHistory) {
8123                            this.pdfHistory.forward();
8124                        }
8125                        break;
8126                    case 'NextPage':
8127                        this.page++;
8128                        break;
8129                    case 'PrevPage':
8130                        this.page--;
8131                        break;
8132                    case 'LastPage':
8133                        this.page = this.pagesCount;
8134                        break;
8135                    case 'FirstPage':
8136                        this.page = 1;
8137                        break;
8138                    default:
8139                        break; // No action according to spec
8140                }
8141                var event = document.createEvent('CustomEvent');
8142                event.initCustomEvent('namedaction', true, true, {
8143                    action: action
8144                });
8145                this.pdfApp.container.dispatchEvent(event);
8146            }
8147        },
8148        {
8149            // noinspection JSUnusedGlobalSymbols
8150            /**
8151   * @param {number} pageNum - page number.
8152   * @param {Object} pageRef - reference to the page.
8153   */ key: "cachePageRef",
8154            value: function cachePageRef(pageNum, pageRef) {
8155                var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
8156                this._pagesRefCache[refStr] = pageNum;
8157            }
8158        }
8159    ]);
8160    return PDFLinkService;
8161}();
8162var DocumentProvider = /*#__PURE__*/ function() {
8163    "use strict";
8164    function DocumentProvider(props, context) {
8165        provider_class_call_check(this, DocumentProvider);
8166        this.props = props;
8167        this.app = context;
8168        this.textureCache = [];
8169        this.pageCount = 0;
8170        this.numPages = 0;
8171        this.outline = [];
8172        this.viewPorts = [];
8173        this.requestedPages = '';
8174        this.requestIndex = 0;
8175        this.pagesToClean = [];
8176        this.defaultPage = undefined;
8177        this.pageSize = this.app.options.pageSize;
8178        this._page1Pass = false;
8179        this._page2Pass = false;
8180        this.pageLabels = void 0;
8181        this.textSearchLength = 0;
8182        this.textSearch = "";
8183        this.textContentSearch = [];
8184        this.textContentJoinedSearch = [];
8185        this.textOffsetSearch = [];
8186        this.textContent = [];
8187        this.textContentJoined = [];
8188        this.textOffset = [];
8189        this.autoLinkItemsCache = [];
8190        this.autoLinkHitsCache = [];
8191        this.searchHitItemsCache = [];
8192        this.searchHits = [];
8193        this.PDFLinkItemsCache = [];
8194        this.canPrint = true;
8195        this.textPostion = [];
8196    }
8197    provider_create_class(DocumentProvider, [
8198        {
8199            key: "finalize",
8200            value: function finalize() {}
8201        },
8202        {
8203            key: "dispose",
8204            value: function dispose() {}
8205        },
8206        {
8207            key: "softDispose",
8208            value: function softDispose() {}
8209        },
8210        {
8211            key: "setCache",
8212            value: function setCache(index, src, cacheIndexSize) {
8213                var provider = this;
8214                var cacheIndex = cacheIndexSize;
8215                if (cacheIndexSize) {
8216                    if (provider.textureCache[cacheIndex] === undefined) provider.textureCache[cacheIndex] = [];
8217                    provider.textureCache[cacheIndex][index] = src;
8218                }
8219            }
8220        },
8221        {
8222            key: "getCache",
8223            value: function getCache(index, textureIndex) {
8224                var provider = this;
8225                return provider.textureCache[textureIndex] === undefined ? undefined : provider.textureCache[textureIndex][index];
8226            }
8227        },
8228        {
8229            key: "_isValidPage",
8230            value: function _isValidPage(pageNumber) {
8231                return pageNumber > 0 && pageNumber <= this.pageCount;
8232            }
8233        },
8234        {
8235            key: "getLabelforPage",
8236            value: function getLabelforPage(pageNumber) {
8237                if (this.pageLabels && this.pageLabels[pageNumber - 1] !== void 0) return this.pageLabels[pageNumber - 1];
8238                return pageNumber;
8239            }
8240        },
8241        {
8242            key: "getThumbLabel",
8243            value: function getThumbLabel(pageNumber) {
8244                var label = this.getLabelforPage(pageNumber);
8245                if (label !== pageNumber) {
8246                    return label + " (" + pageNumber + ")";
8247                }
8248                return pageNumber;
8249            }
8250        },
8251        {
8252            key: "getPageNumberForLabel",
8253            value: function getPageNumberForLabel(label) {
8254                if (!this.pageLabels) {
8255                    return label;
8256                }
8257                var i = this.pageLabels.indexOf(label);
8258                if (i < 0) {
8259                    return null;
8260                }
8261                return i + 1;
8262            }
8263        },
8264        {
8265            key: "processPage",
8266            value: function processPage(param) {}
8267        },
8268        {
8269            key: "cleanUpPages",
8270            value: function cleanUpPages() {}
8271        },
8272        {
8273            key: "checkRequestQueue",
8274            value: function checkRequestQueue() {}
8275        },
8276        {
8277            key: "processAnnotations",
8278            value: function processAnnotations() {}
8279        },
8280        {
8281            key: "processTextContent",
8282            value: function processTextContent() {}
8283        },
8284        {
8285            key: "loadDocument",
8286            value: function loadDocument() {}
8287        },
8288        {
8289            key: "pagesLoaded",
8290            value: function pagesLoaded() {
8291                var provider = this;
8292                if (provider._page1Pass && provider._page2Pass) {
8293                    provider.app.viewer.checkDocumentPageSizes();
8294                    provider.finalize();
8295                }
8296            }
8297        },
8298        {
8299            key: "_documentLoaded",
8300            value: function _documentLoaded() {
8301                this.finalizeOutLine();
8302                //checks so that new providers fulfill all the required steps
8303                if (this.app && this.app.dimensions && this.app.dimensions.pageFit === undefined) provider_utils.log("Provider needs to initialize page properties for the app");
8304                this.app._documentLoaded();
8305            }
8306        },
8307        {
8308            key: "finalizeOutLine",
8309            value: function finalizeOutLine() {
8310                if (this.app === null || this.app.options === null) return;
8311                var outline = this.app.options.outline, provider = this;
8312                if (outline) {
8313                    for(var count = 0; count < outline.length; count++){
8314                        outline[count].custom = true;
8315                        provider.outline.push(outline[count]);
8316                    }
8317                }
8318            }
8319        },
8320        {
8321            key: "search",
8322            value: function search() {}
8323        }
8324    ]);
8325    return DocumentProvider;
8326}();
8327var PDFDocumentProvider = /*#__PURE__*/ function(DocumentProvider) {
8328    "use strict";
8329    provider_inherits(PDFDocumentProvider, DocumentProvider);
8330    var _super = provider_create_super(PDFDocumentProvider);
8331    function PDFDocumentProvider(props, context) {
8332        provider_class_call_check(this, PDFDocumentProvider);
8333        var _this;
8334        var getPDFScript = function getPDFScript(callback) {
8335            if (typeof pdfjsLib === "undefined") {
8336                app.updateInfo(app.options.text.loading + " PDF Service ...");
8337                provider_utils.getScript(app.options.pdfjsSrc + provider.cacheBustParameters, function() {
8338                    if (typeof define === 'function' && __webpack_require__.amdO && window.requirejs && window.require && window.require.config) {
8339                        app.updateInfo(app.options.text.loading + " PDF Service (require) ...");
8340                        window.require.config({
8341                            paths: {
8342                                'pdfjs-dist/build/pdf.worker': app.options.pdfjsWorkerSrc.replace(".js", "")
8343                            }
8344                        });
8345                        window.require([
8346                            'pdfjs-dist/build/pdf'
8347                        ], function(pdfjsLib1) {
8348                            window.pdfjsLib = pdfjsLib1;
8349                            getWorkerScript(callback);
8350                        });
8351                    } else {
8352                        getWorkerScript(callback);
8353                    }
8354                }, function() {
8355                    app.updateInfo("Unable to load PDF service..");
8356                    provider.dispose();
8357                }, app.options.pdfjsSrc.indexOf("pdfjs-4") > 1);
8358            } else {
8359                if (typeof callback === "function") callback();
8360            }
8361        };
8362        var getWorkerScript = function getWorkerScript(callback) {
8363            app.updateInfo(app.options.text.loading + " PDF Worker ...");
8364            var tmp = document.createElement('a');
8365            tmp.href = app.options.pdfjsWorkerSrc + provider.cacheBustParameters;
8366            if (tmp.hostname !== window.location.hostname && defaults_DEARVIEWER['loadCorsPdfjsWorker'] === true) {
8367                app.updateInfo(app.options.text.loading + " PDF Worker CORS ...");
8368                jQuery.ajax({
8369                    url: app.options.pdfjsWorkerSrc + provider.cacheBustParameters,
8370                    cache: true,
8371                    success: function success(data) {
8372                        app.options.pdfjsWorkerSrc = provider_utils.createObjectURL(data, "text/javascript");
8373                        if (typeof callback === "function") callback();
8374                    }
8375                });
8376            } else {
8377                if (typeof callback === "function") callback();
8378            }
8379        };
8380        _this = _super.call(this, props, context);
8381        var app = _this.app, provider = provider_assert_this_initialized(_this);
8382        provider.pdfDocument = undefined;
8383        provider._page2Ratio = undefined;
8384        provider.cacheBustParameters = "?ver=" + defaults_DEARVIEWER.version + "&pdfver=" + app.options.pdfVersion;
8385        getPDFScript(function() {
8386            pdfjsLib.GlobalWorkerOptions.workerSrc = app.options.pdfjsWorkerSrc + provider.cacheBustParameters;
8387            pdfjsLib.canvasWillReadFrequently = defaults_DEARVIEWER.defaults.canvasWillReadFrequently;
8388            provider.loadDocument();
8389        });
8390        return _this;
8391    }
8392    provider_create_class(PDFDocumentProvider, [
8393        {
8394            key: "dispose",
8395            value: function dispose() {
8396                if (this.pdfDocument) this.pdfDocument.destroy();
8397                this.linkService = provider_utils.disposeObject(this.linkService);
8398                if (this.pdfLoadProgress) this.pdfLoadProgress.destroy();
8399                this.pdfLoadProgress = null;
8400                this.pdfDocument = null;
8401            }
8402        },
8403        {
8404            key: "loadDocument",
8405            value: function loadDocument() {
8406                var app = this.app, options = this.app.options, provider = this;
8407                var parameters = options.pdfParameters || {};
8408                parameters.url = provider_utils.httpsCorrection(parameters.url || options.source);
8409                parameters.rangeChunkSize = options.rangeChunkSize;
8410                parameters.cMapPacked = true;
8411                parameters.disableAutoFetch = options.disableAutoFetch;
8412                parameters.disableStream = options.disableStream;
8413                parameters.disableRange = options.disableRange === true;
8414                parameters.disableFontFace = options.disableFontFace;
8415                parameters.isEvalSupported = false;
8416                parameters.cMapUrl = options.cMapUrl;
8417                parameters.imagesLocation = options.imagesLocation;
8418                parameters.imageResourcesPath = options.imageResourcesPath;
8419                //region Loading Document
8420                if (!parameters.url && !parameters.data && !parameters.range) {
8421                    //Display No PDF file found error
8422                    app.updateInfo("ERROR : No PDF File provided! ", "df-error");
8423                    return;
8424                }
8425                // app.updateInfo(app.options.text.loading + " PDF ...");
8426                var pdfLoadProcess = provider.pdfLoadProgress = pdfjsLib.getDocument(parameters);
8427                pdfLoadProcess._worker.promise.then(function(a) {
8428                    app.updateInfo(app.options.text.loading + " PDF ...");
8429                });
8430                pdfLoadProcess.onPassword = function(updatePassword, reason) {
8431                    switch(reason){
8432                        case pdfjsLib.PasswordResponses.NEED_PASSWORD:
8433                            var password = prompt("Enter the password to open the PDF file.");
8434                            if (password === null) {
8435                                throw new Error("No password givsen.");
8436                            }
8437                            updatePassword(password);
8438                            break;
8439                        case pdfjsLib.PasswordResponses.INCORRECT_PASSWORD:
8440                            var password = prompt("Invalid password. Please try again.");
8441                            if (!password) {
8442                                throw new Error("No password givaen.");
8443                            }
8444                            updatePassword(password);
8445                            break;
8446                    }
8447                };
8448                pdfLoadProcess.promise.then(/**
8449       * @constructs pdfLoaded
8450       * @param {PDFDocument} pdf
8451       */ function pdfLoaded(pdf) {
8452                    provider.pdfDocument = pdf;
8453                    pdf.getPage(1).then(function(page) {
8454                        //set defaultPage details
8455                        provider.defaultPage = page;
8456                        var _defaultViewPort = provider.defaultPage.viewPort = page.getViewport({
8457                            scale: 1,
8458                            rotation: page._pageInfo.rotate + app.options.pageRotation
8459                        });
8460                        var _defaultPageRatio = provider.defaultPage.pageRatio = _defaultViewPort.width / _defaultViewPort.height;
8461                        var _isDefaultPageWide = _defaultPageRatio > 1;
8462                        provider.viewPorts[1] = _defaultViewPort;
8463                        app.dimensions.defaultPage = {
8464                            ratio: _defaultPageRatio,
8465                            viewPort: _defaultViewPort,
8466                            width: _defaultViewPort.width,
8467                            height: _defaultViewPort.height
8468                        };
8469                        var _options_maxTextureSize;
8470                        app.dimensions.maxTextureHeight = ((_options_maxTextureSize = options.maxTextureSize) !== null && _options_maxTextureSize !== void 0 ? _options_maxTextureSize : 3200) / (!_isDefaultPageWide ? 1 : _defaultPageRatio);
8471                        app.dimensions.maxTextureWidth = app.dimensions.maxTextureHeight * _defaultPageRatio;
8472                        app.dimensions.autoHeightRatio = 1 / _defaultPageRatio;
8473                        provider.pageCount = pdf.numPages;
8474                        provider.numPages = pdf.numPages;
8475                        provider._page1Pass = true;
8476                        provider.pagesLoaded();
8477                    });
8478                    //check if internal pages are of double sizes.
8479                    if (pdf.numPages > 1 && app.checkSecondPage === true) {
8480                        /**
8481           * @constructs checkInternalPages
8482           * @param {PDFPageProxy} page
8483           */ pdf.getPage(2).then(function checkInternalPages(page) {
8484                            var _page2ViewPort = page.getViewport({
8485                                scale: 1,
8486                                rotation: page._pageInfo.rotate + app.options.pageRotation
8487                            });
8488                            provider._page2Ratio = _page2ViewPort.width / _page2ViewPort.height;
8489                            provider.viewPorts[2] = _page2ViewPort;
8490                            provider._page2Pass = true;
8491                            provider.pagesLoaded();
8492                        });
8493                    } else {
8494                        provider._page2Pass = true;
8495                        provider.pagesLoaded();
8496                    }
8497                }).catch(function(error) {
8498                    if (app !== null && app.options != null) {
8499                        var _app_options;
8500                        //Find errors condition
8501                        var cors = "", _a = document.createElement('a');
8502                        _a.href = app.options.source;
8503                        if (_a.hostname !== window.location.hostname && _a.href.indexOf("file://") === -1 && !provider_utils.isChromeExtension() && _a.href.indexOf("blob:") === -1) cors = "<strong>CROSS ORIGIN!! </strong>";
8504                        var fileName = ((_app_options = app.options) === null || _app_options === void 0 ? void 0 : _app_options.fileName) || _a.href;
8505                        //Display error reason
8506                        app.updateInfo(cors + "<strong>Error: Cannot access file!  </strong>" + unescape(fileName) + "<br><br>" + error.message, "df-error");
8507                        console.log(error);
8508                        app.container.removeClass('df-loading').addClass("df-error");
8509                        provider.dispose();
8510                    }
8511                });
8512                pdfLoadProcess.getTotalLength = function() {
8513                    return provider.pdfLoadProgress._transport._networkStream._fullRequestReader.contentLength;
8514                };
8515                pdfLoadProcess.onProgress = function getDocumentProgress(progressData) {
8516                    if (app !== null) {
8517                        var percentage = 100 * progressData.loaded / pdfLoadProcess.getTotalLength();
8518                        if (isNaN(percentage)) {
8519                            if (progressData && progressData.loaded) {
8520                                // skip loading value if the differnces is less than 250kb,
8521                                // not required in percentage since percentage only updates in partial load chunk completion
8522                                if (pdfLoadProcess.lastLoaded === void 0 || pdfLoadProcess.lastLoaded + 250000 < progressData.loaded) {
8523                                    pdfLoadProcess.lastLoaded = progressData.loaded;
8524                                    app.updateInfo(app.options.text.loading + " PDF " + (Math.ceil(progressData.loaded / 10000) / 100).toFixed(2).toString() + "MB ...");
8525                                }
8526                            } else {
8527                                app.updateInfo(app.options.text.loading + " PDF ...");
8528                            }
8529                        } else {
8530                            app.updateInfo(app.options.text.loading + " PDF " + Math.ceil(Math.min(100, percentage)).toString().split(".")[0] + "% ...");
8531                        }
8532                    }
8533                };
8534            //endregion
8535            }
8536        },
8537        {
8538            key: "pdfFetchStarted",
8539            value: function pdfFetchStarted() {
8540                this.pdfFetchStatusCount = 0;
8541                this.app.container.addClass('df-fetch-pdf');
8542                this.pdfFetchStatus = defaults_DEARVIEWER.REQUEST_STATUS.COUNT;
8543            }
8544        },
8545        {
8546            key: "checkRequestQueue",
8547            value: function checkRequestQueue() {
8548                return;
8549                var REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS;
8550                if (this.pdfFetchStatus === REQUEST_STATUS.ON) {
8551                    this.app.container.removeClass('df-fetch-pdf');
8552                    this.pdfFetchStatus = REQUEST_STATUS.OFF;
8553                } else if (this.pdfFetchStatus === REQUEST_STATUS.COUNT) {
8554                    this.pdfFetchStatusCount++;
8555                    if (this.pdfFetchStatusCount > 30) {
8556                        this.pdfFetchStatusCount = 0;
8557                        this.pdfFetchStatus = REQUEST_STATUS.ON;
8558                    }
8559                }
8560            }
8561        },
8562        {
8563            key: "finalize",
8564            value: function finalize() {
8565                var app = this.app, provider = this;
8566                if (app === null || app.options === null) return;
8567                provider.linkService = new PDFLinkService();
8568                provider.linkService.setDocument(provider.pdfDocument, null);
8569                provider.linkService.setViewer(app);
8570                provider.pdfDocument.getOutline().then(function(pdfOutline) {
8571                    if (app.options.overwritePDFOutline === true) {
8572                        pdfOutline = [];
8573                    }
8574                    pdfOutline = pdfOutline || [];
8575                    provider.outline = pdfOutline;
8576                }).finally(function() {
8577                    provider._getLabels();
8578                });
8579            }
8580        },
8581        {
8582            key: "_getLabels",
8583            value: function _getLabels() {
8584                var app = this.app, provider = this;
8585                provider.pdfDocument.getPageLabels().then(function(pageLabels) {
8586                    if (!pageLabels || app.options.disablePageLabels === true) {
8587                        return;
8588                    }
8589                    var numLabels = pageLabels.length;
8590                    // Ignore page labels that correspond to standard page numbering,
8591                    // or page labels that are all empty.
8592                    var standardLabels = 0, emptyLabels = 0;
8593                    for(var i = 0; i < numLabels; i++){
8594                        var label = pageLabels[i];
8595                        if (label === (i + 1).toString()) {
8596                            standardLabels++;
8597                        } else if (label === "") {
8598                            emptyLabels++;
8599                        } else {
8600                            break;
8601                        }
8602                    }
8603                    if (standardLabels >= numLabels || emptyLabels >= numLabels) {
8604                        return;
8605                    }
8606                    provider.pageLabels = pageLabels;
8607                }).finally(function() {
8608                    provider._getPermissions();
8609                });
8610            }
8611        },
8612        {
8613            key: "_getPermissions",
8614            value: function _getPermissions() {
8615                var app = this.app, provider = this;
8616                provider.pdfDocument.getPermissions().then(function(permissions) {
8617                    if (permissions !== null && Array.isArray(permissions)) {
8618                        provider.canPrint = permissions.indexOf(pdfjsLib.PermissionFlag.PRINT) > -1;
8619                        if (provider.canPrint == false) {
8620                            console.log("PDF printing is disabled.");
8621                            app.options.showPrintControl = app.options.showPrintControl && provider.canPrint;
8622                        }
8623                    }
8624                }).finally(function() {
8625                    provider._documentLoaded();
8626                });
8627            }
8628        },
8629        {
8630            key: "processPage",
8631            value: function processPage(param) {
8632                var app = this.app, provider = this, pageNumber = param.pageNumber, startTime = performance.now();
8633                var dimen = app.viewer.getTextureSize(param);
8634                if (DEARFLIP.defaults.cachePDFTexture === true) {
8635                    if (this.getCache(pageNumber, dimen.height) !== undefined) {
8636                        app.applyTexture(this.getCache(pageNumber, dimen.height), param);
8637                        provider_utils.log("Texture loaded from cache for : " + pageNumber);
8638                        return;
8639                    }
8640                }
8641                //region determine page to render
8642                var pdfPageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber);
8643                //endregion
8644                provider_utils.log("Requesting PDF Page:" + pdfPageNumberToRender);
8645                provider.pdfDocument.getPage(pdfPageNumberToRender).then(function(pdfPage) {
8646                    if (!provider.viewPorts[pageNumber]) {
8647                        param.isFreshPage = true;
8648                        provider.viewPorts[pageNumber] = pdfPage.getViewport({
8649                            scale: 1,
8650                            rotation: pdfPage._pageInfo.rotate + app.options.pageRotation
8651                        });
8652                    }
8653                    //region Render the Page
8654                    var renderContext = app.viewer.getRenderContext(pdfPage, param);
8655                    if (param.isFreshPage) {
8656                        var _app_viewer_getPageByNumber;
8657                        (_app_viewer_getPageByNumber = app.viewer.getPageByNumber(param.pageNumber)) === null || _app_viewer_getPageByNumber === void 0 ? void 0 : _app_viewer_getPageByNumber.changeTexture(param.pageNumber, renderContext.canvas.height);
8658                    }
8659                    provider_utils.log("Page " + pageNumber + " rendering - " + renderContext.canvas.width + "x" + renderContext.canvas.height);
8660                    param.trace = provider.requestIndex++;
8661                    provider.requestedPages += "," + param.trace + "[" + pdfPageNumberToRender + "|" + renderContext.canvas.height + "]";
8662                    pdfPage.cleanupAfterRender = false; //needs to disable the cleanup after render code in pdf.js
8663                    var pageRendering = pdfPage.render(renderContext);
8664                    pageRendering.promise.then(function() {
8665                        app.applyTexture(renderContext.canvas, param);
8666                        if (DEARFLIP.defaults.cachePDFTexture === true) {
8667                            provider.setCache(param.pageNumber, renderContext.canvas, dimen.height);
8668                        }
8669                        if (app.options.cleanupAfterRender === true) {
8670                            var checkString = "," + param.trace + "[" + pdfPageNumberToRender + "|" + renderContext.canvas.height + "]";
8671                            provider_utils.log("CleanUp Requesting for (" + pageNumber + ") actual " + pdfPageNumberToRender);
8672                            if (provider.requestedPages.indexOf(checkString) > -1) {
8673                                provider.requestedPages = provider.requestedPages.replace(checkString, "");
8674                                if (provider.requestedPages.indexOf("[" + pdfPageNumberToRender + "|") == -1) {
8675                                    provider_utils.log("CleanUp Passed for (" + pageNumber + ") actual " + pdfPageNumberToRender);
8676                                    provider.pagesToClean.push(pdfPage);
8677                                    if (provider.pagesToClean.length > 0) provider.cleanUpPages();
8678                                } else {
8679                                    provider_utils.log("CleanUp Cancelled waiting for (" + pageNumber + ") actual " + pdfPageNumberToRender + " : " + provider.requestedPages);
8680                                }
8681                            }
8682                        }
8683                        renderContext = null;
8684                        provider_utils.log("Rendered " + pageNumber + " in " + (performance.now() - startTime) + " milliseconds");
8685                    }).catch(function(error) {
8686                        console.log(error);
8687                    });
8688                //endregion
8689                }).catch(function(error) {
8690                    console.log(error);
8691                });
8692            }
8693        },
8694        {
8695            key: "cleanUpPages",
8696            value: function cleanUpPages() {
8697                while(this.pagesToClean.length > 0){
8698                    var page = this.pagesToClean.splice(-1)[0];
8699                    provider_utils.log("Cleanup Completed for PDF page: " + (page._pageIndex + 1));
8700                    page.cleanup();
8701                }
8702            }
8703        },
8704        {
8705            key: "clearSearch",
8706            value: function clearSearch() {
8707                var provider = this;
8708                provider.searchHits = [];
8709                provider.searchHitItemsCache = [];
8710                provider.totalHits = 0;
8711                provider.app.searchResults.html("");
8712                provider.app.container.removeClass("df-search-open");
8713                provider.textSearch = "";
8714                provider.app.container.find(".df-search-hits").remove();
8715            }
8716        },
8717        {
8718            key: "search",
8719            value: function search(text) {
8720                var provider = this;
8721                if (provider.textSearch === text) return;
8722                provider.clearSearch();
8723                if (text.length < 3 && text != "") {
8724                    provider.app.updateSearchInfo("Minimum 3 letters required.");
8725                    return;
8726                }
8727                provider.textSearch = text;
8728                provider.textSearchLength = text.length;
8729                provider.app.searchContainer.addClass("df-searching");
8730                provider.app.container.addClass('df-fetch-pdf');
8731                provider._search(text, 1);
8732            }
8733        },
8734        {
8735            key: "_search",
8736            value: function _search(text) {
8737                var pageNumber = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
8738                var provider = this;
8739                provider.app.updateSearchInfo("Searching Page: " + pageNumber);
8740                provider.searchPage(pageNumber).then(function(textContent) {
8741                    // console.log(textContent);
8742                    var searchString = textContent, pos = 0, myRegexp = new RegExp(text, 'gi'), result;
8743                    var hits = [];
8744                    while(result = myRegexp.exec(searchString)){
8745                        hits.push({
8746                            index: result.index,
8747                            length: provider.textSearchLength
8748                        });
8749                    }
8750                    provider.searchHits[pageNumber] = hits;
8751                    if (hits.length > 0) {
8752                        var searchPage = provider.app.viewer.searchPage(pageNumber);
8753                        if (searchPage.include === true) {
8754                            provider.totalHits += hits.length;
8755                            provider.app.searchResults.append('<div class="df-search-result ' + (provider.app.currentPageNumber === pageNumber ? 'df-active' : '') + '" data-df-page="' + pageNumber + '">' + '<span>Page ' + searchPage.label + '</span><span>' + hits.length + ' ' + (hits.length > 1 ? 'results' : 'result') + '</span></div>');
8756                        }
8757                    }
8758                    if (provider.app.viewer.isActivePage(pageNumber)) {
8759                        provider.processTextContent(pageNumber, provider.app.viewer.getTextElement(pageNumber, true));
8760                        provider.app.ui.update();
8761                    }
8762                    provider._search(text, pageNumber + 1);
8763                }).catch(function() {}).finally(function() {
8764                    if (provider.totalHits == 0) {
8765                        provider.app.updateSearchInfo("No results Found!");
8766                    } else {
8767                        provider.app.updateSearchInfo(provider.totalHits + " results found");
8768                    }
8769                    provider.app.searchContainer.removeClass("df-searching");
8770                    provider.app.container.removeClass('df-fetch-pdf');
8771                });
8772            }
8773        },
8774        {
8775            key: "prepareTextContent",
8776            value: function prepareTextContent(textContent, pageNumbertoSearch) {
8777                var rePrepare = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
8778                var provider = this;
8779                if (provider.textContentJoinedSearch[pageNumbertoSearch] == void 0 || rePrepare) {
8780                    var provider = this;
8781                    var item, p = 0, p_search = 0, len = 0;
8782                    provider.textContentSearch[pageNumbertoSearch] = [];
8783                    provider.textContent[pageNumbertoSearch] = [];
8784                    provider.textOffsetSearch[pageNumbertoSearch] = [];
8785                    provider.textOffset[pageNumbertoSearch] = [];
8786                    provider.textContentJoinedSearch[pageNumbertoSearch] = [];
8787                    provider.textContentJoined[pageNumbertoSearch] = [];
8788                    for(var item_count = 0; item_count < textContent.items.length; item_count++){
8789                        item = textContent.items[item_count];
8790                        provider.textContentSearch[pageNumbertoSearch].push(item.hasEOL === true ? item.str + " " : item.str);
8791                        provider.textContent[pageNumbertoSearch].push(item.str + " ");
8792                        len = (item.str.length || 0) + (item.hasEOL === true ? 1 : 0);
8793                        p_search += len;
8794                        provider.textOffsetSearch[pageNumbertoSearch].push({
8795                            length: len,
8796                            offset: p_search - len
8797                        });
8798                        len = (item.str.length || 0) + 1;
8799                        p += len;
8800                        provider.textOffset[pageNumbertoSearch].push({
8801                            length: len,
8802                            offset: p - len
8803                        });
8804                    }
8805                    provider.textContentJoinedSearch[pageNumbertoSearch] = provider.textContentSearch[pageNumbertoSearch].join("");
8806                    provider.textContentJoined[pageNumbertoSearch] = provider.textContent[pageNumbertoSearch].join("");
8807                }
8808            }
8809        },
8810        {
8811            key: "searchPage",
8812            value: function searchPage(pageNumber) {
8813                var provider = this;
8814                return new Promise(function(resolve, reject) {
8815                    if (!provider._isValidPage(pageNumber)) {
8816                        reject();
8817                    } else {
8818                        try {
8819                            var pageNumbertoSearch = provider.app.viewer.getDocumentPageNumber(pageNumber);
8820                            if (provider.textContentJoinedSearch[pageNumbertoSearch] == void 0) {
8821                                provider.pdfDocument.getPage(pageNumbertoSearch).then(function(page) {
8822                                    page.getTextContent().then(function(textContent) {
8823                                        provider.prepareTextContent(textContent, pageNumbertoSearch);
8824                                        resolve(provider.textContentJoinedSearch[pageNumbertoSearch]);
8825                                    });
8826                                });
8827                            } else {
8828                                resolve(provider.textContentJoinedSearch[pageNumbertoSearch]);
8829                            }
8830                        } catch (error) {
8831                            provider_utils.log(error);
8832                            reject(error);
8833                        }
8834                    }
8835                });
8836            }
8837        }
8838    ]);
8839    return PDFDocumentProvider;
8840}(DocumentProvider);
8841defaults_DEARVIEWER.providers['pdf'] = PDFDocumentProvider;
8842
8843
8844;// CONCATENATED MODULE: ./src/js/dearviewer/utils/image-provider.js
8845function image_provider_assert_this_initialized(self) {
8846    if (self === void 0) {
8847        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
8848    }
8849    return self;
8850}
8851function image_provider_class_call_check(instance, Constructor) {
8852    if (!(instance instanceof Constructor)) {
8853        throw new TypeError("Cannot call a class as a function");
8854    }
8855}
8856function image_provider_defineProperties(target, props) {
8857    for(var i = 0; i < props.length; i++){
8858        var descriptor = props[i];
8859        descriptor.enumerable = descriptor.enumerable || false;
8860        descriptor.configurable = true;
8861        if ("value" in descriptor) descriptor.writable = true;
8862        Object.defineProperty(target, descriptor.key, descriptor);
8863    }
8864}
8865function image_provider_create_class(Constructor, protoProps, staticProps) {
8866    if (protoProps) image_provider_defineProperties(Constructor.prototype, protoProps);
8867    if (staticProps) image_provider_defineProperties(Constructor, staticProps);
8868    return Constructor;
8869}
8870function image_provider_get_prototype_of(o) {
8871    image_provider_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o
8871) {
8872        return o.__proto__ || Object.getPrototypeOf(o);
8873    };
8874    return image_provider_get_prototype_of(o);
8875}
8876function image_provider_inherits(subClass, superClass) {
8877    if (typeof superClass !== "function" && superClass !== null) {
8878        throw new TypeError("Super expression must either be null or a function");
8879    }
8880    subClass.prototype = Object.create(superClass && superClass.prototype, {
8881        constructor: {
8882            value: subClass,
8883            writable: true,
8884            configurable: true
8885        }
8886    });
8887    if (superClass) image_provider_set_prototype_of(subClass, superClass);
8888}
8889function image_provider_possible_constructor_return(self, call) {
8890    if (call && (image_provider_type_of(call) === "object" || typeof call === "function")) {
8891        return call;
8892    }
8893    return image_provider_assert_this_initialized(self);
8894}
8895function image_provider_set_prototype_of(o, p) {
8896    image_provider_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
8897        o.__proto__ = p;
8898        return o;
8899    };
8900    return image_provider_set_prototype_of(o, p);
8901}
8902function image_provider_type_of(obj) {
8903    "@swc/helpers - typeof";
8904    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
8905}
8906function image_provider_is_native_reflect_construct() {
8907    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
8908    if (Reflect.construct.sham) return false;
8909    if (typeof Proxy === "function") return true;
8910    try {
8911        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
8912        return true;
8913    } catch (e) {
8914        return false;
8915    }
8916}
8917function image_provider_create_super(Derived) {
8918    var hasNativeReflectConstruct = image_provider_is_native_reflect_construct();
8919    return function _createSuperInternal() {
8920        var Super = image_provider_get_prototype_of(Derived), result;
8921        if (hasNativeReflectConstruct) {
8922            var NewTarget = image_provider_get_prototype_of(this).constructor;
8923            result = Reflect.construct(Super, arguments, NewTarget);
8924        } else {
8925            result = Super.apply(this, arguments);
8926        }
8927        return image_provider_possible_constructor_return(this, result);
8928    };
8929}
8930
8931
8932var image_provider_utils = defaults_DEARVIEWER.utils;
8933var ImagePage = /*#__PURE__*/ function() {
8934    "use strict";
8935    function ImagePage(props) {
8936        image_provider_class_call_check(this, ImagePage);
8937        this._viewPort = new Viewport(0, 0);
8938        this._pageInfo = {
8939            rotate: 0
8940        };
8941        this.src = props.src;
8942    }
8943    image_provider_create_class(ImagePage, [
8944        {
8945            key: "getViewport",
8946            value: function getViewport() {
8947                var params = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
8948                    scale: 1
8949                };
8950                return new Viewport(this._viewPort.height * params.scale, this._viewPort.width * params.scale, params.scale);
8951            }
8952        }
8953    ]);
8954    return ImagePage;
8955}();
8956var ImageDocument = /*#__PURE__*/ function() {
8957    "use strict";
8958    function ImageDocument(source) {
8959        image_provider_class_call_check(this, ImageDocument);
8960        this.source = [];
8961        this.pages = [];
8962        this.numPages = source.length;
8963        for(var _correct = 0; _correct < source.length; _correct++){
8964            this.source[_correct] = image_provider_utils.httpsCorrection(source[_correct].toString());
8965            this.pages.push(new ImagePage({
8966                src: this.source[_correct]
8967            }));
8968        }
8969    }
8970    image_provider_create_class(ImageDocument, [
8971        {
8972            key: "getPage",
8973            value: function getPage(pageNumber) {
8974                var provider = this;
8975                return new Promise(function(resolve, reject) {
8976                    try {
8977                        jQuery("<img/>").attr("src", provider.source[pageNumber - 1]).prop("crossOrigin", "Anonymous").on('load', function() {
8978                            jQuery(this).off();
8979                            var page = new ImagePage({
8980                                src: this.src
8981                            });
8982                            page._viewPort.height = this.height;
8983                            page._viewPort.width = this.width;
8984                            page._viewPort.scale = 1;
8985                            page.image = this;
8986                            resolve(page);
8987                        });
8988                    } catch (error) {
8989                        reject(error);
8990                    }
8991                });
8992            }
8993        }
8994    ]);
8995    return ImageDocument;
8996}();
8997var Viewport = /*#__PURE__*/ function() {
8998    "use strict";
8999    function Viewport(height, width) {
9000        var scale = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
9001        image_provider_class_call_check(this, Viewport);
9002        this.scale = scale;
9003        this.height = height;
9004        this.width = width;
9005        this.scale = scale;
9006        this.transform = [
9007            0,
9008            0,
9009            0,
9010            0,
9011            0,
9012            this.height
9013        ];
9014    }
9015    image_provider_create_class(Viewport, [
9016        {
9017            key: "clone",
9018            value: function clone() {
9019                return new Viewport(this.height, this.width, this.scale);
9020            }
9021        }
9022    ]);
9023    return Viewport;
9024}();
9025var ImageDocumentProvider = /*#__PURE__*/ function(DocumentProvider) {
9026    "use strict";
9027    image_provider_inherits(ImageDocumentProvider, DocumentProvider);
9028    var _super = image_provider_create_super(ImageDocumentProvider);
9029    function ImageDocumentProvider(options, context) {
9030        image_provider_class_call_check(this, ImageDocumentProvider);
9031        var _this;
9032        _this = _super.call(this, options, context);
9033        var app = _this.app, provider = image_provider_assert_this_initialized(_this);
9034        provider.document = new ImageDocument(app.options.source);
9035        provider.pageCount = provider.document.numPages;
9036        provider.numPages = provider.document.numPages;
9037        provider.loadDocument();
9038        return _this;
9039    }
9040    image_provider_create_class(ImageDocumentProvider, [
9041        {
9042            key: "dispose",
9043            value: function dispose() {}
9044        },
9045        {
9046            key: "loadDocument",
9047            value: function loadDocument() {
9048                var app = this.app, options = this.app.options, provider = this;
9049                provider.document.getPage(1).then(function(page) {
9050                    provider.defaultPage = page;
9051                    var _defaultViewPort = provider.defaultPage.viewPort = page._viewPort;
9052                    var _defaultPageRatio = provider.defaultPage.pageRatio = _defaultViewPort.width / _defaultViewPort.height;
9053                    var _isdefaultPageWide = _defaultPageRatio > 1;
9054                    provider.viewPorts[1] = _defaultViewPort;
9055                    app.dimensions.defaultPage = {
9056                        ratio: _defaultPageRatio,
9057                        viewPort: _defaultViewPort,
9058                        width: _defaultViewPort.width,
9059                        height: _defaultViewPort.height
9060                    };
9061                    var _options_maxTextureSize;
9062                    app.dimensions.maxTextureHeight = ((_options_maxTextureSize = options.maxTextureSize) !== null && _options_maxTextureSize !== void 0 ? _options_maxTextureSize : 3200) / (!_isdefaultPageWide ? 1 : _defaultPageRatio);
9063                    app.dimensions.maxTextureWidth = app.dimensions.maxTextureHeight * _defaultPageRatio;
9064                    app.dimensions.autoHeightRatio = 1 / _defaultPageRatio;
9065                    provider._page1Pass = true;
9066                    provider.pagesLoaded();
9067                });
9068                //check if internal pages are of double sizes.
9069                if (provider.pageCount > 1 && app.checkSecondPage === true) {
9070                    provider.document.getPage(2).then(function(page) {
9071                        var _page2ViewPort = page._viewPort;
9072                        provider._page2Ratio = _page2ViewPort.width / _page2ViewPort.height;
9073                        provider.viewPorts[2] = _page2ViewPort;
9074                        provider._page2Pass = true;
9075                        provider.pagesLoaded();
9076                    });
9077                } else {
9078                    provider._page2Pass = true;
9079                    provider.pagesLoaded();
9080                }
9081            }
9082        },
9083        {
9084            key: "finalize",
9085            value: function finalize() {
9086                var app = this.app, provider = this;
9087                if (app === null || app.options === null) return;
9088                provider.linkService = new PDFLinkService();
9089                // provider.linkService.setDocument(provider.pdfDocument, null);
9090                provider.linkService.setViewer(app);
9091                provider._documentLoaded();
9092            }
9093        },
9094        {
9095            key: "processPage",
9096            value: function processPage(param) {
9097                var app = this.app, provider = this, pageNumber = param.pageNumber, startTime = performance.now();
9098                //region determine page to render
9099                var pdfPageNumberToRender = app.viewer.getDocumentPageNumber(pageNumber);
9100                image_provider_utils.log("Requesting PDF Page:" + pdfPageNumberToRender);
9101                provider.document.getPage(pdfPageNumberToRender).then(function(page) {
9102                    if (!provider.viewPorts[pageNumber]) {
9103                        param.isFreshPage = true;
9104                        provider.viewPorts[pageNumber] = page._viewPort;
9105                    }
9106                    var renderContext = app.viewer.getRenderContext(page, param);
9107                    if (param.isFreshPage) {
9108                        var _app_viewer_getPageByNumber;
9109                        (_app_viewer_getPageByNumber = app.viewer.getPageByNumber(param.pageNumber)) === null || _app_viewer_getPageByNumber === void 0 ? void 0 : _app_viewer_getPageByNumber.changeTexture(param.pageNumber, renderContext.canvas.height);
9110                    }
9111                    param.preferCanvas = true;
9112                    if (param.preferCanvas === true) {
9113                        var context = renderContext.canvas.getContext("2d");
9114                        var _renderContext_viewport_widthFix;
9115                        context.drawImage(page.image, renderContext.viewport.transform[4], 0, renderContext.canvas.width * ((_renderContext_viewport_widthFix = renderContext.viewport.widthFix) !== null && _renderContext_viewport_widthFix !== void 0 ? _renderContext_viewport_widthFix : 1), renderContext.canvas.height);
9116                        //todo cleanup page.image , don't keep in memory
9117                        app.applyTexture(renderContext.canvas, param);
9118                    } else {
9119                        app.applyTexture({
9120                            src: page.src,
9121                            height: renderContext.canvas.height,
9122                            width: renderContext.canvas.width
9123                        }, param);
9124                    }
9125                    image_provider_utils.log("Rendered " + pageNumber + " in " + (performance.now() - startTime) + " milliseconds");
9126                });
9127            }
9128        }
9129    ]);
9130    return ImageDocumentProvider;
9131}(DocumentProvider);
9132defaults_DEARVIEWER.providers['image'] = ImageDocumentProvider;
9133
9134
9135// EXTERNAL MODULE: ./src/js/dearviewer/utils/tween.js
9136var tween = __webpack_require__(101);
9137;// CONCATENATED MODULE: ./src/js/dearviewer/utils/controls.js
9138/* globals jQuery */ function controls_class_call_check(instance, Constructor) {
9139    if (!(instance instanceof Constructor)) {
9140        throw new TypeError("Cannot call a class as a function");
9141    }
9142}
9143function controls_defineProperties(target, props) {
9144    for(var i = 0; i < props.length; i++){
9145        var descriptor = props[i];
9146        descriptor.enumerable = descriptor.enumerable || false;
9147        descriptor.configurable = true;
9148        if ("value" in descriptor) descriptor.writable = true;
9149        Object.defineProperty(target, descriptor.key, descriptor);
9150    }
9151}
9152function controls_create_class(Constructor, protoProps, staticProps) {
9153    if (protoProps) controls_defineProperties(Constructor.prototype, protoProps);
9154    if (staticProps) controls_defineProperties(Constructor, staticProps);
9155    return Constructor;
9156}
9157function controls_type_of(obj) {
9158    "@swc/helpers - typeof";
9159    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
9160}
9161
9162var controls_DV = (/* unused pure expression or super */ null && (DEARVIEWER));
9163var controls_jQuery = defaults_DEARVIEWER.jQuery;
9164var controls_utils = defaults_DEARVIEWER.utils, REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS;
9165var UI = /*#__PURE__*/ function() {
9166    "use strict";
9167    function UI(options, appContext) {
9168        controls_class_call_check(this, UI);
9169        this.options = options;
9170        this.app = appContext;
9171        this.parentElement = this.app.container;
9172        this.element = controls_jQuery('<div>', {
9173            class: "df-ui"
9174        });
9175        this.leftElement = controls_jQuery('<div>', {
9176            class: "df-ui-left"
9177        }).appendTo(this.element);
9178        this.centerElement = controls_jQuery('<div>', {
9179            class: "df-ui-center"
9180        }).appendTo(this.element);
9181        this.rightElement = controls_jQuery('<div>', {
9182            class: "df-ui-right"
9183        }).appendTo(this.element);
9184        this.parentElement.append(this.element);
9185        this.events = {};
9186        this.controls = {};
9187    }
9188    controls_create_class(UI, [
9189        {
9190            key: "init",
9191            value: function init() {
9192                var ui = this, div = '<div>', app = this.app, controls = this.controls;
9193                var text = app.options.text, icons = app.options.icons;
9194                ui.createLogo();
9195                this.openRight = controls.openRight = controls_jQuery(div, {
9196                    class: "df-ui-nav df-ui-next",
9197                    title: app.isRTL ? text.previousPage : text.nextPage,
9198                    html: '<div class="df-ui-btn ' + icons['next'] + '"></div>'
9199                }).on("click", function() {
9200                    app.openRight();
9201                });
9202                this.openLeft = controls.openLeft = controls_jQuery(div, {
9203                    class: "df-ui-nav df-ui-prev",
9204                    title: app.isRTL ? text.nextPage : text.previousPage,
9205                    html: '<div class="df-ui-btn ' + icons['prev'] + '"></div>'
9206                }).on("click", function() {
9207                    app.openLeft();
9208                });
9209                if (app.options.autoPlay == true) {
9210                    this.play = controls.play = controls_utils.createBtn('play', icons['play'], text.play).on("click", function() {
9211                        var el = controls_jQuery(this);
9212                        app.setAutoPlay(!el.hasClass(app.options.icons['pause']));
9213                    });
9214                    app.setAutoPlay(app.options.autoPlayStart);
9215                }
9216                this.pageNumber = controls.pageNumber = controls_utils.createBtn('page').on("change", function() {
9217                    app.gotoPageLabel(controls.pageInput.val());
9218                }).on("keyup", function(event) {
9219                    if (event.keyCode === 13) {
9220                        app.gotoPageLabel(controls.pageInput.val());
9221                    }
9222                });
9223                var rnd_id = "df_book_page_number_" + Math.ceil(performance.now() / 10);
9224                this.pageInput = controls.pageInput = controls_jQuery('<input id="' + rnd_id + '" type="text"/>').appendTo(controls.pageNumber);
9225                this.pageLabel = controls.pageLabel = controls_jQuery('<label for="' + rnd_id + '"></label>').appendTo(controls.pageNumber);
9226                this.thumbnail = controls.thumbnail = controls_utils.createBtn('thumbnail', icons['thumbnail'], text.toggleThumbnails);
9227                controls.thumbnail.on("click", function() {
9228                    var el = controls_jQuery(this);
9229                    if (app.thumblist == null) {
9230                        app.initThumbs();
9231                    }
9232                    var thumbContainer = app.thumbContainer;
9233                    thumbContainer.toggleClass("df-sidemenu-visible");
9234                    el.toggleClass('df-active');
9235                    if (el.hasClass("df-active")) {
9236                        el.siblings(".df-active").trigger("click");
9237                        app.thumbRequestStatus = REQUEST_STATUS.ON;
9238                    }
9239                    ui.update();
9240                    if (app.options.sideMenuOverlay === false) app.resizeRequestStart();
9241                }).addClass("df-sidemenu-trigger");
9242                if (app.hasOutline()) {
9243                    this.outline = controls.outline = controls_utils.createBtn('outline', icons['outline'], text.toggleOutline);
9244                    controls.outline.on("click", function() {
9245                        var el = controls_jQuery(this);
9246                        if (app.outlineViewer == null) {
9247                            app.initOutline();
9248                        }
9249                        if (app.outlineContainer) {
9250                            var outlineContainer = app.outlineContainer;
9251                            el.toggleClass('df-active');
9252                            outlineContainer.toggleClass("df-sidemenu-visible");
9253                            if (el.hasClass("df-active")) {
9254                                el.siblings(".df-active").trigger("click");
9255                            }
9256                            ui.update();
9257                            if (app.options.sideMenuOverlay === false) app.resizeRequestStart();
9258                        }
9259                    }).addClass("df-sidemenu-trigger");
9260                }
9261                if (app.options.showSearchControl === true && controls_utils.isMobile !== true && typeof app.options.source === 'string') {
9262                    controls.search = controls_utils.createBtn('search', icons['search'], text.search);
9263                    controls.search.on("click", function() {
9264                        var el = controls_jQuery(this);
9265                        if (app.searchContainer == null) {
9266                            app.initSearch();
9267                        }
9268                        if (app.searchContainer) {
9269                            var searchContainer = app.searchContainer;
9270                            el.toggleClass('df-active');
9271                            searchContainer.toggleClass("df-sidemenu-visible");
9272                            if (el.hasClass("df-active")) {
9273                                el.siblings(".df-active").trigger("click");
9274                                app.searchBox.focus();
9275                            }
9276                            ui.update();
9277                            if (app.options.sideMenuOverlay === false) app.resizeRequestStart();
9278                        }
9279                    }).addClass("df-sidemenu-trigger");
9280                }
9281                var controlsContainer = ui.element;
9282                this.zoomIn = controls.zoomIn = controls_utils.createBtn('zoomin', icons['zoomin'], text.zoomIn).on("click", function() {
9283                    app.zoom(1);
9284                    ui.update();
9285                });
9286                this.zoomOut = controls.zoomOut = controls_utils.createBtn('zoomout', icons['zoomout'], text.zoomOut).on("click", function() {
9287                    app.zoom(-1);
9288                    ui.update();
9289                });
9290                this.resetZoom = controls.resetZoom = controls_utils.createBtn('resetzoom', icons['resetzoom'], text.resetZoom).on("click", function() {
9291                    app.resetZoom(-1);
9292                    ui.update();
9293                });
9294                /*PAGEMODE/PAGEFIT*/ if (app.viewer.isFlipBook) {
9295                    if (app.pageCount > 2) {
9296                        var isSingle = app.viewer.pageMode === defaults_DEARVIEWER.FLIPBOOK_PAGE_MODE.SINGLE;
9297                        this.pageMode = controls.pageMode = controls_utils.createBtn('pagemode', icons[isSingle ? 'doublepage' : 'singlepage'], isSingle ? text.doublePageMode : text.singlePageMode).on("click", function() {
9298                            var el = controls_jQuery(this);
9299                            app.viewer.setPageMode({
9300                                isSingle: !el.hasClass(icons['doublepage'])
9301                            });
9302                            app.viewer.pageModeChangedManually = true;
9303                        });
9304                    }
9305                } else {
9306                    this.pageFit = controls.pageFit = controls_utils.createBtn('pagefit', icons['pagefit'], text.pageFit).on("click", function() {
9307                        var pageFit = controls.pageFit;
9308                        var isPageFit = !pageFit.hasClass(icons['widthfit']);
9309                        if (isPageFit === true) {
9310                            pageFit.addClass(icons['widthfit']);
9311                            pageFit.html("<span>" + text.widthFit + "</span>");
9312                            pageFit.attr("title", text.widthFit);
9313                        } else {
9314                            pageFit.removeClass(icons['widthfit']);
9315                            pageFit.html("<span>" + text.pageFit + "</span>");
9316                            pageFit.attr("title", text.pageFit);
9317                        }
9318                    // jQuery(this).toggleClass(buttonClass + " " + uiClass + "-widthfit ");
9319                    });
9320                }
9321                ui.shareBox = new DV_Share(app.container, app.options);
9322                this.share = controls.share = controls_utils.createBtn('share', icons['share'], text.share).on("click", function() {
9323                    if (ui.shareBox.isOpen === true) ui.shareBox.close();
9324                    else {
9325                        ui.shareBox.update(app.getURLHash());
9326                        ui.shareBox.show();
9327                    }
9328                });
9329                //More button
9330                this.more = controls.more = controls_utils.createBtn('more', icons['more']).on("click", function(event) {
9331                    if (ui.moreContainerOpen !== true) {
9332                        controls_jQuery(this).addClass("df-active");
9333                        ui.moreContainerOpen = true;
9334                        event.stopPropagation();
9335                    }
9336                });
9337                this.startPage = controls.startPage = controls_utils.createBtn('start', icons['start'], text.gotoFirstPage).on("click", function() {
9338                    app.start();
9339                });
9340                this.endPage = controls.endPage = controls_utils.createBtn('end', icons['end'], text.gotoLastPage).on("click", function() {
9341                    app.end();
9342                });
9343                if (app.options.showPrintControl === true && controls_utils.isMobile !== true && typeof app.options.source === 'string') {
9344                    this.print = controls.print = controls_utils.createBtn('print', icons['print'], text.print).on("click", function() {
9345                        defaults_DEARVIEWER.printHandler = defaults_DEARVIEWER.printHandler || new PrintHandler();
9346                        defaults_DEARVIEWER.printHandler.printPDF(app.options.source);
9347                    });
9348                }
9349                if (app.options.showDownloadControl === true && typeof app.options.source === 'string') {
9350                    var downloadClass = "df-ui-btn df-ui" + "-download " + icons['download'];
9351                    this.download = controls.download = controls_jQuery('<a download target="_blank" class="' + downloadClass + '"><span>' + text.downloadPDFFile + '</span></a>');
9352                    controls.download.attr("href", controls_utils.httpsCorrection(app.options.source)).attr("title", text.downloadPDFFile);
9353                //moreContainer.append(download);
9354                }
9355                //endregion
9356                //region MoreContainer
9357                ui.moreContainer = controls_jQuery(div, {
9358                    class: "df-more-container"
9359                });
9360                controls.more.append(ui.moreContainer);
9361                //endregion
9362                if (!(app.options.isLightBox === true && app.fullscreenSupported !== true)) {
9363                    this.fullScreen = controls.fullScreen = controls_utils.createBtn('fullscreen', icons['fullscreen'], text.toggleFullscreen).on("click", app.switchFullscreen.bind(app));
9364                }
9365                app.viewer.initCustomControls();
9366                /**
9367     * Controls position and placement is determined by options.moreControls and options.hideControls
9368     */ var allControls = app.options.allControls.replace(/ /g, '').split(','), moreControls = ',' + app.options.moreControls.replace(/ /g, '') + ',', hideControls = ',' + app.options.hideControls.replace(/ /g, '') + ',', leftControls = ',' + app.options.leftControls.replace(/ /g, '') + ',', rightControls = ',' + app.options.rightControls.replace(/ /g, '') + ',', devControls = ','; // + app.options.devControls.replace(/ /g, '') + ',';
9369                // if (utils.isIOS) {
9370                //   hideControls += ",fullScreen,";
9371                // }
9372                hideControls += devControls;
9373                for(var controlCount = 0; controlCount < allControls.length; controlCount++){
9374                    //if hidden skip
9375                    var controlName = allControls[controlCount];
9376                    if (hideControls.indexOf(',' + controlName + ',') < 0) {
9377                        var control = controls[controlName];
9378                        if (control != null && (typeof control === "undefined" ? "undefined" : controls_type_of(control)) == "object") {
9379                            if (moreControls.indexOf(',' + controlName + ',') > -1 && controlName !== 'more' && controlName !== 'pageNumber') {
9380                                ui.moreContainer.append(control);
9381                            } else if (app.options.controlsFloating == true) {
9382                                controlsContainer.append(control);
9383                            } else {
9384                                this.centerElement.append(control);
9385                            }
9386                        }
9387                    }
9388                }
9389                if (ui.moreContainer.children().length == 0) {
9390                    this.more.addClass("df-hidden");
9391                }
9392                app.container.append(controlsContainer);
9393                app.container.append(controls.openLeft);
9394                app.container.append(this.controls.openRight);
9395                //register a click event on window to close the more-options and search options
9396                window.addEventListener('click', ui.events.closePanels = ui.closePanels.bind(ui), false);
9397                window.addEventListener('keyup', ui.events.keyup = ui.keyUp.bind(ui), false);
9398                document.addEventListener('fullscreenchange', ui.events.fullscreenChange = ui.fullscreenChange.bind(u
9398i), false);
9399                if (app.options.autoOpenThumbnail === true) {
9400                    ui.controls.thumbnail.trigger("click");
9401                }
9402                if (app.hasOutline() && app.options.autoOpenOutline === true) {
9403                    ui.controls.outline.trigger("click");
9404                }
9405                app.executeCallback('onCreateUI');
9406            }
9407        },
9408        {
9409            key: "closePanels",
9410            value: function closePanels(event) {
9411                if (this.moreContainerOpen === true) {
9412                    var _this_controls_more;
9413                    (_this_controls_more = this.controls.more) === null || _this_controls_more === void 0 ? void 0 : _this_controls_more.removeClass("df-active");
9414                    this.moreContainerOpen = false;
9415                }
9416            }
9417        },
9418        {
9419            key: "fullscreenChange",
9420            value: function fullscreenChange(event) {
9421                var isExit = controls_utils.getFullscreenElement() === void 0;
9422                if (isExit && this.app.isFullscreen === true) {
9423                    this.app.switchFullscreen();
9424                }
9425            }
9426        },
9427        {
9428            key: "keyUp",
9429            value: function keyUp(event) {
9430                var ui = this, app = this.app;
9431                //bail out if the keys are getting entered in some input box.
9432                if (event.target.nodeName === "INPUT") return;
9433                var navKeysValid = app.isFullscreen === true || app.options.isLightBox === true || app.options.arrowKeysAction === defaults_DEARVIEWER.ARROW_KEYS_ACTIONS.NAV;
9434                switch(event.keyCode){
9435                    case 27:
9436                        if (defaults_DEARVIEWER.activeLightBox && defaults_DEARVIEWER.activeLightBox.app && !controls_utils.isChromeExtension()) {
9437                            defaults_DEARVIEWER.activeLightBox.closeButton.trigger("click");
9438                        }
9439                        break;
9440                    case 37:
9441                        if (navKeysValid) app.openLeft();
9442                        break;
9443                    case 39:
9444                        if (navKeysValid) app.openRight();
9445                        break;
9446                    default:
9447                        break;
9448                }
9449            }
9450        },
9451        {
9452            key: "createLogo",
9453            value: function createLogo() {
9454                var app = this.app;
9455                var logo = null;
9456                if (app.options.logo.indexOf("<") > -1) {
9457                    logo = controls_jQuery(app.options.logo).addClass("df-logo df-logo-html");
9458                } else if (app.options.logo.trim().length > 2) {
9459                    logo = controls_jQuery('<a class="df-logo df-logo-img" target="_blank" href="' + app.options.logoUrl + '"><img alt="" src="' + app.options.logo + '"/>');
9460                }
9461                this.element.append(logo);
9462            }
9463        },
9464        {
9465            key: "dispose",
9466            value: function dispose() {
9467                var ui = this;
9468                for(var key in this.controls){
9469                    if (this.controls.hasOwnProperty(key)) {
9470                        var control = this.controls[key];
9471                        if (control !== null && (typeof control === "undefined" ? "undefined" : controls_type_of(control)) == "object") control.off().remove();
9472                    }
9473                }
9474                ui.element.remove();
9475                ui.shareBox = controls_utils.disposeObject(ui.shareBox);
9476                window.removeEventListener('click', ui.events.closePanels, false);
9477                window.removeEventListener('keyup', ui.events.keyup, false);
9478                document.removeEventListener('fullscreenchange', ui.events.fullscreenChange, false);
9479            }
9480        },
9481        {
9482            key: "update",
9483            value: function update() {
9484                var app = this.app, controls = this.controls;
9485                if (this._pageLabelWidthSet !== true) {
9486                    //https://github.com/deepak-ghimire/dearviewer/issues/349
9487                    this.pageLabel.width("");
9488                    if (app.provider.pageLabels) {
9489                        this.pageLabel.html("88888888888888888".substring(0, app.pageCount.toString().length * 3 + 4));
9490                    } else {
9491                        this.pageLabel.html("88888888888".substring(0, app.pageCount.toString().length * 2 + 3));
9492                    }
9493                    this.pageNumber.width(this.pageLabel.width());
9494                    this.pageLabel.width(this.pageLabel.width());
9495                    this.pageLabel.html("");
9496                    this._pageLabelWidthSet = true;
9497                }
9498                var pageLabel = app.getCurrentLabel();
9499                if (pageLabel.toString() !== app.currentPageNumber.toString()) {
9500                    controls.pageLabel.html(pageLabel + "(" + app.currentPageNumber + "/" + app.pageCount + ")");
9501                } else {
9502                    controls.pageLabel.html(pageLabel + "/" + app.pageCount);
9503                }
9504                controls.pageInput.val(pageLabel);
9505                app.container.toggleClass("df-sidemenu-open", app.container.find(".df-sidemenu-visible").length > 0);
9506                var isSearchOpen = app.provider.totalHits > 0 && app.container.find(".df-sidemenu-visible.df-search-container").length > 0;
9507                app.container.toggleClass("df-search-open", isSearchOpen);
9508                if (isSearchOpen) {
9509                    var targetSearchresult = app.searchContainer.find(".df-search-result[data-df-page=" + app.currentPageNumber + "]");
9510                    app.searchContainer.find(".df-search-result.df-active").removeClass("df-active");
9511                    if (targetSearchresult.length > 0 && !targetSearchresult.hasClass(".df-active")) {
9512                        targetSearchresult.addClass("df-active");
9513                        var searchWrapper = app.searchResults[0];
9514                        var searchWrapperScrollTop = searchWrapper.scrollTop, searchWrapperScrollHeight = searchWrapper.getBoundingClientRect().height;
9515                        targetSearchresult = targetSearchresult[0];
9516                        //when the thumb is below the display area scroll so that just it's fully visible
9517                        if (searchWrapperScrollTop + searchWrapperScrollHeight < targetSearchresult.offsetTop + targetSearchresult.scrollHeight) controls_utils.scrollIntoView(targetSearchresult, null, false);
9518                        else if (searchWrapperScrollTop > targetSearchresult.offsetTop) controls_utils.scrollIntoView(targetSearchresult);
9519                    }
9520                }
9521                controls.zoomIn.toggleClass("disabled", app.zoomValue === app.viewer.maxZoom);
9522                controls.zoomOut.toggleClass("disabled", app.zoomValue === app.viewer.minZoom);
9523                var isRTL = app.isRTL, isStart = app.currentPageNumber === app.startPage, isEnd = app.currentPageNumber === app.endPage;
9524                var noPrev = isStart && !isRTL || isEnd && isRTL, noNext = isEnd && !isRTL || isStart && isRTL;
9525                controls.openRight.toggleClass("df-hidden", noNext);
9526                controls.openLeft.toggleClass("df-hidden", noPrev);
9527                app.viewer.afterControlUpdate();
9528            }
9529        }
9530    ]);
9531    return UI;
9532}();
9533var DV_Share = /*#__PURE__*/ function() {
9534    "use strict";
9535    function DV_Share(container, options) {
9536        controls_class_call_check(this, DV_Share);
9537        var dfShare = this;
9538        dfShare.isOpen = false;
9539        dfShare.shareUrl = "";
9540        dfShare.init(container, options);
9541    }
9542    controls_create_class(DV_Share, [
9543        {
9544            key: "init",
9545            value: function init(container, options) {
9546                var _loop = function(shareKey) {
9547                    if (options.share.hasOwnProperty(shareKey) && options.hideShareControls.indexOf(shareKey) < 0) {
9548                        var shareTemplate = options.share[shareKey];
9549                        if (shareTemplate !== null) {
9550                            dfShare[shareKey] = controls_jQuery('<div>', {
9551                                class: shareButtonClass + " df-share-" + shareKey + " " + options.icons[shareKey]
9552                            }).on("click", function(e) {
9553                                e.preventDefault();
9554                                window.open(shareTemplate.replace("{{url}}", encodeURIComponent(dfShare.shareUrl)).replace("{{mailsubject}}", options.text.mailSubject), "Sharer", windowParameters);
9555                                e.stopPropagation(); //so the default event is not cancelled by parent element
9556                            });
9557                            dfShare.box.append(dfShare[shareKey]);
9558                        }
9559                    }
9560                };
9561                var dfShare = this;
9562                var shareButtonClass = "df-share-button";
9563                var windowParameters = "width=500,height=400";
9564                dfShare.wrapper = controls_jQuery('<div class="df-share-wrapper" style="display: none;">').on("click", function() {
9565                    dfShare.close();
9566                });
9567                dfShare.box = controls_jQuery('<div class="df-share-box">');
9568                dfShare.box.on("click", function(e) {
9569                    e.preventDefault();
9570                    e.stopPropagation();
9571                });
9572                dfShare.box.appendTo(dfShare.wrapper).html('<span class="df-share-title">' + options.text.share + '</span>');
9573                dfShare.urlInput = controls_jQuery('<textarea name="df-share-url" class="df-share-url">').on("click", function() {
9574                    controls_jQuery(this).select();
9575                });
9576                dfShare.box.append(dfShare.urlInput);
9577                for(var shareKey in options.share)_loop(shareKey);
9578                controls_jQuery(container).append(dfShare.wrapper);
9579            }
9580        },
9581        {
9582            key: "show",
9583            value: function show() {
9584                this.wrapper.fadeIn(300);
9585                this.urlInput.val(this.shareUrl);
9586                this.urlInput.trigger("click");
9587                this.isOpen = true;
9588            }
9589        },
9590        {
9591            key: "dispose",
9592            value: function dispose() {
9593                var dfShare = this;
9594                for(var key in dfShare){
9595                    if (dfShare.hasOwnProperty(key)) {
9596                        if (dfShare[key] && dfShare[key].off) dfShare[key].off();
9597                    }
9598                }
9599                dfShare.wrapper.remove();
9600            }
9601        },
9602        {
9603            key: "close",
9604            value: function close() {
9605                this.wrapper.fadeOut(300);
9606                this.isOpen = false;
9607            }
9608        },
9609        {
9610            key: "update",
9611            value: function update(url) {
9612                this.shareUrl = url;
9613            }
9614        }
9615    ]);
9616    return DV_Share;
9617}();
9618var DVLightBox = /*#__PURE__*/ function() {
9619    "use strict";
9620    function DVLightBox(closeCallback) {
9621        controls_class_call_check(this, DVLightBox);
9622        this.duration = 300;
9623        //cache this
9624        var lightbox = this;
9625        //lightbox wrapper div
9626        lightbox.lightboxWrapper = controls_jQuery("<div>").addClass("df-lightbox-wrapper");
9627        //lightbox background
9628        lightbox.backGround = controls_jQuery("<div>").addClass("df-lightbox-bg").appendTo(lightbox.lightboxWrapper);
9629        //lightbox element
9630        lightbox.element = controls_jQuery("<div>").addClass("df-app").appendTo(lightbox.lightboxWrapper);
9631        //lightbox controls
9632        lightbox.controls = controls_jQuery("<div>").addClass("df-lightbox-controls").appendTo(lightbox.lightboxWrapper);
9633        //lightbox close button
9634        lightbox.closeButton = controls_jQuery("<div>").addClass("df-lightbox-close df-ui-btn " + defaults_DEARVIEWER.defaults.icons['close']).on("click", function() {
9635            lightbox.close(closeCallback);
9636        }
9636).appendTo(lightbox.controls);
9637        lightbox.lightboxWrapper.append(lightbox.element);
9638        return lightbox;
9639    }
9640    controls_create_class(DVLightBox, [
9641        {
9642            key: "show",
9643            value: function show(callback) {
9644                if (this.lightboxWrapper.parent().length === 0) controls_jQuery("body").append(this.lightboxWrapper);
9645                controls_jQuery("html,body").addClass("df-lightbox-open");
9646                this.lightboxWrapper.fadeIn(this.duration);
9647                if (typeof callback === "function") callback();
9648                return this;
9649            }
9650        },
9651        {
9652            key: "close",
9653            value: function close(callback) {
9654                this.lightboxWrapper.fadeOut(this.duration);
9655                Array.prototype.forEach.call(defaults_DEARVIEWER.utils.getSharePrefixes(), function(prefix) {
9656                    if (window.location.hash.indexOf("#" + prefix) === 0) history.replaceState(undefined, undefined, "#_");
9657                //window.location.hash = "#_";
9658                });
9659                if (typeof callback === "function") setTimeout(callback, this.duration);
9660                controls_jQuery("html,body").removeClass("df-lightbox-open");
9661                //cleanup any classes to remove old CSS classes
9662                this.element.attr("class", "df-app").attr("style", "");
9663                this.lightboxWrapper.attr("class", "df-lightbox-wrapper").attr("style", "");
9664                this.backGround.attr("style", "");
9665                return this;
9666            }
9667        }
9668    ]);
9669    return DVLightBox;
9670}();
9671var PrintHandler = /*#__PURE__*/ function() {
9672    "use strict";
9673    function PrintHandler() {
9674        controls_class_call_check(this, PrintHandler);
9675        //cache this
9676        var printHandler = this;
9677        printHandler.frame = controls_jQuery('<iframe id="df-print-frame" style="display:none">').appendTo(controls_jQuery("body"));
9678        printHandler.frame.on("load", function() {
9679            try {
9680                printHandler.frame[0].contentWindow.print();
9681            } catch (e) {
9682                console.log(e);
9683            }
9684        });
9685        return printHandler;
9686    }
9687    controls_create_class(PrintHandler, [
9688        {
9689            key: "printPDF",
9690            value: function printPDF(source) {
9691                this.frame[0].src = source;
9692            }
9693        }
9694    ]);
9695    return PrintHandler;
9696}();
9697var Sidemenu = /*#__PURE__*/ function() {
9698    "use strict";
9699    function Sidemenu(options, appContext) {
9700        controls_class_call_check(this, Sidemenu);
9701        this.options = options;
9702        this.app = appContext;
9703        this.parentElement = options.parentElement;
9704        this.element = controls_jQuery('<div>', {
9705            class: "df-sidemenu-wrapper"
9706        });
9707        this.parentElement.append(this.element);
9708        this.buttons = controls_jQuery('<div>', {
9709            class: "df-sidemenu-buttons df-ui-wrapper"
9710        }).appendTo(this.element);
9711        /*
9712        let icons = this.app.options.icons,
9713          text = this.app.options.text;
9714
9715        this.thumbnail = utils.createBtn('thumbnail', icons['thumbnail'], text.toggleThumbnails);
9716        this.outline = utils.createBtn('outline', icons['outline'], text.toggleOutline);*/ this.close = controls_utils.createBtn('close', appContext.options.icons['close'], appContext.options.text.close); //todo
9717        this.buttons.append(this.close);
9718    }
9719    controls_create_class(Sidemenu, [
9720        {
9721            key: "dispose",
9722            value: function dispose() {
9723                this.element.remove();
9724            }
9725        }
9726    ]);
9727    return Sidemenu;
9728}();
9729var BookMarkViewer = /*#__PURE__*/ function() {
9730    "use strict";
9731    function BookMarkViewer(options) {
9732        controls_class_call_check(this, BookMarkViewer);
9733        this.outline = null;
9734        this.lastToggleIsShow = true;
9735        this.container = options.container;
9736        this.linkService = options.linkService;
9737        this.outlineItemClass = options.outlineItemClass || "outlineItem";
9738        this.outlineToggleClass = options.outlineToggleClass || "outlineItemToggler";
9739        this.outlineToggleHiddenClass = options.outlineToggleHiddenClass || "outlineItemsHidden";
9740    }
9741    controls_create_class(BookMarkViewer, [
9742        {
9743            key: "dispose",
9744            value: function dispose() {
9745                if (this.container) {
9746                    if (this.container.parentNode) {
9747                        this.container.parentNode.removeChild(this.container);
9748                    }
9749                }
9750                this.linkService = null;
9751            }
9752        },
9753        {
9754            key: "reset",
9755            value: function reset() {
9756                this.outline = null;
9757                this.lastToggleIsShow = true;
9758                var container = this.container;
9759                while(container.firstChild){
9760                    container.removeChild(container.firstChild);
9761                }
9762            }
9763        },
9764        {
9765            /**
9766   * @private
9767   */ key: "_dispatchEvent",
9768            value: function _dispatchEvent(outlineCount) {
9769                var event = document.createEvent('CustomEvent');
9770                event.initCustomEvent('outlineloaded', true, true, {
9771                    outlineCount: outlineCount
9772                });
9773                this.container.dispatchEvent(event);
9774            }
9775        },
9776        {
9777            /**
9778   * @private
9779   */ key: "_bindLink",
9780            value: function _bindLink(element, item) {
9781                var linkService = this.linkService;
9782                if (item.custom === true) {
9783                    element.href = linkService.getCustomDestinationHash(item.dest);
9784                    element.onclick = function goToDestination() {
9785                        linkService.customNavigateTo(item.dest);
9786                        return false;
9787                    };
9788                } else {
9789                    if (item.url) {
9790                        pdfjsLib.addLinkAttributes(element, {
9791                            url: item.url
9792                        });
9793                        return;
9794                    }
9795                    element.href = linkService.getDestinationHash(item.dest);
9796                    element.onclick = function goToDestination() {
9797                        linkService.navigateTo(item.dest);
9798                        return false;
9799                    };
9800                }
9801            }
9802        },
9803        {
9804            /**
9805   * Prepend a button before an outline item which allows the user to toggle
9806   * the visibility of all outline items at that level.
9807   *
9808   * @private
9809   */ key: "_addToggleButton",
9810            value: function _addToggleButton(div) {
9811                var _bookMarkViewer = this;
9812                var toggler = document.createElement('div');
9813                toggler.className = this.outlineToggleClass + " " + this.outlineToggleHiddenClass;
9814                toggler.onclick = (function(event) {
9815                    event.stopPropagation();
9816                    toggler.classList.toggle(this.outlineToggleHiddenClass);
9817                    if (event.shiftKey) {
9818                        var shouldShowAll = !toggler.classList.contains(this.outlineToggleHiddenClass);
9819                        _bookMarkViewer._toggleOutlineItem(div, shouldShowAll);
9820                    }
9821                }).bind(this);
9822                div.insertBefore(toggler, div.firstChild);
9823            }
9824        },
9825        {
9826            /**
9827   * Toggle the visibility of the subtree of an outline item.
9828   *
9829   * @param {Element} root - the root of the outline (sub)tree.
9830   * @param {boolean} show - whether to show the outline (sub)tree. If false,
9831   *   the outline subtree rooted at |root| will be collapsed.
9832   *
9833   * @private
9834   */ key: "_toggleOutlineItem",
9835            value: function _toggleOutlineItem(root, show) {
9836                this.lastToggleIsShow = show;
9837                var togglers = root.querySelectorAll('.' + this.outlineToggleClass);
9838                for(var i = 0, ii = togglers.length; i < ii; ++i){
9839                    togglers[i].classList[show ? 'remove' : 'add'](this.outlineToggleHiddenClass);
9840                }
9841            }
9842        },
9843        {
9844            /**
9845   * @param {BookMarkViewerRenderParameters} params
9846   */ key: "render",
9847            value: function render(params) {
9848                var outline = params && params.outline || null;
9849                var outlineCount = 0;
9850                if (this.outline) {
9851                    this.reset();
9852                }
9853                this.outline = outline;
9854                if (!outline) {
9855                    //this._dispatchEvent(outlineCount);
9856                    return;
9857                }
9858                var fragment = document.createDocumentFragment();
9859                var queue = [
9860                    {
9861                        parent: fragment,
9862                        items: this.outline,
9863                        custom: false
9864                    }
9865                ];
9866                var hasAnyNesting = false;
9867                while(queue.length > 0){
9868                    var levelData = queue.shift();
9869                    var isCustom = levelData.custom;
9870                    for(var i = 0, len = levelData.items.length; i < len; i++){
9871                        var item = levelData.items[i];
9872                        var div = document.createElement('div');
9873                        div.className = this.outlineItemClass;
9874                        var element = document.createElement('a');
9875                        if (item.custom == null && isCustom != null) item.custom = isCustom;
9876                        this._bindLink(element, item);
9877                        //element.
9878                        element.textContent = item.title.replace(/\x00/g, '');
9879                        //pdfjsLib.removeNullCharacters(item.title) || "Untitled Bookmark";
9880                        div.appendChild(element);
9881                        if (item.items && item.items.length > 0) {
9882                            hasAnyNesting = true;
9883                            this._addToggleButton(div);
9884                            var itemsDiv = document.createElement('div');
9885                            itemsDiv.className = this.outlineItemClass + "s";
9886                            div.appendChild(itemsDiv);
9887                            // noinspection JSCheckFunctionSignatures
9888                            queue.push({
9889                                parent: itemsDiv,
9890                                custom: item.custom,
9891                                items: item.items
9892                            });
9893                        }
9894                        levelData.parent.appendChild(div);
9895                        outlineCount++;
9896                    }
9897                }
9898                if (hasAnyNesting) {
9899                    if (this.container.classList != null) {
9900                        this.container.classList.add(this.outlineItemClass + "s");
9901                    } else if (this.container.className != null) {
9902                        this.container.className += " picWindow";
9903                    }
9904                }
9905                this.container.appendChild(fragment);
9906                this._dispatchEvent(outlineCount);
9907            }
9908        }
9909    ]);
9910    return BookMarkViewer;
9911}();
9912var ThumbList = /*#__PURE__*/ function() {
9913    "use strict";
9914    function ThumbList(config) {
9915        controls_class_call_check(this, ThumbList);
9916        var onScroll = function onScroll() {
9917            app.thumbRequestCount = 0;
9918            app.thumbRequestStatus = REQUEST_STATUS.COUNT;
9919        };
9920        var itemHeight = this.itemHeight = config.itemHeight;
9921        var itemWidth = this.itemWidth = config.itemWidth;
9922        var app = this.app = config.app;
9923        this.items = config.items;
9924        this.generatorFn = config.generatorFn;
9925        this.totalRows = config.totalRows || config.items && config.items.length;
9926        this.addFn = config.addFn;
9927        this.scrollFn = config.scrollFn;
9928        this.container = document.createElement('div');
9929        var self = this;
9930        for(var count = 0; count < this.totalRows; count++){
9931            var el = document.createElement("div");
9932            var pageNumber = count + 1;
9933            el.id = "df-thumb" + pageNumber;
9934            var image = document.createElement("div"), thumbNumber = document.createElement("div"), wrapper = document.createElement("div");
9935            wrapper.className = "df-wrapper";
9936            thumbNumber.className = "df-thumb-number";
9937            el.className = "df-thumb";
9938            image.className = "df-bg-image";
9939            wrapper.style.height = itemHeight + 'px';
9940            wrapper.style.width = itemWidth + 'px';
9941            thumbNumber.innerText = app.provider.getLabelforPage(pageNumber);
9942            el.appendChild(wrapper);
9943            wrapper.appendChild(thumbNumber);
9944            wrapper.appendChild(image);
9945            this.container.appendChild(el);
9946        }
9947        self.dispose = function() {
9948            if (self.container) {
9949                if (self.container.parentNode) {
9950                    self.container.parentNode.removeChild(self.container);
9951                }
9952            }
9953            self.container.removeEventListener('scroll', onScroll);
9954        };
9955        self.container.addEventListener('scroll', onScroll);
9956    }
9957    controls_create_class(ThumbList, [
9958        {
9959            key: "processThumbRequest",
9960            value: function processThumbRequest() {
9961                controls_utils.log("Thumb Request Initiated");
9962                var app = this.app;
9963                app.thumbRequestStatus = REQUEST_STATUS.OFF;
9964                //move to thumb if thumb is on
9965                if (app.activeThumb !== app.currentPageNumber) {
9966                    var thumbVisible = app.thumbContainer != null && app.thumbContainer.hasClass("df-sidemenu-visible");
9967                    if (thumbVisible) {
9968                        var thumbWrapper = app.thumblist.container;
9969                        var thumbWrapperScrollTop = thumbWrapper.scrollTop, thumbWrapperScrollHeight = thumbWrapper.getBoundingClientRect().height;
9970                        var thumb = app.thumbContainer.find("#df-thumb" + app.currentPageNumber);
9971                        if (thumb.length > 0) {
9972                            app.thumbContainer.find(".df-selected").removeClass("df-selected");
9973                            thumb.addClass("df-selected");
9974                            //js calculation
9975                            thumb = thumb[0];
9976                            //when the thumb is below the display area scroll so that just it's fully visible
9977                            if (thumbWrapperScrollTop + thumbWrapperScrollHeight < thumb.offsetTop + thumb.scrollHeight) controls_utils.scrollIntoView(thumb, null, false);
9978                            else if (thumbWrapperScrollTop > thumb.offsetTop) controls_utils.scrollIntoView(thumb);
9979                            app.activeThumb = app.currentPageNumber;
9980                        } else {
9981                            //noinspection JSValidateTypes
9982                            controls_jQuery(thumbWrapper).scrollTop(app.currentPageNumber * 124);
9983                            app.thumbRequestStatus = REQUEST_STATUS.ON;
9984                        }
9985                    }
9986                }
9987                if (app.thumblist.container.getElementsByClassName("df-thumb-requested").length === 0) {
9988                    var visible = controls_utils.getVisibleElements({
9989                        container: app.thumblist.container,
9990                        elements: app.thumblist.container.children
9991                    });
9992                    if (controls_jQuery.inArray(visible)) visible.unshift(app.activeThumb);
9993                    for(var count = 0; count < visible.length; count++){
9994                        var thumb1 = app.thumblist.container.children[visible[count] - 1];
9995                        if (thumb1 !== void 0 && thumb1.classList.contains("df-thumb-loaded") === false && thumb1.classList.contains("df-thumb-requested") === false) {
9996                            thumb1.classList.add("df-thumb-requested");
9997                            controls_utils.log("Thumb Requested for " + visible[count]);
9998                            app.provider.processPage({
9999                                pageNumber: visible[count],
10000                                textureTarget: defaults_DEARVIEWER.TEXTURE_TARGET.THUMB
10001                            });
10002                            return false;
10003                        }
10004                    }
10005                }
10006            }
10007        },
10008        {
10009            key: "setPage",
10010            value: function setPage(param) {
10011                var app = this.app, pageNumber = param.pageNumber, texture = param.texture, textureTarget = param.textureTarget;
10012                if (textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) {
10013                    var thumb = app.container.find("#df-thumb" + pageNumber);
10014                    thumb.find(".df-wrapper").css({
10015                        height: param.height,
10016                        width: param.width
10017                    });
10018                    thumb.find(".df-bg-image").css({
10019                        backgroundImage: controls_utils.bgImage(texture)
10020                    });
10021                    thumb.addClass("df-thumb-loaded").removeClass("df-thumb-requested");
10022                }
10023                controls_utils.log("Thumbnail set for " + param.pageNumber);
10024                app.thumbRequestStatus = REQUEST_STATUS.ON;
10025            }
10026        }
10027    ]);
10028    return ThumbList;
10029}();
10030defaults_DEARVIEWER.openLightBox = function openLightBox(app) {
10031    if (!defaults_DEARVIEWER.activeLightBox) {
10032        defaults_DEARVIEWER.activeLightBox = new DVLightBox(function() {
10033            if (defaults_DEARVIEWER.activeLightBox.app) {
10034                defaults_DEARVIEWER.activeLightBox.app.closeRequested = true;
10035                defaults_DEARVIEWER.activeLightBox.app.analytics({
10036                    eventAction: defaults_DEARVIEWER.activeLightBox.app.options.analyticsViewerClose,
10037                    options: defaults_DEARVIEWER.activeLightBox.app.options
10038                });
10039            }
10040            defaults_DEARVIEWER.activeLightBox.app = controls_utils.disposeObject(defaults_DEARVIEWER.activeLightBox.app);
10041        });
10042    }
10043    defaults_DEARVIEWER.activeLightBox.duration = 300;
10044    if (defaults_DEARVIEWER.activeLightBox.app === undefined || defaults_DEARVIEWER.activeLightBox.app === null || defaults_DEARVIEWER.activeLightBox.app.closeRequested === true || defaults_DEARVIEWER.openLocalFileInput == app // request is through OpenFile function
10045    ) {
10046        defaults_DEARVIEWER.activeLightBox.app = controls_utils.disposeObject(defaults_DEARVIEWER.activeLightBox.app);
10047        if (defaults_DEARVIEWER.activeLightBox.app === null) {
10048            defaults_DEARVIEWER.activeLightBox.show(function() {
10049                defaults_DEARVIEWER.activeLightBox.app = controls_jQuery(defaults_DEARVIEWER.activeLightBox.element).dearviewer({
10050                    transparent: false,
10051                    isLightBox: true,
10052                    hashNavigationEnabled: true,
10053                    height: "100%",
10054                    dataElement: app
10055                });
10056                history.pushState({}, null, "#");
10057                defaults_DEARVIEWER.activeLightBox.lightboxWrapper.toggleClass("df-lightbox-padded", defaults_DEARVIEWER.activeLightBox.app.options.popupFullsize === false);
10058                defaults_DEARVIEWER.activeLightBox.lightboxWrapper.toggleClass("df-rtl", defaults_DEARVIEWER.activeLightBox.app.options.readDirection === defaults_DEARVIEWER.READ_DIRECTION.RTL);
10059                defaults_DEARVIEWER.activeLightBox.backGround.css({
10060                    "backgroundColor": defaults_DEARVIEWER.activeLightBox.app.options.backgroundColor === "transparent" ? defaults_DEARVIEWER.defaults.popupBackGroundColor : defaults_DEARVIEWER.activeLightBox.app.options.backgroundColor
10061                });
10062            });
10063        }
10064    }
10065};
10066defaults_DEARVIEWER.checkBrowserURLforDefaults = function() {
10067    if (controls_utils.isIEUnsupported) return;
10068    var viewerType = new URL(location.href).searchParams.get('viewer-type') || new URL(location.href).searchParams.get('viewertype');
10069    var is3D = new URL(location.href).searchParams.get('is-3d') || new URL(location.href).searchParams.get('is3d');
10070    if (viewerType) {
10071        defaults_DEARVIEWER.defaults.viewerType = viewerType;
10072    }
10073    if (is3D === "true" || is3D === "false") {
10074        defaults_DEARVIEWER.defaults.is3D = is3D === "true";
10075    }
10076};
10077defaults_DEARVIEWER.checkBrowserURLforPDF = function() {
10078    var openFlipbook = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
10079    if (controls_utils.isIEUnsupported) return;
10080    var pdf = new URL(location.href).searchParams.get('pdf-source');
10081    if (pdf) {
10082        pdf = unescape(pdf);
10083        if (openFlipbook) {
10084            defaults_DEARVIEWER.openURL(pdf);
10085        }
10086    }
10087    return pdf;
10088};
10089//Exists if there is need for open file and other lightbox present in the same page. They cannot share same settings.
10090//also is needed just be a dummy elemet for lightbox dataElement
10091function createFileInput() {
10092    if (defaults_DEARVIEWER.openLocalFileInput === void 0) {
10093        var input = defaults_DEARVIEWER.openLocalFileInput = controls_jQuery('<input type="file" accept=".pdf" style="display:none">').appendTo(controls_jQuery("body")).data('df-option', defaults_DEARVIEWER.openFileOptions);
10094        input.change(function() {
10095            var files = input[0].files;
10096            var file;
10097            if (files.length) {
10098                file = files[0];
10099                input.val("");
10100                defaults_DEARVIEWER.openFile(file);
10101            }
10102        });
10103    }
10104}
10105//default fileDropHandler
10106defaults_DEARVIEWER.fileDropHandler = function(files, e) {
10107    var file = files[0];
10108    if (file.type === "application/pdf") {
10109        e.preventDefault();
10110        e.stopPropagation();
10111        defaults_DEARVIEWER.openFile(file);
10112    }
10113};
10114defaults_DEARVIEWER.openFile = function(file) {
10115    if (file) {
10116        var //callback to handle any actions once file is selected.
10117        _DEARVIEWER_openFileSelected;
10118        if (defaults_DEARVIEWER.oldLocalFileObjectURL) window.URL.revokeObjectURL(defaults_DEARVIEWER.oldLocalFileObjectURL);
10119        defaults_DEARVIEWER.oldLocalFileObjectURL = window.URL.createObjectURL(file);
10120        (_DEARVIEWER_openFileSelected = defaults_DEARVIEWER['openFileSelected']) === null || _DEARVIEWER_openFileSelected === void 0 ? void 0 : _DEARVIEWER_openFileSelected.call(defaults_DEARVIEWER, {
10121            url: defaults_DEARVIEWER.oldLocalFileObjectURL,
10122            file: file
10123        });
10124        defaults_DEARVIEWER.openURL(defaults_DEARVIEWER.oldLocalFileObjectURL);
10125    } else {
10126        defaults_DEARVIEWER.openURL();
10127    }
10128};
10129defaults_DEARVIEWER.openURL = function(src) {
10130    createFileInput();
10131    if (src) {
10132        defaults_DEARVIEWER.openFileOptions.source = src;
10133        defaults_DEARVIEWER.openFileOptions.pdfParameters = null;
10134    }
10135    defaults_DEARVIEWER.openLightBox(defaults_DEARVIEWER.openLocalFileInput);
10136};
10137defaults_DEARVIEWER.openBase64 = function(data) {
10138    defaults_DEARVIEWER.openFileOptions.source = null;
10139    defaults_DEARVIEWER.openFileOptions.pdfParameters = {
10140        data: atob(data)
10141    };
10142    defaults_DEARVIEWER.openURL();
10143};
10144defaults_DEARVIEWER.openLocalFile = function() {
10145    createFileInput();
10146    defaults_DEARVIEWER.openLocalFileInput.click();
10147};
10148//jQuery events
10149defaults_DEARVIEWER.initControls = function() {
10150    //Lightbox Trigger
10151    var body = controls_jQuery('body');
10152    if (defaults_DEARVIEWER.defaults.autoPDFLinktoViewer !== false) {
10153        body.on('click', 'a[href$=".pdf"]', function(event) {
10154            var app = controls_jQuery(this);
10155            //prevent Download button to trigger Flipbook!
10156            if (app.attr("download") !== undefined || app.attr("target") === "_blank" || app.hasClass("df-ui-btn") || app.parents(".df-app").length > 0) {} else {
10157                event.preventDefault();
10158                app.data('df-source', app.attr('href'));
10159                defaults_DEARVIEWER.openLightBox(app);
10160            }
10161        });
10162    }
10163    window.addEventListener('popstate', function(event) {
10164        if (defaults_DEARVIEWER.activeLightBox && defaults_DEARVIEWER.activeLightBox.app && !control
10164s_utils.isChromeExtension()) {
10165            defaults_DEARVIEWER.activeLightBox.closeButton.trigger("click");
10166        }
10167    });
10168    body.on('click', '.df-open-local-file', function(event) {
10169        defaults_DEARVIEWER.openLocalFile();
10170    });
10171    body.on('click', '.df-sidemenu-buttons .df-ui-close', function() {
10172        var el = controls_jQuery(this);
10173        el.closest(".df-app").find(".df-ui-btn.df-active").trigger("click");
10174    });
10175    body.on('mouseout', '.df-link-content section.squareAnnotation, .df-link-content section.textAnnotation, .df-link-content section.freeTextAnnotation', function() {
10176        var el = controls_jQuery(this);
10177        defaults_DEARVIEWER.handlePopup(el, false);
10178    });
10179    body.on('mouseover', '.df-link-content section.squareAnnotation, .df-link-content section.textAnnotation, .df-link-content section.freeTextAnnotation', function() {
10180        var el = controls_jQuery(this);
10181        defaults_DEARVIEWER.handlePopup(el, true);
10182    });
10183    defaults_DEARVIEWER.handlePopup = function(el) {
10184        var show = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
10185        var container = el.closest('.df-container');
10186        var commentPopup = container.find('.df-comment-popup');
10187        commentPopup.toggleClass("df-active", show);
10188        if (show) {
10189            var elBounds = el[0].getBoundingClientRect();
10190            var containerBounds = container[0].getBoundingClientRect();
10191            var popup = el.find(".popupWrapper").first();
10192            if (el.hasClass("popupTriggerArea")) {
10193                var annotation_id = el.data("annotation-id");
10194                if (annotation_id !== void 0) {
10195                    popup = el.siblings("[data-annotation-id=popup_" + annotation_id + "]");
10196                }
10197            }
10198            commentPopup.html(popup.html());
10199            var left = elBounds.left - containerBounds.left;
10200            if (left + 360 > containerBounds.width) left = containerBounds.width - 360 - 10;
10201            else if (left < 10) left = 10;
10202            var top = elBounds.top - containerBounds.top + elBounds.height + 5;
10203            if (top + commentPopup.height() > containerBounds.height) top = elBounds.top - commentPopup.height() - elBounds.height - 10;
10204            else if (top < 10) top = 10;
10205            commentPopup.css({
10206                "left": left,
10207                "top": top
10208            });
10209        }
10210    };
10211    if (defaults_DEARVIEWER.fileDropElement != void 0) {
10212        var fileDropElement = controls_jQuery(defaults_DEARVIEWER.fileDropElement);
10213        if (fileDropElement.length > 0) {
10214            fileDropElement.on("dragover", function(event) {
10215                event.preventDefault();
10216                event.stopPropagation();
10217                controls_jQuery(this).addClass('df-dragging');
10218            });
10219            fileDropElement.on("dragleave", function(event) {
10220                event.preventDefault();
10221                event.stopPropagation();
10222                controls_jQuery(this).removeClass('df-dragging');
10223            });
10224            fileDropElement.on("drop", function(e) {
10225                var files = e.originalEvent.dataTransfer.files; // Array of all files
10226                var file;
10227                if (files.length) {
10228                    defaults_DEARVIEWER.fileDropHandler(files, e);
10229                }
10230            });
10231        }
10232    }
10233};
10234
10235
10236;// CONCATENATED MODULE: ./src/js/dearviewer/app.js
10237/* globals pdfjsLib,THREE  */ function app_class_call_check(instance, Constructor) {
10238    if (!(instance instanceof Constructor)) {
10239        throw new TypeError("Cannot call a class as a function");
10240    }
10241}
10242function app_defineProperties(target, props) {
10243    for(var i = 0; i < props.length; i++){
10244        var descriptor = props[i];
10245        descriptor.enumerable = descriptor.enumerable || false;
10246        descriptor.configurable = true;
10247        if ("value" in descriptor) descriptor.writable = true;
10248        Object.defineProperty(target, descriptor.key, descriptor);
10249    }
10250}
10251function app_create_class(Constructor, protoProps, staticProps) {
10252    if (protoProps) app_defineProperties(Constructor.prototype, protoProps);
10253    if (staticProps) app_defineProperties(Constructor, staticProps);
10254    return Constructor;
10255}
10256function app_instanceof(left, right) {
10257    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
10258        return !!right[Symbol.hasInstance](left);
10259    } else {
10260        return left instanceof right;
10261    }
10262}
10263
10264
10265
10266var app_DV = (/* unused pure expression or super */ null && (DEARVIEWER));
10267var app_jQuery = defaults_DEARVIEWER.jQuery;
10268var app_REQUEST_STATUS = defaults_DEARVIEWER.REQUEST_STATUS, app_utils = defaults_DEARVIEWER.utils;
10269var App = /*#__PURE__*/ function() {
10270    "use strict";
10271    function App(options) {
10272        app_class_call_check(this, App);
10273        this.options = options;
10274        this.viewerType = this.options.viewerType;
10275        this.startPage = 1;
10276        this.endPage = 1;
10277        this.element = app_jQuery(this.options.element);
10278        var _options_maxTextureSize;
10279        options.maxTextureSize = (_options_maxTextureSize = options.maxTextureSize) !== null && _options_maxTextureSize !== void 0 ? _options_maxTextureSize : 2048;
10280        if (app_utils.isMobile) {
10281            options.maxTextureSize = options.maxTextureSize === 4096 ? 3200 : options.maxTextureSize;
10282        }
10283        this.dimensions = {
10284            padding: {},
10285            offset: {},
10286            pageFit: {},
10287            stage: {},
10288            isAutoHeight: options.height === "auto",
10289            maxTextureSize: options.maxTextureSize
10290        };
10291        this.is3D = options.is3D;
10292        this.options.pixelRatio = app_utils.limitAt(this.options.pixelRatio, 1, this.options.maxDPI);
10293        var _this_options_fakeZoom;
10294        this.options.fakeZoom = (_this_options_fakeZoom = this.options.fakeZoom) !== null && _this_options_fakeZoom !== void 0 ? _this_options_fakeZoom : 1;
10295        this.events = {};
10296        this.links = options.links;
10297        this.thumbSize = 128;
10298        this.pendingZoom = true;
10299        this.currentPageNumber = this.options.openPage || this.startPage;
10300        this.hashNavigationEnabled = this.options.hashNavigationEnabled === true;
10301        this.pendingZoom = true;
10302        this.zoomValue = 1;
10303        this.pageScaling = defaults_DEARVIEWER.PAGE_SCALE.MANUAL;
10304        this.isRTL = options.readDirection === defaults_DEARVIEWER.READ_DIRECTION.RTL;
10305        this.jumpStep = 1;
10306        this.resizeRequestStatus = app_REQUEST_STATUS.OFF;
10307        this.refreshRequestStatus = app_REQUEST_STATUS.OFF;
10308        this.refreshRequestCount = 0;
10309        this.resizeRequestCount = 0;
10310        this.fullscreenSupported = app_utils.hasFullscreenEnabled();
10311        this.thumbRequestCount = 0;
10312        var _this_options_isExternalReady;
10313        this.isExternalReady = (_this_options_isExternalReady = this.options.isExternalReady) !== null && _this_options_isExternalReady !== void 0 ? _this_options_isExternalReady : true; //used when external document viewer or logic needs to wait
10314        this.init();
10315        if (this.options.autoLightBoxFullscreen === true && this.options.isLightBox === true) this.switchFullscreen(); //doesn't work properly https://github.com/deepak-ghimire/dearviewer/issues/332
10316        this.executeCallback('onCreate');
10317        this.target = this;
10318    }
10319    app_create_class(App, [
10320        {
10321            key: "init",
10322            value: function init() {
10323                var options = this.options, app = this;
10324                app.initDOM();
10325                app.initResourcesLocation();
10326                app.initInfo();
10327                //region Source Validation
10328                if ((options.source == null || options.source.length === 0) && options.pdfParameters == null) {
10329                    app.updateInfo("ERROR: Set a Valid Document Source.", defaults_DEARVIEWER.INFO_TYPE.ERROR);
10330                    app.container.removeClass('df-loading').addClass("df-error");
10331                    return;
10332                }
10333                //endregion
10334                //region Old Browsers
10335                if (app_utils.isIEUnsupported) {
10336                    app.updateInfo("Your browser (Internet Explorer) is out of date! <br><a href='https://browsehappy.com/'>Upgrade to a new browser.</a>", "df-old-browser");
10337                    app.container.removeClass('df-loading').addClass("df-error");
10338                    return;
10339                }
10340                //endregion
10341                app.commentPopup = app_jQuery('<div class="df-comment-popup">').appendTo(app.container);
10342                app.viewer = new app.viewerType(options, this);
10343                app.sideMenu = new Sidemenu({
10344                    parentElement: this.container
10345                }, app);
10346                app.provider = new defaults_DEARVIEWER.providers[options.providerType](options, app);
10347                app.state = 'loading';
10348                app.checkRequestQueue();
10349            }
10350        },
10351        {
10352            key: "initDOM",
10353            value: function initDOM() {
10354                this.element.addClass("df-app").removeClass("df-container df-loading");
10355                this.container = app_jQuery("<div>").appendTo(this.element);
10356                // Q. Why are this.element and this.container defined separately?
10357                // A. In IOS when fullscreen is used, then the whole this.container can be transferred to the pseudo fullscreen container that stays at the last of the DOM.
10358                this.container.addClass('df-container df-loading df-init' + " df-controls-" + this.options.controlsPosition + (this.options.controlsFloating === true ? " df-float" : " df-float-off") + (this.options.backgroundColor === 'transparent' ? " df-transparent" : "") + (this.isRTL === true ? " df-rtl" : "") + (app_utils.isIOS === true || app_utils.isIPad === true ? " df-ios" : ""));
10359                this._offsetParent = this.container[0].offsetParent;
10360                this.backGround = app_jQuery("<div class='df-bg'>").appendTo(this.container).css({
10361                    "backgroundColor": this.options.backgroundColor,
10362                    "backgroundImage": this.options.backgroundImage ? "url('" + this.options.backgroundImage + "')" : ''
10363                });
10364                this.viewerContainer = app_jQuery("<div>").appendTo(this.container);
10365                this.viewerContainer.addClass('df-viewer-container');
10366            }
10367        },
10368        {
10369            /**
10370   * Prepares Resource location based on the window[DEARVIEWER.locationVar]
10371   */ key: "initResourcesLocation",
10372            value: function initResourcesLocation() {
10373                var options = this.options;
10374                if (typeof window[defaults_DEARVIEWER.locationVar] !== 'undefined') {
10375                    options.pdfjsSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdf.min.js";
10376                    options.threejsSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/three.min.js";
10377                    options.pdfjsWorkerSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdf.worker.min.js";
10378                    options.soundFile = window[defaults_DEARVIEWER.locationVar] + options.soundFile;
10379                    options.imagesLocation = window[defaults_DEARVIEWER.locationVar] + options.imagesLocation;
10380                    options.imageResourcesPath = window[defaults_DEARVIEWER.locationVar] + options.imageResourcesPath;
10381                    options.cMapUrl = window[defaults_DEARVIEWER.locationVar] + options.cMapUrl;
10382                    if (options.pdfVersion !== undefined) {
10383                        var pdfDir = "";
10384                        if (options.pdfVersion == "latest" || options.pdfVersion == "beta") {
10385                            pdfDir = "latest";
10386                        } else if (options.pdfVersion == "stable") {
10387                            pdfDir = "stable";
10388                        }
10389                        //region checking if browser supports latest versions
10390                        if (options.pdfVersion == "latest" || options.pdfVersion == "default") {
10391                            var supports37 = Array.prototype.at !== undefined;
10392                            //if browser doesn't support pdf.js 3.7 it fallsback to stable version
10393                            //3.7 supported by 15.1+
10394                            //3.2 supported by 13.1+
10395                            //2.5 supported by most
10396                            if (Array.prototype.at === undefined) {
10397                                pdfDir = "stable";
10398                                console.log("Proper Support for Latest version PDF.js 3.7 not available. Switching to PDF.js 2.5!");
10399                            }
10400                        }
10401                        //endregion
10402                        if (pdfDir !== "default" && pdfDir !== "") {
10403                            options.pdfjsSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdfjs/" + pdfDir + "/pdf.min.js";
10404                            options.pdfjsWorkerSrc = window[defaults_DEARVIEWER.locationVar] + "js/libs/pdfjs/" + pdfDir + "/pdf.worker.min.js";
10405                        }
10406                    }
10407                } else {
10408                    console.warn("DEARVIEWER locationVar not found!");
10409                }
10410                this.executeCallback('onInitResourcesLocation');
10411            }
10412        },
10413        {
10414            key: "initEvents",
10415            value: function initEvents() {
10416                var app = this, containerDOM = this.container[0];
10417                // Use our detect's results. passive applied if supported, capture will be false either way.
10418                // let opts = utils.supportsPassive ? {passive: true} : false;
10419                var opts = false; //passive is not possible. like it's in https://www.google.com/maps/
10420                window.addEventListener("resize", app.events.resize = app.resetResizeRequest.bind(app), false);
10421                containerDOM.addEventListener("mousemove", app.events.mousemove = app.mouseMove.bind(app), false);
10422                containerDOM.addEventListener("mousedown", app.events.mousedown = app.mouseDown.bind(app), false);
10423                window.addEventListener("mouseup", app.events.mouseup = app.mouseUp.bind(app), false);
10424                containerDOM.addEventListener("touchmove", app.events.touchmove = app.mouseMove.bind(app), opts);
10425                containerDOM.addEventListener("touchstart", app.events.touchstart = app.mouseDown.bind(app), opts);
10426                window.addEventListener("touchend", app.events.touchend = app.mouseUp.bind(app), false);
10427            }
10428        },
10429        {
10430            key: "mouseMove",
10431            value: function mouseMove(event) {
10432                if (event.touches && event.touches.length > 1) {
10433                    event.preventDefault();
10434                }
10435                if (this.viewer.acceptAppMouseEvents === true) this.viewer.mouseMove(event);
10436            }
10437        },
10438        {
10439            key: "mouseDown",
10440            value: function mouseDown(event) {
10441                this.userHasInteracted = true;
10442                if (this.viewer.acceptAppMouseEvents === true && app_jQuery(event.srcElement).closest(".df-sidemenu").length === 0) this.viewer.mouseDown(event);
10443            }
10444        },
10445        {
10446            key: "mouseUp",
10447            value: function mouseUp(event) {
10448                if (this.viewer && this.viewer.acceptAppMouseEvents === true) this.viewer.mouseUp(event);
10449            }
10450        },
10451        {
10452            key: "softDispose",
10453            value: function softDispose() {
10454                var app = this;
10455                app.softDisposed = true;
10456                app.provider.dispose();
10457                app.viewer.dispose();
10458            }
10459        },
10460        {
10461            key: "softInit",
10462            value: function softInit() {
10463                var app = this;
10464                app.viewer = new app.viewerType(app.options, this);
10465                app.provider = new defaults_DEARVIEWER.providers[app.options.providerType](app.options, app);
10466                app.softDisposed = false;
10467            }
10468        },
10469        {
10470            key: "dispose",
10471            value: function dispose() {
10472                var _app_info, _app_loadingIcon, _app_backGround, _app_outlineContainer, _app_commentPopup;
10473                var app = this, containerDOM = this.container[0];
10474                clearInterval(this.autoPlayTimer);
10475                this.autoPlayTimer = null;
10476                this.autoPlayFunction = null;
10477                app.provider = app_utils.disposeObject(app.provider);
10478                app.contentProvider = null;
10479                app.target = null;
10480                app.viewer = app_utils.disposeObject(app.viewer);
10481                app.sideMenu = app_utils.disposeObject(app.sideMenu);
10482                app.ui = app_utils.disposeObject(app.ui);
10483                app.thumblist = app_utils.disposeObject(app.thumblist);
10484                app.outlineViewer = app_utils.disposeObject(app.outlineViewer);
10485                if (this.events) {
10486                    window.removeEventListener("resize", app.events.resize, false);
10487                    containerDOM.removeEventListener("mousemove", app.events.mousemove, false);
10488                    containerDOM.removeEventListener("mousedown", app.events.mousedown, false);
10489                    window.removeEventListener("mouseup", app.events.mouseup, false);
10490                    containerDOM.removeEventListener("touchmove", app.events.touchmove, false);
10491                    containerDOM.removeEventListener("touchstart", app.events.touchstart, false);
10492                    window.removeEventListener("touchend", app.events.touchend, false);
10493                }
10494                app.events = null;
10495                app.options = null;
10496                app.element.removeClass("df-app");
10497                app.viewerType = null;
10498                app.checkRequestQueue = null;
10499                (_app_info = app.info) === null || _app_info === void 0 ? void 0 : _app_info.remove();
10500                app.info = null;
10501                (_app_loadingIcon = app.loadingIcon) === null || _app_loadingIcon === void 0 ? void 0 : _app_loadingIcon.remove();
10502                app.loadingIcon = null;
10503                (_app_backGround = app.backGround) === null || _app_backGround === void 0 ? void 0 : _app_backGround.remove();
10504                app.backGround = null;
10505                (_app_outlineContainer = app.outlineContainer) === null || _app_outlineContainer === void 0 ? void 0 : _app_outlineContainer.remove();
10506                app.outlineContainer = null;
10507                (_app_commentPopup = app.commentPopup) === null || _app_commentPopup === void 0 ? void 0 : _app_commentPopup.remove();
10508                app.commentPopup = null;
10509                app.viewerContainer.off();
10510                app.viewerContainer.remove();
10511                app.viewerContainer = null;
10512                app.container.off();
10513                app.container.remove();
10514                app.container = null;
10515                app.element.off();
10516                app.element.data("df-app", null);
10517                app.element = null;
10518                app._offsetParent = null;
10519                app.dimensions = null;
10520            }
10521        },
10522        {
10523            key: "resetResizeRequest",
10524            value: function resetResizeRequest() {
10525                this.resizeRequestStatus = app_REQUEST_STATUS.COUNT;
10526                this.resizeRequestCount = 0;
10527                this.container.addClass("df-pendingresize");
10528                this.pendingResize = true;
10529            }
10530        },
10531        {
10532            /**
10533   * Prepares the element for displaying Loading icon
10534   */ key: "initInfo",
10535            value: function initInfo() {
10536                this.info = app_jQuery('<div>', {
10537                    class: 'df-loading-info'
10538                });
10539                this.container.append(this.info);
10540                this.info.html(this.options.text.loading + "...");
10541                this.loadingIcon = app_jQuery('<div>', {
10542                    class: 'df-loading-icon'
10543                }).appendTo(this.container);
10544            }
10545        },
10546        {
10547            // noinspection JSUnusedLocalSymbols
10548            key: "updateInfo",
10549            value: function updateInfo(message, className) {
10550                app_utils.log(message);
10551                if (this.info !== void 0) {
10552                    this.info.html(message);
10553                }
10554            }
10555        },
10556        {
10557            key: "_documentLoaded",
10558            value: function _documentLoaded() {
10559                app_utils.log("Document Loaded");
10560                this.isDocumentReady = true;
10561                this.contentProvider = this.provider;
10562                this.executeCallback('onDocumentLoad');
10563                this.endPage = this.pageCount = this.provider.page
10563Count;
10564                this.currentPageNumber = this.getValidPage(this.currentPageNumber);
10565            }
10566        },
10567        {
10568            key: "_viewerPrepared",
10569            value: function _viewerPrepared() {
10570                app_utils.log("Viewer Prepared");
10571                this.isViewerPrepared = true;
10572                this.executeCallback('onViewerLoad');
10573            }
10574        },
10575        {
10576            key: "requestFinalize",
10577            value: function requestFinalize() {
10578                if (this.isDocumentReady !== true || this.isViewerPrepared !== true || this.isExternalReady !== true || this.finalizeRequested === true) return;
10579                this.finalizeRequested = true;
10580                this.finalize();
10581            }
10582        },
10583        {
10584            key: "finalizeComponents",
10585            value: function finalizeComponents() {
10586                this.ui = new UI({}, this);
10587                this.ui.init();
10588                this.calculateLayout();
10589                this.viewer.init();
10590            }
10591        },
10592        {
10593            key: "finalize",
10594            value: function finalize() {
10595                this.resize();
10596                this.ui.update();
10597                this.initEvents();
10598                if (this.options.isLightBox == true) {
10599                    this.analytics({
10600                        eventAction: this.options.analyticsViewerOpen,
10601                        options: this.options
10602                    });
10603                }
10604                this.container.removeClass('df-loading df-init');
10605                this.viewer.onReady();
10606                this.analytics({
10607                    eventAction: this.options.analyticsViewerReady,
10608                    options: this.options
10609                });
10610                this.executeCallback('onReady');
10611                if (this.options.dataElement.hasClass("df-hash-focused") === true) {
10612                    app_utils.focusHash(this.options.dataElement);
10613                    this.options.dataElement.removeClass("df-hash-focused");
10614                }
10615                if (this.hashNavigationEnabled === true) this.getURLHash();
10616                app_utils.log("App Finalized");
10617            }
10618        },
10619        {
10620            key: "initOutline",
10621            value: function initOutline() {
10622                var app = this;
10623                var outlineContainer = app_jQuery('<div>').addClass("df-outline-container df-sidemenu");
10624                outlineContainer.append('<div class="df-sidemenu-title">' + this.options.text.outlineTitle + '</div>');
10625                var outlineWrapper = app_jQuery('<div>').addClass("df-wrapper");
10626                outlineContainer.append(outlineWrapper);
10627                app.sideMenu.element.append(outlineContainer);
10628                app.outlineContainer = outlineContainer;
10629                app.outlineViewer = new BookMarkViewer({
10630                    container: outlineWrapper[0],
10631                    linkService: app.provider.linkService,
10632                    outlineItemClass: "df-outline-item",
10633                    outlineToggleClass: "df-outline-toggle",
10634                    outlineToggleHiddenClass: "df-outlines-hidden"
10635                });
10636                app.outlineViewer.render({
10637                    outline: app.provider.outline
10638                });
10639            }
10640        },
10641        {
10642            key: "initThumbs",
10643            value: function initThumbs() {
10644                var app = this;
10645                app.thumblist = new ThumbList({
10646                    app: app,
10647                    addFn: function addFn(row) {},
10648                    scrollFn: function scrollFn() {
10649                        app.thumbRequestStatus = app_REQUEST_STATUS.ON;
10650                    },
10651                    itemHeight: app.thumbSize,
10652                    itemWidth: app_utils.limitAt(Math.floor(app.dimensions.defaultPage.ratio * app.thumbSize), 32, 180),
10653                    totalRows: app.pageCount
10654                });
10655                app.thumblist.lastScrolled = Date.now();
10656                app.thumbRequestStatus = app_REQUEST_STATUS.ON;
10657                var thumbContainer = app_jQuery('<div>').addClass("df-thumb-container df-sidemenu");
10658                thumbContainer.append('<div class="df-sidemenu-title">' + this.options.text.thumbTitle + '</div>');
10659                thumbContainer.append(app_jQuery(app.thumblist.container).addClass("df-wrapper"));
10660                app.thumbContainer = thumbContainer;
10661                app.sideMenu.element.append(thumbContainer);
10662                app.container.on('click', '.df-thumb-container .df-thumb', function(e) {
10663                    e.stopPropagation();
10664                    var id = app_jQuery(this).attr("id").replace("df-thumb", "");
10665                    app.gotoPage(parseInt(id, 10));
10666                });
10667            }
10668        },
10669        {
10670            key: "initSearch",
10671            value: function initSearch() {
10672                var app = this;
10673                var searchContainer = app_jQuery('<div>').addClass("df-search-container df-sidemenu");
10674                searchContainer.append('<div class="df-sidemenu-title">' + this.options.text.searchTitle + '</div>');
10675                app.searchForm = app_jQuery('<div class="df-search-form">').appendTo(searchContainer);
10676                app.searchBox = app_jQuery('<input type="text" class="df-search-text" placeholder="' + this.options.text.searchPlaceHolder + '">').on("keyup", function(event) {
10677                    if (event.keyCode === 13) {
10678                        app.search();
10679                    }
10680                }).appendTo(app.searchForm);
10681                app.searchButton = app_jQuery('<div class="df-ui-btn df-search-btn df-icon-search">').on("click", function(event) {
10682                    app.search();
10683                }).appendTo(app.searchForm);
10684                app.clearButton = app_jQuery('<a class="df-search-clear">Clear</a>').on("click", function(event) {
10685                    app.clearSearch();
10686                }).appendTo(app.searchForm);
10687                app.searchInfo = app_jQuery('<div class="df-search-info">').appendTo(searchContainer);
10688                app.searchResults = app_jQuery('<div class="df-wrapper df-search-results">').appendTo(searchContainer);
10689                app.searchContainer = searchContainer;
10690                app.sideMenu.element.append(searchContainer);
10691                app.container.on('click', '.df-search-result', function(e) {
10692                    e.stopPropagation();
10693                    var element = app_jQuery(this);
10694                    var id = element.data("df-page");
10695                    app.gotoPage(parseInt(id, 10));
10696                });
10697            }
10698        },
10699        {
10700            key: "search",
10701            value: function search(text) {
10702                if (text == void 0) {
10703                    text = this.searchBox.val();
10704                }
10705                this.provider.search(text.trim());
10706            }
10707        },
10708        {
10709            key: "clearSearch",
10710            value: function clearSearch() {
10711                this.searchBox.val("");
10712                this.searchInfo.html("");
10713                this.provider.clearSearch();
10714            }
10715        },
10716        {
10717            key: "updateSearchInfo",
10718            value: function updateSearchInfo(message) {
10719                app_utils.log(message);
10720                if (this.searchInfo !== void 0) {
10721                    this.searchInfo.html(message);
10722                }
10723            }
10724        },
10725        {
10726            key: "checkRequestQueue",
10727            value: function checkRequestQueue() {
10728                var app = this;
10729                if (app.checkRequestQueue) {
10730                    requestAnimationFrame(function() {
10731                        if (app && app.checkRequestQueue) app.checkRequestQueue();
10732                    });
10733                }
10734                if (app.softDisposed) return;
10735                //region loading & initiaization
10736                if (app.state != 'ready') {
10737                    if (app.state === 'loading' && this.isDocumentReady === true && this.isViewerPrepared === true && this.isExternalReady === true) {
10738                        app.state = 'finalizing'; //need to add ahead else it can keep running multiple times if the funcion throws error.
10739                        this.finalizeComponents();
10740                    }
10741                    if (app.state === 'finalizing') {
10742                        app.state = 'ready';
10743                        app.finalize();
10744                    }
10745                    return;
10746                }
10747                //endregion
10748                //offsetParent changes when display : none to block changes, scenarios in tab
10749                if (app.container && app.container[0] && app._offsetParent !== app.container[0].offsetParent) {
10750                    app._offsetParent = app.container[0].offsetParent;
10751                    if (app._offsetParent !== null) {
10752                        app.resize();
10753                        app.resizeRequestStatus = app_REQUEST_STATUS.OFF;
10754                    }
10755                    app_utils.log("Visibility Resize Detected");
10756                }
10757                if (app._offsetParent === null && !app.isFullscreen) return;
10758                // Removed since stage.render() is called from app.viewer.render(); - encapsulated
10759                // if (app.viewer.stage && app.viewer.stage.render)
10760                //   app.viewer.stage.render();
10761                if (TWEEN.getAll().length > 0) {
10762                    TWEEN.update();
10763                    app.renderRequestStatus = app_REQUEST_STATUS.ON;
10764                }
10765                if (app.resizeRequestStatus === app_REQUEST_STATUS.ON) {
10766                    app.resizeRequestStatus = app_REQUEST_STATUS.OFF;
10767                    app.resize();
10768                } else if (app.resizeRequestStatus === app_REQUEST_STATUS.COUNT) {
10769                    app.resizeRequestCount++;
10770                    if (app.resizeRequestCount > 10) {
10771                        app.resizeRequestCount = 0;
10772                        app.resizeRequestStatus = app_REQUEST_STATUS.ON;
10773                    }
10774                }
10775                if (app.refreshRequestStatus === app_REQUEST_STATUS.ON) {
10776                    app.refreshRequestStatus = app_REQUEST_STATUS.OFF;
10777                    app.pendingResize = false;
10778                    app.viewer.refresh();
10779                    this.container.removeClass("df-pendingresize");
10780                } else if (app.refreshRequestStatus === app_REQUEST_STATUS.COUNT) {
10781                    app.refreshRequestCount++;
10782                    if (app.refreshRequestCount > 3) {
10783                        app.refreshRequestCount = 0;
10784                        app.refreshRequestStatus = app_REQUEST_STATUS.ON;
10785                    }
10786                }
10787                if (app.textureRequestStatus === app_REQUEST_STATUS.ON) {
10788                    app.processTextureRequest();
10789                }
10790                if (app.thumbRequestStatus === app_REQUEST_STATUS.ON) app.processThumbRequest();
10791                else if (app.thumbRequestStatus === app_REQUEST_STATUS.COUNT) {
10792                    app.thumbRequestCount++;
10793                    if (app.thumbRequestCount > 3) {
10794                        app.thumbRequestCount = 0;
10795                        app.thumbRequestStatus = app_REQUEST_STATUS.ON;
10796                    }
10797                }
10798                if (app.renderRequestStatus === app_REQUEST_STATUS.ON) {
10799                    app.viewer.render();
10800                    app.renderRequestStatus = app_REQUEST_STATUS.OFF;
10801                }
10802                app.provider.checkRequestQueue();
10803                app.viewer.checkRequestQueue();
10804            }
10805        },
10806        {
10807            key: "processTextureRequest",
10808            value: function processTextureRequest() {
10809                // utils.log("Texture Request Preparing");
10810                var app = this, viewer = this.viewer, provider = this.provider;
10811                var visible = viewer.getVisiblePages().main, page, textureSize, requestCount = 0, zoomView = app.zoomValue > 1; //this should be independent of zoomview
10812                if (!viewer.isAnimating() || DEARFLIP.defaults.instantTextureProcess === true) {
10813                    app_utils.log("Texture Request Working");
10814                    for(var i = 0; i < visible.length; i++){
10815                        requestCount = 0;
10816                        var pageNumber = visible[i];
10817                        if (pageNumber > 0 && pageNumber <= app.pageCount) {
10818                            page = zoomView ? viewer.zoomViewer.getPageByNumber(pageNumber) : viewer.getPageByNumber(pageNumber);
10819                            if (page) {
10820                                textureSize = viewer.getTextureSize({
10821                                    pageNumber: pageNumber
10822                                });
10823                                if (page.changeTexture(pageNumber, Math.floor(textureSize.height))) {
10824                                    provider.processPage({
10825                                        pageNumber: pageNumber,
10826                                        textureTarget: zoomView ? defaults_DEARVIEWER.TEXTURE_TARGET.ZOOM : defaults_DEARVIEWER.TEXTURE_TARGET.VIEWER
10827                                    });
10828                                    requestCount++;
10829                                    app.viewer.getAnnotationElement(pageNumber, true);
10830                                }
10831                            }
10832                            if (requestCount > 0) break;
10833                        }
10834                    }
10835                    if (requestCount === 0) {
10836                        app.textureRequestStatus = app_REQUEST_STATUS.OFF;
10837                    }
10838                } else {
10839                    app.textureRequestStatus = app_REQUEST_STATUS.ON;
10840                }
10841            }
10842        },
10843        {
10844            key: "applyTexture",
10845            value: function applyTexture(canvas, param) {
10846                var app = this;
10847                var isCanvas = canvas.toDataURL !== void 0;
10848                if (param.textureTarget === defaults_DEARVIEWER.TEXTURE_TARGET.THUMB) {
10849                    param.height = canvas.height;
10850                    param.width = canvas.width;
10851                    if (!isCanvas) {
10852                        param.texture = canvas.src;
10853                    } else {
10854                        var src = canvas.toDataURL('image/png');
10855                        app.provider.setCache(param.pageNumber, src, app.thumbSize);
10856                        param.texture = src;
10857                    }
10858                    app.thumblist.setPage(param);
10859                } else {
10860                    param.texture = isCanvas ? canvas : canvas.src;
10861                    var set = app.viewer.setPage(param);
10862                    if (set === true) {
10863                        app.provider.processAnnotations(param.pageNumber, app.viewer.getAnnotationElement(param.pageNumber, true));
10864                        app.provider.processTextContent(param.pageNumber, app.viewer.getTextElement(param.pageNumber, true));
10865                    }
10866                }
10867            }
10868        },
10869        {
10870            key: "processThumbRequest",
10871            value: function processThumbRequest() {
10872                if (this.thumblist !== null && this.thumblist !== undefined) this.thumblist.processThumbRequest();
10873            }
10874        },
10875        {
10876            key: "refreshRequestStart",
10877            value: function refreshRequestStart() {
10878                this.refreshRequestStatus = app_REQUEST_STATUS.COUNT;
10879                this.refreshRequestCount = 0;
10880            }
10881        },
10882        {
10883            key: "renderRequestStart",
10884            value: function renderRequestStart() {
10885                this.renderRequestStatus = app_REQUEST_STATUS.ON;
10886            }
10887        },
10888        {
10889            key: "resizeRequestStart",
10890            value: function resizeRequestStart() {
10891                this.resizeRequestStatus = app_REQUEST_STATUS.ON;
10892            }
10893        },
10894        {
10895            key: "zoom",
10896            value: function zoom(delta) {
10897                var app = this;
10898                app.pendingZoom = true;
10899                app.zoomDelta = delta;
10900                app.resize();
10901            }
10902        },
10903        {
10904            key: "resetZoom",
10905            value: function resetZoom() {
10906                if (this.zoomValue !== 1) {
10907                    this.zoomValue = 1.001;
10908                    this.zoom(-1);
10909                }
10910            }
10911        },
10912        {
10913            key: "calculateLayout",
10914            value: function calculateLayout() {
10915                var app = this, isSideMenuOpen = app.isSideMenuOpen = app.container.hasClass("df-sidemenu-open"), dimensions = app.dimensions, padding = app.dimensions.padding, windowHeight = app_jQuery(window).height();
10916                // region Calculation of Offset and Padding
10917                dimensions.offset = {
10918                    top: 0,
10919                    left: !app.options.sideMenuOverlay && isSideMenuOpen && !app.isRTL ? 220 : 0,
10920                    right: !app.options.sideMenuOverlay && isSideMenuOpen && app.isRTL ? 220 : 0,
10921                    bottom: 0,
10922                    width: !app.options.sideMenuOverlay && isSideMenuOpen ? 220 : 0
10923                };
10924                app.viewerContainer.css({
10925                    left: dimensions.offset.left,
10926                    right: dimensions.offset.right
10927                });
10928                var controlsHeight = dimensions.controlsHeight = app.container.find(".df-ui").height();
10929                padding.top = app.options.paddingTop + (app.options.controlsPosition === defaults_DEARVIEWER.CONTROLS_POSITION.TOP ? controlsHeight : 0);
10930                padding.left = app.options.paddingLeft;
10931                padding.right = app.options.paddingRight;
10932                padding.bottom = app.options.paddingBottom + (app.options.controlsPosition === defaults_DEARVIEWER.CONTROLS_POSITION.BOTTOM ? controlsHeight : 0);
10933                padding.height = padding.top + padding.bottom;
10934                padding.width = padding.left + padding.right;
10935                padding.heightDiff = padding.top - padding.bottom;
10936                padding.widthDiff = padding.left - padding.right;
10937                //endregion
10938                //Priority: (isFullSize|isLockedHeight > isLockedHeight) > autoHeight
10939                dimensions.isFullSize = app.isFullscreen === true;
10940                dimensions.isFixedHeight = dimensions.isFullSize || !dimensions.isAutoHeight;
10941                dimensions.containerWidth = dimensions.isFullSize ? app_jQuery(window).width() : this.element.width();
10942                app.container.toggleClass('df-xs', dimensions.containerWidth < 400).toggleClass('df-xss', dimensions.containerWidth < 320);
10943                var _app_options_headerElementSelector, _jQuery_height;
10944                //region Determine MaxHeight
10945                dimensions.maxHeight = windowHeight - (dimensions.containerWidth > 600 ? (_jQuery_height = app_jQuery((_app_options_headerElementSelector = app.options.headerElementSelector) !== null && _app_options_headerElementSelector !== void 0 ? _app_options_headerElementSelector : "#wpadminbar").height()) !== null && _jQuery_height !== void 0 ? _jQuery_height : 0 : 0);
10946                if (dimensions.isFixedHeight) {
10947                    if (dimensions.isFullSize) {
10948                        dimensions.maxHeight = windowHeight;
10949                    } else {
10950                        //locked height but not in fullsize
10951                        //incase height is restricted by value provided by user, we need to determine that first
10952                        //test height on element, but apply on container.
10953                        app.element.height(app.options.height);
10954                        var _height = app.element.height();
10955                        dimensions.maxHeight = Math.min(_height, dimensions.maxHeight);
10956                    }
10957                } else {}
10958                //endregion
10959                //Reference size is not the cover page. IT IS THE VIRTUAL AVAILABLE ZONE
10960                //we have outerWidth, it gives innerwidth
10961                //with innerwidth we get innerheight and then outerHeight
10962                //app should only store outerWidth and outerHeight
10963                var outerWidth = dimensions.width, innerWidth = dimensions.stage.innerWidth = this.viewer._getInnerWidth(), innerHeight = dimensions.stage.innerHe
10963ight = this.viewer._getInnerHeight(), outerHeight = this.viewer._getOuterHeight(innerHeight + dimensions.padding.height);
10964                dimensions.containerHeight = dimensions.isFullSize ? windowHeight : outerHeight;
10965                app.element.height(dimensions.containerHeight);
10966                //Case when User sets height through CSS override.  #199
10967                var testHeight = app.element.height();
10968                if (!dimensions.isFullSize && testHeight != dimensions.containerHeight) {
10969                    dimensions.containerHeight = testHeight;
10970                    dimensions.stage.innerHeight = testHeight - dimensions.padding.height;
10971                    dimensions.stage.height = testHeight;
10972                }
10973                /*ZOOM values*/ dimensions.origin = {
10974                    x: (padding.widthDiff + dimensions.containerWidth - dimensions.offset.left - dimensions.offset.right) / 2,
10975                    y: (padding.heightDiff + dimensions.containerHeight) / 2
10976                };
10977                app.viewer.determinePageMode();
10978            }
10979        },
10980        {
10981            key: "resize",
10982            value: function resize() {
10983                var textureRefresh = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
10984                app_utils.log("Resize Request Initiated");
10985                var app = this;
10986                this.calculateLayout();
10987                app.viewer.handleZoom();
10988                app.viewer.resize();
10989                if (textureRefresh === false) return;
10990                if (app.pendingZoom) {
10991                    this.viewer.refresh();
10992                    app_utils.log("Pending Zoom updated");
10993                } else this.refreshRequestStart();
10994                this.ui.update();
10995                this.renderRequestStatus = app_REQUEST_STATUS.ON;
10996                app.zoomChanged = false;
10997                app.pendingZoom = false;
10998                this.executeCallback('afterResize');
10999            }
11000        },
11001        {
11002            key: "hasOutline",
11003            value: function hasOutline() {
11004                if (this.provider.outline.length > 0) return true;
11005            }
11006        },
11007        {
11008            key: "switchFullscreen",
11009            value: function switchFullscreen() {
11010                var _app_ui_controls, _app_ui;
11011                var app = this;
11012                // ui = viewer.ui;
11013                var element = app.container[0];
11014                app.container.toggleClass("df-fullscreen", app.isFullscreen !== true);
11015                if (app === null || app === void 0 ? void 0 : (_app_ui = app.ui) === null || _app_ui === void 0 ? void 0 : (_app_ui_controls = _app_ui.controls) === null || _app_ui_controls === void 0 ? void 0 : _app_ui_controls.fullscreen) app.ui.controls.fullScreen.toggleClass(app.options.icons["fullscreen-off"], app.isFullscreen !== true);
11016                if (app.isFullscreen !== true) {
11017                    var _promise = null;
11018                    //noinspection JSUnresolvedVariable
11019                    if (element['requestFullscreen']) {
11020                        _promise = element['requestFullscreen']();
11021                    } else if (element['msRequestFullscreen']) {
11022                        _promise = element['msRequestFullscreen']();
11023                    } else if (element['mozRequestFullScreen']) {
11024                        _promise = element['mozRequestFullScreen']();
11025                    } else if (element['webkitRequestFullscreen']) {
11026                        _promise = element['webkitRequestFullscreen']();
11027                    }
11028                    if (_promise && _promise["then"]) {
11029                        _promise.then(function() {
11030                            app.refreshRequestStatus === app_REQUEST_STATUS.ON;
11031                            app.resize();
11032                        });
11033                    }
11034                    app.isFullscreen = true;
11035                } else {
11036                    app.isFullscreen = false;
11037                    if (document['exitFullscreen']) {
11038                        if (document.fullscreenElement) document['exitFullscreen']();
11039                    } else if (document['msExitFullscreen']) {
11040                        document['msExitFullscreen']();
11041                    } else if (document['mozCancelFullScreen']) {
11042                        document['mozCancelFullScreen']();
11043                    } else if (document['webkitExitFullscreen']) {
11044                        document['webkitExitFullscreen']();
11045                    }
11046                    // if (app.options.autoLightBoxFullscreen === true && app.options.isLightBox === true) {
11047                    //   DEARFLIP.activeLightBox.close();
11048                    // }
11049                    if (!app_utils.hasFullscreenEnabled()) {
11050                        app.container[0].scrollIntoView();
11051                    }
11052                }
11053                if (!app_utils.hasFullscreenEnabled()) {
11054                    app.resizeRequestStatus = app_REQUEST_STATUS.ON;
11055                }
11056            }
11057        },
11058        {
11059            //region Navigation
11060            key: "next",
11061            value: function next() {
11062                this.jumpBy(this.jumpStep);
11063            }
11064        },
11065        {
11066            key: "prev",
11067            value: function prev() {
11068                this.jumpBy(-this.jumpStep);
11069            }
11070        },
11071        {
11072            key: "jumpBy",
11073            value: function jumpBy(step) {
11074                var nextPage = this.currentPageNumber + step;
11075                nextPage = app_utils.limitAt(nextPage, this.startPage, this.endPage);
11076                if (this.anyFirstPageChanged != true) {
11077                    this.analytics({
11078                        eventAction: this.options.analyticsFirstPageChange,
11079                        options: this.options
11080                    });
11081                    this.anyFirstPageChanged = true;
11082                }
11083                this.gotoPage(nextPage);
11084                this.ui.update();
11085            }
11086        },
11087        {
11088            key: "openRight",
11089            value: function openRight() {
11090                this.isRTL ? this.prev() : this.next();
11091            }
11092        },
11093        {
11094            key: "openLeft",
11095            value: function openLeft() {
11096                this.isRTL ? this.next() : this.prev();
11097            }
11098        },
11099        {
11100            key: "start",
11101            value: function start() {
11102                this.gotoPage(this.startPage);
11103            }
11104        },
11105        {
11106            key: "end",
11107            value: function end() {
11108                this.gotoPage(this.endPage);
11109            }
11110        },
11111        {
11112            key: "gotoPage",
11113            value: function gotoPage(pageNumber) {
11114                var app = this;
11115                pageNumber = app.getValidPage(parseInt(pageNumber, 10));
11116                if (app.viewer === null || app.viewer.validatePageChange(pageNumber) === false) return;
11117                this.executeCallback('beforePageChanged');
11118                app.requestDestRefKey = undefined;
11119                app.container.removeClass('df-fetch-pdf');
11120                app.oldPageNumber = app.currentPageNumber;
11121                app.currentPageNumber = pageNumber;
11122                app.thumbRequestStatus = app_REQUEST_STATUS.ON;
11123                if (app.viewer.gotoPageCallBack) app.viewer.gotoPageCallBack();
11124                app.ui.update();
11125                if (this.autoPlay == true) {
11126                    this.setAutoPlay(this.autoPlay);
11127                }
11128                if (this.hashNavigationEnabled === true) this.getURLHash();
11129                this.executeCallback('onPageChanged');
11130            }
11131        },
11132        {
11133            key: "gotoPageLabel",
11134            value: function gotoPageLabel(pageLabel) {
11135                this.gotoPage(this.provider.getPageNumberForLabel(pageLabel.toString().trim()));
11136            }
11137        },
11138        {
11139            key: "getCurrentLabel",
11140            value: function getCurrentLabel() {
11141                return this.provider.getLabelforPage(this.currentPageNumber);
11142            }
11143        },
11144        {
11145            key: "autoPlayFunction",
11146            value: function autoPlayFunction() {
11147                if (this && this.autoPlay) {
11148                    var nextPage = app_utils.limitAt(this.currentPageNumber + this.jumpStep, this.startPage, this.endPage);
11149                    if (nextPage !== this.currentPageNumber) {
11150                        this.next();
11151                    } else {
11152                        this.setAutoPlay(false);
11153                    }
11154                }
11155            }
11156        },
11157        {
11158            key: "setAutoPlay",
11159            value: function setAutoPlay(isPlay) {
11160                if (this.options.autoPlay) {
11161                    isPlay = isPlay == true;
11162                    var text = isPlay ? this.options.text.pause : this.options.text.play;
11163                    this.ui.controls.play.toggleClass(this.options.icons['pause'], isPlay);
11164                    this.ui.controls.play.html("<span>
11164" + text + "</span>");
11165                    this.ui.controls.play.attr("title", text);
11166                    clearInterval(this.autoPlayTimer);
11167                    if (isPlay) {
11168                        this.autoPlayTimer = setInterval(this.autoPlayFunction.bind(this), this.options.autoPlayDuration);
11169                    }
11170                    this.autoPlay = isPlay;
11171                }
11172            }
11173        },
11174        {
11175            //endregion
11176            key: "isValidPage",
11177            value: function isValidPage(pageNumber) {
11178                return this.provider._isValidPage(pageNumber);
11179            }
11180        },
11181        {
11182            key: "getValidPage",
11183            value: function getValidPage(pageNumber) {
11184                var app = this;
11185                if (isNaN(pageNumber)) pageNumber = app.currentPageNumber;
11186                else if (pageNumber < 1) pageNumber = 1;
11187                else if (pageNumber > app.pageCount) pageNumber = app.pageCount;
11188                return pageNumber;
11189            }
11190        },
11191        {
11192            key: "getURLHash",
11193            value: function getURLHash() {
11194                if (this.options.id != null) {
11195                    var hash = app_utils.getSharePrefix(this.options.sharePrefix) + (this.options.slug != null ? this.options.slug : this.options.id) + "/";
11196                    if (this.currentPageNumber != null) {
11197                        hash += this.currentPageNumber + "/";
11198                    }
11199                    history.replaceState(undefined, undefined, "#" + hash);
11200                }
11201                return window.location.href;
11202            }
11203        },
11204        {
11205            key: "executeCallback",
11206            value: function executeCallback(callbackName) {}
11207        },
11208        {
11209            key: "analytics",
11210            value: function analytics(eventData) {}
11211        }
11212    ]);
11213    return App;
11214}();
11215defaults_DEARVIEWER.prepareOptions = function(options) {
11216    //convert the element to jQuery Element
11217    if (!app_instanceof(options.element, app_jQuery)) options.element = app_jQuery(options.element);
11218    var element = options.element;
11219    /**
11220   * @type {jQuery|HTMLElement} - is useful when lightbox is displayed in one location but the options are pulled from another button or thumb element. Used by internal lightbox. No external use.
11221   */ if (options.dataElement == null) {
11222        options.dataElement = element;
11223    }
11224    var dataElement = options.dataElement;
11225    //region Merge Options
11226    var elementOptions = defaults_DEARVIEWER.utils.getOptions(dataElement);
11227    var customOptions = app_jQuery.extend(true, {}, defaults_DEARVIEWER.defaults, options, elementOptions);
11228    customOptions = app_utils.fallbackOptions(customOptions);
11229    app_utils.log(customOptions);
11230    //Note: ... spread will overwrite undefined variables too and won't perform deep scan
11231    var opts = app_jQuery.extend(true, {}, defaults_DEARVIEWER._defaults, customOptions);
11232    //endregion
11233    //check for mobile ViewerType
11234    if (app_utils.isMobile && typeof defaults_DEARVIEWER.viewers[opts.mobileViewerType] == "function") {
11235        opts.viewerType = opts.mobileViewerType;
11236    }
11237    if (typeof defaults_DEARVIEWER.viewers[opts.viewerType] !== "function") {
11238        console.warn("Invalid Viewer Type! " + opts.viewerType + " | Using default Viewer!");
11239        opts.viewerType = defaults_DEARVIEWER.viewers.default;
11240    } else {
11241        opts.viewerType = defaults_DEARVIEWER.viewers[opts.viewerType];
11242    }
11243    opts = app_utils.finalizeOptions(app_utils.sanitizeOptions(opts));
11244    return opts;
11245};
11246defaults_DEARVIEWER.Application = function(options) {
11247    var opts = defaults_DEARVIEWER.prepareOptions(options);
11248    var app = new App(opts);
11249    options.element.data("df-app", app);
11250    if (opts.id != null && opts.isLightBox !== true) {
11251        window[opts.id.toString()] = app;
11252    }
11253    return app;
11254};
11255//region jQuery Extension and Triggers
11256//jQuery Extension
11257app_jQuery.fn.extend({
11258    dearviewer_options: function dearviewer_options(options) {
11259        if (options == null) options = {};
11260        options.element = app_jQuery(this);
11261        return new defaults_DEARVIEWER.prepareOptions(options);
11262    },
11263    dearviewer: function dearviewer(options) {
11264        if (options == null) options = {};
11265        options.element = app_jQuery(this);
11266        return new defaults_DEARVIEWER.Application(options);
11267    }
11268});
11269
11270
11271;// CONCATENATED MODULE: ./src/js/dflip.js
11272/* globals jQuery, pdfjsLib, THREE */ function dflip_instanceof(left, right) {
11273    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
11274        return !!right[Symbol.hasInstance](left);
11275    } else {
11276        return left instanceof right;
11277    }
11278}
11279
11280
11281
11282
11283
11284
11285var dflip_jQuery = defaults_DEARVIEWER.jQuery;
11286var dflip_DEARFLIP = window.DFLIP = window.DEARFLIP = defaults_DEARVIEWER;
11287dflip_DEARFLIP.defaults.viewerType = 'flipbook';
11288dflip_DEARFLIP.slug = 'dflip';
11289dflip_DEARFLIP.locationVar = 'dFlipLocation';
11290dflip_DEARFLIP.locationFile = "dflip";
11291//region old Constants
11292//These are depreciated , so do not use them anymore
11293dflip_DEARFLIP.PAGE_MODE = {
11294    SINGLE: 1,
11295    DOUBLE: 2,
11296    AUTO: null
11297};
11298dflip_DEARFLIP.SINGLE_PAGE_MODE = {
11299    ZOOM: 1,
11300    BOOKLET: 2,
11301    AUTO: null
11302};
11303dflip_DEARFLIP.CONTROLSPOSITION = {
11304    HIDDEN: 'hide',
11305    TOP: 'top',
11306    BOTTOM: 'bottom'
11307};
11308dflip_DEARFLIP.DIRECTION = {
11309    LTR: 1,
11310    RTL: 2
11311};
11312dflip_DEARFLIP.PAGE_SIZE = {
11313    AUTO: 0,
11314    SINGLE: 1,
11315    DOUBLEINTERNAL: 2
11316};
11317//endregion
11318dflip_DEARFLIP.parseFallBack = function() {
11319    //region pre-parse fix for DFLIP
11320    dflip_jQuery('.df-posts').addClass("dflip-books"); //backward-compatibity
11321    dflip_jQuery('.dflip-books').addClass("df-posts"); //backward-compatibity
11322    dflip_jQuery('._df_button, ._df_thumb, ._df_book').each(function() {
11323        var app = dflip_jQuery(this);
11324        var isParsed = app.data("df-parsed");
11325        if (isParsed !== "true") {
11326            app.addClass("df-element");
11327            if (app.hasClass("_df_book")) {} else {
11328                if (app.hasClass("_df_thumb")) {
11329                    app.attr("data-df-lightbox", "thumb");
11330                    if (app.attr("thumb") !== void 0) {
11331                        app.data("df-thumb", app.attr("thumb"));
11332                    }
11333                } else {
11334                    app.attr("data-df-lightbox", "button");
11335                }
11336            }
11337        }
11338    });
11339//todo update this so that - this is also done in ajax calls, better use in getOptions fallback
11340//endregion
11341};
11342dflip_DEARFLIP.parseBooks = function() {
11343    dflip_DEARFLIP.parseFallBack();
11344    dflip_DEARFLIP.parseElements();
11345};
11346var updateOptions = function updateOptions(options) {
11347    if (options.source != null && (Array === options.source.constructor || Array.isArray(options.source) || dflip_instanceof(options.source, Array))) {
11348        options.providerType = "image";
11349    }
11350    //Replaced with cover3DType
11351    //options.has3DCover = utils.isTrue(options.has3DCover);
11352    if (options.cover3DType != null) {
11353        if (options.cover3DType == true || options.cover3DType == "true") {
11354            options.cover3DType = dflip_DEARFLIP.FLIPBOOK_COVER_TYPE.BASIC;
11355        } else if (options.cover3DType == false || options.cover3DType == "false") {
11356            options.cover3DType = dflip_DEARFLIP.FLIPBOOK_COVER_TYPE.NONE;
11357        }
11358    }
11359    //existing but modified
11360    if (options.pageSize !== void 0) {
11361        if (options.pageSize === "1" || options.pageSize === 1 || options.pageSize === dflip_DEARFLIP.FLIPBOOK_PAGE_SIZE.SINGLE) {
11362            options.pageSize = dflip_DEARFLIP.FLIPBOOK_PAGE_SIZE.SINGLE;
11363        } else if (options.pageSize === "2" || options.pageSize === 2 || options.pageSize === dflip_DEARFLIP.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL) {
11364            options.pageSize = dflip_DEARFLIP.FLIPBOOK_PAGE_SIZE.DOUBLE_INTERNAL;
11365        } else if (options.pageSize === dflip_DEARFLIP.FLIPBOOK_PAGE_SIZE.DOUBLE_COVER_BACK) {} else {
11366            options.pageSize = dflip_DEARFLIP.FLIPBOOK_PAGE_SIZE.AUTO;
11367        }
11368    }
11369    if (options.pageMode !== void 0) {
11370        if (options.pageMode === "1" || options.pageMode === 1 || options.pageMode === dflip_DEARFLIP.FLIPBOOK_PAGE_MODE.SINGLE) {
11371            options.pageMode = dflip_DEARFLIP.FLIPBOOK_PAGE_MODE.SINGLE;
11372        } else if (options.pageMode === "2" || options.pageMode === 2 || options.pageMode === dflip_DEARFLIP.FLIPBOOK_PAGE_MODE.DOUBLE) {
11373            options.pageMode = dflip_DEARFLIP.FLIPBOOK_PAGE_MODE.DOUBLE;
11374        } else {
11375            options.pageMode = dflip_DEARFLIP.FLIPBOOK_PAGE_MODE.AUTO;
11376        }
11377    }
11378    if (options.singlePageMode !== void 0) {
11379        if (options.singlePageMode === "1" || options.singlePageMode === 1 || options.singlePageMode === dflip_DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.ZOOM) {
11380            options.singlePageMode = dflip_DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.ZOOM;
11381        } else if (options.singlePageMode === "2" || options.singlePageMode === 2 || options.singlePageMode === dflip_DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET) {
11382            options.singlePageMode = dflip_DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.BOOKLET;
11383        } else {
11384            options.singlePageMode = dflip_DEARFLIP.FLIPBOOK_SINGLE_PAGE_MODE.AUTO;
11385        }
11386    }
11387    if (options.controlsPosition !== void 0) {
11388        if (options.controlsPosition === "hide") {
11389            options.controlsPosition = dflip_DEARFLIP.CONTROLS_POSITION.HIDDEN;
11390        }
11391    }
11392    if (options.overwritePDFOutline !== void 0) {
11393        options.overwritePDFOutline = utils.isTrue(options.overwritePDFOutline);
11394    }
11395    //replaced
11396    if (options.webgl !== void 0) {
11397        options.is3D = options.webgl = options.webgl;
11398        delete options.webgl;
11399    }
11400    if (options.webglShadow !== void 0) {
11401        options.has3DShadow = utils.isTrue(options.webglShadow);
11402        delete options.webglShadow;
11403    }
11404    if (options.scrollWheel !== void 0) {
11405        if (utils.isTrue(options.scrollWheel)) {
11406            options.mouseScrollAction = dflip_DEARFLIP.MOUSE_SCROLL_ACTIONS.ZOOM;
11407        }
11408        delete options.scrollWheel;
11409    }
11410    if (options.stiffness !== void 0) {
11411        delete options.stiffness;
11412    }
11413    if (options.soundEnable !== void 0) {
11414        options.enableSound = utils.isTrue(options.soundEnable);
11415        delete options.soundEnable;
11416    }
11417    if (options.enableDownload !== void 0) {
11418        options.showDownloadControl = utils.isTrue(options.enableDownload);
11419        delete options.enableDownload;
11420    }
11421    if (options.autoEnableOutline !== void 0) {
11422        options.autoOpenOutline = utils.isTrue(options.autoEnableOutline);
11423        delete options.autoEnableOutline;
11424    }
11425    if (options.autoEnableThumbnail !== void 0) {
11426        options.autoOpenThumbnail = utils.isTrue(options.autoEnableThumbnail);
11427        delete options.autoEnableThumbnail;
11428    }
11429    if (options.direction !== void 0) {
11430        if (options.direction === "2" || options.direction === 2 || options.direction === dflip_DEARFLIP.READ_DIRECTION.RTL) {
11431            options.readDirection = dflip_DEARFLIP.READ_DIRECTION.RTL;
11432        } else {
11433            options.readDirection = dflip_DEARFLIP.READ_DIRECTION.LTR;
11434        }
11435        delete options.direction;
11436    }
11437    if (options.hard !== void 0) {
11438        options.flipbookHardPages = options.hard;
11439        if (options.flipbookHardPages === "hard") {
11440            options.flipbookHardPages = "all";
11441        }
11442        delete options.hard;
11443    }
11444    //removed
11445    //forcefit is no longer required in DearFlip
11446    if (options.forceFit !== void 0) {
11447        delete options.forceFit;
11448    }
11449    return utils.sanitizeOptions(options);
11450};
11451//region jQuery Extension and Triggers
11452//jQuery Extension
11453dflip_jQuery.fn.extend({
11454    flipBook: function flipBook(source, options) {
11455        if (options == null) options = {};
11456        options.source = source;
11457        options.element = dflip_jQuery(this);
11458        return new defaults_DEARVIEWER.Application(options);
11459    }
11460});
11461//jQuery events
11462dflip_jQuery(document).ready(function() {
11463    //Lightbox Trigger
11464    var body = dflip_jQuery('body');
11465    dflip_DEARFLIP.executeCallback("beforeDearFlipInit");
11466    if (typeof window['dFlipWPGlobal'] !== 'undefined') {
11467        dflip_jQuery.extend(true, dflip_DEARFLIP.defaults, updateOptions(window['dFlipWPGlobal']));
11468    }
11469    dflip_DEARFLIP.initUtils();
11470    dflip_DEARFLIP.initControls();
11471    body.on('click', '.df-element[data-df-lightbox],.df-element[data-lightbox]', function(event) {
11472        var element = dflip_jQuery(this);
11473        event.preventDefault();
11474        event.stopPropagation();
11475        dflip_DEARFLIP.openLightBox(element);
11476    });
11477    dflip_DEARFLIP.checkBrowserURLforDefaults();
11478    dflip_DEARFLIP.parseCSSElements();
11479    dflip_DEARFLIP.parseFallBack();
11480    utils.detectHash();
11481    dflip_DEARFLIP.parseNormalElements();
11482    dflip_DEARFLIP.checkBrowserURLforPDF(true);
11483    dflip_DEARFLIP.executeCallback("afterDearFlipInit");
11484});
11485utils.finalizeOptions = function(options) {
11486    return updateOptions(options);
11487};
11488dflip_DEARFLIP.executeCallback("onDearFlipLoad");
11489/* harmony default export */ var dflip = ((/* unused pure expression or super */ null && (dflip_DEARFLIP)));
11490
11491}();
11492/******/ })()
11493;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.