PageSourceSearch

https://pipelbiz.com/bower_components/pdf.js-viewer/pdf.js?ver=1761830182

js pipelbiz.com collected 2026-09-26 11:48:51 UTC 1,240,912 bytes, 19,485 lines download raw bytes

vendor: 6,001 bytes, lines 1-163
1/**
2 * Copyright (c) 2011-2013 Fabien Cazenave, Mozilla.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
21 */
22/*
23 Additional modifications for PDF.js project:
24 - Disables language initialization on page loading;
25 - Removes consoleWarn and consoleLog and use console.log/warn directly.
26 - Removes window._ assignment.
27 - Remove compatibility code for OldIE.
28 */
29
30/*jshint browser: true, devel: true, es5: true, globalstrict: true */
31'use strict';
32
33document.webL10n = (function (window, document, undefined) {
34    var gL10nData = {};
35    var gTextData = '';
36    var gTextProp = 'textContent';
37    var gLanguage = '';
38    var gMacros = {};
39    var gReadyState = 'loading';
40
41
42    /**
43     * Synchronously loading l10n resources significantly minimizes flickering
44     * from displaying the app with non-localized strings and then updating the
45     * strings. Although this will block all script execution on this page, we
46     * expect that the l10n resources are available locally on flash-storage.
47     *
48     * As synchronous XHR is generally considered as a bad idea, we're still
49     * loading l10n resources asynchronously -- but we keep this in a setting,
50     * just in case... and applications using this library should hide their
51     * content until the `localized' event happens.
52     */
53
54    var gAsyncResourceLoading = true; // read-only
55
56
57    /**
58     * DOM helpers for the so-called "HTML API".
59     *
60     * These functions are written for modern browsers. For old versions of IE,
61     * they're overridden in the 'startup' section at the end of this file.
62     */
63
64    function getL10nResourceLinks() {
65        return document.querySelectorAll('link[type="application/l10n"]');
66    }
67
68    function getL10nDictionary() {
69        var script = document.querySelector('script[type="application/l10n"]');
70        // TODO: support multiple and external JSON dictionaries
71        return script ? JSON.parse(script.innerHTML) : null;
72    }
73
74    function getTranslatableChildren(element) {
75        return element ? element.querySelectorAll('*[data-l10n-id]') : [];
76    }
77
78    function getL10nAttributes(element) {
79        if (!element)
80            return {};
81
82        var l10nId = element.getAttribute('data-l10n-id');
83        var l10nArgs = element.getAttribute('data-l10n-args');
84        var args = {};
85        if (l10nArgs) {
86            try {
87                args = JSON.parse(l10nArgs);
88            } catch (e) {
89                console.warn('could not parse arguments for #' + l10nId);
90            }
91        }
92        return {id: l10nId, args: args};
93    }
94
95    function fireL10nReadyEvent(lang) {
96        var evtObject = document.createEvent('Event');
97        evtObject.initEvent('localized', true, false);
98        evtObject.language = lang;
99        document.dispatchEvent(evtObject);
100    }
101
102    function xhrLoadText(url, onSuccess, onFailure) {
103        onSuccess = onSuccess || function _onSuccess(data) {};
104        onFailure = onFailure || function _onFailure() {};
105
106        var xhr = new XMLHttpRequest();
107        xhr.open('GET', url, gAsyncResourceLoading);
108        if (xhr.overrideMimeType) {
109            xhr.overrideMimeType('text/plain; charset=utf-8');
110        }
111        xhr.onreadystatechange = function () {
112            if (xhr.readyState == 4) {
113                if (xhr.status == 200 || xhr.status === 0) {
114                    onSuccess(xhr.responseText);
115                } else {
116                    onFailure();
117                }
118            }
119        };
120        xhr.onerror = onFailure;
121        xhr.ontimeout = onFailure;
122
123        // in Firefox OS with the app:// protocol, trying to XHR a non-existing
124        // URL will raise an exception here -- hence this ugly try...catch.
125        try {
126            xhr.send(null);
127        } catch (e) {
128            onFailure();
129        }
130    }
131
132
133    /**
134     * l10n resource parser:
135     *  - reads (async XHR) the l10n resource matching `lang';
136     *  - imports linked resources (synchronously) when specified;
137     *  - parses the text data (fills `gL10nData' and `gTextData');
138     *  - triggers success/failure callbacks when done.
139     *
140     * @param {string} href
141     *    URL of the l10n resource to parse.
142     *
143     * @param {string} lang
144     *    locale (language) to parse. Must be a lowercase string.
145     *
146     * @param {Function} successCallback
147     *    triggered when the l10n resource has been successully parsed.
148     *
149     * @param {Function} failureCallback
150     *    triggered when the an error has occured.
151     *
152     * @return {void}
153     *    uses the following global variables: gL10nData, gTextData, gTextProp.
154     */
155
156    function parseResource(href, lang, successCallback, failureCallback) {
157        var baseURL = href.replace(/[^\/]*$/, '') || './';
158
159        // handle escaped characters (backslashes) in a string
160        function evalString(text) {
161            if (text.lastIndexOf('\\') < 0)
162                return text;
163            return text.replace(/\\\\/g, '\\')
164                    .replace(/\\n/g, '\n')
165                    .replace(/\\r/g, '\r')
166                    .replace(/\\t/g, '\t')
167                    .replace(/\\b/g, '\b')
168                    .replace(/\\f/g, '\f')
169                    .replace(/\\{/g, '{')
170                    .replace(/\\}/g, '}')
171                    .replace(/\\"/g, '"')
172                    .replace(/\\'/g, "'");
173        }
174
175        // parse *.properties text data into an l10n dictionary
176        // If gAsyncResourceLoading is false, then the callback will be called
177        // synchronously. Otherwise it is called asynchronously.
178        function parseProperties(text, parsedPropertiesCallback) {
179            var dictionary = {};
180
181            // token expressions
182            var reBlank = /^\s*|\s*$/;
183            var reComment = /^\s*#|^\s*$/;
184            var reSection = /^\s*\[(.*)\]\s*$/;
185            var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
186            var reSplit = /^([^=\s]*)\s*=\s*(.+)$/; // TODO: escape EOLs with '\'
187
188            // parse the *.properties file into an associative array
189            function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
190                var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
191                var currentLang = '*';
192                var genericLang = lang.split('-', 1)[0];
193                var skipLang = false;
194                var match = '';
195
196                function nextEntry() {
197                    // Use infinite loop instead of recursion to avoid reaching the
198                    // maximum recursion limit for content with many lines.
199                    while (true) {
200                        if (!entries.length) {
201                            parsedRawLinesCallback();
202                            return;
203                        }
204                        var line = entries.shift();
205
206                        // comment or blank line?
207                        if (reComment.test(line))
208                            continue;
209
vendor: 27,566 bytes, lines 210-1052
210                        // the extended syntax supports [lang] sections and @import rules
211                        if (extendedSyntax) {
212                            match = reSection.exec(line);
213                            if (match) { // section start?
214                                // RFC 4646, section 4.4, "All comparisons MUST be performed
215                                // in a case-insensitive manner."
216
217                                currentLang = match[1].toLowerCase();
218                                skipLang = (currentLang !== '*') &&
219                                        (currentLang !== lang) && (currentLang !== genericLang);
220                                continue;
221                            } else if (skipLang) {
222                                continue;
223                            }
224                            match = reImport.exec(line);
225                            if (match) { // @import rule?
226                                loadImport(baseURL + match[1], nextEntry);
227                                return;
228                            }
229                        }
230
231                        // key-value pair
232                        var tmp = line.match(reSplit);
233                        if (tmp && tmp.length == 3) {
234                            dictionary[tmp[1]] = evalString(tmp[2]);
235                        }
236                    }
237                }
238                nextEntry();
239            }
240
241            // import another *.properties file
242            function loadImport(url, callback) {
243                xhrLoadText(url, function (content) {
244                    parseRawLines(content, false, callback); // don't allow recursive imports
245                }, function () {
246                    console.warn(url + ' not found.');
247                    callback();
248                });
249            }
250
251            // fill the dictionary
252            parseRawLines(text, true, function () {
253                parsedPropertiesCallback(dictionary);
254            });
255        }
256
257        // load and parse l10n data (warning: global variables are used here)
258        xhrLoadText(href, function (response) {
259            gTextData += response; // mostly for debug
260
261            // parse *.properties text data into an l10n dictionary
262            parseProperties(response, function (data) {
263
264                // find attribute descriptions, if any
265                for (var key in data) {
266                    var id, prop, index = key.lastIndexOf('.');
267                    if (index > 0) { // an attribute has been specified
268                        id = key.substring(0, index);
269                        prop = key.substr(index + 1);
270                    } else { // no attribute: assuming text content by default
271                        id = key;
272                        prop = gTextProp;
273                    }
274                    if (!gL10nData[id]) {
275                        gL10nData[id] = {};
276                    }
277                    gL10nData[id][prop] = data[key];
278                }
279
280                // trigger callback
281                if (successCallback) {
282                    successCallback();
283                }
284            });
285        }, failureCallback);
286    }
287
288    // load and parse all resources for the specified locale
289    function loadLocale(lang, callback) {
290        // RFC 4646, section 2.1 states that language tags have to be treated as
291        // case-insensitive. Convert to lowercase for case-insensitive comparisons.
292        if (lang) {
293            lang = lang.toLowerCase();
294        }
295
296        callback = callback || function _callback() {};
297
298        clear();
299        gLanguage = lang;
300
301        // check all <link type="application/l10n" href="..." /> nodes
302        // and load the resource files
303        var langLinks = getL10nResourceLinks();
304        var langCount = langLinks.length;
305        if (langCount === 0) {
306            // we might have a pre-compiled dictionary instead
307            var dict = getL10nDictionary();
308            if (dict && dict.locales && dict.default_locale) {
309                console.log('using the embedded JSON directory, early way out');
310                gL10nData = dict.locales[lang];
311                if (!gL10nData) {
312                    var defaultLocale = dict.default_locale.toLowerCase();
313                    for (var anyCaseLang in dict.locales) {
314                        anyCaseLang = anyCaseLang.toLowerCase();
315                        if (anyCaseLang === lang) {
316                            gL10nData = dict.locales[lang];
317                            break;
318                        } else if (anyCaseLang === defaultLocale) {
319                            gL10nData = dict.locales[defaultLocale];
320                        }
321                    }
322                }
323                callback();
324            } else {
325                console.log('no resource to load, early way out');
326            }
327            // early way out
328            fireL10nReadyEvent(lang);
329            gReadyState = 'complete';
330            return;
331        }
332
333        // start the callback when all resources are loaded
334        var onResourceLoaded = null;
335        var gResourceCount = 0;
336        onResourceLoaded = function () {
337            gResourceCount++;
338            if (gResourceCount >= langCount) {
339                callback();
340                fireL10nReadyEvent(lang);
341                gReadyState = 'complete';
342            }
343        };
344
345        // load all resource files
346        function L10nResourceLink(link) {
347            var href = link.href;
348            // Note: If |gAsyncResourceLoading| is false, then the following callbacks
349            // are synchronously called.
350            this.load = function (lang, callback) {
351                parseResource(href, lang, callback, function () {
352                    console.warn(href + ' not found.');
353                    // lang not found, used default resource instead
354                    console.warn('"' + lang + '" resource not found');
355                    gLanguage = '';
356                    // Resource not loaded, but we still need to call the callback.
357                    callback();
358                });
359            };
360        }
361
362        for (var i = 0; i < langCount; i++) {
363            var resource = new L10nResourceLink(langLinks[i]);
364            resource.load(lang, onResourceLoaded);
365        }
366    }
367
368    // clear all l10n data
369    function clear() {
370        gL10nData = {};
371        gTextData = '';
372        gLanguage = '';
373        // TODO: clear all non predefined macros.
374        // There's no such macro /yet/ but we're planning to have some...
375    }
376
377
378    /**
379     * Get rules for plural forms (shared with JetPack), see:
380     * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
381     * https://github.com/mozilla/addon-sdk/blob/master/python-lib/plural-rules-generator.p
382     *
383     * @param {string} lang
384     *    locale (language) used.
385     *
386     * @return {Function}
387     *    returns a function that gives the plural form name for a given integer:
388     *       var fun = getPluralRules('en');
389     *       fun(1)    -> 'one'
390     *       fun(0)    -> 'other'
391     *       fun(1000) -> 'other'.
392     */
393
394    function getPluralRules(lang) {
395        var locales2rules = {
396            'af': 3,
397            'ak': 4,
398            'am': 4,
399            'ar': 1,
400            'asa': 3,
401            'az': 0,
402            'be': 11,
403            'bem': 3,
404            'bez': 3,
405            'bg': 3,
406            'bh': 4,
407            'bm': 0,
408            'bn': 3,
409            'bo': 0,
410            'br': 20,
411            'brx': 3,
412            'bs': 11,
413            'ca': 3,
414            'cgg': 3,
415            'chr': 3,
416            'cs': 12,
417            'cy': 17,
418            'da': 3,
419            'de': 3,
420            'dv': 3,
421            'dz': 0,
422            'ee': 3,
423            'el': 3,
424            'en': 3,
425            'eo': 3,
426            'es': 3,
427            'et': 3,
428            'eu': 3,
429            'fa': 0,
430            'ff': 5,
431            'fi': 3,
432            'fil': 4,
433            'fo': 3,
434            'fr': 5,
435            'fur': 3,
436            'fy': 3,
437            'ga': 8,
438            'gd': 24,
439            'gl': 3,
440            'gsw': 3,
441            'gu': 3,
442            'guw': 4,
443            'gv': 23,
444            'ha': 3,
445            'haw': 3,
446            'he': 2,
447            'hi': 4,
448            'hr': 11,
449            'hu': 0,
450            'id': 0,
451            'ig': 0,
452            'ii': 0,
453            'is': 3,
454            'it': 3,
455            'iu': 7,
456            'ja': 0,
457            'jmc': 3,
458            'jv': 0,
459            'ka': 0,
460            'kab': 5,
461            'kaj': 3,
462            'kcg': 3,
463            'kde': 0,
464            'kea': 0,
465            'kk': 3,
466            'kl': 3,
467            'km': 0,
468            'kn': 0,
469            'ko': 0,
470            'ksb': 3,
471            'ksh': 21,
472            'ku': 3,
473            'kw': 7,
474            'lag': 18,
475            'lb': 3,
476            'lg': 3,
477            'ln': 4,
478            'lo': 0,
479            'lt': 10,
480            'lv': 6,
481            'mas': 3,
482            'mg': 4,
483            'mk': 16,
484            'ml': 3,
485            'mn': 3,
486            'mo': 9,
487            'mr': 3,
488            'ms': 0,
489            'mt': 15,
490            'my': 0,
491            'nah': 3,
492            'naq': 7,
493            'nb': 3,
494            'nd': 3,
495            'ne': 3,
496            'nl': 3,
497            'nn': 3,
498            'no': 3,
499            'nr': 3,
500            'nso': 4,
501            'ny': 3,
502            'nyn': 3,
503            'om': 3,
504            'or': 3,
505            'pa': 3,
506            'pap': 3,
507            'pl': 13,
508            'ps': 3,
509            'pt': 3,
510            'rm': 3,
511            'ro': 9,
512            'rof': 3,
513            'ru': 11,
514            'rwk': 3,
515            'sah': 0,
516            'saq': 3,
517            'se': 7,
518            'seh': 3,
519            'ses': 0,
520            'sg': 0,
521            'sh': 11,
522            'shi': 19,
523            'sk': 12,
524            'sl': 14,
525            'sma': 7,
526            'smi': 7,
527            'smj': 7,
528            'smn': 7,
529            'sms': 7,
530            'sn': 3,
531            'so': 3,
532            'sq': 3,
533            'sr': 11,
534            'ss': 3,
535            'ssy': 3,
536            'st': 3,
537            'sv': 3,
538            'sw': 3,
539            'syr': 3,
540            'ta': 3,
541            'te': 3,
542            'teo': 3,
543            'th': 0,
544            'ti': 4,
545            'tig': 3,
546            'tk': 3,
547            'tl': 4,
548            'tn': 3,
549            'to': 0,
550            'tr': 0,
551            'ts': 3,
552            'tzm': 22,
553            'uk': 11,
554            'ur': 3,
555            've': 3,
556            'vi': 0,
557            'vun': 3,
558            'wa': 4,
559            'wae': 3,
560            'wo': 0,
561            'xh': 3,
562            'xog': 3,
563            'yo': 0,
564            'zh': 0,
565            'zu': 3
566        };
567
568        // utility functions for plural rules methods
569        function isIn(n, list) {
570            return list.indexOf(n) !== -1;
571        }
572        function isBetween(n, start, end) {
573            return start <= n && n <= end;
574        }
575
576        // list of all plural rules methods:
577        // map an integer to the plural form name to use
578        var pluralRules = {
579            '0': function (n) {
580                return 'other';
581            },
582            '1': function (n) {
583                if ((isBetween((n % 100), 3, 10)))
584                    return 'few';
585                if (n === 0)
586                    return 'zero';
587                if ((isBetween((n % 100), 11, 99)))
588                    return 'many';
589                if (n == 2)
590                    return 'two';
591                if (n == 1)
592                    return 'one';
593                return 'other';
594            },
595            '2': function (n) {
596                if (n !== 0 && (n % 10) === 0)
597                    return 'many';
598                if (n == 2)
599                    return 'two';
600                if (n == 1)
601                    return 'one';
602                return 'other';
603            },
604            '3': function (n) {
605                if (n == 1)
606                    return 'one';
607                return 'other';
608            },
609            '4': function (n) {
610                if ((isBetween(n, 0, 1)))
611                    return 'one';
612                return 'other';
613            },
614            '5': function (n) {
615                if ((isBetween(n, 0, 2)) && n != 2)
616                    return 'one';
617                return 'other';
618            },
619            '6': function (n) {
620                if (n === 0)
621                    return 'zero';
622                if ((n % 10) == 1 && (n % 100) != 11)
623                    return 'one';
624                return 'other';
625            },
626            '7': function (n) {
627                if (n == 2)
628                    return 'two';
629                if (n == 1)
630                    return 'one';
631                return 'other';
632            },
633            '8': function (n) {
634                if ((isBetween(n, 3, 6)))
635                    return 'few';
636                if ((isBetween(n, 7, 10)))
637                    return 'many';
638                if (n == 2)
639                    return 'two';
640                if (n == 1)
641                    return 'one';
642                return 'other';
643            },
644            '9': function (n) {
645                if (n === 0 || n != 1 && (isBetween((n % 100), 1, 19)))
646                    return 'few';
647                if (n == 1)
648                    return 'one';
649                return 'other';
650            },
651            '10': function (n) {
652                if ((isBetween((n % 10), 2, 9)) && !(isBetween((n % 100), 11, 19)))
653                    return 'few';
654                if ((n % 10) == 1 && !(isBetween((n % 100), 11, 19)))
655                    return 'one';
656                return 'other';
657            },
658            '11': function (n) {
659                if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))
660                    return 'few';
661                if ((n % 10) === 0 ||
662                        (isBetween((n % 10), 5, 9)) ||
663                        (isBetween((n % 100), 11, 14)))
664                    return 'many';
665                if ((n % 10) == 1 && (n % 100) != 11)
666                    return 'one';
667                return 'other';
668            },
669            '12': function (n) {
670                if ((isBetween(n, 2, 4)))
671                    return 'few';
672                if (n == 1)
673                    return 'one';
674                return 'other';
675            },
676            '13': function (n) {
677                if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))
678                    return 'few';
679                if (n != 1 && (isBetween((n % 10), 0, 1)) ||
680                        (isBetween((n % 10), 5, 9)) ||
681                        (isBetween((n % 100), 12, 14)))
682                    return 'many';
683                if (n == 1)
684                    return 'one';
685                return 'other';
686            },
687            '14': function (n) {
688                if ((isBetween((n % 100), 3, 4)))
689                    return 'few';
690                if ((n % 100) == 2)
691                    return 'two';
692                if ((n % 100) == 1)
693                    return 'one';
694                return 'other';
695            },
696            '15': function (n) {
697                if (n === 0 || (isBetween((n % 100), 2, 10)))
698                    return 'few';
699                if ((isBetween((n % 100), 11, 19)))
700                    return 'many';
701                if (n == 1)
702                    return 'one';
703                return 'other';
704            },
705            '16': function (n) {
706                if ((n % 10) == 1 && n != 11)
707                    return 'one';
708                return 'other';
709            },
710            '17': function (n) {
711                if (n == 3)
712                    return 'few';
713                if (n === 0)
714                    return 'zero';
715                if (n == 6)
716                    return 'many';
717                if (n == 2)
718                    return 'two';
719                if (n == 1)
720                    return 'one';
721                return 'other';
722            },
723            '18': function (n) {
724                if (n === 0)
725                    return 'zero';
726                if ((isBetween(n, 0, 2)) && n !== 0 && n != 2)
727                    return 'one';
728                return 'other';
729            },
730            '19': function (n) {
731                if ((isBetween(n, 2, 10)))
732                    return 'few';
733                if ((isBetween(n, 0, 1)))
734                    return 'one';
735                return 'other';
736            },
737            '20': function (n) {
738                if ((isBetween((n % 10), 3, 4) || ((n % 10) == 9)) && !(
739                        isBetween((n % 100), 10, 19) ||
740                        isBetween((n % 100), 70, 79) ||
741                        isBetween((n % 100), 90, 99)
742                        ))
743                    return 'few';
744                if ((n % 1000000) === 0 && n !== 0)
745                    return 'many';
746                if ((n % 10) == 2 && !isIn((n % 100), [12, 72, 92]))
747                    return 'two';
748                if ((n % 10) == 1 && !isIn((n % 100), [11, 71, 91]))
749                    return 'one';
750                return 'other';
751            },
752            '21': function (n) {
753                if (n === 0)
754                    return 'zero';
755                if (n == 1)
756                    return 'one';
757                return 'other';
758            },
759            '22': function (n) {
760                if ((isBetween(n, 0, 1)) || (isBetween(n, 11, 99)))
761                    return 'one';
762                return 'other';
763            },
764            '23': function (n) {
765                if ((isBetween((n % 10), 1, 2)) || (n % 20) === 0)
766                    return 'one';
767                return 'other';
768            },
769            '24': function (n) {
770                if ((isBetween(n, 3, 10) || isBetween(n, 13, 19)))
771                    return 'few';
772                if (isIn(n, [2, 12]))
773                    return 'two';
774                if (isIn(n, [1, 11]))
775                    return 'one';
776                return 'other';
777            }
778        };
779
780        // return a function that gives the plural form name for a given integer
781        var index = locales2rules[lang.replace(/-.*$/, '')];
782        if (!(index in pluralRules)) {
783            console.warn('plural form unknown for [' + lang + ']');
784            return function () {
785                return 'other';
786            };
787        }
788        return pluralRules[index];
789    }
790
791    // pre-defined 'plural' macro
792    gMacros.plural = function (str, param, key, prop) {
793        var n = parseFloat(param);
794        if (isNaN(n))
795            return str;
796
797        // TODO: support other properties (l20n still doesn't...)
798        if (prop != gTextProp)
799            return str;
800
801        // initialize _pluralRules
802        if (!gMacros._pluralRules) {
803            gMacros._pluralRules = getPluralRules(gLanguage);
804        }
805        var index = '[' + gMacros._pluralRules(n) + ']';
806
807        // try to find a [zero|one|two] key if it's defined
808        if (n === 0 && (key + '[zero]') in gL10nData) {
809            str = gL10nData[key + '[zero]'][prop];
810        } else if (n == 1 && (key + '[one]') in gL10nData) {
811            str = gL10nData[key + '[one]'][prop];
812        } else if (n == 2 && (key + '[two]') in gL10nData) {
813            str = gL10nData[key + '[two]'][prop];
814        } else if ((key + index) in gL10nData) {
815            str = gL10nData[key + index][prop];
816        } else if ((key + '[other]') in gL10nData) {
817            str = gL10nData[key + '[other]'][prop];
818        }
819
820        return str;
821    };
822
823
824    /**
825     * l10n dictionary functions
826     */
827
828    // fetch an l10n object, warn if not found, apply `args' if possible
829    function getL10nData(key, args, fallback) {
830        var data = gL10nData[key];
831        if (!data) {
832            ///console.warn('#' + key + ' is undefined.'); /// patched
833            // === patch start ===
834            if (Object.keys(gL10nData).length > 0) {
835                console.warn('#' + key + ' is undefined.');
836            }
837            // === patch end === 
838            if (!fallback) {
839                return null;
840            }
841            data = fallback;
842        }
843
844        /** This is where l10n expressions should be processed.
845         * The plan is to support C-style expressions from the l20n project;
846         * until then, only two kinds of simple expressions are supported:
847         *   {[ index ]} and {{ arguments }}.
848         */
849        var rv = {};
850        for (var prop in data) {
851            var str = data[prop];
852            str = substIndexes(str, args, key, prop);
853            str = substArguments(str, args, key);
854            rv[prop] = str;
855        }
856        return rv;
857    }
858
859    // replace {[macros]} with their values
860    function substIndexes(str, args, key, prop) {
861        var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
862        var reMatch = reIndex.exec(str);
863        if (!reMatch || !reMatch.length)
864            return str;
865
866        // an index/macro has been found
867        // Note: at the moment, only one parameter is supported
868        var macroName = reMatch[1];
869        var paramName = reMatch[2];
870        var param;
871        if (args && paramName in args) {
872            param = args[paramName];
873        } else if (paramName in gL10nData) {
874            param = gL10nData[paramName];
875        }
876
877        // there's no macro parser yet: it has to be defined in gMacros
878        if (macroName in gMacros) {
879            var macro = gMacros[macroName];
880            str = macro(str, param, key, prop);
881        }
882        return str;
883    }
884
885    // replace {{arguments}} with their values
886    function substArguments(str, args, key) {
887        var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
888        return str.replace(reArgs, function (matched_text, arg) {
889            if (args && arg in args) {
890                return args[arg];
891            }
892            if (arg in gL10nData) {
893                return gL10nData[arg];
894            }
895            console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
896            return matched_text;
897        });
898    }
899
900    // translate an HTML element
901    function translateElement(element) {
902        var l10n = getL10nAttributes(element);
903        if (!l10n.id)
904            return;
905
906        // get the related l10n object
907        var data = getL10nData(l10n.id, l10n.args);
908        if (!data) {
909            console.warn('#' + l10n.id + ' is undefined.');
910            return;
911        }
912
913        // translate element (TODO: security checks?)
914        if (data[gTextProp]) { // XXX
915            if (getChildElementCount(element) === 0) {
916                element[gTextProp] = data[gTextProp];
917            } else {
918                // this element has element children: replace the content of the first
919                // (non-empty) child textNode and clear other child textNodes
920                var children = element.childNodes;
921                var found = false;
922                for (var i = 0, l = children.length; i < l; i++) {
923                    if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
924                        if (found) {
925                            children[i].nodeValue = '';
926                        } else {
927                            children[i].nodeValue = data[gTextProp];
928                            found = true;
929                        }
930                    }
931                }
932                // if no (non-empty) textNode is found, insert a textNode before the
933                // first element child.
934                if (!found) {
935                    var textNode = document.createTextNode(data[gTextProp]);
936                    element.insertBefore(textNode, element.firstChild);
937                }
938            }
939            delete data[gTextProp];
940        }
941
942        for (var k in data) {
943            element[k] = data[k];
944        }
945    }
946
947    // webkit browsers don't currently support 'children' on SVG elements...
948    function getChildElementCount(element) {
949        if (element.children) {
950            return element.children.length;
951        }
952        if (typeof element.childElementCount !== 'undefined') {
953            return element.childElementCount;
954        }
955        var count = 0;
956        for (var i = 0; i < element.childNodes.length; i++) {
957            count += element.nodeType === 1 ? 1 : 0;
958        }
959        return count;
960    }
961
962    // translate an HTML subtree
963    function translateFragment(element) {
964        element = element || document.documentElement;
965
966        // check all translatable children (= w/ a `data-l10n-id' attribute)
967        var children = getTranslatableChildren(element);
968        var elementCount = children.length;
969        for (var i = 0; i < elementCount; i++) {
970            translateElement(children[i]);
971        }
972
973        // translate element itself if necessary
974        translateElement(element);
975    }
976
977    return {
978        // get a localized string
979        get: function (key, args, fallbackString) {
980            var index = key.lastIndexOf('.');
981            var prop = gTextProp;
982            if (index > 0) { // An attribute has been specified
983                prop = key.substr(index + 1);
984                key = key.substring(0, index);
985            }
986            var fallback;
987            if (fallbackString) {
988                fallback = {};
989                fallback[prop] = fallbackString;
990            }
991            var data = getL10nData(key, args, fallback);
992            if (data && prop in data) {
993                return data[prop];
994            }
995            return '{{' + key + '}}';
996        },
997
998        // debug
999        getData: function () {
1000            return gL10nData;
1001        },
1002        getText: function () {
1003            return gTextData;
1004        },
1005
1006        // get|set the document language
1007        getLanguage: function () {
1008            return gLanguage;
1009        },
1010        setLanguage: function (lang, callback) {
1011            loadLocale(lang, function () {
1012                if (callback)
1013                    callback();
1014                translateFragment();
1015            });
1016        },
1017
1018        // get the direction (ltr|rtl) of the current language
1019        getDirection: function () {
1020            // http://www.w3.org/International/questions/qa-scripts
1021            // Arabic, Hebrew, Farsi, Pashto, Urdu
1022            var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
1023            var shortCode = gLanguage.split('-', 1)[0];
1024            return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr';
1025        },
1026
1027        // translate an element or document fragment
1028        translate: translateFragment,
1029
1030        // this can be used to prevent race conditions
1031        getReadyState: function () {
1032            return gReadyState;
1033        },
1034        ready: function (callback) {
1035            if (!callback) {
1036                return;
1037            } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
1038                window.setTimeout(function () {
1039                    callback();
1040                });
1041            } else if (document.addEventListener) {
1042                document.addEventListener('localized', function once() {
1043                    document.removeEventListener('localized', once);
1044                    callback();
1045                });
1046            }
1047        }
1048    };
1049})(window, document);
1050/* Copyright 2017 Mozilla Foundation
1051 *
1052 * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 7,750 bytes, lines 1053-1216
1053 * you may not use this file except in compliance with the License.
1054 * You may obtain a copy of the License at
1055 *
1056 *     http://www.apache.org/licenses/LICENSE-2.0
1057 *
1058 * Unless required by applicable law or agreed to in writing, software
1059 * distributed under the License is distributed on an "AS IS" BASIS,
1060 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1061 * See the License for the specific language governing permissions and
1062 * limitations under the License.
1063 */
1064
1065(function webpackUniversalModuleDefinition(root, factory) {
1066    if (typeof exports === 'object' && typeof module === 'object')
1067        module.exports = factory();
1068    else if (typeof define === 'function' && define.amd)
1069        define("pdfjs-dist/build/pdf", [], factory);
1070    else if (typeof exports === 'object')
1071        exports["pdfjs-dist/build/pdf"] = factory();
1072    else
1073        root["pdfjs-dist/build/pdf"] = root.pdfjsDistBuildPdf = factory();
1074})(this, function () {
1075    return /******/ (function (modules) { // webpackBootstrap
1076        /******/ 	// The module cache
1077        /******/ 	var installedModules = {};
1078        /******/
1079        /******/ 	// The require function
1080        /******/ 	function __w_pdfjs_require__(moduleId) {
1081            /******/
1082            /******/ 		// Check if module is in cache
1083            /******/ 		if (installedModules[moduleId])
1084                /******/ 			return installedModules[moduleId].exports;
1085            /******/
1086            /******/ 		// Create a new module (and put it into the cache)
1087            /******/ 		var module = installedModules[moduleId] = {
1088                /******/ 			i: moduleId,
1089                /******/ 			l: false,
1090                /******/ 			exports: {}
1091                /******/};
1092            /******/
1093            /******/ 		// Execute the module function
1094            /******/ 		modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
1095            /******/
1096            /******/ 		// Flag the module as loaded
1097            /******/ 		module.l = true;
1098            /******/
1099            /******/ 		// Return the exports of the module
1100            /******/ 		return module.exports;
1101            /******/ 	}
1102        /******/
1103        /******/
1104        /******/ 	// expose the modules object (__webpack_modules__)
1105        /******/ 	__w_pdfjs_require__.m = modules;
1106        /******/
1107        /******/ 	// expose the module cache
1108        /******/ 	__w_pdfjs_require__.c = installedModules;
1109        /******/
1110        /******/ 	// identity function for calling harmony imports with the correct context
1111        /******/ 	__w_pdfjs_require__.i = function (value) {
1112            return value;
1113        };
1114        /******/
1115        /******/ 	// define getter function for harmony exports
1116        /******/ 	__w_pdfjs_require__.d = function (exports, name, getter) {
1117            /******/ 		if (!__w_pdfjs_require__.o(exports, name)) {
1118                /******/ 			Object.defineProperty(exports, name, {
1119                    /******/ 				configurable: false,
1120                    /******/ 				enumerable: true,
1121                    /******/ 				get: getter
1122                            /******/});
1123                /******/ 		}
1124            /******/ 	};
1125        /******/
1126        /******/ 	// getDefaultExport function for compatibility with non-harmony modules
1127        /******/ 	__w_pdfjs_require__.n = function (module) {
1128            /******/ 		var getter = module && module.__esModule ?
1129                    /******/ 			function getDefault() {
1130                        return module['default'];
1131                    } :
1132                    /******/ 			function getModuleExports() {
1133                        return module;
1134                    };
1135            /******/ 		__w_pdfjs_require__.d(getter, 'a', getter);
1136            /******/ 		return getter;
1137            /******/ 	};
1138        /******/
1139        /******/ 	// Object.prototype.hasOwnProperty.call
1140        /******/ 	__w_pdfjs_require__.o = function (object, property) {
1141            return Object.prototype.hasOwnProperty.call(object, property);
1142        };
1143        /******/
1144        /******/ 	// __webpack_public_path__
1145        /******/ 	__w_pdfjs_require__.p = "";
1146        /******/
1147        /******/ 	// Load entry module and return exports
1148        /******/ 	return __w_pdfjs_require__(__w_pdfjs_require__.s = 14);
1149        /******/ })
1150            /************************************************************************/
1151                    /******/([
1152                        /* 0 */
1153                        /***/ (function (module, exports, __w_pdfjs_require__) {
1154
1155                            "use strict";
1156                            /* WEBPACK VAR INJECTION */(function (global) {
1157                                var compatibility = __w_pdfjs_require__(13);
1158                                var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
1159                                var FONT_IDENTITY_MATRIX = [
1160                                    0.001,
1161                                    0,
1162                                    0,
1163                                    0.001,
1164                                    0,
1165                                    0
1166                                ];
1167                                var TextRenderingMode = {
1168                                    FILL: 0,
1169                                    STROKE: 1,
1170                                    FILL_STROKE: 2,
1171                                    INVISIBLE: 3,
1172                                    FILL_ADD_TO_PATH: 4,
1173                                    STROKE_ADD_TO_PATH: 5,
1174                                    FILL_STROKE_ADD_TO_PATH: 6,
1175                                    ADD_TO_PATH: 7,
1176                                    FILL_STROKE_MASK: 3,
1177                                    ADD_TO_PATH_FLAG: 4
1178                                };
1179                                var ImageKind = {
1180                                    GRAYSCALE_1BPP: 1,
1181                                    RGB_24BPP: 2,
1182                                    RGBA_32BPP: 3
1183                                };
1184                                var AnnotationType = {
1185                                    TEXT: 1,
1186                                    LINK: 2,
1187                                    FREETEXT: 3,
1188                                    LINE: 4,
1189                                    SQUARE: 5,
1190                                    CIRCLE: 6,
1191                                    POLYGON: 7,
1192                                    POLYLINE: 8,
1193                                    HIGHLIGHT: 9,
1194                                    UNDERLINE: 10,
1195                                    SQUIGGLY: 11,
1196                                    STRIKEOUT: 12,
1197                                    STAMP: 13,
1198                                    CARET: 14,
1199                                    INK: 15,
1200                                    POPUP: 16,
1201                                    FILEATTACHMENT: 17,
1202                                    SOUND: 18,
1203                                    MOVIE: 19,
1204                                    WIDGET: 20,
1205                                    SCREEN: 21,
1206                                    PRINTERMARK: 22,
1207                                    TRAPNET: 23,
1208                                    WATERMARK: 24,
1209                                    THREED: 25,
1210                                    REDACT: 26
1211                                };
1212                                var AnnotationFlag = {
1213                                    INVISIBLE: 0x01,
1214                                    HIDDEN: 0x02,
1215                                    PRINT: 0x04,
1216                                    NOZOOM: 0x08,
1217                                    NOROTATE: 0x10,
1218                                    NOVIEW: 0x20,
1219                                    READONLY: 0x40,
1220                                    LOCKED: 0x80,
1221                                    TOGGLENOVIEW: 0x100,
1222                                    LOCKEDCONTENTS: 0x200
1223                                };
1224                                var AnnotationFieldFlag = {
1225                                    READONLY: 0x0000001,
1226                                    REQUIRED: 0x0000002,
1227                                    NOEXPORT: 0x0000004,
1228                                    MULTILINE: 0x0001000,
1229                                    PASSWORD: 0x0002000,
1230                                    NOTOGGLETOOFF: 0x0004000,
1231                                    RADIO: 0x0008000,
1232                                    PUSHBUTTON: 0x0010000,
1233                                    COMBO: 0x0020000,
1234                                    EDIT: 0x0040000,
1235                                    SORT: 0x0080000,
1236                                    FILESELECT: 0x0100000,
1237                                    MULTISELECT: 0x0200000,
1238                                    DONOTSPELLCHECK: 0x0400000,
1239                                    DONOTSCROLL: 0x0800000,
1240                                    COMB: 0x1000000,
1241                                    RICHTEXT: 0x2000000,
1242                                    RADIOSINUNISON: 0x2000000,
1243                                    COMMITONSELCHANGE: 0x4000000
1244                                };
1245                                var AnnotationBorderStyleType = {
1246                                    SOLID: 1,
1247                                    DASHED: 2,
1248                                    BEVELED: 3,
1249                                    INSET: 4,
1250                                    UNDERLINE: 5
1251                                };
1252                                var StreamType = {
1253                                    UNKNOWN: 0,
1254                                    FLATE: 1,
1255                                    LZW: 2,
1256                                    DCT: 3,
1257                                    JPX: 4,
1258                                    JBIG: 5,
1259                                    A85: 6,
1260                                    AHX: 7,
1261                                    CCF: 8,
1262                                    RL: 9
1263                                };
1264                                var FontType = {
1265                                    UNKNOWN: 0,
1266                                    TYPE1: 1,
1267                                    TYPE1C: 2,
1268                                    CIDFONTTYPE0: 3,
1269                                    CIDFONTTYPE0C: 4,
1270                                    TRUETYPE: 5,
1271                                    CIDFONTTYPE2: 6,
1272                                    TYPE3: 7,
1273                                    OPENTYPE: 8,
1274                                    TYPE0: 9,
1275                                    MMTYPE1: 10
1276                                };
1277                                var VERBOSITY_LEVELS = {
1278                                    errors: 0,
1279                                    warnings: 1,
1280                                    infos: 5
1281                                };
1282                                var CMapCompressionType = {
1283                                    NONE: 0,
1284                                    BINARY: 1,
1285                                    STREAM: 2
1286                                };
1287                                var OPS = {
1288                                    dependency: 1,
1289                                    setLineWidth: 2,
1290                                    setLineCap: 3,
1291                                    setLineJoin: 4,
1292                                    setMiterLimit: 5,
1293                                    setDash: 6,
1294                                    setRenderingIntent: 7,
1295                                    setFlatness: 8,
1296                                    setGState: 9,
1297                                    save: 10,
1298                                    restore: 11,
1299                                    transform: 12,
1300                                    moveTo: 13,
1301                                    lineTo: 14,
1302                                    curveTo: 15,
1303                                    curveTo2: 16,
1304                                    curveTo3: 17,
1305                                    closePath: 18,
1306                                    rectangle: 19,
1307                                    stroke: 20,
1308                                    closeStroke: 21,
1309                                    fill: 22,
1310                                    eoFill: 23,
1311                                    fillStroke: 24,
1312                                    eoFillStroke: 25,
1313                                    closeFillStroke: 26,
1314                                    closeEOFillStroke: 27,
1315                                    endPath: 28,
1316                                    clip: 29,
1317                                    eoClip: 30,
1318                                    beginText: 31,
1319                                    endText: 32,
1320                                    setCharSpacing: 33,
1321                                    setWordSpacing: 34,
1322                                    setHScale: 35,
1323                                    setLeading: 36,
1324                                    setFont: 37,
1325                                    setTextRenderingMode: 38,
1326                                    setTextRise: 39,
1327                                    moveText: 40,
1328                                    setLeadingMoveText: 41,
1329                                    setTextMatrix: 42,
1330                                    nextLine: 43,
1331                                    showText: 44,
1332                                    showSpacedText: 45,
1333                                    nextLineShowText: 46,
1334                                    nextLineSetSpacingShowText: 47,
1335                                    setCharWidth: 48,
1336                                    setCharWidthAndBounds: 49,
1337                                    setStrokeColorSpace: 50,
1338                                    setFillColorSpace: 51,
1339                                    setStrokeColor: 52,
1340                                    setStrokeColorN: 53,
1341                                    setFillColor: 54,
1342                                    setFillColorN: 55,
1343                                    setStrokeGray: 56,
1344                                    setFillGray: 57,
1345                                    setStrokeRGBColor: 58,
1346                                    setFillRGBColor: 59,
1347                                    setStrokeCMYKColor: 60,
1348                                    setFillCMYKColor: 61,
1349                                    shadingFill: 62,
1350                                    beginInlineImage: 63,
1351                                    beginImageData: 64,
1352                                    endInlineImage: 65,
1353                                    paintXObject: 66,
1354                                    markPoint: 67,
1355                                    markPointProps: 68,
1356                                    beginMarkedContent: 69,
1357                                    beginMarkedContentProps: 70,
1358                                    endMarkedContent: 71,
1359                                    beginCompat: 72,
1360                                    endCompat: 73,
1361                                    paintFormXObjectBegin: 74,
1362                                    paintFormXObjectEnd: 75,
1363                                    beginGroup: 76,
1364                                    endGroup: 77,
1365                                    beginAnnotations: 78,
1366                                    endAnnotations: 79,
1367                                    beginAnnotation: 80,
1368                                    endAnnotation: 81,
1369                                    paintJpegXObject: 82,
1370                                    paintImageMaskXObject: 83,
1371                                    paintImageMaskXObjectGroup: 84,
1372                                    paintImageXObject: 85,
1373                                    paintInlineImageXObject: 86,
1374                                    paintInlineImageXObjectGroup: 87,
1375                                    paintImageXObjectRepeat: 88,
1376                                    paintImageMaskXObjectRepeat: 89,
1377                                    paintSolidColorImageMask: 90,
1378                                    constructPath: 91
1379                                };
1380                                var verbosity = VERBOSITY_LEVELS.warnings;
1381                                function setVerbosityLevel(level) {
1382                                    verbosity = level;
1383                                }
1384                                function getVerbosityLevel() {
1385                                    return verbosity;
1386                                }
1387                                function info(msg) {
1388                                    if (verbosity >= VERBOSITY_LEVELS.infos) {
1389                                        console.log('Info: ' + msg);
1390                                    }
1391                                }
1392                                function warn(msg) {
1393                                    if (verbosity >= VERBOSITY_LEVELS.warnings) {
1394                                        console.log('Warning: ' + msg);
1395                                    }
1396                                }
1397                                function deprecated(details) {
1398                                    console.log('Deprecated API usage: ' + details);
1399                                }
1400                                function error(msg) {
1401                                    if (verbosity >= VERBOSITY_LEVELS.errors) {
1402                                        console.log('Error: ' + msg);
1403                                        console.log(backtrace());
1404                                    }
1405                                    throw new Error(msg);
1406                                }
1407                                function backtrace() {
1408                                    try {
1409                                        throw new Error();
1410                                    } catch (e) {
1411                                        return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
1412                                    }
1413                                }
1414                                function assert(cond, msg) {
1415                                    if (!cond) {
1416                                        error(msg);
1417                                    }
1418                                }
1419                                var UNSUPPORTED_FEATURES = {
1420                                    unknown: 'unknown',
1421                                    forms: 'forms',
1422                                    javaScript: 'javaScript',
1423                                    smask: 'smask',
1424                                    shadingPattern: 'shadingPattern',
1425                                    font: 'font'
1426                                };
1427                                function isSameOrigin(baseUrl, otherUrl) {
1428                                    try {
1429                                        var base = new URL(baseUrl);
1430                                        if (!base.origin || base.origin === 'null') {
1431                                            return false;
1432                                        }
1433                                    } catch (e) {
1434                                        return false;
1435                                    }
1436                                    var other = new URL(otherUrl, base);
1437                                    return base.origin === other.origin;
1438                                }
1439                                function isValidProtocol(url) {
1440                                    if (!url) {
1441                                        return false;
1442                                    }
1443                                    switch (url.protocol) {
1444                                        case 'http:':
1445                                        case 'https:':
1446                                        case 'ftp:':
1447                                        case 'mailto:':
1448                                        case 'tel:':
1449                                            return true;
1450                                        default:
1451                                            return false;
1452                                    }
1453                                }
1454                                function createValidAbsoluteUrl(url, baseUrl) {
1455                                    if (!url) {
1456                                        return null;
1457                                    }
1458                                    try {
1459                                        var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
1460                                        if (isValidProtocol(absoluteUrl)) {
1461                                            return absoluteUrl;
1462                                        }
1463                                    } catch (ex) {
1464                                    }
1465                                    return null;
1466                                }
1467                                function shadow(obj, prop, value) {
1468                                    Object.defineProperty(obj, prop, {
1469                                        value: value,
1470                                        enumerable: true,
1471                                        configurable: true,
1472                                        writable: false
1473                                    });
1474                                    return value;
1475                                }
1476                                function getLookupTableFactory(initializer) {
1477                                    var lookup;
1478                                    return function () {
1479                                        if (initializer) {
1480                                            lookup = Object.create(null);
1481                                            initializer(lookup);
1482                                            initializer = null;
1483                                        }
1484                                        return lookup;
1485                                    };
1486                                }
1487                                var PasswordResponses = {
1488                                    NEED_PASSWORD: 1,
1489                                    INCORRECT_PASSWORD: 2
1490                                };
1491                                var PasswordException = function PasswordExceptionClosure() {
1492                                    function PasswordException(msg, code) {
1493                                        this.name = 'PasswordException';
1494                                        this.message = msg;
1495                                        this.code = code;
1496                                    }
1497                                    PasswordException.prototype = new Error();
1498                                    PasswordException.constructor = PasswordException;
1499                                    return PasswordException;
1500                                }();
1501                                var UnknownErrorException = function UnknownErrorExceptionClosure() {
1502                                    function UnknownErrorException(msg, details) {
1503                                        this.name = 'UnknownErrorException';
1504                                        this.message = msg;
1505                                        this.details = details;
1506                                    }
1507                                    UnknownErrorException.prototype = new Error();
1508                                    UnknownErrorException.constructor = UnknownErrorException;
1509                                    return UnknownErrorException;
1510                                }();
1511                                var InvalidPDFException = function InvalidPDFExceptionClosure() {
1512                                    function InvalidPDFException(msg) {
1513                                        this.name = 'InvalidPDFException';
1514                                        this.message = msg;
1515                                    }
1516                                    InvalidPDFException.prototype = new Error();
1517                                    InvalidPDFException.constructor = InvalidPDFException;
1518                                    return InvalidPDFException;
1519                                }();
1520                                var MissingPDFException = function MissingPDFExceptionClosure() {
1521                                    function MissingPDFException(msg) {
1522                                        this.name = 'MissingPDFException';
1523                                        this.message = msg;
1524                                    }
1525                                    MissingPDFException.prototype = new Error();
1526                                    MissingPDFException.constructor = MissingPDFException;
1527                                    return MissingPDFException;
1528                                }();
1529                                var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
1530                                    function UnexpectedResponseException(msg, status) {
1531                                        this.name = 'UnexpectedResponseException';
1532                                        this.message = msg;
1533                                        this.status = status;
1534                                    }
1535                                    UnexpectedResponseException.prototype = new Error();
1536                                    UnexpectedResponseException.constructor = UnexpectedResponseException;
1537                                    return UnexpectedResponseException;
1538                                }();
1539                                var NotImplementedException = function NotImplementedExceptionClosure() {
1540                                    function NotImplementedException(msg) {
1541                                        this.message = msg;
1542                                    }
1543                                    NotImplementedException.prototype = new Error();
1544                                    NotImplementedException.prototype.name = 'NotImplementedException';
1545                                    NotImplementedException.constructor = NotImplementedException;
1546                                    return NotImplementedException;
1547                                }();
1548                                var MissingDataException = function MissingDataExceptionClosure() {
1549                                    function MissingDataException(begin, end) {
1550                                        this.begin = begin;
1551                                        this.end = end;
1552                                        this.message = 'Missing data [' + begin + ', ' + end + ')';
1553                                    }
1554                                    MissingDataException.prototype = new Error();
1555                                    MissingDataException.prototype.name = 'MissingDataException';
1556                                    MissingDataException.constructor = MissingDataException;
1557                                    return MissingDataException;
1558                                }();
1559                                var XRefParseException = function XRefParseExceptionClosure() {
1560                                    function XRefParseException(msg) {
1561                                        this.message = msg;
1562                                    }
1563                                    XRefParseException.prototype = new Error();
1564                                    XRefParseException.prototype.name = 'XRefParseException';
1565                                    XRefParseException.constructor = XRefParseException;
1566                                    return XRefParseException;
1567                                }();
1568                                var NullCharactersRegExp = /\x00/g;
1569                                function removeNullCharacters(str) {
1570                                    if (typeof str !== 'string') {
1571                                        warn('The argument for removeNullCharacters must be a string.');
1572                                        return str;
1573                                    }
1574                                    return str.replace(NullCharactersRegExp, '');
1575                                }
1576                                function bytesToString(bytes) {
1577                                    assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
1578                                    var length = bytes.length;
1579                                    var MAX_ARGUMENT_COUNT = 8192;
1580                                    if (length < MAX_ARGUMENT_COUNT) {
1581                                        return String.fromCharCode.apply(null, bytes);
1582                                    }
1583                                    var strBuf = [];
1584                                    for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
1585                                        var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
1586                                        var chunk = bytes.subarray(i, chunkEnd);
1587                                        strBuf.push(String.fromCharCode.apply(null, chunk));
1588                                    }
1589                                    return strBuf.join('');
1590                                }
1591                                function stringToBytes(str) {
1592                                    assert(typeof str === 'string', 'Invalid argument for stringToBytes');
1593                                    var length = str.length;
1594                                    var bytes = new Uint8Array(length);
1595                                    for (var i = 0; i < length; ++i) {
1596                                        bytes[i] = str.charCodeAt(i) & 0xFF;
1597                                    }
1598                                    return bytes;
1599                                }
1600                                function arrayByteLength(arr) {
1601                                    if (arr.length !== undefined) {
1602                                        return arr.length;
1603                                    }
1604                                    assert(arr.byteLength !== undefined);
1605                                    return arr.byteLength;
1606                                }
1607                                function arraysToBytes(arr) {
1608                                    if (arr.length === 1 && arr[0] instanceof Uint8Array) {
1609                                        return arr[0];
1610                                    }
1611                                    var resultLength = 0;
1612                                    var i, ii = arr.length;
1613                                    var item, itemLength;
1614                                    for (i = 0; i < ii; i++) {
1615                                        item = arr[i];
1616                                        itemLength = arrayByteLength(item);
1617                                        resultLength += itemLength;
1618                                    }
1619                                    var pos = 0;
1620                                    var data = new Uint8Array(resultLength);
1621                                    for (i = 0; i < ii; i++) {
1622                                        item = arr[i];
1623                                        if (!(item instanceof Uint8Array)) {
1624                                            if (typeof item === 'string') {
1625                                                item = stringToBytes(item);
1626                                            } else {
1627                                                item = new Uint8Array(item);
1628                                            }
1629                                        }
1630                                        itemLength = item.byteLength;
1631                                        data.set(item, pos);
1632                                        pos += itemLength;
1633                                    }
1634                                    return data;
1635                                }
1636                                function string32(value) {
1637                                    return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
1638                                }
1639                                function log2(x) {
1640                                    var n = 1, i = 0;
1641                                    while (x > n) {
1642                                        n <<= 1;
1643                                        i++;
1644                                    }
1645                                    return i;
1646                                }
1647                                function readInt8(data, start) {
1648                                    return data[start] << 24 >> 24;
1649                                }
1650                                function readUint16(data, offset) {
1651                                    return data[offset] << 8 | data[offset + 1];
1652                                }
1653                                function readUint32(data, offset) {
1654                                    return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
1655                                }
1656                                function isLittleEndian() {
1657                                    var buffer8 = new Uint8Array(2);
1658                                    buffer8[0] = 1;
1659                                    var buffer16 = new Uint16Array(buffer8.buffer);
1660                                    return buffer16[0] === 1;
1661                                }
1662                                function isEvalSupported() {
1663                                    try {
1664                                        new Function('');
1665                                        return true;
1666                                    } catch (e) {
1667                                        return false;
vendor: 11,387 bytes, lines 1668-1845
1668                                    }
1669                                }
1670                                var Uint32ArrayView = function Uint32ArrayViewClosure() {
1671                                    function Uint32ArrayView(buffer, length) {
1672                                        this.buffer = buffer;
1673                                        this.byteLength = buffer.length;
1674                                        this.length = length === undefined ? this.byteLength >> 2 : length;
1675                                        ensureUint32ArrayViewProps(this.length);
1676                                    }
1677                                    Uint32ArrayView.prototype = Object.create(null);
1678                                    var uint32ArrayViewSetters = 0;
1679                                    function createUint32ArrayProp(index) {
1680                                        return {
1681                                            get: function () {
1682                                                var buffer = this.buffer, offset = index << 2;
1683                                                return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
1684                                            },
1685                                            set: function (value) {
1686                                                var buffer = this.buffer, offset = index << 2;
1687                                                buffer[offset] = value & 255;
1688                                                buffer[offset + 1] = value >> 8 & 255;
1689                                                buffer[offset + 2] = value >> 16 & 255;
1690                                                buffer[offset + 3] = value >>> 24 & 255;
1691                                            }
1692                                        };
1693                                    }
1694                                    function ensureUint32ArrayViewProps(length) {
1695                                        while (uint32ArrayViewSetters < length) {
1696                                            Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
1697                                            uint32ArrayViewSetters++;
1698                                        }
1699                                    }
1700                                    return Uint32ArrayView;
1701                                }();
1702                                exports.Uint32ArrayView = Uint32ArrayView;
1703                                var IDENTITY_MATRIX = [
1704                                    1,
1705                                    0,
1706                                    0,
1707                                    1,
1708                                    0,
1709                                    0
1710                                ];
1711                                var Util = function UtilClosure() {
1712                                    function Util() {
1713                                    }
1714                                    var rgbBuf = [
1715                                        'rgb(',
1716                                        0,
1717                                        ',',
1718                                        0,
1719                                        ',',
1720                                        0,
1721                                        ')'
1722                                    ];
1723                                    Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
1724                                        rgbBuf[1] = r;
1725                                        rgbBuf[3] = g;
1726                                        rgbBuf[5] = b;
1727                                        return rgbBuf.join('');
1728                                    };
1729                                    Util.transform = function Util_transform(m1, m2) {
1730                                        return [
1731                                            m1[0] * m2[0] + m1[2] * m2[1],
1732                                            m1[1] * m2[0] + m1[3] * m2[1],
1733                                            m1[0] * m2[2] + m1[2] * m2[3],
1734                                            m1[1] * m2[2] + m1[3] * m2[3],
1735                                            m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
1736                                            m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
1737                                        ];
1738                                    };
1739                                    Util.applyTransform = function Util_applyTransform(p, m) {
1740                                        var xt = p[0] * m[0] + p[1] * m[2] + m[4];
1741                                        var yt = p[0] * m[1] + p[1] * m[3] + m[5];
1742                                        return [
1743                                            xt,
1744                                            yt
1745                                        ];
1746                                    };
1747                                    Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
1748                                        var d = m[0] * m[3] - m[1] * m[2];
1749                                        var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
1750                                        var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
1751                                        return [
1752                                            xt,
1753                                            yt
1754                                        ];
1755                                    };
1756                                    Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
1757                                        var p1 = Util.applyTransform(r, m);
1758                                        var p2 = Util.applyTransform(r.slice(2, 4), m);
1759                                        var p3 = Util.applyTransform([
1760                                            r[0],
1761                                            r[3]
1762                                        ], m);
1763                                        var p4 = Util.applyTransform([
1764                                            r[2],
1765                                            r[1]
1766                                        ], m);
1767                                        return [
1768                                            Math.min(p1[0], p2[0], p3[0], p4[0]),
1769                                            Math.min(p1[1], p2[1], p3[1], p4[1]),
1770                                            Math.max(p1[0], p2[0], p3[0], p4[0]),
1771                                            Math.max(p1[1], p2[1], p3[1], p4[1])
1772                                        ];
1773                                    };
1774                                    Util.inverseTransform = function Util_inverseTransform(m) {
1775                                        var d = m[0] * m[3] - m[1] * m[2];
1776                                        return [
1777                                            m[3] / d,
1778                                            -m[1] / d,
1779                                            -m[2] / d,
1780                                            m[0] / d,
1781                                            (m[2] * m[5] - m[4] * m[3]) / d,
1782                                            (m[4] * m[1] - m[5] * m[0]) / d
1783                                        ];
1784                                    };
1785                                    Util.apply3dTransform = function Util_apply3dTransform(m, v) {
1786                                        return [
1787                                            m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
1788                                            m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
1789                                            m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
1790                                        ];
1791                                    };
1792                                    Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
1793                                        var transpose = [
1794                                            m[0],
1795                                            m[2],
1796                                            m[1],
1797                                            m[3]
1798                                        ];
1799                                        var a = m[0] * transpose[0] + m[1] * transpose[2];
1800                                        var b = m[0] * transpose[1] + m[1] * transpose[3];
1801                                        var c = m[2] * transpose[0] + m[3] * transpose[2];
1802                                        var d = m[2] * transpose[1] + m[3] * transpose[3];
1803                                        var first = (a + d) / 2;
1804                                        var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
1805                                        var sx = first + second || 1;
1806                                        var sy = first - second || 1;
1807                                        return [
1808                                            Math.sqrt(sx),
1809                                            Math.sqrt(sy)
1810                                        ];
1811                                    };
1812                                    Util.normalizeRect = function Util_normalizeRect(rect) {
1813                                        var r = rect.slice(0);
1814                                        if (rect[0] > rect[2]) {
1815                                            r[0] = rect[2];
1816                                            r[2] = rect[0];
1817                                        }
1818                                        if (rect[1] > rect[3]) {
1819                                            r[1] = rect[3];
1820                                            r[3] = rect[1];
1821                                        }
1822                                        return r;
1823                                    };
1824                                    Util.intersect = function Util_intersect(rect1, rect2) {
1825                                        function compare(a, b) {
1826                                            return a - b;
1827                                        }
1828                                        var orderedX = [
1829                                            rect1[0],
1830                                            rect1[2],
1831                                            rect2[0],
1832                                            rect2[2]
1833                                        ].sort(compare), orderedY = [
1834                                            rect1[1],
1835                                            rect1[3],
1836                                            rect2[1],
1837                                            rect2[3]
1838                                        ].sort(compare), result = [];
1839                                        rect1 = Util.normalizeRect(rect1);
1840                                        rect2 = Util.normalizeRect(rect2);
1841                                        if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
1842                                            result[0] = orderedX[1];
1843                                            result[2] = orderedX[2];
1844                                        } else {
1845                                            return false;
1846                                        }
1847                                        if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
1848                                            result[1] = orderedY[1];
1849                                            result[3] = orderedY[2];
1850                                        } else {
1851                                            return false;
1852                                        }
1853                                        return result;
1854                                    };
1855                                    Util.sign = function Util_sign(num) {
1856                                        return num < 0 ? -1 : 1;
1857                                    };
1858                                    var ROMAN_NUMBER_MAP = [
1859                                        '',
1860                                        'C',
1861                                        'CC',
1862                                        'CCC',
1863                                        'CD',
1864                                        'D',
1865                                        'DC',
1866                                        'DCC',
1867                                        'DCCC',
1868                                        'CM',
1869                                        '',
1870                                        'X',
1871                                        'XX',
1872                                        'XXX',
1873                                        'XL',
1874                                        'L',
1875                                        'LX',
1876                                        'LXX',
1877                                        'LXXX',
1878                                        'XC',
1879                                        '',
1880                                        'I',
1881                                        'II',
1882                                        'III',
1883                                        'IV',
1884                                        'V',
1885                                        'VI',
1886                                        'VII',
1887                                        'VIII',
1888                                        'IX'
1889                                    ];
1890                                    Util.toRoman = function Util_toRoman(number, lowerCase) {
1891                                        assert(isInt(number) && number > 0, 'The number should be a positive integer.');
1892                                        var pos, romanBuf = [];
1893                                        while (number >= 1000) {
1894                                            number -= 1000;
1895                                            romanBuf.push('M');
1896                                        }
1897                                        pos = number / 100 | 0;
1898                                        number %= 100;
1899                                        romanBuf.push(ROMAN_NUMBER_MAP[pos]);
1900                                        pos = number / 10 | 0;
1901                                        number %= 10;
1902                                        romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
1903                                        romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
1904                                        var romanStr = romanBuf.join('');
1905                                        return lowerCase ? romanStr.toLowerCase() : romanStr;
1906                                    };
1907                                    Util.appendToArray = function Util_appendToArray(arr1, arr2) {
1908                                        Array.prototype.push.apply(arr1, arr2);
1909                                    };
1910                                    Util.prependToArray = function Util_prependToArray(arr1, arr2) {
1911                                        Array.prototype.unshift.apply(arr1, arr2);
1912                                    };
1913                                    Util.extendObj = function extendObj(obj1, obj2) {
1914                                        for (var key in obj2) {
1915                                            obj1[key] = obj2[key];
1916                                        }
1917                                    };
1918                                    Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
1919                                        while (dict && !dict.has(name)) {
1920                                            dict = dict.get('Parent');
1921                                        }
1922                                        if (!dict) {
1923                                            return null;
1924                                        }
1925                                        return getArray ? dict.getArray(name) : dict.get(name);
1926                                    };
1927                                    Util.inherit = function Util_inherit(sub, base, prototype) {
1928                                        sub.prototype = Object.create(base.prototype);
1929                                        sub.prototype.constructor = sub;
1930                                        for (var prop in prototype) {
1931                                            sub.prototype[prop] = prototype[prop];
1932                                        }
1933                                    };
1934                                    Util.loadScript = function Util_loadScript(src, callback) {
1935                                        var script = document.createElement('script');
1936                                        var loaded = false;
vendor: 15,896 bytes, lines 1937-2240
1937                                        script.setAttribute('src', src);
1938                                        if (callback) {
1939                                            script.onload = function () {
1940                                                if (!loaded) {
1941                                                    callback();
1942                                                }
1943                                                loaded = true;
1944                                            };
1945                                        }
1946                                        document.getElementsByTagName('head')[0].appendChild(script);
1947                                    };
1948                                    return Util;
1949                                }();
1950                                var PageViewport = function PageViewportClosure() {
1951                                    function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
1952                                        this.viewBox = viewBox;
1953                                        this.scale = scale;
1954                                        this.rotation = rotation;
1955                                        this.offsetX = offsetX;
1956                                        this.offsetY = offsetY;
1957                                        var centerX = (viewBox[2] + viewBox[0]) / 2;
1958                                        var centerY = (viewBox[3] + viewBox[1]) / 2;
1959                                        var rotateA, rotateB, rotateC, rotateD;
1960                                        rotation = rotation % 360;
1961                                        rotation = rotation < 0 ? rotation + 360 : rotation;
1962                                        switch (rotation) {
1963                                            case 180:
1964                                                rotateA = -1;
1965                                                rotateB = 0;
1966                                                rotateC = 0;
1967                                                rotateD = 1;
1968                                                break;
1969                                            case 90:
1970                                                rotateA = 0;
1971                                                rotateB = 1;
1972                                                rotateC = 1;
1973                                                rotateD = 0;
1974                                                break;
1975                                            case 270:
1976                                                rotateA = 0;
1977                                                rotateB = -1;
1978                                                rotateC = -1;
1979                                                rotateD = 0;
1980                                                break;
1981                                            default:
1982                                                rotateA = 1;
1983                                                rotateB = 0;
1984                                                rotateC = 0;
1985                                                rotateD = -1;
1986                                                break;
1987                                        }
1988                                        if (dontFlip) {
1989                                            rotateC = -rotateC;
1990                                            rotateD = -rotateD;
1991                                        }
1992                                        var offsetCanvasX, offsetCanvasY;
1993                                        var width, height;
1994                                        if (rotateA === 0) {
1995                                            offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
1996                                            offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
1997                                            width = Math.abs(viewBox[3] - viewBox[1]) * scale;
1998                                            height = Math.abs(viewBox[2] - viewBox[0]) * scale;
1999                                        } else {
2000                                            offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
2001                                            offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
2002                                            width = Math.abs(viewBox[2] - viewBox[0]) * scale;
2003                                            height = Math.abs(viewBox[3] - viewBox[1]) * scale;
2004                                        }
2005                                        this.transform = [
2006                                            rotateA * scale,
2007                                            rotateB * scale,
2008                                            rotateC * scale,
2009                                            rotateD * scale,
2010                                            offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
2011                                            offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
2012                                        ];
2013                                        this.width = width;
2014                                        this.height = height;
2015                                        this.fontScale = scale;
2016                                    }
2017                                    PageViewport.prototype = {
2018                                        clone: function PageViewPort_clone(args) {
2019                                            args = args || {};
2020                                            var scale = 'scale' in args ? args.scale : this.scale;
2021                                            var rotation = 'rotation' in args ? args.rotation : this.rotation;
2022                                            return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
2023                                        },
2024                                        convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
2025                                            return Util.applyTransform([
2026                                                x,
2027                                                y
2028                                            ], this.transform);
2029                                        },
2030                                        convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
2031                                            var tl = Util.applyTransform([
2032                                                rect[0],
2033                                                rect[1]
2034                                            ], this.transform);
2035                                            var br = Util.applyTransform([
2036                                                rect[2],
2037                                                rect[3]
2038                                            ], this.transform);
2039                                            return [
2040                                                tl[0],
2041                                                tl[1],
2042                                                br[0],
2043                                                br[1]
2044                                            ];
2045                                        },
2046                                        convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
2047                                            return Util.applyInverseTransform([
2048                                                x,
2049                                                y
2050                                            ], this.transform);
2051                                        }
2052                                    };
2053                                    return PageViewport;
2054                                }();
2055                                var PDFStringTranslateTable = [
2056                                    0,
2057                                    0,
2058                                    0,
2059                                    0,
2060                                    0,
2061                                    0,
2062                                    0,
2063                                    0,
2064                                    0,
2065                                    0,
2066                                    0,
2067                                    0,
2068                                    0,
2069                                    0,
2070                                    0,
2071                                    0,
2072                                    0,
2073                                    0,
2074                                    0,
2075                                    0,
2076                                    0,
2077                                    0,
2078                                    0,
2079                                    0,
2080                                    0x2D8,
2081                                    0x2C7,
2082                                    0x2C6,
2083                                    0x2D9,
2084                                    0x2DD,
2085                                    0x2DB,
2086                                    0x2DA,
2087                                    0x2DC,
2088                                    0,
2089                                    0,
2090                                    0,
2091                                    0,
2092                                    0,
2093                                    0,
2094                                    0,
2095                                    0,
2096                                    0,
2097                                    0,
2098                                    0,
2099                                    0,
2100                                    0,
2101                                    0,
2102                                    0,
2103                                    0,
2104                                    0,
2105                                    0,
2106                                    0,
2107                                    0,
2108                                    0,
2109                                    0,
2110                                    0,
2111                                    0,
2112                                    0,
2113                                    0,
2114                                    0,
2115                                    0,
2116                                    0,
2117                                    0,
2118                                    0,
2119                                    0,
2120                                    0,
2121                                    0,
2122                                    0,
2123                                    0,
2124                                    0,
2125                                    0,
2126                                    0,
2127                                    0,
2128                                    0,
2129                                    0,
2130                                    0,
2131                                    0,
2132                                    0,
2133                                    0,
2134                                    0,
2135                                    0,
2136                                    0,
2137                                    0,
2138                                    0,
2139                                    0,
2140                                    0,
2141                                    0,
2142                                    0,
2143                                    0,
2144                                    0,
2145                                    0,
2146                                    0,
2147                                    0,
2148                                    0,
2149                                    0,
2150                                    0,
2151                                    0,
2152                                    0,
2153                                    0,
2154                                    0,
2155                                    0,
2156                                    0,
2157                                    0,
2158                                    0,
2159                                    0,
2160                                    0,
2161                                    0,
2162                                    0,
2163                                    0,
2164                                    0,
2165                                    0,
2166                                    0,
2167                                    0,
2168                                    0,
2169                                    0,
2170                                    0,
2171                                    0,
2172                                    0,
2173                                    0,
2174                                    0,
2175                                    0,
2176                                    0,
2177                                    0,
2178                                    0,
2179                                    0,
2180                                    0,
2181                                    0,
2182                                    0,
2183                                    0,
2184                                    0x2022,
2185                                    0x2020,
2186                                    0x2021,
2187                                    0x2026,
2188                                    0x2014,
2189                                    0x2013,
2190                                    0x192,
2191                                    0x2044,
2192                                    0x2039,
2193                                    0x203A,
2194                                    0x2212,
2195                                    0x2030,
2196                                    0x201E,
2197                                    0x201C,
2198                                    0x201D,
2199                                    0x2018,
2200                                    0x2019,
2201                                    0x201A,
2202                                    0x2122,
2203                                    0xFB01,
2204                                    0xFB02,
2205                                    0x141,
2206                                    0x152,
2207                                    0x160,
2208                                    0x178,
2209                                    0x17D,
2210                                    0x131,
2211                                    0x142,
2212                                    0x153,
2213                                    0x161,
2214                                    0x17E,
2215                                    0,
2216                                    0x20AC
2217                                ];
2218                                function stringToPDFString(str) {
2219                                    var i, n = str.length, strBuf = [];
2220                                    if (str[0] === '\xFE' && str[1] === '\xFF') {
2221                                        for (i = 2; i < n; i += 2) {
2222                                            strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
2223                                        }
2224                                    } else {
2225                                        for (i = 0; i < n; ++i) {
2226                                            var code = PDFStringTranslateTable[str.charCodeAt(i)];
2227                                            strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
2228                                        }
2229                                    }
2230                                    return strBuf.join('');
2231                                }
2232                                function stringToUTF8String(str) {
2233                                    return decodeURIComponent(escape(str));
2234                                }
2235                                function utf8StringToString(str) {
2236                                    return unescape(encodeURIComponent(str));
2237                                }
2238                                function isEmptyObj(obj) {
2239                                    for (var key in obj) {
2240                                        return false;
vendor: 6,377 bytes, lines 2241-2343
2241                                    }
2242                                    return true;
2243                                }
2244                                function isBool(v) {
2245                                    return typeof v === 'boolean';
2246                                }
2247                                function isInt(v) {
2248                                    return typeof v === 'number' && (v | 0) === v;
2249                                }
2250                                function isNum(v) {
2251                                    return typeof v === 'number';
2252                                }
2253                                function isString(v) {
2254                                    return typeof v === 'string';
2255                                }
2256                                function isArray(v) {
2257                                    return v instanceof Array;
2258                                }
2259                                function isArrayBuffer(v) {
2260                                    return typeof v === 'object' && v !== null && v.byteLength !== undefined;
2261                                }
2262                                function isSpace(ch) {
2263                                    return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
2264                                }
2265                                function isNodeJS() {
2266                                    if (typeof __pdfjsdev_webpack__ === 'undefined') {
2267                                        return typeof process === 'object' && process + '' === '[object process]';
2268                                    }
2269                                    return false;
2270                                }
2271                                function createPromiseCapability() {
2272                                    var capability = {};
2273                                    capability.promise = new Promise(function (resolve, reject) {
2274                                        capability.resolve = resolve;
2275                                        capability.reject = reject;
2276                                    });
2277                                    return capability;
2278                                }
2279                                var StatTimer = function StatTimerClosure() {
2280                                    function rpad(str, pad, length) {
2281                                        while (str.length < length) {
2282                                            str += pad;
2283                                        }
2284                                        return str;
2285                                    }
2286                                    function StatTimer() {
2287                                        this.started = Object.create(null);
2288                                        this.times = [];
2289                                        this.enabled = true;
2290                                    }
2291                                    StatTimer.prototype = {
2292                                        time: function StatTimer_time(name) {
2293                                            if (!this.enabled) {
2294                                                return;
2295                                            }
2296                                            if (name in this.started) {
2297                                                warn('Timer is already running for ' + name);
2298                                            }
2299                                            this.started[name] = Date.now();
2300                                        },
2301                                        timeEnd: function StatTimer_timeEnd(name) {
2302                                            if (!this.enabled) {
2303                                                return;
2304                                            }
2305                                            if (!(name in this.started)) {
2306                                                warn('Timer has not been started for ' + name);
2307                                            }
2308                                            this.times.push({
2309                                                'name': name,
2310                                                'start': this.started[name],
2311                                                'end': Date.now()
2312                                            });
2313                                            delete this.started[name];
2314                                        },
2315                                        toString: function StatTimer_toString() {
2316                                            var i, ii;
2317                                            var times = this.times;
2318                                            var out = '';
2319                                            var longest = 0;
2320                                            for (i = 0, ii = times.length; i < ii; ++i) {
2321                                                var name = times[i]['name'];
2322                                                if (name.length > longest) {
2323                                                    longest = name.length;
2324                                                }
2325                                            }
2326                                            for (i = 0, ii = times.length; i < ii; ++i) {
2327                                                var span = times[i];
2328                                                var duration = span.end - span.start;
2329                                                out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
2330                                            }
2331                                            return out;
2332                                        }
2333                                    };
2334                                    return StatTimer;
2335                                }();
2336                                var createBlob = function createBlob(data, contentType) {
2337                                    if (typeof Blob !== 'undefined') {
2338                                        return new Blob([data], {type: contentType});
2339                                    }
2340                                    warn('The "Blob" constructor is not supported.');
2341                                };
2342                                var createObjectURL = function createObjectURLClosure() {
2343                                    var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2343+/=';
2344                                    return function createObjectURL(data, contentType, forceDataSchema) {
2345                                        if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
2346                                            var blob = createBlob(data, contentType);
2347                                            return URL.createObjectURL(blob);
2348                                        }
2349                                        var buffer = 'data:' + contentType + ';base64,';
2350                                        for (var i = 0, ii = data.length; i < ii; i += 3) {
2351                                            var b1 = data[i] & 0xFF;
2352                                            var b2 = data[i + 1] & 0xFF;
2353                                            var b3 = data[i + 2] & 0xFF;
2354                                            var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
2355                                            var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
2356                                            var d4 = i + 2 < ii ? b3 & 0x3F : 64;
2357                                            buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
2358                                        }
2359                                        return buffer;
2360                                    };
2361                                }();
2362                                function MessageHandler(sourceName, targetName, comObj) {
2363                                    this.sourceName = sourceName;
2364                                    this.targetName = targetName;
2365                                    this.comObj = comObj;
2366                                    this.callbackIndex = 1;
2367                                    this.postMessageTransfers = true;
2368                                    var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
2369                                    var ah = this.actionHandler = Object.create(null);
2370                                    this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
2371                                        var data = event.data;
2372                                        if (data.targetName !== this.sourceName) {
2373                                            return;
2374                                        }
2375                                        if (data.isReply) {
2376                                            var callbackId = data.callbackId;
2377                                            if (data.callbackId in callbacksCapabilities) {
2378                                                var callback = callbacksCapabilities[callbackId];
2379                                                delete callbacksCapabilities[callbackId];
2380                                                if ('error' in data) {
2381                                                    callback.reject(data.error);
2382                                                } else {
2383                                                    callback.resolve(data.data);
2384                                                }
2385                                            } else {
2386                                                error('Cannot resolve callback ' + callbackId);
2387                                            }
2388                                        } else if (data.action in ah) {
2389                                            var action = ah[data.action];
2390                                            if (data.callbackId) {
2391                                                var sourceName = this.sourceName;
2392                                                var targetName = data.sourceName;
2393                                                Promise.resolve().then(function () {
2394                                                    return action[0].call(action[1], data.data);
2395                                                }).then(function (result) {
2396                                                    comObj.postMessage({
2397                                                        sourceName: sourceName,
2398                                                        targetName: targetName,
2399                                                        isReply: true,
2400                                                        callbackId: data.callbackId,
2401                                                        data: result
2402                                                    });
2403                                                }, function (reason) {
2404                                                    if (reason instanceof Error) {
2405                                                        reason = reason + '';
2406                                                    }
2407                                                    comObj.postMessage({
2408                                                        sourceName: sourceName,
2409                                                        targetName: targetName,
2410                                                        isReply: true,
2411                                                        callbackId: data.callbackId,
2412                                                        error: reason
2413                                                    });
2414                                                });
2415                                            } else {
2416                                                action[0].call(action[1], data.data);
2417                                            }
2418                                        } else {
2419                                            error('Unknown action from worker: ' + data.action);
2420                                        }
2421                                    }.bind(this);
2422                                    comObj.addEventListener('message', this._onComObjOnMessage);
2423                                }
2424                                MessageHandler.prototype = {
2425                                    on: function messageHandlerOn(actionName, handler, scope) {
2426                                        var ah = this.actionHandler;
2427                                        if (ah[actionName]) {
2428                                            error('There is already an actionName called "' + actionName + '"');
2429                                        }
2430                                        ah[actionName] = [
2431                                            handler,
2432                                            scope
2433                                        ];
2434                                    },
2435                                    send: function messageHandlerSend(actionName, data, transfers) {
2436                                        var message = {
2437                                            sourceName: this.sourceName,
2438                                            targetName: this.targetName,
2439                                            action: actionName,
2440                                            data: data
2441                                        };
2442                                        this.postMessage(message, transfers);
2443                                    },
2444                                    sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
2445                                        var callbackId = this.callbackIndex++;
2446                                        var message = {
2447                                            sourceName: this.sourceName,
2448                                            targetName: this.targetName,
2449                                            action: actionName,
2450                                            data: data,
2451                                            callbackId: callbackId
2452                                        };
2453                                        var capability = createPromiseCapability();
2454                                        this.callbacksCapabilities[callbackId] = capability;
2455                                        try {
2456                                            this.postMessage(message, transfers);
2457                                        } catch (e) {
2458                                            capability.reject(e);
2459                                        }
2460                                        return capability.promise;
2461                                    },
2462                                    postMessage: function (message, transfers) {
2463                                        if (transfers && this.postMessageTransfers) {
2464                                            this.comObj.postMessage(message, transfers);
2465                                        } else {
2466                                            this.comObj.postMessage(message);
2467                                        }
2468                                    },
2469                                    destroy: function () {
2470                                        this.comObj.removeEventListener('message', this._onComObjOnMessage);
2471                                    }
2472                                };
2473                                function loadJpegStream(id, imageUrl, objs) {
2474                                    var img = new Image();
2475                                    img.onload = function loadJpegStream_onloadClosure() {
2476                                        objs.resolve(id, img);
2477                                    };
2478                                    img.onerror = function loadJpegStream_onerrorClosure() {
2479                                        objs.resolve(id, null);
2480                                        warn('Error during JPEG image loading');
2481                                    };
2482                                    img.src = imageUrl;
2483                                }
2484                                exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
2485                                exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
2486                                exports.OPS = OPS;
2487                                exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
2488                                exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
2489                                exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
2490                                exports.AnnotationFieldFlag = AnnotationFieldFlag;
2491                                exports.AnnotationFlag = AnnotationFlag;
2492                                exports.AnnotationType = AnnotationType;
2493                                exports.FontType = FontType;
2494                                exports.ImageKind = ImageKind;
2495                                exports.CMapCompressionType = CMapCompressionType;
2496                                exports.InvalidPDFException = InvalidPDFException;
2497                                exports.MessageHandler = MessageHandler;
2498                                exports.MissingDataException = MissingDataException;
2499                                exports.MissingPDFException = MissingPDFException;
2500                                exports.NotImplementedException = NotImplementedException;
2501                                exports.PageViewport = PageViewport;
2502                                exports.PasswordException = PasswordException;
2503                                exports.PasswordResponses = PasswordResponses;
2504                                exports.StatTimer = StatTimer;
2505                                exports.StreamType = StreamType;
2506                                exports.TextRenderingMode = TextRenderingMode;
2507                                exports.UnexpectedResponseException = UnexpectedResponseException;
2508                                exports.UnknownErrorException = UnknownErrorException;
2509                                exports.Util = Util;
2510                                exports.XRefParseException = XRefParseException;
2511                                exports.arrayByteLength = arrayByteLength;
2512                                exports.arraysToBytes = arraysToBytes;
2513                                exports.assert = assert;
2514                                exports.bytesToString = bytesToString;
2515                                exports.createBlob = createBlob;
2516                                exports.createPromiseCapability = createPromiseCapability;
2517                                exports.createObjectURL = createObjectURL;
2518                                exports.deprecated = deprecated;
2519                                exports.error = error;
2520                                exports.getLookupTableFactory = getLookupTableFactory;
2521                                exports.getVerbosityLevel = getVerbosityLevel;
2522                                exports.globalScope = globalScope;
2523                                exports.info = info;
2524                                exports.isArray = isArray;
2525                                exports.isArrayBuffer = isArrayBuffer;
2526                                exports.isBool = isBool;
2527                                exports.isEmptyObj = isEmptyObj;
2528                                exports.isInt = isInt;
2529                                exports.isNum = isNum;
2530                                exports.isString = isString;
2531                                exports.isSpace = isSpace;
2532                                exports.isNodeJS = isNodeJS;
2533                                exports.isSameOrigin = isSameOrigin;
2534                                exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
2535                                exports.isLittleEndian = isLittleEndian;
2536                                exports.isEvalSupported = isEvalSupported;
2537                                exports.loadJpegStream = loadJpegStream;
2538                                exports.log2 = log2;
2539                                exports.readInt8 = readInt8;
2540                                exports.readUint16 = readUint16;
2541                                exports.readUint32 = readUint32;
2542                                exports.removeNullCharacters = removeNullCharacters;
2543                                exports.setVerbosityLevel = setVerbosityLevel;
2544                                exports.shadow = shadow;
2545                                exports.string32 = string32;
2546                                exports.stringToBytes = stringToBytes;
2547                                exports.stringToPDFString = stringToPDFString;
2548                                exports.stringToUTF8String = stringToUTF8String;
2549                                exports.utf8StringToString = utf8StringToString;
2550                                exports.warn = warn;
2551                                /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(6)))
2552
2553                            /***/ }),
2554                        /* 1 */
2555                        /***/ (function (module, exports, __w_pdfjs_require__) {
2556
2557                            "use strict";
2558
2559                            var sharedUtil = __w_pdfjs_require__(0);
2560                            var assert = sharedUtil.assert;
2561                            var removeNullCharacters = sharedUtil.removeNullCharacters;
2562                            var warn = sharedUtil.warn;
2563                            var deprecated = sharedUtil.deprecated;
2564                            var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
2565                            var stringToBytes = sharedUtil.stringToBytes;
2566                            var CMapCompressionType = sharedUtil.CMapCompressionType;
2567                            var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
2568                            function DOMCanvasFactory() {
2569                            }
2570                            DOMCanvasFactory.prototype = {
2571                                create: function DOMCanvasFactory_create(width, height) {
2572                                    assert(width > 0 && height > 0, 'invalid canvas size');
2573                                    var canvas = document.createElement('canvas');
2574                                    var context = canvas.getContext('2d');
2575                                    canvas.width = width;
2576                                    canvas.height = height;
2577                                    return {
2578                                        canvas: canvas,
2579                                        context: context
2580                                    };
2581                                },
2582                                reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
2583                                    assert(canvasAndContextPair.canvas, 'canvas is not specified');
2584                                    assert(width > 0 && height > 0, 'invalid canvas size');
2585                                    canvasAndContextPair.canvas.width = width;
2586                                    canvasAndContextPair.canvas.height = height;
2587                                },
2588                                destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
2589                                    assert(canvasAndContextPair.canvas, 'canvas is not specified');
2590                                    canvasAndContextPair.canvas.width = 0;
2591                                    canvasAndContextPair.canvas.height = 0;
2592                                    canvasAndContextPair.canvas = null;
2593                                    canvasAndContextPair.context = null;
2594                                }
2595                            };
2596                            var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
2597                                function DOMCMapReaderFactory(params) {
2598                                    this.baseUrl = params.baseUrl || null;
2599                                    this.isCompressed = params.isCompressed || false;
2600                                }
2601                                DOMCMapReaderFactory.prototype = {
2602                                    fetch: function (params) {
2603                                        if (!params.name) {
2604                                            return Promise.reject(new Error('CMap name must be specified.'));
2605                                        }
2606                                        return new Promise(function (resolve, reject) {
2607                                            var url = this.baseUrl + params.name;
2608                                            var request = new XMLHttpRequest();
2609                                            if (this.isCompressed) {
2610                                                url += '.bcmap';
2611                                                request.responseType = 'arraybuffer';
2612                                            }
2613                                            request.onreadystatechange = function () {
2614                                                if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
2615                                                    var data;
2616                                                    if (this.isCompressed && request.response) {
2617                                                        data = new Uint8Array(request.response);
2618                                                    } else if (!this.isCompressed && request.responseText) {
2619                                                        data = stringToBytes(request.responseText);
2620                                                    }
2621                                                    if (data) {
2622                                                        resolve({
2623                                                            cMapData: data,
2624                                                            compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
2625                                                        });
2626                                                        return;
2627                                                    }
2628                                                    reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
2629                                                }
2630                                            }.bind(this);
2631                                            request.open('GET', url, true);
2632                                            request.send(null);
2633                                        }.bind(this));
2634                                    }
2635                                };
2636                                return DOMCMapReaderFactory;
2637                            }();
2638                            var CustomStyle = function CustomStyleClosure() {
2639                                var prefixes = [
2640                                    'ms',
2641                                    'Moz',
2642                                    'Webkit',
2643                                    'O'
2644                                ];
2645                                var _cache = Object.create(null);
2646                                function CustomStyle() {
2647                                }
2648                                CustomStyle.getProp = function get(propName, element) {
2649                                    if (arguments.length === 1 && typeof _c
2649ache[propName] === 'string') {
2650                                        return _cache[propName];
2651                                    }
2652                                    element = element || document.documentElement;
2653                                    var style = element.style, prefixed, uPropName;
2654                                    if (typeof style[propName] === 'string') {
2655                                        return _cache[propName] = propName;
2656                                    }
2657                                    uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
2658                                    for (var i = 0, l = prefixes.length; i < l; i++) {
2659                                        prefixed = prefixes[i] + uPropName;
2660                                        if (typeof style[prefixed] === 'string') {
2661                                            return _cache[propName] = prefixed;
2662                                        }
2663                                    }
2664                                    return _cache[propName] = 'undefined';
2665                                };
2666                                CustomStyle.setProp = function set(propName, element, str) {
2667                                    var prop = this.getProp(propName);
2668                                    if (prop !== 'undefined') {
2669                                        element.style[prop] = str;
2670                                    }
2671                                };
2672                                return CustomStyle;
2673                            }();
2674                            var hasCanvasTypedArrays;
2675                            hasCanvasTypedArrays = function hasCanvasTypedArrays() {
2676                                var canvas = document.createElement('canvas');
2677                                canvas.width = canvas.height = 1;
2678                                var ctx = canvas.getContext('2d');
2679                                var imageData = ctx.createImageData(1, 1);
2680                                return typeof imageData.data.buffer !== 'undefined';
2681                            };
2682                            var LinkTarget = {
2683                                NONE: 0,
2684                                SELF: 1,
2685                                BLANK: 2,
2686                                PARENT: 3,
2687                                TOP: 4
2688                            };
2689                            var LinkTargetStringMap = [
2690                                '',
2691                                '_self',
2692                                '_blank',
2693                                '_parent',
2694                                '_top'
2695                            ];
2696                            function addLinkAttributes(link, params) {
2697                                var url = params && params.url;
2698                                link.href = link.title = url ? removeNullCharacters(url) : '';
2699                                if (url) {
2700                                    var target = params.target;
2701                                    if (typeof target === 'undefined') {
2702                                        target = getDefaultSetting('externalLinkTarget');
2703                                    }
2704                                    link.target = LinkTargetStringMap[target];
2705                                    var rel = params.rel;
2706                                    if (typeof rel === 'undefined') {
2707                                        rel = getDefaultSetting('externalLinkRel');
2708                                    }
2709                                    link.rel = rel;
2710                                }
2711                            }
2712                            function getFilenameFromUrl(url) {
2713                                var anchor = url.indexOf('#');
2714                                var query = url.indexOf('?');
2715                                var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
2716                                return url.substring(url.lastIndexOf('/', end) + 1, end);
2717                            }
2718                            function getDefaultSetting(id) {
2719                                var globalSettings = sharedUtil.globalScope.PDFJS;
2720                                switch (id) {
2721                                    case 'pdfBug':
2722                                        return globalSettings ? globalSettings.pdfBug : false;
2723                                    case 'disableAutoFetch':
2724                                        return globalSettings ? globalSettings.disableAutoFetch : false;
2725                                    case 'disableStream':
2726                                        return globalSettings ? globalSettings.disableStream : false;
2727                                    case 'disableRange':
2728                                        return globalSettings ? globalSettings.disableRange : false;
2729                                    case 'disableFontFace':
2730                                        return globalSettings ? globalSettings.disableFontFace : false;
2731                                    case 'disableCreateObjectURL':
2732                                        return globalSettings ? globalSettings.disableCreateObjectURL : false;
2733                                    case 'disableWebGL':
2734                                        return globalSettings ? globalSettings.disableWebGL : true;
2735                                    case 'cMapUrl':
2736                                        return globalSettings ? globalSettings.cMapUrl : null;
2737                                    case 'cMapPacked':
2738                                        return globalSettings ? globalSettings.cMapPacked : false;
2739                                    case 'postMessageTransfers':
2740                                        return globalSettings ? globalSettings.postMessageTransfers : true;
2741                                    case 'workerPort':
2742                                        return globalSettings ? globalSettings.workerPort : null;
2743                                    case 'workerSrc':
2744                                        return globalSettings ? globalSettings.workerSrc : null;
2745                                    case 'disableWorker':
2746                                        return globalSettings ? globalSettings.disableWorker : false;
2747                                    case 'maxImageSize':
2748                                        return globalSettings ? globalSettings.maxImageSize : -1;
2749                                    case 'imageResourcesPath':
2750                                        return globalSettings ? globalSettings.imageResourcesPath : '';
2751                                    case 'isEvalSupported':
2752                                        return globalSettings ? globalSettings.isEvalSupported : true;
2753                                    case 'externalLinkTarget':
2754                                        if (!globalSettings) {
2755                                            return LinkTarget.NONE;
2756                                        }
2757                                        switch (globalSettings.externalLinkTarget) {
2758                                            case LinkTarget.NONE:
2759                                            case LinkTarget.SELF:
2760                                            case LinkTarget.BLANK:
2761                                            case LinkTarget.PARENT:
2762                                            case LinkTarget.TOP:
2763                                                return globalSettings.externalLinkTarget;
2764                                        }
2765                                        warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
2766                                        globalSettings.externalLinkTarget = LinkTarget.NONE;
2767                                        return LinkTarget.NONE;
2768                                    case 'externalLinkRel':
2769                                        return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
2770                                    case 'enableStats':
2771                                        return !!(globalSettings && globalSettings.enableStats);
2772                                    default:
2773                                        throw new Error('Unknown default setting: ' + id);
2774                                }
2775                            }
2776                            function isExternalLinkTargetSet() {
2777                                var externalLinkTarget = getDefaultSetting('externalLinkTarget');
2778                                switch (externalLinkTarget) {
2779                                    case LinkTarget.NONE:
2780                                        return false;
2781                                    case LinkTarget.SELF:
2782                                    case LinkTarget.BLANK:
2783                                    case LinkTarget.PARENT:
2784                                    case LinkTarget.TOP:
2785                                        return true;
2786                                }
2787                            }
2788                            function isValidUrl(url, allowRelative) {
2789                                deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
2790                                var baseUrl = allowRelative ? 'http://example.com' : null;
2791                                return createValidAbsoluteUrl(url, baseUrl) !== null;
2792                            }
2793                            exports.CustomStyle = CustomStyle;
2794                            exports.addLinkAttributes = addLinkAttributes;
2795                            exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
2796                            exports.isValidUrl = isValidUrl;
2797                            exports.getFilenameFromUrl = getFilenameFromUrl;
2798                            exports.LinkTarget = LinkTarget;
2799                            exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
2800                            exports.getDefaultSetting = getDefaultSetting;
2801                            exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
2802                            exports.DOMCanvasFactory = DOMCanvasFactory;
2803                            exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
2804
2805                            /***/ }),
2806                        /* 2 */
2807                        /***/ (function (module, exports, __w_pdfjs_require__) {
2808
2809                            "use strict";
2810
2811                            var sharedUtil = __w_pdfjs_require__(0);
2812                            var displayDOMUtils = __w_pdfjs_require__(1);
2813                            var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
2814                            var AnnotationType = sharedUtil.AnnotationType;
2815                            var stringToPDFString = sharedUtil.stringToPDFString;
2816                            var Util = sharedUtil.Util;
2817                            var addLinkAttributes = displayDOMUtils.addLinkAttributes;
2818                            var LinkTarget = displayDOMUtils.LinkTarget;
2819                            var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
2820                            var warn = sharedUtil.warn;
2821                            var CustomStyle = displayDOMUtils.CustomStyle;
2822                            var getDefaultSetting = displayDOMUtils.getDefaultSetting;
2823                            function AnnotationElementFactory() {
2824                            }
2825                            AnnotationElementFactory.prototype = {
2826                                create: function AnnotationElementFactory_create(parameters) {
2827                                    var subtype = parameters.data.annotationType;
2828                                    switch (subtype) {
2829                                        case AnnotationType.LINK:
2830                                            return new LinkAnnotationElement(parameters);
2831                                        case AnnotationType.TEXT:
2832                                            return new TextAnnotationElement(parameters);
2833                                        case AnnotationType.WIDGET:
2834                                            var fieldType = parameters.data.fieldType;
2835                                            switch (fieldType) {
2836                                                case 'Tx':
2837                                                    return new TextWidgetAnnotationElement(parameters);
2838                                                case 'Btn':
2839                                                    if (parameters.data.radioButton) {
2840                                                        return new RadioButtonWidgetAnnotationElement(parameters);
2841                                                    } else if (parameters.data.checkBox) {
2842                                                        return new CheckboxWidgetAnnotationElement(parameters);
2843                                                    }
2844                                                    warn('Unimplemented button widget annotation: pushbutton');
2845                                                    break;
2846                                                case 'Ch':
2847                                                    return new ChoiceWidgetAnnotationElement(parameters);
2848                                            }
2849                                            return new WidgetAnnotationElement(parameters);
2850                                        case AnnotationType.POPUP:
2851                                            return new PopupAnnotationElement(parameters);
2852                                        case AnnotationType.HIGHLIGHT:
2853                                            return new HighlightAnnotationElement(parameters);
2854                                        case AnnotationType.UNDERLINE:
2855                                            return new UnderlineAnnotationElement(parameters);
2856                                        case AnnotationType.SQUIGGLY:
2857                                            return new SquigglyAnnotationElement(parameters);
2858                                        case AnnotationType.STRIKEOUT:
2859                                            return new StrikeOutAnnotationElement(parameters);
2860                                        case AnnotationType.FILEATTACHMENT:
2861                                            return new FileAttachmentAnnotationElement(parameters);
2862                                        default:
2863                                            return new AnnotationElement(parameters);
2864                                    }
2865                                }
2866                            };
2867                            var AnnotationElement = function AnnotationElementClosure() {
2868                                function AnnotationElement(parameters, isRenderable) {
2869                                    this.isRenderable = isRenderable || false;
2870                                    this.data = parameters.data;
2871                                    this.layer = parameters.layer;
2872                                    this.page = parameters.page;
2873                                    this.viewport = parameters.viewport;
2874                                    this.linkService = parameters.linkService;
2875                                    this.downloadManager = parameters.downloadManager;
2876                                    this.imageResourcesPath = parameters.imageResourcesPath;
2877                                    this.renderInteractiveForms = parameters.renderInteractiveForms;
2878                                    if (isRenderable) {
2879                                        this.container = this._createContainer();
2880                                    }
2881                                }
2882                                AnnotationElement.prototype = {
2883                                    _createContainer: function AnnotationElement_createContainer() {
2884                                        var data = this.data, page = this.page, viewport = this.viewport;
2885                                        var container = document.createElement('section');
2886                                        var width = data.rect[2] - data.rect[0];
2887                                        var height = data.rect[3] - data.rect[1];
2888                                        container.setAttribute('data-annotation-id', data.id);
2889                                        var rect = Util.normalizeRect([
2890                                            data.rect[0],
2891                                            page.view[3] - data.rect[1] + page.view[1],
2892                                            data.rect[2],
2893                                            page.view[3] - data.rect[3] + page.view[1]
2894                                        ]);
2895                                        CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
2896                                        CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
2897                                        if (data.borderStyle.width > 0) {
2898                                            container.style.borderWidth = data.borderStyle.width + 'px';
2899                                            if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
2900                                                width = width - 2 * data.borderStyle.width;
2901                                                height = height - 2 * data.borderStyle.width;
2902                                            }
2903                                            var horizontalRadius = data.borderStyle.horizontalCornerRadius;
2904                                            var verticalRadius = data.borderStyle.verticalCornerRadius;
2905                                            if (horizontalRadius > 0 || verticalRadius > 0) {
2906                                                var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
2907                                                CustomStyle.setProp('borderRadius', container, radius);
2908                                            }
2909                                            switch (data.borderStyle.style) {
2910                                                case AnnotationBorderStyleType.SOLID:
2911                                                    container.style.borderStyle = 'solid';
2912                                                    break;
2913                                                case AnnotationBorderStyleType.DASHED:
2914                                                    container.style.borderStyle = 'dashed';
2915                                                    break;
2916                                                case AnnotationBorderStyleType.BEVELED:
2917                                                    warn('Unimplemented border style: beveled');
2918                                                    break;
2919                                                case AnnotationBorderStyleType.INSET:
2920                                                    warn('Unimplemented border style: inset');
2921                                                    break;
2922                                                case AnnotationBorderStyleType.UNDERLINE:
2923                                                    container.style.borderBottomStyle = 'solid';
2924                                                    break;
2925                                                default:
2926                                                    break;
2927                                            }
2928                                            if (data.color) {
2929                                                container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
2930                                            } else {
2931                                                container.style.borderWidth = 0;
2932                                            }
2933                                        }
2934                                        container.style.left = rect[0] + 'px';
2935                                        container.style.top = rect[1] + 'px';
2936                                        container.style.width = width + 'px';
2937                                        container.style.height = height + 'px';
2938                                        return container;
2939                                    },
2940                                    _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
2941                                        if (!trigger) {
2942                                            trigger = document.createElement('div');
2943                                            trigger.style.height = container.style.height;
2944                                            trigger.style.width = container.style.width;
2945                                            container.appendChild(trigger);
2946                                        }
2947                                        var popupElement = new PopupElement({
2948                                            container: container,
2949                                            trigger: trigger,
2950                                            color: data.color,
2951                                            title: data.title,
2952                                            contents: data.contents,
2953                                            hideWrapper: true
2954                                        });
2955                                        var popup = popupElement.render();
2956                                        popup.style.left = container.style.width;
vendor: 16,384 bytes, lines 2957-3179
2957                                        container.appendChild(popup);
2958                                    },
2959                                    render: function AnnotationElement_render() {
2960                                        throw new Error('Abstract method AnnotationElement.render called');
2961                                    }
2962                                };
2963                                return AnnotationElement;
2964                            }();
2965                            var LinkAnnotationElement = function LinkAnnotationElementClosure() {
2966                                function LinkAnnotationElement(parameters) {
2967                                    AnnotationElement.call(this, parameters, true);
2968                                }
2969                                Util.inherit(LinkAnnotationElement, AnnotationElement, {
2970                                    render: function LinkAnnotationElement_render() {
2971                                        this.container.className = 'linkAnnotation';
2972                                        var link = document.createElement('a');
2973                                        addLinkAttributes(link, {
2974                                            url: this.data.url,
2975                                            target: this.data.newWindow ? LinkTarget.BLANK : undefined
2976                                        });
2977                                        if (!this.data.url) {
2978                                            if (this.data.action) {
2979                                                this._bindNamedAction(link, this.data.action);
2980                                            } else {
2981                                                this._bindLink(link, this.data.dest);
2982                                            }
2983                                        }
2984                                        this.container.appendChild(link);
2985                                        return this.container;
2986                                    },
2987                                    _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
2988                                        var self = this;
2989                                        link.href = this.linkService.getDestinationHash(destination);
2990                                        link.onclick = function () {
2991                                            if (destination) {
2992                                                self.linkService.navigateTo(destination);
2993                                            }
2994                                            return false;
2995                                        };
2996                                        if (destination) {
2997                                            link.className = 'internalLink';
2998                                        }
2999                                    },
3000                                    _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
3001                                        var self = this;
3002                                        link.href = this.linkService.getAnchorUrl('');
3003                                        link.onclick = function () {
3004                                            self.linkService.executeNamedAction(action);
3005                                            return false;
3006                                        };
3007                                        link.className = 'internalLink';
3008                                    }
3009                                });
3010                                return LinkAnnotationElement;
3011                            }();
3012                            var TextAnnotationElement = function TextAnnotationElementClosure() {
3013                                function TextAnnotationElement(parameters) {
3014                                    var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
3015                                    AnnotationElement.call(this, parameters, isRenderable);
3016                                }
3017                                Util.inherit(TextAnnotationElement, AnnotationElement, {
3018                                    render: function TextAnnotationElement_render() {
3019                                        this.container.className = 'textAnnotation';
3020                                        var image = document.createElement('img');
3021                                        image.style.height = this.container.style.height;
3022                                        image.style.width = this.container.style.width;
3023                                        image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
3024                                        image.alt = '[{{type}} Annotation]';
3025                                        image.dataset.l10nId = 'text_annotation_type';
3026                                        image.dataset.l10nArgs = JSON.stringify({type: this.data.name});
3027                                        if (!this.data.hasPopup) {
3028                                            this._createPopup(this.container, image, this.data);
3029                                        }
3030                                        this.container.appendChild(image);
3031                                        return this.container;
3032                                    }
3033                                });
3034                                return TextAnnotationElement;
3035                            }();
3036                            var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
3037                                function WidgetAnnotationElement(parameters, isRenderable) {
3038                                    AnnotationElement.call(this, parameters, isRenderable);
3039                                }
3040                                Util.inherit(WidgetAnnotationElement, AnnotationElement, {
3041                                    render: function WidgetAnnotationElement_render() {
3042                                        return this.container;
3043                                    }
3044                                });
3045                                return WidgetAnnotationElement;
3046                            }();
3047                            var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
3048                                var TEXT_ALIGNMENT = [
3049                                    'left',
3050                                    'center',
3051                                    'right'
3052                                ];
3053                                function TextWidgetAnnotationElement(parameters) {
3054                                    var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
3055                                    WidgetAnnotationElement.call(this, parameters, isRenderable);
3056                                }
3057                                Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
3058                                    render: function TextWidgetAnnotationElement_render() {
3059                                        this.container.className = 'textWidgetAnnotation';
3060                                        var element = null;
3061                                        if (this.renderInteractiveForms) {
3062                                            if (this.data.multiLine) {
3063                                                element = document.createElement('textarea');
3064                                                element.textContent = this.data.fieldValue;
3065                                            } else {
3066                                                element = document.createElement('input');
3067                                                element.type = 'text';
3068                                                element.setAttribute('value', this.data.fieldValue);
3069                                            }
3070                                            element.disabled = this.data.readOnly;
3071                                            if (this.data.maxLen !== null) {
3072                                                element.maxLength = this.data.maxLen;
3073                                            }
3074                                            if (this.data.comb) {
3075                                                var fieldWidth = this.data.rect[2] - this.data.rect[0];
3076                                                var combWidth = fieldWidth / this.data.maxLen;
3077                                                element.classList.add('comb');
3078                                                element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
3079                                            }
3080                                        } else {
3081                                            element = document.createElement('div');
3082                                            element.textContent = this.data.fieldValue;
3083                                            element.style.verticalAlign = 'middle';
3084                                            element.style.display = 'table-cell';
3085                                            var font = null;
3086                                            if (this.data.fontRefName) {
3087                                                font = this.page.commonObjs.getData(this.data.fontRefName);
3088                                            }
3089                                            this._setTextStyle(element, font);
3090                                        }
3091                                        if (this.data.textAlignment !== null) {
3092                                            element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
3093                                        }
3094                                        this.container.appendChild(element);
3095                                        return this.container;
3096                                    },
3097                                    _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
3098                                        var style = element.style;
3099                                        style.fontSize = this.data.fontSize + 'px';
3100                                        style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
3101                                        if (!font) {
3102                                            return;
3103                                        }
3104                                        style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
3105                                        style.fontStyle = font.italic ? 'italic' : 'normal';
3106                                        var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
3107                                        var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
3108                                        style.fontFamily = fontFamily + fallbackName;
3109                                    }
3110                                });
3111                                return TextWidgetAnnotationElement;
3112                            }();
3113                            var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
3114                                function CheckboxWidgetAnnotationElement(parameters) {
3115                                    WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
3116                                }
3117                                Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
3118                                    render: function CheckboxWidgetAnnotationElement_render() {
3119                                        this.container.className = 'buttonWidgetAnnotation checkBox';
3120                                        var element = document.createElement('input');
3121                                        element.disabled = this.data.readOnly;
3122                                        element.type = 'checkbox';
3123                                        if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
3124                                            element.setAttribute('checked', true);
3125                                        }
3126                                        this.container.appendChild(element);
3127                                        return this.container;
3128                                    }
3129                                });
3130                                return CheckboxWidgetAnnotationElement;
3131                            }();
3132                            var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
3133                                function RadioButtonWidgetAnnotationElement(parameters) {
3134                                    WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
3135                                }
3136                                Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
3137                                    render: function RadioButtonWidgetAnnotationElement_render() {
3138                                        this.container.className = 'buttonWidgetAnnotation radioButton';
3139                                        var element = document.createElement('input');
3140                                        element.disabled = this.data.readOnly;
3141                                        element.type = 'radio';
3142                                        element.name = this.data.fieldName;
3143                                        if (this.data.fieldValue === this.data.buttonValue) {
3144                                            element.setAttribute('checked', true);
3145                                        }
3146                                        this.container.appendChild(element);
3147                                        return this.container;
3148                                    }
3149                                });
3150                                return RadioButtonWidgetAnnotationElement;
3151                            }();
3152                            var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
3153                                function ChoiceWidgetAnnotationElement(parameters) {
3154                                    WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
3155                                }
3156                                Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
3157                                    render: function ChoiceWidgetAnnotationElement_render() {
3158                                        this.container.className = 'choiceWidgetAnnotation';
3159                                        var selectElement = document.createElement('select');
3160                                        selectElement.disabled = this.data.readOnly;
3161                                        if (!this.data.combo) {
3162                                            selectElement.size = this.data.options.length;
3163                                            if (this.data.multiSelect) {
3164                                                selectElement.multiple = true;
3165                                            }
3166                                        }
3167                                        for (var i = 0, ii = this.data.options.length; i < ii; i++) {
3168                                            var option = this.data.options[i];
3169                                            var optionElement = document.createElement('option');
3170                                            optionElement.textContent = option.displayValue;
3171                                            optionElement.value = option.exportValue;
3172                                            if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
3173                                                optionElement.setAttribute('selected', true);
3174                                            }
3175                                            selectElement.appendChild(optionElement);
3176                                        }
3177                                        this.container.appendChild(selectElement);
3178                                        return this.container;
3179                               
3179     }
3180                                });
3181                                return ChoiceWidgetAnnotationElement;
3182                            }();
3183                            var PopupAnnotationElement = function PopupAnnotationElementClosure() {
3184                                function PopupAnnotationElement(parameters) {
3185                                    var isRenderable = !!(parameters.data.title || parameters.data.contents);
3186                                    AnnotationElement.call(this, parameters, isRenderable);
3187                                }
3188                                Util.inherit(PopupAnnotationElement, AnnotationElement, {
3189                                    render: function PopupAnnotationElement_render() {
3190                                        this.container.className = 'popupAnnotation';
3191                                        var selector = '[data-annotation-id="' + this.data.parentId + '"]';
3192                                        var parentElement = this.layer.querySelector(selector);
3193                                        if (!parentElement) {
3194                                            return this.container;
3195                                        }
3196                                        var popup = new PopupElement({
3197                                            container: this.container,
3198                                            trigger: parentElement,
3199                                            color: this.data.color,
3200                                            title: this.data.title,
3201                                            contents: this.data.contents
3202                                        });
3203                                        var parentLeft = parseFloat(parentElement.style.left);
3204                                        var parentWidth = parseFloat(parentElement.style.width);
3205                                        CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
3206                                        this.container.style.left = parentLeft + parentWidth + 'px';
3207                                        this.container.appendChild(popup.render());
3208                                        return this.container;
3209                                    }
3210                                });
3211                                return PopupAnnotationElement;
3212                            }();
3213                            var PopupElement = function PopupElementClosure() {
3214                                var BACKGROUND_ENLIGHT = 0.7;
3215                                function PopupElement(parameters) {
3216                                    this.container = parameters.container;
3217                                    this.trigger = parameters.trigger;
3218                                    this.color = parameters.color;
3219                                    this.title = parameters.title;
3220                                    this.contents = parameters.contents;
3221                                    this.hideWrapper = parameters.hideWrapper || false;
3222                                    this.pinned = false;
3223                                }
3224                                PopupElement.prototype = {
3225                                    render: function PopupElement_render() {
3226                                        var wrapper = document.createElement('div');
3227                                        wrapper.className = 'popupWrapper';
3228                                        this.hideElement = this.hideWrapper ? wrapper : this.container;
3229                                        this.hideElement.setAttribute('hidden', true);
3230                                        var popup = document.createElement('div');
3231                                        popup.className = 'popup';
3232                                        var color = this.color;
3233                                        if (color) {
3234                                            var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
3235                                            var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
3236                                            var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
3237                                            popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
3238                                        }
3239                                        var contents = this._formatContents(this.contents);
3240                                        var title = document.createElement('h1');
3241                                        title.textContent = this.title;
3242                                        this.trigger.addEventListener('click', this._toggle.bind(this));
3243                                        this.trigger.addEventListener('mouseover', this._show.bind(this, false));
3244                                        this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
3245                                        popup.addEventListener('click', this._hide.bind(this, true));
3246                                        popup.appendChild(title);
3247                                        popup.appendChild(contents);
3248                                        wrapper.appendChild(popup);
3249                                        return wrapper;
3250                                    },
3251                                    _formatContents: function PopupElement_formatContents(contents) {
3252                                        var p = document.createElement('p');
3253                                        var lines = contents.split(/(?:\r\n?|\n)/);
3254                                        for (var i = 0, ii = lines.length; i < ii; ++i) {
3255                                            var line = lines[i];
3256                                            p.appendChild(document.createTextNode(line));
3257                                            if (i < ii - 1) {
3258                                                p.appendChild(document.createElement('br'));
3259                                            }
3260                                        }
3261                                        return p;
3262                                    },
3263                                    _toggle: function PopupElement_toggle() {
3264                                        if (this.pinned) {
3265                                            this._hide(true);
3266                                        } else {
3267                                            this._show(true);
3268                                        }
3269                                    },
3270                                    _show: function PopupElement_show(pin) {
3271                                        if (pin) {
3272                                            this.pinned = true;
3273                                        }
3274                                        if (this.hideElement.hasAttribute('hidden')) {
3275                                            this.hideElement.removeAttribute('hidden');
3276                                            this.container.style.zIndex += 1;
3277                                        }
3278                                    },
3279                                    _hide: function PopupElement_hide(unpin) {
3280                                        if (unpin) {
3281                                            this.pinned = false;
3282                                        }
3283                                        if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
3284                                            this.hideElement.setAttribute('hidden', true);
3285                                            this.container.style.zIndex -= 1;
3286                                        }
3287                                    }
3288                                };
3289                                return PopupElement;
3290                            }();
3291                            var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
3292                                function HighlightAnnotationElement(parameters) {
3293                                    var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
3294                                    AnnotationElement.call(this, parameters, isRenderable);
3295                                }
3296                                Util.inherit(HighlightAnnotationElement, AnnotationElement, {
3297                                    render: function HighlightAnnotationElement_render() {
3298                                        this.container.className = 'highlightAnnotation';
3299                                        if (!this.data.hasPopup) {
3300                                            this._createPopup(this.container, null, this.data);
3301                                        }
3302                                        return this.container;
3303                                    }
3304                                });
3305                                return HighlightAnnotationElement;
3306                            }();
3307                            var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
3308                                function UnderlineAnnotationElement(parameters) {
3309                                    var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
3310                                    AnnotationElement.call(this, parameters, isRenderable);
3311                                }
3312                                Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
3313                                    render: function UnderlineAnnotationElement_render() {
3314                                        this.container.className = 'underlineAnnotation';
3315                                        if (!this.data.hasPopup) {
3316                                            this._createPopup(this.container, null, this.data);
3317                                        }
3318                                        return this.container;
3319                                    }
3320                                });
3321                                return UnderlineAnnotationElement;
3322                            }();
3323                            var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
3324                                function SquigglyAnnotationElement(parameters) {
3325                                    var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
3326                                    AnnotationElement.call(this, parameters, isRenderable);
3327                                }
3328                                Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
3329                                    render: function SquigglyAnnotationElement_render() {
3330                                        this.container.className = 'squigglyAnnotation';
3331                                        if (!this.data.hasPopup) {
3332                                            this._createPopup(this.container, null, this.data);
3333                                        }
3334                                        return this.container;
3335                                    }
3336                                });
3337                                return SquigglyAnnotationElement;
3338                            }();
3339                            var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
3340                                function StrikeOutAnnotationElement(parameters) {
3341                                    var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
3342                                    AnnotationElement.call(this, parameters, isRenderable);
3343                                }
3344                                Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
3345                                    render: function StrikeOutAnnotationElement_render() {
3346                                        this.container.className = 'strikeoutAnnotation';
3347                                        if (!this.data.hasPopup) {
3348                                            this._createPopup(this.container, null, this.data);
3349                                        }
3350                                        return this.container;
3351                                    }
3352                                });
3353                                return StrikeOutAnnotationElement;
3354                            }();
3355                            var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
3356                                function FileAttachmentAnnotationElement(parameters) {
3357                                    AnnotationElement.call(this, parameters, true);
3358                                    var file = this.data.file;
3359                                    this.filename = getFilenameFromUrl(file.filename);
3360                                    this.content = file.content;
3361                                    this.linkService.onFileAttachmentAnnotation({
3362                                        id: stringToPDFString(file.filename),
3363                                        filename: file.filename,
3364                                        content: file.content
3365                                    });
3366                                }
3367                                Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
3368                                    render: function FileAttachmentAnnotationElement_render() {
3369                                        this.container.className = 'fileAttachmentAnnotation';
3370                                        var trigger = document.createElement('div');
3371                                        trigger.style.height = this.container.style.height;
3372                                        trigger.style.width = this.container.style.width;
3373                                        trigger.addEventListener('dblclick', this._download.bind(this));
3374                                        if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
3375                                            this._createPopup(this.container, trigger, this.data);
3376                                        }
3377                                        this.container.appendChild(trigger);
3378                                        return this.container;
3379                                    },
3380                                    _download: function FileAttachmentAnnotationElement_download() {
3381                                        if (!this.downloadManager) {
3382                                            warn('Download cannot be started due to unavailable download manager');
3383                                            return;
3384                                        }
3385                                        this.downloadManager.downloadData(this.content, this.filename, '');
3386                                    }
3387                                });
3388                                return FileAttachmentAnnotationElement;
3389                            }();
3390                            var AnnotationLayer = function AnnotationLayerClosure() {
3391                                return {
3392                                    render: function AnnotationLayer_render(parameters) {
3393                                        var annotationElementFactory = new AnnotationElementFactory();
3394                                        for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
3395                                            var data = parameters.annotations[i];
3396                                            if (!data) {
3397                                                continue;
3398                                            }
3399                                            var element = annotationElementFactory.create({
3400                                                data: data,
3401                                                layer: parameters.div,
3402                                                page: parameters.page,
3403                                                viewport: parameters.viewport,
3404                                                linkService: parameters.linkService,
3405                                                downloadManager: parameters.downloadManager,
3406                                                imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
3407                                                renderInteractiveForms: parameters.renderInteractiveForms || false
3408                                            });
3409                                            if (element.isRenderable) {
3410                                                parameters.div.appendChild(element.render());
3411                                            }
3412                                        }
3413                                    },
3414                                    update: function AnnotationLayer_update(parameters) {
3415                                        for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
3416                                            var data = parameters.annotations[i];
3417                                            var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
3418                                            if (element) {
3419                                                CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
3420                                            }
3421                                        }
3422                                        parameters.div.removeAttribute('hidden');
3423                                    }
3424                                };
3425                            }();
3426                            exports.AnnotationLayer = AnnotationLayer;
3427
3428                            /***/ }),
3429                        /* 3 */
3430                        /***/ (function (module, exports, __w_pdfjs_require__) {
3431
3432                            "use strict";
3433
3434                            var sharedUtil = __w_pdfjs_require__(0);
3435                            var displayFontLoader = __w_pdfjs_require__(11);
3436                            var displayCanvas = __w_pdfjs_require__(10);
3437                            var displayMetadata = __w_pdfjs_require__(7);
3438                            var displayDOMUtils = __w_pdfjs_require__(1);
3439                            var amdRequire;
3440                            var InvalidPDFException = sharedUtil.InvalidPDFException;
3441                            var MessageHandler = sharedUtil.MessageHandler;
3442                            var MissingPDFException = sharedUtil.MissingPDFException;
3443                            var PageViewport = sharedUtil.PageViewport;
3444                            var PasswordException = sharedUtil.PasswordException;
3445                            var StatTimer = sharedUtil.StatTimer;
3446                            var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
3447                            var UnknownErrorException = sharedUtil.UnknownErrorException;
3448                            var Util = sharedUtil.Util;
3449                            var createPromiseCapability = sharedUtil.createPromiseCapability;
3450                            var error = sharedUtil.error;
3451                            var deprecated = sharedUtil.deprecated;
3452                            var getVerbosityLevel = sharedUtil.getVerbosityLevel;
3453                            var info = sharedUtil.info;
3454                            var isInt = sharedUtil.isInt;
3455                            var isArray = sharedUtil.isArray;
3456                            var isArrayBuffer = sharedUtil.isArrayBuffer;
3457                            var isSameOrigin = sharedUtil.isSameOrigin;
3458                            var loadJpegStream = sharedUtil.loadJpegStream;
3459                            var stringToBytes = sharedUtil.stringToBytes;
3460                            var globalScope = sharedUtil.globalScope;
3461                            var warn = sharedUtil.warn;
3462                            var FontFaceObject = displayFontLoader.FontFaceObject;
3463                            var FontLoader = displayFontLoader.FontLoader;
3464                            var CanvasGraphics = displayCanvas.CanvasGraphics;
3465                            var Metadata = displayMetadata.Metadata;
3466                            var getDefaultSetting = displayDOMUtils.getDefaultSetting;
3467                            var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
3468                            var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
3469                            var DEFAULT_RANGE_CHUNK_SIZE = 65536;
3470                            var isWorkerDisabled = false;
3471                            var workerSrc;
3472                            var isPostMessageTransfersDisabled = false;
3473                            var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
3474                            var fakeWorkerFilesLoader = null;
3475                            var useRequireEnsure = false;
3476                            if (typeof __pdfjsdev_webpack__ === 'undefined') {
3477                                if (typeof window === 'undefined') {
3478                                    isWorkerDisabled = true;
3479                                    if (typeof require.ensure === 'undefined') {
3480                                        require.ensure = require('node-ensure');
3481                                    }
3482                                    useRequireEnsure = true;
3483                                } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
3484                                    useRequireEnsure = true;
3485                                }
3486                                if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
3487                                    workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
3488                                }
3489                                var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
3490                                fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
3491                                    require.ensure([], function () {
3492                                        var worker = require('./pdf.worker.js');
3493                                        callback(worker.WorkerMessageHandler);
3494                                    });
3495                                } : dynamicLoaderSupported ? function (callback) {
3496                                    requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
3497                                        callback(worker.WorkerMessageHandler);
3498                                    });
3499                                } : null;
3500                            }
3501                            function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
3502                                var task = new PDFDocumentLoadingTask();
3503                                if (arguments.length > 1) {
3504                                    deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
3505                                }
3506                                if (pdfDataRangeTransport) {
3507                                    if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
3508                                        pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
3509                                        pdfDataRangeTransport.length = src.length;
3510                                        pdfDataRangeTransport.initialData = src.initialData;
3511                                        if (!pdfDataRangeTransport.abort) {
3512                                            pdfDataRangeTransport.abort = function () {
3513                                            };
3514                                        }
3515                                    }
3516                                    src = Object.create(src);
3517                                    src.range = pdfDataRangeTransport;
3518                                }
3519                                task.onPassword = passwordCallback || null;
3520                                task.onProgress = progressCallback || null;
3521                                var source;
3522                                if (typeof src === 'string') {
3523                                    source = {url: src};
3524                                } else if (isArrayBuffer(src)) {
3525                                    source = {data: src};
3526                                } else if (src instanceof PDFDataRangeTransport) {
3527                                    source = {range: src};
3528                                } else {
3529                                    if (typeof src !== 'object') {
3530                                        error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
3531                                    }
3532                                    if (!src.url && !src.data && !src.range) {
3533                                        error('Invalid parameter object: need either .data, .range or .url');
3534                                    }
3535                                    source = src;
3536                                }
3537                                var params = {};
3538                                var rangeTransport = null;
3539                                var worker = null;
3540                                for (var key in source) {
3541                                    if (key === 'url' && typeof window !== 'undefined') {
3542                                        params[key] = new URL(source[key], window.location).href;
3543                                        continue;
3544                                    } else if (key === 'range') {
3545                                        rangeTransport = source[key];
3546                                        continue;
3547                                    } else if (key === 'worker') {
3548                                        worker = source[key];
3549                                        continue;
3550                                    } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
3551                                        var pdfBytes = source[key];
3552                                        if (typeof pdfBytes === 'string') {
3553                                            params[key] = stringToBytes(pdfBytes);
3554                                        } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
3555                                            params[key] = new Uint8Array(pdfBytes);
3556                                        } else if (isArrayBuffer(pdfBytes)) {
3557                                            params[key] = new Uint8Array(pdfBytes);
3558                                        } else {
3559                                            error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
3560                                        }
3561                                        continue;
3562                                    }
3563                                    params[key] = source[key];
3564                                }
3565                                params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
3566                                params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
3567                                var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
3568                                if (!worker) {
3569                                    var workerPort = getDefaultSetting('workerPort');
3570                                    worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
3571                                    task._worker = worker;
3572                                }
3573                                var docId = task.docId;
3574                                worker.promise.then(function () {
3575                                    if (task.destroyed) {
3576                                        throw new Error('Loading aborted');
3577                                    }
3578                                    return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
3579                                        if (task.destroyed) {
3580                                            throw new Error('Loading aborted');
3581                                        }
3582                                        var messageHandler = new MessageHandler(docId, workerId, worker.port);
3583                                        var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
3584                                        task._transport = transport;
3585                                        messageHandler.send('Ready', null);
3586                                    });
3587                                }).catch(task._capability.reject);
3588                                return task;
3589                            }
3590                            function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
3591                                if (worker.destroyed) {
3592                                    return Promise.reject(new Error('Worker was destroyed'));
3593                                }
3594                                source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
3595                                source.disableStream = getDefaultSetting('disableStream');
3596                                source.chunkedViewerLoading = !!pdfDataRangeTransport;
3597                                if (pdfDataRangeTransport) {
3598                                    source.length = pdfDataRangeTransport.length;
3599                                    source.initialData = pdfDataRangeTransport.initialData;
3600                                }
3601                                return worker.messageHandler.sendWithProm
3601ise('GetDocRequest', {
3602                                    docId: docId,
3603                                    source: source,
3604                                    disableRange: getDefaultSetting('disableRange'),
3605                                    maxImageSize: getDefaultSetting('maxImageSize'),
3606                                    disableFontFace: getDefaultSetting('disableFontFace'),
3607                                    disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
3608                                    postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
3609                                    docBaseUrl: source.docBaseUrl,
3610                                    disableNativeImageDecoder: source.disableNativeImageDecoder
3611                                }).then(function (workerId) {
3612                                    if (worker.destroyed) {
3613                                        throw new Error('Worker was destroyed');
3614                                    }
3615                                    return workerId;
3616                                });
3617                            }
3618                            var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
3619                                var nextDocumentId = 0;
3620                                function PDFDocumentLoadingTask() {
3621                                    this._capability = createPromiseCapability();
3622                                    this._transport = null;
3623                                    this._worker = null;
3624                                    this.docId = 'd' + nextDocumentId++;
3625                                    this.destroyed = false;
3626                                    this.onPassword = null;
3627                                    this.onProgress = null;
3628                                    this.onUnsupportedFeature = null;
3629                                }
3630                                PDFDocumentLoadingTask.prototype = {
3631                                    get promise() {
3632                                        return this._capability.promise;
3633                                    },
3634                                    destroy: function () {
3635                                        this.destroyed = true;
3636                                        var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
3637                                        return transportDestroyed.then(function () {
3638                                            this._transport = null;
3639                                            if (this._worker) {
3640                                                this._worker.destroy();
3641                                                this._worker = null;
3642                                            }
3643                                        }.bind(this));
3644                                    },
3645                                    then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
3646                                        return this.promise.then.apply(this.promise, arguments);
3647                                    }
3648                                };
3649                                return PDFDocumentLoadingTask;
3650                            }();
3651                            var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
3652                                function PDFDataRangeTransport(length, initialData) {
3653                                    this.length = length;
3654                                    this.initialData = initialData;
3655                                    this._rangeListeners = [];
3656                                    this._progressListeners = [];
3657                                    this._progressiveReadListeners = [];
3658                                    this._readyCapability = createPromiseCapability();
3659                                }
3660                                PDFDataRangeTransport.prototype = {
3661                                    addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
3662                                        this._rangeListeners.push(listener);
3663                                    },
3664                                    addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
3665                                        this._progressListeners.push(listener);
3666                                    },
3667                                    addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
3668                                        this._progressiveReadListeners.push(listener);
3669                                    },
3670                                    onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
3671                                        var listeners = this._rangeListeners;
3672                                        for (var i = 0, n = listeners.length; i < n; ++i) {
3673                                            listeners[i](begin, chunk);
3674                                        }
3675                                    },
3676                                    onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
3677                                        this._readyCapability.promise.then(function () {
3678                                            var listeners = this._progressListeners;
3679                                            for (var i = 0, n = listeners.length; i < n; ++i) {
3680                                                listeners[i](loaded);
3681                                            }
3682                                        }.bind(this));
3683                                    },
3684                                    onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
3685                                        this._readyCapability.promise.then(function () {
3686                                            var listeners = this._progressiveReadListeners;
3687                                            for (var i = 0, n = listeners.length; i < n; ++i) {
3688                                                listeners[i](chunk);
3689                                            }
3690                                        }.bind(this));
3691                                    },
3692                                    transportReady: function PDFDataRangeTransport_transportReady() {
3693                                        this._readyCapability.resolve();
3694                                    },
3695                                    requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
3696                                        throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
3697                                    },
3698                                    abort: function PDFDataRangeTransport_abort() {
3699                                    }
3700                                };
3701                                return PDFDataRangeTransport;
3702                            }();
3703                            var PDFDocumentProxy = function PDFDocumentProxyClosure() {
3704                                function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
3705                                    this.pdfInfo = pdfInfo;
3706                                    this.transport = transport;
3707                                    this.loadingTask = loadingTask;
3708                                }
3709                                PDFDocumentProxy.prototype = {
3710                                    get numPages() {
3711                                        return this.pdfInfo.numPages;
3712                                    },
3713                                    get fingerprint() {
3714                                        return this.pdfInfo.fingerprint;
3715                                    },
3716                                    getPage: function PDFDocumentProxy_getPage(pageNumber) {
3717                                        return this.transport.getPage(pageNumber);
3718                                    },
3719                                    getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
3720                                        return this.transport.getPageIndex(ref);
3721                                    },
3722                                    getDestinations: function PDFDocumentProxy_getDestinations() {
3723                                        return this.transport.getDestinations();
3724                                    },
3725                                    getDestination: function PDFDocumentProxy_getDestination(id) {
3726                                        return this.transport.getDestination(id);
3727                                    },
3728                                    getPageLabels: function PDFDocumentProxy_getPageLabels() {
3729                                        return this.transport.getPageLabels();
3730                                    },
3731                                    getAttachments: function PDFDocumentProxy_getAttachments() {
3732                                        return this.transport.getAttachments();
3733                                    },
3734                                    getJavaScript: function PDFDocumentProxy_getJavaScript() {
3735                                        return this.transport.getJavaScript();
3736                                    },
3737                                    getOutline: function PDFDocumentProxy_getOutline() {
3738                                        return this.transport.getOutline();
3739                                    },
3740                                    getMetadata: function PDFDocumentProxy_getMetadata() {
3741                                        return this.transport.getMetadata();
3742                                    },
3743                                    getData: function PDFDocumentProxy_getData() {
3744                                        return this.transport.getData();
3745                                    },
3746                                    getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
3747                                        return this.transport.downloadInfoCapability.promise;
3748                                    },
3749                                    getStats: function PDFDocumentProxy_getStats() {
3750                                        return this.transport.getStats();
3751                                    },
3752                                    cleanup: function PDFDocumentProxy_cleanup() {
3753                                        this.transport.startCleanup();
3754                                    },
3755                                    destroy: function PDFDocumentProxy_destroy() {
3756                                        return this.loadingTask.destroy();
3757                                    }
3758                                };
3759                                return PDFDocumentProxy;
3760                            }();
3761                            var PDFPageProxy = function PDFPageProxyClosure() {
3762                                function PDFPageProxy(pageIndex, pageInfo, transport) {
3763                                    this.pageIndex = pageIndex;
3764                                    this.pageInfo = pageInfo;
3765                                    this.transport = transport;
3766                                    this.stats = new StatTimer();
3767                                    this.stats.enabled = getDefaultSetting('enableStats');
3768                                    this.commonObjs = transport.commonObjs;
3769                                    this.objs = new PDFObjects();
3770                                    this.cleanupAfterRender = false;
3771                                    this.pendingCleanup = false;
3772                                    this.intentStates = Object.create(null);
3773                                    this.destroyed = false;
3774                                }
3775                                PDFPageProxy.prototype = {
3776                                    get pageNumber() {
3777                                        return this.pageIndex + 1;
3778                                    },
3779                                    get rotate() {
3780                                        return this.pageInfo.rotate;
3781                                    },
3782                                    get ref() {
3783                                        return this.pageInfo.ref;
3784                                    },
3785                                    get userUnit() {
3786                                        return this.pageInfo.userUnit;
3787                                    },
3788                                    get view() {
3789                                        return this.pageInfo.view;
3790                                    },
3791                                    getViewport: function PDFPageProxy_getViewport(scale, rotate) {
3792                                        if (arguments.length < 2) {
3793                                            rotate = this.rotate;
3794                                        }
3795                                        return new PageViewport(this.view, scale, rotate, 0, 0);
3796                                    },
3797                                    getAnnotations: function PDFPageProxy_getAnnotations(params) {
3798                                        var intent = params && params.intent || null;
3799                                        if (!this.annotationsPromise || this.annotationsIntent !== intent) {
3800                                            this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
3801                                            this.annotationsIntent = intent;
3802                                        }
3803                                        return this.annotationsPromise;
3804                                    },
3805                                    render: function PDFPageProxy_render(params) {
3806                                        var stats = this.stats;
3807                                        stats.time('Overall');
3808                                        this.pendingCleanup = false;
3809                                        var renderingIntent = params.intent === 'print' ? 'print' : 'display';
3810                                        var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
3811                                        var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
3812                                        if (!this.intentStates[renderingIntent]) {
3813                                            this.intentStates[renderingIntent] = Object.create(null);
3814                                        }
3815                                        var intentState = this.intentStates[renderingIntent];
3816                                        if (!intentState.displayReadyCapability) {
3817                                            intentState.receivingOperatorList = true;
3818                                            intentState.displayReadyCapability = createPromiseCapability();
3819                                            intentState.operatorList = {
3820                                                fnArray: [],
3821                                                argsArray: [],
3822                                                lastChunk: false
3823                                            };
3824                                            this.stats.time('Page Request');
3825                                            this.transport.messageHandler.send('RenderPageRequest', {
3826                                                pageIndex: this.pageNumber - 1,
3827                                                intent: renderingIntent,
3828                                                renderInteractiveForms: renderInteractiveForms
3829                                            });
3830                                        }
3831                                        var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, 
3831canvasFactory);
3832                                        internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
3833                                        if (!intentState.renderTasks) {
3834                                            intentState.renderTasks = [];
3835                                        }
3836                                        intentState.renderTasks.push(internalRenderTask);
3837                                        var renderTask = internalRenderTask.task;
3838                                        if (params.continueCallback) {
3839                                            deprecated('render is used with continueCallback parameter');
3840                                            renderTask.onContinue = params.continueCallback;
3841                                        }
3842                                        var self = this;
3843                                        intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
3844                                            if (self.pendingCleanup) {
3845                                                complete();
3846                                                return;
3847                                            }
3848                                            stats.time('Rendering');
3849                                            internalRenderTask.initializeGraphics(trans
vendor: 4,301 bytes, lines 3849-3909
3849parency);
3850                                            internalRenderTask.operatorListChanged();
3851                                        }, function pageDisplayReadPromiseError(reason) {
3852                                            complete(reason);
3853                                        });
3854                                        function complete(error) {
3855                                            var i = intentState.renderTasks.indexOf(internalRenderTask);
3856                                            if (i >= 0) {
3857                                                intentState.renderTasks.splice(i, 1);
3858                                            }
3859                                            if (self.cleanupAfterRender) {
3860                                                self.pendingCleanup = true;
3861                                            }
3862                                            self._tryCleanup();
3863                                            if (error) {
3864                                                internalRenderTask.capability.reject(error);
3865                                            } else {
3866                                                internalRenderTask.capability.resolve();
3867                                            }
3868                                            stats.timeEnd('Rendering');
3869                                            stats.timeEnd('Overall');
3870                                        }
3871                                        return renderTask;
3872                                    },
3873                                    getOperatorList: function PDFPageProxy_getOperatorList() {
3874                                        function operatorListChanged() {
3875                                            if (intentState.operatorList.lastChunk) {
3876                                                intentState.opListReadCapability.resolve(intentState.operatorList);
3877                                                var i = intentState.renderTasks.indexOf(opListTask);
3878                                                if (i >= 0) {
3879                                                    intentState.renderTasks.splice(i, 1);
3880                                                }
3881                                            }
3882                                        }
3883                                        var renderingIntent = 'oplist';
3884                                        if (!this.intentStates[renderingIntent]) {
3885                                            this.intentStates[renderingIntent] = Object.create(null);
3886                                        }
3887                                        var intentState = this.intentStates[renderingIntent];
3888                                        var opListTask;
3889                                        if (!intentState.opListReadCapability) {
3890                                            opListTask = {};
3891                                            opListTask.operatorListChanged = operatorListChanged;
3892                                            intentState.receivingOperatorList = true;
3893                                            intentState.opListReadCapability = createPromiseCapability();
3894                                            intentState.renderTasks = [];
3895                                            intentState.renderTasks.push(opListTask);
3896                                            intentState.operatorList = {
3897                                                fnArray: [],
3898                                                argsArray: [],
3899                                                lastChunk: false
3900                                            };
3901                                            this.transport.messageHandler.send('RenderPageRequest', {
3902                                                pageIndex: this.pageIndex,
3903                                                intent: renderingIntent
3904                                            });
3905                                        }
3906                                        return intentState.opListReadCapability.promise;
3907                                    },
3908                                    getTextContent: function PDFPageProxy_getTextContent(params) {
3909                                        return this.transport.messageHandler.sendWithProm
3909ise('GetTextContent', {
3910                                            pageIndex: this.pageNumber - 1,
3911                                            normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
3912                                            combineTextItems: params && params.disableCombineTextItems === true ? false : true
3913                                        });
3914                                    },
3915                                    _destroy: function PDFPageProxy_destroy() {
3916                                        this.destroyed = true;
3917                                        this.transport.pageCache[this.pageIndex] = null;
3918                                        var waitOn = [];
3919                                        Object.keys(this.intentStates).forEach(function (intent) {
3920                                            if (intent === 'oplist') {
3921                                                return;
3922                                            }
3923                                            var intentState = this.intentStates[intent];
3924                                            intentState.renderTasks.forEach(function (renderTask) {
3925                                                var renderCompleted = renderTask.capability.promise.catch(function () {
3926                                                });
3927                                                waitOn.push(renderCompleted);
3928                                                renderTask.cancel();
3929                                            });
3930                                        }, this);
3931                                        this.objs.clear();
3932                                        this.annotationsPromise = null;
3933                                        this.pendingCleanup = false;
3934                                        return Promise.all(waitOn);
3935                                    },
3936                                    destroy: function () {
3937                                        deprecated('page destroy method, use cleanup() instead');
3938                                        this.cleanup();
3939                                    },
3940                                    cleanup: function PDFPageProxy_cleanup() {
3941                                        this.pendingCleanup = true;
3942                                        this._tryCleanup();
3943                                    },
3944                                    _tryCleanup: function PDFPageProxy_tryCleanup() {
3945                                        if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
3946                                            var intentState = this.intentStates[intent];
3947                                            return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
3948                                        }, this)) {
3949                                            return;
3950                                        }
3951                                        Object.keys(this.intentStates).forEach(function (intent) {
3952                                            delete this.intentStates[intent];
3953                                        }, this);
3954                                        this.objs.clear();
3955                                        this.annotationsPromise = null;
3956                                        this.pendingCleanup = false;
3957                                    },
3958                                    _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
3959                                        var intentState = this.intentStates[intent];
3960                                        if (intentState.displayReadyCapability) {
3961                                            intentState.displayReadyCapability.resolve(transparency);
3962                                        }
3963                                    },
3964                                    _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
3965                                        var intentState = this.intentStates[intent];
3966                                        var i, ii;
3967                                        for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
3968                                            intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
3969                                            intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
3970                                        }
3971                                        intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
3972                                        for (i = 0; i < intentState.renderTasks.length; i++) {
3973                                            intentState.renderTasks[i].operatorListChanged();
3974                                        }
3975                                        if (operatorListChunk.lastChunk) {
3976                                            intentState.receivingOperatorList = false;
3977                                            this._tryCleanup();
3978                                        }
3979                                    }
3980                                };
3981                                return PDFPageProxy;
3982                            }();
3983                            var PDFWorker = function PDFWorkerClosure() {
3984                                var nextFakeWorkerId = 0;
3985                                function getWorkerSrc() {
3986                                    if (typeof workerSrc !== 'undefined') {
3987                                        return workerSrc;
3988                                    }
3989                                    if (getDefaultSetting('workerSrc')) {
3990                                        return getDefaultSetting('workerSrc');
3991                                    }
3992                                    if (pdfjsFilePath) {
3993                                        return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
3994                                    }
3995                                    error('No PDFJS.workerSrc specified');
3996                                }
3997                                var fakeWorkerFilesLoadedCapability;
3998                                function setupFakeWorkerGlobal() {
3999                                    var WorkerMessageHandler;
4000                                    if (fakeWorkerFilesLoadedCapability) {
4001                                        return fakeWorkerFilesLoadedCapability.promise;
4002                                    }
4003                                    fakeWorkerFilesLoadedCapability = createPromiseCapability();
4004                                    var loader = fakeWorkerFilesLoader || function (callback) {
4005                                        Util.loadScript(getWorkerSrc(), function () {
4006                                            callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
4007                                        });
4008                                    };
4009                                    loader(fakeWorkerFilesLoadedCapability.resolve);
4010                                    return fakeWorkerFilesLoadedCapability.promise;
4011                                }
4012                                function FakeWorkerPort(defer) {
4013                                    this._listeners = [];
4014                                    this._defer = defer;
4015                                    this._deferred = Promise.resolve(undefined);
4016                                }
4017                                FakeWorkerPort.prototype = {
4018                                    postMessage: function (obj, transfers) {
4019                                        function cloneValue(value) {
4020                                            if (typeof value !== 'object' || value === null) {
4021                                                return value;
4022                                            }
4023                                            if (cloned.has(value)) {
4024                                                return cloned.get(value);
4025                                            }
4026                                            var result;
4027                                            var buffer;
4028                                            if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
4029                                                var transferable = transfers && transfers.indexOf(buffer) >= 0;
4030                                                if (value === buffer) {
4031                                                    result = value;
4032                                                } else if (transferable) {
4033                                                    result = new value.constructor(buffer, value.byteOffset, value.byteLength);
4034                                                } else {
4035                                                    result = new value.constructor(value);
4036                                                }
4037                                                cloned.set(value, result);
4038                                                return result;
4039                                            }
4040                                            result = isArray(value) ? [] : {};
4041                                            cloned.set(value, result);
4042                                            for (var i in value) {
4043                                                var desc, p = value;
4044                                                while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
4045                                                    p = Object.getPrototypeOf(p);
4046                                                }
4047                                                if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
4048                                                    continue;
4049                                                }
4050                                                result[i] = cloneValue(desc.value);
4051                                            }
4052                                            return result;
4053                                        }
4054                                        if (!this._defer) {
4055                                            this._listeners.forEac
4055h(function (listener) {
4056                                                listener.call(this, {data: obj});
4057                                            }, this);
4058                                            return;
4059                                        }
4060                                        var cloned = new WeakMap();
4061                                        var e = {data: cloneValue(obj)};
4062                                        this._deferred.then(function () {
4063                                            this._listeners.forEach(function (listener) {
4064                                                listener.call(this, e);
4065                                            }, this);
4066                                        }.bind(this));
4067                                    },
4068                                    addEventListener: function (name, listener) {
4069                                        this._listeners.push(listener);
4070                                    },
4071                                    removeEventListener: function (name, listener) {
4072                                        var i = this._listeners.indexOf(listener);
4073                                        this._listeners.splice(i, 1);
4074                                    },
4075                                    terminate: function () {
4076                                        this._listeners = [];
4077                                    }
4078                                };
4079                                function createCDNWrapper(url) {
4080                                    var wrapper = 'importScripts(\'' + url + '\');';
4081                                    return URL.createObjectURL(new Blob([wrapper]));
4082                                }
4083                                function PDFWorker(name, port) {
4084                                    this.name = name;
4085                                    this.destroyed = false;
4086                                    this._readyCapability = createPromiseCapability();
4087                                    this._port = null;
4088                                    this._webWorker = null;
4089                                    this._messageHandler = null;
4090                                    if (port) {
4091                                        this._initializeFromPort(port);
4092                                        return;
4093                                    }
4094                                    this._initialize();
4095                                }
4096                                PDFWorker.prototype = {
4097                                    get promise() {
4098                                        return this._readyCapability.promise;
4099                                    },
4100                                    get port() {
4101                                        return this._port;
4102                                    },
4103                                    get messageHandler() {
4104                                        return this._messageHandler;
4105                                    },
4106                                    _initializeFromPort: function PDFWorker_initializeFromPort(port) {
4107                                        this._port = port;
4108                                        this._messageHandler = new MessageHandler('main', 'worker', port);
4109                                        this._messageHandler.on('ready', function () {
4110                                        });
4111                                        this._readyCapability.resolve();
4112                                    },
4113                                    _initialize: function PDFWorker_initialize() {
4114                                        if (!isWorkerDisabled && !getDefaultSetting('disableWorker') && typeof Worker !== 'undefined') {
4115                                            var workerSrc = getWorkerSrc();
4116                                            try {
4117                                                if (!isSameOrigin(window.location.href, workerSrc)) {
4118                                                    workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href);
4119                                                }
4120                                                var worker = new Worker(workerSrc);
4121                                                var messageHandler = new MessageHandler('main', 'worker', worker);
4122                                                var terminateEarly = function () {
4123                                                    worker.removeEventListener('error', onWorkerError);
4124                                                    messageHandler.destroy();
4125                                                    worker.terminate();
4126                                                    if (this.destroyed) {
4127                                                        this._readyCapability.reject(new Error('Worker was destroyed'));
4128                                                    } else {
4129                                                        this._setupFakeWorker();
4130                                                    }
4131                                                }.bind(this);
4132                                                var onWorkerError = function (event) {
4133                                                    if (!this._webWorker) {
4134                                                        terminateEarly();
4135                                                    }
4136                                                }.bind(this);
4137                                                worker.addEventListener('error', onWorkerError);
4138                                                messageHandler.on('test', function PDFWorker_test(data) {
4139                                                    worker.removeEventListener('error', onWorkerError);
4140                                                    if (this.destroyed) {
4141                                                        terminateEarly();
4142                                                        return;
4143                                                    }
4144                                                    var supportTypedArray = data && data.supportTypedArray;
4145                                                    if (supportTypedArray) {
4146                                                        this._messageHandler = messageHandler;
4147                                                        this._port = worker;
4148                                                        this._webWorker = worker;
4149                                                        if (!data.supportTransfers) {
4150                                                            isPostMessageTransfersDisabled = true;
4151                                                        }
4152                                                        this._readyCapability.resolve();
4153                                                        messageHandler.send('configure', {verbosity: getVerbosityLevel()});
4154                                                    } else {
4155                                                        this._setupFakeWorker();
4156                                                        messageHandler.destroy();
4157                                                        worker.terminate();
4158                                                    }
4159                                                }.bind(this));
4160                                                messageHandler.on('console_log', function (data) {
4161                                                    console.log.apply(console, data);
4162                                                });
4163                                                messageHandler.on('console_error', function (data) {
4164                                                    console.error.apply(console, data);
4165                                                });
4166                                                messageHandler.on('ready', function (data) {
4167                                                    worker.removeEventListener('error', onWorkerError);
4168                                                    if (this.destroyed) {
4169                                                        terminateEarly();
4170                                                        return;
4171                                                    }
4172                                                    try {
4173                                                        sendTest();
4174                                                    } catch (e) {
4175                                                        this._setupFakeWorker();
4176                                                    }
4177                                                }.bind(this));
4178                                                var sendTest = function () {
4179                                                    var postMessageTransfers = getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled;
4180                                                    var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]);
4181                                                    try {
4182                                                        messageHandler.send('test', testObj, [testObj.buffer]);
4183                                                    } catch (ex) {
4184                                                        info('Cannot use postMessage transfers');
4185                                                        testObj[0] = 0;
4186                                                        messageHandler.send('test', testObj);
4187                                                    }
4188                                                };
4189                                                sendTest();
4190                                                return;
4191                                            } catch (e) {
4192                                                info('The worker has been disabled.');
4193                                            }
4194                                        }
4195                                        this._setupFakeWorker();
4196                                    },
4197                                    _setupFakeWorker: function PDFWorker_setupFakeWorker() {
4198                                        if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
4199                                            warn('Setting up fake worker.');
4200                                            isWorkerDisabled = true;
4201                                        }
4202                                        setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
4203                                            if (this.destroyed) {
4204                                                this._readyCapability.reject(new Error('Worker was destroyed'));
4205                                                return;
4206                                            }
4207                                            var isTypedArraysPresent = Uint8Array !== Float32Array;
4208                                            var port = new FakeWorkerPort(isTypedArraysPresent);
4209                                            this._port = port;
4210                                            var id = 'fake' + nextFakeWorkerId++;
4211                                            var workerHandler = new MessageHandler(id + '_worker', id, port);
4212                                            WorkerMessageHandler.setup(workerHandler, port);
4213                                            var messageHandler = new MessageHandler(id, id + '_worker', port);
4214                                            this._messageHandler = messageHandler;
4215                                            this._readyCapability.resolve();
4216                                        }.bind(this));
4217                                    },
4218                                    destroy: function PDFWorker_destroy() {
4219                                        this.destroyed = true;
4220                                        if (this._webWorker) {
4221                                            this._webWorker.terminate();
4222                                            this._webWorker = null;
4223                                        }
4224                                        this._port = null;
4225                                        if (this._messageHandler) {
4226                                            this._messageHandler.destroy();
4227                                            this._messageHandler = null;
4228                                        }
4229                                    }
4230                                };
4231                                return PDFWorker;
4232                            }();
4233                            var WorkerTransport = function WorkerTransportClosure() {
4234                                function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
4235                                    this.messageHandler = messageHandler;
4236                                    this.loadingTask = loadingTask;
4237                                    this.pdfDataRangeTransport = pdfDataRangeTransport;
4238                                    this.commonObjs = new PDFObjects();
4239                                    this.fontLoader = new FontLoader(loadingTask.docId);
4240                                    this.CMapReaderFactory = new CMapReaderFactory({
4241                                        baseUrl: getDefaultSetting('cMapUrl'),
4242                                        isCompressed: getDefaultSetting('cMapPacked')
4243                                    });
4244                                    this.destroyed = false;
4245                                    this.destroyCapability = null;
4246                                    this._passwordCapability = null;
4247                                    this.pageCache = [];
4248                                    this.pagePromises = [];
4249                                    this.downloadInfoCapability = createPromiseCapability();
4250                                    this.setupMessageHandler();
4251                                }
4252                                WorkerTransport.prototype = {
4253                                    destroy: function WorkerTransport_destroy() {
4254                                        if (this.destroyCapability) {
4255                                            return this.destroyCapability.promise;
4256                                        }
4257                                        this.destroyed = true;
4258                                        this.destroyCapability = createPromiseCapability();
4259                                        if (this._passwordCapability) {
4260                                            this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
4261                                        }
4262                                        var waitOn = [];
4263                                        this.pageCache.forEach(function (page) {
4264                                            if (page) {
4265                                                waitOn.push(page._destroy());
4266                                            }
4267                                        });
4268                                        this.pageCache = [];
4269                                        this.pagePromises = [];
4270                                        var self = this;
4271                                        var terminated = this.messageHandler.sendWithProm
4271ise('Terminate', null);
4272                                        waitOn.push(terminated);
4273                                        Promise.all(waitOn).then(function () {
4274                                            self.fontLoader.clear();
4275                                            if (self.pdfDataRangeTransport) {
4276                                                self.pdfDataRangeTransport.abort();
4277                                                self.pdfDataRangeTransport = null;
4278                                            }
4279                                            if (self.messageHandler) {
4280                                                self.messageHandler.destroy();
4281                                                self.messageHandler = null;
4282                                            }
4283                                            self.destroyCapability.resolve();
4284                                        }, this.destroyCapability.reject);
4285                                        return this.destroyCapability.promise;
4286                                    },
4287                                    setupMessageHandler: function WorkerTransport_setupMessageHandler() {
4288                                        var messageHandler = this.messageHandler;
4289                                        var loadingTask = this.loadingTask;
4290                                        var pdfDataRangeTransport = this.pdfDataRangeTransport;
4291                                        if (pdfDataRangeTransport) {
4292                                            pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
4293                                                messageHandler.send('OnDataRange', {
4294                                                    begin: begin,
4295                                                    chunk: chunk
4296                                                });
4297                                            });
4298                                            pdfDataRangeTransport.addProgressListener(function (loaded) {
4299                                                messageHandler.send('OnDataProgress', {loaded: loaded});
4300                                            });
4301                                            pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
4302                                                messageHandler.send('OnDataRange', {chunk: chunk});
4303                                            });
4304                                            messageHandler.on('RequestDataRange', function transportDataRange(data) {
4305                                                pdfDataRangeTransport.requestDataRange(data.begin, data.end);
4306                                            }, this);
4307                                        }
4308                                        messageHandler.on('GetDoc', function transportDoc(data) {
4309                                            var pdfInfo = data.pdfInfo;
4310                                            this.numPages = data.pdfInfo.numPages;
4311                                            var loadingTask = this.loadingTask;
4312                                            var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
4313                                            this.pdfDocument = pdfDocument;
4314                                            loadingTask._capability.resolve(pdfDocument);
4315                                        }, this);
4316                                        messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
4317                                            this._passwordCapability = createPromiseCapability();
4318                                            if (loadingTask.onPassword) {
4319                                                var updatePassword = function (password) {
4320                                                    this._passwordCapability.resolve({password: password});
4321                                                }.bind(this);
4322                                                loadingTask.onPassword(updatePassword, exception.code);
4323                                            } else {
4324                                                this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
4325                                            }
4326                                            return this._passwordCapability.promise;
4327                                        }, this);
4328                                        messageHandler.on('PasswordException', function transportPasswordException(exception) {
4329                                            loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
4330                                        }, this);
4331                                        messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
4332                                            this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
4333                                        }, this);
4334                                        messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
4335                                            this.loadingTask._capability.reject(new MissingPDFException(exception.message));
4336                                        }, this);
4337                                        messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
4338                                            this.loadingTask._capability.reject(new 
vendor: 11,711 bytes, lines 4338-4494
4338UnexpectedResponseException(exception.message, exception.status));
4339                                        }, this);
4340                                        messageHandler.on('UnknownError', function transportUnknownError(exception) {
4341                                            this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
4342                                        }, this);
4343                                        messageHandler.on('DataLoaded', function transportPage(data) {
4344                                            this.downloadInfoCapability.resolve(data);
4345                                        }, this);
4346                                        messageHandler.on('PDFManagerReady', function transportPage(data) {
4347                                            if (this.pdfDataRangeTransport) {
4348                                                this.pdfDataRangeTransport.transportReady();
4349                                            }
4350                                        }, this);
4351                                        messageHandler.on('StartRenderPage', function transportRender(data) {
4352                                            if (this.destroyed) {
4353                                                return;
4354                                            }
4355                                            var page = this.pageCache[data.pageIndex];
4356                                            page.stats.timeEnd('Page Request');
4357                                            page._startRenderPage(data.transparency, data.intent);
4358                                        }, this);
4359                                        messageHandler.on('RenderPageChunk', function transportRender(data) {
4360                                            if (this.destroyed) {
4361                                                return;
4362                                            }
4363                                            var page = this.pageCache[data.pageIndex];
4364                                            page._renderPageChunk(data.operatorList, data.intent);
4365                                        }, this);
4366                                        messageHandler.on('commonobj', function transportObj(data) {
4367                                            if (this.destroyed) {
4368                                                return;
4369                                            }
4370                                            var id = data[0];
4371                                            var type = data[1];
4372                                            if (this.commonObjs.hasData(id)) {
4373                                                return;
4374                                            }
4375                                            switch (type) {
4376                                                case 'Font':
4377                                                    var exportedData = data[2];
4378                                                    if ('error' in exportedData) {
4379                                                        var exportedError = exportedData.error;
4380                                                        warn('Error during font loading: ' + exportedError);
4381                                                        this.commonObjs.resolve(id, exportedError);
4382                                                        break;
4383                                                    }
4384                                                    var fontRegistry = null;
4385                                                    if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
4386                                                        fontRegistry = {
4387                                                            registerFont: function (font, url) {
4388                                                                globalScope['FontInspector'].fontAdded(font, url);
4389                                                            }
4390                                                        };
4391                                                    }
4392                                                    var font = new FontFaceObject(exportedData, {
4393                                                        isEvalSuported: getDefaultSetting('isEvalSupported'),
4394                                                        disableFontFace: getDefaultSetting('disableFontFace'),
4395                                                        fontRegistry: fontRegistry
4396                                                    });
4397                                                    this.fontLoader.bind([font], function fontReady(fontObjs) {
4398                                                        this.commonObjs.resolve(id, font);
4399                                                    }.bind(this));
4400                                                    break;
4401                                                case 'FontPath':
4402                                                    this.commonObjs.resolve(id, data[2]);
4403                                                    break;
4404                                                default:
4405                                                    error('Got unknown common object type ' + type);
4406                                            }
4407                                        }, this);
4408                                        messageHandler.on('obj', function transportObj(data) {
4409                                            if (this.destroyed) {
4410                                                return;
4411                                            }
4412                                            var id = data[0];
4413                                            var pageIndex = data[1];
4414                                            var type = data[2];
4415                                            var pageProxy = this.pageCache[pageIndex];
4416                                            var imageData;
4417                                            if (pageProxy.objs.hasData(id)) {
4418                                                return;
4419                                            }
4420                                            switch (type) {
4421                                                case 'JpegStream':
4422                                                    imageData = data[3];
4423                                                    loadJpegStream(id, imageData, pageProxy.objs);
4424                                                    break;
4425                                                case 'Image':
4426                                                    imageData = data[3];
4427                                                    pageProxy.objs.resolve(id, imageData);
4428                                                    var MAX_IMAGE_SIZE_TO_STORE = 8000000;
4429                                                    if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
4430                                                        pageProxy.cleanupAfterRender = true;
4431                                                    }
4432                                                    break;
4433                                                default:
4434                                                    error('Got unknown object type ' + type);
4435                                            }
4436                                        }, this);
4437                                        messageHandler.on('DocProgress', function transportDocProgress(data) {
4438                                            if (this.destroyed) {
4439                                                return;
4440                                            }
4441                                            var loadingTask = this.loadingTask;
4442                                            if (loadingTask.onProgress) {
4443                                                loadingTask.onProgress({
4444                                                    loaded: data.loaded,
4445                                                    total: data.total
4446                                                });
4447                                            }
4448                                        }, this);
4449                                        messageHandler.on('PageError', function transportError(data) {
4450                                            if (this.destroyed) {
4451                                                return;
4452                                            }
4453                                            var page = this.pageCache[data.pageNum - 1];
4454                                            var intentState = page.intentStates[data.intent];
4455                                            if (intentState.displayReadyCapability) {
4456                                                intentState.displayReadyCapability.reject(data.error);
4457                                            } else {
4458                                                error(data.error);
4459                                            }
4460                                            if (intentState.operatorList) {
4461                                                intentState.operatorList.lastChunk = true;
4462                                                for (var i = 0; i < intentState.renderTasks.length; i++) {
4463                                                    intentState.renderTasks[i].operatorListChanged();
4464                                                }
4465                                            }
4466                                        }, this);
4467                                        messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
4468                                            if (this.destroyed) {
4469                                                return;
4470                                            }
4471                                            var featureId = data.featureId;
4472                                            var loadingTask = this.loadingTask;
4473                                            if (loadingTask.onUnsupportedFeature) {
4474                                                loadingTask.onUnsupportedFeature(featureId);
4475                                            }
4476                                            _UnsupportedManager.notify(featureId);
4477                                        }, this);
4478                                        messageHandler.on('JpegDecode', function (data) {
4479                                            if (this.destroyed) {
4480                                                return Promise.reject(new Error('Worker was destroyed'));
4481                                            }
4482                                            if (typeof document === 'undefined') {
4483                                                return Promise.reject(new Error('"document" is not defined.'));
4484                                            }
4485                                            var imageUrl = data[0];
4486                                            var components = data[1];
4487                                            if (components !== 3 && components !== 1) {
4488                                                return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
4489                                            }
4490                                            return new Promise(function (resolve, reject) {
4491                                                var img = new Image();
4492                                                img.onload = function () {
4493                                                    var width = img.width;
4494                                                    var height = img.he
4494ight;
4495                                                    var size = width * height;
4496                                                    var rgbaLength = size * 4;
4497                                                    var buf = new Uint8Array(size * components);
4498                                                    var tmpCanvas = document.createElement('canvas');
4499                                                    tmpCanvas.width = width;
4500                                                    tmpCanvas.height = height;
4501                                                    var tmpCtx = tmpCanvas.getContext('2d');
4502                                                    tmpCtx.drawImage(img, 0, 0);
4503                                                    var data = tmpCtx.getImageData(0, 0, width, height).data;
4504                                                    var i, j;
4505                                                    if (components === 3) {
4506                                                        for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
4507                                                            buf[j] = data[i];
4508                                                            buf[j + 1] = data[i + 1];
4509                                                            buf[j + 2] = data[i + 2];
4510                                                        }
4511                                                    } else if (components === 1) {
4512                                                        for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
4513                                                            buf[j] = data[i];
4514                                                        }
4515                                                    }
4516                                                    resolve({
4517                                                        data: buf,
4518                                                        width: width,
4519                                                        height: height
4520                                                    });
4521                                                };
4522                                                img.onerror = function () {
4523                                                    reject(new Error('JpegDecode failed to load image'));
4524                                                };
4525                                                img.src = imageUrl;
4526                                            });
4527                                        }, this);
4528                                        messageHandler.on('FetchBuiltInCMap', function (data) {
4529                                            if (this.destroyed) {
4530                                                return Promise.reject(new Error('Worker was destroyed'));
4531                                            }
4532                                            return this.CMapReaderFactory.fetch({name: data.name});
4533                                        }, this);
4534                                    },
4535                                    getData: function WorkerTransport_getData() {
4536                                        return this.messageHandler.sendWithPromise('GetData', null);
4537                                    },
4538                                    getPage: function WorkerTransport_getPage(pageNumber, capability) {
4539                                        if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
4540                                            return Promise.reject(new Error('Invalid page request'));
4541                                        }
4542                                        var pageIndex = pageNumber - 1;
4543                                        if (pageIndex in this.pagePromises) {
4544                                            return this.pagePromises[pageIndex];
4545                                        }
4546                                        var promise = this.messageHandler.sendWithPromise('GetPage', {pageIndex: pageIndex}).then(function (pageInfo) {
4547                                            if (this.destroyed) {
4548                                                throw new Error('Trans
vendor: 6,790 bytes, lines 4548-4646
4548port destroyed');
4549                                            }
4550                                            var page = new PDFPageProxy(pageIndex, pageInfo, this);
4551                                            this.pageCache[pageIndex] = page;
4552                                            return page;
4553                                        }.bind(this));
4554                                        this.pagePromises[pageIndex] = promise;
4555                                        return promise;
4556                                    },
4557                                    getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
4558                                        return this.messageHandler.sendWithPromise('GetPageIndex', {ref: ref}).catch(function (reason) {
4559                                            return Promise.reject(new Error(reason));
4560                                        });
4561                                    },
4562                                    getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
4563                                        return this.messageHandler.sendWithPromise('GetAnnotations', {
4564                                            pageIndex: pageIndex,
4565                                            intent: intent
4566                                        });
4567                                    },
4568                                    getDestinations: function WorkerTransport_getDestinations() {
4569                                        return this.messageHandler.sendWithPromise('GetDestinations', null);
4570                                    },
4571                                    getDestination: function WorkerTransport_getDestination(id) {
4572                                        return this.messageHandler.sendWithPromise('GetDestination', {id: id});
4573                                    },
4574                                    getPageLabels: function WorkerTransport_getPageLabels() {
4575                                        return this.messageHandler.sendWithPromise('GetPageLabels', null);
4576                                    },
4577                                    getAttachments: function WorkerTransport_getAttachments() {
4578                                        return this.messageHandler.sendWithPromise('GetAttachments', null);
4579                                    },
4580                                    getJavaScript: function WorkerTransport_getJavaScript() {
4581                                        return this.messageHandler.sendWithPromise('GetJavaScript', null);
4582                                    },
4583                                    getOutline: function WorkerTransport_getOutline() {
4584                                        return this.messageHandler.sendWithPromise('GetOutline', null);
4585                                    },
4586                                    getMetadata: function WorkerTransport_getMetadata() {
4587                                        return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
4588                                            return {
4589                                                info: results[0],
4590                                                metadata: results[1] ? new Metadata(results[1]) : null
4591                                            };
4592                                        });
4593                                    },
4594                                    getStats: function WorkerTransport_getStats() {
4595                                        return this.messageHandler.sendWithPromise('GetStats', null);
4596                                    },
4597                                    startCleanup: function WorkerTransport_startCleanup() {
4598                                        this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
4599                                            for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
4600                                                var page = this.pageCache[i];
4601                                                if (page) {
4602                                                    page.cleanup();
4603                                                }
4604                                            }
4605                                            this.commonObjs.clear();
4606                                            this.fontLoader.clear();
4607                                        }.bind(this));
4608                                    }
4609                                };
4610                                return WorkerTransport;
4611                            }();
4612                            var PDFObjects = function PDFObjectsClosure() {
4613                                function PDFObjects() {
4614                                    this.objs = Object.create(null);
4615                                }
4616                                PDFObjects.prototype = {
4617                                    ensureObj: function PDFObjects_ensureObj(objId) {
4618                                        if (this.objs[objId]) {
4619                                            return this.objs[objId];
4620                                        }
4621                                        var obj = {
4622                                            capability: createPromiseCapability(),
4623                                            data: null,
4624                                            resolved: false
4625                                        };
4626                                        this.objs[objId] = obj;
4627                                        return obj;
4628                                    },
4629                                    get: function PDFObjects_get(objId, callback) {
4630                                        if (callback) {
4631                                            this.ensureObj(objId).capability.promise.then(callback);
4632                                            return null;
4633                                        }
4634                                        var obj = this.objs[objId];
4635                                        if (!obj || !obj.resolved) {
4636                                            error('Requesting object that isn\'t resolved yet ' + objId);
4637                                        }
4638                                        return obj.data;
4639                                    },
4640                                    resolve: function PDFObjects_resolve(objId, data) {
4641                                        var obj = this.ensureObj(objId);
4642                                        obj.resolved = true;
4643                                        obj.data = data;
4644                                        obj.capability.resolve(data);
4645                                    },
4646                                    isResolved: function PDFObjects_isResolved(objI
4646d) {
4647                                        var objs = this.objs;
4648                                        if (!objs[objId]) {
4649                                            return false;
4650                                        }
4651                                        return objs[objId].resolved;
4652                                    },
4653                                    hasData: function PDFObjects_hasData(objId) {
4654                                        return this.isResolved(objId);
4655                                    },
4656                                    getData: function PDFObjects_getData(objId) {
4657                                        var objs = this.objs;
4658                                        if (!objs[objId] || !objs[objId].resolved) {
4659                                            return null;
4660                                        }
4661                                        return objs[objId].data;
4662                                    },
4663                                    clear: function PDFObjects_clear() {
4664                                        this.objs = Object.create(null);
4665                                    }
4666                                };
4667                                return PDFObjects;
4668                            }();
4669                            var RenderTask = function RenderTaskClosure() {
4670                                function RenderTask(internalRenderTask) {
4671                                    this._internalRenderTask = internalRenderTask;
4672                                    this.onContinue = null;
4673                                }
4674                                RenderTask.prototype = {
4675                                    get promise() {
4676                                        return this._internalRenderTask.capability.promise;
4677                                    },
4678                                    cancel: function RenderTask_cancel() {
4679                                        this._internalRenderTask.cancel();
4680                                    },
4681                                    then: function RenderTask_then(onFulfilled, onRejected) {
4682                                        return this.promise.then.apply(this.promise, arguments);
4683                                    }
4684                                };
4685                                return RenderTask;
4686                            }();
4687                            var InternalRenderTask = function InternalRenderTaskClosure() {
4688                                function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
4689                                    this.callback = callback;
4690                                    this.params = params;
4691                                    this.objs = objs;
4692                                    this.commonObjs = commonObjs;
4693                                    this.operatorListIdx = null;
4694                                    this.operatorList = operatorList;
4695                                    this.pageNumber = pageNumber;
4696                                    this.canvasFactory = canvasFactory;
4697                                    this.running = false;
4698                                    this.graphicsReadyCallback = null;
4699                                    this.graphicsReady = false;
4700                                    this.useRequestAnimationFrame = false;
4701                                    this.cancelled = false;
4702                                    this.capability = createPromiseCapability();
4703                                    this.task = new RenderTask(this);
4704                                    this._continueBound = this._continue.bind(this);
4705                                    this._scheduleNextBound = this._scheduleNext.bind(this);
4706                                    this._nextBound = this._next.bind(this);
4707                                }
4708                                InternalRenderTask.prototype = {
4709                                    initializeGraphics: function InternalRenderTask_initializeGraphics(trans
vendor: 4,376 bytes, lines 4709-4771
4709parency) {
4710                                        if (this.cancelled) {
4711                                            return;
4712                                        }
4713                                        if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
4714                                            this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
4715                                            this.stepper.init(this.operatorList);
4716                                            this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
4717                                        }
4718                                        var params = this.params;
4719                                        this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
4720                                        this.gfx.beginDrawing(params.transform, params.viewport, transparency);
4721                                        this.operatorListIdx = 0;
4722                                        this.graphicsReady = true;
4723                                        if (this.graphicsReadyCallback) {
4724                                            this.graphicsReadyCallback();
4725                                        }
4726                                    },
4727                                    cancel: function InternalRenderTask_cancel() {
4728                                        this.running = false;
4729                                        this.cancelled = true;
4730                                        this.callback('cancelled');
4731                                    },
4732                                    operatorListChanged: function InternalRenderTask_operatorListChanged() {
4733                                        if (!this.graphicsReady) {
4734                                            if (!this.graphicsReadyCallback) {
4735                                                this.graphicsReadyCallback = this._continueBound;
4736                                            }
4737                                            return;
4738                                        }
4739                                        if (this.stepper) {
4740                                            this.stepper.updateOperatorList(this.operatorList);
4741                                        }
4742                                        if (this.running) {
4743                                            return;
4744                                        }
4745                                        this._continue();
4746                                    },
4747                                    _continue: function InternalRenderTask__continue() {
4748                                        this.running = true;
4749                                        if (this.cancelled) {
4750                                            return;
4751                                        }
4752                                        if (this.task.onContinue) {
4753                                            this.task.onContinue(this._scheduleNextBound);
4754                                        } else {
4755                                            this._scheduleNext();
4756                                        }
4757                                    },
4758                                    _scheduleNext: function InternalRenderTask__scheduleNext() {
4759                                        if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
4760                                            window.requestAnimationFrame(this._nextBound);
4761                                        } else {
4762                                            Promise.resolve(undefined).then(this._nextBound);
4763                                        }
4764                                    },
4765                                    _next: function InternalRenderTask__next() {
4766                                        if (this.cancelled) {
4767                                            return;
4768                                        }
4769                                        this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
4770                                        if (this.operatorListIdx === this.operatorList.argsArray.length) {
4771                                            this.running = false;
4772                                            if (this.operatorList.lastChunk) {
4773                                                this.gfx.endDrawing();
4774                                                this.callback();
4775                                            }
4776                                        }
4777                                    }
4778                                };
4779                                return InternalRenderTask;
4780                            }();
4781                            var _UnsupportedManager = function UnsupportedManagerClosure() {
4782                                var listeners = [];
4783                                return {
4784                                    listen: function (cb) {
4785                                        deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
4786                                        listeners.push(cb);
4787                                    },
4788                                    notify: function (featureId) {
4789                                        for (var i = 0, ii = listeners.length; i < ii; i++) {
4790                                            listeners[i](featureId);
4791                                        }
4792                                    }
4793                                };
4794                            }();
4795                            exports.version = '1.7.354';
4796                            exports.build = '0f7548ba';
4797                            exports.getDocument = getDocument;
4798                            exports.PDFDataRangeTransport = PDFDataRangeTransport;
4799                            exports.PDFWorker = PDFWorker;
4800                            exports.PDFDocumentProxy = PDFDocumentProxy;
4801                            exports.PDFPageProxy = PDFPageProxy;
4802                            exports._UnsupportedManager = _UnsupportedManager;
4803
4804                            /***/ }),
4805                        /* 4 */
4806                        /***/ (function (module, exports, __w_pdfjs_require__) {
4807
4808                            "use strict";
4809
4810                            var sharedUtil = __w_pdfjs_require__(0);
4811                            var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
4812                            var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
4813                            var ImageKind = sharedUtil.ImageKind;
4814                            var OPS = sharedUtil.OPS;
4815                            var Util = sharedUtil.Util;
4816                            var isNum = sharedUtil.isNum;
4817                            var isArray = sharedUtil.isArray;
4818                            var warn = sharedUtil.warn;
4819                            var createObjectURL = sharedUtil.createObjectURL;
4820                            var SVG_DEFAULTS = {
4821                                fontStyle: 'normal',
4822                                fontWeight: 'normal',
4823                                fillColor: '#000000'
4824                            };
4825                            var convertImgDataToPng = function convertImgDataToPngClosure() {
4826                                var PNG_HEADER = new Uint8Array([
4827                                    0x89,
4828                                    0x50,
4829                                    0x4e,
4830                                    0x47,
4831                                    0x0d,
4832                                    0x0a,
4833                                    0x1a,
4834                                    0x0a
4835                                ]);
4836                                var CHUNK_WRAPPER_SIZE = 12;
4837                                var crcTable = new Int32Array(256);
4838                                for (var i = 0; i < 256; i++) {
4839                                    var c = i;
4840                                    for (var h = 0; h < 8; h++) {
4841                                        if (c & 1) {
4842                                            c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
4843                                        } else {
4844                                            c = c >> 1 & 0x7fffffff;
4845                                        }
4846                                    }
4847                                    crcTable[i] = c;
4848                                }
4849                                function crc32(data, start, end) {
4850                                    var crc = -1;
4851                                    for (var i = start; i < end; i++) {
4852                                        var a = (crc ^ data[i]) & 0xff;
vendor: 6,443 bytes, lines 4853-4958
4853                                        var b = crcTable[a];
4854                                        crc = crc >>> 8 ^ b;
4855                                    }
4856                                    return crc ^ -1;
4857                                }
4858                                function writePngChunk(type, body, data, offset) {
4859                                    var p = offset;
4860                                    var len = body.length;
4861                                    data[p] = len >> 24 & 0xff;
4862                                    data[p + 1] = len >> 16 & 0xff;
4863                                    data[p + 2] = len >> 8 & 0xff;
4864                                    data[p + 3] = len & 0xff;
4865                                    p += 4;
4866                                    data[p] = type.charCodeAt(0) & 0xff;
4867                                    data[p + 1] = type.charCodeAt(1) & 0xff;
4868                                    data[p + 2] = type.charCodeAt(2) & 0xff;
4869                                    data[p + 3] = type.charCodeAt(3) & 0xff;
4870                                    p += 4;
4871                                    data.set(body, p);
4872                                    p += body.length;
4873                                    var crc = crc32(data, offset + 4, p);
4874                                    data[p] = crc >> 24 & 0xff;
4875                                    data[p + 1] = crc >> 16 & 0xff;
4876                                    data[p + 2] = crc >> 8 & 0xff;
4877                                    data[p + 3] = crc & 0xff;
4878                                }
4879                                function adler32(data, start, end) {
4880                                    var a = 1;
4881                                    var b = 0;
4882                                    for (var i = start; i < end; ++i) {
4883                                        a = (a + (data[i] & 0xff)) % 65521;
4884                                        b = (b + a) % 65521;
4885                                    }
4886                                    return b << 16 | a;
4887                                }
4888                                function encode(imgData, kind, forceDataSchema) {
4889                                    var width = imgData.width;
4890                                    var height = imgData.height;
4891                                    var bitDepth, colorType, lineSize;
4892                                    var bytes = imgData.data;
4893                                    switch (kind) {
4894                                        case ImageKind.GRAYSCALE_1BPP:
4895                                            colorType = 0;
4896                                            bitDepth = 1;
4897                                            lineSize = width + 7 >> 3;
4898                                            break;
4899                                        case ImageKind.RGB_24BPP:
4900                                            colorType = 2;
4901                                            bitDepth = 8;
4902                                            lineSize = width * 3;
4903                                            break;
4904                                        case ImageKind.RGBA_32BPP:
4905                                            colorType = 6;
4906                                            bitDepth = 8;
4907                                            lineSize = width * 4;
4908                                            break;
4909                                        default:
4910                                            throw new Error('invalid format');
4911                                    }
4912                                    var literals = new Uint8Array((1 + lineSize) * height);
4913                                    var offsetLiterals = 0, offsetBytes = 0;
4914                                    var y, i;
4915                                    for (y = 0; y < height; ++y) {
4916                                        literals[offsetLiterals++] = 0;
4917                                        literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
4918                                        offsetBytes += lineSize;
4919                                        offsetLiterals += lineSize;
4920                                    }
4921                                    if (kind === ImageKind.GRAYSCALE_1BPP) {
4922                                        offsetLiterals = 0;
4923                                        for (y = 0; y < height; y++) {
4924                                            offsetLiterals++;
4925                                            for (i = 0; i < lineSize; i++) {
4926                                                literals[offsetLiterals++] ^= 0xFF;
4927                                            }
4928                                        }
4929                                    }
4930                                    var ihdr = new Uint8Array([
4931                                        width >> 24 & 0xff,
4932                                        width >> 16 & 0xff,
4933                                        width >> 8 & 0xff,
4934                                        width & 0xff,
4935                                        height >> 24 & 0xff,
4936                                        height >> 16 & 0xff,
4937                                        height >> 8 & 0xff,
4938                                        height & 0xff,
4939                                        bitDepth,
4940                                        colorType,
4941                                        0x00,
4942                                        0x00,
4943                                        0x00
4944                                    ]);
4945                                    var len = literals.length;
4946                                    var maxBlockLength = 0xFFFF;
4947                                    var deflateBlocks = Math.ceil(len / maxBlockLength);
4948                                    var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
4949                                    var pi = 0;
4950                                    idat[pi++] = 0x78;
4951                                    idat[pi++] = 0x9c;
4952                                    var pos = 0;
4953                                    while (len > maxBlockLength) {
4954                                        idat[pi++] = 0x00;
4955                                        idat[pi++] = 0xff;
4956                                        idat[pi++] = 0xff;
4957                                        idat[pi++] = 0x00;
4958                                        idat[pi++] = 0x00;
vendor: 4,786 bytes, lines 4959-5032
4959                                        idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
4960                                        pi += maxBlockLength;
4961                                        pos += maxBlockLength;
4962                                        len -= maxBlockLength;
4963                                    }
4964                                    idat[pi++] = 0x01;
4965                                    idat[pi++] = len & 0xff;
4966                                    idat[pi++] = len >> 8 & 0xff;
4967                                    idat[pi++] = ~len & 0xffff & 0xff;
4968                                    idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
4969                                    idat.set(literals.subarray(pos), pi);
4970                                    pi += literals.length - pos;
4971                                    var adler = adler32(literals, 0, literals.length);
4972                                    idat[pi++] = adler >> 24 & 0xff;
4973                                    idat[pi++] = adler >> 16 & 0xff;
4974                                    idat[pi++] = adler >> 8 & 0xff;
4975                                    idat[pi++] = adler & 0xff;
4976                                    var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
4977                                    var data = new Uint8Array(pngLength);
4978                                    var offset = 0;
4979                                    data.set(PNG_HEADER, offset);
4980                                    offset += PNG_HEADER.length;
4981                                    writePngChunk('IHDR', ihdr, data, offset);
4982                                    offset += CHUNK_WRAPPER_SIZE + ihdr.length;
4983                                    writePngChunk('IDATA', idat, data, offset);
4984                                    offset += CHUNK_WRAPPER_SIZE + idat.length;
4985                                    writePngChunk('IEND', new Uint8Array(0), data, offset);
4986                                    return createObjectURL(data, 'image/png', forceDataSchema);
4987                                }
4988                                return function convertImgDataToPng(imgData, forceDataSchema) {
4989                                    var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
4990                                    return encode(imgData, kind, forceDataSchema);
4991                                };
4992                            }();
4993                            var SVGExtraState = function SVGExtraStateClosure() {
4994                                function SVGExtraState() {
4995                                    this.fontSizeScale = 1;
4996                                    this.fontWeight = SVG_DEFAULTS.fontWeight;
4997                                    this.fontSize = 0;
4998                                    this.textMatrix = IDENTITY_MATRIX;
4999                                    this.fontMatrix = FONT_IDENTITY_MATRIX;
5000                                    this.leading = 0;
5001                                    this.x = 0;
5002                                    this.y = 0;
5003                                    this.lineX = 0;
5004                                    this.lineY = 0;
5005                                    this.charSpacing = 0;
5006                                    this.wordSpacing = 0;
5007                                    this.textHScale = 1;
5008                                    this.textRise = 0;
5009                                    this.fillColor = SVG_DEFAULTS.fillColor;
5010                                    this.strokeColor = '#000000';
5011                                    this.fillAlpha = 1;
5012                                    this.strokeAlpha = 1;
5013                                    this.lineWidth = 1;
5014                                    this.lineJoin = '';
5015                                    this.lineCap = '';
5016                                    this.miterLimit = 0;
5017                                    this.dashArray = [];
5018                                    this.dashPhase = 0;
5019                                    this.dependencies = [];
5020                                    this.activeClipUrl = null;
5021                                    this.clipGroup = null;
5022                                    this.maskId = '';
5023                                }
5024                                SVGExtraState.prototype = {
5025                                    clone: function SVGExtraState_clone() {
5026                                        return Object.create(this);
5027                                    },
5028                                    setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
5029                                        this.x = x;
5030                                        this.y = y;
5031                                    }
5032                                };
vendor: 51,638 bytes, lines 5033-5752
5033                                return SVGExtraState;
5034                            }();
5035                            var SVGGraphics = function SVGGraphicsClosure() {
5036                                function opListToTree(opList) {
5037                                    var opTree = [];
5038                                    var tmp = [];
5039                                    var opListLen = opList.length;
5040                                    for (var x = 0; x < opListLen; x++) {
5041                                        if (opList[x].fn === 'save') {
5042                                            opTree.push({
5043                                                'fnId': 92,
5044                                                'fn': 'group',
5045                                                'items': []
5046                                            });
5047                                            tmp.push(opTree);
5048                                            opTree = opTree[opTree.length - 1].items;
5049                                            continue;
5050                                        }
5051                                        if (opList[x].fn === 'restore') {
5052                                            opTree = tmp.pop();
5053                                        } else {
5054                                            opTree.push(opList[x]);
5055                                        }
5056                                    }
5057                                    return opTree;
5058                                }
5059                                function pf(value) {
5060                                    if (value === (value | 0)) {
5061                                        return value.toString();
5062                                    }
5063                                    var s = value.toFixed(10);
5064                                    var i = s.length - 1;
5065                                    if (s[i] !== '0') {
5066                                        return s;
5067                                    }
5068                                    do {
5069                                        i--;
5070                                    } while (s[i] === '0');
5071                                    return s.substr(0, s[i] === '.' ? i : i + 1);
5072                                }
5073                                function pm(m) {
5074                                    if (m[4] === 0 && m[5] === 0) {
5075                                        if (m[1] === 0 && m[2] === 0) {
5076                                            if (m[0] === 1 && m[3] === 1) {
5077                                                return '';
5078                                            }
5079                                            return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
5080                                        }
5081                                        if (m[0] === m[3] && m[1] === -m[2]) {
5082                                            var a = Math.acos(m[0]) * 180 / Math.PI;
5083                                            return 'rotate(' + pf(a) + ')';
5084                                        }
5085                                    } else {
5086                                        if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
5087                                            return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
5088                                        }
5089                                    }
5090                                    return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
5091                                }
5092                                function SVGGraphics(commonObjs, objs, forceDataSchema) {
5093                                    this.current = new SVGExtraState();
5094                                    this.transformMatrix = IDENTITY_MATRIX;
5095                                    this.transformStack = [];
5096                                    this.extraStack = [];
5097                                    this.commonObjs = commonObjs;
5098                                    this.objs = objs;
5099                                    this.pendingEOFill = false;
5100                                    this.embedFonts = false;
5101                                    this.embeddedFonts = Object.create(null);
5102                                    this.cssStyle = null;
5103                                    this.forceDataSchema = !!forceDataSchema;
5104                                }
5105                                var NS = 'http://www.w3.org/2000/svg';
5106                                var XML_NS = 'http://www.w3.org/XML/1998/namespace';
5107                                var XLINK_NS = 'http://www.w3.org/1999/xlink';
5108                                var LINE_CAP_STYLES = [
5109                                    'butt',
5110                                    'round',
5111                                    'square'
5112                                ];
5113                                var LINE_JOIN_STYLES = [
5114                                    'miter',
5115                                    'round',
5116                                    'bevel'
5117                                ];
5118                                var clipCount = 0;
5119                                var maskCount = 0;
5120                                SVGGraphics.prototype = {
5121                                    save: function SVGGraphics_save() {
5122                                        this.transformStack.push(this.transformMatrix);
5123                                        var old = this.current;
5124                                        this.extraStack.push(old);
5125                                        this.current = old.clone();
5126                                    },
5127                                    restore: function SVGGraphics_restore() {
5128                                        this.transformMatrix = this.transformStack.pop();
5129                                        this.current = this.extraStack.pop();
5130                                        this.tgrp = null;
5131                                    },
5132                                    group: function SVGGraphics_group(items) {
5133                                        this.save();
5134                                        this.executeOpTree(items);
5135                                        this.restore();
5136                                    },
5137                                    loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
5138                                        var fnArray = operatorList.fnArray;
5139                                        var fnArrayLen = fnArray.length;
5140                                        var argsArray = operatorList.argsArray;
5141                                        var self = this;
5142                                        for (var i = 0; i < fnArrayLen; i++) {
5143                                            if (OPS.dependency === fnArray[i]) {
5144                                                var deps = argsArray[i];
5145                                                for (var n = 0, nn = deps.length; n < nn; n++) {
5146                                                    var obj = deps[n];
5147                                                    var common = obj.substring(0, 2) === 'g_';
5148                                                    var promise;
5149                                                    if (common) {
5150                                                        promise = new Promise(function (resolve) {
5151                                                            self.commonObjs.get(obj, resolve);
5152                                                        });
5153                                                    } else {
5154                                                        promise = new Promise(function (resolve) {
5155                                                            self.objs.get(obj, resolve);
5156                                                        });
5157                                                    }
5158                                                    this.current.dependencies.push(promise);
5159                                                }
5160                                            }
5161                                        }
5162                                        return Promise.all(this.current.dependencies);
5163                                    },
5164                                    transform: function SVGGraphics_transform(a, b, c, d, e, f) {
5165                                        var transformMatrix = [
5166                                            a,
5167                                            b,
5168                                            c,
5169                                            d,
5170                                            e,
5171                                            f
5172                                        ];
5173                                        this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
5174                                        this.tgrp = null;
5175                                    },
5176                                    getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
5177                                        this.viewport = viewport;
5178                                        var svgElement = this._initialize(viewport);
5179                                        return this.loadDependencies(operatorList).then(function () {
5180                                            this.transformMatrix = IDENTITY_MATRIX;
5181                                            var opTree = this.convertOpList(operatorList);
5182                                            this.executeOpTree(opTree);
5183                                            return svgElement;
5184                                        }.bind(this));
5185                                    },
5186                                    convertOpList: function SVGGraphics_convertOpList(operatorList) {
5187                                        var argsArray = operatorList.argsArray;
5188                                        var fnArray = operatorList.fnArray;
5189                                        var fnArrayLen = fnArray.length;
5190                                        var REVOPS = [];
5191                                        var opList = [];
5192                                        for (var op in OPS) {
5193                                            REVOPS[OPS[op]] = op;
5194                                        }
5195                                        for (var x = 0; x < fnArrayLen; x++) {
5196                                            var fnId = fnArray[x];
5197                                            opList.push({
5198                                                'fnId': fnId,
5199                                                'fn': REVOPS[fnId],
5200                                                'args': argsArray[x]
5201                                            });
5202                                        }
5203                                        return opListToTree(opList);
5204                                    },
5205                                    executeOpTree: function SVGGraphics_executeOpTree(opTree) {
5206                                        var opTreeLen = opTree.length;
5207                                        for (var x = 0; x < opTreeLen; x++) {
5208                                            var fn = opTree[x].fn;
5209                                            var fnId = opTree[x].fnId;
5210                                            var args = opTree[x].args;
5211                                            switch (fnId | 0) {
5212                                                case OPS.beginText:
5213                                                    this.beginText();
5214                                                    break;
5215                                                case OPS.setLeading:
5216                                                    this.setLeading(args);
5217                                                    break;
5218                                                case OPS.setLeadingMoveText:
5219                                                    this.setLeadingMoveText(args[0], args[1]);
5220                                                    break;
5221                                                case OPS.setFont:
5222                                                    this.setFont(args);
5223                                                    break;
5224                                                case OPS.showText:
5225                                                    this.showText(args[0]);
5226                                                    break;
5227                                                case OPS.showSpacedText:
5228                                                    this.showText(args[0]);
5229                                                    break;
5230                                                case OPS.endText:
5231                                                    this.endText();
5232                                                    break;
5233                                                case OPS.moveText:
5234                                                    this.moveText(args[0], args[1]);
5235                                                    break;
5236                                                case OPS.setCharSpacing:
5237                                                    this.setCharSpacing(args[0]);
5238                                                    break;
5239                                                case OPS.setWordSpacing:
5240                                                    this.setWordSpacing(args[0]);
5241                                                    break;
5242                                                case OPS.setHScale:
5243                                                    this.setHScale(args[0]);
5244                                                    break;
5245                                                case OPS.setTextMatrix:
5246                                                    this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
5247                                                    break;
5248                                                case OPS.setLineWidth:
5249                                                    this.setLineWidth(args[0]);
5250                                                    break;
5251                                                case OPS.setLineJoin:
5252                                                    this.setLineJoin(args[0]);
5253                                                    break;
5254                                                case OPS.setLineCap:
5255                                                    this.setLineCap(args[0]);
5256                                                    break;
5257                                                case OPS.setMiterLimit:
5258                                                    this.setMiterLimit(args[0]);
5259                                                    break;
5260                                                case OPS.setFillRGBColor:
5261                                                    this.setFillRGBColor(args[0], args[1], args[2]);
5262                                                    break;
5263                                                case OPS.setStrokeRGBColor:
5264                                                    this.setStrokeRGBColor(args[0], args[1], args[2]);
5265                                                    break;
5266                                                case OPS.setDash:
5267                                                    this.setDash(args[0], args[1]);
5268                                                    break;
5269                                                case OPS.setGState:
5270                                                    this.setGState(args[0]);
5271                                                    break;
5272                                                case OPS.fill:
5273                                                    this.fill();
5274                                                    break;
5275                                                case OPS.eoFill:
5276                                                    this.eoFill();
5277                                                    break;
5278                                                case OPS.stroke:
5279                                                    this.stroke();
5280                                                    break;
5281                                                case OPS.fillStroke:
5282                                                    this.fillStroke();
5283                                                    break;
5284                                                case OPS.eoFillStroke:
5285                                                    this.eoFillStroke();
5286                                                    break;
5287                                                case OPS.clip:
5288                                                    this.clip('nonzero');
5289                                                    break;
5290                                                case OPS.eoClip:
5291                                                    this.clip('evenodd');
5292                                                    break;
5293                                                case OPS.paintSolidColorImageMask:
5294                                                    this.paintSolidColorImageMask();
5295                                                    break;
5296                                                case OPS.paintJpegXObject:
5297                                                    this.paintJpegXObject(args[0], args[1], args[2]);
5298                                                    break;
5299                                                case OPS.paintImageXObject:
5300                                                    this.paintImageXObject(args[0]);
5301                                                    break;
5302                                                case OPS.paintInlineImageXObject:
5303                                                    this.paintInlineImageXObject(args[0]);
5304                                                    break;
5305                                                case OPS.paintImageMaskXObject:
5306                                                    this.paintImageMaskXObject(args[0]);
5307                                                    break;
5308                                                case OPS.paintFormXObjectBegin:
5309                                                    this.paintFormXObjectBegin(args[0], args[1]);
5310                                                    break;
5311                                                case OPS.paintFormXObjectEnd:
5312                                                    this.paintFormXObjectEnd();
5313                                                    break;
5314                                                case OPS.closePath:
5315                                                    this.closePath();
5316                                                    break;
5317                                                case OPS.closeStroke:
5318                                                    this.closeStroke();
5319                                                    break;
5320                                                case OPS.closeFillStroke:
5321                                                    this.closeFillStroke();
5322                                                    break;
5323                                                case OPS.nextLine:
5324                                                    this.nextLine();
5325                                                    break;
5326                                                case OPS.transform:
5327                                                    this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
5328                                                    break;
5329                                                case OPS.constructPath:
5330                                                    this.constructPath(args[0], args[1]);
5331                                                    break;
5332                                                case OPS.endPath:
5333                                                    this.endPath();
5334                                                    break;
5335                                                case 92:
5336                                                    this.group(opTree[x].items);
5337                                                    break;
5338                                                default:
5339                                                    warn('Unimplemented operator ' + fn);
5340                                                    break;
5341                                            }
5342                                        }
5343                                    },
5344                                    setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
5345                                        this.current.wordSpacing = wordSpacing;
5346                                    },
5347                                    setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
5348                                        this.current.charSpacing = charSpacing;
5349                                    },
5350                                    nextLine: function SVGGraphics_nextLine() {
5351                                        this.moveText(0, this.current.leading);
5352                                    },
5353                                    setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
5354                                        var current = this.current;
5355                                        this.current.textMatrix = this.current.lineMatrix = [
5356                                            a,
5357                                            b,
5358                                            c,
5359                                            d,
5360                                            e,
5361                                            f
5362                                        ];
5363                                        this.current.x = this.current.lineX = 0;
5364                                        this.current.y = this.current.lineY = 0;
5365                                        current.xcoords = [];
5366                                        current.tspan = document.createElementNS(NS, 'svg:tspan');
5367                                        current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
5368                                        current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
5369                                        current.tspan.setAttributeNS(null, 'y', pf(-current.y));
5370                                        current.txtElement = document.createElementNS(NS, 'svg:text');
5371                                        current.txtElement.appendChild(current.tspan);
5372                                    },
5373                                    beginText: function SVGGraphics_beginText() {
5374                                        this.current.x = this.current.lineX = 0;
5375                                        this.current.y = this.current.lineY = 0;
5376                                        this.current.textMatrix = IDENTITY_MATRIX;
5377                                        this.current.lineMatrix = IDENTITY_MATRIX;
5378                                        this.current.tspan = document.createElementNS(NS, 'svg:tspan');
5379                                        this.current.txtElement = document.createElementNS(NS, 'svg:text');
5380                                        this.current.txtgrp = document.createElementNS(NS, 'svg:g');
5381                                        this.current.xcoords = [];
5382                                    },
5383                                    moveText: function SVGGraphics_moveText(x, y) {
5384                                        var current = this.current;
5385                                        this.current.x = this.current.lineX += x;
5386                                        this.current.y = this.current.lineY += y;
5387                                        current.xcoords = [];
5388                                        current.tspan = document.createElementNS(NS, 'svg:tspan');
5389                                        current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
5390                                        current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
5391                                        current.tspan.setAttributeNS(null, 'y', pf(-current.y));
5392                                    },
5393                                    showText: function SVGGraphics_showText(glyphs) {
5394                                        var current = this.current;
5395                                        var font = current.font;
5396                                        var fontSize = current.fontSize;
5397                                        if (fontSize === 0) {
5398                                            return;
5399                                        }
5400                                        var charSpacing = current.charSpacing;
5401                                        var wordSpacing = current.wordSpacing;
5402                                        var fontDirection = current.fontDirection;
5403                                        var textHScale = current.textHScale * fontDirection;
5404                                        var glyphsLength = glyphs.length;
5405                                        var vertical = font.vertical;
5406                                        var widthAdvanceScale = fontSize * current.fontMatrix[0];
5407                                        var x = 0, i;
5408                                        for (i = 0; i < glyphsLength; ++i) {
5409                                            var glyph = glyphs[i];
5410                                            if (glyph === null) {
5411                                                x += fontDirection * wordSpacing;
5412                                                continue;
5413                                            } else if (isNum(glyph)) {
5414                                                x += -glyph * fontSize * 0.001;
5415                                                continue;
5416                                            }
5417                                            current.xcoords.push(current.x + x * textHScale);
5418                                            var width = glyph.width;
5419                                            var character = glyph.fontChar;
5420                                            var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
5421                                            x += charWidth;
5422                                            current.tspan.textContent += character;
5423                                        }
5424                                        if (vertical) {
5425                                            current.y -= x * textHScale;
5426                                        } else {
5427                                            current.x += x * textHScale;
5428                                        }
5429                                        current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
5430                                        current.tspan.setAttributeNS(null, 'y', pf(-current.y));
5431                                        current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
5432                                        current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
5433                                        if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
5434                                            current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
5435                                        }
5436                                        if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
5437                                            current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
5438                                        }
5439                                        if (current.fillColor !== SVG_DEFAULTS.fillColor) {
5440                                            current.tspan.setAttributeNS(null, 'fill', current.fillColor);
5441                                        }
5442                                        current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
5443                                        current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
5444                                        current.txtElement.appendChild(current.tspan);
5445                                        current.txtgrp.appendChild(current.txtElement);
5446                                        this._ensureTransformGroup().appendChild(current.txtElement);
5447                                    },
5448                                    setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
5449                                        this.setLeading(-y);
5450                                        this.moveText(x, y);
5451                                    },
5452                                    addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
5453                                        if (!this.cssStyle) {
5454                                            this.cssStyle = document.createElementNS(NS, 'svg:style');
5455                                            this.cssStyle.setAttributeNS(null, 'type', 'text/css');
5456                                            this.defs.appendChild(this.cssStyle);
5457                                        }
5458                                        var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
5459                                        this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
5460                                    },
5461                                    setFont: function SVGGraphics_setFont(details) {
5462                                        var current = this.current;
5463                                        var fontObj = this.commonObjs.get(details[0]);
5464                                        var size = details[1];
5465                                        this.current.font = fontObj;
5466                                        if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
5467                                            this.addFontStyle(fontObj);
5468                                            this.embeddedFonts[fontObj.loadedName] = fontObj;
5469                                        }
5470                                        current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
5471                                        var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
5472                                        var italic = fontObj.italic ? 'italic' : 'normal';
5473                                        if (size < 0) {
5474                                            size = -size;
5475                                            current.fontDirection = -1;
5476                                        } else {
5477                                            current.fontDirection = 1;
5478                                        }
5479                                        current.fontSize = size;
5480                                        current.fontFamily = fontObj.loadedName;
5481                                        current.fontWeight = bold;
5482                                        current.fontStyle = italic;
5483                                        current.tspan = document.createElementNS(NS, 'svg:tspan');
5484                                        current.tspan.setAttributeNS(null, 'y', pf(-current.y));
5485                                        current.xcoords = [];
5486                                    },
5487                                    endText: function SVGGraphics_endText() {
5488                                    },
5489                                    setLineWidth: function SVGGraphics_setLineWidth(width) {
5490                                        this.current.lineWidth = width;
5491                                    },
5492                                    setLineCap: function SVGGraphics_setLineCap(style) {
5493                                        this.current.lineCap = LINE_CAP_STYLES[style];
5494                                    },
5495                                    setLineJoin: function SVGGraphics_setLineJoin(style) {
5496                                        this.current.lineJoin = LINE_JOIN_STYLES[style];
5497                                    },
5498                                    setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
5499                                        this.current.miterLimit = limit;
5500                                    },
5501                                    setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
5502                                        var color = Util.makeCssRgb(r, g, b);
5503                                        this.current.strokeColor = color;
5504                                    },
5505                                    setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
5506                                        var color = Util.makeCssRgb(r, g, b);
5507                                        this.current.fillColor = color;
5508                                        this.current.tspan = document.createElementNS(NS, 'svg:tspan');
5509                                        this.current.xcoords = [];
5510                                    },
5511                                    setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
5512                                        this.current.dashArray = dashArray;
5513                                        this.current.dashPhase = dashPhase;
5514                                    },
5515                                    constructPath: function SVGGraphics_constructPath(ops, args) {
5516                                        var current = this.current;
5517                                        var x = current.x, y = current.y;
5518                                        current.path = document.createElementNS(NS, 'svg:path');
5519                                        var d = [];
5520                                        var opLength = ops.length;
5521                                        for (var i = 0, j = 0; i < opLength; i++) {
5522                                            switch (ops[i] | 0) {
5523                                                case OPS.rectangle:
5524                                                    x = args[j++];
5525                                                    y = args[j++];
5526                                                    var width = args[j++];
5527                                                    var height = args[j++];
5528                                                    var xw = x + width;
5529                                                    var yh = y + height;
5530                                                    d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
5531                                                    break;
5532                                                case OPS.moveTo:
5533                                                    x = args[j++];
5534                                                    y = args[j++];
5535                                                    d.push('M', pf(x), pf(y));
5536                                                    break;
5537                                                case OPS.lineTo:
5538                                                    x = args[j++];
5539                                                    y = args[j++];
5540                                                    d.push('L', pf(x), pf(y));
5541                                                    break;
5542                                                case OPS.curveTo:
5543                                                    x = args[j + 4];
5544                                                    y = args[j + 5];
5545                                                    d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
5546                                                    j += 6;
5547                                                    break;
5548                                                case OPS.curveTo2:
5549                                                    x = args[j + 2];
5550                                                    y = args[j + 3];
5551                                                    d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
5552                                                    j += 4;
5553                                                    break;
5554                                                case OPS.curveTo3:
5555                                                    x = args[j + 2];
5556                                                    y = args[j + 3];
5557                                                    d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
5558                                                    j += 4;
5559                                                    break;
5560                                                case OPS.closePath:
5561                                                    d.push('Z');
5562                                                    break;
5563                                            }
5564                                        }
5565                                        current.path.setAttributeNS(null, 'd', d.join(' '));
5566                                        current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
5567                                        current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
5568                                        current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
5569                                        current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
5570                                        current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
5571                                        current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
5572                                        current.path.setAttributeNS(null, 'fill', 'none');
5573                                        this._ensureTransformGroup().appendChild(current.path);
5574                                        current.element = current.path;
5575                                        current.setCurrentPoint(x, y);
5576                                    },
5577                                    endPath: function SVGGraphics_endPath() {
5578                                    },
5579                                    clip: function SVGGraphics_clip(type) {
5580                                        var current = this.current;
5581                                        var clipId = 'clippath' + clipCount;
5582                                        clipCount++;
5583                                        var clipPath = document.createElementNS(NS, 'svg:clipPath');
5584                                        clipPath.setAttributeNS(null, 'id', clipId);
5585                                        clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
5586                                        var clipElement = current.element.cloneNode();
5587                                        if (type === 'evenodd') {
5588                                            clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
5589                                        } else {
5590                                            clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
5591                                        }
5592                                        clipPath.appendChild(clipElement);
5593                                        this.defs.appendChild(clipPath);
5594                                        if (current.activeClipUrl) {
5595                                            current.clipGroup = null;
5596                                            this.extraStack.forEach(function (prev) {
5597                                                prev.clipGroup = null;
5598                                            });
5599                                        }
5600                                        current.activeClipUrl = 'url(#' + clipId + ')';
5601                                        this.tgrp = null;
5602                                    },
5603                                    closePath: function SVGGraphics_closePath() {
5604                                        var current = this.current;
5605                                        var d = current.path.getAttributeNS(null, 'd');
5606                                        d += 'Z';
5607                                        current.path.setAttributeNS(null, 'd', d);
5608                                    },
5609                                    setLeading: function SVGGraphics_setLeading(leading) {
5610                                        this.current.leading = -leading;
5611                                    },
5612                                    setTextRise: function SVGGraphics_setTextRise(textRise) {
5613                                        this.current.textRise = textRise;
5614                                    },
5615                                    setHScale: function SVGGraphics_setHScale(scale) {
5616                                        this.current.textHScale = scale / 100;
5617                                    },
5618                                    setGState: function SVGGraphics_setGState(states) {
5619                                        for (var i = 0, ii = states.length; i < ii; i++) {
5620                                            var state = states[i];
5621                                            var key = state[0];
5622                                            var value = state[1];
5623                                            switch (key) {
5624                                                case 'LW':
5625                                                    this.setLineWidth(value);
5626                                                    break;
5627                                                case 'LC':
5628                                                    this.setLineCap(value);
5629                                                    break;
5630                                                case 'LJ':
5631                                                    this.setLineJoin(value);
5632                                                    break;
5633                                                case 'ML':
5634                                                    this.setMiterLimit(value);
5635                                                    break;
5636                                                case 'D':
5637                                                    this.setDash(value[0], value[1]);
5638                                                    break;
5639                                                case 'Font':
5640                                                    this.setFont(value);
5641                                                    break;
5642                                                default:
5643                                                    warn('Unimplemented graphic state ' + key);
5644                                                    break;
5645                                            }
5646                                        }
5647                                    },
5648                                    fill: function SVGGraphics_fill() {
5649                                        var current = this.current;
5650                                        current.element.setAttributeNS(null, 'fill', current.fillColor);
5651                                    },
5652                                    stroke: function SVGGraphics_stroke() {
5653                                        var current = this.current;
5654                                        current.element.setAttributeNS(null, 'stroke', current.strokeColor);
5655                                        current.element.setAttributeNS(null, 'fill', 'none');
5656                                    },
5657                                    eoFill: function SVGGraphics_eoFill() {
5658                                        var current = this.current;
5659                                        current.element.setAttributeNS(null, 'fill', current.fillColor);
5660                                        current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
5661                                    },
5662                                    fillStroke: function SVGGraphics_fillStroke() {
5663                                        this.stroke();
5664                                        this.fill();
5665                                    },
5666                                    eoFillStroke: function SVGGraphics_eoFillStroke() {
5667                                        this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
5668                                        this.fillStroke();
5669                                    },
5670                                    closeStroke: function SVGGraphics_closeStroke() {
5671                                        this.closePath();
5672                                        this.stroke();
5673                                    },
5674                                    closeFillStroke: function SVGGraphics_closeFillStroke() {
5675                                        this.closePath();
5676                                        this.fillStroke();
5677                                    },
5678                                    paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
5679                                        var current = this.current;
5680                                        var rect = document.createElementNS(NS, 'svg:rect');
5681                                        rect.setAttributeNS(null, 'x', '0');
5682                                        rect.setAttributeNS(null, 'y', '0');
5683                                        rect.setAttributeNS(null, 'width', '1px');
5684                                        rect.setAttributeNS(null, 'height', '1px');
5685                                        rect.setAttributeNS(null, 'fill', current.fillColor);
5686                                        this._ensureTransformGroup().appendChild(rect);
5687                                    },
5688                                    paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
5689                                        var imgObj = this.objs.get(objId);
5690                                        var imgEl = document.createElementNS(NS, 'svg:image');
5691                                        imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
5692                                        imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
5693                                        imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
5694                                        imgEl.setAttributeNS(null, 'x', '0');
5695                                        imgEl.setAttributeNS(null, 'y', pf(-h));
5696                                        imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
5697                                        this._ensureTransformGroup().appendChild(imgEl);
5698                                    },
5699                                    paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
5700                                        var imgData = this.objs.get(objId);
5701                                        if (!imgData) {
5702                                            warn('Dependent image isn\'t ready yet');
5703                                            return;
5704                                        }
5705                                        this.paintInlineImageXObject(imgData);
5706                                    },
5707                                    paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
5708                                        var width = imgData.width;
5709                                        var height = imgData.height;
5710                                        var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
5711                                        var cliprect = document.createElementNS(NS, 'svg:rect');
5712                                        cliprect.setAttributeNS(null, 'x', '0');
5713                                        cliprect.setAttributeNS(null, 'y', '0');
5714                                        cliprect.setAttributeNS(null, 'width', pf(width));
5715                                        cliprect.setAttributeNS(null, 'height', pf(height));
5716                                        this.current.element = cliprect;
5717                                        this.clip('nonzero');
5718                                        var imgEl = document.createElementNS(NS, 'svg:image');
5719                                        imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
5720                                        imgEl.setAttributeNS(null, 'x', '0');
5721                                        imgEl.setAttributeNS(null, 'y', pf(-height));
5722                                        imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
5723                                        imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
5724                                        imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
5725                                        if (mask) {
5726                                            mask.appendChild(imgEl);
5727                                        } else {
5728                                            this._ensureTransformGroup().appendChild(imgEl);
5729                                        }
5730                                    },
5731                                    paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
5732                                        var current = this.current;
5733                                        var width = imgData.width;
5734                                        var height = imgData.height;
5735                                        var fillColor = current.fillColor;
5736                                        current.maskId = 'mask' + maskCount++;
5737                                        var mask = document.createElementNS(NS, 'svg:mask');
5738                                        mask.setAttributeNS(null, 'id', current.maskId);
5739                                        var rect = document.createElementNS(NS, 'svg:rect');
5740                                        rect.setAttributeNS(null, 'x', '0');
5741                                        rect.setAttributeNS(null, 'y', '0');
5742                                        rect.setAttributeNS(null, 'width', pf(width));
5743                                        rect.setAttributeNS(null, 'height', pf(height));
5744                                        rect.setAttributeNS(null, 'fill', fillColor);
5745                                        rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
5746                                        this.defs.appendChild(mask);
5747                                        this._ensureTransformGroup().appendChild(rect);
5748                                        this.paintInlineImageXObject(imgData, mask);
5749                                    },
5750                                    paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
5751                                        if (isArray(matrix) && matrix.length === 6) {
5752                                            this.transform(matrix[0], matrix[
57521], matrix[2], matrix[3], matrix[4], matrix[5]);
5753                                        }
5754                                        if (isArray(bbox) && bbox.length === 4) {
5755                                            var width = bbox[2] - bbox[0];
5756                                            var height = bbox[3] - bbox[1];
5757                                            var cliprect = document.createElementNS(NS, 'svg:rect');
5758                                            cliprect.setAttributeNS(null, 'x', bbox[0]);
5759                                            cliprect.setAttributeNS(null, 'y', bbox[1]);
5760                                            cliprect.setAttributeNS(null, 'width', pf(width));
5761                                            cliprect.setAttributeNS(null, 'height', pf(height));
5762                                            this.current.element = cliprect;
5763                                            this.clip('nonzero');
5764                                            this.endPath();
5765                                        }
5766                                    },
5767                                    paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
5768                                    },
5769                                    _initialize: function SVGGraphics_initialize(viewport) {
5770                                        var svg = document.createElementNS(NS, 'svg:svg');
5771                                        svg.setAttributeNS(null, 'version', '1.1');
5772                                        svg.setAttributeNS(null, 'width', viewport.width + 'px');
5773                                        svg.setAttributeNS(null, 'height', viewport.height + 'px');
5774                                        svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
5775                                        svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
5776                                        var definitions = document.createElementNS(NS, 'svg:defs');
5777                                        svg.appendChild(definitions);
5778                                        this.defs = definitions;
5779                                        var rootGroup = document.createElementNS(NS, 'svg:g');
5780                                        rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
5781                                        svg.appendChild(rootGroup);
5782                                        this.svg = rootGroup;
5783                                        return svg;
5784                                    },
5785                                    _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
5786                                        if (!this.current.clipGroup) {
5787                                            var clipGroup = document.createElementNS(NS, 'svg:g');
5788                                            clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
5789                                            this.svg.appendChild(clipGroup);
5790                                            this.current.clipGroup = clipGroup;
5791                                        }
5792                                        return this.current.clipGroup;
5793                                    },
5794                                    _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
5795                                        if (!this.tgrp) {
5796                                            this.tgrp = document.createElementNS(NS, 'svg:g');
5797                                            this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
5798                                            if (this.current.activeClipUrl) {
5799                                                this._ensureClipGroup().appendChild(this.tgrp);
5800                                            } else {
5801                                                this.svg.appendChild(this.tgrp);
5802                                            }
5803                                        }
5804                                        return this.tgrp;
5805                                    }
5806                                };
5807                                return SVGGraphics;
5808                            }();
5809                            exports.SVGGraphics = SVGGraphics;
5810
5811                            /***/ }),
5812                        /* 5 */
5813                        /***/ (function (module, exports, __w_pdfjs_require__) {
5814
5815                            "use strict";
5816
5817                            var sharedUtil = __w_pdfjs_require__(0);
5818                            var displayDOMUtils = __w_pdfjs_require__(1);
5819                            var Util = sharedUtil.Util;
5820                            var createPromiseCapability = sharedUtil.createPromiseCapability;
5821                            var CustomStyle = displayDOMUtils.CustomStyle;
5822                            var getDefaultSetting = displayDOMUtils.getDefaultSetting;
5823                            var renderTextLayer = function renderTextLayerClosure() {
5824                                var MAX_TEXT_DIVS_TO_RENDER = 100000;
5825                                var NonWhitespaceRegexp = /\S/;
5826                                function isAllWhitespace(str) {
5827                                    return !NonWhitespaceRegexp.test(str);
5828                                }
5829                                var styleBuf = [
5830                                    'left: ',
5831                                    0,
5832                                    'px; top: ',
5833                                    0,
5834                                    'px; font-size: ',
5835                                    0,
5836                                    'px; font-family: ',
5837                                    '',
5838                                    ';'
5839                                ];
5840                                function appendText(task, geom, styles) {
5841                                    var textDiv = document.createElement('div');
5842                                    var textDivProperties = {
5843                                        style: null,
5844                                        angle: 0,
5845                                        canvasWidth: 0,
5846                                        isWhitespace: false,
5847                                        originalTransform: null,
5848                                        paddingBottom: 0,
5849                                        paddingLeft: 0,
5850                                        paddingRight: 0,
5851                                        paddingTop: 0,
5852                                        scale: 1
5853                                    };
5854                                    task._textDivs.push(textDiv);
5855                                    if (isAllWhitespace(geom.str)) {
5856                                        textDivProperties.isWhitespace = true;
5857                                        task._textDivProperties.set(textDiv, textDivProperties);
5858                                        return;
5859                                    }
5860                                    var tx = Util.transform(task._viewport.transform, geom.transform);
5861                                    var angle = Math.atan2(tx[1], tx[0]);
5862                                    var style = styles[geom.fontName];
5863                                    if (style.vertical) {
5864                                        angle += Math.PI / 2;
5865                                    }
5866                                    var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
5867                                    var fontAscent = fontHeight;
5868                                    if (style.ascent) {
5869                                        fontAscent = style.ascent * fontAscent;
5870                                    }
5870 else if (style.descent) {
5871                                        fontAscent = (1 + style.descent) * fontAscent;
5872                                    }
5873                                    var left;
5874                                    var top;
5875                                    if (angle === 0) {
5876                                        left = tx[4];
5877                                        top = tx[5] - fontAscent;
5878                                    } else {
5879                                        left = tx[4] + fontAscent * Math.sin(angle);
5880                                        top = tx[5] - fontAscent * Math.cos(angle);
5881                                    }
5882                                    styleBuf[1] = left;
5883                                    styleBuf[3] = top;
5884                                    styleBuf[5] = fontHeight;
5885                                    styleBuf[7] = style.fontFamily;
5886                                    textDivProperties.style = styleBuf.join('');
5887                                    textDiv.setAttribute('style', textDivProperties.style);
5888                                    textDiv.textContent = geom.str;
5889                                    if (getDefaultSetting('pdfBug')) {
5890                                        textDiv.dataset.fontName = geom.fontName;
5891                                    }
5892                                    if (angle !== 0) {
5893                                        textDivProperties.angle = angle * (180 / Math.PI);
5894                                    }
5895                                    if (geom.str.length > 1) {
5896                                        if (style.vertical) {
5897                                            textDivProperties.canvasWidth = geom.height * task._viewport.scale;
5898                                        } else {
5899                                            textDivProperties.canvasWidth = geom.width * task._viewport.scale;
5900                                        }
5901                                    }
5902                                    task._textDivProperties.set(textDiv, textDivProperties);
5903                                    if (task._enhanceTextSelection) {
5904                                        var angleCos = 1, angleSin = 0;
5905                                        if (angle !== 0) {
5906                                            angleCos = Math.cos(angle);
5907                                            angleSin = Math.sin(angle);
5908                                        }
5909                                        var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
5910                                        var divHeight = fontHeight;
5911                                        var m, b;
5912                                        if (angle !== 0) {
5913                                            m = [
5914                                                angleCos,
5915                                                angleSin,
5916                                                -angleSin,
5917                                                angleCos,
5918                                                left,
5919                                                top
5920                                            ];
5921                                            b = Util.getAxialAlignedBoundingBox([
5922                                                0,
5923                                                0,
5924                                                divWidth,
5925                                                divHeight
5926                                            ], m);
5927                                        } else {
5928                                            b = [
5929                                                left,
5930                                                top,
5931                                                left + divWidth,
5932                                                top + divHeight
5933                                            ];
5934                                        }
5935                                        task._bounds.push({
5936                                            left: b[0],
5937                                            top: b[1],
5938                                            right: b[2],
5939                                            bottom: b[3],
5940                                            div: textDiv,
5941                                            size: [
5942                                                divWidth,
5943                                                divHeight
5944                                            ],
5945                                            m: m
5946                                        });
5947                                    }
5948                                }
5949                                function render(task) {
5950                                    if (task._canceled) {
5951                                        return;
5952                                    }
5953                                    var textLayerFrag = task._container;
5954                                    var textDivs = task._textDivs;
5955                                    var capability = task._capability;
5956                                    var textDivsLength = textDivs.length;
5957                                    if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
5958                                        task._renderingDone = true;
5959                                        capability.resolve();
5960                                        return;
5961                                    }
5962                                    var canvas = document.createElement('canvas');
5963                                    canvas.mozOpaque = true;
5964                                    var ctx = canvas.getContext('2d', {alpha: false});
5965                                    var lastFontSize;
5966                                    var lastFontFamily;
5967                                    for (var i = 0; i < textDivsLength; i++) {
5968                                        var textDiv = textDivs[i];
5969                                        var textDivProperties = task._textDivProperties.get(textDiv);
5970                                        if (textDivProperties.isWhitespace) {
5971                                            continue;
5972                                        }
5973                                        var fontSize = textDiv.style.fontSize;
5974                                        var fontFamily = textDiv.style.fontFamily;
5975                                        if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
5976                                            ctx.font = fontSize + ' ' + fontFamily;
5977                                            lastFontSize = fontSize;
5978                                            lastFontFamily = fontFamily;
5979                                        }
5980                                        var width = ctx.measureText(textDiv.textContent).width;
5981                                        textLayerFrag.appendChild(textDiv);
5982                                        var transform = '';
5983                                        if (textDivProperties.canvasWidth !== 0 && width > 0) {
5984                                            textDivProperties.scale = textDivProperties.canvasWidth / width;
5985                                            transform = 'scaleX(' + textDivProperties.scale + ')';
5986                                        }
5987                                        if (textDivProperties.angle !== 0) {
5988                                            transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
5989                                        }
5990                                        if (transform !== '') {
5991                                            textDivProperties.originalTransform = transform;
5992                                            CustomStyle.setProp('transform', textDiv, transform);
5993                                        }
5994                                        task._textDivProperties.set(textDiv, textDivProperties);
5995                                    }
5996                                    task._renderingDone = true;
5997                                    capability.resolve();
5998                                }
5999                                function expand(task) {
6000                                    var bounds = task._bounds;
6001                                    var viewport = task._viewport;
6002                                    var expanded = expandBounds(viewport.width, viewport.height, bounds);
6003                                    for (var i = 0; i < expanded.length; i++) {
6004                                        var div = bounds[i].div;
6005                                        var divProperties = task._textDivProperties.get(div);
6006                                        if (divProperties.angle === 0) {
6007                                            divProperties.paddingLeft = bounds[i].left - expanded[i].left;
6008                                            divProperties.paddingTop = bounds[i].top - expanded[i].top;
6009                                            divProperties.paddingRight = expanded[i].right - bounds[i].right;
6010                                            divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
6011                                            task._textDivProperties.set(div, divProperties);
6012                                            continue;
6013                                        }
6014                                        var e = expanded[i], b = bounds[i];
6015                                        var m = b.m, c = m[0], s = m[1];
6016                                        var points = [
6017                                            [
6018                                                0,
6019                                                0
6020                                            ],
6021                                            [
6022                                                0,
6023                                                b.size[1]
6024                                            ],
6025                                            [
6026                                                b.size[0],
6027                                                0
6028                                            ],
6029                                            b.size
6030                                        ];
6031                                        var ts = new Float64Array(64);
vendor: 12,030 bytes, lines 6032-6208
6032                                        points.forEach(function (p, i) {
6033                                            var t = Util.applyTransform(p, m);
6034                                            ts[i + 0] = c && (e.left - t[0]) / c;
6035                                            ts[i + 4] = s && (e.top - t[1]) / s;
6036                                            ts[i + 8] = c && (e.right - t[0]) / c;
6037                                            ts[i + 12] = s && (e.bottom - t[1]) / s;
6038                                            ts[i + 16] = s && (e.left - t[0]) / -s;
6039                                            ts[i + 20] = c && (e.top - t[1]) / c;
6040                                            ts[i + 24] = s && (e.right - t[0]) / -s;
6041                                            ts[i + 28] = c && (e.bottom - t[1]) / c;
6042                                            ts[i + 32] = c && (e.left - t[0]) / -c;
6043                                            ts[i + 36] = s && (e.top - t[1]) / -s;
6044                                            ts[i + 40] = c && (e.right - t[0]) / -c;
6045                                            ts[i + 44] = s && (e.bottom - t[1]) / -s;
6046                                            ts[i + 48] = s && (e.left - t[0]) / s;
6047                                            ts[i + 52] = c && (e.top - t[1]) / -c;
6048                                            ts[i + 56] = s && (e.right - t[0]) / s;
6049                                            ts[i + 60] = c && (e.bottom - t[1]) / -c;
6050                                        });
6051                                        var findPositiveMin = function (ts, offset, count) {
6052                                            var result = 0;
6053                                            for (var i = 0; i < count; i++) {
6054                                                var t = ts[offset++];
6055                                                if (t > 0) {
6056                                                    result = result ? Math.min(t, result) : t;
6057                                                }
6058                                            }
6059                                            return result;
6060                                        };
6061                                        var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
6062                                        divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
6063                                        divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
6064                                        divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
6065                                        divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
6066                                        task._textDivProperties.set(div, divProperties);
6067                                    }
6068                                }
6069                                function expandBounds(width, height, boxes) {
6070                                    var bounds = boxes.map(function (box, i) {
6071                                        return {
6072                                            x1: box.left,
6073                                            y1: box.top,
6074                                            x2: box.right,
6075                                            y2: box.bottom,
6076                                            index: i,
6077                                            x1New: undefined,
6078                                            x2New: undefined
6079                                        };
6080                                    });
6081                                    expandBoundsLTR(width, bounds);
6082                                    var expanded = new Array(boxes.length);
6083                                    bounds.forEach(function (b) {
6084                                        var i = b.index;
6085                                        expanded[i] = {
6086                                            left: b.x1New,
6087                                            top: 0,
6088                                            right: b.x2New,
6089                                            bottom: 0
6090                                        };
6091                                    });
6092                                    boxes.map(function (box, i) {
6093                                        var e = expanded[i], b = bounds[i];
6094                                        b.x1 = box.top;
6095                                        b.y1 = width - e.right;
6096                                        b.x2 = box.bottom;
6097                                        b.y2 = width - e.left;
6098                                        b.index = i;
6099                                        b.x1New = undefined;
6100                                        b.x2New = undefined;
6101                                    });
6102                                    expandBoundsLTR(height, bounds);
6103                                    bounds.forEach(function (b) {
6104                                        var i = b.index;
6105                                        expanded[i].top = b.x1New;
6106                                        expanded[i].bottom = b.x2New;
6107                                    });
6108                                    return expanded;
6109                                }
6110                                function expandBoundsLTR(width, bounds) {
6111                                    bounds.sort(function (a, b) {
6112                                        return a.x1 - b.x1 || a.index - b.index;
6113                                    });
6114                                    var fakeBoundary = {
6115                                        x1: -Infinity,
6116                                        y1: -Infinity,
6117                                        x2: 0,
6118                                        y2: Infinity,
6119                                        index: -1,
6120                                        x1New: 0,
6121                                        x2New: 0
6122                                    };
6123                                    var horizon = [{
6124                                            start: -Infinity,
6125                                            end: Infinity,
6126                                            boundary: fakeBoundary
6127                                        }];
6128                                    bounds.forEach(function (boundary) {
6129                                        var i = 0;
6130                                        while (i < horizon.length && horizon[i].end <= boundary.y1) {
6131                                            i++;
6132                                        }
6133                                        var j = horizon.length - 1;
6134                                        while (j >= 0 && horizon[j].start >= boundary.y2) {
6135                                            j--;
6136                                        }
6137                                        var horizonPart, affectedBoundary;
6138                                        var q, k, maxXNew = -Infinity;
6139                                        for (q = i; q <= j; q++) {
6140                                            horizonPart = horizon[q];
6141                                            affectedBoundary = horizonPart.boundary;
6142                                            var xNew;
6143                                            if (affectedBoundary.x2 > boundary.x1) {
6144                                                xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
6145                                            } else if (affectedBoundary.x2New === undefined) {
6146                                                xNew = (affectedBoundary.x2 + boundary.x1) / 2;
6147                                            } else {
6148                                                xNew = affectedBoundary.x2New;
6149                                            }
6150                                            if (xNew > maxXNew) {
6151                                                maxXNew = xNew;
6152                                            }
6153                                        }
6154                                        boundary.x1New = maxXNew;
6155                                        for (q = i; q <= j; q++) {
6156                                            horizonPart = horizon[q];
6157                                            affectedBoundary = horizonPart.boundary;
6158                                            if (affectedBoundary.x2New === undefined) {
6159                                                if (affectedBoundary.x2 > boundary.x1) {
6160                                                    if (affectedBoundary.index > boundary.index) {
6161                                                        affectedBoundary.x2New = affectedBoundary.x2;
6162                                                    }
6163                                                } else {
6164                                                    affectedBoundary.x2New = maxXNew;
6165                                                }
6166                                            } else if (affectedBoundary.x2New > maxXNew) {
6167                                                affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
6168                                            }
6169                                        }
6170                                        var changedHorizon = [], lastBoundary = null;
6171                                        for (q = i; q <= j; q++) {
6172                                            horizonPart = horizon[q];
6173                                            affectedBoundary = horizonPart.boundary;
6174                                            var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
6175                                            if (lastBoundary === useBoundary) {
6176                                                changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
6177                                            } else {
6178                                                changedHorizon.push({
6179                                                    start: horizonPart.start,
6180                                                    end: horizonPart.end,
6181                                                    boundary: useBoundary
6182                                                });
6183                                                lastBoundary = useBoundary;
6184                                            }
6185                                        }
6186                                        if (horizon[i].start < boundary.y1) {
6187                                            changedHorizon[0].start = boundary.y1;
6188                                            changedHorizon.unshift({
6189                                                start: horizon[i].start,
6190                                                end: boundary.y1,
6191                                                boundary: horizon[i].boundary
6192                                            });
6193                                        }
6194                                        if (boundary.y2 < horizon[j].end) {
6195                                            changedHorizon[changedHorizon.length - 1].end = boundary.y2;
6196                                            changedHorizon.push({
6197                                                start: boundary.y2,
6198                                                end: horizon[j].end,
6199                                                boundary: horizon[j].boundary
6200                                            });
6201                                        }
6202                                        for (q = i; q <= j; q++) {
6203                                            horizonPart = horizon[q];
6204                                            affectedBoundary = horizonPart.boundary;
6205                                            if (affectedBoundary.x2New !== undefined) {
6206                                                continue;
6207                                            }
6208                                            var used = false;
6209                                            for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
6210                                                used = horizon[k].boundary === affectedBoundary;
6211                                            }
6212                                            for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
6213                                                used = horizon[k].boundary === affectedBoundary;
6214                                            }
6215                                            for (k = 0; !used && k < changedHorizon.length; k++) {
6216                                                used = changedHorizon[k].boundary === affectedBoundary;
6217                                            }
6218                                            if (!used) {
6219                                                affectedBoundary.x2New = maxXNew;
6220                                            }
6221                                        }
6222                                        Array.prototype.splice.apply(horizon, [
6223                                            i,
6224                                            j - i + 1
6225                                        ].concat(changedHorizon));
6226                                    });
6227                                    horizon.forEach(function (horizonPart) {
6228                                        var affectedBoundary = horizonPart.boundary;
6229                                        if (affectedBoundary.x2New === undefined) {
6230                                            affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
6231                                        }
6232                                    });
6233                                }
6234                                function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
6235                                    this._textContent = textContent;
6236                                    this._container = container;
6237                                    this._viewport = viewport;
6238                                    this._textDivs = textDivs || [];
6239                                    this._textDivProperties = new WeakMap();
6240                                    this._renderingDone = false;
6241                                    this._canceled = false;
6242                                    this._capability = createPromiseCapability();
6243                                    this._renderTimer = null;
6244                                    this._bounds = [];
6245                                    this._enhanceTextSelection = !!enhanceTextSelection;
6246                                }
6247                                TextLayerRenderTask.prototype = {
6248                                    get promise() {
6249                                        return this._capability.promise;
6250                                    },
6251                                    cancel: function TextLayer_cancel() {
6252                                        this._canceled = true;
6253                                        if (this._renderTimer !== null) {
6254                                            clearTimeout(this._renderTimer);
6255                                            this._renderTimer = null;
6256                                        }
6257                                        this._capability.reject('canceled');
6258                                    },
6259                                    _render: function TextLayer_render(timeout) {
6260                                        var textItems = this._textContent.items;
6261                                        var textStyles = this._textContent.styles;
6262                                        for (var i = 0, len = textItems.length; i < len; i++) {
6263                                            appendText(this, textItems[i], textStyles);
6264                                        }
6265                                        if (!timeout) {
6266                                            render(this);
6267                                        } else {
6268                                            var self = this;
6269                                            this._renderTimer = setTimeout(function () {
6270                                                render(self);
6271                                                self._renderTimer = null;
6272                                            }, timeout);
6273                                        }
6274                                    },
6275                                    expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
6276                                        if (!this._enhanceTextSelection || !this._renderingDone) {
6277                                            return;
6278                                        }
6279                                        if (this._bounds !== null) {
6280                                            expand(this);
6281                                            this._bounds = null;
6282                                        }
6283                                        for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
6284                                            var div = this._textDivs[i];
6285                                            var divProperties = this._textDivProperties.get(div);
6286                                            if (divProperties.isWhitespace) {
6287                                                continue;
6288                                            }
6289                                            if (expandDivs) {
6290                                                var transform = '', padding = '';
6291                                                if (divProperties.scale !== 1) {
6292                                                    transform = 'scaleX(' + divProperties.scale + ')';
6293                                                }
6294                                                if (divProperties.angle !== 0) {
6295                                                    transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
6296                                                }
6297                                                if (divProperties.paddingLeft !== 0) {
6298                                                    padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
6299                                                    transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
6300                                                }
6301                                                if (divProperties.paddingTop !== 0) {
6302                                                    padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
6303                                                    transform += ' translateY(' + -divProperties.paddingTop + 'px)';
6304                                                }
6305                                                if (divProperties.paddingRight !== 0) {
6306                                                    padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
6307                                                }
6308                                                if (divProperties.paddingBottom !== 0) {
6309                                                    padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
6310                                                }
6311                                                if (padding !== '') {
6312                                                    div.setAttribute('style', divProperties.style + padding);
6313                                                }
6314                                                if (transform !== '') {
6315                                                    CustomStyle.setProp('transform', div, transform);
6316                                                }
6317                                            } else {
6318                                                div.style.padding = 0;
6319                                                CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
6320                                            }
6321                                        }
6322                                    }
6323                                };
6324                                function renderTextLayer(renderParameters) {
6325                                    var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
6326                                    task._render(renderParameters.timeout);
6327                                    return task;
6328                                }
6329                                return renderTextLayer;
6330                            }();
6331                            exports.renderTextLayer = renderTextLayer;
6332
6333                            /***/ }),
6334                        /* 6 */
vendor: 20,198 bytes, lines 6335-6649
6335                        /***/ (function (module, exports) {
6336
6337                            var g;
6338                            g = function () {
6339                                return this;
6340                            }();
6341                            try {
6342                                g = g || Function("return this")() || (1, eval)("this");
6343                            } catch (e) {
6344                                if (typeof window === "object")
6345                                    g = window;
6346                            }
6347                            module.exports = g;
6348
6349                            /***/ }),
6350                        /* 7 */
6351                        /***/ (function (module, exports, __w_pdfjs_require__) {
6352
6353                            "use strict";
6354
6355                            var sharedUtil = __w_pdfjs_require__(0);
6356                            var error = sharedUtil.error;
6357                            function fixMetadata(meta) {
6358                                return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
6359                                    var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
6360                                        return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
6361                                    });
6362                                    var chars = '';
6363                                    for (var i = 0; i < bytes.length; i += 2) {
6364                                        var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
6365                                        chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
6366                                    }
6367                                    return '>' + chars;
6368                                });
6369                            }
6370                            function Metadata(meta) {
6371                                if (typeof meta === 'string') {
6372                                    meta = fixMetadata(meta);
6373                                    var parser = new DOMParser();
6374                                    meta = parser.parseFromString(meta, 'application/xml');
6375                                } else if (!(meta instanceof Document)) {
6376                                    error('Metadata: Invalid metadata object');
6377                                }
6378                                this.metaDocument = meta;
6379                                this.metadata = Object.create(null);
6380                                this.parse();
6381                            }
6382                            Metadata.prototype = {
6383                                parse: function Metadata_parse() {
6384                                    var doc = this.metaDocument;
6385                                    var rdf = doc.documentElement;
6386                                    if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
6387                                        rdf = rdf.firstChild;
6388                                        while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
6389                                            rdf = rdf.nextSibling;
6390                                        }
6391                                    }
6392                                    var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
6393                                    if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
6394                                        return;
6395                                    }
6396                                    var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
6397                                    for (i = 0, length = children.length; i < length; i++) {
6398                                        desc = children[i];
6399                                        if (desc.nodeName.toLowerCase() !== 'rdf:description') {
6400                                            continue;
6401                                        }
6402                                        for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
6403                                            if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
6404                                                entry = desc.childNodes[ii];
6405                                                name = entry.nodeName.toLowerCase();
6406                                                this.metadata[name] = entry.textContent.trim();
6407                                            }
6408                                        }
6409                                    }
6410                                },
6411                                get: function Metadata_get(name) {
6412                                    return this.metadata[name] || null;
6413                                },
6414                                has: function Metadata_has(name) {
6415                                    return typeof this.metadata[name] !== 'undefined';
6416                                }
6417                            };
6418                            exports.Metadata = Metadata;
6419
6420                            /***/ }),
6421                        /* 8 */
6422                        /***/ (function (module, exports, __w_pdfjs_require__) {
6423
6424                            "use strict";
6425
6426                            var sharedUtil = __w_pdfjs_require__(0);
6427                            var displayDOMUtils = __w_pdfjs_require__(1);
6428                            var shadow = sharedUtil.shadow;
6429                            var getDefaultSetting = displayDOMUtils.getDefaultSetting;
6430                            var WebGLUtils = function WebGLUtilsClosure() {
6431                                function loadShader(gl, code, shaderType) {
6432                                    var shader = gl.createShader(shaderType);
6433                                    gl.shaderSource(shader, code);
6434                                    gl.compileShader(shader);
6435                                    var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
6436                                    if (!compiled) {
6437                                        var errorMsg = gl.getShaderInfoLog(shader);
6438                                        throw new Error('Error during shader compilation: ' + errorMsg);
6439                                    }
6440                                    return shader;
6441                                }
6442                                function createVertexShader(gl, code) {
6443                                    return loadShader(gl, code, gl.VERTEX_SHADER);
6444                                }
6445                                function createFragmentShader(gl, code) {
6446                                    return loadShader(gl, code, gl.FRAGMENT_SHADER);
6447                                }
6448                                function createProgram(gl, shaders) {
6449                                    var program = gl.createProgram();
6450                                    for (var i = 0, ii = shaders.length; i < ii; ++i) {
6451                                        gl.attachShader(program, shaders[i]);
6452                                    }
6453                                    gl.linkProgram(program);
6454                                    var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
6455                                    if (!linked) {
6456                                        var errorMsg = gl.getProgramInfoLog(program);
6457                                        throw new Error('Error during program linking: ' + errorMsg);
6458                                    }
6459                                    return program;
6460                                }
6461                                function createTexture(gl, image, textureId) {
6462                                    gl.activeTexture(textureId);
6463                                    var texture = gl.createTexture();
6464                                    gl.bindTexture(gl.TEXTURE_2D, texture);
6465                                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
6466                                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
6467                                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
6468                                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
6469                                    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
6470                                    return texture;
6471                                }
6472                                var currentGL, currentCanvas;
6473                                function generateGL() {
6474                                    if (currentGL) {
6475                                        return;
6476                                    }
6477                                    currentCanvas = document.createElement('canvas');
6478                                    currentGL = currentCanvas.getContext('webgl', {premultipliedalpha: false});
6479                                }
6480                                var smaskVertexShaderCode = '\
6481  attribute vec2 a_position;                                    \
6482  attribute vec2 a_texCoord;                                    \
6483                                                                \
6484  uniform vec2 u_resolution;                                    \
6485                                                                \
6486  varying vec2 v_texCoord;                                      \
6487                                                                \
6488  void main() {                                                 \
6489    vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0;   \
6490    gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);          \
6491                                                                \
6492    v_texCoord = a_texCoord;                                    \
6493  }                                                             ';
6494                                var smaskFragmentShaderCode = '\
6495  precision mediump float;                                      \
6496                                                                \
6497  uniform vec4 u_backdrop;                                      \
6498  uniform int u_subtype;                                        \
6499  uniform sampler2D u_image;                                    \
6500  uniform sampler2D u_mask;                                     \
6501                                                                \
6502  varying vec2 v_texCoord;                                      \
6503                                                                \
6504  void main() {                                                 \
6505    vec4 imageColor = texture2D(u_image, v_texCoord);           \
6506    vec4 maskColor = texture2D(u_mask, v_texCoord);             \
6507    if (u_backdrop.a > 0.0) {                                   \
6508      maskColor.rgb = maskColor.rgb * maskColor.a +             \
6509                      u_backdrop.rgb * (1.0 - maskColor.a);     \
6510    }                                                           \
6511    float lum;                                                  \
6512    if (u_subtype == 0) {                                       \
6513      lum = maskColor.a;                                        \
6514    } else {                                                    \
6515      lum = maskColor.r * 0.3 + maskColor.g * 0.59 +            \
6516            maskColor.b * 0.11;                                 \
6517    }                                                           \
6518    imageColor.a *= lum;                                        \
6519    imageColor.rgb *= imageColor.a;                             \
6520    gl_FragColor = imageColor;                                  \
6521  }                                                             ';
6522                                var smaskCache = null;
6523                                function initSmaskGL() {
6524                                    var canvas, gl;
6525                                    generateGL();
6526                                    canvas = currentCanvas;
6527                                    currentCanvas = null;
6528                                    gl = currentGL;
6529                                    currentGL = null;
6530                                    var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
6531                                    var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
6532                                    var program = createProgram(gl, [
6533                                        vertexShader,
6534                                        fragmentShader
6535                                    ]);
6536                                    gl.useProgram(program);
6537                                    var cache = {};
6538                                    cache.gl = gl;
6539                                    cache.canvas = canvas;
6540                                    cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
6541                                    cache.positionLocation = gl.getAttribLocation(program, 'a_position');
6542                                    cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
6543                                    cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
6544                                    var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
6545                                    var texLayerLocation = gl.getUniformLocation(program, 'u_image');
6546                                    var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
6547                                    var texCoordBuffer = gl.createBuffer();
6548                                    gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
6549                                    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
6550                                        0.0,
6551                                        0.0,
6552                                        1.0,
6553                                        0.0,
6554                                        0.0,
6555                                        1.0,
6556                                        0.0,
6557                                        1.0,
6558                                        1.0,
6559                                        0.0,
6560                                        1.0,
6561                                        1.0
6562                                    ]), gl.STATIC_DRAW);
6563                                    gl.enableVertexAttribArray(texCoordLocation);
6564                                    gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
6565                                    gl.uniform1i(texLayerLocation, 0);
6566                                    gl.uniform1i(texMaskLocation, 1);
6567                                    smaskCache = cache;
6568                                }
6569                                function composeSMask(layer, mask, properties) {
6570                                    var width = layer.width, height = layer.height;
6571                                    if (!smaskCache) {
6572                                        initSmaskGL();
6573                                    }
6574                                    var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
6575                                    canvas.width = width;
6576                                    canvas.height = height;
6577                                    gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
6578                                    gl.uniform2f(cache.resolutionLocation, width, height);
6579                                    if (properties.backdrop) {
6580                                        gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
6581                                    } else {
6582                                        gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
6583                                    }
6584                                    gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
6585                                    var texture = createTexture(gl, layer, gl.TEXTURE0);
6586                                    var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
6587                                    var buffer = gl.createBuffer();
6588                                    gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
6589                                    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
6590                                        0,
6591                                        0,
6592                                        width,
6593                                        0,
6594                                        0,
6595                                        height,
6596                                        0,
6597                                        height,
6598                                        width,
6599                                        0,
6600                                        width,
6601                                        height
6602                                    ]), gl.STATIC_DRAW);
6603                                    gl.enableVertexAttribArray(cache.positionLocation);
6604                                    gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
6605                                    gl.clearColor(0, 0, 0, 0);
6606                                    gl.enable(gl.BLEND);
6607                                    gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
6608                                    gl.clear(gl.COLOR_BUFFER_BIT);
6609                                    gl.drawArrays(gl.TRIANGLES, 0, 6);
6610                                    gl.flush();
6611                                    gl.deleteTexture(texture);
6612                                    gl.deleteTexture(maskTexture);
6613                                    gl.deleteBuffer(buffer);
6614                                    return canvas;
6615                                }
6616                                var figuresVertexShaderCode = '\
6617  attribute vec2 a_position;                                    \
6618  attribute vec3 a_color;                                       \
6619                                                                \
6620  uniform vec2 u_resolution;                                    \
6621  uniform vec2 u_scale;                                         \
6622  uniform vec2 u_offset;                                        \
6623                                                                \
6624  varying vec4 v_color;                                         \
6625                                                                \
6626  void main() {                                                 \
6627    vec2 position = (a_position + u_offset) * u_scale;          \
6628    vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0;     \
6629    gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);          \
6630                                                                \
6631    v_color = vec4(a_color / 255.0, 1.0);                       \
6632  }                                                             ';
6633                                var figuresFragmentShaderCode = '\
6634  precision mediump float;                                      \
6635                                                                \
6636  varying vec4 v_color;                                         \
6637                                                                \
6638  void main() {                                                 \
6639    gl_FragColor = v_color;                                     \
6640  }                                                             ';
6641                                var figuresCache = null;
6642                                function initFiguresGL() {
6643                                    var canvas, gl;
6644                                    generateGL();
6645                                    canvas = currentCanvas;
6646                                    currentCanvas = null;
6647                                    gl = currentGL;
6648                                    currentGL = null;
6649                                    var vertexShader = createVertexShader(gl, figuresVertexS
vendor: 5,485 bytes, lines 6649-6716
6649haderCode);
6650                                    var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
6651                                    var program = createProgram(gl, [
6652                                        vertexShader,
6653                                        fragmentShader
6654                                    ]);
6655                                    gl.useProgram(program);
6656                                    var cache = {};
6657                                    cache.gl = gl;
6658                                    cache.canvas = canvas;
6659                                    cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
6660                                    cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
6661                                    cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
6662                                    cache.positionLocation = gl.getAttribLocation(program, 'a_position');
6663                                    cache.colorLocation = gl.getAttribLocation(program, 'a_color');
6664                                    figuresCache = cache;
6665                                }
6666                                function drawFigures(width, height, backgroundColor, figures, context) {
6667                                    if (!figuresCache) {
6668                                        initFiguresGL();
6669                                    }
6670                                    var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
6671                                    canvas.width = width;
6672                                    canvas.height = height;
6673                                    gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
6674                                    gl.uniform2f(cache.resolutionLocation, width, height);
6675                                    var count = 0;
6676                                    var i, ii, rows;
6677                                    for (i = 0, ii = figures.length; i < ii; i++) {
6678                                        switch (figures[i].type) {
6679                                            case 'lattice':
6680                                                rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
6681                                                count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
6682                                                break;
6683                                            case 'triangles':
6684                                                count += figures[i].coords.length;
6685                                                break;
6686                                        }
6687                                    }
6688                                    var coords = new Float32Array(count * 2);
6689                                    var colors = new Uint8Array(count * 3);
6690                                    var coordsMap = context.coords, colorsMap = context.colors;
6691                                    var pIndex = 0, cIndex = 0;
6692                                    for (i = 0, ii = figures.length; i < ii; i++) {
6693                                        var figure = figures[i], ps = figure.coords, cs = figure.colors;
6694                                        switch (figure.type) {
6695                                            case 'lattice':
6696                                                var cols = figure.verticesPerRow;
6697                                                rows = ps.length / cols | 0;
6698                                                for (var row = 1; row < rows; row++) {
6699                                                    var offset = row * cols + 1;
6700                                                    for (var col = 1; col < cols; col++, offset++) {
6701                                                        coords[pIndex] = coordsMap[ps[offset - cols - 1]];
6702                                                        coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
6703                                                        coords[pIndex + 2] = coordsMap[ps[offset - cols]];
6704                                                        coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
6705                                                        coords[pIndex + 4] = coordsMap[ps[offset - 1]];
6706                                                        coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
6707                                                        colors[cIndex] = colorsMap[cs[offset - cols - 1]];
6708                                                        colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
6709                                                        colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
6710                                                        colors[cIndex + 3] = colorsMap[cs[offset - cols]];
6711                                                        colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
6712                                                        colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
6713                                                        colors[cIndex + 6] = colorsMap[cs[offset - 1]];
6714                                                        colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
6715                                                        colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
6716                                                        coords[pIndex + 6] = co
vendor: 5,447 bytes, lines 6716-6788
6716ords[pIndex + 2];
6717                                                        coords[pIndex + 7] = coords[pIndex + 3];
6718                                                        coords[pIndex + 8] = coords[pIndex + 4];
6719                                                        coords[pIndex + 9] = coords[pIndex + 5];
6720                                                        coords[pIndex + 10] = coordsMap[ps[offset]];
6721                                                        coords[pIndex + 11] = coordsMap[ps[offset] + 1];
6722                                                        colors[cIndex + 9] = colors[cIndex + 3];
6723                                                        colors[cIndex + 10] = colors[cIndex + 4];
6724                                                        colors[cIndex + 11] = colors[cIndex + 5];
6725                                                        colors[cIndex + 12] = colors[cIndex + 6];
6726                                                        colors[cIndex + 13] = colors[cIndex + 7];
6727                                                        colors[cIndex + 14] = colors[cIndex + 8];
6728                                                        colors[cIndex + 15] = colorsMap[cs[offset]];
6729                                                        colors[cIndex + 16] = colorsMap[cs[offset] + 1];
6730                                                        colors[cIndex + 17] = colorsMap[cs[offset] + 2];
6731                                                        pIndex += 12;
6732                                                        cIndex += 18;
6733                                                    }
6734                                                }
6735                                                break;
6736                                            case 'triangles':
6737                                                for (var j = 0, jj = ps.length; j < jj; j++) {
6738                                                    coords[pIndex] = coordsMap[ps[j]];
6739                                                    coords[pIndex + 1] = coordsMap[ps[j] + 1];
6740                                                    colors[cIndex] = colorsMap[cs[j]];
6741                                                    colors[cIndex + 1] = colorsMap[cs[j] + 1];
6742                                                    colors[cIndex + 2] = colorsMap[cs[j] + 2];
6743                                                    pIndex += 2;
6744                                                    cIndex += 3;
6745                                                }
6746                                                break;
6747                                        }
6748                                    }
6749                                    if (backgroundColor) {
6750                                        gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
6751                                    } else {
6752                                        gl.clearColor(0, 0, 0, 0);
6753                                    }
6754                                    gl.clear(gl.COLOR_BUFFER_BIT);
6755                                    var coordsBuffer = gl.createBuffer();
6756                                    gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
6757                                    gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
6758                                    gl.enableVertexAttribArray(cache.positionLocation);
6759                                    gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
6760                                    var colorsBuffer = gl.createBuffer();
6761                                    gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
6762                                    gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
6763                                    gl.enableVertexAttribArray(cache.colorLocation);
6764                                    gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
6765                                    gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
6766                                    gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
6767                                    gl.drawArrays(gl.TRIANGLES, 0, count);
6768                                    gl.flush();
6769                                    gl.deleteBuffer(coordsBuffer);
6770                                    gl.deleteBuffer(colorsBuffer);
6771                                    return canvas;
6772                                }
6773                                function cleanup() {
6774                                    if (smaskCache && smaskCache.canvas) {
6775                                        smaskCache.canvas.width = 0;
6776                                        smaskCache.canvas.height = 0;
6777                                    }
6778                                    if (figuresCache && figuresCache.canvas) {
6779                                        figuresCache.canvas.width = 0;
6780                                        figuresCache.canvas.height = 0;
6781                                    }
6782                                    smaskCache = null;
6783                                    figuresCache = null;
6784                                }
6785                                return {
6786                                    get isEnabled() {
6787                                        if (getDefaultSetting('disableWebGL')) {
6788                                            return false;
6789                                        }
6790                                        var enabled = false;
6791                                        try {
6792                                            generateGL();
6793                                            enabled = !!currentGL;
6794                                        } catch (e) {
6795                                        }
6796                                        return shadow(this, 'isEnabled', enabled);
6797                                    },
6798                                    composeSMask: composeSMask,
6799                                    drawFigures: drawFigures,
6800                                    clear: cleanup
6801                                };
6802                            }();
6803                            exports.WebGLUtils = WebGLUtils;
6804
6805                            /***/ }),
6806                        /* 9 */
6807                        /***/ (function (module, exports, __w_pdfjs_require__) {
6808
6809                            "use strict";
6810
6811                            var sharedUtil = __w_pdfjs_require__(0);
6812                            var displayDOMUtils = __w_pdfjs_require__(1);
6813                            var displayAPI = __w_pdfjs_require__(3);
6814                            var displayAnnotationLayer = __w_pdfjs_require__(2);
6815                            var displayTextLayer = __w_pdfjs_require__(5);
6816                            var displayMetadata = __w_pdfjs_require__(7);
6817                            var displaySVG = __w_pdfjs_require__(4);
6818                            var globalScope = sharedUtil.globalScope;
6819                            var deprecated = sharedUtil.deprecated;
6820                            var warn = sharedUtil.warn;
6821                            var LinkTarget = displayDOMUtils.LinkTarget;
6822                            var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
6823                            var isWorker = typeof window === 'undefined';
6824                            if (!globalScope.PDFJS) {
6825                                globalScope.PDFJS = {};
6826                            }
6827                            var PDFJS = globalScope.PDFJS;
6828                            PDFJS.version = '1.7.354';
6829                            PDFJS.build = '0f7548ba';
6830                            PDFJS.pdfBug = false;
6831                            if (PDFJS.verbosity !== undefined) {
6832                                sharedUtil.setVerbosityLevel(PDFJS.verbosity);
6833                            }
6834                            delete PDFJS.verbosity;
6835                            Object.defineProperty(PDFJS, 'verbosity', {
6836                                get: function () {
6837                                    return sharedUtil.getVerbosityLevel();
6838                                },
6839                                set: function (level) {
6840                                    sharedUtil.setVerbosityLevel(level);
6841                                },
6842                                enumerable: true,
6843                                configurable: true
6844                            });
6845                            PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
6846                            PDFJS.OPS = sharedUtil.OPS;
6847                            PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
6848                            PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
6849                            PDFJS.shadow = sharedUtil.shadow;
6850                            PDFJS.createBlob = sharedUtil.createBlob;
6851                            PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
6852                                return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
6853                            };
6854                            Object.defineProperty(PDFJS, 'isLittleEndian', {
6855                                configurable: true,
6856                                get: function PDFJS_isLittleEndian() {
6857                                    var value = sharedUtil.isLittleEndian();
6858                                    return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
6859                                }
6860                            });
6861                            PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
6862                            PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
6863                            PDFJS.PasswordException = sharedUtil.PasswordException;
6864                            PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
6865                            PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
6866                            PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
6867                            PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
6868                            PDFJS.Util = sharedUtil.Util;
6869                            PDFJS.PageViewport = sharedUtil.PageViewport;
6870                            PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
6871                            PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
6872                            PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
6873                            PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
6874                            PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
6875                            PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
6876                            PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
6877                            PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
6878                            PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
6879                            PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
6880                            PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
6881                            PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
6882                            PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
6883                            PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
6884                            PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
6885                            PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
6886                            PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
6887                            PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
6888                            PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
6889                            var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
6890                            delete PDFJS.openExternalLinksInNewWindow;
6891                            Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
6892                                get: function () {
6893                                    return PDFJS.externalLinkTarget === LinkTarget.BLANK;
6894                                },
6895                                set: function (value) {
6896                                    if (value) {
6897                                        deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
6898                                    }
6899                                    if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
6900                                        warn('PDFJS.externalLinkTarget is already initialized');
6901                                        return;
6902                                    }
6903                                    PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
6904                                },
6905                                enumerable: true,
6906                                configurable: true
6907                            });
6908                            if (savedOpenExternalLinksInNewWindow) {
6909                                PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
6910                            }
6911                            PDFJS.getDocument = displayAPI.getDocument;
6912                            PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
6913                            PDFJS.PDFWorker = displayAPI.PDFWorker;
6914                            Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
6915                                configurable: true,
6916                                get: function PDFJS_hasCanvasTypedArrays() {
6917                                    var value = displayDOMUtils.hasCanvasTypedArrays();
6918                                    return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
6919                                }
6920                            });
6921                            PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
6922                            PDFJS.LinkTarget = LinkTarget;
6923                            PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
6924                            PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
6925                            PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
6926                            PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
6927                            PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
vendor: 46,128 bytes, lines 6928-7644
6928                            PDFJS.Metadata = displayMetadata.Metadata;
6929                            PDFJS.SVGGraphics = displaySVG.SVGGraphics;
6930                            PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
6931                            exports.globalScope = globalScope;
6932                            exports.isWorker = isWorker;
6933                            exports.PDFJS = globalScope.PDFJS;
6934
6935                            /***/ }),
6936                        /* 10 */
6937                        /***/ (function (module, exports, __w_pdfjs_require__) {
6938
6939                            "use strict";
6940
6941                            var sharedUtil = __w_pdfjs_require__(0);
6942                            var displayDOMUtils = __w_pdfjs_require__(1);
6943                            var displayPatternHelper = __w_pdfjs_require__(12);
6944                            var displayWebGL = __w_pdfjs_require__(8);
6945                            var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
6946                            var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
6947                            var ImageKind = sharedUtil.ImageKind;
6948                            var OPS = sharedUtil.OPS;
6949                            var TextRenderingMode = sharedUtil.TextRenderingMode;
6950                            var Uint32ArrayView = sharedUtil.Uint32ArrayView;
6951                            var Util = sharedUtil.Util;
6952                            var assert = sharedUtil.assert;
6953                            var info = sharedUtil.info;
6954                            var isNum = sharedUtil.isNum;
6955                            var isArray = sharedUtil.isArray;
6956                            var isLittleEndian = sharedUtil.isLittleEndian;
6957                            var error = sharedUtil.error;
6958                            var shadow = sharedUtil.shadow;
6959                            var warn = sharedUtil.warn;
6960                            var TilingPattern = displayPatternHelper.TilingPattern;
6961                            var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
6962                            var WebGLUtils = displayWebGL.WebGLUtils;
6963                            var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
6964                            var MIN_FONT_SIZE = 16;
6965                            var MAX_FONT_SIZE = 100;
6966                            var MAX_GROUP_SIZE = 4096;
6967                            var MIN_WIDTH_FACTOR = 0.65;
6968                            var COMPILE_TYPE3_GLYPHS = true;
6969                            var MAX_SIZE_TO_COMPILE = 1000;
6970                            var FULL_CHUNK_HEIGHT = 16;
6971                            var HasCanvasTypedArraysCached = {
6972                                get value() {
6973                                    return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
6974                                }
6975                            };
6976                            var IsLittleEndianCached = {
6977                                get value() {
6978                                    return shadow(IsLittleEndianCached, 'value', isLittleEndian());
6979                                }
6980                            };
6981                            function addContextCurrentTransform(ctx) {
6982                                if (!ctx.mozCurrentTransform) {
6983                                    ctx._originalSave = ctx.save;
6984                                    ctx._originalRestore = ctx.restore;
6985                                    ctx._originalRotate = ctx.rotate;
6986                                    ctx._originalScale = ctx.scale;
6987                                    ctx._originalTranslate = ctx.translate;
6988                                    ctx._originalTransform = ctx.transform;
6989                                    ctx._originalSetTransform = ctx.setTransform;
6990                                    ctx._transformMatrix = ctx._transformMatrix || [
6991                                        1,
6992                                        0,
6993                                        0,
6994                                        1,
6995                                        0,
6996                                        0
6997                                    ];
6998                                    ctx._transformStack = [];
6999                                    Object.defineProperty(ctx, 'mozCurrentTransform', {
7000                                        get: function getCurrentTransform() {
7001                                            return this._transformMatrix;
7002                                        }
7003                                    });
7004                                    Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
7005                                        get: function getCurrentTransformInverse() {
7006                                            var m = this._transformMatrix;
7007                                            var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
7008                                            var ad_bc = a * d - b * c;
7009                                            var bc_ad = b * c - a * d;
7010                                            return [
7011                                                d / ad_bc,
7012                                                b / bc_ad,
7013                                                c / bc_ad,
7014                                                a / ad_bc,
7015                                                (d * e - c * f) / bc_ad,
7016                                                (b * e - a * f) / ad_bc
7017                                            ];
7018                                        }
7019                                    });
7020                                    ctx.save = function ctxSave() {
7021                                        var old = this._transformMatrix;
7022                                        this._transformStack.push(old);
7023                                        this._transformMatrix = old.slice(0, 6);
7024                                        this._originalSave();
7025                                    };
7026                                    ctx.restore = function ctxRestore() {
7027                                        var prev = this._transformStack.pop();
7028                                        if (prev) {
7029                                            this._transformMatrix = prev;
7030                                            this._originalRestore();
7031                                        }
7032                                    };
7033                                    ctx.translate = function ctxTranslate(x, y) {
7034                                        var m = this._transformMatrix;
7035                                        m[4] = m[0] * x + m[2] * y + m[4];
7036                                        m[5] = m[1] * x + m[3] * y + m[5];
7037                                        this._originalTranslate(x, y);
7038                                    };
7039                                    ctx.scale = function ctxScale(x, y) {
7040                                        var m = this._transformMatrix;
7041                                        m[0] = m[0] * x;
7042                                        m[1] = m[1] * x;
7043                                        m[2] = m[2] * y;
7044                                        m[3] = m[3] * y;
7045                                        this._originalScale(x, y);
7046                                    };
7047                                    ctx.transform = function ctxTransform(a, b, c, d, e, f) {
7048                                        var m = this._transformMatrix;
7049                                        this._transformMatrix = [
7050                                            m[0] * a + m[2] * b,
7051                                            m[1] * a + m[3] * b,
7052                                            m[0] * c + m[2] * d,
7053                                            m[1] * c + m[3] * d,
7054                                            m[0] * e + m[2] * f + m[4],
7055                                            m[1] * e + m[3] * f + m[5]
7056                                        ];
7057                                        ctx._originalTransform(a, b, c, d, e, f);
7058                                    };
7059                                    ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
7060                                        this._transformMatrix = [
7061                                            a,
7062                                            b,
7063                                            c,
7064                                            d,
7065                                            e,
7066                                            f
7067                                        ];
7068                                        ctx._originalSetTransform(a, b, c, d, e, f);
7069                                    };
7070                                    ctx.rotate = function ctxRotate(angle) {
7071                                        var cosValue = Math.cos(angle);
7072                                        var sinValue = Math.sin(angle);
7073                                        var m = this._transformMatrix;
7074                                        this._transformMatrix = [
7075                                            m[0] * cosValue + m[2] * sinValue,
7076                                            m[1] * cosValue + m[3] * sinValue,
7077                                            m[0] * -sinValue + m[2] * cosValue,
7078                                            m[1] * -sinValue + m[3] * cosValue,
7079                                            m[4],
7080                                            m[5]
7081                                        ];
7082                                        this._originalRotate(angle);
7083                                    };
7084                                }
7085                            }
7086                            var CachedCanvases = function CachedCanvasesClosure() {
7087                                function CachedCanvases(canvasFactory) {
7088                                    this.canvasFactory = canvasFactory;
7089                                    this.cache = Object.create(null);
7090                                }
7091                                CachedCanvases.prototype = {
7092                                    getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
7093                                        var canvasEntry;
7094                                        if (this.cache[id] !== undefined) {
7095                                            canvasEntry = this.cache[id];
7096                                            this.canvasFactory.reset(canvasEntry, width, height);
7097                                            canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
7098                                        } else {
7099                                            canvasEntry = this.canvasFactory.create(width, height);
7100                                            this.cache[id] = canvasEntry;
7101                                        }
7102                                        if (trackTransform) {
7103                                            addContextCurrentTransform(canvasEntry.context);
7104                                        }
7105                                        return canvasEntry;
7106                                    },
7107                                    clear: function () {
7108                                        for (var id in this.cache) {
7109                                            var canvasEntry = this.cache[id];
7110                                            this.canvasFactory.destroy(canvasEntry);
7111                                            delete this.cache[id];
7112                                        }
7113                                    }
7114                                };
7115                                return CachedCanvases;
7116                            }();
7117                            function compileType3Glyph(imgData) {
7118                                var POINT_TO_PROCESS_LIMIT = 1000;
7119                                var width = imgData.width, height = imgData.height;
7120                                var i, j, j0, width1 = width + 1;
7121                                var points = new Uint8Array(width1 * (height + 1));
7122                                var POINT_TYPES = new Uint8Array([
7123                                    0,
7124                                    2,
7125                                    4,
7126                                    0,
7127                                    1,
7128                                    0,
7129                                    5,
7130                                    4,
7131                                    8,
7132                                    10,
7133                                    0,
7134                                    8,
7135                                    0,
7136                                    2,
7137                                    1,
7138                                    0
7139                                ]);
7140                                var lineSize = width + 7 & ~7, data0 = imgData.data;
7141                                var data = new Uint8Array(lineSize * height), pos = 0, ii;
7142                                for (i = 0, ii = data0.length; i < ii; i++) {
7143                                    var mask = 128, elem = data0[i];
7144                                    while (mask > 0) {
7145                                        data[pos++] = elem & mask ? 0 : 255;
7146                                        mask >>= 1;
7147                                    }
7148                                }
7149                                var count = 0;
7150                                pos = 0;
7151                                if (data[pos] !== 0) {
7152                                    points[0] = 1;
7153                                    ++count;
7154                                }
7155                                for (j = 1; j < width; j++) {
7156                                    if (data[pos] !== data[pos + 1]) {
7157                                        points[j] = data[pos] ? 2 : 1;
7158                                        ++count;
7159                                    }
7160                                    pos++;
7161                                }
7162                                if (data[pos] !== 0) {
7163                                    points[j] = 2;
7164                                    ++count;
7165                                }
7166                                for (i = 1; i < height; i++) {
7167                                    pos = i * lineSize;
7168                                    j0 = i * width1;
7169                                    if (data[pos - lineSize] !== data[pos]) {
7170                                        points[j0] = data[pos] ? 1 : 8;
7171                                        ++count;
7172                                    }
7173                                    var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
7174                                    for (j = 1; j < width; j++) {
7175                                        sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
7176                                        if (POINT_TYPES[sum]) {
7177                                            points[j0 + j] = POINT_TYPES[sum];
7178                                            ++count;
7179                                        }
7180                                        pos++;
7181                                    }
7182                                    if (data[pos - lineSize] !== data[pos]) {
7183                                        points[j0 + j] = data[pos] ? 2 : 4;
7184                                        ++count;
7185                                    }
7186                                    if (count > POINT_TO_PROCESS_LIMIT) {
7187                                        return null;
7188                                    }
7189                                }
7190                                pos = lineSize * (height - 1);
7191                                j0 = i * width1;
7192                                if (data[pos] !== 0) {
7193                                    points[j0] = 8;
7194                                    ++count;
7195                                }
7196                                for (j = 1; j < width; j++) {
7197                                    if (data[pos] !== data[pos + 1]) {
7198                                        points[j0 + j] = data[pos] ? 4 : 8;
7199                                        ++count;
7200                                    }
7201                                    pos++;
7202                                }
7203                                if (data[pos] !== 0) {
7204                                    points[j0 + j] = 4;
7205                                    ++count;
7206                                }
7207                                if (count > POINT_TO_PROCESS_LIMIT) {
7208                                    return null;
7209                                }
7210                                var steps = new Int32Array([
7211                                    0,
7212                                    width1,
7213                                    -1,
7214                                    0,
7215                                    -width1,
7216                                    0,
7217                                    0,
7218                                    0,
7219                                    1
7220                                ]);
7221                                var outlines = [];
7222                                for (i = 0; count && i <= height; i++) {
7223                                    var p = i * width1;
7224                                    var end = p + width;
7225                                    while (p < end && !points[p]) {
7226                                        p++;
7227                                    }
7228                                    if (p === end) {
7229                                        continue;
7230                                    }
7231                                    var coords = [
7232                                        p % width1,
7233                                        i
7234                                    ];
7235                                    var type = points[p], p0 = p, pp;
7236                                    do {
7237                                        var step = steps[type];
7238                                        do {
7239                                            p += step;
7240                                        } while (!points[p]);
7241                                        pp = points[p];
7242                                        if (pp !== 5 && pp !== 10) {
7243                                            type = pp;
7244                                            points[p] = 0;
7245                                        } else {
7246                                            type = pp & 0x33 * type >> 4;
7247                                            points[p] &= type >> 2 | type << 2;
7248                                        }
7249                                        coords.push(p % width1);
7250                                        coords.push(p / width1 | 0);
7251                                        --count;
7252                                    } while (p0 !== p);
7253                                    outlines.push(coords);
7254                                    --i;
7255                                }
7256                                var drawOutline = function (c) {
7257                                    c.save();
7258                                    c.scale(1 / width, -1 / height);
7259                                    c.translate(0, -height);
7260                                    c.beginPath();
7261                                    for (var i = 0, ii = outlines.length; i < ii; i++) {
7262                                        var o = outlines[i];
7263                                        c.moveTo(o[0], o[1]);
7264                                        for (var j = 2, jj = o.length; j < jj; j += 2) {
7265                                            c.lineTo(o[j], o[j + 1]);
7266                                        }
7267                                    }
7268                                    c.fill();
7269                                    c.beginPath();
7270                                    c.restore();
7271                                };
7272                                return drawOutline;
7273                            }
7274                            var CanvasExtraState = function CanvasExtraStateClosure() {
7275                                function CanvasExtraState(old) {
7276                                    this.alphaIsShape = false;
7277                                    this.fontSize = 0;
7278                                    this.fontSizeScale = 1;
7279                                    this.textMatrix = IDENTITY_MATRIX;
7280                                    this.textMatrixScale = 1;
7281                                    this.fontMatrix = FONT_IDENTITY_MATRIX;
7282                                    this.leading = 0;
7283                                    this.x = 0;
7284                                    this.y = 0;
7285                                    this.lineX = 0;
7286                                    this.lineY = 0;
7287                                    this.charSpacing = 0;
7288                                    this.wordSpacing = 0;
7289                                    this.textHScale = 1;
7290                                    this.textRenderingMode = TextRenderingMode.FILL;
7291                                    this.textRise = 0;
7292                                    this.fillColor = '#000000';
7293                                    this.strokeColor = '#000000';
7294                                    this.patternFill = false;
7295                                    this.fillAlpha = 1;
7296                                    this.strokeAlpha = 1;
7297                                    this.lineWidth = 1;
7298                                    this.activeSMask = null;
7299                                    this.resumeSMaskCtx = null;
7300                                    this.old = old;
7301                                }
7302                                CanvasExtraState.prototype = {
7303                                    clone: function CanvasExtraState_clone() {
7304                                        return Object.create(this);
7305                                    },
7306                                    setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
7307                                        this.x = x;
7308                                        this.y = y;
7309                                    }
7310                                };
7311                                return CanvasExtraState;
7312                            }();
7313                            var CanvasGraphics = function CanvasGraphicsClosure() {
7314                                var EXECUTION_TIME = 15;
7315                                var EXECUTION_STEPS = 10;
7316                                function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
7317                                    this.ctx = canvasCtx;
7318                                    this.current = new CanvasExtraState();
7319                                    this.stateStack = [];
7320                                    this.pendingClip = null;
7321                                    this.pendingEOFill = false;
7322                                    this.res = null;
7323                                    this.xobjs = null;
7324                                    this.commonObjs = commonObjs;
7325                                    this.objs = objs;
7326                                    this.canvasFactory = canvasFactory;
7327                                    this.imageLayer = imageLayer;
7328                                    this.groupStack = [];
7329                                    this.processingType3 = null;
7330                                    this.baseTransform = null;
7331                                    this.baseTransformStack = [];
7332                                    this.groupLevel = 0;
7333                                    this.smaskStack = [];
7334                                    this.smaskCounter = 0;
7335                                    this.tempSMask = null;
7336                                    this.cachedCanvases = new CachedCanvases(this.canvasFactory);
7337                                    if (canvasCtx) {
7338                                        addContextCurrentTransform(canvasCtx);
7339                                    }
7340                                    this.cachedGetSinglePixelWidth = null;
7341                                }
7342                                function putBinaryImageData(ctx, imgData) {
7343                                    if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
7344                                        ctx.putImageData(imgData, 0, 0);
7345                                        return;
7346                                    }
7347                                    var height = imgData.height, width = imgData.width;
7348                                    var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
7349                                    var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
7350                                    var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
7351                                    var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
7352                                    var srcPos = 0, destPos;
7353                                    var src = imgData.data;
7354                                    var dest = chunkImgData.data;
7355                                    var i, j, thisChunkHeight, elemsInThisChunk;
7356                                    if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
7357                                        var srcLength = src.byteLength;
7358                                        var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
7359                                        var dest32DataLength = dest32.length;
7360                                        var fullSrcDiff = width + 7 >> 3;
7361                                        var white = 0xFFFFFFFF;
7362                                        var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
7363                                        for (i = 0; i < totalChunks; i++) {
7364                                            thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
7365                                            destPos = 0;
7366                                            for (j = 0; j < thisChunkHeight; j++) {
7367                                                var srcDiff = srcLength - srcPos;
7368                                                var k = 0;
7369                                                var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
7370                                                var kEndUnrolled = kEnd & ~7;
7371                                                var mask = 0;
7372                                                var srcByte = 0;
7373                                                for (; k < kEndUnrolled; k += 8) {
7374                                                    srcByte = src[srcPos++];
7375                                                    dest32[destPos++] = srcByte & 128 ? white : black;
7376                                                    dest32[destPos++] = srcByte & 64 ? white : black;
7377                                                    dest32[destPos++] = srcByte & 32 ? white : black;
7378                                                    dest32[destPos++] = srcByte & 16 ? white : black;
7379                                                    dest32[destPos++] = srcByte & 8 ? white : black;
7380                                                    dest32[destPos++] = srcByte & 4 ? white : black;
7381                                                    dest32[destPos++] = srcByte & 2 ? white : black;
7382                                                    dest32[destPos++] = srcByte & 1 ? white : black;
7383                                                }
7384                                                for (; k < kEnd; k++) {
7385                                                    if (mask === 0) {
7386                                                        srcByte = src[srcPos++];
7387                                                        mask = 128;
7388                                                    }
7389                                                    dest32[destPos++] = srcByte & mask ? white : black;
7390                                                    mask >>= 1;
7391                                                }
7392                                            }
7393                                            while (destPos < dest32DataLength) {
7394                                                dest32[destPos++] = 0;
7395                                            }
7396                                            ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
7397                                        }
7398                                    } else if (imgData.kind === ImageKind.RGBA_32BPP) {
7399                                        j = 0;
7400                                        elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
7401                                        for (i = 0; i < fullChunks; i++) {
7402                                            dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
7403                                            srcPos += elemsInThisChunk;
7404                                            ctx.putImageData(chunkImgData, 0, j);
7405                                            j += FULL_CHUNK_HEIGHT;
7406                                        }
7407                                        if (i < totalChunks) {
7408                                            elemsInThisChunk = width * partialChunkHeight * 4;
7409                                            dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
7410                                            ctx.putImageData(chunkImgData, 0, j);
7411                                        }
7412                                    } else if (imgData.kind === ImageKind.RGB_24BPP) {
7413                                        thisChunkHeight = FULL_CHUNK_HEIGHT;
7414                                        elemsInThisChunk = width * thisChunkHeight;
7415                                        for (i = 0; i < totalChunks; i++) {
7416                                            if (i >= fullChunks) {
7417                                                thisChunkHeight = partialChunkHeight;
7418                                                elemsInThisChunk = width * thisChunkHeight;
7419                                            }
7420                                            destPos = 0;
7421                                            for (j = elemsInThisChunk; j--; ) {
7422                                                dest[destPos++] = src[srcPos++];
7423                                                dest[destPos++] = src[srcPos++];
7424                                                dest[destPos++] = src[srcPos++];
7425                                                dest[destPos++] = 255;
7426                                            }
7427                                            ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
7428                                        }
7429                                    } else {
7430                                        error('bad image kind: ' + imgData.kind);
7431                                    }
7432                                }
7433                                function putBinaryImageMask(ctx, imgData) {
7434                                    var height = imgData.height, width = imgData.width;
7435                                    var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
7436                                    var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
7437                                    var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
7438                                    var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
7439                                    var srcPos = 0;
7440                                    var src = imgData.data;
7441                                    var dest = chunkImgData.data;
7442                                    for (var i = 0; i < totalChunks; i++) {
7443                                        var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
7444                                        var destPos = 3;
7445                                        for (var j = 0; j < thisChunkHeight; j++) {
7446                                            var mask = 0;
7447                                            for (var k = 0; k < width; k++) {
7448                                                if (!mask) {
7449                                                    var elem = src[srcPos++];
7450                                                    mask = 128;
7451                                                }
7452                                                dest[destPos] = elem & mask ? 0 : 255;
7453                                                destPos += 4;
7454                                                mask >>= 1;
7455                                            }
7456                                        }
7457                                        ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
7458                                    }
7459                                }
7460                                function copyCtxState(sourceCtx, destCtx) {
7461                                    var properties = [
7462                                        'strokeStyle',
7463                                        'fillStyle',
7464                                        'fillRule',
7465                                        'globalAlpha',
7466                                        'lineWidth',
7467                                        'lineCap',
7468                                        'lineJoin',
7469                                        'miterLimit',
7470                                        'globalCompositeOperation',
7471                                        'font'
7472                                    ];
7473                                    for (var i = 0, ii = properties.length; i < ii; i++) {
7474                                        var property = properties[i];
7475                                        if (sourceCtx[property] !== undefined) {
7476                                            destCtx[property] = sourceCtx[property];
7477                                        }
7478                                    }
7479                                    if (sourceCtx.setLineDash !== undefined) {
7480                                        destCtx.setLineDash(sourceCtx.getLineDash());
7481                                        destCtx.lineDashOffset = sourceCtx.lineDashOffset;
7482                                    }
7483                                }
7484                                function composeSMaskBackdrop(bytes, r0, g0, b0) {
7485                                    var length = bytes.length;
7486                                    for (var i = 3; i < length; i += 4) {
7487                                        var alpha = bytes[i];
7488                                        if (alpha === 0) {
7489                                            bytes[i - 3] = r0;
7490                                            bytes[i - 2] = g0;
7491                                            bytes[i - 1] = b0;
7492                                        } else if (alpha < 255) {
7493                                            var alpha_ = 255 - alpha;
7494                                            bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
7495                                            bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
7496                                            bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
7497                                        }
7498                                    }
7499                                }
7500                                function composeSMaskAlpha(maskData, layerData, transferMap) {
7501                                    var length = maskData.length;
7502                                    var scale = 1 / 255;
7503                                    for (var i = 3; i < length; i += 4) {
7504                                        var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
7505                                        layerData[i] = layerData[i] * alpha * scale | 0;
7506                                    }
7507                                }
7508                                function composeSMaskLuminosity(maskData, layerData, transferMap) {
7509                                    var length = maskData.length;
7510                                    for (var i = 3; i < length; i += 4) {
7511                                        var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
7512                                        layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
7513                                    }
7514                                }
7515                                function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
7516                                    var hasBackdrop = !!backdrop;
7517                                    var r0 = hasBackdrop ? backdrop[0] : 0;
7518                                    var g0 = hasBackdrop ? backdrop[1] : 0;
7519                                    var b0 = hasBackdrop ? backdrop[2] : 0;
7520                                    var composeFn;
7521                                    if (subtype === 'Luminosity') {
7522                                        composeFn = composeSMaskLuminosity;
7523                                    } else {
7524                                        composeFn = composeSMaskAlpha;
7525                                    }
7526                                    var PIXELS_TO_PROCESS = 1048576;
7527                                    var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
7528                                    for (var row = 0; row < height; row += chunkSize) {
7529                                        var chunkHeight = Math.min(chunkSize, height - row);
7530                                        var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
7531                                        var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
7532                                        if (hasBackdrop) {
7533                                            composeSMaskBackdrop(maskData.data, r0, g0, b0);
7534                                        }
7535                                        composeFn(maskData.data, layerData.data, transferMap);
7536                                        maskCtx.putImageData(layerData, 0, row);
7537                                    }
7538                                }
7539                                function composeSMask(ctx, smask, layerCtx) {
7540                                    var mask = smask.canvas;
7541                                    var maskCtx = smask.context;
7542                                    ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
7543                                    var backdrop = smask.backdrop || null;
7544                                    if (!smask.transferMap && WebGLUtils.isEnabled) {
7545                                        var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
7546                                            subtype: smask.subtype,
7547                                            backdrop: backdrop
7548                                        });
7549                                        ctx.setTransform(1, 0, 0, 1, 0, 0);
7550                                        ctx.drawImage(composed, smask.offsetX, smask.offsetY);
7551                                        return;
7552                                    }
7553                                    genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
7554                                    ctx.drawImage(mask, 0, 0);
7555                                }
7556                                var LINE_CAP_STYLES = [
7557                                    'butt',
7558                                    'round',
7559                                    'square'
7560                                ];
7561                                var LINE_JOIN_STYLES = [
7562                                    'miter',
7563                                    'round',
7564                                    'bevel'
7565                                ];
7566                                var NORMAL_CLIP = {};
7567                                var EO_CLIP = {};
7568                                CanvasGraphics.prototype = {
7569                                    beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
7570                                        var width = this.ctx.canvas.width;
7571                                        var height = this.ctx.canvas.height;
7572                                        this.ctx.save();
7573                                        this.ctx.fillStyle = 'rgb(255, 255, 255)';
7574                                        this.ctx.fillRect(0, 0, width, height);
7575                                        this.ctx.restore();
7576                                        if (transparency) {
7577                                            var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
7578                                            this.compositeCtx = this.ctx;
7579                                            this.transparentCanvas = transparentCanvas.canvas;
7580                                            this.ctx = transparentCanvas.context;
7581                                            this.ctx.save();
7582                                            this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
7583                                        }
7584                                        this.ctx.save();
7585                                        if (transform) {
7586                                            this.ctx.transform.apply(this.ctx, transform);
7587                                        }
7588                                        this.ctx.transform.apply(this.ctx, viewport.transform);
7589                                        this.baseTransform = this.ctx.mozCurrentTransform.slice();
7590                                        if (this.imageLayer) {
7591                                            this.imageLayer.beginLayout();
7592                                        }
7593                                    },
7594                                    executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
7595                                        var argsArray = operatorList.argsArray;
7596                                        var fnArray = operatorList.fnArray;
7597                                        var i = executionStartIdx || 0;
7598                                        var argsArrayLen = argsArray.length;
7599                                        if (argsArrayLen === i) {
7600                                            return i;
7601                                        }
7602                                        var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
7603                                        var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
7604                                        var steps = 0;
7605                                        var commonObjs = this.commonObjs;
7606                                        var objs = this.objs;
7607                                        var fnId;
7608                                        while (true) {
7609                                            if (stepper !== undefined && i === stepper.nextBreakPoint) {
7610                                                stepper.breakIt(i, continueCallback);
7611                                                return i;
7612                                            }
7613                                            fnId = fnArray[i];
7614                                            if (fnId !== OPS.dependency) {
7615                                                this[fnId].apply(this, argsArray[i]);
7616                                            } else {
7617                                                var deps = argsArray[i];
7618                                                for (var n = 0, nn = deps.length; n < nn; n++) {
7619                                                    var depObjId = deps[n];
7620                                                    var common = depObjId[0] === 'g' && depObjId[1] === '_';
7621                                                    var objsPool = common ? commonObjs : objs;
7622                                                    if (!objsPool.isResolved(depObjId)) {
7623                                                        objsPool.get(depObjId, continueCallback);
7624                                                        return i;
7625                                                    }
7626                                                }
7627                                            }
7628                                            i++;
7629                                            if (i === argsArrayLen) {
7630                                                return i;
7631                                            }
7632                                            if (chunkOperations && ++steps > EXECUTION_STEPS) {
7633                                                if (Date.now() > endTime) {
7634                                                    continueCallback();
7635                                                    return i;
7636                                                }
7637                                                steps = 0;
7638                                            }
7639                                        }
7640                                    },
7641                                    endDrawing: function CanvasGraphics_endDrawing() {
7642                                        if (this.current.activeSMask !== null) {
7643                                            this.endSMaskGroup();
7644                                        }
7645                                        this.ctx.restore();
7646                                        if (this.transparentCanvas) {
7647                                            this.ctx = this.compositeCtx;
7648                                            this.ctx.save();
7649                                            this.ctx.setTransform(1, 0, 0, 1, 0, 0);
7650                                            this.ctx.drawImage(this.transparentCanvas, 0, 0);
7651                                            this.ctx.restore();
7652                                            this.transparentCanvas = null;
7653                                        }
7654                                        this.cachedCanvases.clear();
7655                                        WebGLUtils.clear();
7656                                        if (this.imageLayer) {
7657                                            this.imageLayer.endLayout();
7658                                        }
7659                                    },
7660                                    setLineWidth: function CanvasGraphics_setLineWidth(width) {
7661                                        this.current.lineWidth = width;
7662                                        this.ctx.lineWidth = width;
7663                                    },
7664                                    setLineCap: function CanvasGraphics_setLineCap(style) {
7665                                        this.ctx.lineCap = LINE_CAP_STYLES[style];
7666                                    },
7667                                    setLineJoin: function CanvasGraphics_setLineJoin(style) {
7668                                        this.ctx.lineJoin = LINE_JOIN_STYLES[style];
7669                                    },
7670                                    setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
7671                                        this.ctx.miterLimit = limit;
7672                                    },
7673                                    setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
7674                                        var ctx = this.ctx;
7675                                        if (ctx.setLineDash !== undefined) {
7676                                            ctx.setLineDash(dashArray);
7677                                            ctx.lineDashOffset = dashPhase;
7678                                        }
7679                                    },
7680                                    setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
7681                                    },
7682                                    setFlatness: function CanvasGraphics_setFlatness(flatness) {
7683                                    },
7684                                    setGState: function CanvasGraphics_setGState(states) {
7685                                        for (var i = 0, ii = states.length; i < ii; i++) {
7686                                            var state = states[i];
7687                                            var key = state[0];
7688                                            var value = state[1];
7689                                            switch (key) {
7690                                                case 'LW':
7691                                                    this.setLineWidth(value);
7692                                                    break;
7693                                                case 'LC':
7694                                                    this.setLineCap(value);
7695                                                    break;
7696                                                case 'LJ':
7697                                                    this.setLineJoin(value);
7698                                                    break;
7699                                                case 'ML':
7700                                                    this.setMiterLimit(value);
7701                                                    break;
7702                                                case 'D':
7703                                                    this.setDash(value[0], value[1]);
7704                                                    break;
7705                                                case 'RI':
7706                                                    this.setRenderingIntent
vendor: 4,808 bytes, lines 7706-7767
7706(value);
7707                                                    break;
7708                                                case 'FL':
7709                                                    this.setFlatness(value);
7710                                                    break;
7711                                                case 'Font':
7712                                                    this.setFont(value[0], value[1]);
7713                                                    break;
7714                                                case 'CA':
7715                                                    this.current.strokeAlpha = state[1];
7716                                                    break;
7717                                                case 'ca':
7718                                                    this.current.fillAlpha = state[1];
7719                                                    this.ctx.globalAlpha = state[1];
7720                                                    break;
7721                                                case 'BM':
7722                                                    if (value && value.name && value.name !== 'Normal') {
7723                                                        var mode = value.name.replace(/([A-Z])/g, function (c) {
7724                                                            return '-' + c.toLowerCase();
7725                                                        }).substring(1);
7726                                                        this.ctx.globalCompositeOperation = mode;
7727                                                        if (this.ctx.globalCompositeOperation !== mode) {
7728                                                            warn('globalCompositeOperation "' + mode + '" is not supported');
7729                                                        }
7730                                                    } else {
7731                                                        this.ctx.globalCompositeOperation = 'source-over';
7732                                                    }
7733                                                    break;
7734                                                case 'SMask':
7735                                                    if (this.current.activeSMask) {
7736                                                        if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
7737                                                            this.suspendSMaskGroup();
7738                                                        } else {
7739                                                            this.endSMaskGroup();
7740                                                        }
7741                                                    }
7742                                                    this.current.activeSMask = value ? this.tempSMask : null;
7743                                                    if (this.current.activeSMask) {
7744                                                        this.beginSMaskGroup();
7745                                                    }
7746                                                    this.tempSMask = null;
7747                                                    break;
7748                                            }
7749                                        }
7750                                    },
7751                                    beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
7752                                        var activeSMask = this.current.activeSMask;
7753                                        var drawnWidth = activeSMask.canvas.width;
7754                                        var drawnHeight = activeSMask.canvas.height;
7755                                        var cacheId = 'smaskGroupAt' + this.groupLevel;
7756                                        var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
7757                                        var currentCtx = this.ctx;
7758                                        var currentTransform = currentCtx.mozCurrentTransform;
7759                                        this.ctx.save();
7760                                        var groupCtx = scratchCanvas.context;
7761                                        groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
7762                                        groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
7763                                        groupCtx.transform.apply(groupCtx, currentTransform);
7764                                        activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
7765                                        copyCtxState(currentCtx, groupCtx);
7766                                        this.ctx = groupCtx;
7767                                        this.setGState([
7768                                            [
7769                                                'BM',
7770                                                'Normal'
7771                                            ],
7772                                            [
7773                                                'ca',
7774                                                1
7775                                            ],
7776                                            [
7777                                                'CA',
7778                                                1
7779                                            ]
7780                                        ]);
7781                                        this.groupStack.push(currentCtx);
7782                                        this.groupLevel++;
7783                                    },
7784                                    suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
7785                                        var groupCtx = this.ctx;
7786                                        this.groupLevel--;
7787                                        this.ctx = this.groupStack.pop();
7788                                        composeSMask(this.ctx, this.current.activeSMask, groupCtx);
7789                                        this.ctx.restore();
7790                                        this.ctx.save();
7791                                        copyCtxState(groupCtx, this.ctx);
7792                                        this.current.resumeSMaskCtx = groupCtx;
7793                                        var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
7794                                        this.ctx.transform.apply(this.ctx, deltaTransform);
7795                                        groupCtx.save();
7796                                        groupCtx.setTransform(1, 0, 0, 1, 0, 0);
7797                                        groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
7798                                        groupCtx.restore();
7799                                    },
7800                                    resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
7801                                        var groupCtx = this.current.resumeSMaskCtx;
7802                                        var currentCtx = this.ctx;
7803                                        this.ctx = groupCtx;
7804                                        this.groupStack.push(currentCtx);
7805                                        this.groupLevel++;
7806                                    },
7807                                    endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
7808                                        var groupCtx = this.ctx;
7809                                        this.groupLevel--;
7810                                        this.ctx = this.groupStack.pop();
7811                                        composeSMask(this.ctx, this.current.activeSMask, groupCtx);
7812                                        this.ctx.restore();
7813                                        copyCtxState(groupCtx, this.ctx);
7814                                        var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
7815                                        this.ctx.transform.apply(this.ctx, deltaTransform);
7816                                    },
7817                                    save: function CanvasGraphics_save() {
7818                                        this.ctx.save();
7819                                        var old = this.current;
7820                                        this.stateStack.push(old);
7821                                        this.current = old.clone();
7822                                        this.current.resumeSMaskCtx = null;
7823                                    },
7824                                    restore: function CanvasGraphics_restore() {
7825                                        if (this.current.resumeSMaskCtx) {
7826                                            this.resumeSMaskGroup();
7827                                        }
7828                                        if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
7829                                            this.endSMaskGroup();
7830                                        }
7831                                        if (this.stateStack.length !== 0) {
7832                                            this.current = this.stateStack.pop();
vendor: 24,416 bytes, lines 7833-8181
7833                                            this.ctx.restore();
7834                                            this.pendingClip = null;
7835                                            this.cachedGetSinglePixelWidth = null;
7836                                        }
7837                                    },
7838                                    transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
7839                                        this.ctx.transform(a, b, c, d, e, f);
7840                                        this.cachedGetSinglePixelWidth = null;
7841                                    },
7842                                    constructPath: function CanvasGraphics_constructPath(ops, args) {
7843                                        var ctx = this.ctx;
7844                                        var current = this.current;
7845                                        var x = current.x, y = current.y;
7846                                        for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
7847                                            switch (ops[i] | 0) {
7848                                                case OPS.rectangle:
7849                                                    x = args[j++];
7850                                                    y = args[j++];
7851                                                    var width = args[j++];
7852                                                    var height = args[j++];
7853                                                    if (width === 0) {
7854                                                        width = this.getSinglePixelWidth();
7855                                                    }
7856                                                    if (height === 0) {
7857                                                        height = this.getSinglePixelWidth();
7858                                                    }
7859                                                    var xw = x + width;
7860                                                    var yh = y + height;
7861                                                    this.ctx.moveTo(x, y);
7862                                                    this.ctx.lineTo(xw, y);
7863                                                    this.ctx.lineTo(xw, yh);
7864                                                    this.ctx.lineTo(x, yh);
7865                                                    this.ctx.lineTo(x, y);
7866                                                    this.ctx.closePath();
7867                                                    break;
7868                                                case OPS.moveTo:
7869                                                    x = args[j++];
7870                                                    y = args[j++];
7871                                                    ctx.moveTo(x, y);
7872                                                    break;
7873                                                case OPS.lineTo:
7874                                                    x = args[j++];
7875                                                    y = args[j++];
7876                                                    ctx.lineTo(x, y);
7877                                                    break;
7878                                                case OPS.curveTo:
7879                                                    x = args[j + 4];
7880                                                    y = args[j + 5];
7881                                                    ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
7882                                                    j += 6;
7883                                                    break;
7884                                                case OPS.curveTo2:
7885                                                    ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
7886                                                    x = args[j + 2];
7887                                                    y = args[j + 3];
7888                                                    j += 4;
7889                                                    break;
7890                                                case OPS.curveTo3:
7891                                                    x = args[j + 2];
7892                                                    y = args[j + 3];
7893                                                    ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
7894                                                    j += 4;
7895                                                    break;
7896                                                case OPS.closePath:
7897                                                    ctx.closePath();
7898                                                    break;
7899                                            }
7900                                        }
7901                                        current.setCurrentPoint(x, y);
7902                                    },
7903                                    closePath: function CanvasGraphics_closePath() {
7904                                        this.ctx.closePath();
7905                                    },
7906                                    stroke: function CanvasGraphics_stroke(consumePath) {
7907                                        consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
7908                                        var ctx = this.ctx;
7909                                        var strokeColor = this.current.strokeColor;
7910                                        ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
7911                                        ctx.globalAlpha = this.current.strokeAlpha;
7912                                        if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
7913                                            ctx.save();
7914                                            ctx.strokeStyle = strokeColor.getPattern(ctx, this);
7915                                            ctx.stroke();
7916                                            ctx.restore();
7917                                        } else {
7918                                            ctx.stroke();
7919                                        }
7920                                        if (consumePath) {
7921                                            this.consumePath();
7922                                        }
7923                                        ctx.globalAlpha = this.current.fillAlpha;
7924                                    },
7925                                    closeStroke: function CanvasGraphics_closeStroke() {
7926                                        this.closePath();
7927                                        this.stroke();
7928                                    },
7929                                    fill: function CanvasGraphics_fill(consumePath) {
7930                                        consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
7931                                        var ctx = this.ctx;
7932                                        var fillColor = this.current.fillColor;
7933                                        var isPatternFill = this.current.patternFill;
7934                                        var needRestore = false;
7935                                        if (isPatternFill) {
7936                                            ctx.save();
7937                                            if (this.baseTransform) {
7938                                                ctx.setTransform.apply(ctx, this.baseTransform);
7939                                            }
7940                                            ctx.fillStyle = fillColor.getPattern(ctx, this);
7941                                            needRestore = true;
7942                                        }
7943                                        if (this.pendingEOFill) {
7944                                            ctx.fill('evenodd');
7945                                            this.pendingEOFill = false;
7946                                        } else {
7947                                            ctx.fill();
7948                                        }
7949                                        if (needRestore) {
7950                                            ctx.restore();
7951                                        }
7952                                        if (consumePath) {
7953                                            this.consumePath();
7954                                        }
7955                                    },
7956                                    eoFill: function CanvasGraphics_eoFill() {
7957                                        this.pendingEOFill = true;
7958                                        this.fill();
7959                                    },
7960                                    fillStroke: function CanvasGraphics_fillStroke() {
7961                                        this.fill(false);
7962                                        this.stroke(false);
7963                                        this.consumePath();
7964                                    },
7965                                    eoFillStroke: function CanvasGraphics_eoFillStroke() {
7966                                        this.pendingEOFill = true;
7967                                        this.fillStroke();
7968                                    },
7969                                    closeFillStroke: function CanvasGraphics_closeFillStroke() {
7970                                        this.closePath();
7971                                        this.fillStroke();
7972                                    },
7973                                    closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
7974                                        this.pendingEOFill = true;
7975                                        this.closePath();
7976                                        this.fillStroke();
7977                                    },
7978                                    endPath: function CanvasGraphics_endPath() {
7979                                        this.consumePath();
7980                                    },
7981                                    clip: function CanvasGraphics_clip() {
7982                                        this.pendingClip = NORMAL_CLIP;
7983                                    },
7984                                    eoClip: function CanvasGraphics_eoClip() {
7985                                        this.pendingClip = EO_CLIP;
7986                                    },
7987                                    beginText: function CanvasGraphics_beginText() {
7988                                        this.current.textMatrix = IDENTITY_MATRIX;
7989                                        this.current.textMatrixScale = 1;
7990                                        this.current.x = this.current.lineX = 0;
7991                                        this.current.y = this.current.lineY = 0;
7992                                    },
7993                                    endText: function CanvasGraphics_endText() {
7994                                        var paths = this.pendingTextPaths;
7995                                        var ctx = this.ctx;
7996                                        if (paths === undefined) {
7997                                            ctx.beginPath();
7998                                            return;
7999                                        }
8000                                        ctx.save();
8001                                        ctx.beginPath();
8002                                        for (var i = 0; i < paths.length; i++) {
8003                                            var path = paths[i];
8004                                            ctx.setTransform.apply(ctx, path.transform);
8005                                            ctx.translate(path.x, path.y);
8006                                            path.addToPath(ctx, path.fontSize);
8007                                        }
8008                                        ctx.restore();
8009                                        ctx.clip();
8010                                        ctx.beginPath();
8011                                        delete this.pendingTextPaths;
8012                                    },
8013                                    setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
8014                                        this.current.charSpacing = spacing;
8015                                    },
8016                                    setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
8017                                        this.current.wordSpacing = spacing;
8018                                    },
8019                                    setHScale: function CanvasGraphics_setHScale(scale) {
8020                                        this.current.textHScale = scale / 100;
8021                                    },
8022                                    setLeading: function CanvasGraphics_setLeading(leading) {
8023                                        this.current.leading = -leading;
8024                                    },
8025                                    setFont: function CanvasGraphics_setFont(fontRefName, size) {
8026                                        var fontObj = this.commonObjs.get(fontRefName);
8027                                        var current = this.current;
8028                                        if (!fontObj) {
8029                                            error('Can\'t find font for ' + fontRefName);
8030                                        }
8031                                        current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
8032                                        if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
8033                                            warn('Invalid font matrix for font ' + fontRefName);
8034                                        }
8035                                        if (size < 0) {
8036                                            size = -size;
8037                                            current.fontDirection = -1;
8038                                        } else {
8039                                            current.fontDirection = 1;
8040                                        }
8041                                        this.current.font = fontObj;
8042                                        this.current.fontSize = size;
8043                                        if (fontObj.isType3Font) {
8044                                            return;
8045                                        }
8046                                        var name = fontObj.loadedName || 'sans-serif';
8047                                        var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
8048                                        var italic = fontObj.italic ? 'italic' : 'normal';
8049                                        var typeface = '"' + name + '", ' + fontObj.fallbackName;
8050                                        var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
8051                                        this.current.fontSizeScale = size / browserFontSize;
8052                                        var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
8053                                        this.ctx.font = rule;
8054                                    },
8055                                    setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
8056                                        this.current.textRenderingMode = mode;
8057                                    },
8058                                    setTextRise: function CanvasGraphics_setTextRise(rise) {
8059                                        this.current.textRise = rise;
8060                                    },
8061                                    moveText: function CanvasGraphics_moveText(x, y) {
8062                                        this.current.x = this.current.lineX += x;
8063                                        this.current.y = this.current.lineY += y;
8064                                    },
8065                                    setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
8066                                        this.setLeading(-y);
8067                                        this.moveText(x, y);
8068                                    },
8069                                    setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
8070                                        this.current.textMatrix = [
8071                                            a,
8072                                            b,
8073                                            c,
8074                                            d,
8075                                            e,
8076                                            f
8077                                        ];
8078                                        this.current.textMatrixScale = Math.sqrt(a * a + b * b);
8079                                        this.current.x = this.current.lineX = 0;
8080                                        this.current.y = this.current.lineY = 0;
8081                                    },
8082                                    nextLine: function CanvasGraphics_nextLine() {
8083                                        this.moveText(0, this.current.leading);
8084                                    },
8085                                    paintChar: function CanvasGraphics_paintChar(character, x, y) {
8086                                        var ctx = this.ctx;
8087                                        var current = this.current;
8088                                        var font = current.font;
8089                                        var textRenderingMode = current.textRenderingMode;
8090                                        var fontSize = current.fontSize / current.fontSizeScale;
8091                                        var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
8092                                        var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
8093                                        var addToPath;
8094                                        if (font.disableFontFace || isAddToPathSet) {
8095                                            addToPath = font.getPathGenerator(this.commonObjs, character);
8096                                        }
8097                                        if (font.disableFontFace) {
8098                                            ctx.save();
8099                                            ctx.translate(x, y);
8100                                            ctx.beginPath();
8101                                            addToPath(ctx, fontSize);
8102                                            if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8103                                                ctx.fill();
8104                                            }
8105                                            if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8106                                                ctx.stroke();
8107                                            }
8108                                            ctx.restore();
8109                                        } else {
8110                                            if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8111                                                ctx.fillText(character, x, y);
8112                                            }
8113                                            if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8114                                                ctx.strokeText(character, x, y);
8115                                            }
8116                                        }
8117                                        if (isAddToPathSet) {
8118                                            var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
8119                                            paths.push({
8120                                                transform: ctx.mozCurrentTransform,
8121                                                x: x,
8122                                                y: y,
8123                                                fontSize: fontSize,
8124                                                addToPath: addToPath
8125                                            });
8126                                        }
8127                                    },
8128                                    get isFontSubpixelAAEnabled() {
8129                                        var ctx = this.canvasFactory.create(10, 10).context;
8130                                        ctx.scale(1.5, 1);
8131                                        ctx.fillText('I', 0, 10);
8132                                        var data = ctx.getImageData(0, 0, 10, 10).data;
8133                                        var enabled = false;
8134                                        for (var i = 3; i < data.length; i += 4) {
8135                                            if (data[i] > 0 && data[i] < 255) {
8136                                                enabled = true;
8137                                                break;
8138                                            }
8139                                        }
8140                                        return shadow(this, 'isFontSubpixelAAEnabled', enabled);
8141                                    },
8142                                    showText: function CanvasGraphics_showText(glyphs) {
8143                                        var current = this.current;
8144                                        var font = current.font;
8145                                        if (font.isType3Font) {
8146                                            return this.showType3Text(glyphs);
8147                                        }
8148                                        var fontSize = current.fontSize;
8149                                        if (fontSize === 0) {
8150                                            return;
8151                                        }
8152                                        var ctx = this.ctx;
8153                                        var fontSizeScale = current.fontSizeScale;
8154                                        var charSpacing = current.charSpacing;
8155                                        var wordSpacing = current.wordSpacing;
8156                                        var fontDirection = current.fontDirection;
8157                                        var textHScale = current.textHScale * fontDirection;
8158                                        var glyphsLength = glyphs.length;
8159                                        var vertical = font.vertical;
8160                                        var spacingDir = vertical ? 1 : -1;
8161                                        var defaultVMetrics = font.defaultVMetrics;
8162                                        var widthAdvanceScale = fontSize * current.fontMatrix[0];
8163                                        var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
8164                                        ctx.save();
8165                                        ctx.transform.apply(ctx, current.textMatrix);
8166                                        ctx.translate(current.x, current.y + current.textRise);
8167                                        if (current.patternFill) {
8168                                            ctx.fillStyle = current.fillColor.getPattern(ctx, this);
8169                                        }
8170                                        if (fontDirection > 0) {
8171                                            ctx.scale(textHScale, -1);
8172                                        } else {
8173                                            ctx.scale(textHScale, 1);
8174                                        }
8175                                        var lineWidth = current.lineWidth;
8176                                        var scale = current.textMatrixScale;
8177                                        if (scale === 0 || lineWidth === 0) {
8178                                            var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
8179                                            if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8180                                                this.cachedGetSinglePixelWidth = null;
8181                                                lineWidth = this.get
vendor: 4,732 bytes, lines 8181-8243
8181SinglePixelWidth() * MIN_WIDTH_FACTOR;
8182                                            }
8183                                        } else {
8184                                            lineWidth /= scale;
8185                                        }
8186                                        if (fontSizeScale !== 1.0) {
8187                                            ctx.scale(fontSizeScale, fontSizeScale);
8188                                            lineWidth /= fontSizeScale;
8189                                        }
8190                                        ctx.lineWidth = lineWidth;
8191                                        var x = 0, i;
8192                                        for (i = 0; i < glyphsLength; ++i) {
8193                                            var glyph = glyphs[i];
8194                                            if (isNum(glyph)) {
8195                                                x += spacingDir * glyph * fontSize / 1000;
8196                                                continue;
8197                                            }
8198                                            var restoreNeeded = false;
8199                                            var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
8200                                            var character = glyph.fontChar;
8201                                            var accent = glyph.accent;
8202                                            var scaledX, scaledY, scaledAccentX, scaledAccentY;
8203                                            var width = glyph.width;
8204                                            if (vertical) {
8205                                                var vmetric, vx, vy;
8206                                                vmetric = glyph.vmetric || defaultVMetrics;
8207                                                vx = glyph.vmetric ? vmetric[1] : width * 0.5;
8208                                                vx = -vx * widthAdvanceScale;
8209                                                vy = vmetric[2] * widthAdvanceScale;
8210                                                width = vmetric ? -vmetric[0] : width;
8211                                                scaledX = vx / fontSizeScale;
8212                                                scaledY = (x + vy) / fontSizeScale;
8213                                            } else {
8214                                                scaledX = x / fontSizeScale;
8215                                                scaledY = 0;
8216                                            }
8217                                            if (font.remeasure && width > 0) {
8218                                                var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
8219                                                if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
8220                                                    var characterScaleX = width / measuredWidth;
8221                                                    restoreNeeded = true;
8222                                                    ctx.save();
8223                                                    ctx.scale(characterScaleX, 1);
8224                                                    scaledX /= characterScaleX;
8225                                                } else if (width !== measuredWidth) {
8226                                                    scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
8227                                                }
8228                                            }
8229                                            if (glyph.isInFont || font.missingFile) {
8230                                                if (simpleFillText && !accent) {
8231                                                    ctx.fillText(character, scaledX, scaledY);
8232                                                } else {
8233                                                    this.paintChar(character, scaledX, scaledY);
8234                                                    if (accent) {
8235                                                        scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
8236                                                        scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
8237                                                        this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
8238                                                    }
8239                                                }
8240                                            }
8241                                            var charWidth = width * widthAdvanceScale + spacing * fontDirection;
8242                                            x += charWidth;
8243                                            if (restoreNeeded) {
vendor: 38,704 bytes, lines 8244-8786
8244                                                ctx.restore();
8245                                            }
8246                                        }
8247                                        if (vertical) {
8248                                            current.y -= x * textHScale;
8249                                        } else {
8250                                            current.x += x * textHScale;
8251                                        }
8252                                        ctx.restore();
8253                                    },
8254                                    showType3Text: function CanvasGraphics_showType3Text(glyphs) {
8255                                        var ctx = this.ctx;
8256                                        var current = this.current;
8257                                        var font = current.font;
8258                                        var fontSize = current.fontSize;
8259                                        var fontDirection = current.fontDirection;
8260                                        var spacingDir = font.vertical ? 1 : -1;
8261                                        var charSpacing = current.charSpacing;
8262                                        var wordSpacing = current.wordSpacing;
8263                                        var textHScale = current.textHScale * fontDirection;
8264                                        var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
8265                                        var glyphsLength = glyphs.length;
8266                                        var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
8267                                        var i, glyph, width, spacingLength;
8268                                        if (isTextInvisible || fontSize === 0) {
8269                                            return;
8270                                        }
8271                                        this.cachedGetSinglePixelWidth = null;
8272                                        ctx.save();
8273                                        ctx.transform.apply(ctx, current.textMatrix);
8274                                        ctx.translate(current.x, current.y);
8275                                        ctx.scale(textHScale, fontDirection);
8276                                        for (i = 0; i < glyphsLength; ++i) {
8277                                            glyph = glyphs[i];
8278                                            if (isNum(glyph)) {
8279                                                spacingLength = spacingDir * glyph * fontSize / 1000;
8280                                                this.ctx.translate(spacingLength, 0);
8281                                                current.x += spacingLength * textHScale;
8282                                                continue;
8283                                            }
8284                                            var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
8285                                            var operatorList = font.charProcOperatorList[glyph.operatorListId];
8286                                            if (!operatorList) {
8287                                                warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
8288                                                continue;
8289                                            }
8290                                            this.processingType3 = glyph;
8291                                            this.save();
8292                                            ctx.scale(fontSize, fontSize);
8293                                            ctx.transform.apply(ctx, fontMatrix);
8294                                            this.executeOperatorList(operatorList);
8295                                            this.restore();
8296                                            var transformed = Util.applyTransform([
8297                                                glyph.width,
8298                                                0
8299                                            ], fontMatrix);
8300                                            width = transformed[0] * fontSize + spacing;
8301                                            ctx.translate(width, 0);
8302                                            current.x += width * textHScale;
8303                                        }
8304                                        ctx.restore();
8305                                        this.processingType3 = null;
8306                                    },
8307                                    setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
8308                                    },
8309                                    setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
8310                                        this.ctx.rect(llx, lly, urx - llx, ury - lly);
8311                                        this.clip();
8312                                        this.endPath();
8313                                    },
8314                                    getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
8315                                        var pattern;
8316                                        if (IR[0] === 'TilingPattern') {
8317                                            var color = IR[1];
8318                                            var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
8319                                            var self = this;
8320                                            var canvasGraphicsFactory = {
8321                                                createCanvasGraphics: function (ctx) {
8322                                                    return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
8323                                                }
8324                                            };
8325                                            pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
8326                                        } else {
8327                                            pattern = getShadingPatternFromIR(IR);
8328                                        }
8329                                        return pattern;
8330                                    },
8331                                    setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
8332                                        this.current.strokeColor = this.getColorN_Pattern(arguments);
8333                                    },
8334                                    setFillColorN: function CanvasGraphics_setFillColorN() {
8335                                        this.current.fillColor = this.getColorN_Pattern(arguments);
8336                                        this.current.patternFill = true;
8337                                    },
8338                                    setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
8339                                        var color = Util.makeCssRgb(r, g, b);
8340                                        this.ctx.strokeStyle = color;
8341                                        this.current.strokeColor = color;
8342                                    },
8343                                    setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
8344                                        var color = Util.makeCssRgb(r, g, b);
8345                                        this.ctx.fillStyle = color;
8346                                        this.current.fillColor = color;
8347                                        this.current.patternFill = false;
8348                                    },
8349                                    shadingFill: function CanvasGraphics_shadingFill(patternIR) {
8350                                        var ctx = this.ctx;
8351                                        this.save();
8352                                        var pattern = getShadingPatternFromIR(patternIR);
8353                                        ctx.fillStyle = pattern.getPattern(ctx, this, true);
8354                                        var inv = ctx.mozCurrentTransformInverse;
8355                                        if (inv) {
8356                                            var canvas = ctx.canvas;
8357                                            var width = canvas.width;
8358                                            var height = canvas.height;
8359                                            var bl = Util.applyTransform([
8360                                                0,
8361                                                0
8362                                            ], inv);
8363                                            var br = Util.applyTransform([
8364                                                0,
8365                                                height
8366                                            ], inv);
8367                                            var ul = Util.applyTransform([
8368                                                width,
8369                                                0
8370                                            ], inv);
8371                                            var ur = Util.applyTransform([
8372                                                width,
8373                                                height
8374                                            ], inv);
8375                                            var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
8376                                            var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
8377                                            var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
8378                                            var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
8379                                            this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
8380                                        } else {
8381                                            this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
8382                                        }
8383                                        this.restore();
8384                                    },
8385                                    beginInlineImage: function CanvasGraphics_beginInlineImage() {
8386                                        error('Should not call beginInlineImage');
8387                                    },
8388                                    beginImageData: function CanvasGraphics_beginImageData() {
8389                                        error('Should not call beginImageData');
8390                                    },
8391                                    paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
8392                                        this.save();
8393                                        this.baseTransformStack.push(this.baseTransform);
8394                                        if (isArray(matrix) && matrix.length === 6) {
8395                                            this.transform.apply(this, matrix);
8396                                        }
8397                                        this.baseTransform = this.ctx.mozCurrentTransform;
8398                                        if (isArray(bbox) && bbox.length === 4) {
8399                                            var width = bbox[2] - bbox[0];
8400                                            var height = bbox[3] - bbox[1];
8401                                            this.ctx.rect(bbox[0], bbox[1], width, height);
8402                                            this.clip();
8403                                            this.endPath();
8404                                        }
8405                                    },
8406                                    paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
8407                                        this.restore();
8408                                        this.baseTransform = this.baseTransformStack.pop();
8409                                    },
8410                                    beginGroup: function CanvasGraphics_beginGroup(group) {
8411                                        this.save();
8412                                        var currentCtx = this.ctx;
8413                                        if (!group.isolated) {
8414                                            info('TODO: Support non-isolated groups.');
8415                                        }
8416                                        if (group.knockout) {
8417                                            warn('Knockout groups not supported.');
8418                                        }
8419                                        var currentTransform = currentCtx.mozCurrentTransform;
8420                                        if (group.matrix) {
8421                                            currentCtx.transform.apply(currentCtx, group.matrix);
8422                                        }
8423                                        assert(group.bbox, 'Bounding box is required.');
8424                                        var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
8425                                        var canvasBounds = [
8426                                            0,
8427                                            0,
8428                                            currentCtx.canvas.width,
8429                                            currentCtx.canvas.height
8430                                        ];
8431                                        bounds = Util.intersect(bounds, canvasBounds) || [
8432                                            0,
8433                                            0,
8434                                            0,
8435                                            0
8436                                        ];
8437                                        var offsetX = Math.floor(bounds[0]);
8438                                        var offsetY = Math.floor(bounds[1]);
8439                                        var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
8440                                        var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
8441                                        var scaleX = 1, scaleY = 1;
8442                                        if (drawnWidth > MAX_GROUP_SIZE) {
8443                                            scaleX = drawnWidth / MAX_GROUP_SIZE;
8444                                            drawnWidth = MAX_GROUP_SIZE;
8445                                        }
8446                                        if (drawnHeight > MAX_GROUP_SIZE) {
8447                                            scaleY = drawnHeight / MAX_GROUP_SIZE;
8448                                            drawnHeight = MAX_GROUP_SIZE;
8449                                        }
8450                                        var cacheId = 'groupAt' + this.groupLevel;
8451                                        if (group.smask) {
8452                                            cacheId += '_smask_' + this.smaskCounter++ % 2;
8453                                        }
8454                                        var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
8455                                        var groupCtx = scratchCanvas.context;
8456                                        groupCtx.scale(1 / scaleX, 1 / scaleY);
8457                                        groupCtx.translate(-offsetX, -offsetY);
8458                                        groupCtx.transform.apply(groupCtx, currentTransform);
8459                                        if (group.smask) {
8460                                            this.smaskStack.push({
8461                                                canvas: scratchCanvas.canvas,
8462                                                context: groupCtx,
8463                                                offsetX: offsetX,
8464                                                offsetY: offsetY,
8465                                                scaleX: scaleX,
8466                                                scaleY: scaleY,
8467                                                subtype: group.smask.subtype,
8468                                                backdrop: group.smask.backdrop,
8469                                                transferMap: group.smask.transferMap || null,
8470                                                startTransformInverse: null
8471                                            });
8472                                        } else {
8473                                            currentCtx.setTransform(1, 0, 0, 1, 0, 0);
8474                                            currentCtx.translate(offsetX, offsetY);
8475                                            currentCtx.scale(scaleX, scaleY);
8476                                        }
8477                                        copyCtxState(currentCtx, groupCtx);
8478                                        this.ctx = groupCtx;
8479                                        this.setGState([
8480                                            [
8481                                                'BM',
8482                                                'Normal'
8483                                            ],
8484                                            [
8485                                                'ca',
8486                                                1
8487                                            ],
8488                                            [
8489                                                'CA',
8490                                                1
8491                                            ]
8492                                        ]);
8493                                        this.groupStack.push(currentCtx);
8494                                        this.groupLevel++;
8495                                        this.current.activeSMask = null;
8496                                    },
8497                                    endGroup: function CanvasGraphics_endGroup(group) {
8498                                        this.groupLevel--;
8499                                        var groupCtx = this.ctx;
8500                                        this.ctx = this.groupStack.pop();
8501                                        if (this.ctx.imageSmoothingEnabled !== undefined) {
8502                                            this.ctx.imageSmoothingEnabled = false;
8503                                        } else {
8504                                            this.ctx.mozImageSmoothingEnabled = false;
8505                                        }
8506                                        if (group.smask) {
8507                                            this.tempSMask = this.smaskStack.pop();
8508                                        } else {
8509                                            this.ctx.drawImage(groupCtx.canvas, 0, 0);
8510                                        }
8511                                        this.restore();
8512                                    },
8513                                    beginAnnotations: function CanvasGraphics_beginAnnotations() {
8514                                        this.save();
8515                                        this.current = new CanvasExtraState();
8516                                        if (this.baseTransform) {
8517                                            this.ctx.setTransform.apply(this.ctx, this.baseTransform);
8518                                        }
8519                                    },
8520                                    endAnnotations: function CanvasGraphics_endAnnotations() {
8521                                        this.restore();
8522                                    },
8523                                    beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
8524                                        this.save();
8525                                        if (isArray(rect) && rect.length === 4) {
8526                                            var width = rect[2] - rect[0];
8527                                            var height = rect[3] - rect[1];
8528                                            this.ctx.rect(rect[0], rect[1], width, height);
8529                                            this.clip();
8530                                            this.endPath();
8531                                        }
8532                                        this.transform.apply(this, transform);
8533                                        this.transform.apply(this, matrix);
8534                                    },
8535                                    endAnnotation: function CanvasGraphics_endAnnotation() {
8536                                        this.restore();
8537                                    },
8538                                    paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
8539                                        var domImage = this.objs.get(objId);
8540                                        if (!domImage) {
8541                                            warn('Dependent image isn\'t ready yet');
8542                                            return;
8543                                        }
8544                                        this.save();
8545                                        var ctx = this.ctx;
8546                                        ctx.scale(1 / w, -1 / h);
8547                                        ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
8548                                        if (this.imageLayer) {
8549                                            var currentTransform = ctx.mozCurrentTransformInverse;
8550                                            var position = this.getCanvasPosition(0, 0);
8551                                            this.imageLayer.appendImage({
8552                                                objId: objId,
8553                                                left: position[0],
8554                                                top: position[1],
8555                                                width: w / currentTransform[0],
8556                                                height: h / currentTransform[3]
8557                                            });
8558                                        }
8559                                        this.restore();
8560                                    },
8561                                    paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
8562                                        var ctx = this.ctx;
8563                                        var width = img.width, height = img.height;
8564                                        var fillColor = this.current.fillColor;
8565                                        var isPatternFill = this.current.patternFill;
8566                                        var glyph = this.processingType3;
8567                                        if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
8568                                            if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
8569                                                glyph.compiled = compileType3Glyph({
8570                                                    data: img.data,
8571                                                    width: width,
8572                                                    height: height
8573                                                });
8574                                            } else {
8575                                                glyph.compiled = null;
8576                                            }
8577                                        }
8578                                        if (glyph && glyph.compiled) {
8579                                            glyph.compiled(ctx);
8580                                            return;
8581                                        }
8582                                        var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
8583                                        var maskCtx = maskCanvas.context;
8584                                        maskCtx.save();
8585                                        putBinaryImageMask(maskCtx, img);
8586                                        maskCtx.globalCompositeOperation = 'source-in';
8587                                        maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
8588                                        maskCtx.fillRect(0, 0, width, height);
8589                                        maskCtx.restore();
8590                                        this.paintInlineImageXObject(maskCanvas.canvas);
8591                                    },
8592                                    paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
8593                                        var width = imgData.width;
8594                                        var height = imgData.height;
8595                                        var fillColor = this.current.fillColor;
8596                                        var isPatternFill = this.current.patternFill;
8597                                        var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
8598                                        var maskCtx = maskCanvas.context;
8599                                        maskCtx.save();
8600                                        putBinaryImageMask(maskCtx, imgData);
8601                                        maskCtx.globalCompositeOperation = 'source-in';
8602                                        maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
8603                                        maskCtx.fillRect(0, 0, width, height);
8604                                        maskCtx.restore();
8605                                        var ctx = this.ctx;
8606                                        for (var i = 0, ii = positions.length; i < ii; i += 2) {
8607                                            ctx.save();
8608                                            ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
8609                                            ctx.scale(1, -1);
8610                                            ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
8611                                            ctx.restore();
8612                                        }
8613                                    },
8614                                    paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
8615                                        var ctx = this.ctx;
8616                                        var fillColor = this.current.fillColor;
8617                                        var isPatternFill = this.current.patternFill;
8618                                        for (var i = 0, ii = images.length; i < ii; i++) {
8619                                            var image = images[i];
8620                                            var width = image.width, height = image.height;
8621                                            var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
8622                                            var maskCtx = maskCanvas.context;
8623                                            maskCtx.save();
8624                                            putBinaryImageMask(maskCtx, image);
8625                                            maskCtx.globalCompositeOperation = 'source-in';
8626                                            maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
8627                                            maskCtx.fillRect(0, 0, width, height);
8628                                            maskCtx.restore();
8629                                            ctx.save();
8630                                            ctx.transform.apply(ctx, image.transform);
8631                                            ctx.scale(1, -1);
8632                                            ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
8633                                            ctx.restore();
8634                                        }
8635                                    },
8636                                    paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
8637                                        var imgData = this.objs.get(objId);
8638                                        if (!imgData) {
8639                                            warn('Dependent image isn\'t ready yet');
8640                                            return;
8641                                        }
8642                                        this.paintInlineImageXObject(imgData);
8643                                    },
8644                                    paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
8645                                        var imgData = this.objs.get(objId);
8646                                        if (!imgData) {
8647                                            warn('Dependent image isn\'t ready yet');
8648                                            return;
8649                                        }
8650                                        var width = imgData.width;
8651                                        var height = imgData.height;
8652                                        var map = [];
8653                                        for (var i = 0, ii = positions.length; i < ii; i += 2) {
8654                                            map.push({
8655                                                transform: [
8656                                                    scaleX,
8657                                                    0,
8658                                                    0,
8659                                                    scaleY,
8660                                                    positions[i],
8661                                                    positions[i + 1]
8662                                                ],
8663                                                x: 0,
8664                                                y: 0,
8665                                                w: width,
8666                                                h: height
8667                                            });
8668                                        }
8669                                        this.paintInlineImageXObjectGroup(imgData, map);
8670                                    },
8671                                    paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
8672                                        var width = imgData.width;
8673                                        var height = imgData.height;
8674                                        var ctx = this.ctx;
8675                                        this.save();
8676                                        ctx.scale(1 / width, -1 / height);
8677                                        var currentTransform = ctx.mozCurrentTransformInverse;
8678                                        var a = currentTransform[0], b = currentTransform[1];
8679                                        var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
8680                                        var c = currentTransform[2], d = currentTransform[3];
8681                                        var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
8682                                        var imgToPaint, tmpCanvas;
8683                                        if (imgData instanceof HTMLElement || !imgData.data) {
8684                                            imgToPaint = imgData;
8685                                        } else {
8686                                            tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
8687                                            var tmpCtx = tmpCanvas.context;
8688                                            putBinaryImageData(tmpCtx, imgData);
8689                                            imgToPaint = tmpCanvas.canvas;
8690                                        }
8691                                        var paintWidth = width, paintHeight = height;
8692                                        var tmpCanvasId = 'prescale1';
8693                                        while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
8694                                            var newWidth = paintWidth, newHeight = paintHeight;
8695                                            if (widthScale > 2 && paintWidth > 1) {
8696                                                newWidth = Math.ceil(paintWidth / 2);
8697                                                widthScale /= paintWidth / newWidth;
8698                                            }
8699                                            if (heightScale > 2 && paintHeight > 1) {
8700                                                newHeight = Math.ceil(paintHeight / 2);
8701                                                heightScale /= paintHeight / newHeight;
8702                                            }
8703                                            tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
8704                                            tmpCtx = tmpCanvas.context;
8705                                            tmpCtx.clearRect(0, 0, newWidth, newHeight);
8706                                            tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
8707                                            imgToPaint = tmpCanvas.canvas;
8708                                            paintWidth = newWidth;
8709                                            paintHeight = newHeight;
8710                                            tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
8711                                        }
8712                                        ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
8713                                        if (this.imageLayer) {
8714                                            var position = this.getCanvasPosition(0, -height);
8715                                            this.imageLayer.appendImage({
8716                                                imgData: imgData,
8717                                                left: position[0],
8718                                                top: position[1],
8719                                                width: width / currentTransform[0],
8720                                                height: height / currentTransform[3]
8721                                            });
8722                                        }
8723                                        this.restore();
8724                                    },
8725                                    paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
8726                                        var ctx = this.ctx;
8727                                        var w = imgData.width;
8728                                        var h = imgData.height;
8729                                        var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
8730                                        var tmpCtx = tmpCanvas.context;
8731                                        putBinaryImageData(tmpCtx, imgData);
8732                                        for (var i = 0, ii = map.length; i < ii; i++) {
8733                                            var entry = map[i];
8734                                            ctx.save();
8735                                            ctx.transform.apply(ctx, entry.transform);
8736                                            ctx.scale(1, -1);
8737                                            ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
8738                                            if (this.imageLayer) {
8739                                                var position = this.getCanvasPosition(entry.x, entry.y);
8740                                                this.imageLayer.appendImage({
8741                                                    imgData: imgData,
8742                                                    left: position[0],
8743                                                    top: position[1],
8744                                                    width: w,
8745                                                    height: h
8746                                                });
8747                                            }
8748                                            ctx.restore();
8749                                        }
8750                                    },
8751                                    paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
8752                                        this.ctx.fillRect(0, 0, 1, 1);
8753                                    },
8754                                    paintXObject: function CanvasGraphics_paintXObject() {
8755                                        warn('Unsupported \'paintXObject\' command.');
8756                                    },
8757                                    markPoint: function CanvasGraphics_markPoint(tag) {
8758                                    },
8759                                    markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
8760                                    },
8761                                    beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
8762                                    },
8763                                    beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
8764                                    },
8765                                    endMarkedContent: function CanvasGraphics_endMarkedContent() {
8766                                    },
8767                                    beginCompat: function CanvasGraphics_beginCompat() {
8768                                    },
8769                                    endCompat: function CanvasGraphics_endCompat() {
8770                                    },
8771                                    consumePath: function CanvasGraphics_consumePath() {
8772                                        var ctx = this.ctx;
8773                                        if (this.pendingClip) {
8774                                            if (this.pendingClip === EO_CLIP) {
8775                                                ctx.clip('evenodd');
8776                                            } else {
8777                                                ctx.clip();
8778                                            }
8779                                            this.pendingClip = null;
8780                                        }
8781                                        ctx.beginPath();
8782                                    },
8783                                    getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
8784                                        if (this.cachedGetSinglePixelWidth === null) {
8785                                            this.ctx.save();
8786                                            var inverse = this.ctx.mozCurrentTransformInverse;
8787                                            this.ctx.restore();
8788                                            this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
8789                                        }
8790                                        return this.cachedGetSinglePixelWidth;
8791                                    },
8792                                    getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
8793                                        var transform = this.ctx.mozCurrentTransform;
8794                                        return [
8795                                            transform[0] * x + transform[2] * y + transform[4],
8796                                            transform[1] * x + transform[3] * y + transform[5]
8797                                        ];
8798                                    }
8799                                };
8800                                for (var op in OPS) {
8801                                    CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
8802                                }
8803                                return CanvasGraphics;
8804                            }();
8805                            exports.CanvasGraphics = CanvasGraphics;
8806
8807                            /***/ }),
8808                        /* 11 */
8809                        /***/ (function (module, exports, __w_pdfjs_require__) {
8810
8811                            "use strict";
8812
8813                            var sharedUtil = __w_pdfjs_require__(0);
8814                            var assert = sharedUtil.assert;
8815                            var bytesToString = sharedUtil.bytesToString;
8816                            var string32 = sharedUtil.string32;
8817                            var shadow = sharedUtil.shadow;
8818                            var warn = sharedUtil.warn;
8819                            function FontLoader(docId) {
8820                                this.docId = docId;
8821                                this.styleElement = null;
8822                                this.nativeFontFaces = [];
8823                                this.loadTestFontId = 0;
8824                                this.loadingContext = {
8825                                    requests: [],
8826                                    nextRequestId: 0
8827                                };
8828                            }
8829                            FontLoader.prototype = {
8830                                insertRule: function fontLoaderInsertRule(rule) {
8831                                    var styleElement = this.styleElement;
8832                                    if (!styleElement) {
8833                                        styleElement = this.styleElement = document.createElement('style');
8834                                        styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
8835                                        document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
8836                                    }
8837                                    var styleSheet = styleElement.sheet;
8838                                    styleSheet.insertRule(rule, styleSheet.cssRules.length);
8839                                },
8840                                clear: function fontLoaderClear() {
8841                                    if (this.styleElement) {
8842                                        this.styleElement.remove();
8843                                        this.styleElement = null;
8844                                    }
8845                                    this.nativeFontFaces.forEach(function (nativeFontFace) {
8846                                        document.fonts.delete(nativeFontFace);
8847                                    });
8848                                    this.nativeFontFaces.length = 0;
8849                                }
8850                            };
8851                            var getLoadTestFont = function () {
8852                                return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
8853                            };
8854                            Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
8855                                get: function () {
8856                                    return shadow(this, 'loadTestFont', getLoadTestFont());
8857                                },
8858                                configurable: true
8859                            });
8860                            FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
8861                                this.nativeFontFaces.push(nativeFontFace);
8862                                document.fonts.add(nativeFontFace);
8863                            };
8864                            FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
8865                                var rules = [];
8866                                var fontsToLoad = [];
8867                                var fontLoadPromises = [];
8868                                var getNativeFontPromise = function (nativeFontFace) {
8869                                    return nativeFontFace.loaded.catch(function (e) {
8870                                        warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
8871                                    });
8872                                };
8873                                var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
8874                                for (var i = 0, ii = fonts.length; i < ii; i++) {
8875                                    var font = fonts[i];
8876                                    if (font.attached || font.loading === false) {
8877                                        continue;
8878                                    }
8879                                    font.attached = true;
8880                                    if (isFontLoadingAPISupported) {
8881                                        var nativeFontFace = font.createNativeFontFace();
8882                                        if (nativeFontFace) {
8883                                            this.addNativeFontFace(nativeFontFace);
8884                                            fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
8885                                        }
8886                                    } else {
8887                                        var rule = font.createFontFaceRule();
8888                                        if (rule) {
8889                                            this.insertRule(rule);
8890                                            rules.push(rule);
8891                                            fontsToLoad.push(font);
8892                                        }
8893                                    }
8894                                }
8895                                var request = this.queueLoadingCallback(callback);
8896                                if (isFontLoadingAPISupported) {
8897                                    Promise.all(fontLoadPromises).then(function () {
8898                                        request.complete();
8899                                    });
8900                                } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
8901                                    this.prepareFontLoadEvent(rules, fontsToLoad, request);
8902                                } else {
8903                                    request.complete();
8904                                }
8905                            };
8906                            FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
8907                                function LoadLoader_completeRequest() {
8908                                    assert(!request.end, 'completeRequest() cannot be called twice');
8909                                    request.end = Date.now();
8910                                    while (context.requests.length > 0 && context.requests[0].end) {
8911                                        var otherRequest = context.requests.shift();
8912                                        setTimeout(otherRequest.callback, 0);
8913                                    }
8914                                }
8915                                var context = this.loadingContext;
8916                                var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
8917                                var request = {
8918                                    id: requestId,
8919                                    complete: LoadLoader_completeRequest,
8920                                    callback: callback,
8921                                    started: Date.now()
8922                                };
8923                                context.requests.push(request);
8924                                return request;
8925                            };
8926                            FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
8927                                function int32(data, offset) {
8928                                    return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
vendor: 4,623 bytes, lines 8929-8998
8929                                }
8930                                function spliceString(s, offset, remove, insert) {
8931                                    var chunk1 = s.substr(0, offset);
8932                                    var chunk2 = s.substr(offset + remove);
8933                                    return chunk1 + insert + chunk2;
8934                                }
8935                                var i, ii;
8936                                var canvas = document.createElement('canvas');
8937                                canvas.width = 1;
8938                                canvas.height = 1;
8939                                var ctx = canvas.getContext('2d');
8940                                var called = 0;
8941                                function isFontReady(name, callback) {
8942                                    called++;
8943                                    if (called > 30) {
8944                                        warn('Load test font never loaded.');
8945                                        callback();
8946                                        return;
8947                                    }
8948                                    ctx.font = '30px ' + name;
8949                                    ctx.fillText('.', 0, 20);
8950                                    var imageData = ctx.getImageData(0, 0, 1, 1);
8951                                    if (imageData.data[3] > 0) {
8952                                        callback();
8953                                        return;
8954                                    }
8955                                    setTimeout(isFontReady.bind(null, name, callback));
8956                                }
8957                                var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
8958                                var data = this.loadTestFont;
8959                                var COMMENT_OFFSET = 976;
8960                                data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
8961                                var CFF_CHECKSUM_OFFSET = 16;
8962                                var XXXX_VALUE = 0x58585858;
8963                                var checksum = int32(data, CFF_CHECKSUM_OFFSET);
8964                                for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
8965                                    checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
8966                                }
8967                                if (i < loadTestFontId.length) {
8968                                    checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
8969                                }
8970                                data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
8971                                var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
8972                                var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
8973                                this.insertRule(rule);
8974                                var names = [];
8975                                for (i = 0, ii = fonts.length; i < ii; i++) {
8976                                    names.push(fonts[i].loadedName);
8977                                }
8978                                names.push(loadTestFontId);
8979                                var div = document.createElement('div');
8980                                div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
8981                                for (i = 0, ii = names.length; i < ii; ++i) {
8982                                    var span = document.createElement('span');
8983                                    span.textContent = 'Hi';
8984                                    span.style.fontFamily = names[i];
8985                                    div.appendChild(span);
8986                                }
8987                                document.body.appendChild(div);
8988                                isFontReady(loadTestFontId, function () {
8989                                    document.body.removeChild(div);
8990                                    request.complete();
8991                                });
8992                            };
8993                            FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
8994                            var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
8995                                if (typeof navigator === 'undefined') {
8996                                    return true;
8997                                }
8998                                var supported = false;
8999                                var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
9000                                if (m && m[1] >= 14) {
9001                                    supported = true;
9002                                }
9003                                return supported;
9004                            };
9005                            Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
9006                                get: function () {
9007                                    return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
9008                                },
9009                                enumerable: true,
9010                                configurable: true
9011                            });
9012                            var IsEvalSupportedCached = {
9013                                get value() {
9014                                    return shadow(this, 'value', sharedUtil.isEvalSupported());
9015                                }
9016                            };
9017                            var FontFaceObject = function FontFaceObjectClosure() {
9018                                function FontFaceObject(translatedData, options) {
9019                                    this.compiledGlyphs = Object.create(null);
9020                                    for (var i in translatedData) {
9021                                        this[i] = translatedData[i];
9022                                    }
9023                                    this.options = options;
9024                                }
9025                                FontFaceObject.prototype = {
9026                                    createNativeFontFace: function FontFaceObject_createNativeFontFace() {
9027                                        if (!this.data) {
9028                                            return null;
9029                                        }
9030                                        if (this.options.disableFontFace) {
9031                                            this.disableFontFace = true;
9032                                            return null;
9033                                        }
9034                                        var nativeFontFace = new FontFace(this.loadedName, this.data, {});
9035                                        if (this.options.fontRegistry) {
9036                                            this.options.fontRegistry.registerFont(this);
9037                                        }
9038                                        return nativeFontFace;
9039                                    },
9040                                    createFontFaceRule: function FontFaceObject_createFontFaceRule() {
9041                                        if (!this.data) {
9042                                            return null;
9043                                        }
9044                                        if (this.options.disableFontFace) {
9045                                            this.disableFontFace = true;
9046                                            return null;
9047                                        }
9048                                        var data = bytesToString(new Uint8Array(this.data));
9049                                        var fontName = this.loadedName;
9050                                        var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
9051                                        var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
9052                                        if (this.options.fontRegistry) {
9053                                            this.options.fontRegistry.registerFont(this, url);
9054                                        }
9055                                        return rule;
9056                                    },
9057                                    getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
9058                                        if (!(character in this.compiledGlyphs)) {
9059                                            var cmds = objs.get(this.loadedName + '_path_' + character);
9060                                            var current, i, len;
9061                                            if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
9062                                                var args, js = '';
9063                                                for (i = 0, len = cmds.length; i < len; i++) {
9064                                                    current = cmds[i];
9065                                                    if (current.args !== undefined) {
9066                                                        args = current.args.join(',');
9067                                                    } else {
9068                                                        args = '';
9069                                                    }
9070                                                    js += 'c.' + current.cmd + '(' + args + ');\n';
9071                                                }
9072                                                this.compiledGlyphs[character] = new Function('c', 'size', js);
9073                                            } else {
9074                                                this.compiledGlyphs[character] = function (c, size) {
9075                                                    for (i = 0, len = cmds.length; i < len; i++) {
9076                                                        current = cmds[i];
9077                                                        if (current.cmd === 'scale') {
9078                                                            current.args = [
9079                                                                size,
9080                                                                -size
9081                                                            ];
9082                                                        }
9083                                                        c[current.cmd].apply(c, current.args);
9084                                                    }
9085                                                };
9086                                            }
9087                                        }
9088                                        return this.compiledGlyphs[character];
9089                                    }
9090                                };
9091                                return FontFaceObject;
9092                            }();
9093                            exports.FontFaceObject = FontFaceObject;
9094                            exports.FontLoader = FontLoader;
9095
9096                            /***/ }),
9097                        /* 12 */
9098                        /***/ (function (module, exports, __w_pdfjs_require__) {
9099
9100                            "use strict";
9101
9102                            var sharedUtil = __w_pdfjs_require__(0);
9103                            var displayWebGL = __w_pdfjs_require__(8);
9104                            var Util = sharedUtil.Util;
9105                            var info = sharedUtil.info;
9106                            var isArray = sharedUtil.isArray;
9107                            var error = sharedUtil.error;
9108                            var WebGLUtils = displayWebGL.WebGLUtils;
9109                            var ShadingIRs = {};
9110                            ShadingIRs.RadialAxial = {
9111                                fromIR: function RadialAxial_fromIR(raw) {
9112                                    var type = raw[1];
9113                                    var colorStops = raw[2];
9114                                    var p0 = raw[3];
9115                                    var p1 = raw[4];
9116                                    var r0 = raw[5];
9117                                    var r1 = raw[6];
9118                                    return {
9119                                        type: 'Pattern',
9120                                        getPattern: function RadialAxial_getPattern(ctx) {
9121                                            var grad;
9122                                            if (type === 'axial') {
9123                                                grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
9124                                            } else if (type === 'radial') {
9125                                                grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
9126                                            }
9127                                            for (var i = 0, ii = colorStops.length; i < ii; ++i) {
9128                                                var c = colorStops[i];
9129                                                grad.addColorStop(c[0], c[
vendor: 23,807 bytes, lines 9129-9480
91291]);
9130                                            }
9131                                            return grad;
9132                                        }
9133                                    };
9134                                }
9135                            };
9136                            var createMeshCanvas = function createMeshCanvasClosure() {
9137                                function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
9138                                    var coords = context.coords, colors = context.colors;
9139                                    var bytes = data.data, rowSize = data.width * 4;
9140                                    var tmp;
9141                                    if (coords[p1 + 1] > coords[p2 + 1]) {
9142                                        tmp = p1;
9143                                        p1 = p2;
9144                                        p2 = tmp;
9145                                        tmp = c1;
9146                                        c1 = c2;
9147                                        c2 = tmp;
9148                                    }
9149                                    if (coords[p2 + 1] > coords[p3 + 1]) {
9150                                        tmp = p2;
9151                                        p2 = p3;
9152                                        p3 = tmp;
9153                                        tmp = c2;
9154                                        c2 = c3;
9155                                        c3 = tmp;
9156                                    }
9157                                    if (coords[p1 + 1] > coords[p2 + 1]) {
9158                                        tmp = p1;
9159                                        p1 = p2;
9160                                        p2 = tmp;
9161                                        tmp = c1;
9162                                        c1 = c2;
9163                                        c2 = tmp;
9164                                    }
9165                                    var x1 = (coords[p1] + context.offsetX) * context.scaleX;
9166                                    var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
9167                                    var x2 = (coords[p2] + context.offsetX) * context.scaleX;
9168                                    var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
9169                                    var x3 = (coords[p3] + context.offsetX) * context.scaleX;
9170                                    var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
9171                                    if (y1 >= y3) {
9172                                        return;
9173                                    }
9174                                    var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
9175                                    var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
9176                                    var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
9177                                    var minY = Math.round(y1), maxY = Math.round(y3);
9178                                    var xa, car, cag, cab;
9179                                    var xb, cbr, cbg, cbb;
9180                                    var k;
9181                                    for (var y = minY; y <= maxY; y++) {
9182                                        if (y < y2) {
9183                                            k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
9184                                            xa = x1 - (x1 - x2) * k;
9185                                            car = c1r - (c1r - c2r) * k;
9186                                            cag = c1g - (c1g - c2g) * k;
9187                                            cab = c1b - (c1b - c2b) * k;
9188                                        } else {
9189                                            k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
9190                                            xa = x2 - (x2 - x3) * k;
9191                                            car = c2r - (c2r - c3r) * k;
9192                                            cag = c2g - (c2g - c3g) * k;
9193                                            cab = c2b - (c2b - c3b) * k;
9194                                        }
9195                                        k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
9196                                        xb = x1 - (x1 - x3) * k;
9197                                        cbr = c1r - (c1r - c3r) * k;
9198                                        cbg = c1g - (c1g - c3g) * k;
9199                                        cbb = c1b - (c1b - c3b) * k;
9200                                        var x1_ = Math.round(Math.min(xa, xb));
9201                                        var x2_ = Math.round(Math.max(xa, xb));
9202                                        var j = rowSize * y + x1_ * 4;
9203                                        for (var x = x1_; x <= x2_; x++) {
9204                                            k = (xa - x) / (xa - xb);
9205                                            k = k < 0 ? 0 : k > 1 ? 1 : k;
9206                                            bytes[j++] = car - (car - cbr) * k | 0;
9207                                            bytes[j++] = cag - (cag - cbg) * k | 0;
9208                                            bytes[j++] = cab - (cab - cbb) * k | 0;
9209                                            bytes[j++] = 255;
9210                                        }
9211                                    }
9212                                }
9213                                function drawFigure(data, figure, context) {
9214                                    var ps = figure.coords;
9215                                    var cs = figure.colors;
9216                                    var i, ii;
9217                                    switch (figure.type) {
9218                                        case 'lattice':
9219                                            var verticesPerRow = figure.verticesPerRow;
9220                                            var rows = Math.floor(ps.length / verticesPerRow) - 1;
9221                                            var cols = verticesPerRow - 1;
9222                                            for (i = 0; i < rows; i++) {
9223                                                var q = i * verticesPerRow;
9224                                                for (var j = 0; j < cols; j++, q++) {
9225                                                    drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
9226                                                    drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
9227                                                }
9228                                            }
9229                                            break;
9230                                        case 'triangles':
9231                                            for (i = 0, ii = ps.length; i < ii; i += 3) {
9232                                                drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
9233                                            }
9234                                            break;
9235                                        default:
9236                                            error('illigal figure');
9237                                            break;
9238                                    }
9239                                }
9240                                function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
9241                                    var EXPECTED_SCALE = 1.1;
9242                                    var MAX_PATTERN_SIZE = 3000;
9243                                    var BORDER_SIZE = 2;
9244                                    var offsetX = Math.floor(bounds[0]);
9245                                    var offsetY = Math.floor(bounds[1]);
9246                                    var boundsWidth = Math.ceil(bounds[2]) - offsetX;
9247                                    var boundsHeight = Math.ceil(bounds[3]) - offsetY;
9248                                    var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
9249                                    var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
9250                                    var scaleX = boundsWidth / width;
9251                                    var scaleY = boundsHeight / height;
9252                                    var context = {
9253                                        coords: coords,
9254                                        colors: colors,
9255                                        offsetX: -offsetX,
9256                                        offsetY: -offsetY,
9257                                        scaleX: 1 / scaleX,
9258                                        scaleY: 1 / scaleY
9259                                    };
9260                                    var paddedWidth = width + BORDER_SIZE * 2;
9261                                    var paddedHeight = height + BORDER_SIZE * 2;
9262                                    var canvas, tmpCanvas, i, ii;
9263                                    if (WebGLUtils.isEnabled) {
9264                                        canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
9265                                        tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
9266                                        tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
9267                                        canvas = tmpCanvas.canvas;
9268                                    } else {
9269                                        tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
9270                                        var tmpCtx = tmpCanvas.context;
9271                                        var data = tmpCtx.createImageData(width, height);
9272                                        if (backgroundColor) {
9273                                            var bytes = data.data;
9274                                            for (i = 0, ii = bytes.length; i < ii; i += 4) {
9275                                                bytes[i] = backgroundColor[0];
9276                                                bytes[i + 1] = backgroundColor[1];
9277                                                bytes[i + 2] = backgroundColor[2];
9278                                                bytes[i + 3] = 255;
9279                                            }
9280                                        }
9281                                        for (i = 0; i < figures.length; i++) {
9282                                            drawFigure(data, figures[i], context);
9283                                        }
9284                                        tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
9285                                        canvas = tmpCanvas.canvas;
9286                                    }
9287                                    return {
9288                                        canvas: canvas,
9289                                        offsetX: offsetX - BORDER_SIZE * scaleX,
9290                                        offsetY: offsetY - BORDER_SIZE * scaleY,
9291                                        scaleX: scaleX,
9292                                        scaleY: scaleY
9293                                    };
9294                                }
9295                                return createMeshCanvas;
9296                            }();
9297                            ShadingIRs.Mesh = {
9298                                fromIR: function Mesh_fromIR(raw) {
9299                                    var coords = raw[2];
9300                                    var colors = raw[3];
9301                                    var figures = raw[4];
9302                                    var bounds = raw[5];
9303                                    var matrix = raw[6];
9304                                    var background = raw[8];
9305                                    return {
9306                                        type: 'Pattern',
9307                                        getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
9308                                            var scale;
9309                                            if (shadingFill) {
9310                                                scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
9311                                            } else {
9312                                                scale = Util.singularValueDecompose2dScale(owner.baseTransform);
9313                                                if (matrix) {
9314                                                    var matrixScale = Util.singularValueDecompose2dScale(matrix);
9315                                                    scale = [
9316                                                        scale[0] * matrixScale[0],
9317                                                        scale[1] * matrixScale[1]
9318                                                    ];
9319                                                }
9320                                            }
9321                                            var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
9322                                            if (!shadingFill) {
9323                                                ctx.setTransform.apply(ctx, owner.baseTransform);
9324                                                if (matrix) {
9325                                                    ctx.transform.apply(ctx, matrix);
9326                                                }
9327                                            }
9328                                            ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
9329                                            ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
9330                                            return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
9331                                        }
9332                                    };
9333                                }
9334                            };
9335                            ShadingIRs.Dummy = {
9336                                fromIR: function Dummy_fromIR() {
9337                                    return {
9338                                        type: 'Pattern',
9339                                        getPattern: function Dummy_fromIR_getPattern() {
9340                                            return 'hotpink';
9341                                        }
9342                                    };
9343                                }
9344                            };
9345                            function getShadingPatternFromIR(raw) {
9346                                var shadingIR = ShadingIRs[raw[0]];
9347                                if (!shadingIR) {
9348                                    error('Unknown IR type: ' + raw[0]);
9349                                }
9350                                return shadingIR.fromIR(raw);
9351                            }
9352                            var TilingPattern = function TilingPatternClosure() {
9353                                var PaintType = {
9354                                    COLORED: 1,
9355                                    UNCOLORED: 2
9356                                };
9357                                var MAX_PATTERN_SIZE = 3000;
9358                                function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
9359                                    this.operatorList = IR[2];
9360                                    this.matrix = IR[3] || [
9361                                        1,
9362                                        0,
9363                                        0,
9364                                        1,
9365                                        0,
9366                                        0
9367                                    ];
9368                                    this.bbox = IR[4];
9369                                    this.xstep = IR[5];
9370                                    this.ystep = IR[6];
9371                                    this.paintType = IR[7];
9372                                    this.tilingType = IR[8];
9373                                    this.color = color;
9374                                    this.canvasGraphicsFactory = canvasGraphicsFactory;
9375                                    this.baseTransform = baseTransform;
9376                                    this.type = 'Pattern';
9377                                    this.ctx = ctx;
9378                                }
9379                                TilingPattern.prototype = {
9380                                    createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
9381                                        var operatorList = this.operatorList;
9382                                        var bbox = this.bbox;
9383                                        var xstep = this.xstep;
9384                                        var ystep = this.ystep;
9385                                        var paintType = this.paintType;
9386                                        var tilingType = this.tilingType;
9387                                        var color = this.color;
9388                                        var canvasGraphicsFactory = this.canvasGraphicsFactory;
9389                                        info('TilingType: ' + tilingType);
9390                                        var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
9391                                        var topLeft = [
9392                                            x0,
9393                                            y0
9394                                        ];
9395                                        var botRight = [
9396                                            x0 + xstep,
9397                                            y0 + ystep
9398                                        ];
9399                                        var width = botRight[0] - topLeft[0];
9400                                        var height = botRight[1] - topLeft[1];
9401                                        var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
9402                                        var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
9403                                        var combinedScale = [
9404                                            matrixScale[0] * curMatrixScale[0],
9405                                            matrixScale[1] * curMatrixScale[1]
9406                                        ];
9407                                        width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
9408                                        height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
9409                                        var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
9410                                        var tmpCtx = tmpCanvas.context;
9411                                        var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
9412                                        graphics.groupLevel = owner.groupLevel;
9413                                        this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
9414                                        this.setScale(width, height, xstep, ystep);
9415                                        this.transformToScale(graphics);
9416                                        var tmpTranslate = [
9417                                            1,
9418                                            0,
9419                                            0,
9420                                            1,
9421                                            -topLeft[0],
9422                                            -topLeft[1]
9423                                        ];
9424                                        graphics.transform.apply(graphics, tmpTranslate);
9425                                        this.clipBbox(graphics, bbox, x0, y0, x1, y1);
9426                                        graphics.executeOperatorList(operatorList);
9427                                        return tmpCanvas.canvas;
9428                                    },
9429                                    setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
9430                                        this.scale = [
9431                                            width / xstep,
9432                                            height / ystep
9433                                        ];
9434                                    },
9435                                    transformToScale: function TilingPattern_transformToScale(graphics) {
9436                                        var scale = this.scale;
9437                                        var tmpScale = [
9438                                            scale[0],
9439                                            0,
9440                                            0,
9441                                            scale[1],
9442                                            0,
9443                                            0
9444                                        ];
9445                                        graphics.transform.apply(graphics, tmpScale);
9446                                    },
9447                                    scaleToContext: function TilingPattern_scaleToContext() {
9448                                        var scale = this.scale;
9449                                        this.ctx.scale(1 / scale[0], 1 / scale[1]);
9450                                    },
9451                                    clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
9452                                        if (bbox && isArray(bbox) && bbox.length === 4) {
9453                                            var bboxWidth = x1 - x0;
9454                                            var bboxHeight = y1 - y0;
9455                                            graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
9456                                            graphics.clip();
9457                                            graphics.endPath();
9458                                        }
9459                                    },
9460                                    setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
9461                                        switch (paintType) {
9462                                            case PaintType.COLORED:
9463                                                var ctx = this.ctx;
9464                                                context.fillStyle = ctx.fillStyle;
9465                                                context.strokeStyle = ctx.strokeStyle;
9466                                                break;
9467                                            case PaintType.UNCOLORED:
9468                                                var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
9469                                                context.fillStyle = cssColor;
9470                                                context.strokeStyle = cssColor;
9471                                                break;
9472                                            default:
9473                                                error('Unsupported paint type: ' + paintType);
9474                                        }
9475                                    },
9476                                    getPattern: function TilingPattern_getPattern(ctx, owner) {
9477                                        var temporaryPatternCanvas = this.createPatternCanvas(owner);
9478                                        ctx = this.ctx;
9479                                        ctx.setTransform.apply(ctx, this.baseTransform);
9480                                        ctx.transform.apply(ctx, this.matrix
9480);
9481                                        this.scaleToContext();
9482                                        return ctx.createPattern(temporaryPatternCanvas, 'repeat');
9483                                    }
9484                                };
9485                                return TilingPattern;
9486                            }();
9487                            exports.getShadingPatternFromIR = getShadingPatternFromIR;
9488                            exports.TilingPattern = TilingPattern;
9489
9490                            /***/ }),
9491                        /* 13 */
9492                        /***/ (function (module, exports, __w_pdfjs_require__) {
9493
9494                            "use strict";
9495                            /* WEBPACK VAR INJECTION */(function (global) {
9496                                if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
9497                                    var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
9498                                    var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
9499                                    var isAndroid = /Android/.test(userAgent);
9500                                    var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
9501                                    var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
9502                                    var isChrome = userAgent.indexOf('Chrom') >= 0;
9503                                    var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
9504                                    var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
9505                                    var isIE = userAgent.indexOf('Trident') >= 0;
9506                                    var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
9507                                    var isOpera = userAgent.indexOf('Opera') >= 0;
9508                                    var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
9509                                    var hasDOM = typeof window === 'object' && typeof document === 'object';
9510                                    if (typeof PDFJS === 'undefined') {
9511                                        globalScope.PDFJS = {};
9512                                    }
9513                                    PDFJS.compatibilityChecked = true;
9514                                    (function checkTypedArrayCompatibility() {
9515                                        if (typeof Uint8Array !== 'undefined') {
9516                                            if (typeof Uint8Array.prototype.subarray === 'undefined') {
9517                                                Uint8Array.prototype.subarray = function subarray(start, end) {
9518                                                    return new Uint8Array(this.slice(start, end));
9519                                                };
9520                                                Float32Array.prototype.subarray = function subarray(start, end) {
9521                                                    return new Float32Array(this.slice(start, end));
9522                                                };
9523                                            }
9524                                            if (typeof Float64Array === 'undefined') {
9525                                                globalScope.Float64Array = Float32Array;
9526                                            }
9527                                            return;
9528                                        }
9529                                        function subarray(start, end) {
9530                                            return new TypedArray(this.slice(start, end));
9531                                        }
9532                                        function setArrayOffset(array, offset) {
9533                                            if (arguments.length < 2) {
9534                                                offset = 0;
9535                                            }
9536                                            for (var i = 0, n = array.length; i < n; ++i, ++offset) {
9537                                                this[offset] = array[i] & 0xFF;
9538                                            }
9539                                        }
9540                                        function TypedArray(arg1) {
9541                                            var result, i, n;
9542                                            if (typeof arg1 === 'number') {
9543                                                result = [];
9544                                                for (i = 0; i < arg1; ++i) {
9545                                                    result[i] = 0;
9546                                                }
9547                                            } else if ('slice' in arg1) {
9548                                                result = arg1.slice(0);
9549                                            } else {
9550                                                result = [];
9551                                                for (i = 0, n = arg1.length; i < n; ++i) {
9552                                                    result[i] = arg1[i];
9553                                                }
9554                                            }
9555                                            result.subarray = subarray;
9556                                            result.buffer = result;
9557                                            result.byteLength = result.length;
9558                                            result.set = setArrayOffset;
9559                                            if (typeof arg1 === 'object' && arg1.buffer) {
9560                                                result.buffer = arg1.buffer;
9561                                            }
9562                                            return result;
9563                                        }
9564                                        globalScope.Uint8Array = TypedArray;
9565                                        globalScope.Int8Array = TypedArray;
9566                                        globalScope.Uint32Array = TypedArray;
9567                                        globalScope.Int32Array = TypedArray;
9568                                        globalScope.Uint16Array = TypedArray;
9569                                        globalScope.Float32Array = TypedArray;
9570                                        globalScope.Float64Array = TypedArray;
9571                                    }());
9572                                    (function normalizeURLObject() {
9573                                        if (!globalScope.URL) {
9574                                            globalScope.URL = globalScope.webkitURL;
9575                                        }
9576                                    }());
9577                                    (function checkObjectDefinePropertyCompatibility() {
9578                                        if (typeof Object.defineProperty !== 'undefined') {
9579                                            var definePropertyPossible = true;
9580                                            try {
9581                                                if (hasDOM) {
9582                                                    Object.defineProperty(new Image(), 'id', {value: 'test'});
9583                                                }
9584                                                var Test = function Test() {
9585                                                };
9586                                                Test.prototype = {
9587                                                    get id() {
9588                                                    }
9589                                                };
9590                                                Object.defineProperty(new Test(), 'id', {
9591                                                    value: '',
9592                                                    configurable: true,
9593                                                    enumerable: true,
9594                                                    writable: false
9595                                                });
9596                                            } catch (e) {
9597                                                definePropertyPossible = false;
vendor: 12,888 bytes, lines 9598-9779
9598                                            }
9599                                            if (definePropertyPossible) {
9600                                                return;
9601                                            }
9602                                        }
9603                                        Object.defineProperty = function objectDefineProperty(obj, name, def) {
9604                                            delete obj[name];
9605                                            if ('get' in def) {
9606                                                obj.__defineGetter__(name, def['get']);
9607                                            }
9608                                            if ('set' in def) {
9609                                                obj.__defineSetter__(name, def['set']);
9610                                            }
9611                                            if ('value' in def) {
9612                                                obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
9613                                                    this.__defineGetter__(name, function objectDefinePropertyGetter() {
9614                                                        return value;
9615                                                    });
9616                                                    return value;
9617                                                });
9618                                                obj[name] = def.value;
9619                                            }
9620                                        };
9621                                    }());
9622                                    (function checkXMLHttpRequestResponseCompatibility() {
9623                                        if (typeof XMLHttpRequest === 'undefined') {
9624                                            return;
9625                                        }
9626                                        var xhrPrototype = XMLHttpRequest.prototype;
9627                                        var xhr = new XMLHttpRequest();
9628                                        if (!('overrideMimeType' in xhr)) {
9629                                            Object.defineProperty(xhrPrototype, 'overrideMimeType', {
9630                                                value: function xmlHttpRequestOverrideMimeType(mimeType) {
9631                                                }
9632                                            });
9633                                        }
9634                                        if ('responseType' in xhr) {
9635                                            return;
9636                                        }
9637                                        Object.defineProperty(xhrPrototype, 'responseType', {
9638                                            get: function xmlHttpRequestGetResponseType() {
9639                                                return this._responseType || 'text';
9640                                            },
9641                                            set: function xmlHttpRequestSetResponseType(value) {
9642                                                if (value === 'text' || value === 'arraybuffer') {
9643                                                    this._responseType = value;
9644                                                    if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
9645                                                        this.overrideMimeType('text/plain; charset=x-user-defined');
9646                                                    }
9647                                                }
9648                                            }
9649                                        });
9650                                        if (typeof VBArray !== 'undefined') {
9651                                            Object.defineProperty(xhrPrototype, 'response', {
9652                                                get: function xmlHttpRequestResponseGet() {
9653                                                    if (this.responseType === 'arraybuffer') {
9654                                                        return new Uint8Array(new VBArray(this.responseBody).toArray());
9655                                                    }
9656                                                    return this.responseText;
9657                                                }
9658                                            });
9659                                            return;
9660                                        }
9661                                        Object.defineProperty(xhrPrototype, 'response', {
9662                                            get: function xmlHttpRequestResponseGet() {
9663                                                if (this.responseType !== 'arraybuffer') {
9664                                                    return this.responseText;
9665                                                }
9666                                                var text = this.responseText;
9667                                                var i, n = text.length;
9668                                                var result = new Uint8Array(n);
9669                                                for (i = 0; i < n; ++i) {
9670                                                    result[i] = text.charCodeAt(i) & 0xFF;
9671                                                }
9672                                                return result.buffer;
9673                                            }
9674                                        });
9675                                    }());
9676                                    (function checkWindowBtoaCompatibility() {
9677                                        if ('btoa' in globalScope) {
9678                                            return;
9679                                        }
9680                                        var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
9681                                        globalScope.btoa = function (chars) {
9682                                            var buffer = '';
9683                                            var i, n;
9684                                            for (i = 0, n = chars.length; i < n; i += 3) {
9685                                                var b1 = chars.charCodeAt(i) & 0xFF;
9686                                                var b2 = chars.charCodeAt(i + 1) & 0xFF;
9687                                                var b3 = chars.charCodeAt(i + 2) & 0xFF;
9688                                                var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
9689                                                var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
9690                                                var d4 = i + 2 < n ? b3 & 0x3F : 64;
9691                                                buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
9692                                            }
9693                                            return buffer;
9694                                        };
9695                                    }());
9696                                    (function checkWindowAtobCompatibility() {
9697                                        if ('atob' in globalScope) {
9698                                            return;
9699                                        }
9700                                        var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
9701                                        globalScope.atob = function (input) {
9702                                            input = input.replace(/=+$/, '');
9703                                            if (input.length % 4 === 1) {
9704                                                throw new Error('bad atob input');
9705                                            }
9706                                            for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
9707                                                buffer = digits.indexOf(buffer);
9708                                            }
9709                                            return output;
9710                                        };
9711                                    }());
9712                                    (function checkFunctionPrototypeBindCompatibility() {
9713                                        if (typeof Function.prototype.bind !== 'undefined') {
9714                                            return;
9715                                        }
9716                                        Function.prototype.bind = function functionPrototypeBind(obj) {
9717                                            var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
9718                                            var bound = function functionPrototypeBindBound() {
9719                                                var args = headArgs.concat(Array.prototype.slice.call(arguments));
9720                                                return fn.apply(obj, args);
9721                                            };
9722                                            return bound;
9723                                        };
9724                                    }());
9725                                    (function checkDatasetProperty() {
9726                                        if (!hasDOM) {
9727                                            return;
9728                                        }
9729                                        var div = document.createElement('div');
9730                                        if ('dataset' in div) {
9731                                            return;
9732                                        }
9733                                        Object.defineProperty(HTMLElement.prototype, 'dataset', {
9734                                            get: function () {
9735                                                if (this._dataset) {
9736                                                    return this._dataset;
9737                                                }
9738                                                var dataset = {};
9739                                                for (var j = 0, jj = this.attributes.length; j < jj; j++) {
9740                                                    var attribute = this.attributes[j];
9741                                                    if (attribute.name.substring(0, 5) !== 'data-') {
9742                                                        continue;
9743                                                    }
9744                                                    var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
9745                                                        return ch.toUpperCase();
9746                                                    });
9747                                                    dataset[key] = attribute.value;
9748                                                }
9749                                                Object.defineProperty(this, '_dataset', {
9750                                                    value: dataset,
9751                                                    writable: false,
9752                                                    enumerable: false
9753                                                });
9754                                                return dataset;
9755                                            },
9756                                            enumerable: true
9757                                        });
9758                                    }());
9759                                    (function checkClassListProperty() {
9760                                        function changeList(element, itemName, add, remove) {
9761                                            var s = element.className || '';
9762                                            var list = s.split(/\s+/g);
9763                                            if (list[0] === '') {
9764                                                list.shift();
9765                                            }
9766                                            var index = list.indexOf(itemName);
9767                                            if (index < 0 && add) {
9768                                                list.push(itemName);
9769                                            }
9770                                            if (index >= 0 && remove) {
9771                                                list.splice(index, 1);
9772                                            }
9773                                            element.className = list.join(' ');
9774                                            return index >= 0;
9775                                        }
9776                                        if (!hasDOM) {
9777                                            return;
9778                                        }
9779                                        var div = document.createElement('div');
9780                                        if ('classList' in div) {
9781                                            return;
9782                                        }
9783                                        var classListPrototype = {
9784                                            add: function (name) {
9785                                                changeList(this.element, name, true, false);
9786                                            },
9787                                            contains: function (name) {
9788                                                return changeList(this.element, name, false, false);
9789                                            },
9790                                            remove: function (name) {
9791                                                changeList(this.element, name, false, true);
9792                                            },
9793                                            toggle: function (name) {
9794                                                changeList(this.element, name, true, true);
9795                                            }
9796                                        };
9797                                        Object.defineProperty(HTMLElement.prototype, 'classList', {
9798                                            get: function () {
9799                                                if (this._classList) {
9800                                                    return this._classList;
9801                                                }
9802                                                var classList = Object.create(classListPrototype, {
9803                                                    element: {
9804                                                        value: this,
9805                                                        writable: false,
9806                                                        enumerable: true
9807                                                    }
9808                                                });
9809                                                Object.defineProperty(this, '_classList', {
9810                                                    value: classList,
9811                                                    writable: false,
9812                                                    enumerable: false
9813                                                });
9814                                                return classList;
9815                                            },
9816                                            enumerable: true
9817                                        });
9818                                    }());
9819                                    (function checkWorkerConsoleCompatibility() {
9820                                        if (typeof importScripts === 'undefined' || 'console' in globalScope) {
9821                                            return;
9822                                        }
9823                                        var consoleTimer = {};
9824                                        var workerConsole = {
9825                                            log: function log() {
9826                                                var args = Array.prototype.slice.call(arguments);
9827                                                globalScope.postMessage({
9828                                                    targetName: 'main',
9829                                                    action: 'console_log',
9830                                                    data: args
9831                                                });
9832                                            },
9833                                            error: function error() {
9834                                                var args = Array.prototype.slice.call(arguments);
9835                                                globalScope.postMessage({
9836                                                    targetName: 'main',
9837                                                    action: 'console_error',
9838                                                    data: args
9839                                                });
9840                                            },
9841                                            time: function time(name) {
9842                                                consoleTimer[name] = Date.now();
9843                                            },
9844                                            timeEnd: function timeEnd(name) {
9845                                                var time = consoleTimer[name];
9846                                                if (!time) {
9847                                                    throw new Error('Unknown timer name ' + name);
9848                                                }
9849                                                this.log('Timer:', name, Date.now() - time);
9850                                            }
9851                                        };
9852                                        globalScope.console = workerConsole;
9853                                    }());
9854                                    (function checkConsoleCompatibility() {
9855                                        if (!hasDOM) {
9856                                            return;
9857                                        }
9858                                        if (!('console' in window)) {
9859                                            window.console = {
9860                                                log: function () {
9861                                                },
9862                                                error: function () {
9863                                                },
9864                                                warn: function () {
9865                                                }
9866                                            };
9867                                            return;
9868                                        }
9869                                        if (!('bind' in console.log)) {
9870                                            console.log = function (fn) {
9871                                                return function (msg) {
9872                                                    return fn(msg);
9873                                                };
9874                                            }(console.log);
9875                                            console.error = function (fn) {
9876                                                return function (msg) {
9877                                                    return fn(msg);
9878                                                };
9879                                            }(console.error);
9880                                            console.warn = function (fn) {
9881                                                return function (msg) {
9882                                                    return fn(msg);
9883                                                };
9884                                            }(console.warn);
9885                                            return;
9886                                        }
9887                                    }());
9888                                    (function checkOnClickCompatibility() {
9889                                        function ignoreIfTargetDisabled(event) {
9890                                            if (isDisabled(event.target)) {
9891                                                event.stopPropagation();
9892                                            }
9893                                        }
9894                                        function isDisabled(node) {
9895                                            return node.disabled || node.parentNode && isDisabled(node.parentNode);
9896                                        }
9897                                        if (isOpera) {
9898                                            document.addEventListener('click', ignoreIfTargetDisabled, true);
9899                                        }
9900                                    }());
9901                                    (function checkOnBlobSupport() {
9902                                        if (isIE || isIOSChrome) {
9903                                            PDFJS.disableCreateObjectURL = true;
9904                                        }
9905                                    }());
9906                                    (function checkNavigatorLanguage() {
9907                                        if (typeof navigator === 'undefined') {
9908                                            return;
9909                                        }
9910                                        if ('language' in navigator) {
9911                                            return;
9912                                        }
9913                                        PDFJS.locale = navigator.userLanguage || 'en-US';
9914                                    }());
9915                                    (function checkRangeRequests() {
9916                                        if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
9917                                            PDFJS.disableRange = true;
9918                                            PDFJS.disableStream = true;
9919                                        }
9920                                    }());
9921                                    (function checkHistoryManipulation() {
9922                                        if (!hasDOM) {
9923                                            return;
9924                                        }
9925                                        if (!history.pushState || isAndroidPre3) {
9926                                            PDFJS.disableHistory = true;
9927                                        }
9928                                    }());
9929                                    (function checkSetPresenceInImageData() {
9930                                        if (!hasDOM) {
9931                                            return;
9932                                        }
9933                                        if (window.CanvasPixelArray) {
9934                                            if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
9935                                                window.CanvasPixelArray.prototype.set = function (arr) {
9936                                                    for (var i = 0, ii = this.length; i < ii; i++) {
9937                                                        this[i] = arr[i];
9938                                                    }
9939                                                };
9940                                            }
9941                                        } else {
9942                                            var polyfill = false, versionMatch;
9943                                            if (isChrome) {
9944                                                versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
9945                                                polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
9946                                            } else if (isAndroid) {
9947                                                polyfill = isAndroidPre5;
9948                                            } else if (isSafari) {
9949                                                versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
9950                                                polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
9951                                            }
9952                                            if (polyfill) {
9953                                                var contextPrototype = window.CanvasRenderingContext2D.prototype;
9954                                                var createImageData = contextPrototype.createImageData;
9955                                                contextPrototype.createImageData = function (w, h) {
9956                                                    var imageData = createImageData.call(this, w, h);
9957                                                    imageData.data.set = function (arr) {
9958                                                        for (var i = 0, ii = this.length; i < ii; i++) {
9959                                                            this[i] = arr[i];
9960                                                        }
9961                                                    };
9962                                                    return imageData;
9963                                                };
9964                                                contextPrototype = null;
9965                                            }
9966                                        }
9967                                    }());
9968                                    (function checkRequestAnimationFrame() {
9969                                        function fakeRequestAnimationFrame(callback) {
9970                                            window.setTimeout(callback, 20);
9971                                        }
9972                                        if (!hasDOM) {
9973                                            return;
9974                                        }
9975                                        if (isIOS) {
9976                                            window.requestAnimationFrame = fakeRequestAnimationFrame;
9977                                            return;
9978                                        }
9979                                        if ('requestAnimationFrame' in window) {
9980                                            return;
9981                                        }
9982                                        window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
9983                                    }());
9984                                    (function checkCanvasSizeLimitation() {
9985                                        if (isIOS || isAndroid) {
9986                                            PDFJS.maxCanvasPixels = 5242880;
9987                                        }
9988                                    }());
9989                                    (function checkFullscreenSupport() {
9990                                        if (!hasDOM) {
9991                                            return;
9992                                        }
9993                                        if (isIE && window.parent !== window) {
9994                                            PDFJS.disableFullscreen = true;
9995                                        }
9996                                    }());
9997                                    (function checkCurrentScript() {
9998                                        if (!hasDOM) {
9999                                            return;
10000                                        }
10001                                        if ('currentScript' in document) {
10002                                            return;
10003                                        }
10004                                        Object.defineProperty(document, 'currentScript', {
10005                                            get: function () {
10006                                                var scripts = document.getElementsByTagName('script');
10007                                                return scripts[scripts.length - 1];
10008                                            },
10009                                            enumerable: true,
10010                                            configurable: true
10011                                        });
10012                                    }());
10013                                    (function checkInputTypeNumberAssign() {
10014                                        if (!hasDOM) {
10015                                            return;
10016                                        }
10017                                        var el = document.createElement('input');
10018                                        try {
10019                                            el.type = 'number';
10020                                        } catch (ex) {
10021                                            var inputProto = el.constructor.prototype;
10022                                            var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
10023                                            Object.defineProperty(inputProto, 'type', {
10024                                                get: function () {
10025                                                    return typeProperty.get.call(this);
10026                                                },
10027                                                set: function (value) {
10028                                                    typeProperty.set.call(this, value === 'number' ? 'text' : value);
10029                                                },
10030                                                enumerable: true,
10031                                                configurable: true
10032                                            });
10033                                        }
10034                                    }());
10035                                    (function checkDocumentReadyState() {
10036                                        if (!hasDOM) {
10037                                            return;
10038                                        }
10039                                        if (!document.attachEvent) {
10040                                            return;
10041                                        }
10042                                        var documentProto = document.constructor.prototype;
10043                                        var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
10044                                        Object.defineProperty(documentProto, 'readyState', {
10045                                            get: function () {
10046                                                var value = readyStateProto.get.call(this);
10047                                                return value === 'interactive' ? 'loading' : value;
10048                                            },
10049                                            set: function (value) {
10050                                                readyStateProto.set.call(this, value);
10051                                            },
10052                                            enumerable: true,
10053                                            configurable: true
10054                                        });
10055                                    }());
10056                                    (function checkChildNodeRemove() {
10057                                        if (!hasDOM) {
10058                                            return;
10059                                        }
10060                                        if (typeof Element.prototype.remove !== 'undefined') {
10061                                            return;
10062                                        }
10063                                        Element.prototype.remove = function () {
10064                                            if (this.parentNode) {
10065                                                this.parentNode.removeChild(this);
10066                                            }
10067                                        };
10068                                    }());
10069                                    (function checkPromise() {
10070                                        if (globalScope.Promise) {
10071                                            if (typeof globalScope.Promise.all !== 'function') {
10072                                                globalScope.Promise.all = function (iterable) {
10073                                                    var count = 0, results = [], resolve, reject;
10074                                                    var promise = new globalScope.Promise(function (resolve_, reject_) {
10075                                                        resolve = resolve_;
10076                                                        reject = reject_;
10077                                                    });
10078                                                    iterable.forEach(function (p, i) {
10079                                                        count++;
10080                                                        p.then(function (result) {
10081                                                            results[i] = result;
10082                                                            count--;
10083                                                            if (count === 0) {
10084                                                                resolve(results);
10085                                                            }
10086                                                        }, reject);
10087                                                    });
10088                                                    if (count === 0) {
10089                                                        resolve(results);
10090                                                    }
10091                                                    return promise;
10092                                                };
10093                                            }
10094                                            if (typeof globalScope.Promise.resolve !== 'function') {
10095                                                globalScope.Promise.resolve = function (value) {
10096                                                    return new globalScope.Promise(function (resolve) {
10097                                                        resolve(value);
10098                                                    });
10099                                                };
10100                                            }
10101                                            if (typeof globalScope.Promise.reject !== 'function') {
10102                                                globalScope.Promise.reject = function (reason) {
10103                                                    return new globalScope.Promise(function (resolve, reject) {
10104                                                        reject(reason);
10105                                                    });
10106                                                };
10107                                            }
10108                                            if (typeof globalScope.Promise.prototype.catch !== 'function') {
10109                                                globalScope.Promise.prototype.catch = function (onReject) {
10110                                                    return globalScope.Promise.prototype.then(undefined, onReject);
10111                                                };
10112                                            }
10113                                            return;
10114                                        }
10115                                        var STATUS_PENDING = 0;
10116                                        var STATUS_RESOLVED = 1;
10117                                        var STATUS_REJECTED = 2;
10118                                        var REJECTION_TIMEOUT = 500;
10119                                        var HandlerManager = {
10120                                            handlers: [],
10121                                            running: false,
10122                                            unhandledRejections: [],
10123                                            pendingRejectionCheck: fal
vendor: 4,294 bytes, lines 10123-10178
10123se,
10124                                            scheduleHandlers: function scheduleHandlers(promise) {
10125                                                if (promise._status === STATUS_PENDING) {
10126                                                    return;
10127                                                }
10128                                                this.handlers = this.handlers.concat(promise._handlers);
10129                                                promise._handlers = [];
10130                                                if (this.running) {
10131                                                    return;
10132                                                }
10133                                                this.running = true;
10134                                                setTimeout(this.runHandlers.bind(this), 0);
10135                                            },
10136                                            runHandlers: function runHandlers() {
10137                                                var RUN_TIMEOUT = 1;
10138                                                var timeoutAt = Date.now() + RUN_TIMEOUT;
10139                                                while (this.handlers.length > 0) {
10140                                                    var handler = this.handlers.shift();
10141                                                    var nextStatus = handler.thisPromise._status;
10142                                                    var nextValue = handler.thisPromise._value;
10143                                                    try {
10144                                                        if (nextStatus === STATUS_RESOLVED) {
10145                                                            if (typeof handler.onResolve === 'function') {
10146                                                                nextValue = handler.onResolve(nextValue);
10147                                                            }
10148                                                        } else if (typeof handler.onReject === 'function') {
10149                                                            nextValue = handler.onReject(nextValue);
10150                                                            nextStatus = STATUS_RESOLVED;
10151                                                            if (handler.thisPromise._unhandledRejection) {
10152                                                                this.removeUnhandeledRejection(handler.thisPromise);
10153                                                            }
10154                                                        }
10155                                                    } catch (ex) {
10156                                                        nextStatus = STATUS_REJECTED;
10157                                                        nextValue = ex;
10158                                                    }
10159                                                    handler.nextPromise._updateStatus(nextStatus, nextValue);
10160                                                    if (Date.now() >= timeoutAt) {
10161                                                        break;
10162                                                    }
10163                                                }
10164                                                if (this.handlers.length > 0) {
10165                                                    setTimeout(this.runHandlers.bind(this), 0);
10166                                                    return;
10167                                                }
10168                                                this.running = false;
10169                                            },
10170                                            addUnhandledRejection: function addUnhandledRejection(promise) {
10171                                                this.unhandledRejections.push({
10172                                                    promise: promise,
10173                                                    time: Date.now()
10174                                                });
10175                                                this.scheduleRejectionCheck();
10176                                            },
10177                                            removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
10178                                                promise._unhandledRejection = false;
vendor: 10,398 bytes, lines 10179-10320
10179                                                for (var i = 0; i < this.unhandledRejections.length; i++) {
10180                                                    if (this.unhandledRejections[i].promise === promise) {
10181                                                        this.unhandledRejections.splice(i);
10182                                                        i--;
10183                                                    }
10184                                                }
10185                                            },
10186                                            scheduleRejectionCheck: function scheduleRejectionCheck() {
10187                                                if (this.pendingRejectionCheck) {
10188                                                    return;
10189                                                }
10190                                                this.pendingRejectionCheck = true;
10191                                                setTimeout(function rejectionCheck() {
10192                                                    this.pendingRejectionCheck = false;
10193                                                    var now = Date.now();
10194                                                    for (var i = 0; i < this.unhandledRejections.length; i++) {
10195                                                        if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
10196                                                            var unhandled = this.unhandledRejections[i].promise._value;
10197                                                            var msg = 'Unhandled rejection: ' + unhandled;
10198                                                            if (unhandled.stack) {
10199                                                                msg += '\n' + unhandled.stack;
10200                                                            }
10201                                                            try {
10202                                                                throw new Error(msg);
10203                                                            } catch (_) {
10204                                                                console.warn(msg);
10205                                                            }
10206                                                            this.unhandledRejections.splice(i);
10207                                                            i--;
10208                                                        }
10209                                                    }
10210                                                    if (this.unhandledRejections.length) {
10211                                                        this.scheduleRejectionCheck();
10212                                                    }
10213                                                }.bind(this), REJECTION_TIMEOUT);
10214                                            }
10215                                        };
10216                                        var Promise = function Promise(resolver) {
10217                                            this._status = STATUS_PENDING;
10218                                            this._handlers = [];
10219                                            try {
10220                                                resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
10221                                            } catch (e) {
10222                                                this._reject(e);
10223                                            }
10224                                        };
10225                                        Promise.all = function Promise_all(promises) {
10226                                            var resolveAll, rejectAll;
10227                                            var deferred = new Promise(function (resolve, reject) {
10228                                                resolveAll = resolve;
10229                                                rejectAll = reject;
10230                                            });
10231                                            var unresolved = promises.length;
10232                                            var results = [];
10233                                            if (unresolved === 0) {
10234                                                resolveAll(results);
10235                                                return deferred;
10236                                            }
10237                                            function reject(reason) {
10238                                                if (deferred._status === STATUS_REJECTED) {
10239                                                    return;
10240                                                }
10241                                                results = [];
10242                                                rejectAll(reason);
10243                                            }
10244                                            for (var i = 0, ii = promises.length; i < ii; ++i) {
10245                                                var promise = promises[i];
10246                                                var resolve = function (i) {
10247                                                    return function (value) {
10248                                                        if (deferred._status === STATUS_REJECTED) {
10249                                                            return;
10250                                                        }
10251                                                        results[i] = value;
10252                                                        unresolved--;
10253                                                        if (unresolved === 0) {
10254                                                            resolveAll(results);
10255                                                        }
10256                                                    };
10257                                                }(i);
10258                                                if (Promise.isPromise(promise)) {
10259                                                    promise.then(resolve, reject);
10260                                                } else {
10261                                                    resolve(promise);
10262                                                }
10263                                            }
10264                                            return deferred;
10265                                        };
10266                                        Promise.isPromise = function Promise_isPromise(value) {
10267                                            return value && typeof value.then === 'function';
10268                                        };
10269                                        Promise.resolve = function Promise_resolve(value) {
10270                                            return new Promise(function (resolve) {
10271                                                resolve(value);
10272                                            });
10273                                        };
10274                                        Promise.reject = function Promise_reject(reason) {
10275                                            return new Promise(function (resolve, reject) {
10276                                                reject(reason);
10277                                            });
10278                                        };
10279                                        Promise.prototype = {
10280                                            _status: null,
10281                                            _value: null,
10282                                            _handlers: null,
10283                                            _unhandledRejection: null,
10284                                            _updateStatus: function Promise__updateStatus(status, value) {
10285                                                if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
10286                                                    return;
10287                                                }
10288                                                if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
10289                                                    value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
10290                                                    return;
10291                                                }
10292                                                this._status = status;
10293                                                this._value = value;
10294                                                if (status === STATUS_REJECTED && this._handlers.length === 0) {
10295                                                    this._unhandledRejection = true;
10296                                                    HandlerManager.addUnhandledRejection(this);
10297                                                }
10298                                                HandlerManager.scheduleHandlers(this);
10299                                            },
10300                                            _resolve: function Promise_resolve(value) {
10301                                                this._updateStatus(STATUS_RESOLVED, value);
10302                                            },
10303                                            _reject: function Promise_reject(reason) {
10304                                                this._updateStatus(STATUS_REJECTED, reason);
10305                                            },
10306                                            then: function Promise_then(onResolve, onReject) {
10307                                                var nextPromise = new Promise(function (resolve, reject) {
10308                                                    this.resolve = resolve;
10309                                                    this.reject = reject;
10310                                                });
10311                                                this._handlers.push({
10312                                                    thisPromise: this,
10313                                                    onResolve: onResolve,
10314                                                    onReject: onReject,
10315                                                    nextPromise: nextPromise
10316                                                });
10317                                                HandlerManager.scheduleHandlers(this);
10318                                                return nextPromise;
10319                                            },
10320                                            catch : function Promise_cat
10320ch(onReject) {
10321                                                return this.then(undefined, onReject);
10322                                            }
10323                                        };
10324                                        globalScope.Promise = Promise;
10325                                    }());
10326                                    (function checkWeakMap() {
10327                                        if (globalScope.WeakMap) {
10328                                            return;
10329                                        }
10330                                        var id = 0;
10331                                        function WeakMap() {
10332                                            this.id = '$weakmap' + id++;
10333                                        }
10334                                        WeakMap.prototype = {
10335                                            has: function (obj) {
10336                                                return !!Object.getOwnPropertyDescriptor(obj, this.id);
10337                                            },
10338                                            get: function (obj, defaultValue) {
10339                                                return this.has(obj) ? obj[this.id] : defaultValue;
10340                                            },
10341                                            set: function (obj, value) {
10342                                                Object.defineProperty(obj, this.id, {
10343                                                    value: value,
10344                                                    enumerable: false,
10345                                                    configurable: true
10346                                                });
10347                                            },
10348                                            delete: function (obj) {
10349                                                delete obj[this.id];
10350                                            }
10351                                        };
10352                                        globalScope.WeakMap = WeakMap;
10353                                    }());
10354                                    (function checkURLConstructor() {
10355                                        var hasWorkingUrl = false;
10356                                        try {
10357                                            if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
10358                                                var u = new URL('b', 'http://a');
10359                                                u.pathname = 'c%20d';
10360                                                hasWorkingUrl = u.href === 'http://a/c%20d';
10361                                            }
10362                                        } catch (e) {
10363                                        }
10364                                        if (hasWorkingUrl) {
10365                                            return;
10366                                        }
10367                                        var relative = Object.create(null);
10368                                        relative['ftp'] = 21;
10369                                        relative['file'] = 0;
10370                                        relative['gopher'] = 70;
10371                                        relative['http'] = 80;
10372                                        relative['https'] = 443;
10373                                        relative['ws'] = 80;
10374                                        relative['wss'] = 443;
10375                                        var relativePathDotMapping = Object.create(null);
10376                                        relativePathDotMapping['%2e'] = '.';
10377                                        relativePathDotMapping['.%2e'] = '..';
10378                                        relativePathDotMapping['%2e.'] = '..';
10379                                        relativePathDotMapping['%2e%2e'] = '..';
10380                                        function isRelativeScheme(scheme) {
10381                                            return relative[scheme] !== undefined;
10382                                        }
vendor: 7,390 bytes, lines 10383-10484
10383                                        function invalid() {
10384                                            clear.call(this);
10385                                            this._isInvalid = true;
10386                                        }
10387                                        function IDNAToASCII(h) {
10388                                            if (h === '') {
10389                                                invalid.call(this);
10390                                            }
10391                                            return h.toLowerCase();
10392                                        }
10393                                        function percentEscape(c) {
10394                                            var unicode = c.charCodeAt(0);
10395                                            if (unicode > 0x20 && unicode < 0x7F && [
10396                                                0x22,
10397                                                0x23,
10398                                                0x3C,
10399                                                0x3E,
10400                                                0x3F,
10401                                                0x60
10402                                            ].indexOf(unicode) === -1) {
10403                                                return c;
10404                                            }
10405                                            return encodeURIComponent(c);
10406                                        }
10407                                        function percentEscapeQuery(c) {
10408                                            var unicode = c.charCodeAt(0);
10409                                            if (unicode > 0x20 && unicode < 0x7F && [
10410                                                0x22,
10411                                                0x23,
10412                                                0x3C,
10413                                                0x3E,
10414                                                0x60
10415                                            ].indexOf(unicode) === -1) {
10416                                                return c;
10417                                            }
10418                                            return encodeURIComponent(c);
10419                                        }
10420                                        var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
10421                                        function parse(input, stateOverride, base) {
10422                                            function err(message) {
10423                                                errors.push(message);
10424                                            }
10425                                            var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
10426                                            loop:
10427                                                    while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
10428                                                var c = input[cursor];
10429                                                switch (state) {
10430                                                    case 'scheme start':
10431                                                        if (c && ALPHA.test(c)) {
10432                                                            buffer += c.toLowerCase();
10433                                                            state = 'scheme';
10434                                                        } else if (!stateOverride) {
10435                                                            buffer = '';
10436                                                            state = 'no scheme';
10437                                                            continue;
10438                                                        } else {
10439                                                            err('Invalid scheme.');
10440                                                            break loop;
10441                                                        }
10442                                                        break;
10443                                                    case 'scheme':
10444                                                        if (c && ALPHANUMERIC.test(c)) {
10445                                                            buffer += c.toLowerCase();
10446                                                        } else if (c === ':') {
10447                                                            this._scheme = buffer;
10448                                                            buffer = '';
10449                                                            if (stateOverride) {
10450                                                                break loop;
10451                                                            }
10452                                                            if (isRelativeScheme(this._scheme)) {
10453                                                                this._isRelative = true;
10454                                                            }
10455                                                            if (this._scheme === 'file') {
10456                                                                state = 'relative';
10457                                                            } else if (this._isRelative && base && base._scheme === this._scheme) {
10458                                                                state = 'relative or authority';
10459                                                            } else if (this._isRelative) {
10460                                                                state = 'authority first slash';
10461                                                            } else {
10462                                                                state = 'scheme data';
10463                                                            }
10464                                                        } else if (!stateOverride) {
10465                                                            buffer = '';
10466                                                            cursor = 0;
10467                                                            state = 'no scheme';
10468                                                            continue;
10469                                                        } else if (EOF === c) {
10470                                                            break loop;
10471                                                        } else {
10472                                                            err('Code point not allowed in scheme: ' + c);
10473                                                            break loop;
10474                                                        }
10475                                                        break;
10476                                                    case 'scheme data':
10477                                                        if (c === '?') {
10478                                                            this._query = '?';
10479                                                            state = 'query';
10480                                                        } else if (c === '#') {
10481                                                            this._fragment = '#';
10482                                                            state = 'fragment';
10483                                                        } else {
10484                                                            if (EOF !== c && '\t' 
10484!== c && '\n' !== c && '\r' !== c) {
10485                                                                this._schemeData += percentEscape(c);
10486                                                            }
10487                                                        }
10488                                                        break;
10489                                                    case 'no scheme':
10490                                                        if (!base || !isRelativeScheme(base._scheme)) {
10491                                                            err('Missing scheme.');
10492                                                            invalid.call(this);
10493                                                        } else {
10494                                                            state = 'relative';
10495                                                            continue;
10496                                                        }
10497                                                        break;
10498                                                    case 'relative or authority':
10499                                                        if (c === '/' && input[cursor + 1] === '/') {
10500                                                            state = 'authority ignore slashes';
10501                                                        } else {
10502                                                            err('Expected /, got: ' + c);
10503                                                            state = 'relative';
10504                                                            continue;
10505                                                        }
10506                                                        break;
10507                                                    case 'relative':
10508                                                        this._isRelative = true;
10509                                                        if ('file' !== this._scheme) {
10510                                                            this._scheme = base._scheme;
10511                                                        }
10512                                                        if (EOF === c) {
10513                                                            this._host = base._host;
10514                                                            this._port = base._port;
10515                                                            this._path = base._path.slice();
10516                                                            this._query = base._query;
10517                                                            this._username = base._username;
10518                                                            this._password = base._password;
10519                                                            break loop;
10520                                                        } else if (c === '/' || c === '\\') {
10521                                                            if (c === '\\') {
10522                                                                err('\\ is an invalid code point.');
10523                                                            }
10524                                                            state = 'relative slash';
10525                                                        } else if (c === '?') {
10526                                                            this._host = base._host;
10527                                                            this._port = base._port;
10528                                                            this._path = base._path.slice();
10529                                                            this._query = '?';
10530                                                            this._username = base._username;
10531                                                            this._password = base._password;
10532                                                            state = 'query';
10533                                                        } else if (c === '#') {
10534                                                            this._host = base._host;
10535                                                            this._port = base._port;
10536                                                            this._path = base._path.slice();
10537                                                            this._query = base._query;
10538                                                            this._fragment = '#';
10539                                                            this._username = base._username;
10540                                                            this._password = base._password;
10541                                                            state = 'fragment';
10542                                                        } else {
10543                                                            var nextC = input[cursor + 1];
10544                                                            var nextNextC = input[cursor + 2];
10545                                                            if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
10546                                                                this._host = base._host;
10547                                                                this._port = base._port;
10548                                                                this._username = base._username;
10549                                                                this._password = base._password;
10550                                                                this._path = base._path.slice();
10551                                                                this._path.pop();
10552                                                            }
10553                                                            state = 'relative path';
10554                                                            continue;
10555                                                        }
10556                                                        break;
10557                                                    case 'relative slash':
10558                                                        if (c === '/' || c === '\\') {
10559                                                            if (c === '\\') {
10560                                                                err('\\ is an invali
10560d code point.');
10561                                                            }
10562                                                            if (this._scheme === 'file') {
10563                                                                state = 'file host';
10564                                                            } else {
10565                                                                state = 'authority ignore slashes';
10566                                                            }
10567                                                        } else {
10568                                                            if ('file' !== this._scheme) {
10569                                                                this._host = base._host;
10570                                                                this._port = base._port;
10571                                                                this._username = base._username;
10572                                                                this._password = base._password;
10573                                                            }
10574                                                            state = 'relative path';
10575                                                            continue;
10576                                                        }
10577                                                        break;
10578                                                    case 'authority first slash':
10579                                                        if (c === '/') {
10580                                                            state = 'authority second slash';
10581                                                        } else {
10582                                                            err('Expected \'/\', got: ' + c);
10583                                                            state = 'authority ignore slashes';
10584                                                            continue;
10585                                                        }
10586                                                        break;
10587                                                    case 'authority second slash':
10588                                                        state = 'authority ignore slashes';
10589                                                        if ('/' !== c) {
10590                                                            err('Expected \'/\', got: ' + c);
10591                                                            continue;
10592                                                        }
10593                                                        break;
10594                                                    case 'authority ignore slashes':
10595                                                        if ('/' !== c && '\\' !== c) {
10596                                                            state = 'authority';
10597                                                            continue;
10598                                                        } else {
10599                                                            err('Expected authority, got: ' + c);
10600                                                        }
10601                                                        break;
10602                                                    case 'authority':
10603                                                        if (c === '@') {
10604                                                            if (seenAt) {
10605                                                                err('@ already seen.');
10606                                                                buffer += '%40';
10607                                                            }
10608                                                            seenAt = true;
10609                                                            for (var i = 0; i < buffer.length; i++) {
10610                                                                var cp = buffer[i];
10611                                                                if (cp === '\t' || cp === '\n' || cp === '\r') {
10612                                                                    err('Invalid whitespace in authority.');
10613                                                                    continue;
10614                                                                }
10615                                                                if (cp === ':' && this._password === null) {
10616                                                                    this._password = '';
10617                                                                    continue;
10618                                                                }
10619                                                                var tempC = percentEscape(cp);
10620                                                                if (null !== this._password) {
10621                                                                    this._password += tempC;
10622                                                                } else {
10623                                                                    this._username += tempC;
10624                                                                }
10625                                                            }
10626                                                            buffer = '';
10627                                                        } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
10628                                                            cursor -= buffer.length;
10629                                                            buffer = '';
10630                                                            state = 'host';
10631                                                            continue;
10632                                                        } else {
10633                                                            buffer += c;
10634                                                        }
10635                                                        break;
10636                                                    case 'file host':
10637                                                        if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
10638                                                            if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
10639                                                                state = 'relative path';
10640                                                            } else if (buffer.length === 0) {
10641                                                                state = 'relative path start';
10642                                                            } else {
10643                                                                this._host = IDNAToASCII.c
10643all(this, buffer);
10644                                                                buffer = '';
10645                                                                state = 'relative path start';
10646                                                            }
10647                                                            continue;
10648                                                        } else if (c === '\t' || c === '\n' || c === '\r') {
10649                                                            err('Invalid whitespace in file host.');
10650                                                        } else {
10651                                                            buffer += c;
10652                                                        }
10653                                                        break;
10654                                                    case 'host':
10655                                                    case 'hostname':
10656                                                        if (c === ':' && !seenBracket) {
10657                                                            this._host = IDNAToASCII.call(this, buffer);
10658                                                            buffer = '';
10659                                                            state = 'port';
10660                                                            if (stateOverride === 'hostname') {
10661                                                                break loop;
10662                                                            }
10663                                                        } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
10664                                                            this._host = IDNAToASCII.call(this, buffer);
10665                                                            buffer = '';
10666                                                            state = 'relative path start';
10667                                                            if (stateOverride) {
10668                                                                break loop;
10669                                                            }
10670                                                            continue;
10671                                                        } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
10672                                                            if (c === '[') {
10673                                                                seenBracket = true;
10674                                                            } else if (c === ']') {
10675                                                                seenBracket = false;
10676                                                            }
10677                                                            buffer += c;
10678                                                        } else {
10679                                                            err('Invalid code point in host/hostname: ' + c);
10680                                                        }
10681                                                        break;
10682                                                    case 'port':
10683                                                        if (/[0-9]/.test(c)) {
10684                                                            buffer += c;
10685                                                        } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
10686                                                            if ('' !== buffer) {
10687                                                                var temp = parseInt(buffer, 10);
10688                                                                if (temp !== relative[this._scheme]) {
10689                                                                    this._port = temp + '';
10690                                                                }
10691                                                                buffer = '';
10692                                                            }
10693                                                            if (stateOverride) {
10694                                                                break loop;
10695                                                            }
10696                                                            state = 'relative path start';
10697                                                            continue;
10698                                                        } else if (c === '\t' || c === '\n' || c === '\r') {
10699                                                            err('Invalid code point in port: ' + c);
10700                                                        } else {
10701                                                            invalid.call(this);
10702                                                        }
10703                                                        break;
10704                                                    case 'relative path start':
10705                                                        if (c === '\\') {
10706                                                            err('\'\\\' not allowed in path.');
10707                                                        }
10708                                                        state = 'relative path';
10709                                                        if ('/' !== c && '\\' !== c) {
10710                                                            continue;
10711                                                        }
10712                                                        break;
10713                                                    case 'relative path':
10714                                                        if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
10715                                                            if (c === '\\') {
10716                                                                err('\\ not allowed in relative path.');
10717                                                            }
10718                                                            var tmp;
10719                                                            if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
10720                                                                buffer = tmp;
10721                                                            }
10722                                                            if (buffer === '..') {
10723                                                                this._path.pop();
10724                                                                if ('/' !== c && '\\' !== c) {
10725                                                                    this._path.push('');
10726                                                                }
10727                                                            } else if (buffer === '.' && '/' !== c && '\\' !== c) {
10728                                                                this._path.push('');
10729                                                            } else if ('.' !== buffer) {
10730                                                                if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
10731                                                                    buffer = buffer[0] + ':';
10732                                                                }
10733                                                                this._path.push(buffer);
10734                                                            }
10735                                                            buffer = '';
10736                                                            if (c === '?') {
10737                                                                this._query = '?';
10738                                                                state = 'query';
10739                                                            } else if (c === '#') {
10740                                                                this._fragment = '#';
10741                                                                state = 'fragment';
10742                                                            }
10743                                                        } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
10744                                                            buffer += percentEscape(c);
10745                                                        }
10746                                                        break;
10747                                                    case 'query':
10748                                                        if (!stateOverride && c === '#') {
10749                                                            this._fragment = '#';
10750                                                            state = 'fragment';
10751                                                        }
vendor: 9,231 bytes, lines 10751-10886
10751 else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
10752                                                            this._query += percentEscapeQuery(c);
10753                                                        }
10754                                                        break;
10755                                                    case 'fragment':
10756                                                        if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
10757                                                            this._fragment += c;
10758                                                        }
10759                                                        break;
10760                                                }
10761                                                cursor++;
10762                                            }
10763                                        }
10764                                        function clear() {
10765                                            this._scheme = '';
10766                                            this._schemeData = '';
10767                                            this._username = '';
10768                                            this._password = null;
10769                                            this._host = '';
10770                                            this._port = '';
10771                                            this._path = [];
10772                                            this._query = '';
10773                                            this._fragment = '';
10774                                            this._isInvalid = false;
10775                                            this._isRelative = false;
10776                                        }
10777                                        function JURL(url, base) {
10778                                            if (base !== undefined && !(base instanceof JURL)) {
10779                                                base = new JURL(String(base));
10780                                            }
10781                                            this._url = url;
10782                                            clear.call(this);
10783                                            var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
10784                                            parse.call(this, input, null, base);
10785                                        }
10786                                        JURL.prototype = {
10787                                            toString: function () {
10788                                                return this.href;
10789                                            },
10790                                            get href() {
10791                                                if (this._isInvalid) {
10792                                                    return this._url;
10793                                                }
10794                                                var authority = '';
10795                                                if ('' !== this._username || null !== this._password) {
10796                                                    authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
10797                                                }
10798                                                return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
10799                                            },
10800                                            set href(href) {
10801                                                clear.call(this);
10802                                                parse.call(this, href);
10803                                            },
10804                                            get protocol() {
10805                                                return this._scheme + ':';
10806                                            },
10807                                            set protocol(protocol) {
10808                                                if (this._isInvalid) {
10809                                                    return;
10810                                                }
10811                                                parse.call(this, protocol + ':', 'scheme start');
10812                                            },
10813                                            get host() {
10814                                                return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
10815                                            },
10816                                            set host(host) {
10817                                                if (this._isInvalid || !this._isRelative) {
10818                                                    return;
10819                                                }
10820                                                parse.call(this, host, 'host');
10821                                            },
10822                                            get hostname() {
10823                                                return this._host;
10824                                            },
10825                                            set hostname(hostname) {
10826                                                if (this._isInvalid || !this._isRelative) {
10827                                                    return;
10828                                                }
10829                                                parse.call(this, hostname, 'hostname');
10830                                            },
10831                                            get port() {
10832                                                return this._port;
10833                                            },
10834                                            set port(port) {
10835                                                if (this._isInvalid || !this._isRelative) {
10836                                                    return;
10837                                                }
10838                                                parse.call(this, port, 'port');
10839                                            },
10840                                            get pathname() {
10841                                                return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
10842                                            },
10843                                            set pathname(pathname) {
10844                                                if (this._isInvalid || !this._isRelative) {
10845                                                    return;
10846                                                }
10847                                                this._path = [];
10848                                                parse.call(this, pathname, 'relative path start');
10849                                            },
10850                                            get search() {
10851                                                return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
10852                                            },
10853                                            set search(search) {
10854                                                if (this._isInvalid || !this._isRelative) {
10855                                                    return;
10856                                                }
10857                                                this._query = '?';
10858                                                if (search[0] === '?') {
10859                                                    search = search.slice(1);
10860                                                }
10861                                                parse.call(this, search, 'query');
10862                                            },
10863                                            get hash() {
10864                                                return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
10865                                            },
10866                                            set hash(hash) {
10867                                                if (this._isInvalid) {
10868                                                    return;
10869                                                }
10870                                                this._fragment = '#';
10871                                                if (hash[0] === '#') {
10872                                                    hash = hash.slice(1);
10873                                                }
10874                                                parse.call(this, hash, 'fragment');
10875                                            },
10876                                            get origin() {
10877                                                var host;
10878                                                if (this._isInvalid || !this._scheme) {
10879                                                    return '';
10880                                                }
10881                                                switch (this._scheme) {
10882                                                    case 'data':
10883                                                    case 'file':
10884                                                    case 'javascript':
10885                                                    case 'mailto':
10886                                                        return 'null';
10887                                                }
10888                                                host = this.host;
10889                                                if (!host) {
10890                                                    return '';
10891                                                }
10892                                                return this._scheme + '://' + host;
10893                                            }
10894                                        };
10895                                        var OriginalURL = globalScope.URL;
10896                                        if (OriginalURL) {
10897                                            JURL.createObjectURL = function (blob) {
10898                                                return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
10899                                            };
10900                                            JURL.revokeObjectURL = function (url) {
10901                                                OriginalURL.revokeObjectURL(url);
10902                                            };
10903                                        }
10904                                        globalScope.URL = JURL;
10905                                    }());
10906                                }
10907                                /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(6)))
10908
10909                            /***/ }),
10910                        /* 14 */
10911                        /***/ (function (module, exports, __w_pdfjs_require__) {
10912
10913                            "use strict";
10914
10915                            var pdfjsVersion = '1.7.354';
10916                            var pdfjsBuild = '0f7548ba';
10917                            var pdfjsSharedUtil = __w_pdfjs_require__(0);
10918                            var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
10919                            var pdfjsDisplayAPI = __w_pdfjs_require__(3);
10920                            var pdfjsDisplayTextLayer = __w_pdfjs_require__(5);
10921                            var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(2);
10922                            var pdfjsDisplayDOMUtils = __w_pdfjs_require__(1);
10923                            var pdfjsDisplaySVG = __w_pdfjs_require__(4);
10924                            exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
10925                            exports.build = pdfjsDisplayAPI.build;
10926                            exports.version = pdfjsDisplayAPI.version;
10927                            exports.getDocument = pdfjsDisplayAPI.getDocument;
10928                            exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
10929                            exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
10930                            exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
10931                            exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
10932                            exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
10933                            exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
10934                            exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
10935                            exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
10936                            exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
10937                            exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
10938                            exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
10939                            exports.OPS = pdfjsSharedUtil.OPS;
10940                            exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
10941                            exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
10942                            exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
10943                            exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
10944                            exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
10945                            exports.shadow = pdfjsSharedUtil.shadow;
10946                            exports.createBlob = pdfjsSharedUtil.createBlob;
10947                            exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
10948                            exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
10949
10950                            /***/ })
10951                                /******/]);
10952        });/* Copyright 2012 Mozilla Foundation
10953         *
10954         * Licensed under the Apache License, Version 2.0 (the "License");
vendor: 38,181 bytes, lines 10955-11869
10955         * you may not use this file except in compliance with the License.
10956         * You may obtain a copy of the License at
10957         *
10958         *     http://www.apache.org/licenses/LICENSE-2.0
10959         *
10960         * Unless required by applicable law or agreed to in writing, software
10961         * distributed under the License is distributed on an "AS IS" BASIS,
10962         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10963         * See the License for the specific language governing permissions and
10964         * limitations under the License.
10965         */
10966
10967'use strict';
10968
10969var FontInspector = (function FontInspectorClosure() {
10970    var fonts;
10971    var active = false;
10972    var fontAttribute = 'data-font-name';
10973    function removeSelection() {
10974        var divs = document.querySelectorAll('div[' + fontAttribute + ']');
10975        for (var i = 0, ii = divs.length; i < ii; ++i) {
10976            var div = divs[i];
10977            div.className = '';
10978        }
10979    }
10980    function resetSelection() {
10981        var divs = document.querySelectorAll('div[' + fontAttribute + ']');
10982        for (var i = 0, ii = divs.length; i < ii; ++i) {
10983            var div = divs[i];
10984            div.className = 'debuggerHideText';
10985        }
10986    }
10987    function selectFont(fontName, show) {
10988        var divs = document.querySelectorAll('div[' + fontAttribute + '=' +
10989                fontName + ']');
10990        for (var i = 0, ii = divs.length; i < ii; ++i) {
10991            var div = divs[i];
10992            div.className = show ? 'debuggerShowText' : 'debuggerHideText';
10993        }
10994    }
10995    function textLayerClick(e) {
10996        if (!e.target.dataset.fontName ||
10997                e.target.tagName.toUpperCase() !== 'DIV') {
10998            return;
10999        }
11000        var fontName = e.target.dataset.fontName;
11001        var selects = document.getElementsByTagName('input');
11002        for (var i = 0; i < selects.length; ++i) {
11003            var select = selects[i];
11004            if (select.dataset.fontName !== fontName) {
11005                continue;
11006            }
11007            select.checked = !select.checked;
11008            selectFont(fontName, select.checked);
11009            select.scrollIntoView();
11010        }
11011    }
11012    return {
11013        // Properties/functions needed by PDFBug.
11014        id: 'FontInspector',
11015        name: 'Font Inspector',
11016        panel: null,
11017        manager: null,
11018        init: function init(pdfjsLib) {
11019            var panel = this.panel;
11020            panel.setAttribute('style', 'padding: 5px;');
11021            var tmp = document.createElement('button');
11022            tmp.addEventListener('click', resetSelection);
11023            tmp.textContent = 'Refresh';
11024            panel.appendChild(tmp);
11025
11026            fonts = document.createElement('div');
11027            panel.appendChild(fonts);
11028        },
11029        cleanup: function cleanup() {
11030            fonts.textContent = '';
11031        },
11032        enabled: false,
11033        get active() {
11034            return active;
11035        },
11036        set active(value) {
11037            active = value;
11038            if (active) {
11039                document.body.addEventListener('click', textLayerClick, true);
11040                resetSelection();
11041            } else {
11042                document.body.removeEventListener('click', textLayerClick, true);
11043                removeSelection();
11044            }
11045        },
11046        // FontInspector specific functions.
11047        fontAdded: function fontAdded(fontObj, url) {
11048            function properties(obj, list) {
11049                var moreInfo = document.createElement('table');
11050                for (var i = 0; i < list.length; i++) {
11051                    var tr = document.createElement('tr');
11052                    var td1 = document.createElement('td');
11053                    td1.textContent = list[i];
11054                    tr.appendChild(td1);
11055                    var td2 = document.createElement('td');
11056                    td2.textContent = obj[list[i]].toString();
11057                    tr.appendChild(td2);
11058                    moreInfo.appendChild(tr);
11059                }
11060                return moreInfo;
11061            }
11062            var moreInfo = properties(fontObj, ['name', 'type']);
11063            var fontName = fontObj.loadedName;
11064            var font = document.createElement('div');
11065            var name = document.createElement('span');
11066            name.textContent = fontName;
11067            var download = document.createElement('a');
11068            if (url) {
11069                url = /url\(['"]?([^\)"']+)/.exec(url);
11070                download.href = url[1];
11071            } else if (fontObj.data) {
11072                url = URL.createObjectURL(new Blob([fontObj.data], {
11073                    type: fontObj.mimeType
11074                }));
11075                download.href = url;
11076            }
11077            download.textContent = 'Download';
11078            var logIt = document.createElement('a');
11079            logIt.href = '';
11080            logIt.textContent = 'Log';
11081            logIt.addEventListener('click', function (event) {
11082                event.preventDefault();
11083                console.log(fontObj);
11084            });
11085            var select = document.createElement('input');
11086            select.setAttribute('type', 'checkbox');
11087            select.dataset.fontName = fontName;
11088            select.addEventListener('click', (function (select, fontName) {
11089                return (function () {
11090                    selectFont(fontName, select.checked);
11091                });
11092            })(select, fontName));
11093            font.appendChild(select);
11094            font.appendChild(name);
11095            font.appendChild(document.createTextNode(' '));
11096            font.appendChild(download);
11097            font.appendChild(document.createTextNode(' '));
11098            font.appendChild(logIt);
11099            font.appendChild(moreInfo);
11100            fonts.appendChild(font);
11101            // Somewhat of a hack, should probably add a hook for when the text layer
11102            // is done rendering.
11103            setTimeout(function () {
11104                if (this.active) {
11105                    resetSelection();
11106                }
11107            }.bind(this), 2000);
11108        }
11109    };
11110})();
11111
11112var opMap;
11113
11114// Manages all the page steppers.
11115var StepperManager = (function StepperManagerClosure() {
11116    var steppers = [];
11117    var stepperDiv = null;
11118    var stepperControls = null;
11119    var stepperChooser = null;
11120    var breakPoints = Object.create(null);
11121    return {
11122        // Properties/functions needed by PDFBug.
11123        id: 'Stepper',
11124        name: 'Stepper',
11125        panel: null,
11126        manager: null,
11127        init: function init(pdfjsLib) {
11128            var self = this;
11129            this.panel.setAttribute('style', 'padding: 5px;');
11130            stepperControls = document.createElement('div');
11131            stepperChooser = document.createElement('select');
11132            stepperChooser.addEventListener('change', function (event) {
11133                self.selectStepper(this.value);
11134            });
11135            stepperControls.appendChild(stepperChooser);
11136            stepperDiv = document.createElement('div');
11137            this.panel.appendChild(stepperControls);
11138            this.panel.appendChild(stepperDiv);
11139            if (sessionStorage.getItem('pdfjsBreakPoints')) {
11140                breakPoints = JSON.parse(sessionStorage.getItem('pdfjsBreakPoints'));
11141            }
11142
11143            opMap = Object.create(null);
11144            for (var key in pdfjsLib.OPS) {
11145                opMap[pdfjsLib.OPS[key]] = key;
11146            }
11147        },
11148        cleanup: function cleanup() {
11149            stepperChooser.textContent = '';
11150            stepperDiv.textContent = '';
11151            steppers = [];
11152        },
11153        enabled: false,
11154        active: false,
11155        // Stepper specific functions.
11156        create: function create(pageIndex) {
11157            var debug = document.createElement('div');
11158            debug.id = 'stepper' + pageIndex;
11159            debug.setAttribute('hidden', true);
11160            debug.className = 'stepper';
11161            stepperDiv.appendChild(debug);
11162            var b = document.createElement('option');
11163            b.textContent = 'Page ' + (pageIndex + 1);
11164            b.value = pageIndex;
11165            stepperChooser.appendChild(b);
11166            var initBreakPoints = breakPoints[pageIndex] || [];
11167            var stepper = new Stepper(debug, pageIndex, initBreakPoints);
11168            steppers.push(stepper);
11169            if (steppers.length === 1) {
11170                this.selectStepper(pageIndex, false);
11171            }
11172            return stepper;
11173        },
11174        selectStepper: function selectStepper(pageIndex, selectPanel) {
11175            var i;
11176            pageIndex = pageIndex | 0;
11177            if (selectPanel) {
11178                this.manager.selectPanel(this);
11179            }
11180            for (i = 0; i < steppers.length; ++i) {
11181                var stepper = steppers[i];
11182                if (stepper.pageIndex === pageIndex) {
11183                    stepper.panel.removeAttribute('hidden');
11184                } else {
11185                    stepper.panel.setAttribute('hidden', true);
11186                }
11187            }
11188            var options = stepperChooser.options;
11189            for (i = 0; i < options.length; ++i) {
11190                var option = options[i];
11191                option.selected = (option.value | 0) === pageIndex;
11192            }
11193        },
11194        saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
11195            breakPoints[pageIndex] = bps;
11196            sessionStorage.setItem('pdfjsBreakPoints', JSON.stringify(breakPoints));
11197        }
11198    };
11199})();
11200
11201// The stepper for each page's IRQueue.
11202var Stepper = (function StepperClosure() {
11203    // Shorter way to create element and optionally set textContent.
11204    function c(tag, textContent) {
11205        var d = document.createElement(tag);
11206        if (textContent) {
11207            d.textContent = textContent;
11208        }
11209        return d;
11210    }
11211
11212    function simplifyArgs(args) {
11213        if (typeof args === 'string') {
11214            var MAX_STRING_LENGTH = 75;
11215            return args.length <= MAX_STRING_LENGTH ? args :
11216                    args.substr(0, MAX_STRING_LENGTH) + '...';
11217        }
11218        if (typeof args !== 'object' || args === null) {
11219            return args;
11220        }
11221        if ('length' in args) { // array
11222            var simpleArgs = [], i, ii;
11223            var MAX_ITEMS = 10;
11224            for (i = 0, ii = Math.min(MAX_ITEMS, args.length); i < ii; i++) {
11225                simpleArgs.push(simplifyArgs(args[i]));
11226            }
11227            if (i < args.length) {
11228                simpleArgs.push('...');
11229            }
11230            return simpleArgs;
11231        }
11232        var simpleObj = {};
11233        for (var key in args) {
11234            simpleObj[key] = simplifyArgs(args[key]);
11235        }
11236        return simpleObj;
11237    }
11238
11239    function Stepper(panel, pageIndex, initialBreakPoints) {
11240        this.panel = panel;
11241        this.breakPoint = 0;
11242        this.nextBreakPoint = null;
11243        this.pageIndex = pageIndex;
11244        this.breakPoints = initialBreakPoints;
11245        this.currentIdx = -1;
11246        this.operatorListIdx = 0;
11247    }
11248    Stepper.prototype = {
11249        init: function init(operatorList) {
11250            var panel = this.panel;
11251            var content = c('div', 'c=continue, s=step');
11252            var table = c('table');
11253            content.appendChild(table);
11254            table.cellSpacing = 0;
11255            var headerRow = c('tr');
11256            table.appendChild(headerRow);
11257            headerRow.appendChild(c('th', 'Break'));
11258            headerRow.appendChild(c('th', 'Idx'));
11259            headerRow.appendChild(c('th', 'fn'));
11260            headerRow.appendChild(c('th', 'args'));
11261            panel.appendChild(content);
11262            this.table = table;
11263            this.updateOperatorList(operatorList);
11264        },
11265        updateOperatorList: function updateOperatorList(operatorList) {
11266            var self = this;
11267
11268            function cboxOnClick() {
11269                var x = +this.dataset.idx;
11270                if (this.checked) {
11271                    self.breakPoints.push(x);
11272                } else {
11273                    self.breakPoints.splice(self.breakPoints.indexOf(x), 1);
11274                }
11275                StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
11276            }
11277
11278            var MAX_OPERATORS_COUNT = 15000;
11279            if (this.operatorListIdx > MAX_OPERATORS_COUNT) {
11280                return;
11281            }
11282
11283            var chunk = document.createDocumentFragment();
11284            var operatorsToDisplay = Math.min(MAX_OPERATORS_COUNT,
11285                    operatorList.fnArray.length);
11286            for (var i = this.operatorListIdx; i < operatorsToDisplay; i++) {
11287                var line = c('tr');
11288                line.className = 'line';
11289                line.dataset.idx = i;
11290                chunk.appendChild(line);
11291                var checked = this.breakPoints.indexOf(i) !== -1;
11292                var args = operatorList.argsArray[i] || [];
11293
11294                var breakCell = c('td');
11295                var cbox = c('input');
11296                cbox.type = 'checkbox';
11297                cbox.className = 'points';
11298                cbox.checked = checked;
11299                cbox.dataset.idx = i;
11300                cbox.onclick = cboxOnClick;
11301
11302                breakCell.appendChild(cbox);
11303                line.appendChild(breakCell);
11304                line.appendChild(c('td', i.toString()));
11305                var fn = opMap[operatorList.fnArray[i]];
11306                var decArgs = args;
11307                if (fn === 'showText') {
11308                    var glyphs = args[0];
11309                    var newArgs = [];
11310                    var str = [];
11311                    for (var j = 0; j < glyphs.length; j++) {
11312                        var glyph = glyphs[j];
11313                        if (typeof glyph === 'object' && glyph !== null) {
11314                            str.push(glyph.fontChar);
11315                        } else {
11316                            if (str.length > 0) {
11317                                newArgs.push(str.join(''));
11318                                str = [];
11319                            }
11320                            newArgs.push(glyph); // null or number
11321                        }
11322                    }
11323                    if (str.length > 0) {
11324                        newArgs.push(str.join(''));
11325                    }
11326                    decArgs = [newArgs];
11327                }
11328                line.appendChild(c('td', fn));
11329                line.appendChild(c('td', JSON.stringify(simplifyArgs(decArgs))));
11330            }
11331            if (operatorsToDisplay < operatorList.fnArray.length) {
11332                line = c('tr');
11333                var lastCell = c('td', '...');
11334                lastCell.colspan = 4;
11335                chunk.appendChild(lastCell);
11336            }
11337            this.operatorListIdx = operatorList.fnArray.length;
11338            this.table.appendChild(chunk);
11339        },
11340        getNextBreakPoint: function getNextBreakPoint() {
11341            this.breakPoints.sort(function (a, b) {
11342                return a - b;
11343            });
11344            for (var i = 0; i < this.breakPoints.length; i++) {
11345                if (this.breakPoints[i] > this.currentIdx) {
11346                    return this.breakPoints[i];
11347                }
11348            }
11349            return null;
11350        },
11351        breakIt: function breakIt(idx, callback) {
11352            StepperManager.selectStepper(this.pageIndex, true);
11353            var self = this;
11354            var dom = document;
11355            self.currentIdx = idx;
11356            var listener = function (e) {
11357                switch (e.keyCode) {
11358                    case 83: // step
11359                        dom.removeEventListener('keydown', listener);
11360                        self.nextBreakPoint = self.currentIdx + 1;
11361                        self.goTo(-1);
11362                        callback();
11363                        break;
11364                    case 67: // continue
11365                        dom.removeEventListener('keydown', listener);
11366                        var breakPoint = self.getNextBreakPoint();
11367                        self.nextBreakPoint = breakPoint;
11368                        self.goTo(-1);
11369                        callback();
11370                        break;
11371                }
11372            };
11373            dom.addEventListener('keydown', listener);
11374            self.goTo(idx);
11375        },
11376        goTo: function goTo(idx) {
11377            var allRows = this.panel.getElementsByClassName('line');
11378            for (var x = 0, xx = allRows.length; x < xx; ++x) {
11379                var row = allRows[x];
11380                if ((row.dataset.idx | 0) === idx) {
11381                    row.style.backgroundColor = 'rgb(251,250,207)';
11382                    row.scrollIntoView();
11383                } else {
11384                    row.style.backgroundColor = null;
11385                }
11386            }
11387        }
11388    };
11389    return Stepper;
11390})();
11391
11392var Stats = (function Stats() {
11393    var stats = [];
11394    function clear(node) {
11395        while (node.hasChildNodes()) {
11396            node.removeChild(node.lastChild);
11397        }
11398    }
11399    function getStatIndex(pageNumber) {
11400        for (var i = 0, ii = stats.length; i < ii; ++i) {
11401            if (stats[i].pageNumber === pageNumber) {
11402                return i;
11403            }
11404        }
11405        return false;
11406    }
11407    return {
11408        // Properties/functions needed by PDFBug.
11409        id: 'Stats',
11410        name: 'Stats',
11411        panel: null,
11412        manager: null,
11413        init: function init(pdfjsLib) {
11414            this.panel.setAttribute('style', 'padding: 5px;');
11415            pdfjsLib.PDFJS.enableStats = true;
11416        },
11417        enabled: false,
11418        active: false,
11419        // Stats specific functions.
11420        add: function (pageNumber, stat) {
11421            if (!stat) {
11422                return;
11423            }
11424            var statsIndex = getStatIndex(pageNumber);
11425            if (statsIndex !== false) {
11426                var b = stats[statsIndex];
11427                this.panel.removeChild(b.div);
11428                stats.splice(statsIndex, 1);
11429            }
11430            var wrapper = document.createElement('div');
11431            wrapper.className = 'stats';
11432            var title = document.createElement('div');
11433            title.className = 'title';
11434            title.textContent = 'Page: ' + pageNumber;
11435            var statsDiv = document.createElement('div');
11436            statsDiv.textContent = stat.toString();
11437            wrapper.appendChild(title);
11438            wrapper.appendChild(statsDiv);
11439            stats.push({pageNumber: pageNumber, div: wrapper});
11440            stats.sort(function (a, b) {
11441                return a.pageNumber - b.pageNumber;
11442            });
11443            clear(this.panel);
11444            for (var i = 0, ii = stats.length; i < ii; ++i) {
11445                this.panel.appendChild(stats[i].div);
11446            }
11447        },
11448        cleanup: function () {
11449            stats = [];
11450            clear(this.panel);
11451        }
11452    };
11453})();
11454
11455// Manages all the debugging tools.
11456var PDFBug = (function PDFBugClosure() {
11457    var panelWidth = 300;
11458    var buttons = [];
11459    var activePanel = null;
11460
11461    return {
11462        tools: [
11463            FontInspector,
11464            StepperManager,
11465            Stats
11466        ],
11467        enable: function (ids) {
11468            var all = false, tools = this.tools;
11469            if (ids.length === 1 && ids[0] === 'all') {
11470                all = true;
11471            }
11472            for (var i = 0; i < tools.length; ++i) {
11473                var tool = tools[i];
11474                if (all || ids.indexOf(tool.id) !== -1) {
11475                    tool.enabled = true;
11476                }
11477            }
11478            if (!all) {
11479                // Sort the tools by the order they are enabled.
11480                tools.sort(function (a, b) {
11481                    var indexA = ids.indexOf(a.id);
11482                    indexA = indexA < 0 ? tools.length : indexA;
11483                    var indexB = ids.indexOf(b.id);
11484                    indexB = indexB < 0 ? tools.length : indexB;
11485                    return indexA - indexB;
11486                });
11487            }
11488        },
11489        init: function init(pdfjsLib, container) {
11490            /*
11491             * Basic Layout:
11492             * PDFBug
11493             *  Controls
11494             *  Panels
11495             *    Panel
11496             *    Panel
11497             *    ...
11498             */
11499            var ui = document.createElement('div');
11500            ui.id = 'PDFBug';
11501
11502            var controls = document.createElement('div');
11503            controls.setAttribute('class', 'controls');
11504            ui.appendChild(controls);
11505
11506            var panels = document.createElement('div');
11507            panels.setAttribute('class', 'panels');
11508            ui.appendChild(panels);
11509
11510            container.appendChild(ui);
11511            container.style.right = panelWidth + 'px';
11512
11513            // Initialize all the debugging tools.
11514            var tools = this.tools;
11515            var self = this;
11516            for (var i = 0; i < tools.length; ++i) {
11517                var tool = tools[i];
11518                var panel = document.createElement('div');
11519                var panelButton = document.createElement('button');
11520                panelButton.textContent = tool.name;
11521                panelButton.addEventListener('click', (function (selected) {
11522                    return function (event) {
11523                        event.preventDefault();
11524                        self.selectPanel(selected);
11525                    };
11526                })(i));
11527                controls.appendChild(panelButton);
11528                panels.appendChild(panel);
11529                tool.panel = panel;
11530                tool.manager = this;
11531                if (tool.enabled) {
11532                    tool.init(pdfjsLib);
11533                } else {
11534                    panel.textContent = tool.name + ' is disabled. To enable add ' +
11535                            ' "' + tool.id + '" to the pdfBug parameter ' +
11536                            'and refresh (separate multiple by commas).';
11537                }
11538                buttons.push(panelButton);
11539            }
11540            this.selectPanel(0);
11541        },
11542        cleanup: function cleanup() {
11543            for (var i = 0, ii = this.tools.length; i < ii; i++) {
11544                if (this.tools[i].enabled) {
11545                    this.tools[i].cleanup();
11546                }
11547            }
11548        },
11549        selectPanel: function selectPanel(index) {
11550            if (typeof index !== 'number') {
11551                index = this.tools.indexOf(index);
11552            }
11553            if (index === activePanel) {
11554                return;
11555            }
11556            activePanel = index;
11557            var tools = this.tools;
11558            for (var j = 0; j < tools.length; ++j) {
11559                if (j === index) {
11560                    buttons[j].setAttribute('class', 'active');
11561                    tools[j].active = true;
11562                    tools[j].panel.removeAttribute('hidden');
11563                } else {
11564                    buttons[j].setAttribute('class', '');
11565                    tools[j].active = false;
11566                    tools[j].panel.setAttribute('hidden', 'true');
11567                }
11568            }
11569        }
11570    };
11571})();
11572/* Copyright 2017 Mozilla Foundation
11573 *
11574 * Licensed under the Apache License, Version 2.0 (the "License");
11575 * you may not use this file except in compliance with the License.
11576 * You may obtain a copy of the License at
11577 *
11578 *     http://www.apache.org/licenses/LICENSE-2.0
11579 *
11580 * Unless required by applicable law or agreed to in writing, software
11581 * distributed under the License is distributed on an "AS IS" BASIS,
11582 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11583 * See the License for the specific language governing permissions and
11584 * limitations under the License.
11585 */
11586
11587/******/ (function (modules) { // webpackBootstrap
11588    /******/ 	// The module cache
11589    /******/ 	var installedModules = {};
11590    /******/
11591    /******/ 	// The require function
11592    /******/ 	function __webpack_require__(moduleId) {
11593        /******/
11594        /******/ 		// Check if module is in cache
11595        /******/ 		if (installedModules[moduleId])
11596            /******/ 			return installedModules[moduleId].exports;
11597        /******/
11598        /******/ 		// Create a new module (and put it into the cache)
11599        /******/ 		var module = installedModules[moduleId] = {
11600            /******/ 			i: moduleId,
11601            /******/ 			l: false,
11602            /******/ 			exports: {}
11603            /******/};
11604        /******/
11605        /******/ 		// Execute the module function
11606        /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
11607        /******/
11608        /******/ 		// Flag the module as loaded
11609        /******/ 		module.l = true;
11610        /******/
11611        /******/ 		// Return the exports of the module
11612        /******/ 		return module.exports;
11613        /******/ 	}
11614    /******/
11615    /******/
11616    /******/ 	// expose the modules object (__webpack_modules__)
11617    /******/ 	__webpack_require__.m = modules;
11618    /******/
11619    /******/ 	// expose the module cache
11620    /******/ 	__webpack_require__.c = installedModules;
11621    /******/
11622    /******/ 	// identity function for calling harmony imports with the correct context
11623    /******/ 	__webpack_require__.i = function (value) {
11624        return value;
11625    };
11626    /******/
11627    /******/ 	// define getter function for harmony exports
11628    /******/ 	__webpack_require__.d = function (exports, name, getter) {
11629        /******/ 		if (!__webpack_require__.o(exports, name)) {
11630            /******/ 			Object.defineProperty(exports, name, {
11631                /******/ 				configurable: false,
11632                /******/ 				enumerable: true,
11633                /******/ 				get: getter
11634                        /******/});
11635            /******/ 		}
11636        /******/ 	};
11637    /******/
11638    /******/ 	// getDefaultExport function for compatibility with non-harmony modules
11639    /******/ 	__webpack_require__.n = function (module) {
11640        /******/ 		var getter = module && module.__esModule ?
11641                /******/ 			function getDefault() {
11642                    return module['default'];
11643                } :
11644                /******/ 			function getModuleExports() {
11645                    return module;
11646                };
11647        /******/ 		__webpack_require__.d(getter, 'a', getter);
11648        /******/ 		return getter;
11649        /******/ 	};
11650    /******/
11651    /******/ 	// Object.prototype.hasOwnProperty.call
11652    /******/ 	__webpack_require__.o = function (object, property) {
11653        return Object.prototype.hasOwnProperty.call(object, property);
11654    };
11655    /******/
11656    /******/ 	// __webpack_public_path__
11657    /******/ 	__webpack_require__.p = "";
11658    /******/
11659    /******/ 	// Load entry module and return exports
11660    /******/ 	return __webpack_require__(__webpack_require__.s = 30);
11661    /******/ })
11662        /************************************************************************/
11663                /******/([
11664                    /* 0 */
11665                    /***/ (function (module, exports, __webpack_require__) {
11666
11667                        "use strict";
11668
11669                        var pdfjsLib = __webpack_require__(1);
11670                        var CSS_UNITS = 96.0 / 72.0;
11671                        var DEFAULT_SCALE_VALUE = 'auto';
11672                        var DEFAULT_SCALE = 1.0;
11673                        var MIN_SCALE = 0.25;
11674                        var MAX_SCALE = 10.0;
11675                        var UNKNOWN_SCALE = 0;
11676                        var MAX_AUTO_SCALE = 1.25;
11677                        var SCROLLBAR_PADDING = 40;
11678                        var VERTICAL_PADDING = 5;
11679                        var RendererType = {
11680                            CANVAS: 'canvas',
11681                            SVG: 'svg'
11682                        };
11683                        var mozL10n = document.mozL10n || document.webL10n;
11684                        var PDFJS = pdfjsLib.PDFJS;
11685                        PDFJS.disableFullscreen = PDFJS.disableFullscreen === undefined ? false : PDFJS.disableFullscreen;
11686                        PDFJS.useOnlyCssZoom = PDFJS.useOnlyCssZoom === undefined ? false : PDFJS.useOnlyCssZoom;
11687                        PDFJS.maxCanvasPixels = PDFJS.maxCanvasPixels === undefined ? 16777216 : PDFJS.maxCanvasPixels;
11688                        PDFJS.disableHistory = PDFJS.disableHistory === undefined ? false : PDFJS.disableHistory;
11689                        PDFJS.disableTextLayer = PDFJS.disableTextLayer === undefined ? false : PDFJS.disableTextLayer;
11690                        PDFJS.ignoreCurrentPositionOnZoom = PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : PDFJS.ignoreCurrentPositionOnZoom;
11691                        PDFJS.locale = PDFJS.locale === undefined ? navigator.language : PDFJS.locale;
11692                        function getOutputScale(ctx) {
11693                            var devicePixelRatio = window.devicePixelRatio || 1;
11694                            var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
11695                            var pixelRatio = devicePixelRatio / backingStoreRatio;
11696                            return {
11697                                sx: pixelRatio,
11698                                sy: pixelRatio,
11699                                scaled: pixelRatio !== 1
11700                            };
11701                        }
11702                        function scrollIntoView(element, spot, skipOverflowHiddenElements) {
11703                            var parent = element.offsetParent;
11704                            if (!parent) {
11705                                console.error('offsetParent is not set -- cannot scroll');
11706                                return;
11707                            }
11708                            var checkOverflow = skipOverflowHiddenElements || false;
11709                            var offsetY = element.offsetTop + element.clientTop;
11710                            var offsetX = element.offsetLeft + element.clientLeft;
11711                            while (parent.clientHeight === parent.scrollHeight || checkOverflow && getComputedStyle(parent).overflow === 'hidden') {
11712                                if (parent.dataset._scaleY) {
11713                                    offsetY /= parent.dataset._scaleY;
11714                                    offsetX /= parent.dataset._scaleX;
11715                                }
11716                                offsetY += parent.offsetTop;
11717                                offsetX += parent.offsetLeft;
11718                                parent = parent.offsetParent;
11719                                if (!parent) {
11720                                    return;
11721                                }
11722                            }
11723                            if (spot) {
11724                                if (spot.top !== undefined) {
11725                                    offsetY += spot.top;
11726                                }
11727                                if (spot.left !== undefined) {
11728                                    offsetX += spot.left;
11729                                    parent.scrollLeft = offsetX;
11730                                }
11731                            }
11732                            parent.scrollTop = offsetY;
11733                        }
11734                        function watchScroll(viewAreaElement, callback) {
11735                            var debounceScroll = function debounceScroll(evt) {
11736                                if (rAF) {
11737                                    return;
11738                                }
11739                                rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
11740                                    rAF = null;
11741                                    var currentY = viewAreaElement.scrollTop;
11742                                    var lastY = state.lastY;
11743                                    if (currentY !== lastY) {
11744                                        state.down = currentY > lastY;
11745                                    }
11746                                    state.lastY = currentY;
11747                                    callback(state);
11748                                });
11749                            };
11750                            var state = {
11751                                down: true,
11752                                lastY: viewAreaElement.scrollTop,
11753                                _eventHandler: debounceScroll
11754                            };
11755                            var rAF = null;
11756                            viewAreaElement.addEventListener('scroll', debounceScroll, true);
11757                            return state;
11758                        }
11759                        function parseQueryString(query) {
11760                            var parts = query.split('&');
11761                            var params = {};
11762                            for (var i = 0, ii = parts.length; i < ii; ++i) {
11763                                var param = parts[i].split('=');
11764                                var key = param[0].toLowerCase();
11765                                var value = param.length > 1 ? param[1] : null;
11766                                params[decodeURIComponent(key)] = decodeURIComponent(value);
11767                            }
11768                            return params;
11769                        }
11770                        function binarySearchFirstItem(items, condition) {
11771                            var minIndex = 0;
11772                            var maxIndex = items.length - 1;
11773                            if (items.length === 0 || !condition(items[maxIndex])) {
11774                                return items.length;
11775                            }
11776                            if (condition(items[minIndex])) {
11777                                return minIndex;
11778                            }
11779                            while (minIndex < maxIndex) {
11780                                var currentIndex = minIndex + maxIndex >> 1;
11781                                var currentItem = items[currentIndex];
11782                                if (condition(currentItem)) {
11783                                    maxIndex = currentIndex;
11784                                } else {
11785                                    minIndex = currentIndex + 1;
11786                                }
11787                            }
11788                            return minIndex;
11789                        }
11790                        function approximateFraction(x) {
11791                            if (Math.floor(x) === x) {
11792                                return [
11793                                    x,
11794                                    1
11795                                ];
11796                            }
11797                            var xinv = 1 / x;
11798                            var limit = 8;
11799                            if (xinv > limit) {
11800                                return [
11801                                    1,
11802                                    limit
11803                                ];
11804                            } else if (Math.floor(xinv) === xinv) {
11805                                return [
11806                                    1,
11807                                    xinv
11808                                ];
11809                            }
11810                            var x_ = x > 1 ? xinv : x;
11811                            var a = 0, b = 1, c = 1, d = 1;
11812                            while (true) {
11813                                var p = a + c, q = b + d;
11814                                if (q > limit) {
11815                                    break;
11816                                }
11817                                if (x_ <= p / q) {
11818                                    c = p;
11819                                    d = q;
11820                                } else {
11821                                    a = p;
11822                                    b = q;
11823                                }
11824                            }
11825                            var result;
11826                            if (x_ - a / b < c / d - x_) {
11827                                result = x_ === x ? [
11828                                    a,
11829                                    b
11830                                ] : [
11831                                    b,
11832                                    a
11833                                ];
11834                            } else {
11835                                result = x_ === x ? [
11836                                    c,
11837                                    d
11838                                ] : [
11839                                    d,
11840                                    c
11841                                ];
11842                            }
11843                            return result;
11844                        }
11845                        function roundToDivide(x, div) {
11846                            var r = x % div;
11847                            return r === 0 ? x : Math.round(x - r + div);
11848                        }
11849                        function getVisibleElements(scrollEl, views, sortByVisibility) {
11850                            var top = scrollEl.scrollTop, bottom = top + scrollEl.clientHeight;
11851                            var left = scrollEl.scrollLeft, right = left + scrollEl.clientWidth;
11852                            function isElementBottomBelowViewTop(view) {
11853                                var element = view.div;
11854                                var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
11855                                return elementBottom > top;
11856                            }
11857                            var visible = [], view, element;
11858                            var currentHeight, viewHeight, hiddenHeight, percentHeight;
11859                            var currentWidth, viewWidth;
11860                            var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
11861                            for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
11862                                view = views[i];
11863                                element = view.div;
11864                                currentHeight = element.offsetTop + element.clientTop;
11865                                viewHeight = element.clientHeight;
11866                                if (currentHeight > bottom) {
11867                                    break;
11868                                }
11869                                currentWidth = element.offsetLef
11869t + element.clientLeft;
11870                                viewWidth = element.clientWidth;
11871                                if (currentWidth + viewWidth < left || currentWidth > right) {
11872                                    continue;
11873                                }
11874                                hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
11875                                percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
11876                                visible.push({
11877                                    id: view.id,
11878                                    x: currentWidth,
11879                                    y: currentHeight,
11880                                    view: view,
11881                                    percent: percentHeight
11882                                });
11883                            }
11884                            var first = visible[0];
11885                            var last = visible[visible.length - 1];
11886                            if (sortByVisibility) {
11887                                visible.sort(function (a, b) {
11888                                    var pc = a.percent - b.percent;
11889                                    if (Math.abs(pc) > 0.001) {
11890                                        return -pc;
11891                                    }
11892                                    return a.id - b.id;
11893                                });
11894                            }
11895                            return {
11896                                first: first,
11897                                last: last,
11898                                views: visible
11899                            };
11900                        }
11901                        function noContextMenuHandler(e) {
11902                            e.preventDefault();
11903                        }
11904                        function getPDFFileNameFromURL(url, defaultFilename) {
11905                            if (typeof defaultFilename === 'undefined') {
11906                                defaultFilename = 'document.pdf';
11907                            }
11908                            var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
11909                            var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
11910                            var splitURI = reURI.exec(url);
11911                            var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
11912                            if (suggestedFilename) {
11913                                suggestedFilename = suggestedFilename[0];
11914                                if (suggestedFilename.indexOf('%') !== -1) {
11915                                    try {
11916                                        suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
11917                                    } catch (e) {
11918                                    }
11919                                }
11920                            }
11921                            return suggestedFilename || defaultFilename;
11922                        }
11923                        function normalizeWheelEventDelta(evt) {
11924                            var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
11925                            var angle = Math.atan2(evt.deltaY, evt.deltaX);
11926                            if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
11927                                delta = -delta;
11928                            }
11929                            var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
11930                            var MOUSE_DOM_DELTA_LINE_MODE = 1;
11931                            var MOUSE_PIXELS_PER_LINE = 30;
11932                            var MOUSE_LINES_PER_PAGE = 30;
11933                            if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
11934                                delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
11935                            } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
11936                                delta /= MOUSE_LINES_PER_PAGE;
11937                            }
11938                            return delta;
11939                        }
11940                        var animationStarted = new Promise(function (resolve) {
11941                            window.requestAnimationFrame(resolve);
11942                        });
11943                        var localized = new Promise(function (resolve, reject) {
11944                            if (!mozL10n) {
11945                                resolve();
11946                                return;
11947                            }
11948                            if (mozL10n.getReadyState() !== 'loading') {
11949                                resolve();
11950                                return;
11951                            }
11952                            window.addEventListener('localized', function localized(evt) {
11953                                resolve();
11954                            });
11955                        });
11956                        var EventBus = function EventBusClosure() {
11957                            function EventBus() {
11958                                this._listeners = Object.create(null);
11959                            }
11960                            EventBus.prototype = {
11961                                on: function EventBus_on(eventName, listener) {
11962                                    var eventListeners = this._listeners[eventName];
11963                                    if (!eventListeners) {
11964                                        eventListeners = [];
11965                                        this._listeners[eventName] = eventListeners;
11966                                    }
11967                                    eventListeners.push(listener);
11968                                },
11969                                off: function EventBus_on(eventName, listener) {
11970                                    var eventListeners = this._listeners[eventName];
11971                                    var i;
11972                                    if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
11973                                        return;
11974                                    }
11975                                    eventListeners.splice(i, 1);
11976                                },
vendor: 8,758 bytes, lines 11977-12126
11977                                dispatch: function EventBus_dispath(eventName) {
11978                                    var eventListeners = this._listeners[eventName];
11979                                    if (!eventListeners || eventListeners.length === 0) {
11980                                        return;
11981                                    }
11982                                    var args = Array.prototype.slice.call(arguments, 1);
11983                                    eventListeners.slice(0).forEach(function (listener) {
11984                                        listener.apply(null, args);
11985                                    });
11986                                }
11987                            };
11988                            return EventBus;
11989                        }();
11990                        var ProgressBar = function ProgressBarClosure() {
11991                            function clamp(v, min, max) {
11992                                return Math.min(Math.max(v, min), max);
11993                            }
11994                            function ProgressBar(id, opts) {
11995                                this.visible = true;
11996                                this.div = document.querySelector(id + ' .progress');
11997                                this.bar = this.div.parentNode;
11998                                this.height = opts.height || 100;
11999                                this.width = opts.width || 100;
12000                                this.units = opts.units || '%';
12001                                this.div.style.height = this.height + this.units;
12002                                this.percent = 0;
12003                            }
12004                            ProgressBar.prototype = {
12005                                updateBar: function ProgressBar_updateBar() {
12006                                    if (this._indeterminate) {
12007                                        this.div.classList.add('indeterminate');
12008                                        this.div.style.width = this.width + this.units;
12009                                        return;
12010                                    }
12011                                    this.div.classList.remove('indeterminate');
12012                                    var progressSize = this.width * this._percent / 100;
12013                                    this.div.style.width = progressSize + this.units;
12014                                },
12015                                get percent() {
12016                                    return this._percent;
12017                                },
12018                                set percent(val) {
12019                                    this._indeterminate = isNaN(val);
12020                                    this._percent = clamp(val, 0, 100);
12021                                    this.updateBar();
12022                                },
12023                                setWidth: function ProgressBar_setWidth(viewer) {
12024                                    if (viewer) {
12025                                        var container = viewer.parentNode;
12026                                        var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
12027                                        if (scrollbarWidth > 0) {
12028                                            this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
12029                                        }
12030                                    }
12031                                },
12032                                hide: function ProgressBar_hide() {
12033                                    if (!this.visible) {
12034                                        return;
12035                                    }
12036                                    this.visible = false;
12037                                    this.bar.classList.add('hidden');
12038                                    document.body.classList.remove('loadingInProgress');
12039                                },
12040                                show: function ProgressBar_show() {
12041                                    if (this.visible) {
12042                                        return;
12043                                    }
12044                                    this.visible = true;
12045                                    document.body.classList.add('loadingInProgress');
12046                                    this.bar.classList.remove('hidden');
12047                                }
12048                            };
12049                            return ProgressBar;
12050                        }();
12051                        exports.CSS_UNITS = CSS_UNITS;
12052                        exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
12053                        exports.DEFAULT_SCALE = DEFAULT_SCALE;
12054                        exports.MIN_SCALE = MIN_SCALE;
12055                        exports.MAX_SCALE = MAX_SCALE;
12056                        exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
12057                        exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
12058                        exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
12059                        exports.VERTICAL_PADDING = VERTICAL_PADDING;
12060                        exports.RendererType = RendererType;
12061                        exports.mozL10n = mozL10n;
12062                        exports.EventBus = EventBus;
12063                        exports.ProgressBar = ProgressBar;
12064                        exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
12065                        exports.noContextMenuHandler = noContextMenuHandler;
12066                        exports.parseQueryString = parseQueryString;
12067                        exports.getVisibleElements = getVisibleElements;
12068                        exports.roundToDivide = roundToDivide;
12069                        exports.approximateFraction = approximateFraction;
12070                        exports.getOutputScale = getOutputScale;
12071                        exports.scrollIntoView = scrollIntoView;
12072                        exports.watchScroll = watchScroll;
12073                        exports.binarySearchFirstItem = binarySearchFirstItem;
12074                        exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
12075                        exports.animationStarted = animationStarted;
12076                        exports.localized = localized;
12077
12078                        /***/ }),
12079                    /* 1 */
12080                    /***/ (function (module, exports, __webpack_require__) {
12081
12082                        "use strict";
12083
12084                        {
12085                            var pdfjsLib;
12086                            if (typeof __pdfjsdev_webpack__ === 'undefined') {
12087                                if (typeof require === 'function') {
12088                                    pdfjsLib = require('../build/pdf.js');
12089                                } else {
12090                                    pdfjsLib = window['pdfjs-dist/build/pdf'];
12091                                }
12092                            }
12093                            module.exports = pdfjsLib;
12094                        }
12095
12096                        /***/ }),
12097                    /* 2 */
12098                    /***/ (function (module, exports, __webpack_require__) {
12099
12100                        "use strict";
12101
12102                        var uiUtils = __webpack_require__(0);
12103                        var EventBus = uiUtils.EventBus;
12104                        function attachDOMEventsToEventBus(eventBus) {
12105                            eventBus.on('documentload', function () {
12106                                var event = document.createEvent('CustomEvent');
12107                                event.initCustomEvent('documentload', true, true, {});
12108                                window.dispatchEvent(event);
12109                            });
12110                            eventBus.on('pagerendered', function (e) {
12111                                var event = document.createEvent('CustomEvent');
12112                                event.initCustomEvent('pagerendered', true, true, {
12113                                    pageNumber: e.pageNumber,
12114                                    cssTransform: e.cssTransform
12115                                });
12116                                e.source.div.dispatchEvent(event);
12117                            });
12118                            eventBus.on('textlayerrendered', function (e) {
12119                                var event = document.createEvent('CustomEvent');
12120                                event.initCustomEvent('textlayerrendered', true, true, {pageNumber: e.pageNumber});
12121                                e.source.textLayerDiv.dispatchEvent(event);
12122                            });
12123                            eventBus.on('pagechange', function (e) {
12124                                var event = document.createEvent('UIEvents');
12125                                event.initUIEvent('pagechange', true, true, window, 0);
12126                                event.pageNumber = e.pageNumber;
12127                                e.source.container.dispatchEvent(event);
12128                            });
12129                            eventBus.on('pagesinit', function (e) {
12130                                var event = document.createEvent('CustomEvent');
12131                                event.initCustomEvent('pagesinit', true, true, null);
12132                                e.source.container.dispatchEvent(event);
12133                            });
12134                            eventBus.on('pagesloaded', function (e) {
12135                                var event = document.createEvent('CustomEvent');
12136                                event.initCustomEvent('pagesloaded', true, true, {pagesCount: e.pagesCount});
12137                                e.source.container.dispatchEvent(event);
12138                            });
12139                            eventBus.on('scalechange', function (e) {
12140                                var event = document.createEvent('UIEvents');
12141                                event.initUIEvent('scalechange', true, true, window, 0);
12142                                event.scale = e.scale;
12143                                event.presetValue = e.presetValue;
12144                                e.source.container.dispatchEvent(event);
12145                            });
12146                            eventBus.on('updateviewarea', function (e) {
12147                                var event = document.createEvent('UIEvents');
12148                                event.initUIEvent('updateviewarea', true, true, window, 0);
12149                                event.location = e.location;
12150                                e.source.container.dispatchEvent(event);
12151                            });
12152                            eventBus.on('find', function (e) {
12153                                if (e.source === window) {
12154                                    return;
12155                                }
12156                                var event = document.createEvent('CustomEvent');
12157                                event.initCustomEvent('find' + e.type, true, true, {
12158                                    query: e.query,
12159                                    phraseSearch: e.phraseSearch,
12160                                    caseSensitive: e.caseSensitive,
12161                                    highlightAll: e.highlightAll,
12162                                    findPrevious: e.findPrevious
12163                                });
12164                                window.dispatchEvent(event);
12165                            });
12166                            eventBus.on('attachmentsloaded', function (e) {
12167                                var event = document.createEvent('CustomEvent');
12168                                event.initCustomEvent('attachmentsloaded', true, true, {attachmentsCount: e.attachmentsCount});
12169                                e.source.container.dispatchEvent(event);
12170                            });
12171                            eventBus.on('sidebarviewchanged', function (e) {
12172                                var event = document.createEvent('CustomEvent');
12173                                event.initCustomEvent('sidebarviewchanged', true, true, {view: e.view});
12174                                e.source.outerContainer.dispatchEvent(event);
12175                            });
12176                            eventBus.on('pagemode', function (e) {
12177                                var event = document.createEvent('CustomEvent');
12178                                event.initCustomEvent('pagemode', true, true, {mode: e.mode});
12179                                e.source.pdfViewer.container.dispatchEvent(event);
12180                            });
12181                            eventBus.on('namedaction', function (e) {
12182                                var event = document.createEvent('CustomEvent');
12183                                event.initCustomEvent('namedaction', true, true, {action: e.action});
12184                                e.source.pdfViewer.container.dispatchEvent(event);
12185                            });
12186                            eventBus.on('presentationmodechanged', function (e) {
12187                                var event = document.createEvent('CustomEvent');
12188                                event.initCustomEvent('presentationmodechanged', true, true, {
12189                                    active: e.active,
12190                                    switchInProgress: e.switchInProgress
12191                                });
12192                                window.dispatchEvent(event);
12193                            });
12194                            eventBus.on('outlineloaded', function (e) {
12195                                var event = document.createEvent('CustomEvent');
12196                                event.initCustomEvent('outlineloaded', true, true, {outlineCount: e.outlineCount});
vendor: 14,809 bytes, lines 12197-12444
12197                                e.source.container.dispatchEvent(event);
12198                            });
12199                        }
12200                        var globalEventBus = null;
12201                        function getGlobalEventBus() {
12202                            if (globalEventBus) {
12203                                return globalEventBus;
12204                            }
12205                            globalEventBus = new EventBus();
12206                            attachDOMEventsToEventBus(globalEventBus);
12207                            return globalEventBus;
12208                        }
12209                        exports.attachDOMEventsToEventBus = attachDOMEventsToEventBus;
12210                        exports.getGlobalEventBus = getGlobalEventBus;
12211
12212                        /***/ }),
12213                    /* 3 */
12214                    /***/ (function (module, exports, __webpack_require__) {
12215
12216                        "use strict";
12217
12218                        var CLEANUP_TIMEOUT = 30000;
12219                        var RenderingStates = {
12220                            INITIAL: 0,
12221                            RUNNING: 1,
12222                            PAUSED: 2,
12223                            FINISHED: 3
12224                        };
12225                        var PDFRenderingQueue = function PDFRenderingQueueClosure() {
12226                            function PDFRenderingQueue() {
12227                                this.pdfViewer = null;
12228                                this.pdfThumbnailViewer = null;
12229                                this.onIdle = null;
12230                                this.highestPriorityPage = null;
12231                                this.idleTimeout = null;
12232                                this.printing = false;
12233                                this.isThumbnailViewEnabled = false;
12234                            }
12235                            PDFRenderingQueue.prototype = {
12236                                setViewer: function PDFRenderingQueue_setViewer(pdfViewer) {
12237                                    this.pdfViewer = pdfViewer;
12238                                },
12239                                setThumbnailViewer: function PDFRenderingQueue_setThumbnailViewer(pdfThumbnailViewer) {
12240                                    this.pdfThumbnailViewer = pdfThumbnailViewer;
12241                                },
12242                                isHighestPriority: function PDFRenderingQueue_isHighestPriority(view) {
12243                                    return this.highestPriorityPage === view.renderingId;
12244                                },
12245                                renderHighestPriority: function PDFRenderingQueue_renderHighestPriority(currentlyVisiblePages) {
12246                                    if (this.idleTimeout) {
12247                                        clearTimeout(this.idleTimeout);
12248                                        this.idleTimeout = null;
12249                                    }
12250                                    if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
12251                                        return;
12252                                    }
12253                                    if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
12254                                        if (this.pdfThumbnailViewer.forceRendering()) {
12255                                            return;
12256                                        }
12257                                    }
12258                                    if (this.printing) {
12259                                        return;
12260                                    }
12261                                    if (this.onIdle) {
12262                                        this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
12263                                    }
12264                                },
12265                                getHighestPriority: function PDFRenderingQueue_getHighestPriority(visible, views, scrolledDown) {
12266                                    var visibleViews = visible.views;
12267                                    var numVisible = visibleViews.length;
12268                                    if (numVisible === 0) {
12269                                        return false;
12270                                    }
12271                                    for (var i = 0; i < numVisible; ++i) {
12272                                        var view = visibleViews[i].view;
12273                                        if (!this.isViewFinished(view)) {
12274                                            return view;
12275                                        }
12276                                    }
12277                                    if (scrolledDown) {
12278                                        var nextPageIndex = visible.last.id;
12279                                        if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
12280                                            return views[nextPageIndex];
12281                                        }
12282                                    } else {
12283                                        var previousPageIndex = visible.first.id - 2;
12284                                        if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
12285                                            return views[previousPageIndex];
12286                                        }
12287                                    }
12288                                    return null;
12289                                },
12290                                isViewFinished: function PDFRenderingQueue_isViewFinished(view) {
12291                                    return view.renderingState === RenderingStates.FINISHED;
12292                                },
12293                                renderView: function PDFRenderingQueue_renderView(view) {
12294                                    var state = view.renderingState;
12295                                    switch (state) {
12296                                        case RenderingStates.FINISHED:
12297                                            return false;
12298                                        case RenderingStates.PAUSED:
12299                                            this.highestPriorityPage = view.renderingId;
12300                                            view.resume();
12301                                            break;
12302                                        case RenderingStates.RUNNING:
12303                                            this.highestPriorityPage = view.renderingId;
12304                                            break;
12305                                        case RenderingStates.INITIAL:
12306                                            this.highestPriorityPage = view.renderingId;
12307                                            var continueRendering = function () {
12308                                                this.renderHighestPriority();
12309                                            }.bind(this);
12310                                            view.draw().then(continueRendering, continueRendering);
12311                                            break;
12312                                    }
12313                                    return true;
12314                                }
12315                            };
12316                            return PDFRenderingQueue;
12317                        }();
12318                        exports.RenderingStates = RenderingStates;
12319                        exports.PDFRenderingQueue = PDFRenderingQueue;
12320
12321                        /***/ }),
12322                    /* 4 */
12323                    /***/ (function (module, exports, __webpack_require__) {
12324
12325                        "use strict";
12326
12327                        var OverlayManager = {
12328                            overlays: {},
12329                            active: null,
12330                            register: function overlayManagerRegister(name, element, callerCloseMethod, canForceClose) {
12331                                return new Promise(function (resolve) {
12332                                    var container;
12333                                    if (!name || !element || !(container = element.parentNode)) {
12334                                        throw new Error('Not enough parameters.');
12335                                    } else if (this.overlays[name]) {
12336                                        if (this.active !== name) {
12337                                            this.unregister(name);
12338                                        } else {
12339                                            throw new Error('The overlay is already registered and active.');
12340                                        }
12341                                    }
12342                                    this.overlays[name] = {
12343                                        element: element,
12344                                        container: container,
12345                                        callerCloseMethod: callerCloseMethod || null,
12346                                        canForceClose: canForceClose || false
12347                                    };
12348                                    resolve();
12349                                }.bind(this));
12350                            },
12351                            unregister: function overlayManagerUnregister(name) {
12352                                return new Promise(function (resolve) {
12353                                    if (!this.overlays[name]) {
12354                                        throw new Error('The overlay does not exist.');
12355                                    } else if (this.active === name) {
12356                                        throw new Error('The overlay cannot be removed while it is active.');
12357                                    }
12358                                    delete this.overlays[name];
12359                                    resolve();
12360                                }.bind(this));
12361                            },
12362                            open: function overlayManagerOpen(name) {
12363                                return new Promise(function (resolve) {
12364                                    if (!this.overlays[name]) {
12365                                        throw new Error('The overlay does not exist.');
12366                                    } else if (this.active) {
12367                                        if (this.overlays[name].canForceClose) {
12368                                            this._closeThroughCaller();
12369                                        } else if (this.active === name) {
12370                                            throw new Error('The overlay is already active.');
12371                                        } else {
12372                                            throw new Error('Another overlay is currently active.');
12373                                        }
12374                                    }
12375                                    this.active = name;
12376                                    this.overlays[this.active].element.classList.remove('hidden');
12377                                    this.overlays[this.active].container.classList.remove('hidden');
12378                                    window.addEventListener('keydown', this._keyDown);
12379                                    resolve();
12380                                }.bind(this));
12381                            },
12382                            close: function overlayManagerClose(name) {
12383                                return new Promise(function (resolve) {
12384                                    if (!this.overlays[name]) {
12385                                        throw new Error('The overlay does not exist.');
12386                                    } else if (!this.active) {
12387                                        throw new Error('The overlay is currently not active.');
12388                                    } else if (this.active !== name) {
12389                                        throw new Error('Another overlay is currently active.');
12390                                    }
12391                                    this.overlays[this.active].container.classList.add('hidden');
12392                                    this.overlays[this.active].element.classList.add('hidden');
12393                                    this.active = null;
12394                                    window.removeEventListener('keydown', this._keyDown);
12395                                    resolve();
12396                                }.bind(this));
12397                            },
12398                            _keyDown: function overlayManager_keyDown(evt) {
12399                                var self = OverlayManager;
12400                                if (self.active && evt.keyCode === 27) {
12401                                    self._closeThroughCaller();
12402                                    evt.preventDefault();
12403                                }
12404                            },
12405                            _closeThroughCaller: function overlayManager_closeThroughCaller() {
12406                                if (this.overlays[this.active].callerCloseMethod) {
12407                                    this.overlays[this.active].callerCloseMethod();
12408                                }
12409                                if (this.active) {
12410                                    this.close(this.active);
12411                                }
12412                            }
12413                        };
12414                        exports.OverlayManager = OverlayManager;
12415
12416                        /***/ }),
12417                    /* 5 */
12418                    /***/ (function (module, exports, __webpack_require__) {
12419
12420                        "use strict";
12421
12422                        var uiUtils = __webpack_require__(0);
12423                        var domEvents = __webpack_require__(2);
12424                        var parseQueryString = uiUtils.parseQueryString;
12425                        var PageNumberRegExp = /^\d+$/;
12426                        function isPageNumber(str) {
12427                            return PageNumberRegExp.test(str);
12428                        }
12429                        var PDFLinkService = function PDFLinkServiceClosure() {
12430                            function PDFLinkService(options) {
12431                                options = options || {};
12432                                this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
12433                                this.baseUrl = null;
12434                                this.pdfDocument = null;
12435                                this.pdfViewer = null;
12436                                this.pdfHistory = null;
12437                                this._pagesRefCache = null;
12438                            }
12439                            PDFLinkService.prototype = {
12440                                setDocument: function PDFLinkService_setDocument(pdfDocument, baseUrl) {
12441                                    this.baseUrl = baseUrl;
12442                                    this.pdfDocument = pdfDocument;
12443                                    this._pagesRefCache = Object.create(null);
12444                                },
12445                                setViewer: function PDFLinkService_setViewer(pdfViewer) {
12446                                    this.pdfViewer = pdfViewer;
12447                                },
12448                                setHistory: function PDFLinkService_setHistory(pdfHistory) {
12449                                    this.pdfHistory = pdfHistory;
12450                                },
12451                                get pagesCount() {
12452                                    return this.pdfDocument ? this.pdfDocument.numPages : 0;
12453                                },
12454                                get page() {
12455                                    return this.pdfViewer.currentPageNumber;
12456                                },
12457                                set page(value) {
12458                                    this.pdfViewer.currentPageNumber = value;
12459                                },
12460                                navigateTo: function PDFLinkService_navigateTo(dest) {
12461                                    var destString = '';
12462                                    var self = this;
12463                                    var goToDestination = function (destRef) {
12464                                        var pageNumber;
12465                                        if (destRef instanceof Object) {
12466                                            pageNumber = self._cachedPageNumber(destRef);
12467                                        } else if ((destRef | 0) === destRef) {
12468                                            pageNumber = destRef + 1;
12469                                        } else {
12470                                            console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid destination reference.');
12471                                            return;
12472                                        }
12473                                        if (pageNumber) {
12474                                            if (pageNumber < 1 || pageNumber > self.pagesCount) {
12475                                                console.error('PDFLinkService_navigateTo: "' + pageNumber + '" is a non-existent page number.');
12476                                                return;
12477                                            }
12478                                            self.pdfViewer.scrollPageIntoView({
12479                                                pageNumber: pageNumber,
12480                                                destArray: dest
12481                                            });
12482                                            if (self.pdfHistory) {
12483                                                self.pdfHistory.push({
12484                                                    dest: dest,
12485                                                    hash: destString,
12486                                                    page: pageNumber
12487                                                });
12488                                            }
12489                                        } else {
12490                                            self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
12491                                                self.cachePageRef(pageIndex + 1, destRef);
12492                                                goToDestination(destRef);
12493                                            }).catch(function () {
12494                                                console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid page reference.');
12495                                            });
12496                                        }
12497                                    };
12498                                    var destinationPromise;
12499                                    if (typeof dest === 'string') {
12500                                        destString = dest;
12501                                        destinationPromise = this.pdfDocument.getDestination(dest);
12502                                    } else {
12503                                        destinationPromise = Promise.resolve(dest);
12504                                    }
12505                                    destinationPromise.then(function (destination) {
12506                                        dest = destination;
12507                                        if (!(destination instanceof Array)) {
12508                                            console.error('PDFLinkService_navigateTo: "' + destination + '" is not a valid destination array.');
12509                                            return;
12510                                        }
12511                                        goToDestination(destination[0]);
12512                                    });
12513                                },
12514                                getDestinationHash: function PDFLinkService_getDestinationHash(dest) {
12515                                    if (typeof dest === 'string') {
12516                                        return this.getAnchorUrl('#' + (isPageNumber(dest) ? 'nameddest=' : '') + escape(dest));
12517                                    }
12518                                    if (dest instanceof Array) {
12519                                        var str = JSON.stringify(dest);
12520                                        return this.getAnchorUrl('#' + escape(str));
12521                                    }
12522                                    return this.getAnchorUrl('');
12523                                },
12524                                getAnchorUrl: function PDFLinkService_getAnchorUrl(anchor) {
12525                                    return (this.baseUrl || '') + anchor;
12526                                },
12527                                setHash: function PDFLinkService_setHash(hash) {
12528                                    var pageNumber, dest;
12529                                    if (hash.indexOf('=') >= 0) {
12530                                        var params = parseQueryString(hash);
12531                                        if ('search' in params) {
12532                                            this.eventBus.dispatch('findfromurlhash', {
12533                                                source: this,
12534                                                query: params['search'].replace(/"/g, ''),
12535                                                phraseSearch: params['phrase'] === 'true'
12536                                            });
12537                                        }
12538                                        if ('nameddest' in params) {
12539                                            if (this.pdfHistory) {
12540                                                this.pdfHistory.updateNextHashParam(params.nameddest);
12541                                            }
12542                                            this.navigateTo(params.nameddest);
12543                                            return;
12544                                        }
12545                                        if ('page' in params) {
12546                                            pageNumber = params.page | 0 || 1;
12547                                        }
12548                                        if ('zoom' in params) {
12549                                            var zoomArgs = params.zoom.split(',');
12550                                            var zoomArg = zoomArgs[0];
12551                                            var zoomArgNumber = parseFloat(zoomArg);
12552                                            if (zoomArg.indexOf('Fit') === -1) {
12553                                                dest = [
12554                                                    null,
12555                                                    {name: 'XYZ'},
12556                                                    zoomArgs.length > 1 ? zoomArgs[1] | 0 : null,
12557                                                    zoomArgs.length > 2 ? zoomArgs[2] | 0 : null,
12558                                                    zoomArgNumber ? zoomArgNumber / 100 : zoomArg
12559                                                ];
12560                                            } else {
12561                                                if (zoomArg === 'Fit' || zoomArg === 'FitB') {
12562                                                    dest = [
12563                                                        null,
12564                                                        {name: zoomArg}
12565                                                    ];
12566                                                } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || (zoomArg === 'FitV' || zoomArg === 'FitBV')) {
12567                                                    dest = [
12568                                                        null,
12569                                                        {name: zoomArg},
12570                                                        zoomArgs.length > 1 ? zoomArgs[1] | 0 : null
12571                                                    ];
12572                                                } else if (zoomArg === 'FitR') {
12573                                                    if (zoomArgs.length !== 5) {
12574                                                        console.error('PDFLinkService_setHash: ' + 'Not enough parameters for \'FitR\'.');
12575                                                    } else {
12576                                                        dest = [
12577                                                            null,
12578                                                            {name: zoomArg},
12579                                                            zoomArgs[1] | 0,
12580                                                            zoomArgs[2] | 0,
12581                                                            zoomArgs[3] | 0,
12582                                                            zoomArgs[4] | 0
12583                                                        ];
12584                                                    }
12585                                                } else {
12586                                                    console.error('PDFLinkService_setHash: \'' + zoomArg + '\' is not a valid zoom value.');
12587                                                }
12588                                            }
12589                                        }
12590                                        if (dest) {
12591                                            this.pdfViewer.scrollPageIntoView({
12592                                                pageNumber: pageNumber || this.page,
12593                                                destArray: dest,
12594                                                allowNegativeOffset: true
12595                                            });
12596                                        } else if (pageNumber) {
12597                                            this.page = pageNumber;
12598                                        }
12599                                        if ('pagemode' in params) {
12600                                            this.eventBus.dispatch('pagemode', {
12601                                                source: this,
12602                                                mode: params.pagemode
12603                                            });
12604                                        }
12605                                    } else {
12606                                        if (isPageNumber(hash) && hash <= this.pagesCount) {
12607                                            console.warn('PDFLinkService_setHash: specifying a page number ' + 'directly after the hash symbol (#) is deprecated, ' + 'please use the "#page=' + hash + '" form instead.');
12608                                            this.page = hash | 0;
12609                                        }
12610                                        dest = unescape(hash);
12611                                        try {
12612                                            dest = JSON.parse(dest);
12613                                            if (!(dest instanceof Array)) {
12614                                                dest = dest.toString();
12615                                            }
12616                                        } catch (ex) {
12617                                        }
12618                                        if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
12619                                            if (this.pdfHistory) {
12620                                                this.pdfHistory.updateNextHashParam(dest);
12621                                            }
12622                                            this.navigateTo(dest);
12623                                            return;
12624                                        }
12625                                        console.error('PDFLinkService_setHash: \'' + unescape(hash) + '\' is not a valid destination.');
12626                                    }
12627                                },
12628                                executeNamedAction: function PDFLinkService_executeNamedAction(action) {
12629                                    switch (action) {
12630                                        case 'GoBack':
12631                                            if (this.pdfHistory) {
12632                                                this.pdfHistory.back();
12633                                            }
12634                                            break;
12635                                        case 'GoForward':
12636                                            if (this.pdfHistory) {
12637                                                this.pdfHistory.forward();
12638                                            }
12639                                            break;
12640                                        case 'NextPage':
12641                                            if (this.page < this.pagesCount) {
12642                                                this.page++;
12643                                            }
12644                                            break;
12645                                        case 'PrevPage':
12646                                            if (this.page > 1) {
12647                                                this.page--;
12648                                            }
12649                                            break;
12650                                        case 'LastPage':
12651                                            this.page = this.pagesCount;
12652                                            break;
12653                                        case 'FirstPage':
12654                                            this.page = 1;
12655                                            break;
12656                                        default:
12657                                            break;
12658                                    }
12659                                    this.eventBus.dispatch('namedaction', {
12660                                        source: this,
12661                                        action: action
12662                                    });
12663                                },
12664                                onFileAttachmentAnnotation: function (params) {
12665                                    this.eventBus.dispatch('fileattachmentannotation', {
12666                                        source: this,
12667                                        id: params.id,
12668                                        filename: params.filename,
12669                                        content: params.content
12670                                    });
12671                                },
12672                                cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) {
12673                                    var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
12674                                    this._pagesRefCache[refStr] = pageNum;
12675                                },
12676                                _cachedPageNumber: function PDFLinkService_cachedPageNumber(pageRef) {
12677                                    var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
12678                                    return this._pagesRefCache && this._pagesRefCache[refStr] || null;
12679                                }
12680                            };
12681                            function isValidExplicitDestination(dest) {
12682                                if (!(dest instanceof Array)) {
12683                                    return false;
12684                                }
12685                                var destLength = dest.length, allowNull = true;
12686                                if (destLength < 2) {
12687                                    return false;
12688                                }
12689                                var page = dest[0];
12690                                if (!(typeof page === 'object' && typeof page.num === 'number' && (page.num | 0) === page.num && typeof page.gen === 'number' && (page.gen | 0) === page.gen) && !(typeof page === 'number' && (page | 0) === page && page >= 0)) {
12691                                    return false;
12692                                }
12693                                var zoom = dest[1];
12694                                if (!(typeof zoom === 'object' && typeof zoom.name === 'string')) {
12695                                    return false;
12696                                }
12697                                switch (zoom.name) {
12698                                    case 'XYZ':
12699                                        if (destLength !== 5) {
12700                                            return false;
12701                                        }
12702                                        break;
12703                                    case 'Fit':
12704                                    case 'FitB':
12705                                        return destLength === 2;
12706                                    case 'FitH':
12707                                    case 'FitBH':
12708                                    case 'FitV':
12709                                    case 'FitBV':
12710                                        if (destLength !== 3) {
12711                                            return false;
12712                                        }
12713                                        break;
12714                                    case 'FitR':
12715                                        if (destLength !== 6) {
12716                                            return false;
12717                                        }
12718                                        allowNull = false;
12719                                        break;
12720                                    default:
12721                                        return false;
12722                                }
12723                                for (var i = 2; i < destLength; i++) {
12724                                    var param = dest[i];
12725                                    if (!(typeof param === 'number' || allowNull && param === null)) {
12726                                        return false;
12727                                    }
12728                                }
12729                                return true;
12730                            }
12731                            return PDFLinkService;
12732                        }();
12733                        var SimpleLinkService = function SimpleLinkServiceClosure() {
12734                            function SimpleLinkService() {
12735                            }
12736                            SimpleLinkService.prototype = {
12737                                get page() {
12738                                    return 0;
12739                                },
12740                                set page(value) {
12741                                },
12742                                navigateTo: function (dest) {
12743                                },
12744                                getDestinationHash: function (dest) {
12745                                    return '#';
12746                                },
12747                                getAnchorUrl: function (hash) {
12748                                    return '#';
12749                                },
12750                                setHash: function (hash) {
12751                                },
12752                                executeNamedAction: function (action) {
12753                                },
12754                                onFileAttachmentAnnotation: function (params) {
12755                                },
12756                                cachePageRef: function (pageNum, pageRef) {
12757                                }
12758                            };
12759                            return SimpleLinkService;
12760                        }();
12761                        exports.PDFLinkService = PDFLinkService;
12762                        exports.SimpleLinkService = SimpleLinkService;
12763
12764                        /***/ }),
12765                    /* 6 */
12766                    /***/ (function (module, exports, __webpack_require__) {
12767
12768                        "use strict";
12769
12770                        var uiUtilsLib = __webpack_require__(0);
12771                        var downloadManagerLib = __webpack_require__(11);
12772                        var pdfHistoryLib = __webpack_require__(18);
12773                        var preferencesLib = __webpack_require__(8);
12774                        var pdfSidebarLib = __webpack_require__(22);
12775                        var viewHistoryLib = __webpack_require__(29);
12776                        var pdfThumbnailViewerLib = __webpack_require__(24);
12777                        var toolbarLib = __webpack_require__(28);
12778                        var secondaryToolbarLib = __webpack_require__(26);
12779                        var passwordPromptLib = __webpack_require__(14);
12780                        var pdfPresentationModeLib = __webpack_require__(21);
12781                        var pdfDocumentPropertiesLib = __webpack_require__(16);
12782                        var handToolLib = __webpack_require__(13);
12783                        var pdfViewerLib = __webpack_require__(25);
12784                        var pdfRenderingQueueLib = __webpack_require__(3);
12785                        var pdfLinkServiceLib = __webpack_require__(5);
12786                        var pdfOutlineViewerLib = __webpack_require__(19);
12787                        var overlayManagerLib = __webpack_require__(4);
12788                        var pdfAttachmentViewerLib = __webpack_require__(15);
12789                        var pdfFindControllerLib = __webpack_require__(7);
12790                        var pdfFindBarLib = __webpack_require__(17);
12791                        var domEventsLib = __webpack_require__(2);
12792                        var pdfjsLib = __webpack_require__(1);
12793                        var UNKNOWN_SCALE = uiUtilsLib.UNKNOWN_SCALE;
12794                        var DEFAULT_SCALE_VALUE = uiUtilsLib.DEFAULT_SCALE_VALUE;
12795                        var MIN_SCALE = uiUtilsLib.MIN_SCALE;
12796                        var MAX_SCALE = uiUtilsLib.MAX_SCALE;
12797                        var ProgressBar = uiUtilsLib.ProgressBar;
12798                        var getPDFFileNameFromURL = uiUtilsLib.getPDFFileNameFromURL;
12799                        var noContextMenuHandler = uiUtilsLib.noContextMenuHandler;
12800                        var mozL10n = uiUtilsLib.mozL10n;
12801                        var parseQueryString = uiUtilsLib.parseQueryString;
12802                        var PDFHistory = pdfHistoryLib.PDFHistory;
12803                        var Preferences = preferencesLib.Preferences;
12804                        var SidebarView = pdfSidebarLib.SidebarView;
12805                        var PDFSidebar = pdfSidebarLib.PDFSidebar;
12806                        var ViewHistory = viewHistoryLib.ViewHistory;
12807                        var PDFThumbnailViewer = pdfThumbnailViewerLib.PDFThumbnailViewer;
12808                        var Toolbar = toolbarLib.Toolbar;
12809                        var SecondaryToolbar = secondaryToolbarLib.SecondaryToolbar;
12810                        var PasswordPrompt = passwordPromptLib.PasswordPrompt;
12811                        var PDFPresentationMode = pdfPresentationModeLib.PDFPresentationMode;
12812                        var PDFDocumentProperties = pdfDocumentPropertiesLib.PDFDocumentProperties;
12813                        var HandTool = handToolLib.HandTool;
12814                        var PresentationModeState = pdfViewerLib.PresentationModeState;
12815                        var PDFViewer = pdfViewerLib.PDFViewer;
12816                        var RenderingStates = pdfRenderingQueueLib.RenderingStates;
12817                        var PDFRenderingQueue = pdfRenderingQueueLib.PDFRenderingQueue;
12818                        var PDFLinkService = pdfLinkServiceLib.PDFLinkService;
12819                        var PDFOutlineViewer = pdfOutlineViewerLib.PDFOutlineViewer;
12820                        var OverlayManager = overlayManagerLib.OverlayManager;
12821                        var PDFAttachmentViewer = pdfAttachmentViewerLib.PDFAttachmentViewer;
12822                        var PDFFindController = pdfFindControllerLib.PDFFindController;
12823                        var PDFFindBar = pdfFindBarLib.PDFFindBar;
12824                        var getGlobalEventBus = domEventsLib.getGlobalEventBus;
12825                        var normalizeWheelEventDelta = uiUtilsLib.normalizeWheelEventDelta;
12826                        var animationStarted = uiUtilsLib.animationStarted;
12827                        var localized = uiUtilsLib.localized;
12828                        var RendererType = uiUtilsLib.RendererType;
12829                        var DEFAULT_SCALE_DELTA = 1.1;
12830                        var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
12831                        function configure(PDFJS) {
12832                            PDFJS.cMapPacked = true;
12833                            var scriptTagContainer = document.body || document.getElementsByTagName('head')[0];
12834                            var pdfjsSrc = scriptTagContainer.lastChild.src;
12835                            if (pdfjsSrc) {
12836                                PDFJS.imageResourcesPath = pdfjsSrc.replace(/pdf\.js$/i, 'images/');
12837                                PDFJS.workerSrc = pdfjsSrc.replace(/pdf\.js$/i, 'pdf.worker.js');
12838                                PDFJS.cMapUrl = pdfjsSrc.replace(/pdf\.js$/i, 'cmaps/');
12839                            }
12840                        }
12841                        var DefaultExernalServices = {
12842                            updateFindControlState: function (data) {
12843                            },
12844                            initPassiveLoading: function (callbacks) {
12845                            },
12846                            fallback: function (data, callback) {
12847                            },
12848                            reportTelemetry: function (data) {
12849                            },
12850                            createDownloadManager: function () {
12851                                return new downloadManagerLib.DownloadManager();
12852                            },
12853                            supportsIntegratedFind: false,
12854                            supportsDocumentFonts: true,
12855                            supportsDocumentColors: true,
12856                            supportedMouseWheelZoomModifierKeys: {
12857                                ctrlKey: true,
12858                                metaKey: true
12859                            }
12860                        };
12861                        var PDFViewerApplication = {
12862                            initialBookmark: document.location.hash.substring(1),
12863                            initialDestination: null,
12864                            initialized: false,
12865                            fellback: false,
12866                            appConfig: null,
12867                            pdfDocument: null,
12868                            pdfLoadingTask: null,
12869                            printService: null,
12870                            pdfViewer: null,
12871                            pdfThumbnailViewer: null,
12872                            pdfRenderingQueue: null,
12873                            pdfPresentationMode: null,
12874                            pdfDocumentProperties: null,
12875                            pdfLinkService: null,
12876                            pdfHistory: null,
12877                            pdfSidebar: null,
12878                            pdfOutlineViewer: null,
12879                            pdfAttachmentViewer: null,
12880                            store: null,
12881                            downloadManager: null,
12882                            toolbar: null,
12883                            secondaryToolbar: null,
12884                            eventBus: null,
12885                            pageRotation: 0,
12886                            isInitialViewSet: false,
12887                            viewerPrefs: {
12888                                sidebarViewOnLoad: SidebarView.NONE,
12889                                pdfBugEnabled: false,
12890                                showPreviousViewOnLoad: true,
12891                                defaultZoomValue: '',
12892                                disablePageLabels: false,
12893                                renderer: 'canvas',
12894                                enhanceTextSelection: false,
12895                                renderInteractiveForms: false,
12896                                enablePrintAutoRotate: false
12897                            },
12898                            isViewerEmbedded: window.parent !== window,
12899                            url: '',
12900                            baseUrl: '',
12901                            externalServices: DefaultExernalServices,
12902                            initialize: function pdfViewInitialize(appConfig) {
12903                                var self = this;
12904                                var PDFJS = pdfjsLib.PDFJS;
12905                                Preferences.initialize();
12906                                this.preferences = Preferences;
12907                                configure(PDFJS);
12908                                this.appConfig = appConfig;
12909                                return this._readPreferences().then(function () {
12910                                    return self._initializeViewerComponents();
12911                                }).then(function () {
12912                                    self.bindEvents();
12913                                    self.bindWindowEvents();
12914                                    localized.then(function () {
12915                                        self.eventBus.dispatch('localized');
12916                                    });
12917                                    if (self.isViewerEmbedded && !PDFJS.isExternalLinkTargetSet()) {
12918                                        PDFJS.externalLinkTarget = PDFJS.LinkTarget.TOP;
12919                                    }
12920                                    self.initialized = true;
12921                                });
12922                            },
12923                            _readPreferences: function () {
12924                                var self = this;
12925                                var PDFJS = pdfjsLib.PDFJS;
12926                                return Promise.all([
12927                                    Preferences.get('enableWebGL').then(function resolved(value) {
12928                                        PDFJS.disableWebGL = !value;
12929                                    }),
12930                                    Preferences.get('sidebarViewOnLoad').then(function resolved(value) {
12931                                        self.viewerPrefs['sidebarViewOnLoad'] = value;
12932                                    }),
12933                                    Preferences.get('pdfBugEnabled').then(function resolved(value) {
12934                                        self.viewerPrefs['pdfBugEnabled'] = value;
12935                                    }),
12936                                    Preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
12937                                        self.viewerPrefs['showPreviousViewOnLoad'] = value;
12938                                    }),
12939                                    Preferences.get('defaultZoomValue').then(function resolved(value) {
12940                                        self.viewerPrefs['defaultZoomValue'] = value;
12941                                    }),
12942                                    Preferences.get('enhanceTextSelection').then(function resolved(value) {
12943                                        self.viewerPrefs['enhanceTextSelection'] = value;
12944                                    }),
12945                                    Preferences.get('disableTextLayer').then(function resolved(value) {
12946                                        if (PDFJS.disableTextLayer === true) {
12947                                            return;
12948                                        }
12949                                        PDFJS.disableTextLayer = value;
12950                                    }),
12951                                    Preferences.get('disableRange').then(function resolved(value) {
12952                                        if (PDFJS.disableRange === true) {
12953                                            return;
12954                                        }
12955                                        PDFJS.disableRange = value;
12956                                    }),
12957                                    Preferences.get('disableStream').then(function resolved(value) {
12958                                        if (PDFJS.disableStream === true) {
12959                                            return;
12960                                        }
12961                                        PDFJS.disableStream = value;
12962                                    }),
12963                                    Preferences.get('disableAutoFetch').then(function resolved(value) {
12964                                        PDFJS.disableAutoFetch = value;
12965                                    }),
12966                                    Preferences.get('disableFontFace').then(function resolved(value) {
12967                                        if (PDFJS.disableFontFace === true) {
12968                                            return;
12969                                        }
12970                                        PDFJS.disableFontFace = value;
12971                                    }),
12972                                    Preferences.get('useOnlyCssZoom').then(function resolved(value) {
12973                                        PDFJS.useOnlyCssZoom = value;
12974                                    }),
12975                                    Preferences.get('externalLinkTarget').then(function resolved(value) {
12976                                        if (PDFJS.isExternalLinkTargetSet()) {
12977                                            return;
12978                                        }
12979                                        PDFJS.externalLinkTarget = value;
12980                                    }),
12981                                    Preferences.get('renderer').then(function resolved(value) {
12982                                        self.viewerPrefs['renderer'] = value;
12983                                    }),
12984                                    Preferences.get('renderInteractiveForms').then(function resolved(value) {
12985                                        self.viewerPrefs['renderInteractiveForms'] = value;
12986                                    }),
12987                                    Preferences.get('disablePageLabels').then(function resolved(value) {
12988                                        self.viewerPrefs['disablePageLabels'] = value;
12989                                    }),
12990                                    Preferences.get('enablePrintAutoRotate').then(function resolved(value) {
12991                                        self.viewerPrefs['enablePrintAutoRotate'] = value;
12992                                    })
12993                                ]).catch(function (reason) {
12994                                });
12995                            },
12996                            _initializeViewerComponents: function () {
12997                                var self = this;
12998                                var appConfig = this.appConfig;
12999                                return new Promise(function (resolve, reject) {
13000                                    var eventBus = appConfig.eventBus || getGlobalEventBus();
13001                                    self.eventBus = eventBus;
13002                                    var pdfRenderingQueue = new PDFRenderingQueue();
13003                                    pdfRenderingQueue.onIdle = self.cleanup.bind(self);
13004                                    self.pdfRenderingQueue = pdfRenderingQueue;
13005                                    var pdfLinkService = new PDFLinkService({eventBus: eventBus});
13006                                    self.pdfLinkService = pdfLinkService;
13007                                    var downloadManager = self.externalServices.createDownloadManager();
13008                                    self.downloadManager = downloadManager;
13009                                    var container = appConfig.mainContainer;
13010                                    var viewer = appConfig.viewerContainer;
13011                                    self.pdfViewer = new PDFViewer({
13012                                        container: container,
13013                                        viewer: viewer,
13014                                        eventBus: eventBus,
13015                                        renderingQueue: pdfRenderingQueue,
13016                                        linkService: pdfLinkService,
13017                                        downloadManager: downloadManager,
13018                                        renderer: self.viewerPrefs['renderer'],
13019                                        enhanceTextSelection: self.viewerPrefs['enhanceTextSelection'],
13020                                        renderInteractiveForms: self.viewerPrefs['renderInteractiveForms'],
13021                                        enablePrintAutoRotate: self.viewerPrefs['enablePrintAutoRotate']
13022                                    });
13023                                    pdfRenderingQueue.setViewer(self.pdfViewer);
13024                                    pdfLinkService.setViewer(self.pdfViewer);
13025                                    var thumbnailContainer = appConfig.sidebar.thumbnailView;
13026                                    self.pdfThumbnailViewer = new PDFThumbnailViewer({
13027                                        container: thumbnailContainer,
13028                                        renderingQueue: pdfRenderingQueue,
13029                                        linkService: pdfLinkService
13030                                    });
13031                                    pdfRenderingQueue.setThumbnailViewer(self.pdfThumbnailViewer);
13032                                    self.pdfHistory = new PDFHistory({
13033                                        linkService: pdfLinkService,
13034                                        eventBus: eventBus
13035                                    });
13036                                    pdfLinkService.setHistory(self.pdfHistory);
13037                                    self.findController = new PDFFindController({pdfViewer: self.pdfViewer});
13038                                    self.findController.onUpdateResultsCount = function (matchCount) {
13039                                        if (self.supportsIntegratedFind) {
13040                                            return;
13041                                        }
13042                                        self.findBar.updateResultsCount(matchCount);
13043                                    };
13044                                    self.findController.onUpdateState = function (state, previous, matchCount) {
13045                                        if (self.supportsIntegratedFind) {
13046                                            self.externalServices.updateFindControlState({
13047                                                result: state,
13048                                                findPrevious: previous
13049                                            });
13050                                        } else {
13051                                            self.findBar.updateUIState(state, previous, matchCount);
13052                                        }
13053                                    };
13054                                    self.pdfViewer.setFindController(self.findController);
13055                                    var findBarConfig = Object.create(appConfig.findBar);
13056                                    findBarConfig.findController = self.findController;
13057                                    findBarConfig.eventBus = eventBus;
13058                                    self.findBar = new PDFFindBar(findBarConfig);
13059                                    self.overlayManager = OverlayManager;
13060                                    self.handTool = new HandTool({
13061                                        container: container,
13062                                        eventBus: eventBus
13063                                    });
13064                                    self.pdfDocumentProperties = new PDFDocumentProperties(appConfig.documentProperties);
13065                                    self.toolbar = new Toolbar(appConfig.toolbar, container, eventBus);
13066                                    self.secondaryToolbar = new SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
13067                                    if (self.supportsFullscreen) {
13068                                        self.pdfPresentationMode = new PDFPresentationMode({
13069                                            container: container,
13070                                            viewer: viewer,
13071                                            pdfViewer: self.pdfViewer,
13072                                            eventBus: eventBus,
13073                                            contextMenuItems: appConfig.fullscreen
13074                                        });
13075                                    }
13076                                    self.passwordPrompt = new PasswordPrompt(appConfig.passwordOverlay);
13077                                    self.pdfOutlineViewer = new PDFOutlineViewer({
13078                                        container: appConfig.sidebar.outlineView,
13079                                        eventBus: eventBus,
13080                                        linkService: pdfLinkService
13081                                    });
13082                                    self.pdfAttachmentViewer = new PDFAttachmentViewer({
13083                                        container: appConfig.sidebar.attachmentsView,
13084                                        eventBus: eventBus,
13085                                        downloadManager: downloadManager
13086                                    });
13087                                    var sidebarConfig = Object.create(appConfig.sidebar);
13088                                    sidebarConfig.pdfViewer = self.pdfViewer;
13089                                    sidebarConfig.pdfThumbnailViewer = self.pdfThumbnailViewer;
13090                                    sidebarConfig.pdfOutlineViewer = self.pdfOutlineViewer;
13091                                    sidebarConfig.eventBus = eventBus;
13092                                    self.pdfSidebar = new PDFSidebar(sidebarConfig);
13093                                    self.pdfSidebar.onToggled = self.forceRendering.bind(self);
13094                                    resolve(undefined);
13095                                });
13096                            },
13097                            run: function pdfViewRun(config) {
13098                                this.initialize(config).then(webViewerInitialized);
13099                            },
13100                            zoomIn: function pdfViewZoomIn(ticks) {
13101                                var newScale = this.pdfViewer.currentScale;
13102                                do {
13103                                    newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
13104                                    newScale = Math.ceil(newScale * 10) / 10;
13105                                    newScale = Math.min(MAX_SCALE, newScale);
13106                                } while (--ticks > 0 && newScale < MAX_SCALE);
13107                                this.pdfViewer.currentScaleValue = newScale;
13108                            },
13109                            zoomOut: function pdfViewZoomOut(ticks) {
13110                                var newScale = this.pdfViewer.currentScale;
13111                                do {
13112                                    newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
13113                                    newScale = Math.floor(newScale * 10) / 10;
13114                                    newScale = Math.max(MIN_SCALE, newScale);
13115                                } while (--ticks > 0 && newScale > MIN_SCALE);
13116                                this.pdfViewer.currentScaleValue = newScale;
13117                            },
13118                            get pagesCount() {
13119                                return this.pdfDocument ? this.pdfDocument.numPages : 0;
13120                            },
13121                            set page(val) {
13122                                this.pdfViewer.currentPageNumber = val;
13123                            },
13124                            get page() {
13125                                return this.pdfViewer.currentPageNumber;
13126                            },
13127                            get printing() {
13128                                return !!this.printService;
13129                            },
13130                            get supportsPrinting() {
13131                                return PDFPrintServiceFactory.instance.supportsPrinting;
13132                            },
13133                            get supportsFullscreen() {
13134                                var support;
13135                                var doc = document.documentElement;
13136                                support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
13137                                if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
13138                                    support = false;
13139                                }
13140                                if (support && pdfjsLib.PDFJS.disableFullscreen === true) {
13141                                    support = false;
13142                                }
13143                                return pdfjsLib.shadow(this, 'supportsFullscreen', support);
13144                            },
13145                            get supportsIntegratedFind() {
13146                                return this.externalServices.supportsIntegratedFind;
13147                            },
13148                            get supportsDocumentFonts() {
13149                                return this.externalServices.supportsDocumentFonts;
13150                            },
13151                            get supportsDocumentColors() {
13152                                return this.externalServices.supportsDocumentColors;
13153                            },
13154                            get loadingBar() {
13155                                var bar = new ProgressBar('#loadingBar', {});
13156                                return pdfjsLib.shadow(this, 'loadingBar', bar);
13157                            },
13158                            get supportedMouseWheelZoomModifierKeys() {
13159                                return this.externalServices.supportedMouseWheelZoomModifierKeys;
13160                            },
13161                            initPassiveLoading: function pdfViewInitPassiveLoading() {
13162                                throw new Error('Not implemented: initPassiveLoading');
13163                            },
13164                            setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
13165                                this.url = url;
13166                                this.baseUrl = url.split('#')[0];
13167                                var title = getPDFFileNameFromURL(url, '');
13168                                if (!title) {
13169                                    try {
13170                                        title = decodeURIComponent(pdfjsLib.getFilenameFromUrl(url)) || url;
13171                                    } catch (e) {
13172                                        title = url;
13173                                    }
13174                                }
13175                                this.setTitle(title);
13176                            },
13177                            setTitle: function pdfViewSetTitle(title) {
13178                                if (this.isViewerEmbedded) {
13179                                    return;
13180                                }
13181                                document.title = title;
13182                            },
13183                            close: function pdfViewClose() {
13184                                var errorWrapper = this.appConfig.errorWrapper.container;
13185                                errorWrapper.setAttribute('hidden', 'true');
13186                                if (!this.pdfLoadingTask) {
13187                                    return Promise.resolve();
13188                                }
13189                                var promise = this.pdfLoadingTask.destroy();
13190                                this.pdfLoadingTask = null;
13191                                if (this.pdfDocument) {
13192                                    this.pdfDocument = null;
13193                                    this.pdfThumbnailViewer.setDocument(null);
13194                                    this.pdfViewer.setDocument(null);
13195                                    this.pdfLinkService.setDocument(null, null);
13196                                }
13197                                this.store = null;
13198                                this.isInitialViewSet = false;
13199                                if (this.pdfSidebar)
13200                                    this.pdfSidebar.reset();
13201                                if (this.pdfOutlineViewer)
13202                                    this.pdfOutlineViewer.reset();
13203                                if (this.pdfAttachmentViewer)
13204                                    this.pdfAttachmentViewer.reset();
13205                                if (this.findController)
13206                                    this.findController.reset();
13207                                if (this.findBar)
13208                                    this.findBar.reset();
13209                                if (this.toolbar)
13210                                    this.toolbar.reset();
13211                                if (this.secondaryToolbar)
13212                                    this.secondaryToolbar.reset();
13213                                if (typeof PDFBug !== 'undefined') {
13214                                    PDFBug.cleanup();
13215                                }
13216                                return promise;
13217                            },
13218                            open: function pdfViewOpen(file, args) {
13219                                if (arguments.length > 2 || typeof args === 'number') {
13220                                    return Promise.reject(new Error('Call of open() with obsolete signature.'));
13221                                }
13222                                if (this.pdfLoadingTask) {
13223                                    return this.close().then(function () {
13224                                        Preferences.reload();
13225                                        return this.open(file, args);
13226                                    }.bind(this));
13227                                }
13228                                var parameters = Object.create(null), scale;
13229                                if (typeof file === 'string') {
13230                                    this.setTitleUsingUrl(file);
13231                                    parameters.url = file;
13232                                } else if (file && 'byteLength' in file) {
13233                                    parameters.data = file;
13234                                } else if (file.url && file.originalUrl) {
13235                                    this.setTitleUsingUrl(file.originalUrl);
13236                                    parameters.url = file.url;
13237                                }
13238                                if (args) {
13239                                    for (var prop in args) {
13240                                        parameters[prop] = args[prop];
13241                                    }
13242                                    if (args.scale) {
13243                                        scale = args.scale;
13244                                    }
13245                                    if (args.length) {
13246                                        this.pdfDocumentProperties.setFileSize(args.length);
13247                                    }
13248                                }
13249                                var self = this;
13250                                self.downloadComplete = false;
13251                                var loadingTask = pdfjsLib.getDocument(parameters);
13252                                this.pdfLoadingTask = loadingTask;
13253                                loadingTask.onPassword = function passwordNeeded(updateCallback, reason) {
13254                                    self.passwordPrompt.setUpdateCallback(updateCallback, reason);
13255                                    self.passwordPrompt.open();
13256                                };
13257                                loadingTask.onProgress = function getDocumentProgress(progressData) {
13258                                    self.progress(progressData.loaded / progressData.total);
13259                                };
13260                                loadingTask.onUnsupportedFeature = this.fallback.bind(this);
13261                                return loadingTask.promise.then(function getDocumentCallback(pdfDocument) {
13262                                    self.load(pdfDocument, scale);
13263                                }, function getDocumentError(exception) {
13264                                    var message = exception && exception.message;
13265                                    var loadingErrorMessage = mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
13266                                    if (exception instanceof pdfjsLib.InvalidPDFException) {
13267                                        loadingErrorMessage = mozL10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
13268                                    } else if (exception instanceof pdfjsLib.MissingPDFException) {
13269                                        loadingErrorMessage = mozL10n.get('missing_file_error', null, 'Missing PDF file.');
13270                                    } else if (exception instanceof pdfjsLib.UnexpectedResponseException) {
13271                                        loadingErrorMessage = mozL10n.get('unexpected_response_error', null, 'Unexpected server response.');
13272                                    }
13273                                    var moreInfo = {message: message};
13274                                    self.error(loadingErrorMessage, moreInfo);
13275                                    throw new Error(loadingErrorMessage);
13276                                });
13277                            },
13278                            download: function pdfViewDownload() {
13279                                function downloadByUrl() {
13280                                    downloadManager.downloadUrl(url, filename);
13281                                }
13282                                var url = this.baseUrl;
13283                                var filename = getPDFFileNameFromURL(this.url);
13284                                var downloadManager = this.downloadManager;
13285                                downloadManager.onerror = function (err) {
13286                                    PDFViewerApplication.error('PDF failed to download.');
13287                                };
13288                                if (!this.pdfDocument) {
13289                                    downloadByUrl();
13290                                    return;
13291                                }
13292                                if (!this.downloadComplete) {
13293                                    downloadByUrl();
13294                                    return;
13295                                }
13296                                this.pdfDocument.getData().then(function getDataSuccess(data) {
13297                                    var blob = pdfjsLib.createBlob(data, 'application/pdf');
13298                                    downloadManager.download(blob, url, filename);
13299                                }, downloadByUrl).then(null, downloadByUrl);
13300                            },
13301                            fallback: function pdfViewFallback(featureId) {
13302                            },
13303                            error: function pdfViewError(message, moreInfo) {
13304                                var moreInfoText = mozL10n.get('error_version_info', {
vendor: 5,016 bytes, lines 13305-13372
13305                                    version: pdfjsLib.version || '?',
13306                                    build: pdfjsLib.build || '?'
13307                                }, 'PDF.js v{{version}} (build: {{build}})') + '\n';
13308                                if (moreInfo) {
13309                                    moreInfoText += mozL10n.get('error_message', {message: moreInfo.message}, 'Message: {{message}}');
13310                                    if (moreInfo.stack) {
13311                                        moreInfoText += '\n' + mozL10n.get('error_stack', {stack: moreInfo.stack}, 'Stack: {{stack}}');
13312                                    } else {
13313                                        if (moreInfo.filename) {
13314                                            moreInfoText += '\n' + mozL10n.get('error_file', {file: moreInfo.filename}, 'File: {{file}}');
13315                                        }
13316                                        if (moreInfo.lineNumber) {
13317                                            moreInfoText += '\n' + mozL10n.get('error_line', {line: moreInfo.lineNumber}, 'Line: {{line}}');
13318                                        }
13319                                    }
13320                                }
13321                                var errorWrapperConfig = this.appConfig.errorWrapper;
13322                                var errorWrapper = errorWrapperConfig.container;
13323                                errorWrapper.removeAttribute('hidden');
13324                                var errorMessage = errorWrapperConfig.errorMessage;
13325                                errorMessage.textContent = message;
13326                                var closeButton = errorWrapperConfig.closeButton;
13327                                closeButton.onclick = function () {
13328                                    errorWrapper.setAttribute('hidden', 'true');
13329                                };
13330                                var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
13331                                var moreInfoButton = errorWrapperConfig.moreInfoButton;
13332                                var lessInfoButton = errorWrapperConfig.lessInfoButton;
13333                                moreInfoButton.onclick = function () {
13334                                    errorMoreInfo.removeAttribute('hidden');
13335                                    moreInfoButton.setAttribute('hidden', 'true');
13336                                    lessInfoButton.removeAttribute('hidden');
13337                                    errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
13338                                };
13339                                lessInfoButton.onclick = function () {
13340                                    errorMoreInfo.setAttribute('hidden', 'true');
13341                                    moreInfoButton.removeAttribute('hidden');
13342                                    lessInfoButton.setAttribute('hidden', 'true');
13343                                };
13344                                moreInfoButton.oncontextmenu = noContextMenuHandler;
13345                                lessInfoButton.oncontextmenu = noContextMenuHandler;
13346                                closeButton.oncontextmenu = noContextMenuHandler;
13347                                moreInfoButton.removeAttribute('hidden');
13348                                lessInfoButton.setAttribute('hidden', 'true');
13349                                errorMoreInfo.value = moreInfoText;
13350                            },
13351                            progress: function pdfViewProgress(level) {
13352                                var percent = Math.round(level * 100);
13353                                if (percent > this.loadingBar.percent || isNaN(percent)) {
13354                                    this.loadingBar.percent = percent;
13355                                    if (pdfjsLib.PDFJS.disableAutoFetch && percent) {
13356                                        if (this.disableAutoFetchLoadingBarTimeout) {
13357                                            clearTimeout(this.disableAutoFetchLoadingBarTimeout);
13358                                            this.disableAutoFetchLoadingBarTimeout = null;
13359                                        }
13360                                        this.loadingBar.show();
13361                                        this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
13362                                            this.loadingBar.hide();
13363                                            this.disableAutoFetchLoadingBarTimeout = null;
13364                                        }.bind(this), DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
13365                                    }
13366                                }
13367                            },
13368                            load: function pdfViewLoad(pdfDocument, scale) {
13369                                var self = this;
13370                                scale = scale || UNKNOWN_SCALE;
13371                                this.pdfDocument = pdfDocument;
13372                                this.pdfDocumentProperties.setDocumentAndUrl(pdfDocument, this.url);
13373                                var downloadedPromise = pdfDocument.getDownloadInfo().then(function () {
13374                                    self.downloadComplete = true;
13375                                    self.loadingBar.hide();
13376                                });
13377                                this.toolbar.setPagesCount(pdfDocument.numPages, false);
13378                                this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
13379                                var id = this.documentFingerprint = pdfDocument.fingerprint;
13380                                var store = this.store = new ViewHistory(id);
13381                                var baseDocumentUrl;
13382                                baseDocumentUrl = null;
13383                                this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
13384                                var pdfViewer = this.pdfViewer;
13385                                pdfViewer.currentScale = scale;
13386                                pdfViewer.setDocument(pdfDocument);
13387                                var firstPagePromise = pdfViewer.firstPagePromise;
13388                                var pagesPromise = pdfViewer.pagesPromise;
13389                                var onePageRendered = pdfViewer.onePageRendered;
13390                                this.pageRotation = 0;
13391                                var pdfThumbnailViewer = this.pdfThumbnailViewer;
13392                                pdfThumbnailViewer.setDocument(pdfDocument);
13393                                firstPagePromise.then(function (pdfPage) {
13394                                    downloadedPromise.then(function () {
13395                                        self.eventBus.dispatch('documentload', {source: self});
13396                                    });
13397                                    self.loadingBar.setWidth(self.appConfig.viewerContainer);
13398                                    if (!pdfjsLib.PDFJS.disableHistory && !self.isViewerEmbedded) {
13399                                        if (!self.viewerPrefs['showPreviousViewOnLoad']) {
13400                                            self.pdfHistory.clearHistoryState();
13401                                        }
13402                                        self.pdfHistory.initialize(self.documentFingerprint);
13403                                        if (self.pdfHistory.initialDestination) {
13404                                            self.initialDestination = self.pdfHistory.initialDestination;
13405                                        } else if (self.pdfHistory.initialBookmark) {
13406                                            self.initialBookmark = self.pdfHistory.initialBookmark;
13407                                        }
13408                                    }
13409                                    var initialParams = {
13410                                        destination: self.initialDestination,
13411                                        bookmark: self.initialBookmark,
13412                                        hash: null
13413                                    };
13414                                    store.initializedPromise.then(function resolved() {
13415                                        var storedHash = null, sidebarView = null;
13416                                        if (self.viewerPrefs['showPreviousViewOnLoad'] && store.get('exists', false)) {
13417                                            var pageNum = store.get('page', '1');
13418                                            var zoom = self.viewerPrefs['defaultZoomValue'] || store.get('zoom', DEFAULT_SCALE_VALUE);
13419                                            var left = store.get('scrollLeft', '0');
13420                                            var top = store.get('scrollTop', '0');
13421                                            storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' + left + ',' + top;
13422                                            sidebarView = store.get('sidebarView', SidebarView.NONE);
13423                                        } else if (self.viewerPrefs['defaultZoomValue']) {
13424                                            storedHash = 'page=1&zoom=' + self.viewerPrefs['defaultZoomValue'];
13425                                        }
13426                                        self.setInitialView(storedHash, {
13427                                            scale: scale,
13428                                            sidebarView: sidebarView
13429                                        });
13430                                        initialParams.hash = storedHash;
13431                                        if (!self.isViewerEmbedded) {
13432                                            self.pdfViewer.focus();
13433                                        }
13434                                    }, function rejected(reason) {
13435                                        console.error(reason);
13436                                        self.setInitialView(null, {scale: scale});
13437                                    });
13438                                    pagesPromise.then(function resolved() {
13439                                        if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
13440                                            return;
13441                                        }
13442                                        if (self.hasEqualPageSizes) {
13443                                            return;
13444                                        }
13445                                        self.initialDestination = initialParams.destination;
13446                                        self.initialBookmark = initialParams.bookmark;
13447                                        self.pdfViewer.currentScaleValue = self.pdfViewer.currentScaleValue;
13448                                        self.setInitialView(initialParams.hash);
13449                                    });
13450                                });
13451                                pdfDocument.getPageLabels().then(function (labels) {
13452                                    if (!labels || self.viewerPrefs['disablePageLabels']) {
13453                                        return;
13454                                    }
13455                                    var i = 0, numLabels = labels.length;
13456                                    if (numLabels !== self.pagesCount) {
13457                                        console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
13458                                        return;
13459                                    }
13460                                    while (i < numLabels && labels[i] === (i + 1).toString()) {
13461                                        i++;
13462                                    }
13463                                    if (i === numLabels) {
13464                                        return;
13465                                    }
13466                                    pdfViewer.setPageLabels(labels);
13467                                    pdfThumbnailViewer.setPageLabels(labels);
13468                                    self.toolbar.setPagesCount(pdfDocument.numPages, true);
13469                                    self.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
13470                                });
13471                                pagesPromise.then(function () {
13472                                    if (self.supportsPrinting) {
13473                                        pdfDocument.getJavaScript().then(function (javaScript) {
13474                                            if (javaScript.length) {
13475                                                console.warn('Warning: JavaScript is not supported');
13476                                                self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
13477                                            }
13478                                            var regex = /\bprint\s*\(/;
13479                                            for (var i = 0, ii = javaScript.length; i < ii; i++) {
13480                                                var js = javaScript[i];
13481                                                if (js && regex.test(js)) {
13482                                                    setTimeout(function () {
13483                                                        window.print();
13484                                                    });
13485                                                    return;
13486                                                }
13487                                            }
13488                                        });
13489                                    }
13490                                });
13491                                Promise.all([
13492                                    onePageRendered,
13493                                    animationStarted
13494                                ]).then(function () {
13495                                    pdfDocument.getOutline().then(function (outline) {
13496                                        self.pdfOutlineViewer.render({outline: outline});
13497                                    });
13498                                    pdfDocument.getAttachments().then(function (attachments) {
13499                                        self.pdfAttachmentViewer.render({attachments: attachments});
13500                                    });
13501                                });
13502                                pdfDocument.getMetadata().then(function (data) {
13503                                    var info = data.info, metadata = data.metadata;
13504                                    self.documentInfo = info;
13505                                    self.metadata = metadata;
13506                                    console.log('PDF ' + pdfDocument.fingerprint 
vendor: 6,112 bytes, lines 13506-13593
13506+ ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (pdfjsLib.version || '-') + (!pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
13507                                    var pdfTitle;
13508                                    if (metadata && metadata.has('dc:title')) {
13509                                        var title = metadata.get('dc:title');
13510                                        if (title !== 'Untitled') {
13511                                            pdfTitle = title;
13512                                        }
13513                                    }
13514                                    if (!pdfTitle && info && info['Title']) {
13515                                        pdfTitle = info['Title'];
13516                                    }
13517                                    if (pdfTitle) {
13518                                        self.setTitle(pdfTitle + ' - ' + document.title);
13519                                    }
13520                                    if (info.IsAcroFormPresent) {
13521                                        console.warn('Warning: AcroForm/XFA is not supported');
13522                                        self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms);
13523                                    }
13524                                });
13525                            },
13526                            setInitialView: function pdfViewSetInitialView(storedHash, options) {
13527                                var scale = options && options.scale;
13528                                var sidebarView = options && options.sidebarView;
13529                                this.isInitialViewSet = true;
13530                                this.pdfSidebar.setInitialView(this.viewerPrefs['sidebarViewOnLoad'] || sidebarView | 0);
13531                                if (this.initialDestination) {
13532                                    this.pdfLinkService.navigateTo(this.initialDestination);
13533                                    this.initialDestination = null;
13534                                } else if (this.initialBookmark) {
13535                                    this.pdfLinkService.setHash(this.initialBookmark);
13536                                    this.pdfHistory.push({hash: this.initialBookmark}, true);
13537                                    this.initialBookmark = null;
13538                                } else if (storedHash) {
13539                                    this.pdfLinkService.setHash(storedHash);
13540                                } else if (scale) {
13541                                    this.pdfViewer.currentScaleValue = scale;
13542                                    this.page = 1;
13543                                }
13544                                this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
13545                                this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
13546                                if (!this.pdfViewer.currentScaleValue) {
13547                                    this.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
13548                                }
13549                            },
13550                            cleanup: function pdfViewCleanup() {
13551                                if (!this.pdfDocument) {
13552                                    return;
13553                                }
13554                                this.pdfViewer.cleanup();
13555                                this.pdfThumbnailViewer.cleanup();
13556                                if (this.pdfViewer.renderer !== RendererType.SVG) {
13557                                    if (this.pdfDocument) {
13558                                        this.pdfDocument.cleanup();
13559                                    }
13560                                }
13561                            },
13562                            forceRendering: function pdfViewForceRendering() {
13563                                this.pdfRenderingQueue.printing = this.printing;
13564                                this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
13565                                this.pdfRenderingQueue.renderHighestPriority();
13566                            },
13567                            beforePrint: function pdfViewSetupBeforePrint() {
13568                                if (this.printService) {
13569                                    return;
13570                                }
13571                                if (!this.supportsPrinting) {
13572                                    var printMessage = mozL10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by this browser.');
13573                                    this.error(printMessage);
13574                                    return;
13575                                }
13576                                if (!this.pdfViewer.pageViewsReady) {
13577                                    var notReadyMessage = mozL10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.');
13578                                    window.alert(notReadyMessage);
13579                                    return;
13580                                }
13581                                var pagesOverview = this.pdfViewer.getPagesOverview();
13582                                var printContainer = this.appConfig.printContainer;
13583                                var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer);
13584                                this.printService = printService;
13585                                this.forceRendering();
13586                                printService.layout();
13587                            },
13588                            get hasEqualPageSizes() {
13589                                var firstPage = this.pdfViewer.getPageView(0);
13590                                for (var i = 1, ii = this.pagesCount; i < ii; ++i) {
13591                                    var pageView = this.pdfViewer.getPageView(i);
13592                                    if (pageView.width !== firstPage.width || pageView.height !== firstPage.height) {
13593                                        return false;
13594                                    }
13595                                }
13596                                return true;
13597                            },
13598                            afterPrint: function pdfViewSetupAfterPrint() {
13599                                if (this.printService) {
13600                                    this.printService.destroy();
13601                                    this.printService = null;
13602                                }
13603                                this.forceRendering();
13604                            },
13605                            rotatePages: function pdfViewRotatePages(delta) {
13606                                var pageNumber = this.page;
13607                                this.pageRotation = (this.pageRotation + 360 + delta) % 360;
13608                                this.pdfViewer.pagesRotation = this.pageRotation;
13609                                this.pdfThumbnailViewer.pagesRotation = this.pageRotation;
13610                                this.forceRendering();
13611                                this.pdfViewer.currentPageNumber = pageNumber;
13612                            },
13613                            requestPresentationMode: function pdfViewRequestPresentationMode() {
13614                                if (!this.pdfPresentationMode) {
13615                                    return;
13616                                }
13617                                this.pdfPresentationMode.request();
13618                            },
13619                            bindEvents: function pdfViewBindEvents() {
13620                                var eventBus = this.eventBus;
13621                                eventBus.on('resize', webViewerResize);
13622                                eventBus.on('hashchange', webViewerHashchange);
13623                                eventBus.on('beforeprint', this.beforePrint.bind(this));
13624                                eventBus.on('afterprint', this.afterPrint.bind(this));
13625                                eventBus.on('pagerendered', webViewerPageRendered);
13626                                eventBus.on('textlayerrendered', webViewerTextLayerRendered);
13627                                eventBus.on('updateviewarea', webViewerUpdateViewarea);
13628                                eventBus.on('pagechanging', webViewerPageChanging);
13629                                eventBus.on('scalechanging', webViewerScaleChanging);
13630                                eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
13631                                eventBus.on('pagemode', webViewerPageMode);
13632                                eventBus.on('namedaction', webViewerNamedAction);
13633                                eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
13634                                eventBus.on('presentationmode', webViewerPresentationMode);
13635                                eventBus.on('openfile', webViewerOpenFile);
13636                                eventBus.on('print', webViewerPrint);
13637                                eventBus.on('download', webViewerDownload);
13638                                eventBus.on('firstpage', webViewerFirstPage);
13639                                eventBus.on('lastpage', webViewerLastPage);
13640                                eventBus.on('nextpage', webViewerNextPage);
13641                                eventBus.on('previouspage', webViewerPreviousPage);
13642                                eventBus.on('zoomin', webViewerZoomIn);
13643                                eventBus.on('zoomout', webViewerZoomOut);
13644                                eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
13645                                eventBus.on('scalechanged', webViewerScaleChanged);
13646                                eventBus.on('rotatecw', webViewerRotateCw);
13647                                eventBus.on('rotateccw', webViewerRotateCcw);
13648                                eventBus.on('documentproperties', webViewerDocumentProperties);
13649                                eventBus.on('find', webViewerFind);
13650                                eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
13651                                eventBus.on('fileinputchange', webViewerFileInputChange);
13652                            },
13653                            bindWindowEvents: function pdfViewBindWindowEvents() {
13654                                var eventBus = this.eventBus;
13655                                window.addEventListener('wheel', webViewerWheel);
13656                                window.addEventListener('click', webViewerClick);
13657                                window.addEventListener('keydown', webViewerKeyDown);
13658                                window.addEventListener('resize', function windowResize() {
13659                                    eventBus.dispatch('resize');
13660                                });
13661                                window.addEventListener('hashchange', function windowHashChange() {
13662                                    eventBus.dispatch('hashchange', {hash: document.location.hash.substring(1)});
13663                                });
13664                                window.addEventListener('beforeprint', function windowBeforePrint() {
13665                                    eventBus.dispatch('beforeprint');
13666                                });
13667                                window.addEventListener('afterprint', function windowAfterPrint() {
13668                                    eventBus.dispatch('afterprint');
13669                                });
13670                                window.addEventListener('change', function windowChange(evt) {
13671                                    var files = evt.target.files;
13672                                    if (!files || files.length === 0) {
13673                                        return;
13674                                    }
13675                                    if (evt.target.id == PDFViewerApplication.appConfig.openFileInputName)
13676                                        eventBus.dispatch('fileinputchange', {fileInput: evt.target});
13677                                });
13678                            }
13679                        };
13680                        var validateFileURL;
13681                        var HOSTED_VIEWER_ORIGINS = [
13682                            'null',
13683                            'http://mozilla.github.io',
13684                            'https://mozilla.github.io'
13685                        ];
13686                        validateFileURL = function validateFileURL(file) {
13687                            try {
13688                                var viewerOrigin = new URL(window.location.href).origin || 'null';
13689                                if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
13690                                    return;
13691                                }
13692                                var fileOrigin = new URL(file, window.location.href).origin;
13693                                if (fileOrigin !== viewerOrigin) {
13694                                    throw new Error('file origin does not match viewer\'s');
13695                                }
13696                            } catch (e) {
13697                                var message = e && e.message;
13698                                var loadingErrorMessage = mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.');
13699                                var moreInfo = {message: message};
13700                                PDFViewerApplication.error(loadingErrorMessage, moreInfo);
13701                                throw e;
13702                            }
13703                        };
13704                        function loadAndEnablePDFBug(enabledTabs) {
13705                            return new Promise(function (resolve, reject) {
13706                                var appConfig = PDFViewerApplication.appConfig;
13707                                var script = document.createElement('script');
13708                                script.src = appConfig.debuggerScriptPath;
13709                                script.onload = function () {
13710                                    PDFBug.enable(enabledTabs);
13711                                    PDFBug.init(pdfjsLib, appConfig.mainContainer);
13712                                    resolve();
13713                                };
13714                                script.onerror = function () {
13715                                    reject(new Error('Cannot load debugger at ' + script.src));
13716                                };
13717                                (document.getElementsByTagName('head')[0] || document.body).appendChild(script);
13718                            });
13719                        }
13720                        function webViewerInitialized() {
13721                            var appConfig = PDFViewerApplication.appConfig;
13722                            var file;
13723                            var queryString = document.location.search.substring(1);
13724                            var params = parseQueryString(queryString);
13725                            file = 'file' in params ? params.file : appConfig.defaultUrl;
13726                            validateFileURL(file);
13727                            var waitForBeforeOpening = [];
13728                            var fileInput = document.createElement('input');
13729                            fileInput.id = appConfig.openFileInputName;
13730                            fileInput.className = 'fileInput';
13731                            fileInput.setAttribute('type', 'file');
13732                            fileInput.oncontextmenu = noContextMenuHandler;
13733                            document.body.appendChild(fileInput);
13734                            if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
13735                                appConfig.toolbar.openFile.setAttribute('hidden', 'true');
13736                                appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
13737                            } else {
13738                                fileInput.value = null;
13739                            }
13740                            var PDFJS = pdfjsLib.PDFJS;
13741                            if (PDFViewerApplication.viewerPrefs['pdfBugEnabled']) {
13742                                var hash = document.location.hash.substring(1);
13743                                var hashParams = parseQueryString(hash);
13744                                if ('disableworker' in hashParams) {
13745                                    PDFJS.disableWorker = hashParams['disableworker'] === 'true';
13746                                }
13747                                if ('disablerange' in hashParams) {
13748                                    PDFJS.disableRange = hashParams['disablerange'] === 'true';
13749                                }
13750                                if ('disablestream' in hashParams) {
13751                                    PDFJS.disableStream = hashParams['disablestream'] === 'true';
13752                                }
13753                                if ('disableautofetch' in hashParams) {
13754                                    PDFJS.disableAutoFetch = hashParams['disableautofetch'] === 'true';
13755                                }
13756                                if ('disablefontface' in hashParams) {
13757                                    PDFJS.disableFontFace = hashParams['disablefontface'] === 'true';
13758                                }
13759                                if ('disablehistory' in hashParams) {
13760                                    PDFJS.disableHistory = hashParams['disablehistory'] === 'true';
13761                                }
13762                                if ('webgl' in hashParams) {
13763                                    PDFJS.disableWebGL = hashParams['webgl'] !== 'true';
13764                                }
13765                                if ('useonlycsszoom' in hashParams) {
13766                                    PDFJS.useOnlyCssZoom = hashParams['useonlycsszoom'] === 'true';
13767                                }
13768                                if ('verbosity' in hashParams) {
13769                                    PDFJS.verbosity = hashParams['verbosity'] | 0;
13770                                }
13771                                if ('ignorecurrentpositiononzoom' in hashParams) {
13772                                    PDFJS.ignoreCurrentPositionOnZoom = hashParams['ignorecurrentpositiononzoom'] === 'true';
13773                                }
13774                                if ('locale' in hashParams) {
13775                                    PDFJS.locale = hashParams['locale'];
13776                                }
13777                                if ('textlayer' in hashParams) {
13778                                    switch (hashParams['textlayer']) {
13779                                        case 'off':
13780                                            PDFJS.disableTextLayer = true;
13781                                            break;
13782                                        case 'visible':
13783                                        case 'shadow':
13784                                        case 'hover':
13785                                            var viewer = appConfig.viewerContainer;
13786                                            viewer.classList.add('textLayer-' + hashParams['textlayer']);
13787                                            break;
13788                                    }
13789                                }
13790                                if ('pdfbug' in hashParams) {
13791                                    PDFJS.pdfBug = true;
13792                                    var pdfBug = hashParams['pdfbug'];
13793                                    var enabled = pdfBug.split(',');
13794                                    waitForBeforeOpening.push(loadAndEnablePDFBug(enabled));
13795                                }
13796                            }
13797                            mozL10n.setLanguage(PDFJS.locale);
13798                            if (!PDFViewerApplication.supportsPrinting) {
13799                                appConfig.toolbar.print.classList.add('hidden');
13800                                appConfig.secondaryToolbar.printButton.classList.add('hidden');
13801                            }
13802                            if (!PDFViewerApplication.supportsFullscreen) {
13803                                appConfig.toolbar.presentationModeButton.classList.add('hidden');
13804                                appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
13805                            }
13806                            if (PDFViewerApplication.supportsIntegratedFind) {
13807                                appConfig.toolbar.viewFind.classList.add('hidden');
13808                            }
13809                            appConfig.sidebar.mainContainer.addEventListener('transitionend', function (e) {
13810                                if (e.target === this) {
13811                                    PDFViewerApplication.eventBus.dispatch('resize');
13812                                }
13813                            }, true);
13814                            appConfig.sidebar.toggleButton.addEventListener('click', function () {
13815                                PDFViewerApplication.pdfSidebar.toggle(
13815);
13816                            });
13817                            Promise.all(waitForBeforeOpening).then(function () {
13818                                webViewerOpenFileViaURL(file);
13819                            }).catch(function (reason) {
13820                                PDFViewerApplication.error(mozL10n.get('loading_error', null, 'An error occurred while opening.'), reason);
13821                            });
13822                        }
13823                        var webViewerOpenFileViaURL;
13824                        webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
13825                            if (file && file.lastIndexOf('file:', 0) === 0) {
13826                                PDFViewerApplication.setTitleUsingUrl(file);
13827                                var xhr = new XMLHttpRequest();
13828                                xhr.onload = function () {
13829                                    PDFViewerApplication.open(new Uint8Array(xhr.response));
13830                                };
13831                                try {
13832                                    xhr.open('GET', file);
13833                                    xhr.responseType = 'arraybuffer';
13834                                    xhr.send();
13835                                } catch (e) {
13836                                    PDFViewerApplication.error(mozL10n.get('loading_error', null, 'An error occurred while loading the PDF.'), e);
13837                                }
13838                                return;
13839                            }
13840                            if (file) {
13841                                PDFViewerApplication.open(file);
13842                            }
13843                        };
13844                        function webViewerPageRendered(e) {
13845                            var pageNumber = e.pageNumber;
13846                            var pageIndex = pageNumber - 1;
13847                            var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
13848                            if (pageNumber === PDFViewerApplication.page) {
13849                                PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
13850                            }
13851                            if (!pageView) {
13852                                return;
13853                            }
13854                            if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
13855                                var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
13856                                thumbnailView.setImage(pageView);
13857                            }
13858                            if (pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
13859                                Stats.add(pageNumber, pageView.stats);
13860                            }
13861                            if (pageView.error) {
13862                                PDFViewerApplication.error(mozL10n.get('rendering_error', null, 'An error occurred while rendering the page.'), pageView.error);
13863                            }
13864                        }
13865                        function webViewerTextLayerRendered(e) {
13866                        }
13867                        function webViewerPageMode(e) {
13868                            var mode = e.mode, view;
13869                            switch (mode) {
13870                                case 'thumbs':
13871                                    view = SidebarView.THUMBS;
13872                                    break;
13873                                case 'bookmarks':
13874                                case 'outline':
13875                                    view = SidebarView.OUTLINE;
13876                                    break;
13877                                case 'attachments':
13878                                    view = SidebarView.ATTACHMENTS;
13879                                    break;
13880                                case 'none':
13881                                    view = SidebarView.NONE;
13882                                    break;
13883                                default:
13884                                    console.error('Invalid "pagemode" hash parameter: ' + mode);
13885                                    return;
13886                            }
13887                            PDFViewerApplication.pdfSidebar.switchView(view, true);
13888                        }
13889                        function webViewerNamedAction(e) {
13890                            var action = e.action;
13891                            switch (action) {
13892                                case 'GoToPage':
13893                                    PDFViewerApplication.appConfig.toolbar.pageNumber.select();
13894                                    break;
13895                                case 'Find':
13896                                    if (!PDFViewerApplication.supportsIntegratedFind) {
13897                                        PDFViewerApplication.findBar.toggle(
13897);
13898                                    }
13899                                    break;
13900                            }
13901                        }
13902                        function webViewerPresentationModeChanged(e) {
13903                            var active = e.active;
13904                            var switchInProgress = e.switchInProgress;
13905                            PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? PresentationModeState.CHANGING : active ? PresentationModeState.FULLSCREEN : PresentationModeState.NORMAL;
13906                        }
13907                        function webViewerSidebarViewChanged(e) {
13908                            PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
13909                            var store = PDFViewerApplication.store;
13910                            if (!store || !PDFViewerApplication.isInitialViewSet) {
13911                                return;
13912                            }
13913                            store.initializedPromise.then(function () {
13914                                store.set('sidebarView', e.view).catch(function () {
13915                                });
13916                            });
13917                        }
13918                        function webViewerUpdateViewarea(e) {
13919                            var location = e.location, store = PDFViewerApplication.store;
13920                            if (store) {
13921                                store.initializedPromise.then(function () {
13922                                    store.setMultiple({
13923                                        'exists': true,
13924                                        'page': location.pageNumber,
13925                                        'zoom': location.scale,
13926                                        'scrollLeft': location.left,
13927                                        'scrollTop': location.top
13928                                    }).catch(function () {
13929                                    });
13930                                });
13931                            }
13932                            var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
13933                            PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
13934                            PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
13935                            PDFViewerApplication.pdfHistory.updateCurrentBookmark(location.pdfOpenParams, location.pageNumber);
13936                            var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
13937                            var loading = currentPage.renderingState !== RenderingStates.FINISHED;
13938                            PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
13939                        }
13940                        function webViewerResize() {
13941                            var currentScaleValue = PDFViewerApplication.pdfViewer.currentScaleValue;
13942                            if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
13943                                PDFViewerApplication.pdfViewer.currentScaleValue = currentScaleValue;
13944                            } else if (!currentScaleValue) {
13945                                PDFViewerApplication.pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
13946                            }
13947                            PDFViewerApplication.pdfViewer.update();
13948                        }
13949                        function webViewerHashchange(e) {
13950                            if (PDFViewerApplication.pdfHistory.isHashChangeUnlocked) {
13951                                var hash = e.hash;
13952                                if (!hash) {
13953                                    return;
13954                                }
13955                                if (!PDFViewerApplication.isInitialViewSet) {
13956                                    PDFViewerApplication.initialBookmark = hash;
13957                                } else {
13958                                    PDFViewerApplication.pdfLinkService.setHash(hash);
13959                                }
13960                            }
13961                        }
13962                        var webViewerFileInputChange;
13963                        webViewerFileInputChange = function webViewerFileInputChange(e) {
13964                            var file = e.fileInput.files[0];
13965                            if (!pdfjsLib.PDFJS.disableCreateObjectURL && typeof URL !== 'undefined' && URL.createObjectURL) {
13966                                PDFViewerApplication.open(URL.createObjectURL(file));
13967                            } else {
13968                                var fileReader = new FileReader();
13969                                fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
13970                                    var buffer = evt.target.result;
13971                                    var uint8Array = new Uint8Array(buffer);
13972                                    PDFViewerApplication.open(uint8Array);
13973                                };
13974                                fileReader.readAsArrayBuffer(file);
13975                            }
13976                            PDFViewerApplication.setTitleUsingUrl(file.name);
13977                            var appConfig = PDFViewerApplication.appConfig;
13978                            appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
13979                            appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
13980                            appConfig.toolbar.download.setAttribute('hidden', 'true');
13981                            appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
13982                        };
13983                        function webViewerPresentationMode() {
13984                            PDFViewerApplication.requestPresentationMode();
13985                        }
13986                        function webViewerOpenFile() {
13987                            var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
13988                            document.getElementById(openFileInputName).click();
13989                        }
13990                        function webViewerPrint() {
13991                            window.print();
13992                        }
13993                        function webViewerDownload() {
13994                            PDFViewerApplication.download();
13995                        }
13996                        function webViewerFirstPage() {
13997                            if (PDFViewerApplication.pdfDocument) {
13998                                PDFViewerApplication.page = 1;
13999                            }
14000                        }
14001                        function webViewerLastPage() {
14002                            if (PDFViewerApplication.pdfDocument) {
14003                                PDFViewerApplication.page = PDFViewerApplication.pagesCount;
14004                            }
14005                        }
14006                        function webViewerNextPage() {
14007                            PDFViewerApplication.page++;
14008                        }
14009                        function webViewerPreviousPage() {
14010                            PDFViewerApplication.page--;
14011                        }
14012                        function webViewerZoomIn() {
14013                            PDFViewerApplication.zoomIn();
14014                        }
14015                        function webViewerZoomOut() {
14016                            PDFViewerApplication.zoomOut();
14017                        }
14018                        function webViewerPageNumberChanged(e) {
14019                            var pdfViewer = PDFViewerApplication.pdfViewer;
14020                            pdfViewer.currentPageLabel = e.value;
14021                            if (e.value !== pdfViewer.currentPageNumber.toString() && e.value !== pdfViewer.currentPageLabel) {
14022                                PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
14023                            }
14024                        }
14025                        function webViewerScaleChanged(e) {
14026                            PDFViewerApplication.pdfViewer.currentScaleValue = e.value;
14027                        }
14028                        function webViewerRotateCw() {
14029                            PDFViewerApplication.rotatePages(90);
14030                        }
14031                        function webViewerRotateCcw() {
14032                            PDFViewerApplication.rotatePages(-90);
14033                        }
14034                        function webViewerDocumentProperties() {
14035                            PDFViewerApplication.pdfDocumentProperties.open();
14036                        }
14037                        function webViewerFind(e) {
14038                            PDFViewerApplication.findController.executeCommand('find' + e.type, {
14039                                query: e.query,
14040                                phraseSearch: e.phraseSearch,
14041                                caseSensitive: e.caseSensitive,
14042                                highlightAll: e.highlightAll,
14043                                findPrevious: e.findPrevious
14044                            });
14045                        }
14046                        function webViewerFindFromUrlHash(e) {
14047                            PDFViewerApplication.findController.executeCommand('find', {
14048                                query: e.query,
14049                                phraseSearch: e.phraseSearch,
14050                                caseSensitive: false,
14051                                highlightAll: true,
14052                                findPrevious: false
14053                            });
14054                        }
14055                        function webViewerScaleChanging(e) {
14056                            PDFViewerApplication.toolbar.setPageScale(e.presetValue, e.scale);
14057                            PDFViewerApplication.pdfViewer.update(
14057);
14058                        }
14059                        function webViewerPageChanging(e) {
14060                            var page = e.pageNumber;
14061                            PDFViewerApplication.toolbar.setPageNumber(page, e.pageLabel || null);
14062                            PDFViewerApplication.secondaryToolbar.setPageNumber(page);
14063                            if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
14064                                PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
14065                            }
14066                            if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
14067                                var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
14068                                if (pageView.stats) {
14069                                    Stats.add(page, pageView.stats);
14070                                }
14071                            }
14072                        }
14073                        var zoomDisabled = false, zoomDisabledTimeout;
14074                        function webViewerWheel(evt) {
14075                            var pdfViewer = PDFViewerApplication.pdfViewer;
14076                            if (pdfViewer.isInPresentationMode) {
14077                                return;
14078                            }
14079                            if (evt.ctrlKey || evt.metaKey) {
14080                                var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
14081                                if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
14082                                    return;
14083                                }
14084                                evt.preventDefault();
14085                                if (zoomDisabled) {
14086                                    return;
14087                                }
14088                                var previousScale = pdfViewer.currentScale;
14089                                var delta = normalizeWheelEventDelta(evt);
14090                                var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
14091                                var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
14092                                if (ticks < 0) {
14093                                    PDFViewerApplication.zoomOut(-ticks);
14094                                } else {
14095                                    PDFViewerApplication.zoomIn(ticks);
14096                                }
14097                                var currentScale = pdfViewer.currentScale;
14098                                if (previousScale !== currentScale) {
14099                                    var scaleCorrectionFactor = currentScale / previousScale - 1;
14100                                    var rect = pdfViewer.container.getBoundingClientRect();
14101                                    var dx = evt.clientX - rect.left;
14102                                    var dy = evt.clientY - rect.top;
14103                                    pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
14104                                    pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
14105                                }
14106                            } else {
14107                                zoomDisabled = true;
14108                                clearTimeout(zoomDisabledTimeout);
14109                                zoomDisabledTimeout = setTimeout(function () {
14110                                    zoomDisabled = false;
14111                                }, 1000);
14112                            }
14113                        }
14114                        function webViewerClick(evt) {
14115                            if (!PDFViewerApplication.secondaryToolbar.isOpen) {
14116                                return;
14117                            }
14118                            var appConfig = PDFViewerApplication.appConfig;
14119                            if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
14120                                PDFViewerApplication.secondaryToolbar.close();
14121                            }
14122                        }
14123                        function webViewerKeyDown(evt) {
14124                            if (OverlayManager.active) {
14125                                return;
14126                            }
14127                            var handled = false, ensureViewerFocused = false;
vendor: 5,578 bytes, lines 14128-14217
14128                            var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
14129                            var pdfViewer = PDFViewerApplication.pdfViewer;
14130                            var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
14131                            if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
14132                                switch (evt.keyCode) {
14133                                    case 70:
14134                                        if (!PDFViewerApplication.supportsIntegratedFind) {
14135                                            PDFViewerApplication.findBar.open();
14136                                            handled = true;
14137                                        }
14138                                        break;
14139                                    case 71:
14140                                        if (!PDFViewerApplication.supportsIntegratedFind) {
14141                                            var findState = PDFViewerApplication.findController.state;
14142                                            if (findState) {
14143                                                PDFViewerApplication.findController.executeCommand('findagain', {
14144                                                    query: findState.query,
14145                                                    phraseSearch: findState.phraseSearch,
14146                                                    caseSensitive: findState.caseSensitive,
14147                                                    highlightAll: findState.highlightAll,
14148                                                    findPrevious: cmd === 5 || cmd === 12
14149                                                });
14150                                            }
14151                                            handled = true;
14152                                        }
14153                                        break;
14154                                    case 61:
14155                                    case 107:
14156                                    case 187:
14157                                    case 171:
14158                                        if (!isViewerInPresentationMode) {
14159                                            PDFViewerApplication.zoomIn();
14160                                        }
14161                                        handled = true;
14162                                        break;
14163                                    case 173:
14164                                    case 109:
14165                                    case 189:
14166                                        if (!isViewerInPresentationMode) {
14167                                            PDFViewerApplication.zoomOut();
14168                                        }
14169                                        handled = true;
14170                                        break;
14171                                    case 48:
14172                                    case 96:
14173                                        if (!isViewerInPresentationMode) {
14174                                            setTimeout(function () {
14175                                                pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
14176                                            });
14177                                            handled = false;
14178                                        }
14179                                        break;
14180                                    case 38:
14181                                        if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
14182                                            PDFViewerApplication.page = 1;
14183                                            handled = true;
14184                                            ensureViewerFocused = true;
14185                                        }
14186                                        break;
14187                                    case 40:
14188                                        if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
14189                                            PDFViewerApplication.page = PDFViewerApplication.pagesCount;
14190                                            handled = true;
14191                                            ensureViewerFocused = true;
14192                                        }
14193                                        break;
14194                                }
14195                            }
14196                            if (cmd === 1 || cmd === 8) {
14197                                switch (evt.keyCode) {
14198                                    case 83:
14199                                        PDFViewerApplication.download();
14200                                        handled = true;
14201                                        break;
14202                                }
14203                            }
14204                            if (cmd === 3 || cmd === 10) {
14205                                switch (evt.keyCode) {
14206                                    case 80:
14207                                        PDFViewerApplication.requestPresentationMode();
14208                                        handled = true;
14209                                        break;
14210                                    case 71:
14211                                        PDFViewerApplication.appConfig.toolbar.pageNumber.select();
14212                                        handled = true;
14213                                        break;
14214                                }
14215                            }
14216                            if (handled) {
14217                                if (ensureViewerFocused && !isViewerInPresentationMode) {
14218                                    pdfViewer.focus();
14219                                }
14220                                evt.preventDefault();
14221                                return;
14222                            }
14223                            var curElement = document.activeElement || document.querySelector(':focus');
14224                            var curElementTagName = curElement && curElement.tagName.toUpperCase();
14225                            if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
14226                                if (evt.keyCode !== 27) {
14227                                    return;
14228                                }
14229                            }
14230                            if (cmd === 0) {
14231                                switch (evt.keyCode) {
14232                                    case 38:
14233                                    case 33:
14234                                    case 8:
14235                                        if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
14236                                            break;
14237                                        }
14238                                    case 37:
14239                                        if (pdfViewer.isHorizontalScrollbarEnabled) {
14240                                            break;
14241                                        }
14242                                    case 75:
14243                                    case 80:
14244                                        if (PDFViewerApplication.page > 1) {
14245                                            PDFViewerApplication.page--;
14246                                        }
14247                                        handled = true;
14248                                        break;
14249                                    case 27:
14250                                        if (PDFViewerApplication.secondaryToolbar.isOpen) {
14251                                            PDFViewerApplication.secondaryToolbar.close();
14252                                            handled = true;
14253                                        }
14254                                        if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
14255                                            PDFViewerApplication.findBar.close();
14256                                            handled = true;
14257                                        }
14258                                        break;
14259                                    case 40:
14260                                    case 34:
14261                                    case 32:
14262                                        if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
14263                                            break;
14264                                        }
14265                                    case 39:
14266                                        if (pdfViewer.isHorizontalScrollbarEnabled) {
14267                                            break;
14268                                        }
14269                                    case 74:
14270                                    case 78:
14271                                        if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
14272                                            PDFViewerApplication.page++;
14273                                        }
14274                                        handled = true;
14275                                        break;
14276                                    case 36:
14277                                        if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
14278                                            PDFViewerApplication.page = 1;
14279                                            handled = true;
14280                                            ensureViewerFocused = true;
14281                                        }
14282                                        break;
14283                                    case 35:
14284                                        if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
14285                                            PDFViewerApplication.page = PDFViewerApplication.pagesCount;
14286                                            handled = true;
14287                                            ensureViewerFocused = true;
14288                                        }
14289                                        break;
14290                                    case 72:
14291                                        if (!isViewerInPresentationMode) {
14292                                            PDFViewerApplication.handTool.toggle(
14292);
14293                                        }
14294                                        break;
14295                                    case 82:
14296                                        PDFViewerApplication.rotatePages(90);
14297                                        break;
14298                                }
14299                            }
14300                            if (cmd === 4) {
14301                                switch (evt.keyCode) {
14302                                    case 32:
14303                                        if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
14304                                            break;
14305                                        }
14306                                        if (PDFViewerApplication.page > 1) {
14307                                            PDFViewerApplication.page--;
14308                                        }
14309                                        handled = true;
14310                                        break;
14311                                    case 82:
14312                                        PDFViewerApplication.rotatePages(-90);
14313                                        break;
14314                                }
14315                            }
14316                            if (!handled && !isViewerInPresentationMode) {
14317                                if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
14318                                    ensureViewerFocused = true;
14319                                }
14320                            }
14321                            if (cmd === 2) {
14322                                switch (evt.keyCode) {
14323                                    case 37:
14324                                        if (isViewerInPresentationMode) {
14325                                            PDFViewerApplication.pdfHistory.back();
14326                                            handled = true;
14327                                        }
14328                                        break;
14329                                    case 39:
14330                                        if (isViewerInPresentationMode) {
14331                                            PDFViewerApplication.pdfHistory.forward();
14332                                            handled = true;
14333                                        }
14334                                        break;
14335                                }
14336                            }
14337                            if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
14338                                pdfViewer.focus();
14339                            }
14340                            if (handled) {
14341                                evt.preventDefault();
14342                            }
14343                        }
14344                        localized.then(function webViewerLocalized() {
14345                            document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
14346                        });
14347                        var PDFPrintServiceFactory = {
14348                            instance: {
14349                                supportsPrinting: false,
14350                                createPrintService: function () {
14351                                    throw new Error('Not implemented: createPrintService');
14352                                }
14353                            }
14354                        };
14355                        exports.PDFViewerApplication = PDFViewerApplication;
14356                        exports.DefaultExernalServices = DefaultExernalServices;
14357                        exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
14358
14359                        /***/ }),
14360                    /* 7 */
14361                    /***/ (function (module, exports, __webpack_require__) {
14362
14363                        "use strict";
14364
14365                        var uiUtils = __webpack_require__(0);
14366                        var scrollIntoView = uiUtils.scrollIntoView;
14367                        var FindStates = {
14368                            FIND_FOUND: 0,
14369                            FIND_NOTFOUND: 1,
14370                            FIND_WRAPPED: 2,
14371                            FIND_PENDING: 3
14372                        };
14373                        var FIND_SCROLL_OFFSET_TOP = -50;
14374                        var FIND_SCROLL_OFFSET_LEFT = -400;
14375                        var CHARACTERS_TO_NORMALIZE = {
14376                            '\u2018': '\'',
14377                            '\u2019': '\'',
14378                            '\u201A': '\'',
14379                            '\u201B': '\'',
14380                            '\u201C': '"',
14381                            '\u201D': '"',
14382                            '\u201E': '"',
14383                            '\u201F': '"',
14384                            '\u00BC': '1/4',
14385                            '\u00BD': '1/2',
14386                            '\u00BE': '3/4'
14387                        };
14388                        var PDFFindController = function PDFFindControllerClosure() {
14389                            function PDFFindController(options) {
14390                                this.pdfViewer = options.pdfViewer || null;
14391                                this.onUpdateResultsCount = null;
14392                                this.onUpdateState = null;
14393                                this.reset();
14394                                var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
14395                                this.normalizationRegex = new RegExp('[' + replace + ']', 'g');
14396                            }
14397                            PDFFindController.prototype = {
14398                                reset: function PDFFindController_reset() {
14399                                    this.startedTextExtraction = false;
14400                                    this.extractTextPromises = [];
14401                                    this.pendingFindMatches = Object.create(null);
14402                                    this.active = false;
14403                                    this.pageContents = [];
14404                                    this.pageMatches = [];
14405                                    this.pageMatchesLength = null;
14406                                    this.matchCount = 0;
14407                                    this.selected = {
14408                                        pageIdx: -1,
14409                                        matchIdx: -1
14410                                    };
14411                                    this.offset = {
14412                                        pageIdx: null,
14413                                        matchIdx: null
14414                                    };
14415                                    this.pagesToSearch = null;
14416                                    this.resumePageIdx = null;
14417                                    this.state = null;
14418                                    this.dirtyMatch = false;
14419                                    this.findTimeout = null;
14420                                    this.firstPagePromise = new Promise(function (resolve) {
14421                                        this.resolveFirstPage = resolve;
14422                                    }.bind(this));
14423                                },
14424                                normalize: function PDFFindController_normalize(text) {
14425                                    return text.replace(this.normalizationRegex, function (ch) {
14426                                        return CHARACTERS_TO_NORMALIZE[ch];
14427                                    });
14428                                },
14429                                _prepareMatches: function PDFFindController_prepareMatches(matchesWithLength, matches, matchesLength) {
14430                                    function isSubTerm(matchesWithLength, currentIndex) {
14431                                        var currentElem, prevElem, nextElem;
14432                                        currentElem = matchesWithLength[currentIndex];
14433                                        nextElem = matchesWithLength[currentIndex + 1];
14434                                        if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
14435                                            currentElem.skipped = true;
14436                                            return true;
14437                                        }
14438                                        for (var i = currentIndex - 1; i >= 0; i--) {
14439                                            prevElem = matchesWithLength[i];
14440                                            if (prevElem.skipped) {
14441                                                continue;
14442                                            }
14443                                            if (prevElem.match + prevElem.matchLength < currentElem.match) {
14444                                                break;
14445                                            }
14446                                            if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
14447                                                currentElem.skipped = true;
14448                                                return true;
14449                                            }
14450                                        }
14451                                        return false;
14452                                    }
14453                                    var i, len;
14454                                    matchesWithLength.sort(function (a, b) {
14455                                        return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
14456                                    });
14457                                    for (i = 0, len = matchesWithLength.length; i < len; i++) {
14458                                        if (isSubTerm(matchesWithLength, i)) {
14459                                            continue;
14460                                        }
14461                                        matches.push(matchesWithLength[i].match);
14462                                        matchesLength.push(matchesWithLength[i].matchLength);
14463                                    }
14464                                },
14465                                calcFindPhraseMatch: function PDFFindController_calcFindPhraseMatch(query, pageIndex, pageContent) {
14466                                    var matches = [];
14467                                    var queryLen = query.length;
14468                                    var matchIdx = -queryLen;
14469                                    while (true) {
14470                                        matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
14471                                        if (matchIdx === -1) {
14472                                            break;
14473                                        }
14474                                        matches.push(matchIdx);
14475                                    }
14476                                    this.pageMatches[pageIndex] = matches;
14477                                },
14478                                calcFindWordMatch: function PDFFindController_calcFindWordMatch(query, pageIndex, pageContent) {
14479                                    var matchesWithLength = [];
14480                                    var queryArray = query.match(/\S+/g);
14481                                    var subquery, subqueryLen, matchIdx;
14482                                    for (var i = 0, len = queryArray.length; i < len; i++) {
14483                                        subquery = queryArray[i];
14484                                        subqueryLen = subquery.length;
14485                                        matchIdx = -subqueryLen;
14486                                        while (true) {
14487                                            matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
14488                                            if (matchIdx === -1) {
14489                                                break;
14490                                            }
14491                                            matchesWithLength.push({
14492                                                match: matchIdx,
14493                                                matchLength: subqueryLen,
14494                                                skipped: false
14495                                            });
14496                                        }
14497                                    }
14498                                    if (!this.pageMatchesLength) {
14499                                        this.pageMatchesLength = [];
14500                                    }
14501                                    this.pageMatchesLength[pageIndex] = [];
14502                                    this.pageMatches[pageIndex] = [];
14503                                    this._prepareMatches(matchesWithLength, this.pageMatches[pageIndex], this.pageMatchesLength[pageIndex]);
14504                                },
14505                                calcFindMatch: function PDFFindController_calcFindMatch(pageIndex) {
14506                                    var pageContent = this.normalize(this.pageContents[pageIndex]);
14507                                    var query = this.normalize(this.state.query);
14508                                    var caseSensitive = this.state.caseSensitive;
14509                                    var phraseSearch = this.state.phraseSearch;
14510                                    var queryLen = query.length;
14511                                    if (queryLen === 0) {
14512                                        return;
14513                                    }
14514                                    if (!caseSensitive) {
14515                                        pageContent = pageContent.toLowerCase();
14516                                        query = query.toLowerCase();
14517                                    }
14518                                    if (phraseSearch) {
14519                                        this.calcFindPhraseMatch(query, pageIndex, pageContent);
14520                                    } else {
14521                                        this.calcFindWordMatch(query, pageIndex, pageContent);
14522                                    }
14523                                    this.updatePage(pageIndex);
14524                                    if (this.resumePageIdx === pageIndex) {
14525                                        this.resumePageIdx = null;
14526                                        this.nextPageMatch();
14527                                    }
14528                                    if (this.pageMatches[pageIndex].length > 0) {
14529                                        this.matchCount += this.pageMatches[pageIndex].length;
14530                                        this.updateUIResultsCount();
14531                                    }
14532                                },
14533                                extractText: function PDFFindController_extractText() {
14534                                    if (this.startedTextExtraction) {
14535                                        return;
14536                                    }
14537                                    this.startedTextExtraction = true;
14538                                    this.pageContents = [];
14539                                    var extractTextPromisesResolves = [];
14540                                    var numPages = this.pdfViewer.pagesCount;
14541                                    for (var i = 0; i < numPages; i++) {
14542                                        this.extractTextPromises.push(new Promise(function (resolve) {
14543                                            extractTextPromisesResolves.push(resolve);
14544                                        }));
14545                                    }
14546                                    var self = this;
14547                                    function extractPageText(pageIndex) {
14548                                        self.pdfViewer.getPageTextContent(pageIndex).then(function textContentResolved(textContent) {
14549                                            var textItems = textContent.items;
14550                                            var str = [];
14551                                            for (var i = 0, len = textItems.length; i < len; i++) {
14552                                                str.push(textItems[i].str);
14553                                            }
14554                                            self.pageContents.push(str.join(''));
vendor: 4,521 bytes, lines 14555-14623
14555                                            extractTextPromisesResolves[pageIndex](pageIndex);
14556                                            if (pageIndex + 1 < self.pdfViewer.pagesCount) {
14557                                                extractPageText(pageIndex + 1);
14558                                            }
14559                                        });
14560                                    }
14561                                    extractPageText(0);
14562                                },
14563                                executeCommand: function PDFFindController_executeCommand(cmd, state) {
14564                                    if (this.state === null || cmd !== 'findagain') {
14565                                        this.dirtyMatch = true;
14566                                    }
14567                                    this.state = state;
14568                                    this.updateUIState(FindStates.FIND_PENDING);
14569                                    this.firstPagePromise.then(function () {
14570                                        this.extractText();
14571                                        clearTimeout(this.findTimeout);
14572                                        if (cmd === 'find') {
14573                                            this.findTimeout = setTimeout(this.nextMatch.bind(this), 250);
14574                                        } else {
14575                                            this.nextMatch();
14576                                        }
14577                                    }.bind(this));
14578                                },
14579                                updatePage: function PDFFindController_updatePage(index) {
14580                                    if (this.selected.pageIdx === index) {
14581                                        this.pdfViewer.currentPageNumber = index + 1;
14582                                    }
14583                                    var page = this.pdfViewer.getPageView(index);
14584                                    if (page.textLayer) {
14585                                        page.textLayer.updateMatches();
14586                                    }
14587                                },
14588                                nextMatch: function PDFFindController_nextMatch() {
14589                                    var previous = this.state.findPrevious;
14590                                    var currentPageIndex = this.pdfViewer.currentPageNumber - 1;
14591                                    var numPages = this.pdfViewer.pagesCount;
14592                                    this.active = true;
14593                                    if (this.dirtyMatch) {
14594                                        this.dirtyMatch = false;
14595                                        this.selected.pageIdx = this.selected.matchIdx = -1;
14596                                        this.offset.pageIdx = currentPageIndex;
14597                                        this.offset.matchIdx = null;
14598                                        this.hadMatch = false;
14599                                        this.resumePageIdx = null;
14600                                        this.pageMatches = [];
14601                                        this.matchCount = 0;
14602                                        this.pageMatchesLength = null;
14603                                        var self = this;
14604                                        for (var i = 0; i < numPages; i++) {
14605                                            this.updatePage(i);
14606                                            if (!(i in this.pendingFindMatches)) {
14607                                                this.pendingFindMatches[i] = true;
14608                                                this.extractTextPromises[i].then(function (pageIdx) {
14609                                                    delete self.pendingFindMatches[pageIdx];
14610                                                    self.calcFindMatch(pageIdx);
14611                                                });
14612                                            }
14613                                        }
14614                                    }
14615                                    if (this.state.query === '') {
14616                                        this.updateUIState(FindStates.FIND_FOUND);
14617                                        return;
14618                                    }
14619                                    if (this.resumePageIdx) {
14620                                        return;
14621                                    }
14622                                    var offset = this.offset;
14623                                    this.pagesToSearch = numPages;
14624                                    if (offset.matchIdx !== null) {
14625                                        var numPageMatches = this.pageMatches[offset.pageIdx].length;
14626                                        if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
14627                                            this.hadMatch = true;
14628                                            offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
14629                                            this.updateMatch(true);
14630                                            return;
14631                                        }
14632                                        this.advanceOffsetPage(previous);
14633                                    }
14634                                    this.nextPageMatch();
14635                                },
14636                                matchesReady: function PDFFindController_matchesReady(matches) {
14637                                    var offset = this.offset;
14638                                    var numMatches = matches.length;
14639                                    var previous = this.state.findPrevious;
14640                                    if (numMatches) {
14641                                        this.hadMatch = true;
14642                                        offset.matchIdx = previous ? numMatches - 1 : 0;
14643                                        this.updateMatch(true);
14644                                        return true;
14645                                    }
14646                                    this.advanceOffsetPage(previous);
14647                                    if (offset.wrapped) {
14648                                        offset.matchIdx = null;
14649                                        if (this.pagesToSearch < 0) {
14650                                            this.updateMatch(false);
14651                                            return true;
14652                                        }
14653                                    }
14654                                    return false;
14655                                },
14656                                updateMatchPosition: function PDFFindController_updateMatchPosition(pageIndex, index, elements, beginIdx) {
14657                                    if (this.selected.matchIdx === index && this.selected.pageIdx === pageIndex) {
14658                                        var spot = {
14659                                            top: FIND_SCROLL_OFFSET_TOP,
14660                                            left: FIND_SCROLL_OFFSET_LEFT
14661                                        };
14662                                        scrollIntoView(elements[beginIdx], spot, true);
14663                                    }
14664                                },
14665                                nextPageMatch: function PDFFindController_nextPageMatch() {
14666                                    if (this.resumePageIdx !== null) {
14667                                        console.error('There can only be one pending page.');
14668                                    }
14669                                    do {
14670                                        var pageIdx = this.offset.pageIdx;
14671                                        var matches = this.pageMatches[pageIdx];
14672                                        if (!matches) {
14673                                            this.resumePageIdx = pageIdx;
14674                                            break;
14675                                        }
14676                                    } while (!this.matchesReady(matches));
14677                                },
14678                                advanceOffsetPage: function PDFFindController_advanceOffsetPage(previous) {
14679                                    var offset = this.offset;
14680                                    var numPages = this.extractTextPromises.length;
14681                                    offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
14682                                    offset.matchIdx = null;
14683                                    this.pagesToSearch--;
14684                                    if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
14685                                        offset.pageIdx = previous ? numPages - 1 : 0;
14686                                        offset.wrapped = true;
14687                                    }
14688                                },
14689                                updateMatch: function PDFFindController_updateMatch(found) {
14690                                    var state = FindStates.FIND_NOTFOUND;
14691                                    var wrapped = this.offset.wrapped;
14692                                    this.offset.wrapped = false;
14693                                    if (found) {
14694                                        var previousPage = this.selected.pageIdx;
14695                                        this.selected.pageIdx = this.offset.pageIdx;
14696                                        this.selected.matchIdx = this.offset.matchIdx;
14697                                        state = wrapped ? FindStates.FIND_WRAPPED : FindStates.FIND_FOUND;
14698                                        if (previousPage !== -1 && previousPage !== this.selected.pageIdx) {
14699                                            this.updatePage(previousPage);
14700                                        }
14701                                    }
14702                                    this.updateUIState(state, this.state.findPrevious);
14703                                    if (this.selected.pageIdx !== -1) {
14704                                        this.updatePage(this.selected.pageIdx);
14705                                    }
14706                                },
14707                                updateUIResultsCount: function PDFFindController_updateUIResultsCount() {
14708                                    if (this.onUpdateResultsCount) {
14709                                        this.onUpdateResultsCount(this.matchCount);
14710                                    }
14711                                },
14712                                updateUIState: function PDFFindController_updateUIState(state, previous) {
14713                                    if (this.onUpdateState) {
14714                                        this.onUpdateState(state, previous, this.matchCount);
14715                                    }
14716                                }
14717                            };
14718                            return PDFFindController;
14719                        }();
14720                        exports.FindStates = FindStates;
14721                        exports.PDFFindController = PDFFindController;
14722
14723                        /***/ }),
14724                    /* 8 */
14725                    /***/ (function (module, exports, __webpack_require__) {
14726
14727                        "use strict";
14728
14729                        var defaultPreferences = null;
14730                        function getDefaultPreferences() {
14731                            if (!defaultPreferences) {
14732                                defaultPreferences = Promise.resolve({
14733                                    "showPreviousViewOnLoad": true,
14734                                    "defaultZoomValue": "",
14735                                    "sidebarViewOnLoad": 0,
14736                                    "enableHandToolOnLoad": false,
14737                                    "enableWebGL": false,
14738                                    "pdfBugEnabled": false,
14739                                    "disableRange": false,
14740                                    "disableStream": false,
14741                                    "disableAutoFetch": false,
14742                                    "disableFontFace": false,
14743                                    "disableTextLayer": false,
14744                                    "useOnlyCssZoom": false,
14745                                    "externalLinkTarget": 0,
14746                                    "enhanceTextSelection": false,
14747                                    "renderer": "canvas",
14748                                    "renderInteractiveForms": false,
14749                                    "enablePrintAutoRotate": false,
14750                                    "disablePageLabels": false
14751                                });
14752                            }
14753                            return defaultPreferences;
14754                        }
14755                        function cloneObj(obj) {
14756                            var result = {};
14757                            for (var i in obj) {
14758                                if (Object.prototype.hasOwnProperty.call(obj, i)) {
14759                                    result[i] = obj[i];
14760                                }
14761                            }
14762                            return result;
14763                        }
14764                        var Preferences = {
14765                            prefs: null,
14766                            isInitializedPromiseResolved: false,
14767                            initializedPromise: null,
14768                            initialize: function preferencesInitialize() {
14769                                return this.initializedPromise = getDefaultPreferences().then(function (defaults) {
14770                                    Object.defineProperty(this, 'defaults', {
14771                                        value: Object.freeze(defaults),
14772                                        writable: false,
14773                                        enumerable: true,
14774                                        configurable: false
14775                                    });
14776                                    this.prefs = cloneObj(defaults);
14777                                    return this._readFromStorage(defaults);
14778                                }.bind(this)).then(function (prefObj) {
14779                                    this.isInitializedPromiseResolved = true;
14780                                    if (prefObj) {
14781                                        this.prefs = prefObj;
14782                                    }
14783                                }.bind(this));
14784                            },
14785                            _writeToStorage: function preferences_writeToStorage(prefObj) {
14786                                return Promise.resolve();
14787                            },
14788                            _readFromStorage: function preferences_readFromStorage(prefObj) {
14789                                return Promise.resolve();
14790                            },
14791                            reset: function preferencesReset() {
14792                                return this.initializedPromise.then(function () {
14793                                    this.prefs = cloneObj(this.defaults);
14794                                    return this._writeToStorage(this.defaults);
14795                                }.bind(this));
14796                            },
14797                            reload: function preferencesReload() {
14798                                return this.initializedPromise.then(function () {
14799                                    this._readFromStorage(this.defaults).then(function (prefObj) {
14800                                        if (prefObj) {
14801                                            this.prefs = prefObj;
14802                                        }
14803                                    }.bind(this));
14804                                }.bind(this));
14805                            },
14806                            set: function preferencesSet(name, value) {
14807                                return this.initializedPromise.then(function () {
14808                                    if (this.defaults[name] === undefined) {
14809                                        throw new Error('preferencesSet: \'' + name + '\' is undefined.');
14810                                    } else if (value === undefined) {
14811                                        throw new Error('preferencesSet: no value is specified.');
14812                                    }
14813                                    var valueType = typeof value;
14814                                    var defaultType = typeof this.defaults[name];
14815                                    if (valueType !== defaultType) {
14816                                        if (valueType === 'number' && defaultType === 'string') {
14817                                            value = value.toString();
14818                                        } else {
14819                                            throw new Error('Preferences_set: \'' + value + '\' is a \"' + valueType + '\", expected \"' + defaultType + '\".');
14820                                        }
14821                                    } else {
14822                                        if (valueType === 'number' && (value | 0) !== value) {
14823                                            throw new Error('Preferences_set: \'' + value + '\' must be an \"integer\".');
14824                                        }
14825                                    }
14826                                    this.prefs[name] = value;
14827                                    return this._writeToStorage(this.prefs);
14828                                }.bind(this));
14829                            },
14830                            get: function preferencesGet(name) {
14831                                return this.initializedPromise.then(function () {
14832                                    var defaultValue = this.defaults[name];
14833                                    if (defaultValue === undefined) {
14834                                        throw new Error('preferencesGet: \'' + name + '\' is undefined.');
14835                                    } else {
14836                                        var prefValue = this.prefs[name];
14837                                        if (prefValue !== undefined) {
14838                                            return prefValue;
14839                                        }
14840                                    }
14841                                    return defaultValue;
14842                                }.bind(this));
14843                            }
14844                        };
14845                        Preferences._writeToStorage = function (prefObj) {
14846                            return new Promise(function (resolve) {
14847                                localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
14848                                resolve();
14849                            });
14850                        };
14851                        Preferences._readFromStorage = function (prefObj) {
14852                            return new Promise(function (resolve) {
14853                                var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
14854                                resolve(readPrefs);
14855                            });
14856                        };
14857                        exports.Preferences = Preferences;
14858
14859                        /***/ }),
14860                    /* 9 */
14861                    /***/ (function (module, exports, __webpack_require__) {
14862
14863                        "use strict";
14864
14865                        var uiUtils = __webpack_require__(0);
14866                        var overlayManager = __webpack_require__(4);
14867                        var app = __webpack_require__(6);
14868                        var pdfjsLib = __webpack_require__(1);
14869                        var mozL10n = uiUtils.mozL10n;
14870                        var CSS_UNITS = uiUtils.CSS_UNITS;
14871                        var PDFPrintServiceFactory = app.PDFPrintServiceFactory;
14872                        var OverlayManager = overlayManager.OverlayManager;
14873                        var activeService = null;
14874                        function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
14875                            var scratchCanvas = activeService.scratchCanvas;
14876                            var PRINT_RESOLUTION = 150;
14877                            var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
14878                            scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
14879                            scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
14880                            var width = Math.floor(size.width * CSS_UNITS) + 'px';
14881                            var height = Math.floor(size.height * CSS_UNITS) + 'px';
14882                            var ctx = scratchCanvas.getContext('2d');
14883                            ctx.save();
14884                            ctx.fillStyle = 'rgb(255, 255, 255)';
14885                            ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
14886                            ctx.restore();
14887                            return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
14888                                var renderContext = {
14889                                    canvasContext: ctx,
14890                                    transform: [
14891                                        PRINT_UNITS,
14892                                        0,
14893                                        0,
14894                                        PRINT_UNITS,
14895                                        0,
14896                                        0
14897                                    ],
14898                                    viewport: pdfPage.getViewport(1, size.rotation),
14899                                    intent: 'print'
14900                                };
14901                                return pdfPage.render(renderContext).promise;
14902                            }).then(function () {
14903                                return {
14904                                    width: width,
14905                                    height: height
14906                                };
14907                            });
14908                        }
14909                        function PDFPrintService(pdfDocument, pagesOverview, printContainer) {
14910                            this.pdfDocument = pdfDocument;
14911                            this.pagesOverview = pagesOverview;
14912                            this.printContainer = printContainer;
14913                            this.currentPage = -1;
14914                            this.scratchCanvas = document.createElement('canvas');
14915                        }
14916                        PDFPrintService.prototype = {
14917                            layout: function () {
14918                                this.throwIfInactive();
14919                                var body = document.querySelector('body');
14920                                body.setAttribute('data-pdfjsprinting', true);
14921                                var hasEqualPageSizes = this.pagesOverview.every(function (size) {
14922                                    return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
14923                                }, this);
14924                                if (!hasEqualPageSizes) {
14925                                    console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
14926                                }
14927                                this.pageStyleSheet = document.createElement('style');
14928                                var pageSize = this.pagesOverview[0];
14929                                this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
14930                                body.appendChild(this.pageStyleSheet);
14931                            },
14932                            destroy: function () {
14933                                if (activeService !== this) {
14934                                    return;
14935                                }
14936                                this.printContainer.textContent = '';
14937                                if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
14938                                    this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
14939                                    this.pageStyleSheet = null;
14940                                }
14941                                this.scratchCanvas.width = this.scratchCanvas.height = 0;
14942                                this.scratchCanvas = null;
14943                                activeService = null;
14944                                ensureOverlay().then(function () {
14945                                    if (OverlayManager.active !== 'printServiceOverlay') {
14946                                        return;
14947                                    }
14948                                    OverlayManager.close('printServiceOverlay');
14949                                });
14950                            },
14951                            renderPages: function () {
14952                                var pageCount = this.pagesOverview.length;
14953                                var renderNextPage = function (resolve, reject) {
14954                                    this.throwIfInactive();
14955                                    if (++this.currentPage >= pageCount) {
14956                                        renderProgress(pageCount, pageCount);
14957                                        resolve();
14958                                        return;
14959                                    }
14960                                    var index = this.currentPage;
14961                                    renderProgress(index, pageCount);
14962                                    renderPage(this, this.pdfDocument, index + 1, this.pagesOverview[index]).then(this.useRenderedPage.bind(this)).then(function () {
14963                                        renderNextPage(resolve, reject);
14964                                    }, reject);
14965                                }.bind(this);
14966                                return new Promise(renderNextPage);
14967                            },
14968                            useRenderedPage: function (printItem) {
14969                                this.throwIfInactive();
14970                                var img = document.createElement('img');
14971                                img.style.width = printItem.width;
14972                                img.style.height = printItem.height;
14973                                var scratchCanvas = this.scratchCanvas;
14974                                if ('toBlob' in scratchCanvas && !pdfjsLib.PDFJS.disableCreateObjectURL) {
14975                                    scratchCanvas.toBlob(function (blob) {
14976                                        img.src = URL.createObjectURL(blob);
14977                                    });
14978                                } else {
14979                                    img.src = scratchCanvas.toDataURL();
14980                                }
14981                                var wrapper = document.createElement('div');
14982                                wrapper.appendChild(img);
14983                                this.printContainer.appendChild(wrapper);
14984                                return new Promise(function (resolve, reject) {
14985                                    img.onload = resolve;
14986                                    img.onerror = reject;
14987                                });
14988                            },
14989                            performPrint: function () {
14990                                this.throwIfInactive();
14991                                return new Promise(function (resolve) {
14992                                    setTimeout(function () {
14993                                        if (!this.active) {
14994                                            resolve();
14995                                            return;
14996                                        }
14997                                        print.call(window);
14998                                        setTimeout(resolve, 20);
14999                                    }.bind(this), 0);
15000                                }.bind(this));
15001                            },
15002                            get active() {
15003                                return this === activeService;
15004                            },
15005                            throwIfInactive: function () {
15006                                if (!this.active) {
15007                                    throw new Error('This print request was cancelled or completed.');
15008                                }
15009                            }
15010                        };
15011                        var print = window.print;
15012                        window.print = function print() {
15013                            if (activeService) {
15014                                console.warn('Ignored window.print() because of a pending print job.');
15015                                return;
15016                            }
15017                            ensureOverlay().then(function () {
15018                                if (activeService) {
15019                                    OverlayManager.open('printServiceOverlay');
15020                                }
15021                            });
15022                            try {
15023                                dispatchEvent('beforeprint');
15024                            } finally {
15025                                if (!activeService) {
15026                                    console.error('Expected print service to be initialized.');
15027                                    if (OverlayManager.active === 'printServiceOverlay') {
15028                                        OverlayManager.close('printServiceOverlay');
15029                                    }
15030                                    return;
15031                                }
15032                                var activeServiceOnEntry = activeService;
15033                                activeService.renderPages().then(function () {
15034                                    return activeServiceOnEntry.performPrint();
15035                                }).catch(function () {
15036                                }).then(function () {
15037                                    if (activeServiceOnEntry.active) {
15038                                        abort();
15039                                    }
15040                                });
15041                            }
15042                        };
15043                        function dispatchEvent(eventType) {
15044                            var event = document.createEvent('CustomEvent');
15045                            event.initCustomEvent(eventType, false, false, 'custom');
15046                            window.dispatchEvent(event);
15047                        }
15048                        function abort() {
15049                            if (activeService) {
15050                                activeService.destroy();
15051                                dispatchEvent('afterprint');
15052                            }
15053                        }
15054                        function renderProgress(index, total) {
15055                            var progressContainer = document.getElementById('printServiceOverlay');
15056                            var progress = Math.round(100 * index / total);
15057                            var progressBar = progressContainer.querySelector('progress');
15058                            var progressPerc = progressContainer.querySelector('.relative-progress');
15059                            progressBar.value = progress;
15060                            progressPerc.textContent = mozL10n.get('print_progress_percent', {progress: progress}, progress + '%');
15061                        }
15062                        var hasAttachEvent = !!document.attachEvent;
15063                        window.addEventListener('keydown', function (event) {
15064                            if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
15065                                window.print();
15066                                if (hasAttachEvent) {
15067                                    return;
15068                                }
15069                                event.preventDefault();
15070                                if (event.stopImmediatePropagation) {
15071                                    event.stopImmediatePropagation();
15072                                } else {
15073                                    event.stopPropagation();
15074                                }
15075                                return;
15076                            }
15077                        }, true);
15078                        if (hasAttachEvent) {
15079                            document.attachEvent('onkeydown', function (event) {
15080                                event = event || window.event;
15081                                if (event.keyCode === 80 && event.ctrlKey) {
15082                                    event.keyCode = 0;
15083                                    return false;
15084                                }
15085                            });
15086                        }
15087                        if ('onbeforeprint' in window) {
15088                            var stopPropagationIfNeeded = function (event) {
15089                                if (event.detail !== 'custom' && event.stopImmediatePropagation) {
15090                                    event.stopImmediatePropagation();
15091                                }
15092                            };
15093                            window.addEventListener('beforeprint', stopPropagationIfNeeded);
15094                            window.addEventListener('afterprint', stopPropagationIfNeeded);
15095                        }
15096                        var overlayPromise;
15097                        function ensureOverlay() {
15098                            if (!overlayPromise) {
15099                                overlayPromise = OverlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
15100                                document.getElementById('printCancel').onclick = abort;
15101                            }
15102                            return overlayPromise;
15103                        }
15104                        PDFPrintServiceFactory.instance = {
15105                            supportsPrinting: true,
15106                            createPrintService: function (pdfDocument, pagesOverview, printContainer) {
15107                                if (activeService) {
15108                                    throw new Error('The print service is created and active.');
15109                                }
15110                                activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer);
15111                                return activeService;
15112                            }
15113                        };
15114                        exports.PDFPrintService = PDFPrintService;
15115
15116                        /***/ }),
15117                    /* 10 */
15118                    /***/ (function (module, exports, __webpack_require__) {
15119
15120                        "use strict";
15121
15122                        var uiUtils = __webpack_require__(0);
15123                        var pdfLinkService = __webpack_require__(5);
15124                        var pdfjsLib = __webpack_require__(1);
15125                        var mozL10n = uiUtils.mozL10n;
15126                        var SimpleLinkService = pdfLinkService.SimpleLinkService;
15127                        var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
15128                            function AnnotationLayerBuilder(options) {
15129                                this.pageDiv = options.pageDiv;
15130                                this.pdfPage = options.pdfPage;
15131                                this.renderInteractiveForms = options.renderInteractiveForms;
15132                                this.linkService = options.linkService;
15133                                this.downloadManager = options.downloadManager;
15134                                this.div = null;
15135                            }
15136                            AnnotationLayerBuilder.prototype = {
15137                                render: function AnnotationLayerBuilder_render(viewport, intent) {
15138                                    var self = this;
15139                                    var parameters = {intent: intent === undefined ? 'display' : intent};
15140                                    this.pdfPage.getAnnotations(parameters).then(function (annotations) {
15141                                        viewport = viewport.clone({dontFlip: true});
15142                                        parameters = {
15143                                            viewport: viewport,
15144                                            div: self.div,
15145                                            annotations: annotations,
15146                                            page: self.pdfPage,
15147                                            renderInteractiveForms: self.renderInteractiveForms,
15148                                            linkService: self.linkService,
15149                                            downloadManager: self.downloadManager
15150                                        };
15151                                        if (self.div) {
15152                                            pdfjsLib.AnnotationLayer.update(parameters);
15153                                        } else {
15154                                            if (annotations.length === 0) {
15155                                                return;
15156                                            }
15157                                            self.div = document.createElement('div');
15158                                            self.div.className = 'annotationLayer';
15159                                            self.pageDiv.appendChild(self.div);
15160                                            parameters.div = self.div;
15161                                            pdfjsLib.AnnotationLayer.render(parameters);
15162                                            if (typeof mozL10n !== 'undefined') {
15163                                                mozL10n.translate(self.div);
15164                                            }
15165                                        }
15166                                    });
15167                                },
15168                                hide: function AnnotationLayerBuilder_hide() {
15169                                    if (!this.div) {
15170                                        return;
15171                                    }
15172                                    this.div.setAttribute('hidden', 'true');
15173                                }
15174                            };
15175                            return AnnotationLayerBuilder;
15176                        }();
15177                        function DefaultAnnotationLayerFactory() {
15178                        }
15179                        DefaultAnnotationLayerFactory.prototype = {
15180                            createAnnotationLayerBuilder: function (pageDiv, pdfPage, renderInteractiveForms) {
15181                                return new AnnotationLayerBuilder({
15182                                    pageDiv: pageDiv,
15183                                    pdfPage: pdfPage,
15184                                    renderInteractiveForms: renderInteractiveForms,
15185                                    linkService: new SimpleLinkService()
15186                                });
15187                            }
15188                        };
15189                        exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
15190                        exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
15191
15192                        /***/ }),
15193                    /* 11 */
15194                    /***/ (function (module, exports, __webpack_require__) {
15195
15196                        "use strict";
15197
15198                        var pdfjsLib = __webpack_require__(1);
15199                        function download(blobUrl, filename) {
15200                            var a = document.createElement('a');
15201                            if (a.click) {
15202                                a.href = blobUrl;
15203                                a.target = '_parent';
15204                                if ('download' in a) {
15205                                    a.download = filename;
15206                                }
15207                                (document.body || document.documentElement).appendChild(a);
15208                                a.click();
15209                                a.parentNode.removeChild(a);
15210                            } else {
15211                                if (window.top === window && blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
15212                                    var padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&';
15213                                    blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&');
15214                                }
15215                                window.open(blobUrl, '_parent');
15216                            }
15217                        }
15218                        function DownloadManager() {
15219                        }
15220                        DownloadManager.prototype = {
15221                            downloadUrl: function DownloadManager_downloadUrl(url, filename) {
15222                                if (!pdfjsLib.createValidAbsoluteUrl(url, 'http://example.com')) {
15223                                    return;
15224                                }
15225                                download(url + '#pdfjs.action=download', filename);
15226                            },
15227                            downloadData: function DownloadManager_downloadData(data, filename, contentType) {
15228                                if (navigator.msSaveBlob) {
15229                                    return navigator.msSaveBlob(new Blob([data], {type: contentType}), filename);
15230                                }
15231                                var blobUrl = pdfjsLib.createObjectURL(data, contentType, pdfjsLib.PDFJS.disableCreateObjectURL);
15232                                download(blobUrl, filename);
15233                            },
15234                            download: function DownloadManager_download(blob, url, filename) {
15235                                if (navigator.msSaveBlob) {
15236                                    if (!navigator.msSaveBlob(blob, filename)) {
15237                                        this.downloadUrl(url, filename);
15238                                    }
15239                                    return;
15240                                }
15241                                if (pdfjsLib.PDFJS.disableCreateObjectURL) {
15242                                    this.downloadUrl(url, filename);
15243                                    return;
15244                                }
15245                                var blobUrl = URL.createObjectURL(blob);
15246                                download(blobUrl, filename);
15247                            }
15248                        };
15249                        exports.DownloadManager = DownloadManager;
15250
15251                        /***/ }),
15252                    /* 12 */
15253                    /***/ (function (module, exports, __webpack_require__) {
15254
15255                        "use strict";
15256
15257                        function GrabToPan(options) {
15258                            this.element = options.element;
15259                            this.document = options.element.ownerDocument;
15260                            if (typeof options.ignoreTarget === 'function') {
15261                                this.ignoreTarget = options.ignoreTarget;
15262                            }
15263                            this.onActiveChanged = options.onActiveChanged;
15264                            this.activate = this.activate.bind(this);
15265                            this.deactivate = this.deactivate.bind(this);
15266                            this.toggle = this.toggle.bind(this);
15267                            this._onmousedown = this._onmousedown.bind(this);
15268                            this._onmousemove = this._onmousemove.bind(this);
15269                            this._endPan = this._endPan.bind(this);
vendor: 8,195 bytes, lines 15270-15410
15270                            var overlay = this.overlay = document.createElement('div');
15271                            overlay.className = 'grab-to-pan-grabbing';
15272                        }
15273                        GrabToPan.prototype = {
15274                            CSS_CLASS_GRAB: 'grab-to-pan-grab',
15275                            activate: function GrabToPan_activate() {
15276                                if (!this.active) {
15277                                    this.active = true;
15278                                    this.element.addEventListener('mousedown', this._onmousedown, true);
15279                                    this.element.classList.add(this.CSS_CLASS_GRAB);
15280                                    if (this.onActiveChanged) {
15281                                        this.onActiveChanged(true);
15282                                    }
15283                                }
15284                            },
15285                            deactivate: function GrabToPan_deactivate() {
15286                                if (this.active) {
15287                                    this.active = false;
15288                                    this.element.removeEventListener('mousedown', this._onmousedown, true);
15289                                    this._endPan();
15290                                    this.element.classList.remove(this.CSS_CLASS_GRAB);
15291                                    if (this.onActiveChanged) {
15292                                        this.onActiveChanged(false);
15293                                    }
15294                                }
15295                            },
15296                            toggle: function GrabToPan_toggle() {
15297                                if (this.active) {
15298                                    this.deactivate();
15299                                } else {
15300                                    this.activate();
15301                                }
15302                            },
15303                            ignoreTarget: function GrabToPan_ignoreTarget(node) {
15304                                return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
15305                            },
15306                            _onmousedown: function GrabToPan__onmousedown(event) {
15307                                if (event.button !== 0 || this.ignoreTarget(event.target)) {
15308                                    return;
15309                                }
15310                                if (event.originalTarget) {
15311                                    try {
15312                                        event.originalTarget.tagName;
15313                                    } catch (e) {
15314                                        return;
15315                                    }
15316                                }
15317                                this.scrollLeftStart = this.element.scrollLeft;
15318                                this.scrollTopStart = this.element.scrollTop;
15319                                this.clientXStart = event.clientX;
15320                                this.clientYStart = event.clientY;
15321                                this.document.addEventListener('mousemove', this._onmousemove, true);
15322                                this.document.addEventListener('mouseup', this._endPan, true);
15323                                this.element.addEventListener('scroll', this._endPan, true);
15324                                event.preventDefault();
15325                                event.stopPropagation();
15326                                var focusedElement = document.activeElement;
15327                                if (focusedElement && !focusedElement.contains(event.target)) {
15328                                    focusedElement.blur();
15329                                }
15330                            },
15331                            _onmousemove: function GrabToPan__onmousemove(event) {
15332                                this.element.removeEventListener('scroll', this._endPan, true);
15333                                if (isLeftMouseReleased(event)) {
15334                                    this._endPan();
15335                                    return;
15336                                }
15337                                var xDiff = event.clientX - this.clientXStart;
15338                                var yDiff = event.clientY - this.clientYStart;
15339                                var scrollTop = this.scrollTopStart - yDiff;
15340                                var scrollLeft = this.scrollLeftStart - xDiff;
15341                                if (this.element.scrollTo) {
15342                                    this.element.scrollTo({
15343                                        top: scrollTop,
15344                                        left: scrollLeft,
15345                                        behavior: 'instant'
15346                                    });
15347                                } else {
15348                                    this.element.scrollTop = scrollTop;
15349                                    this.element.scrollLeft = scrollLeft;
15350                                }
15351                                if (!this.overlay.parentNode) {
15352                                    document.body.appendChild(this.overlay);
15353                                }
15354                            },
15355                            _endPan: function GrabToPan__endPan() {
15356                                this.element.removeEventListener('scroll', this._endPan, true);
15357                                this.document.removeEventListener('mousemove', this._onmousemove, true);
15358                                this.document.removeEventListener('mouseup', this._endPan, true);
15359                                this.overlay.remove();
15360                            }
15361                        };
15362                        var matchesSelector;
15363                        [
15364                            'webkitM',
15365                            'mozM',
15366                            'msM',
15367                            'oM',
15368                            'm'
15369                        ].some(function (prefix) {
15370                            var name = prefix + 'atches';
15371                            if (name in document.documentElement) {
15372                                matchesSelector = name;
15373                            }
15374                            name += 'Selector';
15375                            if (name in document.documentElement) {
15376                                matchesSelector = name;
15377                            }
15378                            return matchesSelector;
15379                        });
15380                        var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
15381                        var chrome = window.chrome;
15382                        var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
15383                        var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
15384                        function isLeftMouseReleased(event) {
15385                            if ('buttons' in event && isNotIEorIsIE10plus) {
15386                                return !(event.buttons & 1);
15387                            }
15388                            if (isChrome15OrOpera15plus || isSafari6plus) {
15389                                return event.which === 0;
15390                            }
15391                        }
15392                        exports.GrabToPan = GrabToPan;
15393
15394                        /***/ }),
15395                    /* 13 */
15396                    /***/ (function (module, exports, __webpack_require__) {
15397
15398                        "use strict";
15399
15400                        var grabToPan = __webpack_require__(12);
15401                        var preferences = __webpack_require__(8);
15402                        var uiUtils = __webpack_require__(0);
15403                        var GrabToPan = grabToPan.GrabToPan;
15404                        var Preferences = preferences.Preferences;
15405                        var localized = uiUtils.localized;
15406                        var HandTool = function HandToolClosure() {
15407                            function HandTool(options) {
15408                                this.container = options.container;
15409                                this.eventBus = options.eventBus;
15410                                this.wasActive = false;
15411                                this.handTool = new GrabToPan({
15412                                    element: this.container,
15413                                    onActiveChanged: function (isActive) {
15414                                        this.eventBus.dispatch('handtoolchanged', {isActive: isActive});
15415                                    }.bind(this)
15416                                });
15417                                this.eventBus.on('togglehandtool', this.toggle.bind(this));
15418                                Promise.all([
15419                                    localized,
15420                                    Preferences.get('enableHandToolOnLoad')
15421                                ]).then(function resolved(values) {
15422                                    if (values[1] === true) {
15423                                        this.handTool.activate();
15424                                    }
15425                                }.bind(this)).catch(function rejected(reason) {
15426                                });
15427                                this.eventBus.on('presentationmodechanged', function (e) {
15428                                    if (e.switchInProgress) {
15429                                        return;
15430                                    }
15431                                    if (e.active) {
15432                                        this.enterPresentationMode();
15433                                    } else {
15434                                        this.exitPresentationMode();
15435                                    }
15436                                }.bind(this));
15437                            }
15438                            HandTool.prototype = {
15439                                get isActive() {
15440                                    return !!this.handTool.active;
15441                                },
15442                                toggle: function HandTool_toggle() {
15443                                    this.handTool.toggle();
15444                                },
15445                                enterPresentationMode: function HandTool_enterPresentationMode() {
15446                                    if (this.isActive) {
15447                                        this.wasActive = true;
15448                                        this.handTool.deactivate();
15449                                    }
15450                                },
15451                                exitPresentationMode: function HandTool_exitPresentationMode() {
15452                                    if (this.wasActive) {
15453                                        this.wasActive = false;
15454                                        this.handTool.activate();
15455                                    }
15456                                }
15457                            };
15458                            return HandTool;
15459                        }();
15460                        exports.HandTool = HandTool;
15461
15462                        /***/ }),
15463                    /* 14 */
15464                    /***/ (function (module, exports, __webpack_require__) {
15465
15466                        "use strict";
15467
15468                        var uiUtils = __webpack_require__(0);
15469                        var overlayManager = __webpack_require__(4);
15470                        var pdfjsLib = __webpack_require__(1);
15471                        var mozL10n = uiUtils.mozL10n;
15472                        var OverlayManager = overlayManager.OverlayManager;
15473                        var PasswordPrompt = function PasswordPromptClosure() {
15474                            function PasswordPrompt(options) {
15475                                this.overlayName = options.overlayName;
15476                                this.container = options.container;
15477                                this.label = options.label;
15478                                this.input = options.input;
15479                                this.submitButton = options.submitButton;
15480                                this.cancelButton = options.cancelButton;
15481                                this.updateCallback = null;
15482                                this.reason = null;
15483                                this.submitButton.addEventListener('click', this.verify.bind(this));
15484                                this.cancelButton.addEventListener('click', this.close.bind(this));
15485                                this.input.addEventListener('keydown', function (e) {
15486                                    if (e.keyCode === 13) {
15487                                        this.verify();
15488                                    }
15489                                }.bind(this));
15490                                OverlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
15491                            }
15492                            PasswordPrompt.prototype = {
15493                                open: function PasswordPrompt_open() {
15494                                    OverlayManager.open(this.overlayName).then(function () {
15495                                        this.input.type = 'password';
15496                                        this.input.focus();
15497                                        var promptString = mozL10n.get('password_label', null, 'Enter the password to open this PDF file.');
15498                                        if (this.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
15499                                            promptString = mozL10n.get('password_invali
15499d', null, 'Invalid password. Please try again.');
15500                                        }
15501                                        this.label.textContent = promptString;
15502                                    }.bind(this));
15503                                },
15504                                close: function PasswordPrompt_close() {
15505                                    OverlayManager.close(this.overlayName).then(function () {
15506                                        this.input.value = '';
15507                                        this.input.type = '';
15508                                    }.bind(this));
15509                                },
15510                                verify: function PasswordPrompt_verify() {
15511                                    var password = this.input.value;
15512                                    if (password && password.length > 0) {
15513                                        this.close();
15514                                        return this.updateCallback(password);
15515                                    }
15516                                },
15517                                setUpdateCallback: function PasswordPrompt_setUpdateCallback(updateCallback, reason) {
15518                                    this.updateCallback = updateCallback;
15519                                    this.reason = reason;
15520                                }
15521                            };
15522                            return PasswordPrompt;
15523                        }();
15524                        exports.PasswordPrompt = PasswordPrompt;
15525
15526                        /***/ }),
15527                    /* 15 */
15528                    /***/ (function (module, exports, __webpack_require__) {
15529
15530                        "use strict";
15531
15532                        var pdfjsLib = __webpack_require__(1);
15533                        var PDFAttachmentViewer = function PDFAttachmentViewerClosure() {
15534                            function PDFAttachmentViewer(options) {
15535                                this.attachments = null;
15536                                this.container = options.container;
15537                                this.eventBus = options.eventBus;
15538                                this.downloadManager = options.downloadManager;
15539                                this._renderedCapability = pdfjsLib.createPromiseCapability();
15540                                this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
15541                            }
15542                            PDFAttachmentViewer.prototype = {
15543                                reset: function PDFAttachmentViewer_reset(keepRenderedCapability) {
15544                                    this.attachments = null;
15545                                    this.container.textContent = '';
15546                                    if (!keepRenderedCapability) {
15547                                        this._renderedCapability = pdfjsLib.createPromiseCapability();
15548                                    }
15549                                },
15550                                _dispatchEvent: function PDFAttachmentViewer_dispatchEvent(attachmentsCount) {
15551                                    this.eventBus.dispatch('attachmentsloaded', {
15552                                        source: this,
15553                                        attachmentsCount: attachmentsCount
15554                                    });
15555                                    this._renderedCapability.resolve();
15556                                },
15557                                _bindPdfLink: function PDFAttachmentViewer_bindPdfLink(button, content, filename) {
15558                                    var blobUrl;
15559                                    button.onclick = function () {
15560                                        if (!blobUrl) {
15561                                            blobUrl = pdfjsLib.createObjectURL(content, 'application/pdf', pdfjsLib.PDFJS.disableCreateObjectURL);
15562                                        }
15563                                        var viewerUrl;
15564                                        viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
15565                                        window.open(viewerUrl);
15566                                        return false;
vendor: 40,384 bytes, lines 15567-16197
15567                                    };
15568                                },
15569                                _bindLink: function PDFAttachmentViewer_bindLink(button, content, filename) {
15570                                    button.onclick = function downloadFile(e) {
15571                                        this.downloadManager.downloadData(content, filename, '');
15572                                        return false;
15573                                    }.bind(this);
15574                                },
15575                                render: function PDFAttachmentViewer_render(params) {
15576                                    params = params || {};
15577                                    var attachments = params.attachments || null;
15578                                    var attachmentsCount = 0;
15579                                    if (this.attachments) {
15580                                        var keepRenderedCapability = params.keepRenderedCapability === true;
15581                                        this.reset(keepRenderedCapability);
15582                                    }
15583                                    this.attachments = attachments;
15584                                    if (!attachments) {
15585                                        this._dispatchEvent(attachmentsCount);
15586                                        return;
15587                                    }
15588                                    var names = Object.keys(attachments).sort(function (a, b) {
15589                                        return a.toLowerCase().localeCompare(b.toLowerCase());
15590                                    });
15591                                    attachmentsCount = names.length;
15592                                    for (var i = 0; i < attachmentsCount; i++) {
15593                                        var item = attachments[names[i]];
15594                                        var filename = pdfjsLib.getFilenameFromUrl(item.filename);
15595                                        filename = pdfjsLib.removeNullCharacters(filename);
15596                                        var div = document.createElement('div');
15597                                        div.className = 'attachmentsItem';
15598                                        var button = document.createElement('button');
15599                                        button.textContent = filename;
15600                                        if (/\.pdf$/i.test(filename)) {
15601                                            this._bindPdfLink(button, item.content, filename);
15602                                        } else {
15603                                            this._bindLink(button, item.content, filename);
15604                                        }
15605                                        div.appendChild(button);
15606                                        this.container.appendChild(div);
15607                                    }
15608                                    this._dispatchEvent(attachmentsCount);
15609                                },
15610                                _appendAttachment: function PDFAttachmentViewer_appendAttachment(item) {
15611                                    this._renderedCapability.promise.then(function (id, filename, content) {
15612                                        var attachments = this.attachments;
15613                                        if (!attachments) {
15614                                            attachments = Object.create(null);
15615                                        } else {
15616                                            for (var name in attachments) {
15617                                                if (id === name) {
15618                                                    return;
15619                                                }
15620                                            }
15621                                        }
15622                                        attachments[id] = {
15623                                            filename: filename,
15624                                            content: content
15625                                        };
15626                                        this.render({
15627                                            attachments: attachments,
15628                                            keepRenderedCapability: true
15629                                        });
15630                                    }.bind(this, item.id, item.filename, item.content));
15631                                }
15632                            };
15633                            return PDFAttachmentViewer;
15634                        }();
15635                        exports.PDFAttachmentViewer = PDFAttachmentViewer;
15636
15637                        /***/ }),
15638                    /* 16 */
15639                    /***/ (function (module, exports, __webpack_require__) {
15640
15641                        "use strict";
15642
15643                        var uiUtils = __webpack_require__(0);
15644                        var overlayManager = __webpack_require__(4);
15645                        var getPDFFileNameFromURL = uiUtils.getPDFFileNameFromURL;
15646                        var mozL10n = uiUtils.mozL10n;
15647                        var OverlayManager = overlayManager.OverlayManager;
15648                        var PDFDocumentProperties = function PDFDocumentPropertiesClosure() {
15649                            function PDFDocumentProperties(options) {
15650                                this.fields = options.fields;
15651                                this.overlayName = options.overlayName;
15652                                this.container = options.container;
15653                                this.rawFileSize = 0;
15654                                this.url = null;
15655                                this.pdfDocument = null;
15656                                if (options.closeButton) {
15657                                    options.closeButton.addEventListener('click', this.close.bind(this));
15658                                }
15659                                this.dataAvailablePromise = new Promise(function (resolve) {
15660                                    this.resolveDataAvailable = resolve;
15661                                }.bind(this));
15662                                OverlayManager.register(this.overlayName, this.container, this.close.bind(this));
15663                            }
15664                            PDFDocumentProperties.prototype = {
15665                                open: function PDFDocumentProperties_open() {
15666                                    Promise.all([
15667                                        OverlayManager.open(this.overlayName),
15668                                        this.dataAvailablePromise
15669                                    ]).then(function () {
15670                                        this._getProperties();
15671                                    }.bind(this));
15672                                },
15673                                close: function PDFDocumentProperties_close() {
15674                                    OverlayManager.close(this.overlayName);
15675                                },
15676                                setFileSize: function PDFDocumentProperties_setFileSize(fileSize) {
15677                                    if (fileSize > 0) {
15678                                        this.rawFileSize = fileSize;
15679                                    }
15680                                },
15681                                setDocumentAndUrl: function PDFDocumentProperties_setDocumentAndUrl(pdfDocument, url) {
15682                                    this.pdfDocument = pdfDocument;
15683                                    this.url = url;
15684                                    this.resolveDataAvailable();
15685                                },
15686                                _getProperties: function PDFDocumentProperties_getProperties() {
15687                                    if (!OverlayManager.active) {
15688                                        return;
15689                                    }
15690                                    this.pdfDocument.getDownloadInfo().then(function (data) {
15691                                        if (data.length === this.rawFileSize) {
15692                                            return;
15693                                        }
15694                                        this.setFileSize(data.length);
15695                                        this._updateUI(this.fields['fileSize'], this._parseFileSize());
15696                                    }.bind(this));
15697                                    this.pdfDocument.getMetadata().then(function (data) {
15698                                        var content = {
15699                                            'fileName': getPDFFileNameFromURL(this.url),
15700                                            'fileSize': this._parseFileSize(),
15701                                            'title': data.info.Title,
15702                                            'author': data.info.Author,
15703                                            'subject': data.info.Subject,
15704                                            'keywords': data.info.Keywords,
15705                                            'creationDate': this._parseDate(data.info.CreationDate),
15706                                            'modificationDate': this._parseDate(data.info.ModDate),
15707                                            'creator': data.info.Creator,
15708                                            'producer': data.info.Producer,
15709                                            'version': data.info.PDFFormatVersion,
15710                                            'pageCount': this.pdfDocument.numPages
15711                                        };
15712                                        for (var identifier in content) {
15713                                            this._updateUI(this.fields[identifier], content[identifier]);
15714                                        }
15715                                    }.bind(this));
15716                                },
15717                                _updateUI: function PDFDocumentProperties_updateUI(field, content) {
15718                                    if (field && content !== undefined && content !== '') {
15719                                        field.textContent = content;
15720                                    }
15721                                },
15722                                _parseFileSize: function PDFDocumentProperties_parseFileSize() {
15723                                    var fileSize = this.rawFileSize, kb = fileSize / 1024;
15724                                    if (!kb) {
15725                                        return;
15726                                    } else if (kb < 1024) {
15727                                        return mozL10n.get('document_properties_kb', {
15728                                            size_kb: (+kb.toPrecision(3)).toLocaleString(),
15729                                            size_b: fileSize.toLocaleString()
15730                                        }, '{{size_kb}} KB ({{size_b}} bytes)');
15731                                    }
15732                                    return mozL10n.get('document_properties_mb', {
15733                                        size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
15734                                        size_b: fileSize.toLocaleString()
15735                                    }, '{{size_mb}} MB ({{size_b}} bytes)');
15736                                },
15737                                _parseDate: function PDFDocumentProperties_parseDate(inputDate) {
15738                                    var dateToParse = inputDate;
15739                                    if (dateToParse === undefined) {
15740                                        return '';
15741                                    }
15742                                    if (dateToParse.substring(0, 2) === 'D:') {
15743                                        dateToParse = dateToParse.substring(2);
15744                                    }
15745                                    var year = parseInt(dateToParse.substring(0, 4), 10);
15746                                    var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
15747                                    var day = parseInt(dateToParse.substring(6, 8), 10);
15748                                    var hours = parseInt(dateToParse.substring(8, 10), 10);
15749                                    var minutes = parseInt(dateToParse.substring(10, 12), 10);
15750                                    var seconds = parseInt(dateToParse.substring(12, 14), 10);
15751                                    var utRel = dateToParse.substring(14, 15);
15752                                    var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
15753                                    var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
15754                                    if (utRel === '-') {
15755                                        hours += offsetHours;
15756                                        minutes += offsetMinutes;
15757                                    } else if (utRel === '+') {
15758                                        hours -= offsetHours;
15759                                        minutes -= offsetMinutes;
15760                                    }
15761                                    var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
15762                                    var dateString = date.toLocaleDateString();
15763                                    var timeString = date.toLocaleTimeString();
15764                                    return mozL10n.get('document_properties_date_string', {
15765                                        date: dateString,
15766                                        time: timeString
15767                                    }, '{{date}}, {{time}}');
15768                                }
15769                            };
15770                            return PDFDocumentProperties;
15771                        }();
15772                        exports.PDFDocumentProperties = PDFDocumentProperties;
15773
15774                        /***/ }),
15775                    /* 17 */
15776                    /***/ (function (module, exports, __webpack_require__) {
15777
15778                        "use strict";
15779
15780                        var uiUtils = __webpack_require__(0);
15781                        var pdfFindController = __webpack_require__(7);
15782                        var mozL10n = uiUtils.mozL10n;
15783                        var FindStates = pdfFindController.FindStates;
15784                        var PDFFindBar = function PDFFindBarClosure() {
15785                            function PDFFindBar(options) {
15786                                this.opened = false;
15787                                this.bar = options.bar || null;
15788                                this.toggleButton = options.toggleButton || null;
15789                                this.findField = options.findField || null;
15790                                this.highlightAll = options.highlightAllCheckbox || null;
15791                                this.caseSensitive = options.caseSensitiveCheckbox || null;
15792                                this.findMsg = options.findMsg || null;
15793                                this.findResultsCount = options.findResultsCount || null;
15794                                this.findStatusIcon = options.findStatusIcon || null;
15795                                this.findPreviousButton = options.findPreviousButton || null;
15796                                this.findNextButton = options.findNextButton || null;
15797                                this.findController = options.findController || null;
15798                                this.eventBus = options.eventBus;
15799                                if (this.findController === null) {
15800                                    throw new Error('PDFFindBar cannot be used without a ' + 'PDFFindController instance.');
15801                                }
15802                                var self = this;
15803                                this.toggleButton.addEventListener('click', function () {
15804                                    self.toggle();
15805                                });
15806                                this.findField.addEventListener('input', function () {
15807                                    self.dispatchEvent('');
15808                                });
15809                                this.bar.addEventListener('keydown', function (evt) {
15810                                    switch (evt.keyCode) {
15811                                        case 13:
15812                                            if (evt.target === self.findField) {
15813                                                self.dispatchEvent('again', evt.shiftKey);
15814                                            }
15815                                            break;
15816                                        case 27:
15817                                            self.close();
15818                                            break;
15819                                    }
15820                                });
15821                                this.findPreviousButton.addEventListener('click', function () {
15822                                    self.dispatchEvent('again', true);
15823                                });
15824                                this.findNextButton.addEventListener('click', function () {
15825                                    self.dispatchEvent('again', false);
15826                                });
15827                                this.highlightAll.addEventListener('click', function () {
15828                                    self.dispatchEvent('highlightallchange');
15829                                });
15830                                this.caseSensitive.addEventListener('click', function () {
15831                                    self.dispatchEvent('casesensitivitychange');
15832                                });
15833                            }
15834                            PDFFindBar.prototype = {
15835                                reset: function PDFFindBar_reset() {
15836                                    this.updateUIState();
15837                                },
15838                                dispatchEvent: function PDFFindBar_dispatchEvent(type, findPrev) {
15839                                    this.eventBus.dispatch('find', {
15840                                        source: this,
15841                                        type: type,
15842                                        query: this.findField.value,
15843                                        caseSensitive: this.caseSensitive.checked,
15844                                        phraseSearch: true,
15845                                        highlightAll: this.highlightAll.checked,
15846                                        findPrevious: findPrev
15847                                    });
15848                                },
15849                                updateUIState: function PDFFindBar_updateUIState(state, previous, matchCount) {
15850                                    var notFound = false;
15851                                    var findMsg = '';
15852                                    var status = '';
15853                                    switch (state) {
15854                                        case FindStates.FIND_FOUND:
15855                                            break;
15856                                        case FindStates.FIND_PENDING:
15857                                            status = 'pending';
15858                                            break;
15859                                        case FindStates.FIND_NOTFOUND:
15860                                            findMsg = mozL10n.get('find_not_found', null, 'Phrase not found');
15861                                            notFound = true;
15862                                            break;
15863                                        case FindStates.FIND_WRAPPED:
15864                                            if (previous) {
15865                                                findMsg = mozL10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
15866                                            } else {
15867                                                findMsg = mozL10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
15868                                            }
15869                                            break;
15870                                    }
15871                                    if (notFound) {
15872                                        this.findField.classList.add('notFound');
15873                                    } else {
15874                                        this.findField.classList.remove('notFound');
15875                                    }
15876                                    this.findField.setAttribute('data-status', status);
15877                                    this.findMsg.textContent = findMsg;
15878                                    this.updateResultsCount(matchCount);
15879                                },
15880                                updateResultsCount: function (matchCount) {
15881                                    if (!this.findResultsCount) {
15882                                        return;
15883                                    }
15884                                    if (!matchCount) {
15885                                        this.findResultsCount.classList.add('hidden');
15886                                        return;
15887                                    }
15888                                    this.findResultsCount.textContent = matchCount.toLocaleString();
15889                                    this.findResultsCount.classList.remove('hidden');
15890                                },
15891                                open: function PDFFindBar_open() {
15892                                    if (!this.opened) {
15893                                        this.opened = true;
15894                                        this.toggleButton.classList.add('toggled');
15895                                        this.bar.classList.remove('hidden');
15896                                    }
15897                                    this.findField.select();
15898                                    this.findField.focus();
15899                                },
15900                                close: function PDFFindBar_close() {
15901                                    if (!this.opened) {
15902                                        return;
15903                                    }
15904                                    this.opened = false;
15905                                    this.toggleButton.classList.remove('toggled');
15906                                    this.bar.classList.add('hidden');
15907                                    this.findController.active = false;
15908                                },
15909                                toggle: function PDFFindBar_toggle() {
15910                                    if (this.opened) {
15911                                        this.close();
15912                                    } else {
15913                                        this.open();
15914                                    }
15915                                }
15916                            };
15917                            return PDFFindBar;
15918                        }();
15919                        exports.PDFFindBar = PDFFindBar;
15920
15921                        /***/ }),
15922                    /* 18 */
15923                    /***/ (function (module, exports, __webpack_require__) {
15924
15925                        "use strict";
15926
15927                        var domEvents = __webpack_require__(2);
15928                        function PDFHistory(options) {
15929                            this.linkService = options.linkService;
15930                            this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
15931                            this.initialized = false;
15932                            this.initialDestination = null;
15933                            this.initialBookmark = null;
15934                        }
15935                        PDFHistory.prototype = {
15936                            initialize: function pdfHistoryInitialize(fingerprint) {
15937                                this.initialized = true;
15938                                this.reInitialized = false;
15939                                this.allowHashChange = true;
15940                                this.historyUnlocked = true;
15941                                this.isViewerInPresentationMode = false;
15942                                this.previousHash = window.location.hash.substring(1);
15943                                this.currentBookmark = '';
15944                                this.currentPage = 0;
15945                                this.updatePreviousBookmark = false;
15946                                this.previousBookmark = '';
15947                                this.previousPage = 0;
15948                                this.nextHashParam = '';
15949                                this.fingerprint = fingerprint;
15950                                this.currentUid = this.uid = 0;
15951                                this.current = {};
15952                                var state = window.history.state;
15953                                if (this._isStateObjectDefined(state)) {
15954                                    if (state.target.dest) {
15955                                        this.initialDestination = state.target.dest;
15956                                    } else {
15957                                        this.initialBookmark = state.target.hash;
15958                                    }
15959                                    this.currentUid = state.uid;
15960                                    this.uid = state.uid + 1;
15961                                    this.current = state.target;
15962                                } else {
15963                                    if (state && state.fingerprint && this.fingerprint !== state.fingerprint) {
15964                                        this.reInitialized = true;
15965                                    }
15966                                    this._pushOrReplaceState({fingerprint: this.fingerprint}, true);
15967                                }
15968                                var self = this;
15969                                window.addEventListener('popstate', function pdfHistoryPopstate(evt) {
15970                                    if (!self.historyUnlocked) {
15971                                        return;
15972                                    }
15973                                    if (evt.state) {
15974                                        self._goTo(evt.state);
15975                                        return;
15976                                    }
15977                                    if (self.uid === 0) {
15978                                        var previousParams = self.previousHash && self.currentBookmark && self.previousHash !== self.currentBookmark ? {
15979                                            hash: self.currentBookmark,
15980                                            page: self.currentPage
15981                                        } : {page: 1};
15982                                        replacePreviousHistoryState(previousParams, function () {
15983                                            updateHistoryWithCurrentHash();
15984                                        });
15985                                    } else {
15986                                        updateHistoryWithCurrentHash();
15987                                    }
15988                                });
15989                                function updateHistoryWithCurrentHash() {
15990                                    self.previousHash = window.location.hash.slice(1);
15991                                    self._pushToHistory({hash: self.previousHash}, false, true);
15992                                    self._updatePreviousBookmark();
15993                                }
15994                                function replacePreviousHistoryState(params, callback) {
15995                                    self.historyUnlocked = false;
15996                                    self.allowHashChange = false;
15997                                    window.addEventListener('popstate', rewriteHistoryAfterBack);
15998                                    history.back();
15999                                    function rewriteHistoryAfterBack() {
16000                                        window.removeEventListener('popstate', rewriteHistoryAfterBack);
16001                                        window.addEventListener('popstate', rewriteHistoryAfterForward);
16002                                        self._pushToHistory(params, false, true);
16003                                        history.forward();
16004                                    }
16005                                    function rewriteHistoryAfterForward() {
16006                                        window.removeEventListener('popstate', rewriteHistoryAfterForward);
16007                                        self.allowHashChange = true;
16008                                        self.historyUnlocked = true;
16009                                        callback();
16010                                    }
16011                                }
16012                                function pdfHistoryBeforeUnload() {
16013                                    var previousParams = self._getPreviousParams(null, true);
16014                                    if (previousParams) {
16015                                        var replacePrevious = !self.current.dest && self.current.hash !== self.previousHash;
16016                                        self._pushToHistory(previousParams, false, replacePrevious);
16017                                        self._updatePreviousBookmark();
16018                                    }
16019                                    window.removeEventListener('beforeunload', pdfHistoryBeforeUnload);
16020                                }
16021                                window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
16022                                window.addEventListener('pageshow', function pdfHistoryPageShow(evt) {
16023                                    window.addEventListener('beforeunload', pdfHistoryBeforeUnload);
16024                                });
16025                                self.eventBus.on('presentationmodechanged', function (e) {
16026                                    self.isViewerInPresentationMode = e.active;
16027                                });
16028                            },
16029                            clearHistoryState: function pdfHistory_clearHistoryState() {
16030                                this._pushOrReplaceState(null, true);
16031                            },
16032                            _isStateObjectDefined: function pdfHistory_isStateObjectDefined(state) {
16033                                return state && state.uid >= 0 && state.fingerprint && this.fingerprint === state.fingerprint && state.target && state.target.hash ? true : false;
16034                            },
16035                            _pushOrReplaceState: function pdfHistory_pushOrReplaceState(stateObj, replace) {
16036                                if (replace) {
16037                                    window.history.replaceState(stateObj, '', document.URL);
16038                                } else {
16039                                    window.history.pushState(stateObj, '', document.URL);
16040                                }
16041                            },
16042                            get isHashChangeUnlocked() {
16043                                if (!this.initialized) {
16044                                    return true;
16045                                }
16046                                return this.allowHashChange;
16047                            },
16048                            _updatePreviousBookmark: function pdfHistory_updatePreviousBookmark() {
16049                                if (this.updatePreviousBookmark && this.currentBookmark && this.currentPage) {
16050                                    this.previousBookmark = this.currentBookmark;
16051                                    this.previousPage = this.currentPage;
16052                                    this.updatePreviousBookmark = false;
16053                                }
16054                            },
16055                            updateCurrentBookmark: function pdfHistoryUpdateCurrentBookmark(bookmark, pageNum) {
16056                                if (this.initialized) {
16057                                    this.currentBookmark = bookmark.substring(1);
16058                                    this.currentPage = pageNum | 0;
16059                                    this._updatePreviousBookmark();
16060                                }
16061                            },
16062                            updateNextHashParam: function pdfHistoryUpdateNextHashParam(param) {
16063                                if (this.initialized) {
16064                                    this.nextHashParam = param;
16065                                }
16066                            },
16067                            push: function pdfHistoryPush(params, isInitialBookmark) {
16068                                if (!(this.initialized && this.historyUnlocked)) {
16069                                    return;
16070                                }
16071                                if (params.dest && !params.hash) {
16072                                    params.hash = this.current.hash && this.current.dest && this.current.dest === params.dest ? this.current.hash : this.linkService.getDestinationHash(params.dest).split('#')[1];
16073                                }
16074                                if (params.page) {
16075                                    params.page |= 0;
16076                                }
16077                                if (isInitialBookmark) {
16078                                    var target = window.history.state.target;
16079                                    if (!target) {
16080                                        this._pushToHistory(params, false);
16081                                        this.previousHash = window.location.hash.substring(1);
16082                                    }
16083                                    this.updatePreviousBookmark = this.nextHashParam ? false : true;
16084                                    if (target) {
16085                                        this._updatePreviousBookmark();
16086                                    }
16087                                    return;
16088                                }
16089                                if (this.nextHashParam) {
16090                                    if (this.nextHashParam === params.hash) {
16091                                        this.nextHashParam = null;
16092                                        this.updatePreviousBookmark = true;
16093                                        return;
16094                                    }
16095                                    this.nextHashParam = null;
16096                                }
16097                                if (params.hash) {
16098                                    if (this.current.hash) {
16099                                        if (this.current.hash !== params.hash) {
16100                                            this._pushToHistory(params, true);
16101                                        } else {
16102                                            if (!this.current.page && params.page) {
16103                                                this._pushToHistory(params, false, true);
16104                                            }
16105                                            this.updatePreviousBookmark = true;
16106                                        }
16107                                    } else {
16108                                        this._pushToHistory(params, true);
16109                                    }
16110                                } else if (this.current.page && params.page && this.current.page !== params.page) {
16111                                    this._pushToHistory(params, true);
16112                                }
16113                            },
16114                            _getPreviousParams: function pdfHistory_getPreviousParams(onlyCheckPage, beforeUnload) {
16115                                if (!(this.currentBookmark && this.currentPage)) {
16116                                    return null;
16117                                } else if (this.updatePreviousBookmark) {
16118                                    this.updatePreviousBookmark = false;
16119                                }
16120                                if (this.uid > 0 && !(this.previousBookmark && this.previousPage)) {
16121                                    return null;
16122                                }
16123                                if (!this.current.dest && !onlyCheckPage || beforeUnload) {
16124                                    if (this.previousBookmark === this.currentBookmark) {
16125                                        return null;
16126                                    }
16127                                } else if (this.current.page || onlyCheckPage) {
16128                                    if (this.previousPage === this.currentPage) {
16129                                        return null;
16130                                    }
16131                                } else {
16132                                    return null;
16133                                }
16134                                var params = {
16135                                    hash: this.currentBookmark,
16136                                    page: this.currentPage
16137                                };
16138                                if (this.isViewerInPresentationMode) {
16139                                    params.hash = null;
16140                                }
16141                                return params;
16142                            },
16143                            _stateObj: function pdfHistory_stateObj(params) {
16144                                return {
16145                                    fingerprint: this.fingerprint,
16146                                    uid: this.uid,
16147                                    target: params
16148                                };
16149                            },
16150                            _pushToHistory: function pdfHistory_pushToHistory(params, addPrevious, overwrite) {
16151                                if (!this.initialized) {
16152                                    return;
16153                                }
16154                                if (!params.hash && params.page) {
16155                                    params.hash = 'page=' + params.page;
16156                                }
16157                                if (addPrevious && !overwrite) {
16158                                    var previousParams = this._getPreviousParams();
16159                                    if (previousParams) {
16160                                        var replacePrevious = !this.current.dest && this.current.hash !== this.previousHash;
16161                                        this._pushToHistory(previousParams, false, replacePrevious);
16162                                    }
16163                                }
16164                                this._pushOrReplaceState(this._stateObj(params), overwrite || this.uid === 0);
16165                                this.currentUid = this.uid++;
16166                                this.current = params;
16167                                this.updatePreviousBookmark = true;
16168                            },
16169                            _goTo: function pdfHistory_goTo(state) {
16170                                if (!(this.initialized && this.historyUnlocked && this._isStateObjectDefined(state))) {
16171                                    return;
16172                                }
16173                                if (!this.reInitialized && state.uid < this.currentUid) {
16174                                    var previousParams = this._getPreviousParams(true);
16175                                    if (previousParams) {
16176                                        this._pushToHistory(this.current, false);
16177                                        this._pushToHistory(previousParams, false);
16178                                        this.currentUid = state.uid;
16179                                        window.history.back();
16180                                        return;
16181                                    }
16182                                }
16183                                this.historyUnlocked = false;
16184                                if (state.target.dest) {
16185                                    this.linkService.navigateTo(state.target.dest);
16186                                } else {
16187                                    this.linkService.setHash(state.target.hash);
16188                                }
16189                                this.currentUid = state.uid;
16190                                if (state.uid > this.uid) {
16191                                    this.uid = state.uid;
16192                                }
16193                                this.current = state.target;
16194                                this.updatePreviousBookmark = true;
16195                                var currentHash = window.location.hash.substring(1);
16196                                if (this.previousHash !== currentHash) {
16197                                    this.allowHashChange = false;
16198                                }
16199                                this.previousHash = currentHash;
16200                                this.historyUnlocked = true;
16201                            },
16202                            back: function pdfHistoryBack() {
16203                                this.go(-1);
16204                            },
16205                            forward: function pdfHistoryForward() {
16206                                this.go(1);
16207                            },
16208                            go: function pdfHistoryGo(direction) {
16209                                if (this.initialized && this.historyUnlocked) {
16210                                    var state = window.history.state;
16211                                    if (direction === -1 && state && state.uid > 0) {
16212                                        window.history.back();
16213                                    } else if (direction === 1 && state && state.uid < this.uid - 1) {
16214                                        window.history.forward();
16215                                    }
16216                                }
16217                            }
16218                        };
16219                        exports.PDFHistory = PDFHistory;
16220
16221                        /***/ }),
16222                    /* 19 */
16223                    /***/ (function (module, exports, __webpack_require__) {
16224
16225                        "use strict";
16226
16227                        var pdfjsLib = __webpack_require__(1);
16228                        var PDFJS = pdfjsLib.PDFJS;
16229                        var DEFAULT_TITLE = '\u2013';
16230                        var PDFOutlineViewer = function PDFOutlineViewerClosure() {
16231                            function PDFOutlineViewer(options) {
16232                                this.outline = null;
16233                                this.lastToggleIsShow = true;
16234                                this.container = options.container;
16235                                this.linkService = options.linkService;
16236                                this.eventBus = options.eventBus;
16237                            }
16238                            PDFOutlineViewer.prototype = {
16239                                reset: function PDFOutlineViewer_reset() {
16240                                    this.outline = null;
16241                                    this.lastToggleIsShow = true;
16242                                    this.container.textContent = '';
16243                                    this.container.classList.remove('outlineWithDeepNesting');
16244                                },
16245                                _dispatchEvent: function PDFOutlineViewer_dispatchEvent(outlineCount) {
16246                                    this.eventBus.dispatch('outlineloaded', {
16247                                        source: this,
16248                                        outlineCount: outlineCount
16249                                    });
16250                                },
16251                                _bindLink: function PDFOutlineViewer_bindLink(element, item) {
16252                                    if (item.url) {
16253                                        pdfjsLib.addLinkAttributes(element, {
16254                                            url: item.url,
16255                                            target: item.newWindow ? PDFJS.LinkTarget.BLANK : undefined
16256                                        });
16257                                        return;
16258                                    }
16259                                    var self = this, destination = item.dest;
16260                                    element.href = self.linkService.getDestinationHash(destination);
16261                                    element.onclick = function () {
16262                                        if (destination) {
16263                                            self.linkService.navigateTo(destination);
16264                                        }
16265                                        return false;
16266                                    };
16267                                },
16268                                _setStyles: function PDFOutlineViewer_setStyles(element, item) {
16269                                    var styleStr = '';
16270                                    if (item.bold) {
16271                                        styleStr += 'font-weight: bold;';
16272                                    }
16273                                    if (item.italic) {
16274                                        styleStr += 'font-style: italic;';
16275                                    }
16276                                    if (styleStr) {
16277                                        element.setAttribute('style', styleStr);
16278                                    }
16279                                },
16280                                _addToggleButton: function PDFOutlineViewer_addToggleButton(div) {
16281                                    var toggler = document.createElement('div');
16282                                    toggler.className = 'outlineItemToggler';
16283                                    toggler.onclick = function (event) {
16284                                        event.stopPropagation();
16285                                        toggler.classList.toggle('outlineItemsHidden');
16286                                        if (event.shiftKey) {
16287                                            var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
16288                                            this._toggleOutlineItem(div, shouldShowAll);
16289                                        }
16290                                    }.bind(this);
16291                                    div.insertBefore(toggler, div.firstChild);
16292                                },
16293                                _toggleOutlineItem: function PDFOutlineViewer_toggleOutlineItem(root, show) {
16294                                    this.lastToggleIsShow = show;
16295                                    var togglers = root.querySelectorAll('.outlineItemToggler');
16296                                    for (var i = 0, ii = togglers.length; i < ii; ++i) {
16297                                        togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden');
16298                                    }
16299                                },
16300                                toggleOutlineTree: function PDFOutlineViewer_toggleOutlineTree() {
16301                                    if (!this.outline) {
16302                                        return;
16303                                    }
16304                                    this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
16305                                },
16306                                render: function PDFOutlineViewer_render(params) {
16307                                    var outline = params && params.outline || null;
16308                                    var outlineCount = 0;
16309                                    if (this.outline) {
16310                                        this.reset();
16311                                    }
16312                                    this.outline = outline;
16313                                    if (!outline) {
16314                                        this._dispatchEvent(outlineCount);
16315                                        return;
16316                                    }
16317                                    var fragment = document.createDocumentFragment();
16318                                    var queue = [{
16319                                            parent: fragment,
16320                                            items: this.outline
16321                                        }];
16322                                    var hasAnyNesting = false;
16323                                    while (queue.length > 0) {
16324                                        var levelData = queue.shift();
16325                                        for (var i = 0, len = levelData.items.length; i < len; i++) {
16326                                            var item = levelData.items[i];
16327                                            var div = document.createElement('div');
16328                                            div.className = 'outlineItem';
16329                                            var element = document.createElement('a');
16330                                            this._bindLink(element, item);
16331                                            this._setStyles(element, item);
16332                                            element.textContent = pdfjsLib.removeNullCharacters(item.title) || DEFAULT_TITLE;
16333                                            div.appendChild(element);
16334                                            if (item.items.length > 0) {
16335                                                hasAnyNesting = true;
16336                                                this._addToggleButton(div);
16337                                                var itemsDiv = document.createElement('div');
16338                                                itemsDiv.className = 'outlineItems';
16339                                                div.appendChild(itemsDiv);
16340                                                queue.push({
16341                                                    parent: itemsDiv,
16342                                                    items: item.items
16343                                                });
16344                                            }
16345                                            levelData.parent.appendChild(div);
16346                                            outlineCount++;
16347                                        }
16348                                    }
16349                                    if (hasAnyNesting) {
16350                                        this.container.classList.add('outlineWithDeepNesting');
16351                                    }
16352                                    this.container.appendChild(fragment);
16353                                    this._dispatchEvent(outlineCount);
16354                                }
16355                            };
16356                            return PDFOutlineViewer;
16357                        }();
16358                        exports.PDFOutlineViewer = PDFOutlineViewer;
16359
16360                        /***/ }),
16361                    /* 20 */
16362                    /***/ (function (module, exports, __webpack_require__) {
16363
16364                        "use strict";
16365
16366                        var uiUtils = __webpack_require__(0);
16367                        var pdfRenderingQueue = __webpack_require__(3);
16368                        var domEvents = __webpack_require__(2);
16369                        var pdfjsLib = __webpack_require__(1);
16370                        var CSS_UNITS = uiUtils.CSS_UNITS;
16371                        var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
16372                        var getOutputScale = uiUtils.getOutputScale;
16373                        var approximateFraction = uiUtils.approximateFraction;
16374                        var roundToDivide = uiUtils.roundToDivide;
16375                        var RendererType = uiUtils.RendererType;
16376                        var RenderingStates = pdfRenderingQueue.RenderingStates;
16377                        var TEXT_LAYER_RENDER_DELAY = 200;
16378                        var PDFPageView = function PDFPageViewClosure() {
16379                            function PDFPageView(options) {
16380                                var container = options.container;
16381                                var id = options.id;
16382                                var scale = options.scale;
16383                                var defaultViewport = options.defaultViewport;
16384                                var renderingQueue = options.renderingQueue;
16385                                var textLayerFactory = options.textLayerFactory;
16386                                var annotationLayerFactory = options.annotationLayerFactory;
16387                                var enhanceTextSelection = options.enhanceTextSelection || false;
16388                                var renderInteractiveForms = options.renderInteractiveForms || false;
16389                                this.id = id;
16390                                this.renderingId = 'page' + id;
16391                                this.pageLabel = null;
16392                                this.rotation = 0;
16393                                this.scale = scale || DEFAULT_SCALE;
16394                                this.viewport = defaultViewport;
16395                                this.pdfPageRotate = defaultViewport.rotation;
16396                                this.hasRestrictedScaling = false;
vendor: 4,334 bytes, lines 16397-16459
16397                                this.enhanceTextSelection = enhanceTextSelection;
16398                                this.renderInteractiveForms = renderInteractiveForms;
16399                                this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
16400                                this.renderingQueue = renderingQueue;
16401                                this.textLayerFactory = textLayerFactory;
16402                                this.annotationLayerFactory = annotationLayerFactory;
16403                                this.renderer = options.renderer || RendererType.CANVAS;
16404                                this.paintTask = null;
16405                                this.paintedViewportMap = new WeakMap();
16406                                this.renderingState = RenderingStates.INITIAL;
16407                                this.resume = null;
16408                                this.error = null;
16409                                this.onBeforeDraw = null;
16410                                this.onAfterDraw = null;
16411                                this.textLayer = null;
16412                                this.zoomLayer = null;
16413                                this.annotationLayer = null;
16414                                var div = document.createElement('div');
16415                                div.className = 'page';
16416                                div.style.width = Math.floor(this.viewport.width) + 'px';
16417                                div.style.height = Math.floor(this.viewport.height) + 'px';
16418                                div.setAttribute('data-page-number', this.id);
16419                                this.div = div;
16420                                container.appendChild(div);
16421                            }
16422                            PDFPageView.prototype = {
16423                                setPdfPage: function PDFPageView_setPdfPage(pdfPage) {
16424                                    this.pdfPage = pdfPage;
16425                                    this.pdfPageRotate = pdfPage.rotate;
16426                                    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
16427                                    this.viewport = pdfPage.getViewport(this.scale * CSS_UNITS, totalRotation);
16428                                    this.stats = pdfPage.stats;
16429                                    this.reset();
16430                                },
16431                                destroy: function PDFPageView_destroy() {
16432                                    this.zoomLayer = null;
16433                                    this.reset();
16434                                    if (this.pdfPage) {
16435                                        this.pdfPage.cleanup();
16436                                    }
16437                                },
16438                                reset: function PDFPageView_reset(keepZoomLayer, keepAnnotations) {
16439                                    this.cancelRendering();
16440                                    var div = this.div;
16441                                    div.style.width = Math.floor(this.viewport.width) + 'px';
16442                                    div.style.height = Math.floor(this.viewport.height) + 'px';
16443                                    var childNodes = div.childNodes;
16444                                    var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
16445                                    var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
16446                                    for (var i = childNodes.length - 1; i >= 0; i--) {
16447                                        var node = childNodes[i];
16448                                        if (currentZoomLayerNode === node || currentAnnotationNode === node) {
16449                                            continue;
16450                                        }
16451                                        div.removeChild(node);
16452                                    }
16453                                    div.removeAttribute('data-loaded');
16454                                    if (currentAnnotationNode) {
16455                                        this.annotationLayer.hide();
16456                                    } else {
16457                                        this.annotationLayer = null;
16458                                    }
16459                                    if (this.canvas && !currentZoomLayerNo
16459de) {
16460                                        this.paintedViewportMap.delete(this.canvas);
16461                                        this.canvas.width = 0;
16462                                        this.canvas.height = 0;
16463                                        delete this.canvas;
16464                                    }
16465                                    if (this.svg) {
16466                                        this.paintedViewportMap.delete(this.svg);
16467                                        delete this.svg;
16468                                    }
16469                                    this.loadingIconDiv = document.createElement('div');
16470                                    this.loadingIconDiv.className = 'loadingIcon';
16471                                    div.appendChild(this.loadingIconDiv);
16472                                },
16473                                update: function PDFPageView_update(scale, rotation) {
16474                                    this.scale = scale || this.scale;
16475                                    if (typeof rotation !== 'undefined') {
16476                                        this.rotation = rotation;
16477                                    }
16478                                    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
16479                                    this.viewport = this.viewport.clone({
16480                                        scale: this.scale * CSS_UNITS,
16481                                        rotation: totalRotation
16482                                    });
16483                                    if (this.svg) {
16484                                        this.cssTransform(this.svg, true);
16485                                        this.eventBus.dispatch('pagerendered', {
16486                                            source: this,
16487                                            pageNumber: this.id,
16488                                            cssTransform: true
16489                                        });
16490                                        return;
16491                                    }
16492                                    var isScalingRestricted = false;
16493                                    if (this.canvas && pdfjsLib.PDFJS.maxCanvasPixels > 0) {
16494                                        var outputScale = this.outputScale;
16495                                        if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > pdfjsLib.PDFJS.maxCanvasPixels) {
16496                                            isScalingRestricted = true;
16497                                        }
16498                                    }
16499                                    if (this.canvas) {
16500                                        if (pdfjsLib.PDFJS.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
16501                                            this.cssTransform(this.canvas, true);
16502                                            this.eventBus.dispatch('pagerendered', {
16503                                                source: this,
16504                                                pageNumber: this.id,
16505                                                cssTransform: true
16506                                            });
16507                                            return;
16508                                        }
16509                                        if (!this.zoomLayer) {
16510                                            this.zoomLayer = this.canvas.parentNode;
16511                                            this.zoomLayer.style.position = 'absolute';
16512                                        }
16513                                    }
16514                                    if (this.zoomLayer) {
16515                                        this.cssTransform(this.zoomLayer.firstChild);
16516                                    }
16517                                    this.reset(true, true);
16518                                },
16519                                cancelRendering: function PDFPageView_cancelRendering() {
16520                                    if (this.paintTask) {
16521                                        this.paintTask.cancel();
16522                                        this.paintTask = null;
16523                                    }
16524                                    this.renderingState = RenderingStates.INITIAL;
16525                                    this.resume = null;
16526                                    if (this.textLayer) {
16527                                        this.textLayer.cancel();
16528                                        this.textLayer = null;
16529                                    }
16530                                },
16531                                updatePosition: function PDFPageView_updatePosition() {
16532                                    if (this.textLayer) {
16533                                        this.textLayer.render(TEXT_LAYER_RENDER_DELAY);
16534                                    }
16535                                },
16536                                cssTransform: function PDFPageView_transform(target, redrawAnnotations) {
16537                                    var CustomStyle = pdfjsLib.CustomStyle;
16538                                    var width = this.viewport.width;
16539                                    var height = this.viewport.height;
16540                                    var div = this.div;
16541                                    target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
16542                                    target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
16543                                    var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
16544                                    var absRotation = Math.abs(relativeRotation);
16545                                    var scaleX = 1, scaleY = 1;
16546                                    if (absRotation === 90 || absRotation === 270) {
16547                                        scaleX = height / width;
16548                                        scaleY = width / height;
16549                                    }
16550                                    var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
16551                                    CustomStyle.setProp('transform', target, cssTransform);
16552                                    if (this.textLayer) {
16553                                        var textLayerViewport = this.textLayer.viewport;
16554                                        var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
16555                                        var textAbsRotation = Math.abs(textRelativeRotation);
16556                                        var scale = width / textLayerViewport.width;
16557                                        if (textAbsRotation === 90 || textAbsRotation === 270) {
16558                                            scale = width / textLayerViewport.height;
16559                                        }
16560                                        var textLayerDiv = this.textLayer.textLayerDiv;
16561                                        var transX, transY;
16562                                        switch (textAbsRotation) {
16563                                            case 0:
16564                                                transX = transY = 0;
16565                                                break;
16566                                            case 90:
16567                                                transX = 0;
16568                                                transY = '-' + textLayerDiv.style.height;
16569                                                break;
16570                                            case 180:
16571                                                transX = '-' + textLayerDiv.style.width;
16572                                                transY = '-' + textLayerDiv.style.height;
16573                                                break;
16574                                            case 270:
16575                                                transX = '-' + textLayerDiv.style.width;
16576                                                transY = 0;
16577                                                break;
16578                                            default:
16579                                                console.error('Bad rotation value.');
16580                                                break;
16581                                        }
16582                                        CustomStyle.setProp('transform', textLayerDiv, 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')');
16583                                        CustomStyle.setProp('transformOrigin', textLayerDiv, '0% 0%');
16584                                    }
16585                                    if (redrawAnnotations && this.annotationLayer) {
16586                                        this.annotationLayer.render(this.viewport, 'display');
16587                                    }
16588                                },
16589                                get width() {
16590                                    return this.viewport.width;
16591                                },
16592                                get height() {
16593                                    return this.viewport.height;
16594                                },
16595                                getPagePoint: function PDFPageView_getPagePoint(x, y) {
16596                                    return this.viewport.convertToPdfPoint(x, y);
16597                                },
16598                                draw: function PDFPageView_draw() {
16599                                    if (this.renderingState !== RenderingStates.INITIAL) {
16600                                        console.error('Must be in new state before drawing');
16601                                        this.reset();
16602                                    }
16603                                    this.renderingState = RenderingStates.RUNNING;
16604                                    var self = this;
16605                                    var pdfPage = this.pdfPage;
16606                                    var div = this.div;
16607                                    var canvasWrapper = document.createElement('div');
16608                                    canvasWrapper.style.width = div.style.width;
16609                                    canvasWrapper.style.height = div.style.height;
16610                                    canvasWrapper.classList.add('canvasWrapper');
16611                                    if (this.annotationLayer && this.annotationLayer.div) {
16612                                        div.insertBefore(canvasWrapper, this.annotationLayer.div);
16613                                    } else {
16614                                        div.appendChild(canvasWrapper);
16615                                    }
16616                                    var textLayerDiv = null;
16617                                    var textLayer = null;
16618                                    if (this.textLayerFactory) {
16619                                        textLayerDiv = document.createElement('div');
16620                                        textLayerDiv.className = 'textLayer';
16621                                        textLayerDiv.style.width = canvasWrapper.style.width;
16622                                        textLayerDiv.style.height = canvasWrapper.style.height;
16623                                        if (this.annotationLayer && this.annotationLayer.div) {
16624                                            div.insertBefore(textLayerDiv, this.annotationLayer.div);
16625                                        } else {
16626                                            div.appendChild(textLayerDiv);
16627                                        }
16628                                        textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.enhanceTextSelection);
16629                                    }
16630                                    this.textLayer = textLayer;
16631                                    var renderContinueCallback = null;
16632                                    if (this.renderingQueue) {
16633                                        renderContinueCallback = function renderContinueCallback(cont) {
16634                                            if (!self.renderingQueue.isHighestPriority(self)) {
16635                                                self.renderingState = RenderingStates.PAUSED;
16636                                                self.resume = function resumeCallback() {
16637                                                    self.renderingState = RenderingStates.RUNNING;
16638                                                    cont();
16639                                                };
16640                                                return;
16641                                            }
16642                                            cont();
16643                                        };
16644                                    }
16645                                    var finishPaintTask = function finishPaintTask(error) {
16646                                        if (paintTask === self.paintTask) {
16647                                            self.paintTask = null;
16648                                        }
16649                                        if (error === 'cancelled') {
16650                                            self.error = null;
16651                                            return Promise.resolve(undefined);
16652                                        }
16653                                        self.renderingState = RenderingStates.FINISHED;
16654                                        if (self.loadingIconDiv) {
16655                                            div.removeChild(self.loadingIconDiv);
16656                                            delete self.loadingIconDiv;
16657                                        }
16658                                        if (self.zoomLayer) {
16659                                            var zoomLayerCanvas = self.zoomLayer.firstChild;
16660                                            self.paintedViewportMap.delete(zoomLayerCanvas);
16661                                            zoomLayerCanvas.width = 0;
16662                                            zoomLayerCanvas.height = 0;
16663                                            if (div.contains(self.zoomLayer)) {
16664                                                div.removeChild(self.zoomLayer);
16665                                            }
16666                                            self.zoomLayer = null;
16667                                        }
16668                                        self.error = error;
16669                                        self.stats = pdfPage.stats;
16670                                        if (self.onAfterDraw) {
16671                                            self.onAfterDraw();
16672                                        }
16673                                        self.eventBus.dispatch('pagerendered', {
16674                                            source: self,
16675                                            pageNumber: self.id,
16676                                            cssTransform: false
16677                                        });
16678                                        if (error) {
16679                                            return Promise.reject(error);
16680                                        }
16681                                        return Promise.resolve(undefined);
16682                                    };
16683                                    var paintTask = this.renderer === RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
16684                                    paintTask.onRenderContinue = renderContinueCallback;
16685                                    this.paintTask = paintTask;
16686                                    var resultPromise = paintTask.promise.then(function () {
16687                                        return finishPaintTask(null).then(function () {
16688                                            if (textLayer) {
16689                                                pdfPage.getTextContent({normalizeWhitespace: true}).then(function textContentResolved(textContent) {
16690                                                    textLayer.setTextContent(textContent);
16691                                                    textLayer.render(TEXT_LAYER_RENDER_DELAY);
16692                                                });
16693                                            }
16694                                        });
16695                                    }, function (reason) {
16696                                        return finishPaintTask(reason);
16697                                    });
16698                                    if (this.annotationLayerFactory) {
16699                                        if (!this.annotationLayer) {
16700                                            this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.renderInteractiveForms);
16701                                        }
16702                                        this.annotationLayer.render(this.viewport, 'display');
16703                                    }
16704                                    div.setAttribute('data-loaded', true);
16705                                    if (this.onBeforeDraw) {
16706                                        this.onBeforeDraw();
16707                                    }
16708                                    return resultPromise;
16709                                },
16710                                paintOnCanvas: function (canvasWrapper) {
16711                                    var resolveRenderPromise, rejectRenderPromise;
16712                                    var promise = new Promise(function (resolve, reject) {
16713                                        resolveRenderPromise = resolve;
16714                                        rejectRenderPromise = reject;
16715                                    });
16716                                    var result = {
16717                                        promise: promise,
16718                                        onRenderContinue: function (cont) {
16719                                            cont();
16720                                        },
16721                                        cancel: function () {
16722                                            renderTask.cancel();
16723                                        }
16724                                    };
16725                                    var viewport = this.viewport;
16726                                    var canvas = document.createElement('canvas');
16727                                    canvas.id = 'page' + this.id;
16728                                    canvas.setAttribute('hidden', 'hidden');
16729                                    var isCanvasHidden = true;
16730                                    var showCanvas = function () {
16731                                        if (isCanvasHidden) {
16732                                            canvas.removeAttribute('hidden');
16733                                            isCanvasHidden = false;
16734                                        }
16735                                    };
16736                                    canvasWrapper.appendChild(canvas);
16737                                    this.canvas = canvas;
16738                                    canvas.mozOpaque = true;
16739                                    var ctx = canvas.getContext('2d', {alpha: false});
16740                                    var outputScale = getOutputScale(ctx);
16741                                    this.outputScale = outputScale;
16742                                    if (pdfjsLib.PDFJS.useOnlyCssZoom) {
16743                                        var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
16744                                        outputScale.sx *= actualSizeViewport.width / viewport.width;
16745                                        outputScale.sy *= actualSizeViewport.height / viewport.height;
16746                                        outputScale.scaled = true;
16747                                    }
16748                                    if (pdfjsLib.PDFJS.maxCanvasPixels > 0) {
16749                                        var pixelsInViewport = viewport.width * viewport.height;
16750                                        var maxScale = Math.sqrt(pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
16751                                        if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
16752                                            outputScale.sx = maxScale;
16753                                            outputScale.sy = maxScale;
16754                                            outputScale.scaled = true;
16755                                            this.hasRestrictedScaling = true;
16756                                        } else {
16757                                            this.hasRestrictedScaling = false;
16758                                        }
16759                                    }
16760                                    var sfx = approximateFraction(outputScale.sx);
16761                                    var sfy = approximateFraction(outputScale.sy);
16762                                    canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);
16763                                    canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);
16764                                    canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';
16765                                    canvas.style.height = roundToDivide(viewport.height, sfy[1]) + 'px';
16766                                    this.paintedViewportMap.set(canvas, viewport);
16767                                    var transform = !outputScale.scaled ? null : [
16768                                        outputScale.sx,
16769                                        0,
16770                                        0,
16771                                        outputScale.sy,
16772                                        0,
16773                                        0
16774                                    ];
16775                                    var renderContext = {
16776                                        canvasContext: ctx,
16777                                        transform: transform,
16778                                        viewport: this.viewport,
16779                                        renderInteractiveForms: this.renderInteractiveForms
16780                                    };
16781                                    var renderTask = this.pdfPage.render(renderContext);
16782                                    renderTask.onContinue = function (cont) {
16783                                        showCanvas();
16784                                        if (result.onRenderContinue) {
16785                                            result.onRenderContinue(cont);
16786                                        } else {
16787                                            cont();
16788                                        }
16789                                    };
16790                                    renderTask.promise.then(function pdfPageRenderCallback() {
16791                                        showCanvas();
16792                                        resolveRenderPromise(undefined);
16793                                    }, function pdfPageRenderError(error) {
16794                                        showCanvas();
16795                                        rejectRenderPromise(error);
16796                                    });
16797                                    return result;
16798                                },
16799                                paintOnSvg: function PDFPageView_paintOnSvg(wrapper) {
16800                                    var cancelled = false;
16801                                    var ensureNotCancelled = function () {
16802                                        if (cancelled) {
16803                                            throw 'cancelled';
16804                                        }
16805                                    };
16806                                    var self = this;
16807                                    var pdfPage = this.pdfPage;
16808                                    var SVGGraphics = pdfjsLib.SVGGraphics;
16809                                    var actualSizeViewport = this.viewport.clone({scale: CSS_UNITS});
16810                                    var promise = pdfPage.getOperatorList().then(function (opList) {
16811                                        ensureNotCancelled();
16812                                        var svgGfx = new SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
16813                                        return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
16814                                            ensureNotCancelled();
16815                                            self.svg = svg;
16816                                            self.paintedViewportMap.set(svg, actualSizeViewport);
16817                                            svg.style.width = wrapper.style.width;
16818                                            svg.style.height = wrapper.style.height;
16819                                            self.renderingState = RenderingStates.FINISHED;
16820                                            wrapper.appendChild(svg);
16821                                        });
16822                                    });
16823                                    return {
16824                                        promise: promise,
16825                                        onRenderContinue: function (cont) {
16826                                            cont();
16827                                        },
16828                                        cancel: function () {
16829                                            cancelled = true;
16830                                        }
16831                                    };
16832                                },
16833                                setPageLabel: function PDFView_setPageLabel(label) {
16834                                    this.pageLabel = typeof label === 'string' ? label : null;
16835                                    if (this.pageLabel !== null) {
16836                                        this.div.setAttribute('data-page-label', this.pageLabel);
16837                                    } else {
16838                                        this.div.removeAttribute('data-page-label');
16839                                    }
16840                                }
16841                            };
16842                            return PDFPageView;
16843                        }();
16844                        exports.PDFPageView = PDFPageView;
16845
16846                        /***/ }),
16847                    /* 21 */
16848                    /***/ (function (module, exports, __webpack_require__) {
16849
16850                        "use strict";
16851
16852                        var uiUtils = __webpack_require__(0);
16853                        var normalizeWheelEventDelta = uiUtils.normalizeWheelEventDelta;
16854                        var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
16855                        var DELAY_BEFORE_HIDING_CONTROLS = 3000;
16856                        var ACTIVE_SELECTOR = 'pdfPresentationMode';
16857                        var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
16858                        var PDFPresentationMode = function PDFPresentationModeClosure() {
16859                            function PDFPresentationMode(options) {
16860                                this.container = options.container;
16861                                this.viewer = options.viewer || options.container.firstElementChild;
16862                                this.pdfViewer = options.pdfViewer;
16863                                this.eventBus = options.eventBus;
16864                                var contextMenuItems = options.contextMenuItems || null;
16865                                this.active = false;
16866                                this.args = null;
16867                                this.contextMenuOpen = false;
16868                                this.mouseScrollTimeStamp = 0;
16869                                this.mouseScrollDelta = 0;
16870                                this.touchSwipeState = null;
16871                                if (contextMenuItems) {
16872                                    contextMenuItems.contextFirstPage.addEventListener('click', function PDFPresentationMode_contextFirstPageClick(e) {
16873                                        this.contextMenuOpen = false;
16874                                        this.eventBus.dispatch('firstpage');
16875                                    }.bind(this));
16876                                    contextMenuItems.contextLastPage.addEventListener('click', function PDFPresentationMode_contextLastPageClick(e) {
16877                                        this.contextMenuOpen = false;
16878                                        this.eventBus.dispatch('lastpage');
16879                                    }.bind(this));
16880                                    contextMenuItems.contextPageRotateCw.addEventListener('click', function PDFPresentationMode_contextPageRotateCwClick(e) {
16881                                        this.contextMenuOpen = false;
16882                                        this.eventBus.dispatch('rotatecw');
16883                                    }.bind(this));
16884                                    contextMenuItems.contextPageRotateCcw.addEventListener('click', function PDFPresentationMode_contextPageRotateCcwClick(e) {
16885                                        this.contextMenuOpen = false;
16886                                        this.eventBus.dispatch('rotateccw');
16887                                    }.bind(this));
16888                                }
16889                            }
16890                            PDFPresentationMode.prototype = {
16891                                request: function PDFPresentationMode_request() {
16892                                    if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
16893                                        return false;
16894                                    }
16895                                    this._addFullscreenChangeListeners();
16896                                    this._setSwitchInProgress();
16897                                    this._notifyStateChange();
16898                                    if (this.container.requestFullscreen) {
16899                                        this.container.requestFullscreen();
16900                                    } else if (this.container.mozRequestFullScreen) {
16901                                        this.container.mozRequestFullScreen();
16902                                    } else if (this.container.webkitRequestFullscreen) {
16903                                        this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
16904                                    } else if (this.container.msRequestFullscreen) {
16905                                        this.container.msRequestFullscreen();
16906                                    } else {
16907                                        return false;
16908                                    }
16909                                    this.args = {
16910                                        page: this.pdfViewer.currentPageNumber,
16911                                        previousScale: this.pdfViewer.currentScaleValue
16912                                    };
16913                                    return true;
16914                                },
16915                                _mouseWheel: function PDFPresentationMode_mouseWheel(evt) {
16916                                    if (!this.active) {
16917                                        return;
16918                                    }
16919                                    evt.preventDefault();
16920                                    var delta = normalizeWheelEventDelta(evt);
16921                                    var MOUSE_SCROLL_COOLDOWN_TIME = 50;
16922                                    var PAGE_SWITCH_THRESHOLD = 0.1;
16923                                    var currentTime = new Date().getTime();
16924                                    var storedTime = this.mouseScrollTimeStamp;
16925                                    if (currentTime >
16925 storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
16926                                        return;
16927                                    }
16928                                    if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
16929                                        this._resetMouseScrollState();
16930                                    }
16931                                    this.mouseScrollDelta += delta;
16932                                    if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
16933                                        var totalDelta = this.mouseScrollDelta;
16934                                        this._resetMouseScrollState();
16935                                        var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
16936                                        if (success) {
16937                                            this.mouseScrollTimeStamp = currentTime;
16938                                        }
16939                                    }
16940                                },
16941                                get isFullscreen() {
16942                                    return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
16943                                },
16944                                _goToPreviousPage: function PDFPresentationMode_goToPreviousPage() {
16945                                    var page = this.pdfViewer.currentPageNumber;
16946                                    if (page <= 1) {
16947                                        return false;
16948                                    }
16949                                    this.pdfViewer.currentPageNumber = page - 1;
16950                                    return true;
16951                                },
16952                                _goToNextPage: function PDFPresentationMode_goToNextPage() {
16953                                    var page = this.pdfViewer.currentPageNumber;
16954                                    if (page >= this.pdfViewer.pagesCount) {
16955                                        return false;
16956                                    }
16957                                    this.pdfViewer.currentPageNumber = page + 1;
16958                                    return true;
16959                                },
16960                                _notifyStateChange: function PDFPresentationMode_notifyStateChange() {
16961                                    this.eventBus.dispatch('presentationmodechanged', {
16962                                        source: this,
16963                                        active: this.active,
16964                                        switchInProgress: !!this.switchInProgress
16965                                    });
16966                                },
16967                                _setSwitchInProgress: function PDFPresentationMode_setSwitchInProgress() {
16968                                    if (this.switchInProgress) {
16969                                        clearTimeout(this.switchInProgress);
16970                                    }
16971                                    this.switchInProgress = setTimeout(function switchInProgressTimeout() {
16972                                        this._removeFullscreenChangeListeners();
16973                                        delete this.switchInProgress;
16974                                        this._notifyStateChange();
16975                                    }.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
16976                                },
16977                                _resetSwitchInProgress: function PDFPresentationMode_resetSwitchInProgress() {
16978                                    if (this.switchInProgress) {
16979                                        clearTimeout(this.switchInProgress);
16980                                        delete this.switchInProgress;
16981                                    }
16982                                },
16983                                _enter: function PDFPresentationMode_enter() {
16984                                    this.active = true;
16985                                    this._resetSwitchInProgress();
16986                                    this._notifyStateChange();
16987                                    this.container.classList.add(ACTIVE_SELECTOR);
16988                                    setTimeout(function enterPresentationModeTimeout() {
16989                                        this.pdfViewer.currentPageNumber = this.args.page;
16990                                        this.pdfViewer.currentScaleValue = 'page-fit';
16991                                    }.bind(this), 0);
16992                                    this._addWindowListeners();
16993                                    this._showControls();
16994                                    this.contextMenuOpen = false;
16995                                    this.container.setAttribute('contextmenu', 'viewerContextMenu');
16996                                    window.getSelection().removeAllRanges();
16997                                },
16998                                _exit: function PDFPresentationMode_exit() {
16999                                    var page = this.pdfViewer.currentPageNumber;
17000                                    this.container.classList.remove(ACTIVE_SELECTOR);
17001                                    setTimeout(function exitPresentationModeTimeout() {
17002                                        this.active = false;
17003                                        this._removeFullscreenChangeListeners();
17004                                        this._notifyStateChange();
17005                                        this.pdfViewer.currentScaleValue = this.args.previousScale;
17006                                        this.pdfViewer.currentPageNumber = page;
17007                                        this.args = null;
17008                                    }.bind(this), 0);
17009                                    this._removeWindowListeners();
17010                                    this._hideControls();
17011                                    this._resetMouseScrollState();
17012                                    this.container.removeAttribute('contextmenu');
17013                                    this.contextMenuOpen = false;
17014                                },
17015                                _mouseDown: function PDFPresentationMode_mouseDown(evt) {
17016                                    if (this.contextMenuOpen) {
17017                                        this.contextMenuOpen = false;
17018                                        evt.preventDefault();
17019                                        return;
17020                                    }
17021                                    if (evt.button === 0) {
17022                                        var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
17023                                        if (!isInternalLink) {
17024                                            evt.preventDefault();
17025                                            this.pdfViewer.currentPageNumber += evt.shiftKey ? -1 : 1;
17026                                        }
17027                                    }
17028                                },
17029                                _contextMenu: function PDFPresentationMode_contextMenu() {
17030                                    this.contextMenuOpen = true;
17031                                },
17032                                _showControls: function PDFPresentationMode_showControls() {
17033                                    if (this.controlsTimeout) {
17034                                        clearTimeout(this.controlsTimeout);
17035                                    } else {
17036                                        this.container.classList.add(CONTROLS_SELECTOR);
17037                                    }
17038                                    this.controlsTimeout = setTimeout(function showControlsTimeout() {
17039                                        this.container.classList.remove(CONTROLS_SELECTOR);
17040                                        delete this.controlsTimeout;
17041                                    }.bind(this), DELAY_BEFORE_HIDING_CONTROLS);
17042                                },
17043                                _hideControls: function PDFPresentationMode_hideControls() {
17044                                    if (!this.controlsTimeout) {
17045                                        return;
17046                                    }
17047                                    clearTimeout(this.controlsTimeout);
17048                                    this.container.classList.remove(CONTROLS_SELECTOR);
17049                                    delete this.controlsTimeout;
17050                                },
17051                                _resetMouseScrollState: function PDFPresentationMode_resetMouseScrollState() {
17052                                    this.mouseScrollTimeStamp = 0;
17053                                    this.mouseScrollDelta = 0;
17054                                },
17055                                _touchSwipe: function PDFPresentationMode_touchSwipe(evt) {
17056                                    if (!this.active) {
17057                                        return;
17058                                    }
17059                                    var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
17060                                    var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
17061                                    if (evt.touches.length > 1) {
17062                                        this.touchSwipeState = null;
17063                                        return;
17064                                    }
17065                                    switch (evt.type) {
17066                                        case 'touchstart':
17067                                            this.touchSwipeState = {
17068                                                startX: evt.touches[0].pageX,
17069                                                startY: evt.touches[0].pageY,
17070                                                endX: evt.touches[0].pageX,
17071                                                endY: evt.touches[0].pageY
17072                                            };
17073                                            break;
17074                                        case 'touchmove':
17075                                            if (this.touchSwipeState === null) {
17076                                                return;
17077                                            }
17078                                            this.touchSwipeState.endX = evt.touches[0].pageX;
17079                                            this.touchSwipeState.endY = evt.touches[0].pageY;
17080                                            evt.preventDefault();
17081                                            break;
17082                                        case 'touchend':
17083                                            if (this.touchSwipeState === null) {
17084                                                return;
17085                                            }
17086                                            var delta = 0;
17087                                            var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
17088                                            var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
17089                                            var absAngle = Math.abs(Math.atan2(dy, dx));
17090                                            if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
17091                                                delta = dx;
17092                                            } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
17093                                                delta = dy;
17094                                            }
17095                                            if (delta > 0) {
17096                                                this._goToPreviousPage();
17097                                            } else if (delta < 0) {
17098                                                this._goToNextPage();
17099                                            }
17100                                            break;
17101                                    }
17102                                },
17103                                _addWindowListeners: function PDFPresentationMode_addWindowListeners() {
17104                                    this.showControlsBind = this._showControls.bind(this);
17105                                    this.mouseDownBind = this._mouseDown.bind(this);
17106                                    this.mouseWheelBind = this._mouseWheel.bind(this);
17107                                    this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
17108                                    this.contextMenuBind = this._contextMenu.bind(this);
17109                                    this.touchSwipeBind = this._touchSwipe.bind(this);
17110                                    window.addEventListener('mousemove', this.showControlsBind);
17111                                    window.addEventListener('mousedown', this.mouseDownBind);
17112                                    window.addEventListener('wheel', this.mouseWheelBind);
17113                                    window.addEventListener('keydown', this.resetMouseScrollStateBind);
17114                                    window.addEventListener('contextmenu', this.contextMenuBind);
17115                                    window.addEventListener('touchstart', this.touchSwipeBind);
17116                                    window.addEventListener('touchmove', this.touchSwipeBind);
17117                                    window.addEventListener('touchend', this.touchSwipeBind);
17118                                },
17119                                _removeWindowListeners: function PDFPresentationMode_removeWindowListeners() {
17120                                    window.removeEventListener('mousemove', this.showControlsBind);
17121                                    window.removeEventListener('mousedown', this.mouseDownBind);
17122                                    window.removeEventListener('wheel', this.mouseWheelBind);
17123                                    window.removeEventListener('keydown', this.resetMouseScrollStateBind);
17124                                    window.removeEventListener('contextmenu', this.contextMenuBind);
17125                                    window.removeEventListener('touchstart', this.touchSwipeBind);
17126                                    window.removeEventListener('touchmove', this.touchSwipeBind);
17127                                    window.removeEventListener('touchend', this.touchSwipeBind);
17128                                    delete this.showControlsBind;
17129                                    delete this.mouseDownBind;
17130                                    delete this.mouseWheelBind;
17131                                    delete this.resetMouseScrollStateBind;
17132                                    delete this.contextMenuBind;
17133                                    delete this.touchSwipeBind;
17134                                },
17135                                _fullscreenChange: function PDFPresentationMode_fullscreenChange() {
17136                                    if (this.isFullscreen) {
17137                                        this._enter();
17138                                    } else {
17139                                        this._exit();
17140                                    }
17141                                },
17142                                _addFullscreenChangeListeners: function PDFPresentationMode_addFullscreenChangeListeners() {
17143                                    this.fullscreenChangeBind = this._fullscreenChange.bind(this);
17144                                    window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
17145                                    window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
17146                                    window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
17147                                    window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
17148                                },
17149                                _removeFullscreenChangeListeners: function PDFPresentationMode_removeFullscreenChangeListeners() {
17150                                    window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
17151                                    window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
17152                                    window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
17153                                    window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
17154                                    delete this.fullscreenChangeBind;
17155                                }
17156                            };
17157                            return PDFPresentationMode;
17158                        }();
17159                        exports.PDFPresentationMode = PDFPresentationMode;
17160
17161                        /***/ }),
17162                    /* 22 */
17163                    /***/ (function (module, exports, __webpack_require__) {
17164
17165                        "use strict";
17166
17167                        var pdfRenderingQueue = __webpack_require__(3);
17168                        var uiUtils = __webpack_require__(0);
17169                        var RenderingStates = pdfRenderingQueue.RenderingStates;
17170                        var mozL10n = uiUtils.mozL10n;
17171                        var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
17172                        var SidebarView = {
17173                            NONE: 0,
17174                            THUMBS: 1,
17175                            OUTLINE: 2,
17176                            ATTACHMENTS: 3
17177                        };
17178                        var PDFSidebar = function PDFSidebarClosure() {
17179                            function PDFSidebar(options) {
17180                                this.isOpen = false;
17181                                this.active = SidebarView.THUMBS;
17182                                this.isInitialViewSet = false;
17183                                this.onToggled = null;
17184                                this.pdfViewer = options.pdfViewer;
17185                                this.pdfThumbnailViewer = options.pdfThumbnailViewer;
17186                                this.pdfOutlineViewer = options.pdfOutlineViewer;
17187                                this.mainContainer = options.mainContainer;
17188                                this.outerContainer = options.outerContainer;
17189                                this.eventBus = options.eventBus;
17190                                this.toggleButton = options.toggleButton;
17191                                this.thumbnailButton = options.thumbnailButton;
17192                                this.outlineButton = options.outlineButton;
17193                                this.attachmentsButton = options.attachmentsButton;
17194                                this.thumbnailView = options.thumbnailView;
17195                                this.outlineView = options.outlineView;
17196                                this.attachmentsView = options.attachmentsView;
17197                                this.disableNotification = options.disableNotification || false;
17198                                this._addEventListeners();
17199                            }
17200                            PDFSidebar.prototype = {
17201                                reset: function PDFSidebar_reset() {
17202                                    this.isInitialViewSet = false;
17203                                    this._hideUINotification(null);
17204                                    this.switchView(SidebarView.THUMBS);
17205                                    this.outlineButton.disabled = false;
17206                                    this.attachmentsButton.disabled = false;
17207                                },
17208                                get visibleView() {
17209                                    return this.isOpen ? this.active : SidebarView.NONE;
17210                                },
17211                                get isThumbnailViewVisible() {
17212                                    return this.isOpen && this.active === SidebarView.THUMBS;
17213                                },
17214                                get isOutlineViewVisible() {
17215                                    return this.isOpen && this.active === SidebarView.OUTLINE;
17216                                },
17217                                get isAttachmentsViewVisible() {
17218                                    return this.isOpen && this.active === SidebarView.ATTACHMENTS;
17219                                },
17220                                setInitialView: function PDFSidebar_setInitialView(view) {
17221                                    if (this.isInitialViewSet) {
17222                                        return;
17223                                    }
17224                                    this.isInitialViewSet = true;
17225                                    if (this.isOpen && view === SidebarView.NONE) {
17226                                        this._dispatchEvent();
17227                                        return;
17228                                    }
17229                                    var isViewPreserved = view === this.visibleView;
17230                                    this.switchView(view, true);
17231                                    if (isViewPreserved) {
17232                                        this._dispatchEvent();
17233                                    }
17234                                },
17235                                switchView: function PDFSidebar_switchView(view, forceOpen) {
17236                                    if (view === SidebarView.NONE) {
17237                                        this.close();
17238                                        return;
17239                                    }
17240                                    var isViewChanged = view !== this.active;
17241                                    var shouldForceRendering = false;
17242                                    switch (view) {
17243                                        case SidebarView.THUMBS:
17244                                            this.thumbnailButton.classList.add('toggled');
17245                                            this.outlineButton.classList.remove('toggled');
17246                                            this.attachmentsButton.classList.remove('toggled');
17247                                            this.thumbnailView.classList.remove('hidden');
17248                                            this.outlineView.classList.add('hidden');
17249                                            this.attachmentsView.classList.add('hidden');
17250                                            if (this.isOpen && isViewChanged) {
17251                                                this._updateThumbnailViewer();
17252                                                shouldForceRendering = true;
17253                                            }
17254                                            break;
17255                                        case SidebarView.OUTLINE:
17256                                            if (this.outlineButton.disabled) {
17257                                                return;
17258                                            }
17259                                            this.thumbnailButton.classList.remove('toggled');
17260                                            this.outlineButton.classList.add('toggled');
17261                                            this.attachmentsButton.classList.remove('toggled');
17262                                            this.thumbnailView.classList.add('hidden');
17263                                            this.outlineView.classList.remove('hidden');
17264                                            this.attachmentsView.classList.add('hidden');
17265                                            break;
17266                                        case SidebarView.ATTACHMENTS:
17267                                            if (this.attachmentsButton.disabled) {
17268                                                return;
17269                                            }
17270                                            this.thumbnailButton.classList.remove('toggled');
17271                                            this.outlineButton.classList.remove('toggled');
17272                                            this.attachmentsButton.classList.add('toggled');
17273                                            this.thumbnailView.classList.add('hidden');
17274                                            this.outlineView.classList.add('hidden');
17275                                            this.attachmentsView.classList.remove('hidden');
17276                                            break;
17277                                        default:
17278                                            console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
17279                                            return;
17280                                    }
17281                                    this.active = view | 0;
17282                                    if (forceOpen && !this.isOpen) {
17283                                        this.open();
17284                                        return;
17285                                    }
17286                                    if (shouldForceRendering) {
17287                                        this._forceRendering();
17288                                    }
17289                                    if (isViewChanged) {
17290                                        this._dispatchEvent();
17291                                    }
17292                                    this._hideUINotification(this.active);
17293                                },
17294                                open: function PDFSidebar_open() {
17295                                    if (this.isOpen) {
17296                                        return;
17297                                    }
17298                                    this.isOpen = true;
17299                                    this.toggleButton.classList.add('toggled');
17300                                    this.outerContainer.classList.add('sidebarMoving');
17301                                    this.outerContainer.classList.add('sidebarOpen');
17302                                    if (this.active === SidebarView.THUMBS) {
17303                                        this._updateThumbnailViewer();
17304                                    }
17305                                    this._forceRendering();
17306                                    this._dispatchEvent();
17307                                    this._hideUINotification(this.active);
17308                                },
17309                                close: function PDFSidebar_close() {
17310                                    if (!this.isOpen) {
17311                                        return;
17312                                    }
17313                                    this.isOpen = false;
17314                                    this.toggleButton.classList.remove('toggled');
17315                                    this.outerContainer.classList.add('sidebarMoving');
17316                                    this.outerContainer.classList.remove('sidebarOpen');
17317                                    this._forceRendering();
17318                                    this._dispatchEvent();
17319                                },
17320                                toggle: function PDFSidebar_toggle() {
17321                                    if (this.isOpen) {
17322                                        this.close();
17323                                    } else {
17324                                        this.open();
17325                                    }
17326                                },
17327                                _dispatchEvent: function PDFSidebar_dispatchEvent() {
17328                                    this.eventBus.dispatch('sidebarviewchanged', {
17329                                        source: this,
17330                                        view: this.visibleView
17331                                    });
17332                                },
17333                                _forceRendering: function PDFSidebar_forceRendering() {
17334                                    if (this.onToggled) {
17335                                        this.onToggled();
17336                                    } else {
17337                                        this.pdfViewer.forceRendering();
17338                                        this.pdfThumbnailViewer.forceRendering();
17339                                    }
17340                                },
17341                                _updateThumbnailViewer: function PDFSidebar_updateThumbnailViewer() {
17342                                    var pdfViewer = this.pdfViewer;
17343                                    var thumbnailViewer = this.pdfThumbnailViewer;
17344                                    var pagesCount = pdfViewer.pagesCount;
17345                                    for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
17346                                        var pageView = pdfViewer.getPageView(pageIndex);
17347                                        if (pageView && pageView.renderingState === RenderingStates.FINISHED) {
17348                                            var thumbnailView = thumbnailViewer.getThumbnail(pageIndex);
17349                                            thumbnailView.setImage(pageView);
17350                                        }
17351                                    }
17352                                    thumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
17353                                },
17354                                _showUINotification: function (view) {
17355                                    if (this.disableNotification) {
17356                                        return;
17357                                    }
17358                                    this.toggleButton.title = mozL10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)');
17359                                    if (!this.isOpen) {
17360                                        this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
17361                                    } else if (view === this.active) {
17362                                        return;
17363                                    }
17364                                    switch (view) {
17365                                        case SidebarView.OUTLINE:
17366                                            this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
17367                                            break;
17368                                        case SidebarView.ATTACHMENTS:
17369                                            this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
17370                                            break;
17371                                    }
17372                                },
17373                                _hideUINotification: function (view) {
17374                                    if (this.disableNotification) {
17375                                        return;
17376                                    }
17377                                    var removeNotification = function (view) {
17378                                        switch (view) {
17379                                            case SidebarView.OUTLINE:
17380                                                this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
17381                                                break;
17382                                            case SidebarView.ATTACHMENTS:
17383                                                this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
17384                                                break;
17385                                        }
17386                                    }.bind(this);
17387                                    if (!this.isOpen && view !== null) {
17388                                        return;
17389                                    }
17390                                    this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
17391                                    if (view !== null) {
17392                                        removeNotification(view);
17393                                        return;
17394                                    }
17395                                    for (view in SidebarView) {
17396                                        removeNotification(SidebarView[view]);
17397                                    }
17398                                    this.toggleButton.title = mozL10n.get('toggle_sidebar.title', null, 'Toggle Sidebar');
17399                                },
17400                                _addEventListeners: function PDFSidebar_addEventListeners() {
17401                                    var self = this;
17402                                    self.mainContainer.addEventListener('transitionend', function (evt) {
17403                                        if (evt.target === this) {
17404                                            self.outerContainer.classList.remove('sidebarMoving');
17405                                        }
17406                                    });
17407                                    self.thumbnailButton.addEventListener('click', function () {
17408                                        self.switchView(SidebarView.THUMBS);
17409                                    });
17410                                    self.outlineButton.addEventListener('click', function () {
17411                                        self.switchView(SidebarView.OUTLINE);
17412                                    });
17413                                    self.outlineButton.addEventListener('dblclick', function () {
17414                                        self.pdfOutlineViewer.toggleOutlineTree();
17415                                    });
17416                                    self.attachmentsButton.addEventListener('click', function () {
17417                                        self.switchView(SidebarView.ATTACHMENTS);
17418                                    });
17419                                    self.eventBus.on('outlineloaded', function (e) {
17420                                        var outlineCount = e.outlineCount;
17421                                        self.outlineButton.disabled = !outlineCount;
17422                                        if (outlineCount) {
17423                                            self._showUINotification(SidebarView.OUTLINE);
17424                                        } else if (self.active === SidebarView.OUTLINE) {
17425                                            self.switchView(SidebarView.THUMBS);
17426                                        }
17427                                    });
17428                                    self.eventBus.on('attachmentsloaded', function (e) {
17429                                        var attachmentsCount = e.attachmentsCount;
17430                                        self.attachmentsButton.disabled = !attachmentsCount;
17431                                        if (attachmentsCount) {
17432                                            self._showUINotification(SidebarView.ATTACHMENTS);
17433                                        } else if (self.active === SidebarView.ATTACHMENTS) {
17434                                            self.switchView(SidebarView.THUMBS);
17435                                        }
17436                                    });
17437                                    self.eventBus.on('presentationmodechanged', function (e) {
17438                                        if (!e.active && !e.switchInProgress && self.isThumbnailViewVisible) {
17439                                            self._updateThumbnailViewer();
17440                                        }
17441                                    });
17442                                }
17443                            };
17444                            return PDFSidebar;
17445                        }();
17446                        exports.SidebarView = SidebarView;
17447                        exports.PDFSidebar = PDFSidebar;
17448
17449                        /***/ }),
17450                    /* 23 */
17451                    /***/ (function (module, exports, __webpack_require__) {
17452
17453                        "use strict";
17454
17455                        var uiUtils = __webpack_require__(0);
17456                        var pdfRenderingQueue = __webpack_require__(3);
17457                        var mozL10n = uiUtils.mozL10n;
17458                        var getOutputScale = uiUtils.getOutputScale;
17459                        var RenderingStates = pdfRenderingQueue.RenderingStates;
17460                        var THUMBNAIL_WIDTH = 98;
17461                        var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
17462                        var PDFThumbnailView = function PDFThumbnailViewClosure() {
17463                            function getTempCanvas(width, height) {
17464                                var tempCanvas = PDFThumbnailView.tempImageCache;
17465                                if (!tempCanvas) {
17466                                    tempCanvas = document.createElement('canvas');
17467                                    PDFThumbnailView.tempImageCache = tempCanvas;
17468                                }
17469                                tempCanvas.width = width;
17470                                tempCanvas.height = height;
17471                                tempCanvas.mozOpaque = true;
17472                                var ctx = tempCanvas.getContext('2d', {alpha: false});
17473                                ctx.save();
17474                                ctx.fillStyle = 'rgb(255, 255, 255)';
17475                                ctx.fillRect(0, 0, width, height);
vendor: 28,204 bytes, lines 17476-17893
17476                                ctx.restore();
17477                                return tempCanvas;
17478                            }
17479                            function PDFThumbnailView(options) {
17480                                var container = options.container;
17481                                var id = options.id;
17482                                var defaultViewport = options.defaultViewport;
17483                                var linkService = options.linkService;
17484                                var renderingQueue = options.renderingQueue;
17485                                var disableCanvasToImageConversion = options.disableCanvasToImageConversion || false;
17486                                this.id = id;
17487                                this.renderingId = 'thumbnail' + id;
17488                                this.pageLabel = null;
17489                                this.pdfPage = null;
17490                                this.rotation = 0;
17491                                this.viewport = defaultViewport;
17492                                this.pdfPageRotate = defaultViewport.rotation;
17493                                this.linkService = linkService;
17494                                this.renderingQueue = renderingQueue;
17495                                this.renderTask = null;
17496                                this.renderingState = RenderingStates.INITIAL;
17497                                this.resume = null;
17498                                this.disableCanvasToImageConversion = disableCanvasToImageConversion;
17499                                this.pageWidth = this.viewport.width;
17500                                this.pageHeight = this.viewport.height;
17501                                this.pageRatio = this.pageWidth / this.pageHeight;
17502                                this.canvasWidth = THUMBNAIL_WIDTH;
17503                                this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
17504                                this.scale = this.canvasWidth / this.pageWidth;
17505                                var anchor = document.createElement('a');
17506                                anchor.href = linkService.getAnchorUrl('#page=' + id);
17507                                anchor.title = mozL10n.get('thumb_page_title', {page: id}, 'Page {{page}}');
17508                                anchor.onclick = function stopNavigation() {
17509                                    linkService.page = id;
17510                                    return false;
17511                                };
17512                                this.anchor = anchor;
17513                                var div = document.createElement('div');
17514                                div.className = 'thumbnail';
17515                                div.setAttribute('data-page-number', this.id);
17516                                this.div = div;
17517                                if (id === 1) {
17518                                    div.classList.add('selected');
17519                                }
17520                                var ring = document.createElement('div');
17521                                ring.className = 'thumbnailSelectionRing';
17522                                var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
17523                                ring.style.width = this.canvasWidth + borderAdjustment + 'px';
17524                                ring.style.height = this.canvasHeight + borderAdjustment + 'px';
17525                                this.ring = ring;
17526                                div.appendChild(ring);
17527                                anchor.appendChild(div);
17528                                container.appendChild(anchor);
17529                            }
17530                            PDFThumbnailView.prototype = {
17531                                setPdfPage: function PDFThumbnailView_setPdfPage(pdfPage) {
17532                                    this.pdfPage = pdfPage;
17533                                    this.pdfPageRotate = pdfPage.rotate;
17534                                    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
17535                                    this.viewport = pdfPage.getViewport(1, totalRotation);
17536                                    this.reset();
17537                                },
17538                                reset: function PDFThumbnailView_reset() {
17539                                    this.cancelRendering();
17540                                    this.pageWidth = this.viewport.width;
17541                                    this.pageHeight = this.viewport.height;
17542                                    this.pageRatio = this.pageWidth / this.pageHeight;
17543                                    this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
17544                                    this.scale = this.canvasWidth / this.pageWidth;
17545                                    this.div.removeAttribute('data-loaded');
17546                                    var ring = this.ring;
17547                                    var childNodes = ring.childNodes;
17548                                    for (var i = childNodes.length - 1; i >= 0; i--) {
17549                                        ring.removeChild(childNodes[i]);
17550                                    }
17551                                    var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
17552                                    ring.style.width = this.canvasWidth + borderAdjustment + 'px';
17553                                    ring.style.height = this.canvasHeight + borderAdjustment + 'px';
17554                                    if (this.canvas) {
17555                                        this.canvas.width = 0;
17556                                        this.canvas.height = 0;
17557                                        delete this.canvas;
17558                                    }
17559                                    if (this.image) {
17560                                        this.image.removeAttribute('src');
17561                                        delete this.image;
17562                                    }
17563                                },
17564                                update: function PDFThumbnailView_update(rotation) {
17565                                    if (typeof rotation !== 'undefined') {
17566                                        this.rotation = rotation;
17567                                    }
17568                                    var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
17569                                    this.viewport = this.viewport.clone({
17570                                        scale: 1,
17571                                        rotation: totalRotation
17572                                    });
17573                                    this.reset();
17574                                },
17575                                cancelRendering: function PDFThumbnailView_cancelRendering() {
17576                                    if (this.renderTask) {
17577                                        this.renderTask.cancel();
17578                                        this.renderTask = null;
17579                                    }
17580                                    this.renderingState = RenderingStates.INITIAL;
17581                                    this.resume = null;
17582                                },
17583                                _getPageDrawContext: function PDFThumbnailView_getPageDrawContext(noCtxScale) {
17584                                    var canvas = document.createElement('canvas');
17585                                    this.canvas = canvas;
17586                                    canvas.mozOpaque = true;
17587                                    var ctx = canvas.getContext('2d', {alpha: false});
17588                                    var outputScale = getOutputScale(ctx);
17589                                    canvas.width = this.canvasWidth * outputScale.sx | 0;
17590                                    canvas.height = this.canvasHeight * outputScale.sy | 0;
17591                                    canvas.style.width = this.canvasWidth + 'px';
17592                                    canvas.style.height = this.canvasHeight + 'px';
17593                                    if (!noCtxScale && outputScale.scaled) {
17594                                        ctx.scale(outputScale.sx, outputScale.sy);
17595                                    }
17596                                    return ctx;
17597                                },
17598                                _convertCanvasToImage: function PDFThumbnailView_convertCanvasToImage() {
17599                                    if (!this.canvas) {
17600                                        return;
17601                                    }
17602                                    if (this.renderingState !== RenderingStates.FINISHED) {
17603                                        return;
17604                                    }
17605                                    var id = this.renderingId;
17606                                    var className = 'thumbnailImage';
17607                                    var ariaLabel = mozL10n.get('thumb_page_canvas', {page: this.pageId}, 'Thumbnail of Page {{page}}');
17608                                    if (this.disableCanvasToImageConversion) {
17609                                        this.canvas.id = id;
17610                                        this.canvas.className = className;
17611                                        this.canvas.setAttribute('aria-label', ariaLabel);
17612                                        this.div.setAttribute('data-loaded', true);
17613                                        this.ring.appendChild(this.canvas);
17614                                        return;
17615                                    }
17616                                    var image = document.createElement('img');
17617                                    image.id = id;
17618                                    image.className = className;
17619                                    image.setAttribute('aria-label', ariaLabel);
17620                                    image.style.width = this.canvasWidth + 'px';
17621                                    image.style.height = this.canvasHeight + 'px';
17622                                    image.src = this.canvas.toDataURL();
17623                                    this.image = image;
17624                                    this.div.setAttribute('data-loaded', true);
17625                                    this.ring.appendChild(image);
17626                                    this.canvas.width = 0;
17627                                    this.canvas.height = 0;
17628                                    delete this.canvas;
17629                                },
17630                                draw: function PDFThumbnailView_draw() {
17631                                    if (this.renderingState !== RenderingStates.INITIAL) {
17632                                        console.error('Must be in new state before drawing');
17633                                        return Promise.resolve(undefined);
17634                                    }
17635                                    this.renderingState = RenderingStates.RUNNING;
17636                                    var resolveRenderPromise, rejectRenderPromise;
17637                                    var promise = new Promise(function (resolve, reject) {
17638                                        resolveRenderPromise = resolve;
17639                                        rejectRenderPromise = reject;
17640                                    });
17641                                    var self = this;
17642                                    function thumbnailDrawCallback(error) {
17643                                        if (renderTask === self.renderTask) {
17644                                            self.renderTask = null;
17645                                        }
17646                                        if (error === 'cancelled') {
17647                                            rejectRenderPromise(error);
17648                                            return;
17649                                        }
17650                                        self.renderingState = RenderingStates.FINISHED;
17651                                        self._convertCanvasToImage();
17652                                        if (!error) {
17653                                            resolveRenderPromise(undefined);
17654                                        } else {
17655                                            rejectRenderPromise(error);
17656                                        }
17657                                    }
17658                                    var ctx = this._getPageDrawContext();
17659                                    var drawViewport = this.viewport.clone({scale: this.scale});
17660                                    var renderContinueCallback = function renderContinueCallback(cont) {
17661                                        if (!self.renderingQueue.isHighestPriority(self)) {
17662                                            self.renderingState = RenderingStates.PAUSED;
17663                                            self.resume = function resumeCallback() {
17664                                                self.renderingState = RenderingStates.RUNNING;
17665                                                cont();
17666                                            };
17667                                            return;
17668                                        }
17669                                        cont();
17670                                    };
17671                                    var renderContext = {
17672                                        canvasContext: ctx,
17673                                        viewport: drawViewport
17674                                    };
17675                                    var renderTask = this.renderTask = this.pdfPage.render(renderContext);
17676                                    renderTask.onContinue = renderContinueCallback;
17677                                    renderTask.promise.then(function pdfPageRenderCallback() {
17678                                        thumbnailDrawCallback(null);
17679                                    }, function pdfPageRenderError(error) {
17680                                        thumbnailDrawCallback(error);
17681                                    });
17682                                    return promise;
17683                                },
17684                                setImage: function PDFThumbnailView_setImage(pageView) {
17685                                    if (this.renderingState !== RenderingStates.INITIAL) {
17686                                        return;
17687                                    }
17688                                    var img = pageView.canvas;
17689                                    if (!img) {
17690                                        return;
17691                                    }
17692                                    if (!this.pdfPage) {
17693                                        this.setPdfPage(pageView.pdfPage);
17694                                    }
17695                                    this.renderingState = RenderingStates.FINISHED;
17696                                    var ctx = this._getPageDrawContext(true);
17697                                    var canvas = ctx.canvas;
17698                                    if (img.width <= 2 * canvas.width) {
17699                                        ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
17700                                        this._convertCanvasToImage();
17701                                        return;
17702                                    }
17703                                    var MAX_NUM_SCALING_STEPS = 3;
17704                                    var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
17705                                    var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
17706                                    var reducedImage = getTempCanvas(reducedWidth, reducedHeight);
17707                                    var reducedImageCtx = reducedImage.getContext('2d');
17708                                    while (reducedWidth > img.width || reducedHeight > img.height) {
17709                                        reducedWidth >>= 1;
17710                                        reducedHeight >>= 1;
17711                                    }
17712                                    reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
17713                                    while (reducedWidth > 2 * canvas.width) {
17714                                        reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
17715                                        reducedWidth >>= 1;
17716                                        reducedHeight >>= 1;
17717                                    }
17718                                    ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
17719                                    this._convertCanvasToImage();
17720                                },
17721                                get pageId() {
17722                                    return this.pageLabel !== null ? this.pageLabel : this.id;
17723                                },
17724                                setPageLabel: function PDFThumbnailView_setPageLabel(label) {
17725                                    this.pageLabel = typeof label === 'string' ? label : null;
17726                                    this.anchor.title = mozL10n.get('thumb_page_title', {page: this.pageId}, 'Page {{page}}');
17727                                    if (this.renderingState !== RenderingStates.FINISHED) {
17728                                        return;
17729                                    }
17730                                    var ariaLabel = mozL10n.get('thumb_page_canvas', {page: this.pageId}, 'Thumbnail of Page {{page}}');
17731                                    if (this.image) {
17732                                        this.image.setAttribute('aria-label', ariaLabel);
17733                                    } else if (this.disableCanvasToImageConversion && this.canvas) {
17734                                        this.canvas.setAttribute('aria-label', ariaLabel);
17735                                    }
17736                                }
17737                            };
17738                            return PDFThumbnailView;
17739                        }();
17740                        PDFThumbnailView.tempImageCache = null;
17741                        exports.PDFThumbnailView = PDFThumbnailView;
17742
17743                        /***/ }),
17744                    /* 24 */
17745                    /***/ (function (module, exports, __webpack_require__) {
17746
17747                        "use strict";
17748
17749                        var uiUtils = __webpack_require__(0);
17750                        var pdfThumbnailView = __webpack_require__(23);
17751                        var watchScroll = uiUtils.watchScroll;
17752                        var getVisibleElements = uiUtils.getVisibleElements;
17753                        var scrollIntoView = uiUtils.scrollIntoView;
17754                        var PDFThumbnailView = pdfThumbnailView.PDFThumbnailView;
17755                        var THUMBNAIL_SCROLL_MARGIN = -19;
17756                        var PDFThumbnailViewer = function PDFThumbnailViewerClosure() {
17757                            function PDFThumbnailViewer(options) {
17758                                this.container = options.container;
17759                                this.renderingQueue = options.renderingQueue;
17760                                this.linkService = options.linkService;
17761                                this.scroll = watchScroll(this.container, this._scrollUpdated.bind(this));
17762                                this._resetView();
17763                            }
17764                            PDFThumbnailViewer.prototype = {
17765                                _scrollUpdated: function PDFThumbnailViewer_scrollUpdated() {
17766                                    this.renderingQueue.renderHighestPriority();
17767                                },
17768                                getThumbnail: function PDFThumbnailViewer_getThumbnail(index) {
17769                                    return this.thumbnails[index];
17770                                },
17771                                _getVisibleThumbs: function PDFThumbnailViewer_getVisibleThumbs() {
17772                                    return getVisibleElements(this.container, this.thumbnails);
17773                                },
17774                                scrollThumbnailIntoView: function PDFThumbnailViewer_scrollThumbnailIntoView(page) {
17775                                    var selected = document.querySelector('.thumbnail.selected');
17776                                    if (selected) {
17777                                        selected.classList.remove('selected');
17778                                    }
17779                                    var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]');
17780                                    if (thumbnail) {
17781                                        thumbnail.classList.add('selected');
17782                                    }
17783                                    var visibleThumbs = this._getVisibleThumbs();
17784                                    var numVisibleThumbs = visibleThumbs.views.length;
17785                                    if (numVisibleThumbs > 0) {
17786                                        var first = visibleThumbs.first.id;
17787                                        var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
17788                                        if (page <= first || page >= last) {
17789                                            scrollIntoView(thumbnail, {top: THUMBNAIL_SCROLL_MARGIN});
17790                                        }
17791                                    }
17792                                },
17793                                get pagesRotation() {
17794                                    return this._pagesRotation;
17795                                },
17796                                set pagesRotation(rotation) {
17797                                    this._pagesRotation = rotation;
17798                                    for (var i = 0, l = this.thumbnails.length; i < l; i++) {
17799                                        var thumb = this.thumbnails[i];
17800                                        thumb.update(rotation);
17801                                    }
17802                                },
17803                                cleanup: function PDFThumbnailViewer_cleanup() {
17804                                    var tempCanvas = PDFThumbnailView.tempImageCache;
17805                                    if (tempCanvas) {
17806                                        tempCanvas.width = 0;
17807                                        tempCanvas.height = 0;
17808                                    }
17809                                    PDFThumbnailView.tempImageCache = null;
17810                                },
17811                                _resetView: function PDFThumbnailViewer_resetView() {
17812                                    this.thumbnails = [];
17813                                    this._pageLabels = null;
17814                                    this._pagesRotation = 0;
17815                                    this._pagesRequests = [];
17816                                    this.container.textContent = '';
17817                                },
17818                                setDocument: function PDFThumbnailViewer_setDocument(pdfDocument) {
17819                                    if (this.pdfDocument) {
17820                                        this._cancelRendering();
17821                                        this._resetView();
17822                                    }
17823                                    this.pdfDocument = pdfDocument;
17824                                    if (!pdfDocument) {
17825                                        return Promise.resolve();
17826                                    }
17827                                    return pdfDocument.getPage(1).then(function (firstPage) {
17828                                        var pagesCount = pdfDocument.numPages;
17829                                        var viewport = firstPage.getViewport(1.0);
17830                                        for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
17831                                            var thumbnail = new PDFThumbnailView({
17832                                                container: this.container,
17833                                                id: pageNum,
17834                                                defaultViewport: viewport.clone(),
17835                                                linkService: this.linkService,
17836                                                renderingQueue: this.renderingQueue,
17837                                                disableCanvasToImageConversion: false
17838                                            });
17839                                            this.thumbnails.push(thumbnail);
17840                                        }
17841                                    }.bind(this));
17842                                },
17843                                _cancelRendering: function PDFThumbnailViewer_cancelRendering() {
17844                                    for (var i = 0, ii = this.thumbnails.length; i < ii; i++) {
17845                                        if (this.thumbnails[i]) {
17846                                            this.thumbnails[i].cancelRendering();
17847                                        }
17848                                    }
17849                                },
17850                                setPageLabels: function PDFThumbnailViewer_setPageLabels(labels) {
17851                                    if (!this.pdfDocument) {
17852                                        return;
17853                                    }
17854                                    if (!labels) {
17855                                        this._pageLabels = null;
17856                                    } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
17857                                        this._pageLabels = null;
17858                                        console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
17859                                    } else {
17860                                        this._pageLabels = labels;
17861                                    }
17862                                    for (var i = 0, ii = this.thumbnails.length; i < ii; i++) {
17863                                        var thumbnailView = this.thumbnails[i];
17864                                        var label = this._pageLabels && this._pageLabels[i];
17865                                        thumbnailView.setPageLabel(label);
17866                                    }
17867                                },
17868                                _ensurePdfPageLoaded: function PDFThumbnailViewer_ensurePdfPageLoaded(thumbView) {
17869                                    if (thumbView.pdfPage) {
17870                                        return Promise.resolve(thumbView.pdfPage);
17871                                    }
17872                                    var pageNumber = thumbView.id;
17873                                    if (this._pagesRequests[pageNumber]) {
17874                                        return this._pagesRequests[pageNumber];
17875                                    }
17876                                    var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
17877                                        thumbView.setPdfPage(pdfPage);
17878                                        this._pagesRequests[pageNumber] = null;
17879                                        return pdfPage;
17880                                    }.bind(this));
17881                                    this._pagesRequests[pageNumber] = promise;
17882                                    return promise;
17883                                },
17884                                forceRendering: function () {
17885                                    var visibleThumbs = this._getVisibleThumbs();
17886                                    var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this.thumbnails, this.scroll.down);
17887                                    if (thumbView) {
17888                                        this._ensurePdfPageLoaded(thumbView).then(function () {
17889                                            this.renderingQueue.renderView(thumbView);
17890                                        }.bind(this));
17891                                        return true;
17892                                    }
17893                                    return false;
17894                                }
17895                            };
17896                            return PDFThumbnailViewer;
17897                        }();
17898                        exports.PDFThumbnailViewer = PDFThumbnailViewer;
17899
17900                        /***/ }),
17901                    /* 25 */
17902                    /***/ (function (module, exports, __webpack_require__) {
17903
17904                        "use strict";
17905
17906                        var uiUtils = __webpack_require__(0);
17907                        var pdfPageView = __webpack_require__(20);
17908                        var pdfRenderingQueue = __webpack_require__(3);
17909                        var textLayerBuilder = __webpack_require__(27);
17910                        var annotationLayerBuilder = __webpack_require__(10);
17911                        var pdfLinkService = __webpack_require__(5);
17912                        var domEvents = __webpack_require__(2);
17913                        var pdfjsLib = __webpack_require__(1);
17914                        var UNKNOWN_SCALE = uiUtils.UNKNOWN_SCALE;
17915                        var SCROLLBAR_PADDING = uiUtils.SCROLLBAR_PADDING;
17916                        var VERTICAL_PADDING = uiUtils.VERTICAL_PADDING;
17917                        var MAX_AUTO_SCALE = uiUtils.MAX_AUTO_SCALE;
17918                        var CSS_UNITS = uiUtils.CSS_UNITS;
17919                        var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
17920                        var DEFAULT_SCALE_VALUE = uiUtils.DEFAULT_SCALE_VALUE;
17921                        var RendererType = uiUtils.RendererType;
17922                        var scrollIntoView = uiUtils.scrollIntoView;
17923                        var watchScroll = uiUtils.watchScroll;
17924                        var getVisibleElements = uiUtils.getVisibleElements;
17925                        var PDFPageView = pdfPageView.PDFPageView;
17926                        var RenderingStates = pdfRenderingQueue.RenderingStates;
17927                        var PDFRenderingQueue = pdfRenderingQueue.PDFRenderingQueue;
17928                        var TextLayerBuilder = textLayerBuilder.TextLayerBuilder;
17929                        var AnnotationLayerBuilder = annotationLayerBuilder.AnnotationLayerBuilder;
17930                        var SimpleLinkService = pdfLinkService.SimpleLinkService;
17931                        var PresentationModeState = {
17932                            UNKNOWN: 0,
17933                            NORMAL: 1,
17934                            CHANGING: 2,
17935                            FULLSCREEN: 3
17936                        };
17937                        var DEFAULT_CACHE_SIZE = 10;
17938                        var PDFViewer = function pdfViewer() {
17939                            function PDFPageViewBuffer(size) {
17940                                var data = [];
17941                                this.push = function cachePush(view) {
17942                                    var i = data.indexOf(view);
17943                                    if (i >= 0) {
17944                                        data.splice(i, 1);
17945                                    }
17946                                    data.push(view);
17947                                    if (data.length > size) {
17948                                        data.shift().destroy();
17949                                    }
17950                                };
17951                                this.resize = function (newSize) {
17952                                    size = newSize;
17953                                    while (data.length > size) {
17954                                        data.shift().destroy();
17955                                    }
17956                                };
17957                            }
17958                            function isSameScale(oldScale, newScale) {
17959                                if (newScale === oldScale) {
17960                                    return true;
17961                                }
17962                                if (Math.abs(newScale - oldScale) < 1e-15) {
17963                                    return true;
17964                                }
17965                                return false;
17966                            }
17967                            function isPortraitOrientation(size) {
17968                                return size.width <= size.height;
17969                            }
17970                            function PDFViewer(options) {
17971                                this.container = options.container;
17972                                this.viewer = options.viewer || options.container.firstElementChild;
17973                                this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
17974                                this.linkService = options.linkService || new SimpleLinkService();
17975                                this.downloadManager = options.downloadManager || null;
17976                                this.removePageBorders = options.removePageBorders || false;
17977                                this.enhanceTextSelection = options.enhanceTextSelection || false;
17978                                this.renderInteractiveForms = options.renderInteractiveForms || false;
17979                                this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
17980                                this.renderer = options.renderer || RendererType.CANVAS;
17981                                this.defaultRenderingQueue = !options.renderingQueue;
17982                                if (this.defaultRenderingQueue) {
17983                                    this.renderingQueue = new PDFRenderingQueue();
17984                                    this.renderingQueue.setViewer(this);
17985                                } else {
17986                                    this.renderingQueue = options.renderingQueue;
17987                                }
17988                                this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this));
17989                                this.presentationModeState = PresentationModeState.UNKNOWN;
17990                                this._resetView();
17991                                if (this.removePageBorders) {
17992                                    this.viewer.classList.add('removePageBorders');
17993                                }
17994                            }
17995                            PDFViewer.prototype = {
17996                                get pagesCount() {
17997                                    return this._pages.length;
17998                                },
17999                                getPageView: function (index) {
18000                                    return this._pages[index];
18001                                },
18002                                get pageViewsReady() {
18003                                    return this._pageViewsReady;
18004                                },
18005                                get currentPageNumber() {
18006                                    return this._currentPageNumber;
18007                                },
18008                                set currentPageNumber(val) {
18009                                    if ((val | 0) !== val) {
18010                                        throw new Error('Invalid page number.');
18011                                    }
18012                                    if (!this.pdfDocument) {
18013                                        this._currentPageNumber = val;
18014                                        return;
18015                                    }
18016                                    this._setCurrentPageNumber(val, true);
18017                                },
18018                                _setCurrentPageNumber: function PDFViewer_setCurrentPageNumber(val, resetCurrentPageView) {
18019                                    if (this._currentPageNumber === val) {
18020                                        if (resetCurrentPageView) {
18021                                            this._resetCurrentPageView();
18022                                        }
18023                                        return;
18024                                    }
18025                                    if (!(0 < val && val <= this.pagesCount)) {
18026                                        console.error('PDFViewer_setCurrentPageNumber: "' + val + '" is out of bounds.');
18027                                        return;
18028                                    }
18029                                    var arg = {
18030                                        source: this,
18031                                        pageNumber: val,
18032                                        pageLabel: this._pageLabels && this._pageLabels[val - 1]
18033                                    };
18034                                    this._currentPageNumber = val;
18035                                    this.eventBus.dispatch('pagechanging', arg);
18036                                    this.eventBus.dispatch('pagechange', arg);
18037                                    if (resetCurrentPageView) {
18038                                        this._resetCurrentPageView();
18039                                    }
18040                                },
18041                                get currentPageLabel() {
18042                                    return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
18043                                },
18044                                set currentPageLabel(val) {
18045                                    var pageNumber = val | 0;
18046                                    if (this._pageLabels) {
18047                                        var i = this._pageLabels.indexOf(val);
18048                                        if (i >= 0) {
18049                                            pageNumber = i + 1;
18050                                        }
18051                                    }
18052                                    this.currentPageNumber = pageNumber;
18053                                },
18054                                get currentScale() {
18055                                    return this._currentScale !== UNKNOWN_SCALE ? this._currentScale : DEFAULT_SCALE;
18056                                },
18057                                set currentScale(val) {
18058                                    if (isNaN(val)) {
18059                                        throw new Error('Invalid numeric scale');
18060                                    }
18061                                    if (!this.pdfDocument) {
18062                                        this._currentScale = val;
18063                                        this._currentScaleValue = val !== UNKNOWN_SCALE ? val.toString() : null;
18064                                        return;
18065                                    }
18066                                    this._setScale(val, false);
18067                                },
18068                                get currentScaleValue() {
18069                                    return this._currentScaleValue;
18070                                },
18071                                set currentScaleValue(val) {
18072                                    if (!this.pdfDocument) {
18073                                        this._currentScale = isNaN(val) ? UNKNOWN_SCALE : val;
18074                                        this._currentScaleValue = val.toString();
18075                                        return;
18076                                    }
18077                                    this._setScale(val, false);
18078                                },
18079                                get pagesRotation() {
18080                                    return this._pagesRotation;
18081                                },
18082                                set pagesRotation(rotation) {
18083                                    if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
18084                                        throw new Error('Invalid pages rotation angle.');
18085                                    }
18086                                    this._pagesRotation = rotation;
18087                                    if (!this.pdfDocument) {
18088                                        return;
18089                                    }
18090                                    for (var i = 0, l = this._pages.length; i < l; i++) {
18091                                        var pageView = this._pages[i];
18092                                        pageView.update(pageView.scale, rotation);
18093                                    }
18094                                    this._setScale(this._currentScaleValue, true);
18095                                    if (this.defaultRenderingQueue) {
18096                                        this.update();
18097                                    }
18098                                },
18099                                setDocument: function (pdfDocument) {
18100                                    if (this.pdfDocument) {
18101                                        this._cancelRendering();
18102                                        this._resetView();
18103                                    }
18104                                    this.pdfDocument = pdfDocument;
18105                                    if (!pdfDocument) {
18106                                        return;
18107                                    }
18108                                    var pagesCount = pdfDocument.numPages;
18109                                    var self = this;
18110                                    var resolvePagesPromise;
18111                                    var pagesPromise = new Promise(function (resolve) {
18112                                        resolvePagesPromise = resolve;
18113                                    });
18114                                    this.pagesPromise = pagesPromise;
18115                                    pagesPromise.then(function () {
18116                                        self._pageViewsReady = true;
18117                                        self.eventBus.dispatch('pagesloaded', {
18118                                            source: self,
18119                                            pagesCount: pagesCount
18120                                        });
18121                                    });
18122                                    var isOnePageRenderedResolved = false;
vendor: 29,211 bytes, lines 18123-18548
18123                                    var resolveOnePageRendered = null;
18124                                    var onePageRendered = new Promise(function (resolve) {
18125                                        resolveOnePageRendered = resolve;
18126                                    });
18127                                    this.onePageRendered = onePageRendered;
18128                                    var bindOnAfterAndBeforeDraw = function (pageView) {
18129                                        pageView.onBeforeDraw = function pdfViewLoadOnBeforeDraw() {
18130                                            self._buffer.push(this);
18131                                        };
18132                                        pageView.onAfterDraw = function pdfViewLoadOnAfterDraw() {
18133                                            if (!isOnePageRenderedResolved) {
18134                                                isOnePageRenderedResolved = true;
18135                                                resolveOnePageRendered();
18136                                            }
18137                                        };
18138                                    };
18139                                    var firstPagePromise = pdfDocument.getPage(1);
18140                                    this.firstPagePromise = firstPagePromise;
18141                                    return firstPagePromise.then(function (pdfPage) {
18142                                        var scale = this.currentScale;
18143                                        var viewport = pdfPage.getViewport(scale * CSS_UNITS);
18144                                        for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
18145                                            var textLayerFactory = null;
18146                                            if (!pdfjsLib.PDFJS.disableTextLayer) {
18147                                                textLayerFactory = this;
18148                                            }
18149                                            var pageView = new PDFPageView({
18150                                                container: this.viewer,
18151                                                eventBus: this.eventBus,
18152                                                id: pageNum,
18153                                                scale: scale,
18154                                                defaultViewport: viewport.clone(),
18155                                                renderingQueue: this.renderingQueue,
18156                                                textLayerFactory: textLayerFactory,
18157                                                annotationLayerFactory: this,
18158                                                enhanceTextSelection: this.enhanceTextSelection,
18159                                                renderInteractiveForms: this.renderInteractiveForms,
18160                                                renderer: this.renderer
18161                                            });
18162                                            bindOnAfterAndBeforeDraw(pageView);
18163                                            this._pages.push(pageView);
18164                                        }
18165                                        var linkService = this.linkService;
18166                                        onePageRendered.then(function () {
18167                                            if (!pdfjsLib.PDFJS.disableAutoFetch) {
18168                                                var getPagesLeft = pagesCount;
18169                                                for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
18170                                                    pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
18171                                                        var pageView = self._pages[pageNum - 1];
18172                                                        if (!pageView.pdfPage) {
18173                                                            pageView.setPdfPage(pdfPage);
18174                                                        }
18175                                                        linkService.cachePageRef(pageNum, pdfPage.ref);
18176                                                        getPagesLeft--;
18177                                                        if (!getPagesLeft) {
18178                                                            resolvePagesPromise();
18179                                                        }
18180                                                    }.bind(null, pageNum));
18181                                                }
18182                                            } else {
18183                                                resolvePagesPromise();
18184                                            }
18185                                        });
18186                                        self.eventBus.dispatch('pagesinit', {source: self});
18187                                        if (this.defaultRenderingQueue) {
18188                                            this.update();
18189                                        }
18190                                        if (this.findController) {
18191                                            this.findController.resolveFirstPage();
18192                                        }
18193                                    }.bind(this));
18194                                },
18195                                setPageLabels: function PDFViewer_setPageLabels(labels) {
18196                                    if (!this.pdfDocument) {
18197                                        return;
18198                                    }
18199                                    if (!labels) {
18200                                        this._pageLabels = null;
18201                                    } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
18202                                        this._pageLabels = null;
18203                                        console.error('PDFViewer_setPageLabels: Invalid page labels.');
18204                                    } else {
18205                                        this._pageLabels = labels;
18206                                    }
18207                                    for (var i = 0, ii = this._pages.length; i < ii; i++) {
18208                                        var pageView = this._pages[i];
18209                                        var label = this._pageLabels && this._pageLabels[i];
18210                                        pageView.setPageLabel(label);
18211                                    }
18212                                },
18213                                _resetView: function () {
18214                                    this._pages = [];
18215                                    this._currentPageNumber = 1;
18216                                    this._currentScale = UNKNOWN_SCALE;
18217                                    this._currentScaleValue = null;
18218                                    this._pageLabels = null;
18219                                    this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
18220                                    this._location = null;
18221                                    this._pagesRotation = 0;
18222                                    this._pagesRequests = [];
18223                                    this._pageViewsReady = false;
18224                                    this.viewer.textContent = '';
18225                                },
18226                                _scrollUpdate: function PDFViewer_scrollUpdate() {
18227                                    if (this.pagesCount === 0) {
18228                                        return;
18229                                    }
18230                                    this.update();
18231                                    for (var i = 0, ii = this._pages.length; i < ii; i++) {
18232                                        this._pages[i].updatePosition();
18233                                    }
18234                                },
18235                                _setScaleDispatchEvent: function pdfViewer_setScaleDispatchEvent(newScale, newValue, preset) {
18236                                    var arg = {
18237                                        source: this,
18238                                        scale: newScale,
18239                                        presetValue: preset ? newValue : undefined
18240                                    };
18241                                    this.eventBus.dispatch('scalechanging', arg);
18242                                    this.eventBus.dispatch('scalechange', arg);
18243                                },
18244                                _setScaleUpdatePages: function pdfViewer_setScaleUpdatePages(newScale, newValue, noScroll, preset) {
18245                                    this._currentScaleValue = newValue.toString();
18246                                    if (isSameScale(this._currentScale, newScale)) {
18247                                        if (preset) {
18248                                            this._setScaleDispatchEvent(newScale, newValue, true);
18249                                        }
18250                                        return;
18251                                    }
18252                                    for (var i = 0, ii = this._pages.length; i < ii; i++) {
18253                                        this._pages[i].update(newScale);
18254                                    }
18255                                    this._currentScale = newScale;
18256                                    if (!noScroll) {
18257                                        var page = this._currentPageNumber, dest;
18258                                        if (this._location && !pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
18259                                            page = this._location.pageNumber;
18260                                            dest = [
18261                                                null,
18262                                                {name: 'XYZ'},
18263                                                this._location.left,
18264                                                this._location.top,
18265                                                null
18266                                            ];
18267                                        }
18268                                        this.scrollPageIntoView({
18269                                            pageNumber: page,
18270                                            destArray: dest,
18271                                            allowNegativeOffset: true
18272                                        });
18273                                    }
18274                                    this._setScaleDispatchEvent(newScale, newValue, preset);
18275                                    if (this.defaultRenderingQueue) {
18276                                        this.update();
18277                                    }
18278                                },
18279                                _setScale: function PDFViewer_setScale(value, noScroll) {
18280                                    var scale = parseFloat(value);
18281                                    if (scale > 0) {
18282                                        this._setScaleUpdatePages(scale, value, noScroll, false);
18283                                    } else {
18284                                        var currentPage = this._pages[this._currentPageNumber - 1];
18285                                        if (!currentPage) {
18286                                            return;
18287                                        }
18288                                        var hPadding = this.isInPresentationMode || this.removePageBorders ? 0 : SCROLLBAR_PADDING;
18289                                        var vPadding = this.isInPresentationMode || this.removePageBorders ? 0 : VERTICAL_PADDING;
18290                                        var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
18291                                        var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
18292                                        switch (value) {
18293                                            case 'page-actual':
18294                                                scale = 1;
18295                                                break;
18296                                            case 'page-width':
18297                                                scale = pageWidthScale;
18298                                                break;
18299                                            case 'page-height':
18300                                                scale = pageHeightScale;
18301                                                break;
18302                                            case 'page-fit':
18303                                                scale = Math.min(pageWidthScale, pageHeightScale);
18304                                                break;
18305                                            case 'auto':
18306                                                var isLandscape = currentPage.width > currentPage.height;
18307                                                var horizontalScale = isLandscape ? Math.min(pageHeightScale, pageWidthScale) : pageWidthScale;
18308                                                scale = Math.min(MAX_AUTO_SCALE, horizontalScale);
18309                                                break;
18310                                            default:
18311                                                console.error('PDFViewer_setScale: "' + value + '" is an unknown zoom value.');
18312                                                return;
18313                                        }
18314                                        this._setScaleUpdatePages(scale, value, noScroll, true);
18315                                    }
18316                                },
18317                                _resetCurrentPageView: function () {
18318                                    if (this.isInPresentationMode) {
18319                                        this._setScale(this._currentScaleValue, true);
18320                                    }
18321                                    var pageView = this._pages[this._currentPageNumber - 1];
18322                                    scrollIntoView(pageView.div);
18323                                },
18324                                scrollPageIntoView: function PDFViewer_scrollPageIntoView(params) {
18325                                    if (!this.pdfDocument) {
18326                                        return;
18327                                    }
18328                                    if (arguments.length > 1 || typeof params === 'number') {
18329                                        console.warn('Call of scrollPageIntoView() with obsolete signature.');
18330                                        var paramObj = {};
18331                                        if (typeof params === 'number') {
18332                                            paramObj.pageNumber = params;
18333                                        }
18334                                        if (arguments[1] instanceof Array) {
18335                                            paramObj.destArray = arguments[1];
18336                                        }
18337                                        params = paramObj;
18338                                    }
18339                                    var pageNumber = params.pageNumber || 0;
18340                                    var dest = params.destArray || null;
18341                                    var allowNegativeOffset = params.allowNegativeOffset || false;
18342                                    if (this.isInPresentationMode || !dest) {
18343                                        this._setCurrentPageNumber(pageNumber, true);
18344                                        return;
18345                                    }
18346                                    var pageView = this._pages[pageNumber - 1];
18347                                    if (!pageView) {
18348                                        console.error('PDFViewer_scrollPageIntoView: ' + 'Invalid "pageNumber" parameter.');
18349                                        return;
18350                                    }
18351                                    var x = 0, y = 0;
18352                                    var width = 0, height = 0, widthScale, heightScale;
18353                                    var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
18354                                    var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / CSS_UNITS;
18355                                    var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / CSS_UNITS;
18356                                    var scale = 0;
18357                                    switch (dest[1].name) {
18358                                        case 'XYZ':
18359                                            x = dest[2];
18360                                            y = dest[3];
18361                                            scale = dest[4];
18362                                            x = x !== null ? x : 0;
18363                                            y = y !== null ? y : pageHeight;
18364                                            break;
18365                                        case 'Fit':
18366                                        case 'FitB':
18367                                            scale = 'page-fit';
18368                                            break;
18369                                        case 'FitH':
18370                                        case 'FitBH':
18371                                            y = dest[2];
18372                                            scale = 'page-width';
18373                                            if (y === null && this._location) {
18374                                                x = this._location.left;
18375                                                y = this._location.top;
18376                                            }
18377                                            break;
18378                                        case 'FitV':
18379                                        case 'FitBV':
18380                                            x = dest[2];
18381                                            width = pageWidth;
18382                                            height = pageHeight;
18383                                            scale = 'page-height';
18384                                            break;
18385                                        case 'FitR':
18386                                            x = dest[2];
18387                                            y = dest[3];
18388                                            width = dest[4] - x;
18389                                            height = dest[5] - y;
18390                                            var hPadding = this.removePageBorders ? 0 : SCROLLBAR_PADDING;
18391                                            var vPadding = this.removePageBorders ? 0 : VERTICAL_PADDING;
18392                                            widthScale = (this.container.clientWidth - hPadding) / width / CSS_UNITS;
18393                                            heightScale = (this.container.clientHeight - vPadding) / height / CSS_UNITS;
18394                                            scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
18395                                            break;
18396                                        default:
18397                                            console.error('PDFViewer_scrollPageIntoView: \'' + dest[1].name + '\' is not a valid destination type.');
18398                                            return;
18399                                    }
18400                                    if (scale && scale !== this._currentScale) {
18401                                        this.currentScaleValue = scale;
18402                                    } else if (this._currentScale === UNKNOWN_SCALE) {
18403                                        this.currentScaleValue = DEFAULT_SCALE_VALUE;
18404                                    }
18405                                    if (scale === 'page-fit' && !dest[4]) {
18406                                        scrollIntoView(pageView.div);
18407                                        return;
18408                                    }
18409                                    var boundingRect = [
18410                                        pageView.viewport.convertToViewportPoint(x, y),
18411                                        pageView.viewport.convertToViewportPoint(x + width, y + height)
18412                                    ];
18413                                    var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
18414                                    var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
18415                                    if (!allowNegativeOffset) {
18416                                        left = Math.max(left, 0);
18417                                        top = Math.max(top, 0);
18418                                    }
18419                                    scrollIntoView(pageView.div, {
18420                                        left: left,
18421                                        top: top
18422                                    });
18423                                },
18424                                _updateLocation: function (firstPage) {
18425                                    var currentScale = this._currentScale;
18426                                    var currentScaleValue = this._currentScaleValue;
18427                                    var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
18428                                    var pageNumber = firstPage.id;
18429                                    var pdfOpenParams = '#page=' + pageNumber;
18430                                    pdfOpenParams += '&zoom=' + normalizedScaleValue;
18431                                    var currentPageView = this._pages[pageNumber - 1];
18432                                    var container = this.container;
18433                                    var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
18434                                    var intLeft = Math.round(topLeft[0]);
18435                                    var intTop = Math.round(topLeft[1]);
18436                                    pdfOpenParams += ',' + intLeft + ',' + intTop;
18437                                    this._location = {
18438                                        pageNumber: pageNumber,
18439                                        scale: normalizedScaleValue,
18440                                        top: intTop,
18441                                        left: intLeft,
18442                                        pdfOpenParams: pdfOpenParams
18443                                    };
18444                                },
18445                                update: function PDFViewer_update() {
18446                                    var visible = this._getVisiblePages();
18447                                    var visiblePages = visible.views;
18448                                    if (visiblePages.length === 0) {
18449                                        return;
18450                                    }
18451                                    var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * visiblePages.length + 1);
18452                                    this._buffer.resize(suggestedCacheSize);
18453                                    this.renderingQueue.renderHighestPriority(visible);
18454                                    var currentId = this._currentPageNumber;
18455                                    var firstPage = visible.first;
18456                                    for (var i = 0, ii = visiblePages.length, stillFullyVisible = false; i < ii; ++i) {
18457                                        var page = visiblePages[i];
18458                                        if (page.percent < 100) {
18459                                            break;
18460                                        }
18461                                        if (page.id === currentId) {
18462                                            stillFullyVisible = true;
18463                                            break;
18464                                        }
18465                                    }
18466                                    if (!stillFullyVisible) {
18467                                        currentId = visiblePages[0].id;
18468                                    }
18469                                    if (!this.isInPresentationMode) {
18470                                        this._setCurrentPageNumber(currentId);
18471                                    }
18472                                    this._updateLocation(firstPage);
18473                                    this.eventBus.dispatch('updateviewarea', {
18474                                        source: this,
18475                                        location: this._location
18476                                    });
18477                                },
18478                                containsElement: function (element) {
18479                                    return this.container.contains(element);
18480                                },
18481                                focus: function () {
18482                                    this.container.focus();
18483                                },
18484                                get isInPresentationMode() {
18485                                    return this.presentationModeState === PresentationModeState.FULLSCREEN;
18486                                },
18487                                get isChangingPresentationMode() {
18488                                    return this.presentationModeState === PresentationModeState.CHANGING;
18489                                },
18490                                get isHorizontalScrollbarEnabled() {
18491                                    return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
18492                                },
18493                                _getVisiblePages: function () {
18494                                    if (!this.isInPresentationMode) {
18495                                        return getVisibleElements(this.container, this._pages, true);
18496                                    }
18497                                    var visible = [];
18498                                    var currentPage = this._pages[this._currentPageNumber - 1];
18499                                    visible.push({
18500                                        id: currentPage.id,
18501                                        view: currentPage
18502                                    });
18503                                    return {
18504                                        first: currentPage,
18505                                        last: currentPage,
18506                                        views: visible
18507                                    };
18508                                },
18509                                cleanup: function () {
18510                                    for (var i = 0, ii = this._pages.length; i < ii; i++) {
18511                                        if (this._pages[i] && this._pages[i].renderingState !== RenderingStates.FINISHED) {
18512                                            this._pages[i].reset();
18513                                        }
18514                                    }
18515                                },
18516                                _cancelRendering: function PDFViewer_cancelRendering() {
18517                                    for (var i = 0, ii = this._pages.length; i < ii; i++) {
18518                                        if (this._pages[i]) {
18519                                            this._pages[i].cancelRendering();
18520                                        }
18521                                    }
18522                                },
18523                                _ensurePdfPageLoaded: function (pageView) {
18524                                    if (pageView.pdfPage) {
18525                                        return Promise.resolve(pageView.pdfPage);
18526                                    }
18527                                    var pageNumber = pageView.id;
18528                                    if (this._pagesRequests[pageNumber]) {
18529                                        return this._pagesRequests[pageNumber];
18530                                    }
18531                                    var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
18532                                        pageView.setPdfPage(pdfPage);
18533                                        this._pagesRequests[pageNumber] = null;
18534                                        return pdfPage;
18535                                    }.bind(this));
18536                                    this._pagesRequests[pageNumber] = promise;
18537                                    return promise;
18538                                },
18539                                forceRendering: function (currentlyVisiblePages) {
18540                                    var visiblePages = currentlyVisiblePages || this._getVisiblePages();
18541                                    var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
18542                                    if (pageView) {
18543                                        this._ensurePdfPageLoaded(pageView).then(function () {
18544                                            this.renderingQueue.renderView(pageView);
18545                                        }.bind(this));
18546                                        return true;
18547                                    }
18548                                    return false;
18549                                },
18550                                getPageTextContent: function (pageIndex) {
18551                                    return this.pdfDocument.getPage(pageIndex + 1).then(function (page) {
18552                                        return page.getTextContent({normalizeWhitespace: true});
18553                                    });
18554                                },
18555                                createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport, enhanceTextSelection) {
18556                                    return new TextLayerBuilder({
18557                                        textLayerDiv: textLayerDiv,
18558                                        eventBus: this.eventBus,
18559                                        pageIndex: pageIndex,
18560                                        viewport: viewport,
18561                                        findController: this.isInPresentationMode ? null : this.findController,
18562                                        enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
18563                                    });
18564                                },
18565                                createAnnotationLayerBuilder: function (pageDiv, pdfPage, renderInteractiveForms) {
18566                                    return new AnnotationLayerBuilder({
18567                                        pageDiv: pageDiv,
18568                                        pdfPage: pdfPage,
18569                                        renderInteractiveForms: renderInteractiveForms,
18570                                        linkService: this.linkService,
18571                                        downloadManager: this.downloadManager
18572                                    });
18573                                },
18574                                setFindController: function (findController) {
18575                                    this.findController = findController;
18576                                },
18577                                getPagesOverview: function () {
18578                                    var pagesOverview = this._pages.map(function (pageView) {
18579                                        var viewport = pageView.pdfPage.getViewport(1);
18580                                        return {
18581                                            width: viewport.width,
18582                                            height: viewport.height,
18583                                            rotation: viewport.rotation
18584                                        };
18585                                    });
18586                                    if (!this.enablePrintAutoRotate) {
18587                                        return pagesOverview;
18588                                    }
18589                                    var isFirstPagePortrait = isPortraitOrientation(pagesOverview[0]);
18590                                    return pagesOverview.map(function (size) {
18591                                        if (isFirstPagePortrait === isPortraitOrientation(size)) {
18592                                            return size;
18593                                        }
18594                                        return {
18595                                            width: size.height,
18596                                            height: size.width,
18597                                            rotation: (size.rotation + 90) % 360
18598                                        };
18599                                    });
18600                                }
18601                            };
18602                            return PDFViewer;
18603                        }();
18604                        exports.PresentationModeState = PresentationModeState;
18605                        exports.PDFViewer = PDFViewer;
18606
18607                        /***/ }),
18608                    /* 26 */
18609                    /***/ (function (module, exports, __webpack_require__) {
18610
18611                        "use strict";
18612
18613                        var uiUtils = __webpack_require__(0);
18614                        var SCROLLBAR_PADDING = uiUtils.SCROLLBAR_PADDING;
18615                        var mozL10n = uiUtils.mozL10n;
18616                        var SecondaryToolbar = function SecondaryToolbarClosure() {
18617                            function SecondaryToolbar(options, mainContainer, eventBus) {
18618                                this.toolbar = options.toolbar;
18619                                this.toggleButton = options.toggleButton;
18620                                this.toolbarButtonContainer = options.toolbarButtonContainer;
18621                                this.buttons = [
18622                                    {
18623                                        element: options.presentationModeButton,
18624                                        eventName: 'presentationmode',
18625                                        close: true
18626                                    },
18627                                    {
18628                                        element: options.openFileButton,
18629                                        eventName: 'openfile',
18630                                        close: true
18631                                    },
18632                                    {
18633                                        element: options.printButton,
18634                                        eventName: 'print',
18635                                        close: true
18636                                    },
18637                                    {
18638                                        element: options.downloadButton,
18639                                        eventName: 'download',
18640                                        close: true
18641                                    },
18642                                    {
18643                                        element: options.viewBookmarkButton,
18644                                        eventName: null,
18645                                        close: true
18646                                    },
18647                                    {
18648                                        element: options.firstPageButton,
18649                                        eventName: 'firstpage',
18650                                        close: true
18651                                    },
18652                                    {
18653                                        element: options.lastPageButton,
18654                                        eventName: 'lastpage',
18655                                        close: true
18656                                    },
18657                                    {
18658                                        element: options.pageRotateCwButton,
18659                                        eventName: 'rotatecw',
18660                                        close: false
18661                                    },
18662                                    {
18663                                        element: options.pageRotateCcwButton,
18664                                        eventName: 'rotateccw',
18665                                        close: false
18666                                    },
18667                                    {
18668                                        element: options.toggleHandToolButton,
18669                                        eventName: 'togglehandtool',
18670                                        close: true
18671                                    },
18672                                    {
18673                                        element: options.documentPropertiesButton,
18674                                        eventName: 'documentproperties',
18675                                        close: true
18676                                    }
18677                                ];
18678                                this.items = {
18679                                    firstPage: options.firstPageButton,
18680                                    lastPage: options.lastPageButton,
18681                                    pageRotateCw: options.pageRotateCwButton,
18682                                    pageRotateCcw: options.pageRotateCcwButton
18683                                };
18684                                this.mainContainer = mainContainer;
18685                                this.eventBus = eventBus;
18686                                this.opened = false;
18687                                this.containerHeight = null;
18688                                this.previousContainerHeight = null;
18689                                this.reset();
18690                                this._bindClickListeners();
18691                                this._bindHandToolListener(options.toggleHandToolButton);
18692                                this.eventBus.on('resize', this._setMaxHeight.bind(this));
18693                            }
18694                            SecondaryToolbar.prototype = {
18695                                get isOpen() {
18696                                    return this.opened;
18697                                },
18698                                setPageNumber: function SecondaryToolbar_setPageNumber(pageNumber) {
18699                                    this.pageNumber = pageNumber;
18700                                    this._updateUIState();
18701                                },
18702                                setPagesCount: function SecondaryToolbar_setPagesCount(pagesCount) {
18703                                    this.pagesCount = pagesCount;
18704                                    this._updateUIState();
18705                                },
18706                                reset: function SecondaryToolbar_reset() {
18707                                    this.pageNumber = 0;
18708                                    this.pagesCount = 0;
18709                                    this._updateUIState();
18710                                },
18711                                _updateUIState: function SecondaryToolbar_updateUIState() {
18712                                    var items = this.items;
18713                                    items.firstPage.disabled = this.pageNumber <= 1;
18714                                    items.lastPage.disabled = this.pageNumber >= this.pagesCount;
18715                                    items.pageRotateCw.disabled = this.pagesCount === 0;
18716                                    items.pageRotateCcw.disabled = this.pagesCount === 0;
18717                                },
18718                                _bindClickListeners: function SecondaryToolbar_bindClickListeners() {
18719                                    this.toggleButton.addEventListener('click', this.toggle.bind(this));
18720                                    for (var button in this.buttons) {
18721                                        var element = this.buttons[button].element;
18722                                        var eventName = this.buttons[button].eventName;
18723                                        var close = this.buttons[button].close;
18724                                        element.addEventListener('click', function (eventName, close) {
18725                                            if (eventName !== null) {
18726                                                this.eventBus.dispatch(eventName, {source: this});
18727                                            }
18728                                            if (close) {
18729                                                this.close();
18730                                            }
18731                                        }.bind(this, eventName, close));
18732                                    }
18733                                },
18734                                _bindHandToolListener: function SecondaryToolbar_bindHandToolListener(toggleHandToolButton) {
18735                                    var isHandToolActive = false;
18736                                    this.eventBus.on('handtoolchanged', function (e) {
18737                                        if (isHandToolActive === e.isActive) {
18738                                            return;
18739                                        }
18740                                        isHandToolActive = e.isActive;
18741                                        if (isHandToolActive) {
18742                                            toggleHandToolButton.title = mozL10n.get('hand_tool_disable.title', null, 'Disable hand tool');
18743                                            toggleHandToolButton.firstElementChild.textContent = mozL10n.get('hand_tool_disable_label', null, 'Disable hand tool');
18744                                        } else {
18745                                            toggleHandToolButton.title = mozL10n.get('hand_tool_enable.title', null, 'Enable hand tool');
18746                                            toggleHandToolButton.firstElementChild.textContent = mozL10n.get('hand_tool_enable_label', null, 'Enable hand tool');
18747                                        }
18748                                    });
18749                                },
18750                                open: function SecondaryToolbar_open() {
18751                                    if (this.opened) {
18752                                        return;
18753                                    }
18754                                    this.opened = true;
18755                                    this._setMaxHeight();
18756                                    this.toggleButton.classList.add('toggled');
18757                                    this.toolbar.classList.remove('hidden');
18758                                },
18759                                close: function SecondaryToolbar_close() {
18760                                    if (!this.opened) {
18761                                        return;
18762                                    }
18763                                    this.opened = false;
18764                                    this.toolbar.classList.add('hidden');
18765                                    this.toggleButton.classList.remove('toggled');
18766                                },
18767                                toggle: function SecondaryToolbar_toggle() {
18768                                    if (this.opened) {
18769                                        this.close();
18770                                    } else {
18771                                        this.open();
18772                                    }
18773                                },
18774                                _setMaxHeight: function SecondaryToolbar_setMaxHeight() {
18775                                    if (!this.opened) {
18776                                        return;
18777                                    }
18778                                    this.containerHeight = this.mainContainer.clientHeight;
18779                                    if (this.containerHeight === this.previousContainerHeight) {
18780                                        return;
18781                                    }
18782                                    this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - SCROLLBAR_PADDING) + 'px;');
18783                                    this.previousContainerHeight = this.containerHeight;
18784                                }
18785                            };
18786                            return SecondaryToolbar;
18787                        }();
18788                        exports.SecondaryToolbar = SecondaryToolbar;
18789
18790                        /***/ }),
18791                    /* 27 */
18792                    /***/ (function (module, exports, __webpack_require__) {
18793
18794                        "use strict";
18795
18796                        var domEvents = __webpack_require__(2);
18797                        var pdfjsLib = __webpack_require__(1);
18798                        var EXPAND_DIVS_TIMEOUT = 300;
18799                        var TextLayerBuilder = function TextLayerBuilderClosure() {
18800                            function TextLayerBuilder(options) {
18801                                this.textLayerDiv = options.textLayerDiv;
18802                                this.eventBus = options.eventBus || domEvents.getGlobalEventBus();
18803                                this.textContent = null;
18804                                this.renderingDone = false;
18805                                this.pageIdx = options.pageIndex;
18806                                this.pageNumber = this.pageIdx + 1;
18807                                this.matches = [];
18808                                this.viewport = options.viewport;
18809                                this.textDivs = [];
18810                                this.findController = options.findController || null;
18811                                this.textLayerRenderTask = null;
18812                                this.enhanceTextSelection = options.enhanceTextSelection;
18813                                this._bindMouse();
18814                            }
18815                            TextLayerBuilder.prototype = {
18816                                _finishRendering: function TextLayerBuilder_finishRendering() {
18817                                    this.renderingDone = true;
18818                                    if (!this.enhanceTextSelection) {
18819                                        var endOfContent = document.createElement('div');
18820                                        endOfContent.className = 'endOfContent';
18821                                        this.textLayerDiv.appendChild(endOfContent);
18822                                    }
18823                                    this.eventBus.dispatch('textlayerrendered', {
18824                                        source: this,
18825                                        pageNumber: this.pageNumber,
18826                                        numTextDivs: this.textDivs.length
18827                                    });
18828                                },
18829                                render: function TextLayerBuilder_render(timeout) {
18830                                    if (!this.textContent || this.renderingDone) {
18831                                        return;
18832                                    }
18833                                    this.cancel();
18834                                    this.textDivs = [];
18835                                    var textLayerFrag = document.createDocumentFragment();
18836                                    this.textLayerRenderTask = pdfjsLib.renderTextLayer({
18837                                        textContent: this.textContent,
18838                                        container: textLayerFrag,
18839                                        viewport: this.viewport,
18840                                        textDivs: this.textDivs,
18841                                        timeout: timeout,
18842                                        enhanceTextSelection: this.enhanceTextSelection
18843                                    });
18844                                    this.textLayerRenderTask.promise.then(function () {
18845                                        this.textLayerDiv.appendChild(textLayerFrag);
18846                                        this._finishRendering();
18847                                        this.updateMatches();
18848                                    }.bind(this), function (reason) {
18849                                    });
18850                                },
18851                                cancel: function TextLayerBuilder_cancel() {
18852                                    if (this.textLayerRenderTask) {
18853                                        this.textLayerRenderTask.cancel();
18854                                        this.textLayerRenderTask = null;
18855                                    }
18856                                },
18857                                setTextContent: function TextLayerBuilder_setTextContent(textContent) {
18858                                    this.cancel();
18859                                    this.textContent = textContent;
18860                                },
18861                                convertMatches: function TextLayerBuilder_convertMatches(matches, matchesLength) {
18862                                    var i = 0;
18863                                    var iIndex = 0;
18864                                    var bidiTexts = this.textContent.items;
18865                                    var end = bidiTexts.length - 1;
18866                                    var queryLen = this.findController === null ? 0 : this.findController.state.query.length;
18867                                    var ret = [];
18868                                    if (!matches) {
18869                                        return ret;
18870                                    }
18871                                    for (var m = 0, len = matches.length; m < len; m++) {
18872                                        var matchIdx = matches[m];
18873                                        while (i !== end && matchIdx >= iIndex + bidiTexts[i].str.length) {
18874                                            iIndex += bidiTexts[i].str.length;
18875                                            i++;
18876                                        }
18877                                        if (i === bidiTexts.length) {
18878                                            console.error('Could not find a matching mapping');
18879                                        }
18880                                        var match = {
18881                                            begin: {
18882                                                divIdx: i,
18883                                                offset: matchIdx - iIndex
18884                                            }
18885                                        };
18886                                        if (matchesLength) {
18887                                            matchIdx += matchesLength[m];
18888                                        } else {
18889                                            matchIdx += queryLen;
18890                                        }
18891                                        while (i !== end && matchIdx > iIndex + bidiTexts[i].str.length) {
18892                                            iIndex += bidiTexts[i].str.length;
18893                                            i++;
18894                                        }
18895                                        match.end = {
18896                                            divIdx: i,
18897                                            offset: matchIdx - iIndex
18898                                        };
18899                                        ret.push(match);
18900                                    }
18901                                    return ret;
18902                                },
18903                                renderMatches: function TextLayerBuilder_renderMatches(matches) {
18904                                    if (matches.length === 0) {
18905                                        return;
18906                                    }
18907                                    var bidiTexts = this.textContent.items;
18908                                    var textDivs = this.textDivs;
18909                                    var prevEnd = null;
18910                                    var pageIdx = this.pageIdx;
18911                                    var isSelectedPage = this.findController === null ? false : pageIdx === this.findController.selected.pageIdx;
18912                                    var selectedMatchIdx = this.findController === null ? -1 : this.findController.selected.matchIdx;
18913                                    var highlightAll = this.findController === null ? false : this.findController.state.highlightAll;
18914                                    var infinity = {
18915                                        divIdx: -1,
18916                                        offset: undefined
18917                                    };
18918                                    function beginText(begin, className) {
18919                                        var divIdx = begin.divIdx;
18920                                        textDivs[divIdx].textContent = '';
18921                                        appendTextToDiv(divIdx, 0, begin.offset, className);
18922                                    }
18923                                    function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
18924                                        var div = textDivs[divIdx];
18925                                        var content = bidiTexts[divIdx].str.substring(fromOffset, toOffset);
18926                                        var node = document.createTextNode(content);
18927                                        if (className) {
18928                                            var span = document.createElement('span');
18929                                            span.className = className;
18930                                            span.appendChild(node);
18931                                            div.appendChild(span);
18932                                            return;
18933                                        }
18934                                        div.appendChild(node);
18935                                    }
18936                                    var i0 = selectedMatchIdx, i1 = i0 + 1;
18937                                    if (highlightAll) {
18938                                        i0 = 0;
18939                                        i1 = matches.length;
18940                                    } else if (!isSelectedPage) {
18941                                        return;
18942                                    }
18943                                    for (var i = i0; i < i1; i++) {
18944                                        var match = matches[i];
18945                                        var begin = match.begin;
18946                                        var end = match.end;
18947                                        var isSelected = isSelectedPage && i === selectedMatchIdx;
18948                                        var highlightSuffix = isSelected ? ' selected' : '';
18949                                        if (this.findController) {
18950                                            this.findController.updateMatchPosition(pageIdx, i, textDivs, begin.divIdx);
18951                                        }
18952                                        if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
18953                                            if (prevEnd !== null) {
18954                                                appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
18955                                            }
18956                                            beginText(begin);
18957                                        } else {
18958                                            appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
18959                                        }
18960                                        if (begin.divIdx === end.divIdx) {
18961                                            appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix
18961);
18962                                        } else {
18963                                            appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
18964                                            for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
18965                                                textDivs[n0].className = 'highlight middle' + highlightSuffix;
18966                                            }
18967                                            beginText(end, 'highlight end' + highlightSuffix);
18968                                        }
18969                                        prevEnd = end;
18970                                    }
18971                                    if (prevEnd) {
18972                                        appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
18973                                    }
18974                                },
18975                                updateMatches: function TextLayerBuilder_updateMatches() {
18976                                    if (!this.renderingDone) {
18977                                        return;
18978                                    }
18979                                    var matches = this.matches;
18980                                    var textDivs = this.textDivs;
18981                                    var bidiTexts = this.textContent.items;
18982                                    var clearedUntilDivIdx = -1;
18983                                    for (var i = 0, len = matches.length; i < len; i++) {
18984                                        var match = matches[i];
18985                                        var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
18986                                        for (var n = begin, end = match.end.divIdx; n <= end; n++) {
18987                                            var div = textDivs[n];
18988                                            div.textContent = bidiTexts[n].str;
18989                                            div.className = '';
18990                                        }
18991                                        clearedUntilDivIdx = match.end.divIdx + 1;
18992                                    }
18993                                    if (this.findController === null || !this.findController.active) {
18994                                        return;
18995                                    }
18996                                    var pageMatches, pageMatchesLength;
18997                                    if (this.findController !== null) {
18998                                        pageMatches = this.findController.pageMatches[this.pageIdx] || null;
18999                                        pageMatchesLength = this.findController.pageMatchesLength ? this.findController.pageMatchesLength[this.pageIdx] || null : null;
19000                                    }
19001                                    this.matches = this.convertMatches(pageMatches, pageMatchesLength);
19002                                    this.renderMatches(this.matches);
19003                                },
19004                                _bindMouse: function TextLayerBuilder_bindMouse() {
19005                                    var div = this.textLayerDiv;
19006                                    var self = this;
19007                                    var expandDivsTimer = null;
19008                                    div.addEventListener('mousedown', function (e) {
19009                                        if (self.enhanceTextSelection && self.textLayerRenderTask) {
19010                                            self.textLayerRenderTask.expandTextDivs(true);
19011                                            if (expandDivsTimer) {
19012                                                clearTimeout(expandDivsTimer);
19013                                                expandDivsTimer = null;
19014                                            }
19015                                            return;
19016                                        }
19017                                        var end = div.querySelector('.endOfContent');
19018                                        if (!end) {
19019                                            return;
19020                                        }
19021                                        var adjustTop = e.target !== div;
19022                                        adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
19023                                        if (adjustTop) {
19024                                            var divBounds = div.getBoundingClientRect();
19025                                            var r = Math.max(0, (e.pageY - divBounds.top) / divBounds.height);
19026                                            end.style.top = (r * 100).toFixed(2) + '%';
19027                                        }
19028                                        end.classList.add('active');
19029                                    });
19030                                    div.addEventListener('mouseup', function (e) {
19031                                        if (self.enhanceTextSelection && self.textLayerRenderTask) {
19032                                            expandDivsTimer = setTimeout(function () {
19033                                                if (self.textLayerRenderTask) {
19034                                                    self.textLayerRenderTask.expandTextDivs(false);
19035                                                }
19036                                                expandDivsTimer = null;
19037                                            }, EXPAND_DIVS_TIMEOUT);
19038                                            return;
19039                                        }
19040                                        var end = div.querySelector('.endOfContent');
19041                                        if (!end) {
19042                                            return;
19043                                        }
19044                                        end.style.top = '';
19045                                        end.classList.remove('active');
19046                                    });
19047                                }
19048                            };
19049                            return TextLayerBuilder;
19050                        }();
19051                        function DefaultTextLayerFactory() {
19052                        }
19053                        DefaultTextLayerFactory.prototype = {
19054                            createTextLayerBuilder: function (textLayerDiv, pageIndex, viewport, enhanceTextSelection) {
19055                                return new TextLayerBuilder({
19056                                    textLayerDiv: textLayerDiv,
19057                                    pageIndex: pageIndex,
19058                                    viewport: viewport,
19059                                    enhanceTextSelection: enhanceTextSelection
19060                                });
19061                            }
19062                        };
19063                        exports.TextLayerBuilder = TextLayerBuilder;
19064                        exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
19065
19066                        /***/ }),
19067                    /* 28 */
19068                    /***/ (function (module, exports, __webpack_require__) {
19069
19070                        "use strict";
19071
19072                        var uiUtils = __webpack_require__(0);
19073                        var mozL10n = uiUtils.mozL10n;
19074                        var noContextMenuHandler = uiUtils.noContextMenuHandler;
19075                        var animationStarted = uiUtils.animationStarted;
19076                        var localized = uiUtils.localized;
19077                        var DEFAULT_SCALE_VALUE = uiUtils.DEFAULT_SCALE_VALUE;
19078                        var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
19079                        var MIN_SCALE = uiUtils.MIN_SCALE;
19080                        var MAX_SCALE = uiUtils.MAX_SCALE;
19081                        var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
19082                        var SCALE_SELECT_CONTAINER_PADDING = 8;
19083                        var SCALE_SELECT_PADDING = 22;
19084                        var Toolbar = function ToolbarClosure() {
19085                            function Toolbar(options, mainContainer, eventBus) {
19086                                this.toolbar = options.container;
19087                                this.mainContainer = mainContainer;
19088                                this.eventBus = eventBus;
19089                                this.items = options;
19090                                this._wasLocalized = false;
19091                                this.reset();
19092                                this._bindListeners();
19093                            }
19094                            Toolbar.prototype = {
19095                                setPageNumber: function (pageNumber, pageLabel) {
19096                                    this.pageNumber = pageNumber;
19097                                    this.pageLabel = pageLabel;
19098                                    this._updateUIState(false);
19099                                },
19100                                setPagesCount: function (pagesCount, hasPageLabels) {
19101                                    this.pagesCount = pagesCount;
19102                                    this.hasPageLabels = hasPageLabels;
19103                                    this._updateUIState(true);
19104                                },
19105                                setPageScale: function (pageScaleValue, pageScale) {
19106                                    this.pageScaleValue = pageScaleValue;
19107                                    this.pageScale = pageScale;
19108                                    this._updateUIState(false);
19109                                },
19110                                reset: function () {
19111                                    this.pageNumber = 0;
19112                                    this.pageLabel = null;
19113                                    this.hasPageLabels = false;
19114                                    this.pagesCount = 0;
19115                                    this.pageScaleValue = DEFAULT_SCALE_VALUE;
19116                                    this.pageScale = DEFAULT_SCALE;
19117                                    this._updateUIState(true);
19118                                },
19119                                _bindListeners: function Toolbar_bindClickListeners() {
19120                                    var eventBus = this.eventBus;
19121                                    var self = this;
19122                                    var items = this.items;
19123                                    items.previous.addEventListener('click', function () {
19124                                        eventBus.dispatch('previouspage');
19125                                    });
19126                                    items.next.addEventListener('click', function () {
19127                                        eventBus.dispatch('nextpage');
19128                                    });
19129                                    items.zoomIn.addEventListener('click', function () {
19130                                        eventBus.dispatch('zoomin');
19131                                    });
19132                                    items.zoomOut.addEventListener('click', function () {
19133                                        eventBus.dispatch('zoomout');
19134                                    });
19135                                    items.pageNumber.addEventListener('click', function () {
19136                                        this.select();
19137                                    });
19138                                    items.pageNumber.addEventListener('change', function () {
19139                                        eventBus.dispatch('pagenumberchanged', {
19140                                            source: self,
19141                                            value: this.value
19142                                        });
19143                                    });
19144                                    items.scaleSelect.addEventListener('change', function () {
19145                                        if (this.value === 'custom') {
19146                                            return;
19147                                        }
19148                                        eventBus.dispatch('scalechanged', {
19149                                            source: self,
19150                                            value: this.value
19151                                        });
19152                                    });
19153                                    items.presentationModeButton.addEventListener('click', function (e) {
19154                                        eventBus.dispatch('presentationmode');
19155                                    });
19156                                    items.openFile.addEventListener('click', function (e) {
19157                                        eventBus.dispatch('openfile');
19158                                    });
19159                                    items.print.addEventListener('click', function (e) {
19160                                        eventBus.dispatch('print');
19161                                    });
19162                                    items.download.addEventListener('click', function (e) {
19163                                        eventBus.dispatch('download');
19164                                    });
19165                                    items.scaleSelect.oncontextmenu = noContextMenuHandler;
19166                                    localized.then(this._localized.bind(this));
19167                                },
19168                                _localized: function Toolbar_localized() {
19169                                    this._wasLocalized = true;
19170                                    this._adjustScaleWidth();
19171                                    this._updateUIState(true);
19172                                },
19173                                _updateUIState: function Toolbar_updateUIState(resetNumPages) {
19174                                    function selectScaleOption(value, scale) {
19175                                        var options = items.scaleSelect.options;
19176                                        var predefinedValueFound = false;
19177                                        for (var i = 0, ii = options.length; i < ii; i++) {
19178                                            var option = options[i];
19179                                            if (option.value !== value) {
19180                                                option.selected = false;
19181                                                continue;
19182                                            }
19183                                            option.selected = true;
19184                                            predefinedValueFound = true;
19185                                        }
19186                                        if (!predefinedValueFound) {
19187                                            var customScale = Math.round(scale * 10000) / 100;
19188                                            items.customScaleOption.textContent = mozL10n.get('page_scale_percent', {scale: customScale}, '{{scale}}%');
19189                                            items.customScaleOption.selected = true;
19190                                        }
19191                                    }
19192                                    if (!this._wasLocalized) {
19193                                        return;
19194                                    }
19195                                    var pageNumber = this.pageNumber;
19196                                    var scaleValue = (this.pageScaleValue || this.pageScale).toString();
19197                                    var scale = this.pageScale;
19198                                    var items = this.items;
19199                                    var pagesCount = this.pagesCount;
19200                                    if (resetNumPages) {
19201                                        if (this.hasPageLabels) {
19202                                            items.pageNumber.type = 'text';
19203                                        } else {
19204                                            items.pageNumber.type = 'number';
19205                                            items.numPages.textContent = mozL10n.get('of_pages', {pagesCount: pagesCount}, 'of {{pagesCount}}');
19206                                        }
19207                                        items.pageNumber.max = pagesCount;
19208                                    }
19209                                    if (this.hasPageLabels) {
19210                                        items.pageNumber.value = this.pageLabel;
19211                                        items.numPages.textContent = mozL10n.get('page_of_pages', {
19212                                            pageNumber: pageNumber,
19213                                            pagesCount: pagesCount
19214                                        }, '({{pageNumber}} of {{pagesCount}})');
19215                                    } else {
19216                                        items.pageNumber.value = pageNumber;
19217                                    }
19218                                    items.previous.disabled = pageNumber <= 1;
19219                                    items.next.disabled = pageNumber >= pagesCount;
19220                                    items.zoomOut.disabled = scale <= MIN_SCALE;
19221                                    items.zoomIn.disabled = scale >= MAX_SCALE;
19222                                    selectScaleOption(scaleValue, scale);
19223                                },
19224                                updateLoadingIndicatorState: function Toolbar_updateLoadingIndicatorState(loading) {
19225                                    var pageNumberInput = this.items.pageNumber;
19226                                    if (loading) {
19227                                        pageNumberInput.classList.add(PAGE_NUMBER_LOADING_INDICATOR);
19228                                    } else {
19229                                        pageNumberInput.classList.remove(PAGE_NUMBER_LOADING_INDICATOR);
19230                                    }
19231                                },
19232                                _adjustScaleWidth: function Toolbar_adjustScaleWidth() {
19233                                    var container = this.items.scaleSelectContainer;
19234                                    var select = this.items.scaleSelect;
19235                                    animationStarted.then(function () {
19236                                        if (container.clientWidth === 0) {
19237                                            container.setAttribute('style', 'display: inherit;');
19238                                        }
19239                                        if (container.clientWidth > 0) {
19240                                            select.setAttribute('style', 'min-width: inherit;');
19241                                            var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
19242                                            select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
19243                                            container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
19244                                        }
19245                                    });
19246                                }
19247                            };
19248                            return Toolbar;
19249                        }();
19250                        exports.Toolbar = Toolbar;
19251
19252                        /***/ }),
19253                    /* 29 */
19254                    /***/ (function (module, exports, __webpack_require__) {
19255
19256                        "use strict";
19257
19258                        var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
19259                        var ViewHistory = function ViewHistoryClosure() {
19260                            function ViewHistory(fingerprint, cacheSize) {
19261                                this.fingerprint = fingerprint;
19262                                this.cacheSize = cacheSize || DEFAULT_VIEW_HISTORY_CACHE_SIZE;
19263                                this.isInitializedPromiseResolved = false;
vendor: 7,277 bytes, lines 19264-19381
19264                                this.initializedPromise = this._readFromStorage().then(function (databaseStr) {
19265                                    this.isInitializedPromiseResolved = true;
19266                                    var database = JSON.parse(databaseStr || '{}');
19267                                    if (!('files' in database)) {
19268                                        database.files = [];
19269                                    }
19270                                    if (database.files.length >= this.cacheSize) {
19271                                        database.files.shift();
19272                                    }
19273                                    var index;
19274                                    for (var i = 0, length = database.files.length; i < length; i++) {
19275                                        var branch = database.files[i];
19276                                        if (branch.fingerprint === this.fingerprint) {
19277                                            index = i;
19278                                            break;
19279                                        }
19280                                    }
19281                                    if (typeof index !== 'number') {
19282                                        index = database.files.push({fingerprint: this.fingerprint}) - 1;
19283                                    }
19284                                    this.file = database.files[index];
19285                                    this.database = database;
19286                                }.bind(this));
19287                            }
19288                            ViewHistory.prototype = {
19289                                _writeToStorage: function ViewHistory_writeToStorage() {
19290                                    return new Promise(function (resolve) {
19291                                        var databaseStr = JSON.stringify(this.database);
19292                                        localStorage.setItem('pdfjs.history', databaseStr);
19293                                        resolve();
19294                                    }.bind(this));
19295                                },
19296                                _readFromStorage: function ViewHistory_readFromStorage() {
19297                                    return new Promise(function (resolve) {
19298                                        var value = localStorage.getItem('pdfjs.history');
19299                                        if (!value) {
19300                                            var databaseStr = localStorage.getItem('database');
19301                                            if (databaseStr) {
19302                                                try {
19303                                                    var database = JSON.parse(databaseStr);
19304                                                    if (typeof database.files[0].fingerprint === 'string') {
19305                                                        localStorage.setItem('pdfjs.history', databaseStr);
19306                                                        localStorage.removeItem('database');
19307                                                        value = databaseStr;
19308                                                    }
19309                                                } catch (ex) {
19310                                                }
19311                                            }
19312                                        }
19313                                        resolve(value);
19314                                    });
19315                                },
19316                                set: function ViewHistory_set(name, val) {
19317                                    if (!this.isInitializedPromiseResolved) {
19318                                        return;
19319                                    }
19320                                    this.file[name] = val;
19321                                    return this._writeToStorage();
19322                                },
19323                                setMultiple: function ViewHistory_setMultiple(properties) {
19324                                    if (!this.isInitializedPromiseResolved) {
19325                                        return;
19326                                    }
19327                                    for (var name in properties) {
19328                                        this.file[name] = properties[name];
19329                                    }
19330                                    return this._writeToStorage();
19331                                },
19332                                get: function ViewHistory_get(name, defaultValue) {
19333                                    if (!this.isInitializedPromiseResolved) {
19334                                        return defaultValue;
19335                                    }
19336                                    return this.file[name] || defaultValue;
19337                                }
19338                            };
19339                            return ViewHistory;
19340                        }();
19341                        exports.ViewHistory = ViewHistory;
19342
19343                        /***/ }),
19344                    /* 30 */
19345                    /***/ (function (module, exports, __webpack_require__) {
19346
19347                        "use strict";
19348
19349                        var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
19350                        ;
19351                        var pdfjsWebApp;
19352                        {
19353                            pdfjsWebApp = __webpack_require__(6);
19354                        }
19355                        ;
19356                        ;
19357                        {
19358                            __webpack_require__(9);
19359                        }
19360                        function getViewerConfiguration() {
19361                            return {
19362                                appContainer: document.body,
19363                                mainContainer: document.getElementById('viewerContainer'),
19364                                viewerContainer: document.getElementById('viewer'),
19365                                eventBus: null,
19366                                toolbar: {
19367                                    container: document.getElementById('toolbarViewer'),
19368                                    numPages: document.getElementById('numPages'),
19369                                    pageNumber: document.getElementById('pageNumber'),
19370                                    scaleSelectContainer: document.getElementById('scaleSelectContainer'),
19371                                    scaleSelect: document.getElementById('scaleSelect'),
19372                                    customScaleOption: document.getElementById('customScaleOption'),
19373                                    previous: document.getElementById('previous'),
19374                                    next: document.getElementById('next'),
19375                                    zoomIn: document.getElementById('zoomIn'),
19376                                    zoomOut: document.getElementById('zoomOut'),
19377                                    viewFind: document.getElementById('viewFind'),
19378                                    openFile: document.getElementById('openFile'),
19379                                    print: document.getElementById('print'),
19380                                    presentationModeButton: document.getElementById('presentationMode'),
19381                                    download: document.getElementById('download'),
19382                                    viewBookmark: document.getElementById('viewBookmark')
19383                                },
19384                                secondaryToolbar: {
19385                                    toolbar: document.getElementById('secondaryToolbar'),
19386                                    toggleButton: document.getElementById('secondaryToolbarToggle'),
19387                                    toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
19388                                    presentationModeButton: document.getElementById('secondaryPresentationMode'),
19389                                    openFileButton: document.getElementById('secondaryOpenFile'),
19390                                    printButton: document.getElementById('secondaryPrint'),
19391                                    downloadButton: document.getElementById('secondaryDownload'),
19392                                    viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
19393                                    firstPageButton: document.getElementById('firstPage'),
19394                                    lastPageButton: document.getElementById('lastPage'),
19395                                    pageRotateCwButton: document.getElementById('pageRotateCw'),
19396                                    pageRotateCcwButton: document.getElementById('pageRotateCcw'),
19397                                    toggleHandToolButton: document.getElementById('toggleHandTool'),
19398                                    documentPropertiesButton: document.getElementById('documentProperties')
19399                                },
19400                                fullscreen: {
19401                                    contextFirstPage: document.getElementById('contextFirstPage'),
19402                                    contextLastPage: document.getElementById('contextLastPage'),
19403                                    contextPageRotateCw: document.getElementById('contextPageRotateCw'),
19404                                    contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
19405                                },
19406                                sidebar: {
19407                                    mainContainer: document.getElementById('mainContainer'),
19408                                    outerContainer: document.getElementById('outerContainer'),
19409                                    toggleButton: document.getElementById('sidebarToggle'),
19410                                    thumbnailButton: document.getElementById('viewThumbnail'),
19411                                    outlineButton: document.getElementById('viewOutline'),
19412                                    attachmentsButton: document.getElementById('viewAttachments'),
19413                                    thumbnailView: document.getElementById('thumbnailView'),
19414                                    outlineView: document.getElementById('outlineView'),
19415                                    attachmentsView: document.getElementById('attachmentsView')
19416                                },
19417                                findBar: {
19418                                    bar: document.getElementById('findbar'),
19419                                    toggleButton: document.getElementById('viewFind'),
19420                                    findField: document.getElementById('findInput'),
19421                                    highlightAllCheckbox: document.getElementById('findHighlightAll'),
19422                                    caseSensitiveCheckbox: document.getElementById('findMatchCase'),
19423                                    findMsg: document.getElementById('findMsg'),
19424                                    findResultsCount: document.getElementById('findResultsCount'),
19425                                    findStatusIcon: document.getElementById('findStatusIcon'),
19426                                    findPreviousButton: document.getElementById('findPrevious'),
19427                                    findNextButton: document.getElementById('findNext')
19428                                },
19429                                passwordOverlay: {
19430                                    overlayName: 'passwordOverlay',
19431                                    container: document.getElementById('passwordOverlay'),
19432                                    label: document.getElementById('passwordText'),
19433                                    input: document.getElementById('password'),
19434                                    submitButton: document.getElementById('passwordSubmit'),
19435                                    cancelButton: document.getElementById('passwordCancel')
19436                                },
19437                                documentProperties: {
19438                                    overlayName: 'documentPropertiesOverlay',
19439                                    container: document.getElementById('documentPropertiesOverlay'),
19440                                    closeButton: document.getElementById('documentPropertiesClose'),
19441                                    fields: {
19442                                        'fileName': document.getElementById('fileNameField'),
19443                                        'fileSize': document.getElementById('fileSizeField'),
19444                                        'title': document.getElementById('titleField'),
19445                                        'author': document.getElementById('authorField'),
19446                                        'subject': document.getElementById('subjectField'),
19447                                        'keywords': document.getElementById('keywordsField'),
19448                                        'creationDate': document.getElementById('creationDateField'),
19449                                        'modificationDate': document.getElementById('modificationDateField'),
19450                                        'creator': document.getElementById('creatorField'),
19451                                        'producer': document.getElementById('producerField'),
19452                                        'version': document.getElementById('versionField'),
19453                                        'pageCount': document.getElementById('pageCountField')
19454                                    }
19455                                },
19456                                errorWrapper: {
19457                                    container: document.getElementById('errorWrapper'),
19458                                    errorMessage: document.getElementById('errorMessage'),
19459                                    closeButton: document.getElementById('errorClose'),
19460                                    errorMoreInfo: document.getElementById('errorMoreInfo'),
19461                                    moreInfoButton: document.getElementById('errorShowMore'),
19462                                    lessInfoButton: document.getElementById('errorShowLess')
19463                                },
19464                                printContainer: document.getElementById('printContainer'),
19465                                openFileInputName: 'fileInput',
19466                                debuggerScriptPath: './debugger.js',
19467                                defaultUrl: DEFAULT_URL
19468                            };
19469                        }
19470                        function webViewerLoad() {
19471                            var config = getViewerConfiguration();
19472                            window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
19473                            pdfjsWebApp.PDFViewerApplication.run(config);
19474                        }
19475                        if (document.readyState === 'interactive' || document.readyState === 'complete') {
19476                            webViewerLoad();
19477                        } else {
19478                            PDFJS.webViewerLoad = function (src) {
19479                                DEFAULT_URL = src;
19480                                webViewerLoad();
19481                            };
19482                        }
19483
19484                        /***/ })
19485                            /******/]);

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.