diff --git a/wp/wp-content/plugins/wp-media-folder/assets/css/style.css b/wp/wp-content/plugins/wp-media-folder/assets/css/style.css index d4b03d36..d0e0248d 100644 --- a/wp/wp-content/plugins/wp-media-folder/assets/css/style.css +++ b/wp/wp-content/plugins/wp-media-folder/assets/css/style.css @@ -335,6 +335,11 @@ column-gap: 10px; } +.edit-php .wpmf-folder-actions { + width: calc(100% - 40px); + margin: 0 10px 10px 10px; +} + .media-frame .wpmf-folder-actions { width: calc(50% - 25px); } @@ -771,7 +776,7 @@ padding: 0 10px !important; background: #0073ab !important; color: #ffffff; - width: 186px !important; + width: 210px !important; height: 40px !important; overflow: hidden; text-overflow: ellipsis; @@ -3759,4 +3764,130 @@ svg.wpmf-icon-category { .table-view-list.media .media-icon.image-icon img{ width: 60px!important; height: 60px!important; +} + +.wpmf-folder-post-type { + position: fixed !important; + top: 32px; + left: 160px; + bottom: 0; + box-sizing: border-box; + z-index: 1; + direction: ltr; +} +body.folded .wpmf-folder-post-type { + left: 36px!important; +} +.wpmf-folder-post-type .wpmf-main-tree { + padding: 15px 0 0; + transition: all .15s linear; + -webkit-transition: all .15s linear; + -moz-transition: all .15s linear; +} +.wpmf-folder-post-type .wpmf-main-tree-resize { + top: 65px; +} +.wpmf-folder-post-type .wpmf-tree-actions { + justify-content: center; +} + +.wpmf-folder-post-type .wpmf-new-folder { + cursor: pointer; +} + +.wp-list-table tr td .wpmf-folder-move-file { + vertical-align: middle; + opacity: 0; + cursor: move; +} + +.wp-list-table tr:hover td .wpmf-folder-move-file { + opacity: 1; +} + +.wp-list-table tr td .wpmf-folder-move-file .wpmf-folder-item { + display: none; +} + +.wpmf-folder-post-type .wpmf-main-tree li > .wpmf-item .wpmf-item-count-all { + display: inline-block; +} + +#wpmf_folder_move { + width: 20px!important; +} + +.wpmf-folder-type-metabox { + margin-top: 0; +} +.wpmf-folder-type-metabox .tabs-panel { + border: none!important; + padding: 0!important; +} +[id^="taxonomy_wpmf-folder-type-"][id$="_metabox"] h2 { + padding: 16px!important; + font-weight: 500!important; + font-size: 13px!important; +} +[id^="taxonomy_wpmf-folder-type-"][id$="_metabox"] .inside { + margin: 0!important; + padding: 0 16px 16px!important; +} +[id^="taxonomy_wpmf-folder-type-"][id$="_metabox"] .categorychecklist li { + margin-left: 1px; +} +[id^="wpmf-folder-type-"][id$="-checklist"] { + margin: 0!important; +} +[id^="wpmf-folder-type-"][id$="-all"] #genesis-category-checklist-toggle { + display: none!important; +} + +.wpmf-item-icon.wpmf-item-unassigned { + margin-left: 3px; +} + +.wpmf-hide-show-buttons { + position: absolute; + top: 22px; + right: -12px; + cursor: pointer; +} +.wpmf-hide-folder-tree .wpmf-hide-show-buttons { + right: -22px; +} +.wpmf-hide-show-buttons .toggle-buttons { + display: none; +} +.wpmf-hide-show-buttons .toggle-buttons .dashicons { + color: transparent; + width: 24px; + height: 24px; +} +.wpmf-hide-show-buttons .toggle-buttons.active { + display: block; +} +.wpmf-hide-show-buttons .hide-folders { + background: url('../images/folder-off.svg') no-repeat; +} +.wpmf-hide-show-buttons .show-folders { + background: url('../images/drive-file-move-outline.svg') no-repeat; +} +.wpmf-hide-folder-tree .wpmf-main-tree { + width: 0!important; + min-width: 0!important; +} +.wpmf-hide-folder-tree .wpmf-tree-actions, .wpmf-hide-folder-tree .wpmf-expandable-search, .wpmf-hide-folder-tree .wpmf-all-tree, .wpmf-hide-folder-tree .wpmf-main-tree-resize { + display: none; + transition: all .15s linear; + -webkit-transition: all .15s linear; + -moz-transition: all .15s linear; +} +body.wp-admin #wpcontent { + transition: all .15s linear; + -webkit-transition: all .15s linear; + -moz-transition: all .15s linear; +} +body.woocommerce-page th#taxonomy-wpmf-folder-type-product, body.woocommerce-admin-page th#taxonomy-wpmf-folder-type-product { + width: 10% !important; } \ No newline at end of file diff --git a/wp/wp-content/plugins/wp-media-folder/assets/images/drive-file-move-outline.svg b/wp/wp-content/plugins/wp-media-folder/assets/images/drive-file-move-outline.svg new file mode 100644 index 00000000..4f31d198 --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/assets/images/drive-file-move-outline.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/wp/wp-content/plugins/wp-media-folder/assets/images/folder-off.svg b/wp/wp-content/plugins/wp-media-folder/assets/images/folder-off.svg new file mode 100644 index 00000000..ea6bdb9d --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/assets/images/folder-off.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/wp/wp-content/plugins/wp-media-folder/assets/js/folder-post-type.js b/wp/wp-content/plugins/wp-media-folder/assets/js/folder-post-type.js new file mode 100644 index 00000000..369d1901 --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/assets/js/folder-post-type.js @@ -0,0 +1,1548 @@ +'use strict'; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +/** + * Main WP Media Folder script + * It handles the categories filtering + */ +var wpmfFoldersModule = void 0, + wpmfAddCloudQueue = void 0, + cloud_sync_loader_icon = void 0; +(function ($) { + wpmfFoldersModule = { + taxonomy: null, // WPMF taxonomy + categories: null, // All categories objects + relation_category_filter: [], // Relation between categories variable and filter select + last_selected_folder: 0, // Last folder we moved into + dragging_elements: null, // Variable used to store elements while dragging files or folders + doing_global_search: false, // Save status of search + page_type: null, // Current page type upload-list, upload-grid + editFolderId: 0, // Current folder id to edit or delete ... + editFileId: 0, // Current file id to edit + folder_search: null, + events: [], // event handling + limit_folders: 400, + enable_folders: true, + folders_order: 'custom', + + /** + * Retrieve the current displayed frame + */ + getFrame: function getFrame() { + return $('.edit-php .wpmf-folder-post-type'); + }, + + /** + * Initialize module related things + */ + initModule: function initModule() { + // Retrieve values we'll use + wpmfFoldersModule.limit_folders = parseInt(wpmf.vars.limit_folders_number); + wpmfFoldersModule.categories = wpmf.vars.wpmf_categories; + wpmfFoldersModule.taxonomy = wpmf.vars.taxo; + wpmfFoldersModule.post_type = wpmf.vars.post_type; + + var init = function init() { + var $current_frame = wpmfFoldersModule.getFrame(); + // get last access folder + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof lastAccessFolder !== "undefined") { + wpmfFoldersModule.last_selected_folder = lastAccessFolder; + } + // render context menu box + wpmfFoldersModule.renderContextMenu(); + + // render folder permissions wrap + wpmfFoldersModule.renderFolderPermissionsWrap(); + + // open / close context menu box + wpmfFoldersModule.openContextMenuFolder(); + + wpmfFoldersModule.trigger('ready', $current_frame); + }; + + init(); + }, + + /** + * render context menu box + */ + renderContextMenu: function renderContextMenu() { + var colors = ''; + // render list color + $.each(wpmf.l18n.colorlists, function (i, title) { + colors += '
'; + }); + + // render context menu for folder + var context_folder = ''; + + // Add the context menu box for folder to body + if (!$('.wpmf-contextmenu.wpmf-contextmenu-folder').length) { + $('body').append(context_folder); + } + }, + + /** + * right click on folder to open menu + */ + openContextMenuFolder: function openContextMenuFolder() { + // init context menu on folders + $('.wpmf-attachment, .wpmf-main-tree ul li .wpmf-item[data-id]').off('contextmenu').on('contextmenu', function (e) { + if (parseInt($(e.target).data('id')) === 0 || $(e.target).closest('li').data('id') === 0) { + $('.wpmf-contextmenu-folder li').hide(); + $('.material_newfolder').closest('li').show(); + $('.wpmf-download-contextmenu, .wpmf-download-contextmenu li').show(); + } else if (parseInt($(e.target).data('id')) === -1 || $(e.target).closest('li').data('id') === -1) { + $('.wpmf-contextmenu-folder li').hide(); + } else { + $('.wpmf-contextmenu-folder li').show(); + } + if (!$(this).hasClass('wpmf-new') && !$(this).hasClass('wpmf-back')) { + wpmfFoldersModule.houtside(); + var x = e.clientX; // Get the horizontal coordinate + var y = e.clientY; + if ($(e.target).hasClass('wpmf-attachment')) { + wpmfFoldersModule.editFolderId = $(e.target).data('id'); + } else { + wpmfFoldersModule.editFolderId = $(e.target).closest('li').data('id'); + } + + if (parseInt($(e.target).data('id')) !== parseInt(wpmfFoldersModule.last_selected_folder) && parseInt($(e.target).closest('li').data('id')) !== parseInt(wpmfFoldersModule.last_selected_folder)) { + $('.material_refreshfolder').closest('li').hide(); + } else { + $('.material_refreshfolder').closest('li').show(); + } + + if (parseInt($(e.target).data('id')) === -1 || $(e.target).closest('li').data('id') === -1) { + $('.material_refreshfolder').closest('li').show(); + } + + if (wpmf.vars.show_folder_id) { + $('.wpmf_folderID').html(wpmfFoldersModule.editFolderId); + } + + // render custom color + wpmfFoldersModule.renderCustomColor(); + // change color for folder + wpmfFoldersModule.setFolderColor(); + // Set status folder color + // wpmfFoldersModule.appendCheckColor(); + $('.wpmf-contextmenu').removeClass('context_overflow'); + if ($('.wpmf-main-tree').length && $(this).hasClass('wpmf-item')) { + if (y + $('.wpmf-contextmenu-folder').outerHeight() > $('.wpmf-main-tree').offset().top + $('.wpmf-main-tree').height()) { + y = y - $('.wpmf-contextmenu-folder').outerHeight(); + } + } + if (x + $('.wpmf-contextmenu-folder').width() + 236 > $(window).width()) { + $('.wpmf-contextmenu.wpmf-contextmenu-folder').addClass('context_overflow').slideDown(200).css({ + 'right': $(window).width() - x + 'px', + 'left': 'auto', + 'top': y + 'px' + }); + } else { + $('.wpmf-contextmenu.wpmf-contextmenu-folder').slideDown(200).css({ + 'left': x + 'px', + 'right': 'auto', + 'top': y + 'px' + }); + } + } + return false; + }); + + $('body').on('click', function (e) { + if (!$(e.target).hasClass('colorsub') && !$(e.target).hasClass('wp-color-folder')) { + wpmfFoldersModule.houtside(); + } + }); + + // edit folder + $('.material_editfolder').off('click').on('click', function (e) { + wpmfFoldersModule.clickEditFolder(e, wpmfFoldersModule.editFolderId); + wpmfFoldersModule.houtside(); + }); + + $('.material_newfolder').off('click').on('click', function (e) { + wpmfFoldersModule.newFolder(wpmfFoldersModule.editFolderId); + wpmfFoldersModule.houtside(); + }); + + $('.material_refreshfolder').off('click').on('click', function (e) { + wpmfFoldersModule.reloadFolder(); + wpmfFoldersModule.houtside(); + }); + + // delete folder + $('.material_deletefolder').off('click').on('click', function (e) { + wpmfFoldersModule.clickDeleteFolder(e, wpmfFoldersModule.editFolderId); + wpmfFoldersModule.houtside(); + }); + + $('.wpmf-bulk-folders-btn').off('click').on('click', function (e) { + e.preventDefault(); + if ($('.wpmf-folder-actions').hasClass('wpmf-deactivate')) { + $('.wpmf-tree-actions').find('.wpmf-new-folder').addClass('hide'); + } else { + $('.wpmf-tree-actions').find('.wpmf-new-folder').removeClass('hide'); + } + $('.wpmf-folder-actions').toggleClass('wpmf-deactivate'); + $('.wpmf-tree-checkbox').toggleClass('hide'); + }); + + // delete folder + $('.material_downloadfolder').off('click').on('click', function (e) { + var sub = $(this).data('sub'); + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf", + task: "download_folder", + folder_id: wpmfFoldersModule.editFolderId, + download_sub: sub, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + // Show snackbar + if (!$('.wpmf-snackbar[data-id="download_folder"]').length) { + wpmfSnackbarModule.show({ + id: 'download_folder', + content: wpmf.l18n.download_folder, + auto_close: false, + is_progress: true + }); + } + }, + success: function success(response) { + wpmfSnackbarModule.close('download_folder'); + if (response.status) { + var hidden_a = document.createElement('a'); + hidden_a.setAttribute('href', response.link); + hidden_a.setAttribute('download', response.zipname); + document.body.appendChild(hidden_a); + hidden_a.click(); + } + } + }); + wpmfFoldersModule.houtside(); + }); + + // get URL attachment + $('.material_copyFolderId').off('click').on('click', function (e) { + wpmfFoldersModule.setClipboardText(wpmfFoldersModule.editFolderId, wpmf.l18n.copy_folderID_msg); + wpmfFoldersModule.houtside(); + }); + + // change color for folder + wpmfFoldersModule.setFolderColor(); + }, + + /** + * Set status folder color + */ + appendCheckColor: function appendCheckColor() { + $('.color-wrapper .color .color_check:not(.custom_color .color_check)').remove(); + $('.color-wrapper > .color[data-color="' + wpmf.vars.colors[wpmfFoldersModule.editFolderId] + '"]').append('done'); + }, + + /** + * render custom color + */ + renderCustomColor: function renderCustomColor() { + // remove old html + $('.custom_color_wrap').remove(); + var value = ''; + var custom_color = ''; + var colorlists = wpmf.l18n.colorlists; + var folder_color = '
'; + if (typeof colorlists[wpmf.vars.colors[wpmfFoldersModule.editFolderId]] === 'undefined') { + if (typeof wpmf.vars.colors[wpmfFoldersModule.editFolderId] === 'undefined') { + custom_color = '#8f8f8f'; + } else { + custom_color = wpmf.vars.colors[wpmfFoldersModule.editFolderId]; + value = wpmf.vars.colors[wpmfFoldersModule.editFolderId]; + } + } else { + custom_color = '#8f8f8f'; + } + folder_color += '\n '; + folder_color += '
check
'; + folder_color += '
'; + $('.color-wrapper').append(folder_color); + }, + + /** + * Set folder color + */ + setFolderColor: function setFolderColor() { + $('.wp-color-folder').on('keyup', function (e) { + var val = $(this).val(); + if (val.length >= 4) { + $('.color.custom_color').data('color', val).css('background', val); + } else { + $('.color.custom_color').data('color', 'transparent').css('background', 'transparent'); + } + }); + + // change color for folder + $('.wpmf-contextmenu.wpmf-contextmenu-folder .color').off('click').on('click', function (e) { + var color = $(this).data('color'); + $('.wpmf-attachment.wpmf-folder[data-id="' + wpmfFoldersModule.editFolderId + '"] .mdc-list-item__start-detail').css('color', color); + $('.wpmf-main-tree .wpmf-item[data-id="' + wpmfFoldersModule.editFolderId + '"] .wpmf-item-icon, .wpmf-main-tree .wpmf-item[data-id="' + wpmfFoldersModule.editFolderId + '"] .tree_drive_icon').css('color', color); + $('.wpmf-attachment.wpmf-folder[data-id="' + wpmfFoldersModule.editFolderId + '"] .mdc-list-item__start-detail svg .cls-2').css('fill', color); + $('.wpmf-main-tree .wpmf-item[data-id="' + wpmfFoldersModule.editFolderId + '"] .tree_drive_icon_img > .cls-2').css('fill', color); + wpmf.vars.colors[wpmfFoldersModule.editFolderId] = color; + wpmfFoldersModule.appendCheckColor(); + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "set_folder_color", + color: color, + folder_id: wpmfFoldersModule.editFolderId, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + success: function success(response) { + if (!response.status) { + // Show dialog when set background folder failed + showDialog({ + title: wpmf.l18n.information, // todo : use the response message instead of a predefined one + text: wpmf.l18n.bgcolorerror, + closeicon: true + }); + } + } + }); + }); + }, + + /** + * Open a lightbox to enter the new folder name + * + * @param parent_id id parent folder + */ + newFolder: function newFolder(parent_id) { + var options = { + title: wpmf.l18n.create_folder, + text: '', + negative: { + title: wpmf.l18n.cancel + }, + positive: { + title: wpmf.l18n.create, + onClick: function onClick() { + // Call php script to create the folder + wpmfFoldersModule.createNewFolder($('.wpmf_newfolder_input').val(), parent_id); + + // Hide the dialog + hideDialog(jQuery('#orrsDiag')); + } + } + }; + showDialog(options); + + // Bind the press enter key to submit the modal + $('.wpmf_newfolder_input').focus().on('keypress', function (e) { + if (e.which === 13) { + options.positive.onClick.call(this); + } + }); + }, + + /** + * Send ajax request to create a new folder + * + * @param name string new folder name + * @param parent_id int parent folder + */ + createNewFolder: function createNewFolder(name, parent_id) { + return $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "add_folder", + name: name, + parent: parent_id, + folder_post_type_name: wpmfFoldersModule.taxonomy, + post_type: wpmfFoldersModule.post_type, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + // Show snackbar + wpmfSnackbarModule.show({ + id: 'upload_folder', + content: wpmf.l18n.wpmf_folder_adding, + auto_close: false, + is_progress: true + }); + }, + success: function success(response) { + if (response.status) { + // Update the categories variables + wpmfFoldersModule.categories = response.categories; + + // Regenerate the folder filter + // wpmfFoldersModule.initFolderFilter(); + + // Reload the folders + wpmfFoldersModule.renderFolders(); + + wpmfSnackbarModule.close('upload_folder'); + // Show snackbar + wpmfSnackbarModule.show({ + id: 'folder_added', + icon: 'create_new_folder', + content: wpmf.l18n.wpmf_addfolder + }); + + wpmfFoldersModule.trigger('addFolder', response.term); + } else { + wpmfSnackbarModule.close('upload_folder'); + + // Show dialog when adding folder failed + showDialog({ + title: wpmf.l18n.information, // todo : use the response message instead of a predefined one + text: response.msg, + closeicon: true + }); + } + } + }); + }, + + /** + * Clicki on edit icon on a folder + */ + clickEditFolder: function clickEditFolder(event, folder_id) { + event.stopPropagation(); + + // Retrieve the current folder name + var name = wpmfFoldersModule.categories[folder_id].label; + + // Show the input dialog + var options = { + title: wpmf.l18n.promt, + text: '', + negative: { + title: wpmf.l18n.cancel + }, + positive: { + title: wpmf.l18n.save, + onClick: function onClick() { + var new_name = $('.wpmf_newfolder_input').val(); + if (new_name !== '' && new_name !== 'null') { + // Call php script to update folder name + wpmfFoldersModule.updateFolderName(folder_id, new_name); + + // Close the dialog + hideDialog($('#orrsDiag')); + } + } + } + }; + showDialog(options); + + // Bind the press enter key to submit the modal + $('.wpmf_newfolder_input').keypress(function (e) { + if (e.which === 13) { + options.positive.onClick.call(this); + } + }); + }, + + /** + * Update folder name + * + * @param id int id of folder + * @param name string new name of folder + */ + updateFolderName: function updateFolderName(id, name) { + return $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "edit_folder", + name: name, + id: id, + folder_post_type_name: wpmfFoldersModule.taxonomy, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + // Show snackbar + if (!$('.wpmf-snackbar[data-id="edit_folder"]').length) { + wpmfSnackbarModule.show({ + id: 'edit_folder', + content: wpmf.l18n.folder_editing, + auto_close: false, + is_progress: true + }); + } + }, + success: function success(response) { + var $snack = wpmfSnackbarModule.getFromId('edit_folder'); + wpmfSnackbarModule.close('edit_folder'); + if (!response.status) { + if (name !== wpmfFoldersModule.categories[id].label) { + // todo: why do we check that? + showDialog({ + title: wpmf.l18n.information, + text: response.msg, + closeicon: true + }); + } + } else { + // Store variables in case of undo + var old_name = wpmfFoldersModule.categories[id].label; + + // Update the name in stored variables + wpmfFoldersModule.categories[id].label = response.details.name; + + // Show snackbar + wpmfSnackbarModule.show({ + id: 'undo_editfolder', + content: wpmf.l18n.wpmf_undo_editfolder, + is_undoable: true, + onUndo: function onUndo() { + // Cancel delete folder + wpmfFoldersModule.updateFolderName(id, old_name); + } + }); + + wpmfFoldersModule.trigger('updateFolder', id); + } + } + }); + }, + + /** + * Delete folder click function in template + * @param event Object + * @param id int folder id to delete + */ + clickDeleteFolder: function clickDeleteFolder(event, id) { + event = event || window.event; // FF IE fix if event has not been passed in function + + event.stopPropagation(); + + // Show an alter depending on if we delete also included images inside the folder + var alert_delete = void 0; + if (typeof wpmf.vars.wpmf_remove_media !== "undefined" && parseInt(wpmf.vars.wpmf_remove_media) === 1) { + alert_delete = wpmf.l18n.alert_delete_all; + } else { + alert_delete = wpmf.l18n.alert_delete; + } + + showDialog({ + title: alert_delete, + negative: { + title: wpmf.l18n.cancel + }, + positive: { + title: wpmf.l18n.delete, + onClick: function onClick() { + // Add effect in the folder deleted while we wait the response from server + $('.wpmf-attachment[data-id="' + id + '"]').css({ 'opacity': '0.5' }); + $('.wpmf-attachment[data-id="' + id + '"] .wpmf-attachment-preview').append('
'); + + wpmfFoldersModule.deleteFolder(id); + } + } + }); + }, + + /** + * Send ajax request to delete a folder + * @param id + */ + deleteFolder: function deleteFolder(id) { + // Store some values in case of undo + var old_folder_name = wpmfFoldersModule.categories[id].label, + old_parent = wpmfFoldersModule.categories[id].parent_id; + + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "delete_folder", + id: id, + folder_post_type_name: wpmfFoldersModule.taxonomy, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + // Show snackbar + if (typeof wpmf.vars.wpmf_remove_media !== "undefined" && parseInt(wpmf.vars.wpmf_remove_media) === 1) { + if (!$('.wpmf-snackbar[data-id="deleting_folder"]').length) { + wpmfSnackbarModule.show({ + id: 'deleting_folder', + content: wpmf.l18n.wpmf_folder_deleting, + auto_close: false, + is_progress: true + }); + } + } + }, + success: function success(response) { + if (response.status) { + // Update the categories variables + wpmfFoldersModule.categories = response.categories; + wpmfSnackbarModule.close('deleting_folder'); + // Show snackbar + wpmfSnackbarModule.show({ + id: 'undo_remove_folder', + content: wpmf.l18n.wpmf_undo_remove, + icon: 'delete_outline', + }); + + wpmfFoldersModule.last_selected_folder = 0; + + wpmfFoldersModule.trigger('deleteFolder', id); + } else { + if (typeof response.msg !== "undefined" && response.msg === 'limit') { + wpmfFoldersModule.deleteFolder(id); + } else { + // todo : show error message from json response + showDialog({ + title: wpmf.l18n.information, + text: response.error, + closeicon: true + }); + $('.wpmf-attachment[data-id="' + id + '"]').css({ 'opacity': 1 }); + } + } + } + }); + }, + + /** + * Send ajax request to delete multiple folders + * @param ids + */ + deleteMultipleFolders: function deleteMultipleFolders(ids) { + if (ids.length) { + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "delete_multiple_folders", + id: ids.join(), + folder_post_type_name: wpmfFoldersModule.taxonomy, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + // Show snackbar + if (!$('.wpmf-snackbar[data-id="deleting_folder"]').length) { + wpmfSnackbarModule.show({ + id: 'deleting_folder', + content: wpmf.l18n.wpmf_folder_deleting, + auto_close: false, + is_progress: true + }); + } + }, + success: function success(response) { + if (response.status) { + // Update the categories variables + wpmfFoldersModule.categories = response.categories; + wpmfSnackbarModule.close('deleting_folder'); + wpmfFoldersModule.trigger('deleteFolder'); + } else { + if (typeof response.msg !== "undefined" && response.msg === 'limit') { + wpmfFoldersModule.deleteMultipleFolders(ids); + } else { + // todo : show error message from json response + showDialog({ + title: wpmf.l18n.information, + text: response.error, + closeicon: true + }); + $('.wpmf-attachment[data-id="' + id + '"]').css({ 'opacity': 1 }); + } + } + } + }); + } + }, + + /** + * Render the folders to the attachments listing + * + * @param term_id + */ + renderFolders: function renderFolders(term_id) { + if (parseInt(wpmfFoldersModule.enable_folders) === 0) { + // return if disable show folders option + return; + } + + if (typeof term_id === "undefined") { + // check if enable display own media + if (typeof wpmfFoldersModule.categories[wpmfFoldersModule.last_selected_folder] === "undefined") { + wpmfFoldersModule.last_selected_folder = 0; + // wpmfFoldersModule.changeFolder(0); + } + + term_id = wpmfFoldersModule.last_selected_folder; + } else { + // Let's save this term as the last used one + wpmfFoldersModule.last_selected_folder = term_id; + } + + // Retrieve current frame + var $frame = wpmfFoldersModule.getFrame(); + + // Retrieve the attachments container + var $attachments_container = void 0; + if (wpmfFoldersModule.page_type === 'upload-list') { + $attachments_container = $frame.find('ul.attachments'); + } else { + $attachments_container = $frame.find('.attachments-browser ul.attachments'); + } + + // Remove previous folders + $attachments_container.find('.wpmf-attachment, .wpmf-line-break').remove(); + + // Retrieve the folders that may be added to current view + var folders_ordered = []; + // get search keyword + var search = $('.wpmf_search_folder').val(); + wpmfFoldersModule.folder_search = []; + if (typeof search === "undefined") { + search = ''; + } else { + search = search.trim().toLowerCase(); + } + + folders_ordered = wpmfFoldersModule.categories; + + var folder_order = wpmfFoldersModule.folder_order; + if (typeof folder_order !== "undefined") { + wpmfFoldersModule.folder_ordering = folder_order; + } else { + wpmfFoldersModule.folder_ordering = 'name-ASC'; + } + + // Order folders + switch (wpmfFoldersModule.folder_ordering) { + default: + case 'name-ASC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + return a.label.localeCompare(b.label); + }); + break; + case 'name-DESC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + return b.label.localeCompare(a.label); + }); + break; + case 'id-ASC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + return a.id - b.id; + }); + break; + case 'id-DESC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + return b.id - a.id; + }); + break; + case 'custom': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + return a.order - b.order; + }); + break; + } + + // Add each folder to the attachments listing + $(folders_ordered).each(function () { + // Get the formatted folder for the attachment listing + if (parseInt(this.parent_id) !== 0) { + var folder = wpmfFoldersModule.getFolderRendering('folder', this.label, this.id, this.parent_id); + // Add the folder to the attachment listing + $attachments_container.append(folder); + } + }); + + // Get the formatted folder to use as a line break + var line_break = wpmfFoldersModule.getFolderRendering('line break', '', '', ''); + + // Add the folder to the attachment listing + $attachments_container.append(line_break); + if ($('.display-all-media .check').length) { + $('.attachments .wpmf-attachment').hide(); + } else { + $('.attachments .wpmf-attachment').show(); + } + $('.wpmf_id_category').val(wpmfFoldersModule.last_selected_folder).change(); + }, + + /** + * Generate the html tag for a folder attachment + * + * @param type string type of folder + * @param name string folder name + * @param term_id int folder term id + * @param parent_id int folder parent id + * + * @return {string} the string that contains the single folder attachment rendered + */ + getFolderRendering: function getFolderRendering(type, name, term_id, parent_id) { + var buttons = ''; + var class_names = ''; + var main_icon = ''; + var action = ''; + if (type === 'folder') { + // This is a folder + buttons = '\n '; + class_names = 'wpmf-folder'; + action = 'onclick="wpmfFoldersModule.changeFolder(' + term_id + ');"'; + main_icon = 'folder'; + } else if (type === 'back') { + // This is a back folder + class_names = 'wpmf-folder wpmf-back'; + main_icon = ' keyboard_arrow_left '; + action = 'onclick="wpmfFoldersModule.changeFolder(' + term_id + ');"'; + } else if (type === 'new') { + // This is a create new folder button + class_names = 'wpmf-new'; + main_icon = 'create_new_folder'; + action = 'onclick="wpmfFoldersModule.newFolder(' + term_id + ');"'; + } else if (type === 'line break') { + class_names = 'wpmf-line-break'; + } + + // get color folder + var bgcolor = 'color: #8f8f8f'; + if (typeof wpmf.vars.colors !== 'undefined' && typeof wpmf.vars.colors[term_id] !== 'undefined' && type === 'folder') { + bgcolor = 'color: ' + wpmf.vars.colors[term_id]; + } + + if (class_names === 'wpmf-line-break') { + return '
  • '; + } + + return '
  • \n \n ' + main_icon + '\n \n \n ' + name + '\n \n
  • '; + }, + + /** + * Move into the term_id folder + * It will change the selected option in the filter + * This will update the attachments and render the folders + * + * @param term_id + */ + changeFolder: function changeFolder(term_id) { + // set cookie last access folder + if (typeof term_id === "undefined") { + wpmfFoldersModule.setCookie('lastAccessFolder_' + wpmf.vars.host, 0, 365); + wpmfFoldersModule.last_selected_folder = 0; + } else { + wpmfFoldersModule.setCookie('lastAccessFolder_' + wpmf.vars.host, term_id, 365); + wpmfFoldersModule.last_selected_folder = term_id; + } + + if (typeof wpmfFoldersModule.categories[term_id].getTermAdminLink !== "undefined") { + var ajaxURL = wpmfFoldersModule.categories[term_id].getTermAdminLink; + $("#wpbody").load(ajaxURL + " #wpbody-content", false, function (res) { + var obj = { Title: "", Url: ajaxURL }; + history.pushState(obj, obj.Title, obj.Url); + + wpmfFoldersTreeModule.initModule(wpmfFoldersModule.getFrame()); + wpmfFoldersModule.reloadEventWP(); + }) + } + }, + + /** + * Move a folder inside another folder + * + * @param folder_id int folder we're moving + * @param folder_to_id int folder we're moving into + * @return jqXHR + */ + moveFolder: function moveFolder(folder_id, folder_to_id) { + // Store parent id in order to use it in the undo function + var parent_id = wpmfFoldersModule.categories[folder_id].parent_id; + + return $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "move_folder", + id: folder_id, + id_category: folder_to_id, + folder_post_type_name: wpmfFoldersModule.taxonomy, + type: 'move', // todo: handle the undo feature + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + // Show snackbar + if (!$('.wpmf-snackbar[data-id="moving_folder"]').length) { + wpmfSnackbarModule.show({ + id: 'moving_folder', + content: wpmf.l18n.folder_moving, + auto_close: false, + is_progress: true + }); + } + }, + success: function success(response) { + if (response.status) { + // Update the categories variables + wpmfFoldersModule.categories = response.categories; + + // Reload the folders + wpmfFoldersModule.renderFolders(); + + // Trigger event + wpmfFoldersModule.trigger('moveFolder', folder_id, folder_to_id); + + wpmfSnackbarModule.close('moving_folder'); + // Show snackbar + wpmfSnackbarModule.show({ + id: 'undo_movefolder', + content: wpmf.l18n.wpmf_undo_movefolder, + icon: 'trending_flat', + is_undoable: true, + onUndo: function onUndo() { + // Move back to old folder + wpmfFoldersModule.moveFolder(folder_id, parent_id); + } + }); + } else { + wpmfSnackbarModule.close('moving_folder'); + if (typeof response.msg !== "undefined") { + //todo: change wrong variable name to something more understandable like message or error_message, and what should we do if wrong is set? + showDialog({ + title: wpmf.l18n.information, + text: response.msg, + closeicon: true + }); + } + } + } + }); + }, + + /** + * Force attachments to be reloaded in the current view + */ + reloadFolder: function reloadFolder() { + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "reload_folder_tree", + folder_post_type_name: wpmfFoldersModule.taxonomy, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + success: function success(response) { + if (response.status) { + wpmfFoldersModule.categories = response.categories; + wpmfFoldersModule.last_selected_folder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + + var ajaxURL = wpmf.vars.current_url; + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof wpmfFoldersModule.categories[lastAccessFolder] !== 'undefined') { + var folderName = wpmfFoldersModule.categories[lastAccessFolder].slug; + var urlParams = new URLSearchParams(window.location.search); + if (typeof urlParams.get(wpmfFoldersModule.taxonomy) !== 'undefined' && (urlParams.get(wpmfFoldersModule.taxonomy) === '' || urlParams.get(wpmfFoldersModule.taxonomy) === null )) { + ajaxURL += folderName; + } else { + ajaxURL = wpmfFoldersModule.categories[lastAccessFolder].getTermAdminLink; + } + + if (wpmf.vars.lastAccessFolder !== lastAccessFolder) { + ajaxURL = wpmfFoldersModule.categories[lastAccessFolder].getTermAdminLink; + } + } else { + wpmfFoldersModule.setCookie('lastAccessFolder_' + wpmf.vars.host, 0, 365); + } + $("#wpbody").load(ajaxURL + " #wpbody-content", false, function (res) { + var obj = { Title: "", Url: ajaxURL }; + history.pushState(obj, obj.Title, obj.Url); + + wpmfFoldersTreeModule.initModule(wpmfFoldersModule.getFrame()); + wpmfFoldersModule.reloadEventWP(); + }) + } + } + }); + }, + + renderPermissionHtml: function renderPermissionHtml(role_user_list) { + var cl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'folder_permission_items'; + + return '
    \n ' + role_user_list + '\n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    '; + }, + + renderFolderPermissionsWrap: function renderFolderPermissionsWrap() { + if (wpmf.vars.wpmf_role !== 'administrator') { + return false; + } + + var roles = '', + users = ''; + $.each(wpmf.vars.roles, function (role, role_infos) { + roles += ''; + }); + + $.each(wpmf.vars.users, function (user, user_infos) { + users += ''; + }); + + var role_list = '
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n delete \n
    \n
    '; + + var user_list = '
    \n
    \n
    \n \n
    \n \n
    \n
    \n \n delete \n
    \n
    '; + + var role_permission_html = wpmfFoldersModule.renderPermissionHtml(role_list, 'folder_permission_items folder_role_permission_items'); + var user_permission_html = wpmfFoldersModule.renderPermissionHtml(user_list, 'folder_permission_items folder_user_permission_items'); + var html = '\n
    \n
    \n
    \n
      \n
    • ' + wpmf.l18n.by_role + '
    • \n
    • ' + wpmf.l18n.by_user + '
    • \n
    \n
    \n

    ' + wpmf.l18n.permissions_list_of + ' ' + wpmf.l18n.folder + ':

    \n
    \n
    \n
    \n ' + role_permission_html + '\n
    \n

    \n
    \n \n
    \n
    \n ' + user_permission_html + '\n
    \n

    \n
    \n
    \n \n

    \n \n \n \n

    \n
    \n
    '; + $('body').append(html); + + $('#folder_permissions .wpmf_tab').unbind('click').bind('click', function () { + var tab = $(this).data('tab'); + $('#folder_permissions .wpmf_tab').removeClass('active'); + $(this).addClass('active'); + $('.wpmf_permission_content').hide(); + $('.wpmf_permission_content[data-tab="' + tab + '"]').show(); + }); + + // show popup inline + if ($().magnificPopup) { + $('.open_folder_permissions').magnificPopup({ + type: 'inline', + mainClass: 'wpmf_folder_permissions_popup', + closeBtnInside: true, + midClick: true, + closeOnBgClick: true, + callbacks: { + beforeOpen: function beforeOpen() { + this.wrap.removeAttr('tabindex'); + }, + open: function open() { + wpmfFoldersModule.houtside(); + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "get_folder_permissions", + folder_id: wpmfFoldersModule.editFolderId, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + $('.folder_permissions_wrap').addClass('wpmf_saving'); + $('.roles_list_html').html(''); + $('.users_list_html').html(''); + }, + success: function success(response) { + $('.folder_permissions_wrap').removeClass('wpmf_saving'); + if (response.status) { + $('.permission_folder_name').html(wpmfFoldersModule.categories[wpmfFoldersModule.editFolderId].label); + if (response.role_permissions.length) { + $.each(response.role_permissions, function (i, permission) { + var selected = permission[0]; + if (selected == null) { + selected = 0; + } + var html = role_permission_html.replace('{{wpmf_role}}', selected); + $('.roles_list_html').append(html); + $('.folder_role_permission_items[data-role="' + selected + '"]').find('.wpmf_role_permissions').val(selected).change(); + $('.folder_role_permission_items[data-role="' + selected + '"]').find('.permission_item_checkbox').prop('checked', false); + $.each(permission, function (j, permission2) { + $('.folder_role_permission_items[data-role="' + selected + '"]').find('.permission_item_checkbox[value="' + permission2 + '"]').prop('checked', true); + }); + }); + } else { + $('.roles_list_html').append(role_permission_html); + } + + if (response.user_permissions.length) { + $.each(response.user_permissions, function (i, permission) { + var selected = permission[0]; + if (selected == null) { + selected = 0; + } + + var html = user_permission_html.replace('{{wpmf_role}}', selected); + $('.users_list_html').append(html); + $('.folder_user_permission_items[data-role="' + selected + '"]').find('.wpmf_user_permissions').val(selected).change(); + $('.folder_user_permission_items[data-role="' + selected + '"]').find('.permission_item_checkbox').prop('checked', false); + $.each(permission, function (j, permission2) { + $('.folder_user_permission_items[data-role="' + selected + '"]').find('.permission_item_checkbox[value="' + permission2 + '"]').prop('checked', true); + }); + }); + } else { + $('.users_list_html').append(user_permission_html); + } + + if (!$('.inherit_folder_wrap').length) { + $('.wpmf_contents_wrap').prepend('
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    '); + } + + if (parseInt(response.inherit_folder) === 1) { + $('.permission_item_checkbox[value="inherit_folder"]').prop('checked', true); + $('.folder_permission_items_wrap:not(.inherit_folder_wrap)').hide(); + } else { + $('.permission_item_checkbox[value="inherit_folder"]').prop('checked', false); + $('.folder_permission_items_wrap').show(); + } + + $('.permission_item_checkbox[value="inherit_folder"]').on('change', function () { + if ($(this).is(':checked')) { + $('.folder_permission_items_wrap:not(.inherit_folder_wrap)').hide(); + } else { + $('.folder_permission_items_wrap').show(); + } + }); + + $('.permission_item_checkbox[value="inherit_folder"]').on('change', function () { + if ($(this).is(':checked')) { + $('.folder_permission_items_wrap:not(.inherit_folder_wrap)').hide(); + } else { + $('.folder_permission_items_wrap').show(); + } + }); + + $('.wpmf_role_permissions').on('change', function () { + if ($(this).val() != 0) { + $('.wpmf_add_role').addClass('show'); + } else { + $('.wpmf_add_role').removeClass('show'); + } + }); + + $('.wpmf_user_permissions').on('change', function () { + if ($(this).val() != 0) { + $('.wpmf_add_user').addClass('show'); + } else { + $('.wpmf_add_user').removeClass('show'); + } + }); + + if ($('.wpmf_role_permissions :selected').val() != 0) { + $('.wpmf_add_role').addClass('show'); + } else { + $('.wpmf_add_role').removeClass('show'); + } + + if ($('.wpmf_user_permissions :selected').val() != 0) { + $('.wpmf_add_user').addClass('show'); + } else { + $('.wpmf_add_user').removeClass('show'); + } + + if ($().wpmfSelect2) { + $('.wpmf_user_permissions, .wpmf_role_permissions').wpmfSelect2(); + } + + wpmfFoldersModule.removeRolePermissions(); + } + } + }); + }, + close: function close() { + $('.roles_list_html').html(''); + $('.users_list_html').html(''); + } + // e.t.c. + } + }); + + $('.wpmf_add_role').on('click', function () { + if ($('.wpmf_role_permissions').length > 0 && $('.wpmf_role_permissions:last :selected').val() == 0) { + return; + } + $('.roles_list_html').append(role_permission_html); + if ($().wpmfSelect2) { + $('.wpmf_role_permissions:last').wpmfSelect2(); + } + wpmfFoldersModule.removeRolePermissions(); + }); + + $('.wpmf_add_user').on('click', function () { + if ($('.wpmf_user_permissions').length > 0 && $('.wpmf_user_permissions:last :selected').val() == 0) { + return; + } + $('.users_list_html').append(user_permission_html); + if ($().wpmfSelect2) { + $('.wpmf_user_permissions:last').wpmfSelect2(); + } + wpmfFoldersModule.removeRolePermissions(); + }); + + $('.wpmf_cancel_btn').on('click', function () { + $.magnificPopup.close(); + }); + + wpmfFoldersModule.removeRolePermissions(); + + $('.wpmf_save_permission').on('click', function () { + var button = $(this); + var all_role_permissions = [], + all_user_permissions = []; + $('.folder_role_permission_items').each(function (i, item) { + var role = $(item).find('.wpmf_role_permissions :selected').val(); + var permissions = []; + permissions.push(role); + $(item).find('.permission_item_checkbox').each(function (i, permission) { + if ($(permission).is(':checked')) { + permissions.push($(permission).val()); + } + }); + all_role_permissions.push(permissions); + }); + + $('.folder_user_permission_items').each(function (i, item) { + var user = $(item).find('.wpmf_user_permissions :selected').val(); + var permissions = []; + permissions.push(user); + $(item).find('.permission_item_checkbox').each(function (i, permission) { + if ($(permission).is(':checked')) { + permissions.push($(permission).val()); + } + }); + all_user_permissions.push(permissions); + }); + + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "save_folder_permissions", + folder_id: wpmfFoldersModule.editFolderId, + inherit_folder: $('.permission_item_checkbox[value="inherit_folder"]').is(':checked') ? 1 : 0, + role_permissions: JSON.stringify(all_role_permissions), + user_permissions: JSON.stringify(all_user_permissions), + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + beforeSend: function beforeSend() { + $('.folder_permissions_wrap').addClass('wpmf_saving'); + }, + success: function success(response) { + $('.folder_permissions_wrap').removeClass('wpmf_saving'); + if (response.status) { + if (button.hasClass('wpmf_save_close_btn')) { + $.magnificPopup.close(); + } + } + } + }); + }); + } + }, + + removeRolePermissions: function removeRolePermissions() { + $('.delete_role_permissions').unbind('click').bind('click', function () { + $(this).closest('.folder_permission_items_wrap').remove(); + }); + }, + + /** + * set a cookie + * @param cname cookie name + * @param cvalue cookie value + * @param exdays + */ + setCookie: function setCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000); + var expires = "expires=" + d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; + }, + + /** + * get a cookie + * @param cname cookie name + * @returns {*} + */ + getCookie: function getCookie(cname) { + var name = cname + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; + }, + + /** + * click outside + */ + houtside: function houtside() { + $('.wpmf-contextmenu-file, .wpmf-contextmenu-folder').hide(); + }, + + /** + * Trigger an event + * @param event string the event name + * @param arguments + */ + trigger: function trigger(event) { + // Retrieve the list of arguments to send to the function + var args = Array.prototype.slice.call(arguments).slice(1); // Cross browser compatible let args = Array.from(arguments).slice(1); + + // Retrieve registered function + var events = wpmfFoldersModule.events[event]; + + // For each registered function apply arguments + if (events) { + for (var i = 0; i < events.length; i++) { + events[i].apply(this, args); + } + } + }, + + /** + * Subscribe to an or multiple events + * @param events {string|array} event name + * @param subscriber function the callback function + */ + on: function on(events, subscriber) { + // If event is a string convert it as an array + if (typeof events === 'string') { + events = [events]; + } + + // Allow multiple event to subscript + for (var ij in events) { + if (typeof subscriber === 'function') { + if (typeof wpmfFoldersModule.events[events[ij]] === "undefined") { + this.events[events[ij]] = []; + } + wpmfFoldersModule.events[events[ij]].push(subscriber); + } + } + }, + + reloadEventWP: function reloadEventWP() { + if (typeof screenMeta == 'object') { + screenMeta.init(); + $(document).off("click", "#screen-meta-links .show-settings").on("click", "#screen-meta-links .show-settings", function() { + var panel = $( '#' + $( this ).attr( 'aria-controls' ) ); + if ( !panel.length ) + return; + + if (panel.hasClass('hidden')) { + screenMeta.open( panel, $(this) ); + } else { + screenMeta.close( panel, $(this) ); + } + }); + } + + if (typeof columns == 'object') { + columns.init(); + $(document).off("click", "#adv-settings .hide-column-tog").on("click", "#adv-settings .hide-column-tog", function() { + var $t = $(this), column = $t.val(); + if ( $t.prop('checked') ) + columns.checked(column); + else + columns.unchecked(column); + + columns.saveManageColumnsState(); + }); + } + + if(typeof inlineEditPost == "object") { + inlineEditPost.init(); + $(document).on("click","#the-list .editinline",function(){ + $(this).attr("aria-expanded","true"); + inlineEditPost.edit(this); + }); + $(document).on("click", ".inline-edit-save .save", function(e){ + e.preventDefault(); + var thisID = $(this).closest("tr").attr("id"); + thisID = thisID.replace("edit-",""); + thisID = thisID.replace("post-",""); + inlineEditPost.save(thisID); + + setTimeout(function() { + wpmfFoldersModule.reloadFolder(); + }, 1000); + }); + $(document).on("click", ".inline-edit-save .cancel", function(){ + var thisID = $(this).closest("tr").attr("id"); + thisID = thisID.replace("edit-",""); + thisID = thisID.replace("post-",""); + inlineEditPost.revert(thisID); + }); + + wpmfFoldersModule.checkInlineEditWooC(); + } + }, + + checkInlineEditWooC: function checkInlineEditWooC() { + if(wpmf.vars.post_type != 'product' || typeof woocommerce_quick_edit != "object") { + return; + } + + $(document).on('click', '#the-list .editinline', function() { + var post_id = $(this).closest('tr').attr('id'); + post_id = post_id.replace('post-', ''); + + var $wwop_inline_data = jQuery( '#wholesale_prices_inline_' + post_id ), + $base_currency = $wwop_inline_data.find( ".product_base_currency" ); + + $wwop_inline_data.find( ".whole_price" ).each(function(index) { + if ( $base_currency.length > 0 ) { + if ( jQuery( this ).attr( 'data-currencyCode' ) == $base_currency.text() ) { + var $wholesale_price_field = jQuery( 'input[name="' + jQuery( this ).attr( 'data-wholesalePriceKeyWithCurrency' ) + '"]' , '.inline-edit-row' ); + // meaning we already modified the name, so we use the name with no currency instead + if ( $wholesale_price_field.length <= 0 ) { + $wholesale_price_field = jQuery( 'input[name="' + jQuery( this ).attr( 'id' ) + '"]' , '.inline-edit-row' ); + } + $wholesale_price_field.val( jQuery( this ).text() ); + $wholesale_price_field.attr( 'placeholder' , '' ); + $wholesale_price_field.siblings( '.title' ).html( $wholesale_price_field.siblings( '.title' ).html() + ' Base Currency' ); + $wholesale_price_field.attr( "name" , jQuery( this ).attr( 'id' ) ); + + var $parent_section_container = $wholesale_price_field.closest( ".section-container" ); + $wholesale_price_field.closest( "label" ).detach().prependTo( $parent_section_container ); + } else { + jQuery( 'input[name="' + jQuery( this ).attr( 'id' ) + '"]' , '.inline-edit-row' ).val( jQuery( this ).text() ); + } + } else { + jQuery( 'input[name="' + jQuery( this ).attr( 'id' ) + '"]' , '.inline-edit-row' ).val( jQuery( this ).text() ); + } + }); + + var $wc_inline_data = $( '#woocommerce_inline_' + post_id ); + + var sku = $wc_inline_data.find( '.sku' ).text(), + regular_price = $wc_inline_data.find( '.regular_price' ).text(), + sale_price = $wc_inline_data.find( '.sale_price ' ).text(), + weight = $wc_inline_data.find( '.weight' ).text(), + length = $wc_inline_data.find( '.length' ).text(), + width = $wc_inline_data.find( '.width' ).text(), + height = $wc_inline_data.find( '.height' ).text(), + shipping_class = $wc_inline_data.find( '.shipping_class' ).text(), + visibility = $wc_inline_data.find( '.visibility' ).text(), + stock_status = $wc_inline_data.find( '.stock_status' ).text(), + stock = $wc_inline_data.find( '.stock' ).text(), + featured = $wc_inline_data.find( '.featured' ).text(), + manage_stock = $wc_inline_data.find( '.manage_stock' ).text(), + menu_order = $wc_inline_data.find( '.menu_order' ).text(), + tax_status = $wc_inline_data.find( '.tax_status' ).text(), + tax_class = $wc_inline_data.find( '.tax_class' ).text(), + backorders = $wc_inline_data.find( '.backorders' ).text(), + product_type = $wc_inline_data.find( '.product_type' ).text(); + console.log(backorders); + var formatted_regular_price = regular_price.replace( '.', woocommerce_admin.mon_decimal_point ), + formatted_sale_price = sale_price.replace( '.', woocommerce_admin.mon_decimal_point ); + + $( 'input[name="_sku"]', '.inline-edit-row' ).val( sku ); + $( 'input[name="_regular_price"]', '.inline-edit-row' ).val( formatted_regular_price ); + $( 'input[name="_sale_price"]', '.inline-edit-row' ).val( formatted_sale_price ); + $( 'input[name="_weight"]', '.inline-edit-row' ).val( weight ); + $( 'input[name="_length"]', '.inline-edit-row' ).val( length ); + $( 'input[name="_width"]', '.inline-edit-row' ).val( width ); + $( 'input[name="_height"]', '.inline-edit-row' ).val( height ); + + $( 'select[name="_shipping_class"] option:selected', '.inline-edit-row' ).attr( 'selected', false ).trigger( 'change' ); + $( 'select[name="_shipping_class"] option[value="' + shipping_class + '"]' ).attr( 'selected', 'selected' ) + .trigger( 'change' ); + + $( 'input[name="_stock"]', '.inline-edit-row' ).val( stock ); + $( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order ); + + $( + 'select[name="_tax_status"] option, ' + + 'select[name="_tax_class"] option, ' + + 'select[name="_visibility"] option, ' + + 'select[name="_stock_status"] option, ' + + 'select[name="_backorders"] option' + ).prop( 'selected', false ).removeAttr( 'selected' ); + + var is_variable_product = 'variable' === product_type; + $( 'select[name="_stock_status"] ~ .wc-quick-edit-warning', '.inline-edit-row' ).toggle( is_variable_product ); + $( 'select[name="_stock_status"] option[value="' + (is_variable_product ? '' : stock_status) + '"]', '.inline-edit-row' ) + .attr( 'selected', 'selected' ); + + $( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); + $( 'select[name="_tax_class"] option[value="' + tax_class + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); + $( 'select[name="_visibility"] option[value="' + visibility + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); + $( 'select[name="_backorders"] option[value="' + backorders + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); + + if ( 'yes' === featured ) { + $( 'input[name="_featured"]', '.inline-edit-row' ).prop( 'checked', true ); + } else { + $( 'input[name="_featured"]', '.inline-edit-row' ).prop( 'checked', false ); + } + + // Conditional display. + var product_is_virtual = $wc_inline_data.find( '.product_is_virtual' ).text(); + + var product_supports_stock_status = 'external' !== product_type; + var product_supports_stock_fields = 'external' !== product_type && 'grouped' !== product_type; + + $( '.stock_fields, .manage_stock_field, .stock_status_field, .backorder_field' ).show(); + + if ( product_supports_stock_fields ) { + if ( 'yes' === manage_stock ) { + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).show().removeAttr( 'style' ); + $( '.stock_status_field' ).hide(); + $( '.manage_stock_field input' ).prop( 'checked', true ); + } else { + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).hide(); + $( '.stock_status_field' ).show().removeAttr( 'style' ); + $( '.manage_stock_field input' ).prop( 'checked', false ); + } + } else if ( product_supports_stock_status ) { + $( '.stock_fields, .manage_stock_field, .backorder_field' ).hide(); + } else { + $( '.stock_fields, .manage_stock_field, .stock_status_field, .backorder_field' ).hide(); + } + + if ( 'simple' === product_type || 'external' === product_type ) { + $( '.price_fields', '.inline-edit-row' ).show().removeAttr( 'style' ); + } else { + $( '.price_fields', '.inline-edit-row' ).hide(); + } + + if ( 'yes' === product_is_virtual ) { + $( '.dimension_fields', '.inline-edit-row' ).hide(); + } else { + $( '.dimension_fields', '.inline-edit-row' ).show().removeAttr( 'style' ); + } + + // Rename core strings. + $( 'input[name="comment_status"]' ).parent().find( '.checkbox-title' ).text( woocommerce_quick_edit.strings.allow_reviews ); + }); + + $(document).on('change', '#the-list .inline-edit-row input[name="_manage_stock"]', function() { + if ( $( this ).is( ':checked' ) ) { + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).show().removeAttr( 'style' ); + $( '.stock_status_field' ).hide(); + } else { + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).hide(); + $( '.stock_status_field' ).show().removeAttr( 'style' ); + } + }); + } + } + + // Let's initialize WPMF features + $(document).ready(function () { + wpmfFoldersModule.initModule(); + }); +})(jQuery); \ No newline at end of file diff --git a/wp/wp-content/plugins/wp-media-folder/assets/js/folder-tree-for-post-type.js b/wp/wp-content/plugins/wp-media-folder/assets/js/folder-tree-for-post-type.js new file mode 100644 index 00000000..70f66dfe --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/assets/js/folder-tree-for-post-type.js @@ -0,0 +1,1211 @@ +'use strict'; + +/** + * Folder tree for WP Media Folder + */ +var wpmfFoldersTreeModule = void 0; +(function ($) { + wpmfFoldersTreeModule = { + categories: [], // categories + folders_states: [], // Contains open or closed status of folders + cloudInterval: false, + folder_tree_status: '', + + /** + * Retrieve the Jquery tree view element + * of the current frame + * @return jQuery + */ + getTreeElement: function getTreeElement() { + return $('body').find('.wpmf-main-tree').first(); + }, + + /** + * Initialize module related things + */ + initModule: function initModule($current_frame) { + // Import categories from wpmf main module + wpmfFoldersTreeModule.importCategories(); + + var $menu = $current_frame.find('.media-frame-menu .media-menu'); + if (!$menu.length) { + $menu = $current_frame.find('.media-frame-menu'); + $current_frame.find('.media-frame-menu-heading').hide(); + } + if (!$menu.find('.wpmf-main-tree').length) { + $('
    ').appendTo($menu); + } + // Render the tree view + wpmfFoldersTreeModule.loadTreeView(); + + // Subscribe to the add folder event in main wpmf module + wpmfFoldersModule.on(['addFolder', 'deleteFolder', 'updateFolder', 'foldersSelection', 'loadmoreFolder'], function (folder) { + wpmfFoldersTreeModule.importCategories(); + wpmfFoldersTreeModule.loadTreeView(); + + var ajaxURL = wpmf.vars.current_url; + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof wpmfFoldersModule.categories[lastAccessFolder] !== 'undefined') { + var folderName = wpmfFoldersModule.categories[lastAccessFolder].slug; + var urlParams = new URLSearchParams(window.location.search); + if (typeof urlParams.get(wpmfFoldersModule.taxonomy) !== 'undefined' && (urlParams.get(wpmfFoldersModule.taxonomy) === '' || urlParams.get(wpmfFoldersModule.taxonomy) === null )) { + ajaxURL += folderName; + } + } else { + wpmfFoldersModule.setCookie('lastAccessFolder_' + wpmf.vars.host, 0, 365); + } + $("#wpbody").load(ajaxURL + " #wpbody-content", false, function (res) { + var obj = { Title: "", Url: ajaxURL }; + history.pushState(obj, obj.Title, obj.Url); + + wpmfFoldersTreeModule.initModule(wpmfFoldersModule.getFrame()); + }) + // Initialize folder tree resizing + wpmfFoldersTreeModule.initContainerResizing($current_frame); + }); + wpmfFoldersModule.on(['moveFolder'], function (folder) { + wpmfFoldersTreeModule.importCategories(); + wpmfFoldersTreeModule.loadTreeView(); + + // Initialize folder tree resizing + wpmfFoldersTreeModule.initContainerResizing($current_frame); + }); + }, + + /** + * Import categories from wpmf main module + */ + importCategories: function importCategories() { + var folders_ordered = wpmfFoldersModule.categories; + + var folder_order = wpmfFoldersModule.folders_order; + if (typeof folder_order !== "undefined") { + wpmfFoldersModule.folder_ordering = folder_order; + } else { + wpmfFoldersModule.folder_ordering = 'name-ASC'; + } + + // Order the array depending on main ordering + switch (wpmfFoldersModule.folder_ordering) { + default: + case 'name-ASC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + if (a.id === 0) return -1; // Root folder is always first + if (b.id === 0) return 1; // Root folder is always first + return a.label.localeCompare(b.label); + }); + break; + case 'name-DESC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + if (a.id === 0) return -1; // Root folder is always first + if (b.id === 0) return 1; // Root folder is always first + return b.label.localeCompare(a.label); + }); + break; + case 'id-ASC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + if (a.id === 0) return -1; // Root folder is always first + if (b.id === 0) return 1; // Root folder is always first + return a.id - b.id; + }); + break; + case 'id-DESC': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + if (a.id === 0) return -1; // Root folder is always first + if (b.id === 0) return 1; // Root folder is always first + return b.id - a.id; + }); + break; + case 'custom': + folders_ordered = Object.values(folders_ordered).sort(function (a, b) { + if (a.id === 0 && b.id !== 0) return -1; // Root folder is always first + if (a.id !== 0 && b.id === 0) return 1; // Root folder is always first + // Make sure id = -1 always comes after id 0 and before other ids + if (a.id === -1 && b.id !== -1) return -1; + if (a.id !== -1 && b.id === -1) return 1; + return a.order - b.order; + }); + break; + } + + // Reorder array based on children + var folders_ordered_deep = []; + var processed_ids = []; + var loadChildren = function loadChildren(id) { + if (processed_ids.indexOf(id) < 0) { + processed_ids.push(id); + for (var ij = 0; ij < folders_ordered.length; ij++) { + if (folders_ordered[ij].parent_id === id) { + folders_ordered_deep.push(folders_ordered[ij]); + loadChildren(folders_ordered[ij].id); + } + } + } + }; + + loadChildren(0); + // Finally save it to the global var + wpmfFoldersTreeModule.categories = folders_ordered_deep; + }, + + /** + * Render tree view inside content + */ + loadTreeView: function loadTreeView() { + // update height for folder tree when toggle menu + if (wpmf.vars.wpmf_pagenow !== 'upload.php') { + var $current_frame = wpmfFoldersTreeModule.getTreeElement().closest('.media-frame'); + var $menu = $current_frame.find('.media-frame-menu'); + if (!$current_frame.find('.wpmf-toggle-media-menu').length) { + $current_frame.addClass('wpmf_hide_media_menu'); + $current_frame.find('.media-frame-menu-heading').append(' arrow_drop_down arrow_drop_up '); + $current_frame.find('.wpmf-toggle-media-menu').off('click').bind('click', function () { + var h = 220; + if ($menu.find('.wpmf-all-tree').hasClass('wpmf-tree-loadmore')) { + h += 70; + } + if ($current_frame.hasClass('wpmf_hide_media_menu')) { + $current_frame.removeClass('wpmf_hide_media_menu').addClass('wpmf_show_media_menu'); + var a = $menu.find(".media-menu-item").length; + $menu.find('.wpmf-all-tree').height($menu.height() - 34 * a - h); + } else { + $current_frame.removeClass('wpmf_show_media_menu').addClass('wpmf_hide_media_menu'); + $menu.find('.wpmf-all-tree').height($menu.height() - h); + } + }); + } + } + + // render folder tree + wpmfFoldersTreeModule.getTreeElement().html(wpmfFoldersTreeModule.getRendering()); + wpmfFoldersTreeModule.initContainerResizing(wpmfFoldersModule.getFrame()); + $('.wpmf-loadmore-folder').unbind('click').bind('click', function () { + var count = $(this).data('count'); + count += parseInt(wpmfFoldersModule.limit_folders); + if (parseInt(count) < wpmfFoldersModule.categories_order_full.length) { + wpmfFoldersModule.categories_order = wpmfFoldersModule.categories_order_full.slice(0, count); + wpmfFoldersModule.trigger('loadmoreFolder'); + } + }); + + $('.wpmf-cancel-remove-folders-btn').unbind('click').bind('click', function (e) { + e.preventDefault(); + $('.wpmf-folder-actions').toggleClass('wpmf-deactivate'); + $('.wpmf-tree-actions').find('.wpmf-new-folder').removeClass('hide'); + $('.wpmf-tree-checkbox').addClass('hide'); + }); + + $('.wpmf-remove-folders-btn').unbind('click').bind('click', function (e) { + e.preventDefault(); + if (!$(this).hasClass('disabled')) { + var ids = []; + $('.wpmf-tree-checkbox:checked').each(function (i, checkbox) { + var folder_id = $(checkbox).val(); + ids.push(folder_id); + }); + showDialog({ + title: wpmf.l18n.delete_multiple_folder.replace('%d', ids.length), + negative: { + title: wpmf.l18n.cancel + }, + positive: { + title: wpmf.l18n.delete, + onClick: function onClick() { + wpmfFoldersModule.deleteMultipleFolders(ids); + } + } + }); + } + }); + + $('.wpmf-tree-checkbox').unbind('click').bind('click', function () { + if ($(this).is(':checked')) { + $(this).closest('li').find('ul .wpmf-tree-checkbox').prop('checked', true); + } else { + $(this).closest('li').find('ul .wpmf-tree-checkbox').prop('checked', false); + } + if ($('.wpmf-tree-checkbox:checked').length) { + $('.wpmf-remove-folders-btn').removeClass('disabled'); + } else { + $('.wpmf-remove-folders-btn').addClass('disabled'); + } + }); + + // load count by subfolders + if (wpmfFoldersModule.show_files_count) { + if (wpmfFoldersTreeModule.categories.length < 1000) { + wpmfFoldersTreeModule.loadCountAll(); + } else { + wpmfFoldersTreeModule.getTreeElement().addClass('wpmf-many-folders'); + } + } + wpmfFoldersModule.openContextMenuFolder(); + var append_element = void 0; + + if (wpmfFoldersModule.page_type === 'upload-list') { + append_element = '#posts-filter'; + } else { + append_element = '.media-frame'; + } + + var folder_order = wpmfFoldersModule.folders_order; + var sortable = false; + if (typeof folder_order !== "undefined" && folder_order === 'custom') { + sortable = true; + } + + if (sortable) { + if ($().sortable) { + wpmfFoldersTreeModule.getTreeElement().find('ul').sortable({ + placeholder: 'wpmf_tree_drop_sort', + delay: 100, // Prevent dragging when only trying to click + distance: 10, + cursorAt: { top: 10, left: 10 }, + revert: true, + revertDuration: 1000, + scroll: false, + /*tolerance: "intersect",*/ + helper: function helper(ui) { + var helper = '
    '; + helper += 'folder'; + helper += ' ' + wpmf.l18n.folder_moving_text + ' '; + helper += '
    '; + return helper; + }, + /** Prevent firefox bug positionnement **/ + start: function start(event, ui) { + wpmfFoldersTreeModule.getTreeElement().addClass('wpmf_tree_sorting'); + var userAgent = navigator.userAgent.toLowerCase(); + if (ui.helper !== "undefined" && userAgent.match(/firefox/)) { + ui.helper.css('position', 'absolute'); + } + }, + stop: function stop(event, ui) { + wpmfFoldersTreeModule.getTreeElement().removeClass('wpmf_tree_sorting'); + }, + beforeStop: function beforeStop(event, ui) {}, + update: function update(event, ui) { + var order = ''; + $(event.target).find('li').each(function (i, val) { + var id = $(val).data('id'); + if (id !== 0) { + if (order !== '') { + order += ','; + } + order += '"' + i + '":' + id; + wpmfFoldersModule.categories[id].order = i; + } + }); + order = '{' + order + '}'; + + $.ajax({ + type: "POST", + url: ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "reorderfolder", + folder_post_type_name: wpmfFoldersModule.taxonomy, + order: order, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + success: function success(res) { + if (typeof res.status !== "undefined") { + if (res.status) { + wpmfFoldersTreeModule.importCategories(); + wpmfFoldersTreeModule.loadTreeView(); + wpmfFoldersModule.renderFolders(); + } + } + } + }); + } + }).disableSelection(); + } + } else { + if ($().draggable) { + // Initialize dragping folder on tree view + wpmfFoldersTreeModule.getTreeElement().find('ul li .wpmf-item[data-id!="0"]').draggable({ + revert: true, + revertDuration: 1000, + helper: function helper(ui) { + var helper = '
    '; + helper += 'folder'; + helper += ' ' + wpmf.l18n.folder_moving_text + ' '; + helper += '
    '; + return helper; + }, + appendTo: append_element, + delay: 100, // Prevent dragging when only trying to click + distance: 10, + cursorAt: { top: 0, left: 0 }, + drag: function drag() {}, + start: function start(event, ui) { + // Add the original size of element + $(ui.helper).css('width', $(ui.helper.context).outerWidth() + 'px'); + $(ui.helper).css('height', $(ui.helper.context).outerWidth() + 'px'); + + // Add some style to original elements + $(this).addClass('wpmf-dragging'); + }, + stop: function stop(event, ui) { + // Revert style + $(this).removeClass('wpmf-dragging'); + } + }); + } + } + + if ($().droppable) { + // Initialize dropping folder on tree view + wpmfFoldersTreeModule.getTreeElement().find('ul li .wpmf-item-inside').droppable({ + hoverClass: "wpmf-hover-folder", + tolerance: 'pointer', + over: function over(event, ui) { + $('.wpmf_tree_drop_sort').hide(); + }, + out: function out(event, ui) { + $('.wpmf_tree_drop_sort').show(); + }, + drop: function drop(event, ui) { + event.stopPropagation(); + $(ui.helper).addClass('wpmf_dragout'); + var folderID = $(this).data('id'); + if ($(ui.draggable).hasClass('wpmf-folder') || $(ui.draggable).hasClass('wpmf-item') || (sortable && (!$(ui.draggable).hasClass('wpmf-folder-move-multiple') && !$(ui.draggable).hasClass('wpmf-folder-move-file')))) { + // move folder with folder tree + wpmfFoldersModule.moveFolder($(ui.draggable).data('id'), folderID); + } else { + // Assign folder to post + if ($(ui.draggable).hasClass('wpmf-folder-move-multiple') || ($(ui.draggable).hasClass('wpmf-folder-move-file') && $(".wp-list-table tbody .check-column input:checked").length) ) { + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: 'wpmf_folder_post_type', + task: 'assign_folder_to_post', + type: 'multiple', + post_id: $('.wpmf-folder-move-multiple input').val(), + folder_id: folderID, + folder_post_type_name: wpmfFoldersModule.taxonomy, + post_type: wpmfFoldersModule.post_type, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + success: function success(response) { + if (typeof response.status !== "undefined") { + if (response.status) { + wpmfFoldersModule.categories = response.categories; + wpmfFoldersTreeModule.importCategories(); + wpmfFoldersTreeModule.loadTreeView(); + + var ajaxURL = wpmf.vars.current_url; + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof wpmfFoldersModule.categories[lastAccessFolder] !== 'undefined') { + var folderName = wpmfFoldersModule.categories[lastAccessFolder].slug; + var urlParams = new URLSearchParams(window.location.search); + if (typeof urlParams.get(wpmfFoldersModule.taxonomy) !== 'undefined' && (urlParams.get(wpmfFoldersModule.taxonomy) === '' || urlParams.get(wpmfFoldersModule.taxonomy) === null )) { + ajaxURL += folderName; + } + } + $("#wpbody").load(ajaxURL + " #wpbody-content", false, function (res) { + var obj = { Title: "", Url: ajaxURL }; + history.pushState(obj, obj.Title, obj.Url); + + wpmfFoldersTreeModule.initModule(wpmfFoldersModule.getFrame()); + }) + } else { + if (typeof response.error !== "undefined") { + //todo: change wrong variable name to something more understandable like message or error_message, and what should we do if wrong is set? + showDialog({ + title: wpmf.l18n.information, + text: response.error, + closeicon: true + }); + } + } + } + } + }) + } else if($(ui.draggable).hasClass('wpmf-folder-move-file')) { + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: 'wpmf_folder_post_type', + task: 'assign_folder_to_post', + type: 'single', + post_id: $(ui.draggable).data('id'), + folder_id: folderID, + folder_post_type_name: wpmfFoldersModule.taxonomy, + post_type: wpmfFoldersModule.post_type, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + success: function success(response) { + if (typeof response.status !== "undefined") { + if (response.status) { + wpmfFoldersModule.categories = response.categories; + wpmfFoldersTreeModule.importCategories(); + wpmfFoldersTreeModule.loadTreeView(); + + var ajaxURL = wpmf.vars.current_url; + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof wpmfFoldersModule.categories[lastAccessFolder] !== 'undefined') { + var folderName = wpmfFoldersModule.categories[lastAccessFolder].slug; + var urlParams = new URLSearchParams(window.location.search); + if (typeof urlParams.get(wpmfFoldersModule.taxonomy) !== 'undefined' && (urlParams.get(wpmfFoldersModule.taxonomy) === '' || urlParams.get(wpmfFoldersModule.taxonomy) === null )) { + ajaxURL += folderName; + } + } + $("#wpbody").load(ajaxURL + " #wpbody-content", false, function (res) { + var obj = { Title: "", Url: ajaxURL }; + history.pushState(obj, obj.Title, obj.Url); + + wpmfFoldersTreeModule.initModule(wpmfFoldersModule.getFrame()); + }) + } else { + if (typeof response.error !== "undefined") { + //todo: change wrong variable name to something more understandable like message or error_message, and what should we do if wrong is set? + showDialog({ + title: wpmf.l18n.information, + text: response.error, + closeicon: true + }); + } + } + } + } + }) + } + } + } + }); + } + + if ($().draggable) { + // Initialize dragping folder on tree view + jQuery('.wpmf-folder-move-file').draggable({ + revert: true, + revertDuration: 1000, + helper: function helper(ui) { + var helper = '
    '; + helper += $(this).html(); + helper += '
    '; + + var counter = 0; + var selected_txt = wpmf.l18n.select_this_item; + if($(".wp-list-table tbody .check-column input:checked").length) { + var chkStr = ""; + $(".wp-list-table tbody .check-column input:checked").each(function(){ + chkStr += $(this).val()+","; + counter++; + }); + $('.wpmf-folder-move-multiple input').val(chkStr); + selected_txt = wpmf.l18n.item_selected; + if (counter > 1) { + selected_txt = wpmf.l18n.items_selected; + } + selected_txt = counter + ' ' + selected_txt; + } + helper = '
    '; + helper += '' + selected_txt + ''; + helper += '
    '; + + return helper; + }, + appendTo: $('body'), + delay: 100, // Prevent dragging when only trying to click + distance: 10, + cursorAt: { top: 0, left: 0 }, + drag: function drag() {}, + start: function start(event, ui) { + // Add the original size of element + $(ui.helper).css('width', $(ui.helper.context).outerWidth() + 'px'); + $(ui.helper).css('height', $(ui.helper.context).outerWidth() + 'px'); + + // Add some style to original elements + $(this).addClass('wpmf-dragging'); + }, + stop: function stop(event, ui) { + // Revert style + $(this).removeClass('wpmf-dragging'); + } + }); + $('.wpmf-folder-move-multiple').draggable({ + revert: true, + revertDuration: 1000, + helper: function helper(ui) { + var counter = 0; + var selected_txt = wpmf.l18n.select_item; + if($(".wp-list-table tbody .check-column input:checked").length) { + var chkStr = ""; + $(".wp-list-table tbody .check-column input:checked").each(function(){ + chkStr += $(this).val()+","; + counter++; + }); + $('.wpmf-folder-move-multiple input').val(chkStr); + selected_txt = wpmf.l18n.item_selected; + if (counter > 1) { + selected_txt = wpmf.l18n.items_selected; + } + selected_txt = counter + ' ' + selected_txt; + } + var helper = '
    '; + helper += '' + selected_txt + ''; + helper += '
    '; + return helper; + }, + appendTo: $('body'), + delay: 100, // Prevent dragging when only trying to click + distance: 10, + cursorAt: { top: 0, left: 0 }, + drag: function drag() {}, + start: function start(event, ui) { + // Add the original size of element + $(ui.helper).css('width', $(ui.helper.context).outerWidth() + 'px'); + $(ui.helper).css('height', $(ui.helper.context).outerWidth() + 'px'); + + // Add some style to original elements + $(this).addClass('wpmf-dragging'); + }, + stop: function stop(event, ui) { + // Revert style + $(this).removeClass('wpmf-dragging'); + } + }); + + } + + // Initialize change keyword to search folder + wpmfFoldersTreeModule.getTreeElement().find('.searchfolder').on('click', function (e) { + wpmfFoldersTreeModule.doSearch(); + }); + + // search with enter key + $('.wpmf_search_folder').on('keypress', function (e) { + if (e.which === 13) { + wpmfFoldersTreeModule.doSearch(); + return false; + } + }); + + $(".wpmf_search_folder").wpmfHandleKeyboardChange(1000).change(function () { + wpmfFoldersTreeModule.doSearch(); + }); + + // Initialize double click to folder title on tree view + wpmfFoldersTreeModule.getTreeElement().find('ul .wpmf-item[data-id]').wpmfSingleDoubleClick(function (e) { + if ($(e.target).hasClass('wpmf-arrow') || $(e.target).hasClass('wpmf-tree-checkbox')) { + return; + } + if (!$(e.target).closest('.wpmf-item').find('.wpmf-tree-checkbox').hasClass('hide') && $(e.target).closest('.wpmf-item').data('id') > 0) { + return; + } + // single click + var id = $(this).data('id'); + if (parseInt(id) !== parseInt(wpmfFoldersModule.last_selected_folder)) { + wpmfFoldersModule.changeFolder(id); + } + }, function (e) { + // double click + var id = $(this).data('id'); + wpmfFoldersModule.clickEditFolder(e, id); + wpmfFoldersModule.houtside(); + }); + + var folderStatus = wpmf.vars.minimize_folder_tree; + if (typeof wpmf.vars.folder_tree_status[wpmf.vars.post_type] !== 'undefined') { + folderStatus = wpmf.vars.folder_tree_status[wpmf.vars.post_type]; + } + if (wpmfFoldersTreeModule.folder_tree_status !== '') { + folderStatus = wpmfFoldersTreeModule.folder_tree_status; + } + if (folderStatus == 'show') { + var classHideFolderBtn = 'active'; + var classShowFolderBtn = ''; + } else { + var classHideFolderBtn = ''; + var classShowFolderBtn = 'active'; + } + var show_hide_btn = '
    '; + show_hide_btn += '
    '; + show_hide_btn += '
    '; + show_hide_btn += '
    '; + wpmfFoldersTreeModule.getTreeElement().append(show_hide_btn); + + wpmfFoldersTreeModule.getTreeElement().append('
    '); + wpmfFoldersTreeModule.getTreeElement().find('.wpmf_media_library').appendTo(wpmfFoldersTreeModule.getTreeElement().find('.wpmf-all-tree')); + + // load scroll bar + if (wpmfFoldersTreeModule.getTreeElement().find('.wpmf-all-tree').is(':visible')) { + wpmfFoldersTreeModule.getTreeElement().find('.wpmf-all-tree').scrollbar(); + if (wpmf.vars.wpmf_pagenow !== 'upload.php') { + var $menu1 = wpmfFoldersTreeModule.getTreeElement().closest('.media-frame').find('.media-frame-menu'); + var h = 220; + if ($menu1.find('.wpmf-all-tree').hasClass('wpmf-tree-loadmore')) { + h += 70; + } + $menu1.find('.wpmf-all-tree').height($menu1.height() - h); + } + } + // if (wpmfFoldersModule.categories_order_full.length > wpmfFoldersModule.limit_folders) { + // $('.wpmf-all-tree').addClass('wpmf-tree-loadmore'); + // } + }, + + loadCountAll: function loadCountAll() { + wpmfFoldersTreeModule.getTreeElement().find('li').each(function (i, element) { + var id = $(element).data('id'); + if (parseInt(id) !== 0) { + var countElements = $(element).find('.wpmf-item-count'); + var count = 0; + $(countElements).each(function (index, countElement) { + count += parseInt($(countElement).html()); + }); + + $(element).find('> .wpmf-item .wpmf-item-count-all').html(count); + } + }); + }, + + /** + * Do search folder + */ + doSearch: function doSearch() { + // search on folder tree + var keyword = $('.wpmf_search_folder').val().trim().toLowerCase(); + var search_folders = []; + // get folder when disable folders on right bar + var folder_search = []; + for (var folder_id in wpmfFoldersModule.categories) { + if (keyword !== '') { + keyword = keyword.trim().toLowerCase(); + var folder_name = wpmfFoldersModule.categories[folder_id].lower_label; + if (folder_name.indexOf(keyword) !== -1) { + folder_search.push(folder_id); + } + } + } + search_folders = folder_search; + if (keyword !== '') { + $('.wpmf-main-tree li').addClass('folderhide').removeClass('foldershow'); + $.each(search_folders, function (i, v) { + $('.wpmf-main-tree li[data-id="' + v + '"]').addClass('foldershow').removeClass('folderhide closed'); + $('.wpmf-main-tree li[data-id="' + v + '"]').parents('.wpmf-main-tree li').addClass('foldershow').removeClass('folderhide closed'); + }); + + if ($('.foldershow').length) { + $('.search_no_result_wrap').hide(); + wpmfFoldersTreeModule.getTreeElement().find('.wpmf-all-tree').show(); + } else { + $('.search_no_result_wrap').show(); + wpmfFoldersTreeModule.getTreeElement().find('.wpmf-all-tree').hide(); + } + } else { + $('.wpmf-main-tree li').removeClass('foldershow folderhide'); + $('.search_no_result_wrap').hide(); + wpmfFoldersTreeModule.getTreeElement().find('.wpmf-all-tree').show(); + } + }, + + /** + * Get the html resulting tree view + * @return {string} + */ + getRendering: function getRendering() { + var ij = 0; + var content = ''; // Final tree view cwpmf-main-tree-resizeontent + // render search folder box + var search_folder = '\n \n '; + + var remove_folder = '
    \n ' + wpmf.l18n.delete + '\n \n ' + wpmf.l18n.cancel + '\n
    '; + + var search_no_result = '
    \n\n\n\n

    ' + wpmf.l18n.search_no_result + '

    \n
    '; + + // get last status folder tree + var lastStatusTree = wpmfFoldersModule.getCookie('lastStatusTree_' + wpmf.vars.host); + if (lastStatusTree !== '') { + lastStatusTree = JSON.parse(lastStatusTree); + } + + /** + * Recursively print list of folders + * @return {boolean} + */ + var generateList = function generateList() { + var tree_class = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; + + content += ''; + } + + // We are at the end don't continue to process array + return false; + } + + if (wpmfFoldersTreeModule.categories[ij + 1].depth > wpmfFoldersTreeModule.categories[ij].depth) { + // The next element is a sub folder + // Recursively list it + ij++; + if (generateList() === false) { + // We have reached the end, let's recursively end + return false; + } + } else if (wpmfFoldersTreeModule.categories[ij + 1].depth < wpmfFoldersTreeModule.categories[ij].depth) { + // The next element don't have the same parent + // Let's close opened tags + for (var _ik = wpmfFoldersTreeModule.categories[ij].depth; _ik > wpmfFoldersTreeModule.categories[ij + 1].depth; _ik--) { + content += ''; + content += ''; + } + + // We're not at the end of the array let's continue processing it + return true; + } + + // Close the current element + content += ''; + ij++; + } + }; + + // Start generation + generateList('wpmf_media_library'); + + var loadmore = ''; + // if (wpmfFoldersModule.categories_order_full.length > wpmfFoldersModule.limit_folders) { + // loadmore = ' expand_more ' + wpmf.l18n.load_more + ''; + // } + + // Add the new folder button + content = '
    add' + wpmf.l18n.create_folder + '' + remove_folder + '
    ' + search_folder + content + loadmore + search_no_result; + + return content; + }, + + /** + * Change the selected folder in tree view + * @param folder_id + */ + changeFolder: function changeFolder(folder_id) { + // Remove previous selection + wpmfFoldersTreeModule.getTreeElement().find('li').removeClass('selected'); + + // Select the folder + wpmfFoldersTreeModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('selected'). // Open parent folders + parents('.wpmf-main-tree li.closed').removeClass('closed'); + }, + + /** + * Toggle the open / closed state of a folder + * @param folder_id + */ + toggle: function toggle(folder_id) { + // get last status folder tree + var lastStatusTree = []; + // Check is folder has closed class + if (wpmfFoldersTreeModule.getTreeElement().find('li[data-id="' + folder_id + '"]').hasClass('closed')) { + // Open the folder + wpmfFoldersTreeModule.openFolder(folder_id); + } else { + // Close the folder + wpmfFoldersTreeModule.closeFolder(folder_id); + // close all sub folder + $('li[data-id="' + folder_id + '"]').find('li').addClass('closed'); + } + + wpmfFoldersTreeModule.getTreeElement().find('li:not(.closed)').each(function (i, v) { + var id = $(v).data('id'); + lastStatusTree.push(id); + }); + // set last status folder tree + wpmfFoldersModule.setCookie("lastStatusTree_" + wpmf.vars.host, JSON.stringify(lastStatusTree), 365); + }, + + /** + * Open a folder to show children + */ + openFolder: function openFolder(folder_id) { + wpmfFoldersTreeModule.getTreeElement().find('li[data-id="' + folder_id + '"]').removeClass('closed'); + wpmfFoldersTreeModule.folders_states[folder_id] = 'open'; + }, + + /** + * Close a folder and hide children + */ + closeFolder: function closeFolder(folder_id) { + wpmfFoldersTreeModule.getTreeElement().find('li[data-id="' + folder_id + '"]').addClass('closed'); + wpmfFoldersTreeModule.folders_states[folder_id] = 'close'; + }, + + /** + * Initialize the fixed position when user is scrolling + * to keep the folder tree always visible + */ + initFixedScrolling: function initFixedScrolling() { + setTimeout(function () { + // Fix initial left margin in list view + if (wpmfFoldersModule.page_type === 'upload-list' || wpmfFoldersModule.page_type === 'upload-grid') { + var $tree = $('.wpmf-main-tree'); + var tree_width = $tree.outerWidth() + 'px'; + var $admin_bar_height = $('#wpadminbar').height(); + if ($admin_bar_height > 32) { + $tree.css('top', $admin_bar_height + 'px'); + } + $('#wpbody-content').css({ 'width': 'calc(100% - ' + tree_width + ')', 'margin-left': tree_width, 'opacity': 1, 'padding-left': '20px', 'box-sizing': 'border-box' }); + // trigger window resize to set attachments columns + if (wpmfFoldersModule.page_type === 'upload-grid') { + $(window).trigger('resize'); + } + $('.rtl #wpbody-content').css({ + 'margin-right': wpmfFoldersTreeModule.getTreeElement().outerWidth() + 'px', + 'margin-left': 0, + 'opacity': 1, + 'padding-right': '20px', + 'box-sizing': 'border-box' + }); + $tree.css({ 'opacity': 1 }); + // Remove the loader on list page + if (!$('.upload-php #posts-filter').hasClass('listview-loaded')) { + setTimeout(function () { + $('.upload-php #posts-filter').addClass('listview-loaded'); + }, 200); + } + } + }, 200); + }, + + /** + * Initialize folder tree resizing + * @param $current_frame + */ + initContainerResizing: function initContainerResizing($current_frame) { + var is_resizing = false; + var $body = $('body'); + + $(window).on('resize', function () { + $('.wpmf-all-tree.scrollbar-inner').scrollbar(); + }); + if (wpmf.vars.wpmf_pagenow === 'edit.php') { + var $main = $('#wpbody'); + var $tree = $('.wpmf-main-tree'); + var $tree_max_width = 500; + var $tree_min_width = 290; + + var $handle = $('
    ').appendTo($tree); + $handle.on('mousedown', function (e) { + is_resizing = true; + $('body').css('user-select', 'none'); // prevent content selection while moving + }); + + var folderStatus = wpmf.vars.minimize_folder_tree; + if (typeof wpmf.vars.folder_tree_status[wpmf.vars.post_type] !== 'undefined') { + folderStatus = wpmf.vars.folder_tree_status[wpmf.vars.post_type]; + } + if (wpmfFoldersTreeModule.folder_tree_status !== '') { + folderStatus = wpmfFoldersTreeModule.folder_tree_status; + } + + wpmfFoldersTreeModule.minimizedFolderTree(folderStatus); + if (folderStatus == 'show') { + var folderTreeSizeKey = wpmfFoldersModule.taxonomy; + var folderTreeSize = wpmfFoldersModule.getCookie(folderTreeSizeKey); + if (folderTreeSize < $tree_min_width) folderTreeSize = $tree_min_width; + if (typeof folderTreeSize !== "undefined" && parseFloat(folderTreeSize) > 0) { + $tree.css({ 'width': parseFloat(folderTreeSize) + 'px' }); + var folder_tree_width = parseFloat(folderTreeSize) + 20; + if ($('body').hasClass('rtl')) { + $('#wpcontent').css({ 'padding-right': folder_tree_width + 'px', 'box-sizing': 'border-box' }); + } else { + $('#wpcontent').css({ 'padding-left': folder_tree_width + 'px', 'box-sizing': 'border-box' }); + } + } + } + + $(document).on('mousemove', function (e) { + // we don't want to do anything if we aren't resizing. + if (!is_resizing) return; + + // Calculate tree width + var tree_width = e.clientX - $tree.offset().left; + if (tree_width < $tree_min_width) tree_width = $tree_min_width; + if (tree_width > $tree_max_width) { + tree_width = $tree_max_width; + } + + + var folder_tree_width = tree_width + 20; + + $tree.css('width', tree_width + 'px'); + // We have to set margin if we are in a fixed tree position or in list page + if ($('body').hasClass('rtl')) { + $('#wpcontent').css({ 'padding-right': folder_tree_width + 'px', 'box-sizing': 'border-box' }); + } else { + $('#wpcontent').css({ 'padding-left': folder_tree_width + 'px', 'box-sizing': 'border-box' }); + } + wpmfFoldersModule.setCookie(folderTreeSizeKey, tree_width, 365); + }).on('mouseup', function (e) { + if (is_resizing) { + // stop resizing + is_resizing = false; + $body.css('user-select', ''); + $(window).trigger('resize'); + } + }); + } + }, + + minimizedFolderTree: function minimizedFolderTree(folderStatus) { + if(folderStatus == "show") { + var $tree = $('.wpmf-main-tree'); + var $tree_max_width = 500; + var $tree_min_width = 290; + var folderTreeSizeKey = wpmfFoldersModule.taxonomy; + var folderTreeSize = wpmfFoldersModule.getCookie(folderTreeSizeKey); + if (folderTreeSize < $tree_min_width) folderTreeSize = $tree_min_width; + if (typeof folderTreeSize !== "undefined" && parseFloat(folderTreeSize) > 0) { + $tree.css({ 'width': parseFloat(folderTreeSize) + 'px' }); + var folder_tree_width = parseFloat(folderTreeSize) + 20; + if ($('body').hasClass('rtl')) { + $('#wpcontent').css({ 'padding-right': folder_tree_width + 'px', 'box-sizing': 'border-box' }); + } else { + $('#wpcontent').css({ 'padding-left': folder_tree_width + 'px', 'box-sizing': 'border-box' }); + } + } + $('.wpmf-folder-post-type').removeClass('wpmf-hide-folder-tree'); + } else { + if ($('body').hasClass('rtl')) { + $('#wpcontent').css({ 'padding-right': '25px', 'box-sizing': 'border-box' }); + } else { + $('#wpcontent').css({ 'padding-left': '25px', 'box-sizing': 'border-box' }); + } + $('.wpmf-folder-post-type').addClass('wpmf-hide-folder-tree'); + } + } + }; + + // Let's initialize WPMF folder tree features + $(document).ready(function () { + if (typeof wpmfFoldersModule !== "undefined") { + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof lastAccessFolder !== 'undefined') { + var lastAccessFolder = wpmfFoldersModule.getCookie('lastAccessFolder_' + wpmf.vars.host); + if (typeof wpmfFoldersModule.categories[lastAccessFolder] === 'undefined') { + wpmfFoldersModule.setCookie('lastAccessFolder_' + wpmf.vars.host, 0, 365); + } + } + + wpmfFoldersTreeModule.initModule(wpmfFoldersModule.getFrame()); + + $(document).on("click", ".subsubsub a", function(e){ + if($(".wpmf-folder-post-type .wpmf-main-tree").length) { + wpmfFoldersModule.setCookie('lastAccessFolder_' + wpmf.vars.host, 0, 365); + } + }); + + var folderCheckListClass = 'ul.cat-checklist.'+wpmfFoldersModule.taxonomy+'-checklist input[type="checkbox"]'; + $(document).on('change', folderCheckListClass, function() { + if ($(this).is(':checked')) { + $(folderCheckListClass).not(this).prop('checked', false); + } + }); + + $(document).on('click', '.wpmf-hide-show-buttons .toggle-buttons', function() { + var folderStatus = "show"; + if($(this).hasClass("hide-folders")) { + folderStatus = "hide"; + } + $(".wpmf-hide-show-buttons .toggle-buttons").toggleClass("active"); + wpmfFoldersTreeModule.minimizedFolderTree(folderStatus); + + $.ajax({ + type: "POST", + url: wpmf.vars.ajaxurl, + data: { + action: "wpmf_folder_post_type", + task: "change_folder_tree_display_status", + status: folderStatus, + post_type: wpmfFoldersModule.post_type, + wpmf_nonce: wpmf.vars.wpmf_nonce + }, + success: function success(response) { + if (response.status) { + wpmfFoldersTreeModule.folder_tree_status = folderStatus; + } + } + }); + }); + } + }); +})(jQuery); + +// call single click or double click on folder tree +jQuery.fn.wpmfSingleDoubleClick = function (single_click_callback, double_click_callback, timeout) { + return this.each(function () { + var clicks = 0, + self = this; + jQuery(this).on('click', function (event) { + clicks++; + if (clicks === 1) { + setTimeout(function () { + if (clicks === 1) { + single_click_callback.call(self, event); + } else { + double_click_callback.call(self, event); + } + clicks = 0; + }, timeout || 300); + } + }); + }); +}; + +jQuery.fn.wpmfHandleKeyboardChange = function (nDelay) { + // Utility function to test if a keyboard event should be ignored + function shouldIgnore(event) { + var mapIgnoredKeys = { + 9: true, // Tab + 16: true, 17: true, 18: true, // Shift, Alt, Ctrl + 37: true, 38: true, 39: true, 40: true, // Arrows + 91: true, 92: true, 93: true // Windows keys + }; + return mapIgnoredKeys[event.which]; + } + + // Utility function to fire OUR change event if the value was actually changed + function fireChange($element) { + if ($element.val() != jQuery.data($element[0], "valueLast")) { + jQuery.data($element[0], "valueLast", $element.val()); + $element.trigger("change"); + } + } + + // The currently running timeout, + // will be accessed with closures + var timeout = 0; + + // Utility function to cancel a previously set timeout + function clearPreviousTimeout() { + if (timeout) { + clearTimeout(timeout); + } + } + + return this.keydown(function (event) { + if (shouldIgnore(event)) return; + // User pressed a key, stop the timeout for now + clearPreviousTimeout(); + return null; + }).keyup(function (event) { + if (shouldIgnore(event)) return; + // Start a timeout to fire our event after some time of inactivity + // Eventually cancel a previously running timeout + clearPreviousTimeout(); + var $self = jQuery(this); + timeout = setTimeout(function () { + fireChange($self); + }, nDelay); + }).change(function () { + // Fire a change + // Use our function instead of just firing the event + // Because we want to check if value really changed since + // our previous event. + // This is for when the browser fires the change event + // though we already fired the event because of the timeout + fireChange(jQuery(this)); + }); +}; diff --git a/wp/wp-content/plugins/wp-media-folder/assets/js/pdf-embed/pdf-old.js b/wp/wp-content/plugins/wp-media-folder/assets/js/pdf-embed/pdf-old.js new file mode 100644 index 00000000..b0984738 --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/assets/js/pdf-embed/pdf-old.js @@ -0,0 +1,10905 @@ +/* Copyright 2012 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* jshint globalstrict: false */ +/* umdutils ignore */ + +(function (root, factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { +define('pdfjs-dist/build/pdf', ['exports'], factory); + } else if (typeof exports !== 'undefined') { + factory(exports); + } else { +factory((root.pdfjsDistBuildPdf = {})); + } +}(this, function (exports) { + // Use strict in our context only - users might not want it + 'use strict'; + +var pdfjsVersion = '1.5.322'; +var pdfjsBuild = 'b6826a4'; + + var pdfjsFilePath = + typeof document !== 'undefined' && document.currentScript ? + document.currentScript.src : null; + + var pdfjsLibs = {}; + + (function pdfjsWrapper() { + + + +(function (root, factory) { + { + factory((root.pdfjsSharedUtil = {})); + } +}(this, function (exports) { + +var globalScope = (typeof window !== 'undefined') ? window : + (typeof global !== 'undefined') ? global : + (typeof self !== 'undefined') ? self : this; + +var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; + +var TextRenderingMode = { + FILL: 0, + STROKE: 1, + FILL_STROKE: 2, + INVISIBLE: 3, + FILL_ADD_TO_PATH: 4, + STROKE_ADD_TO_PATH: 5, + FILL_STROKE_ADD_TO_PATH: 6, + ADD_TO_PATH: 7, + FILL_STROKE_MASK: 3, + ADD_TO_PATH_FLAG: 4 +}; + +var ImageKind = { + GRAYSCALE_1BPP: 1, + RGB_24BPP: 2, + RGBA_32BPP: 3 +}; + +var AnnotationType = { + TEXT: 1, + LINK: 2, + FREETEXT: 3, + LINE: 4, + SQUARE: 5, + CIRCLE: 6, + POLYGON: 7, + POLYLINE: 8, + HIGHLIGHT: 9, + UNDERLINE: 10, + SQUIGGLY: 11, + STRIKEOUT: 12, + STAMP: 13, + CARET: 14, + INK: 15, + POPUP: 16, + FILEATTACHMENT: 17, + SOUND: 18, + MOVIE: 19, + WIDGET: 20, + SCREEN: 21, + PRINTERMARK: 22, + TRAPNET: 23, + WATERMARK: 24, + THREED: 25, + REDACT: 26 +}; + +var AnnotationFlag = { + INVISIBLE: 0x01, + HIDDEN: 0x02, + PRINT: 0x04, + NOZOOM: 0x08, + NOROTATE: 0x10, + NOVIEW: 0x20, + READONLY: 0x40, + LOCKED: 0x80, + TOGGLENOVIEW: 0x100, + LOCKEDCONTENTS: 0x200 +}; + +var AnnotationBorderStyleType = { + SOLID: 1, + DASHED: 2, + BEVELED: 3, + INSET: 4, + UNDERLINE: 5 +}; + +var StreamType = { + UNKNOWN: 0, + FLATE: 1, + LZW: 2, + DCT: 3, + JPX: 4, + JBIG: 5, + A85: 6, + AHX: 7, + CCF: 8, + RL: 9 +}; + +var FontType = { + UNKNOWN: 0, + TYPE1: 1, + TYPE1C: 2, + CIDFONTTYPE0: 3, + CIDFONTTYPE0C: 4, + TRUETYPE: 5, + CIDFONTTYPE2: 6, + TYPE3: 7, + OPENTYPE: 8, + TYPE0: 9, + MMTYPE1: 10 +}; + +var VERBOSITY_LEVELS = { + errors: 0, + warnings: 1, + infos: 5 +}; + +// All the possible operations for an operator list. +var OPS = { + // Intentionally start from 1 so it is easy to spot bad operators that will be + // 0's. + dependency: 1, + setLineWidth: 2, + setLineCap: 3, + setLineJoin: 4, + setMiterLimit: 5, + setDash: 6, + setRenderingIntent: 7, + setFlatness: 8, + setGState: 9, + save: 10, + restore: 11, + transform: 12, + moveTo: 13, + lineTo: 14, + curveTo: 15, + curveTo2: 16, + curveTo3: 17, + closePath: 18, + rectangle: 19, + stroke: 20, + closeStroke: 21, + fill: 22, + eoFill: 23, + fillStroke: 24, + eoFillStroke: 25, + closeFillStroke: 26, + closeEOFillStroke: 27, + endPath: 28, + clip: 29, + eoClip: 30, + beginText: 31, + endText: 32, + setCharSpacing: 33, + setWordSpacing: 34, + setHScale: 35, + setLeading: 36, + setFont: 37, + setTextRenderingMode: 38, + setTextRise: 39, + moveText: 40, + setLeadingMoveText: 41, + setTextMatrix: 42, + nextLine: 43, + showText: 44, + showSpacedText: 45, + nextLineShowText: 46, + nextLineSetSpacingShowText: 47, + setCharWidth: 48, + setCharWidthAndBounds: 49, + setStrokeColorSpace: 50, + setFillColorSpace: 51, + setStrokeColor: 52, + setStrokeColorN: 53, + setFillColor: 54, + setFillColorN: 55, + setStrokeGray: 56, + setFillGray: 57, + setStrokeRGBColor: 58, + setFillRGBColor: 59, + setStrokeCMYKColor: 60, + setFillCMYKColor: 61, + shadingFill: 62, + beginInlineImage: 63, + beginImageData: 64, + endInlineImage: 65, + paintXObject: 66, + markPoint: 67, + markPointProps: 68, + beginMarkedContent: 69, + beginMarkedContentProps: 70, + endMarkedContent: 71, + beginCompat: 72, + endCompat: 73, + paintFormXObjectBegin: 74, + paintFormXObjectEnd: 75, + beginGroup: 76, + endGroup: 77, + beginAnnotations: 78, + endAnnotations: 79, + beginAnnotation: 80, + endAnnotation: 81, + paintJpegXObject: 82, + paintImageMaskXObject: 83, + paintImageMaskXObjectGroup: 84, + paintImageXObject: 85, + paintInlineImageXObject: 86, + paintInlineImageXObjectGroup: 87, + paintImageXObjectRepeat: 88, + paintImageMaskXObjectRepeat: 89, + paintSolidColorImageMask: 90, + constructPath: 91 +}; + +var verbosity = VERBOSITY_LEVELS.warnings; + +function setVerbosityLevel(level) { + verbosity = level; +} + +function getVerbosityLevel() { + return verbosity; +} + +// A notice for devs. These are good for things that are helpful to devs, such +// as warning that Workers were disabled, which is important to devs but not +// end users. +function info(msg) { + if (verbosity >= VERBOSITY_LEVELS.infos) { + console.log('Info: ' + msg); + } +} + +// Non-fatal warnings. +function warn(msg) { + if (verbosity >= VERBOSITY_LEVELS.warnings) { + console.log('Warning: ' + msg); + } +} + +// Deprecated API function -- display regardless of the PDFJS.verbosity setting. +function deprecated(details) { + console.log('Deprecated API usage: ' + details); +} + +// Fatal errors that should trigger the fallback UI and halt execution by +// throwing an exception. +function error(msg) { + if (verbosity >= VERBOSITY_LEVELS.errors) { + console.log('Error: ' + msg); + console.log(backtrace()); + } + throw new Error(msg); +} + +function backtrace() { + try { + throw new Error(); + } catch (e) { + return e.stack ? e.stack.split('\n').slice(2).join('\n') : ''; + } +} + +function assert(cond, msg) { + if (!cond) { + error(msg); + } +} + +var UNSUPPORTED_FEATURES = { + unknown: 'unknown', + forms: 'forms', + javaScript: 'javaScript', + smask: 'smask', + shadingPattern: 'shadingPattern', + font: 'font' +}; + +// Checks if URLs have the same origin. For non-HTTP based URLs, returns false. +function isSameOrigin(baseUrl, otherUrl) { + try { + var base = new URL(baseUrl); + if (!base.origin || base.origin === 'null') { + return false; // non-HTTP url + } + } catch (e) { + return false; + } + + var other = new URL(otherUrl, base); + return base.origin === other.origin; +} + +// Validates if URL is safe and allowed, e.g. to avoid XSS. +function isValidUrl(url, allowRelative) { + if (!url || typeof url !== 'string') { + return false; + } + // RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1) + // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) + var protocol = /^[a-z][a-z0-9+\-.]*(?=:)/i.exec(url); + if (!protocol) { + return allowRelative; + } + protocol = protocol[0].toLowerCase(); + switch (protocol) { + case 'http': + case 'https': + case 'ftp': + case 'mailto': + case 'tel': + return true; + default: + return false; + } +} + +function shadow(obj, prop, value) { + Object.defineProperty(obj, prop, { value: value, + enumerable: true, + configurable: true, + writable: false }); + return value; +} + +function getLookupTableFactory(initializer) { + var lookup; + return function () { + if (initializer) { + lookup = Object.create(null); + initializer(lookup); + initializer = null; + } + return lookup; + }; +} + +var PasswordResponses = { + NEED_PASSWORD: 1, + INCORRECT_PASSWORD: 2 +}; + +var PasswordException = (function PasswordExceptionClosure() { + function PasswordException(msg, code) { + this.name = 'PasswordException'; + this.message = msg; + this.code = code; + } + + PasswordException.prototype = new Error(); + PasswordException.constructor = PasswordException; + + return PasswordException; +})(); + +var UnknownErrorException = (function UnknownErrorExceptionClosure() { + function UnknownErrorException(msg, details) { + this.name = 'UnknownErrorException'; + this.message = msg; + this.details = details; + } + + UnknownErrorException.prototype = new Error(); + UnknownErrorException.constructor = UnknownErrorException; + + return UnknownErrorException; +})(); + +var InvalidPDFException = (function InvalidPDFExceptionClosure() { + function InvalidPDFException(msg) { + this.name = 'InvalidPDFException'; + this.message = msg; + } + + InvalidPDFException.prototype = new Error(); + InvalidPDFException.constructor = InvalidPDFException; + + return InvalidPDFException; +})(); + +var MissingPDFException = (function MissingPDFExceptionClosure() { + function MissingPDFException(msg) { + this.name = 'MissingPDFException'; + this.message = msg; + } + + MissingPDFException.prototype = new Error(); + MissingPDFException.constructor = MissingPDFException; + + return MissingPDFException; +})(); + +var UnexpectedResponseException = + (function UnexpectedResponseExceptionClosure() { + function UnexpectedResponseException(msg, status) { + this.name = 'UnexpectedResponseException'; + this.message = msg; + this.status = status; + } + + UnexpectedResponseException.prototype = new Error(); + UnexpectedResponseException.constructor = UnexpectedResponseException; + + return UnexpectedResponseException; +})(); + +var NotImplementedException = (function NotImplementedExceptionClosure() { + function NotImplementedException(msg) { + this.message = msg; + } + + NotImplementedException.prototype = new Error(); + NotImplementedException.prototype.name = 'NotImplementedException'; + NotImplementedException.constructor = NotImplementedException; + + return NotImplementedException; +})(); + +var MissingDataException = (function MissingDataExceptionClosure() { + function MissingDataException(begin, end) { + this.begin = begin; + this.end = end; + this.message = 'Missing data [' + begin + ', ' + end + ')'; + } + + MissingDataException.prototype = new Error(); + MissingDataException.prototype.name = 'MissingDataException'; + MissingDataException.constructor = MissingDataException; + + return MissingDataException; +})(); + +var XRefParseException = (function XRefParseExceptionClosure() { + function XRefParseException(msg) { + this.message = msg; + } + + XRefParseException.prototype = new Error(); + XRefParseException.prototype.name = 'XRefParseException'; + XRefParseException.constructor = XRefParseException; + + return XRefParseException; +})(); + +var NullCharactersRegExp = /\x00/g; + +function removeNullCharacters(str) { + if (typeof str !== 'string') { + warn('The argument for removeNullCharacters must be a string.'); + return str; + } + return str.replace(NullCharactersRegExp, ''); +} + +function bytesToString(bytes) { + assert(bytes !== null && typeof bytes === 'object' && + bytes.length !== undefined, 'Invalid argument for bytesToString'); + var length = bytes.length; + var MAX_ARGUMENT_COUNT = 8192; + if (length < MAX_ARGUMENT_COUNT) { + return String.fromCharCode.apply(null, bytes); + } + var strBuf = []; + for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) { + var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length); + var chunk = bytes.subarray(i, chunkEnd); + strBuf.push(String.fromCharCode.apply(null, chunk)); + } + return strBuf.join(''); +} + +function stringToBytes(str) { + assert(typeof str === 'string', 'Invalid argument for stringToBytes'); + var length = str.length; + var bytes = new Uint8Array(length); + for (var i = 0; i < length; ++i) { + bytes[i] = str.charCodeAt(i) & 0xFF; + } + return bytes; +} + +/** + * Gets length of the array (Array, Uint8Array, or string) in bytes. + * @param {Array|Uint8Array|string} arr + * @returns {number} + */ +function arrayByteLength(arr) { + if (arr.length !== undefined) { + return arr.length; + } + assert(arr.byteLength !== undefined); + return arr.byteLength; +} + +/** + * Combines array items (arrays) into single Uint8Array object. + * @param {Array} arr - the array of the arrays (Array, Uint8Array, or string). + * @returns {Uint8Array} + */ +function arraysToBytes(arr) { + // Shortcut: if first and only item is Uint8Array, return it. + if (arr.length === 1 && (arr[0] instanceof Uint8Array)) { + return arr[0]; + } + var resultLength = 0; + var i, ii = arr.length; + var item, itemLength ; + for (i = 0; i < ii; i++) { + item = arr[i]; + itemLength = arrayByteLength(item); + resultLength += itemLength; + } + var pos = 0; + var data = new Uint8Array(resultLength); + for (i = 0; i < ii; i++) { + item = arr[i]; + if (!(item instanceof Uint8Array)) { + if (typeof item === 'string') { + item = stringToBytes(item); + } else { + item = new Uint8Array(item); + } + } + itemLength = item.byteLength; + data.set(item, pos); + pos += itemLength; + } + return data; +} + +function string32(value) { + return String.fromCharCode((value >> 24) & 0xff, (value >> 16) & 0xff, + (value >> 8) & 0xff, value & 0xff); +} + +function log2(x) { + var n = 1, i = 0; + while (x > n) { + n <<= 1; + i++; + } + return i; +} + +function readInt8(data, start) { + return (data[start] << 24) >> 24; +} + +function readUint16(data, offset) { + return (data[offset] << 8) | data[offset + 1]; +} + +function readUint32(data, offset) { + return ((data[offset] << 24) | (data[offset + 1] << 16) | + (data[offset + 2] << 8) | data[offset + 3]) >>> 0; +} + +// Lazy test the endianness of the platform +// NOTE: This will be 'true' for simulated TypedArrays +function isLittleEndian() { + var buffer8 = new Uint8Array(2); + buffer8[0] = 1; + var buffer16 = new Uint16Array(buffer8.buffer); + return (buffer16[0] === 1); +} + +// Checks if it's possible to eval JS expressions. +function isEvalSupported() { + try { + /* jshint evil: true */ + new Function(''); + return true; + } catch (e) { + return false; + } +} + +var Uint32ArrayView = (function Uint32ArrayViewClosure() { + + function Uint32ArrayView(buffer, length) { + this.buffer = buffer; + this.byteLength = buffer.length; + this.length = length === undefined ? (this.byteLength >> 2) : length; + ensureUint32ArrayViewProps(this.length); + } + Uint32ArrayView.prototype = Object.create(null); + + var uint32ArrayViewSetters = 0; + function createUint32ArrayProp(index) { + return { + get: function () { + var buffer = this.buffer, offset = index << 2; + return (buffer[offset] | (buffer[offset + 1] << 8) | + (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24)) >>> 0; + }, + set: function (value) { + var buffer = this.buffer, offset = index << 2; + buffer[offset] = value & 255; + buffer[offset + 1] = (value >> 8) & 255; + buffer[offset + 2] = (value >> 16) & 255; + buffer[offset + 3] = (value >>> 24) & 255; + } + }; + } + + function ensureUint32ArrayViewProps(length) { + while (uint32ArrayViewSetters < length) { + Object.defineProperty(Uint32ArrayView.prototype, + uint32ArrayViewSetters, + createUint32ArrayProp(uint32ArrayViewSetters)); + uint32ArrayViewSetters++; + } + } + + return Uint32ArrayView; +})(); + +exports.Uint32ArrayView = Uint32ArrayView; + +var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; + +var Util = (function UtilClosure() { + function Util() {} + + var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')']; + + // makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids + // creating many intermediate strings. + Util.makeCssRgb = function Util_makeCssRgb(r, g, b) { + rgbBuf[1] = r; + rgbBuf[3] = g; + rgbBuf[5] = b; + return rgbBuf.join(''); + }; + + // Concatenates two transformation matrices together and returns the result. + Util.transform = function Util_transform(m1, m2) { + return [ + m1[0] * m2[0] + m1[2] * m2[1], + m1[1] * m2[0] + m1[3] * m2[1], + m1[0] * m2[2] + m1[2] * m2[3], + m1[1] * m2[2] + m1[3] * m2[3], + m1[0] * m2[4] + m1[2] * m2[5] + m1[4], + m1[1] * m2[4] + m1[3] * m2[5] + m1[5] + ]; + }; + + // For 2d affine transforms + Util.applyTransform = function Util_applyTransform(p, m) { + var xt = p[0] * m[0] + p[1] * m[2] + m[4]; + var yt = p[0] * m[1] + p[1] * m[3] + m[5]; + return [xt, yt]; + }; + + Util.applyInverseTransform = function Util_applyInverseTransform(p, m) { + var d = m[0] * m[3] - m[1] * m[2]; + var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d; + var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d; + return [xt, yt]; + }; + + // Applies the transform to the rectangle and finds the minimum axially + // aligned bounding box. + Util.getAxialAlignedBoundingBox = + function Util_getAxialAlignedBoundingBox(r, m) { + + var p1 = Util.applyTransform(r, m); + var p2 = Util.applyTransform(r.slice(2, 4), m); + var p3 = Util.applyTransform([r[0], r[3]], m); + var p4 = Util.applyTransform([r[2], r[1]], m); + return [ + Math.min(p1[0], p2[0], p3[0], p4[0]), + Math.min(p1[1], p2[1], p3[1], p4[1]), + Math.max(p1[0], p2[0], p3[0], p4[0]), + Math.max(p1[1], p2[1], p3[1], p4[1]) + ]; + }; + + Util.inverseTransform = function Util_inverseTransform(m) { + var d = m[0] * m[3] - m[1] * m[2]; + return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, + (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d]; + }; + + // Apply a generic 3d matrix M on a 3-vector v: + // | a b c | | X | + // | d e f | x | Y | + // | g h i | | Z | + // M is assumed to be serialized as [a,b,c,d,e,f,g,h,i], + // with v as [X,Y,Z] + Util.apply3dTransform = function Util_apply3dTransform(m, v) { + return [ + m[0] * v[0] + m[1] * v[1] + m[2] * v[2], + m[3] * v[0] + m[4] * v[1] + m[5] * v[2], + m[6] * v[0] + m[7] * v[1] + m[8] * v[2] + ]; + }; + + // This calculation uses Singular Value Decomposition. + // The SVD can be represented with formula A = USV. We are interested in the + // matrix S here because it represents the scale values. + Util.singularValueDecompose2dScale = + function Util_singularValueDecompose2dScale(m) { + + var transpose = [m[0], m[2], m[1], m[3]]; + + // Multiply matrix m with its transpose. + var a = m[0] * transpose[0] + m[1] * transpose[2]; + var b = m[0] * transpose[1] + m[1] * transpose[3]; + var c = m[2] * transpose[0] + m[3] * transpose[2]; + var d = m[2] * transpose[1] + m[3] * transpose[3]; + + // Solve the second degree polynomial to get roots. + var first = (a + d) / 2; + var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2; + var sx = first + second || 1; + var sy = first - second || 1; + + // Scale values are the square roots of the eigenvalues. + return [Math.sqrt(sx), Math.sqrt(sy)]; + }; + + // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2) + // For coordinate systems whose origin lies in the bottom-left, this + // means normalization to (BL,TR) ordering. For systems with origin in the + // top-left, this means (TL,BR) ordering. + Util.normalizeRect = function Util_normalizeRect(rect) { + var r = rect.slice(0); // clone rect + if (rect[0] > rect[2]) { + r[0] = rect[2]; + r[2] = rect[0]; + } + if (rect[1] > rect[3]) { + r[1] = rect[3]; + r[3] = rect[1]; + } + return r; + }; + + // Returns a rectangle [x1, y1, x2, y2] corresponding to the + // intersection of rect1 and rect2. If no intersection, returns 'false' + // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2] + Util.intersect = function Util_intersect(rect1, rect2) { + function compare(a, b) { + return a - b; + } + + // Order points along the axes + var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare), + orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare), + result = []; + + rect1 = Util.normalizeRect(rect1); + rect2 = Util.normalizeRect(rect2); + + // X: first and second points belong to different rectangles? + if ((orderedX[0] === rect1[0] && orderedX[1] === rect2[0]) || + (orderedX[0] === rect2[0] && orderedX[1] === rect1[0])) { + // Intersection must be between second and third points + result[0] = orderedX[1]; + result[2] = orderedX[2]; + } else { + return false; + } + + // Y: first and second points belong to different rectangles? + if ((orderedY[0] === rect1[1] && orderedY[1] === rect2[1]) || + (orderedY[0] === rect2[1] && orderedY[1] === rect1[1])) { + // Intersection must be between second and third points + result[1] = orderedY[1]; + result[3] = orderedY[2]; + } else { + return false; + } + + return result; + }; + + Util.sign = function Util_sign(num) { + return num < 0 ? -1 : 1; + }; + + var ROMAN_NUMBER_MAP = [ + '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', + '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', + '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX' + ]; + /** + * Converts positive integers to (upper case) Roman numerals. + * @param {integer} number - The number that should be converted. + * @param {boolean} lowerCase - Indicates if the result should be converted + * to lower case letters. The default is false. + * @return {string} The resulting Roman number. + */ + Util.toRoman = function Util_toRoman(number, lowerCase) { + assert(isInt(number) && number > 0, + 'The number should be a positive integer.'); + var pos, romanBuf = []; + // Thousands + while (number >= 1000) { + number -= 1000; + romanBuf.push('M'); + } + // Hundreds + pos = (number / 100) | 0; + number %= 100; + romanBuf.push(ROMAN_NUMBER_MAP[pos]); + // Tens + pos = (number / 10) | 0; + number %= 10; + romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]); + // Ones + romanBuf.push(ROMAN_NUMBER_MAP[20 + number]); + + var romanStr = romanBuf.join(''); + return (lowerCase ? romanStr.toLowerCase() : romanStr); + }; + + Util.appendToArray = function Util_appendToArray(arr1, arr2) { + Array.prototype.push.apply(arr1, arr2); + }; + + Util.prependToArray = function Util_prependToArray(arr1, arr2) { + Array.prototype.unshift.apply(arr1, arr2); + }; + + Util.extendObj = function extendObj(obj1, obj2) { + for (var key in obj2) { + obj1[key] = obj2[key]; + } + }; + + Util.getInheritableProperty = function Util_getInheritableProperty(dict, + name) { + while (dict && !dict.has(name)) { + dict = dict.get('Parent'); + } + if (!dict) { + return null; + } + return dict.get(name); + }; + + Util.inherit = function Util_inherit(sub, base, prototype) { + sub.prototype = Object.create(base.prototype); + sub.prototype.constructor = sub; + for (var prop in prototype) { + sub.prototype[prop] = prototype[prop]; + } + }; + + Util.loadScript = function Util_loadScript(src, callback) { + var script = document.createElement('script'); + var loaded = false; + script.setAttribute('src', src); + if (callback) { + script.onload = function() { + if (!loaded) { + callback(); + } + loaded = true; + }; + } + document.getElementsByTagName('head')[0].appendChild(script); + }; + + return Util; +})(); + +/** + * PDF page viewport created based on scale, rotation and offset. + * @class + * @alias PageViewport + */ +var PageViewport = (function PageViewportClosure() { + /** + * @constructor + * @private + * @param viewBox {Array} xMin, yMin, xMax and yMax coordinates. + * @param scale {number} scale of the viewport. + * @param rotation {number} rotations of the viewport in degrees. + * @param offsetX {number} offset X + * @param offsetY {number} offset Y + * @param dontFlip {boolean} if true, axis Y will not be flipped. + */ + function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) { + this.viewBox = viewBox; + this.scale = scale; + this.rotation = rotation; + this.offsetX = offsetX; + this.offsetY = offsetY; + + // creating transform to convert pdf coordinate system to the normal + // canvas like coordinates taking in account scale and rotation + var centerX = (viewBox[2] + viewBox[0]) / 2; + var centerY = (viewBox[3] + viewBox[1]) / 2; + var rotateA, rotateB, rotateC, rotateD; + rotation = rotation % 360; + rotation = rotation < 0 ? rotation + 360 : rotation; + switch (rotation) { + case 180: + rotateA = -1; rotateB = 0; rotateC = 0; rotateD = 1; + break; + case 90: + rotateA = 0; rotateB = 1; rotateC = 1; rotateD = 0; + break; + case 270: + rotateA = 0; rotateB = -1; rotateC = -1; rotateD = 0; + break; + //case 0: + default: + rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1; + break; + } + + if (dontFlip) { + rotateC = -rotateC; rotateD = -rotateD; + } + + var offsetCanvasX, offsetCanvasY; + var width, height; + if (rotateA === 0) { + offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX; + offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY; + width = Math.abs(viewBox[3] - viewBox[1]) * scale; + height = Math.abs(viewBox[2] - viewBox[0]) * scale; + } else { + offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX; + offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY; + width = Math.abs(viewBox[2] - viewBox[0]) * scale; + height = Math.abs(viewBox[3] - viewBox[1]) * scale; + } + // creating transform for the following operations: + // translate(-centerX, -centerY), rotate and flip vertically, + // scale, and translate(offsetCanvasX, offsetCanvasY) + this.transform = [ + rotateA * scale, + rotateB * scale, + rotateC * scale, + rotateD * scale, + offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, + offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY + ]; + + this.width = width; + this.height = height; + this.fontScale = scale; + } + PageViewport.prototype = /** @lends PageViewport.prototype */ { + /** + * Clones viewport with additional properties. + * @param args {Object} (optional) If specified, may contain the 'scale' or + * 'rotation' properties to override the corresponding properties in + * the cloned viewport. + * @returns {PageViewport} Cloned viewport. + */ + clone: function PageViewPort_clone(args) { + args = args || {}; + var scale = 'scale' in args ? args.scale : this.scale; + var rotation = 'rotation' in args ? args.rotation : this.rotation; + return new PageViewport(this.viewBox.slice(), scale, rotation, + this.offsetX, this.offsetY, args.dontFlip); + }, + /** + * Converts PDF point to the viewport coordinates. For examples, useful for + * converting PDF location into canvas pixel coordinates. + * @param x {number} X coordinate. + * @param y {number} Y coordinate. + * @returns {Object} Object that contains 'x' and 'y' properties of the + * point in the viewport coordinate space. + * @see {@link convertToPdfPoint} + * @see {@link convertToViewportRectangle} + */ + convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) { + return Util.applyTransform([x, y], this.transform); + }, + /** + * Converts PDF rectangle to the viewport coordinates. + * @param rect {Array} xMin, yMin, xMax and yMax coordinates. + * @returns {Array} Contains corresponding coordinates of the rectangle + * in the viewport coordinate space. + * @see {@link convertToViewportPoint} + */ + convertToViewportRectangle: + function PageViewport_convertToViewportRectangle(rect) { + var tl = Util.applyTransform([rect[0], rect[1]], this.transform); + var br = Util.applyTransform([rect[2], rect[3]], this.transform); + return [tl[0], tl[1], br[0], br[1]]; + }, + /** + * Converts viewport coordinates to the PDF location. For examples, useful + * for converting canvas pixel location into PDF one. + * @param x {number} X coordinate. + * @param y {number} Y coordinate. + * @returns {Object} Object that contains 'x' and 'y' properties of the + * point in the PDF coordinate space. + * @see {@link convertToViewportPoint} + */ + convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) { + return Util.applyInverseTransform([x, y], this.transform); + } + }; + return PageViewport; +})(); + +var PDFStringTranslateTable = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, + 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, + 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, + 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC +]; + +function stringToPDFString(str) { + var i, n = str.length, strBuf = []; + if (str[0] === '\xFE' && str[1] === '\xFF') { + // UTF16BE BOM + for (i = 2; i < n; i += 2) { + strBuf.push(String.fromCharCode( + (str.charCodeAt(i) << 8) | str.charCodeAt(i + 1))); + } + } else { + for (i = 0; i < n; ++i) { + var code = PDFStringTranslateTable[str.charCodeAt(i)]; + strBuf.push(code ? String.fromCharCode(code) : str.charAt(i)); + } + } + return strBuf.join(''); +} + +function stringToUTF8String(str) { + return decodeURIComponent(escape(str)); +} + +function utf8StringToString(str) { + return unescape(encodeURIComponent(str)); +} + +function isEmptyObj(obj) { + for (var key in obj) { + return false; + } + return true; +} + +function isBool(v) { + return typeof v === 'boolean'; +} + +function isInt(v) { + return typeof v === 'number' && ((v | 0) === v); +} + +function isNum(v) { + return typeof v === 'number'; +} + +function isString(v) { + return typeof v === 'string'; +} + +function isArray(v) { + return v instanceof Array; +} + +function isArrayBuffer(v) { + return typeof v === 'object' && v !== null && v.byteLength !== undefined; +} + +// Checks if ch is one of the following characters: SPACE, TAB, CR or LF. +function isSpace(ch) { + return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A); +} + +/** + * Promise Capability object. + * + * @typedef {Object} PromiseCapability + * @property {Promise} promise - A promise object. + * @property {function} resolve - Fullfills the promise. + * @property {function} reject - Rejects the promise. + */ + +/** + * Creates a promise capability object. + * @alias createPromiseCapability + * + * @return {PromiseCapability} A capability object contains: + * - a Promise, resolve and reject methods. + */ +function createPromiseCapability() { + var capability = {}; + capability.promise = new Promise(function (resolve, reject) { + capability.resolve = resolve; + capability.reject = reject; + }); + return capability; +} + +/** + * Polyfill for Promises: + * The following promise implementation tries to generally implement the + * Promise/A+ spec. Some notable differences from other promise libaries are: + * - There currently isn't a seperate deferred and promise object. + * - Unhandled rejections eventually show an error if they aren't handled. + * + * Based off of the work in: + * https://bugzilla.mozilla.org/show_bug.cgi?id=810490 + */ +(function PromiseClosure() { + if (globalScope.Promise) { + // Promises existing in the DOM/Worker, checking presence of all/resolve + if (typeof globalScope.Promise.all !== 'function') { + globalScope.Promise.all = function (iterable) { + var count = 0, results = [], resolve, reject; + var promise = new globalScope.Promise(function (resolve_, reject_) { + resolve = resolve_; + reject = reject_; + }); + iterable.forEach(function (p, i) { + count++; + p.then(function (result) { + results[i] = result; + count--; + if (count === 0) { + resolve(results); + } + }, reject); + }); + if (count === 0) { + resolve(results); + } + return promise; + }; + } + if (typeof globalScope.Promise.resolve !== 'function') { + globalScope.Promise.resolve = function (value) { + return new globalScope.Promise(function (resolve) { resolve(value); }); + }; + } + if (typeof globalScope.Promise.reject !== 'function') { + globalScope.Promise.reject = function (reason) { + return new globalScope.Promise(function (resolve, reject) { + reject(reason); + }); + }; + } + if (typeof globalScope.Promise.prototype.catch !== 'function') { + globalScope.Promise.prototype.catch = function (onReject) { + return globalScope.Promise.prototype.then(undefined, onReject); + }; + } + return; + } + var STATUS_PENDING = 0; + var STATUS_RESOLVED = 1; + var STATUS_REJECTED = 2; + + // In an attempt to avoid silent exceptions, unhandled rejections are + // tracked and if they aren't handled in a certain amount of time an + // error is logged. + var REJECTION_TIMEOUT = 500; + + var HandlerManager = { + handlers: [], + running: false, + unhandledRejections: [], + pendingRejectionCheck: false, + + scheduleHandlers: function scheduleHandlers(promise) { + if (promise._status === STATUS_PENDING) { + return; + } + + this.handlers = this.handlers.concat(promise._handlers); + promise._handlers = []; + + if (this.running) { + return; + } + this.running = true; + + setTimeout(this.runHandlers.bind(this), 0); + }, + + runHandlers: function runHandlers() { + var RUN_TIMEOUT = 1; // ms + var timeoutAt = Date.now() + RUN_TIMEOUT; + while (this.handlers.length > 0) { + var handler = this.handlers.shift(); + + var nextStatus = handler.thisPromise._status; + var nextValue = handler.thisPromise._value; + + try { + if (nextStatus === STATUS_RESOLVED) { + if (typeof handler.onResolve === 'function') { + nextValue = handler.onResolve(nextValue); + } + } else if (typeof handler.onReject === 'function') { + nextValue = handler.onReject(nextValue); + nextStatus = STATUS_RESOLVED; + + if (handler.thisPromise._unhandledRejection) { + this.removeUnhandeledRejection(handler.thisPromise); + } + } + } catch (ex) { + nextStatus = STATUS_REJECTED; + nextValue = ex; + } + + handler.nextPromise._updateStatus(nextStatus, nextValue); + if (Date.now() >= timeoutAt) { + break; + } + } + + if (this.handlers.length > 0) { + setTimeout(this.runHandlers.bind(this), 0); + return; + } + + this.running = false; + }, + + addUnhandledRejection: function addUnhandledRejection(promise) { + this.unhandledRejections.push({ + promise: promise, + time: Date.now() + }); + this.scheduleRejectionCheck(); + }, + + removeUnhandeledRejection: function removeUnhandeledRejection(promise) { + promise._unhandledRejection = false; + for (var i = 0; i < this.unhandledRejections.length; i++) { + if (this.unhandledRejections[i].promise === promise) { + this.unhandledRejections.splice(i); + i--; + } + } + }, + + scheduleRejectionCheck: function scheduleRejectionCheck() { + if (this.pendingRejectionCheck) { + return; + } + this.pendingRejectionCheck = true; + setTimeout(function rejectionCheck() { + this.pendingRejectionCheck = false; + var now = Date.now(); + for (var i = 0; i < this.unhandledRejections.length; i++) { + if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) { + var unhandled = this.unhandledRejections[i].promise._value; + var msg = 'Unhandled rejection: ' + unhandled; + if (unhandled.stack) { + msg += '\n' + unhandled.stack; + } + warn(msg); + this.unhandledRejections.splice(i); + i--; + } + } + if (this.unhandledRejections.length) { + this.scheduleRejectionCheck(); + } + }.bind(this), REJECTION_TIMEOUT); + } + }; + + function Promise(resolver) { + this._status = STATUS_PENDING; + this._handlers = []; + try { + resolver.call(this, this._resolve.bind(this), this._reject.bind(this)); + } catch (e) { + this._reject(e); + } + } + /** + * Builds a promise that is resolved when all the passed in promises are + * resolved. + * @param {array} promises array of data and/or promises to wait for. + * @return {Promise} New dependant promise. + */ + Promise.all = function Promise_all(promises) { + var resolveAll, rejectAll; + var deferred = new Promise(function (resolve, reject) { + resolveAll = resolve; + rejectAll = reject; + }); + var unresolved = promises.length; + var results = []; + if (unresolved === 0) { + resolveAll(results); + return deferred; + } + function reject(reason) { + if (deferred._status === STATUS_REJECTED) { + return; + } + results = []; + rejectAll(reason); + } + for (var i = 0, ii = promises.length; i < ii; ++i) { + var promise = promises[i]; + var resolve = (function(i) { + return function(value) { + if (deferred._status === STATUS_REJECTED) { + return; + } + results[i] = value; + unresolved--; + if (unresolved === 0) { + resolveAll(results); + } + }; + })(i); + if (Promise.isPromise(promise)) { + promise.then(resolve, reject); + } else { + resolve(promise); + } + } + return deferred; + }; + + /** + * Checks if the value is likely a promise (has a 'then' function). + * @return {boolean} true if value is thenable + */ + Promise.isPromise = function Promise_isPromise(value) { + return value && typeof value.then === 'function'; + }; + + /** + * Creates resolved promise + * @param value resolve value + * @returns {Promise} + */ + Promise.resolve = function Promise_resolve(value) { + return new Promise(function (resolve) { resolve(value); }); + }; + + /** + * Creates rejected promise + * @param reason rejection value + * @returns {Promise} + */ + Promise.reject = function Promise_reject(reason) { + return new Promise(function (resolve, reject) { reject(reason); }); + }; + + Promise.prototype = { + _status: null, + _value: null, + _handlers: null, + _unhandledRejection: null, + + _updateStatus: function Promise__updateStatus(status, value) { + if (this._status === STATUS_RESOLVED || + this._status === STATUS_REJECTED) { + return; + } + + if (status === STATUS_RESOLVED && + Promise.isPromise(value)) { + value.then(this._updateStatus.bind(this, STATUS_RESOLVED), + this._updateStatus.bind(this, STATUS_REJECTED)); + return; + } + + this._status = status; + this._value = value; + + if (status === STATUS_REJECTED && this._handlers.length === 0) { + this._unhandledRejection = true; + HandlerManager.addUnhandledRejection(this); + } + + HandlerManager.scheduleHandlers(this); + }, + + _resolve: function Promise_resolve(value) { + this._updateStatus(STATUS_RESOLVED, value); + }, + + _reject: function Promise_reject(reason) { + this._updateStatus(STATUS_REJECTED, reason); + }, + + then: function Promise_then(onResolve, onReject) { + var nextPromise = new Promise(function (resolve, reject) { + this.resolve = resolve; + this.reject = reject; + }); + this._handlers.push({ + thisPromise: this, + onResolve: onResolve, + onReject: onReject, + nextPromise: nextPromise + }); + HandlerManager.scheduleHandlers(this); + return nextPromise; + }, + + catch: function Promise_catch(onReject) { + return this.then(undefined, onReject); + } + }; + + globalScope.Promise = Promise; +})(); + +var StatTimer = (function StatTimerClosure() { + function rpad(str, pad, length) { + while (str.length < length) { + str += pad; + } + return str; + } + function StatTimer() { + this.started = Object.create(null); + this.times = []; + this.enabled = true; + } + StatTimer.prototype = { + time: function StatTimer_time(name) { + if (!this.enabled) { + return; + } + if (name in this.started) { + warn('Timer is already running for ' + name); + } + this.started[name] = Date.now(); + }, + timeEnd: function StatTimer_timeEnd(name) { + if (!this.enabled) { + return; + } + if (!(name in this.started)) { + warn('Timer has not been started for ' + name); + } + this.times.push({ + 'name': name, + 'start': this.started[name], + 'end': Date.now() + }); + // Remove timer from started so it can be called again. + delete this.started[name]; + }, + toString: function StatTimer_toString() { + var i, ii; + var times = this.times; + var out = ''; + // Find the longest name for padding purposes. + var longest = 0; + for (i = 0, ii = times.length; i < ii; ++i) { + var name = times[i]['name']; + if (name.length > longest) { + longest = name.length; + } + } + for (i = 0, ii = times.length; i < ii; ++i) { + var span = times[i]; + var duration = span.end - span.start; + out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n'; + } + return out; + } + }; + return StatTimer; +})(); + +var createBlob = function createBlob(data, contentType) { + if (typeof Blob !== 'undefined') { + return new Blob([data], { type: contentType }); + } + // Blob builder is deprecated in FF14 and removed in FF18. + var bb = new MozBlobBuilder(); + bb.append(data); + return bb.getBlob(contentType); +}; + +var createObjectURL = (function createObjectURLClosure() { + // Blob/createObjectURL is not available, falling back to data schema. + var digits = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + + return function createObjectURL(data, contentType, forceDataSchema) { + if (!forceDataSchema && + typeof URL !== 'undefined' && URL.createObjectURL) { + var blob = createBlob(data, contentType); + return URL.createObjectURL(blob); + } + + var buffer = 'data:' + contentType + ';base64,'; + for (var i = 0, ii = data.length; i < ii; i += 3) { + var b1 = data[i] & 0xFF; + var b2 = data[i + 1] & 0xFF; + var b3 = data[i + 2] & 0xFF; + var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4); + var d3 = i + 1 < ii ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64; + var d4 = i + 2 < ii ? (b3 & 0x3F) : 64; + buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4]; + } + return buffer; + }; +})(); + +function MessageHandler(sourceName, targetName, comObj) { + this.sourceName = sourceName; + this.targetName = targetName; + this.comObj = comObj; + this.callbackIndex = 1; + this.postMessageTransfers = true; + var callbacksCapabilities = this.callbacksCapabilities = Object.create(null); + var ah = this.actionHandler = Object.create(null); + + this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) { + var data = event.data; + if (data.targetName !== this.sourceName) { + return; + } + if (data.isReply) { + var callbackId = data.callbackId; + if (data.callbackId in callbacksCapabilities) { + var callback = callbacksCapabilities[callbackId]; + delete callbacksCapabilities[callbackId]; + if ('error' in data) { + callback.reject(data.error); + } else { + callback.resolve(data.data); + } + } else { + error('Cannot resolve callback ' + callbackId); + } + } else if (data.action in ah) { + var action = ah[data.action]; + if (data.callbackId) { + var sourceName = this.sourceName; + var targetName = data.sourceName; + Promise.resolve().then(function () { + return action[0].call(action[1], data.data); + }).then(function (result) { + comObj.postMessage({ + sourceName: sourceName, + targetName: targetName, + isReply: true, + callbackId: data.callbackId, + data: result + }); + }, function (reason) { + if (reason instanceof Error) { + // Serialize error to avoid "DataCloneError" + reason = reason + ''; + } + comObj.postMessage({ + sourceName: sourceName, + targetName: targetName, + isReply: true, + callbackId: data.callbackId, + error: reason + }); + }); + } else { + action[0].call(action[1], data.data); + } + } else { + error('Unknown action from worker: ' + data.action); + } + }.bind(this); + comObj.addEventListener('message', this._onComObjOnMessage); +} + +MessageHandler.prototype = { + on: function messageHandlerOn(actionName, handler, scope) { + var ah = this.actionHandler; + if (ah[actionName]) { + error('There is already an actionName called "' + actionName + '"'); + } + ah[actionName] = [handler, scope]; + }, + /** + * Sends a message to the comObj to invoke the action with the supplied data. + * @param {String} actionName Action to call. + * @param {JSON} data JSON data to send. + * @param {Array} [transfers] Optional list of transfers/ArrayBuffers + */ + send: function messageHandlerSend(actionName, data, transfers) { + var message = { + sourceName: this.sourceName, + targetName: this.targetName, + action: actionName, + data: data + }; + this.postMessage(message, transfers); + }, + /** + * Sends a message to the comObj to invoke the action with the supplied data. + * Expects that other side will callback with the response. + * @param {String} actionName Action to call. + * @param {JSON} data JSON data to send. + * @param {Array} [transfers] Optional list of transfers/ArrayBuffers. + * @returns {Promise} Promise to be resolved with response data. + */ + sendWithPromise: + function messageHandlerSendWithPromise(actionName, data, transfers) { + var callbackId = this.callbackIndex++; + var message = { + sourceName: this.sourceName, + targetName: this.targetName, + action: actionName, + data: data, + callbackId: callbackId + }; + var capability = createPromiseCapability(); + this.callbacksCapabilities[callbackId] = capability; + try { + this.postMessage(message, transfers); + } catch (e) { + capability.reject(e); + } + return capability.promise; + }, + /** + * Sends raw message to the comObj. + * @private + * @param message {Object} Raw message. + * @param transfers List of transfers/ArrayBuffers, or undefined. + */ + postMessage: function (message, transfers) { + if (transfers && this.postMessageTransfers) { + this.comObj.postMessage(message, transfers); + } else { + this.comObj.postMessage(message); + } + }, + + destroy: function () { + this.comObj.removeEventListener('message', this._onComObjOnMessage); + } +}; + +function loadJpegStream(id, imageUrl, objs) { + var img = new Image(); + img.onload = (function loadJpegStream_onloadClosure() { + objs.resolve(id, img); + }); + img.onerror = (function loadJpegStream_onerrorClosure() { + objs.resolve(id, null); + warn('Error during JPEG image loading'); + }); + img.src = imageUrl; +} + + // Polyfill from https://github.com/Polymer/URL +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ +(function checkURLConstructor(scope) { + /* jshint ignore:start */ + + // feature detect for URL constructor + var hasWorkingUrl = false; + try { + if (typeof URL === 'function' && + typeof URL.prototype === 'object' && + ('origin' in URL.prototype)) { + var u = new URL('b', 'http://a'); + u.pathname = 'c%20d'; + hasWorkingUrl = u.href === 'http://a/c%20d'; + } + } catch(e) { } + + if (hasWorkingUrl) + return; + + var relative = Object.create(null); + relative['ftp'] = 21; + relative['file'] = 0; + relative['gopher'] = 70; + relative['http'] = 80; + relative['https'] = 443; + relative['ws'] = 80; + relative['wss'] = 443; + + var relativePathDotMapping = Object.create(null); + relativePathDotMapping['%2e'] = '.'; + relativePathDotMapping['.%2e'] = '..'; + relativePathDotMapping['%2e.'] = '..'; + relativePathDotMapping['%2e%2e'] = '..'; + + function isRelativeScheme(scheme) { + return relative[scheme] !== undefined; + } + + function invalid() { + clear.call(this); + this._isInvalid = true; + } + + function IDNAToASCII(h) { + if ('' == h) { + invalid.call(this) + } + // XXX + return h.toLowerCase() + } + + function percentEscape(c) { + var unicode = c.charCodeAt(0); + if (unicode > 0x20 && + unicode < 0x7F && + // " # < > ? ` + [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) == -1 + ) { + return c; + } + return encodeURIComponent(c); + } + + function percentEscapeQuery(c) { + // XXX This actually needs to encode c using encoding and then + // convert the bytes one-by-one. + + var unicode = c.charCodeAt(0); + if (unicode > 0x20 && + unicode < 0x7F && + // " # < > ` (do not escape '?') + [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) == -1 + ) { + return c; + } + return encodeURIComponent(c); + } + + var EOF = undefined, + ALPHA = /[a-zA-Z]/, + ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; + + function parse(input, stateOverride, base) { + function err(message) { + errors.push(message) + } + + var state = stateOverride || 'scheme start', + cursor = 0, + buffer = '', + seenAt = false, + seenBracket = false, + errors = []; + + loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) { + var c = input[cursor]; + switch (state) { + case 'scheme start': + if (c && ALPHA.test(c)) { + buffer += c.toLowerCase(); // ASCII-safe + state = 'scheme'; + } else if (!stateOverride) { + buffer = ''; + state = 'no scheme'; + continue; + } else { + err('Invalid scheme.'); + break loop; + } + break; + + case 'scheme': + if (c && ALPHANUMERIC.test(c)) { + buffer += c.toLowerCase(); // ASCII-safe + } else if (':' == c) { + this._scheme = buffer; + buffer = ''; + if (stateOverride) { + break loop; + } + if (isRelativeScheme(this._scheme)) { + this._isRelative = true; + } + if ('file' == this._scheme) { + state = 'relative'; + } else if (this._isRelative && base && base._scheme == this._scheme) { + state = 'relative or authority'; + } else if (this._isRelative) { + state = 'authority first slash'; + } else { + state = 'scheme data'; + } + } else if (!stateOverride) { + buffer = ''; + cursor = 0; + state = 'no scheme'; + continue; + } else if (EOF == c) { + break loop; + } else { + err('Code point not allowed in scheme: ' + c); + break loop; + } + break; + + case 'scheme data': + if ('?' == c) { + this._query = '?'; + state = 'query'; + } else if ('#' == c) { + this._fragment = '#'; + state = 'fragment'; + } else { + // XXX error handling + if (EOF != c && '\t' != c && '\n' != c && '\r' != c) { + this._schemeData += percentEscape(c); + } + } + break; + + case 'no scheme': + if (!base || !(isRelativeScheme(base._scheme))) { + err('Missing scheme.'); + invalid.call(this); + } else { + state = 'relative'; + continue; + } + break; + + case 'relative or authority': + if ('/' == c && '/' == input[cursor+1]) { + state = 'authority ignore slashes'; + } else { + err('Expected /, got: ' + c); + state = 'relative'; + continue + } + break; + + case 'relative': + this._isRelative = true; + if ('file' != this._scheme) + this._scheme = base._scheme; + if (EOF == c) { + this._host = base._host; + this._port = base._port; + this._path = base._path.slice(); + this._query = base._query; + this._username = base._username; + this._password = base._password; + break loop; + } else if ('/' == c || '\\' == c) { + if ('\\' == c) + err('\\ is an invalid code point.'); + state = 'relative slash'; + } else if ('?' == c) { + this._host = base._host; + this._port = base._port; + this._path = base._path.slice(); + this._query = '?'; + this._username = base._username; + this._password = base._password; + state = 'query'; + } else if ('#' == c) { + this._host = base._host; + this._port = base._port; + this._path = base._path.slice(); + this._query = base._query; + this._fragment = '#'; + this._username = base._username; + this._password = base._password; + state = 'fragment'; + } else { + var nextC = input[cursor+1]; + var nextNextC = input[cursor+2]; + if ( + 'file' != this._scheme || !ALPHA.test(c) || + (nextC != ':' && nextC != '|') || + (EOF != nextNextC && '/' != nextNextC && '\\' != nextNextC && '?' != nextNextC && '#' != nextNextC)) { + this._host = base._host; + this._port = base._port; + this._username = base._username; + this._password = base._password; + this._path = base._path.slice(); + this._path.pop(); + } + state = 'relative path'; + continue; + } + break; + + case 'relative slash': + if ('/' == c || '\\' == c) { + if ('\\' == c) { + err('\\ is an invalid code point.'); + } + if ('file' == this._scheme) { + state = 'file host'; + } else { + state = 'authority ignore slashes'; + } + } else { + if ('file' != this._scheme) { + this._host = base._host; + this._port = base._port; + this._username = base._username; + this._password = base._password; + } + state = 'relative path'; + continue; + } + break; + + case 'authority first slash': + if ('/' == c) { + state = 'authority second slash'; + } else { + err("Expected '/', got: " + c); + state = 'authority ignore slashes'; + continue; + } + break; + + case 'authority second slash': + state = 'authority ignore slashes'; + if ('/' != c) { + err("Expected '/', got: " + c); + continue; + } + break; + + case 'authority ignore slashes': + if ('/' != c && '\\' != c) { + state = 'authority'; + continue; + } else { + err('Expected authority, got: ' + c); + } + break; + + case 'authority': + if ('@' == c) { + if (seenAt) { + err('@ already seen.'); + buffer += '%40'; + } + seenAt = true; + for (var i = 0; i < buffer.length; i++) { + var cp = buffer[i]; + if ('\t' == cp || '\n' == cp || '\r' == cp) { + err('Invalid whitespace in authority.'); + continue; + } + // XXX check URL code points + if (':' == cp && null === this._password) { + this._password = ''; + continue; + } + var tempC = percentEscape(cp); + (null !== this._password) ? this._password += tempC : this._username += tempC; + } + buffer = ''; + } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) { + cursor -= buffer.length; + buffer = ''; + state = 'host'; + continue; + } else { + buffer += c; + } + break; + + case 'file host': + if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) { + if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ':' || buffer[1] == '|')) { + state = 'relative path'; + } else if (buffer.length == 0) { + state = 'relative path start'; + } else { + this._host = IDNAToASCII.call(this, buffer); + buffer = ''; + state = 'relative path start'; + } + continue; + } else if ('\t' == c || '\n' == c || '\r' == c) { + err('Invalid whitespace in file host.'); + } else { + buffer += c; + } + break; + + case 'host': + case 'hostname': + if (':' == c && !seenBracket) { + // XXX host parsing + this._host = IDNAToASCII.call(this, buffer); + buffer = ''; + state = 'port'; + if ('hostname' == stateOverride) { + break loop; + } + } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c) { + this._host = IDNAToASCII.call(this, buffer); + buffer = ''; + state = 'relative path start'; + if (stateOverride) { + break loop; + } + continue; + } else if ('\t' != c && '\n' != c && '\r' != c) { + if ('[' == c) { + seenBracket = true; + } else if (']' == c) { + seenBracket = false; + } + buffer += c; + } else { + err('Invalid code point in host/hostname: ' + c); + } + break; + + case 'port': + if (/[0-9]/.test(c)) { + buffer += c; + } else if (EOF == c || '/' == c || '\\' == c || '?' == c || '#' == c || stateOverride) { + if ('' != buffer) { + var temp = parseInt(buffer, 10); + if (temp != relative[this._scheme]) { + this._port = temp + ''; + } + buffer = ''; + } + if (stateOverride) { + break loop; + } + state = 'relative path start'; + continue; + } else if ('\t' == c || '\n' == c || '\r' == c) { + err('Invalid code point in port: ' + c); + } else { + invalid.call(this); + } + break; + + case 'relative path start': + if ('\\' == c) + err("'\\' not allowed in path."); + state = 'relative path'; + if ('/' != c && '\\' != c) { + continue; + } + break; + + case 'relative path': + if (EOF == c || '/' == c || '\\' == c || (!stateOverride && ('?' == c || '#' == c))) { + if ('\\' == c) { + err('\\ not allowed in relative path.'); + } + var tmp; + if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { + buffer = tmp; + } + if ('..' == buffer) { + this._path.pop(); + if ('/' != c && '\\' != c) { + this._path.push(''); + } + } else if ('.' == buffer && '/' != c && '\\' != c) { + this._path.push(''); + } else if ('.' != buffer) { + if ('file' == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == '|') { + buffer = buffer[0] + ':'; + } + this._path.push(buffer); + } + buffer = ''; + if ('?' == c) { + this._query = '?'; + state = 'query'; + } else if ('#' == c) { + this._fragment = '#'; + state = 'fragment'; + } + } else if ('\t' != c && '\n' != c && '\r' != c) { + buffer += percentEscape(c); + } + break; + + case 'query': + if (!stateOverride && '#' == c) { + this._fragment = '#'; + state = 'fragment'; + } else if (EOF != c && '\t' != c && '\n' != c && '\r' != c) { + this._query += percentEscapeQuery(c); + } + break; + + case 'fragment': + if (EOF != c && '\t' != c && '\n' != c && '\r' != c) { + this._fragment += c; + } + break; + } + + cursor++; + } + } + + function clear() { + this._scheme = ''; + this._schemeData = ''; + this._username = ''; + this._password = null; + this._host = ''; + this._port = ''; + this._path = []; + this._query = ''; + this._fragment = ''; + this._isInvalid = false; + this._isRelative = false; + } + + // Does not process domain names or IP addresses. + // Does not handle encoding for the query parameter. + function jURL(url, base /* , encoding */) { + if (base !== undefined && !(base instanceof jURL)) + base = new jURL(String(base)); + + this._url = url; + clear.call(this); + + var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); + // encoding = encoding || 'utf-8' + + parse.call(this, input, null, base); + } + + jURL.prototype = { + toString: function() { + return this.href; + }, + get href() { + if (this._isInvalid) + return this._url; + + var authority = ''; + if ('' != this._username || null != this._password) { + authority = this._username + + (null != this._password ? ':' + this._password : '') + '@'; + } + + return this.protocol + + (this._isRelative ? '//' + authority + this.host : '') + + this.pathname + this._query + this._fragment; + }, + set href(href) { + clear.call(this); + parse.call(this, href); + }, + + get protocol() { + return this._scheme + ':'; + }, + set protocol(protocol) { + if (this._isInvalid) + return; + parse.call(this, protocol + ':', 'scheme start'); + }, + + get host() { + return this._isInvalid ? '' : this._port ? + this._host + ':' + this._port : this._host; + }, + set host(host) { + if (this._isInvalid || !this._isRelative) + return; + parse.call(this, host, 'host'); + }, + + get hostname() { + return this._host; + }, + set hostname(hostname) { + if (this._isInvalid || !this._isRelative) + return; + parse.call(this, hostname, 'hostname'); + }, + + get port() { + return this._port; + }, + set port(port) { + if (this._isInvalid || !this._isRelative) + return; + parse.call(this, port, 'port'); + }, + + get pathname() { + return this._isInvalid ? '' : this._isRelative ? + '/' + this._path.join('/') : this._schemeData; + }, + set pathname(pathname) { + if (this._isInvalid || !this._isRelative) + return; + this._path = []; + parse.call(this, pathname, 'relative path start'); + }, + + get search() { + return this._isInvalid || !this._query || '?' == this._query ? + '' : this._query; + }, + set search(search) { + if (this._isInvalid || !this._isRelative) + return; + this._query = '?'; + if ('?' == search[0]) + search = search.slice(1); + parse.call(this, search, 'query'); + }, + + get hash() { + return this._isInvalid || !this._fragment || '#' == this._fragment ? + '' : this._fragment; + }, + set hash(hash) { + if (this._isInvalid) + return; + this._fragment = '#'; + if ('#' == hash[0]) + hash = hash.slice(1); + parse.call(this, hash, 'fragment'); + }, + + get origin() { + var host; + if (this._isInvalid || !this._scheme) { + return ''; + } + // javascript: Gecko returns String(""), WebKit/Blink String("null") + // Gecko throws error for "data://" + // data: Gecko returns "", Blink returns "data://", WebKit returns "null" + // Gecko returns String("") for file: mailto: + // WebKit/Blink returns String("SCHEME://") for file: mailto: + switch (this._scheme) { + case 'data': + case 'file': + case 'javascript': + case 'mailto': + return 'null'; + } + host = this.host; + if (!host) { + return ''; + } + return this._scheme + '://' + host; + } + }; + + // Copy over the static methods + var OriginalURL = scope.URL; + if (OriginalURL) { + jURL.createObjectURL = function(blob) { + // IE extension allows a second optional options argument. + // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx + return OriginalURL.createObjectURL.apply(OriginalURL, arguments); + }; + jURL.revokeObjectURL = function(url) { + OriginalURL.revokeObjectURL(url); + }; + } + + scope.URL = jURL; + /* jshint ignore:end */ +})(globalScope); + +exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX; +exports.IDENTITY_MATRIX = IDENTITY_MATRIX; +exports.OPS = OPS; +exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS; +exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES; +exports.AnnotationBorderStyleType = AnnotationBorderStyleType; +exports.AnnotationFlag = AnnotationFlag; +exports.AnnotationType = AnnotationType; +exports.FontType = FontType; +exports.ImageKind = ImageKind; +exports.InvalidPDFException = InvalidPDFException; +exports.MessageHandler = MessageHandler; +exports.MissingDataException = MissingDataException; +exports.MissingPDFException = MissingPDFException; +exports.NotImplementedException = NotImplementedException; +exports.PageViewport = PageViewport; +exports.PasswordException = PasswordException; +exports.PasswordResponses = PasswordResponses; +exports.StatTimer = StatTimer; +exports.StreamType = StreamType; +exports.TextRenderingMode = TextRenderingMode; +exports.UnexpectedResponseException = UnexpectedResponseException; +exports.UnknownErrorException = UnknownErrorException; +exports.Util = Util; +exports.XRefParseException = XRefParseException; +exports.arrayByteLength = arrayByteLength; +exports.arraysToBytes = arraysToBytes; +exports.assert = assert; +exports.bytesToString = bytesToString; +exports.createBlob = createBlob; +exports.createPromiseCapability = createPromiseCapability; +exports.createObjectURL = createObjectURL; +exports.deprecated = deprecated; +exports.error = error; +exports.getLookupTableFactory = getLookupTableFactory; +exports.getVerbosityLevel = getVerbosityLevel; +exports.globalScope = globalScope; +exports.info = info; +exports.isArray = isArray; +exports.isArrayBuffer = isArrayBuffer; +exports.isBool = isBool; +exports.isEmptyObj = isEmptyObj; +exports.isInt = isInt; +exports.isNum = isNum; +exports.isString = isString; +exports.isSpace = isSpace; +exports.isSameOrigin = isSameOrigin; +exports.isValidUrl = isValidUrl; +exports.isLittleEndian = isLittleEndian; +exports.isEvalSupported = isEvalSupported; +exports.loadJpegStream = loadJpegStream; +exports.log2 = log2; +exports.readInt8 = readInt8; +exports.readUint16 = readUint16; +exports.readUint32 = readUint32; +exports.removeNullCharacters = removeNullCharacters; +exports.setVerbosityLevel = setVerbosityLevel; +exports.shadow = shadow; +exports.string32 = string32; +exports.stringToBytes = stringToBytes; +exports.stringToPDFString = stringToPDFString; +exports.stringToUTF8String = stringToUTF8String; +exports.utf8StringToString = utf8StringToString; +exports.warn = warn; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil); + } +}(this, function (exports, sharedUtil) { + +var removeNullCharacters = sharedUtil.removeNullCharacters; +var warn = sharedUtil.warn; + +/** + * Optimised CSS custom property getter/setter. + * @class + */ +var CustomStyle = (function CustomStyleClosure() { + + // As noted on: http://www.zachstronaut.com/posts/2009/02/17/ + // animate-css-transforms-firefox-webkit.html + // in some versions of IE9 it is critical that ms appear in this list + // before Moz + var prefixes = ['ms', 'Moz', 'Webkit', 'O']; + var _cache = Object.create(null); + + function CustomStyle() {} + + CustomStyle.getProp = function get(propName, element) { + // check cache only when no element is given + if (arguments.length === 1 && typeof _cache[propName] === 'string') { + return _cache[propName]; + } + + element = element || document.documentElement; + var style = element.style, prefixed, uPropName; + + // test standard property first + if (typeof style[propName] === 'string') { + return (_cache[propName] = propName); + } + + // capitalize + uPropName = propName.charAt(0).toUpperCase() + propName.slice(1); + + // test vendor specific properties + for (var i = 0, l = prefixes.length; i < l; i++) { + prefixed = prefixes[i] + uPropName; + if (typeof style[prefixed] === 'string') { + return (_cache[propName] = prefixed); + } + } + + //if all fails then set to undefined + return (_cache[propName] = 'undefined'); + }; + + CustomStyle.setProp = function set(propName, element, str) { + var prop = this.getProp(propName); + if (prop !== 'undefined') { + element.style[prop] = str; + } + }; + + return CustomStyle; +})(); + +function hasCanvasTypedArrays() { + var canvas = document.createElement('canvas'); + canvas.width = canvas.height = 1; + var ctx = canvas.getContext('2d'); + var imageData = ctx.createImageData(1, 1); + return (typeof imageData.data.buffer !== 'undefined'); +} + +var LinkTarget = { + NONE: 0, // Default value. + SELF: 1, + BLANK: 2, + PARENT: 3, + TOP: 4, +}; + +var LinkTargetStringMap = [ + '', + '_self', + '_blank', + '_parent', + '_top' +]; + +/** + * @typedef ExternalLinkParameters + * @typedef {Object} ExternalLinkParameters + * @property {string} url - An absolute URL. + * @property {LinkTarget} target - The link target. + * @property {string} rel - The link relationship. + */ + +/** + * Adds various attributes (href, title, target, rel) to hyperlinks. + * @param {HTMLLinkElement} link - The link element. + * @param {ExternalLinkParameters} params + */ +function addLinkAttributes(link, params) { + var url = params && params.url; + link.href = link.title = (url ? removeNullCharacters(url) : ''); + + if (url) { + var target = params.target; + if (typeof target === 'undefined') { + target = getDefaultSetting('externalLinkTarget'); + } + link.target = LinkTargetStringMap[target]; + + var rel = params.rel; + if (typeof rel === 'undefined') { + rel = getDefaultSetting('externalLinkRel'); + } + link.rel = rel; + } +} + +// Gets the file name from a given URL. +function getFilenameFromUrl(url) { + var anchor = url.indexOf('#'); + var query = url.indexOf('?'); + var end = Math.min( + anchor > 0 ? anchor : url.length, + query > 0 ? query : url.length); + return url.substring(url.lastIndexOf('/', end) + 1, end); +} + +function getDefaultSetting(id) { + // The list of the settings and their default is maintained for backward + // compatibility and shall not be extended or modified. See also global.js. + var globalSettings = sharedUtil.globalScope.PDFJS; + switch (id) { + case 'pdfBug': + return globalSettings ? globalSettings.pdfBug : false; + case 'disableAutoFetch': + return globalSettings ? globalSettings.disableAutoFetch : false; + case 'disableStream': + return globalSettings ? globalSettings.disableStream : false; + case 'disableRange': + return globalSettings ? globalSettings.disableRange : false; + case 'disableFontFace': + return globalSettings ? globalSettings.disableFontFace : false; + case 'disableCreateObjectURL': + return globalSettings ? globalSettings.disableCreateObjectURL : false; + case 'disableWebGL': + return globalSettings ? globalSettings.disableWebGL : true; + case 'cMapUrl': + return globalSettings ? globalSettings.cMapUrl : null; + case 'cMapPacked': + return globalSettings ? globalSettings.cMapPacked : false; + case 'postMessageTransfers': + return globalSettings ? globalSettings.postMessageTransfers : true; + case 'workerSrc': + return globalSettings ? globalSettings.workerSrc : null; + case 'disableWorker': + return globalSettings ? globalSettings.disableWorker : false; + case 'maxImageSize': + return globalSettings ? globalSettings.maxImageSize : -1; + case 'imageResourcesPath': + return globalSettings ? globalSettings.imageResourcesPath : ''; + case 'isEvalSupported': + return globalSettings ? globalSettings.isEvalSupported : true; + case 'externalLinkTarget': + if (!globalSettings) { + return LinkTarget.NONE; + } + switch (globalSettings.externalLinkTarget) { + case LinkTarget.NONE: + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return globalSettings.externalLinkTarget; + } + warn('PDFJS.externalLinkTarget is invalid: ' + + globalSettings.externalLinkTarget); + // Reset the external link target, to suppress further warnings. + globalSettings.externalLinkTarget = LinkTarget.NONE; + return LinkTarget.NONE; + case 'externalLinkRel': + return globalSettings ? globalSettings.externalLinkRel : 'noreferrer'; + case 'enableStats': + return !!(globalSettings && globalSettings.enableStats); + default: + throw new Error('Unknown default setting: ' + id); + } +} + +function isExternalLinkTargetSet() { + var externalLinkTarget = getDefaultSetting('externalLinkTarget'); + switch (externalLinkTarget) { + case LinkTarget.NONE: + return false; + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return true; + } +} + +exports.CustomStyle = CustomStyle; +exports.addLinkAttributes = addLinkAttributes; +exports.isExternalLinkTargetSet = isExternalLinkTargetSet; +exports.getFilenameFromUrl = getFilenameFromUrl; +exports.LinkTarget = LinkTarget; +exports.hasCanvasTypedArrays = hasCanvasTypedArrays; +exports.getDefaultSetting = getDefaultSetting; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil); + } +}(this, function (exports, sharedUtil) { + +var assert = sharedUtil.assert; +var bytesToString = sharedUtil.bytesToString; +var string32 = sharedUtil.string32; +var shadow = sharedUtil.shadow; +var warn = sharedUtil.warn; + +function FontLoader(docId) { + this.docId = docId; + this.styleElement = null; + this.nativeFontFaces = []; + this.loadTestFontId = 0; + this.loadingContext = { + requests: [], + nextRequestId: 0 + }; +} +FontLoader.prototype = { + insertRule: function fontLoaderInsertRule(rule) { + var styleElement = this.styleElement; + if (!styleElement) { + styleElement = this.styleElement = document.createElement('style'); + styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId; + document.documentElement.getElementsByTagName('head')[0].appendChild( + styleElement); + } + + var styleSheet = styleElement.sheet; + styleSheet.insertRule(rule, styleSheet.cssRules.length); + }, + + clear: function fontLoaderClear() { + var styleElement = this.styleElement; + if (styleElement) { + styleElement.parentNode.removeChild(styleElement); + styleElement = this.styleElement = null; + } + this.nativeFontFaces.forEach(function(nativeFontFace) { + document.fonts.delete(nativeFontFace); + }); + this.nativeFontFaces.length = 0; + }, + get loadTestFont() { + // This is a CFF font with 1 glyph for '.' that fills its entire width and + // height. + return shadow(this, 'loadTestFont', 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==' + )); + }, + + addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) { + this.nativeFontFaces.push(nativeFontFace); + document.fonts.add(nativeFontFace); + }, + + bind: function fontLoaderBind(fonts, callback) { + var rules = []; + var fontsToLoad = []; + var fontLoadPromises = []; + var getNativeFontPromise = function(nativeFontFace) { + // Return a promise that is always fulfilled, even when the font fails to + // load. + return nativeFontFace.loaded.catch(function(e) { + warn('Failed to load font "' + nativeFontFace.family + '": ' + e); + }); + }; + for (var i = 0, ii = fonts.length; i < ii; i++) { + var font = fonts[i]; + + // Add the font to the DOM only once or skip if the font + // is already loaded. + if (font.attached || font.loading === false) { + continue; + } + font.attached = true; + + if (FontLoader.isFontLoadingAPISupported) { + var nativeFontFace = font.createNativeFontFace(); + if (nativeFontFace) { + this.addNativeFontFace(nativeFontFace); + fontLoadPromises.push(getNativeFontPromise(nativeFontFace)); + } + } else { + var rule = font.createFontFaceRule(); + if (rule) { + this.insertRule(rule); + rules.push(rule); + fontsToLoad.push(font); + } + } + } + + var request = this.queueLoadingCallback(callback); + if (FontLoader.isFontLoadingAPISupported) { + Promise.all(fontLoadPromises).then(function() { + request.complete(); + }); + } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) { + this.prepareFontLoadEvent(rules, fontsToLoad, request); + } else { + request.complete(); + } + }, + + queueLoadingCallback: function FontLoader_queueLoadingCallback(callback) { + function LoadLoader_completeRequest() { + assert(!request.end, 'completeRequest() cannot be called twice'); + request.end = Date.now(); + + // sending all completed requests in order how they were queued + while (context.requests.length > 0 && context.requests[0].end) { + var otherRequest = context.requests.shift(); + setTimeout(otherRequest.callback, 0); + } + } + + var context = this.loadingContext; + var requestId = 'pdfjs-font-loading-' + (context.nextRequestId++); + var request = { + id: requestId, + complete: LoadLoader_completeRequest, + callback: callback, + started: Date.now() + }; + context.requests.push(request); + return request; + }, + + prepareFontLoadEvent: function fontLoaderPrepareFontLoadEvent(rules, + fonts, + request) { + /** Hack begin */ + // There's currently no event when a font has finished downloading so the + // following code is a dirty hack to 'guess' when a font is + // ready. It's assumed fonts are loaded in order, so add a known test + // font after the desired fonts and then test for the loading of that + // test font. + + function int32(data, offset) { + return (data.charCodeAt(offset) << 24) | + (data.charCodeAt(offset + 1) << 16) | + (data.charCodeAt(offset + 2) << 8) | + (data.charCodeAt(offset + 3) & 0xff); + } + + function spliceString(s, offset, remove, insert) { + var chunk1 = s.substr(0, offset); + var chunk2 = s.substr(offset + remove); + return chunk1 + insert + chunk2; + } + + var i, ii; + + var canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + var ctx = canvas.getContext('2d'); + + var called = 0; + function isFontReady(name, callback) { + called++; + // With setTimeout clamping this gives the font ~100ms to load. + if(called > 30) { + warn('Load test font never loaded.'); + callback(); + return; + } + ctx.font = '30px ' + name; + ctx.fillText('.', 0, 20); + var imageData = ctx.getImageData(0, 0, 1, 1); + if (imageData.data[3] > 0) { + callback(); + return; + } + setTimeout(isFontReady.bind(null, name, callback)); + } + + var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++; + // Chromium seems to cache fonts based on a hash of the actual font data, + // so the font must be modified for each load test else it will appear to + // be loaded already. + // TODO: This could maybe be made faster by avoiding the btoa of the full + // font by splitting it in chunks before hand and padding the font id. + var data = this.loadTestFont; + var COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum) + data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, + loadTestFontId); + // CFF checksum is important for IE, adjusting it + var CFF_CHECKSUM_OFFSET = 16; + var XXXX_VALUE = 0x58585858; // the "comment" filled with 'X' + var checksum = int32(data, CFF_CHECKSUM_OFFSET); + for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) { + checksum = (checksum - XXXX_VALUE + int32(loadTestFontId, i)) | 0; + } + if (i < loadTestFontId.length) { // align to 4 bytes boundary + checksum = (checksum - XXXX_VALUE + + int32(loadTestFontId + 'XXX', i)) | 0; + } + data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum)); + + var url = 'url(data:font/opentype;base64,' + btoa(data) + ');'; + var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + + url + '}'; + this.insertRule(rule); + + var names = []; + for (i = 0, ii = fonts.length; i < ii; i++) { + names.push(fonts[i].loadedName); + } + names.push(loadTestFontId); + + var div = document.createElement('div'); + div.setAttribute('style', + 'visibility: hidden;' + + 'width: 10px; height: 10px;' + + 'position: absolute; top: 0px; left: 0px;'); + for (i = 0, ii = names.length; i < ii; ++i) { + var span = document.createElement('span'); + span.textContent = 'Hi'; + span.style.fontFamily = names[i]; + div.appendChild(span); + } + document.body.appendChild(div); + + isFontReady(loadTestFontId, function() { + document.body.removeChild(div); + request.complete(); + }); + /** Hack end */ + } +}; +FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && + !!document.fonts; +Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', { + get: function () { + if (typeof navigator === 'undefined') { + // node.js - we can pretend sync font loading is supported. + return shadow(FontLoader, 'isSyncFontLoadingSupported', true); + } + + var supported = false; + + // User agent string sniffing is bad, but there is no reliable way to tell + // if font is fully loaded and ready to be used with canvas. + var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent); + if (m && m[1] >= 14) { + supported = true; + } + // TODO other browsers + return shadow(FontLoader, 'isSyncFontLoadingSupported', supported); + }, + enumerable: true, + configurable: true +}); + +var IsEvalSupportedCached = { + get value() { + return shadow(this, 'value', sharedUtil.isEvalSupported()); + } +}; + +var FontFaceObject = (function FontFaceObjectClosure() { + function FontFaceObject(translatedData, options) { + this.compiledGlyphs = Object.create(null); + // importing translated data + for (var i in translatedData) { + this[i] = translatedData[i]; + } + this.options = options; + } + FontFaceObject.prototype = { + createNativeFontFace: function FontFaceObject_createNativeFontFace() { + if (!this.data) { + return null; + } + + if (this.options.disableFontFace) { + this.disableFontFace = true; + return null; + } + + var nativeFontFace = new FontFace(this.loadedName, this.data, {}); + + if (this.options.fontRegistry) { + this.options.fontRegistry.registerFont(this); + } + return nativeFontFace; + }, + + createFontFaceRule: function FontFaceObject_createFontFaceRule() { + if (!this.data) { + return null; + } + + if (this.options.disableFontFace) { + this.disableFontFace = true; + return null; + } + + var data = bytesToString(new Uint8Array(this.data)); + var fontName = this.loadedName; + + // Add the font-face rule to the document + var url = ('url(data:' + this.mimetype + ';base64,' + btoa(data) + ');'); + var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}'; + + if (this.options.fontRegistry) { + this.options.fontRegistry.registerFont(this, url); + } + + return rule; + }, + + getPathGenerator: + function FontFaceObject_getPathGenerator(objs, character) { + if (!(character in this.compiledGlyphs)) { + var cmds = objs.get(this.loadedName + '_path_' + character); + var current, i, len; + + // If we can, compile cmds into JS for MAXIMUM SPEED + if (this.options.isEvalSupported && IsEvalSupportedCached.value) { + var args, js = ''; + for (i = 0, len = cmds.length; i < len; i++) { + current = cmds[i]; + + if (current.args !== undefined) { + args = current.args.join(','); + } else { + args = ''; + } + + js += 'c.' + current.cmd + '(' + args + ');\n'; + } + /* jshint -W054 */ + this.compiledGlyphs[character] = new Function('c', 'size', js); + } else { + // But fall back on using Function.prototype.apply() if we're + // blocked from using eval() for whatever reason (like CSP policies) + this.compiledGlyphs[character] = function(c, size) { + for (i = 0, len = cmds.length; i < len; i++) { + current = cmds[i]; + + if (current.cmd === 'scale') { + current.args = [size, -size]; + } + + c[current.cmd].apply(c, current.args); + } + }; + } + } + return this.compiledGlyphs[character]; + } + }; + return FontFaceObject; +})(); + +exports.FontFaceObject = FontFaceObject; +exports.FontLoader = FontLoader; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil); + } +}(this, function (exports, sharedUtil) { + +var error = sharedUtil.error; + + function fixMetadata(meta) { + return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) { + var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, + function(code, d1, d2, d3) { + return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1); + }); + var chars = ''; + for (var i = 0; i < bytes.length; i += 2) { + var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1); + chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && + code !== 38 && false ? String.fromCharCode(code) : + '&#x' + (0x10000 + code).toString(16).substring(1) + ';'; + } + return '>' + chars; + }); + } + + function Metadata(meta) { + if (typeof meta === 'string') { + // Ghostscript produces invalid metadata + meta = fixMetadata(meta); + + var parser = new DOMParser(); + meta = parser.parseFromString(meta, 'application/xml'); + } else if (!(meta instanceof Document)) { + error('Metadata: Invalid metadata object'); + } + + this.metaDocument = meta; + this.metadata = Object.create(null); + this.parse(); + } + + Metadata.prototype = { + parse: function Metadata_parse() { + var doc = this.metaDocument; + var rdf = doc.documentElement; + + if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { // Wrapped in + rdf = rdf.firstChild; + while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') { + rdf = rdf.nextSibling; + } + } + + var nodeName = (rdf) ? rdf.nodeName.toLowerCase() : null; + if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) { + return; + } + + var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength; + for (i = 0, length = children.length; i < length; i++) { + desc = children[i]; + if (desc.nodeName.toLowerCase() !== 'rdf:description') { + continue; + } + + for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) { + if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') { + entry = desc.childNodes[ii]; + name = entry.nodeName.toLowerCase(); + this.metadata[name] = entry.textContent.trim(); + } + } + } + }, + + get: function Metadata_get(name) { + return this.metadata[name] || null; + }, + + has: function Metadata_has(name) { + return typeof this.metadata[name] !== 'undefined'; + } + }; + +exports.Metadata = Metadata; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil); + } +}(this, function (exports, sharedUtil) { +var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; +var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX; +var ImageKind = sharedUtil.ImageKind; +var OPS = sharedUtil.OPS; +var Util = sharedUtil.Util; +var isNum = sharedUtil.isNum; +var isArray = sharedUtil.isArray; +var warn = sharedUtil.warn; +var createObjectURL = sharedUtil.createObjectURL; + +var SVG_DEFAULTS = { + fontStyle: 'normal', + fontWeight: 'normal', + fillColor: '#000000' +}; + +var convertImgDataToPng = (function convertImgDataToPngClosure() { + var PNG_HEADER = + new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); + + var CHUNK_WRAPPER_SIZE = 12; + + var crcTable = new Int32Array(256); + for (var i = 0; i < 256; i++) { + var c = i; + for (var h = 0; h < 8; h++) { + if (c & 1) { + c = 0xedB88320 ^ ((c >> 1) & 0x7fffffff); + } else { + c = (c >> 1) & 0x7fffffff; + } + } + crcTable[i] = c; + } + + function crc32(data, start, end) { + var crc = -1; + for (var i = start; i < end; i++) { + var a = (crc ^ data[i]) & 0xff; + var b = crcTable[a]; + crc = (crc >>> 8) ^ b; + } + return crc ^ -1; + } + + function writePngChunk(type, body, data, offset) { + var p = offset; + var len = body.length; + + data[p] = len >> 24 & 0xff; + data[p + 1] = len >> 16 & 0xff; + data[p + 2] = len >> 8 & 0xff; + data[p + 3] = len & 0xff; + p += 4; + + data[p] = type.charCodeAt(0) & 0xff; + data[p + 1] = type.charCodeAt(1) & 0xff; + data[p + 2] = type.charCodeAt(2) & 0xff; + data[p + 3] = type.charCodeAt(3) & 0xff; + p += 4; + + data.set(body, p); + p += body.length; + + var crc = crc32(data, offset + 4, p); + + data[p] = crc >> 24 & 0xff; + data[p + 1] = crc >> 16 & 0xff; + data[p + 2] = crc >> 8 & 0xff; + data[p + 3] = crc & 0xff; + } + + function adler32(data, start, end) { + var a = 1; + var b = 0; + for (var i = start; i < end; ++i) { + a = (a + (data[i] & 0xff)) % 65521; + b = (b + a) % 65521; + } + return (b << 16) | a; + } + + function encode(imgData, kind, forceDataSchema) { + var width = imgData.width; + var height = imgData.height; + var bitDepth, colorType, lineSize; + var bytes = imgData.data; + + switch (kind) { + case ImageKind.GRAYSCALE_1BPP: + colorType = 0; + bitDepth = 1; + lineSize = (width + 7) >> 3; + break; + case ImageKind.RGB_24BPP: + colorType = 2; + bitDepth = 8; + lineSize = width * 3; + break; + case ImageKind.RGBA_32BPP: + colorType = 6; + bitDepth = 8; + lineSize = width * 4; + break; + default: + throw new Error('invalid format'); + } + + // prefix every row with predictor 0 + var literals = new Uint8Array((1 + lineSize) * height); + var offsetLiterals = 0, offsetBytes = 0; + var y, i; + for (y = 0; y < height; ++y) { + literals[offsetLiterals++] = 0; // no prediction + literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), + offsetLiterals); + offsetBytes += lineSize; + offsetLiterals += lineSize; + } + + if (kind === ImageKind.GRAYSCALE_1BPP) { + // inverting for B/W + offsetLiterals = 0; + for (y = 0; y < height; y++) { + offsetLiterals++; // skipping predictor + for (i = 0; i < lineSize; i++) { + literals[offsetLiterals++] ^= 0xFF; + } + } + } + + var ihdr = new Uint8Array([ + width >> 24 & 0xff, + width >> 16 & 0xff, + width >> 8 & 0xff, + width & 0xff, + height >> 24 & 0xff, + height >> 16 & 0xff, + height >> 8 & 0xff, + height & 0xff, + bitDepth, // bit depth + colorType, // color type + 0x00, // compression method + 0x00, // filter method + 0x00 // interlace method + ]); + + var len = literals.length; + var maxBlockLength = 0xFFFF; + + var deflateBlocks = Math.ceil(len / maxBlockLength); + var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4); + var pi = 0; + idat[pi++] = 0x78; // compression method and flags + idat[pi++] = 0x9c; // flags + + var pos = 0; + while (len > maxBlockLength) { + // writing non-final DEFLATE blocks type 0 and length of 65535 + idat[pi++] = 0x00; + idat[pi++] = 0xff; + idat[pi++] = 0xff; + idat[pi++] = 0x00; + idat[pi++] = 0x00; + idat.set(literals.subarray(pos, pos + maxBlockLength), pi); + pi += maxBlockLength; + pos += maxBlockLength; + len -= maxBlockLength; + } + + // writing non-final DEFLATE blocks type 0 + idat[pi++] = 0x01; + idat[pi++] = len & 0xff; + idat[pi++] = len >> 8 & 0xff; + idat[pi++] = (~len & 0xffff) & 0xff; + idat[pi++] = (~len & 0xffff) >> 8 & 0xff; + idat.set(literals.subarray(pos), pi); + pi += literals.length - pos; + + var adler = adler32(literals, 0, literals.length); // checksum + idat[pi++] = adler >> 24 & 0xff; + idat[pi++] = adler >> 16 & 0xff; + idat[pi++] = adler >> 8 & 0xff; + idat[pi++] = adler & 0xff; + + // PNG will consists: header, IHDR+data, IDAT+data, and IEND. + var pngLength = PNG_HEADER.length + (CHUNK_WRAPPER_SIZE * 3) + + ihdr.length + idat.length; + var data = new Uint8Array(pngLength); + var offset = 0; + data.set(PNG_HEADER, offset); + offset += PNG_HEADER.length; + writePngChunk('IHDR', ihdr, data, offset); + offset += CHUNK_WRAPPER_SIZE + ihdr.length; + writePngChunk('IDATA', idat, data, offset); + offset += CHUNK_WRAPPER_SIZE + idat.length; + writePngChunk('IEND', new Uint8Array(0), data, offset); + + return createObjectURL(data, 'image/png', forceDataSchema); + } + + return function convertImgDataToPng(imgData, forceDataSchema) { + var kind = (imgData.kind === undefined ? + ImageKind.GRAYSCALE_1BPP : imgData.kind); + return encode(imgData, kind, forceDataSchema); + }; +})(); + +var SVGExtraState = (function SVGExtraStateClosure() { + function SVGExtraState() { + this.fontSizeScale = 1; + this.fontWeight = SVG_DEFAULTS.fontWeight; + this.fontSize = 0; + + this.textMatrix = IDENTITY_MATRIX; + this.fontMatrix = FONT_IDENTITY_MATRIX; + this.leading = 0; + + // Current point (in user coordinates) + this.x = 0; + this.y = 0; + + // Start of text line (in text coordinates) + this.lineX = 0; + this.lineY = 0; + + // Character and word spacing + this.charSpacing = 0; + this.wordSpacing = 0; + this.textHScale = 1; + this.textRise = 0; + + // Default foreground and background colors + this.fillColor = SVG_DEFAULTS.fillColor; + this.strokeColor = '#000000'; + + this.fillAlpha = 1; + this.strokeAlpha = 1; + this.lineWidth = 1; + this.lineJoin = ''; + this.lineCap = ''; + this.miterLimit = 0; + + this.dashArray = []; + this.dashPhase = 0; + + this.dependencies = []; + + // Clipping + this.clipId = ''; + this.pendingClip = false; + + this.maskId = ''; + } + + SVGExtraState.prototype = { + clone: function SVGExtraState_clone() { + return Object.create(this); + }, + setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) { + this.x = x; + this.y = y; + } + }; + return SVGExtraState; +})(); + +var SVGGraphics = (function SVGGraphicsClosure() { + function createScratchSVG(width, height) { + var NS = 'http://www.w3.org/2000/svg'; + var svg = document.createElementNS(NS, 'svg:svg'); + svg.setAttributeNS(null, 'version', '1.1'); + svg.setAttributeNS(null, 'width', width + 'px'); + svg.setAttributeNS(null, 'height', height + 'px'); + svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height); + return svg; + } + + function opListToTree(opList) { + var opTree = []; + var tmp = []; + var opListLen = opList.length; + + for (var x = 0; x < opListLen; x++) { + if (opList[x].fn === 'save') { + opTree.push({'fnId': 92, 'fn': 'group', 'items': []}); + tmp.push(opTree); + opTree = opTree[opTree.length - 1].items; + continue; + } + + if(opList[x].fn === 'restore') { + opTree = tmp.pop(); + } else { + opTree.push(opList[x]); + } + } + return opTree; + } + + /** + * Formats float number. + * @param value {number} number to format. + * @returns {string} + */ + function pf(value) { + if (value === (value | 0)) { // integer number + return value.toString(); + } + var s = value.toFixed(10); + var i = s.length - 1; + if (s[i] !== '0') { + return s; + } + // removing trailing zeros + do { + i--; + } while (s[i] === '0'); + return s.substr(0, s[i] === '.' ? i : i + 1); + } + + /** + * Formats transform matrix. The standard rotation, scale and translate + * matrices are replaced by their shorter forms, and for identity matrix + * returns empty string to save the memory. + * @param m {Array} matrix to format. + * @returns {string} + */ + function pm(m) { + if (m[4] === 0 && m[5] === 0) { + if (m[1] === 0 && m[2] === 0) { + if (m[0] === 1 && m[3] === 1) { + return ''; + } + return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')'; + } + if (m[0] === m[3] && m[1] === -m[2]) { + var a = Math.acos(m[0]) * 180 / Math.PI; + return 'rotate(' + pf(a) + ')'; + } + } else { + if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) { + return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')'; + } + } + return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')'; + } + + function SVGGraphics(commonObjs, objs, forceDataSchema) { + this.current = new SVGExtraState(); + this.transformMatrix = IDENTITY_MATRIX; // Graphics state matrix + this.transformStack = []; + this.extraStack = []; + this.commonObjs = commonObjs; + this.objs = objs; + this.pendingEOFill = false; + + this.embedFonts = false; + this.embeddedFonts = Object.create(null); + this.cssStyle = null; + this.forceDataSchema = !!forceDataSchema; + } + + var NS = 'http://www.w3.org/2000/svg'; + var XML_NS = 'http://www.w3.org/XML/1998/namespace'; + var XLINK_NS = 'http://www.w3.org/1999/xlink'; + var LINE_CAP_STYLES = ['butt', 'round', 'square']; + var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; + var clipCount = 0; + var maskCount = 0; + + SVGGraphics.prototype = { + save: function SVGGraphics_save() { + this.transformStack.push(this.transformMatrix); + var old = this.current; + this.extraStack.push(old); + this.current = old.clone(); + }, + + restore: function SVGGraphics_restore() { + this.transformMatrix = this.transformStack.pop(); + this.current = this.extraStack.pop(); + + this.tgrp = document.createElementNS(NS, 'svg:g'); + this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + this.pgrp.appendChild(this.tgrp); + }, + + group: function SVGGraphics_group(items) { + this.save(); + this.executeOpTree(items); + this.restore(); + }, + + loadDependencies: function SVGGraphics_loadDependencies(operatorList) { + var fnArray = operatorList.fnArray; + var fnArrayLen = fnArray.length; + var argsArray = operatorList.argsArray; + + var self = this; + for (var i = 0; i < fnArrayLen; i++) { + if (OPS.dependency === fnArray[i]) { + var deps = argsArray[i]; + for (var n = 0, nn = deps.length; n < nn; n++) { + var obj = deps[n]; + var common = obj.substring(0, 2) === 'g_'; + var promise; + if (common) { + promise = new Promise(function(resolve) { + self.commonObjs.get(obj, resolve); + }); + } else { + promise = new Promise(function(resolve) { + self.objs.get(obj, resolve); + }); + } + this.current.dependencies.push(promise); + } + } + } + return Promise.all(this.current.dependencies); + }, + + transform: function SVGGraphics_transform(a, b, c, d, e, f) { + var transformMatrix = [a, b, c, d, e, f]; + this.transformMatrix = Util.transform(this.transformMatrix, + transformMatrix); + + this.tgrp = document.createElementNS(NS, 'svg:g'); + this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + }, + + getSVG: function SVGGraphics_getSVG(operatorList, viewport) { + this.svg = createScratchSVG(viewport.width, viewport.height); + this.viewport = viewport; + + return this.loadDependencies(operatorList).then(function () { + this.transformMatrix = IDENTITY_MATRIX; + this.pgrp = document.createElementNS(NS, 'svg:g'); // Parent group + this.pgrp.setAttributeNS(null, 'transform', pm(viewport.transform)); + this.tgrp = document.createElementNS(NS, 'svg:g'); // Transform group + this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + this.defs = document.createElementNS(NS, 'svg:defs'); + this.pgrp.appendChild(this.defs); + this.pgrp.appendChild(this.tgrp); + this.svg.appendChild(this.pgrp); + var opTree = this.convertOpList(operatorList); + this.executeOpTree(opTree); + return this.svg; + }.bind(this)); + }, + + convertOpList: function SVGGraphics_convertOpList(operatorList) { + var argsArray = operatorList.argsArray; + var fnArray = operatorList.fnArray; + var fnArrayLen = fnArray.length; + var REVOPS = []; + var opList = []; + + for (var op in OPS) { + REVOPS[OPS[op]] = op; + } + + for (var x = 0; x < fnArrayLen; x++) { + var fnId = fnArray[x]; + opList.push({'fnId' : fnId, 'fn': REVOPS[fnId], 'args': argsArray[x]}); + } + return opListToTree(opList); + }, + + executeOpTree: function SVGGraphics_executeOpTree(opTree) { + var opTreeLen = opTree.length; + for(var x = 0; x < opTreeLen; x++) { + var fn = opTree[x].fn; + var fnId = opTree[x].fnId; + var args = opTree[x].args; + + switch (fnId | 0) { + case OPS.beginText: + this.beginText(); + break; + case OPS.setLeading: + this.setLeading(args); + break; + case OPS.setLeadingMoveText: + this.setLeadingMoveText(args[0], args[1]); + break; + case OPS.setFont: + this.setFont(args); + break; + case OPS.showText: + this.showText(args[0]); + break; + case OPS.showSpacedText: + this.showText(args[0]); + break; + case OPS.endText: + this.endText(); + break; + case OPS.moveText: + this.moveText(args[0], args[1]); + break; + case OPS.setCharSpacing: + this.setCharSpacing(args[0]); + break; + case OPS.setWordSpacing: + this.setWordSpacing(args[0]); + break; + case OPS.setHScale: + this.setHScale(args[0]); + break; + case OPS.setTextMatrix: + this.setTextMatrix(args[0], args[1], args[2], + args[3], args[4], args[5]); + break; + case OPS.setLineWidth: + this.setLineWidth(args[0]); + break; + case OPS.setLineJoin: + this.setLineJoin(args[0]); + break; + case OPS.setLineCap: + this.setLineCap(args[0]); + break; + case OPS.setMiterLimit: + this.setMiterLimit(args[0]); + break; + case OPS.setFillRGBColor: + this.setFillRGBColor(args[0], args[1], args[2]); + break; + case OPS.setStrokeRGBColor: + this.setStrokeRGBColor(args[0], args[1], args[2]); + break; + case OPS.setDash: + this.setDash(args[0], args[1]); + break; + case OPS.setGState: + this.setGState(args[0]); + break; + case OPS.fill: + this.fill(); + break; + case OPS.eoFill: + this.eoFill(); + break; + case OPS.stroke: + this.stroke(); + break; + case OPS.fillStroke: + this.fillStroke(); + break; + case OPS.eoFillStroke: + this.eoFillStroke(); + break; + case OPS.clip: + this.clip('nonzero'); + break; + case OPS.eoClip: + this.clip('evenodd'); + break; + case OPS.paintSolidColorImageMask: + this.paintSolidColorImageMask(); + break; + case OPS.paintJpegXObject: + this.paintJpegXObject(args[0], args[1], args[2]); + break; + case OPS.paintImageXObject: + this.paintImageXObject(args[0]); + break; + case OPS.paintInlineImageXObject: + this.paintInlineImageXObject(args[0]); + break; + case OPS.paintImageMaskXObject: + this.paintImageMaskXObject(args[0]); + break; + case OPS.paintFormXObjectBegin: + this.paintFormXObjectBegin(args[0], args[1]); + break; + case OPS.paintFormXObjectEnd: + this.paintFormXObjectEnd(); + break; + case OPS.closePath: + this.closePath(); + break; + case OPS.closeStroke: + this.closeStroke(); + break; + case OPS.closeFillStroke: + this.closeFillStroke(); + break; + case OPS.nextLine: + this.nextLine(); + break; + case OPS.transform: + this.transform(args[0], args[1], args[2], args[3], + args[4], args[5]); + break; + case OPS.constructPath: + this.constructPath(args[0], args[1]); + break; + case OPS.endPath: + this.endPath(); + break; + case 92: + this.group(opTree[x].items); + break; + default: + warn('Unimplemented method '+ fn); + break; + } + } + }, + + setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) { + this.current.wordSpacing = wordSpacing; + }, + + setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) { + this.current.charSpacing = charSpacing; + }, + + nextLine: function SVGGraphics_nextLine() { + this.moveText(0, this.current.leading); + }, + + setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) { + var current = this.current; + this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f]; + + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + + current.xcoords = []; + current.tspan = document.createElementNS(NS, 'svg:tspan'); + current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); + current.tspan.setAttributeNS(null, 'font-size', + pf(current.fontSize) + 'px'); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + + current.txtElement = document.createElementNS(NS, 'svg:text'); + current.txtElement.appendChild(current.tspan); + }, + + beginText: function SVGGraphics_beginText() { + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + this.current.textMatrix = IDENTITY_MATRIX; + this.current.lineMatrix = IDENTITY_MATRIX; + this.current.tspan = document.createElementNS(NS, 'svg:tspan'); + this.current.txtElement = document.createElementNS(NS, 'svg:text'); + this.current.txtgrp = document.createElementNS(NS, 'svg:g'); + this.current.xcoords = []; + }, + + moveText: function SVGGraphics_moveText(x, y) { + var current = this.current; + this.current.x = this.current.lineX += x; + this.current.y = this.current.lineY += y; + + current.xcoords = []; + current.tspan = document.createElementNS(NS, 'svg:tspan'); + current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); + current.tspan.setAttributeNS(null, 'font-size', + pf(current.fontSize) + 'px'); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + }, + + showText: function SVGGraphics_showText(glyphs) { + var current = this.current; + var font = current.font; + var fontSize = current.fontSize; + + if (fontSize === 0) { + return; + } + + var charSpacing = current.charSpacing; + var wordSpacing = current.wordSpacing; + var fontDirection = current.fontDirection; + var textHScale = current.textHScale * fontDirection; + var glyphsLength = glyphs.length; + var vertical = font.vertical; + var widthAdvanceScale = fontSize * current.fontMatrix[0]; + + var x = 0, i; + for (i = 0; i < glyphsLength; ++i) { + var glyph = glyphs[i]; + if (glyph === null) { + // word break + x += fontDirection * wordSpacing; + continue; + } else if (isNum(glyph)) { + x += -glyph * fontSize * 0.001; + continue; + } + current.xcoords.push(current.x + x * textHScale); + + var width = glyph.width; + var character = glyph.fontChar; + var charWidth = width * widthAdvanceScale + charSpacing * fontDirection; + x += charWidth; + + current.tspan.textContent += character; + } + if (vertical) { + current.y -= x * textHScale; + } else { + current.x += x * textHScale; + } + + current.tspan.setAttributeNS(null, 'x', + current.xcoords.map(pf).join(' ')); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); + current.tspan.setAttributeNS(null, 'font-size', + pf(current.fontSize) + 'px'); + if (current.fontStyle !== SVG_DEFAULTS.fontStyle) { + current.tspan.setAttributeNS(null, 'font-style', current.fontStyle); + } + if (current.fontWeight !== SVG_DEFAULTS.fontWeight) { + current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight); + } + if (current.fillColor !== SVG_DEFAULTS.fillColor) { + current.tspan.setAttributeNS(null, 'fill', current.fillColor); + } + + current.txtElement.setAttributeNS(null, 'transform', + pm(current.textMatrix) + + ' scale(1, -1)' ); + current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve'); + current.txtElement.appendChild(current.tspan); + current.txtgrp.appendChild(current.txtElement); + + this.tgrp.appendChild(current.txtElement); + + }, + + setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) { + this.setLeading(-y); + this.moveText(x, y); + }, + + addFontStyle: function SVGGraphics_addFontStyle(fontObj) { + if (!this.cssStyle) { + this.cssStyle = document.createElementNS(NS, 'svg:style'); + this.cssStyle.setAttributeNS(null, 'type', 'text/css'); + this.defs.appendChild(this.cssStyle); + } + + var url = createObjectURL(fontObj.data, fontObj.mimetype, + this.forceDataSchema); + this.cssStyle.textContent += + '@font-face { font-family: "' + fontObj.loadedName + '";' + + ' src: url(' + url + '); }\n'; + }, + + setFont: function SVGGraphics_setFont(details) { + var current = this.current; + var fontObj = this.commonObjs.get(details[0]); + var size = details[1]; + this.current.font = fontObj; + + if (this.embedFonts && fontObj.data && + !this.embeddedFonts[fontObj.loadedName]) { + this.addFontStyle(fontObj); + this.embeddedFonts[fontObj.loadedName] = fontObj; + } + + current.fontMatrix = (fontObj.fontMatrix ? + fontObj.fontMatrix : FONT_IDENTITY_MATRIX); + + var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') : + (fontObj.bold ? 'bold' : 'normal'); + var italic = fontObj.italic ? 'italic' : 'normal'; + + if (size < 0) { + size = -size; + current.fontDirection = -1; + } else { + current.fontDirection = 1; + } + current.fontSize = size; + current.fontFamily = fontObj.loadedName; + current.fontWeight = bold; + current.fontStyle = italic; + + current.tspan = document.createElementNS(NS, 'svg:tspan'); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + current.xcoords = []; + }, + + endText: function SVGGraphics_endText() { + if (this.current.pendingClip) { + this.cgrp.appendChild(this.tgrp); + this.pgrp.appendChild(this.cgrp); + } else { + this.pgrp.appendChild(this.tgrp); + } + this.tgrp = document.createElementNS(NS, 'svg:g'); + this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + }, + + // Path properties + setLineWidth: function SVGGraphics_setLineWidth(width) { + this.current.lineWidth = width; + }, + setLineCap: function SVGGraphics_setLineCap(style) { + this.current.lineCap = LINE_CAP_STYLES[style]; + }, + setLineJoin: function SVGGraphics_setLineJoin(style) { + this.current.lineJoin = LINE_JOIN_STYLES[style]; + }, + setMiterLimit: function SVGGraphics_setMiterLimit(limit) { + this.current.miterLimit = limit; + }, + setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.current.strokeColor = color; + }, + setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.current.fillColor = color; + this.current.tspan = document.createElementNS(NS, 'svg:tspan'); + this.current.xcoords = []; + }, + setDash: function SVGGraphics_setDash(dashArray, dashPhase) { + this.current.dashArray = dashArray; + this.current.dashPhase = dashPhase; + }, + + constructPath: function SVGGraphics_constructPath(ops, args) { + var current = this.current; + var x = current.x, y = current.y; + current.path = document.createElementNS(NS, 'svg:path'); + var d = []; + var opLength = ops.length; + + for (var i = 0, j = 0; i < opLength; i++) { + switch (ops[i] | 0) { + case OPS.rectangle: + x = args[j++]; + y = args[j++]; + var width = args[j++]; + var height = args[j++]; + var xw = x + width; + var yh = y + height; + d.push('M', pf(x), pf(y), 'L', pf(xw) , pf(y), 'L', pf(xw), pf(yh), + 'L', pf(x), pf(yh), 'Z'); + break; + case OPS.moveTo: + x = args[j++]; + y = args[j++]; + d.push('M', pf(x), pf(y)); + break; + case OPS.lineTo: + x = args[j++]; + y = args[j++]; + d.push('L', pf(x) , pf(y)); + break; + case OPS.curveTo: + x = args[j + 4]; + y = args[j + 5]; + d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), + pf(args[j + 3]), pf(x), pf(y)); + j += 6; + break; + case OPS.curveTo2: + x = args[j + 2]; + y = args[j + 3]; + d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), + pf(args[j + 2]), pf(args[j + 3])); + j += 4; + break; + case OPS.curveTo3: + x = args[j + 2]; + y = args[j + 3]; + d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), + pf(x), pf(y)); + j += 4; + break; + case OPS.closePath: + d.push('Z'); + break; + } + } + current.path.setAttributeNS(null, 'd', d.join(' ')); + current.path.setAttributeNS(null, 'stroke-miterlimit', + pf(current.miterLimit)); + current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap); + current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); + current.path.setAttributeNS(null, 'stroke-width', + pf(current.lineWidth) + 'px'); + current.path.setAttributeNS(null, 'stroke-dasharray', + current.dashArray.map(pf).join(' ')); + current.path.setAttributeNS(null, 'stroke-dashoffset', + pf(current.dashPhase) + 'px'); + current.path.setAttributeNS(null, 'fill', 'none'); + + this.tgrp.appendChild(current.path); + if (current.pendingClip) { + this.cgrp.appendChild(this.tgrp); + this.pgrp.appendChild(this.cgrp); + } else { + this.pgrp.appendChild(this.tgrp); + } + // Saving a reference in current.element so that it can be addressed + // in 'fill' and 'stroke' + current.element = current.path; + current.setCurrentPoint(x, y); + }, + + endPath: function SVGGraphics_endPath() { + var current = this.current; + if (current.pendingClip) { + this.cgrp.appendChild(this.tgrp); + this.pgrp.appendChild(this.cgrp); + } else { + this.pgrp.appendChild(this.tgrp); + } + this.tgrp = document.createElementNS(NS, 'svg:g'); + this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + }, + + clip: function SVGGraphics_clip(type) { + var current = this.current; + // Add current path to clipping path + current.clipId = 'clippath' + clipCount; + clipCount++; + this.clippath = document.createElementNS(NS, 'svg:clipPath'); + this.clippath.setAttributeNS(null, 'id', current.clipId); + var clipElement = current.element.cloneNode(); + if (type === 'evenodd') { + clipElement.setAttributeNS(null, 'clip-rule', 'evenodd'); + } else { + clipElement.setAttributeNS(null, 'clip-rule', 'nonzero'); + } + this.clippath.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + this.clippath.appendChild(clipElement); + this.defs.appendChild(this.clippath); + + // Create a new group with that attribute + current.pendingClip = true; + this.cgrp = document.createElementNS(NS, 'svg:g'); + this.cgrp.setAttributeNS(null, 'clip-path', + 'url(#' + current.clipId + ')'); + this.pgrp.appendChild(this.cgrp); + }, + + closePath: function SVGGraphics_closePath() { + var current = this.current; + var d = current.path.getAttributeNS(null, 'd'); + d += 'Z'; + current.path.setAttributeNS(null, 'd', d); + }, + + setLeading: function SVGGraphics_setLeading(leading) { + this.current.leading = -leading; + }, + + setTextRise: function SVGGraphics_setTextRise(textRise) { + this.current.textRise = textRise; + }, + + setHScale: function SVGGraphics_setHScale(scale) { + this.current.textHScale = scale / 100; + }, + + setGState: function SVGGraphics_setGState(states) { + for (var i = 0, ii = states.length; i < ii; i++) { + var state = states[i]; + var key = state[0]; + var value = state[1]; + + switch (key) { + case 'LW': + this.setLineWidth(value); + break; + case 'LC': + this.setLineCap(value); + break; + case 'LJ': + this.setLineJoin(value); + break; + case 'ML': + this.setMiterLimit(value); + break; + case 'D': + this.setDash(value[0], value[1]); + break; + case 'RI': + break; + case 'FL': + break; + case 'Font': + this.setFont(value); + break; + case 'CA': + break; + case 'ca': + break; + case 'BM': + break; + case 'SMask': + break; + } + } + }, + + fill: function SVGGraphics_fill() { + var current = this.current; + current.element.setAttributeNS(null, 'fill', current.fillColor); + }, + + stroke: function SVGGraphics_stroke() { + var current = this.current; + current.element.setAttributeNS(null, 'stroke', current.strokeColor); + current.element.setAttributeNS(null, 'fill', 'none'); + }, + + eoFill: function SVGGraphics_eoFill() { + var current = this.current; + current.element.setAttributeNS(null, 'fill', current.fillColor); + current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); + }, + + fillStroke: function SVGGraphics_fillStroke() { + // Order is important since stroke wants fill to be none. + // First stroke, then if fill needed, it will be overwritten. + this.stroke(); + this.fill(); + }, + + eoFillStroke: function SVGGraphics_eoFillStroke() { + this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); + this.fillStroke(); + }, + + closeStroke: function SVGGraphics_closeStroke() { + this.closePath(); + this.stroke(); + }, + + closeFillStroke: function SVGGraphics_closeFillStroke() { + this.closePath(); + this.fillStroke(); + }, + + paintSolidColorImageMask: + function SVGGraphics_paintSolidColorImageMask() { + var current = this.current; + var rect = document.createElementNS(NS, 'svg:rect'); + rect.setAttributeNS(null, 'x', '0'); + rect.setAttributeNS(null, 'y', '0'); + rect.setAttributeNS(null, 'width', '1px'); + rect.setAttributeNS(null, 'height', '1px'); + rect.setAttributeNS(null, 'fill', current.fillColor); + this.tgrp.appendChild(rect); + }, + + paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) { + var current = this.current; + var imgObj = this.objs.get(objId); + var imgEl = document.createElementNS(NS, 'svg:image'); + imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src); + imgEl.setAttributeNS(null, 'width', imgObj.width + 'px'); + imgEl.setAttributeNS(null, 'height', imgObj.height + 'px'); + imgEl.setAttributeNS(null, 'x', '0'); + imgEl.setAttributeNS(null, 'y', pf(-h)); + imgEl.setAttributeNS(null, 'transform', + 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')'); + + this.tgrp.appendChild(imgEl); + if (current.pendingClip) { + this.cgrp.appendChild(this.tgrp); + this.pgrp.appendChild(this.cgrp); + } else { + this.pgrp.appendChild(this.tgrp); + } + }, + + paintImageXObject: function SVGGraphics_paintImageXObject(objId) { + var imgData = this.objs.get(objId); + if (!imgData) { + warn('Dependent image isn\'t ready yet'); + return; + } + this.paintInlineImageXObject(imgData); + }, + + paintInlineImageXObject: + function SVGGraphics_paintInlineImageXObject(imgData, mask) { + var current = this.current; + var width = imgData.width; + var height = imgData.height; + + var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema); + var cliprect = document.createElementNS(NS, 'svg:rect'); + cliprect.setAttributeNS(null, 'x', '0'); + cliprect.setAttributeNS(null, 'y', '0'); + cliprect.setAttributeNS(null, 'width', pf(width)); + cliprect.setAttributeNS(null, 'height', pf(height)); + current.element = cliprect; + this.clip('nonzero'); + var imgEl = document.createElementNS(NS, 'svg:image'); + imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc); + imgEl.setAttributeNS(null, 'x', '0'); + imgEl.setAttributeNS(null, 'y', pf(-height)); + imgEl.setAttributeNS(null, 'width', pf(width) + 'px'); + imgEl.setAttributeNS(null, 'height', pf(height) + 'px'); + imgEl.setAttributeNS(null, 'transform', + 'scale(' + pf(1 / width) + ' ' + + pf(-1 / height) + ')'); + if (mask) { + mask.appendChild(imgEl); + } else { + this.tgrp.appendChild(imgEl); + } + if (current.pendingClip) { + this.cgrp.appendChild(this.tgrp); + this.pgrp.appendChild(this.cgrp); + } else { + this.pgrp.appendChild(this.tgrp); + } + }, + + paintImageMaskXObject: + function SVGGraphics_paintImageMaskXObject(imgData) { + var current = this.current; + var width = imgData.width; + var height = imgData.height; + var fillColor = current.fillColor; + + current.maskId = 'mask' + maskCount++; + var mask = document.createElementNS(NS, 'svg:mask'); + mask.setAttributeNS(null, 'id', current.maskId); + + var rect = document.createElementNS(NS, 'svg:rect'); + rect.setAttributeNS(null, 'x', '0'); + rect.setAttributeNS(null, 'y', '0'); + rect.setAttributeNS(null, 'width', pf(width)); + rect.setAttributeNS(null, 'height', pf(height)); + rect.setAttributeNS(null, 'fill', fillColor); + rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId +')'); + this.defs.appendChild(mask); + this.tgrp.appendChild(rect); + + this.paintInlineImageXObject(imgData, mask); + }, + + paintFormXObjectBegin: + function SVGGraphics_paintFormXObjectBegin(matrix, bbox) { + this.save(); + + if (isArray(matrix) && matrix.length === 6) { + this.transform(matrix[0], matrix[1], matrix[2], + matrix[3], matrix[4], matrix[5]); + } + + if (isArray(bbox) && bbox.length === 4) { + var width = bbox[2] - bbox[0]; + var height = bbox[3] - bbox[1]; + + var cliprect = document.createElementNS(NS, 'svg:rect'); + cliprect.setAttributeNS(null, 'x', bbox[0]); + cliprect.setAttributeNS(null, 'y', bbox[1]); + cliprect.setAttributeNS(null, 'width', pf(width)); + cliprect.setAttributeNS(null, 'height', pf(height)); + this.current.element = cliprect; + this.clip('nonzero'); + this.endPath(); + } + }, + + paintFormXObjectEnd: + function SVGGraphics_paintFormXObjectEnd() { + this.restore(); + } + }; + return SVGGraphics; +})(); + +exports.SVGGraphics = SVGGraphics; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayAnnotationLayer = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils); + } +}(this, function (exports, sharedUtil, displayDOMUtils) { + +var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType; +var AnnotationType = sharedUtil.AnnotationType; +var Util = sharedUtil.Util; +var addLinkAttributes = displayDOMUtils.addLinkAttributes; +var LinkTarget = displayDOMUtils.LinkTarget; +var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; +var warn = sharedUtil.warn; +var CustomStyle = displayDOMUtils.CustomStyle; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; + +/** + * @typedef {Object} AnnotationElementParameters + * @property {Object} data + * @property {HTMLDivElement} layer + * @property {PDFPage} page + * @property {PageViewport} viewport + * @property {IPDFLinkService} linkService + * @property {DownloadManager} downloadManager + */ + +/** + * @class + * @alias AnnotationElementFactory + */ +function AnnotationElementFactory() {} +AnnotationElementFactory.prototype = + /** @lends AnnotationElementFactory.prototype */ { + /** + * @param {AnnotationElementParameters} parameters + * @returns {AnnotationElement} + */ + create: function AnnotationElementFactory_create(parameters) { + var subtype = parameters.data.annotationType; + + switch (subtype) { + case AnnotationType.LINK: + return new LinkAnnotationElement(parameters); + + case AnnotationType.TEXT: + return new TextAnnotationElement(parameters); + + case AnnotationType.WIDGET: + return new WidgetAnnotationElement(parameters); + + case AnnotationType.POPUP: + return new PopupAnnotationElement(parameters); + + case AnnotationType.HIGHLIGHT: + return new HighlightAnnotationElement(parameters); + + case AnnotationType.UNDERLINE: + return new UnderlineAnnotationElement(parameters); + + case AnnotationType.SQUIGGLY: + return new SquigglyAnnotationElement(parameters); + + case AnnotationType.STRIKEOUT: + return new StrikeOutAnnotationElement(parameters); + + case AnnotationType.FILEATTACHMENT: + return new FileAttachmentAnnotationElement(parameters); + + default: + return new AnnotationElement(parameters); + } + } +}; + +/** + * @class + * @alias AnnotationElement + */ +var AnnotationElement = (function AnnotationElementClosure() { + function AnnotationElement(parameters, isRenderable) { + this.isRenderable = isRenderable || false; + this.data = parameters.data; + this.layer = parameters.layer; + this.page = parameters.page; + this.viewport = parameters.viewport; + this.linkService = parameters.linkService; + this.downloadManager = parameters.downloadManager; + this.imageResourcesPath = parameters.imageResourcesPath; + + if (isRenderable) { + this.container = this._createContainer(); + } + } + + AnnotationElement.prototype = /** @lends AnnotationElement.prototype */ { + /** + * Create an empty container for the annotation's HTML element. + * + * @private + * @memberof AnnotationElement + * @returns {HTMLSectionElement} + */ + _createContainer: function AnnotationElement_createContainer() { + var data = this.data, page = this.page, viewport = this.viewport; + var container = document.createElement('section'); + var width = data.rect[2] - data.rect[0]; + var height = data.rect[3] - data.rect[1]; + + container.setAttribute('data-annotation-id', data.id); + + // Do *not* modify `data.rect`, since that will corrupt the annotation + // position on subsequent calls to `_createContainer` (see issue 6804). + var rect = Util.normalizeRect([ + data.rect[0], + page.view[3] - data.rect[1] + page.view[1], + data.rect[2], + page.view[3] - data.rect[3] + page.view[1] + ]); + + CustomStyle.setProp('transform', container, + 'matrix(' + viewport.transform.join(',') + ')'); + CustomStyle.setProp('transformOrigin', container, + -rect[0] + 'px ' + -rect[1] + 'px'); + + if (data.borderStyle.width > 0) { + container.style.borderWidth = data.borderStyle.width + 'px'; + if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) { + // Underline styles only have a bottom border, so we do not need + // to adjust for all borders. This yields a similar result as + // Adobe Acrobat/Reader. + width = width - 2 * data.borderStyle.width; + height = height - 2 * data.borderStyle.width; + } + + var horizontalRadius = data.borderStyle.horizontalCornerRadius; + var verticalRadius = data.borderStyle.verticalCornerRadius; + if (horizontalRadius > 0 || verticalRadius > 0) { + var radius = horizontalRadius + 'px / ' + verticalRadius + 'px'; + CustomStyle.setProp('borderRadius', container, radius); + } + + switch (data.borderStyle.style) { + case AnnotationBorderStyleType.SOLID: + container.style.borderStyle = 'solid'; + break; + + case AnnotationBorderStyleType.DASHED: + container.style.borderStyle = 'dashed'; + break; + + case AnnotationBorderStyleType.BEVELED: + warn('Unimplemented border style: beveled'); + break; + + case AnnotationBorderStyleType.INSET: + warn('Unimplemented border style: inset'); + break; + + case AnnotationBorderStyleType.UNDERLINE: + container.style.borderBottomStyle = 'solid'; + break; + + default: + break; + } + + if (data.color) { + container.style.borderColor = + Util.makeCssRgb(data.color[0] | 0, + data.color[1] | 0, + data.color[2] | 0); + } else { + // Transparent (invisible) border, so do not draw it at all. + container.style.borderWidth = 0; + } + } + + container.style.left = rect[0] + 'px'; + container.style.top = rect[1] + 'px'; + + container.style.width = width + 'px'; + container.style.height = height + 'px'; + + return container; + }, + + /** + * Create a popup for the annotation's HTML element. This is used for + * annotations that do not have a Popup entry in the dictionary, but + * are of a type that works with popups (such as Highlight annotations). + * + * @private + * @param {HTMLSectionElement} container + * @param {HTMLDivElement|HTMLImageElement|null} trigger + * @param {Object} data + * @memberof AnnotationElement + */ + _createPopup: + function AnnotationElement_createPopup(container, trigger, data) { + // If no trigger element is specified, create it. + if (!trigger) { + trigger = document.createElement('div'); + trigger.style.height = container.style.height; + trigger.style.width = container.style.width; + container.appendChild(trigger); + } + + var popupElement = new PopupElement({ + container: container, + trigger: trigger, + color: data.color, + title: data.title, + contents: data.contents, + hideWrapper: true + }); + var popup = popupElement.render(); + + // Position the popup next to the annotation's container. + popup.style.left = container.style.width; + + container.appendChild(popup); + }, + + /** + * Render the annotation's HTML element in the empty container. + * + * @public + * @memberof AnnotationElement + */ + render: function AnnotationElement_render() { + throw new Error('Abstract method AnnotationElement.render called'); + } + }; + + return AnnotationElement; +})(); + +/** + * @class + * @alias LinkAnnotationElement + */ +var LinkAnnotationElement = (function LinkAnnotationElementClosure() { + function LinkAnnotationElement(parameters) { + AnnotationElement.call(this, parameters, true); + } + + Util.inherit(LinkAnnotationElement, AnnotationElement, { + /** + * Render the link annotation's HTML element in the empty container. + * + * @public + * @memberof LinkAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function LinkAnnotationElement_render() { + this.container.className = 'linkAnnotation'; + + var link = document.createElement('a'); + addLinkAttributes(link, { + url: this.data.url, + target: (this.data.newWindow ? LinkTarget.BLANK : undefined), + }); + + if (!this.data.url) { + if (this.data.action) { + this._bindNamedAction(link, this.data.action); + } else { + this._bindLink(link, (this.data.dest || null)); + } + } + + this.container.appendChild(link); + return this.container; + }, + + /** + * Bind internal links to the link element. + * + * @private + * @param {Object} link + * @param {Object} destination + * @memberof LinkAnnotationElement + */ + _bindLink: function LinkAnnotationElement_bindLink(link, destination) { + var self = this; + + link.href = this.linkService.getDestinationHash(destination); + link.onclick = function() { + if (destination) { + self.linkService.navigateTo(destination); + } + return false; + }; + if (destination) { + link.className = 'internalLink'; + } + }, + + /** + * Bind named actions to the link element. + * + * @private + * @param {Object} link + * @param {Object} action + * @memberof LinkAnnotationElement + */ + _bindNamedAction: + function LinkAnnotationElement_bindNamedAction(link, action) { + var self = this; + + link.href = this.linkService.getAnchorUrl(''); + link.onclick = function() { + self.linkService.executeNamedAction(action); + return false; + }; + link.className = 'internalLink'; + } + }); + + return LinkAnnotationElement; +})(); + +/** + * @class + * @alias TextAnnotationElement + */ +var TextAnnotationElement = (function TextAnnotationElementClosure() { + function TextAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || + parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(TextAnnotationElement, AnnotationElement, { + /** + * Render the text annotation's HTML element in the empty container. + * + * @public + * @memberof TextAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function TextAnnotationElement_render() { + this.container.className = 'textAnnotation'; + + var image = document.createElement('img'); + image.style.height = this.container.style.height; + image.style.width = this.container.style.width; + image.src = this.imageResourcesPath + 'annotation-' + + this.data.name.toLowerCase() + '.svg'; + image.alt = '[{{type}} Annotation]'; + image.dataset.l10nId = 'text_annotation_type'; + image.dataset.l10nArgs = JSON.stringify({type: this.data.name}); + + if (!this.data.hasPopup) { + this._createPopup(this.container, image, this.data); + } + + this.container.appendChild(image); + return this.container; + } + }); + + return TextAnnotationElement; +})(); + +/** + * @class + * @alias WidgetAnnotationElement + */ +var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() { + function WidgetAnnotationElement(parameters) { + var isRenderable = !parameters.data.hasAppearance && + !!parameters.data.fieldValue; + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(WidgetAnnotationElement, AnnotationElement, { + /** + * Render the widget annotation's HTML element in the empty container. + * + * @public + * @memberof WidgetAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function WidgetAnnotationElement_render() { + var content = document.createElement('div'); + content.textContent = this.data.fieldValue; + var textAlignment = this.data.textAlignment; + content.style.textAlign = ['left', 'center', 'right'][textAlignment]; + content.style.verticalAlign = 'middle'; + content.style.display = 'table-cell'; + + var font = (this.data.fontRefName ? + this.page.commonObjs.getData(this.data.fontRefName) : null); + this._setTextStyle(content, font); + + this.container.appendChild(content); + return this.container; + }, + + /** + * Apply text styles to the text in the element. + * + * @private + * @param {HTMLDivElement} element + * @param {Object} font + * @memberof WidgetAnnotationElement + */ + _setTextStyle: + function WidgetAnnotationElement_setTextStyle(element, font) { + // TODO: This duplicates some of the logic in CanvasGraphics.setFont(). + var style = element.style; + style.fontSize = this.data.fontSize + 'px'; + style.direction = (this.data.fontDirection < 0 ? 'rtl': 'ltr'); + + if (!font) { + return; + } + + style.fontWeight = (font.black ? + (font.bold ? '900' : 'bold') : + (font.bold ? 'bold' : 'normal')); + style.fontStyle = (font.italic ? 'italic' : 'normal'); + + // Use a reasonable default font if the font doesn't specify a fallback. + var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : ''; + var fallbackName = font.fallbackName || 'Helvetica, sans-serif'; + style.fontFamily = fontFamily + fallbackName; + } + }); + + return WidgetAnnotationElement; +})(); + +/** + * @class + * @alias PopupAnnotationElement + */ +var PopupAnnotationElement = (function PopupAnnotationElementClosure() { + function PopupAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(PopupAnnotationElement, AnnotationElement, { + /** + * Render the popup annotation's HTML element in the empty container. + * + * @public + * @memberof PopupAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function PopupAnnotationElement_render() { + this.container.className = 'popupAnnotation'; + + var selector = '[data-annotation-id="' + this.data.parentId + '"]'; + var parentElement = this.layer.querySelector(selector); + if (!parentElement) { + return this.container; + } + + var popup = new PopupElement({ + container: this.container, + trigger: parentElement, + color: this.data.color, + title: this.data.title, + contents: this.data.contents + }); + + // Position the popup next to the parent annotation's container. + // PDF viewers ignore a popup annotation's rectangle. + var parentLeft = parseFloat(parentElement.style.left); + var parentWidth = parseFloat(parentElement.style.width); + CustomStyle.setProp('transformOrigin', this.container, + -(parentLeft + parentWidth) + 'px -' + + parentElement.style.top); + this.container.style.left = (parentLeft + parentWidth) + 'px'; + + this.container.appendChild(popup.render()); + return this.container; + } + }); + + return PopupAnnotationElement; +})(); + +/** + * @class + * @alias PopupElement + */ +var PopupElement = (function PopupElementClosure() { + var BACKGROUND_ENLIGHT = 0.7; + + function PopupElement(parameters) { + this.container = parameters.container; + this.trigger = parameters.trigger; + this.color = parameters.color; + this.title = parameters.title; + this.contents = parameters.contents; + this.hideWrapper = parameters.hideWrapper || false; + + this.pinned = false; + } + + PopupElement.prototype = /** @lends PopupElement.prototype */ { + /** + * Render the popup's HTML element. + * + * @public + * @memberof PopupElement + * @returns {HTMLSectionElement} + */ + render: function PopupElement_render() { + var wrapper = document.createElement('div'); + wrapper.className = 'popupWrapper'; + + // For Popup annotations we hide the entire section because it contains + // only the popup. However, for Text annotations without a separate Popup + // annotation, we cannot hide the entire container as the image would + // disappear too. In that special case, hiding the wrapper suffices. + this.hideElement = (this.hideWrapper ? wrapper : this.container); + this.hideElement.setAttribute('hidden', true); + + var popup = document.createElement('div'); + popup.className = 'popup'; + + var color = this.color; + if (color) { + // Enlighten the color. + var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0]; + var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1]; + var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2]; + popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0); + } + + var contents = this._formatContents(this.contents); + var title = document.createElement('h1'); + title.textContent = this.title; + + // Attach the event listeners to the trigger element. + this.trigger.addEventListener('click', this._toggle.bind(this)); + this.trigger.addEventListener('mouseover', this._show.bind(this, false)); + this.trigger.addEventListener('mouseout', this._hide.bind(this, false)); + popup.addEventListener('click', this._hide.bind(this, true)); + + popup.appendChild(title); + popup.appendChild(contents); + wrapper.appendChild(popup); + return wrapper; + }, + + /** + * Format the contents of the popup by adding newlines where necessary. + * + * @private + * @param {string} contents + * @memberof PopupElement + * @returns {HTMLParagraphElement} + */ + _formatContents: function PopupElement_formatContents(contents) { + var p = document.createElement('p'); + var lines = contents.split(/(?:\r\n?|\n)/); + for (var i = 0, ii = lines.length; i < ii; ++i) { + var line = lines[i]; + p.appendChild(document.createTextNode(line)); + if (i < (ii - 1)) { + p.appendChild(document.createElement('br')); + } + } + return p; + }, + + /** + * Toggle the visibility of the popup. + * + * @private + * @memberof PopupElement + */ + _toggle: function PopupElement_toggle() { + if (this.pinned) { + this._hide(true); + } else { + this._show(true); + } + }, + + /** + * Show the popup. + * + * @private + * @param {boolean} pin + * @memberof PopupElement + */ + _show: function PopupElement_show(pin) { + if (pin) { + this.pinned = true; + } + if (this.hideElement.hasAttribute('hidden')) { + this.hideElement.removeAttribute('hidden'); + this.container.style.zIndex += 1; + } + }, + + /** + * Hide the popup. + * + * @private + * @param {boolean} unpin + * @memberof PopupElement + */ + _hide: function PopupElement_hide(unpin) { + if (unpin) { + this.pinned = false; + } + if (!this.hideElement.hasAttribute('hidden') && !this.pinned) { + this.hideElement.setAttribute('hidden', true); + this.container.style.zIndex -= 1; + } + } + }; + + return PopupElement; +})(); + +/** + * @class + * @alias HighlightAnnotationElement + */ +var HighlightAnnotationElement = ( + function HighlightAnnotationElementClosure() { + function HighlightAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || + parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(HighlightAnnotationElement, AnnotationElement, { + /** + * Render the highlight annotation's HTML element in the empty container. + * + * @public + * @memberof HighlightAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function HighlightAnnotationElement_render() { + this.container.className = 'highlightAnnotation'; + + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + + return this.container; + } + }); + + return HighlightAnnotationElement; +})(); + +/** + * @class + * @alias UnderlineAnnotationElement + */ +var UnderlineAnnotationElement = ( + function UnderlineAnnotationElementClosure() { + function UnderlineAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || + parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(UnderlineAnnotationElement, AnnotationElement, { + /** + * Render the underline annotation's HTML element in the empty container. + * + * @public + * @memberof UnderlineAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function UnderlineAnnotationElement_render() { + this.container.className = 'underlineAnnotation'; + + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + + return this.container; + } + }); + + return UnderlineAnnotationElement; +})(); + +/** + * @class + * @alias SquigglyAnnotationElement + */ +var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() { + function SquigglyAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || + parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(SquigglyAnnotationElement, AnnotationElement, { + /** + * Render the squiggly annotation's HTML element in the empty container. + * + * @public + * @memberof SquigglyAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function SquigglyAnnotationElement_render() { + this.container.className = 'squigglyAnnotation'; + + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + + return this.container; + } + }); + + return SquigglyAnnotationElement; +})(); + +/** + * @class + * @alias StrikeOutAnnotationElement + */ +var StrikeOutAnnotationElement = ( + function StrikeOutAnnotationElementClosure() { + function StrikeOutAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || + parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + + Util.inherit(StrikeOutAnnotationElement, AnnotationElement, { + /** + * Render the strikeout annotation's HTML element in the empty container. + * + * @public + * @memberof StrikeOutAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function StrikeOutAnnotationElement_render() { + this.container.className = 'strikeoutAnnotation'; + + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + + return this.container; + } + }); + + return StrikeOutAnnotationElement; +})(); + +/** + * @class + * @alias FileAttachmentAnnotationElement + */ +var FileAttachmentAnnotationElement = ( + function FileAttachmentAnnotationElementClosure() { + function FileAttachmentAnnotationElement(parameters) { + AnnotationElement.call(this, parameters, true); + + this.filename = getFilenameFromUrl(parameters.data.file.filename); + this.content = parameters.data.file.content; + } + + Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, { + /** + * Render the file attachment annotation's HTML element in the empty + * container. + * + * @public + * @memberof FileAttachmentAnnotationElement + * @returns {HTMLSectionElement} + */ + render: function FileAttachmentAnnotationElement_render() { + this.container.className = 'fileAttachmentAnnotation'; + + var trigger = document.createElement('div'); + trigger.style.height = this.container.style.height; + trigger.style.width = this.container.style.width; + trigger.addEventListener('dblclick', this._download.bind(this)); + + if (!this.data.hasPopup && (this.data.title || this.data.contents)) { + this._createPopup(this.container, trigger, this.data); + } + + this.container.appendChild(trigger); + return this.container; + }, + + /** + * Download the file attachment associated with this annotation. + * + * @private + * @memberof FileAttachmentAnnotationElement + */ + _download: function FileAttachmentAnnotationElement_download() { + if (!this.downloadManager) { + warn('Download cannot be started due to unavailable download manager'); + return; + } + this.downloadManager.downloadData(this.content, this.filename, ''); + } + }); + + return FileAttachmentAnnotationElement; +})(); + +/** + * @typedef {Object} AnnotationLayerParameters + * @property {PageViewport} viewport + * @property {HTMLDivElement} div + * @property {Array} annotations + * @property {PDFPage} page + * @property {IPDFLinkService} linkService + * @property {string} imageResourcesPath + */ + +/** + * @class + * @alias AnnotationLayer + */ +var AnnotationLayer = (function AnnotationLayerClosure() { + return { + /** + * Render a new annotation layer with all annotation elements. + * + * @public + * @param {AnnotationLayerParameters} parameters + * @memberof AnnotationLayer + */ + render: function AnnotationLayer_render(parameters) { + var annotationElementFactory = new AnnotationElementFactory(); + + for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { + var data = parameters.annotations[i]; + if (!data) { + continue; + } + + var properties = { + data: data, + layer: parameters.div, + page: parameters.page, + viewport: parameters.viewport, + linkService: parameters.linkService, + downloadManager: parameters.downloadManager, + imageResourcesPath: parameters.imageResourcesPath || + getDefaultSetting('imageResourcesPath') + }; + var element = annotationElementFactory.create(properties); + if (element.isRenderable) { + parameters.div.appendChild(element.render()); + } + } + }, + + /** + * Update the annotation elements on existing annotation layer. + * + * @public + * @param {AnnotationLayerParameters} parameters + * @memberof AnnotationLayer + */ + update: function AnnotationLayer_update(parameters) { + for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { + var data = parameters.annotations[i]; + var element = parameters.div.querySelector( + '[data-annotation-id="' + data.id + '"]'); + if (element) { + CustomStyle.setProp('transform', element, + 'matrix(' + parameters.viewport.transform.join(',') + ')'); + } + } + parameters.div.removeAttribute('hidden'); + } + }; +})(); + +exports.AnnotationLayer = AnnotationLayer; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils); + } +}(this, function (exports, sharedUtil, displayDOMUtils) { + +var Util = sharedUtil.Util; +var createPromiseCapability = sharedUtil.createPromiseCapability; +var CustomStyle = displayDOMUtils.CustomStyle; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; + +/** + * Text layer render parameters. + * + * @typedef {Object} TextLayerRenderParameters + * @property {TextContent} textContent - Text content to render (the object is + * returned by the page's getTextContent() method). + * @property {HTMLElement} container - HTML element that will contain text runs. + * @property {PageViewport} viewport - The target viewport to properly + * layout the text runs. + * @property {Array} textDivs - (optional) HTML elements that are correspond + * the text items of the textContent input. This is output and shall be + * initially be set to empty array. + * @property {number} timeout - (optional) Delay in milliseconds before + * rendering of the text runs occurs. + */ +var renderTextLayer = (function renderTextLayerClosure() { + var MAX_TEXT_DIVS_TO_RENDER = 100000; + + var NonWhitespaceRegexp = /\S/; + + function isAllWhitespace(str) { + return !NonWhitespaceRegexp.test(str); + } + + function appendText(textDivs, viewport, geom, styles) { + var style = styles[geom.fontName]; + var textDiv = document.createElement('div'); + textDivs.push(textDiv); + if (isAllWhitespace(geom.str)) { + textDiv.dataset.isWhitespace = true; + return; + } + var tx = Util.transform(viewport.transform, geom.transform); + var angle = Math.atan2(tx[1], tx[0]); + if (style.vertical) { + angle += Math.PI / 2; + } + var fontHeight = Math.sqrt((tx[2] * tx[2]) + (tx[3] * tx[3])); + var fontAscent = fontHeight; + if (style.ascent) { + fontAscent = style.ascent * fontAscent; + } else if (style.descent) { + fontAscent = (1 + style.descent) * fontAscent; + } + + var left; + var top; + if (angle === 0) { + left = tx[4]; + top = tx[5] - fontAscent; + } else { + left = tx[4] + (fontAscent * Math.sin(angle)); + top = tx[5] - (fontAscent * Math.cos(angle)); + } + textDiv.style.left = left + 'px'; + textDiv.style.top = top + 'px'; + textDiv.style.fontSize = fontHeight + 'px'; + textDiv.style.fontFamily = style.fontFamily; + + textDiv.textContent = geom.str; + // |fontName| is only used by the Font Inspector. This test will succeed + // when e.g. the Font Inspector is off but the Stepper is on, but it's + // not worth the effort to do a more accurate test. + if (getDefaultSetting('pdfBug')) { + textDiv.dataset.fontName = geom.fontName; + } + // Storing into dataset will convert number into string. + if (angle !== 0) { + textDiv.dataset.angle = angle * (180 / Math.PI); + } + // We don't bother scaling single-char text divs, because it has very + // little effect on text highlighting. This makes scrolling on docs with + // lots of such divs a lot faster. + if (geom.str.length > 1) { + if (style.vertical) { + textDiv.dataset.canvasWidth = geom.height * viewport.scale; + } else { + textDiv.dataset.canvasWidth = geom.width * viewport.scale; + } + } + } + + function render(task) { + if (task._canceled) { + return; + } + var textLayerFrag = task._container; + var textDivs = task._textDivs; + var capability = task._capability; + var textDivsLength = textDivs.length; + + // No point in rendering many divs as it would make the browser + // unusable even after the divs are rendered. + if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { + capability.resolve(); + return; + } + + var canvas = document.createElement('canvas'); + canvas.mozOpaque = true; + var ctx = canvas.getContext('2d', {alpha: false}); + + var lastFontSize; + var lastFontFamily; + for (var i = 0; i < textDivsLength; i++) { + var textDiv = textDivs[i]; + if (textDiv.dataset.isWhitespace !== undefined) { + continue; + } + + var fontSize = textDiv.style.fontSize; + var fontFamily = textDiv.style.fontFamily; + + // Only build font string and set to context if different from last. + if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) { + ctx.font = fontSize + ' ' + fontFamily; + lastFontSize = fontSize; + lastFontFamily = fontFamily; + } + + var width = ctx.measureText(textDiv.textContent).width; + textLayerFrag.appendChild(textDiv); + var transform; + if (textDiv.dataset.canvasWidth !== undefined && width > 0) { + // Dataset values come of type string. + var textScale = textDiv.dataset.canvasWidth / width; + transform = 'scaleX(' + textScale + ')'; + } else { + transform = ''; + } + var rotation = textDiv.dataset.angle; + if (rotation) { + transform = 'rotate(' + rotation + 'deg) ' + transform; + } + if (transform) { + CustomStyle.setProp('transform' , textDiv, transform); + } + } + capability.resolve(); + } + + /** + * Text layer rendering task. + * + * @param {TextContent} textContent + * @param {HTMLElement} container + * @param {PageViewport} viewport + * @param {Array} textDivs + * @private + */ + function TextLayerRenderTask(textContent, container, viewport, textDivs) { + this._textContent = textContent; + this._container = container; + this._viewport = viewport; + textDivs = textDivs || []; + this._textDivs = textDivs; + this._canceled = false; + this._capability = createPromiseCapability(); + this._renderTimer = null; + } + TextLayerRenderTask.prototype = { + get promise() { + return this._capability.promise; + }, + + cancel: function TextLayer_cancel() { + this._canceled = true; + if (this._renderTimer !== null) { + clearTimeout(this._renderTimer); + this._renderTimer = null; + } + this._capability.reject('canceled'); + }, + + _render: function TextLayer_render(timeout) { + var textItems = this._textContent.items; + var styles = this._textContent.styles; + var textDivs = this._textDivs; + var viewport = this._viewport; + for (var i = 0, len = textItems.length; i < len; i++) { + appendText(textDivs, viewport, textItems[i], styles); + } + + if (!timeout) { // Render right away + render(this); + } else { // Schedule + var self = this; + this._renderTimer = setTimeout(function() { + render(self); + self._renderTimer = null; + }, timeout); + } + } + }; + + + /** + * Starts rendering of the text layer. + * + * @param {TextLayerRenderParameters} renderParameters + * @returns {TextLayerRenderTask} + */ + function renderTextLayer(renderParameters) { + var task = new TextLayerRenderTask(renderParameters.textContent, + renderParameters.container, + renderParameters.viewport, + renderParameters.textDivs); + task._render(renderParameters.timeout); + return task; + } + + return renderTextLayer; +})(); + +exports.renderTextLayer = renderTextLayer; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils); + } +}(this, function (exports, sharedUtil, displayDOMUtils) { + +var shadow = sharedUtil.shadow; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; + +var WebGLUtils = (function WebGLUtilsClosure() { + function loadShader(gl, code, shaderType) { + var shader = gl.createShader(shaderType); + gl.shaderSource(shader, code); + gl.compileShader(shader); + var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); + if (!compiled) { + var errorMsg = gl.getShaderInfoLog(shader); + throw new Error('Error during shader compilation: ' + errorMsg); + } + return shader; + } + function createVertexShader(gl, code) { + return loadShader(gl, code, gl.VERTEX_SHADER); + } + function createFragmentShader(gl, code) { + return loadShader(gl, code, gl.FRAGMENT_SHADER); + } + function createProgram(gl, shaders) { + var program = gl.createProgram(); + for (var i = 0, ii = shaders.length; i < ii; ++i) { + gl.attachShader(program, shaders[i]); + } + gl.linkProgram(program); + var linked = gl.getProgramParameter(program, gl.LINK_STATUS); + if (!linked) { + var errorMsg = gl.getProgramInfoLog(program); + throw new Error('Error during program linking: ' + errorMsg); + } + return program; + } + function createTexture(gl, image, textureId) { + gl.activeTexture(textureId); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + + // Set the parameters so we can render any size image. + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + + // Upload the image into the texture. + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + return texture; + } + + var currentGL, currentCanvas; + function generateGL() { + if (currentGL) { + return; + } + currentCanvas = document.createElement('canvas'); + currentGL = currentCanvas.getContext('webgl', + { premultipliedalpha: false }); + } + + var smaskVertexShaderCode = '\ + attribute vec2 a_position; \ + attribute vec2 a_texCoord; \ + \ + uniform vec2 u_resolution; \ + \ + varying vec2 v_texCoord; \ + \ + void main() { \ + vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \ + gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ + \ + v_texCoord = a_texCoord; \ + } '; + + var smaskFragmentShaderCode = '\ + precision mediump float; \ + \ + uniform vec4 u_backdrop; \ + uniform int u_subtype; \ + uniform sampler2D u_image; \ + uniform sampler2D u_mask; \ + \ + varying vec2 v_texCoord; \ + \ + void main() { \ + vec4 imageColor = texture2D(u_image, v_texCoord); \ + vec4 maskColor = texture2D(u_mask, v_texCoord); \ + if (u_backdrop.a > 0.0) { \ + maskColor.rgb = maskColor.rgb * maskColor.a + \ + u_backdrop.rgb * (1.0 - maskColor.a); \ + } \ + float lum; \ + if (u_subtype == 0) { \ + lum = maskColor.a; \ + } else { \ + lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \ + maskColor.b * 0.11; \ + } \ + imageColor.a *= lum; \ + imageColor.rgb *= imageColor.a; \ + gl_FragColor = imageColor; \ + } '; + + var smaskCache = null; + + function initSmaskGL() { + var canvas, gl; + + generateGL(); + canvas = currentCanvas; + currentCanvas = null; + gl = currentGL; + currentGL = null; + + // setup a GLSL program + var vertexShader = createVertexShader(gl, smaskVertexShaderCode); + var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode); + var program = createProgram(gl, [vertexShader, fragmentShader]); + gl.useProgram(program); + + var cache = {}; + cache.gl = gl; + cache.canvas = canvas; + cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); + cache.positionLocation = gl.getAttribLocation(program, 'a_position'); + cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop'); + cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype'); + + var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord'); + var texLayerLocation = gl.getUniformLocation(program, 'u_image'); + var texMaskLocation = gl.getUniformLocation(program, 'u_mask'); + + // provide texture coordinates for the rectangle. + var texCoordBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 0.0, 1.0, + 1.0, 0.0, + 1.0, 1.0]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(texCoordLocation); + gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0); + + gl.uniform1i(texLayerLocation, 0); + gl.uniform1i(texMaskLocation, 1); + + smaskCache = cache; + } + + function composeSMask(layer, mask, properties) { + var width = layer.width, height = layer.height; + + if (!smaskCache) { + initSmaskGL(); + } + var cache = smaskCache,canvas = cache.canvas, gl = cache.gl; + canvas.width = width; + canvas.height = height; + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + gl.uniform2f(cache.resolutionLocation, width, height); + + if (properties.backdrop) { + gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], + properties.backdrop[1], properties.backdrop[2], 1); + } else { + gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0); + } + gl.uniform1i(cache.subtypeLocation, + properties.subtype === 'Luminosity' ? 1 : 0); + + // Create a textures + var texture = createTexture(gl, layer, gl.TEXTURE0); + var maskTexture = createTexture(gl, mask, gl.TEXTURE1); + + + // Create a buffer and put a single clipspace rectangle in + // it (2 triangles) + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ + 0, 0, + width, 0, + 0, height, + 0, height, + width, 0, + width, height]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.positionLocation); + gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); + + // draw + gl.clearColor(0, 0, 0, 0); + gl.enable(gl.BLEND); + gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.clear(gl.COLOR_BUFFER_BIT); + + gl.drawArrays(gl.TRIANGLES, 0, 6); + + gl.flush(); + + gl.deleteTexture(texture); + gl.deleteTexture(maskTexture); + gl.deleteBuffer(buffer); + + return canvas; + } + + var figuresVertexShaderCode = '\ + attribute vec2 a_position; \ + attribute vec3 a_color; \ + \ + uniform vec2 u_resolution; \ + uniform vec2 u_scale; \ + uniform vec2 u_offset; \ + \ + varying vec4 v_color; \ + \ + void main() { \ + vec2 position = (a_position + u_offset) * u_scale; \ + vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \ + gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ + \ + v_color = vec4(a_color / 255.0, 1.0); \ + } '; + + var figuresFragmentShaderCode = '\ + precision mediump float; \ + \ + varying vec4 v_color; \ + \ + void main() { \ + gl_FragColor = v_color; \ + } '; + + var figuresCache = null; + + function initFiguresGL() { + var canvas, gl; + + generateGL(); + canvas = currentCanvas; + currentCanvas = null; + gl = currentGL; + currentGL = null; + + // setup a GLSL program + var vertexShader = createVertexShader(gl, figuresVertexShaderCode); + var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode); + var program = createProgram(gl, [vertexShader, fragmentShader]); + gl.useProgram(program); + + var cache = {}; + cache.gl = gl; + cache.canvas = canvas; + cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); + cache.scaleLocation = gl.getUniformLocation(program, 'u_scale'); + cache.offsetLocation = gl.getUniformLocation(program, 'u_offset'); + cache.positionLocation = gl.getAttribLocation(program, 'a_position'); + cache.colorLocation = gl.getAttribLocation(program, 'a_color'); + + figuresCache = cache; + } + + function drawFigures(width, height, backgroundColor, figures, context) { + if (!figuresCache) { + initFiguresGL(); + } + var cache = figuresCache, canvas = cache.canvas, gl = cache.gl; + + canvas.width = width; + canvas.height = height; + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + gl.uniform2f(cache.resolutionLocation, width, height); + + // count triangle points + var count = 0; + var i, ii, rows; + for (i = 0, ii = figures.length; i < ii; i++) { + switch (figures[i].type) { + case 'lattice': + rows = (figures[i].coords.length / figures[i].verticesPerRow) | 0; + count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; + break; + case 'triangles': + count += figures[i].coords.length; + break; + } + } + // transfer data + var coords = new Float32Array(count * 2); + var colors = new Uint8Array(count * 3); + var coordsMap = context.coords, colorsMap = context.colors; + var pIndex = 0, cIndex = 0; + for (i = 0, ii = figures.length; i < ii; i++) { + var figure = figures[i], ps = figure.coords, cs = figure.colors; + switch (figure.type) { + case 'lattice': + var cols = figure.verticesPerRow; + rows = (ps.length / cols) | 0; + for (var row = 1; row < rows; row++) { + var offset = row * cols + 1; + for (var col = 1; col < cols; col++, offset++) { + coords[pIndex] = coordsMap[ps[offset - cols - 1]]; + coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1]; + coords[pIndex + 2] = coordsMap[ps[offset - cols]]; + coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1]; + coords[pIndex + 4] = coordsMap[ps[offset - 1]]; + coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1]; + colors[cIndex] = colorsMap[cs[offset - cols - 1]]; + colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1]; + colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2]; + colors[cIndex + 3] = colorsMap[cs[offset - cols]]; + colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1]; + colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2]; + colors[cIndex + 6] = colorsMap[cs[offset - 1]]; + colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1]; + colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2]; + + coords[pIndex + 6] = coords[pIndex + 2]; + coords[pIndex + 7] = coords[pIndex + 3]; + coords[pIndex + 8] = coords[pIndex + 4]; + coords[pIndex + 9] = coords[pIndex + 5]; + coords[pIndex + 10] = coordsMap[ps[offset]]; + coords[pIndex + 11] = coordsMap[ps[offset] + 1]; + colors[cIndex + 9] = colors[cIndex + 3]; + colors[cIndex + 10] = colors[cIndex + 4]; + colors[cIndex + 11] = colors[cIndex + 5]; + colors[cIndex + 12] = colors[cIndex + 6]; + colors[cIndex + 13] = colors[cIndex + 7]; + colors[cIndex + 14] = colors[cIndex + 8]; + colors[cIndex + 15] = colorsMap[cs[offset]]; + colors[cIndex + 16] = colorsMap[cs[offset] + 1]; + colors[cIndex + 17] = colorsMap[cs[offset] + 2]; + pIndex += 12; + cIndex += 18; + } + } + break; + case 'triangles': + for (var j = 0, jj = ps.length; j < jj; j++) { + coords[pIndex] = coordsMap[ps[j]]; + coords[pIndex + 1] = coordsMap[ps[j] + 1]; + colors[cIndex] = colorsMap[cs[j]]; + colors[cIndex + 1] = colorsMap[cs[j] + 1]; + colors[cIndex + 2] = colorsMap[cs[j] + 2]; + pIndex += 2; + cIndex += 3; + } + break; + } + } + + // draw + if (backgroundColor) { + gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, + backgroundColor[2] / 255, 1.0); + } else { + gl.clearColor(0, 0, 0, 0); + } + gl.clear(gl.COLOR_BUFFER_BIT); + + var coordsBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer); + gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.positionLocation); + gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); + + var colorsBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer); + gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.colorLocation); + gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, + 0, 0); + + gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY); + gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY); + + gl.drawArrays(gl.TRIANGLES, 0, count); + + gl.flush(); + + gl.deleteBuffer(coordsBuffer); + gl.deleteBuffer(colorsBuffer); + + return canvas; + } + + function cleanup() { + if (smaskCache && smaskCache.canvas) { + smaskCache.canvas.width = 0; + smaskCache.canvas.height = 0; + } + if (figuresCache && figuresCache.canvas) { + figuresCache.canvas.width = 0; + figuresCache.canvas.height = 0; + } + smaskCache = null; + figuresCache = null; + } + + return { + get isEnabled() { + if (getDefaultSetting('disableWebGL')) { + return false; + } + var enabled = false; + try { + generateGL(); + enabled = !!currentGL; + } catch (e) { } + return shadow(this, 'isEnabled', enabled); + }, + composeSMask: composeSMask, + drawFigures: drawFigures, + clear: cleanup + }; +})(); + +exports.WebGLUtils = WebGLUtils; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayPatternHelper = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayWebGL); + } +}(this, function (exports, sharedUtil, displayWebGL) { + +var Util = sharedUtil.Util; +var info = sharedUtil.info; +var isArray = sharedUtil.isArray; +var error = sharedUtil.error; +var WebGLUtils = displayWebGL.WebGLUtils; + +var ShadingIRs = {}; + +ShadingIRs.RadialAxial = { + fromIR: function RadialAxial_fromIR(raw) { + var type = raw[1]; + var colorStops = raw[2]; + var p0 = raw[3]; + var p1 = raw[4]; + var r0 = raw[5]; + var r1 = raw[6]; + return { + type: 'Pattern', + getPattern: function RadialAxial_getPattern(ctx) { + var grad; + if (type === 'axial') { + grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]); + } else if (type === 'radial') { + grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1); + } + + for (var i = 0, ii = colorStops.length; i < ii; ++i) { + var c = colorStops[i]; + grad.addColorStop(c[0], c[1]); + } + return grad; + } + }; + } +}; + +var createMeshCanvas = (function createMeshCanvasClosure() { + function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) { + // Very basic Gouraud-shaded triangle rasterization algorithm. + var coords = context.coords, colors = context.colors; + var bytes = data.data, rowSize = data.width * 4; + var tmp; + if (coords[p1 + 1] > coords[p2 + 1]) { + tmp = p1; p1 = p2; p2 = tmp; tmp = c1; c1 = c2; c2 = tmp; + } + if (coords[p2 + 1] > coords[p3 + 1]) { + tmp = p2; p2 = p3; p3 = tmp; tmp = c2; c2 = c3; c3 = tmp; + } + if (coords[p1 + 1] > coords[p2 + 1]) { + tmp = p1; p1 = p2; p2 = tmp; tmp = c1; c1 = c2; c2 = tmp; + } + var x1 = (coords[p1] + context.offsetX) * context.scaleX; + var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY; + var x2 = (coords[p2] + context.offsetX) * context.scaleX; + var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY; + var x3 = (coords[p3] + context.offsetX) * context.scaleX; + var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY; + if (y1 >= y3) { + return; + } + var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2]; + var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2]; + var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2]; + + var minY = Math.round(y1), maxY = Math.round(y3); + var xa, car, cag, cab; + var xb, cbr, cbg, cbb; + var k; + for (var y = minY; y <= maxY; y++) { + if (y < y2) { + k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2); + xa = x1 - (x1 - x2) * k; + car = c1r - (c1r - c2r) * k; + cag = c1g - (c1g - c2g) * k; + cab = c1b - (c1b - c2b) * k; + } else { + k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3); + xa = x2 - (x2 - x3) * k; + car = c2r - (c2r - c3r) * k; + cag = c2g - (c2g - c3g) * k; + cab = c2b - (c2b - c3b) * k; + } + k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3); + xb = x1 - (x1 - x3) * k; + cbr = c1r - (c1r - c3r) * k; + cbg = c1g - (c1g - c3g) * k; + cbb = c1b - (c1b - c3b) * k; + var x1_ = Math.round(Math.min(xa, xb)); + var x2_ = Math.round(Math.max(xa, xb)); + var j = rowSize * y + x1_ * 4; + for (var x = x1_; x <= x2_; x++) { + k = (xa - x) / (xa - xb); + k = k < 0 ? 0 : k > 1 ? 1 : k; + bytes[j++] = (car - (car - cbr) * k) | 0; + bytes[j++] = (cag - (cag - cbg) * k) | 0; + bytes[j++] = (cab - (cab - cbb) * k) | 0; + bytes[j++] = 255; + } + } + } + + function drawFigure(data, figure, context) { + var ps = figure.coords; + var cs = figure.colors; + var i, ii; + switch (figure.type) { + case 'lattice': + var verticesPerRow = figure.verticesPerRow; + var rows = Math.floor(ps.length / verticesPerRow) - 1; + var cols = verticesPerRow - 1; + for (i = 0; i < rows; i++) { + var q = i * verticesPerRow; + for (var j = 0; j < cols; j++, q++) { + drawTriangle(data, context, + ps[q], ps[q + 1], ps[q + verticesPerRow], + cs[q], cs[q + 1], cs[q + verticesPerRow]); + drawTriangle(data, context, + ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], + cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]); + } + } + break; + case 'triangles': + for (i = 0, ii = ps.length; i < ii; i += 3) { + drawTriangle(data, context, + ps[i], ps[i + 1], ps[i + 2], + cs[i], cs[i + 1], cs[i + 2]); + } + break; + default: + error('illigal figure'); + break; + } + } + + function createMeshCanvas(bounds, combinesScale, coords, colors, figures, + backgroundColor, cachedCanvases) { + // we will increase scale on some weird factor to let antialiasing take + // care of "rough" edges + var EXPECTED_SCALE = 1.1; + // MAX_PATTERN_SIZE is used to avoid OOM situation. + var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough + // We need to keep transparent border around our pattern for fill(): + // createPattern with 'no-repeat' will bleed edges accross entire area. + var BORDER_SIZE = 2; + + var offsetX = Math.floor(bounds[0]); + var offsetY = Math.floor(bounds[1]); + var boundsWidth = Math.ceil(bounds[2]) - offsetX; + var boundsHeight = Math.ceil(bounds[3]) - offsetY; + + var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * + EXPECTED_SCALE)), MAX_PATTERN_SIZE); + var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * + EXPECTED_SCALE)), MAX_PATTERN_SIZE); + var scaleX = boundsWidth / width; + var scaleY = boundsHeight / height; + + var context = { + coords: coords, + colors: colors, + offsetX: -offsetX, + offsetY: -offsetY, + scaleX: 1 / scaleX, + scaleY: 1 / scaleY + }; + + var paddedWidth = width + BORDER_SIZE * 2; + var paddedHeight = height + BORDER_SIZE * 2; + + var canvas, tmpCanvas, i, ii; + if (WebGLUtils.isEnabled) { + canvas = WebGLUtils.drawFigures(width, height, backgroundColor, + figures, context); + + // https://bugzilla.mozilla.org/show_bug.cgi?id=972126 + tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, + false); + tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE); + canvas = tmpCanvas.canvas; + } else { + tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, + false); + var tmpCtx = tmpCanvas.context; + + var data = tmpCtx.createImageData(width, height); + if (backgroundColor) { + var bytes = data.data; + for (i = 0, ii = bytes.length; i < ii; i += 4) { + bytes[i] = backgroundColor[0]; + bytes[i + 1] = backgroundColor[1]; + bytes[i + 2] = backgroundColor[2]; + bytes[i + 3] = 255; + } + } + for (i = 0; i < figures.length; i++) { + drawFigure(data, figures[i], context); + } + tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE); + canvas = tmpCanvas.canvas; + } + + return {canvas: canvas, + offsetX: offsetX - BORDER_SIZE * scaleX, + offsetY: offsetY - BORDER_SIZE * scaleY, + scaleX: scaleX, scaleY: scaleY}; + } + return createMeshCanvas; +})(); + +ShadingIRs.Mesh = { + fromIR: function Mesh_fromIR(raw) { + //var type = raw[1]; + var coords = raw[2]; + var colors = raw[3]; + var figures = raw[4]; + var bounds = raw[5]; + var matrix = raw[6]; + //var bbox = raw[7]; + var background = raw[8]; + return { + type: 'Pattern', + getPattern: function Mesh_getPattern(ctx, owner, shadingFill) { + var scale; + if (shadingFill) { + scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform); + } else { + // Obtain scale from matrix and current transformation matrix. + scale = Util.singularValueDecompose2dScale(owner.baseTransform); + if (matrix) { + var matrixScale = Util.singularValueDecompose2dScale(matrix); + scale = [scale[0] * matrixScale[0], + scale[1] * matrixScale[1]]; + } + } + + + // Rasterizing on the main thread since sending/queue large canvases + // might cause OOM. + var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, + colors, figures, shadingFill ? null : background, + owner.cachedCanvases); + + if (!shadingFill) { + ctx.setTransform.apply(ctx, owner.baseTransform); + if (matrix) { + ctx.transform.apply(ctx, matrix); + } + } + + ctx.translate(temporaryPatternCanvas.offsetX, + temporaryPatternCanvas.offsetY); + ctx.scale(temporaryPatternCanvas.scaleX, + temporaryPatternCanvas.scaleY); + + return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat'); + } + }; + } +}; + +ShadingIRs.Dummy = { + fromIR: function Dummy_fromIR() { + return { + type: 'Pattern', + getPattern: function Dummy_fromIR_getPattern() { + return 'hotpink'; + } + }; + } +}; + +function getShadingPatternFromIR(raw) { + var shadingIR = ShadingIRs[raw[0]]; + if (!shadingIR) { + error('Unknown IR type: ' + raw[0]); + } + return shadingIR.fromIR(raw); +} + +var TilingPattern = (function TilingPatternClosure() { + var PaintType = { + COLORED: 1, + UNCOLORED: 2 + }; + + var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough + + function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) { + this.operatorList = IR[2]; + this.matrix = IR[3] || [1, 0, 0, 1, 0, 0]; + this.bbox = IR[4]; + this.xstep = IR[5]; + this.ystep = IR[6]; + this.paintType = IR[7]; + this.tilingType = IR[8]; + this.color = color; + this.canvasGraphicsFactory = canvasGraphicsFactory; + this.baseTransform = baseTransform; + this.type = 'Pattern'; + this.ctx = ctx; + } + + TilingPattern.prototype = { + createPatternCanvas: function TilinPattern_createPatternCanvas(owner) { + var operatorList = this.operatorList; + var bbox = this.bbox; + var xstep = this.xstep; + var ystep = this.ystep; + var paintType = this.paintType; + var tilingType = this.tilingType; + var color = this.color; + var canvasGraphicsFactory = this.canvasGraphicsFactory; + + info('TilingType: ' + tilingType); + + var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3]; + + var topLeft = [x0, y0]; + // we want the canvas to be as large as the step size + var botRight = [x0 + xstep, y0 + ystep]; + + var width = botRight[0] - topLeft[0]; + var height = botRight[1] - topLeft[1]; + + // Obtain scale from matrix and current transformation matrix. + var matrixScale = Util.singularValueDecompose2dScale(this.matrix); + var curMatrixScale = Util.singularValueDecompose2dScale( + this.baseTransform); + var combinedScale = [matrixScale[0] * curMatrixScale[0], + matrixScale[1] * curMatrixScale[1]]; + + // MAX_PATTERN_SIZE is used to avoid OOM situation. + // Use width and height values that are as close as possible to the end + // result when the pattern is used. Too low value makes the pattern look + // blurry. Too large value makes it look too crispy. + width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), + MAX_PATTERN_SIZE); + + height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), + MAX_PATTERN_SIZE); + + var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', + width, height, true); + var tmpCtx = tmpCanvas.context; + var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx); + graphics.groupLevel = owner.groupLevel; + + this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color); + + this.setScale(width, height, xstep, ystep); + this.transformToScale(graphics); + + // transform coordinates to pattern space + var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]]; + graphics.transform.apply(graphics, tmpTranslate); + + this.clipBbox(graphics, bbox, x0, y0, x1, y1); + + graphics.executeOperatorList(operatorList); + return tmpCanvas.canvas; + }, + + setScale: function TilingPattern_setScale(width, height, xstep, ystep) { + this.scale = [width / xstep, height / ystep]; + }, + + transformToScale: function TilingPattern_transformToScale(graphics) { + var scale = this.scale; + var tmpScale = [scale[0], 0, 0, scale[1], 0, 0]; + graphics.transform.apply(graphics, tmpScale); + }, + + scaleToContext: function TilingPattern_scaleToContext() { + var scale = this.scale; + this.ctx.scale(1 / scale[0], 1 / scale[1]); + }, + + clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) { + if (bbox && isArray(bbox) && bbox.length === 4) { + var bboxWidth = x1 - x0; + var bboxHeight = y1 - y0; + graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight); + graphics.clip(); + graphics.endPath(); + } + }, + + setFillAndStrokeStyleToContext: + function setFillAndStrokeStyleToContext(context, paintType, color) { + switch (paintType) { + case PaintType.COLORED: + var ctx = this.ctx; + context.fillStyle = ctx.fillStyle; + context.strokeStyle = ctx.strokeStyle; + break; + case PaintType.UNCOLORED: + var cssColor = Util.makeCssRgb(color[0], color[1], color[2]); + context.fillStyle = cssColor; + context.strokeStyle = cssColor; + break; + default: + error('Unsupported paint type: ' + paintType); + } + }, + + getPattern: function TilingPattern_getPattern(ctx, owner) { + var temporaryPatternCanvas = this.createPatternCanvas(owner); + + ctx = this.ctx; + ctx.setTransform.apply(ctx, this.baseTransform); + ctx.transform.apply(ctx, this.matrix); + this.scaleToContext(); + + return ctx.createPattern(temporaryPatternCanvas, 'repeat'); + } + }; + + return TilingPattern; +})(); + +exports.getShadingPatternFromIR = getShadingPatternFromIR; +exports.TilingPattern = TilingPattern; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayCanvas = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, + root.pdfjsDisplayWebGL); + } +}(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, + displayWebGL) { + +var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; +var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX; +var ImageKind = sharedUtil.ImageKind; +var OPS = sharedUtil.OPS; +var TextRenderingMode = sharedUtil.TextRenderingMode; +var Uint32ArrayView = sharedUtil.Uint32ArrayView; +var Util = sharedUtil.Util; +var assert = sharedUtil.assert; +var info = sharedUtil.info; +var isNum = sharedUtil.isNum; +var isArray = sharedUtil.isArray; +var isLittleEndian = sharedUtil.isLittleEndian; +var error = sharedUtil.error; +var shadow = sharedUtil.shadow; +var warn = sharedUtil.warn; +var TilingPattern = displayPatternHelper.TilingPattern; +var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR; +var WebGLUtils = displayWebGL.WebGLUtils; +var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays; + +// contexts store most of the state we need natively. +// However, PDF needs a bit more state, which we store here. + +// Minimal font size that would be used during canvas fillText operations. +var MIN_FONT_SIZE = 16; +// Maximum font size that would be used during canvas fillText operations. +var MAX_FONT_SIZE = 100; +var MAX_GROUP_SIZE = 4096; + +// Heuristic value used when enforcing minimum line widths. +var MIN_WIDTH_FACTOR = 0.65; + +var COMPILE_TYPE3_GLYPHS = true; +var MAX_SIZE_TO_COMPILE = 1000; + +var FULL_CHUNK_HEIGHT = 16; + +var HasCanvasTypedArraysCached = { + get value() { + return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays()); + } +}; + +var IsLittleEndianCached = { + get value() { + return shadow(IsLittleEndianCached, 'value', isLittleEndian()); + } +}; + +function createScratchCanvas(width, height) { + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + return canvas; +} + +function addContextCurrentTransform(ctx) { + // If the context doesn't expose a `mozCurrentTransform`, add a JS based one. + if (!ctx.mozCurrentTransform) { + ctx._originalSave = ctx.save; + ctx._originalRestore = ctx.restore; + ctx._originalRotate = ctx.rotate; + ctx._originalScale = ctx.scale; + ctx._originalTranslate = ctx.translate; + ctx._originalTransform = ctx.transform; + ctx._originalSetTransform = ctx.setTransform; + + ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0]; + ctx._transformStack = []; + + Object.defineProperty(ctx, 'mozCurrentTransform', { + get: function getCurrentTransform() { + return this._transformMatrix; + } + }); + + Object.defineProperty(ctx, 'mozCurrentTransformInverse', { + get: function getCurrentTransformInverse() { + // Calculation done using WolframAlpha: + // http://www.wolframalpha.com/input/? + // i=Inverse+{{a%2C+c%2C+e}%2C+{b%2C+d%2C+f}%2C+{0%2C+0%2C+1}} + + var m = this._transformMatrix; + var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5]; + + var ad_bc = a * d - b * c; + var bc_ad = b * c - a * d; + + return [ + d / ad_bc, + b / bc_ad, + c / bc_ad, + a / ad_bc, + (d * e - c * f) / bc_ad, + (b * e - a * f) / ad_bc + ]; + } + }); + + ctx.save = function ctxSave() { + var old = this._transformMatrix; + this._transformStack.push(old); + this._transformMatrix = old.slice(0, 6); + + this._originalSave(); + }; + + ctx.restore = function ctxRestore() { + var prev = this._transformStack.pop(); + if (prev) { + this._transformMatrix = prev; + this._originalRestore(); + } + }; + + ctx.translate = function ctxTranslate(x, y) { + var m = this._transformMatrix; + m[4] = m[0] * x + m[2] * y + m[4]; + m[5] = m[1] * x + m[3] * y + m[5]; + + this._originalTranslate(x, y); + }; + + ctx.scale = function ctxScale(x, y) { + var m = this._transformMatrix; + m[0] = m[0] * x; + m[1] = m[1] * x; + m[2] = m[2] * y; + m[3] = m[3] * y; + + this._originalScale(x, y); + }; + + ctx.transform = function ctxTransform(a, b, c, d, e, f) { + var m = this._transformMatrix; + this._transformMatrix = [ + m[0] * a + m[2] * b, + m[1] * a + m[3] * b, + m[0] * c + m[2] * d, + m[1] * c + m[3] * d, + m[0] * e + m[2] * f + m[4], + m[1] * e + m[3] * f + m[5] + ]; + + ctx._originalTransform(a, b, c, d, e, f); + }; + + ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) { + this._transformMatrix = [a, b, c, d, e, f]; + + ctx._originalSetTransform(a, b, c, d, e, f); + }; + + ctx.rotate = function ctxRotate(angle) { + var cosValue = Math.cos(angle); + var sinValue = Math.sin(angle); + + var m = this._transformMatrix; + this._transformMatrix = [ + m[0] * cosValue + m[2] * sinValue, + m[1] * cosValue + m[3] * sinValue, + m[0] * (-sinValue) + m[2] * cosValue, + m[1] * (-sinValue) + m[3] * cosValue, + m[4], + m[5] + ]; + + this._originalRotate(angle); + }; + } +} + +var CachedCanvases = (function CachedCanvasesClosure() { + function CachedCanvases() { + this.cache = Object.create(null); + } + CachedCanvases.prototype = { + getCanvas: function CachedCanvases_getCanvas(id, width, height, + trackTransform) { + var canvasEntry; + if (this.cache[id] !== undefined) { + canvasEntry = this.cache[id]; + canvasEntry.canvas.width = width; + canvasEntry.canvas.height = height; + // reset canvas transform for emulated mozCurrentTransform, if needed + canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0); + } else { + var canvas = createScratchCanvas(width, height); + var ctx = canvas.getContext('2d'); + if (trackTransform) { + addContextCurrentTransform(ctx); + } + this.cache[id] = canvasEntry = {canvas: canvas, context: ctx}; + } + return canvasEntry; + }, + clear: function () { + for (var id in this.cache) { + var canvasEntry = this.cache[id]; + // Zeroing the width and height causes Firefox to release graphics + // resources immediately, which can greatly reduce memory consumption. + canvasEntry.canvas.width = 0; + canvasEntry.canvas.height = 0; + delete this.cache[id]; + } + } + }; + return CachedCanvases; +})(); + +function compileType3Glyph(imgData) { + var POINT_TO_PROCESS_LIMIT = 1000; + + var width = imgData.width, height = imgData.height; + var i, j, j0, width1 = width + 1; + var points = new Uint8Array(width1 * (height + 1)); + var POINT_TYPES = + new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]); + + // decodes bit-packed mask data + var lineSize = (width + 7) & ~7, data0 = imgData.data; + var data = new Uint8Array(lineSize * height), pos = 0, ii; + for (i = 0, ii = data0.length; i < ii; i++) { + var mask = 128, elem = data0[i]; + while (mask > 0) { + data[pos++] = (elem & mask) ? 0 : 255; + mask >>= 1; + } + } + + // finding iteresting points: every point is located between mask pixels, + // so there will be points of the (width + 1)x(height + 1) grid. Every point + // will have flags assigned based on neighboring mask pixels: + // 4 | 8 + // --P-- + // 2 | 1 + // We are interested only in points with the flags: + // - outside corners: 1, 2, 4, 8; + // - inside corners: 7, 11, 13, 14; + // - and, intersections: 5, 10. + var count = 0; + pos = 0; + if (data[pos] !== 0) { + points[0] = 1; + ++count; + } + for (j = 1; j < width; j++) { + if (data[pos] !== data[pos + 1]) { + points[j] = data[pos] ? 2 : 1; + ++count; + } + pos++; + } + if (data[pos] !== 0) { + points[j] = 2; + ++count; + } + for (i = 1; i < height; i++) { + pos = i * lineSize; + j0 = i * width1; + if (data[pos - lineSize] !== data[pos]) { + points[j0] = data[pos] ? 1 : 8; + ++count; + } + // 'sum' is the position of the current pixel configuration in the 'TYPES' + // array (in order 8-1-2-4, so we can use '>>2' to shift the column). + var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0); + for (j = 1; j < width; j++) { + sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + + (data[pos - lineSize + 1] ? 8 : 0); + if (POINT_TYPES[sum]) { + points[j0 + j] = POINT_TYPES[sum]; + ++count; + } + pos++; + } + if (data[pos - lineSize] !== data[pos]) { + points[j0 + j] = data[pos] ? 2 : 4; + ++count; + } + + if (count > POINT_TO_PROCESS_LIMIT) { + return null; + } + } + + pos = lineSize * (height - 1); + j0 = i * width1; + if (data[pos] !== 0) { + points[j0] = 8; + ++count; + } + for (j = 1; j < width; j++) { + if (data[pos] !== data[pos + 1]) { + points[j0 + j] = data[pos] ? 4 : 8; + ++count; + } + pos++; + } + if (data[pos] !== 0) { + points[j0 + j] = 4; + ++count; + } + if (count > POINT_TO_PROCESS_LIMIT) { + return null; + } + + // building outlines + var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]); + var outlines = []; + for (i = 0; count && i <= height; i++) { + var p = i * width1; + var end = p + width; + while (p < end && !points[p]) { + p++; + } + if (p === end) { + continue; + } + var coords = [p % width1, i]; + + var type = points[p], p0 = p, pp; + do { + var step = steps[type]; + do { + p += step; + } while (!points[p]); + + pp = points[p]; + if (pp !== 5 && pp !== 10) { + // set new direction + type = pp; + // delete mark + points[p] = 0; + } else { // type is 5 or 10, ie, a crossing + // set new direction + type = pp & ((0x33 * type) >> 4); + // set new type for "future hit" + points[p] &= (type >> 2 | type << 2); + } + + coords.push(p % width1); + coords.push((p / width1) | 0); + --count; + } while (p0 !== p); + outlines.push(coords); + --i; + } + + var drawOutline = function(c) { + c.save(); + // the path shall be painted in [0..1]x[0..1] space + c.scale(1 / width, -1 / height); + c.translate(0, -height); + c.beginPath(); + for (var i = 0, ii = outlines.length; i < ii; i++) { + var o = outlines[i]; + c.moveTo(o[0], o[1]); + for (var j = 2, jj = o.length; j < jj; j += 2) { + c.lineTo(o[j], o[j+1]); + } + } + c.fill(); + c.beginPath(); + c.restore(); + }; + + return drawOutline; +} + +var CanvasExtraState = (function CanvasExtraStateClosure() { + function CanvasExtraState(old) { + // Are soft masks and alpha values shapes or opacities? + this.alphaIsShape = false; + this.fontSize = 0; + this.fontSizeScale = 1; + this.textMatrix = IDENTITY_MATRIX; + this.textMatrixScale = 1; + this.fontMatrix = FONT_IDENTITY_MATRIX; + this.leading = 0; + // Current point (in user coordinates) + this.x = 0; + this.y = 0; + // Start of text line (in text coordinates) + this.lineX = 0; + this.lineY = 0; + // Character and word spacing + this.charSpacing = 0; + this.wordSpacing = 0; + this.textHScale = 1; + this.textRenderingMode = TextRenderingMode.FILL; + this.textRise = 0; + // Default fore and background colors + this.fillColor = '#000000'; + this.strokeColor = '#000000'; + this.patternFill = false; + // Note: fill alpha applies to all non-stroking operations + this.fillAlpha = 1; + this.strokeAlpha = 1; + this.lineWidth = 1; + this.activeSMask = null; + this.resumeSMaskCtx = null; // nonclonable field (see the save method below) + + this.old = old; + } + + CanvasExtraState.prototype = { + clone: function CanvasExtraState_clone() { + return Object.create(this); + }, + setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) { + this.x = x; + this.y = y; + } + }; + return CanvasExtraState; +})(); + +var CanvasGraphics = (function CanvasGraphicsClosure() { + // Defines the time the executeOperatorList is going to be executing + // before it stops and shedules a continue of execution. + var EXECUTION_TIME = 15; + // Defines the number of steps before checking the execution time + var EXECUTION_STEPS = 10; + + function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) { + this.ctx = canvasCtx; + this.current = new CanvasExtraState(); + this.stateStack = []; + this.pendingClip = null; + this.pendingEOFill = false; + this.res = null; + this.xobjs = null; + this.commonObjs = commonObjs; + this.objs = objs; + this.imageLayer = imageLayer; + this.groupStack = []; + this.processingType3 = null; + // Patterns are painted relative to the initial page/form transform, see pdf + // spec 8.7.2 NOTE 1. + this.baseTransform = null; + this.baseTransformStack = []; + this.groupLevel = 0; + this.smaskStack = []; + this.smaskCounter = 0; + this.tempSMask = null; + this.cachedCanvases = new CachedCanvases(); + if (canvasCtx) { + // NOTE: if mozCurrentTransform is polyfilled, then the current state of + // the transformation must already be set in canvasCtx._transformMatrix. + addContextCurrentTransform(canvasCtx); + } + this.cachedGetSinglePixelWidth = null; + } + + function putBinaryImageData(ctx, imgData) { + if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) { + ctx.putImageData(imgData, 0, 0); + return; + } + + // Put the image data to the canvas in chunks, rather than putting the + // whole image at once. This saves JS memory, because the ImageData object + // is smaller. It also possibly saves C++ memory within the implementation + // of putImageData(). (E.g. in Firefox we make two short-lived copies of + // the data passed to putImageData()). |n| shouldn't be too small, however, + // because too many putImageData() calls will slow things down. + // + // Note: as written, if the last chunk is partial, the putImageData() call + // will (conceptually) put pixels past the bounds of the canvas. But + // that's ok; any such pixels are ignored. + + var height = imgData.height, width = imgData.width; + var partialChunkHeight = height % FULL_CHUNK_HEIGHT; + var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; + var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; + + var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); + var srcPos = 0, destPos; + var src = imgData.data; + var dest = chunkImgData.data; + var i, j, thisChunkHeight, elemsInThisChunk; + + // There are multiple forms in which the pixel data can be passed, and + // imgData.kind tells us which one this is. + if (imgData.kind === ImageKind.GRAYSCALE_1BPP) { + // Grayscale, 1 bit per pixel (i.e. black-and-white). + var srcLength = src.byteLength; + var dest32 = HasCanvasTypedArraysCached.value ? + new Uint32Array(dest.buffer) : new Uint32ArrayView(dest); + var dest32DataLength = dest32.length; + var fullSrcDiff = (width + 7) >> 3; + var white = 0xFFFFFFFF; + var black = (IsLittleEndianCached.value || + !HasCanvasTypedArraysCached.value) ? 0xFF000000 : 0x000000FF; + for (i = 0; i < totalChunks; i++) { + thisChunkHeight = + (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight; + destPos = 0; + for (j = 0; j < thisChunkHeight; j++) { + var srcDiff = srcLength - srcPos; + var k = 0; + var kEnd = (srcDiff > fullSrcDiff) ? width : srcDiff * 8 - 7; + var kEndUnrolled = kEnd & ~7; + var mask = 0; + var srcByte = 0; + for (; k < kEndUnrolled; k += 8) { + srcByte = src[srcPos++]; + dest32[destPos++] = (srcByte & 128) ? white : black; + dest32[destPos++] = (srcByte & 64) ? white : black; + dest32[destPos++] = (srcByte & 32) ? white : black; + dest32[destPos++] = (srcByte & 16) ? white : black; + dest32[destPos++] = (srcByte & 8) ? white : black; + dest32[destPos++] = (srcByte & 4) ? white : black; + dest32[destPos++] = (srcByte & 2) ? white : black; + dest32[destPos++] = (srcByte & 1) ? white : black; + } + for (; k < kEnd; k++) { + if (mask === 0) { + srcByte = src[srcPos++]; + mask = 128; + } + + dest32[destPos++] = (srcByte & mask) ? white : black; + mask >>= 1; + } + } + // We ran out of input. Make all remaining pixels transparent. + while (destPos < dest32DataLength) { + dest32[destPos++] = 0; + } + + ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); + } + } else if (imgData.kind === ImageKind.RGBA_32BPP) { + // RGBA, 32-bits per pixel. + + j = 0; + elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4; + for (i = 0; i < fullChunks; i++) { + dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); + srcPos += elemsInThisChunk; + + ctx.putImageData(chunkImgData, 0, j); + j += FULL_CHUNK_HEIGHT; + } + if (i < totalChunks) { + elemsInThisChunk = width * partialChunkHeight * 4; + dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); + ctx.putImageData(chunkImgData, 0, j); + } + + } else if (imgData.kind === ImageKind.RGB_24BPP) { + // RGB, 24-bits per pixel. + thisChunkHeight = FULL_CHUNK_HEIGHT; + elemsInThisChunk = width * thisChunkHeight; + for (i = 0; i < totalChunks; i++) { + if (i >= fullChunks) { + thisChunkHeight = partialChunkHeight; + elemsInThisChunk = width * thisChunkHeight; + } + + destPos = 0; + for (j = elemsInThisChunk; j--;) { + dest[destPos++] = src[srcPos++]; + dest[destPos++] = src[srcPos++]; + dest[destPos++] = src[srcPos++]; + dest[destPos++] = 255; + } + ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); + } + } else { + error('bad image kind: ' + imgData.kind); + } + } + + function putBinaryImageMask(ctx, imgData) { + var height = imgData.height, width = imgData.width; + var partialChunkHeight = height % FULL_CHUNK_HEIGHT; + var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; + var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; + + var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); + var srcPos = 0; + var src = imgData.data; + var dest = chunkImgData.data; + + for (var i = 0; i < totalChunks; i++) { + var thisChunkHeight = + (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight; + + // Expand the mask so it can be used by the canvas. Any required + // inversion has already been handled. + var destPos = 3; // alpha component offset + for (var j = 0; j < thisChunkHeight; j++) { + var mask = 0; + for (var k = 0; k < width; k++) { + if (!mask) { + var elem = src[srcPos++]; + mask = 128; + } + dest[destPos] = (elem & mask) ? 0 : 255; + destPos += 4; + mask >>= 1; + } + } + ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); + } + } + + function copyCtxState(sourceCtx, destCtx) { + var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', + 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', + 'globalCompositeOperation', 'font']; + for (var i = 0, ii = properties.length; i < ii; i++) { + var property = properties[i]; + if (sourceCtx[property] !== undefined) { + destCtx[property] = sourceCtx[property]; + } + } + if (sourceCtx.setLineDash !== undefined) { + destCtx.setLineDash(sourceCtx.getLineDash()); + destCtx.lineDashOffset = sourceCtx.lineDashOffset; + } else if (sourceCtx.mozDashOffset !== undefined) { + destCtx.mozDash = sourceCtx.mozDash; + destCtx.mozDashOffset = sourceCtx.mozDashOffset; + } + } + + function composeSMaskBackdrop(bytes, r0, g0, b0) { + var length = bytes.length; + for (var i = 3; i < length; i += 4) { + var alpha = bytes[i]; + if (alpha === 0) { + bytes[i - 3] = r0; + bytes[i - 2] = g0; + bytes[i - 1] = b0; + } else if (alpha < 255) { + var alpha_ = 255 - alpha; + bytes[i - 3] = (bytes[i - 3] * alpha + r0 * alpha_) >> 8; + bytes[i - 2] = (bytes[i - 2] * alpha + g0 * alpha_) >> 8; + bytes[i - 1] = (bytes[i - 1] * alpha + b0 * alpha_) >> 8; + } + } + } + + function composeSMaskAlpha(maskData, layerData, transferMap) { + var length = maskData.length; + var scale = 1 / 255; + for (var i = 3; i < length; i += 4) { + var alpha = transferMap ? transferMap[maskData[i]] : maskData[i]; + layerData[i] = (layerData[i] * alpha * scale) | 0; + } + } + + function composeSMaskLuminosity(maskData, layerData, transferMap) { + var length = maskData.length; + for (var i = 3; i < length; i += 4) { + var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000 + (maskData[i - 2] * 152) + // * 0.59 .... + (maskData[i - 1] * 28); // * 0.11 .... + layerData[i] = transferMap ? + (layerData[i] * transferMap[y >> 8]) >> 8 : + (layerData[i] * y) >> 16; + } + } + + function genericComposeSMask(maskCtx, layerCtx, width, height, + subtype, backdrop, transferMap) { + var hasBackdrop = !!backdrop; + var r0 = hasBackdrop ? backdrop[0] : 0; + var g0 = hasBackdrop ? backdrop[1] : 0; + var b0 = hasBackdrop ? backdrop[2] : 0; + + var composeFn; + if (subtype === 'Luminosity') { + composeFn = composeSMaskLuminosity; + } else { + composeFn = composeSMaskAlpha; + } + + // processing image in chunks to save memory + var PIXELS_TO_PROCESS = 1048576; + var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width)); + for (var row = 0; row < height; row += chunkSize) { + var chunkHeight = Math.min(chunkSize, height - row); + var maskData = maskCtx.getImageData(0, row, width, chunkHeight); + var layerData = layerCtx.getImageData(0, row, width, chunkHeight); + + if (hasBackdrop) { + composeSMaskBackdrop(maskData.data, r0, g0, b0); + } + composeFn(maskData.data, layerData.data, transferMap); + + maskCtx.putImageData(layerData, 0, row); + } + } + + function composeSMask(ctx, smask, layerCtx) { + var mask = smask.canvas; + var maskCtx = smask.context; + + ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, + smask.offsetX, smask.offsetY); + + var backdrop = smask.backdrop || null; + if (!smask.transferMap && WebGLUtils.isEnabled) { + var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, + {subtype: smask.subtype, backdrop: backdrop}); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.drawImage(composed, smask.offsetX, smask.offsetY); + return; + } + genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, + smask.subtype, backdrop, smask.transferMap); + ctx.drawImage(mask, 0, 0); + } + + var LINE_CAP_STYLES = ['butt', 'round', 'square']; + var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; + var NORMAL_CLIP = {}; + var EO_CLIP = {}; + + CanvasGraphics.prototype = { + + beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, + transparency) { + // For pdfs that use blend modes we have to clear the canvas else certain + // blend modes can look wrong since we'd be blending with a white + // backdrop. The problem with a transparent backdrop though is we then + // don't get sub pixel anti aliasing on text, creating temporary + // transparent canvas when we have blend modes. + var width = this.ctx.canvas.width; + var height = this.ctx.canvas.height; + + this.ctx.save(); + this.ctx.fillStyle = 'rgb(255, 255, 255)'; + this.ctx.fillRect(0, 0, width, height); + this.ctx.restore(); + + if (transparency) { + var transparentCanvas = this.cachedCanvases.getCanvas( + 'transparent', width, height, true); + this.compositeCtx = this.ctx; + this.transparentCanvas = transparentCanvas.canvas; + this.ctx = transparentCanvas.context; + this.ctx.save(); + // The transform can be applied before rendering, transferring it to + // the new canvas. + this.ctx.transform.apply(this.ctx, + this.compositeCtx.mozCurrentTransform); + } + + this.ctx.save(); + if (transform) { + this.ctx.transform.apply(this.ctx, transform); + } + this.ctx.transform.apply(this.ctx, viewport.transform); + + this.baseTransform = this.ctx.mozCurrentTransform.slice(); + + if (this.imageLayer) { + this.imageLayer.beginLayout(); + } + }, + + executeOperatorList: function CanvasGraphics_executeOperatorList( + operatorList, + executionStartIdx, continueCallback, + stepper) { + var argsArray = operatorList.argsArray; + var fnArray = operatorList.fnArray; + var i = executionStartIdx || 0; + var argsArrayLen = argsArray.length; + + // Sometimes the OperatorList to execute is empty. + if (argsArrayLen === i) { + return i; + } + + var chunkOperations = (argsArrayLen - i > EXECUTION_STEPS && + typeof continueCallback === 'function'); + var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0; + var steps = 0; + + var commonObjs = this.commonObjs; + var objs = this.objs; + var fnId; + + while (true) { + if (stepper !== undefined && i === stepper.nextBreakPoint) { + stepper.breakIt(i, continueCallback); + return i; + } + + fnId = fnArray[i]; + + if (fnId !== OPS.dependency) { + this[fnId].apply(this, argsArray[i]); + } else { + var deps = argsArray[i]; + for (var n = 0, nn = deps.length; n < nn; n++) { + var depObjId = deps[n]; + var common = depObjId[0] === 'g' && depObjId[1] === '_'; + var objsPool = common ? commonObjs : objs; + + // If the promise isn't resolved yet, add the continueCallback + // to the promise and bail out. + if (!objsPool.isResolved(depObjId)) { + objsPool.get(depObjId, continueCallback); + return i; + } + } + } + + i++; + + // If the entire operatorList was executed, stop as were done. + if (i === argsArrayLen) { + return i; + } + + // If the execution took longer then a certain amount of time and + // `continueCallback` is specified, interrupt the execution. + if (chunkOperations && ++steps > EXECUTION_STEPS) { + if (Date.now() > endTime) { + continueCallback(); + return i; + } + steps = 0; + } + + // If the operatorList isn't executed completely yet OR the execution + // time was short enough, do another execution round. + } + }, + + endDrawing: function CanvasGraphics_endDrawing() { + // Finishing all opened operations such as SMask group painting. + if (this.current.activeSMask !== null) { + this.endSMaskGroup(); + } + + this.ctx.restore(); + + if (this.transparentCanvas) { + this.ctx = this.compositeCtx; + this.ctx.save(); + this.ctx.setTransform(1, 0, 0, 1, 0, 0); // Avoid apply transform twice + this.ctx.drawImage(this.transparentCanvas, 0, 0); + this.ctx.restore(); + this.transparentCanvas = null; + } + + this.cachedCanvases.clear(); + WebGLUtils.clear(); + + if (this.imageLayer) { + this.imageLayer.endLayout(); + } + }, + + // Graphics state + setLineWidth: function CanvasGraphics_setLineWidth(width) { + this.current.lineWidth = width; + this.ctx.lineWidth = width; + }, + setLineCap: function CanvasGraphics_setLineCap(style) { + this.ctx.lineCap = LINE_CAP_STYLES[style]; + }, + setLineJoin: function CanvasGraphics_setLineJoin(style) { + this.ctx.lineJoin = LINE_JOIN_STYLES[style]; + }, + setMiterLimit: function CanvasGraphics_setMiterLimit(limit) { + this.ctx.miterLimit = limit; + }, + setDash: function CanvasGraphics_setDash(dashArray, dashPhase) { + var ctx = this.ctx; + if (ctx.setLineDash !== undefined) { + ctx.setLineDash(dashArray); + ctx.lineDashOffset = dashPhase; + } else { + ctx.mozDash = dashArray; + ctx.mozDashOffset = dashPhase; + } + }, + setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) { + // Maybe if we one day fully support color spaces this will be important + // for now we can ignore. + // TODO set rendering intent? + }, + setFlatness: function CanvasGraphics_setFlatness(flatness) { + // There's no way to control this with canvas, but we can safely ignore. + // TODO set flatness? + }, + setGState: function CanvasGraphics_setGState(states) { + for (var i = 0, ii = states.length; i < ii; i++) { + var state = states[i]; + var key = state[0]; + var value = state[1]; + + switch (key) { + case 'LW': + this.setLineWidth(value); + break; + case 'LC': + this.setLineCap(value); + break; + case 'LJ': + this.setLineJoin(value); + break; + case 'ML': + this.setMiterLimit(value); + break; + case 'D': + this.setDash(value[0], value[1]); + break; + case 'RI': + this.setRenderingIntent(value); + break; + case 'FL': + this.setFlatness(value); + break; + case 'Font': + this.setFont(value[0], value[1]); + break; + case 'CA': + this.current.strokeAlpha = state[1]; + break; + case 'ca': + this.current.fillAlpha = state[1]; + this.ctx.globalAlpha = state[1]; + break; + case 'BM': + if (value && value.name && (value.name !== 'Normal')) { + var mode = value.name.replace(/([A-Z])/g, + function(c) { + return '-' + c.toLowerCase(); + } + ).substring(1); + this.ctx.globalCompositeOperation = mode; + if (this.ctx.globalCompositeOperation !== mode) { + warn('globalCompositeOperation "' + mode + + '" is not supported'); + } + } else { + this.ctx.globalCompositeOperation = 'source-over'; + } + break; + case 'SMask': + if (this.current.activeSMask) { + // If SMask is currrenly used, it needs to be suspended or + // finished. Suspend only makes sense when at least one save() + // was performed and state needs to be reverted on restore(). + if (this.stateStack.length > 0 && + (this.stateStack[this.stateStack.length - 1].activeSMask === + this.current.activeSMask)) { + this.suspendSMaskGroup(); + } else { + this.endSMaskGroup(); + } + } + this.current.activeSMask = value ? this.tempSMask : null; + if (this.current.activeSMask) { + this.beginSMaskGroup(); + } + this.tempSMask = null; + break; + } + } + }, + beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() { + + var activeSMask = this.current.activeSMask; + var drawnWidth = activeSMask.canvas.width; + var drawnHeight = activeSMask.canvas.height; + var cacheId = 'smaskGroupAt' + this.groupLevel; + var scratchCanvas = this.cachedCanvases.getCanvas( + cacheId, drawnWidth, drawnHeight, true); + + var currentCtx = this.ctx; + var currentTransform = currentCtx.mozCurrentTransform; + this.ctx.save(); + + var groupCtx = scratchCanvas.context; + groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY); + groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY); + groupCtx.transform.apply(groupCtx, currentTransform); + + activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse; + + copyCtxState(currentCtx, groupCtx); + this.ctx = groupCtx; + this.setGState([ + ['BM', 'Normal'], + ['ca', 1], + ['CA', 1] + ]); + this.groupStack.push(currentCtx); + this.groupLevel++; + }, + suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() { + // Similar to endSMaskGroup, the intermediate canvas has to be composed + // and future ctx state restored. + var groupCtx = this.ctx; + this.groupLevel--; + this.ctx = this.groupStack.pop(); + + composeSMask(this.ctx, this.current.activeSMask, groupCtx); + this.ctx.restore(); + this.ctx.save(); // save is needed since SMask will be resumed. + copyCtxState(groupCtx, this.ctx); + + // Saving state for resuming. + this.current.resumeSMaskCtx = groupCtx; + // Transform was changed in the SMask canvas, reflecting this change on + // this.ctx. + var deltaTransform = Util.transform( + this.current.activeSMask.startTransformInverse, + groupCtx.mozCurrentTransform); + this.ctx.transform.apply(this.ctx, deltaTransform); + + // SMask was composed, the results at the groupCtx can be cleared. + groupCtx.save(); + groupCtx.setTransform(1, 0, 0, 1, 0, 0); + groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height); + groupCtx.restore(); + }, + resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() { + // Resuming state saved by suspendSMaskGroup. We don't need to restore + // any groupCtx state since restore() command (the only caller) will do + // that for us. See also beginSMaskGroup. + var groupCtx = this.current.resumeSMaskCtx; + var currentCtx = this.ctx; + this.ctx = groupCtx; + this.groupStack.push(currentCtx); + this.groupLevel++; + }, + endSMaskGroup: function CanvasGraphics_endSMaskGroup() { + var groupCtx = this.ctx; + this.groupLevel--; + this.ctx = this.groupStack.pop(); + + composeSMask(this.ctx, this.current.activeSMask, groupCtx); + this.ctx.restore(); + copyCtxState(groupCtx, this.ctx); + // Transform was changed in the SMask canvas, reflecting this change on + // this.ctx. + var deltaTransform = Util.transform( + this.current.activeSMask.startTransformInverse, + groupCtx.mozCurrentTransform); + this.ctx.transform.apply(this.ctx, deltaTransform); + }, + save: function CanvasGraphics_save() { + this.ctx.save(); + var old = this.current; + this.stateStack.push(old); + this.current = old.clone(); + this.current.resumeSMaskCtx = null; + }, + restore: function CanvasGraphics_restore() { + // SMask was suspended, we just need to resume it. + if (this.current.resumeSMaskCtx) { + this.resumeSMaskGroup(); + } + // SMask has to be finished once there is no states that are using the + // same SMask. + if (this.current.activeSMask !== null && (this.stateStack.length === 0 || + this.stateStack[this.stateStack.length - 1].activeSMask !== + this.current.activeSMask)) { + this.endSMaskGroup(); + } + + if (this.stateStack.length !== 0) { + this.current = this.stateStack.pop(); + this.ctx.restore(); + + // Ensure that the clipping path is reset (fixes issue6413.pdf). + this.pendingClip = null; + + this.cachedGetSinglePixelWidth = null; + } + }, + transform: function CanvasGraphics_transform(a, b, c, d, e, f) { + this.ctx.transform(a, b, c, d, e, f); + + this.cachedGetSinglePixelWidth = null; + }, + + // Path + constructPath: function CanvasGraphics_constructPath(ops, args) { + var ctx = this.ctx; + var current = this.current; + var x = current.x, y = current.y; + for (var i = 0, j = 0, ii = ops.length; i < ii; i++) { + switch (ops[i] | 0) { + case OPS.rectangle: + x = args[j++]; + y = args[j++]; + var width = args[j++]; + var height = args[j++]; + if (width === 0) { + width = this.getSinglePixelWidth(); + } + if (height === 0) { + height = this.getSinglePixelWidth(); + } + var xw = x + width; + var yh = y + height; + this.ctx.moveTo(x, y); + this.ctx.lineTo(xw, y); + this.ctx.lineTo(xw, yh); + this.ctx.lineTo(x, yh); + this.ctx.lineTo(x, y); + this.ctx.closePath(); + break; + case OPS.moveTo: + x = args[j++]; + y = args[j++]; + ctx.moveTo(x, y); + break; + case OPS.lineTo: + x = args[j++]; + y = args[j++]; + ctx.lineTo(x, y); + break; + case OPS.curveTo: + x = args[j + 4]; + y = args[j + 5]; + ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], + x, y); + j += 6; + break; + case OPS.curveTo2: + ctx.bezierCurveTo(x, y, args[j], args[j + 1], + args[j + 2], args[j + 3]); + x = args[j + 2]; + y = args[j + 3]; + j += 4; + break; + case OPS.curveTo3: + x = args[j + 2]; + y = args[j + 3]; + ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y); + j += 4; + break; + case OPS.closePath: + ctx.closePath(); + break; + } + } + current.setCurrentPoint(x, y); + }, + closePath: function CanvasGraphics_closePath() { + this.ctx.closePath(); + }, + stroke: function CanvasGraphics_stroke(consumePath) { + consumePath = typeof consumePath !== 'undefined' ? consumePath : true; + var ctx = this.ctx; + var strokeColor = this.current.strokeColor; + // Prevent drawing too thin lines by enforcing a minimum line width. + ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, + this.current.lineWidth); + // For stroke we want to temporarily change the global alpha to the + // stroking alpha. + ctx.globalAlpha = this.current.strokeAlpha; + if (strokeColor && strokeColor.hasOwnProperty('type') && + strokeColor.type === 'Pattern') { + // for patterns, we transform to pattern space, calculate + // the pattern, call stroke, and restore to user space + ctx.save(); + ctx.strokeStyle = strokeColor.getPattern(ctx, this); + ctx.stroke(); + ctx.restore(); + } else { + ctx.stroke(); + } + if (consumePath) { + this.consumePath(); + } + // Restore the global alpha to the fill alpha + ctx.globalAlpha = this.current.fillAlpha; + }, + closeStroke: function CanvasGraphics_closeStroke() { + this.closePath(); + this.stroke(); + }, + fill: function CanvasGraphics_fill(consumePath) { + consumePath = typeof consumePath !== 'undefined' ? consumePath : true; + var ctx = this.ctx; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + var needRestore = false; + + if (isPatternFill) { + ctx.save(); + if (this.baseTransform) { + ctx.setTransform.apply(ctx, this.baseTransform); + } + ctx.fillStyle = fillColor.getPattern(ctx, this); + needRestore = true; + } + + if (this.pendingEOFill) { + if (ctx.mozFillRule !== undefined) { + ctx.mozFillRule = 'evenodd'; + ctx.fill(); + ctx.mozFillRule = 'nonzero'; + } else { + ctx.fill('evenodd'); + } + this.pendingEOFill = false; + } else { + ctx.fill(); + } + + if (needRestore) { + ctx.restore(); + } + if (consumePath) { + this.consumePath(); + } + }, + eoFill: function CanvasGraphics_eoFill() { + this.pendingEOFill = true; + this.fill(); + }, + fillStroke: function CanvasGraphics_fillStroke() { + this.fill(false); + this.stroke(false); + + this.consumePath(); + }, + eoFillStroke: function CanvasGraphics_eoFillStroke() { + this.pendingEOFill = true; + this.fillStroke(); + }, + closeFillStroke: function CanvasGraphics_closeFillStroke() { + this.closePath(); + this.fillStroke(); + }, + closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() { + this.pendingEOFill = true; + this.closePath(); + this.fillStroke(); + }, + endPath: function CanvasGraphics_endPath() { + this.consumePath(); + }, + + // Clipping + clip: function CanvasGraphics_clip() { + this.pendingClip = NORMAL_CLIP; + }, + eoClip: function CanvasGraphics_eoClip() { + this.pendingClip = EO_CLIP; + }, + + // Text + beginText: function CanvasGraphics_beginText() { + this.current.textMatrix = IDENTITY_MATRIX; + this.current.textMatrixScale = 1; + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + }, + endText: function CanvasGraphics_endText() { + var paths = this.pendingTextPaths; + var ctx = this.ctx; + if (paths === undefined) { + ctx.beginPath(); + return; + } + + ctx.save(); + ctx.beginPath(); + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + ctx.setTransform.apply(ctx, path.transform); + ctx.translate(path.x, path.y); + path.addToPath(ctx, path.fontSize); + } + ctx.restore(); + ctx.clip(); + ctx.beginPath(); + delete this.pendingTextPaths; + }, + setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) { + this.current.charSpacing = spacing; + }, + setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) { + this.current.wordSpacing = spacing; + }, + setHScale: function CanvasGraphics_setHScale(scale) { + this.current.textHScale = scale / 100; + }, + setLeading: function CanvasGraphics_setLeading(leading) { + this.current.leading = -leading; + }, + setFont: function CanvasGraphics_setFont(fontRefName, size) { + var fontObj = this.commonObjs.get(fontRefName); + var current = this.current; + + if (!fontObj) { + error('Can\'t find font for ' + fontRefName); + } + + current.fontMatrix = (fontObj.fontMatrix ? + fontObj.fontMatrix : FONT_IDENTITY_MATRIX); + + // A valid matrix needs all main diagonal elements to be non-zero + // This also ensures we bypass FF bugzilla bug #719844. + if (current.fontMatrix[0] === 0 || + current.fontMatrix[3] === 0) { + warn('Invalid font matrix for font ' + fontRefName); + } + + // The spec for Tf (setFont) says that 'size' specifies the font 'scale', + // and in some docs this can be negative (inverted x-y axes). + if (size < 0) { + size = -size; + current.fontDirection = -1; + } else { + current.fontDirection = 1; + } + + this.current.font = fontObj; + this.current.fontSize = size; + + if (fontObj.isType3Font) { + return; // we don't need ctx.font for Type3 fonts + } + + var name = fontObj.loadedName || 'sans-serif'; + var bold = fontObj.black ? (fontObj.bold ? '900' : 'bold') : + (fontObj.bold ? 'bold' : 'normal'); + + var italic = fontObj.italic ? 'italic' : 'normal'; + var typeface = '"' + name + '", ' + fontObj.fallbackName; + + // Some font backends cannot handle fonts below certain size. + // Keeping the font at minimal size and using the fontSizeScale to change + // the current transformation matrix before the fillText/strokeText. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=726227 + var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : + size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size; + this.current.fontSizeScale = size / browserFontSize; + + var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; + this.ctx.font = rule; + }, + setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) { + this.current.textRenderingMode = mode; + }, + setTextRise: function CanvasGraphics_setTextRise(rise) { + this.current.textRise = rise; + }, + moveText: function CanvasGraphics_moveText(x, y) { + this.current.x = this.current.lineX += x; + this.current.y = this.current.lineY += y; + }, + setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) { + this.setLeading(-y); + this.moveText(x, y); + }, + setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) { + this.current.textMatrix = [a, b, c, d, e, f]; + this.current.textMatrixScale = Math.sqrt(a * a + b * b); + + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + }, + nextLine: function CanvasGraphics_nextLine() { + this.moveText(0, this.current.leading); + }, + + paintChar: function CanvasGraphics_paintChar(character, x, y) { + var ctx = this.ctx; + var current = this.current; + var font = current.font; + var textRenderingMode = current.textRenderingMode; + var fontSize = current.fontSize / current.fontSizeScale; + var fillStrokeMode = textRenderingMode & + TextRenderingMode.FILL_STROKE_MASK; + var isAddToPathSet = !!(textRenderingMode & + TextRenderingMode.ADD_TO_PATH_FLAG); + + var addToPath; + if (font.disableFontFace || isAddToPathSet) { + addToPath = font.getPathGenerator(this.commonObjs, character); + } + + if (font.disableFontFace) { + ctx.save(); + ctx.translate(x, y); + ctx.beginPath(); + addToPath(ctx, fontSize); + if (fillStrokeMode === TextRenderingMode.FILL || + fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.fill(); + } + if (fillStrokeMode === TextRenderingMode.STROKE || + fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.stroke(); + } + ctx.restore(); + } else { + if (fillStrokeMode === TextRenderingMode.FILL || + fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.fillText(character, x, y); + } + if (fillStrokeMode === TextRenderingMode.STROKE || + fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.strokeText(character, x, y); + } + } + + if (isAddToPathSet) { + var paths = this.pendingTextPaths || (this.pendingTextPaths = []); + paths.push({ + transform: ctx.mozCurrentTransform, + x: x, + y: y, + fontSize: fontSize, + addToPath: addToPath + }); + } + }, + + get isFontSubpixelAAEnabled() { + // Checks if anti-aliasing is enabled when scaled text is painted. + // On Windows GDI scaled fonts looks bad. + var ctx = document.createElement('canvas').getContext('2d'); + ctx.scale(1.5, 1); + ctx.fillText('I', 0, 10); + var data = ctx.getImageData(0, 0, 10, 10).data; + var enabled = false; + for (var i = 3; i < data.length; i += 4) { + if (data[i] > 0 && data[i] < 255) { + enabled = true; + break; + } + } + return shadow(this, 'isFontSubpixelAAEnabled', enabled); + }, + + showText: function CanvasGraphics_showText(glyphs) { + var current = this.current; + var font = current.font; + if (font.isType3Font) { + return this.showType3Text(glyphs); + } + + var fontSize = current.fontSize; + if (fontSize === 0) { + return; + } + + var ctx = this.ctx; + var fontSizeScale = current.fontSizeScale; + var charSpacing = current.charSpacing; + var wordSpacing = current.wordSpacing; + var fontDirection = current.fontDirection; + var textHScale = current.textHScale * fontDirection; + var glyphsLength = glyphs.length; + var vertical = font.vertical; + var spacingDir = vertical ? 1 : -1; + var defaultVMetrics = font.defaultVMetrics; + var widthAdvanceScale = fontSize * current.fontMatrix[0]; + + var simpleFillText = + current.textRenderingMode === TextRenderingMode.FILL && + !font.disableFontFace; + + ctx.save(); + ctx.transform.apply(ctx, current.textMatrix); + ctx.translate(current.x, current.y + current.textRise); + + if (current.patternFill) { + // TODO: Some shading patterns are not applied correctly to text, + // e.g. issues 3988 and 5432, and ShowText-ShadingPattern.pdf. + ctx.fillStyle = current.fillColor.getPattern(ctx, this); + } + + if (fontDirection > 0) { + ctx.scale(textHScale, -1); + } else { + ctx.scale(textHScale, 1); + } + + var lineWidth = current.lineWidth; + var scale = current.textMatrixScale; + if (scale === 0 || lineWidth === 0) { + var fillStrokeMode = current.textRenderingMode & + TextRenderingMode.FILL_STROKE_MASK; + if (fillStrokeMode === TextRenderingMode.STROKE || + fillStrokeMode === TextRenderingMode.FILL_STROKE) { + this.cachedGetSinglePixelWidth = null; + lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR; + } + } else { + lineWidth /= scale; + } + + if (fontSizeScale !== 1.0) { + ctx.scale(fontSizeScale, fontSizeScale); + lineWidth /= fontSizeScale; + } + + ctx.lineWidth = lineWidth; + + var x = 0, i; + for (i = 0; i < glyphsLength; ++i) { + var glyph = glyphs[i]; + if (isNum(glyph)) { + x += spacingDir * glyph * fontSize / 1000; + continue; + } + + var restoreNeeded = false; + var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; + var character = glyph.fontChar; + var accent = glyph.accent; + var scaledX, scaledY, scaledAccentX, scaledAccentY; + var width = glyph.width; + if (vertical) { + var vmetric, vx, vy; + vmetric = glyph.vmetric || defaultVMetrics; + vx = glyph.vmetric ? vmetric[1] : width * 0.5; + vx = -vx * widthAdvanceScale; + vy = vmetric[2] * widthAdvanceScale; + + width = vmetric ? -vmetric[0] : width; + scaledX = vx / fontSizeScale; + scaledY = (x + vy) / fontSizeScale; + } else { + scaledX = x / fontSizeScale; + scaledY = 0; + } + + if (font.remeasure && width > 0) { + // Some standard fonts may not have the exact width: rescale per + // character if measured width is greater than expected glyph width + // and subpixel-aa is enabled, otherwise just center the glyph. + var measuredWidth = ctx.measureText(character).width * 1000 / + fontSize * fontSizeScale; + if (width < measuredWidth && this.isFontSubpixelAAEnabled) { + var characterScaleX = width / measuredWidth; + restoreNeeded = true; + ctx.save(); + ctx.scale(characterScaleX, 1); + scaledX /= characterScaleX; + } else if (width !== measuredWidth) { + scaledX += (width - measuredWidth) / 2000 * + fontSize / fontSizeScale; + } + } + + // Only attempt to draw the glyph if it is actually in the embedded font + // file or if there isn't a font file so the fallback font is shown. + if (glyph.isInFont || font.missingFile) { + if (simpleFillText && !accent) { + // common case + ctx.fillText(character, scaledX, scaledY); + } else { + this.paintChar(character, scaledX, scaledY); + if (accent) { + scaledAccentX = scaledX + accent.offset.x / fontSizeScale; + scaledAccentY = scaledY - accent.offset.y / fontSizeScale; + this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY); + } + } + } + + var charWidth = width * widthAdvanceScale + spacing * fontDirection; + x += charWidth; + + if (restoreNeeded) { + ctx.restore(); + } + } + if (vertical) { + current.y -= x * textHScale; + } else { + current.x += x * textHScale; + } + ctx.restore(); + }, + + showType3Text: function CanvasGraphics_showType3Text(glyphs) { + // Type3 fonts - each glyph is a "mini-PDF" + var ctx = this.ctx; + var current = this.current; + var font = current.font; + var fontSize = current.fontSize; + var fontDirection = current.fontDirection; + var spacingDir = font.vertical ? 1 : -1; + var charSpacing = current.charSpacing; + var wordSpacing = current.wordSpacing; + var textHScale = current.textHScale * fontDirection; + var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX; + var glyphsLength = glyphs.length; + var isTextInvisible = + current.textRenderingMode === TextRenderingMode.INVISIBLE; + var i, glyph, width, spacingLength; + + if (isTextInvisible || fontSize === 0) { + return; + } + this.cachedGetSinglePixelWidth = null; + + ctx.save(); + ctx.transform.apply(ctx, current.textMatrix); + ctx.translate(current.x, current.y); + + ctx.scale(textHScale, fontDirection); + + for (i = 0; i < glyphsLength; ++i) { + glyph = glyphs[i]; + if (isNum(glyph)) { + spacingLength = spacingDir * glyph * fontSize / 1000; + this.ctx.translate(spacingLength, 0); + current.x += spacingLength * textHScale; + continue; + } + + var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; + var operatorList = font.charProcOperatorList[glyph.operatorListId]; + if (!operatorList) { + warn('Type3 character \"' + glyph.operatorListId + + '\" is not available'); + continue; + } + this.processingType3 = glyph; + this.save(); + ctx.scale(fontSize, fontSize); + ctx.transform.apply(ctx, fontMatrix); + this.executeOperatorList(operatorList); + this.restore(); + + var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); + width = transformed[0] * fontSize + spacing; + + ctx.translate(width, 0); + current.x += width * textHScale; + } + ctx.restore(); + this.processingType3 = null; + }, + + // Type3 fonts + setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) { + // We can safely ignore this since the width should be the same + // as the width in the Widths array. + }, + setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, + yWidth, + llx, + lly, + urx, + ury) { + // TODO According to the spec we're also suppose to ignore any operators + // that set color or include images while processing this type3 font. + this.ctx.rect(llx, lly, urx - llx, ury - lly); + this.clip(); + this.endPath(); + }, + + // Color + getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) { + var pattern; + if (IR[0] === 'TilingPattern') { + var color = IR[1]; + var baseTransform = this.baseTransform || + this.ctx.mozCurrentTransform.slice(); + var self = this; + var canvasGraphicsFactory = { + createCanvasGraphics: function (ctx) { + return new CanvasGraphics(ctx, self.commonObjs, self.objs); + } + }; + pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, + baseTransform); + } else { + pattern = getShadingPatternFromIR(IR); + } + return pattern; + }, + setStrokeColorN: function CanvasGraphics_setStrokeColorN(/*...*/) { + this.current.strokeColor = this.getColorN_Pattern(arguments); + }, + setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) { + this.current.fillColor = this.getColorN_Pattern(arguments); + this.current.patternFill = true; + }, + setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.ctx.strokeStyle = color; + this.current.strokeColor = color; + }, + setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.ctx.fillStyle = color; + this.current.fillColor = color; + this.current.patternFill = false; + }, + + shadingFill: function CanvasGraphics_shadingFill(patternIR) { + var ctx = this.ctx; + + this.save(); + var pattern = getShadingPatternFromIR(patternIR); + ctx.fillStyle = pattern.getPattern(ctx, this, true); + + var inv = ctx.mozCurrentTransformInverse; + if (inv) { + var canvas = ctx.canvas; + var width = canvas.width; + var height = canvas.height; + + var bl = Util.applyTransform([0, 0], inv); + var br = Util.applyTransform([0, height], inv); + var ul = Util.applyTransform([width, 0], inv); + var ur = Util.applyTransform([width, height], inv); + + var x0 = Math.min(bl[0], br[0], ul[0], ur[0]); + var y0 = Math.min(bl[1], br[1], ul[1], ur[1]); + var x1 = Math.max(bl[0], br[0], ul[0], ur[0]); + var y1 = Math.max(bl[1], br[1], ul[1], ur[1]); + + this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0); + } else { + // HACK to draw the gradient onto an infinite rectangle. + // PDF gradients are drawn across the entire image while + // Canvas only allows gradients to be drawn in a rectangle + // The following bug should allow us to remove this. + // https://bugzilla.mozilla.org/show_bug.cgi?id=664884 + + this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10); + } + + this.restore(); + }, + + // Images + beginInlineImage: function CanvasGraphics_beginInlineImage() { + error('Should not call beginInlineImage'); + }, + beginImageData: function CanvasGraphics_beginImageData() { + error('Should not call beginImageData'); + }, + + paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, + bbox) { + this.save(); + this.baseTransformStack.push(this.baseTransform); + + if (isArray(matrix) && 6 === matrix.length) { + this.transform.apply(this, matrix); + } + + this.baseTransform = this.ctx.mozCurrentTransform; + + if (isArray(bbox) && 4 === bbox.length) { + var width = bbox[2] - bbox[0]; + var height = bbox[3] - bbox[1]; + this.ctx.rect(bbox[0], bbox[1], width, height); + this.clip(); + this.endPath(); + } + }, + + paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() { + this.restore(); + this.baseTransform = this.baseTransformStack.pop(); + }, + + beginGroup: function CanvasGraphics_beginGroup(group) { + this.save(); + var currentCtx = this.ctx; + // TODO non-isolated groups - according to Rik at adobe non-isolated + // group results aren't usually that different and they even have tools + // that ignore this setting. Notes from Rik on implmenting: + // - When you encounter an transparency group, create a new canvas with + // the dimensions of the bbox + // - copy the content from the previous canvas to the new canvas + // - draw as usual + // - remove the backdrop alpha: + // alphaNew = 1 - (1 - alpha)/(1 - alphaBackdrop) with 'alpha' the alpha + // value of your transparency group and 'alphaBackdrop' the alpha of the + // backdrop + // - remove background color: + // colorNew = color - alphaNew *colorBackdrop /(1 - alphaNew) + if (!group.isolated) { + info('TODO: Support non-isolated groups.'); + } + + // TODO knockout - supposedly possible with the clever use of compositing + // modes. + if (group.knockout) { + warn('Knockout groups not supported.'); + } + + var currentTransform = currentCtx.mozCurrentTransform; + if (group.matrix) { + currentCtx.transform.apply(currentCtx, group.matrix); + } + assert(group.bbox, 'Bounding box is required.'); + + // Based on the current transform figure out how big the bounding box + // will actually be. + var bounds = Util.getAxialAlignedBoundingBox( + group.bbox, + currentCtx.mozCurrentTransform); + // Clip the bounding box to the current canvas. + var canvasBounds = [0, + 0, + currentCtx.canvas.width, + currentCtx.canvas.height]; + bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0]; + // Use ceil in case we're between sizes so we don't create canvas that is + // too small and make the canvas at least 1x1 pixels. + var offsetX = Math.floor(bounds[0]); + var offsetY = Math.floor(bounds[1]); + var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1); + var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1); + var scaleX = 1, scaleY = 1; + if (drawnWidth > MAX_GROUP_SIZE) { + scaleX = drawnWidth / MAX_GROUP_SIZE; + drawnWidth = MAX_GROUP_SIZE; + } + if (drawnHeight > MAX_GROUP_SIZE) { + scaleY = drawnHeight / MAX_GROUP_SIZE; + drawnHeight = MAX_GROUP_SIZE; + } + + var cacheId = 'groupAt' + this.groupLevel; + if (group.smask) { + // Using two cache entries is case if masks are used one after another. + cacheId += '_smask_' + ((this.smaskCounter++) % 2); + } + var scratchCanvas = this.cachedCanvases.getCanvas( + cacheId, drawnWidth, drawnHeight, true); + var groupCtx = scratchCanvas.context; + + // Since we created a new canvas that is just the size of the bounding box + // we have to translate the group ctx. + groupCtx.scale(1 / scaleX, 1 / scaleY); + groupCtx.translate(-offsetX, -offsetY); + groupCtx.transform.apply(groupCtx, currentTransform); + + if (group.smask) { + // Saving state and cached mask to be used in setGState. + this.smaskStack.push({ + canvas: scratchCanvas.canvas, + context: groupCtx, + offsetX: offsetX, + offsetY: offsetY, + scaleX: scaleX, + scaleY: scaleY, + subtype: group.smask.subtype, + backdrop: group.smask.backdrop, + transferMap: group.smask.transferMap || null, + startTransformInverse: null, // used during suspend operation + }); + } else { + // Setup the current ctx so when the group is popped we draw it at the + // right location. + currentCtx.setTransform(1, 0, 0, 1, 0, 0); + currentCtx.translate(offsetX, offsetY); + currentCtx.scale(scaleX, scaleY); + } + // The transparency group inherits all off the current graphics state + // except the blend mode, soft mask, and alpha constants. + copyCtxState(currentCtx, groupCtx); + this.ctx = groupCtx; + this.setGState([ + ['BM', 'Normal'], + ['ca', 1], + ['CA', 1] + ]); + this.groupStack.push(currentCtx); + this.groupLevel++; + + // Reseting mask state, masks will be applied on restore of the group. + this.current.activeSMask = null; + }, + + endGroup: function CanvasGraphics_endGroup(group) { + this.groupLevel--; + var groupCtx = this.ctx; + this.ctx = this.groupStack.pop(); + // Turn off image smoothing to avoid sub pixel interpolation which can + // look kind of blurry for some pdfs. + if (this.ctx.imageSmoothingEnabled !== undefined) { + this.ctx.imageSmoothingEnabled = false; + } else { + this.ctx.mozImageSmoothingEnabled = false; + } + if (group.smask) { + this.tempSMask = this.smaskStack.pop(); + } else { + this.ctx.drawImage(groupCtx.canvas, 0, 0); + } + this.restore(); + }, + + beginAnnotations: function CanvasGraphics_beginAnnotations() { + this.save(); + this.current = new CanvasExtraState(); + + if (this.baseTransform) { + this.ctx.setTransform.apply(this.ctx, this.baseTransform); + } + }, + + endAnnotations: function CanvasGraphics_endAnnotations() { + this.restore(); + }, + + beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, + matrix) { + this.save(); + + if (isArray(rect) && 4 === rect.length) { + var width = rect[2] - rect[0]; + var height = rect[3] - rect[1]; + this.ctx.rect(rect[0], rect[1], width, height); + this.clip(); + this.endPath(); + } + + this.transform.apply(this, transform); + this.transform.apply(this, matrix); + }, + + endAnnotation: function CanvasGraphics_endAnnotation() { + this.restore(); + }, + + paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) { + var domImage = this.objs.get(objId); + if (!domImage) { + warn('Dependent image isn\'t ready yet'); + return; + } + + this.save(); + + var ctx = this.ctx; + // scale the image to the unit square + ctx.scale(1 / w, -1 / h); + + ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, + 0, -h, w, h); + if (this.imageLayer) { + var currentTransform = ctx.mozCurrentTransformInverse; + var position = this.getCanvasPosition(0, 0); + this.imageLayer.appendImage({ + objId: objId, + left: position[0], + top: position[1], + width: w / currentTransform[0], + height: h / currentTransform[3] + }); + } + this.restore(); + }, + + paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) { + var ctx = this.ctx; + var width = img.width, height = img.height; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + + var glyph = this.processingType3; + + if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) { + if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) { + glyph.compiled = + compileType3Glyph({data: img.data, width: width, height: height}); + } else { + glyph.compiled = null; + } + } + + if (glyph && glyph.compiled) { + glyph.compiled(ctx); + return; + } + + var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', + width, height); + var maskCtx = maskCanvas.context; + maskCtx.save(); + + putBinaryImageMask(maskCtx, img); + + maskCtx.globalCompositeOperation = 'source-in'; + + maskCtx.fillStyle = isPatternFill ? + fillColor.getPattern(maskCtx, this) : fillColor; + maskCtx.fillRect(0, 0, width, height); + + maskCtx.restore(); + + this.paintInlineImageXObject(maskCanvas.canvas); + }, + + paintImageMaskXObjectRepeat: + function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, + scaleY, positions) { + var width = imgData.width; + var height = imgData.height; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + + var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', + width, height); + var maskCtx = maskCanvas.context; + maskCtx.save(); + + putBinaryImageMask(maskCtx, imgData); + + maskCtx.globalCompositeOperation = 'source-in'; + + maskCtx.fillStyle = isPatternFill ? + fillColor.getPattern(maskCtx, this) : fillColor; + maskCtx.fillRect(0, 0, width, height); + + maskCtx.restore(); + + var ctx = this.ctx; + for (var i = 0, ii = positions.length; i < ii; i += 2) { + ctx.save(); + ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]); + ctx.scale(1, -1); + ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, + 0, -1, 1, 1); + ctx.restore(); + } + }, + + paintImageMaskXObjectGroup: + function CanvasGraphics_paintImageMaskXObjectGroup(images) { + var ctx = this.ctx; + + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + for (var i = 0, ii = images.length; i < ii; i++) { + var image = images[i]; + var width = image.width, height = image.height; + + var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', + width, height); + var maskCtx = maskCanvas.context; + maskCtx.save(); + + putBinaryImageMask(maskCtx, image); + + maskCtx.globalCompositeOperation = 'source-in'; + + maskCtx.fillStyle = isPatternFill ? + fillColor.getPattern(maskCtx, this) : fillColor; + maskCtx.fillRect(0, 0, width, height); + + maskCtx.restore(); + + ctx.save(); + ctx.transform.apply(ctx, image.transform); + ctx.scale(1, -1); + ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, + 0, -1, 1, 1); + ctx.restore(); + } + }, + + paintImageXObject: function CanvasGraphics_paintImageXObject(objId) { + var imgData = this.objs.get(objId); + if (!imgData) { + warn('Dependent image isn\'t ready yet'); + return; + } + + this.paintInlineImageXObject(imgData); + }, + + paintImageXObjectRepeat: + function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, + positions) { + var imgData = this.objs.get(objId); + if (!imgData) { + warn('Dependent image isn\'t ready yet'); + return; + } + + var width = imgData.width; + var height = imgData.height; + var map = []; + for (var i = 0, ii = positions.length; i < ii; i += 2) { + map.push({transform: [scaleX, 0, 0, scaleY, positions[i], + positions[i + 1]], x: 0, y: 0, w: width, h: height}); + } + this.paintInlineImageXObjectGroup(imgData, map); + }, + + paintInlineImageXObject: + function CanvasGraphics_paintInlineImageXObject(imgData) { + var width = imgData.width; + var height = imgData.height; + var ctx = this.ctx; + + this.save(); + // scale the image to the unit square + ctx.scale(1 / width, -1 / height); + + var currentTransform = ctx.mozCurrentTransformInverse; + var a = currentTransform[0], b = currentTransform[1]; + var widthScale = Math.max(Math.sqrt(a * a + b * b), 1); + var c = currentTransform[2], d = currentTransform[3]; + var heightScale = Math.max(Math.sqrt(c * c + d * d), 1); + + var imgToPaint, tmpCanvas; + // instanceof HTMLElement does not work in jsdom node.js module + if (imgData instanceof HTMLElement || !imgData.data) { + imgToPaint = imgData; + } else { + tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', + width, height); + var tmpCtx = tmpCanvas.context; + putBinaryImageData(tmpCtx, imgData); + imgToPaint = tmpCanvas.canvas; + } + + var paintWidth = width, paintHeight = height; + var tmpCanvasId = 'prescale1'; + // Vertial or horizontal scaling shall not be more than 2 to not loose the + // pixels during drawImage operation, painting on the temporary canvas(es) + // that are twice smaller in size + while ((widthScale > 2 && paintWidth > 1) || + (heightScale > 2 && paintHeight > 1)) { + var newWidth = paintWidth, newHeight = paintHeight; + if (widthScale > 2 && paintWidth > 1) { + newWidth = Math.ceil(paintWidth / 2); + widthScale /= paintWidth / newWidth; + } + if (heightScale > 2 && paintHeight > 1) { + newHeight = Math.ceil(paintHeight / 2); + heightScale /= paintHeight / newHeight; + } + tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, + newWidth, newHeight); + tmpCtx = tmpCanvas.context; + tmpCtx.clearRect(0, 0, newWidth, newHeight); + tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, + 0, 0, newWidth, newHeight); + imgToPaint = tmpCanvas.canvas; + paintWidth = newWidth; + paintHeight = newHeight; + tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1'; + } + ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, + 0, -height, width, height); + + if (this.imageLayer) { + var position = this.getCanvasPosition(0, -height); + this.imageLayer.appendImage({ + imgData: imgData, + left: position[0], + top: position[1], + width: width / currentTransform[0], + height: height / currentTransform[3] + }); + } + this.restore(); + }, + + paintInlineImageXObjectGroup: + function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) { + var ctx = this.ctx; + var w = imgData.width; + var h = imgData.height; + + var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h); + var tmpCtx = tmpCanvas.context; + putBinaryImageData(tmpCtx, imgData); + + for (var i = 0, ii = map.length; i < ii; i++) { + var entry = map[i]; + ctx.save(); + ctx.transform.apply(ctx, entry.transform); + ctx.scale(1, -1); + ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, + 0, -1, 1, 1); + if (this.imageLayer) { + var position = this.getCanvasPosition(entry.x, entry.y); + this.imageLayer.appendImage({ + imgData: imgData, + left: position[0], + top: position[1], + width: w, + height: h + }); + } + ctx.restore(); + } + }, + + paintSolidColorImageMask: + function CanvasGraphics_paintSolidColorImageMask() { + this.ctx.fillRect(0, 0, 1, 1); + }, + + paintXObject: function CanvasGraphics_paintXObject() { + warn('Unsupported \'paintXObject\' command.'); + }, + + // Marked content + + markPoint: function CanvasGraphics_markPoint(tag) { + // TODO Marked content. + }, + markPointProps: function CanvasGraphics_markPointProps(tag, properties) { + // TODO Marked content. + }, + beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) { + // TODO Marked content. + }, + beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps( + tag, properties) { + // TODO Marked content. + }, + endMarkedContent: function CanvasGraphics_endMarkedContent() { + // TODO Marked content. + }, + + // Compatibility + + beginCompat: function CanvasGraphics_beginCompat() { + // TODO ignore undefined operators (should we do that anyway?) + }, + endCompat: function CanvasGraphics_endCompat() { + // TODO stop ignoring undefined operators + }, + + // Helper functions + + consumePath: function CanvasGraphics_consumePath() { + var ctx = this.ctx; + if (this.pendingClip) { + if (this.pendingClip === EO_CLIP) { + if (ctx.mozFillRule !== undefined) { + ctx.mozFillRule = 'evenodd'; + ctx.clip(); + ctx.mozFillRule = 'nonzero'; + } else { + ctx.clip('evenodd'); + } + } else { + ctx.clip(); + } + this.pendingClip = null; + } + ctx.beginPath(); + }, + getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { + if (this.cachedGetSinglePixelWidth === null) { + var inverse = this.ctx.mozCurrentTransformInverse; + // max of the current horizontal and vertical scale + this.cachedGetSinglePixelWidth = Math.sqrt(Math.max( + (inverse[0] * inverse[0] + inverse[1] * inverse[1]), + (inverse[2] * inverse[2] + inverse[3] * inverse[3]))); + } + return this.cachedGetSinglePixelWidth; + }, + getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { + var transform = this.ctx.mozCurrentTransform; + return [ + transform[0] * x + transform[2] * y + transform[4], + transform[1] * x + transform[3] * y + transform[5] + ]; + } + }; + + for (var op in OPS) { + CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op]; + } + + return CanvasGraphics; +})(); + +exports.CanvasGraphics = CanvasGraphics; +exports.createScratchCanvas = createScratchCanvas; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, + root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils); + } +}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, + displayMetadata, displayDOMUtils, amdRequire) { + +var InvalidPDFException = sharedUtil.InvalidPDFException; +var MessageHandler = sharedUtil.MessageHandler; +var MissingPDFException = sharedUtil.MissingPDFException; +var PageViewport = sharedUtil.PageViewport; +var PasswordResponses = sharedUtil.PasswordResponses; +var PasswordException = sharedUtil.PasswordException; +var StatTimer = sharedUtil.StatTimer; +var UnexpectedResponseException = sharedUtil.UnexpectedResponseException; +var UnknownErrorException = sharedUtil.UnknownErrorException; +var Util = sharedUtil.Util; +var createPromiseCapability = sharedUtil.createPromiseCapability; +var error = sharedUtil.error; +var deprecated = sharedUtil.deprecated; +var getVerbosityLevel = sharedUtil.getVerbosityLevel; +var info = sharedUtil.info; +var isArrayBuffer = sharedUtil.isArrayBuffer; +var isSameOrigin = sharedUtil.isSameOrigin; +var loadJpegStream = sharedUtil.loadJpegStream; +var stringToBytes = sharedUtil.stringToBytes; +var globalScope = sharedUtil.globalScope; +var warn = sharedUtil.warn; +var FontFaceObject = displayFontLoader.FontFaceObject; +var FontLoader = displayFontLoader.FontLoader; +var CanvasGraphics = displayCanvas.CanvasGraphics; +var createScratchCanvas = displayCanvas.createScratchCanvas; +var Metadata = displayMetadata.Metadata; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; + +var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536 + +var isWorkerDisabled = false; +var workerSrc; +var isPostMessageTransfersDisabled = false; + + +var useRequireEnsure = false; +if (typeof window === 'undefined') { + // node.js - disable worker and set require.ensure. + isWorkerDisabled = true; + if (typeof require.ensure === 'undefined') { + require.ensure = require('node-ensure'); + } + useRequireEnsure = true; +} +if (typeof __webpack_require__ !== 'undefined') { + useRequireEnsure = true; +} +if (typeof requirejs !== 'undefined' && requirejs.toUrl) { + workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js'); +} +var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load; +var fakeWorkerFilesLoader = useRequireEnsure ? (function (callback) { + require.ensure([], function () { + var worker = require('./pdf.worker.js'); + callback(worker.WorkerMessageHandler); + }); +}) : dynamicLoaderSupported ? (function (callback) { + requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) { + callback(worker.WorkerMessageHandler); + }); +}) : null; + + +/** + * Document initialization / loading parameters object. + * + * @typedef {Object} DocumentInitParameters + * @property {string} url - The URL of the PDF. + * @property {TypedArray|Array|string} data - Binary PDF data. Use typed arrays + * (Uint8Array) to improve the memory usage. If PDF data is BASE64-encoded, + * use atob() to convert it to a binary string first. + * @property {Object} httpHeaders - Basic authentication headers. + * @property {boolean} withCredentials - Indicates whether or not cross-site + * Access-Control requests should be made using credentials such as cookies + * or authorization headers. The default is false. + * @property {string} password - For decrypting password-protected PDFs. + * @property {TypedArray} initialData - A typed array with the first portion or + * all of the pdf data. Used by the extension since some data is already + * loaded before the switch to range requests. + * @property {number} length - The PDF file length. It's used for progress + * reports and range requests operations. + * @property {PDFDataRangeTransport} range + * @property {number} rangeChunkSize - Optional parameter to specify + * maximum number of bytes fetched per range request. The default value is + * 2^16 = 65536. + * @property {PDFWorker} worker - The worker that will be used for the loading + * and parsing of the PDF data. + */ + +/** + * @typedef {Object} PDFDocumentStats + * @property {Array} streamTypes - Used stream types in the document (an item + * is set to true if specific stream ID was used in the document). + * @property {Array} fontTypes - Used font type in the document (an item is set + * to true if specific font ID was used in the document). + */ + +/** + * This is the main entry point for loading a PDF and interacting with it. + * NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR) + * is used, which means it must follow the same origin rules that any XHR does + * e.g. No cross domain requests without CORS. + * + * @param {string|TypedArray|DocumentInitParameters|PDFDataRangeTransport} src + * Can be a url to where a PDF is located, a typed array (Uint8Array) + * already populated with data or parameter object. + * + * @param {PDFDataRangeTransport} pdfDataRangeTransport (deprecated) It is used + * if you want to manually serve range requests for data in the PDF. + * + * @param {function} passwordCallback (deprecated) It is used to request a + * password if wrong or no password was provided. The callback receives two + * parameters: function that needs to be called with new password and reason + * (see {PasswordResponses}). + * + * @param {function} progressCallback (deprecated) It is used to be able to + * monitor the loading progress of the PDF file (necessary to implement e.g. + * a loading bar). The callback receives an {Object} with the properties: + * {number} loaded and {number} total. + * + * @return {PDFDocumentLoadingTask} + */ +function getDocument(src, pdfDataRangeTransport, + passwordCallback, progressCallback) { + var task = new PDFDocumentLoadingTask(); + + // Support of the obsolete arguments (for compatibility with API v1.0) + if (arguments.length > 1) { + deprecated('getDocument is called with pdfDataRangeTransport, ' + + 'passwordCallback or progressCallback argument'); + } + if (pdfDataRangeTransport) { + if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) { + // Not a PDFDataRangeTransport instance, trying to add missing properties. + pdfDataRangeTransport = Object.create(pdfDataRangeTransport); + pdfDataRangeTransport.length = src.length; + pdfDataRangeTransport.initialData = src.initialData; + if (!pdfDataRangeTransport.abort) { + pdfDataRangeTransport.abort = function () {}; + } + } + src = Object.create(src); + src.range = pdfDataRangeTransport; + } + task.onPassword = passwordCallback || null; + task.onProgress = progressCallback || null; + + var source; + if (typeof src === 'string') { + source = { url: src }; + } else if (isArrayBuffer(src)) { + source = { data: src }; + } else if (src instanceof PDFDataRangeTransport) { + source = { range: src }; + } else { + if (typeof src !== 'object') { + error('Invalid parameter in getDocument, need either Uint8Array, ' + + 'string or a parameter object'); + } + if (!src.url && !src.data && !src.range) { + error('Invalid parameter object: need either .data, .range or .url'); + } + + source = src; + } + + var params = {}; + var rangeTransport = null; + var worker = null; + for (var key in source) { + if (key === 'url' && typeof window !== 'undefined') { + // The full path is required in the 'url' field. + params[key] = new URL(source[key], window.location).href; + continue; + } else if (key === 'range') { + rangeTransport = source[key]; + continue; + } else if (key === 'worker') { + worker = source[key]; + continue; + } else if (key === 'data' && !(source[key] instanceof Uint8Array)) { + // Converting string or array-like data to Uint8Array. + var pdfBytes = source[key]; + if (typeof pdfBytes === 'string') { + params[key] = stringToBytes(pdfBytes); + } else if (typeof pdfBytes === 'object' && pdfBytes !== null && + !isNaN(pdfBytes.length)) { + params[key] = new Uint8Array(pdfBytes); + } else if (isArrayBuffer(pdfBytes)) { + params[key] = new Uint8Array(pdfBytes); + } else { + error('Invalid PDF binary data: either typed array, string or ' + + 'array-like object is expected in the data property.'); + } + continue; + } + params[key] = source[key]; + } + + params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; + + if (!worker) { + // Worker was not provided -- creating and owning our own. + worker = new PDFWorker(); + task._worker = worker; + } + var docId = task.docId; + worker.promise.then(function () { + if (task.destroyed) { + throw new Error('Loading aborted'); + } + return _fetchDocument(worker, params, rangeTransport, docId).then( + function (workerId) { + if (task.destroyed) { + throw new Error('Loading aborted'); + } + var messageHandler = new MessageHandler(docId, workerId, worker.port); + var transport = new WorkerTransport(messageHandler, task, rangeTransport); + task._transport = transport; + messageHandler.send('Ready', null); + }); + }).catch(task._capability.reject); + + return task; +} + +/** + * Starts fetching of specified PDF document/data. + * @param {PDFWorker} worker + * @param {Object} source + * @param {PDFDataRangeTransport} pdfDataRangeTransport + * @param {string} docId Unique document id, used as MessageHandler id. + * @returns {Promise} The promise, which is resolved when worker id of + * MessageHandler is known. + * @private + */ +function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { + if (worker.destroyed) { + return Promise.reject(new Error('Worker was destroyed')); + } + + source.disableAutoFetch = getDefaultSetting('disableAutoFetch'); + source.disableStream = getDefaultSetting('disableStream'); + source.chunkedViewerLoading = !!pdfDataRangeTransport; + if (pdfDataRangeTransport) { + source.length = pdfDataRangeTransport.length; + source.initialData = pdfDataRangeTransport.initialData; + } + return worker.messageHandler.sendWithPromise('GetDocRequest', { + docId: docId, + source: source, + disableRange: getDefaultSetting('disableRange'), + maxImageSize: getDefaultSetting('maxImageSize'), + cMapUrl: getDefaultSetting('cMapUrl'), + cMapPacked: getDefaultSetting('cMapPacked'), + disableFontFace: getDefaultSetting('disableFontFace'), + disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'), + postMessageTransfers: getDefaultSetting('postMessageTransfers') && + !isPostMessageTransfersDisabled, + }).then(function (workerId) { + if (worker.destroyed) { + throw new Error('Worker was destroyed'); + } + return workerId; + }); +} + +/** + * PDF document loading operation. + * @class + * @alias PDFDocumentLoadingTask + */ +var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { + var nextDocumentId = 0; + + /** @constructs PDFDocumentLoadingTask */ + function PDFDocumentLoadingTask() { + this._capability = createPromiseCapability(); + this._transport = null; + this._worker = null; + + /** + * Unique document loading task id -- used in MessageHandlers. + * @type {string} + */ + this.docId = 'd' + (nextDocumentId++); + + /** + * Shows if loading task is destroyed. + * @type {boolean} + */ + this.destroyed = false; + + /** + * Callback to request a password if wrong or no password was provided. + * The callback receives two parameters: function that needs to be called + * with new password and reason (see {PasswordResponses}). + */ + this.onPassword = null; + + /** + * Callback to be able to monitor the loading progress of the PDF file + * (necessary to implement e.g. a loading bar). The callback receives + * an {Object} with the properties: {number} loaded and {number} total. + */ + this.onProgress = null; + + /** + * Callback to when unsupported feature is used. The callback receives + * an {UNSUPPORTED_FEATURES} argument. + */ + this.onUnsupportedFeature = null; + } + + PDFDocumentLoadingTask.prototype = + /** @lends PDFDocumentLoadingTask.prototype */ { + /** + * @return {Promise} + */ + get promise() { + return this._capability.promise; + }, + + /** + * Aborts all network requests and destroys worker. + * @return {Promise} A promise that is resolved after destruction activity + * is completed. + */ + destroy: function () { + this.destroyed = true; + + var transportDestroyed = !this._transport ? Promise.resolve() : + this._transport.destroy(); + return transportDestroyed.then(function () { + this._transport = null; + if (this._worker) { + this._worker.destroy(); + this._worker = null; + } + }.bind(this)); + }, + + /** + * Registers callbacks to indicate the document loading completion. + * + * @param {function} onFulfilled The callback for the loading completion. + * @param {function} onRejected The callback for the loading failure. + * @return {Promise} A promise that is resolved after the onFulfilled or + * onRejected callback. + */ + then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) { + return this.promise.then.apply(this.promise, arguments); + } + }; + + return PDFDocumentLoadingTask; +})(); + +/** + * Abstract class to support range requests file loading. + * @class + * @alias PDFDataRangeTransport + * @param {number} length + * @param {Uint8Array} initialData + */ +var PDFDataRangeTransport = (function pdfDataRangeTransportClosure() { + function PDFDataRangeTransport(length, initialData) { + this.length = length; + this.initialData = initialData; + + this._rangeListeners = []; + this._progressListeners = []; + this._progressiveReadListeners = []; + this._readyCapability = createPromiseCapability(); + } + PDFDataRangeTransport.prototype = + /** @lends PDFDataRangeTransport.prototype */ { + addRangeListener: + function PDFDataRangeTransport_addRangeListener(listener) { + this._rangeListeners.push(listener); + }, + + addProgressListener: + function PDFDataRangeTransport_addProgressListener(listener) { + this._progressListeners.push(listener); + }, + + addProgressiveReadListener: + function PDFDataRangeTransport_addProgressiveReadListener(listener) { + this._progressiveReadListeners.push(listener); + }, + + onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) { + var listeners = this._rangeListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](begin, chunk); + } + }, + + onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) { + this._readyCapability.promise.then(function () { + var listeners = this._progressListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](loaded); + } + }.bind(this)); + }, + + onDataProgressiveRead: + function PDFDataRangeTransport_onDataProgress(chunk) { + this._readyCapability.promise.then(function () { + var listeners = this._progressiveReadListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](chunk); + } + }.bind(this)); + }, + + transportReady: function PDFDataRangeTransport_transportReady() { + this._readyCapability.resolve(); + }, + + requestDataRange: + function PDFDataRangeTransport_requestDataRange(begin, end) { + throw new Error('Abstract method PDFDataRangeTransport.requestDataRange'); + }, + + abort: function PDFDataRangeTransport_abort() { + } + }; + return PDFDataRangeTransport; +})(); + +/** + * Proxy to a PDFDocument in the worker thread. Also, contains commonly used + * properties that can be read synchronously. + * @class + * @alias PDFDocumentProxy + */ +var PDFDocumentProxy = (function PDFDocumentProxyClosure() { + function PDFDocumentProxy(pdfInfo, transport, loadingTask) { + this.pdfInfo = pdfInfo; + this.transport = transport; + this.loadingTask = loadingTask; + } + PDFDocumentProxy.prototype = /** @lends PDFDocumentProxy.prototype */ { + /** + * @return {number} Total number of pages the PDF contains. + */ + get numPages() { + return this.pdfInfo.numPages; + }, + /** + * @return {string} A unique ID to identify a PDF. Not guaranteed to be + * unique. + */ + get fingerprint() { + return this.pdfInfo.fingerprint; + }, + /** + * @param {number} pageNumber The page number to get. The first page is 1. + * @return {Promise} A promise that is resolved with a {@link PDFPageProxy} + * object. + */ + getPage: function PDFDocumentProxy_getPage(pageNumber) { + return this.transport.getPage(pageNumber); + }, + /** + * @param {{num: number, gen: number}} ref The page reference. Must have + * the 'num' and 'gen' properties. + * @return {Promise} A promise that is resolved with the page index that is + * associated with the reference. + */ + getPageIndex: function PDFDocumentProxy_getPageIndex(ref) { + return this.transport.getPageIndex(ref); + }, + /** + * @return {Promise} A promise that is resolved with a lookup table for + * mapping named destinations to reference numbers. + * + * This can be slow for large documents: use getDestination instead + */ + getDestinations: function PDFDocumentProxy_getDestinations() { + return this.transport.getDestinations(); + }, + /** + * @param {string} id The named destination to get. + * @return {Promise} A promise that is resolved with all information + * of the given named destination. + */ + getDestination: function PDFDocumentProxy_getDestination(id) { + return this.transport.getDestination(id); + }, + /** + * @return {Promise} A promise that is resolved with: + * an Array containing the pageLabels that correspond to the pageIndexes, + * or `null` when no pageLabels are present in the PDF file. + */ + getPageLabels: function PDFDocumentProxy_getPageLabels() { + return this.transport.getPageLabels(); + }, + /** + * @return {Promise} A promise that is resolved with a lookup table for + * mapping named attachments to their content. + */ + getAttachments: function PDFDocumentProxy_getAttachments() { + return this.transport.getAttachments(); + }, + /** + * @return {Promise} A promise that is resolved with an array of all the + * JavaScript strings in the name tree. + */ + getJavaScript: function PDFDocumentProxy_getJavaScript() { + return this.transport.getJavaScript(); + }, + /** + * @return {Promise} A promise that is resolved with an {Array} that is a + * tree outline (if it has one) of the PDF. The tree is in the format of: + * [ + * { + * title: string, + * bold: boolean, + * italic: boolean, + * color: rgb Uint8Array, + * dest: dest obj, + * url: string, + * items: array of more items like this + * }, + * ... + * ]. + */ + getOutline: function PDFDocumentProxy_getOutline() { + return this.transport.getOutline(); + }, + /** + * @return {Promise} A promise that is resolved with an {Object} that has + * info and metadata properties. Info is an {Object} filled with anything + * available in the information dictionary and similarly metadata is a + * {Metadata} object with information from the metadata section of the PDF. + */ + getMetadata: function PDFDocumentProxy_getMetadata() { + return this.transport.getMetadata(); + }, + /** + * @return {Promise} A promise that is resolved with a TypedArray that has + * the raw data from the PDF. + */ + getData: function PDFDocumentProxy_getData() { + return this.transport.getData(); + }, + /** + * @return {Promise} A promise that is resolved when the document's data + * is loaded. It is resolved with an {Object} that contains the length + * property that indicates size of the PDF data in bytes. + */ + getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() { + return this.transport.downloadInfoCapability.promise; + }, + /** + * @return {Promise} A promise this is resolved with current stats about + * document structures (see {@link PDFDocumentStats}). + */ + getStats: function PDFDocumentProxy_getStats() { + return this.transport.getStats(); + }, + /** + * Cleans up resources allocated by the document, e.g. created @font-face. + */ + cleanup: function PDFDocumentProxy_cleanup() { + this.transport.startCleanup(); + }, + /** + * Destroys current document instance and terminates worker. + */ + destroy: function PDFDocumentProxy_destroy() { + return this.loadingTask.destroy(); + } + }; + return PDFDocumentProxy; +})(); + +/** + * Page getTextContent parameters. + * + * @typedef {Object} getTextContentParameters + * @param {boolean} normalizeWhitespace - replaces all occurrences of + * whitespace with standard spaces (0x20). The default value is `false`. + */ + +/** + * Page text content. + * + * @typedef {Object} TextContent + * @property {array} items - array of {@link TextItem} + * @property {Object} styles - {@link TextStyles} objects, indexed by font + * name. + */ + +/** + * Page text content part. + * + * @typedef {Object} TextItem + * @property {string} str - text content. + * @property {string} dir - text direction: 'ttb', 'ltr' or 'rtl'. + * @property {array} transform - transformation matrix. + * @property {number} width - width in device space. + * @property {number} height - height in device space. + * @property {string} fontName - font name used by pdf.js for converted font. + */ + +/** + * Text style. + * + * @typedef {Object} TextStyle + * @property {number} ascent - font ascent. + * @property {number} descent - font descent. + * @property {boolean} vertical - text is in vertical mode. + * @property {string} fontFamily - possible font family + */ + +/** + * Page annotation parameters. + * + * @typedef {Object} GetAnnotationsParameters + * @param {string} intent - Determines the annotations that will be fetched, + * can be either 'display' (viewable annotations) or 'print' + * (printable annotations). + * If the parameter is omitted, all annotations are fetched. + */ + +/** + * Page render parameters. + * + * @typedef {Object} RenderParameters + * @property {Object} canvasContext - A 2D context of a DOM Canvas object. + * @property {PageViewport} viewport - Rendering viewport obtained by + * calling of PDFPage.getViewport method. + * @property {string} intent - Rendering intent, can be 'display' or 'print' + * (default value is 'display'). + * @property {Array} transform - (optional) Additional transform, applied + * just before viewport transform. + * @property {Object} imageLayer - (optional) An object that has beginLayout, + * endLayout and appendImage functions. + * @property {function} continueCallback - (deprecated) A function that will be + * called each time the rendering is paused. To continue + * rendering call the function that is the first argument + * to the callback. + */ + +/** + * PDF page operator list. + * + * @typedef {Object} PDFOperatorList + * @property {Array} fnArray - Array containing the operator functions. + * @property {Array} argsArray - Array containing the arguments of the + * functions. + */ + +/** + * Proxy to a PDFPage in the worker thread. + * @class + * @alias PDFPageProxy + */ +var PDFPageProxy = (function PDFPageProxyClosure() { + function PDFPageProxy(pageIndex, pageInfo, transport) { + this.pageIndex = pageIndex; + this.pageInfo = pageInfo; + this.transport = transport; + this.stats = new StatTimer(); + this.stats.enabled = getDefaultSetting('enableStats'); + this.commonObjs = transport.commonObjs; + this.objs = new PDFObjects(); + this.cleanupAfterRender = false; + this.pendingCleanup = false; + this.intentStates = Object.create(null); + this.destroyed = false; + } + PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ { + /** + * @return {number} Page number of the page. First page is 1. + */ + get pageNumber() { + return this.pageIndex + 1; + }, + /** + * @return {number} The number of degrees the page is rotated clockwise. + */ + get rotate() { + return this.pageInfo.rotate; + }, + /** + * @return {Object} The reference that points to this page. It has 'num' and + * 'gen' properties. + */ + get ref() { + return this.pageInfo.ref; + }, + /** + * @return {Array} An array of the visible portion of the PDF page in the + * user space units - [x1, y1, x2, y2]. + */ + get view() { + return this.pageInfo.view; + }, + /** + * @param {number} scale The desired scale of the viewport. + * @param {number} rotate Degrees to rotate the viewport. If omitted this + * defaults to the page rotation. + * @return {PageViewport} Contains 'width' and 'height' properties + * along with transforms required for rendering. + */ + getViewport: function PDFPageProxy_getViewport(scale, rotate) { + if (arguments.length < 2) { + rotate = this.rotate; + } + return new PageViewport(this.view, scale, rotate, 0, 0); + }, + /** + * @param {GetAnnotationsParameters} params - Annotation parameters. + * @return {Promise} A promise that is resolved with an {Array} of the + * annotation objects. + */ + getAnnotations: function PDFPageProxy_getAnnotations(params) { + var intent = (params && params.intent) || null; + + if (!this.annotationsPromise || this.annotationsIntent !== intent) { + this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, + intent); + this.annotationsIntent = intent; + } + return this.annotationsPromise; + }, + /** + * Begins the process of rendering a page to the desired context. + * @param {RenderParameters} params Page render parameters. + * @return {RenderTask} An object that contains the promise, which + * is resolved when the page finishes rendering. + */ + render: function PDFPageProxy_render(params) { + var stats = this.stats; + stats.time('Overall'); + + // If there was a pending destroy cancel it so no cleanup happens during + // this call to render. + this.pendingCleanup = false; + + var renderingIntent = (params.intent === 'print' ? 'print' : 'display'); + + if (!this.intentStates[renderingIntent]) { + this.intentStates[renderingIntent] = Object.create(null); + } + var intentState = this.intentStates[renderingIntent]; + + // If there's no displayReadyCapability yet, then the operatorList + // was never requested before. Make the request and create the promise. + if (!intentState.displayReadyCapability) { + intentState.receivingOperatorList = true; + intentState.displayReadyCapability = createPromiseCapability(); + intentState.operatorList = { + fnArray: [], + argsArray: [], + lastChunk: false + }; + + this.stats.time('Page Request'); + this.transport.messageHandler.send('RenderPageRequest', { + pageIndex: this.pageNumber - 1, + intent: renderingIntent + }); + } + + var internalRenderTask = new InternalRenderTask(complete, params, + this.objs, + this.commonObjs, + intentState.operatorList, + this.pageNumber); + internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print'; + if (!intentState.renderTasks) { + intentState.renderTasks = []; + } + intentState.renderTasks.push(internalRenderTask); + var renderTask = internalRenderTask.task; + + // Obsolete parameter support + if (params.continueCallback) { + deprecated('render is used with continueCallback parameter'); + renderTask.onContinue = params.continueCallback; + } + + var self = this; + intentState.displayReadyCapability.promise.then( + function pageDisplayReadyPromise(transparency) { + if (self.pendingCleanup) { + complete(); + return; + } + stats.time('Rendering'); + internalRenderTask.initializeGraphics(transparency); + internalRenderTask.operatorListChanged(); + }, + function pageDisplayReadPromiseError(reason) { + complete(reason); + } + ); + + function complete(error) { + var i = intentState.renderTasks.indexOf(internalRenderTask); + if (i >= 0) { + intentState.renderTasks.splice(i, 1); + } + + if (self.cleanupAfterRender) { + self.pendingCleanup = true; + } + self._tryCleanup(); + + if (error) { + internalRenderTask.capability.reject(error); + } else { + internalRenderTask.capability.resolve(); + } + stats.timeEnd('Rendering'); + stats.timeEnd('Overall'); + } + + return renderTask; + }, + + /** + * @return {Promise} A promise resolved with an {@link PDFOperatorList} + * object that represents page's operator list. + */ + getOperatorList: function PDFPageProxy_getOperatorList() { + function operatorListChanged() { + if (intentState.operatorList.lastChunk) { + intentState.opListReadCapability.resolve(intentState.operatorList); + + var i = intentState.renderTasks.indexOf(opListTask); + if (i >= 0) { + intentState.renderTasks.splice(i, 1); + } + } + } + + var renderingIntent = 'oplist'; + if (!this.intentStates[renderingIntent]) { + this.intentStates[renderingIntent] = Object.create(null); + } + var intentState = this.intentStates[renderingIntent]; + var opListTask; + + if (!intentState.opListReadCapability) { + opListTask = {}; + opListTask.operatorListChanged = operatorListChanged; + intentState.receivingOperatorList = true; + intentState.opListReadCapability = createPromiseCapability(); + intentState.renderTasks = []; + intentState.renderTasks.push(opListTask); + intentState.operatorList = { + fnArray: [], + argsArray: [], + lastChunk: false + }; + + this.transport.messageHandler.send('RenderPageRequest', { + pageIndex: this.pageIndex, + intent: renderingIntent + }); + } + return intentState.opListReadCapability.promise; + }, + + /** + * @param {getTextContentParameters} params - getTextContent parameters. + * @return {Promise} That is resolved a {@link TextContent} + * object that represent the page text content. + */ + getTextContent: function PDFPageProxy_getTextContent(params) { + var normalizeWhitespace = (params && params.normalizeWhitespace) || false; + + return this.transport.messageHandler.sendWithPromise('GetTextContent', { + pageIndex: this.pageNumber - 1, + normalizeWhitespace: normalizeWhitespace, + }); + }, + + /** + * Destroys page object. + */ + _destroy: function PDFPageProxy_destroy() { + this.destroyed = true; + this.transport.pageCache[this.pageIndex] = null; + + var waitOn = []; + Object.keys(this.intentStates).forEach(function(intent) { + if (intent === 'oplist') { + // Avoid errors below, since the renderTasks are just stubs. + return; + } + var intentState = this.intentStates[intent]; + intentState.renderTasks.forEach(function(renderTask) { + var renderCompleted = renderTask.capability.promise. + catch(function () {}); // ignoring failures + waitOn.push(renderCompleted); + renderTask.cancel(); + }); + }, this); + this.objs.clear(); + this.annotationsPromise = null; + this.pendingCleanup = false; + return Promise.all(waitOn); + }, + + /** + * Cleans up resources allocated by the page. (deprecated) + */ + destroy: function() { + deprecated('page destroy method, use cleanup() instead'); + this.cleanup(); + }, + + /** + * Cleans up resources allocated by the page. + */ + cleanup: function PDFPageProxy_cleanup() { + this.pendingCleanup = true; + this._tryCleanup(); + }, + /** + * For internal use only. Attempts to clean up if rendering is in a state + * where that's possible. + * @ignore + */ + _tryCleanup: function PDFPageProxy_tryCleanup() { + if (!this.pendingCleanup || + Object.keys(this.intentStates).some(function(intent) { + var intentState = this.intentStates[intent]; + return (intentState.renderTasks.length !== 0 || + intentState.receivingOperatorList); + }, this)) { + return; + } + + Object.keys(this.intentStates).forEach(function(intent) { + delete this.intentStates[intent]; + }, this); + this.objs.clear(); + this.annotationsPromise = null; + this.pendingCleanup = false; + }, + /** + * For internal use only. + * @ignore + */ + _startRenderPage: function PDFPageProxy_startRenderPage(transparency, + intent) { + var intentState = this.intentStates[intent]; + // TODO Refactor RenderPageRequest to separate rendering + // and operator list logic + if (intentState.displayReadyCapability) { + intentState.displayReadyCapability.resolve(transparency); + } + }, + /** + * For internal use only. + * @ignore + */ + _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, + intent) { + var intentState = this.intentStates[intent]; + var i, ii; + // Add the new chunk to the current operator list. + for (i = 0, ii = operatorListChunk.length; i < ii; i++) { + intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]); + intentState.operatorList.argsArray.push( + operatorListChunk.argsArray[i]); + } + intentState.operatorList.lastChunk = operatorListChunk.lastChunk; + + // Notify all the rendering tasks there are more operators to be consumed. + for (i = 0; i < intentState.renderTasks.length; i++) { + intentState.renderTasks[i].operatorListChanged(); + } + + if (operatorListChunk.lastChunk) { + intentState.receivingOperatorList = false; + this._tryCleanup(); + } + } + }; + return PDFPageProxy; +})(); + +/** + * PDF.js web worker abstraction, it controls instantiation of PDF documents and + * WorkerTransport for them. If creation of a web worker is not possible, + * a "fake" worker will be used instead. + * @class + */ +var PDFWorker = (function PDFWorkerClosure() { + var nextFakeWorkerId = 0; + + function getWorkerSrc() { + if (typeof workerSrc !== 'undefined') { + return workerSrc; + } + if (getDefaultSetting('workerSrc')) { + return getDefaultSetting('workerSrc'); + } + if (pdfjsFilePath) { + return pdfjsFilePath.replace(/\.js$/i, '.worker.js'); + } + error('No PDFJS.workerSrc specified'); + } + + var fakeWorkerFilesLoadedCapability; + + // Loads worker code into main thread. + function setupFakeWorkerGlobal() { + var WorkerMessageHandler; + if (!fakeWorkerFilesLoadedCapability) { + fakeWorkerFilesLoadedCapability = createPromiseCapability(); + // In the developer build load worker_loader which in turn loads all the + // other files and resolves the promise. In production only the + // pdf.worker.js file is needed. + var loader = fakeWorkerFilesLoader || function (callback) { + Util.loadScript(getWorkerSrc(), function () { + callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler); + }); + }; + loader(fakeWorkerFilesLoadedCapability.resolve); + } + return fakeWorkerFilesLoadedCapability.promise; + } + + function createCDNWrapper(url) { + // We will rely on blob URL's property to specify origin. + // We want this function to fail in case if createObjectURL or Blob do not + // exist or fail for some reason -- our Worker creation will fail anyway. + var wrapper = 'importScripts(\'' + url + '\');'; + return URL.createObjectURL(new Blob([wrapper])); + } + + function PDFWorker(name) { + this.name = name; + this.destroyed = false; + + this._readyCapability = createPromiseCapability(); + this._port = null; + this._webWorker = null; + this._messageHandler = null; + this._initialize(); + } + + PDFWorker.prototype = /** @lends PDFWorker.prototype */ { + get promise() { + return this._readyCapability.promise; + }, + + get port() { + return this._port; + }, + + get messageHandler() { + return this._messageHandler; + }, + + _initialize: function PDFWorker_initialize() { + // If worker support isn't disabled explicit and the browser has worker + // support, create a new web worker and test if it/the browser fulfills + // all requirements to run parts of pdf.js in a web worker. + // Right now, the requirement is, that an Uint8Array is still an + // Uint8Array as it arrives on the worker. (Chrome added this with v.15.) + if (!isWorkerDisabled && !getDefaultSetting('disableWorker') && + typeof Worker !== 'undefined') { + var workerSrc = getWorkerSrc(); + + try { + // Wraps workerSrc path into blob URL, if the former does not belong + // to the same origin. + if (!isSameOrigin(window.location.href, workerSrc)) { + workerSrc = createCDNWrapper( + new URL(workerSrc, window.location).href); + } + // Some versions of FF can't create a worker on localhost, see: + // https://bugzilla.mozilla.org/show_bug.cgi?id=683280 + var worker = new Worker(workerSrc); + var messageHandler = new MessageHandler('main', 'worker', worker); + var terminateEarly = function() { + worker.removeEventListener('error', onWorkerError); + messageHandler.destroy(); + worker.terminate(); + if (this.destroyed) { + this._readyCapability.reject(new Error('Worker was destroyed')); + } else { + // Fall back to fake worker if the termination is caused by an + // error (e.g. NetworkError / SecurityError). + this._setupFakeWorker(); + } + }.bind(this); + + var onWorkerError = function(event) { + if (!this._webWorker) { + // Worker failed to initialize due to an error. Clean up and fall + // back to the fake worker. + terminateEarly(); + } + }.bind(this); + worker.addEventListener('error', onWorkerError); + + messageHandler.on('test', function PDFWorker_test(data) { + worker.removeEventListener('error', onWorkerError); + if (this.destroyed) { + terminateEarly(); + return; // worker was destroyed + } + var supportTypedArray = data && data.supportTypedArray; + if (supportTypedArray) { + this._messageHandler = messageHandler; + this._port = worker; + this._webWorker = worker; + if (!data.supportTransfers) { + isPostMessageTransfersDisabled = true; + } + this._readyCapability.resolve(); + // Send global setting, e.g. verbosity level. + messageHandler.send('configure', { + verbosity: getVerbosityLevel() + }); + } else { + this._setupFakeWorker(); + messageHandler.destroy(); + worker.terminate(); + } + }.bind(this)); + + messageHandler.on('console_log', function (data) { + console.log.apply(console, data); + }); + messageHandler.on('console_error', function (data) { + console.error.apply(console, data); + }); + + messageHandler.on('ready', function (data) { + worker.removeEventListener('error', onWorkerError); + if (this.destroyed) { + terminateEarly(); + return; // worker was destroyed + } + try { + sendTest(); + } catch (e) { + // We need fallback to a faked worker. + this._setupFakeWorker(); + } + }.bind(this)); + + var sendTest = function () { + var postMessageTransfers = + getDefaultSetting('postMessageTransfers') && + !isPostMessageTransfersDisabled; + var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]); + // Some versions of Opera throw a DATA_CLONE_ERR on serializing the + // typed array. Also, checking if we can use transfers. + try { + messageHandler.send('test', testObj, [testObj.buffer]); + } catch (ex) { + info('Cannot use postMessage transfers'); + testObj[0] = 0; + messageHandler.send('test', testObj); + } + }; + + // It might take time for worker to initialize (especially when AMD + // loader is used). We will try to send test immediately, and then + // when 'ready' message will arrive. The worker shall process only + // first received 'test'. + sendTest(); + return; + } catch (e) { + info('The worker has been disabled.'); + } + } + // Either workers are disabled, not supported or have thrown an exception. + // Thus, we fallback to a faked worker. + this._setupFakeWorker(); + }, + + _setupFakeWorker: function PDFWorker_setupFakeWorker() { + if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) { + warn('Setting up fake worker.'); + isWorkerDisabled = true; + } + + setupFakeWorkerGlobal().then(function (WorkerMessageHandler) { + if (this.destroyed) { + this._readyCapability.reject(new Error('Worker was destroyed')); + return; + } + + // If we don't use a worker, just post/sendMessage to the main thread. + var port = { + _listeners: [], + postMessage: function (obj) { + var e = {data: obj}; + this._listeners.forEach(function (listener) { + listener.call(this, e); + }, this); + }, + addEventListener: function (name, listener) { + this._listeners.push(listener); + }, + removeEventListener: function (name, listener) { + var i = this._listeners.indexOf(listener); + this._listeners.splice(i, 1); + }, + terminate: function () {} + }; + this._port = port; + + // All fake workers use the same port, making id unique. + var id = 'fake' + (nextFakeWorkerId++); + + // If the main thread is our worker, setup the handling for the + // messages -- the main thread sends to it self. + var workerHandler = new MessageHandler(id + '_worker', id, port); + WorkerMessageHandler.setup(workerHandler, port); + + var messageHandler = new MessageHandler(id, id + '_worker', port); + this._messageHandler = messageHandler; + this._readyCapability.resolve(); + }.bind(this)); + }, + + /** + * Destroys the worker instance. + */ + destroy: function PDFWorker_destroy() { + this.destroyed = true; + if (this._webWorker) { + // We need to terminate only web worker created resource. + this._webWorker.terminate(); + this._webWorker = null; + } + this._port = null; + if (this._messageHandler) { + this._messageHandler.destroy(); + this._messageHandler = null; + } + } + }; + + return PDFWorker; +})(); + +/** + * For internal use only. + * @ignore + */ +var WorkerTransport = (function WorkerTransportClosure() { + function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) { + this.messageHandler = messageHandler; + this.loadingTask = loadingTask; + this.pdfDataRangeTransport = pdfDataRangeTransport; + this.commonObjs = new PDFObjects(); + this.fontLoader = new FontLoader(loadingTask.docId); + + this.destroyed = false; + this.destroyCapability = null; + + this.pageCache = []; + this.pagePromises = []; + this.downloadInfoCapability = createPromiseCapability(); + + this.setupMessageHandler(); + } + WorkerTransport.prototype = { + destroy: function WorkerTransport_destroy() { + if (this.destroyCapability) { + return this.destroyCapability.promise; + } + + this.destroyed = true; + this.destroyCapability = createPromiseCapability(); + + var waitOn = []; + // We need to wait for all renderings to be completed, e.g. + // timeout/rAF can take a long time. + this.pageCache.forEach(function (page) { + if (page) { + waitOn.push(page._destroy()); + } + }); + this.pageCache = []; + this.pagePromises = []; + var self = this; + // We also need to wait for the worker to finish its long running tasks. + var terminated = this.messageHandler.sendWithPromise('Terminate', null); + waitOn.push(terminated); + Promise.all(waitOn).then(function () { + self.fontLoader.clear(); + if (self.pdfDataRangeTransport) { + self.pdfDataRangeTransport.abort(); + self.pdfDataRangeTransport = null; + } + if (self.messageHandler) { + self.messageHandler.destroy(); + self.messageHandler = null; + } + self.destroyCapability.resolve(); + }, this.destroyCapability.reject); + return this.destroyCapability.promise; + }, + + setupMessageHandler: + function WorkerTransport_setupMessageHandler() { + var messageHandler = this.messageHandler; + + function updatePassword(password) { + messageHandler.send('UpdatePassword', password); + } + + var pdfDataRangeTransport = this.pdfDataRangeTransport; + if (pdfDataRangeTransport) { + pdfDataRangeTransport.addRangeListener(function(begin, chunk) { + messageHandler.send('OnDataRange', { + begin: begin, + chunk: chunk + }); + }); + + pdfDataRangeTransport.addProgressListener(function(loaded) { + messageHandler.send('OnDataProgress', { + loaded: loaded + }); + }); + + pdfDataRangeTransport.addProgressiveReadListener(function(chunk) { + messageHandler.send('OnDataRange', { + chunk: chunk + }); + }); + + messageHandler.on('RequestDataRange', + function transportDataRange(data) { + pdfDataRangeTransport.requestDataRange(data.begin, data.end); + }, this); + } + + messageHandler.on('GetDoc', function transportDoc(data) { + var pdfInfo = data.pdfInfo; + this.numPages = data.pdfInfo.numPages; + var loadingTask = this.loadingTask; + var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask); + this.pdfDocument = pdfDocument; + loadingTask._capability.resolve(pdfDocument); + }, this); + + messageHandler.on('NeedPassword', + function transportNeedPassword(exception) { + var loadingTask = this.loadingTask; + if (loadingTask.onPassword) { + return loadingTask.onPassword(updatePassword, + PasswordResponses.NEED_PASSWORD); + } + loadingTask._capability.reject( + new PasswordException(exception.message, exception.code)); + }, this); + + messageHandler.on('IncorrectPassword', + function transportIncorrectPassword(exception) { + var loadingTask = this.loadingTask; + if (loadingTask.onPassword) { + return loadingTask.onPassword(updatePassword, + PasswordResponses.INCORRECT_PASSWORD); + } + loadingTask._capability.reject( + new PasswordException(exception.message, exception.code)); + }, this); + + messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) { + this.loadingTask._capability.reject( + new InvalidPDFException(exception.message)); + }, this); + + messageHandler.on('MissingPDF', function transportMissingPDF(exception) { + this.loadingTask._capability.reject( + new MissingPDFException(exception.message)); + }, this); + + messageHandler.on('UnexpectedResponse', + function transportUnexpectedResponse(exception) { + this.loadingTask._capability.reject( + new UnexpectedResponseException(exception.message, exception.status)); + }, this); + + messageHandler.on('UnknownError', + function transportUnknownError(exception) { + this.loadingTask._capability.reject( + new UnknownErrorException(exception.message, exception.details)); + }, this); + + messageHandler.on('DataLoaded', function transportPage(data) { + this.downloadInfoCapability.resolve(data); + }, this); + + messageHandler.on('PDFManagerReady', function transportPage(data) { + if (this.pdfDataRangeTransport) { + this.pdfDataRangeTransport.transportReady(); + } + }, this); + + messageHandler.on('StartRenderPage', function transportRender(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + var page = this.pageCache[data.pageIndex]; + + page.stats.timeEnd('Page Request'); + page._startRenderPage(data.transparency, data.intent); + }, this); + + messageHandler.on('RenderPageChunk', function transportRender(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + var page = this.pageCache[data.pageIndex]; + + page._renderPageChunk(data.operatorList, data.intent); + }, this); + + messageHandler.on('commonobj', function transportObj(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + + var id = data[0]; + var type = data[1]; + if (this.commonObjs.hasData(id)) { + return; + } + + switch (type) { + case 'Font': + var exportedData = data[2]; + + if ('error' in exportedData) { + var exportedError = exportedData.error; + warn('Error during font loading: ' + exportedError); + this.commonObjs.resolve(id, exportedError); + break; + } + var fontRegistry = null; + if (getDefaultSetting('pdfBug') && globalScope.FontInspector && + globalScope['FontInspector'].enabled) { + fontRegistry = { + registerFont: function (font, url) { + globalScope['FontInspector'].fontAdded(font, url); + } + }; + } + var font = new FontFaceObject(exportedData, { + isEvalSuported: getDefaultSetting('isEvalSupported'), + disableFontFace: getDefaultSetting('disableFontFace'), + fontRegistry: fontRegistry + }); + + this.fontLoader.bind( + [font], + function fontReady(fontObjs) { + this.commonObjs.resolve(id, font); + }.bind(this) + ); + break; + case 'FontPath': + this.commonObjs.resolve(id, data[2]); + break; + default: + error('Got unknown common object type ' + type); + } + }, this); + + messageHandler.on('obj', function transportObj(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + + var id = data[0]; + var pageIndex = data[1]; + var type = data[2]; + var pageProxy = this.pageCache[pageIndex]; + var imageData; + if (pageProxy.objs.hasData(id)) { + return; + } + + switch (type) { + case 'JpegStream': + imageData = data[3]; + loadJpegStream(id, imageData, pageProxy.objs); + break; + case 'Image': + imageData = data[3]; + pageProxy.objs.resolve(id, imageData); + + // heuristics that will allow not to store large data + var MAX_IMAGE_SIZE_TO_STORE = 8000000; + if (imageData && 'data' in imageData && + imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) { + pageProxy.cleanupAfterRender = true; + } + break; + default: + error('Got unknown object type ' + type); + } + }, this); + + messageHandler.on('DocProgress', function transportDocProgress(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + + var loadingTask = this.loadingTask; + if (loadingTask.onProgress) { + loadingTask.onProgress({ + loaded: data.loaded, + total: data.total + }); + } + }, this); + + messageHandler.on('PageError', function transportError(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + + var page = this.pageCache[data.pageNum - 1]; + var intentState = page.intentStates[data.intent]; + + if (intentState.displayReadyCapability) { + intentState.displayReadyCapability.reject(data.error); + } else { + error(data.error); + } + + if (intentState.operatorList) { + // Mark operator list as complete. + intentState.operatorList.lastChunk = true; + for (var i = 0; i < intentState.renderTasks.length; i++) { + intentState.renderTasks[i].operatorListChanged(); + } + } + }, this); + + messageHandler.on('UnsupportedFeature', + function transportUnsupportedFeature(data) { + if (this.destroyed) { + return; // Ignore any pending requests if the worker was terminated. + } + var featureId = data.featureId; + var loadingTask = this.loadingTask; + if (loadingTask.onUnsupportedFeature) { + loadingTask.onUnsupportedFeature(featureId); + } + _UnsupportedManager.notify(featureId); + }, this); + + messageHandler.on('JpegDecode', function(data) { + if (this.destroyed) { + return Promise.reject('Worker was terminated'); + } + + var imageUrl = data[0]; + var components = data[1]; + if (components !== 3 && components !== 1) { + return Promise.reject( + new Error('Only 3 components or 1 component can be returned')); + } + + return new Promise(function (resolve, reject) { + var img = new Image(); + img.onload = function () { + var width = img.width; + var height = img.height; + var size = width * height; + var rgbaLength = size * 4; + var buf = new Uint8Array(size * components); + var tmpCanvas = createScratchCanvas(width, height); + var tmpCtx = tmpCanvas.getContext('2d'); + tmpCtx.drawImage(img, 0, 0); + var data = tmpCtx.getImageData(0, 0, width, height).data; + var i, j; + + if (components === 3) { + for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) { + buf[j] = data[i]; + buf[j + 1] = data[i + 1]; + buf[j + 2] = data[i + 2]; + } + } else if (components === 1) { + for (i = 0, j = 0; i < rgbaLength; i += 4, j++) { + buf[j] = data[i]; + } + } + resolve({ data: buf, width: width, height: height}); + }; + img.onerror = function () { + reject(new Error('JpegDecode failed to load image')); + }; + img.src = imageUrl; + }); + }, this); + }, + + getData: function WorkerTransport_getData() { + return this.messageHandler.sendWithPromise('GetData', null); + }, + + getPage: function WorkerTransport_getPage(pageNumber, capability) { + if (pageNumber <= 0 || pageNumber > this.numPages || + (pageNumber|0) !== pageNumber) { + return Promise.reject(new Error('Invalid page request')); + } + + var pageIndex = pageNumber - 1; + if (pageIndex in this.pagePromises) { + return this.pagePromises[pageIndex]; + } + var promise = this.messageHandler.sendWithPromise('GetPage', { + pageIndex: pageIndex + }).then(function (pageInfo) { + if (this.destroyed) { + throw new Error('Transport destroyed'); + } + var page = new PDFPageProxy(pageIndex, pageInfo, this); + this.pageCache[pageIndex] = page; + return page; + }.bind(this)); + this.pagePromises[pageIndex] = promise; + return promise; + }, + + getPageIndex: function WorkerTransport_getPageIndexByRef(ref) { + return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }). + then(function (pageIndex) { + return pageIndex; + }, function (reason) { + return Promise.reject(new Error(reason)); + }); + }, + + getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) { + return this.messageHandler.sendWithPromise('GetAnnotations', { + pageIndex: pageIndex, + intent: intent, + }); + }, + + getDestinations: function WorkerTransport_getDestinations() { + return this.messageHandler.sendWithPromise('GetDestinations', null); + }, + + getDestination: function WorkerTransport_getDestination(id) { + return this.messageHandler.sendWithPromise('GetDestination', { id: id }); + }, + + getPageLabels: function WorkerTransport_getPageLabels() { + return this.messageHandler.sendWithPromise('GetPageLabels', null); + }, + + getAttachments: function WorkerTransport_getAttachments() { + return this.messageHandler.sendWithPromise('GetAttachments', null); + }, + + getJavaScript: function WorkerTransport_getJavaScript() { + return this.messageHandler.sendWithPromise('GetJavaScript', null); + }, + + getOutline: function WorkerTransport_getOutline() { + return this.messageHandler.sendWithPromise('GetOutline', null); + }, + + getMetadata: function WorkerTransport_getMetadata() { + return this.messageHandler.sendWithPromise('GetMetadata', null). + then(function transportMetadata(results) { + return { + info: results[0], + metadata: (results[1] ? new Metadata(results[1]) : null) + }; + }); + }, + + getStats: function WorkerTransport_getStats() { + return this.messageHandler.sendWithPromise('GetStats', null); + }, + + startCleanup: function WorkerTransport_startCleanup() { + this.messageHandler.sendWithPromise('Cleanup', null). + then(function endCleanup() { + for (var i = 0, ii = this.pageCache.length; i < ii; i++) { + var page = this.pageCache[i]; + if (page) { + page.cleanup(); + } + } + this.commonObjs.clear(); + this.fontLoader.clear(); + }.bind(this)); + } + }; + return WorkerTransport; + +})(); + +/** + * A PDF document and page is built of many objects. E.g. there are objects + * for fonts, images, rendering code and such. These objects might get processed + * inside of a worker. The `PDFObjects` implements some basic functions to + * manage these objects. + * @ignore + */ +var PDFObjects = (function PDFObjectsClosure() { + function PDFObjects() { + this.objs = Object.create(null); + } + + PDFObjects.prototype = { + /** + * Internal function. + * Ensures there is an object defined for `objId`. + */ + ensureObj: function PDFObjects_ensureObj(objId) { + if (this.objs[objId]) { + return this.objs[objId]; + } + + var obj = { + capability: createPromiseCapability(), + data: null, + resolved: false + }; + this.objs[objId] = obj; + + return obj; + }, + + /** + * If called *without* callback, this returns the data of `objId` but the + * object needs to be resolved. If it isn't, this function throws. + * + * If called *with* a callback, the callback is called with the data of the + * object once the object is resolved. That means, if you call this + * function and the object is already resolved, the callback gets called + * right away. + */ + get: function PDFObjects_get(objId, callback) { + // If there is a callback, then the get can be async and the object is + // not required to be resolved right now + if (callback) { + this.ensureObj(objId).capability.promise.then(callback); + return null; + } + + // If there isn't a callback, the user expects to get the resolved data + // directly. + var obj = this.objs[objId]; + + // If there isn't an object yet or the object isn't resolved, then the + // data isn't ready yet! + if (!obj || !obj.resolved) { + error('Requesting object that isn\'t resolved yet ' + objId); + } + + return obj.data; + }, + + /** + * Resolves the object `objId` with optional `data`. + */ + resolve: function PDFObjects_resolve(objId, data) { + var obj = this.ensureObj(objId); + + obj.resolved = true; + obj.data = data; + obj.capability.resolve(data); + }, + + isResolved: function PDFObjects_isResolved(objId) { + var objs = this.objs; + + if (!objs[objId]) { + return false; + } else { + return objs[objId].resolved; + } + }, + + hasData: function PDFObjects_hasData(objId) { + return this.isResolved(objId); + }, + + /** + * Returns the data of `objId` if object exists, null otherwise. + */ + getData: function PDFObjects_getData(objId) { + var objs = this.objs; + if (!objs[objId] || !objs[objId].resolved) { + return null; + } else { + return objs[objId].data; + } + }, + + clear: function PDFObjects_clear() { + this.objs = Object.create(null); + } + }; + return PDFObjects; +})(); + +/** + * Allows controlling of the rendering tasks. + * @class + * @alias RenderTask + */ +var RenderTask = (function RenderTaskClosure() { + function RenderTask(internalRenderTask) { + this._internalRenderTask = internalRenderTask; + + /** + * Callback for incremental rendering -- a function that will be called + * each time the rendering is paused. To continue rendering call the + * function that is the first argument to the callback. + * @type {function} + */ + this.onContinue = null; + } + + RenderTask.prototype = /** @lends RenderTask.prototype */ { + /** + * Promise for rendering task completion. + * @return {Promise} + */ + get promise() { + return this._internalRenderTask.capability.promise; + }, + + /** + * Cancels the rendering task. If the task is currently rendering it will + * not be cancelled until graphics pauses with a timeout. The promise that + * this object extends will resolved when cancelled. + */ + cancel: function RenderTask_cancel() { + this._internalRenderTask.cancel(); + }, + + /** + * Registers callbacks to indicate the rendering task completion. + * + * @param {function} onFulfilled The callback for the rendering completion. + * @param {function} onRejected The callback for the rendering failure. + * @return {Promise} A promise that is resolved after the onFulfilled or + * onRejected callback. + */ + then: function RenderTask_then(onFulfilled, onRejected) { + return this.promise.then.apply(this.promise, arguments); + } + }; + + return RenderTask; +})(); + +/** + * For internal use only. + * @ignore + */ +var InternalRenderTask = (function InternalRenderTaskClosure() { + + function InternalRenderTask(callback, params, objs, commonObjs, operatorList, + pageNumber) { + this.callback = callback; + this.params = params; + this.objs = objs; + this.commonObjs = commonObjs; + this.operatorListIdx = null; + this.operatorList = operatorList; + this.pageNumber = pageNumber; + this.running = false; + this.graphicsReadyCallback = null; + this.graphicsReady = false; + this.useRequestAnimationFrame = false; + this.cancelled = false; + this.capability = createPromiseCapability(); + this.task = new RenderTask(this); + // caching this-bound methods + this._continueBound = this._continue.bind(this); + this._scheduleNextBound = this._scheduleNext.bind(this); + this._nextBound = this._next.bind(this); + } + + InternalRenderTask.prototype = { + + initializeGraphics: + function InternalRenderTask_initializeGraphics(transparency) { + + if (this.cancelled) { + return; + } + if (getDefaultSetting('pdfBug') && globalScope.StepperManager && + globalScope.StepperManager.enabled) { + this.stepper = globalScope.StepperManager.create(this.pageNumber - 1); + this.stepper.init(this.operatorList); + this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint(); + } + + var params = this.params; + this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, + this.objs, params.imageLayer); + + this.gfx.beginDrawing(params.transform, params.viewport, transparency); + this.operatorListIdx = 0; + this.graphicsReady = true; + if (this.graphicsReadyCallback) { + this.graphicsReadyCallback(); + } + }, + + cancel: function InternalRenderTask_cancel() { + this.running = false; + this.cancelled = true; + this.callback('cancelled'); + }, + + operatorListChanged: function InternalRenderTask_operatorListChanged() { + if (!this.graphicsReady) { + if (!this.graphicsReadyCallback) { + this.graphicsReadyCallback = this._continueBound; + } + return; + } + + if (this.stepper) { + this.stepper.updateOperatorList(this.operatorList); + } + + if (this.running) { + return; + } + this._continue(); + }, + + _continue: function InternalRenderTask__continue() { + this.running = true; + if (this.cancelled) { + return; + } + if (this.task.onContinue) { + this.task.onContinue.call(this.task, this._scheduleNextBound); + } else { + this._scheduleNext(); + } + }, + + _scheduleNext: function InternalRenderTask__scheduleNext() { + if (this.useRequestAnimationFrame && typeof window !== 'undefined') { + window.requestAnimationFrame(this._nextBound); + } else { + Promise.resolve(undefined).then(this._nextBound); + } + }, + + _next: function InternalRenderTask__next() { + if (this.cancelled) { + return; + } + this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, + this.operatorListIdx, + this._continueBound, + this.stepper); + if (this.operatorListIdx === this.operatorList.argsArray.length) { + this.running = false; + if (this.operatorList.lastChunk) { + this.gfx.endDrawing(); + this.callback(); + } + } + } + + }; + + return InternalRenderTask; +})(); + +/** + * (Deprecated) Global observer of unsupported feature usages. Use + * onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance. + */ +var _UnsupportedManager = (function UnsupportedManagerClosure() { + var listeners = []; + return { + listen: function (cb) { + deprecated('Global UnsupportedManager.listen is used: ' + + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead'); + listeners.push(cb); + }, + notify: function (featureId) { + for (var i = 0, ii = listeners.length; i < ii; i++) { + listeners[i](featureId); + } + } + }; +})(); + +if (typeof pdfjsVersion !== 'undefined') { + exports.version = pdfjsVersion; +} +if (typeof pdfjsBuild !== 'undefined') { + exports.build = pdfjsBuild; +} + +exports.getDocument = getDocument; +exports.PDFDataRangeTransport = PDFDataRangeTransport; +exports.PDFWorker = PDFWorker; +exports.PDFDocumentProxy = PDFDocumentProxy; +exports.PDFPageProxy = PDFPageProxy; +exports._UnsupportedManager = _UnsupportedManager; +})); + + +(function (root, factory) { + { + factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil, + root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, + root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, + root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG); + } +}(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, + displayAnnotationLayer, displayTextLayer, displayMetadata, + displaySVG) { + + var globalScope = sharedUtil.globalScope; + var deprecated = sharedUtil.deprecated; + var warn = sharedUtil.warn; + var LinkTarget = displayDOMUtils.LinkTarget; + + var isWorker = (typeof window === 'undefined'); + + // The global PDFJS object is now deprecated and will not be supported in + // the future. The members below are maintained for backward compatibility + // and shall not be extended or modified. If the global.js is included as + // a module, we will create a global PDFJS object instance or use existing. + if (!globalScope.PDFJS) { + globalScope.PDFJS = {}; + } + var PDFJS = globalScope.PDFJS; + + if (typeof pdfjsVersion !== 'undefined') { + PDFJS.version = pdfjsVersion; + } + if (typeof pdfjsBuild !== 'undefined') { + PDFJS.build = pdfjsBuild; + } + + PDFJS.pdfBug = false; + + if (PDFJS.verbosity !== undefined) { + sharedUtil.setVerbosityLevel(PDFJS.verbosity); + } + delete PDFJS.verbosity; + Object.defineProperty(PDFJS, 'verbosity', { + get: function () { return sharedUtil.getVerbosityLevel(); }, + set: function (level) { sharedUtil.setVerbosityLevel(level); }, + enumerable: true, + configurable: true + }); + + PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS; + PDFJS.OPS = sharedUtil.OPS; + PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES; + PDFJS.isValidUrl = sharedUtil.isValidUrl; + PDFJS.shadow = sharedUtil.shadow; + PDFJS.createBlob = sharedUtil.createBlob; + PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) { + return sharedUtil.createObjectURL(data, contentType, + PDFJS.disableCreateObjectURL); + }; + Object.defineProperty(PDFJS, 'isLittleEndian', { + configurable: true, + get: function PDFJS_isLittleEndian() { + var value = sharedUtil.isLittleEndian(); + return sharedUtil.shadow(PDFJS, 'isLittleEndian', value); + } + }); + PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters; + PDFJS.PasswordResponses = sharedUtil.PasswordResponses; + PDFJS.PasswordException = sharedUtil.PasswordException; + PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException; + PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException; + PDFJS.MissingPDFException = sharedUtil.MissingPDFException; + PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException; + PDFJS.Util = sharedUtil.Util; + PDFJS.PageViewport = sharedUtil.PageViewport; + PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability; + + /** + * The maximum allowed image size in total pixels e.g. width * height. Images + * above this value will not be drawn. Use -1 for no limit. + * @var {number} + */ + PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ? + -1 : PDFJS.maxImageSize); + + /** + * The url of where the predefined Adobe CMaps are located. Include trailing + * slash. + * @var {string} + */ + PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl); + + /** + * Specifies if CMaps are binary packed. + * @var {boolean} + */ + PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked; + + /** + * By default fonts are converted to OpenType fonts and loaded via font face + * rules. If disabled, the font will be rendered using a built in font + * renderer that constructs the glyphs with primitive path commands. + * @var {boolean} + */ + PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ? + false : PDFJS.disableFontFace); + + /** + * Path for image resources, mainly for annotation icons. Include trailing + * slash. + * @var {string} + */ + PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ? + '' : PDFJS.imageResourcesPath); + + /** + * Disable the web worker and run all code on the main thread. This will + * happen automatically if the browser doesn't support workers or sending + * typed arrays to workers. + * @var {boolean} + */ + PDFJS.disableWorker = (PDFJS.disableWorker === undefined ? + false : PDFJS.disableWorker); + + /** + * Path and filename of the worker file. Required when the worker is enabled + * in development mode. If unspecified in the production build, the worker + * will be loaded based on the location of the pdf.js file. It is recommended + * that the workerSrc is set in a custom application to prevent issues caused + * by third-party frameworks and libraries. + * @var {string} + */ + PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc); + + /** + * Disable range request loading of PDF files. When enabled and if the server + * supports partial content requests then the PDF will be fetched in chunks. + * Enabled (false) by default. + * @var {boolean} + */ + PDFJS.disableRange = (PDFJS.disableRange === undefined ? + false : PDFJS.disableRange); + + /** + * Disable streaming of PDF file data. By default PDF.js attempts to load PDF + * in chunks. This default behavior can be disabled. + * @var {boolean} + */ + PDFJS.disableStream = (PDFJS.disableStream === undefined ? + false : PDFJS.disableStream); + + /** + * Disable pre-fetching of PDF file data. When range requests are enabled + * PDF.js will automatically keep fetching more data even if it isn't needed + * to display the current page. This default behavior can be disabled. + * + * NOTE: It is also necessary to disable streaming, see above, + * in order for disabling of pre-fetching to work correctly. + * @var {boolean} + */ + PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ? + false : PDFJS.disableAutoFetch); + + /** + * Enables special hooks for debugging PDF.js. + * @var {boolean} + */ + PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug); + + /** + * Enables transfer usage in postMessage for ArrayBuffers. + * @var {boolean} + */ + PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ? + true : PDFJS.postMessageTransfers); + + /** + * Disables URL.createObjectURL usage. + * @var {boolean} + */ + PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ? + false : PDFJS.disableCreateObjectURL); + + /** + * Disables WebGL usage. + * @var {boolean} + */ + PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ? + true : PDFJS.disableWebGL); + + /** + * Specifies the |target| attribute for external links. + * The constants from PDFJS.LinkTarget should be used: + * - NONE [default] + * - SELF + * - BLANK + * - PARENT + * - TOP + * @var {number} + */ + PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ? + LinkTarget.NONE : PDFJS.externalLinkTarget); + + /** + * Specifies the |rel| attribute for external links. Defaults to stripping + * the referrer. + * @var {string} + */ + PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ? + 'noreferrer' : PDFJS.externalLinkRel); + + /** + * Determines if we can eval strings as JS. Primarily used to improve + * performance for font rendering. + * @var {boolean} + */ + PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? + true : PDFJS.isEvalSupported); + + var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow; + delete PDFJS.openExternalLinksInNewWindow; + Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', { + get: function () { + return PDFJS.externalLinkTarget === LinkTarget.BLANK; + }, + set: function (value) { + if (value) { + deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.'); + } + if (PDFJS.externalLinkTarget !== LinkTarget.NONE) { + warn('PDFJS.externalLinkTarget is already initialized'); + return; + } + PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE; + }, + enumerable: true, + configurable: true + }); + if (savedOpenExternalLinksInNewWindow) { + /** + * (Deprecated) Opens external links in a new window if enabled. + * The default behavior opens external links in the PDF.js window. + * + * NOTE: This property has been deprecated, please use + * `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead. + * @var {boolean} + */ + PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow; + } + + PDFJS.getDocument = displayAPI.getDocument; + PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; + PDFJS.PDFWorker = displayAPI.PDFWorker; + + Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', { + configurable: true, + get: function PDFJS_hasCanvasTypedArrays() { + var value = displayDOMUtils.hasCanvasTypedArrays(); + return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value); + } + }); + PDFJS.CustomStyle = displayDOMUtils.CustomStyle; + PDFJS.LinkTarget = LinkTarget; + PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes; + PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; + PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet; + + PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer; + + PDFJS.renderTextLayer = displayTextLayer.renderTextLayer; + + PDFJS.Metadata = displayMetadata.Metadata; + + PDFJS.SVGGraphics = displaySVG.SVGGraphics; + + PDFJS.UnsupportedManager = displayAPI._UnsupportedManager; + + exports.globalScope = globalScope; + exports.isWorker = isWorker; + exports.PDFJS = globalScope.PDFJS; +})); + }).call(pdfjsLibs); + + exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS; + exports.build = pdfjsLibs.pdfjsDisplayAPI.build; + exports.version = pdfjsLibs.pdfjsDisplayAPI.version; + exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument; + exports.PDFDataRangeTransport = + pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport; + exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker; + exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer; + exports.AnnotationLayer = + pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer; + exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle; + exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses; + exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException; + exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException; + exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics; + exports.UnexpectedResponseException = + pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException; + exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS; + exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES; + exports.isValidUrl = pdfjsLibs.pdfjsSharedUtil.isValidUrl; + exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL; + exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters; + exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow; + exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob; + exports.getFilenameFromUrl = + pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl; + exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes; +})); + diff --git a/wp/wp-content/plugins/wp-media-folder/assets/js/pdf-embed/pdf.worker.min.js b/wp/wp-content/plugins/wp-media-folder/assets/js/pdf-embed/pdf.worker.min.js new file mode 100644 index 00000000..9770cf2b --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/assets/js/pdf-embed/pdf.worker.min.js @@ -0,0 +1,19 @@ +!function(e,t){"use strict";"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf.worker",["exports"],t):t("undefined"!=typeof exports?exports:e.pdfjsDistBuildPdfWorker={})}(this,function(e){"use strict";var t=("undefined"!=typeof document&&document.currentScript?document.currentScript.src:null,{});(function(){!function(e,t){t(e.pdfjsCoreArithmeticDecoder={})}(this,function(e){var t=function(){function e(e,t,a){this.data=e;this.bp=t;this.dataEnd=a;this.chigh=e[t];this.clow=0;this.byteIn();this.chigh=this.chigh<<7&65535|this.clow>>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}var t=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];e.prototype={byteIn:function(){var e=this.data,t=this.bp;if(255===e[t]){var a=e[t+1];if(a>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}}else{t++;this.clow+=t65535){this.chigh+=this.clow>>16;this.clow&=65535}},readBit:function(e,a){var r,i=e[a]>>1,n=1&e[a],s=t[i],o=s.qe,c=this.a-o;if(this.chighc){c=o;r=n;i=s.nmps}else{c=o;r=1^n;1===s.switchFlag&&(n=r);i=s.nlps}else{this.chigh-=o;if(0!==(32768&c)){this.a=c;return n}if(o>c){r=1^n;1===s.switchFlag&&(n=r);i=s.nlps}else{r=n;i=s.nmps}}do{0===this.ct&&this.byteIn();c<<=1;this.chigh=this.chigh<<1&65535|this.clow>>15&1;this.clow=this.clow<<1&65535;this.ct--}while(0===(32768&c));this.a=c;e[a]=i<<1|n;return r}};return e}();e.ArithmeticDecoder=t});!function(e,t){t(e.pdfjsCoreBidi={})}(this,function(e){function t(e){return 0!==(1&e)}function a(e){return 0===(1&e)}function r(e,t,a){for(var r=t,i=e.length;i>r;++r)if(e[r]!==a)return r;return r}function i(e,t,a,r){for(var i=t;a>i;++i)e[i]=r}function n(e,t,a){for(var r=t,i=a-1;i>r;++r,--i){var n=e[r];e[r]=e[i];e[i]=n}}function s(e,t,a){return{str:e,dir:a?"ttb":t?"ltr":"rtl"}}function o(e,o,f){var d=!0,g=e.length;if(0===g||f)return s(e,d,f);h.length=g;u.length=g;var p,m,b=0;for(p=0;g>p;++p){h[p]=e.charAt(p);var v=e.charCodeAt(p),y="L";255>=v?y=c[v]:v>=1424&&1524>=v?y="R":v>=1536&&1791>=v?y=l[255&v]:v>=1792&&2220>=v&&(y="AL");"R"!==y&&"AL"!==y&&"AN"!==y||b++;u[p]=y}if(0===b){d=!0;return s(e,d)}if(-1===o)if(.3>g/b){d=!0;o=0}else{d=!1;o=1}var k=[];for(p=0;g>p;++p)k[p]=o;var w=t(o)?"R":"L",x=w,C=x,S=x;for(p=0;g>p;++p)"NSM"===u[p]?u[p]=S:S=u[p];S=x;var A;for(p=0;g>p;++p){A=u[p];"EN"===A?u[p]="AL"===S?"AN":"EN":"R"!==A&&"L"!==A&&"AL"!==A||(S=A)}for(p=0;g>p;++p){A=u[p];"AL"===A&&(u[p]="R")}for(p=1;g-1>p;++p){"ES"===u[p]&&"EN"===u[p-1]&&"EN"===u[p+1]&&(u[p]="EN");"CS"!==u[p]||"EN"!==u[p-1]&&"AN"!==u[p-1]||u[p+1]!==u[p-1]||(u[p]=u[p-1])}for(p=0;g>p;++p)if("EN"===u[p]){var I;for(I=p-1;I>=0&&"ET"===u[I];--I)u[I]="EN";for(I=p+1;g>I&&"ET"===u[I];++I)u[I]="EN"}for(p=0;g>p;++p){A=u[p];"WS"!==A&&"ES"!==A&&"ET"!==A&&"CS"!==A||(u[p]="ON")}S=x;for(p=0;g>p;++p){A=u[p];"EN"===A?u[p]="L"===S?"L":"EN":"R"!==A&&"L"!==A||(S=A)}for(p=0;g>p;++p)if("ON"===u[p]){var B=r(u,p+1,"ON"),R=x;p>0&&(R=u[p-1]);var T=C;g>B+1&&(T=u[B+1]);"L"!==R&&(R="R");"L"!==T&&(T="R");R===T&&i(u,p,B,R);p=B-1}for(p=0;g>p;++p)"ON"===u[p]&&(u[p]=w);for(p=0;g>p;++p){A=u[p];a(k[p])?"R"===A?k[p]+=1:"AN"!==A&&"EN"!==A||(k[p]+=2):"L"!==A&&"AN"!==A&&"EN"!==A||(k[p]+=1)}var O,P=-1,L=99;for(p=0,m=k.length;m>p;++p){O=k[p];O>P&&(P=O);L>O&&t(O)&&(L=O)}for(O=P;O>=L;--O){var M=-1;for(p=0,m=k.length;m>p;++p)if(k[p]=0){n(h,M,p);M=-1}}else 0>M&&(M=p);M>=0&&n(h,M,k.length)}for(p=0,m=h.length;m>p;++p){var E=h[p];"<"!==E&&">"!==E||(h[p]="")}return s(h.join(""),d)}var c=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","ON","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],l=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"],h=[],u=[];e.bidi=o});!function(e,t){t(e.pdfjsCoreCharsets={})}(this,function(e){var t=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],a=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],r=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];e.ISOAdobeCharset=t;e.ExpertCharset=a;e.ExpertSubsetCharset=r});!function(e,t){t(e.pdfjsCoreEncodings={})}(this,function(e){function t(e){switch(e){case"WinAnsiEncoding":return s;case"StandardEncoding":return n;case"MacRomanEncoding":return i;case"SymbolSetEncoding":return o;case"ZapfDingbatsEncoding":return c;case"ExpertEncoding":return a;case"MacExpertEncoding":return r;default:return null}}var a=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],r=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","centoldstyle","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","","threequartersemdash","","questionsmall","","","","","Ethsmall","","","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","","","","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hypheninferior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","asuperior","centsuperior","","","","","Aacutesmall","Agravesmall","Acircumflexsmall","Adieresissmall","Atildesmall","Aringsmall","Ccedillasmall","Eacutesmall","Egravesmall","Ecircumflexsmall","Edieresissmall","Iacutesmall","Igravesmall","Icircumflexsmall","Idieresissmall","Ntildesmall","Oacutesmall","Ogravesmall","Ocircumflexsmall","Odieresissmall","Otildesmall","Uacutesmall","Ugravesmall","Ucircumflexsmall","Udieresissmall","","eightsuperior","fourinferior","threeinferior","sixinferior","eightinferior","seveninferior","Scaronsmall","","centinferior","twoinferior","","Dieresissmall","","Caronsmall","osuperior","fiveinferior","","commainferior","periodinferior","Yacutesmall","","dollarinferior","","Thornsmall","","nineinferior","zeroinferior","Zcaronsmall","AEsmall","Oslashsmall","questiondownsmall","oneinferior","Lslashsmall","","","","","","","Cedillasmall","","","","","","OEsmall","figuredash","hyphensuperior","","","","","exclamdownsmall","","Ydieresissmall","","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","ninesuperior","zerosuperior","","esuperior","rsuperior","tsuperior","","","isuperior","ssuperior","dsuperior","","","","","","lsuperior","Ogoneksmall","Brevesmall","Macronsmall","bsuperior","nsuperior","msuperior","commasuperior","periodsuperior","Dotaccentsmall","Ringsmall"],i=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","space","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron"],n=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],s=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","bullet","Euro","bullet","quotesinglbase","florin","quotedblbase","ellipsis","dagger","daggerdbl","circumflex","perthousand","Scaron","guilsinglleft","OE","bullet","Zcaron","bullet","bullet","quoteleft","quoteright","quotedblleft","quotedblright","bullet","endash","emdash","tilde","trademark","scaron","guilsinglright","oe","bullet","zcaron","Ydieresis","space","exclamdown","cent","sterling","currency","yen","brokenbar","section","dieresis","copyright","ordfeminine","guillemotleft","logicalnot","hyphen","registered","macron","degree","plusminus","twosuperior","threesuperior","acute","mu","paragraph","periodcentered","cedilla","onesuperior","ordmasculine","guillemotright","onequarter","onehalf","threequarters","questiondown","Agrave","Aacute","Acircumflex","Atilde","Adieresis","Aring","AE","Ccedilla","Egrave","Eacute","Ecircumflex","Edieresis","Igrave","Iacute","Icircumflex","Idieresis","Eth","Ntilde","Ograve","Oacute","Ocircumflex","Otilde","Odieresis","multiply","Oslash","Ugrave","Uacute","Ucircumflex","Udieresis","Yacute","Thorn","germandbls","agrave","aacute","acircumflex","atilde","adieresis","aring","ae","ccedilla","egrave","eacute","ecircumflex","edieresis","igrave","iacute","icircumflex","idieresis","eth","ntilde","ograve","oacute","ocircumflex","otilde","odieresis","divide","oslash","ugrave","uacute","ucircumflex","udieresis","yacute","thorn","ydieresis"],o=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","universal","numbersign","existential","percent","ampersand","suchthat","parenleft","parenright","asteriskmath","plus","comma","minus","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","congruent","Alpha","Beta","Chi","Delta","Epsilon","Phi","Gamma","Eta","Iota","theta1","Kappa","Lambda","Mu","Nu","Omicron","Pi","Theta","Rho","Sigma","Tau","Upsilon","sigma1","Omega","Xi","Psi","Zeta","bracketleft","therefore","bracketright","perpendicular","underscore","radicalex","alpha","beta","chi","delta","epsilon","phi","gamma","eta","iota","phi1","kappa","lambda","mu","nu","omicron","pi","theta","rho","sigma","tau","upsilon","omega1","omega","xi","psi","zeta","braceleft","bar","braceright","similar","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","Euro","Upsilon1","minute","lessequal","fraction","infinity","florin","club","diamond","heart","spade","arrowboth","arrowleft","arrowup","arrowright","arrowdown","degree","plusminus","second","greaterequal","multiply","proportional","partialdiff","bullet","divide","notequal","equivalence","approxequal","ellipsis","arrowvertex","arrowhorizex","carriagereturn","aleph","Ifraktur","Rfraktur","weierstrass","circlemultiply","circleplus","emptyset","intersection","union","propersuperset","reflexsuperset","notsubset","propersubset","reflexsubset","element","notelement","angle","gradient","registerserif","copyrightserif","trademarkserif","product","radical","dotmath","logicalnot","logicaland","logicalor","arrowdblboth","arrowdblleft","arrowdblup","arrowdblright","arrowdbldown","lozenge","angleleft","registersans","copyrightsans","trademarksans","summation","parenlefttp","parenleftex","parenleftbt","bracketlefttp","bracketleftex","bracketleftbt","bracelefttp","braceleftmid","braceleftbt","braceex","","angleright","integral","integraltp","integralex","integralbt","parenrighttp","parenrightex","parenrightbt","bracketrighttp","bracketrightex","bracketrightbt","bracerighttp","bracerightmid","bracerightbt"],c=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","a1","a2","a202","a3","a4","a5","a119","a118","a117","a11","a12","a13","a14","a15","a16","a105","a17","a18","a19","a20","a21","a22","a23","a24","a25","a26","a27","a28","a6","a7","a8","a9","a10","a29","a30","a31","a32","a33","a34","a35","a36","a37","a38","a39","a40","a41","a42","a43","a44","a45","a46","a47","a48","a49","a50","a51","a52","a53","a54","a55","a56","a57","a58","a59","a60","a61","a62","a63","a64","a65","a66","a67","a68","a69","a70","a71","a72","a73","a74","a203","a75","a204","a76","a77","a78","a79","a81","a82","a83","a84","a97","a98","a99","a100","","a89","a90","a93","a94","a91","a92","a205","a85","a206","a86","a87","a88","a95","a96","","","","","","","","","","","","","","","","","","","","a101","a102","a103","a104","a106","a107","a108","a112","a111","a110","a109","a120","a121","a122","a123","a124","a125","a126","a127","a128","a129","a130","a131","a132","a133","a134","a135","a136","a137","a138","a139","a140","a141","a142","a143","a144","a145","a146","a147","a148","a149","a150","a151","a152","a153","a154","a155","a156","a157","a158","a159","a160","a161","a163","a164","a196","a165","a192","a166","a167","a168","a169","a170","a171","a172","a173","a162","a174","a175","a176","a177","a178","a179","a193","a180","a199","a181","a200","a182","","a201","a183","a184","a197","a185","a194","a198","a186","a195","a187","a188","a189","a190","a191"];e.WinAnsiEncoding=s;e.StandardEncoding=n;e.MacRomanEncoding=i;e.SymbolSetEncoding=o;e.ZapfDingbatsEncoding=c;e.ExpertEncoding=a;e.getEncoding=t});!function(e,t){t(e.pdfjsCoreJpg={})}(this,function(e){var t=function(){function e(){}function t(e,t){for(var a,r,i=0,n=[],s=16;s>0&&!e[s-1];)s--;n.push({children:[],index:0});var o,c=n[0];for(a=0;s>a;a++){for(r=0;r0;)c=n.pop();c.index++;n.push(c);for(;n.length<=a;){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}i++}if(s>a+1){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}}return n[0].children}function a(e,t,a){return 64*((e.blocksPerLine+1)*t+a)}function r(e,t,r,i,n,s,c,l,h){function u(){if(M>0){M--;return L>>M&1}L=e[t++];if(255===L){var a=e[t++];if(a)throw"unexpected marker: "+(L<<8|a).toString(16)}M=7;return L>>>7}function f(e){for(var t=e;;){t=t[u()];if("number"==typeof t)return t;if("object"!=typeof t)throw"invalid huffman sequence"}}function d(e){for(var t=0;e>0;){t=t<<1|u();e--}return t}function g(e){if(1===e)return 1===u()?1:-1;var t=d(e);return t>=1<i;){var n=f(e.huffmanTableAC),s=15&n,c=n>>4;if(0!==s){i+=c;var l=o[i];e.blockData[t+l]=g(s);i++}else{if(15>c)break;i+=16}}}function m(e,t){var a=f(e.huffmanTableDC),r=0===a?0:g(a)<0)E--;else for(var a=s,r=c;r>=a;){var i=f(e.huffmanTableAC),n=15&i,l=i>>4;if(0!==n){a+=l;var u=o[a];e.blockData[t+u]=g(n)*(1<l){E=d(l)+(1<=i;){var p=o[i];switch(D){case 0:r=f(e.huffmanTableAC);a=15&r;l=r>>4;if(0===a)if(15>l){E=d(l)+(1<U;){for(S=0;q>S;S++)i[S].pred=0;E=0;if(1===q){C=i[0];for(B=0;n>B;B++){w(C,R,U);U++}}else for(B=0;n>B;B++){for(S=0;q>S;S++){C=i[S];N=C.h;_=C.v;for(A=0;_>A;A++)for(I=0;N>I;I++)k(C,R,U,A,I)}U++}M=0;j=e[t]<<8|e[t+1];if(65280>=j)throw"marker was not found";if(!(j>=65488&&65495>=j))break;t+=2}return t-P}function i(e,t,a){for(var r,i,n,s,o,m,b,v,y,k,w,x,C,S,A,I,B,R=e.quantizationTable,T=e.blockData,O=0;64>O;O+=8){y=T[t+O];k=T[t+O+1];w=T[t+O+2];x=T[t+O+3];C=T[t+O+4];S=T[t+O+5];A=T[t+O+6];I=T[t+O+7];y*=R[O];if(0!==(k|w|x|C|S|A|I)){k*=R[O+1];w*=R[O+2];x*=R[O+3];C*=R[O+4];S*=R[O+5];A*=R[O+6];I*=R[O+7];r=g*y+128>>8;i=g*C+128>>8;n=w;s=A;o=p*(k-I)+128>>8;v=p*(k+I)+128>>8;m=x<<4;b=S<<4;r=r+i+1>>1;i=r-i;B=n*d+s*f+128>>8;n=n*f-s*d+128>>8;s=B;o=o+b+1>>1;b=o-b;v=v+m+1>>1;m=v-m;r=r+s+1>>1;s=r-s;i=i+n+1>>1;n=i-n;B=o*u+v*h+2048>>12;o=o*h-v*u+2048>>12;v=B;B=m*l+b*c+2048>>12;m=m*c-b*l+2048>>12;b=B;a[O]=r+v;a[O+7]=r-v;a[O+1]=i+b;a[O+6]=i-b;a[O+2]=n+m;a[O+5]=n-m;a[O+3]=s+o;a[O+4]=s-o}else{B=g*y+512>>10;a[O]=B;a[O+1]=B;a[O+2]=B;a[O+3]=B;a[O+4]=B;a[O+5]=B;a[O+6]=B;a[O+7]=B}}for(var P=0;8>P;++P){y=a[P];k=a[P+8];w=a[P+16];x=a[P+24];C=a[P+32];S=a[P+40];A=a[P+48];I=a[P+56];if(0!==(k|w|x|C|S|A|I)){r=g*y+2048>>12;i=g*C+2048>>12;n=w;s=A;o=p*(k-I)+2048>>12;v=p*(k+I)+2048>>12;m=x;b=S;r=(r+i+1>>1)+4112;i=r-i;B=n*d+s*f+2048>>12;n=n*f-s*d+2048>>12;s=B; +o=o+b+1>>1;b=o-b;v=v+m+1>>1;m=v-m;r=r+s+1>>1;s=r-s;i=i+n+1>>1;n=i-n;B=o*u+v*h+2048>>12;o=o*h-v*u+2048>>12;v=B;B=m*l+b*c+2048>>12;m=m*c-b*l+2048>>12;b=B;y=r+v;I=r-v;k=i+b;A=i-b;w=n+m;S=n-m;x=s+o;C=s-o;y=16>y?0:y>=4080?255:y>>4;k=16>k?0:k>=4080?255:k>>4;w=16>w?0:w>=4080?255:w>>4;x=16>x?0:x>=4080?255:x>>4;C=16>C?0:C>=4080?255:C>>4;S=16>S?0:S>=4080?255:S>>4;A=16>A?0:A>=4080?255:A>>4;I=16>I?0:I>=4080?255:I>>4;T[t+P]=y;T[t+P+8]=k;T[t+P+16]=w;T[t+P+24]=x;T[t+P+32]=C;T[t+P+40]=S;T[t+P+48]=A;T[t+P+56]=I}else{B=g*y+8192>>14;B=-2040>B?0:B>=2024?255:B+2056>>4;T[t+P]=B;T[t+P+8]=B;T[t+P+16]=B;T[t+P+24]=B;T[t+P+32]=B;T[t+P+40]=B;T[t+P+48]=B;T[t+P+56]=B}}}function n(e,t){for(var r=t.blocksPerLine,n=t.blocksPerColumn,s=new Int16Array(64),o=0;n>o;o++)for(var c=0;r>c;c++){var l=a(t,o,c);i(t,l,s)}return t.blockData}function s(e){return 0>=e?0:e>=255?255:e}var o=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),c=4017,l=799,h=3406,u=2276,f=1567,d=3784,g=5793,p=2896;e.prototype={parse:function(e){function a(){var t=e[h]<<8|e[h+1];h+=2;return t}function i(){var t=a(),r=e.subarray(h,h+t-2);h+=r.length;return r}function s(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),a=Math.ceil(e.scanLines/8/e.maxV),r=0;rh;){var S=e[h++],A=new Uint16Array(64);if(S>>4===0)for(v=0;64>v;v++){w=o[v];A[w]=e[h++]}else{if(S>>4!==1)throw"DQT: invalid table spec";for(v=0;64>v;v++){w=o[v];A[w]=a()}}d[15&S]=A}break;case 65472:case 65473:case 65474:if(c)throw"Only single frame JPEGs supported";a();c={};c.extended=65473===m;c.progressive=65474===m;c.precision=e[h++];c.scanLines=a();c.samplesPerLine=a();c.components=[];c.componentIds={};var I,B=e[h++],R=0,T=0;for(b=0;B>b;b++){I=e[h];var O=e[h+1]>>4,P=15&e[h+1];O>R&&(R=O);P>T&&(T=P);var L=e[h+2];y=c.components.push({h:O,v:P,quantizationTable:d[L]});c.componentIds[I]=y-1;h+=3}c.maxH=R;c.maxV=T;s(c);break;case 65476:var M=a();for(b=2;M>b;){var E=e[h++],D=new Uint8Array(16),q=0;for(v=0;16>v;v++,h++)q+=D[v]=e[h];var j=new Uint8Array(q);for(v=0;q>v;v++,h++)j[v]=e[h];b+=17+q;(E>>4===0?p:g)[15&E]=t(D,j)}break;case 65501:a();l=a();break;case 65498:var F,U=(a(),e[h++]),N=[];for(b=0;U>b;b++){var _=c.componentIds[e[h++]];F=c.components[_];var z=e[h++];F.huffmanTableDC=p[z>>4];F.huffmanTableAC=g[15&z];N.push(F)}var H=e[h++],G=e[h++],X=e[h++],W=r(e,h,c,N,l,H,G,X>>4,15&X);h+=W;break;case 65535:255!==e[h]&&h--;break;default:if(255===e[h-3]&&e[h-2]>=192&&e[h-2]<=254){h-=3;break}throw"unknown JPEG marker "+m.toString(16)}m=a()}this.width=c.samplesPerLine;this.height=c.scanLines;this.jfif=u;this.adobe=f;this.components=[];for(b=0;bc;c++){a=this.components[c];r=a.scaleX*d;i=a.scaleY*g;p=c;f=a.output;n=a.blocksPerLine+1<<3;for(s=0;e>s;s++){l=0|s*r;y[s]=(l&k)<<3|7&l}for(o=0;t>o;o++){l=0|o*i;u=n*(l&k)|(7&l)<<3;for(s=0;e>s;s++){v[p]=f[u+y[s]];p+=m}}}var w=this.decodeTransform;if(w)for(c=0;b>c;)for(l=0,h=0;m>l;l++,c++,h+=2)v[c]=(v[c]*w[h]>>8)+w[h+1];return v},_isColorConversionNeeded:function(){return this.adobe&&this.adobe.transformCode?!0:3===this.numComponents},_convertYccToRgb:function(e){for(var t,a,r,i=0,n=e.length;n>i;i+=3){t=e[i];a=e[i+1];r=e[i+2];e[i]=s(t-179.456+1.402*r);e[i+1]=s(t+135.459-.344*a-.714*r);e[i+2]=s(t-226.816+1.772*a)}return e},_convertYcckToRgb:function(e){for(var t,a,r,i,n=0,o=0,c=e.length;c>o;o+=4){t=e[o];a=e[o+1];r=e[o+2];i=e[o+3];var l=-122.67195406894+a*(-660635669420364e-19*a+.000437130475926232*r-54080610064599e-18*t+.00048449797120281*i-.154362151871126)+r*(-.000957964378445773*r+.000817076911346625*t-.00477271405408747*i+1.53380253221734)+t*(.000961250184130688*t-.00266257332283933*i+.48357088451265)+i*(-.000336197177618394*i+.484791561490776),h=107.268039397724+a*(219927104525741e-19*a-.000640992018297945*r+.000659397001245577*t+.000426105652938837*i-.176491792462875)+r*(-.000778269941513683*r+.00130872261408275*t+.000770482631801132*i-.151051492775562)+t*(.00126935368114843*t-.00265090189010898*i+.25802910206845)+i*(-.000318913117588328*i-.213742400323665),u=-20.810012546947+a*(-.000570115196973677*a-263409051004589e-19*r+.0020741088115012*t-.00288260236853442*i+.814272968359295)+r*(-153496057440975e-19*r-.000132689043961446*t+.000560833691242812*i-.195152027534049)+t*(.00174418132927582*t-.00255243321439347*i+.116935020465145)+i*(-.000343531996510555*i+.24165260232407);e[n++]=s(l);e[n++]=s(h);e[n++]=s(u)}return e},_convertYcckToCmyk:function(e){for(var t,a,r,i=0,n=e.length;n>i;i+=4){t=e[i];a=e[i+1];r=e[i+2];e[i]=s(434.456-t-1.402*r);e[i+1]=s(119.541-t+.344*a+.714*r);e[i+2]=s(481.816-t-1.772*a)}return e},_convertCmykToRgb:function(e){for(var t,a,r,i,n=0,s=-16581375,o=1/255/255,c=0,l=e.length;l>c;c+=4){t=e[c];a=e[c+1];r=e[c+2];i=e[c+3];var h=t*(-4.387332384609988*t+54.48615194189176*a+18.82290502165302*r+212.25662451639585*i-72734.4411664936)+a*(1.7149763477362134*a-5.6096736904047315*r-17.873870861415444*i-1401.7366389350734)+r*(-2.5217340131683033*r-21.248923337353073*i+4465.541406466231)-i*(21.86122147463605*i+48317.86113160301),u=t*(8.841041422036149*t+60.118027045597366*a+6.871425592049007*r+31.159100130055922*i-20220.756542821975)+a*(-15.310361306967817*a+17.575251261109482*r+131.35250912493976*i-48691.05921601825)+r*(4.444339102852739*r+9.8632861493405*i-6341.191035517494)-i*(20.737325471181034*i+47890.15695978492),f=t*(.8842522430003296*t+8.078677503112928*a+30.89978309703729*r-.23883238689178934*i-3616.812083916688)+a*(10.49593273432072*a+63.02378494754052*r+50.606957656360734*i-28620.90484698408)+r*(.03296041114873217*r+115.60384449646641*i-49363.43385999684)-i*(22.33816807309886*i+45932.16563550634);e[n++]=h>=0?255:s>=h?0:255+h*o|0;e[n++]=u>=0?255:s>=u?0:255+u*o|0;e[n++]=f>=0?255:s>=f?0:255+f*o|0}return e},getData:function(e,t,a){if(this.numComponents>4)throw"Unsupported color mode";var r=this._getLinearizedBlockData(e,t);if(1===this.numComponents&&a){for(var i=r.length,n=new Uint8Array(3*i),s=0,o=0;i>o;o++){var c=r[o];n[s++]=c;n[s++]=c;n[s++]=c}return n}if(3===this.numComponents)return this._convertYccToRgb(r);if(4===this.numComponents){if(this._isColorConversionNeeded())return a?this._convertYcckToRgb(r):this._convertYcckToCmyk(r);if(a)return this._convertCmykToRgb(r)}return r}};return e}();e.JpegImage=t});!function(e,t){t(e.pdfjsSharedUtil={})}(this,function(e){function t(e){J=e}function a(){return J}function r(e){J>=K.infos&&console.log("Info: "+e)}function i(e){J>=K.warnings&&console.log("Warning: "+e)}function n(e){console.log("Deprecated API usage: "+e)}function s(e){if(J>=K.errors){console.log("Error: "+e);console.log(o())}throw new Error(e)}function o(){try{throw new Error}catch(e){return e.stack?e.stack.split("\n").slice(2).join("\n"):""}}function c(e,t){e||s(t)}function l(e,t){try{var a=new URL(e);if(!a.origin||"null"===a.origin)return!1}catch(r){return!1}var i=new URL(t,a);return a.origin===i.origin}function h(e,t){if(!e||"string"!=typeof e)return!1;var a=/^[a-z][a-z0-9+\-.]*(?=:)/i.exec(e);if(!a)return t;a=a[0].toLowerCase();switch(a){case"http":case"https":case"ftp":case"mailto":case"tel":return!0;default:return!1}}function u(e,t,a){Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!1});return a}function f(e){var t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}}function d(e){if("string"!=typeof e){i("The argument for removeNullCharacters must be a string.");return e}return e.replace(oe,"")}function g(e){c(null!==e&&"object"==typeof e&&void 0!==e.length,"Invalid argument for bytesToString");var t=e.length,a=8192;if(a>t)return String.fromCharCode.apply(null,e);for(var r=[],i=0;t>i;i+=a){var n=Math.min(i+a,t),s=e.subarray(i,n);r.push(String.fromCharCode.apply(null,s))}return r.join("")}function p(e){c("string"==typeof e,"Invalid argument for stringToBytes");for(var t=e.length,a=new Uint8Array(t),r=0;t>r;++r)a[r]=255&e.charCodeAt(r);return a}function m(e){if(void 0!==e.length)return e.length;c(void 0!==e.byteLength);return e.byteLength}function b(e){if(1===e.length&&e[0]instanceof Uint8Array)return e[0];var t,a,r,i=0,n=e.length;for(t=0;n>t;t++){a=e[t];r=m(a);i+=r}var s=0,o=new Uint8Array(i);for(t=0;n>t;t++){a=e[t];a instanceof Uint8Array||(a="string"==typeof a?p(a):new Uint8Array(a));r=a.byteLength;o.set(a,s);s+=r}return o}function v(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}function y(e){for(var t=1,a=0;e>t;){t<<=1;a++}return a}function k(e,t){return e[t]<<24>>24}function w(e,t){return e[t]<<8|e[t+1]}function x(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function C(){var e=new Uint8Array(2);e[0]=1;var t=new Uint16Array(e.buffer);return 1===t[0]}function S(){try{new Function("");return!0}catch(e){return!1}}function A(e){var t,a=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(t=2;a>t;t+=2)r.push(String.fromCharCode(e.charCodeAt(t)<<8|e.charCodeAt(t+1)));else for(t=0;a>t;++t){var i=fe[e.charCodeAt(t)];r.push(i?String.fromCharCode(i):e.charAt(t))}return r.join("")}function I(e){return decodeURIComponent(escape(e))}function B(e){return unescape(encodeURIComponent(e))}function R(e){for(var t in e)return!1;return!0}function T(e){return"boolean"==typeof e}function O(e){return"number"==typeof e&&(0|e)===e}function P(e){return"number"==typeof e}function L(e){return"string"==typeof e}function M(e){return e instanceof Array}function E(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength}function D(e){return 32===e||9===e||13===e||10===e}function q(){var e={};e.promise=new Promise(function(t,a){e.resolve=t;e.reject=a});return e}function j(e,t,a){this.sourceName=e;this.targetName=t;this.comObj=a;this.callbackIndex=1;this.postMessageTransfers=!0;var r=this.callbacksCapabilities=Object.create(null),i=this.actionHandler=Object.create(null);this._onComObjOnMessage=function(e){var t=e.data;if(t.targetName===this.sourceName)if(t.isReply){var n=t.callbackId;if(t.callbackId in r){var o=r[n];delete r[n];"error"in t?o.reject(t.error):o.resolve(t.data)}else s("Cannot resolve callback "+n)}else if(t.action in i){var c=i[t.action];if(t.callbackId){var l=this.sourceName,h=t.sourceName;Promise.resolve().then(function(){return c[0].call(c[1],t.data)}).then(function(e){a.postMessage({sourceName:l,targetName:h,isReply:!0,callbackId:t.callbackId,data:e})},function(e){e instanceof Error&&(e+="");a.postMessage({sourceName:l,targetName:h,isReply:!0,callbackId:t.callbackId,error:e})})}else c[0].call(c[1],t.data)}else s("Unknown action from worker: "+t.action)}.bind(this);a.addEventListener("message",this._onComObjOnMessage)}function F(e,t,a){var r=new Image;r.onload=function(){a.resolve(e,r)};r.onerror=function(){a.resolve(e,null);i("Error during JPEG image loading")};r.src=t}var U="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,N=[.001,0,0,.001,0,0],_={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},z={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},H={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},G={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512},X={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},W={UNKNOWN:0,FLATE:1,LZW:2,DCT:3,JPX:4,JBIG:5,A85:6,AHX:7,CCF:8,RL:9},V={UNKNOWN:0,TYPE1:1,TYPE1C:2,CIDFONTTYPE0:3,CIDFONTTYPE0C:4,TRUETYPE:5,CIDFONTTYPE2:6,TYPE3:7,OPENTYPE:8,TYPE0:9,MMTYPE1:10},K={errors:0,warnings:1,infos:5},Y={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},J=K.warnings,Z={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font"},Q={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},$=function(){function e(e,t){this.name="PasswordException";this.message=e;this.code=t}e.prototype=new Error;e.constructor=e;return e}(),ee=function(){function e(e,t){this.name="UnknownErrorException";this.message=e;this.details=t}e.prototype=new Error;e.constructor=e;return e}(),te=function(){function e(e){this.name="InvalidPDFException";this.message=e}e.prototype=new Error;e.constructor=e;return e}(),ae=function(){function e(e){this.name="MissingPDFException";this.message=e}e.prototype=new Error;e.constructor=e;return e}(),re=function(){function e(e,t){this.name="UnexpectedResponseException";this.message=e;this.status=t}e.prototype=new Error;e.constructor=e;return e}(),ie=function(){function e(e){this.message=e}e.prototype=new Error;e.prototype.name="NotImplementedException";e.constructor=e;return e}(),ne=function(){function e(e,t){this.begin=e;this.end=t;this.message="Missing data ["+e+", "+t+")"}e.prototype=new Error;e.prototype.name="MissingDataException";e.constructor=e;return e}(),se=function(){function e(e){this.message=e}e.prototype=new Error;e.prototype.name="XRefParseException";e.constructor=e;return e}(),oe=/\x00/g,ce=function(){function e(e,t){this.buffer=e;this.byteLength=e.length;this.length=void 0===t?this.byteLength>>2:t;a(this.length)}function t(e){return{get:function(){var t=this.buffer,a=e<<2;return(t[a]|t[a+1]<<8|t[a+2]<<16|t[a+3]<<24)>>>0},set:function(t){var a=this.buffer,r=e<<2;a[r]=255&t;a[r+1]=t>>8&255;a[r+2]=t>>16&255;a[r+3]=t>>>24&255}}}function a(a){for(;a>r;){Object.defineProperty(e.prototype,r,t(r));r++}}e.prototype=Object.create(null);var r=0;return e}();e.Uint32ArrayView=ce;var le=[1,0,0,1,0,0],he=function(){function e(){}var t=["rgb(",0,",",0,",",0,")"];e.makeCssRgb=function(e,a,r){t[1]=e;t[3]=a;t[5]=r;return t.join("")};e.transform=function(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]};e.applyTransform=function(e,t){var a=e[0]*t[0]+e[1]*t[2]+t[4],r=e[0]*t[1]+e[1]*t[3]+t[5];return[a,r]};e.applyInverseTransform=function(e,t){var a=t[0]*t[3]-t[1]*t[2],r=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/a,i=(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/a;return[r,i]};e.getAxialAlignedBoundingBox=function(t,a){var r=e.applyTransform(t,a),i=e.applyTransform(t.slice(2,4),a),n=e.applyTransform([t[0],t[3]],a),s=e.applyTransform([t[2],t[1]],a);return[Math.min(r[0],i[0],n[0],s[0]),Math.min(r[1],i[1],n[1],s[1]),Math.max(r[0],i[0],n[0],s[0]),Math.max(r[1],i[1],n[1],s[1])]};e.inverseTransform=function(e){var t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]};e.apply3dTransform=function(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]};e.singularValueDecompose2dScale=function(e){var t=[e[0],e[2],e[1],e[3]],a=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],n=e[2]*t[1]+e[3]*t[3],s=(a+n)/2,o=Math.sqrt((a+n)*(a+n)-4*(a*n-i*r))/2,c=s+o||1,l=s-o||1;return[Math.sqrt(c),Math.sqrt(l)]};e.normalizeRect=function(e){var t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t};e.intersect=function(t,a){function r(e,t){return e-t}var i=[t[0],t[2],a[0],a[2]].sort(r),n=[t[1],t[3],a[1],a[3]].sort(r),s=[];t=e.normalizeRect(t);a=e.normalizeRect(a);if(!(i[0]===t[0]&&i[1]===a[0]||i[0]===a[0]&&i[1]===t[0]))return!1;s[0]=i[1];s[2]=i[2];if(!(n[0]===t[1]&&n[1]===a[1]||n[0]===a[1]&&n[1]===t[1]))return!1;s[1]=n[1];s[3]=n[2];return s};e.sign=function(e){return 0>e?-1:1};var a=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"];e.toRoman=function(e,t){c(O(e)&&e>0,"The number should be a positive integer.");for(var r,i=[];e>=1e3;){e-=1e3;i.push("M")}r=e/100|0;e%=100;i.push(a[r]);r=e/10|0;e%=10;i.push(a[10+r]);i.push(a[20+e]);var n=i.join("");return t?n.toLowerCase():n};e.appendToArray=function(e,t){Array.prototype.push.apply(e,t)};e.prependToArray=function(e,t){Array.prototype.unshift.apply(e,t)};e.extendObj=function(e,t){for(var a in t)e[a]=t[a]};e.getInheritableProperty=function(e,t){for(;e&&!e.has(t);)e=e.get("Parent");return e?e.get(t):null};e.inherit=function(e,t,a){e.prototype=Object.create(t.prototype);e.prototype.constructor=e;for(var r in a)e.prototype[r]=a[r]};e.loadScript=function(e,t){var a=document.createElement("script"),r=!1;a.setAttribute("src",e);t&&(a.onload=function(){r||t();r=!0});document.getElementsByTagName("head")[0].appendChild(a)};return e}(),ue=function(){function e(e,t,a,r,i,n){this.viewBox=e;this.scale=t;this.rotation=a;this.offsetX=r;this.offsetY=i;var s,o,c,l,h=(e[2]+e[0])/2,u=(e[3]+e[1])/2;a%=360;a=0>a?a+360:a;switch(a){case 180:s=-1;o=0;c=0;l=1;break;case 90:s=0;o=1;c=1;l=0;break;case 270:s=0;o=-1;c=-1;l=0;break;default:s=1;o=0;c=0;l=-1}if(n){c=-c;l=-l}var f,d,g,p;if(0===s){f=Math.abs(u-e[1])*t+r;d=Math.abs(h-e[0])*t+i;g=Math.abs(e[3]-e[1])*t;p=Math.abs(e[2]-e[0])*t}else{f=Math.abs(h-e[0])*t+r;d=Math.abs(u-e[1])*t+i;g=Math.abs(e[2]-e[0])*t;p=Math.abs(e[3]-e[1])*t}this.transform=[s*t,o*t,c*t,l*t,f-s*t*h-c*t*u,d-o*t*h-l*t*u];this.width=g;this.height=p;this.fontScale=t}e.prototype={clone:function(t){t=t||{};var a="scale"in t?t.scale:this.scale,r="rotation"in t?t.rotation:this.rotation;return new e(this.viewBox.slice(),a,r,this.offsetX,this.offsetY,t.dontFlip)},convertToViewportPoint:function(e,t){return he.applyTransform([e,t],this.transform)},convertToViewportRectangle:function(e){var t=he.applyTransform([e[0],e[1]],this.transform),a=he.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],a[0],a[1]]},convertToPdfPoint:function(e,t){return he.applyInverseTransform([e,t],this.transform)}};return e}(),fe=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];!function(){function e(e){this._status=t;this._handlers=[];try{e.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(a){this._reject(a)}}if(U.Promise){"function"!=typeof U.Promise.all&&(U.Promise.all=function(e){var t,a,r=0,i=[],n=new U.Promise(function(e,r){t=e;a=r});e.forEach(function(e,n){r++;e.then(function(e){i[n]=e;r--;0===r&&t(i)},a)});0===r&&t(i);return n});"function"!=typeof U.Promise.resolve&&(U.Promise.resolve=function(e){return new U.Promise(function(t){t(e)})});"function"!=typeof U.Promise.reject&&(U.Promise.reject=function(e){return new U.Promise(function(t,a){a(e)})});"function"!=typeof U.Promise.prototype["catch"]&&(U.Promise.prototype["catch"]=function(e){return U.Promise.prototype.then(void 0,e)})}else{var t=0,a=1,r=2,n=500,s={handlers:[],running:!1,unhandledRejections:[],pendingRejectionCheck:!1,scheduleHandlers:function(e){if(e._status!==t){this.handlers=this.handlers.concat(e._handlers);e._handlers=[];if(!this.running){this.running=!0;setTimeout(this.runHandlers.bind(this),0)}}},runHandlers:function(){for(var e=1,t=Date.now()+e;this.handlers.length>0;){var i=this.handlers.shift(),n=i.thisPromise._status,s=i.thisPromise._value;try{if(n===a)"function"==typeof i.onResolve&&(s=i.onResolve(s));else if("function"==typeof i.onReject){s=i.onReject(s);n=a;i.thisPromise._unhandledRejection&&this.removeUnhandeledRejection(i.thisPromise)}}catch(o){n=r;s=o}i.nextPromise._updateStatus(n,s);if(Date.now()>=t)break}this.handlers.length>0?setTimeout(this.runHandlers.bind(this),0):this.running=!1},addUnhandledRejection:function(e){this.unhandledRejections.push({promise:e,time:Date.now()});this.scheduleRejectionCheck()},removeUnhandeledRejection:function(e){e._unhandledRejection=!1;for(var t=0;tn){var a=this.unhandledRejections[t].promise._value,r="Unhandled rejection: "+a;a.stack&&(r+="\n"+a.stack);i(r);this.unhandledRejections.splice(t);t--}this.unhandledRejections.length&&this.scheduleRejectionCheck()}.bind(this),n)}}};e.all=function(t){function a(e){if(s._status!==r){c=[];n(e)}}var i,n,s=new e(function(e,t){i=e;n=t}),o=t.length,c=[];if(0===o){i(c);return s}for(var l=0,h=t.length;h>l;++l){var u=t[l],f=function(e){return function(t){if(s._status!==r){c[e]=t;o--;0===o&&i(c)}}}(l);e.isPromise(u)?u.then(f,a):f(u)}return s};e.isPromise=function(e){return e&&"function"==typeof e.then};e.resolve=function(t){return new e(function(e){e(t)})};e.reject=function(t){return new e(function(e,a){a(t)})};e.prototype={_status:null,_value:null,_handlers:null,_unhandledRejection:null,_updateStatus:function(t,i){if(this._status!==a&&this._status!==r)if(t===a&&e.isPromise(i))i.then(this._updateStatus.bind(this,a),this._updateStatus.bind(this,r));else{this._status=t;this._value=i;if(t===r&&0===this._handlers.length){this._unhandledRejection=!0;s.addUnhandledRejection(this)}s.scheduleHandlers(this)}},_resolve:function(e){this._updateStatus(a,e)},_reject:function(e){this._updateStatus(r,e)},then:function(t,a){var r=new e(function(e,t){this.resolve=e;this.reject=t});this._handlers.push({thisPromise:this,onResolve:t,onReject:a,nextPromise:r});s.scheduleHandlers(this);return r},"catch":function(e){return this.then(void 0,e)}};U.Promise=e}}();var de=function(){function e(e,t,a){for(;e.lengtht;++t){var s=r[t].name;s.length>n&&(n=s.length)}for(t=0,a=r.length;a>t;++t){var o=r[t],c=o.end-o.start;i+=e(o.name," ",n)+" "+c+"ms\n"}return i}};return t}(),ge=function(e,t){if("undefined"!=typeof Blob)return new Blob([e],{type:t});var a=new MozBlobBuilder;a.append(e);return a.getBlob(t)},pe=function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function(t,a,r){if(!r&&"undefined"!=typeof URL&&URL.createObjectURL){var i=ge(t,a);return URL.createObjectURL(i)}for(var n="data:"+a+";base64,",s=0,o=t.length;o>s;s+=3){var c=255&t[s],l=255&t[s+1],h=255&t[s+2],u=c>>2,f=(3&c)<<4|l>>4,d=o>s+1?(15&l)<<2|h>>6:64,g=o>s+2?63&h:64;n+=e[u]+e[f]+e[d]+e[g]}return n}}();j.prototype={on:function(e,t,a){var r=this.actionHandler;r[e]&&s('There is already an actionName called "'+e+'"');r[e]=[t,a]},send:function(e,t,a){var r={sourceName:this.sourceName,targetName:this.targetName,action:e,data:t};this.postMessage(r,a)},sendWithPromise:function(e,t,a){var r=this.callbackIndex++,i={sourceName:this.sourceName,targetName:this.targetName,action:e,data:t,callbackId:r},n=q();this.callbacksCapabilities[r]=n;try{this.postMessage(i,a)}catch(s){n.reject(s)}return n.promise},postMessage:function(e,t){t&&this.postMessageTransfers?this.comObj.postMessage(e,t):this.comObj.postMessage(e)},destroy:function(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}};!function(e){function t(e){return void 0!==f[e]}function a(){o.call(this);this._isInvalid=!0}function r(e){""==e&&a.call(this);return e.toLowerCase()}function i(e){var t=e.charCodeAt(0);return t>32&&127>t&&-1==[34,35,60,62,63,96].indexOf(t)?e:encodeURIComponent(e)}function n(e){var t=e.charCodeAt(0);return t>32&&127>t&&-1==[34,35,60,62,96].indexOf(t)?e:encodeURIComponent(e)}function s(e,s,o){function c(e){y.push(e)}var l=s||"scheme start",h=0,u="",b=!1,v=!1,y=[];e:for(;(e[h-1]!=g||0==h)&&!this._isInvalid;){var k=e[h];switch(l){case"scheme start":if(!k||!p.test(k)){if(s){c("Invalid scheme.");break e}u="";l="no scheme";continue}u+=k.toLowerCase();l="scheme";break;case"scheme":if(k&&m.test(k))u+=k.toLowerCase();else{if(":"!=k){if(s){if(g==k)break e;c("Code point not allowed in scheme: "+k);break e}u="";h=0;l="no scheme";continue}this._scheme=u;u="";if(s)break e;t(this._scheme)&&(this._isRelative=!0);l="file"==this._scheme?"relative":this._isRelative&&o&&o._scheme==this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":if("?"==k){this._query="?";l="query"}else if("#"==k){this._fragment="#";l="fragment"}else g!=k&&" "!=k&&"\n"!=k&&"\r"!=k&&(this._schemeData+=i(k));break;case"no scheme":if(o&&t(o._scheme)){l="relative";continue}c("Missing scheme.");a.call(this);break;case"relative or authority":if("/"!=k||"/"!=e[h+1]){c("Expected /, got: "+k);l="relative";continue}l="authority ignore slashes";break;case"relative":this._isRelative=!0;"file"!=this._scheme&&(this._scheme=o._scheme);if(g==k){this._host=o._host;this._port=o._port;this._path=o._path.slice();this._query=o._query;this._username=o._username;this._password=o._password;break e}if("/"==k||"\\"==k){"\\"==k&&c("\\ is an invalid code point.");l="relative slash"}else if("?"==k){this._host=o._host;this._port=o._port;this._path=o._path.slice();this._query="?";this._username=o._username;this._password=o._password;l="query"}else{if("#"!=k){var w=e[h+1],x=e[h+2];if("file"!=this._scheme||!p.test(k)||":"!=w&&"|"!=w||g!=x&&"/"!=x&&"\\"!=x&&"?"!=x&&"#"!=x){this._host=o._host;this._port=o._port;this._username=o._username;this._password=o._password;this._path=o._path.slice();this._path.pop()}l="relative path";continue}this._host=o._host;this._port=o._port;this._path=o._path.slice();this._query=o._query;this._fragment="#";this._username=o._username;this._password=o._password;l="fragment"}break;case"relative slash":if("/"!=k&&"\\"!=k){if("file"!=this._scheme){this._host=o._host;this._port=o._port;this._username=o._username;this._password=o._password}l="relative path";continue}"\\"==k&&c("\\ is an invalid code point.");l="file"==this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!=k){c("Expected '/', got: "+k);l="authority ignore slashes";continue}l="authority second slash";break;case"authority second slash":l="authority ignore slashes";if("/"!=k){c("Expected '/', got: "+k);continue}break;case"authority ignore slashes":if("/"!=k&&"\\"!=k){l="authority";continue}c("Expected authority, got: "+k);break;case"authority":if("@"==k){if(b){c("@ already seen.");u+="%40"}b=!0;for(var C=0;Cm;++m){var v=p.get(m),y=this.createDict(A,this.parseDict(v),t.strings);this.parsePrivateDict(y);t.fdArray.push(y)}g=null;d=this.parseCharsets(c.getByName("charset"),h.count,t.strings,!0);t.fdSelect=this.parseFDSelect(c.getByName("FDSelect"),h.count)}else{d=this.parseCharsets(c.getByName("charset"),h.count,t.strings,!1);g=this.parseEncoding(c.getByName("Encoding"),e,t.strings,d.charset)}t.charset=d;t.encoding=g;var w=this.parseCharStrings(h,c.privateDict.subrsIndex,s.obj,t.fdSelect,t.fdArray);t.charStrings=w.charStrings;t.seacs=w.seacs;t.widths=w.widths;return t},parseHeader:function(){for(var e=this.bytes,t=e.length,a=0;t>a&&1!==e[a];)++a;if(a>=t)i("Invalid CFF header");else if(0!==a){n("cff data is shifted");e=e.subarray(a);this.bytes=e}var r=e[0],s=e[1],o=e[2],c=e[3],l=new w(r,s,o,c);return{obj:l,endPos:o}},parseDict:function(e){function t(){var t=e[r++];if(30===t)return a();if(28===t){t=e[r++];t=(t<<24|e[r++]<<16)>>16;return t}if(29===t){t=e[r++];t=t<<8|e[r++];t=t<<8|e[r++];t=t<<8|e[r++];return t}if(t>=32&&246>=t)return t-139;if(t>=247&&250>=t)return 256*(t-247)+e[r++]+108;if(t>=251&&254>=t)return-(256*(t-251))-e[r++]-108;i("255 is not a valid DICT command");return-1}function a(){for(var t="",a=15,i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"],n=e.length;n>r;){var s=e[r++],o=s>>4,c=15&s;if(o===a)break;t+=i[o];if(c===a)break;t+=i[c]}return parseFloat(t)}var r=0,n=[],s=[];r=0;for(var o=e.length;o>r;){var c=e[r];if(21>=c){12===c&&(c=c<<8|e[++r]);s.push([c,n]);n=[];++r}else n.push(t())}return s},parseIndex:function(e){var t,a,r=new C,i=this.bytes,n=i[e++]<<8|i[e++],s=[],o=e;if(0!==n){var c=i[e++],l=e+(n+1)*c-1;for(t=0,a=n+1;a>t;++t){for(var h=0,u=0;c>u;++u){h<<=8;h+=i[e++]}s.push(l+h)}o=s[n]}for(t=0,a=s.length-1;a>t;++t){var f=s[t],d=s[t+1];r.add(i.subarray(f,d))}return{obj:r,endPos:o}},parseNameIndex:function(e){for(var t=[],a=0,r=e.count;r>a;++a){for(var i=e.get(a),n=Math.min(i.length,127),o=[],c=0;n>c;++c){var l=i[c];(0!==c||0!==l)&&(33>l||l>126||91===l||93===l||40===l||41===l||123===l||125===l||60===l||62===l||47===l||37===l||35===l)?o[c]=95:o[c]=l}t.push(s(o))}return t},parseStringIndex:function(e){for(var t=new x,a=0,r=e.count;r>a;++a){var i=e.get(a);t.add(s(i))}return t},createDict:function(e,t,a){for(var r=new e(a),i=0,n=t.length;n>i;++i){var s=t[i],o=s[0],c=s[1];r.setByKey(o,c)}return r},parseCharString:function(e,r,i,n){if(e.callDepth>b)return!1;for(var s=e.stackSize,c=e.stack,l=r.length,h=0;l>h;){var u=r[h++],f=null;if(12===u){var d=r[h++];if(0===d){r[h-2]=139;r[h-1]=22;s=0}else f=a[d]}else if(28===u){c[s]=(r[h]<<24|r[h+1]<<16)>>16;h+=2;s++}else if(14===u){if(s>=4){s-=4;if(this.seacAnalysisEnabled){e.seac=c.slice(s,s+4);return!1}}f=t[u]}else if(u>=32&&246>=u){c[s]=u-139;s++}else if(u>=247&&254>=u){c[s]=251>u?(u-247<<8)+r[h]+108:-(u-251<<8)-r[h]-108;h++;s++}else if(255===u){c[s]=(r[h]<<24|r[h+1]<<16|r[h+2]<<8|r[h+3])/65536;h+=4;s++}else if(19===u||20===u){e.hints+=s>>1;h+=e.hints+7>>3;s%=2;f=t[u]}else{if(10===u||29===u){var g;g=10===u?i:n;if(!g){f=t[u];o("Missing subrsIndex for "+f.id);return!1}var p=32768;g.count<1240?p=107:g.count<33900&&(p=1131);var m=c[--s]+p;if(0>m||m>=g.count){f=t[u];o("Out of bounds subrIndex for "+f.id);return!1}e.stackSize=s;e.callDepth++;var v=this.parseCharString(e,g.get(m),i,n);if(!v)return!1;e.callDepth--;s=e.stackSize;continue}if(11===u){e.stackSize=s;return!0}f=t[u]}if(f){f.stem&&(e.hints+=s>>1);if("min"in f&&!e.undefStack&&s=2&&f.stem?s%=2:s>1&&o("Found too many parameters for stack-clearing command");s>0&&c[s-1]>=0&&(e.width=c[s-1])}if("stackDelta"in f){"stackFn"in f&&f.stackFn(c,s);s+=f.stackDelta}else if(f.stackClearing)s=0;else if(f.resetStack){s=0;e.undefStack=!1}else if(f.undefStack){s=0;e.undefStack=!0;e.firstStackClearing=!1}}}e.stackSize=s;return!0},parseCharStrings:function(e,t,a,r,i){for(var n=[],s=[],c=e.count,l=0;c>l;l++){var h=e.get(l),u={callDepth:0,stackSize:0,stack:[],undefStack:!0,hints:0,firstStackClearing:!0,seac:null,width:null},f=!0,d=null;if(r&&i.length){var g=r.getFDIndex(l);if(-1===g){o("Glyph index is not in fd select.");f=!1}if(g>=i.length){o("Invalid fd index for glyph index.");f=!1}f&&(d=i[g].privateDict.subrsIndex)}else t&&(d=t);f&&(f=this.parseCharString(u,h,d,a));null!==u.width&&(s[l]=u.width);null!==u.seac&&(n[l]=u.seac);f||e.set(l,new Uint8Array([14]))}return{charStrings:e,seacs:n,widths:s}},emptyPrivateDictionary:function(e){var t=this.createDict(I,[],e.strings);e.setByKey(18,[0,0]);e.privateDict=t},parsePrivateDict:function(e){if(e.hasName("Private")){var t=e.getByName("Private");if(c(t)&&2===t.length){var a=t[0],r=t[1];if(0===a||r>=this.bytes.length)this.emptyPrivateDictionary(e);else{var i=r+a,n=this.bytes.subarray(r,i),s=this.parseDict(n),o=this.createDict(I,s,e.strings);e.privateDict=o;if(o.getByName("Subrs")){var l=o.getByName("Subrs"),h=r+l;if(0===l||h>=this.bytes.length)this.emptyPrivateDictionary(e);else{var u=this.parseIndex(h);o.subrsIndex=u.obj}}}}else e.removeByName("Private")}else this.emptyPrivateDictionary(e)},parseCharsets:function(e,t,a,r){if(0===e)return new R(!0,B.ISO_ADOBE,f);if(1===e)return new R(!0,B.EXPERT,d);if(2===e)return new R(!0,B.EXPERT_SUBSET,g);var n,s,o,c=this.bytes,l=e,h=c[e++],u=[".notdef"];t-=1;switch(h){case 0:for(o=0;t>o;o++){n=c[e++]<<8|c[e++];u.push(r?n:a.get(n))}break;case 1:for(;u.length<=t;){n=c[e++]<<8|c[e++];s=c[e++];for(o=0;s>=o;o++)u.push(r?n++:a.get(n++))}break;case 2:for(;u.length<=t;){n=c[e++]<<8|c[e++];s=c[e++]<<8|c[e++];for(o=0;s>=o;o++)u.push(r?n++:a.get(n++))}break;default:i("Unknown charset format")}var p=e,m=c.subarray(l,p);return new R(!1,h,u,m)},parseEncoding:function(e,t,a,r){function n(){var t=h[e++];for(o=0;t>o;o++){var i=h[e++],n=(h[e++]<<8)+(255&h[e++]);l[i]=r.indexOf(a.get(n))}}var s,o,c,l=Object.create(null),h=this.bytes,u=!1,f=!1,d=null;if(0===e||1===e){u=!0;s=e;var g=e?m:p;for(o=0,c=r.length;c>o;o++){var b=g.indexOf(r[o]);-1!==b&&(l[b]=o)}}else{var v=e;s=h[e++];switch(127&s){case 0:var y=h[e++];for(o=1;y>=o;o++)l[h[e++]]=o;break;case 1:var k=h[e++],w=1;for(o=0;k>o;o++)for(var x=h[e++],C=h[e++],S=x;x+C>=S;S++)l[S]=w++;break;default:i("Unknow encoding format: "+s+" in CFF")}var A=e;if(128&s){h[v]&=127;n();f=!0}d=h.subarray(v,A)}s=127&s;return new T(u,s,l,d)},parseFDSelect:function(e,t){var a,r,n=e,s=this.bytes,c=s[e++],l=[],h=!1;switch(c){case 0:for(r=0;t>r;++r){var f=s[e++];l.push(f)}a=s.subarray(n,e);break;case 3:var d=s[e++]<<8|s[e++];for(r=0;d>r;++r){var g=s[e++]<<8|s[e++];if(0===r&&0!==g){o("parseFDSelect: The first range must have a first GID of 0 -- trying to recover.");h=!0;g=0}for(var p=s[e++],m=s[e]<<8|s[e+1],b=g;m>b;++b)l.push(p)}e+=2;a=s.subarray(n,e);h&&(a[3]=a[4]=0);break;default:i('parseFDSelect: Unknown format "'+c+'".')}u(l.length===t,"parseFDSelect: Invalid font data.");return new O(l,a)}};return e}(),k=function(){function e(){this.header=null;this.names=[];this.topDict=null;this.strings=new x;this.globalSubrIndex=null;this.encoding=null;this.charset=null;this.charStrings=null;this.fdArray=[];this.fdSelect=null;this.isCIDFont=!1}return e}(),w=function(){function e(e,t,a,r){this.major=e;this.minor=t;this.hdrSize=a;this.offSize=r}return e}(),x=function(){function e(){this.strings=[]}e.prototype={get:function(e){return e>=0&&390>=e?v[e]:e-391<=this.strings.length?this.strings[e-391]:v[0]},add:function(e){this.strings.push(e)},get count(){return this.strings.length}};return e}(),C=function(){function e(){this.objects=[];this.length=0}e.prototype={add:function(e){this.length+=e.length;this.objects.push(e)},set:function(e,t){this.length+=t.length-this.objects[e].length;this.objects[e]=t},get:function(e){return this.objects[e]},get count(){return this.objects.length}};return e}(),S=function(){function e(e,t){this.keyToNameMap=e.keyToNameMap;this.nameToKeyMap=e.nameToKeyMap;this.defaults=e.defaults;this.types=e.types;this.opcodes=e.opcodes;this.order=e.order;this.strings=t;this.values=Object.create(null)}e.prototype={setByKey:function(e,t){if(!(e in this.keyToNameMap))return!1;if(0===t.length)return!0;var a=this.types[e];if("num"===a||"sid"===a||"offset"===a){t=t[0];if(isNaN(t)){o("Invalid CFFDict value: "+t+", for key: "+e+".");return!0}}this.values[e]=t;return!0},setByName:function(e,t){e in this.nameToKeyMap||i('Invalid dictionary name "'+e+'"');this.values[this.nameToKeyMap[e]]=t},hasName:function(e){return this.nameToKeyMap[e]in this.values},getByName:function(e){e in this.nameToKeyMap||i('Invalid dictionary name "'+e+'"');var t=this.nameToKeyMap[e];return t in this.values?this.values[t]:this.defaults[t]},removeByName:function(e){delete this.values[this.nameToKeyMap[e]]}};e.createTables=function(e){for(var t={keyToNameMap:{},nameToKeyMap:{},defaults:{},types:{},opcodes:{},order:[]},a=0,r=e.length;r>a;++a){var i=e[a],n=c(i[0])?(i[0][0]<<8)+i[0][1]:i[0];t.keyToNameMap[n]=i[1];t.nameToKeyMap[i[1]]=n;t.types[n]=i[2];t.defaults[n]=i[3];t.opcodes[n]=c(i[0])?i[0]:[i[0]];t.order.push(n)}return t};return e}(),A=function(){function e(e){null===a&&(a=S.createTables(t));S.call(this,a,e);this.privateDict=null}var t=[[[12,30],"ROS",["sid","sid","num"],null],[[12,20],"SyntheticBase","num",null],[0,"version","sid",null],[1,"Notice","sid",null],[[12,0],"Copyright","sid",null],[2,"FullName","sid",null],[3,"FamilyName","sid",null],[4,"Weight","sid",null],[[12,1],"isFixedPitch","num",0],[[12,2],"ItalicAngle","num",0],[[12,3],"UnderlinePosition","num",-100],[[12,4],"UnderlineThickness","num",50],[[12,5],"PaintType","num",0],[[12,6],"CharstringType","num",2],[[12,7],"FontMatrix",["num","num","num","num","num","num"],[.001,0,0,.001,0,0]],[13,"UniqueID","num",null],[5,"FontBBox",["num","num","num","num"],[0,0,0,0]],[[12,8],"StrokeWidth","num",0],[14,"XUID","array",null],[15,"charset","offset",0],[16,"Encoding","offset",0],[17,"CharStrings","offset",0],[18,"Private",["offset","offset"],null],[[12,21],"PostScript","sid",null],[[12,22],"BaseFontName","sid",null],[[12,23],"BaseFontBlend","delta",null],[[12,31],"CIDFontVersion","num",0],[[12,32],"CIDFontRevision","num",0],[[12,33],"CIDFontType","num",0],[[12,34],"CIDCount","num",8720],[[12,35],"UIDBase","num",null],[[12,37],"FDSelect","offset",null],[[12,36],"FDArray","offset",null],[[12,38],"FontName","sid",null]],a=null;e.prototype=Object.create(S.prototype);return e}(),I=function(){function e(e){null===a&&(a=S.createTables(t));S.call(this,a,e);this.subrsIndex=null}var t=[[6,"BlueValues","delta",null],[7,"OtherBlues","delta",null],[8,"FamilyBlues","delta",null],[9,"FamilyOtherBlues","delta",null],[[12,9],"BlueScale","num",.039625],[[12,10],"BlueShift","num",7],[[12,11],"BlueFuzz","num",1],[10,"StdHW","num",null],[11,"StdVW","num",null],[[12,12],"StemSnapH","delta",null],[[12,13],"StemSnapV","delta",null],[[12,14],"ForceBold","num",0],[[12,17],"LanguageGroup","num",0],[[12,18],"ExpansionFactor","num",.06],[[12,19],"initialRandomSeed","num",0],[20,"defaultWidthX","num",0],[21,"nominalWidthX","num",0],[19,"Subrs","offset",null]],a=null;e.prototype=Object.create(S.prototype);return e}(),B={ISO_ADOBE:0,EXPERT:1,EXPERT_SUBSET:2},R=function(){function e(e,t,a,r){this.predefined=e;this.format=t;this.charset=a;this.raw=r}return e}(),T=function(){function e(e,t,a,r){this.predefined=e;this.format=t;this.encoding=a;this.raw=r}return e}(),O=function(){function e(e,t){this.fdSelect=e;this.raw=t}e.prototype={getFDIndex:function(e){return 0>e||e>=this.fdSelect.length?-1:this.fdSelect[e]}};return e}(),P=function(){function e(){this.offsets=Object.create(null)}e.prototype={isTracking:function(e){return e in this.offsets},track:function(e,t){e in this.offsets&&i("Already tracking location of "+e);this.offsets[e]=t},offset:function(e){for(var t in this.offsets)this.offsets[t]+=e},setEntryLocation:function(e,t,a){e in this.offsets||i("Not tracking location of "+e);for(var r=a.data,n=this.offsets[e],s=5,o=0,c=t.length;c>o;++o){var l=o*s+n,h=l+1,u=l+2,f=l+3,d=l+4;29===r[l]&&0===r[h]&&0===r[u]&&0===r[f]&&0===r[d]||i("writing to an offset that is not empty");var g=t[o];r[l]=29;r[h]=g>>24&255;r[u]=g>>16&255;r[f]=g>>8&255;r[d]=255&g}}};return e}(),L=function(){function e(e){this.cff=e}e.prototype={compile:function(){var e=this.cff,t={data:[],length:0,add:function(e){this.data=this.data.concat(e);this.length=this.data.length}},a=this.compileHeader(e.header);t.add(a);var r=this.compileNameIndex(e.names);t.add(r);if(e.isCIDFont&&e.topDict.hasName("FontMatrix")){var i=e.topDict.getByName("FontMatrix");e.topDict.removeByName("FontMatrix");for(var n=0,s=e.fdArray.length;s>n;n++){var o=e.fdArray[n],c=i.slice(0);o.hasName("FontMatrix")&&(c=l.transform(c,o.getByName("FontMatrix")));o.setByName("FontMatrix",c)}}var h=this.compileTopDicts([e.topDict],t.length,e.isCIDFont);t.add(h.output);var u=h.trackers[0],f=this.compileStringIndex(e.strings.strings);t.add(f);var d=this.compileIndex(e.globalSubrIndex);t.add(d);if(e.encoding&&e.topDict.hasName("Encoding"))if(e.encoding.predefined)u.setEntryLocation("Encoding",[e.encoding.format],t);else{var g=this.compileEncoding(e.encoding);u.setEntryLocation("Encoding",[t.length],t);t.add(g)}if(e.charset&&e.topDict.hasName("charset"))if(e.charset.predefined)u.setEntryLocation("charset",[e.charset.format],t);else{var p=this.compileCharset(e.charset);u.setEntryLocation("charset",[t.length],t);t.add(p)}var m=this.compileCharStrings(e.charStrings);u.setEntryLocation("CharStrings",[t.length],t);t.add(m);if(e.isCIDFont){u.setEntryLocation("FDSelect",[t.length],t);var b=this.compileFDSelect(e.fdSelect.raw);t.add(b);h=this.compileTopDicts(e.fdArray,t.length,!0);u.setEntryLocation("FDArray",[t.length],t);t.add(h.output);var v=h.trackers;this.compilePrivateDicts(e.fdArray,v,t)}this.compilePrivateDicts([e.topDict],[u],t);t.add([0]);return t.data},encodeNumber:function(e){return parseFloat(e)!==parseInt(e,10)||isNaN(e)?this.encodeFloat(e):this.encodeInteger(e)},encodeFloat:function(e){var t=e.toString(),a=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(a){var r=parseFloat("1e"+((a[2]?+a[2]:0)+a[1].length));t=(Math.round(e*r)/r).toString()}var i,n,s="";for(i=0,n=t.length;n>i;++i){var o=t[i];s+="e"===o?"-"===t[++i]?"c":"b":"."===o?"a":"-"===o?"e":o}s+=1&s.length?"f":"ff";var c=[30];for(i=0,n=s.length;n>i;i+=2)c.push(parseInt(s.substr(i,2),16));return c},encodeInteger:function(e){var t;if(e>=-107&&107>=e)t=[e+139];else if(e>=108&&1131>=e){e-=108;t=[(e>>8)+247,255&e]}else if(e>=-1131&&-108>=e){e=-e-108;t=[(e>>8)+251,255&e]}else t=e>=-32768&&32767>=e?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e];return t},compileHeader:function(e){return[e.major,e.minor,e.hdrSize,e.offSize]},compileNameIndex:function(e){for(var t=new C,a=0,r=e.length;r>a;++a)t.add(h(e[a]));return this.compileIndex(t)},compileTopDicts:function(e,t,a){for(var r=[],i=new C,n=0,s=e.length;s>n;++n){var o=e[n];if(a){o.removeByName("CIDFontVersion");o.removeByName("CIDFontRevision");o.removeByName("CIDFontType");o.removeByName("CIDCount");o.removeByName("UIDBase")}var c=new P,l=this.compileDict(o,c);r.push(c);i.add(l);c.offset(t)}i=this.compileIndex(i,r);return{trackers:r,output:i}},compilePrivateDicts:function(e,t,a){for(var r=0,i=e.length;i>r;++r){var n=e[r];u(n.privateDict&&n.hasName("Private"),"There must be an private dictionary.");var s=n.privateDict,o=new P,c=this.compileDict(s,o),l=a.length;o.offset(l);c.length||(l=0);t[r].setEntryLocation("Private",[c.length,l],a);a.add(c);if(s.subrsIndex&&s.hasName("Subrs")){var h=this.compileIndex(s.subrsIndex);o.setEntryLocation("Subrs",[c.length],a);a.add(h)}}},compileDict:function(e,t){for(var a=[],r=e.order,n=0;nh;++h){var f=l[h],d=o[h];switch(f){case"num":case"sid":a=a.concat(this.encodeNumber(d));break;case"offset":var g=e.keyToNameMap[s];t.isTracking(g)||t.track(g,a.length);a=a.concat([29,0,0,0,0]);break;case"array":case"delta":a=a.concat(this.encodeNumber(d));for(var p=1,m=o.length;m>p;++p)a=a.concat(this.encodeNumber(o[p]));break;default:i("Unknown data type of "+f)}}a=a.concat(e.opcodes[s])}}}return a},compileStringIndex:function(e){for(var t=new C,a=0,r=e.length;r>a;++a)t.add(h(e[a]));return this.compileIndex(t)},compileGlobalSubrIndex:function(){var e=this.cff.globalSubrIndex;this.out.writeByteArray(this.compileIndex(e))},compileCharStrings:function(e){return this.compileIndex(e)},compileCharset:function(e){return this.compileTypedArray(e.raw)},compileEncoding:function(e){return this.compileTypedArray(e.raw)},compileFDSelect:function(e){return this.compileTypedArray(e)},compileTypedArray:function(e){for(var t=[],a=0,r=e.length;r>a;++a)t[a]=e[a];return t},compileIndex:function(e,t){t=t||[];var a=e.objects,r=a.length;if(0===r)return[0,0,0];var i,n=[r>>8&255,255&r],s=1;for(i=0;r>i;++i)s+=a[i].length;var o;o=256>s?1:65536>s?2:16777216>s?3:4;n.push(o);var c=1;for(i=0;r+1>i;i++){1===o?n.push(255&c):2===o?n.push(c>>8&255,255&c):3===o?n.push(c>>16&255,c>>8&255,255&c):n.push(c>>>24&255,c>>16&255,c>>8&255,255&c);a[i]&&(c+=a[i].length)}for(i=0;r>i;i++){t[i]&&t[i].offset(n.length);for(var l=0,h=a[i].length;h>l;l++)n.push(a[i][l])}return n}};return e}();e.CFFStandardStrings=v;e.CFFParser=y;e.CFF=k;e.CFFHeader=w;e.CFFStrings=x;e.CFFIndex=C;e.CFFCharset=R;e.CFFTopDict=A;e.CFFPrivateDict=I;e.CFFCompiler=L});!function(e,t){t(e.pdfjsCoreChunkedStream={},e.pdfjsSharedUtil)}(this,function(e,t){var a=t.MissingDataException,r=t.arrayByteLength,i=t.arraysToBytes,n=t.assert,s=t.createPromiseCapability,o=t.isInt,c=t.isEmptyObj,l=function(){function e(e,t,a){this.bytes=new Uint8Array(e);this.start=0;this.pos=0;this.end=e;this.chunkSize=t;this.loadedChunks=[];this.numChunksLoaded=0;this.numChunks=Math.ceil(e/t);this.manager=a;this.progressiveDataLength=0;this.lastSuccessfulEnsureByteChunk=-1}e.prototype={getMissingChunks:function(){for(var e=[],t=0,a=this.numChunks;a>t;++t)this.loadedChunks[t]||e.push(t);return e},getBaseStreams:function(){return[this]},allChunksLoaded:function(){return this.numChunksLoaded===this.numChunks},onReceiveData:function(e,t){var a=e+t.byteLength;n(e%this.chunkSize===0,"Bad begin offset: "+e);var r=this.bytes.length;n(a%this.chunkSize===0||a===r,"Bad end offset: "+a);this.bytes.set(new Uint8Array(t),e);var i,s=this.chunkSize,o=Math.floor(e/s),c=Math.floor((a-1)/s)+1;for(i=o;c>i;++i)if(!this.loadedChunks[i]){this.loadedChunks[i]=!0;++this.numChunksLoaded}},onReceiveProgressiveData:function(e){var t=this.progressiveDataLength,a=Math.floor(t/this.chunkSize);this.bytes.set(new Uint8Array(e),t);t+=e.byteLength;this.progressiveDataLength=t;var r,i=t>=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(r=a;i>r;++r)if(!this.loadedChunks[r]){this.loadedChunks[r]=!0;++this.numChunksLoaded}},ensureByte:function(e){var t=Math.floor(e/this.chunkSize);if(t!==this.lastSuccessfulEnsureByteChunk){if(!this.loadedChunks[t])throw new a(e,e+1);this.lastSuccessfulEnsureByteChunk=t}},ensureRange:function(e,t){if(!(e>=t||t<=this.progressiveDataLength))for(var r=this.chunkSize,i=Math.floor(e/r),n=Math.floor((t-1)/r)+1,s=i;n>s;++s)if(!this.loadedChunks[s])throw new a(e,t)},nextEmptyChunk:function(e){for(var t,a=this.numChunks,r=0;a>r;++r){t=(e+r)%a;if(!this.loadedChunks[t])return t}return null},hasChunk:function(e){return!!this.loadedChunks[e]},get length(){return this.end-this.start},get isEmpty(){return 0===this.length},getByte:function(){var e=this.pos;if(e>=this.end)return-1;this.ensureByte(e);return this.bytes[this.pos++]},getUint16:function(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function(){var e=this.getByte(),t=this.getByte(),a=this.getByte(),r=this.getByte();return(e<<24)+(t<<16)+(a<<8)+r},getBytes:function(e){var t=this.bytes,a=this.pos,r=this.end;if(!e){this.ensureRange(a,r);return t.subarray(a,r)}var i=a+e;i>r&&(i=r);this.ensureRange(a,i);this.pos=i;return t.subarray(a,i)},peekByte:function(){var e=this.getByte();this.pos--;return e},peekBytes:function(e){var t=this.getBytes(e);this.pos-=t.length;return t},getByteRange:function(e,t){this.ensureRange(e,t);return this.bytes.subarray(e,t)},skip:function(e){e||(e=1);this.pos+=e},reset:function(){this.pos=this.start},moveStart:function(){this.start=this.pos},makeSubStream:function(e,t,a){function r(){}this.ensureRange(e,e+t);r.prototype=Object.create(this);r.prototype.getMissingChunks=function(){for(var e=this.chunkSize,t=Math.floor(this.start/e),a=Math.floor((this.end-1)/e)+1,r=[],i=t;a>i;++i)this.loadedChunks[i]||r.push(i);return r};var i=new r;i.pos=i.start=e;i.end=e+t||this.end;i.dict=a;return i},isStream:!0};return e}(),h=function(){function e(e,t){var a=t.rangeChunkSize,r=t.length;this.stream=new l(r,a,this);this.length=r;this.chunkSize=a;this.pdfNetworkStream=e;this.url=t.url;this.disableAutoFetch=t.disableAutoFetch;this.msgHandler=t.msgHandler;this.currRequestId=0; +this.chunksNeededByRequest=Object.create(null);this.requestsByChunk=Object.create(null);this.promisesByRequest=Object.create(null);this.progressiveDataLength=0;this.aborted=!1;this._loadedStreamCapability=s()}e.prototype={onLoadedStream:function(){return this._loadedStreamCapability.promise},sendRequest:function(e,t){var a=this.pdfNetworkStream.getRangeReader(e,t);a.isStreamingSupported||(a.onProgress=this.onProgress.bind(this));var n=[],s=0,o=this,c=new Promise(function(e,t){var c=function(l){try{if(!l.done){var h=l.value;n.push(h);s+=r(h);a.isStreamingSupported&&o.onProgress({loaded:s});a.read().then(c,t);return}var u=i(n);n=null;e(u)}catch(f){t(f)}};a.read().then(c,t)});c.then(function(t){this.aborted||this.onReceiveData({chunk:t,begin:e})}.bind(this))},requestAllChunks:function(){var e=this.stream.getMissingChunks();this._requestChunks(e);return this._loadedStreamCapability.promise},_requestChunks:function(e){var t,a,r=this.currRequestId++,i=Object.create(null);this.chunksNeededByRequest[r]=i;for(t=0,a=e.length;a>t;t++)this.stream.hasChunk(e[t])||(i[e[t]]=!0);if(c(i))return Promise.resolve();var n=s();this.promisesByRequest[r]=n;var o=[];for(var l in i){l=0|l;if(!(l in this.requestsByChunk)){this.requestsByChunk[l]=[];o.push(l)}this.requestsByChunk[l].push(r)}if(!o.length)return n.promise;var h=this.groupChunks(o);for(t=0;tn;++n)i.push(n);return this._requestChunks(i)},requestRanges:function(e){e=e||[];for(var t=[],a=0;an;++n)t.indexOf(n)<0&&t.push(n);t.sort(function(e,t){return e-t});return this._requestChunks(t)},groupChunks:function(e){for(var t=[],a=-1,r=-1,i=0;ia&&(a=n);if(r>=0&&r+1!==n){t.push({beginChunk:a,endChunk:r+1});a=n}i+1===e.length&&t.push({beginChunk:a,endChunk:n+1});r=n}return t},onProgress:function(e){var t=this.stream.numChunksLoaded*this.chunkSize+e.loaded;this.msgHandler.send("DocProgress",{loaded:t,total:this.length})},onReceiveData:function(e){var t=e.chunk,a=void 0===e.begin,r=a?this.progressiveDataLength:e.begin,i=r+t.byteLength,n=Math.floor(r/this.chunkSize),s=it;++t){var f=this.requestsByChunk[t]||[];delete this.requestsByChunk[t];for(l=0;lr;r++){var s=a.readBit(i,n);n=256>n?n<<1|s:511&(n<<1|s)|256;t=t<<1|s}return t>>>0}var i=e.getContexts(t),n=1,s=r(1),o=r(1)?r(1)?r(1)?r(1)?r(1)?r(32)+4436:r(12)+340:r(8)+84:r(6)+20:r(4)+4:r(2);return 0===s?o:o>0?-o:null}function h(e,t,a){for(var r=e.getContexts("IAID"),i=1,n=0;a>n;n++){var s=t.readBit(r,i);i=i<<1|s}return 31>a?i&(1<i;i++){o=f[i]=new Uint8Array(e);c=1>i?o:f[i-1];l=2>i?o:f[i-2];r=l[0]<<13|l[1]<<12|l[2]<<11|c[0]<<7|c[1]<<6|c[2]<<5|c[3]<<4;for(n=0;e>n;n++){o[n]=s=h.readBit(u,r);r=(r&d)<<1|(e>n+3?l[n+3]<<11:0)|(e>n+4?c[n+4]<<4:0)|s}}return f}function f(e,t,a,i,n,s,o,c){e&&r("JBIG2 error: MMR encoding is not supported");if(0===i&&!s&&!n&&4===o.length&&3===o[0].x&&-1===o[0].y&&-3===o[1].x&&-1===o[1].y&&2===o[2].x&&-2===o[2].y&&-2===o[3].x&&-2===o[3].y)return u(t,a,c);var l=!!s,h=A[i].concat(o);h.sort(function(e,t){return e.y-t.y||e.x-t.x});var f,d,g=h.length,p=new Int8Array(g),m=new Int8Array(g),b=[],v=0,y=0,k=0,w=0;for(d=0;g>d;d++){p[d]=h[d].x;m[d]=h[d].y;y=Math.min(y,h[d].x);k=Math.max(k,h[d].x);w=Math.min(w,h[d].y);g-1>d&&h[d].y===h[d+1].y&&h[d].x===h[d+1].x-1?v|=1<f;f++){d=b[f];C[f]=h[d].x;S[f]=h[d].y;I[f]=1<H;H++){if(n){var G=U.readBit(N,q);_^=G;if(_){F.push(j);continue}}j=new Uint8Array(j);F.push(j);for(R=0;t>R;R++)if(l&&s[H][R])j[R]=0;else{if(R>=M&&D>R&&H>=E){z=z<<1&v;for(d=0;x>d;d++){T=H+S[d];O=R+C[d];P=F[T][O];if(P){P=I[d];z|=P}}}else{z=0;L=g-1;for(d=0;g>d;d++,L--){O=R+p[d];if(O>=0&&t>O){T=H+m[d];if(T>=0){P=F[T][O];P&&(z|=P<u;u++){d[u]=h[u].x;g[u]=h[u].y}var p=I[a].reference;0===a&&(p=p.concat([c[1]]));var m=p.length,b=new Int32Array(m),v=new Int32Array(m);for(u=0;m>u;u++){b[u]=p[u].x;v[u]=p[u].y}for(var y=i[0].length,k=i.length,w=R[a],x=[],C=l.decoder,S=l.contextCache.getContexts("GR"),A=0,B=0;t>B;B++){if(o){var T=C.readBit(S,w);A^=T;A&&r("JBIG2 error: prediction is not supported")}var O=new Uint8Array(e);x.push(O);for(var P=0;e>P;P++){var L,M,E=0;for(u=0;f>u;u++){L=B+g[u];M=P+d[u];0>L||0>M||M>=e?E<<=1:E=E<<1|x[L][M]}for(u=0;m>u;u++){L=B+v[u]+s;M=P+b[u]+n;0>L||L>=k||0>M||M>=y?E<<=1:E=E<<1|i[L][M]}var D=C.readBit(S,E);O[P]=D}}return x}function g(e,t,n,s,o,c,l,u,g,m,b){e&&r("JBIG2 error: huffman is not supported");for(var v=[],y=0,k=i(n.length+s),w=b.decoder,x=b.contextCache;v.length1)B=p(e,t,S,y,0,R,1,n.concat(v),k,0,0,1,0,c,g,m,b);else{var T=h(x,w,k),O=a(x,"IARDX",w),P=a(x,"IARDY",w),L=TF;F++)E[F]&&M.push(n[F]);for(var N=0;s>N;F++,N++)E[F]&&M.push(v[N]);return M}function p(e,t,i,n,s,o,c,l,u,f,g,p,m,b,v,y,k){e&&r("JBIG2 error: huffman is not supported");var w,x,C=[];for(w=0;n>w;w++){x=new Uint8Array(i);if(s)for(var S=0;i>S;S++)x[S]=s;C.push(x)}var A=k.decoder,I=k.contextCache,B=-a(I,"IADT",A),R=0;w=0;for(;o>w;){var T=a(I,"IADT",A);B+=T;var O=a(I,"IAFS",A);R+=O;for(var P=R;;){var L=1===c?0:a(I,"IAIT",A),M=c*B+L,E=h(I,A,u),D=t&&a(I,"IARI",A),q=l[E],j=q[0].length,F=q.length;if(D){var U=a(I,"IARDW",A),N=a(I,"IARDH",A),_=a(I,"IARDX",A),z=a(I,"IARDY",A);j+=U;F+=N;q=d(j,F,v,q,(U>>1)+_,(N>>1)+z,!1,y,k)}var H,G,X,W=M-(1&p?0:F),V=P-(2&p?j:0);if(f){for(H=0;F>H;H++){x=C[V+H];if(x){X=q[H];var K=Math.min(i-W,j);switch(m){case 0:for(G=0;K>G;G++)x[W+G]|=X[G];break;case 2:for(G=0;K>G;G++)x[W+G]^=X[G];break;default:r("JBIG2 error: operator "+m+" is not supported")}}}P+=F-1}else{for(G=0;F>G;G++){x=C[W+G];if(x){X=q[G];switch(m){case 0:for(H=0;j>H;H++)x[V+H]|=X[H];break;case 2:for(H=0;j>H;H++)x[V+H]^=X[H];break;default:r("JBIG2 error: operator "+m+" is not supported")}}}P+=j-1}w++;var Y=a(I,"IADS",A);if(null===Y)break;P+=Y+g}}return C}function m(e,t){var a={};a.number=o(e,t);var i=e[t+4],n=63&i;S[n]||r("JBIG2 error: invalid segment type: "+n);a.type=n;a.typeName=S[n];a.deferredNonRetain=!!(128&i);var c=!!(64&i),l=e[t+5],h=l>>5&7,u=[31&l],f=t+6;if(7===l){h=536870911&o(e,f-1);f+=3;var d=h+7>>3;u[0]=e[f++];for(;--d>0;)u.push(e[f++])}else 5!==l&&6!==l||r("JBIG2 error: invalid referred-to flags");a.retainBits=u;var g,p,m=a.number<=256?1:a.number<=65536?2:4,b=[];for(g=0;h>g;g++){var y=1===m?e[f]:2===m?s(e,f):o(e,f);b.push(y);f+=m}a.referredTo=b;if(c){a.pageAssociation=o(e,f);f+=4}else a.pageAssociation=e[f++];a.length=o(e,f);f+=4;if(4294967295===a.length)if(38===n){var k=v(e,f),w=e[f+T],x=!!(1&w),C=6,A=new Uint8Array(C);if(!x){A[0]=255;A[1]=172}A[2]=k.height>>>24&255;A[3]=k.height>>16&255;A[4]=k.height>>8&255;A[5]=255&k.height;for(g=f,p=e.length;p>g;g++){for(var I=0;C>I&&A[I]===e[g+I];)I++;if(I===C){a.length=g+C;break}}4294967295===a.length&&r("JBIG2 error: segment end was not found")}else r("JBIG2 error: invalid unknown segment length");a.headerEnd=f;return a}function b(e,t,a,r){for(var i=[],n=a;r>n;){var s=m(t,n);n=s.headerEnd;var o={header:s,data:t};if(!e.randomAccess){o.start=n;n+=s.length;o.end=n}i.push(o);if(51===s.type)break}if(e.randomAccess)for(var c=0,l=i.length;l>c;c++){i[c].start=n;n+=i[c].header.length;i[c].end=n}return i}function v(e,t){return{width:o(e,t),height:o(e,t+4),x:o(e,t+8),y:o(e,t+12),combinationOperator:7&e[t+16]}}function y(e,t){var a,i,c,l,h=e.header,u=e.data,f=e.start,d=e.end;switch(h.type){case 0:var g={},p=s(u,f);g.huffman=!!(1&p);g.refinement=!!(2&p);g.huffmanDHSelector=p>>2&3;g.huffmanDWSelector=p>>4&3;g.bitmapSizeSelector=p>>6&1;g.aggregationInstancesSelector=p>>7&1;g.bitmapCodingContextUsed=!!(256&p);g.bitmapCodingContextRetained=!!(512&p);g.template=p>>10&3;g.refinementTemplate=p>>12&1;f+=2;if(!g.huffman){l=0===g.template?4:1;i=[];for(c=0;l>c;c++){i.push({x:n(u,f),y:n(u,f+1)});f+=2}g.at=i}if(g.refinement&&!g.refinementTemplate){i=[];for(c=0;2>c;c++){i.push({x:n(u,f),y:n(u,f+1)});f+=2}g.refinementAt=i; +}g.numberOfExportedSymbols=o(u,f);f+=4;g.numberOfNewSymbols=o(u,f);f+=4;a=[g,h.number,h.referredTo,u,f,d];break;case 6:case 7:var m={};m.info=v(u,f);f+=T;var b=s(u,f);f+=2;m.huffman=!!(1&b);m.refinement=!!(2&b);m.stripSize=1<<(b>>2&3);m.referenceCorner=b>>4&3;m.transposed=!!(64&b);m.combinationOperator=b>>7&3;m.defaultPixelValue=b>>9&1;m.dsOffset=b<<17>>27;m.refinementTemplate=b>>15&1;if(m.huffman){var y=s(u,f);f+=2;m.huffmanFS=3&y;m.huffmanDS=y>>2&3;m.huffmanDT=y>>4&3;m.huffmanRefinementDW=y>>6&3;m.huffmanRefinementDH=y>>8&3;m.huffmanRefinementDX=y>>10&3;m.huffmanRefinementDY=y>>12&3;m.huffmanRefinementSizeSelector=!!(14&y)}if(m.refinement&&!m.refinementTemplate){i=[];for(c=0;2>c;c++){i.push({x:n(u,f),y:n(u,f+1)});f+=2}m.refinementAt=i}m.numberOfSymbolInstances=o(u,f);f+=4;m.huffman&&r("JBIG2 error: huffman is not supported");a=[m,h.referredTo,u,f,d];break;case 38:case 39:var k={};k.info=v(u,f);f+=T;var w=u[f++];k.mmr=!!(1&w);k.template=w>>1&3;k.prediction=!!(8&w);if(!k.mmr){l=0===k.template?4:1;i=[];for(c=0;l>c;c++){i.push({x:n(u,f),y:n(u,f+1)});f+=2}k.at=i}a=[k,u,f,d];break;case 48:var x={width:o(u,f),height:o(u,f+4),resolutionX:o(u,f+8),resolutionY:o(u,f+12)};4294967295===x.height&&delete x.height;var C=u[f+16];s(u,f+17);x.lossless=!!(1&C);x.refinement=!!(2&C);x.defaultPixelValue=C>>2&1;x.combinationOperator=C>>3&3;x.requiresBuffer=!!(32&C);x.combinationOperatorOverride=!!(64&C);a=[x];break;case 49:break;case 50:break;case 51:break;case 62:break;default:r("JBIG2 error: segment type "+h.typeName+"("+h.type+") is not implemented")}var S="on"+h.typeName;S in t&&t[S].apply(t,a)}function k(e,t){for(var a=0,r=e.length;r>a;a++)y(e[a],t)}function w(e){for(var t=new x,a=0,r=e.length;r>a;a++){var i=e[a],n=b({},i.data,i.start,i.end);k(n,t)}return t.buffer}function x(){}function C(){}e.prototype={getContexts:function(e){return e in this?this[e]:this[e]=new Int8Array(65536)}};t.prototype={get decoder(){var e=new l(this.data,this.start,this.end);return c(this,"decoder",e)},get contextCache(){var t=new e;return c(this,"contextCache",t)}};var S=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"patternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"],A=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]],I=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}],B=[39717,1941,229,405],R=[32,8],T=17;x.prototype={onPageInformation:function(e){this.currentPageInfo=e;var t=e.width+7>>3,a=new Uint8Array(t*e.height);if(e.defaultPixelValue)for(var r=0,i=a.length;i>r;r++)a[r]=255;this.buffer=a},drawBitmap:function(e,t){var a,i,n,s,o=this.currentPageInfo,c=e.width,l=e.height,h=o.width+7>>3,u=o.combinationOperatorOverride?e.combinationOperator:o.combinationOperator,f=this.buffer,d=128>>(7&e.x),g=e.y*h+(e.x>>3);switch(u){case 0:for(a=0;l>a;a++){n=d;s=g;for(i=0;c>i;i++){t[a][i]&&(f[s]|=n);n>>=1;if(!n){n=128;s++}}g+=h}break;case 2:for(a=0;l>a;a++){n=d;s=g;for(i=0;c>i;i++){t[a][i]&&(f[s]^=n);n>>=1;if(!n){n=128;s++}}g+=h}break;default:r("JBIG2 error: operator "+u+" is not supported")}},onImmediateGenericRegion:function(e,a,r,i){var n=e.info,s=new t(a,r,i),o=f(e.mmr,n.width,n.height,e.template,e.prediction,null,e.at,s);this.drawBitmap(n,o)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,a,i,n,s,o){var c;e.huffman&&r("JBIG2 error: huffman is not supported");var l=this.symbols;l||(this.symbols=l={});for(var h=[],u=0,f=i.length;f>u;u++)h=h.concat(l[i[u]]);var d=new t(n,s,o);l[a]=g(e.huffman,e.refinement,h,e.numberOfNewSymbols,e.numberOfExportedSymbols,c,e.template,e.at,e.refinementTemplate,e.refinementAt,d)},onImmediateTextRegion:function(e,a,r,n,s){for(var o,c=e.info,l=this.symbols,h=[],u=0,f=a.length;f>u;u++)h=h.concat(l[a[u]]);var d=i(h.length),g=new t(r,n,s),m=p(e.huffman,e.refinement,c.width,c.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,h,d,e.transposed,e.dsOffset,e.referenceCorner,e.combinationOperator,o,e.refinementTemplate,e.refinementAt,g);this.drawBitmap(c,m)},onImmediateLosslessTextRegion:function(){this.onImmediateTextRegion.apply(this,arguments)}};C.prototype={parseChunks:function(e){return w(e)}};return C}();e.Jbig2Image=h});!function(e,t){t(e.pdfjsCoreJpx={},e.pdfjsSharedUtil,e.pdfjsCoreArithmeticDecoder)}(this,function(e,t,a){var r=t.info,i=t.log2,n=t.readUint16,s=t.readUint32,o=t.warn,c=a.ArithmeticDecoder,l=function(){function e(){this.failOnCorruptedImage=!1}function t(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz);e.x1=Math.ceil(t.Xsiz/e.XRsiz);e.y0=Math.ceil(t.YOsiz/e.YRsiz);e.y1=Math.ceil(t.Ysiz/e.YRsiz);e.width=e.x1-e.x0;e.height=e.y1-e.y0}function a(e,t){for(var a,r=e.SIZ,i=[],n=Math.ceil((r.Xsiz-r.XTOsiz)/r.XTsiz),s=Math.ceil((r.Ysiz-r.YTOsiz)/r.YTsiz),o=0;s>o;o++)for(var c=0;n>c;c++){a={};a.tx0=Math.max(r.XTOsiz+c*r.XTsiz,r.XOsiz);a.ty0=Math.max(r.YTOsiz+o*r.YTsiz,r.YOsiz);a.tx1=Math.min(r.XTOsiz+(c+1)*r.XTsiz,r.Xsiz);a.ty1=Math.min(r.YTOsiz+(o+1)*r.YTsiz,r.Ysiz);a.width=a.tx1-a.tx0;a.height=a.ty1-a.ty0;a.components=[];i.push(a)}e.tiles=i;for(var l=r.Csiz,h=0,u=l;u>h;h++)for(var f=t[h],d=0,g=i.length;g>d;d++){var p={};a=i[d];p.tcx0=Math.ceil(a.tx0/f.XRsiz);p.tcy0=Math.ceil(a.ty0/f.YRsiz);p.tcx1=Math.ceil(a.tx1/f.XRsiz);p.tcy1=Math.ceil(a.ty1/f.YRsiz);p.width=p.tcx1-p.tcx0;p.height=p.tcy1-p.tcy0;a.components[h]=p}}function l(e,t,a){var r=t.codingStyleParameters,i={};if(r.entropyCoderWithCustomPrecincts){i.PPx=r.precinctsSizes[a].PPx;i.PPy=r.precinctsSizes[a].PPy}else{i.PPx=15;i.PPy=15}i.xcb_=a>0?Math.min(r.xcb,i.PPx-1):Math.min(r.xcb,i.PPx);i.ycb_=a>0?Math.min(r.ycb,i.PPy-1):Math.min(r.ycb,i.PPy);return i}function h(e,t,a){var r=1<t.trx0?Math.ceil(t.trx1/r)-Math.floor(t.trx0/r):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,h=c*l;t.precinctParameters={precinctWidth:r,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function u(e,t,a){var r,i,n,s,o=a.xcb_,c=a.ycb_,l=1<>o,f=t.tby0>>c,d=t.tbx1+l-1>>o,g=t.tby1+h-1>>c,p=t.resolution.precinctParameters,m=[],b=[];for(i=f;g>i;i++)for(r=u;d>r;r++){n={cbx:r,cby:i,tbx0:l*r,tby0:h*i,tbx1:l*(r+1),tby1:h*(i+1)};n.tbx0_=Math.max(t.tbx0,n.tbx0);n.tby0_=Math.max(t.tby0,n.tby0);n.tbx1_=Math.min(t.tbx1,n.tbx1);n.tby1_=Math.min(t.tby1,n.tby1);var v=Math.floor((n.tbx0_-t.tbx0)/p.precinctWidthInSubband),y=Math.floor((n.tby0_-t.tby0)/p.precinctHeightInSubband);s=v+y*p.numprecinctswide;n.precinctNumber=s;n.subbandType=t.type;n.Lblock=3;if(!(n.tbx1_<=n.tbx0_||n.tby1_<=n.tby0_)){m.push(n);var k=b[s];if(void 0!==k){rk.cbxMax&&(k.cbxMax=r);ik.cbyMax&&(k.cbyMax=i)}else b[s]=k={cbxMin:r,cbyMin:i,cbxMax:r,cbyMax:i};n.precinct=k}}t.codeblockParameters={codeblockWidth:o,codeblockHeight:c,numcodeblockwide:d-u+1,numcodeblockhigh:g-f+1};t.codeblocks=m;t.precincts=b}function f(e,t,a){for(var r=[],i=e.subbands,n=0,s=i.length;s>n;n++)for(var o=i[n],c=o.codeblocks,l=0,h=c.length;h>l;l++){var u=c[l];u.precinctNumber===t&&r.push(u)}return{layerNumber:a,codeblocks:r}}function d(e){for(var t=e.SIZ,a=e.currentTile.index,r=e.tiles[a],i=r.codingStyleDefaultParameters.layersCount,n=t.Csiz,s=0,o=0;n>o;o++)s=Math.max(s,r.components[o].codingStyleParameters.decompositionLevelsCount);var c=0,l=0,h=0,u=0;this.nextPacket=function(){for(;i>c;c++){for(;s>=l;l++){for(;n>h;h++){var e=r.components[h];if(!(l>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],a=t.precinctParameters.numprecincts;a>u;){var o=f(t,u,c);u++;return o}u=0}}h=0}l=0}throw new Error("JPX Error: Out of packets")}}function g(e){for(var t=e.SIZ,a=e.currentTile.index,r=e.tiles[a],i=r.codingStyleDefaultParameters.layersCount,n=t.Csiz,s=0,o=0;n>o;o++)s=Math.max(s,r.components[o].codingStyleParameters.decompositionLevelsCount);var c=0,l=0,h=0,u=0;this.nextPacket=function(){for(;s>=c;c++){for(;i>l;l++){for(;n>h;h++){var e=r.components[h];if(!(c>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],a=t.precinctParameters.numprecincts;a>u;){var o=f(t,u,l);u++;return o}u=0}}h=0}l=0}throw new Error("JPX Error: Out of packets")}}function p(e){var t,a,r,i,n=e.SIZ,s=e.currentTile.index,o=e.tiles[s],c=o.codingStyleDefaultParameters.layersCount,l=n.Csiz,h=0;for(r=0;l>r;r++){var u=o.components[r];h=Math.max(h,u.codingStyleParameters.decompositionLevelsCount)}var d=new Int32Array(h+1);for(a=0;h>=a;++a){var g=0;for(r=0;l>r;++r){var p=o.components[r].resolutions;a=a;a++){for(;ir;r++){var e=o.components[r];if(!(a>e.codingStyleParameters.decompositionLevelsCount)){var n=e.resolutions[a],s=n.precinctParameters.numprecincts;if(!(i>=s)){for(;c>t;){var u=f(n,i,t);t++;return u}t=0}}}r=0}i=0}throw new Error("JPX Error: Out of packets")}}function m(e){var t=e.SIZ,a=e.currentTile.index,r=e.tiles[a],i=r.codingStyleDefaultParameters.layersCount,n=t.Csiz,s=y(r),o=s,c=0,l=0,h=0,u=0,d=0;this.nextPacket=function(){for(;dh;h++){for(var e=r.components[h],t=e.codingStyleParameters.decompositionLevelsCount;t>=l;l++){var a=e.resolutions[l],g=s.components[h].resolutions[l],p=v(u,d,g,o,a);if(null!==p){for(;i>c;){var m=f(a,p,c);c++;return m}c=0}}l=0}h=0}u=0}throw new Error("JPX Error: Out of packets")}}function b(e){var t=e.SIZ,a=e.currentTile.index,r=e.tiles[a],i=r.codingStyleDefaultParameters.layersCount,n=t.Csiz,s=y(r),o=0,c=0,l=0,h=0,u=0;this.nextPacket=function(){for(;n>l;++l){for(var e=r.components[l],t=s.components[l],a=e.codingStyleParameters.decompositionLevelsCount;u=c;c++){var d=e.resolutions[c],g=t.resolutions[c],p=v(h,u,g,t,d);if(null!==p){for(;i>o;){var m=f(d,p,o);o++;return m}o=0}}c=0}h=0}u=0}throw new Error("JPX Error: Out of packets")}}function v(e,t,a,r,i){var n=e*r.minWidth,s=t*r.minHeight;if(n%a.width!==0||s%a.height!==0)return null;var o=s/a.width*i.precinctParameters.numprecinctswide;return n/a.height+o}function y(e){for(var t=e.components.length,a=Number.MAX_VALUE,r=Number.MAX_VALUE,i=0,n=0,s=new Array(t),o=0;t>o;o++){for(var c=e.components[o],l=c.codingStyleParameters.decompositionLevelsCount,h=new Array(l+1),u=Number.MAX_VALUE,f=Number.MAX_VALUE,d=0,g=0,p=1,m=l;m>=0;--m){var b=c.resolutions[m],v=p*b.precinctParameters.precinctWidth,y=p*b.precinctParameters.precinctHeight;u=Math.min(u,v);f=Math.min(f,y);d=Math.max(d,b.precinctParameters.numprecinctswide);g=Math.max(g,b.precinctParameters.numprecinctshigh);h[m]={width:v,height:y};p<<=1}a=Math.min(a,u);r=Math.min(r,f);i=Math.max(i,d);n=Math.max(n,g);s[o]={resolutions:h,minWidth:u,minHeight:f,maxNumWide:d,maxNumHigh:g}}return{components:s,minWidth:a,minHeight:r,maxNumWide:i,maxNumHigh:n}}function k(e){for(var t=e.SIZ,a=e.currentTile.index,r=e.tiles[a],i=t.Csiz,n=0;i>n;n++){for(var s=r.components[n],o=s.codingStyleParameters.decompositionLevelsCount,c=[],f=[],v=0;o>=v;v++){var y=l(e,s,v),k={},w=1<f;){var r=t[a+u];u++;if(d){h=h<<7|r;f+=7;d=!1}else{h=h<<8|r;f+=8}255===r&&(d=!0)}f-=e;return h>>>f&(1<e)return e+3;e=n(5);if(31>e)return e+6;e=n(7);return e+37}for(var h,u=0,f=0,d=!1,g=e.currentTile.index,p=e.tiles[g],m=e.COD.sopMarkerUsed,b=e.COD.ephMarkerUsed,v=p.packetsIterator;r>u;){c();m&&s(145)&&o(4);var y=v.nextPacket();if(n(1)){for(var k,w=y.layerNumber,x=[],C=0,S=y.codeblocks.length;S>C;C++){k=y.codeblocks[C];var A,I=k.precinct,T=k.cbx-I.cbxMin,O=k.cby-I.cbyMin,P=!1,L=!1;if(void 0!==k.included)P=!!n(1);else{I=k.precinct;var M,E;if(void 0!==I.inclusionTree)M=I.inclusionTree;else{var D=I.cbxMax-I.cbxMin+1,q=I.cbyMax-I.cbyMin+1;M=new R(D,q,w);E=new B(D,q);I.inclusionTree=M;I.zeroBitPlanesTree=E}if(M.reset(T,O,w))for(;;){if(!n(1)){M.incrementValue(w);break}A=!M.nextLevel();if(A){k.included=!0;P=L=!0;break}}}if(P){if(L){E=I.zeroBitPlanesTree;E.reset(T,O);for(;;)if(n(1)){A=!E.nextLevel();if(A)break}else E.incrementValue();k.zeroBitPlanes=E.value}for(var j=l();n(1);)k.Lblock++;var F=i(j),U=(1<j?F-1:F)+k.Lblock,N=n(U);x.push({codeblock:k,codingpasses:j,dataLength:N})}}c();b&&s(146);for(;x.length>0;){var _=x.shift();k=_.codeblock;void 0===k.data&&(k.data=[]);k.data.push({data:t,start:a+u,end:a+u+_.dataLength,codingpasses:_.codingpasses});u+=_.dataLength}}}return u}function x(e,t,a,r,i,n,s,o){for(var l=r.tbx0,h=r.tby0,u=r.tbx1-r.tbx0,f=r.codeblocks,d="H"===r.type.charAt(0)?1:0,g="H"===r.type.charAt(1)?t:0,p=0,m=f.length;m>p;++p){var b=f[p],v=b.tbx1_-b.tbx0_,y=b.tby1_-b.tby0_;if(0!==v&&0!==y&&void 0!==b.data){var k,w;k=new T(v,y,b.subbandType,b.zeroBitPlanes,n);w=2;var x,C,S,A=b.data,I=0,B=0;for(x=0,C=A.length;C>x;x++){S=A[x];I+=S.end-S.start;B+=S.codingpasses}var R=new Uint8Array(I),O=0;for(x=0,C=A.length;C>x;x++){S=A[x];var P=S.data.subarray(S.start,S.end);R.set(P,O);O+=P.length}var L=new c(R,0,I);k.setDecoder(L);for(x=0;B>x;x++){switch(w){case 0:k.runSignificancePropagationPass();break;case 1:k.runMagnitudeRefinementPass();break;case 2:k.runCleanupPass();o&&k.checkSegmentationSymbol()}w=(w+1)%3}var M,E,D,q=b.tbx0_-l+(b.tby0_-h)*u,j=k.coefficentsSign,F=k.coefficentsMagnitude,U=k.bitsDecoded,N=s?0:.5;O=0;var _="LL"!==r.type;for(x=0;y>x;x++){var z=q/u|0,H=2*z*(t-u)+d+g;for(M=0;v>M;M++){E=F[O];if(0!==E){E=(E+N)*i;0!==j[O]&&(E=-E);D=U[O];var G=_?H+(q<<1):q;s&&D>=n?e[G]=E:e[G]=E*(1<=m;m++){for(var b=r.resolutions[m],v=b.trx1-b.trx0,y=b.try1-b.try0,k=new Float32Array(v*y),w=0,C=b.subbands.length;C>w;w++){var S,A;if(c){S=o[p].mu;A=o[p].epsilon;p++}else{S=o[0].mu;A=o[0].epsilon+(m>0?1-m:0)}var B=b.subbands[w],R=I[B.type],T=f?1:Math.pow(2,u+R-A)*(1+S/2048),O=l+A-1;x(k,v,y,B,T,O,f,h)}g.push({width:v,height:y,items:k})}var M=d.calculate(g,r.tcx0,r.tcy0);return{left:r.tcx0,top:r.tcy0,width:M.width,height:M.height,items:M.items}}function S(e){for(var t=e.SIZ,a=e.components,r=t.Csiz,i=[],n=0,s=e.tiles.length;s>n;n++){var o,c=e.tiles[n],l=[];for(o=0;r>o;o++)l[o]=C(e,c,o);var h,u,f,d,g,p,m,b,v,y,k,w,x,S,A,I=l[0],B=new Uint8Array(I.items.length*r),R={left:I.left,top:I.top,width:I.width,height:I.height,items:B},T=0;if(c.codingStyleDefaultParameters.multipleComponentTransform){var O=4===r,P=l[0].items,L=l[1].items,M=l[2].items,E=O?l[3].items:null;h=a[0].precision-8;u=(128<p;p++,T+=q){b=P[p]+u;v=L[p];y=M[p];w=b-(y+v>>2);k=w+y;x=w+v;B[T++]=0>=k?0:k>=f?255:k>>h;B[T++]=0>=w?0:w>=f?255:w>>h;B[T++]=0>=x?0:x>=f?255:x>>h}else for(p=0;m>p;p++,T+=q){b=P[p]+u;v=L[p];y=M[p];k=b+1.402*y;w=b-.34413*v-.71414*y;x=b+1.772*v;B[T++]=0>=k?0:k>=f?255:k>>h;B[T++]=0>=w?0:w>=f?255:w>>h;B[T++]=0>=x?0:x>=f?255:x>>h}if(O)for(p=0,T=3;m>p;p++,T+=4){S=E[p];B[T]=d>=S?0:S>=g?255:S+u>>h}}else for(o=0;r>o;o++){var j=l[o].items;h=a[o].precision-8;u=(128<p;p++){A=j[p];B[T]=d>=A?0:A>=f?255:A+u>>h;T+=r}}i.push(R)}return i}function A(e,t){for(var a=e.SIZ,r=a.Csiz,i=e.tiles[t],n=0;r>n;n++){var s=i.components[n],o=void 0!==e.currentTile.QCC[n]?e.currentTile.QCC[n]:e.currentTile.QCD;s.quantizationParameters=o;var c=void 0!==e.currentTile.COC[n]?e.currentTile.COC[n]:e.currentTile.COD;s.codingStyleParameters=c}i.codingStyleDefaultParameters=e.currentTile.COD}var I={LL:0,LH:1,HL:1,HH:2};e.prototype={parse:function(e){var t=n(e,0);if(65359!==t)for(var a=0,i=e.length;i>a;){var c=8,l=s(e,a),h=s(e,a+4);a+=c;if(1===l){l=4294967296*s(e,a)+s(e,a+4);a+=8;c+=8}0===l&&(l=i-a+c);if(c>l)throw new Error("JPX Error: Invalid box field size");var u=l-c,f=!0;switch(h){case 1785737832:f=!1;break;case 1668246642:var d=e[a];if(1===d){var g=s(e,a+3);switch(g){case 16:case 17:case 18:break;default:o("Unknown colorspace "+g)}}else 2===d&&r("ICC profile not supported");break;case 1785737827:this.parseCodestream(e,a,a+u);break;case 1783636e3:218793738!==s(e,a)&&o("Invalid JP2 signature");break;case 1783634458:case 1718909296:case 1920099697:case 1919251232:case 1768449138:break;default:var p=String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h);o("Unsupported header type "+h+" ("+p+")")}f&&(a+=u)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function(e){for(var t=e.getByte();t>=0;){var a=t;t=e.getByte();var r=a<<8|t;if(65361===r){e.skip(4);var i=e.getInt32()>>>0,n=e.getInt32()>>>0,s=e.getInt32()>>>0,o=e.getInt32()>>>0;e.skip(16);var c=e.getUint16();this.width=i-s;this.height=n-o;this.componentsCount=c;this.bitsPerComponent=8;return}}throw new Error("JPX Error: No size marker found in JPX stream")},parseCodestream:function(e,r,i){var c={};try{for(var l=!1,h=r;i>h+1;){var u=n(e,h);h+=2;var f,d,g,p,m,b,v=0;switch(u){case 65359:c.mainHeader=!0;break;case 65497:break;case 65361:v=n(e,h);var y={};y.Xsiz=s(e,h+4);y.Ysiz=s(e,h+8);y.XOsiz=s(e,h+12);y.YOsiz=s(e,h+16);y.XTsiz=s(e,h+20);y.YTsiz=s(e,h+24);y.XTOsiz=s(e,h+28);y.YTOsiz=s(e,h+32);var x=n(e,h+36);y.Csiz=x;var C=[];f=h+38;for(var I=0;x>I;I++){var B={precision:(127&e[f])+1,isSigned:!!(128&e[f]),XRsiz:e[f+1],YRsiz:e[f+1]};t(B,y);C.push(B)}c.SIZ=y;c.components=C;a(c,C);c.QCC=[];c.COC=[];break;case 65372:v=n(e,h);var R={};f=h+2;d=e[f++];switch(31&d){case 0:p=8;m=!0;break;case 1:p=16;m=!1;break;case 2:p=16;m=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+d)}R.noQuantization=8===p;R.scalarExpounded=m;R.guardBits=d>>5;g=[];for(;v+h>f;){var T={};if(8===p){T.epsilon=e[f++]>>3;T.mu=0}else{T.epsilon=e[f]>>3;T.mu=(7&e[f])<<8|e[f+1];f+=2}g.push(T)}R.SPqcds=g;if(c.mainHeader)c.QCD=R;else{c.currentTile.QCD=R;c.currentTile.QCC=[]}break;case 65373:v=n(e,h);var O={};f=h+2;var P;if(c.SIZ.Csiz<257)P=e[f++];else{P=n(e,f);f+=2}d=e[f++];switch(31&d){case 0:p=8;m=!0;break;case 1:p=16;m=!1;break;case 2:p=16;m=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+d)}O.noQuantization=8===p;O.scalarExpounded=m;O.guardBits=d>>5;g=[];for(;v+h>f;){T={};if(8===p){T.epsilon=e[f++]>>3;T.mu=0}else{T.epsilon=e[f]>>3;T.mu=(7&e[f])<<8|e[f+1];f+=2}g.push(T)}O.SPqcds=g;c.mainHeader?c.QCC[P]=O:c.currentTile.QCC[P]=O;break;case 65362:v=n(e,h);var L={};f=h+2;var M=e[f++];L.entropyCoderWithCustomPrecincts=!!(1&M);L.sopMarkerUsed=!!(2&M);L.ephMarkerUsed=!!(4&M);L.progressionOrder=e[f++];L.layersCount=n(e,f);f+=2;L.multipleComponentTransform=e[f++];L.decompositionLevelsCount=e[f++];L.xcb=(15&e[f++])+2;L.ycb=(15&e[f++])+2;var E=e[f++];L.selectiveArithmeticCodingBypass=!!(1&E);L.resetContextProbabilities=!!(2&E);L.terminationOnEachCodingPass=!!(4&E);L.verticalyStripe=!!(8&E);L.predictableTermination=!!(16&E);L.segmentationSymbolUsed=!!(32&E);L.reversibleTransformation=e[f++];if(L.entropyCoderWithCustomPrecincts){for(var D=[];v+h>f;){var q=e[f++];D.push({PPx:15&q,PPy:q>>4})}L.precinctsSizes=D}var j=[];L.selectiveArithmeticCodingBypass&&j.push("selectiveArithmeticCodingBypass");L.resetContextProbabilities&&j.push("resetContextProbabilities");L.terminationOnEachCodingPass&&j.push("terminationOnEachCodingPass");L.verticalyStripe&&j.push("verticalyStripe");L.predictableTermination&&j.push("predictableTermination");if(j.length>0){l=!0;throw new Error("JPX Error: Unsupported COD options ("+j.join(", ")+")")}if(c.mainHeader)c.COD=L;else{c.currentTile.COD=L;c.currentTile.COC=[]}break;case 65424:v=n(e,h);b={};b.index=n(e,h+2);b.length=s(e,h+4);b.dataEnd=b.length+h-2;b.partIndex=e[h+8];b.partsCount=e[h+9];c.mainHeader=!1;if(0===b.partIndex){b.COD=c.COD;b.COC=c.COC.slice(0);b.QCD=c.QCD;b.QCC=c.QCC.slice(0)}c.currentTile=b;break;case 65427:b=c.currentTile;if(0===b.partIndex){A(c,b.index);k(c)}v=b.dataEnd-h;w(c,e,h,v);break;case 65365:case 65367:case 65368:case 65380:v=n(e,h);break;case 65363:throw new Error("JPX Error: Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("JPX Error: Unknown codestream code: "+u.toString(16))}h+=v}}catch(F){if(l||this.failOnCorruptedImage)throw F;o("Trying to recover from "+F.message)}this.tiles=S(c);this.width=c.SIZ.Xsiz-c.SIZ.XOsiz;this.height=c.SIZ.Ysiz-c.SIZ.YOsiz;this.componentsCount=c.SIZ.Csiz}};var B=function(){function e(e,t){var a=i(Math.max(e,t))+1;this.levels=[];for(var r=0;a>r;r++){var n={width:e,height:t,items:[]};this.levels.push(n);e=Math.ceil(e/2);t=Math.ceil(t/2)}}e.prototype={reset:function(e,t){for(var a,r=0,i=0;r>=1;t>>=1;r++}r--;a=this.levels[r];a.items[a.index]=i;this.currentLevel=r;delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];e--;if(0>e){this.value=a;return!1}this.currentLevel=e;t=this.levels[e];t.items[t.index]=a;return!0}};return e}(),R=function(){function e(e,t,a){var r=i(Math.max(e,t))+1;this.levels=[];for(var n=0;r>n;n++){for(var s=new Uint8Array(e*t),o=0,c=s.length;c>o;o++)s[o]=a;var l={width:e,height:t,items:s};this.levels.push(l);e=Math.ceil(e/2);t=Math.ceil(t/2)}}e.prototype={reset:function(e,t,a){for(var r=0;ra){this.currentLevel=r;this.propagateValues();return!1}e>>=1;t>>=1;r++}this.currentLevel=r-1;return!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1;this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];--e>=0;){t=this.levels[e];t.items[t.index]=a}},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];t.items[t.index]=255;e--;if(0>e)return!1;this.currentLevel=e;t=this.levels[e];t.items[t.index]=a;return!0}};return e}(),T=function(){function e(e,t,a,s,o){this.width=e;this.height=t;this.contextLabelTable="HH"===a?n:"HL"===a?i:r;var c=e*t;this.neighborsSignificance=new Uint8Array(c);this.coefficentsSign=new Uint8Array(c);this.coefficentsMagnitude=o>14?new Uint32Array(c):o>6?new Uint16Array(c):new Uint8Array(c);this.processingFlags=new Uint8Array(c);var l=new Uint8Array(c);if(0!==s)for(var h=0;c>h;h++)l[h]=s;this.bitsDecoded=l;this.reset()}var t=17,a=18,r=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),i=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),n=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);e.prototype={setDecoder:function(e){this.decoder=e},reset:function(){this.contexts=new Int8Array(19);this.contexts[0]=8;this.contexts[t]=92;this.contexts[a]=6},setNeighborsSignificance:function(e,t,a){var r,i=this.neighborsSignificance,n=this.width,s=this.height,o=t>0,c=n>t+1;if(e>0){r=a-n;o&&(i[r-1]+=16);c&&(i[r+1]+=16);i[r]+=4}if(s>e+1){r=a+n;o&&(i[r-1]+=16);c&&(i[r+1]+=16);i[r]+=4}o&&(i[a-1]+=1);c&&(i[a+1]+=1);i[a]|=128},runSignificancePropagationPass:function(){for(var e=this.decoder,t=this.width,a=this.height,r=this.coefficentsMagnitude,i=this.coefficentsSign,n=this.neighborsSignificance,s=this.processingFlags,o=this.contexts,c=this.contextLabelTable,l=this.bitsDecoded,h=-2,u=1,f=2,d=0;a>d;d+=4)for(var g=0;t>g;g++)for(var p=d*t+g,m=0;4>m;m++,p+=t){var b=d+m;if(b>=a)break;s[p]&=h;if(!r[p]&&n[p]){var v=c[n[p]],y=e.readBit(o,v);if(y){var k=this.decodeSignBit(b,g,p);i[p]=k;r[p]=1;this.setNeighborsSignificance(b,g,p);s[p]|=f}l[p]++;s[p]|=u}}},decodeSignBit:function(e,t,a){var r,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,f=this.coefficentsSign;s=t>0&&0!==u[a-1];if(l>t+1&&0!==u[a+1]){n=f[a+1];if(s){i=f[a-1];r=1-n-i}else r=1-n-n}else if(s){i=f[a-1];r=1-i-i}else r=0;var d=3*r;s=e>0&&0!==u[a-l];if(h>e+1&&0!==u[a+l]){n=f[a+l];if(s){i=f[a-l];r=1-n-i+d}else r=1-n-n+d}else if(s){i=f[a-l];r=1-i-i+d}else r=d;if(r>=0){o=9+r;c=this.decoder.readBit(this.contexts,o)}else{o=9-r;c=1^this.decoder.readBit(this.contexts,o)}return c},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,a=this.width,r=this.height,i=this.coefficentsMagnitude,n=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=1,h=2,u=a*r,f=4*a,d=0;u>d;d=e){e=Math.min(u,d+f);for(var g=0;a>g;g++)for(var p=d+g;e>p;p+=a)if(i[p]&&0===(c[p]&l)){var m=16;if(0!==(c[p]&h)){c[p]^=h;var b=127&n[p];m=0===b?15:14}var v=t.readBit(s,m);i[p]=i[p]<<1|v;o[p]++;c[p]|=l}}},runCleanupPass:function(){for(var e,r=this.decoder,i=this.width,n=this.height,s=this.neighborsSignificance,o=this.coefficentsMagnitude,c=this.coefficentsSign,l=this.contexts,h=this.contextLabelTable,u=this.bitsDecoded,f=this.processingFlags,d=1,g=2,p=i,m=2*i,b=3*i,v=0;n>v;v=e){e=Math.min(v+4,n);for(var y=v*i,k=n>v+3,w=0;i>w;w++){var x,C=y+w,S=k&&0===f[C]&&0===f[C+p]&&0===f[C+m]&&0===f[C+b]&&0===s[C]&&0===s[C+p]&&0===s[C+m]&&0===s[C+b],A=0,I=C,B=v;if(S){var R=r.readBit(l,a);if(!R){u[C]++;u[C+p]++;u[C+m]++;u[C+b]++;continue}A=r.readBit(l,t)<<1|r.readBit(l,t);if(0!==A){B=v+A;I+=A*i}x=this.decodeSignBit(B,w,I);c[I]=x;o[I]=1;this.setNeighborsSignificance(B,w,I);f[I]|=g;I=C;for(var T=v;B>=T;T++,I+=i)u[I]++;A++}for(B=v+A;e>B;B++,I+=i)if(!o[I]&&0===(f[I]&d)){var O=h[s[I]],P=r.readBit(l,O);if(1===P){x=this.decodeSignBit(B,w,I);c[I]=x;o[I]=1;this.setNeighborsSignificance(B,w,I);f[I]|=g}u[I]++}}}},checkSegmentationSymbol:function(){var e=this.decoder,a=this.contexts,r=e.readBit(a,t)<<3|e.readBit(a,t)<<2|e.readBit(a,t)<<1|e.readBit(a,t);if(10!==r)throw new Error("JPX Error: Invalid segmentation symbol")}};return e}(),O=function(){function e(){}e.prototype.calculate=function(e,t,a){for(var r=e[0],i=1,n=e.length;n>i;i++)r=this.iterate(r,e[i],t,a);return r};e.prototype.extend=function(e,t,a){var r=t-1,i=t+1,n=t+a-2,s=t+a;e[r--]=e[i++];e[s++]=e[n--];e[r--]=e[i++];e[s++]=e[n--];e[r--]=e[i++];e[s++]=e[n--];e[r]=e[i];e[s]=e[n]};e.prototype.iterate=function(e,t,a,r){var i,n,s,o,c,l,h=e.width,u=e.height,f=e.items,d=t.width,g=t.height,p=t.items;for(s=0,i=0;u>i;i++){o=2*i*d;for(n=0;h>n;n++,s++,o+=2)p[o]=f[s]}f=e.items=null;var m=4,b=new Float32Array(d+2*m);if(1===d){if(0!==(1&a))for(l=0,s=0;g>l;l++,s+=d)p[s]*=.5}else for(l=0,s=0;g>l;l++,s+=d){b.set(p.subarray(s,s+d),m);this.extend(b,m,d);this.filter(b,m,d);p.set(b.subarray(m,m+d),s)}var v=16,y=[];for(i=0;v>i;i++)y.push(new Float32Array(g+2*m));var k,w=0;e=m+g;if(1===g){if(0!==(1&r))for(c=0;d>c;c++)p[c]*=.5}else for(c=0;d>c;c++){if(0===w){v=Math.min(d-c,v);for(s=c,o=m;e>o;s+=d,o++)for(k=0;v>k;k++)y[k][o]=p[s+k];w=v}w--;var x=y[w];this.extend(x,m,g);this.filter(x,m,g);if(0===w){s=c-v+1;for(o=m;e>o;s+=d,o++)for(k=0;v>k;k++)p[s+k]=y[k][o]}}return{width:d,height:g,items:p}};return e}(),P=function(){function e(){O.call(this)}e.prototype=Object.create(O.prototype);e.prototype.filter=function(e,t,a){var r=a>>1;t=0|t;var i,n,s,o,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,u=.443506852043971,f=1.230174104914001,d=1/f;i=t-3;for(n=r+4;n--;i+=2)e[i]*=d;i=t-2;s=u*e[i-1];for(n=r+3;n--;i+=2){o=u*e[i+1];e[i]=f*e[i]-s-o;if(!n--)break;i+=2;s=u*e[i+1];e[i]=f*e[i]-s-o}i=t-1;s=h*e[i-1];for(n=r+2;n--;i+=2){o=h*e[i+1];e[i]-=s+o;if(!n--)break;i+=2;s=h*e[i+1];e[i]-=s+o}i=t;s=l*e[i-1];for(n=r+1;n--;i+=2){o=l*e[i+1];e[i]-=s+o;if(!n--)break;i+=2;s=l*e[i+1];e[i]-=s+o}if(0!==r){i=t+1;s=c*e[i-1];for(n=r;n--;i+=2){o=c*e[i+1];e[i]-=s+o;if(!n--)break;i+=2;s=c*e[i+1];e[i]-=s+o}}};return e}(),L=function(){function e(){O.call(this)}e.prototype=Object.create(O.prototype);e.prototype.filter=function(e,t,a){var r=a>>1;t=0|t;var i,n;for(i=t,n=r+1;n--;i+=2)e[i]-=e[i-1]+e[i+1]+2>>2;for(i=t+1,n=r;n--;i+=2)e[i]+=e[i-1]+e[i+1]>>1};return e}();return e}();e.JpxImage=l});!function(e,t){t(e.pdfjsCoreMetrics={},e.pdfjsSharedUtil)}(this,function(e,t){var a=t.getLookupTableFactory,r=a(function(e){e.Courier=600;e["Courier-Bold"]=600;e["Courier-BoldOblique"]=600;e["Courier-Oblique"]=600;e.Helvetica=a(function(e){e.space=278;e.exclam=278;e.quotedbl=355;e.numbersign=556;e.dollar=556;e.percent=889;e.ampersand=667;e.quoteright=222;e.parenleft=333;e.parenright=333;e.asterisk=389;e.plus=584;e.comma=278;e.hyphen=333;e.period=278;e.slash=278;e.zero=556;e.one=556;e.two=556;e.three=556;e.four=556;e.five=556;e.six=556;e.seven=556;e.eight=556;e.nine=556;e.colon=278;e.semicolon=278;e.less=584;e.equal=584;e.greater=584;e.question=556;e.at=1015;e.A=667;e.B=667;e.C=722;e.D=722;e.E=667;e.F=611;e.G=778;e.H=722;e.I=278;e.J=500;e.K=667;e.L=556;e.M=833;e.N=722;e.O=778;e.P=667;e.Q=778;e.R=722;e.S=667;e.T=611;e.U=722;e.V=667;e.W=944;e.X=667;e.Y=667;e.Z=611;e.bracketleft=278;e.backslash=278;e.bracketright=278;e.asciicircum=469;e.underscore=556;e.quoteleft=222;e.a=556;e.b=556;e.c=500;e.d=556;e.e=556;e.f=278;e.g=556;e.h=556;e.i=222;e.j=222;e.k=500;e.l=222;e.m=833;e.n=556;e.o=556;e.p=556; +e.q=556;e.r=333;e.s=500;e.t=278;e.u=556;e.v=500;e.w=722;e.x=500;e.y=500;e.z=500;e.braceleft=334;e.bar=260;e.braceright=334;e.asciitilde=584;e.exclamdown=333;e.cent=556;e.sterling=556;e.fraction=167;e.yen=556;e.florin=556;e.section=556;e.currency=556;e.quotesingle=191;e.quotedblleft=333;e.guillemotleft=556;e.guilsinglleft=333;e.guilsinglright=333;e.fi=500;e.fl=500;e.endash=556;e.dagger=556;e.daggerdbl=556;e.periodcentered=278;e.paragraph=537;e.bullet=350;e.quotesinglbase=222;e.quotedblbase=333;e.quotedblright=333;e.guillemotright=556;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=611;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=1e3;e.ordfeminine=370;e.Lslash=556;e.Oslash=778;e.OE=1e3;e.ordmasculine=365;e.ae=889;e.dotlessi=278;e.lslash=222;e.oslash=611;e.oe=944;e.germandbls=611;e.Idieresis=278;e.eacute=556;e.abreve=556;e.uhungarumlaut=556;e.ecaron=556;e.Ydieresis=667;e.divide=584;e.Yacute=667;e.Acircumflex=667;e.aacute=556;e.Ucircumflex=722;e.yacute=500;e.scommaaccent=500;e.ecircumflex=556;e.Uring=722;e.Udieresis=722;e.aogonek=556;e.Uacute=722;e.uogonek=556;e.Edieresis=667;e.Dcroat=722;e.commaaccent=250;e.copyright=737;e.Emacron=667;e.ccaron=500;e.aring=556;e.Ncommaaccent=722;e.lacute=222;e.agrave=556;e.Tcommaaccent=611;e.Cacute=722;e.atilde=556;e.Edotaccent=667;e.scaron=500;e.scedilla=500;e.iacute=278;e.lozenge=471;e.Rcaron=722;e.Gcommaaccent=778;e.ucircumflex=556;e.acircumflex=556;e.Amacron=667;e.rcaron=333;e.ccedilla=500;e.Zdotaccent=611;e.Thorn=667;e.Omacron=778;e.Racute=722;e.Sacute=667;e.dcaron=643;e.Umacron=722;e.uring=556;e.threesuperior=333;e.Ograve=778;e.Agrave=667;e.Abreve=667;e.multiply=584;e.uacute=556;e.Tcaron=611;e.partialdiff=476;e.ydieresis=500;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=667;e.adieresis=556;e.edieresis=556;e.cacute=500;e.nacute=556;e.umacron=556;e.Ncaron=722;e.Iacute=278;e.plusminus=584;e.brokenbar=260;e.registered=737;e.Gbreve=778;e.Idotaccent=278;e.summation=600;e.Egrave=667;e.racute=333;e.omacron=556;e.Zacute=611;e.Zcaron=611;e.greaterequal=549;e.Eth=722;e.Ccedilla=722;e.lcommaaccent=222;e.tcaron=317;e.eogonek=556;e.Uogonek=722;e.Aacute=667;e.Adieresis=667;e.egrave=556;e.zacute=500;e.iogonek=222;e.Oacute=778;e.oacute=556;e.amacron=556;e.sacute=500;e.idieresis=278;e.Ocircumflex=778;e.Ugrave=722;e.Delta=612;e.thorn=556;e.twosuperior=333;e.Odieresis=778;e.mu=556;e.igrave=278;e.ohungarumlaut=556;e.Eogonek=667;e.dcroat=556;e.threequarters=834;e.Scedilla=667;e.lcaron=299;e.Kcommaaccent=667;e.Lacute=556;e.trademark=1e3;e.edotaccent=556;e.Igrave=278;e.Imacron=278;e.Lcaron=556;e.onehalf=834;e.lessequal=549;e.ocircumflex=556;e.ntilde=556;e.Uhungarumlaut=722;e.Eacute=667;e.emacron=556;e.gbreve=556;e.onequarter=834;e.Scaron=667;e.Scommaaccent=667;e.Ohungarumlaut=778;e.degree=400;e.ograve=556;e.Ccaron=722;e.ugrave=556;e.radical=453;e.Dcaron=722;e.rcommaaccent=333;e.Ntilde=722;e.otilde=556;e.Rcommaaccent=722;e.Lcommaaccent=556;e.Atilde=667;e.Aogonek=667;e.Aring=667;e.Otilde=778;e.zdotaccent=500;e.Ecaron=667;e.Iogonek=278;e.kcommaaccent=500;e.minus=584;e.Icircumflex=278;e.ncaron=556;e.tcommaaccent=278;e.logicalnot=584;e.odieresis=556;e.udieresis=556;e.notequal=549;e.gcommaaccent=556;e.eth=556;e.zcaron=500;e.ncommaaccent=556;e.onesuperior=333;e.imacron=278;e.Euro=556});e["Helvetica-Bold"]=a(function(e){e.space=278;e.exclam=333;e.quotedbl=474;e.numbersign=556;e.dollar=556;e.percent=889;e.ampersand=722;e.quoteright=278;e.parenleft=333;e.parenright=333;e.asterisk=389;e.plus=584;e.comma=278;e.hyphen=333;e.period=278;e.slash=278;e.zero=556;e.one=556;e.two=556;e.three=556;e.four=556;e.five=556;e.six=556;e.seven=556;e.eight=556;e.nine=556;e.colon=333;e.semicolon=333;e.less=584;e.equal=584;e.greater=584;e.question=611;e.at=975;e.A=722;e.B=722;e.C=722;e.D=722;e.E=667;e.F=611;e.G=778;e.H=722;e.I=278;e.J=556;e.K=722;e.L=611;e.M=833;e.N=722;e.O=778;e.P=667;e.Q=778;e.R=722;e.S=667;e.T=611;e.U=722;e.V=667;e.W=944;e.X=667;e.Y=667;e.Z=611;e.bracketleft=333;e.backslash=278;e.bracketright=333;e.asciicircum=584;e.underscore=556;e.quoteleft=278;e.a=556;e.b=611;e.c=556;e.d=611;e.e=556;e.f=333;e.g=611;e.h=611;e.i=278;e.j=278;e.k=556;e.l=278;e.m=889;e.n=611;e.o=611;e.p=611;e.q=611;e.r=389;e.s=556;e.t=333;e.u=611;e.v=556;e.w=778;e.x=556;e.y=556;e.z=500;e.braceleft=389;e.bar=280;e.braceright=389;e.asciitilde=584;e.exclamdown=333;e.cent=556;e.sterling=556;e.fraction=167;e.yen=556;e.florin=556;e.section=556;e.currency=556;e.quotesingle=238;e.quotedblleft=500;e.guillemotleft=556;e.guilsinglleft=333;e.guilsinglright=333;e.fi=611;e.fl=611;e.endash=556;e.dagger=556;e.daggerdbl=556;e.periodcentered=278;e.paragraph=556;e.bullet=350;e.quotesinglbase=278;e.quotedblbase=500;e.quotedblright=500;e.guillemotright=556;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=611;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=1e3;e.ordfeminine=370;e.Lslash=611;e.Oslash=778;e.OE=1e3;e.ordmasculine=365;e.ae=889;e.dotlessi=278;e.lslash=278;e.oslash=611;e.oe=944;e.germandbls=611;e.Idieresis=278;e.eacute=556;e.abreve=556;e.uhungarumlaut=611;e.ecaron=556;e.Ydieresis=667;e.divide=584;e.Yacute=667;e.Acircumflex=722;e.aacute=556;e.Ucircumflex=722;e.yacute=556;e.scommaaccent=556;e.ecircumflex=556;e.Uring=722;e.Udieresis=722;e.aogonek=556;e.Uacute=722;e.uogonek=611;e.Edieresis=667;e.Dcroat=722;e.commaaccent=250;e.copyright=737;e.Emacron=667;e.ccaron=556;e.aring=556;e.Ncommaaccent=722;e.lacute=278;e.agrave=556;e.Tcommaaccent=611;e.Cacute=722;e.atilde=556;e.Edotaccent=667;e.scaron=556;e.scedilla=556;e.iacute=278;e.lozenge=494;e.Rcaron=722;e.Gcommaaccent=778;e.ucircumflex=611;e.acircumflex=556;e.Amacron=722;e.rcaron=389;e.ccedilla=556;e.Zdotaccent=611;e.Thorn=667;e.Omacron=778;e.Racute=722;e.Sacute=667;e.dcaron=743;e.Umacron=722;e.uring=611;e.threesuperior=333;e.Ograve=778;e.Agrave=722;e.Abreve=722;e.multiply=584;e.uacute=611;e.Tcaron=611;e.partialdiff=494;e.ydieresis=556;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=667;e.adieresis=556;e.edieresis=556;e.cacute=556;e.nacute=611;e.umacron=611;e.Ncaron=722;e.Iacute=278;e.plusminus=584;e.brokenbar=280;e.registered=737;e.Gbreve=778;e.Idotaccent=278;e.summation=600;e.Egrave=667;e.racute=389;e.omacron=611;e.Zacute=611;e.Zcaron=611;e.greaterequal=549;e.Eth=722;e.Ccedilla=722;e.lcommaaccent=278;e.tcaron=389;e.eogonek=556;e.Uogonek=722;e.Aacute=722;e.Adieresis=722;e.egrave=556;e.zacute=500;e.iogonek=278;e.Oacute=778;e.oacute=611;e.amacron=556;e.sacute=556;e.idieresis=278;e.Ocircumflex=778;e.Ugrave=722;e.Delta=612;e.thorn=611;e.twosuperior=333;e.Odieresis=778;e.mu=611;e.igrave=278;e.ohungarumlaut=611;e.Eogonek=667;e.dcroat=611;e.threequarters=834;e.Scedilla=667;e.lcaron=400;e.Kcommaaccent=722;e.Lacute=611;e.trademark=1e3;e.edotaccent=556;e.Igrave=278;e.Imacron=278;e.Lcaron=611;e.onehalf=834;e.lessequal=549;e.ocircumflex=611;e.ntilde=611;e.Uhungarumlaut=722;e.Eacute=667;e.emacron=556;e.gbreve=611;e.onequarter=834;e.Scaron=667;e.Scommaaccent=667;e.Ohungarumlaut=778;e.degree=400;e.ograve=611;e.Ccaron=722;e.ugrave=611;e.radical=549;e.Dcaron=722;e.rcommaaccent=389;e.Ntilde=722;e.otilde=611;e.Rcommaaccent=722;e.Lcommaaccent=611;e.Atilde=722;e.Aogonek=722;e.Aring=722;e.Otilde=778;e.zdotaccent=500;e.Ecaron=667;e.Iogonek=278;e.kcommaaccent=556;e.minus=584;e.Icircumflex=278;e.ncaron=611;e.tcommaaccent=333;e.logicalnot=584;e.odieresis=611;e.udieresis=611;e.notequal=549;e.gcommaaccent=611;e.eth=611;e.zcaron=500;e.ncommaaccent=611;e.onesuperior=333;e.imacron=278;e.Euro=556});e["Helvetica-BoldOblique"]=a(function(e){e.space=278;e.exclam=333;e.quotedbl=474;e.numbersign=556;e.dollar=556;e.percent=889;e.ampersand=722;e.quoteright=278;e.parenleft=333;e.parenright=333;e.asterisk=389;e.plus=584;e.comma=278;e.hyphen=333;e.period=278;e.slash=278;e.zero=556;e.one=556;e.two=556;e.three=556;e.four=556;e.five=556;e.six=556;e.seven=556;e.eight=556;e.nine=556;e.colon=333;e.semicolon=333;e.less=584;e.equal=584;e.greater=584;e.question=611;e.at=975;e.A=722;e.B=722;e.C=722;e.D=722;e.E=667;e.F=611;e.G=778;e.H=722;e.I=278;e.J=556;e.K=722;e.L=611;e.M=833;e.N=722;e.O=778;e.P=667;e.Q=778;e.R=722;e.S=667;e.T=611;e.U=722;e.V=667;e.W=944;e.X=667;e.Y=667;e.Z=611;e.bracketleft=333;e.backslash=278;e.bracketright=333;e.asciicircum=584;e.underscore=556;e.quoteleft=278;e.a=556;e.b=611;e.c=556;e.d=611;e.e=556;e.f=333;e.g=611;e.h=611;e.i=278;e.j=278;e.k=556;e.l=278;e.m=889;e.n=611;e.o=611;e.p=611;e.q=611;e.r=389;e.s=556;e.t=333;e.u=611;e.v=556;e.w=778;e.x=556;e.y=556;e.z=500;e.braceleft=389;e.bar=280;e.braceright=389;e.asciitilde=584;e.exclamdown=333;e.cent=556;e.sterling=556;e.fraction=167;e.yen=556;e.florin=556;e.section=556;e.currency=556;e.quotesingle=238;e.quotedblleft=500;e.guillemotleft=556;e.guilsinglleft=333;e.guilsinglright=333;e.fi=611;e.fl=611;e.endash=556;e.dagger=556;e.daggerdbl=556;e.periodcentered=278;e.paragraph=556;e.bullet=350;e.quotesinglbase=278;e.quotedblbase=500;e.quotedblright=500;e.guillemotright=556;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=611;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=1e3;e.ordfeminine=370;e.Lslash=611;e.Oslash=778;e.OE=1e3;e.ordmasculine=365;e.ae=889;e.dotlessi=278;e.lslash=278;e.oslash=611;e.oe=944;e.germandbls=611;e.Idieresis=278;e.eacute=556;e.abreve=556;e.uhungarumlaut=611;e.ecaron=556;e.Ydieresis=667;e.divide=584;e.Yacute=667;e.Acircumflex=722;e.aacute=556;e.Ucircumflex=722;e.yacute=556;e.scommaaccent=556;e.ecircumflex=556;e.Uring=722;e.Udieresis=722;e.aogonek=556;e.Uacute=722;e.uogonek=611;e.Edieresis=667;e.Dcroat=722;e.commaaccent=250;e.copyright=737;e.Emacron=667;e.ccaron=556;e.aring=556;e.Ncommaaccent=722;e.lacute=278;e.agrave=556;e.Tcommaaccent=611;e.Cacute=722;e.atilde=556;e.Edotaccent=667;e.scaron=556;e.scedilla=556;e.iacute=278;e.lozenge=494;e.Rcaron=722;e.Gcommaaccent=778;e.ucircumflex=611;e.acircumflex=556;e.Amacron=722;e.rcaron=389;e.ccedilla=556;e.Zdotaccent=611;e.Thorn=667;e.Omacron=778;e.Racute=722;e.Sacute=667;e.dcaron=743;e.Umacron=722;e.uring=611;e.threesuperior=333;e.Ograve=778;e.Agrave=722;e.Abreve=722;e.multiply=584;e.uacute=611;e.Tcaron=611;e.partialdiff=494;e.ydieresis=556;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=667;e.adieresis=556;e.edieresis=556;e.cacute=556;e.nacute=611;e.umacron=611;e.Ncaron=722;e.Iacute=278;e.plusminus=584;e.brokenbar=280;e.registered=737;e.Gbreve=778;e.Idotaccent=278;e.summation=600;e.Egrave=667;e.racute=389;e.omacron=611;e.Zacute=611;e.Zcaron=611;e.greaterequal=549;e.Eth=722;e.Ccedilla=722;e.lcommaaccent=278;e.tcaron=389;e.eogonek=556;e.Uogonek=722;e.Aacute=722;e.Adieresis=722;e.egrave=556;e.zacute=500;e.iogonek=278;e.Oacute=778;e.oacute=611;e.amacron=556;e.sacute=556;e.idieresis=278;e.Ocircumflex=778;e.Ugrave=722;e.Delta=612;e.thorn=611;e.twosuperior=333;e.Odieresis=778;e.mu=611;e.igrave=278;e.ohungarumlaut=611;e.Eogonek=667;e.dcroat=611;e.threequarters=834;e.Scedilla=667;e.lcaron=400;e.Kcommaaccent=722;e.Lacute=611;e.trademark=1e3;e.edotaccent=556;e.Igrave=278;e.Imacron=278;e.Lcaron=611;e.onehalf=834;e.lessequal=549;e.ocircumflex=611;e.ntilde=611;e.Uhungarumlaut=722;e.Eacute=667;e.emacron=556;e.gbreve=611;e.onequarter=834;e.Scaron=667;e.Scommaaccent=667;e.Ohungarumlaut=778;e.degree=400;e.ograve=611;e.Ccaron=722;e.ugrave=611;e.radical=549;e.Dcaron=722;e.rcommaaccent=389;e.Ntilde=722;e.otilde=611;e.Rcommaaccent=722;e.Lcommaaccent=611;e.Atilde=722;e.Aogonek=722;e.Aring=722;e.Otilde=778;e.zdotaccent=500;e.Ecaron=667;e.Iogonek=278;e.kcommaaccent=556;e.minus=584;e.Icircumflex=278;e.ncaron=611;e.tcommaaccent=333;e.logicalnot=584;e.odieresis=611;e.udieresis=611;e.notequal=549;e.gcommaaccent=611;e.eth=611;e.zcaron=500;e.ncommaaccent=611;e.onesuperior=333;e.imacron=278;e.Euro=556});e["Helvetica-Oblique"]=a(function(e){e.space=278;e.exclam=278;e.quotedbl=355;e.numbersign=556;e.dollar=556;e.percent=889;e.ampersand=667;e.quoteright=222;e.parenleft=333;e.parenright=333;e.asterisk=389;e.plus=584;e.comma=278;e.hyphen=333;e.period=278;e.slash=278;e.zero=556;e.one=556;e.two=556;e.three=556;e.four=556;e.five=556;e.six=556;e.seven=556;e.eight=556;e.nine=556;e.colon=278;e.semicolon=278;e.less=584;e.equal=584;e.greater=584;e.question=556;e.at=1015;e.A=667;e.B=667;e.C=722;e.D=722;e.E=667;e.F=611;e.G=778;e.H=722;e.I=278;e.J=500;e.K=667;e.L=556;e.M=833;e.N=722;e.O=778;e.P=667;e.Q=778;e.R=722;e.S=667;e.T=611;e.U=722;e.V=667;e.W=944;e.X=667;e.Y=667;e.Z=611;e.bracketleft=278;e.backslash=278;e.bracketright=278;e.asciicircum=469;e.underscore=556;e.quoteleft=222;e.a=556;e.b=556;e.c=500;e.d=556;e.e=556;e.f=278;e.g=556;e.h=556;e.i=222;e.j=222;e.k=500;e.l=222;e.m=833;e.n=556;e.o=556;e.p=556;e.q=556;e.r=333;e.s=500;e.t=278;e.u=556;e.v=500;e.w=722;e.x=500;e.y=500;e.z=500;e.braceleft=334;e.bar=260;e.braceright=334;e.asciitilde=584;e.exclamdown=333;e.cent=556;e.sterling=556;e.fraction=167;e.yen=556;e.florin=556;e.section=556;e.currency=556;e.quotesingle=191;e.quotedblleft=333;e.guillemotleft=556;e.guilsinglleft=333;e.guilsinglright=333;e.fi=500;e.fl=500;e.endash=556;e.dagger=556;e.daggerdbl=556;e.periodcentered=278;e.paragraph=537;e.bullet=350;e.quotesinglbase=222;e.quotedblbase=333;e.quotedblright=333;e.guillemotright=556;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=611;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=1e3;e.ordfeminine=370;e.Lslash=556;e.Oslash=778;e.OE=1e3;e.ordmasculine=365;e.ae=889;e.dotlessi=278;e.lslash=222;e.oslash=611;e.oe=944;e.germandbls=611;e.Idieresis=278;e.eacute=556;e.abreve=556;e.uhungarumlaut=556;e.ecaron=556;e.Ydieresis=667;e.divide=584;e.Yacute=667;e.Acircumflex=667;e.aacute=556;e.Ucircumflex=722;e.yacute=500;e.scommaaccent=500;e.ecircumflex=556;e.Uring=722;e.Udieresis=722;e.aogonek=556;e.Uacute=722;e.uogonek=556;e.Edieresis=667;e.Dcroat=722;e.commaaccent=250;e.copyright=737;e.Emacron=667;e.ccaron=500;e.aring=556;e.Ncommaaccent=722;e.lacute=222;e.agrave=556;e.Tcommaaccent=611;e.Cacute=722;e.atilde=556;e.Edotaccent=667;e.scaron=500;e.scedilla=500;e.iacute=278;e.lozenge=471;e.Rcaron=722;e.Gcommaaccent=778;e.ucircumflex=556;e.acircumflex=556;e.Amacron=667;e.rcaron=333;e.ccedilla=500;e.Zdotaccent=611;e.Thorn=667;e.Omacron=778;e.Racute=722;e.Sacute=667;e.dcaron=643;e.Umacron=722;e.uring=556;e.threesuperior=333;e.Ograve=778;e.Agrave=667;e.Abreve=667;e.multiply=584;e.uacute=556;e.Tcaron=611;e.partialdiff=476;e.ydieresis=500;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=667;e.adieresis=556;e.edieresis=556;e.cacute=500;e.nacute=556;e.umacron=556;e.Ncaron=722;e.Iacute=278;e.plusminus=584;e.brokenbar=260;e.registered=737;e.Gbreve=778;e.Idotaccent=278;e.summation=600;e.Egrave=667;e.racute=333;e.omacron=556;e.Zacute=611;e.Zcaron=611;e.greaterequal=549;e.Eth=722;e.Ccedilla=722;e.lcommaaccent=222;e.tcaron=317;e.eogonek=556;e.Uogonek=722;e.Aacute=667;e.Adieresis=667;e.egrave=556;e.zacute=500;e.iogonek=222;e.Oacute=778;e.oacute=556;e.amacron=556;e.sacute=500;e.idieresis=278;e.Ocircumflex=778;e.Ugrave=722;e.Delta=612;e.thorn=556;e.twosuperior=333;e.Odieresis=778;e.mu=556;e.igrave=278;e.ohungarumlaut=556;e.Eogonek=667;e.dcroat=556;e.threequarters=834;e.Scedilla=667;e.lcaron=299;e.Kcommaaccent=667;e.Lacute=556;e.trademark=1e3;e.edotaccent=556;e.Igrave=278;e.Imacron=278;e.Lcaron=556;e.onehalf=834;e.lessequal=549;e.ocircumflex=556;e.ntilde=556;e.Uhungarumlaut=722;e.Eacute=667;e.emacron=556;e.gbreve=556;e.onequarter=834;e.Scaron=667;e.Scommaaccent=667;e.Ohungarumlaut=778;e.degree=400;e.ograve=556;e.Ccaron=722;e.ugrave=556;e.radical=453;e.Dcaron=722;e.rcommaaccent=333;e.Ntilde=722;e.otilde=556;e.Rcommaaccent=722;e.Lcommaaccent=556;e.Atilde=667;e.Aogonek=667;e.Aring=667;e.Otilde=778;e.zdotaccent=500;e.Ecaron=667;e.Iogonek=278;e.kcommaaccent=500;e.minus=584;e.Icircumflex=278;e.ncaron=556;e.tcommaaccent=278;e.logicalnot=584;e.odieresis=556;e.udieresis=556;e.notequal=549;e.gcommaaccent=556;e.eth=556;e.zcaron=500;e.ncommaaccent=556;e.onesuperior=333;e.imacron=278;e.Euro=556});e.Symbol=a(function(e){e.space=250;e.exclam=333;e.universal=713;e.numbersign=500;e.existential=549;e.percent=833;e.ampersand=778;e.suchthat=439;e.parenleft=333;e.parenright=333;e.asteriskmath=500;e.plus=549;e.comma=250;e.minus=549;e.period=250;e.slash=278;e.zero=500;e.one=500;e.two=500;e.three=500;e.four=500;e.five=500;e.six=500;e.seven=500;e.eight=500;e.nine=500;e.colon=278;e.semicolon=278;e.less=549;e.equal=549;e.greater=549;e.question=444;e.congruent=549;e.Alpha=722;e.Beta=667;e.Chi=722;e.Delta=612;e.Epsilon=611;e.Phi=763;e.Gamma=603;e.Eta=722;e.Iota=333;e.theta1=631;e.Kappa=722;e.Lambda=686;e.Mu=889;e.Nu=722;e.Omicron=722;e.Pi=768;e.Theta=741;e.Rho=556;e.Sigma=592;e.Tau=611;e.Upsilon=690;e.sigma1=439;e.Omega=768;e.Xi=645;e.Psi=795;e.Zeta=611;e.bracketleft=333;e.therefore=863;e.bracketright=333;e.perpendicular=658;e.underscore=500;e.radicalex=500;e.alpha=631;e.beta=549;e.chi=549;e.delta=494;e.epsilon=439;e.phi=521;e.gamma=411;e.eta=603;e.iota=329;e.phi1=603;e.kappa=549;e.lambda=549;e.mu=576;e.nu=521;e.omicron=549;e.pi=549;e.theta=521;e.rho=549;e.sigma=603;e.tau=439;e.upsilon=576;e.omega1=713;e.omega=686;e.xi=493;e.psi=686;e.zeta=494;e.braceleft=480;e.bar=200;e.braceright=480;e.similar=549;e.Euro=750;e.Upsilon1=620;e.minute=247;e.lessequal=549;e.fraction=167;e.infinity=713;e.florin=500;e.club=753;e.diamond=753;e.heart=753;e.spade=753;e.arrowboth=1042;e.arrowleft=987;e.arrowup=603;e.arrowright=987;e.arrowdown=603;e.degree=400;e.plusminus=549;e.second=411;e.greaterequal=549;e.multiply=549;e.proportional=713;e.partialdiff=494;e.bullet=460;e.divide=549;e.notequal=549;e.equivalence=549;e.approxequal=549;e.ellipsis=1e3;e.arrowvertex=603;e.arrowhorizex=1e3;e.carriagereturn=658;e.aleph=823;e.Ifraktur=686;e.Rfraktur=795;e.weierstrass=987;e.circlemultiply=768;e.circleplus=768;e.emptyset=823;e.intersection=768;e.union=768;e.propersuperset=713;e.reflexsuperset=713;e.notsubset=713;e.propersubset=713;e.reflexsubset=713;e.element=713;e.notelement=713;e.angle=768;e.gradient=713;e.registerserif=790;e.copyrightserif=790;e.trademarkserif=890;e.product=823;e.radical=549;e.dotmath=250;e.logicalnot=713;e.logicaland=603;e.logicalor=603;e.arrowdblboth=1042;e.arrowdblleft=987;e.arrowdblup=603;e.arrowdblright=987;e.arrowdbldown=603;e.lozenge=494;e.angleleft=329;e.registersans=790;e.copyrightsans=790;e.trademarksans=786;e.summation=713;e.parenlefttp=384;e.parenleftex=384;e.parenleftbt=384;e.bracketlefttp=384;e.bracketleftex=384;e.bracketleftbt=384;e.bracelefttp=494;e.braceleftmid=494;e.braceleftbt=494;e.braceex=494;e.angleright=329;e.integral=274;e.integraltp=686;e.integralex=686;e.integralbt=686;e.parenrighttp=384;e.parenrightex=384;e.parenrightbt=384;e.bracketrighttp=384;e.bracketrightex=384;e.bracketrightbt=384;e.bracerighttp=494;e.bracerightmid=494;e.bracerightbt=494;e.apple=790});e["Times-Roman"]=a(function(e){e.space=250;e.exclam=333;e.quotedbl=408;e.numbersign=500;e.dollar=500;e.percent=833;e.ampersand=778;e.quoteright=333;e.parenleft=333;e.parenright=333;e.asterisk=500;e.plus=564;e.comma=250;e.hyphen=333;e.period=250;e.slash=278;e.zero=500;e.one=500;e.two=500;e.three=500;e.four=500;e.five=500;e.six=500;e.seven=500;e.eight=500;e.nine=500;e.colon=278;e.semicolon=278;e.less=564;e.equal=564;e.greater=564;e.question=444;e.at=921;e.A=722;e.B=667;e.C=667;e.D=722;e.E=611;e.F=556;e.G=722;e.H=722;e.I=333;e.J=389;e.K=722;e.L=611;e.M=889;e.N=722;e.O=722;e.P=556;e.Q=722;e.R=667;e.S=556;e.T=611;e.U=722;e.V=722;e.W=944;e.X=722;e.Y=722;e.Z=611;e.bracketleft=333;e.backslash=278;e.bracketright=333;e.asciicircum=469;e.underscore=500;e.quoteleft=333;e.a=444;e.b=500;e.c=444;e.d=500;e.e=444;e.f=333;e.g=500;e.h=500;e.i=278;e.j=278;e.k=500;e.l=278;e.m=778;e.n=500;e.o=500;e.p=500;e.q=500;e.r=333;e.s=389;e.t=278;e.u=500;e.v=500;e.w=722;e.x=500;e.y=500;e.z=444;e.braceleft=480;e.bar=200;e.braceright=480;e.asciitilde=541;e.exclamdown=333;e.cent=500;e.sterling=500;e.fraction=167;e.yen=500;e.florin=500;e.section=500;e.currency=500;e.quotesingle=180;e.quotedblleft=444;e.guillemotleft=500;e.guilsinglleft=333;e.guilsinglright=333;e.fi=556;e.fl=556;e.endash=500;e.dagger=500;e.daggerdbl=500;e.periodcentered=250;e.paragraph=453;e.bullet=350;e.quotesinglbase=333;e.quotedblbase=444;e.quotedblright=444;e.guillemotright=500;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=444;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=889;e.ordfeminine=276;e.Lslash=611;e.Oslash=722;e.OE=889;e.ordmasculine=310;e.ae=667;e.dotlessi=278;e.lslash=278;e.oslash=500;e.oe=722;e.germandbls=500;e.Idieresis=333;e.eacute=444;e.abreve=444;e.uhungarumlaut=500;e.ecaron=444;e.Ydieresis=722;e.divide=564;e.Yacute=722;e.Acircumflex=722;e.aacute=444;e.Ucircumflex=722;e.yacute=500;e.scommaaccent=389;e.ecircumflex=444;e.Uring=722;e.Udieresis=722;e.aogonek=444;e.Uacute=722;e.uogonek=500;e.Edieresis=611;e.Dcroat=722;e.commaaccent=250;e.copyright=760;e.Emacron=611;e.ccaron=444;e.aring=444;e.Ncommaaccent=722;e.lacute=278;e.agrave=444;e.Tcommaaccent=611;e.Cacute=667;e.atilde=444;e.Edotaccent=611;e.scaron=389;e.scedilla=389;e.iacute=278;e.lozenge=471;e.Rcaron=667;e.Gcommaaccent=722;e.ucircumflex=500;e.acircumflex=444;e.Amacron=722;e.rcaron=333;e.ccedilla=444;e.Zdotaccent=611;e.Thorn=556;e.Omacron=722;e.Racute=667;e.Sacute=556;e.dcaron=588;e.Umacron=722;e.uring=500;e.threesuperior=300;e.Ograve=722;e.Agrave=722;e.Abreve=722;e.multiply=564;e.uacute=500;e.Tcaron=611;e.partialdiff=476;e.ydieresis=500;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=611;e.adieresis=444;e.edieresis=444;e.cacute=444;e.nacute=500;e.umacron=500;e.Ncaron=722;e.Iacute=333;e.plusminus=564;e.brokenbar=200;e.registered=760;e.Gbreve=722;e.Idotaccent=333;e.summation=600;e.Egrave=611;e.racute=333;e.omacron=500;e.Zacute=611;e.Zcaron=611;e.greaterequal=549;e.Eth=722;e.Ccedilla=667;e.lcommaaccent=278;e.tcaron=326;e.eogonek=444;e.Uogonek=722;e.Aacute=722;e.Adieresis=722;e.egrave=444;e.zacute=444;e.iogonek=278;e.Oacute=722;e.oacute=500;e.amacron=444;e.sacute=389;e.idieresis=278;e.Ocircumflex=722;e.Ugrave=722;e.Delta=612;e.thorn=500;e.twosuperior=300;e.Odieresis=722;e.mu=500;e.igrave=278;e.ohungarumlaut=500;e.Eogonek=611;e.dcroat=500;e.threequarters=750;e.Scedilla=556;e.lcaron=344;e.Kcommaaccent=722;e.Lacute=611;e.trademark=980;e.edotaccent=444;e.Igrave=333;e.Imacron=333;e.Lcaron=611;e.onehalf=750;e.lessequal=549;e.ocircumflex=500;e.ntilde=500;e.Uhungarumlaut=722;e.Eacute=611;e.emacron=444;e.gbreve=500;e.onequarter=750;e.Scaron=556;e.Scommaaccent=556;e.Ohungarumlaut=722;e.degree=400;e.ograve=500;e.Ccaron=667;e.ugrave=500;e.radical=453;e.Dcaron=722;e.rcommaaccent=333;e.Ntilde=722;e.otilde=500;e.Rcommaaccent=667;e.Lcommaaccent=611;e.Atilde=722;e.Aogonek=722;e.Aring=722;e.Otilde=722;e.zdotaccent=444;e.Ecaron=611;e.Iogonek=333;e.kcommaaccent=500;e.minus=564;e.Icircumflex=333;e.ncaron=500;e.tcommaaccent=278;e.logicalnot=564;e.odieresis=500;e.udieresis=500;e.notequal=549;e.gcommaaccent=500;e.eth=500;e.zcaron=444;e.ncommaaccent=500;e.onesuperior=300;e.imacron=278;e.Euro=500});e["Times-Bold"]=a(function(e){e.space=250;e.exclam=333;e.quotedbl=555;e.numbersign=500;e.dollar=500;e.percent=1e3;e.ampersand=833;e.quoteright=333;e.parenleft=333;e.parenright=333;e.asterisk=500;e.plus=570;e.comma=250;e.hyphen=333;e.period=250;e.slash=278;e.zero=500;e.one=500;e.two=500;e.three=500;e.four=500;e.five=500;e.six=500;e.seven=500;e.eight=500;e.nine=500;e.colon=333;e.semicolon=333;e.less=570;e.equal=570;e.greater=570;e.question=500;e.at=930;e.A=722;e.B=667;e.C=722;e.D=722;e.E=667;e.F=611;e.G=778;e.H=778;e.I=389;e.J=500;e.K=778;e.L=667;e.M=944;e.N=722;e.O=778;e.P=611;e.Q=778;e.R=722;e.S=556;e.T=667;e.U=722;e.V=722;e.W=1e3;e.X=722;e.Y=722;e.Z=667;e.bracketleft=333;e.backslash=278;e.bracketright=333;e.asciicircum=581;e.underscore=500;e.quoteleft=333;e.a=500;e.b=556;e.c=444;e.d=556;e.e=444;e.f=333;e.g=500;e.h=556;e.i=278;e.j=333;e.k=556;e.l=278;e.m=833;e.n=556;e.o=500;e.p=556;e.q=556;e.r=444;e.s=389;e.t=333;e.u=556;e.v=500;e.w=722;e.x=500;e.y=500;e.z=444;e.braceleft=394;e.bar=220;e.braceright=394;e.asciitilde=520;e.exclamdown=333;e.cent=500;e.sterling=500;e.fraction=167;e.yen=500;e.florin=500;e.section=500;e.currency=500;e.quotesingle=278;e.quotedblleft=500;e.guillemotleft=500;e.guilsinglleft=333;e.guilsinglright=333;e.fi=556;e.fl=556;e.endash=500;e.dagger=500;e.daggerdbl=500;e.periodcentered=250;e.paragraph=540;e.bullet=350;e.quotesinglbase=333;e.quotedblbase=500;e.quotedblright=500;e.guillemotright=500;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=500;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=1e3;e.ordfeminine=300;e.Lslash=667;e.Oslash=778;e.OE=1e3;e.ordmasculine=330;e.ae=722;e.dotlessi=278;e.lslash=278;e.oslash=500;e.oe=722;e.germandbls=556;e.Idieresis=389;e.eacute=444;e.abreve=500;e.uhungarumlaut=556;e.ecaron=444;e.Ydieresis=722;e.divide=570;e.Yacute=722;e.Acircumflex=722;e.aacute=500;e.Ucircumflex=722;e.yacute=500;e.scommaaccent=389;e.ecircumflex=444;e.Uring=722;e.Udieresis=722;e.aogonek=500;e.Uacute=722;e.uogonek=556;e.Edieresis=667;e.Dcroat=722;e.commaaccent=250;e.copyright=747;e.Emacron=667;e.ccaron=444;e.aring=500;e.Ncommaaccent=722;e.lacute=278;e.agrave=500;e.Tcommaaccent=667;e.Cacute=722;e.atilde=500;e.Edotaccent=667;e.scaron=389;e.scedilla=389;e.iacute=278;e.lozenge=494;e.Rcaron=722;e.Gcommaaccent=778;e.ucircumflex=556;e.acircumflex=500;e.Amacron=722;e.rcaron=444;e.ccedilla=444;e.Zdotaccent=667;e.Thorn=611;e.Omacron=778;e.Racute=722;e.Sacute=556;e.dcaron=672;e.Umacron=722;e.uring=556;e.threesuperior=300;e.Ograve=778;e.Agrave=722;e.Abreve=722;e.multiply=570;e.uacute=556;e.Tcaron=667;e.partialdiff=494;e.ydieresis=500;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=667;e.adieresis=500;e.edieresis=444;e.cacute=444;e.nacute=556;e.umacron=556;e.Ncaron=722;e.Iacute=389;e.plusminus=570;e.brokenbar=220;e.registered=747;e.Gbreve=778;e.Idotaccent=389;e.summation=600;e.Egrave=667;e.racute=444;e.omacron=500;e.Zacute=667;e.Zcaron=667;e.greaterequal=549;e.Eth=722;e.Ccedilla=722;e.lcommaaccent=278;e.tcaron=416;e.eogonek=444;e.Uogonek=722;e.Aacute=722;e.Adieresis=722;e.egrave=444;e.zacute=444;e.iogonek=278;e.Oacute=778;e.oacute=500;e.amacron=500;e.sacute=389;e.idieresis=278;e.Ocircumflex=778;e.Ugrave=722;e.Delta=612;e.thorn=556;e.twosuperior=300;e.Odieresis=778;e.mu=556;e.igrave=278;e.ohungarumlaut=500;e.Eogonek=667;e.dcroat=556;e.threequarters=750;e.Scedilla=556;e.lcaron=394;e.Kcommaaccent=778;e.Lacute=667;e.trademark=1e3;e.edotaccent=444;e.Igrave=389;e.Imacron=389;e.Lcaron=667;e.onehalf=750;e.lessequal=549;e.ocircumflex=500;e.ntilde=556;e.Uhungarumlaut=722;e.Eacute=667;e.emacron=444;e.gbreve=500;e.onequarter=750;e.Scaron=556;e.Scommaaccent=556;e.Ohungarumlaut=778;e.degree=400;e.ograve=500;e.Ccaron=722;e.ugrave=556;e.radical=549;e.Dcaron=722;e.rcommaaccent=444;e.Ntilde=722;e.otilde=500;e.Rcommaaccent=722;e.Lcommaaccent=667;e.Atilde=722;e.Aogonek=722;e.Aring=722;e.Otilde=778;e.zdotaccent=444;e.Ecaron=667;e.Iogonek=389;e.kcommaaccent=556;e.minus=570;e.Icircumflex=389;e.ncaron=556;e.tcommaaccent=333;e.logicalnot=570;e.odieresis=500;e.udieresis=556;e.notequal=549;e.gcommaaccent=500;e.eth=500;e.zcaron=444;e.ncommaaccent=556;e.onesuperior=300;e.imacron=278;e.Euro=500});e["Times-BoldItalic"]=a(function(e){e.space=250;e.exclam=389;e.quotedbl=555;e.numbersign=500;e.dollar=500;e.percent=833;e.ampersand=778;e.quoteright=333;e.parenleft=333;e.parenright=333;e.asterisk=500;e.plus=570;e.comma=250;e.hyphen=333;e.period=250;e.slash=278;e.zero=500;e.one=500;e.two=500;e.three=500;e.four=500;e.five=500;e.six=500;e.seven=500;e.eight=500;e.nine=500;e.colon=333;e.semicolon=333;e.less=570;e.equal=570;e.greater=570;e.question=500;e.at=832;e.A=667;e.B=667;e.C=667;e.D=722;e.E=667;e.F=667;e.G=722;e.H=778;e.I=389;e.J=500;e.K=667;e.L=611;e.M=889;e.N=722;e.O=722;e.P=611;e.Q=722;e.R=667;e.S=556;e.T=611;e.U=722;e.V=667;e.W=889;e.X=667;e.Y=611;e.Z=611;e.bracketleft=333;e.backslash=278;e.bracketright=333;e.asciicircum=570;e.underscore=500;e.quoteleft=333;e.a=500;e.b=500;e.c=444;e.d=500;e.e=444;e.f=333;e.g=500;e.h=556;e.i=278;e.j=278;e.k=500;e.l=278;e.m=778;e.n=556;e.o=500;e.p=500;e.q=500;e.r=389;e.s=389;e.t=278;e.u=556;e.v=444;e.w=667;e.x=500;e.y=444;e.z=389;e.braceleft=348;e.bar=220;e.braceright=348;e.asciitilde=570;e.exclamdown=389;e.cent=500;e.sterling=500;e.fraction=167;e.yen=500;e.florin=500;e.section=500;e.currency=500;e.quotesingle=278;e.quotedblleft=500;e.guillemotleft=500;e.guilsinglleft=333;e.guilsinglright=333;e.fi=556;e.fl=556;e.endash=500;e.dagger=500;e.daggerdbl=500;e.periodcentered=250;e.paragraph=500;e.bullet=350;e.quotesinglbase=333;e.quotedblbase=500;e.quotedblright=500;e.guillemotright=500;e.ellipsis=1e3;e.perthousand=1e3;e.questiondown=500;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=1e3;e.AE=944;e.ordfeminine=266;e.Lslash=611;e.Oslash=722;e.OE=944;e.ordmasculine=300;e.ae=722;e.dotlessi=278;e.lslash=278;e.oslash=500;e.oe=722;e.germandbls=500;e.Idieresis=389;e.eacute=444;e.abreve=500;e.uhungarumlaut=556;e.ecaron=444;e.Ydieresis=611;e.divide=570;e.Yacute=611;e.Acircumflex=667;e.aacute=500;e.Ucircumflex=722;e.yacute=444;e.scommaaccent=389;e.ecircumflex=444;e.Uring=722;e.Udieresis=722;e.aogonek=500;e.Uacute=722;e.uogonek=556;e.Edieresis=667;e.Dcroat=722;e.commaaccent=250;e.copyright=747;e.Emacron=667;e.ccaron=444;e.aring=500;e.Ncommaaccent=722;e.lacute=278;e.agrave=500;e.Tcommaaccent=611;e.Cacute=667;e.atilde=500;e.Edotaccent=667;e.scaron=389;e.scedilla=389;e.iacute=278;e.lozenge=494;e.Rcaron=667;e.Gcommaaccent=722;e.ucircumflex=556;e.acircumflex=500;e.Amacron=667;e.rcaron=389;e.ccedilla=444;e.Zdotaccent=611;e.Thorn=611;e.Omacron=722;e.Racute=667;e.Sacute=556;e.dcaron=608;e.Umacron=722;e.uring=556;e.threesuperior=300;e.Ograve=722;e.Agrave=667;e.Abreve=667;e.multiply=570;e.uacute=556;e.Tcaron=611;e.partialdiff=494;e.ydieresis=444;e.Nacute=722;e.icircumflex=278;e.Ecircumflex=667;e.adieresis=500;e.edieresis=444;e.cacute=444;e.nacute=556;e.umacron=556;e.Ncaron=722;e.Iacute=389;e.plusminus=570;e.brokenbar=220;e.registered=747;e.Gbreve=722;e.Idotaccent=389;e.summation=600;e.Egrave=667;e.racute=389;e.omacron=500;e.Zacute=611;e.Zcaron=611;e.greaterequal=549;e.Eth=722;e.Ccedilla=667;e.lcommaaccent=278;e.tcaron=366;e.eogonek=444;e.Uogonek=722;e.Aacute=667;e.Adieresis=667;e.egrave=444;e.zacute=389;e.iogonek=278;e.Oacute=722;e.oacute=500;e.amacron=500;e.sacute=389;e.idieresis=278;e.Ocircumflex=722;e.Ugrave=722;e.Delta=612;e.thorn=500;e.twosuperior=300;e.Odieresis=722;e.mu=576;e.igrave=278;e.ohungarumlaut=500;e.Eogonek=667;e.dcroat=500;e.threequarters=750;e.Scedilla=556;e.lcaron=382;e.Kcommaaccent=667;e.Lacute=611;e.trademark=1e3;e.edotaccent=444;e.Igrave=389;e.Imacron=389;e.Lcaron=611;e.onehalf=750;e.lessequal=549;e.ocircumflex=500;e.ntilde=556;e.Uhungarumlaut=722;e.Eacute=667;e.emacron=444;e.gbreve=500;e.onequarter=750;e.Scaron=556;e.Scommaaccent=556;e.Ohungarumlaut=722;e.degree=400;e.ograve=500;e.Ccaron=667;e.ugrave=556;e.radical=549;e.Dcaron=722;e.rcommaaccent=389;e.Ntilde=722;e.otilde=500;e.Rcommaaccent=667;e.Lcommaaccent=611;e.Atilde=667;e.Aogonek=667;e.Aring=667;e.Otilde=722;e.zdotaccent=389;e.Ecaron=667;e.Iogonek=389;e.kcommaaccent=500;e.minus=606;e.Icircumflex=389;e.ncaron=556;e.tcommaaccent=278;e.logicalnot=606;e.odieresis=500;e.udieresis=556;e.notequal=549;e.gcommaaccent=500;e.eth=500;e.zcaron=389;e.ncommaaccent=556;e.onesuperior=300;e.imacron=278;e.Euro=500; +});e["Times-Italic"]=a(function(e){e.space=250;e.exclam=333;e.quotedbl=420;e.numbersign=500;e.dollar=500;e.percent=833;e.ampersand=778;e.quoteright=333;e.parenleft=333;e.parenright=333;e.asterisk=500;e.plus=675;e.comma=250;e.hyphen=333;e.period=250;e.slash=278;e.zero=500;e.one=500;e.two=500;e.three=500;e.four=500;e.five=500;e.six=500;e.seven=500;e.eight=500;e.nine=500;e.colon=333;e.semicolon=333;e.less=675;e.equal=675;e.greater=675;e.question=500;e.at=920;e.A=611;e.B=611;e.C=667;e.D=722;e.E=611;e.F=611;e.G=722;e.H=722;e.I=333;e.J=444;e.K=667;e.L=556;e.M=833;e.N=667;e.O=722;e.P=611;e.Q=722;e.R=611;e.S=500;e.T=556;e.U=722;e.V=611;e.W=833;e.X=611;e.Y=556;e.Z=556;e.bracketleft=389;e.backslash=278;e.bracketright=389;e.asciicircum=422;e.underscore=500;e.quoteleft=333;e.a=500;e.b=500;e.c=444;e.d=500;e.e=444;e.f=278;e.g=500;e.h=500;e.i=278;e.j=278;e.k=444;e.l=278;e.m=722;e.n=500;e.o=500;e.p=500;e.q=500;e.r=389;e.s=389;e.t=278;e.u=500;e.v=444;e.w=667;e.x=444;e.y=444;e.z=389;e.braceleft=400;e.bar=275;e.braceright=400;e.asciitilde=541;e.exclamdown=389;e.cent=500;e.sterling=500;e.fraction=167;e.yen=500;e.florin=500;e.section=500;e.currency=500;e.quotesingle=214;e.quotedblleft=556;e.guillemotleft=500;e.guilsinglleft=333;e.guilsinglright=333;e.fi=500;e.fl=500;e.endash=500;e.dagger=500;e.daggerdbl=500;e.periodcentered=250;e.paragraph=523;e.bullet=350;e.quotesinglbase=333;e.quotedblbase=556;e.quotedblright=556;e.guillemotright=500;e.ellipsis=889;e.perthousand=1e3;e.questiondown=500;e.grave=333;e.acute=333;e.circumflex=333;e.tilde=333;e.macron=333;e.breve=333;e.dotaccent=333;e.dieresis=333;e.ring=333;e.cedilla=333;e.hungarumlaut=333;e.ogonek=333;e.caron=333;e.emdash=889;e.AE=889;e.ordfeminine=276;e.Lslash=556;e.Oslash=722;e.OE=944;e.ordmasculine=310;e.ae=667;e.dotlessi=278;e.lslash=278;e.oslash=500;e.oe=667;e.germandbls=500;e.Idieresis=333;e.eacute=444;e.abreve=500;e.uhungarumlaut=500;e.ecaron=444;e.Ydieresis=556;e.divide=675;e.Yacute=556;e.Acircumflex=611;e.aacute=500;e.Ucircumflex=722;e.yacute=444;e.scommaaccent=389;e.ecircumflex=444;e.Uring=722;e.Udieresis=722;e.aogonek=500;e.Uacute=722;e.uogonek=500;e.Edieresis=611;e.Dcroat=722;e.commaaccent=250;e.copyright=760;e.Emacron=611;e.ccaron=444;e.aring=500;e.Ncommaaccent=667;e.lacute=278;e.agrave=500;e.Tcommaaccent=556;e.Cacute=667;e.atilde=500;e.Edotaccent=611;e.scaron=389;e.scedilla=389;e.iacute=278;e.lozenge=471;e.Rcaron=611;e.Gcommaaccent=722;e.ucircumflex=500;e.acircumflex=500;e.Amacron=611;e.rcaron=389;e.ccedilla=444;e.Zdotaccent=556;e.Thorn=611;e.Omacron=722;e.Racute=611;e.Sacute=500;e.dcaron=544;e.Umacron=722;e.uring=500;e.threesuperior=300;e.Ograve=722;e.Agrave=611;e.Abreve=611;e.multiply=675;e.uacute=500;e.Tcaron=556;e.partialdiff=476;e.ydieresis=444;e.Nacute=667;e.icircumflex=278;e.Ecircumflex=611;e.adieresis=500;e.edieresis=444;e.cacute=444;e.nacute=500;e.umacron=500;e.Ncaron=667;e.Iacute=333;e.plusminus=675;e.brokenbar=275;e.registered=760;e.Gbreve=722;e.Idotaccent=333;e.summation=600;e.Egrave=611;e.racute=389;e.omacron=500;e.Zacute=556;e.Zcaron=556;e.greaterequal=549;e.Eth=722;e.Ccedilla=667;e.lcommaaccent=278;e.tcaron=300;e.eogonek=444;e.Uogonek=722;e.Aacute=611;e.Adieresis=611;e.egrave=444;e.zacute=389;e.iogonek=278;e.Oacute=722;e.oacute=500;e.amacron=500;e.sacute=389;e.idieresis=278;e.Ocircumflex=722;e.Ugrave=722;e.Delta=612;e.thorn=500;e.twosuperior=300;e.Odieresis=722;e.mu=500;e.igrave=278;e.ohungarumlaut=500;e.Eogonek=611;e.dcroat=500;e.threequarters=750;e.Scedilla=500;e.lcaron=300;e.Kcommaaccent=667;e.Lacute=556;e.trademark=980;e.edotaccent=444;e.Igrave=333;e.Imacron=333;e.Lcaron=611;e.onehalf=750;e.lessequal=549;e.ocircumflex=500;e.ntilde=500;e.Uhungarumlaut=722;e.Eacute=611;e.emacron=444;e.gbreve=500;e.onequarter=750;e.Scaron=500;e.Scommaaccent=500;e.Ohungarumlaut=722;e.degree=400;e.ograve=500;e.Ccaron=667;e.ugrave=500;e.radical=453;e.Dcaron=722;e.rcommaaccent=389;e.Ntilde=667;e.otilde=500;e.Rcommaaccent=611;e.Lcommaaccent=556;e.Atilde=611;e.Aogonek=611;e.Aring=611;e.Otilde=722;e.zdotaccent=389;e.Ecaron=611;e.Iogonek=333;e.kcommaaccent=444;e.minus=675;e.Icircumflex=333;e.ncaron=500;e.tcommaaccent=278;e.logicalnot=675;e.odieresis=500;e.udieresis=500;e.notequal=549;e.gcommaaccent=500;e.eth=500;e.zcaron=389;e.ncommaaccent=500;e.onesuperior=300;e.imacron=278;e.Euro=500});e.ZapfDingbats=a(function(e){e.space=278;e.a1=974;e.a2=961;e.a202=974;e.a3=980;e.a4=719;e.a5=789;e.a119=790;e.a118=791;e.a117=690;e.a11=960;e.a12=939;e.a13=549;e.a14=855;e.a15=911;e.a16=933;e.a105=911;e.a17=945;e.a18=974;e.a19=755;e.a20=846;e.a21=762;e.a22=761;e.a23=571;e.a24=677;e.a25=763;e.a26=760;e.a27=759;e.a28=754;e.a6=494;e.a7=552;e.a8=537;e.a9=577;e.a10=692;e.a29=786;e.a30=788;e.a31=788;e.a32=790;e.a33=793;e.a34=794;e.a35=816;e.a36=823;e.a37=789;e.a38=841;e.a39=823;e.a40=833;e.a41=816;e.a42=831;e.a43=923;e.a44=744;e.a45=723;e.a46=749;e.a47=790;e.a48=792;e.a49=695;e.a50=776;e.a51=768;e.a52=792;e.a53=759;e.a54=707;e.a55=708;e.a56=682;e.a57=701;e.a58=826;e.a59=815;e.a60=789;e.a61=789;e.a62=707;e.a63=687;e.a64=696;e.a65=689;e.a66=786;e.a67=787;e.a68=713;e.a69=791;e.a70=785;e.a71=791;e.a72=873;e.a73=761;e.a74=762;e.a203=762;e.a75=759;e.a204=759;e.a76=892;e.a77=892;e.a78=788;e.a79=784;e.a81=438;e.a82=138;e.a83=277;e.a84=415;e.a97=392;e.a98=392;e.a99=668;e.a100=668;e.a89=390;e.a90=390;e.a93=317;e.a94=317;e.a91=276;e.a92=276;e.a205=509;e.a85=509;e.a206=410;e.a86=410;e.a87=234;e.a88=234;e.a95=334;e.a96=334;e.a101=732;e.a102=544;e.a103=544;e.a104=910;e.a106=667;e.a107=760;e.a108=760;e.a112=776;e.a111=595;e.a110=694;e.a109=626;e.a120=788;e.a121=788;e.a122=788;e.a123=788;e.a124=788;e.a125=788;e.a126=788;e.a127=788;e.a128=788;e.a129=788;e.a130=788;e.a131=788;e.a132=788;e.a133=788;e.a134=788;e.a135=788;e.a136=788;e.a137=788;e.a138=788;e.a139=788;e.a140=788;e.a141=788;e.a142=788;e.a143=788;e.a144=788;e.a145=788;e.a146=788;e.a147=788;e.a148=788;e.a149=788;e.a150=788;e.a151=788;e.a152=788;e.a153=788;e.a154=788;e.a155=788;e.a156=788;e.a157=788;e.a158=788;e.a159=788;e.a160=894;e.a161=838;e.a163=1016;e.a164=458;e.a196=748;e.a165=924;e.a192=748;e.a166=918;e.a167=927;e.a168=928;e.a169=928;e.a170=834;e.a171=873;e.a172=828;e.a173=924;e.a162=924;e.a174=917;e.a175=930;e.a176=931;e.a177=463;e.a178=883;e.a179=836;e.a193=836;e.a180=867;e.a199=867;e.a181=696;e.a200=696;e.a182=874;e.a201=874;e.a183=760;e.a184=946;e.a197=771;e.a185=865;e.a194=771;e.a198=888;e.a186=967;e.a195=888;e.a187=831;e.a188=873;e.a189=927;e.a190=970;e.a191=918})});e.getMetrics=r});!function(e,t){t(e.pdfjsCoreMurmurHash3={},e.pdfjsSharedUtil)}(this,function(e,t){var a=t.Uint32ArrayView,r=function(e){function t(e){var t=3285377520;this.h1=e?4294967295&e:t;this.h2=e?4294967295&e:t}var r=4294901760,i=65535,n=!1;try{new Uint32Array(new Uint8Array(5).buffer,0,1)}catch(s){n=!0}t.prototype={update:function(e){var t,s=n;if("string"==typeof e){var o=new Uint8Array(2*e.length),c=0;for(t=0;t=l)o[c++]=l;else{o[c++]=l>>>8;o[c++]=255&l}}}else if(e instanceof Uint8Array){o=e;c=o.length}else{if(!("object"==typeof e&&"length"in e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");o=e;c=o.length;s=!0}var h=c>>2,u=c-4*h,f=s?new a(o,h):new Uint32Array(o.buffer,0,h),d=0,g=0,p=this.h1,m=this.h2,b=3432918353,v=461845907,y=b&i,k=v&i;for(t=0;h>t;t++)if(1&t){d=f[t];d=d*b&r|d*y&i;d=d<<15|d>>>17;d=d*v&r|d*k&i;p^=d;p=p<<13|p>>>19;p=5*p+3864292196}else{g=f[t];g=g*b&r|g*y&i;g=g<<15|g>>>17;g=g*v&r|g*k&i;m^=g;m=m<<13|m>>>19;m=5*m+3864292196}d=0;switch(u){case 3:d^=o[4*h+2]<<16;case 2:d^=o[4*h+1]<<8;case 1:d^=o[4*h];d=d*b&r|d*y&i;d=d<<15|d>>>17;d=d*v&r|d*k&i;1&h?p^=d:m^=d}this.h1=p;this.h2=m;return this},hexdigest:function(){var e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&r|36045*e&i;t=4283543511*t&r|(2950163797*(t<<16|e>>>16)&r)>>>16;e^=t>>>1;e=444984403*e&r|60499*e&i;t=3301882366*t&r|(3120437893*(t<<16|e>>>16)&r)>>>16;e^=t>>>1;for(var a=0,n=[e,t],s="";a>>0).toString(16);o.length<8;)o="0"+o;s+=o}return s}};return t}();e.MurmurHash3_64=r});!function(e,t){t(e.pdfjsCorePrimitives={},e.pdfjsSharedUtil)}(this,function(e,t){function a(e){return e instanceof l}function r(e,t){return e instanceof h&&(void 0===t||e.cmd===t)}function i(e,t){if(!(e instanceof u))return!1;if(!t)return!0;var r=e.get("Type");return a(r)&&r.name===t}function n(e){return e instanceof f}function s(e,t){return e.num===t.num&&e.gen===t.gen}function o(e){return"object"==typeof e&&null!==e&&void 0!==e.getBytes}var c=t.isArray,l=function(){function e(e){this.name=e}e.prototype={};var t=Object.create(null);e.get=function(a){var r=t[a];return r?r:t[a]=new e(a)};return e}(),h=function(){function e(e){this.cmd=e}e.prototype={};var t=Object.create(null);e.get=function(a){var r=t[a];return r?r:t[a]=new e(a)};return e}(),u=function(){function e(e){this.map=Object.create(null);this.xref=e;this.objId=null;this.__nonSerializable__=t}var t=function(){return t};e.prototype={assignXref:function(e){this.xref=e},get:function(e,t,a){var r,i=this.xref;if("undefined"!=typeof(r=this.map[e])||e in this.map||"undefined"==typeof t)return i?i.fetchIfRef(r):r;if("undefined"!=typeof(r=this.map[t])||t in this.map||"undefined"==typeof a)return i?i.fetchIfRef(r):r;r=this.map[a]||null;return i?i.fetchIfRef(r):r},getAsync:function(e,t,a){var r,i=this.xref;if("undefined"!=typeof(r=this.map[e])||e in this.map||"undefined"==typeof t)return i?i.fetchIfRefAsync(r):Promise.resolve(r);if("undefined"!=typeof(r=this.map[t])||t in this.map||"undefined"==typeof a)return i?i.fetchIfRefAsync(r):Promise.resolve(r);r=this.map[a]||null;return i?i.fetchIfRefAsync(r):Promise.resolve(r)},getArray:function(e,t,a){var r=this.get(e,t,a),i=this.xref;if(!c(r)||!i)return r;r=r.slice();for(var s=0,o=r.length;o>s;s++)n(r[s])&&(r[s]=i.fetch(r[s]));return r},getRaw:function(e){return this.map[e]},getKeys:function(){return Object.keys(this.map)},set:function(e,t){this.map[e]=t},has:function(e){return e in this.map},forEach:function(e){for(var t in this.map)e(t,this.get(t))}};e.empty=new e(null);e.merge=function(t,a){for(var r=new e(t),n=0,s=a.length;s>n;n++){var o=a[n];if(i(o))for(var c in o.map)r.map[c]||(r.map[c]=o.map[c])}return r};return e}(),f=function(){function e(e,t){this.num=e;this.gen=t}e.prototype={toString:function(){var e=this.num+"R";0!==this.gen&&(e+=this.gen);return e}};return e}(),d=function(){function e(){this.dict=Object.create(null)}e.prototype={has:function(e){return e.toString()in this.dict},put:function(e){this.dict[e.toString()]=!0},remove:function(e){delete this.dict[e.toString()]}};return e}(),g=function(){function e(){this.dict=Object.create(null)}e.prototype={get:function(e){return this.dict[e.toString()]},has:function(e){return e.toString()in this.dict},put:function(e,t){this.dict[e.toString()]=t},putAlias:function(e,t){this.dict[e.toString()]=this.get(t)},forEach:function(e,t){for(var a in this.dict)e.call(t,this.dict[a])},clear:function(){this.dict=Object.create(null)}};return e}();e.Cmd=h;e.Dict=u;e.Name=l;e.Ref=f;e.RefSet=d;e.RefSetCache=g;e.isCmd=r;e.isDict=i;e.isName=a;e.isRef=n;e.isRefsEqual=s;e.isStream=o});!function(e,t){t(e.pdfjsCoreStandardFonts={},e.pdfjsSharedUtil)}(this,function(e,t){var a=t.getLookupTableFactory,r=a(function(e){e.ArialNarrow="Helvetica";e["ArialNarrow-Bold"]="Helvetica-Bold";e["ArialNarrow-BoldItalic"]="Helvetica-BoldOblique";e["ArialNarrow-Italic"]="Helvetica-Oblique";e.ArialBlack="Helvetica";e["ArialBlack-Bold"]="Helvetica-Bold";e["ArialBlack-BoldItalic"]="Helvetica-BoldOblique";e["ArialBlack-Italic"]="Helvetica-Oblique";e.Arial="Helvetica";e["Arial-Bold"]="Helvetica-Bold";e["Arial-BoldItalic"]="Helvetica-BoldOblique";e["Arial-Italic"]="Helvetica-Oblique";e["Arial-BoldItalicMT"]="Helvetica-BoldOblique";e["Arial-BoldMT"]="Helvetica-Bold";e["Arial-ItalicMT"]="Helvetica-Oblique";e.ArialMT="Helvetica";e["Courier-Bold"]="Courier-Bold";e["Courier-BoldItalic"]="Courier-BoldOblique";e["Courier-Italic"]="Courier-Oblique";e.CourierNew="Courier";e["CourierNew-Bold"]="Courier-Bold";e["CourierNew-BoldItalic"]="Courier-BoldOblique";e["CourierNew-Italic"]="Courier-Oblique";e["CourierNewPS-BoldItalicMT"]="Courier-BoldOblique";e["CourierNewPS-BoldMT"]="Courier-Bold";e["CourierNewPS-ItalicMT"]="Courier-Oblique";e.CourierNewPSMT="Courier";e.Helvetica="Helvetica";e["Helvetica-Bold"]="Helvetica-Bold";e["Helvetica-BoldItalic"]="Helvetica-BoldOblique";e["Helvetica-BoldOblique"]="Helvetica-BoldOblique";e["Helvetica-Italic"]="Helvetica-Oblique";e["Helvetica-Oblique"]="Helvetica-Oblique";e["Symbol-Bold"]="Symbol";e["Symbol-BoldItalic"]="Symbol";e["Symbol-Italic"]="Symbol";e.TimesNewRoman="Times-Roman";e["TimesNewRoman-Bold"]="Times-Bold";e["TimesNewRoman-BoldItalic"]="Times-BoldItalic";e["TimesNewRoman-Italic"]="Times-Italic";e.TimesNewRomanPS="Times-Roman";e["TimesNewRomanPS-Bold"]="Times-Bold";e["TimesNewRomanPS-BoldItalic"]="Times-BoldItalic";e["TimesNewRomanPS-BoldItalicMT"]="Times-BoldItalic";e["TimesNewRomanPS-BoldMT"]="Times-Bold";e["TimesNewRomanPS-Italic"]="Times-Italic";e["TimesNewRomanPS-ItalicMT"]="Times-Italic";e.TimesNewRomanPSMT="Times-Roman";e["TimesNewRomanPSMT-Bold"]="Times-Bold";e["TimesNewRomanPSMT-BoldItalic"]="Times-BoldItalic";e["TimesNewRomanPSMT-Italic"]="Times-Italic"}),i=a(function(e){e.CenturyGothic="Helvetica";e["CenturyGothic-Bold"]="Helvetica-Bold";e["CenturyGothic-BoldItalic"]="Helvetica-BoldOblique";e["CenturyGothic-Italic"]="Helvetica-Oblique";e.ComicSansMS="Comic Sans MS";e["ComicSansMS-Bold"]="Comic Sans MS-Bold";e["ComicSansMS-BoldItalic"]="Comic Sans MS-BoldItalic";e["ComicSansMS-Italic"]="Comic Sans MS-Italic";e.LucidaConsole="Courier";e["LucidaConsole-Bold"]="Courier-Bold";e["LucidaConsole-BoldItalic"]="Courier-BoldOblique";e["LucidaConsole-Italic"]="Courier-Oblique";e["MS-Gothic"]="MS Gothic";e["MS-Gothic-Bold"]="MS Gothic-Bold";e["MS-Gothic-BoldItalic"]="MS Gothic-BoldItalic";e["MS-Gothic-Italic"]="MS Gothic-Italic";e["MS-Mincho"]="MS Mincho";e["MS-Mincho-Bold"]="MS Mincho-Bold";e["MS-Mincho-BoldItalic"]="MS Mincho-BoldItalic";e["MS-Mincho-Italic"]="MS Mincho-Italic";e["MS-PGothic"]="MS PGothic";e["MS-PGothic-Bold"]="MS PGothic-Bold";e["MS-PGothic-BoldItalic"]="MS PGothic-BoldItalic";e["MS-PGothic-Italic"]="MS PGothic-Italic";e["MS-PMincho"]="MS PMincho";e["MS-PMincho-Bold"]="MS PMincho-Bold";e["MS-PMincho-BoldItalic"]="MS PMincho-BoldItalic";e["MS-PMincho-Italic"]="MS PMincho-Italic";e.Wingdings="ZapfDingbats"}),n=a(function(e){e["Adobe Jenson"]=!0;e["Adobe Text"]=!0;e.Albertus=!0;e.Aldus=!0;e.Alexandria=!0;e.Algerian=!0;e["American Typewriter"]=!0;e.Antiqua=!0;e.Apex=!0;e.Arno=!0;e.Aster=!0;e.Aurora=!0;e.Baskerville=!0;e.Bell=!0;e.Bembo=!0;e["Bembo Schoolbook"]=!0;e.Benguiat=!0;e["Berkeley Old Style"]=!0;e["Bernhard Modern"]=!0;e["Berthold City"]=!0;e.Bodoni=!0;e["Bauer Bodoni"]=!0;e["Book Antiqua"]=!0;e.Bookman=!0;e["Bordeaux Roman"]=!0;e["Californian FB"]=!0;e.Calisto=!0;e.Calvert=!0;e.Capitals=!0;e.Cambria=!0;e.Cartier=!0;e.Caslon=!0;e.Catull=!0;e.Centaur=!0;e["Century Old Style"]=!0;e["Century Schoolbook"]=!0;e.Chaparral=!0;e["Charis SIL"]=!0;e.Cheltenham=!0;e["Cholla Slab"]=!0;e.Clarendon=!0;e.Clearface=!0;e.Cochin=!0;e.Colonna=!0;e["Computer Modern"]=!0;e["Concrete Roman"]=!0;e.Constantia=!0;e["Cooper Black"]=!0;e.Corona=!0;e.Ecotype=!0;e.Egyptienne=!0;e.Elephant=!0;e.Excelsior=!0;e.Fairfield=!0;e["FF Scala"]=!0;e.Folkard=!0;e.Footlight=!0;e.FreeSerif=!0;e["Friz Quadrata"]=!0;e.Garamond=!0;e.Gentium=!0;e.Georgia=!0;e.Gloucester=!0;e["Goudy Old Style"]=!0;e["Goudy Schoolbook"]=!0;e["Goudy Pro Font"]=!0;e.Granjon=!0;e["Guardian Egyptian"]=!0;e.Heather=!0;e.Hercules=!0;e["High Tower Text"]=!0;e.Hiroshige=!0;e["Hoefler Text"]=!0;e["Humana Serif"]=!0;e.Imprint=!0;e["Ionic No. 5"]=!0;e.Janson=!0;e.Joanna=!0;e.Korinna=!0;e.Lexicon=!0;e["Liberation Serif"]=!0;e["Linux Libertine"]=!0;e.Literaturnaya=!0;e.Lucida=!0;e["Lucida Bright"]=!0;e.Melior=!0;e.Memphis=!0;e.Miller=!0;e.Minion=!0;e.Modern=!0;e["Mona Lisa"]=!0;e["Mrs Eaves"]=!0;e["MS Serif"]=!0;e["Museo Slab"]=!0;e["New York"]=!0;e["Nimbus Roman"]=!0;e["NPS Rawlinson Roadway"]=!0;e.Palatino=!0;e.Perpetua=!0;e.Plantin=!0;e["Plantin Schoolbook"]=!0;e.Playbill=!0;e["Poor Richard"]=!0;e["Rawlinson Roadway"]=!0;e.Renault=!0;e.Requiem=!0;e.Rockwell=!0;e.Roman=!0;e["Rotis Serif"]=!0;e.Sabon=!0;e.Scala=!0;e.Seagull=!0;e.Sistina=!0;e.Souvenir=!0;e.STIX=!0;e["Stone Informal"]=!0;e["Stone Serif"]=!0;e.Sylfaen=!0;e.Times=!0;e.Trajan=!0;e["Trinité"]=!0;e["Trump Mediaeval"]=!0;e.Utopia=!0;e["Vale Type"]=!0;e["Bitstream Vera"]=!0;e["Vera Serif"]=!0;e.Versailles=!0;e.Wanted=!0;e.Weiss=!0;e["Wide Latin"]=!0;e.Windsor=!0;e.XITS=!0}),s=a(function(e){e.Dingbats=!0;e.Symbol=!0;e.ZapfDingbats=!0}),o=a(function(e){e[2]=10;e[3]=32;e[4]=33;e[5]=34;e[6]=35;e[7]=36;e[8]=37;e[9]=38;e[10]=39;e[11]=40;e[12]=41;e[13]=42;e[14]=43;e[15]=44;e[16]=45;e[17]=46;e[18]=47;e[19]=48;e[20]=49;e[21]=50;e[22]=51;e[23]=52;e[24]=53;e[25]=54;e[26]=55;e[27]=56;e[28]=57;e[29]=58;e[30]=894;e[31]=60;e[32]=61;e[33]=62;e[34]=63;e[35]=64;e[36]=65;e[37]=66;e[38]=67;e[39]=68;e[40]=69;e[41]=70;e[42]=71;e[43]=72;e[44]=73;e[45]=74;e[46]=75;e[47]=76;e[48]=77;e[49]=78;e[50]=79;e[51]=80;e[52]=81;e[53]=82;e[54]=83;e[55]=84;e[56]=85;e[57]=86;e[58]=87;e[59]=88;e[60]=89;e[61]=90;e[62]=91;e[63]=92;e[64]=93;e[65]=94;e[66]=95;e[67]=96;e[68]=97;e[69]=98;e[70]=99;e[71]=100;e[72]=101;e[73]=102;e[74]=103;e[75]=104;e[76]=105;e[77]=106;e[78]=107;e[79]=108;e[80]=109;e[81]=110;e[82]=111;e[83]=112;e[84]=113;e[85]=114;e[86]=115;e[87]=116;e[88]=117;e[89]=118;e[90]=119;e[91]=120;e[92]=121;e[93]=122;e[94]=123;e[95]=124;e[96]=125;e[97]=126;e[98]=196;e[99]=197;e[100]=199;e[101]=201;e[102]=209;e[103]=214;e[104]=220;e[105]=225;e[106]=224;e[107]=226;e[108]=228;e[109]=227;e[110]=229;e[111]=231;e[112]=233;e[113]=232;e[114]=234;e[115]=235;e[116]=237;e[117]=236;e[118]=238;e[119]=239;e[120]=241;e[121]=243;e[122]=242;e[123]=244;e[124]=246;e[125]=245;e[126]=250;e[127]=249;e[128]=251;e[129]=252;e[130]=8224;e[131]=176;e[132]=162;e[133]=163;e[134]=167;e[135]=8226;e[136]=182;e[137]=223;e[138]=174;e[139]=169;e[140]=8482;e[141]=180;e[142]=168;e[143]=8800;e[144]=198;e[145]=216;e[146]=8734;e[147]=177;e[148]=8804;e[149]=8805;e[150]=165;e[151]=181;e[152]=8706;e[153]=8721;e[154]=8719;e[156]=8747;e[157]=170;e[158]=186;e[159]=8486;e[160]=230;e[161]=248;e[162]=191;e[163]=161;e[164]=172;e[165]=8730;e[166]=402;e[167]=8776;e[168]=8710;e[169]=171;e[170]=187;e[171]=8230;e[210]=218;e[223]=711;e[224]=321;e[225]=322;e[227]=353;e[229]=382;e[234]=253;e[252]=263;e[253]=268;e[254]=269;e[258]=258;e[260]=260;e[261]=261;e[265]=280;e[266]=281;e[268]=283;e[269]=313;e[275]=323;e[276]=324;e[278]=328;e[284]=345;e[285]=346;e[286]=347;e[292]=367;e[295]=377;e[296]=378;e[298]=380;e[305]=963;e[306]=964;e[307]=966;e[308]=8215;e[309]=8252;e[310]=8319;e[311]=8359;e[312]=8592;e[313]=8593;e[337]=9552;e[493]=1039;e[494]=1040;e[705]=1524;e[706]=8362;e[710]=64288;e[711]=64298;e[759]=1617;e[761]=1776;e[763]=1778;e[775]=1652;e[777]=1764;e[778]=1780;e[779]=1781;e[780]=1782;e[782]=771;e[783]=64726;e[786]=8363;e[788]=8532;e[790]=768;e[791]=769;e[792]=768;e[795]=803;e[797]=64336;e[798]=64337;e[799]=64342;e[800]=64343;e[801]=64344;e[802]=64345;e[803]=64362;e[804]=64363;e[805]=64364;e[2424]=7821;e[2425]=7822;e[2426]=7823;e[2427]=7824;e[2428]=7825;e[2429]=7826;e[2430]=7827;e[2433]=7682;e[2678]=8045;e[2679]=8046;e[2830]=1552;e[2838]=686;e[2840]=751;e[2842]=753;e[2843]=754;e[2844]=755;e[2846]=757;e[2856]=767;e[2857]=848;e[2858]=849;e[2862]=853;e[2863]=854;e[2864]=855;e[2865]=861;e[2866]=862;e[2906]=7460;e[2908]=7462;e[2909]=7463;e[2910]=7464;e[2912]=7466;e[2913]=7467;e[2914]=7468;e[2916]=7470;e[2917]=7471;e[2918]=7472;e[2920]=7474;e[2921]=7475;e[2922]=7476;e[2924]=7478;e[2925]=7479;e[2926]=7480;e[2928]=7482;e[2929]=7483;e[2930]=7484;e[2932]=7486;e[2933]=7487;e[2934]=7488;e[2936]=7490;e[2937]=7491;e[2938]=7492;e[2940]=7494;e[2941]=7495;e[2942]=7496;e[2944]=7498;e[2946]=7500;e[2948]=7502;e[2950]=7504;e[2951]=7505;e[2952]=7506;e[2954]=7508;e[2955]=7509;e[2956]=7510;e[2958]=7512;e[2959]=7513;e[2960]=7514;e[2962]=7516;e[2963]=7517;e[2964]=7518;e[2966]=7520;e[2967]=7521;e[2968]=7522;e[2970]=7524;e[2971]=7525;e[2972]=7526;e[2974]=7528;e[2975]=7529;e[2976]=7530;e[2978]=1537;e[2979]=1538;e[2980]=1539;e[2982]=1549;e[2983]=1551;e[2984]=1552;e[2986]=1554;e[2987]=1555;e[2988]=1556;e[2990]=1623;e[2991]=1624;e[2995]=1775;e[2999]=1791;e[3002]=64290;e[3003]=64291;e[3004]=64292;e[3006]=64294;e[3007]=64295;e[3008]=64296;e[3011]=1900;e[3014]=8223;e[3015]=8244;e[3017]=7532;e[3018]=7533;e[3019]=7534;e[3075]=7590;e[3076]=7591;e[3079]=7594;e[3080]=7595;e[3083]=7598;e[3084]=7599;e[3087]=7602;e[3088]=7603;e[3091]=7606;e[3092]=7607;e[3095]=7610;e[3096]=7611;e[3099]=7614;e[3100]=7615;e[3103]=7618;e[3104]=7619;e[3107]=8337;e[3108]=8338;e[3116]=1884;e[3119]=1885;e[3120]=1885;e[3123]=1886;e[3124]=1886;e[3127]=1887;e[3128]=1887;e[3131]=1888;e[3132]=1888;e[3135]=1889;e[3136]=1889;e[3139]=1890;e[3140]=1890;e[3143]=1891;e[3144]=1891;e[3147]=1892;e[3148]=1892;e[3153]=580;e[3154]=581;e[3157]=584;e[3158]=585;e[3161]=588;e[3162]=589;e[3165]=891;e[3166]=892;e[3169]=1274;e[3170]=1275;e[3173]=1278;e[3174]=1279;e[3181]=7622;e[3182]=7623;e[3282]=11799;e[3316]=578;e[3379]=42785;e[3393]=1159;e[3416]=8377}),c=a(function(e){e[227]=322;e[264]=261;e[291]=346});e.getStdFontMap=r;e.getNonStdFontMap=i;e.getSerifFonts=n;e.getSymbolsFonts=s;e.getGlyphMapForStandardFonts=o;e.getSupplementalGlyphMapForArialBlack=c});!function(e,t){t(e.pdfjsCoreUnicode={},e.pdfjsSharedUtil)}(this,function(e,t){function a(e){return e>=65520&&65535>=e?0:e>=62976&&63743>=e?c()[e]||e:e}function r(e,t){var a=t[e];if(void 0!==a)return a;if(!e)return-1;if("u"===e[0]){var r,i=e.length;if(7===i&&"n"===e[1]&&"i"===e[2])r=e.substr(3);else{if(!(i>=5&&7>=i))return-1;r=e.substr(1)}if(r===r.toUpperCase()){a=parseInt(r,16);if(a>=0)return a}}return-1}function i(e){for(var t=0,a=l.length;a>t;t++){var r=l[t];if(e>=r.begin&&e=t.begin&&e=t.begin&&e=t||!n(e.charCodeAt(0)))return e;for(var a="",r=t-1;r>=0;r--)a+=e[r];return a}var o=t.getLookupTableFactory,c=o(function(e){e[63721]=169;e[63193]=169;e[63720]=174;e[63194]=174;e[63722]=8482;e[63195]=8482;e[63729]=9127;e[63730]=9128;e[63731]=9129;e[63740]=9131;e[63741]=9132;e[63742]=9133;e[63726]=9121;e[63727]=9122;e[63728]=9123;e[63737]=9124;e[63738]=9125;e[63739]=9126;e[63723]=9115;e[63724]=9116;e[63725]=9117;e[63734]=9118;e[63735]=9119;e[63736]=9120}),l=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}],h=o(function(e){e["¨"]=" ̈";e["¯"]=" ̄";e["´"]=" ́";e["µ"]="μ";e["¸"]=" ̧";e["IJ"]="IJ";e["ij"]="ij";e["Ŀ"]="L·";e["ŀ"]="l·";e["ʼn"]="ʼn";e["ſ"]="s";e["DŽ"]="DŽ";e["Dž"]="Dž";e["dž"]="dž";e["LJ"]="LJ";e["Lj"]="Lj";e["lj"]="lj";e["NJ"]="NJ";e["Nj"]="Nj";e["nj"]="nj";e["DZ"]="DZ";e["Dz"]="Dz";e["dz"]="dz";e["˘"]=" ̆";e["˙"]=" ̇";e["˚"]=" ̊";e["˛"]=" ̨";e["˜"]=" ̃";e["˝"]=" ̋";e["ͺ"]=" ͅ";e["΄"]=" ́";e["ϐ"]="β";e["ϑ"]="θ";e["ϒ"]="Υ";e["ϕ"]="φ";e["ϖ"]="π";e["ϰ"]="κ";e["ϱ"]="ρ";e["ϲ"]="ς";e["ϴ"]="Θ";e["ϵ"]="ε";e["Ϲ"]="Σ";e["և"]="եւ";e["ٵ"]="اٴ";e["ٶ"]="وٴ";e["ٷ"]="ۇٴ";e["ٸ"]="يٴ";e["ำ"]="ํา";e["ຳ"]="ໍາ";e["ໜ"]="ຫນ";e["ໝ"]="ຫມ";e["ཷ"]="ྲཱྀ";e["ཹ"]="ླཱྀ";e["ẚ"]="aʾ";e["᾽"]=" ̓";e["᾿"]=" ̓";e["῀"]=" ͂";e["῾"]=" ̔";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e["‗"]=" ̳";e["․"]=".";e["‥"]="..";e["…"]="...";e["″"]="′′";e["‴"]="′′′";e["‶"]="‵‵";e["‷"]="‵‵‵";e["‼"]="!!";e["‾"]=" ̅";e["⁇"]="??";e["⁈"]="?!";e["⁉"]="!?";e["⁗"]="′′′′";e[" "]=" ";e["₨"]="Rs";e["℀"]="a/c";e["℁"]="a/s";e["℃"]="°C";e["℅"]="c/o";e["℆"]="c/u";e["ℇ"]="Ɛ";e["℉"]="°F";e["№"]="No";e["℡"]="TEL";e["ℵ"]="א";e["ℶ"]="ב";e["ℷ"]="ג";e["ℸ"]="ד";e["℻"]="FAX";e["Ⅰ"]="I";e["Ⅱ"]="II";e["Ⅲ"]="III";e["Ⅳ"]="IV";e["Ⅴ"]="V";e["Ⅵ"]="VI";e["Ⅶ"]="VII";e["Ⅷ"]="VIII";e["Ⅸ"]="IX";e["Ⅹ"]="X";e["Ⅺ"]="XI";e["Ⅻ"]="XII";e["Ⅼ"]="L";e["Ⅽ"]="C";e["Ⅾ"]="D";e["Ⅿ"]="M";e["ⅰ"]="i";e["ⅱ"]="ii";e["ⅲ"]="iii";e["ⅳ"]="iv";e["ⅴ"]="v";e["ⅵ"]="vi";e["ⅶ"]="vii";e["ⅷ"]="viii";e["ⅸ"]="ix";e["ⅹ"]="x";e["ⅺ"]="xi";e["ⅻ"]="xii";e["ⅼ"]="l";e["ⅽ"]="c";e["ⅾ"]="d";e["ⅿ"]="m";e["∬"]="∫∫";e["∭"]="∫∫∫";e["∯"]="∮∮";e["∰"]="∮∮∮";e["⑴"]="(1)";e["⑵"]="(2)";e["⑶"]="(3)";e["⑷"]="(4)";e["⑸"]="(5)";e["⑹"]="(6)";e["⑺"]="(7)";e["⑻"]="(8)";e["⑼"]="(9)";e["⑽"]="(10)";e["⑾"]="(11)";e["⑿"]="(12)";e["⒀"]="(13)";e["⒁"]="(14)";e["⒂"]="(15)";e["⒃"]="(16)";e["⒄"]="(17)";e["⒅"]="(18)";e["⒆"]="(19)";e["⒇"]="(20)";e["⒈"]="1.";e["⒉"]="2.";e["⒊"]="3.";e["⒋"]="4.";e["⒌"]="5.";e["⒍"]="6.";e["⒎"]="7.";e["⒏"]="8.";e["⒐"]="9.";e["⒑"]="10.";e["⒒"]="11.";e["⒓"]="12.";e["⒔"]="13.";e["⒕"]="14.";e["⒖"]="15.";e["⒗"]="16.";e["⒘"]="17.";e["⒙"]="18.";e["⒚"]="19.";e["⒛"]="20.";e["⒜"]="(a)";e["⒝"]="(b)";e["⒞"]="(c)";e["⒟"]="(d)";e["⒠"]="(e)";e["⒡"]="(f)";e["⒢"]="(g)";e["⒣"]="(h)";e["⒤"]="(i)";e["⒥"]="(j)";e["⒦"]="(k)";e["⒧"]="(l)";e["⒨"]="(m)";e["⒩"]="(n)";e["⒪"]="(o)";e["⒫"]="(p)";e["⒬"]="(q)";e["⒭"]="(r)";e["⒮"]="(s)";e["⒯"]="(t)";e["⒰"]="(u)";e["⒱"]="(v)";e["⒲"]="(w)";e["⒳"]="(x)";e["⒴"]="(y)";e["⒵"]="(z)";e["⨌"]="∫∫∫∫";e["⩴"]="::=";e["⩵"]="==";e["⩶"]="===";e["⺟"]="母";e["⻳"]="龟";e["⼀"]="一";e["⼁"]="丨";e["⼂"]="丶";e["⼃"]="丿";e["⼄"]="乙";e["⼅"]="亅";e["⼆"]="二";e["⼇"]="亠";e["⼈"]="人";e["⼉"]="儿";e["⼊"]="入";e["⼋"]="八";e["⼌"]="冂";e["⼍"]="冖";e["⼎"]="冫";e["⼏"]="几";e["⼐"]="凵";e["⼑"]="刀";e["⼒"]="力";e["⼓"]="勹";e["⼔"]="匕";e["⼕"]="匚";e["⼖"]="匸";e["⼗"]="十";e["⼘"]="卜";e["⼙"]="卩";e["⼚"]="厂";e["⼛"]="厶";e["⼜"]="又";e["⼝"]="口";e["⼞"]="囗";e["⼟"]="土";e["⼠"]="士";e["⼡"]="夂";e["⼢"]="夊";e["⼣"]="夕";e["⼤"]="大";e["⼥"]="女";e["⼦"]="子";e["⼧"]="宀";e["⼨"]="寸";e["⼩"]="小";e["⼪"]="尢";e["⼫"]="尸";e["⼬"]="屮";e["⼭"]="山";e["⼮"]="巛";e["⼯"]="工";e["⼰"]="己";e["⼱"]="巾";e["⼲"]="干";e["⼳"]="幺";e["⼴"]="广";e["⼵"]="廴";e["⼶"]="廾";e["⼷"]="弋";e["⼸"]="弓";e["⼹"]="彐";e["⼺"]="彡";e["⼻"]="彳";e["⼼"]="心";e["⼽"]="戈";e["⼾"]="戶";e["⼿"]="手";e["⽀"]="支";e["⽁"]="攴";e["⽂"]="文";e["⽃"]="斗";e["⽄"]="斤";e["⽅"]="方";e["⽆"]="无";e["⽇"]="日";e["⽈"]="曰";e["⽉"]="月";e["⽊"]="木";e["⽋"]="欠";e["⽌"]="止";e["⽍"]="歹";e["⽎"]="殳";e["⽏"]="毋";e["⽐"]="比";e["⽑"]="毛";e["⽒"]="氏";e["⽓"]="气";e["⽔"]="水";e["⽕"]="火";e["⽖"]="爪";e["⽗"]="父";e["⽘"]="爻";e["⽙"]="爿";e["⽚"]="片";e["⽛"]="牙";e["⽜"]="牛";e["⽝"]="犬";e["⽞"]="玄";e["⽟"]="玉";e["⽠"]="瓜";e["⽡"]="瓦";e["⽢"]="甘";e["⽣"]="生";e["⽤"]="用";e["⽥"]="田";e["⽦"]="疋";e["⽧"]="疒";e["⽨"]="癶";e["⽩"]="白";e["⽪"]="皮";e["⽫"]="皿";e["⽬"]="目";e["⽭"]="矛";e["⽮"]="矢";e["⽯"]="石";e["⽰"]="示";e["⽱"]="禸";e["⽲"]="禾";e["⽳"]="穴";e["⽴"]="立";e["⽵"]="竹";e["⽶"]="米";e["⽷"]="糸";e["⽸"]="缶";e["⽹"]="网";e["⽺"]="羊";e["⽻"]="羽";e["⽼"]="老";e["⽽"]="而";e["⽾"]="耒";e["⽿"]="耳";e["⾀"]="聿";e["⾁"]="肉";e["⾂"]="臣";e["⾃"]="自";e["⾄"]="至";e["⾅"]="臼";e["⾆"]="舌";e["⾇"]="舛";e["⾈"]="舟";e["⾉"]="艮";e["⾊"]="色";e["⾋"]="艸";e["⾌"]="虍";e["⾍"]="虫";e["⾎"]="血";e["⾏"]="行";e["⾐"]="衣";e["⾑"]="襾";e["⾒"]="見";e["⾓"]="角";e["⾔"]="言";e["⾕"]="谷";e["⾖"]="豆";e["⾗"]="豕";e["⾘"]="豸";e["⾙"]="貝";e["⾚"]="赤";e["⾛"]="走";e["⾜"]="足";e["⾝"]="身";e["⾞"]="車";e["⾟"]="辛";e["⾠"]="辰";e["⾡"]="辵";e["⾢"]="邑";e["⾣"]="酉";e["⾤"]="釆";e["⾥"]="里";e["⾦"]="金";e["⾧"]="長";e["⾨"]="門";e["⾩"]="阜";e["⾪"]="隶";e["⾫"]="隹";e["⾬"]="雨";e["⾭"]="靑";e["⾮"]="非";e["⾯"]="面";e["⾰"]="革";e["⾱"]="韋";e["⾲"]="韭";e["⾳"]="音";e["⾴"]="頁";e["⾵"]="風";e["⾶"]="飛";e["⾷"]="食";e["⾸"]="首";e["⾹"]="香";e["⾺"]="馬";e["⾻"]="骨";e["⾼"]="高";e["⾽"]="髟";e["⾾"]="鬥";e["⾿"]="鬯";e["⿀"]="鬲";e["⿁"]="鬼";e["⿂"]="魚";e["⿃"]="鳥";e["⿄"]="鹵";e["⿅"]="鹿";e["⿆"]="麥";e["⿇"]="麻";e["⿈"]="黃";e["⿉"]="黍";e["⿊"]="黑";e["⿋"]="黹";e["⿌"]="黽";e["⿍"]="鼎";e["⿎"]="鼓";e["⿏"]="鼠";e["⿐"]="鼻";e["⿑"]="齊";e["⿒"]="齒";e["⿓"]="龍";e["⿔"]="龜";e["⿕"]="龠";e["〶"]="〒";e["〸"]="十";e["〹"]="卄";e["〺"]="卅";e["゛"]=" ゙";e["゜"]=" ゚";e["ㄱ"]="ᄀ";e["ㄲ"]="ᄁ";e["ㄳ"]="ᆪ";e["ㄴ"]="ᄂ";e["ㄵ"]="ᆬ";e["ㄶ"]="ᆭ";e["ㄷ"]="ᄃ";e["ㄸ"]="ᄄ";e["ㄹ"]="ᄅ";e["ㄺ"]="ᆰ";e["ㄻ"]="ᆱ";e["ㄼ"]="ᆲ";e["ㄽ"]="ᆳ";e["ㄾ"]="ᆴ";e["ㄿ"]="ᆵ";e["ㅀ"]="ᄚ";e["ㅁ"]="ᄆ";e["ㅂ"]="ᄇ";e["ㅃ"]="ᄈ";e["ㅄ"]="ᄡ";e["ㅅ"]="ᄉ";e["ㅆ"]="ᄊ";e["ㅇ"]="ᄋ";e["ㅈ"]="ᄌ";e["ㅉ"]="ᄍ";e["ㅊ"]="ᄎ";e["ㅋ"]="ᄏ";e["ㅌ"]="ᄐ";e["ㅍ"]="ᄑ";e["ㅎ"]="ᄒ";e["ㅏ"]="ᅡ";e["ㅐ"]="ᅢ";e["ㅑ"]="ᅣ";e["ㅒ"]="ᅤ";e["ㅓ"]="ᅥ";e["ㅔ"]="ᅦ";e["ㅕ"]="ᅧ";e["ㅖ"]="ᅨ";e["ㅗ"]="ᅩ";e["ㅘ"]="ᅪ";e["ㅙ"]="ᅫ";e["ㅚ"]="ᅬ";e["ㅛ"]="ᅭ";e["ㅜ"]="ᅮ";e["ㅝ"]="ᅯ";e["ㅞ"]="ᅰ";e["ㅟ"]="ᅱ";e["ㅠ"]="ᅲ";e["ㅡ"]="ᅳ";e["ㅢ"]="ᅴ";e["ㅣ"]="ᅵ";e["ㅤ"]="ᅠ";e["ㅥ"]="ᄔ";e["ㅦ"]="ᄕ";e["ㅧ"]="ᇇ";e["ㅨ"]="ᇈ";e["ㅩ"]="ᇌ";e["ㅪ"]="ᇎ";e["ㅫ"]="ᇓ";e["ㅬ"]="ᇗ";e["ㅭ"]="ᇙ";e["ㅮ"]="ᄜ";e["ㅯ"]="ᇝ";e["ㅰ"]="ᇟ";e["ㅱ"]="ᄝ";e["ㅲ"]="ᄞ";e["ㅳ"]="ᄠ";e["ㅴ"]="ᄢ";e["ㅵ"]="ᄣ";e["ㅶ"]="ᄧ";e["ㅷ"]="ᄩ";e["ㅸ"]="ᄫ";e["ㅹ"]="ᄬ";e["ㅺ"]="ᄭ";e["ㅻ"]="ᄮ";e["ㅼ"]="ᄯ";e["ㅽ"]="ᄲ";e["ㅾ"]="ᄶ";e["ㅿ"]="ᅀ";e["ㆀ"]="ᅇ";e["ㆁ"]="ᅌ";e["ㆂ"]="ᇱ";e["ㆃ"]="ᇲ";e["ㆄ"]="ᅗ";e["ㆅ"]="ᅘ";e["ㆆ"]="ᅙ";e["ㆇ"]="ᆄ";e["ㆈ"]="ᆅ";e["ㆉ"]="ᆈ";e["ㆊ"]="ᆑ";e["ㆋ"]="ᆒ";e["ㆌ"]="ᆔ";e["ㆍ"]="ᆞ";e["ㆎ"]="ᆡ";e["㈀"]="(ᄀ)";e["㈁"]="(ᄂ)";e["㈂"]="(ᄃ)";e["㈃"]="(ᄅ)";e["㈄"]="(ᄆ)";e["㈅"]="(ᄇ)";e["㈆"]="(ᄉ)";e["㈇"]="(ᄋ)";e["㈈"]="(ᄌ)";e["㈉"]="(ᄎ)";e["㈊"]="(ᄏ)";e["㈋"]="(ᄐ)";e["㈌"]="(ᄑ)";e["㈍"]="(ᄒ)";e["㈎"]="(가)";e["㈏"]="(나)";e["㈐"]="(다)";e["㈑"]="(라)";e["㈒"]="(마)";e["㈓"]="(바)";e["㈔"]="(사)";e["㈕"]="(아)";e["㈖"]="(자)";e["㈗"]="(차)";e["㈘"]="(카)";e["㈙"]="(타)";e["㈚"]="(파)";e["㈛"]="(하)";e["㈜"]="(주)";e["㈝"]="(오전)";e["㈞"]="(오후)";e["㈠"]="(一)";e["㈡"]="(二)";e["㈢"]="(三)";e["㈣"]="(四)";e["㈤"]="(五)";e["㈥"]="(六)";e["㈦"]="(七)";e["㈧"]="(八)";e["㈨"]="(九)";e["㈩"]="(十)";e["㈪"]="(月)";e["㈫"]="(火)";e["㈬"]="(水)";e["㈭"]="(木)";e["㈮"]="(金)";e["㈯"]="(土)";e["㈰"]="(日)";e["㈱"]="(株)";e["㈲"]="(有)";e["㈳"]="(社)";e["㈴"]="(名)";e["㈵"]="(特)"; +e["㈶"]="(財)";e["㈷"]="(祝)";e["㈸"]="(労)";e["㈹"]="(代)";e["㈺"]="(呼)";e["㈻"]="(学)";e["㈼"]="(監)";e["㈽"]="(企)";e["㈾"]="(資)";e["㈿"]="(協)";e["㉀"]="(祭)";e["㉁"]="(休)";e["㉂"]="(自)";e["㉃"]="(至)";e["㋀"]="1月";e["㋁"]="2月";e["㋂"]="3月";e["㋃"]="4月";e["㋄"]="5月";e["㋅"]="6月";e["㋆"]="7月";e["㋇"]="8月";e["㋈"]="9月";e["㋉"]="10月";e["㋊"]="11月";e["㋋"]="12月";e["㍘"]="0点";e["㍙"]="1点";e["㍚"]="2点";e["㍛"]="3点";e["㍜"]="4点";e["㍝"]="5点";e["㍞"]="6点";e["㍟"]="7点";e["㍠"]="8点";e["㍡"]="9点";e["㍢"]="10点";e["㍣"]="11点";e["㍤"]="12点";e["㍥"]="13点";e["㍦"]="14点";e["㍧"]="15点";e["㍨"]="16点";e["㍩"]="17点";e["㍪"]="18点";e["㍫"]="19点";e["㍬"]="20点";e["㍭"]="21点";e["㍮"]="22点";e["㍯"]="23点";e["㍰"]="24点";e["㏠"]="1日";e["㏡"]="2日";e["㏢"]="3日";e["㏣"]="4日";e["㏤"]="5日";e["㏥"]="6日";e["㏦"]="7日";e["㏧"]="8日";e["㏨"]="9日";e["㏩"]="10日";e["㏪"]="11日";e["㏫"]="12日";e["㏬"]="13日";e["㏭"]="14日";e["㏮"]="15日";e["㏯"]="16日";e["㏰"]="17日";e["㏱"]="18日";e["㏲"]="19日";e["㏳"]="20日";e["㏴"]="21日";e["㏵"]="22日";e["㏶"]="23日";e["㏷"]="24日";e["㏸"]="25日";e["㏹"]="26日";e["㏺"]="27日";e["㏻"]="28日";e["㏼"]="29日";e["㏽"]="30日";e["㏾"]="31日";e["ff"]="ff";e["fi"]="fi";e["fl"]="fl";e["ffi"]="ffi";e["ffl"]="ffl";e["ſt"]="ſt";e["st"]="st";e["ﬓ"]="մն";e["ﬔ"]="մե";e["ﬕ"]="մի";e["ﬖ"]="վն";e["ﬗ"]="մխ";e["ﭏ"]="אל";e["ﭐ"]="ٱ";e["ﭑ"]="ٱ";e["ﭒ"]="ٻ";e["ﭓ"]="ٻ";e["ﭔ"]="ٻ";e["ﭕ"]="ٻ";e["ﭖ"]="پ";e["ﭗ"]="پ";e["ﭘ"]="پ";e["ﭙ"]="پ";e["ﭚ"]="ڀ";e["ﭛ"]="ڀ";e["ﭜ"]="ڀ";e["ﭝ"]="ڀ";e["ﭞ"]="ٺ";e["ﭟ"]="ٺ";e["ﭠ"]="ٺ";e["ﭡ"]="ٺ";e["ﭢ"]="ٿ";e["ﭣ"]="ٿ";e["ﭤ"]="ٿ";e["ﭥ"]="ٿ";e["ﭦ"]="ٹ";e["ﭧ"]="ٹ";e["ﭨ"]="ٹ";e["ﭩ"]="ٹ";e["ﭪ"]="ڤ";e["ﭫ"]="ڤ";e["ﭬ"]="ڤ";e["ﭭ"]="ڤ";e["ﭮ"]="ڦ";e["ﭯ"]="ڦ";e["ﭰ"]="ڦ";e["ﭱ"]="ڦ";e["ﭲ"]="ڄ";e["ﭳ"]="ڄ";e["ﭴ"]="ڄ";e["ﭵ"]="ڄ";e["ﭶ"]="ڃ";e["ﭷ"]="ڃ";e["ﭸ"]="ڃ";e["ﭹ"]="ڃ";e["ﭺ"]="چ";e["ﭻ"]="چ";e["ﭼ"]="چ";e["ﭽ"]="چ";e["ﭾ"]="ڇ";e["ﭿ"]="ڇ";e["ﮀ"]="ڇ";e["ﮁ"]="ڇ";e["ﮂ"]="ڍ";e["ﮃ"]="ڍ";e["ﮄ"]="ڌ";e["ﮅ"]="ڌ";e["ﮆ"]="ڎ";e["ﮇ"]="ڎ";e["ﮈ"]="ڈ";e["ﮉ"]="ڈ";e["ﮊ"]="ژ";e["ﮋ"]="ژ";e["ﮌ"]="ڑ";e["ﮍ"]="ڑ";e["ﮎ"]="ک";e["ﮏ"]="ک";e["ﮐ"]="ک";e["ﮑ"]="ک";e["ﮒ"]="گ";e["ﮓ"]="گ";e["ﮔ"]="گ";e["ﮕ"]="گ";e["ﮖ"]="ڳ";e["ﮗ"]="ڳ";e["ﮘ"]="ڳ";e["ﮙ"]="ڳ";e["ﮚ"]="ڱ";e["ﮛ"]="ڱ";e["ﮜ"]="ڱ";e["ﮝ"]="ڱ";e["ﮞ"]="ں";e["ﮟ"]="ں";e["ﮠ"]="ڻ";e["ﮡ"]="ڻ";e["ﮢ"]="ڻ";e["ﮣ"]="ڻ";e["ﮤ"]="ۀ";e["ﮥ"]="ۀ";e["ﮦ"]="ہ";e["ﮧ"]="ہ";e["ﮨ"]="ہ";e["ﮩ"]="ہ";e["ﮪ"]="ھ";e["ﮫ"]="ھ";e["ﮬ"]="ھ";e["ﮭ"]="ھ";e["ﮮ"]="ے";e["ﮯ"]="ے";e["ﮰ"]="ۓ";e["ﮱ"]="ۓ";e["ﯓ"]="ڭ";e["ﯔ"]="ڭ";e["ﯕ"]="ڭ";e["ﯖ"]="ڭ";e["ﯗ"]="ۇ";e["ﯘ"]="ۇ";e["ﯙ"]="ۆ";e["ﯚ"]="ۆ";e["ﯛ"]="ۈ";e["ﯜ"]="ۈ";e["ﯝ"]="ٷ";e["ﯞ"]="ۋ";e["ﯟ"]="ۋ";e["ﯠ"]="ۅ";e["ﯡ"]="ۅ";e["ﯢ"]="ۉ";e["ﯣ"]="ۉ";e["ﯤ"]="ې";e["ﯥ"]="ې";e["ﯦ"]="ې";e["ﯧ"]="ې";e["ﯨ"]="ى";e["ﯩ"]="ى";e["ﯪ"]="ئا";e["ﯫ"]="ئا";e["ﯬ"]="ئە";e["ﯭ"]="ئە";e["ﯮ"]="ئو";e["ﯯ"]="ئو";e["ﯰ"]="ئۇ";e["ﯱ"]="ئۇ";e["ﯲ"]="ئۆ";e["ﯳ"]="ئۆ";e["ﯴ"]="ئۈ";e["ﯵ"]="ئۈ";e["ﯶ"]="ئې";e["ﯷ"]="ئې";e["ﯸ"]="ئې";e["ﯹ"]="ئى";e["ﯺ"]="ئى";e["ﯻ"]="ئى";e["ﯼ"]="ی";e["ﯽ"]="ی";e["ﯾ"]="ی";e["ﯿ"]="ی";e["ﰀ"]="ئج";e["ﰁ"]="ئح";e["ﰂ"]="ئم";e["ﰃ"]="ئى";e["ﰄ"]="ئي";e["ﰅ"]="بج";e["ﰆ"]="بح";e["ﰇ"]="بخ";e["ﰈ"]="بم";e["ﰉ"]="بى";e["ﰊ"]="بي";e["ﰋ"]="تج";e["ﰌ"]="تح";e["ﰍ"]="تخ";e["ﰎ"]="تم";e["ﰏ"]="تى";e["ﰐ"]="تي";e["ﰑ"]="ثج";e["ﰒ"]="ثم";e["ﰓ"]="ثى";e["ﰔ"]="ثي";e["ﰕ"]="جح";e["ﰖ"]="جم";e["ﰗ"]="حج";e["ﰘ"]="حم";e["ﰙ"]="خج";e["ﰚ"]="خح";e["ﰛ"]="خم";e["ﰜ"]="سج";e["ﰝ"]="سح";e["ﰞ"]="سخ";e["ﰟ"]="سم";e["ﰠ"]="صح";e["ﰡ"]="صم";e["ﰢ"]="ضج";e["ﰣ"]="ضح";e["ﰤ"]="ضخ";e["ﰥ"]="ضم";e["ﰦ"]="طح";e["ﰧ"]="طم";e["ﰨ"]="ظم";e["ﰩ"]="عج";e["ﰪ"]="عم";e["ﰫ"]="غج";e["ﰬ"]="غم";e["ﰭ"]="فج";e["ﰮ"]="فح";e["ﰯ"]="فخ";e["ﰰ"]="فم";e["ﰱ"]="فى";e["ﰲ"]="في";e["ﰳ"]="قح";e["ﰴ"]="قم";e["ﰵ"]="قى";e["ﰶ"]="قي";e["ﰷ"]="كا";e["ﰸ"]="كج";e["ﰹ"]="كح";e["ﰺ"]="كخ";e["ﰻ"]="كل";e["ﰼ"]="كم";e["ﰽ"]="كى";e["ﰾ"]="كي";e["ﰿ"]="لج";e["ﱀ"]="لح";e["ﱁ"]="لخ";e["ﱂ"]="لم";e["ﱃ"]="لى";e["ﱄ"]="لي";e["ﱅ"]="مج";e["ﱆ"]="مح";e["ﱇ"]="مخ";e["ﱈ"]="مم";e["ﱉ"]="مى";e["ﱊ"]="مي";e["ﱋ"]="نج";e["ﱌ"]="نح";e["ﱍ"]="نخ";e["ﱎ"]="نم";e["ﱏ"]="نى";e["ﱐ"]="ني";e["ﱑ"]="هج";e["ﱒ"]="هم";e["ﱓ"]="هى";e["ﱔ"]="هي";e["ﱕ"]="يج";e["ﱖ"]="يح";e["ﱗ"]="يخ";e["ﱘ"]="يم";e["ﱙ"]="يى";e["ﱚ"]="يي";e["ﱛ"]="ذٰ";e["ﱜ"]="رٰ";e["ﱝ"]="ىٰ";e["ﱞ"]=" ٌّ";e["ﱟ"]=" ٍّ";e["ﱠ"]=" َّ";e["ﱡ"]=" ُّ";e["ﱢ"]=" ِّ";e["ﱣ"]=" ّٰ";e["ﱤ"]="ئر";e["ﱥ"]="ئز";e["ﱦ"]="ئم";e["ﱧ"]="ئن";e["ﱨ"]="ئى";e["ﱩ"]="ئي";e["ﱪ"]="بر";e["ﱫ"]="بز";e["ﱬ"]="بم";e["ﱭ"]="بن";e["ﱮ"]="بى";e["ﱯ"]="بي";e["ﱰ"]="تر";e["ﱱ"]="تز";e["ﱲ"]="تم";e["ﱳ"]="تن";e["ﱴ"]="تى";e["ﱵ"]="تي";e["ﱶ"]="ثر";e["ﱷ"]="ثز";e["ﱸ"]="ثم";e["ﱹ"]="ثن";e["ﱺ"]="ثى";e["ﱻ"]="ثي";e["ﱼ"]="فى";e["ﱽ"]="في";e["ﱾ"]="قى";e["ﱿ"]="قي";e["ﲀ"]="كا";e["ﲁ"]="كل";e["ﲂ"]="كم";e["ﲃ"]="كى";e["ﲄ"]="كي";e["ﲅ"]="لم";e["ﲆ"]="لى";e["ﲇ"]="لي";e["ﲈ"]="ما";e["ﲉ"]="مم";e["ﲊ"]="نر";e["ﲋ"]="نز";e["ﲌ"]="نم";e["ﲍ"]="نن";e["ﲎ"]="نى";e["ﲏ"]="ني";e["ﲐ"]="ىٰ";e["ﲑ"]="ير";e["ﲒ"]="يز";e["ﲓ"]="يم";e["ﲔ"]="ين";e["ﲕ"]="يى";e["ﲖ"]="يي";e["ﲗ"]="ئج";e["ﲘ"]="ئح";e["ﲙ"]="ئخ";e["ﲚ"]="ئم";e["ﲛ"]="ئه";e["ﲜ"]="بج";e["ﲝ"]="بح";e["ﲞ"]="بخ";e["ﲟ"]="بم";e["ﲠ"]="به";e["ﲡ"]="تج";e["ﲢ"]="تح";e["ﲣ"]="تخ";e["ﲤ"]="تم";e["ﲥ"]="ته";e["ﲦ"]="ثم";e["ﲧ"]="جح";e["ﲨ"]="جم";e["ﲩ"]="حج";e["ﲪ"]="حم";e["ﲫ"]="خج";e["ﲬ"]="خم";e["ﲭ"]="سج";e["ﲮ"]="سح";e["ﲯ"]="سخ";e["ﲰ"]="سم";e["ﲱ"]="صح";e["ﲲ"]="صخ";e["ﲳ"]="صم";e["ﲴ"]="ضج";e["ﲵ"]="ضح";e["ﲶ"]="ضخ";e["ﲷ"]="ضم";e["ﲸ"]="طح";e["ﲹ"]="ظم";e["ﲺ"]="عج";e["ﲻ"]="عم";e["ﲼ"]="غج";e["ﲽ"]="غم";e["ﲾ"]="فج";e["ﲿ"]="فح";e["ﳀ"]="فخ";e["ﳁ"]="فم";e["ﳂ"]="قح";e["ﳃ"]="قم";e["ﳄ"]="كج";e["ﳅ"]="كح";e["ﳆ"]="كخ";e["ﳇ"]="كل";e["ﳈ"]="كم";e["ﳉ"]="لج";e["ﳊ"]="لح";e["ﳋ"]="لخ";e["ﳌ"]="لم";e["ﳍ"]="له";e["ﳎ"]="مج";e["ﳏ"]="مح";e["ﳐ"]="مخ";e["ﳑ"]="مم";e["ﳒ"]="نج";e["ﳓ"]="نح";e["ﳔ"]="نخ";e["ﳕ"]="نم";e["ﳖ"]="نه";e["ﳗ"]="هج";e["ﳘ"]="هم";e["ﳙ"]="هٰ";e["ﳚ"]="يج";e["ﳛ"]="يح";e["ﳜ"]="يخ";e["ﳝ"]="يم";e["ﳞ"]="يه";e["ﳟ"]="ئم";e["ﳠ"]="ئه";e["ﳡ"]="بم";e["ﳢ"]="به";e["ﳣ"]="تم";e["ﳤ"]="ته";e["ﳥ"]="ثم";e["ﳦ"]="ثه";e["ﳧ"]="سم";e["ﳨ"]="سه";e["ﳩ"]="شم";e["ﳪ"]="شه";e["ﳫ"]="كل";e["ﳬ"]="كم";e["ﳭ"]="لم";e["ﳮ"]="نم";e["ﳯ"]="نه";e["ﳰ"]="يم";e["ﳱ"]="يه";e["ﳲ"]="ـَّ";e["ﳳ"]="ـُّ";e["ﳴ"]="ـِّ";e["ﳵ"]="طى";e["ﳶ"]="طي";e["ﳷ"]="عى";e["ﳸ"]="عي";e["ﳹ"]="غى";e["ﳺ"]="غي";e["ﳻ"]="سى";e["ﳼ"]="سي";e["ﳽ"]="شى";e["ﳾ"]="شي";e["ﳿ"]="حى";e["ﴀ"]="حي";e["ﴁ"]="جى";e["ﴂ"]="جي";e["ﴃ"]="خى";e["ﴄ"]="خي";e["ﴅ"]="صى";e["ﴆ"]="صي";e["ﴇ"]="ضى";e["ﴈ"]="ضي";e["ﴉ"]="شج";e["ﴊ"]="شح";e["ﴋ"]="شخ";e["ﴌ"]="شم";e["ﴍ"]="شر";e["ﴎ"]="سر";e["ﴏ"]="صر";e["ﴐ"]="ضر";e["ﴑ"]="طى";e["ﴒ"]="طي";e["ﴓ"]="عى";e["ﴔ"]="عي";e["ﴕ"]="غى";e["ﴖ"]="غي";e["ﴗ"]="سى";e["ﴘ"]="سي";e["ﴙ"]="شى";e["ﴚ"]="شي";e["ﴛ"]="حى";e["ﴜ"]="حي";e["ﴝ"]="جى";e["ﴞ"]="جي";e["ﴟ"]="خى";e["ﴠ"]="خي";e["ﴡ"]="صى";e["ﴢ"]="صي";e["ﴣ"]="ضى";e["ﴤ"]="ضي";e["ﴥ"]="شج";e["ﴦ"]="شح";e["ﴧ"]="شخ";e["ﴨ"]="شم";e["ﴩ"]="شر";e["ﴪ"]="سر";e["ﴫ"]="صر";e["ﴬ"]="ضر";e["ﴭ"]="شج";e["ﴮ"]="شح";e["ﴯ"]="شخ";e["ﴰ"]="شم";e["ﴱ"]="سه";e["ﴲ"]="شه";e["ﴳ"]="طم";e["ﴴ"]="سج";e["ﴵ"]="سح";e["ﴶ"]="سخ";e["ﴷ"]="شج";e["ﴸ"]="شح";e["ﴹ"]="شخ";e["ﴺ"]="طم";e["ﴻ"]="ظم";e["ﴼ"]="اً";e["ﴽ"]="اً";e["ﵐ"]="تجم";e["ﵑ"]="تحج";e["ﵒ"]="تحج";e["ﵓ"]="تحم";e["ﵔ"]="تخم";e["ﵕ"]="تمج";e["ﵖ"]="تمح";e["ﵗ"]="تمخ";e["ﵘ"]="جمح";e["ﵙ"]="جمح";e["ﵚ"]="حمي";e["ﵛ"]="حمى";e["ﵜ"]="سحج";e["ﵝ"]="سجح";e["ﵞ"]="سجى";e["ﵟ"]="سمح";e["ﵠ"]="سمح";e["ﵡ"]="سمج";e["ﵢ"]="سمم";e["ﵣ"]="سمم";e["ﵤ"]="صحح";e["ﵥ"]="صحح";e["ﵦ"]="صمم";e["ﵧ"]="شحم";e["ﵨ"]="شحم";e["ﵩ"]="شجي";e["ﵪ"]="شمخ";e["ﵫ"]="شمخ";e["ﵬ"]="شمم";e["ﵭ"]="شمم";e["ﵮ"]="ضحى";e["ﵯ"]="ضخم";e["ﵰ"]="ضخم";e["ﵱ"]="طمح";e["ﵲ"]="طمح";e["ﵳ"]="طمم";e["ﵴ"]="طمي";e["ﵵ"]="عجم";e["ﵶ"]="عمم";e["ﵷ"]="عمم";e["ﵸ"]="عمى";e["ﵹ"]="غمم";e["ﵺ"]="غمي";e["ﵻ"]="غمى";e["ﵼ"]="فخم";e["ﵽ"]="فخم";e["ﵾ"]="قمح";e["ﵿ"]="قمم";e["ﶀ"]="لحم";e["ﶁ"]="لحي";e["ﶂ"]="لحى";e["ﶃ"]="لجج";e["ﶄ"]="لجج";e["ﶅ"]="لخم";e["ﶆ"]="لخم";e["ﶇ"]="لمح";e["ﶈ"]="لمح";e["ﶉ"]="محج";e["ﶊ"]="محم";e["ﶋ"]="محي";e["ﶌ"]="مجح";e["ﶍ"]="مجم";e["ﶎ"]="مخج";e["ﶏ"]="مخم";e["ﶒ"]="مجخ";e["ﶓ"]="همج";e["ﶔ"]="همم";e["ﶕ"]="نحم";e["ﶖ"]="نحى";e["ﶗ"]="نجم";e["ﶘ"]="نجم";e["ﶙ"]="نجى";e["ﶚ"]="نمي";e["ﶛ"]="نمى";e["ﶜ"]="يمم";e["ﶝ"]="يمم";e["ﶞ"]="بخي";e["ﶟ"]="تجي";e["ﶠ"]="تجى";e["ﶡ"]="تخي";e["ﶢ"]="تخى";e["ﶣ"]="تمي";e["ﶤ"]="تمى";e["ﶥ"]="جمي";e["ﶦ"]="جحى";e["ﶧ"]="جمى";e["ﶨ"]="سخى";e["ﶩ"]="صحي";e["ﶪ"]="شحي";e["ﶫ"]="ضحي";e["ﶬ"]="لجي";e["ﶭ"]="لمي";e["ﶮ"]="يحي";e["ﶯ"]="يجي";e["ﶰ"]="يمي";e["ﶱ"]="ممي";e["ﶲ"]="قمي";e["ﶳ"]="نحي";e["ﶴ"]="قمح";e["ﶵ"]="لحم";e["ﶶ"]="عمي";e["ﶷ"]="كمي";e["ﶸ"]="نجح";e["ﶹ"]="مخي";e["ﶺ"]="لجم";e["ﶻ"]="كمم";e["ﶼ"]="لجم";e["ﶽ"]="نجح";e["ﶾ"]="جحي";e["ﶿ"]="حجي";e["ﷀ"]="مجي";e["ﷁ"]="فمي";e["ﷂ"]="بحي";e["ﷃ"]="كمم";e["ﷄ"]="عجم";e["ﷅ"]="صمم";e["ﷆ"]="سخي";e["ﷇ"]="نجي";e["﹉"]="‾";e["﹊"]="‾";e["﹋"]="‾";e["﹌"]="‾";e["﹍"]="_";e["﹎"]="_";e["﹏"]="_";e["ﺀ"]="ء";e["ﺁ"]="آ";e["ﺂ"]="آ";e["ﺃ"]="أ";e["ﺄ"]="أ";e["ﺅ"]="ؤ";e["ﺆ"]="ؤ";e["ﺇ"]="إ";e["ﺈ"]="إ";e["ﺉ"]="ئ";e["ﺊ"]="ئ";e["ﺋ"]="ئ";e["ﺌ"]="ئ";e["ﺍ"]="ا";e["ﺎ"]="ا";e["ﺏ"]="ب";e["ﺐ"]="ب";e["ﺑ"]="ب";e["ﺒ"]="ب";e["ﺓ"]="ة";e["ﺔ"]="ة";e["ﺕ"]="ت";e["ﺖ"]="ت";e["ﺗ"]="ت";e["ﺘ"]="ت";e["ﺙ"]="ث";e["ﺚ"]="ث";e["ﺛ"]="ث";e["ﺜ"]="ث";e["ﺝ"]="ج";e["ﺞ"]="ج";e["ﺟ"]="ج";e["ﺠ"]="ج";e["ﺡ"]="ح";e["ﺢ"]="ح";e["ﺣ"]="ح";e["ﺤ"]="ح";e["ﺥ"]="خ";e["ﺦ"]="خ";e["ﺧ"]="خ";e["ﺨ"]="خ";e["ﺩ"]="د";e["ﺪ"]="د";e["ﺫ"]="ذ";e["ﺬ"]="ذ";e["ﺭ"]="ر";e["ﺮ"]="ر";e["ﺯ"]="ز";e["ﺰ"]="ز";e["ﺱ"]="س";e["ﺲ"]="س";e["ﺳ"]="س";e["ﺴ"]="س";e["ﺵ"]="ش";e["ﺶ"]="ش";e["ﺷ"]="ش";e["ﺸ"]="ش";e["ﺹ"]="ص";e["ﺺ"]="ص";e["ﺻ"]="ص";e["ﺼ"]="ص";e["ﺽ"]="ض";e["ﺾ"]="ض";e["ﺿ"]="ض";e["ﻀ"]="ض";e["ﻁ"]="ط";e["ﻂ"]="ط";e["ﻃ"]="ط";e["ﻄ"]="ط";e["ﻅ"]="ظ";e["ﻆ"]="ظ";e["ﻇ"]="ظ";e["ﻈ"]="ظ";e["ﻉ"]="ع";e["ﻊ"]="ع";e["ﻋ"]="ع";e["ﻌ"]="ع";e["ﻍ"]="غ";e["ﻎ"]="غ";e["ﻏ"]="غ";e["ﻐ"]="غ";e["ﻑ"]="ف";e["ﻒ"]="ف";e["ﻓ"]="ف";e["ﻔ"]="ف";e["ﻕ"]="ق";e["ﻖ"]="ق";e["ﻗ"]="ق";e["ﻘ"]="ق";e["ﻙ"]="ك";e["ﻚ"]="ك";e["ﻛ"]="ك";e["ﻜ"]="ك";e["ﻝ"]="ل";e["ﻞ"]="ل";e["ﻟ"]="ل";e["ﻠ"]="ل";e["ﻡ"]="م";e["ﻢ"]="م";e["ﻣ"]="م";e["ﻤ"]="م";e["ﻥ"]="ن";e["ﻦ"]="ن";e["ﻧ"]="ن";e["ﻨ"]="ن";e["ﻩ"]="ه";e["ﻪ"]="ه";e["ﻫ"]="ه";e["ﻬ"]="ه";e["ﻭ"]="و";e["ﻮ"]="و";e["ﻯ"]="ى";e["ﻰ"]="ى";e["ﻱ"]="ي";e["ﻲ"]="ي";e["ﻳ"]="ي";e["ﻴ"]="ي";e["ﻵ"]="لآ";e["ﻶ"]="لآ";e["ﻷ"]="لأ";e["ﻸ"]="لأ";e["ﻹ"]="لإ";e["ﻺ"]="لإ";e["ﻻ"]="لا";e["ﻼ"]="لا"});e.mapSpecialUnicodeValues=a;e.reverseIfRtl=s;e.getUnicodeRangeFor=i;e.getNormalizedUnicodes=h;e.getUnicodeForGlyph=r});!function(e,t){t(e.pdfjsCoreStream={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreJbig2,e.pdfjsCoreJpg,e.pdfjsCoreJpx)}(this,function(e,t,a,r,i,n){var s=t.Util,o=t.error,c=t.info,l=t.isArray,h=t.createObjectURL,u=t.shadow,f=t.warn,d=t.isSpace,g=a.Dict,p=a.isDict,m=r.Jbig2Image,b=i.JpegImage,v=n.JpxImage,y=function(){function e(e,t,a,r){this.bytes=e instanceof Uint8Array?e:new Uint8Array(e);this.start=t||0;this.pos=this.start;this.end=t+a||this.bytes.length;this.dict=r}e.prototype={get length(){return this.end-this.start},get isEmpty(){return 0===this.length},getByte:function(){return this.pos>=this.end?-1:this.bytes[this.pos++]},getUint16:function(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function(){var e=this.getByte(),t=this.getByte(),a=this.getByte(),r=this.getByte();return(e<<24)+(t<<16)+(a<<8)+r},getBytes:function(e){var t=this.bytes,a=this.pos,r=this.end;if(!e)return t.subarray(a,r);var i=a+e;i>r&&(i=r);this.pos=i;return t.subarray(a,i)},peekByte:function(){var e=this.getByte();this.pos--;return e},peekBytes:function(e){var t=this.getBytes(e);this.pos-=t.length;return t},skip:function(e){e||(e=1);this.pos+=e},reset:function(){this.pos=this.start},moveStart:function(){this.start=this.pos},makeSubStream:function(t,a,r){return new e(this.bytes.buffer,t,a,r)},isStream:!0};return e}(),k=function(){function e(e){for(var t=e.length,a=new Uint8Array(t),r=0;t>r;++r)a[r]=e.charCodeAt(r);y.call(this,a)}e.prototype=y.prototype;return e}(),w=function(){function e(e){this.pos=0;this.bufferLength=0;this.eof=!1;this.buffer=t;this.minBufferLength=512;if(e)for(;this.minBufferLengtha;)a*=2;var r=new Uint8Array(a);r.set(t);return this.buffer=r},getByte:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return-1;this.readBlock()}return this.buffer[this.pos++]},getUint16:function(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function(){var e=this.getByte(),t=this.getByte(),a=this.getByte(),r=this.getByte();return(e<<24)+(t<<16)+(a<<8)+r},getBytes:function(e){var t,a=this.pos;if(e){this.ensureBuffer(a+e);t=a+e;for(;!this.eof&&this.bufferLengthr&&(t=r)}else{for(;!this.eof;)this.readBlock();t=this.bufferLength}this.pos=t;return this.buffer.subarray(a,t)},peekByte:function(){var e=this.getByte();this.pos--;return e},peekBytes:function(e){var t=this.getBytes(e);this.pos-=t.length;return t},makeSubStream:function(e,t,a){for(var r=e+t;this.bufferLength<=r&&!this.eof;)this.readBlock();return new y(this.buffer,e,t,a)},skip:function(e){e||(e=1);this.pos+=e},reset:function(){this.pos=0},getBaseStreams:function(){return this.str&&this.str.getBaseStreams?this.str.getBaseStreams():[]}};return e}(),x=function(){function e(e){this.streams=e;w.call(this,null)}e.prototype=Object.create(w.prototype);e.prototype.readBlock=function(){var e=this.streams;if(0!==e.length){var t=e.shift(),a=t.getBytes(),r=this.bufferLength,i=r+a.length,n=this.ensureBuffer(i);n.set(a,r);this.bufferLength=i}else this.eof=!0};e.prototype.getBaseStreams=function(){for(var e=[],t=0,a=this.streams.length;a>t;t++){var r=this.streams[t];r.getBaseStreams&&s.appendToArray(e,r.getBaseStreams())}return e};return e}(),C=function(){function e(e,t){this.str=e;this.dict=e.dict;var a=e.getByte(),r=e.getByte();-1!==a&&-1!==r||o("Invalid header in flate stream: "+a+", "+r);8!==(15&a)&&o("Unknown compression method in flate stream: "+a+", "+r);((a<<8)+r)%31!==0&&o("Bad FCHECK in flate stream: "+a+", "+r);32&r&&o("FDICT bit set in flate stream: "+a+", "+r);this.codeSize=0;this.codeBuf=0;w.call(this,t)}var t=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),i=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],n=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];e.prototype=Object.create(w.prototype);e.prototype.getBits=function(e){for(var t,a=this.str,r=this.codeSize,i=this.codeBuf;e>r;){-1===(t=a.getByte())&&o("Bad encoding in flate stream");i|=t<>e;this.codeSize=r-=e;return t};e.prototype.getCode=function(e){for(var t,a=this.str,r=e[0],i=e[1],n=this.codeSize,s=this.codeBuf;i>n&&-1!==(t=a.getByte());){s|=t<>16,h=65535&c;(1>l||l>n)&&o("Bad encoding in flate stream");this.codeBuf=s>>l;this.codeSize=n-l;return h};e.prototype.generateHuffmanTable=function(e){var t,a=e.length,r=0;for(t=0;a>t;++t)e[t]>r&&(r=e[t]);for(var i=1<=s;++s,o<<=1,c<<=1)for(var l=0;a>l;++l)if(e[l]===s){var h=0,u=o;for(t=0;s>t;++t){h=h<<1|1&u;u>>=1}for(t=h;i>t;t+=c)n[t]=s<<16|l;++o}return[n,r]};e.prototype.readBlock=function(){var e,s,c=this.str,l=this.getBits(3);1&l&&(this.eof=!0);l>>=1;if(0!==l){var h,u;if(1===l){h=i;u=n}else if(2===l){var f,d=this.getBits(5)+257,g=this.getBits(5)+1,p=this.getBits(4)+4,m=new Uint8Array(t.length);for(f=0;p>f;++f)m[t[f]]=this.getBits(3);var b=this.generateHuffmanTable(m);s=0;f=0;for(var v,y,k,w=d+g,x=new Uint8Array(w);w>f;){var C=this.getCode(b);if(16===C){v=2;y=3;k=s}else if(17===C){v=3;y=3;k=s=0}else{if(18!==C){x[f++]=s=C;continue}v=7;y=11;k=s=0}for(var S=this.getBits(v)+y;S-- >0;)x[f++]=k}h=this.generateHuffmanTable(x.subarray(0,d));u=this.generateHuffmanTable(x.subarray(d,w))}else o("Unknown block type in flate stream");e=this.buffer;for(var A=e?e.length:0,I=this.bufferLength;;){var B=this.getCode(h);if(256>B){if(I+1>=A){e=this.ensureBuffer(I+1);A=e.length}e[I++]=B}else{if(256===B){this.bufferLength=I;return}B-=257;B=a[B];var R=B>>16;R>0&&(R=this.getBits(R));s=(65535&B)+R;B=this.getCode(u);B=r[B];R=B>>16;R>0&&(R=this.getBits(R));var T=(65535&B)+R;if(I+s>=A){e=this.ensureBuffer(I+s);A=e.length}for(var O=0;s>O;++O,++I)e[I]=e[I-T]}}}else{var P;-1===(P=c.getByte())&&o("Bad block header in flate stream");var L=P;-1===(P=c.getByte())&&o("Bad block header in flate stream");L|=P<<8;-1===(P=c.getByte())&&o("Bad block header in flate stream");var M=P;-1===(P=c.getByte())&&o("Bad block header in flate stream");M|=P<<8;M===(65535&~L)||0===L&&0===M||o("Bad uncompressed block length in flate stream");this.codeBuf=0;this.codeSize=0;var E=this.bufferLength;e=this.ensureBuffer(E+L);var D=E+L;this.bufferLength=D;if(0===L)-1===c.peekByte()&&(this.eof=!0);else for(var q=E;D>q;++q){if(-1===(P=c.getByte())){this.eof=!0;break}e[q]=P}}};return e}(),S=function(){function e(e,t,a){if(!p(a))return e;var r=this.predictor=a.get("Predictor")||1;if(1>=r)return e;2!==r&&(10>r||r>15)&&o("Unsupported predictor: "+r);2===r?this.readBlock=this.readBlockTiff:this.readBlock=this.readBlockPng;this.str=e;this.dict=e.dict;var i=this.colors=a.get("Colors")||1,n=this.bits=a.get("BitsPerComponent")||8,s=this.columns=a.get("Columns")||1;this.pixBytes=i*n+7>>3;this.rowBytes=s*i*n+7>>3;w.call(this,t);return this}e.prototype=Object.create(w.prototype);e.prototype.readBlockTiff=function(){var e=this.rowBytes,t=this.bufferLength,a=this.ensureBuffer(t+e),r=this.bits,i=this.colors,n=this.str.getBytes(e);this.eof=!n.length;if(!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===r)for(s=0;e>s;++s){var f=n[s];o=o<<8|f;a[u++]=255&(f^o>>i);o&=65535}else if(8===r){for(s=0;i>s;++s)a[u++]=n[s];for(;e>s;++s){a[u]=a[u-i]+n[s];u++}}else{var d=new Uint8Array(i+1),g=(1<s;++s)for(var v=0;i>v;++v){if(r>l){o=o<<8|255&n[p++];l+=8}d[v]=d[v]+(o>>l-r)&g;l-=r;c=c<=8){a[m++]=c>>h-8&255;h-=8}}h>0&&(a[m++]=(c<<8-h)+(o&(1<<8-h)-1))}this.bufferLength+=e}};e.prototype.readBlockPng=function(){var e=this.rowBytes,t=this.pixBytes,a=this.str.getByte(),r=this.str.getBytes(e);this.eof=!r.length;if(!this.eof){var i=this.bufferLength,n=this.ensureBuffer(i+e),s=n.subarray(i-e,i);0===s.length&&(s=new Uint8Array(e));var c,l,h,u=i;switch(a){case 0:for(c=0;e>c;++c)n[u++]=r[c];break;case 1:for(c=0;t>c;++c)n[u++]=r[c];for(;e>c;++c){n[u]=n[u-t]+r[c]&255;u++}break;case 2:for(c=0;e>c;++c)n[u++]=s[c]+r[c]&255;break;case 3:for(c=0;t>c;++c)n[u++]=(s[c]>>1)+r[c];for(;e>c;++c){n[u]=(s[c]+n[u-t]>>1)+r[c]&255;u++}break;case 4:for(c=0;t>c;++c){l=s[c];h=r[c];n[u++]=l+h}for(;e>c;++c){l=s[c];var f=s[c-t],d=n[u-t],g=d+l-f,p=g-d;0>p&&(p=-p);var m=g-l;0>m&&(m=-m);var b=g-f;0>b&&(b=-b);h=r[c];m>=p&&b>=p?n[u++]=d+h:b>=m?n[u++]=l+h:n[u++]=f+h}break;default:o("Unsupported predictor: "+a)}this.bufferLength+=e}};return e}(),A=function(){function e(e,t,a,r){for(var i;-1!==(i=e.getByte());)if(255===i){e.skip(-1);break}this.stream=e;this.maybeLength=t;this.dict=a;w.call(this,t)}e.prototype=Object.create(w.prototype);Object.defineProperty(e.prototype,"bytes",{get:function(){return u(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});e.prototype.ensureBuffer=function(e){if(!this.bufferLength)try{var t=new b;if(this.forceRGB&&this.dict&&l(this.dict.get("Decode"))){for(var a=this.dict.getArray("Decode"),r=this.dict.get("BitsPerComponent")||8,i=a.length,n=new Int32Array(i),s=!1,c=(1<h;h+=2){n[h]=256*(a[h+1]-a[h])|0;n[h+1]=a[h]*c|0;256===n[h]&&0===n[h+1]||(s=!0)}s&&(t.decodeTransform=n)}t.parse(this.bytes);var u=t.getData(this.drawWidth,this.drawHeight,this.forceRGB);this.buffer=u;this.bufferLength=u.length;this.eof=!0}catch(f){o("JPEG error: "+f)}};e.prototype.getBytes=function(e){this.ensureBuffer();return this.buffer};e.prototype.getIR=function(e){return h(this.bytes,"image/jpeg",e)};return e}(),I=function(){function e(e,t,a){this.stream=e;this.maybeLength=t;this.dict=a;w.call(this,t)}e.prototype=Object.create(w.prototype);Object.defineProperty(e.prototype,"bytes",{get:function(){return u(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});e.prototype.ensureBuffer=function(e){if(!this.bufferLength){var t=new v;t.parse(this.bytes);var a=t.width,r=t.height,i=t.componentsCount,n=t.tiles.length;if(1===n)this.buffer=t.tiles[0].items;else{for(var s=new Uint8Array(a*r*i),o=0;n>o;o++)for(var c=t.tiles[o],l=c.width,h=c.height,u=c.left,f=c.top,d=c.items,g=0,p=(a*f+u)*i,m=a*i,b=l*i,y=0;h>y;y++){var k=d.subarray(g,g+b);s.set(k,p);g+=b;p+=m}this.buffer=s}this.bufferLength=this.buffer.length;this.eof=!0}};return e}(),B=function(){function e(e,t,a){this.stream=e;this.maybeLength=t;this.dict=a;w.call(this,t)}e.prototype=Object.create(w.prototype);Object.defineProperty(e.prototype,"bytes",{get:function(){return u(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});e.prototype.ensureBuffer=function(e){if(!this.bufferLength){var t=new m,a=[],r=this.dict.getArray("DecodeParms");if(l(r)){r.length>1&&f("JBIG2 - 'DecodeParms' array with multiple elements not supported.");r=r[0]}if(r&&r.has("JBIG2Globals")){var i=r.get("JBIG2Globals"),n=i.getBytes();a.push({data:n,start:0,end:n.length})}a.push({data:this.bytes,start:0,end:this.bytes.length});for(var s=t.parseChunks(a),o=s.length,c=0;o>c;c++)s[c]^=255;this.buffer=s;this.bufferLength=o;this.eof=!0}};return e}(),R=function(){function e(e,t,a){this.str=e;this.dict=e.dict;this.decrypt=a;this.nextChunk=null;this.initialized=!1;w.call(this,t)}var t=512;e.prototype=Object.create(w.prototype);e.prototype.readBlock=function(){var e;if(this.initialized)e=this.nextChunk;else{e=this.str.getBytes(t);this.initialized=!0}if(e&&0!==e.length){this.nextChunk=this.str.getBytes(t);var a=this.nextChunk&&this.nextChunk.length>0,r=this.decrypt;e=r(e,!a);var i,n=this.bufferLength,s=e.length,o=this.ensureBuffer(n+s);for(i=0;s>i;i++)o[n++]=e[i];this.bufferLength=n}else this.eof=!0};return e}(),T=function(){function e(e,t){this.str=e;this.dict=e.dict;this.input=new Uint8Array(5);t&&(t=.8*t);w.call(this,t)}e.prototype=Object.create(w.prototype);e.prototype.readBlock=function(){for(var e=126,t=122,a=-1,r=this.str,i=r.getByte();d(i);)i=r.getByte();if(i!==a&&i!==e){var n,s,o=this.bufferLength;if(i===t){n=this.ensureBuffer(o+4);for(s=0;4>s;++s)n[o+s]=0;this.bufferLength+=4}else{var c=this.input;c[0]=i;for(s=1;5>s;++s){i=r.getByte();for(;d(i);)i=r.getByte();c[s]=i;if(i===a||i===e)break}n=this.ensureBuffer(o+s-1);this.bufferLength+=s-1;if(5>s){for(;5>s;++s)c[s]=117;this.eof=!0}var l=0;for(s=0;5>s;++s)l=85*l+(c[s]-33);for(s=3;s>=0;--s){n[o+s]=255&l;l>>=8}}}else this.eof=!0};return e}(),O=function(){function e(e,t){this.str=e;this.dict=e.dict;this.firstDigit=-1;t&&(t=.5*t);w.call(this,t)}e.prototype=Object.create(w.prototype);e.prototype.readBlock=function(){var e=8e3,t=this.str.getBytes(e);if(t.length){for(var a=t.length+1>>1,r=this.ensureBuffer(this.bufferLength+a),i=this.bufferLength,n=this.firstDigit,s=0,o=t.length;o>s;s++){var c,l=t[s];if(l>=48&&57>=l)c=15&l;else{if(!(l>=65&&70>=l||l>=97&&102>=l)){if(62===l){this.eof=!0;break}continue}c=(15&l)+9}if(0>n)n=c;else{r[i++]=n<<4|c;n=-1}}if(n>=0&&this.eof){r[i++]=n<<4;n=-1}this.firstDigit=n;this.bufferLength=i}else this.eof=!0};return e}(),P=function(){function e(e,t){this.str=e;this.dict=e.dict;w.call(this,t)}e.prototype=Object.create(w.prototype);e.prototype.readBlock=function(){var e=this.str.getBytes(2);if(!e||e.length<2||128===e[0])this.eof=!0;else{var t,a=this.bufferLength,r=e[0];if(128>r){t=this.ensureBuffer(a+r+1);t[a++]=e[1];if(r>0){var i=this.str.getBytes(r);t.set(i,a);a+=r}}else{r=257-r;var n=e[1];t=this.ensureBuffer(a+r+1);for(var s=0;r>s;s++)t[a++]=n}this.bufferLength=a}};return e}(),L=function(){function e(e,t,a){this.str=e;this.dict=e.dict;a=a||g.empty;this.encoding=a.get("K")||0;this.eoline=a.get("EndOfLine")||!1;this.byteAlign=a.get("EncodedByteAlign")||!1;this.columns=a.get("Columns")||1728;this.rows=a.get("Rows")||0;var r=a.get("EndOfBlock");null!==r&&void 0!==r||(r=!0);this.eoblock=r;this.black=a.get("BlackIs1")||!1;this.codingLine=new Uint32Array(this.columns+1);this.refLine=new Uint32Array(this.columns+2);this.codingLine[0]=this.columns;this.codingPos=0;this.row=0;this.nextLine2D=this.encoding<0;this.inputBits=0;this.inputBuf=0;this.outputBits=0;for(var i;0===(i=this.lookBits(12));)this.eatBits(1);1===i&&this.eatBits(12);if(this.encoding>0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}w.call(this,t)}var t=-2,a=-1,r=0,i=1,n=2,s=3,o=4,l=5,h=6,u=7,f=8,d=[[-1,-1],[-1,-1],[7,f],[7,u],[6,h],[6,h],[6,l],[6,l],[4,r],[4,r],[4,r],[4,r],[4,r],[4,r],[4,r],[4,r],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,i],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,o],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[3,s],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n],[1,n]],p=[[-1,-1],[12,t],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],m=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],b=[[-1,-1],[-1,-1],[12,t],[12,t],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],v=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],y=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]]; +e.prototype=Object.create(w.prototype);e.prototype.readBlock=function(){for(;!this.eof;){var e=this.lookChar();this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=e}};e.prototype.addPixels=function(e,t){var a=this.codingLine,r=this.codingPos;if(e>a[r]){if(e>this.columns){c("row is wrong length");this.err=!0;e=this.columns}1&r^t&&++r;a[r]=e}this.codingPos=r};e.prototype.addPixelsNeg=function(e,t){var a=this.codingLine,r=this.codingPos;if(e>a[r]){if(e>this.columns){c("row is wrong length");this.err=!0;e=this.columns}1&r^t&&++r;a[r]=e}else if(ee){c("invalid code");this.err=!0;e=0}for(;r>0&&e=64);do y+=k=this.getWhiteCode();while(k>=64)}else{do v+=k=this.getWhiteCode();while(k>=64);do y+=k=this.getBlackCode();while(k>=64)}this.addPixels(m[this.codingPos]+v,t);m[this.codingPos]0?--e:++e;for(;p[e]<=m[this.codingPos]&&p[e]0?--e:++e;for(;p[e]<=m[this.codingPos]&&p[e]0?--e:++e;for(;p[e]<=m[this.codingPos]&&p[e]=64)}else do v+=k=this.getWhiteCode();while(k>=64);this.addPixels(m[this.codingPos]+v,t);t^=1}}var w=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){v=this.lookBits(12);if(this.eoline)for(;v!==a&&1!==v;){this.eatBits(1);v=this.lookBits(12)}else for(;0===v;){this.eatBits(1);v=this.lookBits(12)}if(1===v){this.eatBits(12);w=!0}else v===a&&(this.eof=!0)}else this.eof=!0;if(!this.eof&&this.encoding>0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}if(this.eoblock&&w&&this.byteAlign){v=this.lookBits(12);if(1===v){this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}if(this.encoding>=0)for(g=0;4>g;++g){v=this.lookBits(12);1!==v&&c("bad rtc code: "+v);this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){v=this.lookBits(13);if(v===a){this.eof=!0;return null}if(v>>1===1)break;this.eatBits(1)}this.eatBits(12);if(this.encoding>0){this.eatBits(1);this.nextLine2D=!(1&v)}}m[0]>0?this.outputBits=m[this.codingPos=0]:this.outputBits=m[this.codingPos=1];this.row++}var x;if(this.outputBits>=8){x=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&m[this.codingPos]d){x<<=d;1&this.codingPos||(x|=255>>8-d);this.outputBits-=d;d=0}else{x<<=this.outputBits;1&this.codingPos||(x|=255>>8-this.outputBits);d-=this.outputBits;this.outputBits=0;if(m[this.codingPos]0){x<<=d;d=0}}while(d)}this.black&&(x^=255);return x};e.prototype.findTableCode=function(e,t,r,i){for(var n=i||0,s=e;t>=s;++s){var o=this.lookBits(s);if(o===a)return[!0,1,!1];t>s&&(o<<=t-s);if(!n||o>=n){var c=r[o-n];if(c[0]===s){this.eatBits(s);return[!0,c[1],!0]}}}return[!1,0,!1]};e.prototype.getTwoDimCode=function(){var e,t=0;if(this.eoblock){t=this.lookBits(7);e=d[t];if(e&&e[0]>0){this.eatBits(e[0]);return e[1]}}else{var r=this.findTableCode(1,7,d);if(r[0]&&r[2])return r[1]}c("Bad two dim code");return a};e.prototype.getWhiteCode=function(){var e,t=0;if(this.eoblock){t=this.lookBits(12);if(t===a)return 1;e=t>>5===0?p[t]:m[t>>3];if(e[0]>0){this.eatBits(e[0]);return e[1]}}else{var r=this.findTableCode(1,9,m);if(r[0])return r[1];r=this.findTableCode(11,12,p);if(r[0])return r[1]}c("bad white code");this.eatBits(1);return 1};e.prototype.getBlackCode=function(){var e,t;if(this.eoblock){e=this.lookBits(13);if(e===a)return 1;t=e>>7===0?b[e]:e>>9===0&&e>>7!==0?v[(e>>1)-64]:y[e>>7];if(t[0]>0){this.eatBits(t[0]);return t[1]}}else{var r=this.findTableCode(2,6,y);if(r[0])return r[1];r=this.findTableCode(7,12,v,64);if(r[0])return r[1];r=this.findTableCode(10,13,b);if(r[0])return r[1]}c("bad black code");this.eatBits(1);return 1};e.prototype.lookBits=function(e){for(var t;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t;this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e};e.prototype.eatBits=function(e){(this.inputBits-=e)<0&&(this.inputBits=0)};return e}(),M=function(){function e(e,t,a){this.str=e;this.dict=e.dict;this.cachedData=0;this.bitsCached=0;for(var r=4096,i={earlyChange:a,codeLength:9,nextCode:258,dictionaryValues:new Uint8Array(r),dictionaryLengths:new Uint16Array(r),dictionaryPrevCodes:new Uint16Array(r),currentSequence:new Uint8Array(r),currentSequenceLength:0},n=0;256>n;++n){i.dictionaryValues[n]=n;i.dictionaryLengths[n]=1}this.lzwState=i;w.call(this,t)}e.prototype=Object.create(w.prototype);e.prototype.readBits=function(e){for(var t=this.bitsCached,a=this.cachedData;e>t;){var r=this.str.getByte();if(-1===r){this.eof=!0;return null}a=a<<8|r;t+=8}this.bitsCached=t-=e;this.cachedData=a;this.lastCode=null;return a>>>t&(1<e;e++){var y=this.readBits(f),k=p>0;if(256>y){g[0]=y;p=1}else{if(!(y>=258)){if(256===y){f=9;c=258;p=0;continue}this.eof=!0;delete this.lzwState;break}if(c>y){p=h[y];for(t=p-1,a=y;t>=0;t--){g[t]=l[a];a=u[a]}}else g[p++]=g[0]}if(k){u[c]=d;h[c]=h[d]+1;l[c]=g[0];c++;f=c+o&c+o-1?f:0|Math.min(Math.log(c+o)/.6931471805599453+1,12)}d=y;m+=p;if(m>i){do i+=n;while(m>i);v=this.ensureBuffer(this.bufferLength+i)}for(t=0;p>t;t++)v[b++]=g[t]}s.nextCode=c;s.codeLength=f;s.prevCode=d;s.currentSequenceLength=p;this.bufferLength=b}};return e}(),E=function(){function e(){y.call(this,new Uint8Array(0))}e.prototype=y.prototype;return e}();e.Ascii85Stream=T;e.AsciiHexStream=O;e.CCITTFaxStream=L;e.DecryptStream=R;e.DecodeStream=w;e.FlateStream=C;e.Jbig2Stream=B;e.JpegStream=A;e.JpxStream=I;e.NullStream=E;e.PredictorStream=S;e.RunLengthStream=P;e.Stream=y;e.StreamsSequenceStream=x;e.StringStream=k;e.LZWStream=M});!function(e,t){t(e.pdfjsCoreCrypto={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreStream)}(this,function(e,t,a,r){var i=t.PasswordException,n=t.PasswordResponses,s=t.bytesToString,o=t.error,c=t.isInt,l=t.stringToBytes,h=t.utf8StringToString,u=t.warn,f=a.Name,d=a.isName,g=a.isDict,p=r.DecryptStream,m=function(){function e(e){this.a=0;this.b=0;var t,a,r=new Uint8Array(256),i=0,n=e.length;for(t=0;256>t;++t)r[t]=t;for(t=0;256>t;++t){a=r[t];i=i+a+e[t%n]&255;r[t]=r[i];r[i]=a}this.s=r}e.prototype={encryptBlock:function(e){var t,a,r,i=e.length,n=this.a,s=this.b,o=this.s,c=new Uint8Array(i);for(t=0;i>t;++t){n=n+1&255;a=o[n];s=s+a&255;r=o[s];o[n]=r;o[s]=a;c[t]=e[t]^o[a+r&255]}this.a=n;this.b=s;return c}};e.prototype.decryptBlock=e.prototype.encryptBlock;return e}(),b=function(){function e(e,r,i){var n,s,o,c=1732584193,l=-271733879,h=-1732584194,u=271733878,f=i+72&-64,d=new Uint8Array(f);for(n=0;i>n;++n)d[n]=e[r++];d[n++]=128;o=f-8;for(;o>n;)d[n++]=0;d[n++]=i<<3&255;d[n++]=i>>5&255;d[n++]=i>>13&255;d[n++]=i>>21&255;d[n++]=i>>>29&255;d[n++]=0;d[n++]=0;d[n++]=0;var g=new Int32Array(16);for(n=0;f>n;){for(s=0;16>s;++s,n+=4)g[s]=d[n]|d[n+1]<<8|d[n+2]<<16|d[n+3]<<24;var p,m,b=c,v=l,y=h,k=u;for(s=0;64>s;++s){if(16>s){p=v&y|~v&k;m=s}else if(32>s){p=k&v|~k&y;m=5*s+1&15}else if(48>s){p=v^y^k;m=3*s+5&15}else{p=y^(v|~k);m=7*s&15}var w=k,x=b+p+a[s]+g[m]|0,C=t[s];k=y;y=v;v=v+(x<>>32-C)|0;b=w}c=c+b|0;l=l+v|0;h=h+y|0;u=u+k|0}return new Uint8Array([255&c,c>>8&255,c>>16&255,c>>>24&255,255&l,l>>8&255,l>>16&255,l>>>24&255,255&h,h>>8&255,h>>16&255,h>>>24&255,255&u,u>>8&255,u>>16&255,u>>>24&255])}var t=new Uint8Array([7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21]),a=new Int32Array([-680876936,-389564586,606105819,-1044525330,-176418897,1200080426,-1473231341,-45705983,1770035416,-1958414417,-42063,-1990404162,1804603682,-40341101,-1502002290,1236535329,-165796510,-1069501632,643717713,-373897302,-701558691,38016083,-660478335,-405537848,568446438,-1019803690,-187363961,1163531501,-1444681467,-51403784,1735328473,-1926607734,-378558,-2022574463,1839030562,-35309556,-1530992060,1272893353,-155497632,-1094730640,681279174,-358537222,-722521979,76029189,-640364487,-421815835,530742520,-995338651,-198630844,1126891415,-1416354905,-57434055,1700485571,-1894986606,-1051523,-2054922799,1873313359,-30611744,-1560198380,1309151649,-145523070,-1120210379,718787259,-343485551]);return e}(),v=function(){function e(e,t){this.high=0|e;this.low=0|t}e.prototype={and:function(e){this.high&=e.high;this.low&=e.low},xor:function(e){this.high^=e.high;this.low^=e.low},or:function(e){this.high|=e.high;this.low|=e.low},shiftRight:function(e){if(e>=32){this.low=this.high>>>e-32|0;this.high=0}else{this.low=this.low>>>e|this.high<<32-e;this.high=this.high>>>e|0}},shiftLeft:function(e){if(e>=32){this.high=this.low<>>32-e;this.low=this.low<>>e|a<<32-e;this.high=a>>>e|t<<32-e},not:function(){this.high=~this.high;this.low=~this.low},add:function(e){var t=(this.low>>>0)+(e.low>>>0),a=(this.high>>>0)+(e.high>>>0);t>4294967295&&(a+=1);this.low=0|t;this.high=0|a},copyTo:function(e,t){e[t]=this.high>>>24&255;e[t+1]=this.high>>16&255;e[t+2]=this.high>>8&255;e[t+3]=255&this.high;e[t+4]=this.low>>>24&255;e[t+5]=this.low>>16&255;e[t+6]=this.low>>8&255;e[t+7]=255&this.low},assign:function(e){this.high=e.high;this.low=e.low}};return e}(),y=function(){function e(e,t){return e>>>t|e<<32-t}function t(e,t,a){return e&t^~e&a}function a(e,t,a){return e&t^e&a^t&a}function r(t){return e(t,2)^e(t,13)^e(t,22)}function i(t){return e(t,6)^e(t,11)^e(t,25)}function n(t){return e(t,7)^e(t,18)^t>>>3}function s(t){return e(t,17)^e(t,19)^t>>>10}function o(e,o,l){var h,u,f,d=1779033703,g=3144134277,p=1013904242,m=2773480762,b=1359893119,v=2600822924,y=528734635,k=1541459225,w=64*Math.ceil((l+9)/64),x=new Uint8Array(w);for(h=0;l>h;++h)x[h]=e[o++];x[h++]=128;f=w-8;for(;f>h;)x[h++]=0;x[h++]=0;x[h++]=0;x[h++]=0;x[h++]=l>>>29&255;x[h++]=l>>21&255;x[h++]=l>>13&255;x[h++]=l>>5&255;x[h++]=l<<3&255;var C=new Uint32Array(64);for(h=0;w>h;){for(u=0;16>u;++u){C[u]=x[h]<<24|x[h+1]<<16|x[h+2]<<8|x[h+3];h+=4}for(u=16;64>u;++u)C[u]=s(C[u-2])+C[u-7]+n(C[u-15])+C[u-16]|0;var S,A,I=d,B=g,R=p,T=m,O=b,P=v,L=y,M=k;for(u=0;64>u;++u){S=M+i(O)+t(O,P,L)+c[u]+C[u];A=r(I)+a(I,B,R);M=L;L=P;P=O;O=T+S|0;T=R;R=B;B=I;I=S+A|0}d=d+I|0;g=g+B|0;p=p+R|0;m=m+T|0;b=b+O|0;v=v+P|0;y=y+L|0;k=k+M|0}return new Uint8Array([d>>24&255,d>>16&255,d>>8&255,255&d,g>>24&255,g>>16&255,g>>8&255,255&g,p>>24&255,p>>16&255,p>>8&255,255&p,m>>24&255,m>>16&255,m>>8&255,255&m,b>>24&255,b>>16&255,b>>8&255,255&b,v>>24&255,v>>16&255,v>>8&255,255&v,y>>24&255,y>>16&255,y>>8&255,255&y,k>>24&255,k>>16&255,k>>8&255,255&k])}var c=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];return o}(),k=function(){function e(e,t,a,r,i){e.assign(t);e.and(a);i.assign(t);i.not();i.and(r);e.xor(i)}function t(e,t,a,r,i){e.assign(t);e.and(a);i.assign(t);i.and(r);e.xor(i);i.assign(a);i.and(r);e.xor(i)}function a(e,t,a){e.assign(t);e.rotateRight(28);a.assign(t);a.rotateRight(34);e.xor(a);a.assign(t);a.rotateRight(39);e.xor(a)}function r(e,t,a){e.assign(t);e.rotateRight(14);a.assign(t);a.rotateRight(18);e.xor(a);a.assign(t);a.rotateRight(41);e.xor(a)}function i(e,t,a){e.assign(t);e.rotateRight(1);a.assign(t);a.rotateRight(8);e.xor(a);a.assign(t);a.shiftRight(7);e.xor(a)}function n(e,t,a){e.assign(t);e.rotateRight(19);a.assign(t);a.rotateRight(61);e.xor(a);a.assign(t);a.shiftRight(6);e.xor(a)}function s(s,c,l,h){h=!!h;var u,f,d,g,p,m,b,y;if(h){u=new v(3418070365,3238371032);f=new v(1654270250,914150663);d=new v(2438529370,812702999);g=new v(355462360,4144912697);p=new v(1731405415,4290775857);m=new v(2394180231,1750603025);b=new v(3675008525,1694076839);y=new v(1203062813,3204075428)}else{u=new v(1779033703,4089235720);f=new v(3144134277,2227873595);d=new v(1013904242,4271175723);g=new v(2773480762,1595750129);p=new v(1359893119,2917565137);m=new v(2600822924,725511199);b=new v(528734635,4215389547);y=new v(1541459225,327033209)}var k,w,x,C=128*Math.ceil((l+17)/128),S=new Uint8Array(C);for(k=0;l>k;++k)S[k]=s[c++];S[k++]=128;x=C-16;for(;x>k;)S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=0;S[k++]=l>>>29&255;S[k++]=l>>21&255;S[k++]=l>>13&255;S[k++]=l>>5&255;S[k++]=l<<3&255;var A=new Array(80);for(k=0;80>k;k++)A[k]=new v(0,0);var I,B=new v(0,0),R=new v(0,0),T=new v(0,0),O=new v(0,0),P=new v(0,0),L=new v(0,0),M=new v(0,0),E=new v(0,0),D=new v(0,0),q=new v(0,0),j=new v(0,0),F=new v(0,0);for(k=0;C>k;){for(w=0;16>w;++w){A[w].high=S[k]<<24|S[k+1]<<16|S[k+2]<<8|S[k+3];A[w].low=S[k+4]<<24|S[k+5]<<16|S[k+6]<<8|S[k+7];k+=8}for(w=16;80>w;++w){I=A[w];n(I,A[w-2],F);I.add(A[w-7]);i(j,A[w-15],F);I.add(j);I.add(A[w-16])}B.assign(u);R.assign(f);T.assign(d);O.assign(g);P.assign(p);L.assign(m);M.assign(b);E.assign(y);for(w=0;80>w;++w){D.assign(E);r(j,P,F);D.add(j);e(j,P,L,M,F);D.add(j);D.add(o[w]);D.add(A[w]);a(q,B,F);t(j,B,R,T,F);q.add(j);I=E;E=M;M=L;L=P;O.add(D);P=O;O=T;T=R;R=B;I.assign(D);I.add(q);B=I}u.add(B);f.add(R);d.add(T);g.add(O);p.add(P);m.add(L);b.add(M);y.add(E)}var U;if(h){U=new Uint8Array(48);u.copyTo(U,0);f.copyTo(U,8);d.copyTo(U,16);g.copyTo(U,24);p.copyTo(U,32);m.copyTo(U,40)}else{U=new Uint8Array(64);u.copyTo(U,0);f.copyTo(U,8);d.copyTo(U,16);g.copyTo(U,24);p.copyTo(U,32);m.copyTo(U,40);b.copyTo(U,48);y.copyTo(U,56)}return U}var o=[new v(1116352408,3609767458),new v(1899447441,602891725),new v(3049323471,3964484399),new v(3921009573,2173295548),new v(961987163,4081628472),new v(1508970993,3053834265),new v(2453635748,2937671579),new v(2870763221,3664609560),new v(3624381080,2734883394),new v(310598401,1164996542),new v(607225278,1323610764),new v(1426881987,3590304994),new v(1925078388,4068182383),new v(2162078206,991336113),new v(2614888103,633803317),new v(3248222580,3479774868),new v(3835390401,2666613458),new v(4022224774,944711139),new v(264347078,2341262773),new v(604807628,2007800933),new v(770255983,1495990901),new v(1249150122,1856431235),new v(1555081692,3175218132),new v(1996064986,2198950837),new v(2554220882,3999719339),new v(2821834349,766784016),new v(2952996808,2566594879),new v(3210313671,3203337956),new v(3336571891,1034457026),new v(3584528711,2466948901),new v(113926993,3758326383),new v(338241895,168717936),new v(666307205,1188179964),new v(773529912,1546045734),new v(1294757372,1522805485),new v(1396182291,2643833823),new v(1695183700,2343527390),new v(1986661051,1014477480),new v(2177026350,1206759142),new v(2456956037,344077627),new v(2730485921,1290863460),new v(2820302411,3158454273),new v(3259730800,3505952657),new v(3345764771,106217008),new v(3516065817,3606008344),new v(3600352804,1432725776),new v(4094571909,1467031594),new v(275423344,851169720),new v(430227734,3100823752),new v(506948616,1363258195),new v(659060556,3750685593),new v(883997877,3785050280),new v(958139571,3318307427),new v(1322822218,3812723403),new v(1537002063,2003034995),new v(1747873779,3602036899),new v(1955562222,1575990012),new v(2024104815,1125592928),new v(2227730452,2716904306),new v(2361852424,442776044),new v(2428436474,593698344),new v(2756734187,3733110249),new v(3204031479,2999351573),new v(3329325298,3815920427),new v(3391569614,3928383900),new v(3515267271,566280711),new v(3940187606,3454069534),new v(4118630271,4000239992),new v(116418474,1914138554),new v(174292421,2731055270),new v(289380356,3203993006),new v(460393269,320620315),new v(685471733,587496836),new v(852142971,1086792851),new v(1017036298,365543100),new v(1126000580,2618297676),new v(1288033470,3409855158),new v(1501505948,4234509866),new v(1607167915,987167468),new v(1816402316,1246189591)];return s}(),w=function(){function e(e,t,a){return k(e,t,a,!0)}return e}(),x=function(){function e(){}e.prototype={decryptBlock:function(e){return e}};return e}(),C=function(){function e(e){var t=176,a=new Uint8Array(t);a.set(e);for(var r=16,i=1;t>r;++i){var o=a[r-3],c=a[r-2],l=a[r-1],h=a[r-4];o=s[o];c=s[c];l=s[l];h=s[h];o^=n[i];for(var u=0;4>u;++u){a[r]=o^=a[r-16];r++;a[r]=c^=a[r-16];r++;a[r]=l^=a[r-16];r++;a[r]=h^=a[r-16];r++}}return a}function t(e,t){var a=new Uint8Array(16);a.set(e);var r,i,n,s,c,l;for(i=0,n=160;16>i;++i,++n)a[i]^=t[n];for(r=9;r>=1;--r){s=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=s;s=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=s;a[2]=c;s=a[15];c=a[11];l=a[7];a[15]=a[3];a[11]=s;a[7]=c;a[3]=l;for(i=0;16>i;++i)a[i]=o[a[i]];for(i=0,n=16*r;16>i;++i,++n)a[i]^=t[n];for(i=0;16>i;i+=4){var u=h[a[i]],f=h[a[i+1]],d=h[a[i+2]],g=h[a[i+3]];s=u^f>>>8^f<<24^d>>>16^d<<16^g>>>24^g<<8;a[i]=s>>>24&255;a[i+1]=s>>16&255;a[i+2]=s>>8&255;a[i+3]=255&s}}s=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=s;s=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=s;a[2]=c;s=a[15];c=a[11];l=a[7];a[15]=a[3];a[11]=s;a[7]=c;a[3]=l;for(i=0;16>i;++i){a[i]=o[a[i]];a[i]^=t[i]}return a}function a(e,t){var a,r,i,n,o=new Uint8Array(16);o.set(e);for(h=0;16>h;++h)o[h]^=t[h];for(l=1;10>l;l++){for(h=0;16>h;++h)o[h]=s[o[h]];i=o[1];o[1]=o[5];o[5]=o[9];o[9]=o[13];o[13]=i;i=o[2];r=o[6];o[2]=o[10];o[6]=o[14];o[10]=i;o[14]=r;i=o[3];r=o[7];a=o[11];o[3]=o[15];o[7]=i;o[11]=r;o[15]=a;for(var h=0;16>h;h+=4){var u=o[h+0],f=o[h+1],d=o[h+2],g=o[h+3];a=u^f^d^g;o[h+0]^=a^c[u^f];o[h+1]^=a^c[f^d];o[h+2]^=a^c[d^g];o[h+3]^=a^c[g^u]}for(h=0,n=16*l;16>h;++h,++n)o[h]^=t[n]}for(h=0;16>h;++h)o[h]=s[o[h]];i=o[1];o[1]=o[5];o[5]=o[9];o[9]=o[13];o[13]=i;i=o[2];r=o[6];o[2]=o[10];o[6]=o[14];o[10]=i;o[14]=r;i=o[3];r=o[7];a=o[11];o[3]=o[15];o[7]=i;o[11]=r;o[15]=a;for(h=0,n=160;16>h;++h,++n)o[h]^=t[n];return o}function r(t){this.key=e(t);this.buffer=new Uint8Array(16);this.bufferPosition=0}function i(e,a){var r,i,n,s=e.length,o=this.buffer,c=this.bufferPosition,l=[],h=this.iv;for(r=0;s>r;++r){o[c]=e[r];++c;if(!(16>c)){var u=t(o,this.key);for(i=0;16>i;++i)u[i]^=h[i];h=o;l.push(u);o=new Uint8Array(16);c=0}}this.buffer=o;this.bufferLength=c;this.iv=h;if(0===l.length)return new Uint8Array([]);var f=16*l.length;if(a){var d=l[l.length-1],g=d[15];if(16>=g){for(r=15,n=16-g;r>=n;--r)if(d[r]!==g){g=0;break}f-=g;l[l.length-1]=d.subarray(0,16-g)}}var p=new Uint8Array(f);for(r=0,i=0,n=l.length;n>r;++r,i+=16)p.set(l[r],i);return p}for(var n=new Uint8Array([141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141]),s=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),o=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),c=new Uint8Array(256),l=0;256>l;l++)128>l?c[l]=l<<1:c[l]=l<<1^27;var h=new Uint32Array([0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795]);r.prototype={decryptBlock:function(e,t){var a,r=e.length,n=this.buffer,s=this.bufferPosition;for(a=0;16>s&&r>a;++a,++s)n[s]=e[a];if(16>s){this.bufferLength=s;return new Uint8Array([])}this.iv=n;this.buffer=new Uint8Array(16);this.bufferLength=0;this.decryptBlock=i;return this.decryptBlock(e.subarray(16),t)},encrypt:function(e,t){var r,i,n,s=e.length,o=this.buffer,c=this.bufferPosition,l=[];t||(t=new Uint8Array(16));for(r=0;s>r;++r){o[c]=e[r];++c;if(!(16>c)){for(i=0;16>i;++i)o[i]^=t[i];var h=a(o,this.key);t=h;l.push(h);o=new Uint8Array(16);c=0}}this.buffer=o;this.bufferLength=c;this.iv=t;if(0===l.length)return new Uint8Array([]);var u=16*l.length,f=new Uint8Array(u);for(r=0,i=0,n=l.length;n>r;++r,i+=16)f.set(l[r],i);return f}};return r}(),S=function(){function e(e){var t=240,a=new Uint8Array(t),r=1;a.set(e);for(var i=32,s=1;t>i;++s){if(i%32===16){o=n[o];c=n[c];l=n[l];h=n[h]}else if(i%32===0){var o=a[i-3],c=a[i-2],l=a[i-1],h=a[i-4];o=n[o];c=n[c];l=n[l];h=n[h];o^=r;(r<<=1)>=256&&(r=255&(27^r))}for(var u=0;4>u;++u){a[i]=o^=a[i-32];i++;a[i]=c^=a[i-32];i++;a[i]=l^=a[i-32];i++;a[i]=h^=a[i-32];i++}}return a}function t(e,t){var a=new Uint8Array(16);a.set(e);var r,i,n,o,c,h;for(i=0,n=224;16>i;++i,++n)a[i]^=t[n];for(r=13;r>=1;--r){o=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=o;o=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=o;a[2]=c;o=a[15];c=a[11];h=a[7];a[15]=a[3];a[11]=o;a[7]=c;a[3]=h;for(i=0;16>i;++i)a[i]=s[a[i]];for(i=0,n=16*r;16>i;++i,++n)a[i]^=t[n];for(i=0;16>i;i+=4){var u=l[a[i]],f=l[a[i+1]],d=l[a[i+2]],g=l[a[i+3]];o=u^f>>>8^f<<24^d>>>16^d<<16^g>>>24^g<<8;a[i]=o>>>24&255;a[i+1]=o>>16&255;a[i+2]=o>>8&255;a[i+3]=255&o}}o=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=o;o=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=o;a[2]=c;o=a[15];c=a[11];h=a[7];a[15]=a[3];a[11]=o;a[7]=c;a[3]=h;for(i=0;16>i;++i){a[i]=s[a[i]];a[i]^=t[i]}return a}function a(e,t){var a,r,i,s,l=new Uint8Array(16);l.set(e);for(h=0;16>h;++h)l[h]^=t[h];for(c=1;14>c;c++){for(h=0;16>h;++h)l[h]=n[l[h]];i=l[1];l[1]=l[5];l[5]=l[9];l[9]=l[13];l[13]=i;i=l[2];r=l[6];l[2]=l[10];l[6]=l[14];l[10]=i;l[14]=r;i=l[3];r=l[7];a=l[11];l[3]=l[15];l[7]=i;l[11]=r;l[15]=a;for(var h=0;16>h;h+=4){var u=l[h+0],f=l[h+1],d=l[h+2],g=l[h+3];a=u^f^d^g;l[h+0]^=a^o[u^f];l[h+1]^=a^o[f^d];l[h+2]^=a^o[d^g];l[h+3]^=a^o[g^u]}for(h=0,s=16*c;16>h;++h,++s)l[h]^=t[s]}for(h=0;16>h;++h)l[h]=n[l[h]];i=l[1];l[1]=l[5];l[5]=l[9];l[9]=l[13];l[13]=i;i=l[2];r=l[6];l[2]=l[10];l[6]=l[14];l[10]=i;l[14]=r;i=l[3];r=l[7];a=l[11];l[3]=l[15];l[7]=i;l[11]=r;l[15]=a;for(h=0,s=224;16>h;++h,++s)l[h]^=t[s];return l}function r(t){this.key=e(t);this.buffer=new Uint8Array(16);this.bufferPosition=0}function i(e,a){var r,i,n,s=e.length,o=this.buffer,c=this.bufferPosition,l=[],h=this.iv;for(r=0;s>r;++r){o[c]=e[r];++c;if(!(16>c)){var u=t(o,this.key);for(i=0;16>i;++i)u[i]^=h[i];h=o;l.push(u);o=new Uint8Array(16);c=0}}this.buffer=o;this.bufferLength=c;this.iv=h;if(0===l.length)return new Uint8Array([]);var f=16*l.length;if(a){var d=l[l.length-1],g=d[15];if(16>=g){for(r=15,n=16-g;r>=n;--r)if(d[r]!==g){g=0;break}f-=g;l[l.length-1]=d.subarray(0,16-g)}}var p=new Uint8Array(f);for(r=0,i=0,n=l.length;n>r;++r,i+=16)p.set(l[r],i);return p}for(var n=(new Uint8Array([141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141]),new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22])),s=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),o=new Uint8Array(256),c=0;256>c;c++)128>c?o[c]=c<<1:o[c]=c<<1^27; +var l=new Uint32Array([0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795]);r.prototype={decryptBlock:function(e,t,a){var r,n=e.length,s=this.buffer,o=this.bufferPosition;if(a)this.iv=a;else{for(r=0;16>o&&n>r;++r,++o)s[o]=e[r];if(16>o){this.bufferLength=o;return new Uint8Array([])}this.iv=s;e=e.subarray(16)}this.buffer=new Uint8Array(16);this.bufferLength=0;this.decryptBlock=i;return this.decryptBlock(e,t)},encrypt:function(e,t){var r,i,n,s=e.length,o=this.buffer,c=this.bufferPosition,l=[];t||(t=new Uint8Array(16));for(r=0;s>r;++r){o[c]=e[r];++c;if(!(16>c)){for(i=0;16>i;++i)o[i]^=t[i];var h=a(o,this.key);this.iv=h;l.push(h);o=new Uint8Array(16);c=0}}this.buffer=o;this.bufferLength=c;this.iv=t;if(0===l.length)return new Uint8Array([]);var u=16*l.length,f=new Uint8Array(u);for(r=0,i=0,n=l.length;n>r;++r,i+=16)f.set(l[r],i);return f}};return r}(),A=function(){function e(e,t){if(e.length!==t.length)return!1;for(var a=0;as||n[n.length-1]>s-32;){var o=t.length+i.length+r.length,c=new Uint8Array(64*o),l=e(t,i);l=e(l,r);for(var h=0,u=0;64>h;h++,u+=o)c.set(l,u);var f=new C(i.subarray(0,16));n=f.encrypt(c,i.subarray(16,32));for(var d=0,g=0;16>g;g++){d*=1;d%=3;d+=(n[g]>>>0)%3;d%=3}0===d?i=y(n,0,n.length):1===d?i=w(n,0,n.length):2===d&&(i=k(n,0,n.length));s++}return i.subarray(0,32)}function a(){}function r(e,t){if(e.length!==t.length)return!1;for(var a=0;af;++f)u[f]=t[f]}c=0;for(;32>f;)u[f++]=v[c++];for(c=0,l=a.length;l>c;++c)u[f++]=a[c];u[f++]=255&i;u[f++]=i>>8&255;u[f++]=i>>16&255;u[f++]=i>>>24&255;for(c=0,l=e.length;l>c;++c)u[f++]=e[c];if(n>=4&&!o){u[f++]=255;u[f++]=255;u[f++]=255;u[f++]=255}var d=b(u,0,f),g=s>>3;if(n>=3)for(c=0;50>c;++c)d=b(d,0,g);var p,y,k=d.subarray(0,g);if(n>=3){for(f=0;32>f;++f)u[f]=v[f];for(c=0,l=e.length;l>c;++c)u[f++]=e[c];p=new m(k);y=p.encryptBlock(b(u,0,f));l=k.length;var w,x=new Uint8Array(l);for(c=1;19>=c;++c){for(w=0;l>w;++w)x[w]=k[w]^c;p=new m(x);y=p.encryptBlock(y)}for(c=0,l=y.length;l>c;++c)if(r[c]!==y[c])return null}else{p=new m(k);y=p.encryptBlock(v);for(c=0,l=y.length;l>c;++c)if(r[c]!==y[c])return null}return k}function a(e,t,a,r){var i,n,s=new Uint8Array(32),o=0;n=Math.min(32,e.length);for(;n>o;++o)s[o]=e[o];i=0;for(;32>o;)s[o++]=v[i++];var c=b(s,0,o),l=r>>3;if(a>=3)for(i=0;50>i;++i)c=b(c,0,c.length);var h,u;if(a>=3){u=t;var f,d=new Uint8Array(l);for(i=19;i>=0;i--){for(f=0;l>f;++f)d[f]=c[f]^i;h=new m(d);u=h.encryptBlock(u)}}else{h=new m(c.subarray(0,l));u=h.encryptBlock(t)}return u}function r(r,s,f){var p=r.get("Filter");d(p)&&"Standard"===p.name||o("unknown encryption method");this.dict=r;var m=r.get("V");(!c(m)||1!==m&&2!==m&&4!==m&&5!==m)&&o("unsupported encryption algorithm");this.algorithm=m;var b=r.get("Length");if(!b)if(3>=m)b=40;else{var v=r.get("CF"),k=r.get("StmF");if(g(v)&&d(k)){var w=v.get(k.name);b=w&&w.get("Length")||128;40>b&&(b<<=3)}}(!c(b)||40>b||b%8!==0)&&o("invalid key length");var x=l(r.get("O")).subarray(0,32),C=l(r.get("U")).subarray(0,32),S=r.get("P"),A=r.get("R"),I=(4===m||5===m)&&r.get("EncryptMetadata")!==!1;this.encryptMetadata=I;var B,R=l(s);if(f){if(6===A)try{f=h(f)}catch(T){u("CipherTransformFactory: Unable to convert UTF8 encoded password.")}B=l(f)}var O;if(5!==m)O=t(R,B,x,C,S,A,b,I);else{var P=l(r.get("O")).subarray(32,40),L=l(r.get("O")).subarray(40,48),M=l(r.get("U")).subarray(0,48),E=l(r.get("U")).subarray(32,40),D=l(r.get("U")).subarray(40,48),q=l(r.get("OE")),j=l(r.get("UE")),F=l(r.get("Perms"));O=e(A,B,x,P,L,M,C,E,D,q,j,F)}if(!O&&!f)throw new i("No password given",n.NEED_PASSWORD);if(!O&&f){var U=a(B,x,A,b);O=t(R,U,x,C,S,A,b,I)}if(!O)throw new i("Incorrect Password",n.INCORRECT_PASSWORD);this.encryptionKey=O;if(m>=4){this.cf=r.get("CF");this.stmf=r.get("StmF")||y;this.strf=r.get("StrF")||y;this.eff=r.get("EFF")||this.stmf}}function s(e,t,a,r){var i,n,s=new Uint8Array(a.length+9);for(i=0,n=a.length;n>i;++i)s[i]=a[i];s[i++]=255&e;s[i++]=e>>8&255;s[i++]=e>>16&255;s[i++]=255&t;s[i++]=t>>8&255;if(r){s[i++]=115;s[i++]=65;s[i++]=108;s[i++]=84}var o=b(s,0,i);return o.subarray(0,Math.min(a.length+5,16))}function p(e,t,a,r,i){var n,c=e.get(t.name);null!==c&&void 0!==c&&(n=c.get("CFM"));if(!n||"None"===n.name)return function(){return new x};if("V2"===n.name)return function(){return new m(s(a,r,i,!1))};if("AESV2"===n.name)return function(){return new C(s(a,r,i,!0))};if("AESV3"===n.name)return function(){return new S(i)};o("Unknown crypto method")}var v=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]),y=f.get("Identity");r.prototype={createCipherTransform:function(e,t){if(4===this.algorithm||5===this.algorithm)return new B(p(this.cf,this.stmf,e,t,this.encryptionKey),p(this.cf,this.strf,e,t,this.encryptionKey));var a=s(e,t,this.encryptionKey,!1),r=function(){return new m(a)};return new B(r,r)}};return r}();e.AES128Cipher=C;e.AES256Cipher=S;e.ARCFourCipher=m;e.CipherTransformFactory=R;e.PDF17=A;e.PDF20=I;e.calculateMD5=b;e.calculateSHA256=y;e.calculateSHA384=w;e.calculateSHA512=k});!function(e,t){t(e.pdfjsCoreFontRenderer={},e.pdfjsSharedUtil,e.pdfjsCoreStream,e.pdfjsCoreGlyphList,e.pdfjsCoreEncodings,e.pdfjsCoreCFFParser)}(this,function(e,t,a,r,i,n){var s=t.Util,o=t.bytesToString,c=t.error,l=a.Stream,h=r.getGlyphsUnicode,u=i.StandardEncoding,f=n.CFFParser,d=function(){function e(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function t(e,t){return e[t]<<8|e[t+1]}function a(a,r,i){var n,s,o,l,h=1===t(a,r+2)?e(a,r+8):e(a,r+16),u=t(a,r+h);if(4===u){n=t(a,r+h+2);var f=t(a,r+h+6)>>1;o=r+h+14;s=[];for(l=0;f>l;l++,o+=2)s[l]={end:t(a,o)};o+=2;for(l=0;f>l;l++,o+=2)s[l].start=t(a,o);for(l=0;f>l;l++,o+=2)s[l].idDelta=t(a,o);for(l=0;f>l;l++,o+=2){var d=t(a,o);if(0!==d){s[l].ids=[];for(var g=0,p=s[l].end-s[l].start+1;p>g;g++){s[l].ids[g]=t(a,o+d);d+=2}}}return s}if(12===u){n=e(a,r+h+4);var m=e(a,r+h+12);o=r+h+16;s=[];for(l=0;m>l;l++){s.push({start:e(a,o),end:e(a,o+4),idDelta:e(a,o+8)-e(a,o)});o+=12}return s}c("not supported cmap: "+u)}function r(e,t,a,r){var i={},n=new f(new l(e,t,a-t),i,r),s=n.parse();return{glyphs:s.charStrings.objects,subrs:s.topDict.privateDict&&s.topDict.privateDict.subrsIndex&&s.topDict.privateDict.subrsIndex.objects,gsubrs:s.globalSubrIndex&&s.globalSubrIndex.objects}}function i(e,t,a){var r,i;if(a){r=4;i=function(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}}else{r=2;i=function(e,t){return e[t]<<9|e[t+1]<<1}}for(var n=[],s=i(t,0),o=r;oi;){var s=i+n+1>>1;a>16,l=0,h=0;o+=10;if(0>c){do{s=e[o]<<8|e[o+1];var u=e[o+2]<<8|e[o+3];o+=4;var f,g;if(1&s){f=(e[o]<<24|e[o+1]<<16)>>16;g=(e[o+2]<<24|e[o+3]<<16)>>16;o+=4}else{f=e[o++];g=e[o++]}if(2&s){l=f;h=g}else{l=0;h=0}var p=1,m=1,b=0,v=0;if(8&s){p=m=(e[o]<<24|e[o+1]<<16)/1073741824;o+=2}else if(64&s){p=(e[o]<<24|e[o+1]<<16)/1073741824;m=(e[o+2]<<24|e[o+3]<<16)/1073741824;o+=4}else if(128&s){p=(e[o]<<24|e[o+1]<<16)/1073741824;b=(e[o+2]<<24|e[o+3]<<16)/1073741824;v=(e[o+4]<<24|e[o+5]<<16)/1073741824;m=(e[o+6]<<24|e[o+7]<<16)/1073741824;o+=8}var y=a.glyphs[u];if(y){t.push({cmd:"save"});t.push({cmd:"transform",args:[p,b,v,m,l,h]});d(y,t,a);t.push({cmd:"restore"})}}while(32&s)}else{var k,w,x=[];for(k=0;c>k;k++){x.push(e[o]<<8|e[o+1]);o+=2}var C=e[o]<<8|e[o+1];o+=2+C;for(var S=x[x.length-1]+1,A=[];A.length0;)A.push({flags:s})}for(k=0;S>k;k++){switch(18&A[k].flags){case 0:l+=(e[o]<<24|e[o+1]<<16)>>16;o+=2;break;case 2:l-=e[o++];break;case 18:l+=e[o++]}A[k].x=l}for(k=0;S>k;k++){switch(36&A[k].flags){case 0:h+=(e[o]<<24|e[o+1]<<16)>>16;o+=2;break;case 4:h-=e[o++];break;case 36:h+=e[o++]}A[k].y=h}var B=0;for(o=0;c>o;o++){var R=x[o],T=A.slice(B,R+1);if(1&T[0].flags)T.push(T[0]);else if(1&T[T.length-1].flags)T.unshift(T[T.length-1]);else{var O={flags:1,x:(T[0].x+T[T.length-1].x)/2,y:(T[0].y+T[T.length-1].y)/2};T.unshift(O);T.push(O)}r(T[0].x,T[0].y);for(k=1,w=T.length;w>k;k++)if(1&T[k].flags)i(T[k].x,T[k].y);else if(1&T[k+1].flags){n(T[k].x,T[k].y,T[k+1].x,T[k+1].y);k++}else n(T[k].x,T[k].y,(T[k].x+T[k+1].x)/2,(T[k].y+T[k+1].y)/2);B=R+1}}}function g(e,t,a){function r(e,a){t.push({cmd:"moveTo",args:[e,a]})}function i(e,a){t.push({cmd:"lineTo",args:[e,a]})}function s(e,a,r,i,n,s){t.push({cmd:"bezierCurveTo",args:[e,a,r,i,n,s]})}function o(e){for(var p=0;p>1;A=!0;break;case 3:d+=l.length>>1;A=!0;break;case 4:f+=l.pop();r(h,f);A=!0;break;case 5:for(;l.length>0;){h+=l.shift();f+=l.shift();i(h,f)}break;case 6:for(;l.length>0;){h+=l.shift();i(h,f);if(0===l.length)break;f+=l.shift();i(h,f)}break;case 7:for(;l.length>0;){f+=l.shift();i(h,f);if(0===l.length)break;h+=l.shift();i(h,f)}break;case 8:for(;l.length>0;){m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+l.shift();s(m,v,b,y,h,f)}break;case 10:C=l.pop()+a.subrsBias;S=a.subrs[C];S&&o(S);break;case 11:return;case 12:I=e[p++];switch(I){case 34:m=h+l.shift();b=m+l.shift();k=f+l.shift();h=b+l.shift();s(m,f,b,k,h,k);m=h+l.shift();b=m+l.shift();h=b+l.shift();s(m,k,b,f,h,f);break;case 35:m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+l.shift();s(m,v,b,y,h,f);m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+l.shift();s(m,v,b,y,h,f);l.pop();break;case 36:m=h+l.shift();k=f+l.shift();b=m+l.shift();w=k+l.shift();h=b+l.shift();s(m,k,b,w,h,w);m=h+l.shift();b=m+l.shift();x=w+l.shift();h=b+l.shift();s(m,w,b,x,h,f);break;case 37:var B=h,R=f;m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+l.shift();s(m,v,b,y,h,f);m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b;f=y;Math.abs(h-B)>Math.abs(f-R)?h+=l.shift():f+=l.shift();s(m,v,b,y,h,f);break;default:c("unknown operator: 12 "+I)}break;case 14:if(l.length>=4){var T=l.pop(),O=l.pop();f=l.pop();h=l.pop();t.push({cmd:"save"});t.push({cmd:"translate",args:[h,f]});var P=n(a.cmap,String.fromCharCode(a.glyphNameMap[u[T]]));g(a.glyphs[P.glyphId],t,a);t.push({cmd:"restore"});P=n(a.cmap,String.fromCharCode(a.glyphNameMap[u[O]]));g(a.glyphs[P.glyphId],t,a)}return;case 18:d+=l.length>>1;A=!0;break;case 19:d+=l.length>>1;p+=d+7>>3;A=!0;break;case 20:d+=l.length>>1;p+=d+7>>3;A=!0;break;case 21:f+=l.pop();h+=l.pop();r(h,f);A=!0;break;case 22:h+=l.pop();r(h,f);A=!0;break;case 23:d+=l.length>>1;A=!0;break;case 24:for(;l.length>2;){m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+l.shift();s(m,v,b,y,h,f)}h+=l.shift();f+=l.shift();i(h,f);break;case 25:for(;l.length>6;){h+=l.shift();f+=l.shift();i(h,f)}m=h+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+l.shift();s(m,v,b,y,h,f);break;case 26:l.length%2&&(h+=l.shift());for(;l.length>0;){m=h;v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b;f=y+l.shift();s(m,v,b,y,h,f)}break;case 27:l.length%2&&(f+=l.shift());for(;l.length>0;){m=h+l.shift();v=f;b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y;s(m,v,b,y,h,f)}break;case 28:l.push((e[p]<<24|e[p+1]<<16)>>16);p+=2;break;case 29:C=l.pop()+a.gsubrsBias;S=a.gsubrs[C];S&&o(S);break;case 30:for(;l.length>0;){m=h;v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+(1===l.length?l.shift():0);s(m,v,b,y,h,f);if(0===l.length)break;m=h+l.shift();v=f;b=m+l.shift();y=v+l.shift();f=y+l.shift();h=b+(1===l.length?l.shift():0);s(m,v,b,y,h,f)}break;case 31:for(;l.length>0;){m=h+l.shift();v=f;b=m+l.shift();y=v+l.shift();f=y+l.shift();h=b+(1===l.length?l.shift():0);s(m,v,b,y,h,f);if(0===l.length)break;m=h;v=f+l.shift();b=m+l.shift();y=v+l.shift();h=b+l.shift();f=y+(1===l.length?l.shift():0);s(m,v,b,y,h,f)}break;default:32>I&&c("unknown operator: "+I);if(247>I)l.push(I-139);else if(251>I)l.push(256*(I-247)+e[p++]+108);else if(255>I)l.push(256*-(I-251)-e[p++]-108);else{l.push((e[p]<<24|e[p+1]<<16|e[p+2]<<8|e[p+3])/65536);p+=4}}A&&(l.length=0)}}var l=[],h=0,f=0,d=0;o(e)}function p(e){this.compiledGlyphs=Object.create(null);this.compiledCharCodeToGlyphId=Object.create(null);this.fontMatrix=e}function m(e,t,a){a=a||[488e-6,0,0,488e-6,0,0];p.call(this,a);this.glyphs=e;this.cmap=t}function b(e,t,a,r){a=a||[.001,0,0,.001,0,0];p.call(this,a);this.glyphs=e.glyphs;this.gsubrs=e.gsubrs||[];this.subrs=e.subrs||[];this.cmap=t;this.glyphNameMap=r||h();this.gsubrsBias=this.gsubrs.length<1240?107:this.gsubrs.length<33900?1131:32768;this.subrsBias=this.subrs.length<1240?107:this.subrs.length<33900?1131:32768}var v="";p.prototype={getPathJs:function(e){var t=n(this.cmap,e),a=this.compiledGlyphs[t.glyphId];if(!a){a=this.compileGlyph(this.glyphs[t.glyphId]);this.compiledGlyphs[t.glyphId]=a}void 0===this.compiledCharCodeToGlyphId[t.charCode]&&(this.compiledCharCodeToGlyphId[t.charCode]=t.glyphId);return a},compileGlyph:function(e){if(!e||0===e.length||14===e[0])return v;var t=[];t.push({cmd:"save"});t.push({cmd:"transform",args:this.fontMatrix.slice()});t.push({cmd:"scale",args:["size","-size"]});this.compileGlyphImpl(e,t);t.push({cmd:"restore"});return t},compileGlyphImpl:function(){c("Children classes should implement this.")},hasBuiltPath:function(e){var t=n(this.cmap,e);return void 0!==this.compiledGlyphs[t.glyphId]&&void 0!==this.compiledCharCodeToGlyphId[t.charCode]}};s.inherit(m,p,{compileGlyphImpl:function(e,t){d(e,t,this)}});s.inherit(b,p,{compileGlyphImpl:function(e,t){g(e,t,this)}});return{create:function(n,s){for(var c,l,h,u,f,d,g=new Uint8Array(n.data),p=t(g,4),v=0,y=12;p>v;v++,y+=16){var k=o(g.subarray(y,y+4)),w=e(g,y+8),x=e(g,y+12);switch(k){case"cmap":c=a(g,w,w+x);break;case"glyf":l=g.subarray(w,w+x);break;case"loca":h=g.subarray(w,w+x);break;case"head":d=t(g,w+18);f=t(g,w+50);break;case"CFF ":u=r(g,w,w+x,s)}}if(l){var C=d?[1/d,0,0,1/d,0,0]:n.fontMatrix;return new m(i(l,h,f),c,C)}return new b(u,c,n.fontMatrix,n.glyphNameMap)}}}();e.FontRendererFactory=d});!function(e,t){t(e.pdfjsCoreParser={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreStream)}(this,function(e,t,a,r){function i(e){return e===M}var n=t.MissingDataException,s=t.StreamType,o=t.assert,c=t.error,l=t.info,h=t.isArray,u=t.isInt,f=t.isNum,d=t.isString,g=t.warn,p=a.Cmd,m=a.Dict,b=a.Name,v=a.Ref,y=a.isCmd,k=a.isDict,w=a.isName,x=r.Ascii85Stream,C=r.AsciiHexStream,S=r.CCITTFaxStream,A=r.FlateStream,I=r.Jbig2Stream,B=r.JpegStream,R=r.JpxStream,T=r.LZWStream,O=r.NullStream,P=r.PredictorStream,L=r.RunLengthStream,M={},E=1e3,D=function(){function e(e,t,a){this.lexer=e;this.allowStreams=t;this.xref=a;this.imageCache=Object.create(null);this.refill()}e.prototype={refill:function(){this.buf1=this.lexer.getObj();this.buf2=this.lexer.getObj()},shift:function(){if(y(this.buf2,"ID")){this.buf1=this.buf2;this.buf2=null}else{this.buf1=this.buf2;this.buf2=this.lexer.getObj()}},tryShift:function(){try{this.shift();return!0}catch(e){if(e instanceof n)throw e;return!1}},getObj:function(e){var t=this.buf1;this.shift();if(t instanceof p)switch(t.cmd){case"BI":return this.makeInlineImage(e);case"[":for(var a=[];!y(this.buf1,"]")&&!i(this.buf1);)a.push(this.getObj(e));i(this.buf1)&&c("End of file inside array");this.shift();return a;case"<<":for(var r=new m(this.xref);!y(this.buf1,">>")&&!i(this.buf1);)if(w(this.buf1)){var n=this.buf1.name;this.shift();if(i(this.buf1))break;r.set(n,this.getObj(e))}else{l("Malformed dictionary: key must be a name object");this.shift()}i(this.buf1)&&c("End of file inside dictionary");if(y(this.buf2,"stream"))return this.allowStreams?this.makeStream(r,e):r;this.shift();return r;default:return t}if(u(t)){var s=t;if(u(this.buf1)&&y(this.buf2,"R")){var o=new v(s,this.buf1);this.shift();this.shift();return o}return s}if(d(t)){var h=t;e&&(h=e.decryptString(h));return h}return t},findDefaultInlineStreamEnd:function(e){for(var t,a,r,i,n=69,s=73,c=32,l=10,h=13,u=e.pos,f=0;-1!==(t=e.getByte());)if(0===f)f=t===n?1:0;else if(1===f)f=t===s?2:0;else{o(2===f);if(t===c||t===l||t===h){r=5;i=e.peekBytes(r);for(a=0;r>a;a++){t=i[a];if(t!==l&&t!==h&&(c>t||t>127)){f=0;break}}if(2===f)break}else f=0}return e.pos-4-u},findDCTDecodeInlineStreamEnd:function(e){for(var t,a,r,i=e.pos,n=!1;-1!==(t=e.getByte());)if(255===t){switch(e.getByte()){case 0:break;case 255:e.skip(-1);break;case 217:n=!0;break;case 192:case 193:case 194:case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:a=e.getUint16();a>2?e.skip(a-2):e.skip(-2)}if(n)break}r=e.pos-i;if(-1===t){g("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead.");e.skip(-r);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return r},findASCII85DecodeInlineStreamEnd:function(e){for(var t,a,r=126,i=62,n=e.pos;-1!==(t=e.getByte());)if(t===r&&e.peekByte()===i){e.skip();break}a=e.pos-n;if(-1===t){g("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a},findASCIIHexDecodeInlineStreamEnd:function(e){for(var t,a,r=62,i=e.pos;-1!==(t=e.getByte())&&t!==r;);a=e.pos-i;if(-1===t){g("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a},inlineStreamSkipEI:function(e){for(var t,a=69,r=73,i=0;-1!==(t=e.getByte());)if(0===i)i=t===a?1:0;else if(1===i)i=t===r?2:0;else if(2===i)break},makeInlineImage:function(e){for(var t=this.lexer,a=t.stream,r=new m(this.xref);!y(this.buf1,"ID")&&!i(this.buf1);){w(this.buf1)||c("Dictionary key must be a name object");var n=this.buf1.name;this.shift();if(i(this.buf1))break;r.set(n,this.getObj(e))}var s,o=r.get("Filter","F");w(o)?s=o.name:h(o)&&w(o[0])&&(s=o[0].name);var l,u,f,d=a.pos;l="DCTDecode"===s||"DCT"===s?this.findDCTDecodeInlineStreamEnd(a):"ASCII85Decide"===s||"A85"===s?this.findASCII85DecodeInlineStreamEnd(a):"ASCIIHexDecode"===s||"AHx"===s?this.findASCIIHexDecodeInlineStreamEnd(a):this.findDefaultInlineStreamEnd(a);var g,b=a.makeSubStream(d,l,r);if(E>l){var v=b.getBytes();b.reset();var k=1,x=0;for(u=0,f=v.length;f>u;++u){k+=255&v[u];x+=k}g=x%65521<<16|k%65521;if(this.imageCache.adler32===g){this.buf2=p.get("EI");this.shift();this.imageCache[g].reset();return this.imageCache[g]}}e&&(b=e.createStream(b,l));b=this.filter(b,r,l);b.dict=r;if(void 0!==g){b.cacheKey="inline_"+l+"_"+g;this.imageCache[g]=b}this.buf2=p.get("EI");this.shift();return b},makeStream:function(e,t){var a=this.lexer,r=a.stream;a.skipToNextLine();var i=r.pos-1,n=e.get("Length");if(!u(n)){l("Bad "+n+" attribute in stream");n=0}r.pos=i+n;a.nextChar();if(this.tryShift()&&y(this.buf2,"endstream"))this.shift();else{r.pos=i;for(var s,o,h=2048,f=9,d=[101,110,100,115,116,114,101,97,109],g=0,p=!1;r.pos=b)break;p=!1;s=0;for(;b>s;){o=0;for(;f>o&&m[s+o]===d[o];)o++;if(o>=f){p=!0;break}s++}if(p){g+=s;r.pos+=s;break}g+=b;r.pos+=b}p||c("Missing endstream");n=g;a.nextChar();this.shift();this.shift()}this.shift();r=r.makeSubStream(i,n,e);t&&(r=t.createStream(r,n));r=this.filter(r,e,n);r.dict=e;return r},filter:function(e,t,a){var r=t.get("Filter","F"),i=t.get("DecodeParms","DP");if(w(r))return this.makeFilter(e,r.name,a,i);var n=a;if(h(r))for(var s=r,o=i,l=0,u=s.length;u>l;++l){r=s[l];w(r)||c("Bad filter name: "+r);i=null;h(o)&&l in o&&(i=o[l]);e=this.makeFilter(e,r.name,n,i);n=null}return e},makeFilter:function(e,t,a,r){if(0===e.dict.get("Length")&&!a){g('Empty "'+t+'" stream.');return new O(e)}try{r&&this.xref&&(r=this.xref.fetchIfRef(r));var i=this.xref.stats.streamTypes;if("FlateDecode"===t||"Fl"===t){i[s.FLATE]=!0;return r?new P(new A(e,a),a,r):new A(e,a)}if("LZWDecode"===t||"LZW"===t){i[s.LZW]=!0;var o=1;if(r){r.has("EarlyChange")&&(o=r.get("EarlyChange"));return new P(new T(e,a,o),a,r)}return new T(e,a,o)}if("DCTDecode"===t||"DCT"===t){i[s.DCT]=!0;return new B(e,a,e.dict,this.xref)}if("JPXDecode"===t||"JPX"===t){i[s.JPX]=!0;return new R(e,a,e.dict)}if("ASCII85Decode"===t||"A85"===t){i[s.A85]=!0;return new x(e,a)}if("ASCIIHexDecode"===t||"AHx"===t){i[s.AHX]=!0;return new C(e,a)}if("CCITTFaxDecode"===t||"CCF"===t){i[s.CCF]=!0;return new S(e,a,r)}if("RunLengthDecode"===t||"RL"===t){i[s.RL]=!0;return new L(e,a)}if("JBIG2Decode"===t){i[s.JBIG]=!0;return new I(e,a,e.dict)}g('filter "'+t+'" not supported yet');return e}catch(c){if(c instanceof n)throw c;g('Invalid stream: "'+c+'"');return new O(e)}}};return e}(),q=function(){function e(e,t){this.stream=e;this.nextChar();this.strBuf=[];this.knownCommands=t}function t(e){return e>=48&&57>=e?15&e:e>=65&&70>=e||e>=97&&102>=e?(15&e)+9:-1}var a=[1,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,2,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];e.prototype={nextChar:function(){return this.currentChar=this.stream.getByte()},peekChar:function(){return this.stream.peekByte()},getNumber:function(){var e=this.currentChar,t=!1,a=0,r=1;if(45===e){r=-1;e=this.nextChar();45===e&&(e=this.nextChar())}else 43===e&&(e=this.nextChar());if(46===e){a=10;e=this.nextChar()}if(48>e||e>57){c("Invalid number: "+String.fromCharCode(e));return 0}for(var i=e-48,n=0,s=1;(e=this.nextChar())>=0;)if(e>=48&&57>=e){var o=e-48;if(t)n=10*n+o;else{0!==a&&(a*=10);i=10*i+o}}else if(46===e){if(0!==a)break;a=1}else if(45===e)g("Badly formated number");else{if(69!==e&&101!==e)break;e=this.peekChar();if(43===e||45===e){s=45===e?-1:1;this.nextChar()}else if(48>e||e>57)break;t=!0}0!==a&&(i/=a);t&&(i*=Math.pow(10,s*n));return r*i},getString:function(){var e=1,t=!1,a=this.strBuf;a.length=0;for(var r=this.nextChar();;){var i=!1;switch(0|r){case-1:g("Unterminated string");t=!0;break;case 40:++e;a.push("(");break;case 41:if(0===--e){this.nextChar();t=!0}else a.push(")");break;case 92:r=this.nextChar();switch(r){case-1:g("Unterminated string");t=!0;break;case 110:a.push("\n");break;case 114:a.push("\r");break;case 116:a.push(" ");break;case 98:a.push("\b");break;case 102:a.push("\f");break;case 92:case 40:case 41:a.push(String.fromCharCode(r));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:var n=15&r;r=this.nextChar();i=!0;if(r>=48&&55>=r){n=(n<<3)+(15&r);r=this.nextChar();if(r>=48&&55>=r){i=!1;n=(n<<3)+(15&r)}}a.push(String.fromCharCode(n));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:a.push(String.fromCharCode(r))}break;default:a.push(String.fromCharCode(r))}if(t)break;i||(r=this.nextChar())}return a.join("")},getName:function(){var e,r,i=this.strBuf;i.length=0;for(;(e=this.nextChar())>=0&&!a[e];)if(35===e){e=this.nextChar();if(a[e]){g("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number.");i.push("#");break}var n=t(e);if(-1!==n){r=e;e=this.nextChar();var s=t(e);if(-1===s){g("Lexer_getName: Illegal digit ("+String.fromCharCode(e)+") in hexadecimal number.");i.push("#",String.fromCharCode(r));if(a[e])break;i.push(String.fromCharCode(e));continue}i.push(String.fromCharCode(n<<4|s))}else i.push("#",String.fromCharCode(e))}else i.push(String.fromCharCode(e));i.length>127&&g("name token is longer than allowed by the spec: "+i.length);return b.get(i.join(""))},getHexString:function(){var e=this.strBuf;e.length=0;for(var r,i,n=this.currentChar,s=!0;;){if(0>n){g("Unterminated hex string");break}if(62===n){this.nextChar();break}if(1!==a[n]){if(s){r=t(n);if(-1===r){g('Ignoring invalid character "'+n+'" in hex string');n=this.nextChar();continue}}else{i=t(n);if(-1===i){g('Ignoring invalid character "'+n+'" in hex string');n=this.nextChar();continue}e.push(String.fromCharCode(r<<4|i))}s=!s;n=this.nextChar()}else n=this.nextChar()}return e.join("")},getObj:function(){for(var e=!1,t=this.currentChar;;){if(0>t)return M;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(1!==a[t])break;t=this.nextChar()}switch(0|t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:this.nextChar();return p.get("[");case 93:this.nextChar();return p.get("]");case 60:t=this.nextChar();if(60===t){this.nextChar();return p.get("<<")}return this.getHexString();case 62:t=this.nextChar();if(62===t){this.nextChar();return p.get(">>")}return p.get(">");case 123:this.nextChar();return p.get("{");case 125:this.nextChar();return p.get("}");case 41:c("Illegal character: "+t)}for(var r=String.fromCharCode(t),i=this.knownCommands,n=i&&void 0!==i[r];(t=this.nextChar())>=0&&!a[t];){var s=r+String.fromCharCode(t);if(n&&void 0===i[s])break;128===r.length&&c("Command token too long: "+r.length);r=s;n=i&&void 0!==i[r]}return"true"===r?!0:"false"===r?!1:"null"===r?null:p.get(r)},skipToNextLine:function(){for(var e=this.currentChar;e>=0;){if(13===e){e=this.nextChar();10===e&&this.nextChar();break}if(10===e){this.nextChar();break}e=this.nextChar()}}};return e}(),j={create:function(e){function t(e,t){var a=l.get(e);if(u(a)&&(t?a>=0:a>0))return a;throw new Error('The "'+e+'" parameter in the linearization dictionary is invalid.')}function a(){var e,t,a=l.get("H");if(h(a)&&(2===(e=a.length)||4===e)){for(var r=0;e>r;r++)if(!(u(t=a[r])&&t>0))throw new Error("Hint ("+r+") in the linearization dictionary is invalid.");return a}throw new Error("Hint array in the linearization dictionary is invalid.")}var r,i,n=new D(new q(e),!1,null),s=n.getObj(),o=n.getObj(),c=n.getObj(),l=n.getObj();if(!(u(s)&&u(o)&&y(c,"obj")&&k(l)&&f(r=l.get("Linearized"))&&r>0))return null;if((i=t("L"))!==e.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:i,hints:a(),objectNumberFirst:t("O"),endFirst:t("E"),numPages:t("N"),mainXRefEntriesOffset:t("T"),pageFirst:l.has("P")?t("P",!0):0}}};e.EOF=M;e.Lexer=q;e.Linearization=j;e.Parser=D;e.isEOF=i});!function(e,t){t(e.pdfjsCoreType1Parser={},e.pdfjsSharedUtil,e.pdfjsCoreStream,e.pdfjsCoreEncodings)}(this,function(e,t,a,r){var i=t.warn,n=t.isSpace,s=a.Stream,o=r.getEncoding,c=!1,l=function(){function e(){ +this.width=0;this.lsb=0;this.flexing=!1;this.output=[];this.stack=[]}var t={hstem:[1],vstem:[3],vmoveto:[4],rlineto:[5],hlineto:[6],vlineto:[7],rrcurveto:[8],callsubr:[10],flex:[12,35],drop:[12,18],endchar:[14],rmoveto:[21],hmoveto:[22],vhcurveto:[30],hvcurveto:[31]};e.prototype={convert:function(e,a,r){for(var n,s,o,l=e.length,h=!1,u=0;l>u;u++){var f=e[u];if(32>f){12===f&&(f=(f<<8)+e[++u]);switch(f){case 1:if(!c){this.stack=[];break}h=this.executeCommand(2,t.hstem);break;case 3:if(!c){this.stack=[];break}h=this.executeCommand(2,t.vstem);break;case 4:if(this.flexing){if(this.stack.length<1){h=!0;break}var d=this.stack.pop();this.stack.push(0,d);break}h=this.executeCommand(1,t.vmoveto);break;case 5:h=this.executeCommand(2,t.rlineto);break;case 6:h=this.executeCommand(1,t.hlineto);break;case 7:h=this.executeCommand(1,t.vlineto);break;case 8:h=this.executeCommand(6,t.rrcurveto);break;case 9:this.stack=[];break;case 10:if(this.stack.length<1){h=!0;break}o=this.stack.pop();h=this.convert(a[o],a,r);break;case 11:return h;case 13:if(this.stack.length<2){h=!0;break}n=this.stack.pop();s=this.stack.pop();this.lsb=s;this.width=n;this.stack.push(n,s);h=this.executeCommand(2,t.hmoveto);break;case 14:this.output.push(t.endchar[0]);break;case 21:if(this.flexing)break;h=this.executeCommand(2,t.rmoveto);break;case 22:if(this.flexing){this.stack.push(0);break}h=this.executeCommand(1,t.hmoveto);break;case 30:h=this.executeCommand(4,t.vhcurveto);break;case 31:h=this.executeCommand(4,t.hvcurveto);break;case 3072:this.stack=[];break;case 3073:if(!c){this.stack=[];break}h=this.executeCommand(2,t.vstem);break;case 3074:if(!c){this.stack=[];break}h=this.executeCommand(2,t.hstem);break;case 3078:if(r){this.seac=this.stack.splice(-4,4);h=this.executeCommand(0,t.endchar)}else h=this.executeCommand(4,t.endchar);break;case 3079:if(this.stack.length<4){h=!0;break}this.stack.pop();n=this.stack.pop();var g=this.stack.pop();s=this.stack.pop();this.lsb=s;this.width=n;this.stack.push(n,s,g);h=this.executeCommand(3,t.rmoveto);break;case 3084:if(this.stack.length<2){h=!0;break}var p=this.stack.pop(),m=this.stack.pop();this.stack.push(m/p);break;case 3088:if(this.stack.length<2){h=!0;break}o=this.stack.pop();var b=this.stack.pop();if(0===o&&3===b){var v=this.stack.splice(this.stack.length-17,17);this.stack.push(v[2]+v[0],v[3]+v[1],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14]);h=this.executeCommand(13,t.flex,!0);this.flexing=!1;this.stack.push(v[15],v[16])}else 1===o&&0===b&&(this.flexing=!0);break;case 3089:break;case 3105:this.stack=[];break;default:i('Unknown type 1 charstring command of "'+f+'"')}if(h)break}else{246>=f?f-=139:f=250>=f?256*(f-247)+e[++u]+108:254>=f?-(256*(f-251))-e[++u]-108:(255&e[++u])<<24|(255&e[++u])<<16|(255&e[++u])<<8|(255&e[++u])<<0;this.stack.push(f)}}return h},executeCommand:function(e,t,a){var r=this.stack.length;if(e>r)return!0;for(var i=r-e,n=i;r>n;n++){var s=this.stack[n];if(s===(0|s))this.output.push(28,s>>8&255,255&s);else{s=65536*s|0;this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s)}}this.output.push.apply(this.output,t);a?this.stack.splice(i,e):this.stack.length=0;return!1}};return e}(),h=function(){function e(e){return e>=48&&57>=e||e>=65&&70>=e||e>=97&&102>=e}function t(e,t,a){if(a>=e.length)return new Uint8Array(0);var r,i,n=0|t,s=52845,o=22719;for(r=0;a>r;r++)n=(e[r]+n)*s+o&65535;var c=e.length-a,l=new Uint8Array(c);for(r=a,i=0;c>i;r++,i++){var h=e[r];l[i]=h^n>>8;n=(h+n)*s+o&65535}return l}function a(t,a,r){var i,n,s=0|a,o=52845,c=22719,l=t.length,h=l>>>1,u=new Uint8Array(h);for(i=0,n=0;l>i;i++){var f=t[i];if(e(f)){i++;for(var d;l>i&&!e(d=t[i]);)i++;if(l>i){var g=parseInt(String.fromCharCode(f,d),16);u[n++]=g^s>>8;s=(g+s)*o+c&65535}}}return Array.prototype.slice.call(u,r,n)}function r(e){return 47===e||91===e||93===e||123===e||125===e||40===e||41===e}function i(r,i,n){if(i){var o=r.getBytes(),c=!(e(o[0])&&e(o[1])&&e(o[2])&&e(o[3]));r=new s(c?t(o,h,4):a(o,h,4))}this.seacAnalysisEnabled=!!n;this.stream=r;this.nextChar()}var h=55665,u=4330;i.prototype={readNumberArray:function(){this.getToken();for(var e=[];;){var t=this.getToken();if(null===t||"]"===t||"}"===t)break;e.push(parseFloat(t||0))}return e},readNumber:function(){var e=this.getToken();return parseFloat(e||0)},readInt:function(){var e=this.getToken();return 0|parseInt(e||0,10)},readBoolean:function(){var e=this.getToken();return"true"===e?1:0},nextChar:function(){return this.currentChar=this.stream.getByte()},getToken:function(){for(var e=!1,t=this.currentChar;;){if(-1===t)return null;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(!n(t))break;t=this.nextChar()}if(r(t)){this.nextChar();return String.fromCharCode(t)}var a="";do{a+=String.fromCharCode(t);t=this.nextChar()}while(t>=0&&!n(t)&&!r(t));return a},extractFontProgram:function(){var e=this.stream,a=[],r=[],i=Object.create(null);i.lenIV=4;for(var n,s,o,h,f,d={subrs:[],charstrings:[],properties:{privateData:i}};null!==(n=this.getToken());)if("/"===n){n=this.getToken();switch(n){case"CharStrings":this.getToken();this.getToken();this.getToken();this.getToken();for(;;){n=this.getToken();if(null===n||"end"===n)break;if("/"===n){var g=this.getToken();s=this.readInt();this.getToken();o=e.makeSubStream(e.pos,s);h=d.properties.privateData.lenIV;f=t(o.getBytes(),u,h);e.skip(s);this.nextChar();n=this.getToken();"noaccess"===n&&this.getToken();r.push({glyph:g,encoded:f})}}break;case"Subrs":this.readInt();this.getToken();for(;"dup"===(n=this.getToken());){var p=this.readInt();s=this.readInt();this.getToken();o=e.makeSubStream(e.pos,s);h=d.properties.privateData.lenIV;f=t(o.getBytes(),u,h);e.skip(s);this.nextChar();n=this.getToken();"noaccess"===n&&this.getToken();a[p]=f}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var m=this.readNumberArray();m.length>0&&m.length%2===0&&c&&(d.properties.privateData[n]=m);break;case"StemSnapH":case"StemSnapV":d.properties.privateData[n]=this.readNumberArray();break;case"StdHW":case"StdVW":d.properties.privateData[n]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":case"ExpansionFactor":d.properties.privateData[n]=this.readNumber();break;case"ForceBold":d.properties.privateData[n]=this.readBoolean()}}for(var b=0;bs;s++){t=this.getToken();for(;"dup"!==t&&"def"!==t;){t=this.getToken();if(null===t)return}if("def"===t)break;var c=this.readInt();this.getToken();var l=this.getToken();r[c]=l;this.getToken()}}else r=o(i);e.builtInEncoding=r;break;case"FontBBox":var h=this.readNumberArray();e.ascent=h[3];e.descent=h[1];e.ascentScaled=!0}}}};return i}();e.Type1Parser=h});!function(e,t){t(e.pdfjsCoreCMap={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreStream,e.pdfjsCoreParser)}(this,function(e,t,a,r,i){var n=t.Util,s=t.assert,o=t.error,c=t.isInt,l=t.isString,h=a.isName,u=a.isCmd,f=a.isStream,d=r.StringStream,g=i.Lexer,p=i.isEOF,m=["Adobe-GB1-UCS2","Adobe-CNS1-UCS2","Adobe-Japan1-UCS2","Adobe-Korea1-UCS2","78-EUC-H","78-EUC-V","78-H","78-RKSJ-H","78-RKSJ-V","78-V","78ms-RKSJ-H","78ms-RKSJ-V","83pv-RKSJ-H","90ms-RKSJ-H","90ms-RKSJ-V","90msp-RKSJ-H","90msp-RKSJ-V","90pv-RKSJ-H","90pv-RKSJ-V","Add-H","Add-RKSJ-H","Add-RKSJ-V","Add-V","Adobe-CNS1-0","Adobe-CNS1-1","Adobe-CNS1-2","Adobe-CNS1-3","Adobe-CNS1-4","Adobe-CNS1-5","Adobe-CNS1-6","Adobe-GB1-0","Adobe-GB1-1","Adobe-GB1-2","Adobe-GB1-3","Adobe-GB1-4","Adobe-GB1-5","Adobe-Japan1-0","Adobe-Japan1-1","Adobe-Japan1-2","Adobe-Japan1-3","Adobe-Japan1-4","Adobe-Japan1-5","Adobe-Japan1-6","Adobe-Korea1-0","Adobe-Korea1-1","Adobe-Korea1-2","B5-H","B5-V","B5pc-H","B5pc-V","CNS-EUC-H","CNS-EUC-V","CNS1-H","CNS1-V","CNS2-H","CNS2-V","ETHK-B5-H","ETHK-B5-V","ETen-B5-H","ETen-B5-V","ETenms-B5-H","ETenms-B5-V","EUC-H","EUC-V","Ext-H","Ext-RKSJ-H","Ext-RKSJ-V","Ext-V","GB-EUC-H","GB-EUC-V","GB-H","GB-V","GBK-EUC-H","GBK-EUC-V","GBK2K-H","GBK2K-V","GBKp-EUC-H","GBKp-EUC-V","GBT-EUC-H","GBT-EUC-V","GBT-H","GBT-V","GBTpc-EUC-H","GBTpc-EUC-V","GBpc-EUC-H","GBpc-EUC-V","H","HKdla-B5-H","HKdla-B5-V","HKdlb-B5-H","HKdlb-B5-V","HKgccs-B5-H","HKgccs-B5-V","HKm314-B5-H","HKm314-B5-V","HKm471-B5-H","HKm471-B5-V","HKscs-B5-H","HKscs-B5-V","Hankaku","Hiragana","KSC-EUC-H","KSC-EUC-V","KSC-H","KSC-Johab-H","KSC-Johab-V","KSC-V","KSCms-UHC-H","KSCms-UHC-HW-H","KSCms-UHC-HW-V","KSCms-UHC-V","KSCpc-EUC-H","KSCpc-EUC-V","Katakana","NWP-H","NWP-V","RKSJ-H","RKSJ-V","Roman","UniCNS-UCS2-H","UniCNS-UCS2-V","UniCNS-UTF16-H","UniCNS-UTF16-V","UniCNS-UTF32-H","UniCNS-UTF32-V","UniCNS-UTF8-H","UniCNS-UTF8-V","UniGB-UCS2-H","UniGB-UCS2-V","UniGB-UTF16-H","UniGB-UTF16-V","UniGB-UTF32-H","UniGB-UTF32-V","UniGB-UTF8-H","UniGB-UTF8-V","UniJIS-UCS2-H","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V","UniJIS-UCS2-V","UniJIS-UTF16-H","UniJIS-UTF16-V","UniJIS-UTF32-H","UniJIS-UTF32-V","UniJIS-UTF8-H","UniJIS-UTF8-V","UniJIS2004-UTF16-H","UniJIS2004-UTF16-V","UniJIS2004-UTF32-H","UniJIS2004-UTF32-V","UniJIS2004-UTF8-H","UniJIS2004-UTF8-V","UniJISPro-UCS2-HW-V","UniJISPro-UCS2-V","UniJISPro-UTF8-V","UniJISX0213-UTF32-H","UniJISX0213-UTF32-V","UniJISX02132004-UTF32-H","UniJISX02132004-UTF32-V","UniKS-UCS2-H","UniKS-UCS2-V","UniKS-UTF16-H","UniKS-UTF16-V","UniKS-UTF32-H","UniKS-UTF32-V","UniKS-UTF8-H","UniKS-UTF8-V","V","WP-Symbol"],b=function(){function e(e){this.codespaceRanges=[[],[],[],[]];this.numCodespaceRanges=0;this._map=[];this.name="";this.vertical=!1;this.useCMap=null;this.builtInCMap=e}e.prototype={addCodespaceRange:function(e,t,a){this.codespaceRanges[e-1].push(t,a);this.numCodespaceRanges++},mapCidRange:function(e,t,a){for(;t>=e;)this._map[e++]=a++},mapBfRange:function(e,t,a){for(var r=a.length-1;t>=e;){this._map[e++]=a;a=a.substr(0,r)+String.fromCharCode(a.charCodeAt(r)+1)}},mapBfRangeToArray:function(e,t,a){for(var r=0,i=a.length;t>=e&&i>r;){this._map[e]=a[r++];++e}},mapOne:function(e,t){this._map[e]=t},lookup:function(e){return this._map[e]},contains:function(e){return void 0!==this._map[e]},forEach:function(e){var t,a=this._map,r=a.length;if(65536>=r)for(t=0;r>t;t++)void 0!==a[t]&&e(t,a[t]);else for(t in this._map)e(t,a[t])},charCodeOf:function(e){return this._map.indexOf(e)},getMap:function(){return this._map},readCharCode:function(e,t,a){for(var r=0,i=this.codespaceRanges,n=this.codespaceRanges.length,s=0;n>s;s++){r=(r<<8|e.charCodeAt(t+s))>>>0;for(var o=i[s],c=0,l=o.length;l>c;){var h=o[c++],u=o[c++];if(r>=h&&u>=r){a.charcode=r;a.length=s+1;return}}}a.charcode=0;a.length=1},get length(){return this._map.length},get isIdentityCMap(){if("Identity-H"!==this.name&&"Identity-V"!==this.name)return!1;if(65536!==this._map.length)return!1;for(var e=0;65536>e;e++)if(this._map[e]!==e)return!1;return!0}};return e}(),v=function(){function e(e,t){b.call(this);this.vertical=e;this.addCodespaceRange(t,0,65535)}n.inherit(e,b,{});e.prototype={addCodespaceRange:b.prototype.addCodespaceRange,mapCidRange:function(e,t,a){o("should not call mapCidRange")},mapBfRange:function(e,t,a){o("should not call mapBfRange")},mapBfRangeToArray:function(e,t,a){o("should not call mapBfRangeToArray")},mapOne:function(e,t){o("should not call mapCidOne")},lookup:function(e){return c(e)&&65535>=e?e:void 0},contains:function(e){return c(e)&&65535>=e},forEach:function(e){for(var t=0;65535>=t;t++)e(t,t)},charCodeOf:function(e){return c(e)&&65535>=e?e:-1},getMap:function(){for(var e=new Array(65536),t=0;65535>=t;t++)e[t]=t;return e},readCharCode:b.prototype.readCharCode,get length(){return 65536},get isIdentityCMap(){o("should not access .isIdentityCMap")}};return e}(),y=function(){function e(e){return new Promise(function(t,a){var r=new XMLHttpRequest;r.open("GET",e,!0);r.responseType="arraybuffer";r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&(!r.response||200!==r.status&&0!==r.status?a(new Error("Unable to get binary cMap at: "+e)):t(new Uint8Array(r.response)))};r.send(null)})}function t(e,t){for(var a=0,r=0;t>=r;r++)a=a<<8|e[r];return a>>>0}function a(e,t){return 1===t?String.fromCharCode(e[0],e[1]):3===t?String.fromCharCode(e[0],e[1],e[2],e[3]):String.fromCharCode.apply(null,e.subarray(0,t+1))}function r(e,t,a){for(var r=0,i=a;i>=0;i--){r+=e[i]+t[i];e[i]=255&r;r>>=8}}function i(e,t){for(var a=1,r=t;r>=0&&a>0;r--){a+=e[r];e[r]=255&a;a>>=8}}function n(e){this.buffer=e;this.pos=0;this.end=e.length;this.tmpBuf=new Uint8Array(u)}function c(c,l,u){return e(c).then(function(e){var c=new n(e),f=c.readByte();l.vertical=!!(1&f);for(var d,g,p=null,m=new Uint8Array(h),b=new Uint8Array(h),v=new Uint8Array(h),y=new Uint8Array(h),k=new Uint8Array(h);(g=c.readByte())>=0;){var w=g>>5;if(7!==w){var x=!!(16&g),C=15&g;s(h>=C+1);var S,A=1,I=c.readNumber();switch(w){case 0:c.readHex(m,C);c.readHexNumber(b,C);r(b,m,C);l.addCodespaceRange(C+1,t(m,C),t(b,C));for(S=1;I>S;S++){i(b,C);c.readHexNumber(m,C);r(m,b,C);c.readHexNumber(b,C);r(b,m,C);l.addCodespaceRange(C+1,t(m,C),t(b,C))}break;case 1:c.readHex(m,C);c.readHexNumber(b,C);r(b,m,C);d=c.readNumber();for(S=1;I>S;S++){i(b,C);c.readHexNumber(m,C);r(m,b,C);c.readHexNumber(b,C);r(b,m,C);d=c.readNumber()}break;case 2:c.readHex(v,C);d=c.readNumber();l.mapOne(t(v,C),d);for(S=1;I>S;S++){i(v,C);if(!x){c.readHexNumber(k,C);r(v,k,C)}d=c.readSigned()+(d+1);l.mapOne(t(v,C),d)}break;case 3:c.readHex(m,C);c.readHexNumber(b,C);r(b,m,C);d=c.readNumber();l.mapCidRange(t(m,C),t(b,C),d);for(S=1;I>S;S++){i(b,C);if(x)m.set(b);else{c.readHexNumber(m,C);r(m,b,C)}c.readHexNumber(b,C);r(b,m,C);d=c.readNumber();l.mapCidRange(t(m,C),t(b,C),d)}break;case 4:c.readHex(v,A);c.readHex(y,C);l.mapOne(t(v,A),a(y,C));for(S=1;I>S;S++){i(v,A);if(!x){c.readHexNumber(k,A);r(v,k,A)}i(y,C);c.readHexSigned(k,C);r(y,k,C);l.mapOne(t(v,A),a(y,C))}break;case 5:c.readHex(m,A);c.readHexNumber(b,A);r(b,m,A);c.readHex(y,C);l.mapBfRange(t(m,A),t(b,A),a(y,C));for(S=1;I>S;S++){i(b,A);if(x)m.set(b);else{c.readHexNumber(m,A);r(m,b,A)}c.readHexNumber(b,A);r(b,m,A);c.readHex(y,C);l.mapBfRange(t(m,A),t(b,A),a(y,C))}break;default:o("Unknown type: "+w)}}else switch(31&g){case 0:c.readString();break;case 1:p=c.readString()}}return p?u(p):l})}function l(){}var h=16,u=19;n.prototype={readByte:function(){return this.pos>=this.end?-1:this.buffer[this.pos++]},readNumber:function(){var e,t=0;do{var a=this.readByte();0>a&&o("unexpected EOF in bcmap");e=!(128&a);t=t<<7|127&a}while(!e);return t},readSigned:function(){var e=this.readNumber();return 1&e?~(e>>>1):e>>>1},readHex:function(e,t){e.set(this.buffer.subarray(this.pos,this.pos+t+1));this.pos+=t+1},readHexNumber:function(e,t){var a,r=this.tmpBuf,i=0;do{var n=this.readByte();0>n&&o("unexpected EOF in bcmap");a=!(128&n);r[i++]=127&n}while(!a);for(var s=t,c=0,l=0;s>=0;){for(;8>l&&r.length>0;){c=r[--i]<>=8;l-=8}},readHexSigned:function(e,t){this.readHexNumber(e,t);for(var a=1&e[t]?255:0,r=0,i=0;t>=i;i++){r=(1&r)<<8|e[i];e[i]=r>>1^a}},readString:function(){for(var e=this.readNumber(),t="",a=0;e>a;a++)t+=String.fromCharCode(this.readNumber());return t}};l.prototype={read:c};return l}(),k=function(){function e(e){for(var t=0,a=0;a>>0}function t(e){l(e)||o("Malformed CMap: expected string.")}function a(e){c(e)||o("Malformed CMap: expected int.")}function r(a,r){for(;;){var i=r.getObj();if(p(i))break;if(u(i,"endbfchar"))return;t(i);var n=e(i);i=r.getObj();t(i);var s=i;a.mapOne(n,s)}}function i(a,r){for(;;){var i=r.getObj();if(p(i))break;if(u(i,"endbfrange"))return;t(i);var n=e(i);i=r.getObj();t(i);var s=e(i);i=r.getObj();if(c(i)||l(i)){var h=c(i)?String.fromCharCode(i):i;a.mapBfRange(n,s,h)}else{if(!u(i,"["))break;i=r.getObj();for(var f=[];!u(i,"]")&&!p(i);){f.push(i);i=r.getObj()}a.mapBfRangeToArray(n,s,f)}}o("Invalid bf range.")}function n(r,i){for(;;){var n=i.getObj();if(p(n))break;if(u(n,"endcidchar"))return;t(n);var s=e(n);n=i.getObj();a(n);var o=n;r.mapOne(s,o)}}function k(r,i){for(;;){var n=i.getObj();if(p(n))break;if(u(n,"endcidrange"))return;t(n);var s=e(n);n=i.getObj();t(n);var o=e(n);n=i.getObj();a(n);var c=n;r.mapCidRange(s,o,c)}}function w(t,a){for(;;){var r=a.getObj();if(p(r))break;if(u(r,"endcodespacerange"))return;if(!l(r))break;var i=e(r);r=a.getObj();if(!l(r))break;var n=e(r);t.addCodespaceRange(r.length,i,n)}o("Invalid codespace range.")}function x(e,t){var a=t.getObj();c(a)&&(e.vertical=!!a)}function C(e,t){var a=t.getObj();h(a)&&l(a.name)&&(e.name=a.name)}function S(e,t,a,s){var o,c;e:for(;;){var l=t.getObj();if(p(l))break;if(h(l)){"WMode"===l.name?x(e,t):"CMapName"===l.name&&C(e,t);o=l}else if(u(l))switch(l.cmd){case"endcmap":break e;case"usecmap":h(o)&&(c=o.name);break;case"begincodespacerange":w(e,t);break;case"beginbfchar":r(e,t);break;case"begincidchar":n(e,t);break;case"beginbfrange":i(e,t);break;case"begincidrange":k(e,t)}}!s&&c&&(s=c);return s?A(e,a,s):Promise.resolve(e)}function A(e,t,a){return B(a,t).then(function(t){e.useCMap=t;if(0===e.numCodespaceRanges){for(var a=e.useCMap.codespaceRanges,r=0;r=0?s[i]=r:s[i]=0}}else if(e.flags&ce.Symbolic)for(i in t)s[i]=t[i];else{n=E;for(i=0;i=0?s[i]=r:s[i]=0}}var o,c=e.differences;if(c)for(i in c){var l=c[i];r=a.indexOf(l);if(-1===r){o||(o=P());var h=d(l,o);h!==l&&(r=a.indexOf(h))}r>=0?s[i]=r:s[i]=0}return s}var p=t.FONT_IDENTITY_MATRIX,m=t.FontType,b=t.assert,v=t.bytesToString,y=t.error,k=t.info,w=t.isArray,x=t.isInt,C=t.isNum,S=t.readUint32,A=t.shadow,I=t.string32,B=t.warn,R=t.MissingDataException,T=t.isSpace,O=r.Stream,P=i.getGlyphsUnicode,L=i.getDingbatsGlyphsUnicode,M=n.FontRendererFactory,E=s.StandardEncoding,D=s.MacRomanEncoding,q=s.SymbolSetEncoding,j=s.ZapfDingbatsEncoding,F=s.getEncoding,U=o.getStdFontMap,N=o.getNonStdFontMap,_=o.getGlyphMapForStandardFonts,z=o.getSupplementalGlyphMapForArialBlack,H=c.getUnicodeRangeFor,G=c.mapSpecialUnicodeValues,X=c.getUnicodeForGlyph,W=l.Type1Parser,V=h.CFFStandardStrings,K=h.CFFParser,Y=h.CFFCompiler,J=h.CFF,Z=h.CFFHeader,Q=h.CFFTopDict,$=h.CFFPrivateDict,ee=h.CFFStrings,te=h.CFFIndex,ae=h.CFFCharset,re=57344,ie=63743,ne=!1,se=1e3,oe=!1,ce={FixedPitch:1,Serif:2,Symbolic:4,Script:8,Nonsymbolic:32,Italic:64,AllCap:65536,SmallCap:131072,ForceBold:262144},le=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"],he=function(){function e(e,t,a,r,i,n,s,o){this.fontChar=e;this.unicode=t;this.accent=a;this.width=r;this.vmetric=i;this.operatorListId=n;this.isSpace=s;this.isInFont=o}e.prototype.matchesForCache=function(e,t,a,r,i,n,s,o){return this.fontChar===e&&this.unicode===t&&this.accent===a&&this.width===r&&this.vmetric===i&&this.operatorListId===n&&this.isSpace===s&&this.isInFont===o};return e}(),ue=function(){function e(e){this._map=e}e.prototype={get length(){return this._map.length},forEach:function(e){for(var t in this._map)e(t,this._map[t].charCodeAt(0))},has:function(e){return void 0!==this._map[e]},get:function(e){return this._map[e]},charCodeOf:function(e){return this._map.indexOf(e)}};return e}(),fe=function(){function e(e,t){this.firstChar=e;this.lastChar=t}e.prototype={get length(){return this.lastChar+1-this.firstChar},forEach:function(e){for(var t=this.firstChar,a=this.lastChar;a>=t;t++)e(t,t)},has:function(e){return this.firstChar<=e&&e<=this.lastChar},get:function(e){return this.firstChar<=e&&e<=this.lastChar?String.fromCharCode(e):void 0},charCodeOf:function(e){return x(e)&&e>=this.firstChar&&e<=this.lastChar?e:-1}};return e}(),de=function(){function e(e,t,a){e[t]=a>>8&255;e[t+1]=255&a}function t(e,t,a){e[t]=a>>24&255;e[t+1]=a>>16&255;e[t+2]=a>>8&255;e[t+3]=255&a}function a(e,t,a){var r,i;if(a instanceof Uint8Array)e.set(a,t);else if("string"==typeof a)for(r=0,i=a.length;i>r;r++)e[t++]=255&a.charCodeAt(r);else for(r=0,i=a.length;i>r;r++)e[t++]=255&a[r]}function r(e){this.sfnt=e;this.tables=Object.create(null)}r.getSearchParams=function(e,t){for(var a=1,r=0;(a^e)>a;){a<<=1;r++}var i=a*t;return{range:i,entry:r,rangeShift:t*e-i}};var i=12,n=16;r.prototype={toArray:function(){var s=this.sfnt,o=this.tables,c=Object.keys(o);c.sort();var l,h,u,f,d,g=c.length,p=i+g*n,m=[p];for(l=0;g>l;l++){f=o[c[l]];var b=(f.length+3&-4)>>>0;p+=b;m.push(p)}var v=new Uint8Array(p);for(l=0;g>l;l++){f=o[c[l]];a(v,m[l],f)}"true"===s&&(s=I(65536));v[0]=255&s.charCodeAt(0);v[1]=255&s.charCodeAt(1);v[2]=255&s.charCodeAt(2);v[3]=255&s.charCodeAt(3);e(v,4,g);var y=r.getSearchParams(g,16);e(v,6,y.range);e(v,8,y.entry);e(v,10,y.rangeShift);p=i;for(l=0;g>l;l++){d=c[l];v[p]=255&d.charCodeAt(0);v[p+1]=255&d.charCodeAt(1);v[p+2]=255&d.charCodeAt(2);v[p+3]=255&d.charCodeAt(3);var k=0;for(h=m[l],u=m[l+1];u>h;h+=4){var w=S(v,h);k=k+w>>>0}t(v,p+4,k);t(v,p+8,m[l]);t(v,p+12,o[d].length);p+=n}return v},addTable:function(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}};return r}(),ge=new Int32Array([0,32,127,161,173,174,1536,1920,2208,4256,6016,6144,8192,8208,8209,8210,8232,8240,8287,8304,9676,9677,12288,12289,43616,43648,65520,65536]),pe=function(){function e(e,t,a){var r,i,n;this.name=e;this.loadedName=a.loadedName;this.isType3Font=a.isType3Font;this.sizes=[];this.missingFile=!1;this.glyphCache=Object.create(null);var h=e.split("+");h=h.length>1?h[1]:h[0];h=h.split(/[-,_]/g)[0];this.isSerifFont=!!(a.flags&ce.Serif);this.isSymbolicFont=!!(a.flags&ce.Symbolic);this.isMonospace=!!(a.flags&ce.FixedPitch);var d=a.type,g=a.subtype;this.type=d;this.fallbackName=this.isMonospace?"monospace":this.isSerifFont?"serif":"sans-serif";this.differences=a.differences;this.widths=a.widths;this.defaultWidth=a.defaultWidth;this.composite=a.composite;this.wideChars=a.wideChars;this.cMap=a.cMap;this.ascent=a.ascent/se;this.descent=a.descent/se;this.fontMatrix=a.fontMatrix;this.bbox=a.bbox;this.toUnicode=a.toUnicode;this.toFontChar=[];if("Type3"!==a.type){this.cidEncoding=a.cidEncoding;this.vertical=a.vertical;if(this.vertical){this.vmetrics=a.vmetrics;this.defaultVMetrics=a.defaultVMetrics}var p;if(t&&!t.isEmpty){"Type1C"===g&&"Type1"!==d&&"MMType1"!==d&&(s(t)?g="TrueType":d="Type1");"CIDFontType0C"===g&&"CIDFontType0"!==d&&(d="CIDFontType0");"OpenType"===g&&(d="OpenType");"CIDFontType0"===d&&(c(t)?g="CIDFontType0":o(t)?d=g="OpenType":g="CIDFontType0C");var b;switch(d){case"MMType1":k("MMType1 font ("+e+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var v="Type1C"===g||"CIDFontType0C"===g?new ve(t,a):new be(e,t,a);u(a);b=this.convert(e,v,a);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype";b=this.checkAndRepair(e,t,a);if(this.isOpenType){u(a);d="OpenType"}break;default:y("Font "+d+" is not supported")}this.data=b;this.fontType=f(d,g);this.fontMatrix=a.fontMatrix;this.widths=a.widths;this.defaultWidth=a.defaultWidth;this.encoding=a.baseEncoding;this.seacMap=a.seacMap;this.loading=!0}else{t&&B('Font file is empty in "'+e+'" ('+this.loadedName+")");this.missingFile=!0;var w=e.replace(/[,_]/g,"-"),x=U(),C=N(),S=!!x[w]||!(!C[w]||!x[C[w]]);w=x[w]||C[w]||w;this.bold=-1!==w.search(/bold/gi);this.italic=-1!==w.search(/oblique/gi)||-1!==w.search(/italic/gi);this.black=-1!==e.search(/Black/g);this.remeasure=Object.keys(this.widths).length>0;if(S&&"CIDFontType2"===d&&0===a.cidEncoding.indexOf("Identity-")){var A=_(),I=[];for(r in A)I[+r]=A[r];if(/ArialBlack/i.test(e)){var R=z();for(r in R)I[+r]=R[r]}var T=this.toUnicode instanceof fe;T||this.toUnicode.forEach(function(e,t){I[+e]=t});this.toFontChar=I;this.toUnicode=new ue(I)}else if(/Symbol/i.test(w))this.toFontChar=l(q,P(),a.differences);else if(/Dingbats/i.test(w)){/Wingdings/i.test(e)&&B("Non-embedded Wingdings font, falling back to ZapfDingbats.");this.toFontChar=l(j,L(),a.differences)}else if(S)this.toFontChar=l(a.defaultEncoding,P(),a.differences);else{p=P();this.toUnicode.forEach(function(e,t){if(!this.composite){i=a.differences[e]||a.defaultEncoding[e];n=X(i,p);-1!==n&&(t=n)}this.toFontChar[e]=t}.bind(this))}this.loadedName=w.split("-")[0];this.loading=!1;this.fontType=f(d,g)}}else{for(r=0;256>r;r++)this.toFontChar[r]=this.differences[r]||a.defaultEncoding[r];this.fontType=m.TYPE3}}function t(e,t){return(e<<8)+t}function a(e,t){var a=(e<<8)+t;return 32768&a?a-65536:a}function r(e,t,a,r){return(e<<24)+(t<<16)+(a<<8)+r}function i(e){return String.fromCharCode(e>>8&255,255&e)}function n(e){e=e>32767?32767:-32768>e?-32768:e;return String.fromCharCode(e>>8&255,255&e)}function s(e){var t=e.peekBytes(4);return 65536===S(t,0)}function o(e){var t=e.peekBytes(4);return"OTTO"===v(t)}function c(e){var t=e.peekBytes(2);return 37===t[0]&&33===t[1]?!0:128===t[0]&&1===t[1]}function l(e,t,a){for(var r,i=[],n=0,s=e.length;s>n;n++){r=X(e[n],t);-1!==r&&(i[n]=r)}for(var o in a){r=X(a[o],t);-1!==r&&(i[+o]=r)}return i}function h(e){for(var t=0,a=ge.length-1;a>t;){var r=t+a+1>>1;e=c)do{f=c++;if(ne&&61440===f){f=61472;c=f+1}}while(void 0!==o[f]&&ie>=c);n[f]=u;s[l]=f;o[f]=!0}return{toFontChar:s,charCodeToGlyphId:n,nextAvailableFontCharCode:c}}function w(e,t){var a=[];for(var r in e)e[r]>=t||a.push({fontCharCode:0|r,glyphId:e[r]});a.sort(function(e,t){return e.fontCharCode-t.fontCharCode});for(var i=[],n=a.length,s=0;n>s;){var o=a[s].fontCharCode,c=[a[s].glyphId];++s;for(var l=o;n>s&&l+1===a[s].fontCharCode;){c.push(a[s].glyphId);++l;++s;if(65535===l)break}i.push([o,l,c])}return i}function x(e,t){var a,r,n,s,o=w(e,t),c=o[o.length-1][1]>65535?2:1,l="\x00\x00"+i(c)+"\x00\x00"+I(4+8*c);for(a=o.length-1;a>=0&&!(o[a][0]<=65535);--a);var h=a+1;o[a][0]<65535&&65535===o[a][1]&&(o[a][1]=65534);var u,f,d,g,p=o[a][1]<65535?1:0,m=h+p,b=de.getSearchParams(m,2),v="",y="",k="",x="",C="",S=0;for(a=0,r=h;r>a;a++){u=o[a];f=u[0];d=u[1];v+=i(f);y+=i(d);g=u[2];var A=!0;for(n=1,s=g.length;s>n;++n)if(g[n]!==g[n-1]+1){A=!1;break}if(A){var B=g[0];k+=i(B-f&65535);x+=i(0)}else{var R=2*(m-a)+2*S;S+=d-f+1;k+=i(0);x+=i(R);for(n=0,s=g.length;s>n;++n)C+=i(g[n])}}if(p>0){y+="ÿÿ";v+="ÿÿ";k+="\x00";x+="\x00\x00"}var T="\x00\x00"+i(2*m)+i(b.range)+i(b.entry)+i(b.rangeShift)+y+"\x00\x00"+v+k+x+C,O="",P="";if(c>1){l+="\x00\x00\n"+I(4+8*c+4+T.length);O="";for(a=0,r=o.length;r>a;a++){u=o[a];f=u[0];g=u[2];var L=g[0];for(n=1,s=g.length;s>n;++n)if(g[n]!==g[n-1]+1){d=u[0]+n-1;O+=I(f)+I(d)+I(L);f=d+1;L=g[n]}O+=I(f)+I(u[1])+I(L)}P="\x00\f\x00\x00"+I(O.length+16)+"\x00\x00\x00\x00"+I(O.length/12)}return l+"\x00"+i(T.length+4)+T+P+O}function R(e){var t=new O(e.data),a=t.getUint16();t.getBytes(60);var r=t.getUint16();if(4>a&&768&r)return!1;var i=t.getUint16(),n=t.getUint16();if(i>n)return!1;t.getBytes(6);var s=t.getUint16();if(0===s)return!1;e.data[8]=e.data[9]=0;return!0}function T(e,t,a){a=a||{unitsPerEm:0,yMax:0,yMin:0,ascent:0,descent:0};var r=0,n=0,s=0,o=0,c=null,l=0;if(t)for(var h in t){h|=0;(c>h||!c)&&(c=h);h>l&&(l=h);var u=H(h);32>u?r|=1<u?n|=1<u?s|=1<u?o|=1< 123 are reserved for internal usage"); +}else{c=0;l=255}var f=e.bbox||[0,0,0,0],d=a.unitsPerEm||1/(e.fontMatrix||p)[0],g=e.ascentScaled?1:d/se,m=a.ascent||Math.round(g*(e.ascent||f[3])),b=a.descent||Math.round(g*(e.descent||f[1]));b>0&&e.descent>0&&f[1]<0&&(b=-b);var v=a.yMax||m,k=-a.yMin||-b;return"\x00$ô\x00\x00\x00Š»\x00\x00\x00ŒŠ»\x00\x00ß\x001\x00\x00\x00\x00"+String.fromCharCode(e.fixedPitch?9:0)+"\x00\x00\x00\x00\x00\x00"+I(r)+I(n)+I(s)+I(o)+"*21*"+i(e.italicAngle?1:0)+i(c||e.firstChar)+i(l||e.lastChar)+i(m)+i(b)+"\x00d"+i(v)+i(k)+"\x00\x00\x00\x00\x00\x00\x00\x00"+i(e.xHeight)+i(e.capHeight)+i(0)+i(c||e.firstChar)+"\x00"}function W(e){var t=Math.floor(e.italicAngle*Math.pow(2,16));return"\x00\x00\x00"+I(t)+"\x00\x00\x00\x00"+I(e.fixedPitch)+"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}function V(e,t){t||(t=[[],[]]);var a,r,n,s,o,c=[t[0][0]||"Original licence",t[0][1]||e,t[0][2]||"Unknown",t[0][3]||"uniqueID",t[0][4]||e,t[0][5]||"Version 0.11",t[0][6]||"",t[0][7]||"Unknown",t[0][8]||"Unknown",t[0][9]||"Unknown"],l=[];for(a=0,r=c.length;r>a;a++){o=t[1][a]||c[a];var h=[];for(n=0,s=o.length;s>n;n++)h.push(i(o.charCodeAt(n)));l.push(h.join(""))}var u=[c,l],f=["\x00","\x00"],d=["\x00\x00","\x00"],g=["\x00\x00"," "],p=c.length*f.length,m="\x00\x00"+i(p)+i(12*p+6),b=0;for(a=0,r=f.length;r>a;a++){var v=u[a];for(n=0,s=v.length;s>n;n++){o=v[n];var y=f[a]+d[a]+g[a]+i(n)+i(o.length)+i(b);m+=y;b+=o.length}}m+=c.join("")+l.join("");return m}e.getFontID=function(){var e=1;return function(){return String(e++)}}();e.prototype={name:null,font:null,mimetype:null,encoding:null,get renderer(){var e=M.create(this,oe);return A(this,"renderer",e)},exportData:function(){var e={};for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},checkAndRepair:function(e,i,n){function s(e){var t=v(e.getBytes(4)),a=e.getInt32()>>>0,r=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.pos;e.pos=e.start?e.start:0;e.skip(r);var s=e.getBytes(i);e.pos=n;if("head"===t){s[8]=s[9]=s[10]=s[11]=0;s[17]|=32}return{tag:t,checksum:a,length:i,offset:r,data:s}}function o(e){return{version:v(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}function c(e,t,a,r){if(!e){B("No cmap table available.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var i,n=(t.start?t.start:0)+e.offset;t.pos=n;for(var s,o=(t.getUint16(),t.getUint16()),c=!1,l=0;o>l;l++){var h=t.getUint16(),u=t.getUint16(),f=t.getInt32()>>>0,d=!1;if(0===h&&0===u)d=!0;else if(1===h&&0===u)d=!0;else if(3!==h||1!==u||(a||!r)&&s){if(a&&3===h&&0===u){d=!0;c=!0}}else{d=!0;a||(c=!0)}d&&(s={platformId:h,encodingId:u,offset:f});if(c)break}s&&(t.pos=n+s.offset);if(!s||-1===t.peekByte()){B("Could not find a preferred cmap table.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var g,p,m=t.getUint16(),b=(t.getUint16(),t.getUint16(),!1),v=[];if(0===m){for(g=0;256>g;g++){var y=t.getByte();y&&v.push({charCode:g,glyphId:y})}b=!0}else if(4===m){var k=t.getUint16()>>1;t.getBytes(6);var w,x=[];for(w=0;k>w;w++)x.push({end:t.getUint16()});t.getUint16();for(w=0;k>w;w++)x[w].start=t.getUint16();for(w=0;k>w;w++)x[w].delta=t.getUint16();var C=0;for(w=0;k>w;w++){i=x[w];var S=t.getUint16();if(S){var A=(S>>1)-(k-w);i.offsetIndex=A;C=Math.max(C,A+i.end-i.start+1)}else i.offsetIndex=-1}var I=[];for(g=0;C>g;g++)I.push(t.getUint16());for(w=0;k>w;w++){i=x[w];n=i.start;var R=i.end,T=i.delta;A=i.offsetIndex;for(g=n;R>=g;g++)if(65535!==g){p=0>A?g:I[A+g-n];p=p+T&65535;0!==p&&v.push({charCode:g,glyphId:p})}}}else{if(6!==m){B("cmap table has unsupported format: "+m);return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var O=t.getUint16(),P=t.getUint16();for(g=0;P>g;g++){p=t.getUint16();var L=O+g;v.push({charCode:L,glyphId:p})}}v.sort(function(e,t){return e.charCode-t.charCode});for(l=1;lr){k("The numOfMetrics ("+i+") should not be greater than the numGlyphs ("+r+")");i=r;t.data[34]=(65280&i)>>8;t.data[35]=255&i}var n=r-i,s=n-(a.length-4*i>>1);if(s>0){var o=new Uint8Array(a.length+2*s);o.set(a.data);a.data=o}}else a&&(a.data=null)}function h(e,t,a,r,i,n){if(12>=a-t)return 0;var s=e.subarray(t,a),o=s[0]<<8|s[1];if(32768&o){r.set(s,i);return s.length}var c,l=10,h=0;for(c=0;o>c;c++){var u=s[l]<<8|s[l+1];h=u+1;l+=2}var f=l,d=s[l]<<8|s[l+1];l+=2+d;var g=l,p=0;for(c=0;h>c;c++){var m=s[l++];192&m&&(s[l-1]=63&m);var b=(2&m?1:16&m?0:2)+(4&m?1:32&m?0:2);p+=b;if(8&m){var v=s[l++];c+=v;p+=v*b}}if(0===p)return 0;var y=l+p;if(y>s.length)return 0;if(!n&&d>0){r.set(s.subarray(0,f),i);r.set([0,0],i+f);r.set(s.subarray(g,y),i+f+2);y-=d;s.length-y>3&&(y=y+3&-4);return y}if(s.length-y>3){y=y+3&-4;r.set(s.subarray(0,y),i);return y}r.set(s,i);return s.length}function f(e,a,i){var n=e.data,s=r(n[0],n[1],n[2],n[3]);if(s>>16!==1){k("Attempting to fix invalid version in head table: "+s);n[0]=0;n[1]=1;n[2]=0;n[3]=0}var o=t(n[50],n[51]);if(0>o||o>1){k("Attempting to fix invalid indexToLocFormat in head table: "+o);var c=a+1;if(i===c<<1){n[50]=0;n[51]=0}else if(i===c<<2){n[50]=0;n[51]=1}else B("Could not fix indexToLocFormat: "+o)}}function p(e,t,a,r,i,n){var s,o,c;if(r){s=4;o=function(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]};c=function(e,t,a){e[t]=a>>>24&255;e[t+1]=a>>16&255;e[t+2]=a>>8&255;e[t+3]=255&a}}else{s=2;o=function(e,t){return e[t]<<9|e[t+1]<<1};c=function(e,t,a){e[t]=a>>9&255;e[t+1]=a>>1&255}}var l=e.data,u=s*(1+a);if(l.length!==u){l=new Uint8Array(u);l.set(e.data.subarray(0,u));e.data=l}var f=t.data,d=f.length,g=new Uint8Array(d),p=o(l,0),m=0,b=Object.create(null);c(l,0,m);var v,y;for(v=0,y=s;a>v;v++,y+=s){var k=o(l,y);k>d&&(d+3&-4)===k&&(k=d);if(k>d){c(l,y,m);p=k}else{p===k&&(b[v]=!0);var w=h(f,p,k,g,m,i);m+=w;c(l,y,m);p=k}}if(0===m){var x=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(v=0,y=s;a>v;v++,y+=s)c(l,y,x.length);t.data=x;return b}if(n){var C=o(l,s);if(g.length>C+m)t.data=g.subarray(0,C+m);else{t.data=new Uint8Array(C+m);t.data.set(g.subarray(0,m))}t.data.set(g.subarray(0,C),m);c(e.data,l.length-s,m+C)}else t.data=g.subarray(0,m);return b}function m(e,t,a){var r=(i.start?i.start:0)+e.offset;i.pos=r;var n=e.length,s=r+n,o=i.getInt32();i.getBytes(28);var c,l,h=!0;switch(o){case 65536:c=le;break;case 131072:var u=i.getUint16();if(u!==a){h=!1;break}var f=[];for(l=0;u>l;++l){var d=i.getUint16();if(d>=32768){h=!1;break}f.push(d)}if(!h)break;for(var g=[],p=[];i.posl;++l)p[l]=String.fromCharCode(i.getByte());g.push(p.join(""))}c=[];for(l=0;u>l;++l){var b=f[l];258>b?c.push(le[b]):c.push(g[b-258])}break;case 196608:break;default:B("Unknown/unsupported post table version "+o);h=!1;t.defaultEncoding&&(c=t.defaultEncoding)}t.glyphNames=c;return h}function w(e){var t=(i.start?i.start:0)+e.offset;i.pos=t;var a=[[],[]],r=e.length,n=t+r,s=i.getUint16(),o=6;if(0!==s||o>r)return a;var c,l,h=i.getUint16(),u=i.getUint16(),f=[],d=12;for(c=0;h>c&&i.pos+d<=n;c++){var g={platform:i.getUint16(),encoding:i.getUint16(),language:i.getUint16(),name:i.getUint16(),length:i.getUint16(),offset:i.getUint16()};(1===g.platform&&0===g.encoding&&0===g.language||3===g.platform&&1===g.encoding&&1033===g.language)&&f.push(g)}for(c=0,l=f.length;l>c;c++){var p=f[c];if(!(p.length<=0)){var m=t+u+p.offset;if(!(m+p.length>n)){i.pos=m;var b=p.name;if(p.encoding){for(var y="",k=0,w=p.length;w>k;k+=2)y+=String.fromCharCode(i.getUint16());a[1][b]=y}else a[0][b]=v(i.getBytes(p.length))}}}return a}function S(e,t){for(var a,r,i,n,s,o=e.data,c=0,l=0,h=0,u=[],f=[],d=[],g=t.tooComplexToFollowFunctions,p=!1,m=0,b=0,v=o.length;v>c;){var y=o[c++];if(64===y){r=o[c++];if(p||b)c+=r;else for(a=0;r>a;a++)u.push(o[c++])}else if(65===y){r=o[c++];if(p||b)c+=2*r;else for(a=0;r>a;a++){i=o[c++];u.push(i<<8|o[c++])}}else if(176===(248&y)){r=y-176+1;if(p||b)c+=r;else for(a=0;r>a;a++)u.push(o[c++])}else if(184===(248&y)){r=y-184+1;if(p||b)c+=2*r;else for(a=0;r>a;a++){i=o[c++];u.push(i<<8|o[c++])}}else if(43!==y||g)if(44!==y||g){if(45===y)if(p){p=!1;l=c}else{s=f.pop();if(!s){B("TT: ENDF bad stack");t.hintsValid=!1;return}n=d.pop();o=s.data;c=s.i;t.functionsStackDeltas[n]=u.length-s.stackTop}else if(137===y){if(p||b){B("TT: nested IDEFs not allowed");g=!0}p=!0;h=c}else if(88===y)++m;else if(27===y)b=m;else if(89===y){b===m&&(b=0);--m}else if(28===y&&!p&&!b){var k=u[u.length-1];k>0&&(c+=k-1)}}else{if(p||b){B("TT: nested FDEFs not allowed");g=!0}p=!0;h=c;n=u.pop();t.functionsDefined[n]={data:o,i:c}}else if(!p&&!b){n=u[u.length-1];t.functionsUsed[n]=!0;if(n in t.functionsStackDeltas)u.length+=t.functionsStackDeltas[n];else if(n in t.functionsDefined&&d.indexOf(n)<0){f.push({data:o,i:c,stackTop:u.length-1});d.push(n);s=t.functionsDefined[n];if(!s){B("TT: CALL non-existent function");t.hintsValid=!1;return}o=s.data;c=s.i}}if(!p&&!b){var w=142>=y?q[y]:y>=192&&223>=y?-1:y>=224?-2:0;if(y>=113&&117>=y){r=u.pop();r===r&&(w=2*-r)}for(;0>w&&u.length>0;){u.pop();w++}for(;w>0;){u.push(NaN);w--}}}t.tooComplexToFollowFunctions=g;var x=[o];c>o.length&&x.push(new Uint8Array(c-o.length));if(h>l){B("TT: complementing a missing function tail");x.push(new Uint8Array([34,45]))}I(e,x)}function A(e,t){if(!e.tooComplexToFollowFunctions)if(e.functionsDefined.length>t){B("TT: more functions defined than expected");e.hintsValid=!1}else for(var a=0,r=e.functionsUsed.length;r>a;a++){if(a>t){B("TT: invalid function id: "+a);e.hintsValid=!1;return}if(e.functionsUsed[a]&&!e.functionsDefined[a]){B("TT: undefined function: "+a);e.hintsValid=!1;return}}}function I(e,t){if(t.length>1){var a,r,i=0;for(a=0,r=t.length;r>a;a++)i+=t[a].length;i=i+3&-4;var n=new Uint8Array(i),s=0;for(a=0,r=t.length;r>a;a++){n.set(t[a],s);s+=t[a].length}e.data=n;e.length=i}}function L(e,t,a,r){var i={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};e&&S(e,i);t&&S(t,i);e&&A(i,r);if(a&&1&a.length){var n=new Uint8Array(a.length+1);n.set(a.data);a.data=n}return i.hintsValid}function M(e,t,a){return re[e]?!pe&&t>=0&&ue.has(t)?!0:!!(ge&&a>=0&&C(ge[a])):!0}var q=[0,0,0,0,0,0,0,0,-2,-2,-2,-2,0,0,-2,-5,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-1,0,-1,-1,-1,-1,1,-1,-999,0,1,0,-1,-2,0,-1,-2,-1,-1,0,-1,-1,0,0,-999,-999,-1,-1,-1,-1,-2,-999,-2,-2,-999,0,-2,-2,0,0,-2,0,-2,0,0,0,-2,-1,-1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,0,0,-1,0,-1,-1,0,-999,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-2,-999,-999,-999,-999,-999,-1,-1,-2,-2,0,0,0,0,-1,-1,-999,-2,-2,0,0,-1,-2,-2,0,0,0,-1,-1,-1,-2];i=new O(new Uint8Array(i.getBytes()));var j,U,N=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "],_=o(i),z=_.numTables,H=Object.create(null);H["OS/2"]=null;H.cmap=null;H.head=null;H.hhea=null;H.hmtx=null;H.maxp=null;H.name=null;H.post=null;for(var G,X=0;z>X;X++){G=s(i);N.indexOf(G.tag)<0||0!==G.length&&(H[G.tag]=G)}var J=!H["CFF "];if(J){H.loca||y('Required "loca" table is not found');if(!H.glyf){B('Required "glyf" table is not found -- trying to recover.');H.glyf={tag:"glyf",data:new Uint8Array(0)}}this.isOpenType=!1}else{if("OTTO"===_.version&&"CIDFontType2"!==n.type||!H.head||!H.hhea||!H.maxp||!H.post){U=new O(H["CFF "].data);j=new ve(U,n);u(n);return this.convert(e,j,n)}delete H.glyf;delete H.loca;delete H.fpgm;delete H.prep;delete H["cvt "];this.isOpenType=!0}H.maxp||y('Required "maxp" table is not found');i.pos=(i.start||0)+H.maxp.offset;var Z=i.getInt32(),Q=i.getUint16(),$=0;if(Z>=65536&&H.maxp.length>=22){i.pos+=8;var ee=i.getUint16();if(ee>2){H.maxp.data[14]=0;H.maxp.data[15]=2}i.pos+=4;$=i.getUint16()}var te=!1;if("CIDFontType2"===n.type&&n.toUnicode&&n.toUnicode.get(0)>"\x00"){te=!0;Q++;H.maxp.data[4]=Q>>8;H.maxp.data[5]=255&Q}var ae=L(H.fpgm,H.prep,H["cvt "],$);if(!ae){delete H.fpgm;delete H.prep;delete H["cvt "]}l(i,H.hhea,H.hmtx,Q);H.head||y('Required "head" table is not found');f(H.head,Q,J?H.loca.length:0);var re=Object.create(null);if(J){var ie=t(H.head.data[50],H.head.data[51]);re=p(H.loca,H.glyf,Q,ie,ae,te)}H.hhea||y('Required "hhea" table is not found');if(0===H.hhea.data[10]&&0===H.hhea.data[11]){H.hhea.data[10]=255;H.hhea.data[11]=255}var ne={unitsPerEm:t(H.head.data[18],H.head.data[19]),yMax:t(H.head.data[42],H.head.data[43]),yMin:a(H.head.data[38],H.head.data[39]),ascent:t(H.hhea.data[4],H.hhea.data[5]),descent:a(H.hhea.data[6],H.hhea.data[7])};this.ascent=ne.ascent/ne.unitsPerEm;this.descent=ne.descent/ne.unitsPerEm;if(H.post){var se=m(H.post,n,Q);se||(H.post=null)}var ce,he=[],ue=n.toUnicode,ge=n.widths,pe=ue instanceof fe||65536===ue.length;if("CIDFontType2"===n.type){var me=n.cidToGidMap||[],be=0===me.length;n.cMap.forEach(function(e,t){b(65535>=t,"Max size of CID is 65,535");var a=-1;be?a=t:void 0!==me[t]&&(a=me[t]);a>=0&&Q>a&&M(a,e,t)&&(he[e]=a)});te&&(he[0]=Q-1)}else{var ye=n.differences.length>0||!!n.baseEncodingName,ke=c(H.cmap,i,this.isSymbolicFont,ye),we=ke.platformId,xe=ke.encodingId,Ce=ke.mappings,Se=Ce.length;if(ye&&(3===we&&1===xe||1===we&&0===xe)||-1===we&&-1===xe&&F(n.baseEncodingName)){var Ae=[];"MacRomanEncoding"!==n.baseEncodingName&&"WinAnsiEncoding"!==n.baseEncodingName||(Ae=F(n.baseEncodingName));var Ie=P();for(ce=0;256>ce;ce++){var Be,Re;Be=this.differences&&ce in this.differences?this.differences[ce]:ce in Ae&&""!==Ae[ce]?Ae[ce]:E[ce];if(Be){Re=d(Be,Ie);var Te,Oe=!1;if(3===we&&1===xe){Te=Ie[Re];Oe=!0}else 1===we&&0===xe&&(Te=D.indexOf(Re));var Pe=!1;for(X=0;Se>X;++X)if(Ce[X].charCode===Te){var Le=Oe?ce:Te;if(M(Ce[X].glyphId,Le,-1)){he[ce]=Ce[X].glyphId;Pe=!0;break}}if(!Pe&&n.glyphNames){var Me=n.glyphNames.indexOf(Be);-1===Me&&Re!==Be&&(Me=n.glyphNames.indexOf(Re));if(Me>0&&M(Me,-1,-1)){he[ce]=Me;Pe=!0}}Pe||(he[ce]=0)}}}else if(0===we&&0===xe)for(X=0;Se>X;++X)he[Ce[X].charCode]=Ce[X].glyphId;else for(X=0;Se>X;++X){ce=255&Ce[X].charCode;he[ce]=Ce[X].glyphId}}0===he.length&&(he[0]=0);var Ee=g(he,n);this.toFontChar=Ee.toFontChar;H.cmap={tag:"cmap",data:x(Ee.charCodeToGlyphId,Q)};H["OS/2"]&&R(H["OS/2"])||(H["OS/2"]={tag:"OS/2",data:T(n,Ee.charCodeToGlyphId,ne)});H.post||(H.post={tag:"post",data:W(n)});if(!J)try{U=new O(H["CFF "].data);var De=new K(U,n,oe);j=De.parse();var qe=new Y(j);H["CFF "].data=qe.compile()}catch(je){B("Failed to compile font "+n.loadedName)}if(H.name){var Fe=w(H.name);H.name.data=V(e,Fe)}else H.name={tag:"name",data:V(this.name)};var Ue=new de(_.version);for(var Ne in H)Ue.addTable(Ne,H[Ne].data);return Ue.toArray()},convert:function(e,t,a){function r(e,t){var a=null;for(var r in e)if(t===e[r]){a||(a=[]);a.push(0|r)}return a}function s(e,t){for(var a in e)if(t===e[a])return 0|a;c.charCodeToGlyphId[c.nextAvailableFontCharCode]=t;return c.nextAvailableFontCharCode++}a.fixedPitch=!1;var o=t.getGlyphMapping(a),c=g(o,a);this.toFontChar=c.toFontChar;var l=t.numGlyphs,h=t.seacs;if(oe&&h&&h.length){var u=a.fontMatrix||p,f=t.getCharset(),d=Object.create(null);for(var m in h){m|=0;var b=h[m],v=E[b[2]],y=E[b[3]],k=f.indexOf(v),w=f.indexOf(y);if(!(0>k||0>w)){var C={x:b[0]*u[0]+b[1]*u[2]+u[4],y:b[0]*u[1]+b[1]*u[3]+u[5]},S=r(o,m);if(S)for(var A=0,I=S.length;I>A;A++){var B=S[A],R=c.charCodeToGlyphId,O=s(R,k),P=s(R,w);d[B]={baseFontCharCode:O,accentFontCharCode:P,accentOffset:C}}}}a.seacMap=d}var L=1/(a.fontMatrix||p)[0],M=new de("OTTO");M.addTable("CFF ",t.data);M.addTable("OS/2",T(a,c.charCodeToGlyphId));M.addTable("cmap",x(c.charCodeToGlyphId,l));M.addTable("head","\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00_<õ\x00\x00"+n(L)+"\x00\x00\x00\x00ž\x0B~'\x00\x00\x00\x00ž\x0B~'\x00\x00"+n(a.descent)+"ÿ"+n(a.ascent)+i(a.italicAngle?2:0)+"\x00\x00\x00\x00\x00\x00\x00");M.addTable("hhea","\x00\x00\x00"+n(a.ascent)+n(a.descent)+"\x00\x00ÿÿ\x00\x00\x00\x00\x00\x00"+n(a.capHeight)+n(Math.tan(a.italicAngle)*a.xHeight)+"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"+i(l));M.addTable("hmtx",function(){for(var e=t.charstrings,a=t.cff?t.cff.widths:null,r="\x00\x00\x00\x00",n=1,s=l;s>n;n++){var o=0;if(e){var c=e[n-1];o="width"in c?c.width:0}else a&&(o=Math.ceil(a[n]||0));r+=i(o)+i(0)}return r}());M.addTable("maxp","\x00\x00P\x00"+i(l));M.addTable("name",V(e));M.addTable("post",W(a));return M.toArray()},get spaceWidth(){if("_shadowWidth"in this)return this._shadowWidth;for(var e,t=["space","minus","one","i","I"],a=0,r=t.length;r>a;a++){var i=t[a];if(i in this.widths){e=this.widths[i];break}var n=P(),s=n[i],o=0;this.composite&&this.cMap.contains(s)&&(o=this.cMap.lookup(s));!o&&this.toUnicode&&(o=this.toUnicode.charCodeOf(s));0>=o&&(o=s);e=this.widths[o];if(e)break}e=e||this.defaultWidth;this._shadowWidth=e;return e},charToGlyph:function(e,t){var a,r,i,n=e;this.cMap&&this.cMap.contains(e)&&(n=this.cMap.lookup(e));r=this.widths[n];r=C(r)?r:this.defaultWidth;var s=this.vmetrics&&this.vmetrics[n],o=this.toUnicode.get(e)||e;"number"==typeof o&&(o=String.fromCharCode(o));var c=e in this.toFontChar;a=this.toFontChar[e]||e;this.missingFile&&(a=G(a));this.isType3Font&&(i=a);var l=null;if(this.seacMap&&this.seacMap[e]){c=!0;var h=this.seacMap[e];a=h.baseFontCharCode;l={fontChar:String.fromCharCode(h.accentFontCharCode),offset:h.accentOffset}}var u=String.fromCharCode(a),f=this.glyphCache[e];if(!f||!f.matchesForCache(u,o,l,r,s,i,t,c)){f=new he(u,o,l,r,s,i,t,c);this.glyphCache[e]=f}return f},charsToGlyphs:function(e){var t,a,r,i=this.charsCache;if(i){t=i[e];if(t)return t}i||(i=this.charsCache=Object.create(null));t=[];var n,s=e,o=0;if(this.cMap)for(var c=Object.create(null);oo;++o){r=e.charCodeAt(o);a=this.charToGlyph(r,32===r);t.push(a)}return i[s]=t}};return e}(),me=function(){function e(e){this.error=e;this.loadedName="g_font_error";this.loading=!1}e.prototype={charsToGlyphs:function(){return[]},exportData:function(){return{error:this.error}}};return e}(),be=function(){function e(e,t,a){for(var r,i=e.length,n=t.length,s=i-n,o=a,c=!1;s>o;){r=0;for(;n>r&&e[o+r]===t[r];)r++;if(r>=n){o+=r;for(;i>o&&T(e[o]);)o++;c=!0;break}o++}return{found:c,length:o}}function t(t,a){var r,i,n,s=[101,101,120,101,99],o=t.pos;try{r=t.getBytes(a);i=r.length}catch(c){if(c instanceof R)throw c}if(i===a){n=e(r,s,a-2*s.length);if(n.found&&n.length===a)return{stream:new O(r),length:a}}B('Invalid "Length1" property in Type1 font -- trying to recover.');t.pos=o;for(var l,h=2048;;){var u=t.peekBytes(h);n=e(u,s,0);if(0===n.length)break;t.pos+=n.length;if(n.found){l=t.pos-o;break}}t.pos=o;if(l)return{stream:new O(t.getBytes(l)),length:l};B('Unable to recover "Length1" property in Type1 font -- using as is.');return{stream:new O(t.getBytes(a)),length:a}}function a(e,t){var a=e.getBytes();return{stream:new O(a),length:a.length}}function r(e,r,i){var n=6,s=i.length1,o=i.length2,c=r.peekBytes(n),l=128===c[0]&&1===c[1];if(l){r.skip(n);s=c[5]<<24|c[4]<<16|c[3]<<8|c[2]}var h=t(r,s);s=h.length;var u=new W(h.stream,!1,oe);u.extractFontHeader(i);if(l){c=r.getBytes(n);o=c[5]<<24|c[4]<<16|c[3]<<8|c[2]}var f=a(r,o);o=f.length;var d=new W(f.stream,!0,oe),g=d.extractFontProgram();for(var p in g.properties)i[p]=g.properties[p];var m=g.charstrings,b=this.getType2Charstrings(m),v=this.getType2Subrs(g.subrs);this.charstrings=m;this.data=this.wrap(e,b,this.charstrings,v,i);this.seacs=this.getSeacs(g.charstrings)}r.prototype={get numGlyphs(){return this.charstrings.length+1},getCharset:function(){for(var e=[".notdef"],t=this.charstrings,a=0;a=0&&(n[s]=t)}}return g(e,n,r)},getSeacs:function(e){var t,a,r=[];for(t=0,a=e.length;a>t;t++){var i=e[t];i.seac&&(r[t+1]=i.seac)}return r},getType2Charstrings:function(e){for(var t=[],a=0,r=e.length;r>a;a++)t.push(e[a].charstring);return t},getType2Subrs:function(e){var t=0,a=e.length;t=1133>a?107:33769>a?1131:32768;var r,i=[];for(r=0;t>r;r++)i.push([11]);for(r=0;a>r;r++)i.push(e[r]);return i},wrap:function(e,t,a,r,i){var n=new J;n.header=new Z(1,0,4,4);n.names=[e];var s=new Q;s.setByName("version",391);s.setByName("Notice",392);s.setByName("FullName",393);s.setByName("FamilyName",394);s.setByName("Weight",395);s.setByName("Encoding",null);s.setByName("FontMatrix",i.fontMatrix);s.setByName("FontBBox",i.bbox);s.setByName("charset",null);s.setByName("CharStrings",null);s.setByName("Private",null);n.topDict=s;var o=new ee;o.add("Version 0.11");o.add("See original notice");o.add(e);o.add(e);o.add("Medium");n.strings=o;n.globalSubrIndex=new te;var c,l,h=t.length,u=[0];for(c=0;h>c;c++){var f=V.indexOf(a[c].glyphName);-1===f&&(f=0);u.push(f>>8&255,255&f)}n.charset=new ae(!1,0,[],u);var d=new te;d.add([139,14]);for(c=0;h>c;c++)d.add(t[c]);n.charStrings=d;var g=new $;g.setByName("Subrs",null);var p=["BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StemSnapH","StemSnapV","BlueShift","BlueFuzz","BlueScale","LanguageGroup","ExpansionFactor","ForceBold","StdHW","StdVW"];for(c=0,l=p.length;l>c;c++){var m=p[c];if(m in i.privateData){var b=i.privateData[m];if(w(b))for(var v=b.length-1;v>0;v--)b[v]-=b[v-1];g.setByName(m,b)}}n.topDict.privateDict=g;var y=new te;for(c=0,l=r.length;l>c;c++)y.add(r[c]);g.subrsIndex=y;var k=new Y(n);return k.compile()}};return r}(),ve=function(){function e(e,t){this.properties=t;var a=new K(e,t,oe);this.cff=a.parse();var r=new Y(this.cff);this.seacs=this.cff.seacs;try{this.data=r.compile()}catch(i){B("Failed to compile font "+t.loadedName);this.data=e}}e.prototype={get numGlyphs(){return this.cff.charStrings.count},getCharset:function(){return this.cff.charset.charset},getGlyphMapping:function(){var e,t,a=this.cff,r=this.properties,i=a.charset.charset;if(r.composite){e=Object.create(null);if(a.isCIDFont)for(t=0;tt)return n;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(!i(t))break;t=this.nextChar()}switch(0|t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return new c(o.NUMBER,this.getNumber());case 123:this.nextChar();return c.LBRACE;case 125:this.nextChar();return c.RBRACE}var a=this.strBuf;a.length=0;a[0]=String.fromCharCode(t);for(;(t=this.nextChar())>=0&&(t>=65&&90>=t||t>=97&&122>=t);)a.push(String.fromCharCode(t));var r=a.join("");switch(r.toLowerCase()){case"if":return c.IF;case"ifelse":return c.IFELSE;default:return c.getOperator(r)}},getNumber:function(){var e=this.currentChar,t=this.strBuf;t.length=0;t[0]=String.fromCharCode(e);for(;(e=this.nextChar())>=0&&(e>=48&&57>=e||45===e||46===e);)t.push(String.fromCharCode(e));var a=parseFloat(t.join(""));isNaN(a)&&r("Invalid floating point number: "+a);return a}};return e}();e.PostScriptLexer=l;e.PostScriptParser=s});!function(e,t){t(e.pdfjsCoreFunction={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCorePsParser)}(this,function(e,t,a,r){function i(e){var t;if("object"!=typeof e)return!1;if(l(e))t=e;else{if(!h(e))return!1;t=e.dict}return t.has("FunctionType")}var n=t.error,s=t.info,o=t.isArray,c=t.isBool,l=a.isDict,h=a.isStream,u=r.PostScriptLexer,f=r.PostScriptParser,d=function(){var e=0,t=2,a=3,r=4;return{getSampleArray:function(e,t,a,r){var i,n,s=1;for(i=0,n=e.length;n>i;i++)s*=e[i];s*=t;var o=new Array(s),c=0,l=0,h=1/(Math.pow(2,a)-1),u=r.getBytes((s*a+7)/8),f=0;for(i=0;s>i;i++){for(;a>c;){l<<=8;l|=u[f++];c+=8}c-=a;o[i]=(l>>c)*h;l&=(1<r;r++){var n=e.fetchIfRef(t[r]);a.push(d.parse(e,n))}return function(e,t,r,i){for(var n=0,s=a.length;s>n;n++)a[n](e,t,r,i+n)}},constructSampled:function(t,a){function r(e){for(var t=e.length,a=[],r=0,i=0;t>i;i+=2){a[r]=[e[i],e[i+1]];++r}return a}var i=a.getArray("Domain"),o=a.getArray("Range");i&&o||n("No domain or range");var c=i.length/2,l=o.length/2;i=r(i);o=r(o);var h=a.get("Size"),u=a.get("BitsPerSample"),f=a.get("Order")||1;1!==f&&s("No support for cubic spline interpolation: "+f);var d=a.getArray("Encode");if(!d){d=[];for(var g=0;c>g;++g){d.push(0);d.push(h[g]-1)}}d=r(d);var p=a.getArray("Decode");p=p?r(p):o;var m=this.getSampleArray(h,l,u,t);return[e,c,i,d,p,m,h,l,Math.pow(2,u)-1,o]},constructSampledFromIR:function(e){function t(e,t,a,r,i){return r+(e-t)*((i-r)/(a-t))}return function(a,r,i,n){var s,o,c=e[1],l=e[2],h=e[3],u=e[4],f=e[5],d=e[6],g=e[7],p=e[9],m=1<o;o++)b[o]=1;var y=g,k=1;for(s=0;c>s;++s){var w=l[s][0],x=l[s][1],C=Math.min(Math.max(a[r+s],w),x),S=t(C,w,x,h[s][0],h[s][1]),A=d[s];S=Math.min(Math.max(S,0),A-1);var I=A-1>S?Math.floor(S):S-1,B=I+1-S,R=S-I,T=I*y,O=T+y;for(o=0;m>o;o++)if(o&k){b[o]*=R;v[o]+=O}else{b[o]*=B;v[o]+=T}y*=A;k<<=1}for(o=0;g>o;++o){var P=0;for(s=0;m>s;s++)P+=f[v[s]+o]*b[s];P=t(P,0,1,u[o][0],u[o][1]);i[n+o]=Math.min(Math.max(P,p[o][0]),p[o][1])}}},constructInterpolated:function(e,a){var r=a.getArray("C0")||[0],i=a.getArray("C1")||[1],s=a.get("N");o(r)&&o(i)||n("Illegal dictionary for interpolated function");for(var c=r.length,l=[],h=0;c>h;++h)l.push(i[h]-r[h]);return[t,r,l,s]},constructInterpolatedFromIR:function(e){var t=e[1],a=e[2],r=e[3],i=a.length;return function(e,n,s,o){for(var c=1===r?e[n]:Math.pow(e[n],r),l=0;i>l;++l)s[o+l]=t[l]+c*a[l]}},constructStiched:function(e,t,r){var i=t.getArray("Domain");i||n("No domain");var s=i.length/2;1!==s&&n("Bad domain for stiched function");for(var o=t.get("Functions"),c=[],l=0,h=o.length;h>l;++l)c.push(d.getIR(r,r.fetchIfRef(o[l])));var u=t.getArray("Bounds"),f=t.getArray("Encode");return[a,i,u,f,c]},constructStichedFromIR:function(e){for(var t=e[1],a=e[2],r=e[3],i=e[4],n=[],s=new Float32Array(1),o=0,c=i.length;c>o;o++)n.push(d.fromIR(i[o]));return function(e,i,o,c){for(var l=function(e,t,a){e>a?e=a:t>e&&(e=t);return e},h=l(e[i],t[0],t[1]),u=0,f=a.length;f>u&&!(h0&&(d=a[u-1]);var g=t[1];u>1,o=t.length>>1,c=new p(r),l=Object.create(null),h=8192,u=h,f=new Float32Array(o);return function(e,t,r,i){var s,h,d="",g=f;for(s=0;o>s;s++){h=e[t+s];g[s]=h;d+=h+"_"}var p=l[d];if(void 0===p){var m=new Float32Array(n),b=c.execute(g),v=b.length-n;for(s=0;n>s;s++){h=b[v+s];var y=a[2*s];if(y>h)h=y;else{y=a[2*s+1];h>y&&(h=y)}m[s]=h}if(u>0){u--;l[d]=m}r.set(m,i)}else r.set(p,i)}}}}(),g=function(){function e(e){this.stack=e?Array.prototype.slice.call(e,0):[]}var t=100;e.prototype={push:function(e){this.stack.length>=t&&n("PostScript function stack overflow.");this.stack.push(e)},pop:function(){this.stack.length<=0&&n("PostScript function stack underflow.");return this.stack.pop()},copy:function(e){this.stack.length+e>=t&&n("PostScript function stack overflow.");for(var a=this.stack,r=a.length-e,i=e-1;i>=0;i--,r++)a.push(a[r])},index:function(e){this.push(this.stack[this.stack.length-e-1])},roll:function(e,t){var a,r,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(a=s,r=o;r>a;a++,r--){i=n[a];n[a]=n[r];n[r]=i}for(a=s,r=c-1;r>a;a++,r--){i=n[a];n[a]=n[r];n[r]=i}for(a=c,r=o;r>a;a++,r--){i=n[a];n[a]=n[r];n[r]=i}}};return e}(),p=function(){function e(e){this.operators=e}e.prototype={execute:function(e){for(var t,a,r,i=new g(e),s=0,o=this.operators,l=o.length;l>s;){t=o[s++];if("number"!=typeof t)switch(t){case"jz":r=i.pop();a=i.pop();a||(s=r);break;case"j":a=i.pop();s=a;break;case"abs":a=i.pop();i.push(Math.abs(a));break;case"add":r=i.pop();a=i.pop();i.push(a+r);break;case"and":r=i.pop();a=i.pop();c(a)&&c(r)?i.push(a&&r):i.push(a&r);break;case"atan":a=i.pop();i.push(Math.atan(a));break;case"bitshift":r=i.pop();a=i.pop();a>0?i.push(a<>r);break;case"ceiling":a=i.pop();i.push(Math.ceil(a));break;case"copy":a=i.pop();i.copy(a);break;case"cos":a=i.pop();i.push(Math.cos(a));break;case"cvi":a=0|i.pop();i.push(a);break;case"cvr":break;case"div":r=i.pop();a=i.pop();i.push(a/r);break;case"dup":i.copy(1);break;case"eq":r=i.pop();a=i.pop();i.push(a===r);break;case"exch":i.roll(2,1);break;case"exp":r=i.pop();a=i.pop();i.push(Math.pow(a,r));break;case"false":i.push(!1);break;case"floor":a=i.pop();i.push(Math.floor(a));break;case"ge":r=i.pop();a=i.pop();i.push(a>=r);break;case"gt":r=i.pop();a=i.pop();i.push(a>r);break;case"idiv":r=i.pop();a=i.pop();i.push(a/r|0);break;case"index":a=i.pop();i.index(a);break;case"le":r=i.pop();a=i.pop();i.push(r>=a);break;case"ln":a=i.pop();i.push(Math.log(a));break;case"log":a=i.pop();i.push(Math.log(a)/Math.LN10); +break;case"lt":r=i.pop();a=i.pop();i.push(r>a);break;case"mod":r=i.pop();a=i.pop();i.push(a%r);break;case"mul":r=i.pop();a=i.pop();i.push(a*r);break;case"ne":r=i.pop();a=i.pop();i.push(a!==r);break;case"neg":a=i.pop();i.push(-a);break;case"not":a=i.pop();c(a)?i.push(!a):i.push(~a);break;case"or":r=i.pop();a=i.pop();c(a)&&c(r)?i.push(a||r):i.push(a|r);break;case"pop":i.pop();break;case"roll":r=i.pop();a=i.pop();i.roll(a,r);break;case"round":a=i.pop();i.push(Math.round(a));break;case"sin":a=i.pop();i.push(Math.sin(a));break;case"sqrt":a=i.pop();i.push(Math.sqrt(a));break;case"sub":r=i.pop();a=i.pop();i.push(a-r);break;case"true":i.push(!0);break;case"truncate":a=i.pop();a=0>a?Math.ceil(a):Math.floor(a);i.push(a);break;case"xor":r=i.pop();a=i.pop();c(a)&&c(r)?i.push(a!==r):i.push(a^r);break;default:n("Unknown operator "+t)}else i.push(t)}return i.stack}};return e}(),m=function(){function e(e){this.type=e}function t(t,a,r){e.call(this,"args");this.index=t;this.min=a;this.max=r}function a(t){e.call(this,"literal");this.number=t;this.min=t;this.max=t}function r(t,a,r,i,n){e.call(this,"binary");this.op=t;this.arg1=a;this.arg2=r;this.min=i;this.max=n}function i(t,a){e.call(this,"max");this.arg=t;this.min=t.min;this.max=a}function n(t,a,r){e.call(this,"var");this.index=t;this.min=a;this.max=r}function s(t,a){e.call(this,"definition");this.variable=t;this.arg=a}function o(){this.parts=[]}function c(e,t){return"literal"===t.type&&0===t.number?e:"literal"===e.type&&0===e.number?t:"literal"===t.type&&"literal"===e.type?new a(e.number+t.number):new r("+",e,t,e.min+t.min,e.max+t.max)}function l(e,t){if("literal"===t.type){if(0===t.number)return new a(0);if(1===t.number)return e;if("literal"===e.type)return new a(e.number*t.number)}if("literal"===e.type){if(0===e.number)return new a(0);if(1===e.number)return t}var i=Math.min(e.min*t.min,e.min*t.max,e.max*t.min,e.max*t.max),n=Math.max(e.min*t.min,e.min*t.max,e.max*t.min,e.max*t.max);return new r("*",e,t,i,n)}function h(e,t){if("literal"===t.type){if(0===t.number)return e;if("literal"===e.type)return new a(e.number-t.number)}return"binary"===t.type&&"-"===t.op&&"literal"===e.type&&1===e.number&&"literal"===t.arg1.type&&1===t.arg1.number?t.arg2:new r("-",e,t,e.min-t.max,e.max-t.min)}function u(e,t){return e.min>=t?new a(t):e.max<=t?e:new i(e,t)}function f(){}e.prototype.visit=function(e){throw new Error("abstract method")};t.prototype=Object.create(e.prototype);t.prototype.visit=function(e){e.visitArgument(this)};a.prototype=Object.create(e.prototype);a.prototype.visit=function(e){e.visitLiteral(this)};r.prototype=Object.create(e.prototype);r.prototype.visit=function(e){e.visitBinaryOperation(this)};i.prototype=Object.create(e.prototype);i.prototype.visit=function(e){e.visitMin(this)};n.prototype=Object.create(e.prototype);n.prototype.visit=function(e){e.visitVariable(this)};s.prototype=Object.create(e.prototype);s.prototype.visit=function(e){e.visitVariableDefinition(this)};o.prototype={visitArgument:function(e){this.parts.push("Math.max(",e.min,", Math.min(",e.max,", src[srcOffset + ",e.index,"]))")},visitVariable:function(e){this.parts.push("v",e.index)},visitLiteral:function(e){this.parts.push(e.number)},visitBinaryOperation:function(e){this.parts.push("(");e.arg1.visit(this);this.parts.push(" ",e.op," ");e.arg2.visit(this);this.parts.push(")")},visitVariableDefinition:function(e){this.parts.push("var ");e.variable.visit(this);this.parts.push(" = ");e.arg.visit(this);this.parts.push(";")},visitMin:function(e){this.parts.push("Math.min(");e.arg.visit(this);this.parts.push(", ",e.max,")")},toString:function(){return this.parts.join("")}};f.prototype={compile:function(e,r,i){var f,d,g,p,m,b,v,y,k,w,x=[],C=[],S=r.length>>1,A=i.length>>1,I=0;for(f=0;S>f;f++)x.push(new t(f,r[2*f],r[2*f+1]));for(f=0,d=e.length;d>f;f++){w=e[f];if("number"!=typeof w)switch(w){case"add":if(x.length<2)return null;b=x.pop();m=x.pop();x.push(c(m,b));break;case"cvr":if(x.length<1)return null;break;case"mul":if(x.length<2)return null;b=x.pop();m=x.pop();x.push(l(m,b));break;case"sub":if(x.length<2)return null;b=x.pop();m=x.pop();x.push(h(m,b));break;case"exch":if(x.length<2)return null;v=x.pop();y=x.pop();x.push(v,y);break;case"pop":if(x.length<1)return null;x.pop();break;case"index":if(x.length<1)return null;m=x.pop();if("literal"!==m.type)return null;g=m.number;if(0>g||(0|g)!==g||x.length=g||(0|g)!==g||(0|p)!==p||x.lengthe.min){s.unshift("Math.max(",r,", ");s.push(")")}if(nl;l++)m[l]=Math.floor(l*d)*c;for(l=0;n>l;l++){u=Math.floor(l*g)*b;for(h=0;i>h;h++){f=u+m[h];o[p++]=e[f++];o[p++]=e[f++];o[p++]=e[f++];p+=s}}}function t(){i("should not call ColorSpace constructor")}t.prototype={getRgb:function(e,t){var a=new Uint8Array(3);this.getRgbItem(e,t,a,0);return a},getRgbItem:function(e,t,a,r){i("Should not call ColorSpace.getRgbItem")},getRgbBuffer:function(e,t,a,r,n,s,o){i("Should not call ColorSpace.getRgbBuffer")},getOutputLength:function(e,t){i("Should not call ColorSpace.getOutputLength")},isPassthrough:function(e){return!1},fillRgb:function(t,a,r,i,n,s,o,c,l){var h,u,f=a*r,d=null,g=1<g&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){var m,b=8>=o?new Uint8Array(g):new Uint16Array(g);for(h=0;g>h;h++)b[h]=h;var v=new Uint8Array(3*g);this.getRgbBuffer(b,0,g,v,0,o,0);var y,k;if(p){d=new Uint8Array(3*f);k=0;for(h=0;f>h;++h){m=3*c[h];d[k++]=v[m];d[k++]=v[m+1];d[k++]=v[m+2]}}else{y=0;for(h=0;f>h;++h){m=3*c[h];t[y++]=v[m];t[y++]=v[m+1];t[y++]=v[m+2];y+=l}}}else if(p){d=new Uint8Array(3*f);this.getRgbBuffer(c,0,f,d,0,o,0)}else this.getRgbBuffer(c,0,i*s,t,0,o,l);if(d)if(p)e(d,o,a,r,i,n,l,t);else{k=0;y=0;for(h=0,u=i*s;u>h;h++){t[y++]=d[k++];t[y++]=d[k++];t[y++]=d[k++];y+=l}}},usesZeroToOneRange:!0};t.parse=function(e,a,r){var i=t.parseToIR(e,a,r);return i instanceof p?i:t.fromIR(i)};t.fromIR=function(e){var a,r,n,o=s(e)?e[0]:e;switch(o){case"DeviceGrayCS":return this.singletons.gray;case"DeviceRgbCS":return this.singletons.rgb;case"DeviceCmykCS":return this.singletons.cmyk;case"CalGrayCS":a=e[1];r=e[2];n=e[3];return new w(a,r,n);case"CalRGBCS":a=e[1];r=e[2];n=e[3];var c=e[4];return new x(a,r,n,c);case"PatternCS":var l=e[1];l&&(l=t.fromIR(l));return new m(l);case"IndexedCS":var h=e[1],u=e[2],f=e[3];return new b(t.fromIR(h),u,f);case"AlternateCS":var g=e[1],v=e[2],y=e[3];return new p(g,t.fromIR(v),d.fromIR(y));case"LabCS":a=e[1];r=e[2];var k=e[3];return new C(a,r,k);default:i("Unknown name "+o)}return null};t.parseToIR=function(e,a,r){if(u(e)){var n=r.get("ColorSpace");if(h(n)){var o=n.get(e.name);o&&(e=o)}}e=a.fetchIfRef(e);var c;if(u(e)){c=e.name;this.mode=c;switch(c){case"DeviceGray":case"G":return"DeviceGrayCS";case"DeviceRGB":case"RGB":return"DeviceRgbCS";case"DeviceCMYK":case"CMYK":return"DeviceCmykCS";case"Pattern":return["PatternCS",null];default:i("unrecognized colorspace "+c)}}else if(s(e)){c=a.fetchIfRef(e[0]).name;this.mode=c;var g,p,m,b,v,y;switch(c){case"DeviceGray":case"G":return"DeviceGrayCS";case"DeviceRGB":case"RGB":return"DeviceRgbCS";case"DeviceCMYK":case"CMYK":return"DeviceCmykCS";case"CalGray":p=a.fetchIfRef(e[1]);b=p.getArray("WhitePoint");v=p.getArray("BlackPoint");y=p.get("Gamma");return["CalGrayCS",b,v,y];case"CalRGB":p=a.fetchIfRef(e[1]);b=p.getArray("WhitePoint");v=p.getArray("BlackPoint");y=p.getArray("Gamma");var k=p.getArray("Matrix");return["CalRGBCS",b,v,y,k];case"ICCBased":var w=a.fetchIfRef(e[1]),x=w.dict;g=x.get("N");m=x.get("Alternate");if(m){var C=t.parseToIR(m,a,r),S=t.fromIR(C);if(S.numComps===g)return C;l("ICCBased color space: Ignoring incorrect /Alternate entry.")}if(1===g)return"DeviceGrayCS";if(3===g)return"DeviceRgbCS";if(4===g)return"DeviceCmykCS";break;case"Pattern":var A=e[1]||null;A&&(A=t.parseToIR(A,a,r));return["PatternCS",A];case"Indexed":case"I":var I=t.parseToIR(e[1],a,r),B=a.fetchIfRef(e[2])+1,R=a.fetchIfRef(e[3]);f(R)&&(R=R.getBytes());return["IndexedCS",I,B,R];case"Separation":case"DeviceN":var T=a.fetchIfRef(e[1]);g=1;u(T)?g=1:s(T)&&(g=T.length);m=t.parseToIR(e[2],a,r);var O=d.getIR(a,a.fetchIfRef(e[3]));return["AlternateCS",g,m,O];case"Lab":p=a.fetchIfRef(e[1]);b=p.getArray("WhitePoint");v=p.getArray("BlackPoint");var P=p.getArray("Range");return["LabCS",b,v,P];default:i('unimplemented color space object "'+c+'"')}}else i('unrecognized color space object: "'+e+'"');return null};t.isDefaultDecode=function(e,t){if(!s(e))return!0;if(2*t!==e.length){l("The decode map is not the correct length");return!0}for(var a=0,r=e.length;r>a;a+=2)if(0!==e[a]||1!==e[a+1])return!1;return!0};t.singletons={get gray(){return c(this,"gray",new v)},get rgb(){return c(this,"rgb",new y)},get cmyk(){return c(this,"cmyk",new k)}};return t}(),p=function(){function e(e,t,a){this.name="Alternate";this.numComps=e;this.defaultColor=new Float32Array(e);for(var r=0;e>r;++r)this.defaultColor[r]=1;this.base=t;this.tintFn=a;this.tmpBuf=new Float32Array(t.numComps)}e.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(e,t,a,r){var i=this.tmpBuf;this.tintFn(e,t,i,0);this.base.getRgbItem(i,0,a,r)},getRgbBuffer:function(e,t,a,r,i,n,s){var o,c,l=this.tintFn,h=this.base,u=1/((1<o;o++){for(c=0;b>c;c++)v[c]=e[t++]*u;l(v,0,y,0);for(c=0;f>c;c++)m[p++]=255*y[c]}else for(o=0;a>o;o++){for(c=0;b>c;c++)v[c]=e[t++]*u;l(v,0,y,0);h.getRgbItem(y,0,m,p);p+=f}g||h.getRgbBuffer(m,0,a,r,i,8,s)},getOutputLength:function(e,t){return this.base.getOutputLength(e*this.base.numComps/this.numComps,t)},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return g.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0};return e}(),m=function(){function e(e){this.name="Pattern";this.base=e}e.prototype={};return e}(),b=function(){function e(e,t,a){this.name="Indexed";this.numComps=1;this.defaultColor=new Uint8Array([0]);this.base=e;this.highVal=t;var r,n=e.numComps,s=n*t;if(f(a)){r=new Uint8Array(s);var c=a.getBytes(s);r.set(c)}else if(o(a)){r=new Uint8Array(s);for(var l=0;s>l;++l)r[l]=a.charCodeAt(l)}else a instanceof Uint8Array||a instanceof Array?r=a:i("Unrecognized lookup table: "+a);this.lookup=r}e.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(e,t,a,r){var i=this.base.numComps,n=e[t]*i;this.base.getRgbItem(this.lookup,n,a,r)},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=this.base,c=o.numComps,l=o.getOutputLength(c,s),h=this.lookup,u=0;a>u;++u){var f=e[t++]*c;o.getRgbBuffer(h,f,1,r,i,8,s);i+=l}},getOutputLength:function(e,t){return this.base.getOutputLength(e*this.base.numComps,t)},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return!0},usesZeroToOneRange:!0};return e}(),v=function(){function e(){this.name="DeviceGray";this.numComps=1;this.defaultColor=new Float32Array([0])}e.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(e,t,a,r){var i=255*e[t]|0;i=0>i?0:i>255?255:i;a[r]=a[r+1]=a[r+2]=i},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=255/((1<h;++h){var u=o*e[c++]|0;r[l++]=u;r[l++]=u;r[l++]=u;l+=s}},getOutputLength:function(e,t){return e*(3+t)},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return g.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0};return e}(),y=function(){function e(){this.name="DeviceRGB";this.numComps=3;this.defaultColor=new Float32Array([0,0,0])}e.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(e,t,a,r){var i=255*e[t]|0,n=255*e[t+1]|0,s=255*e[t+2]|0;a[r]=0>i?0:i>255?255:i;a[r+1]=0>n?0:n>255?255:n;a[r+2]=0>s?0:s>255?255:s},getRgbBuffer:function(e,t,a,r,i,n,s){if(8!==n||0!==s)for(var o=255/((1<h;++h){r[l++]=o*e[c++]|0;r[l++]=o*e[c++]|0;r[l++]=o*e[c++]|0;l+=s}else r.set(e.subarray(t,t+3*a),i)},getOutputLength:function(e,t){return e*(3+t)/3|0},isPassthrough:function(e){return 8===e},fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return g.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0};return e}(),k=function(){function e(e,t,a,r,i){var n=e[t+0]*a,s=e[t+1]*a,o=e[t+2]*a,c=e[t+3]*a,l=n*(-4.387332384609988*n+54.48615194189176*s+18.82290502165302*o+212.25662451639585*c+-285.2331026137004)+s*(1.7149763477362134*s-5.6096736904047315*o+-17.873870861415444*c-5.497006427196366)+o*(-2.5217340131683033*o-21.248923337353073*c+17.5119270841813)+c*(-21.86122147463605*c-189.48180835922747)+255|0,h=n*(8.841041422036149*n+60.118027045597366*s+6.871425592049007*o+31.159100130055922*c+-79.2970844816548)+s*(-15.310361306967817*s+17.575251261109482*o+131.35250912493976*c-190.9453302588951)+o*(4.444339102852739*o+9.8632861493405*c-24.86741582555878)+c*(-20.737325471181034*c-187.80453709719578)+255|0,u=n*(.8842522430003296*n+8.078677503112928*s+30.89978309703729*o-.23883238689178934*c+-14.183576799673286)+s*(10.49593273432072*s+63.02378494754052*o+50.606957656360734*c-112.23884253719248)+o*(.03296041114873217*o+115.60384449646641*c+-193.58209356861505)+c*(-22.33816807309886*c-180.12613974708367)+255|0;r[i]=l>255?255:0>l?0:l;r[i+1]=h>255?255:0>h?0:h;r[i+2]=u>255?255:0>u?0:u}function t(){this.name="DeviceCMYK";this.numComps=4;this.defaultColor=new Float32Array([0,0,0,1])}t.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(t,a,r,i){e(t,a,1,r,i)},getRgbBuffer:function(t,a,r,i,n,s,o){for(var c=1/((1<l;l++){e(t,a,c,i,n);a+=4;n+=3+o}},getOutputLength:function(e,t){return e/4*(3+t)|0},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return g.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0};return t}(),w=function(){function e(e,t,a){this.name="CalGray";this.numComps=1;this.defaultColor=new Float32Array([0]);e||i("WhitePoint missing - required for color space CalGray");t=t||[0,0,0];a=a||1;this.XW=e[0];this.YW=e[1];this.ZW=e[2];this.XB=t[0];this.YB=t[1];this.ZB=t[2];this.G=a;(this.XW<0||this.ZW<0||1!==this.YW)&&i("Invalid WhitePoint components for "+this.name+", no fallback available");if(this.XB<0||this.YB<0||this.ZB<0){n("Invalid BlackPoint for "+this.name+", falling back to default");this.XB=this.YB=this.ZB=0}0===this.XB&&0===this.YB&&0===this.ZB||l(this.name+", BlackPoint: XB: "+this.XB+", YB: "+this.YB+", ZB: "+this.ZB+", only default values are supported.");if(this.G<1){n("Invalid Gamma: "+this.G+" for "+this.name+", falling back to default");this.G=1}}function t(e,t,a,r,i,n){var s=t[a]*n,o=Math.pow(s,e.G),c=e.YW*o,l=0|Math.max(295.8*Math.pow(c,.3333333333333333)-40.8,0);r[i]=l;r[i+1]=l;r[i+2]=l}e.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(e,a,r,i){t(this,e,a,r,i,1)},getRgbBuffer:function(e,a,r,i,n,s,o){for(var c=1/((1<l;++l){t(this,e,a,i,n,c);a+=1;n+=3+o}},getOutputLength:function(e,t){return e*(3+t)},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return g.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0};return e}(),x=function(){function e(e,t,a,r){this.name="CalRGB";this.numComps=3;this.defaultColor=new Float32Array(3);e||i("WhitePoint missing - required for color space CalRGB");t=t||new Float32Array(3);a=a||new Float32Array([1,1,1]);r=r||new Float32Array([1,0,0,0,1,0,0,0,1]);var s=e[0],o=e[1],c=e[2];this.whitePoint=e;var l=t[0],h=t[1],u=t[2];this.blackPoint=t;this.GR=a[0];this.GG=a[1];this.GB=a[2];this.MXA=r[0];this.MYA=r[1];this.MZA=r[2];this.MXB=r[3];this.MYB=r[4];this.MZB=r[5];this.MXC=r[6];this.MYC=r[7];this.MZC=r[8];(0>s||0>c||1!==o)&&i("Invalid WhitePoint components for "+this.name+", no fallback available");if(0>l||0>h||0>u){n("Invalid BlackPoint for "+this.name+" ["+l+", "+h+", "+u+"], falling back to default");this.blackPoint=new Float32Array(3)}if(this.GR<0||this.GG<0||this.GB<0){n("Invalid Gamma ["+this.GR+", "+this.GG+", "+this.GB+"] for "+this.name+", falling back to default");this.GR=this.GG=this.GB=1}if(this.MXA<0||this.MYA<0||this.MZA<0||this.MXB<0||this.MYB<0||this.MZB<0||this.MXC<0||this.MYC<0||this.MZC<0){n("Invalid Matrix for "+this.name+" ["+this.MXA+", "+this.MYA+", "+this.MZA+this.MXB+", "+this.MYB+", "+this.MZB+this.MXC+", "+this.MYC+", "+this.MZC+"], falling back to default");this.MXA=this.MYB=this.MZC=1;this.MXB=this.MYA=this.MZA=this.MXC=this.MYC=this.MZB=0}}function t(e,t,a){a[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];a[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2];a[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}function a(e,t,a){a[0]=1*t[0]/e[0];a[1]=1*t[1]/e[1];a[2]=1*t[2]/e[2]}function r(e,t,a){var r=.95047,i=1,n=1.08883;a[0]=t[0]*r/e[0];a[1]=t[1]*i/e[1];a[2]=t[2]*n/e[2]}function s(e){return.0031308>=e?o(0,1,12.92*e):o(0,1,1.055*Math.pow(e,1/2.4)-.055)}function o(e,t,a){return Math.max(e,Math.min(t,a))}function c(e){return 0>e?-c(-e):e>8?Math.pow((e+16)/116,3):e*w}function l(e,t,a){if(0!==e[0]||0!==e[1]||0!==e[2]){var r=c(0),i=r,n=c(e[0]),s=r,o=c(e[1]),l=r,h=c(e[2]),u=(1-i)/(1-n),f=1-u,d=(1-s)/(1-o),g=1-d,p=(1-l)/(1-h),m=1-p;a[0]=t[0]*u+f;a[1]=t[1]*d+g;a[2]=t[2]*p+m}else{a[0]=t[0];a[1]=t[1];a[2]=t[2]}}function h(e,r,i){if(1!==e[0]||1!==e[2]){var n=i;t(d,r,n);var s=v;a(e,n,s);t(p,s,i)}else{i[0]=r[0];i[1]=r[1];i[2]=r[2]}}function u(e,a,i){var n=i;t(d,a,n);var s=v;r(e,n,s);t(p,s,i)}function f(e,a,r,i,n,c){var f=o(0,1,a[r]*c),d=o(0,1,a[r+1]*c),g=o(0,1,a[r+2]*c),p=Math.pow(f,e.GR),v=Math.pow(d,e.GG),w=Math.pow(g,e.GB),x=e.MXA*p+e.MXB*v+e.MXC*w,C=e.MYA*p+e.MYB*v+e.MYC*w,S=e.MZA*p+e.MZB*v+e.MZC*w,A=y;A[0]=x;A[1]=C;A[2]=S;var I=k;h(e.whitePoint,A,I);var B=y;l(e.blackPoint,I,B);var R=k;u(b,B,R);var T=y;t(m,R,T);var O=s(T[0]),P=s(T[1]),L=s(T[2]);i[n]=Math.round(255*O);i[n+1]=Math.round(255*P);i[n+2]=Math.round(255*L)}var d=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),p=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),m=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]),b=new Float32Array([1,1,1]),v=new Float32Array(3),y=new Float32Array(3),k=new Float32Array(3),w=Math.pow(24/116,3)/8;e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);this.getRgbItem(e,t,a,0);return a},getRgbItem:function(e,t,a,r){f(this,e,t,a,r,1)},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=1/((1<c;++c){f(this,e,t,r,i,o);t+=3;i+=3+s}},getOutputLength:function(e,t){return e*(3+t)/3|0},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return g.isDefaultDecode(e,this.numComps)},usesZeroToOneRange:!0};return e}(),C=function(){function e(e,t,a){this.name="Lab";this.numComps=3;this.defaultColor=new Float32Array([0,0,0]);e||i("WhitePoint missing - required for color space Lab");t=t||[0,0,0];a=a||[-100,100,-100,100];this.XW=e[0];this.YW=e[1];this.ZW=e[2];this.amin=a[0];this.amax=a[1];this.bmin=a[2];this.bmax=a[3];this.XB=t[0];this.YB=t[1];this.ZB=t[2];(this.XW<0||this.ZW<0||1!==this.YW)&&i("Invalid WhitePoint components, no fallback available");if(this.XB<0||this.YB<0||this.ZB<0){n("Invalid BlackPoint, falling back to default");this.XB=this.YB=this.ZB=0}if(this.amin>this.amax||this.bmin>this.bmax){n("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}function t(e){return e>=6/29?e*e*e:108/841*(e-4/29)}function a(e,t,a,r){return a+e*(r-a)/t}function r(e,r,i,n,s,o){var c=r[i],l=r[i+1],h=r[i+2];if(n!==!1){c=a(c,n,0,100);l=a(l,n,e.amin,e.amax);h=a(h,n,e.bmin,e.bmax)}l=l>e.amax?e.amax:le.bmax?e.bmax:h=u?0:u>=1?255:255*Math.sqrt(u)|0;s[o+1]=0>=f?0:f>=1?255:255*Math.sqrt(f)|0;s[o+2]=0>=d?0:d>=1?255:255*Math.sqrt(d)|0}e.prototype={getRgb:g.prototype.getRgb,getRgbItem:function(e,t,a,i){r(this,e,t,!1,a,i)},getRgbBuffer:function(e,t,a,i,n,s,o){for(var c=(1<l;l++){r(this,e,t,c,i,n);t+=3;n+=3+o}},getOutputLength:function(e,t){return e*(3+t)/3|0},isPassthrough:g.prototype.isPassthrough,fillRgb:g.prototype.fillRgb,isDefaultDecode:function(e){return!0},usesZeroToOneRange:!1};return e}();e.ColorSpace=g});!function(e,t){t(e.pdfjsCoreImage={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreColorSpace,e.pdfjsCoreStream,e.pdfjsCoreJpx)}(this,function(e,t,a,r,i,n){var s=t.ImageKind,o=t.assert,c=t.error,l=t.info,h=t.isArray,u=t.warn,f=a.Name,d=a.isStream,g=r.ColorSpace,p=i.DecodeStream,m=i.JpegStream,b=n.JpxImage,v=function(){function e(e,t){return t&&t.canDecode(e)?t.decode(e):Promise.resolve(e)}function t(e,t,a,r){e=t+e*a;return 0>e?0:e>r?r:e}function a(e,t,a,r,i,n){var s,o,c,l,h=i*n,u=8>=t?new Uint8Array(h):16>=t?new Uint16Array(h):new Uint32Array(h),f=a/i,d=r/n,g=0,p=new Uint16Array(i),m=a;for(s=0;i>s;s++)p[s]=Math.floor(s*f);for(s=0;n>s;s++){c=Math.floor(s*d)*m;for(o=0;i>o;o++){l=c+p[o];u[g++]=e[l]}}return u}function r(e,t,a,i,n,s,o){this.image=a;var h=a.dict;if(h.has("Filter")){var p=h.get("Filter").name;if("JPXDecode"===p){var m=new b;m.parseImageProperties(a.stream);a.stream.reset();a.bitsPerComponent=m.bitsPerComponent;a.numComps=m.componentsCount}else if("JBIG2Decode"===p){a.bitsPerComponent=1;a.numComps=1}}this.width=h.get("Width","W");this.height=h.get("Height","H");(this.width<1||this.height<1)&&c("Invalid image width: "+this.width+" or height: "+this.height);this.interpolate=h.get("Interpolate","I")||!1;this.imageMask=h.get("ImageMask","IM")||!1;this.matte=h.get("Matte")||!1;var v=a.bitsPerComponent;if(!v){v=h.get("BitsPerComponent","BPC");v||(this.imageMask?v=1:c("Bits per component missing in image: "+this.imageMask))}this.bpc=v;if(!this.imageMask){var y=h.get("ColorSpace","CS");if(!y){l("JPX images (which do not require color spaces)");switch(a.numComps){case 1:y=f.get("DeviceGray");break;case 3:y=f.get("DeviceRGB");break;case 4:y=f.get("DeviceCMYK");break;default:c("JPX images with "+this.numComps+" color components not supported.")}}this.colorSpace=g.parse(y,e,t);this.numComps=this.colorSpace.numComps}this.decode=h.getArray("Decode","D");this.needsDecode=!1;if(this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode)||o&&!g.isDefaultDecode(this.decode,1))){this.needsDecode=!0;var k=(1<>3)*a,c=e.byteLength,l=o===c;if(!r||i&&!l)if(i){n=new Uint8Array(o);n.set(e);for(s=c;o>s;s++)n[s]=255}else{n=new Uint8Array(c);n.set(e)}else n=e;if(i)for(s=0;c>s;s++)n[s]=~n[s];return{data:n,width:t,height:a}};r.prototype={get drawWidth(){return Math.max(this.width,this.smask&&this.smask.width||0,this.mask&&this.mask.width||0)},get drawHeight(){return Math.max(this.height,this.smask&&this.smask.height||0,this.mask&&this.mask.height||0)},decodeBuffer:function(e){var a,r,i=this.bpc,n=this.numComps,s=this.decodeAddends,o=this.decodeCoefficients,c=(1<a;a++)for(var h=0;n>h;h++){e[l]=t(e[l],s[h],o[h],c);l++}}else for(a=0,r=e.length;r>a;a++)e[a]=+!e[a]},getComponents:function(e){var t=this.bpc;if(8===t)return e;var a,r,i=this.width,n=this.height,s=this.numComps,o=i*n*s,c=0,l=8>=t?new Uint8Array(o):16>=t?new Uint16Array(o):new Uint32Array(o),h=i*s,u=(1<m;m++){g=f+(-8&h);p=f+h;for(;g>f;){r=e[c++];l[f]=r>>7&1;l[f+1]=r>>6&1;l[f+2]=r>>5&1;l[f+3]=r>>4&1;l[f+4]=r>>3&1;l[f+5]=r>>2&1;l[f+6]=r>>1&1;l[f+7]=1&r;f+=8}if(p>f){r=e[c++];d=128;for(;p>f;){l[f++]=+!!(r&d);d>>=1}}}else{var b=0;r=0;for(f=0,a=o;a>f;++f){if(f%h===0){r=0;b=0}for(;t>b;){r=r<<8|e[c++];b+=8}var v=b-t,y=r>>v;l[f]=0>y?0:y>u?u:y;r&=(1<f;++f)o[f]=255-o[f];l===t&&u===i||(o=a(o,m.bpc,l,u,t,i))}else if(h(m)){o=new Uint8Array(t*i);var b=this.numComps;for(f=0,d=t*i;d>f;++f){var v=0,y=f*b;for(g=0;b>g;++g){var k=s[y+g],w=2*g;if(km[w+1]){v=255;break}}o[f]=v}}else c("Unknown mask format.");if(o)for(f=0,g=3,d=t*n;d>f;++f,g+=4)e[g]=o[f];else for(f=0,g=3,d=t*n;d>f;++f,g+=4)e[g]=255},undoPreblend:function(e,t,a){var r=this.smask&&this.smask.matte;if(r)for(var i,n,s,o=this.colorSpace.getRgb(r,0),c=o[0],l=o[1],h=o[2],u=t*a*4,f=0;u>f;f+=4){var d=e[f+3];if(0!==d){var g=255/d;i=(e[f]-c)*g+c;n=(e[f+1]-l)*g+l;s=(e[f+2]-h)*g+h;e[f]=0>=i?0:i>=255?255:0|i;e[f+1]=0>=n?0:n>=255?255:0|n;e[f+2]=0>=s?0:s>=255?255:0|s}else{e[f]=255;e[f+1]=255;e[f+2]=255}}},createImageData:function(e){var t,a=this.drawWidth,r=this.drawHeight,i={width:a,height:r},n=this.numComps,c=this.width,l=this.height,h=this.bpc,u=c*n*h+7>>3;if(!e){var f;"DeviceGray"===this.colorSpace.name&&1===h?f=s.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==h||this.needsDecode||(f=s.RGB_24BPP);if(f&&!this.smask&&!this.mask&&a===c&&r===l){i.kind=f;t=this.getImageBytes(l*u);if(this.image instanceof p)i.data=t;else{var d=new Uint8Array(t.length);d.set(t);i.data=d}if(this.needsDecode){o(f===s.GRAYSCALE_1BPP);for(var g=i.data,b=0,v=g.length;v>b;b++)g[b]^=255}return i}if(this.image instanceof m&&!this.smask&&!this.mask&&("DeviceGray"===this.colorSpace.name||"DeviceRGB"===this.colorSpace.name||"DeviceCMYK"===this.colorSpace.name)){i.kind=s.RGB_24BPP;i.data=this.getImageBytes(l*u,a,r,!0);return i}}t=this.getImageBytes(l*u);var y,k,w=0|t.length/u*r/l,x=this.getComponents(t);if(e||this.smask||this.mask){i.kind=s.RGBA_32BPP;i.data=new Uint8Array(a*r*4);y=1;k=!0;this.fillOpacity(i.data,a,r,w,x)}else{i.kind=s.RGB_24BPP;i.data=new Uint8Array(a*r*3);y=0;k=!1}this.needsDecode&&this.decodeBuffer(x);this.colorSpace.fillRgb(i.data,c,l,a,r,w,h,x,y);k&&this.undoPreblend(i.data,a,w);return i},fillGrayBuffer:function(e){var t=this.numComps;1!==t&&c("Reading gray scale from a color image: "+t);var a,r,i=this.width,n=this.height,s=this.bpc,o=i*t*s+7>>3,l=this.getImageBytes(n*o),h=this.getComponents(l);if(1!==s){this.needsDecode&&this.decodeBuffer(h);r=i*n;var u=255/((1<a;++a)e[a]=u*h[a]|0}else{r=i*n;if(this.needsDecode)for(a=0;r>a;++a)e[a]=h[a]-1&255;else for(a=0;r>a;++a)e[a]=255&-h[a]}},getImageBytes:function(e,t,a,r){this.image.reset();this.image.drawWidth=t||this.width;this.image.drawHeight=a||this.height;this.image.forceRGB=!!r;return this.image.getBytes(e)}};return r}();e.PDFImage=v});!function(e,t){t(e.pdfjsCoreObj={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreCrypto,e.pdfjsCoreParser,e.pdfjsCoreChunkedStream,e.pdfjsCoreColorSpace)}(this,function(e,t,a,r,i,n,s){var o=t.InvalidPDFException,c=t.MissingDataException,l=t.XRefParseException,h=t.assert,u=t.bytesToString,f=t.createPromiseCapability,d=t.error,g=t.info,p=t.isArray,m=t.isInt,b=t.isString,v=t.shadow,y=t.stringToPDFString,k=t.stringToUTF8String,w=t.warn,x=t.isValidUrl,C=t.Util,S=a.Ref,A=a.RefSet,I=a.RefSetCache,B=a.isName,R=a.isCmd,T=a.isDict,O=a.isRef,P=a.isRefsEqual,L=a.isStream,M=r.CipherTransformFactory,E=i.Lexer,D=i.Parser,q=n.ChunkedStream,j=s.ColorSpace,F=function(){function e(e,t,a){this.pdfManager=e;this.xref=t;this.catDict=t.getCatalogObj();this.fontCache=new I;h(T(this.catDict),"catalog object is not a dictionary");this.pageFactory=a;this.pagePromises=[]}e.prototype={get metadata(){var e=this.catDict.getRaw("Metadata");if(!O(e))return v(this,"metadata",null);var t,a=this.xref.encrypt?this.xref.encrypt.encryptMetadata:!1,r=this.xref.fetch(e,!a);if(r&&T(r.dict)){var i=r.dict.get("Type"),n=r.dict.get("Subtype");if(B(i)&&B(n)&&"Metadata"===i.name&&"XML"===n.name)try{t=k(u(r.getBytes()))}catch(s){g("Skipping invalid metadata.")}}return v(this,"metadata",t)},get toplevelPagesDict(){var e=this.catDict.get("Pages");h(T(e),"invalid top-level pages dictionary");return v(this,"toplevelPagesDict",e)},get documentOutline(){var e=null;try{e=this.readDocumentOutline()}catch(t){if(t instanceof c)throw t;w("Unable to read document outline")}return v(this,"documentOutline",e)},readDocumentOutline:function(){var e=this.catDict.get("Outlines");if(!T(e))return null;e=e.getRaw("First");if(!O(e))return null;var t={items:[]},a=[{obj:e,parent:t}],r=new A;r.put(e);for(var i=this.xref,n=new Uint8Array(3);a.length>0;){var s=a.shift(),o=i.fetchIfRef(s.obj);if(null!==o){h(o.has("Title"),"Invalid outline item");var c=o.get("A"),l=null,u=null;if(c){var f=c.get("D");if(f)l=f;else{var d=c.get("URI");b(d)&&x(d,!1)&&(u=d)}}else if(o.has("Dest")){l=o.getRaw("Dest");B(l)&&(l=l.name)}var g=o.get("Title"),m=o.get("F")||0,v=o.getArray("C"),k=n;!p(v)||3!==v.length||0===v[0]&&0===v[1]&&0===v[2]||(k=j.singletons.rgb.getRgb(v,0));var w={dest:l,url:u,title:y(g),color:k,count:o.get("Count"),bold:!!(2&m),italic:!!(1&m),items:[]};s.parent.items.push(w);e=o.getRaw("First");if(O(e)&&!r.has(e)){a.push({obj:e,parent:w});r.put(e)}e=o.getRaw("Next");if(O(e)&&!r.has(e)){a.push({obj:e,parent:s.parent});r.put(e)}}}return t.items.length>0?t.items:null},get numPages(){var e=this.toplevelPagesDict.get("Count");h(m(e),"page count in top level pages object is not an integer");return v(this,"num",e)},get destinations(){function e(e){return T(e)?e.get("D"):e}var t,a,r=this.xref,i={},n=this.catDict.get("Names");n&&n.has("Dests")?t=n.getRaw("Dests"):this.catDict.has("Dests")&&(a=this.catDict.get("Dests"));if(a){n=a;n.forEach(function(t,a){a&&(i[t]=e(a))})}if(t){var s=new _(t,r),o=s.getAll();for(var c in o)i[c]=e(o[c])}return v(this,"destinations",i); +},getDestination:function(e){function t(e){return T(e)?e.get("D"):e}var a,r,i=this.xref,n=null,s=this.catDict.get("Names");s&&s.has("Dests")?a=s.getRaw("Dests"):this.catDict.has("Dests")&&(r=this.catDict.get("Dests"));if(r){var o=r.get(e);o&&(n=t(o))}if(a){var c=new _(a,i);n=t(c.get(e))}return n},get pageLabels(){var e=null;try{e=this.readPageLabels()}catch(t){if(t instanceof c)throw t;w("Unable to read page labels.")}return v(this,"pageLabels",e)},readPageLabels:function(){var e=this.catDict.getRaw("PageLabels");if(!e)return null;for(var t=new Array(this.numPages),a=null,r="",i=1,n=new z(e,this.xref),s=n.getAll(),o="",c=1,l=0,u=this.numPages;u>l;l++){if(l in s){var f=s[l];h(T(f),"The PageLabel is not a dictionary.");var d=f.get("Type");h(!d||B(d)&&"PageLabel"===d.name,"Invalid type in PageLabel dictionary.");var g=f.get("S");h(!g||B(g),"Invalid style in PageLabel dictionary.");a=g?g.name:null;r=f.get("P")||"";h(b(r),"Invalid prefix in PageLabel dictionary.");i=f.get("St")||1;h(m(i),"Invalid start in PageLabel dictionary.");c=i}switch(a){case"D":o=c;break;case"R":case"r":o=C.toRoman(c,"r"===a);break;case"A":case"a":for(var p=26,v=65,y=97,k="a"===a?y:v,w=c-1,x=String.fromCharCode(k+w%p),S=[],A=0,I=w/p|0;I>=A;A++)S.push(x);o=S.join("");break;default:h(!a,'Invalid style "'+a+'" in PageLabel dictionary.')}t[l]=r+o;o="";c++}return t},get attachments(){var e,t=this.xref,a=null,r=this.catDict.get("Names");r&&(e=r.getRaw("EmbeddedFiles"));if(e){var i=new _(e,t),n=i.getAll();for(var s in n){var o=new H(n[s],t);a||(a=Object.create(null));a[y(s)]=o.serializable}}return v(this,"attachments",a)},get javaScript(){function e(e){var t=e.get("S");if(B(t)&&"JavaScript"===t.name){var a=e.get("JS");if(L(a))a=u(a.getBytes());else if(!b(a))return;r.push(y(a))}}var t=this.xref,a=this.catDict.get("Names"),r=[];if(a&&a.has("JavaScript")){var i=new _(a.getRaw("JavaScript"),t),n=i.getAll();for(var s in n){var o=n[s];T(o)&&e(o)}}var c=this.catDict.get("OpenAction");if(T(c,"Action")){var l=c.get("S");if(B(l)&&"Named"===l.name){var h=c.get("N");B(h)&&"Print"===h.name&&r.push("print({});")}else e(c)}return v(this,"javaScript",r)},cleanup:function(){var e=[];this.fontCache.forEach(function(t){e.push(t)});return Promise.all(e).then(function(e){for(var t=0,a=e.length;a>t;t++){var r=e[t].dict;delete r.translated}this.fontCache.clear()}.bind(this))},getPage:function(e){e in this.pagePromises||(this.pagePromises[e]=this.getPageDict(e).then(function(t){var a=t[0],r=t[1];return this.pageFactory.createPage(e,a,r,this.fontCache)}.bind(this)));return this.pagePromises[e]},getPageDict:function(e){function t(){for(;r.length;){var o=r.pop();if(O(o)){n.fetchAsync(o).then(function(n){if(T(n,"Page")||T(n)&&!n.has("Kids"))if(e===i)a.resolve([n,o]);else{i++;t()}else{r.push(n);t()}},a.reject);return}h(T(o),"page dictionary kid reference points to wrong type of object");var c=o.get("Count");0===c&&(s=!0);if(e>=i+c)i+=c;else{var l=o.get("Kids");h(p(l),"page dictionary kids object is not an array");if(s||c!==l.length)for(var u=l.length-1;u>=0;u--)r.push(l[u]);else{r=[l[e-i]];i=e}}}a.reject("Page index "+e+" not found.")}var a=f(),r=[this.catDict.getRaw("Pages")],i=0,n=this.xref,s=!1;t();return a.promise},getPageIndex:function(e){function t(t){var a,i=0;return r.fetchAsync(t).then(function(r){if(P(t,e)&&!T(r,"Page")&&(!T(r)||r.has("Type")||!r.has("Contents")))throw new Error("The reference does not point to a /Page Dict.");if(!r)return null;h(T(r),"node must be a Dict.");a=r.getRaw("Parent");return r.getAsync("Parent")}).then(function(e){if(!e)return null;h(T(e),"parent must be a Dict.");return e.getAsync("Kids")}).then(function(e){if(!e)return null;for(var n=[],s=!1,o=0;os;s++){a.streamPos=t.pos;a.entryNum=s;a.parserBuf1=e.buf1;a.parserBuf2=e.buf2;var o={};o.offset=e.getObj();o.gen=e.getObj();var c=e.getObj();R(c,"f")?o.free=!0:R(c,"n")&&(o.uncompressed=!0);m(o.offset)&&m(o.gen)&&(o.free||o.uncompressed)||d("Invalid entry in XRef subsection: "+i+", "+n);0===s&&o.free&&1===i&&(i=0);this.entries[s+i]||(this.entries[s+i]=o)}a.entryNum=0;a.streamPos=t.pos;a.parserBuf1=e.buf1;a.parserBuf2=e.buf2;delete a.firstEntryNum;delete a.entryCount}this.entries[0]&&!this.entries[0].free&&d("Invalid XRef table: unexpected first object");return r},processXRefStream:function(e){if(!("streamState"in this)){var t=e.dict,a=t.get("W"),r=t.get("Index");r||(r=[0,t.get("Size")]);this.streamState={entryRanges:r,byteWidths:a,entryNum:0,streamPos:e.pos}}this.readXRefStream(e);delete this.streamState;return e.dict},readXRefStream:function(e){var t,a,r=this.streamState;e.pos=r.streamPos;for(var i=r.byteWidths,n=i[0],s=i[1],o=i[2],c=r.entryRanges;c.length>0;){var l=c[0],h=c[1];m(l)&&m(h)||d("Invalid XRef range fields: "+l+", "+h);m(n)&&m(s)&&m(o)||d("Invalid XRef entry fields length: "+l+", "+h);for(t=r.entryNum;h>t;++t){r.entryNum=t;r.streamPos=e.pos;var u=0,f=0,g=0;for(a=0;n>a;++a)u=u<<8|e.getByte();0===n&&(u=1);for(a=0;s>a;++a)f=f<<8|e.getByte();for(a=0;o>a;++a)g=g<<8|e.getByte();var p={};p.offset=f;p.gen=g;switch(u){case 0:p.free=!0;break;case 1:p.uncompressed=!0;break;case 2:break;default:d("Invalid XRef entry type: "+u)}this.entries[l+t]||(this.entries[l+t]=p)}r.entryNum=0;r.streamPos=e.pos;c.splice(0,2)}},indexObjects:function(){function e(e,t){for(var a="",n=e[t];n!==r&&n!==i&&n!==c&&!(++t>=e.length);){a+=String.fromCharCode(n);n=e[t]}return a}function t(e,t,a){for(var r=a.length,i=e.length,n=0;i>t;){for(var s=0;r>s&&e[t+s]===a[s];)++s;if(s>=r)break;t++;n++}return n}var a=9,r=10,i=13,n=32,s=37,c=60,l=/^(\d+)\s+(\d+)\s+obj\b/,h=new Uint8Array([116,114,97,105,108,101,114]),u=new Uint8Array([115,116,97,114,116,120,114,101,102]),f=new Uint8Array([101,110,100,111,98,106]),d=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var g=this.stream;g.pos=0;for(var p=g.getBytes(),m=g.start,b=p.length,v=[],y=[];b>m;){var k=p[m];if(k!==a&&k!==r&&k!==i&&k!==n)if(k!==s){var w,x=e(p,m);if(0!==x.indexOf("xref")||4!==x.length&&!/\s/.test(x[4]))if(w=l.exec(x)){"undefined"==typeof this.entries[w[1]]&&(this.entries[w[1]]={offset:m-g.start,gen:0|w[2],uncompressed:!0});var C=t(p,m,f)+7,S=p.subarray(m,m+C),A=t(S,0,d);if(C>A&&S[A+5]<64){y.push(m-g.start);this.xrefstms[m-g.start]=1}m+=C}else if(0!==x.indexOf("trailer")||7!==x.length&&!/\s/.test(x[7]))m+=x.length+1;else{v.push(m);m+=t(p,m,u)}else{m+=t(p,m,h);v.push(m);m+=t(p,m,u)}}else do{++m;if(m>=b)break;k=p[m]}while(k!==r&&k!==i);else++m}var I,B;for(I=0,B=y.length;B>I;++I){this.startXRefQueue.push(y[I]);this.readXRef(!0)}var O;for(I=0,B=v.length;B>I;++I){g.pos=v[I];var P=new D(new E(g),!0,this),L=P.getObj();if(R(L,"trailer")&&T(O=P.getObj())&&O.has("ID"))return O}if(O)return O;throw new o("Invalid PDF structure")},readXRef:function(e){var t=this.stream;try{for(;this.startXRefQueue.length;){var a=this.startXRefQueue[0];t.pos=a+t.start;var r,i=new D(new E(t),!0,this),n=i.getObj();if(R(n,"xref")){r=this.processXRefTable(i);this.topDict||(this.topDict=r);n=r.get("XRefStm");if(m(n)){var s=n;if(!(s in this.xrefstms)){this.xrefstms[s]=1;this.startXRefQueue.push(s)}}}else if(m(n)){m(i.getObj())&&R(i.getObj(),"obj")&&L(n=i.getObj())||d("Invalid XRef stream");r=this.processXRefStream(n);this.topDict||(this.topDict=r);r||d("Failed to read XRef stream")}else d("Invalid XRef stream header");n=r.get("Prev");m(n)?this.startXRefQueue.push(n):O(n)&&this.startXRefQueue.push(n.num);this.startXRefQueue.shift()}return this.topDict}catch(o){if(o instanceof c)throw o;g("(while reading XRef): "+o)}if(!e)throw new l},getEntry:function(e){var t=this.entries[e];return t&&!t.free&&t.offset?t:null},fetchIfRef:function(e){return O(e)?this.fetch(e):e},fetch:function(e,t){h(O(e),"ref object is not a reference");var a=e.num;if(a in this.cache){var r=this.cache[a];return r}var i=this.getEntry(a);if(null===i)return this.cache[a]=null;i=i.uncompressed?this.fetchUncompressed(e,i,t):this.fetchCompressed(i,t);T(i)?i.objId=e.toString():L(i)&&(i.dict.objId=e.toString());return i},fetchUncompressed:function(e,t,a){var r=e.gen,i=e.num;t.gen!==r&&d("inconsistent generation in XRef");var n=this.stream.makeSubStream(t.offset+this.stream.start),s=new D(new E(n),!0,this),o=s.getObj(),c=s.getObj(),l=s.getObj();m(o)&&parseInt(o,10)===i&&m(c)&&parseInt(c,10)===r&&R(l)||d("bad XRef entry");if(!R(l,"obj")){if(0===l.cmd.indexOf("obj")){i=parseInt(l.cmd.substring(3),10);if(!isNaN(i))return i}d("bad XRef entry")}t=this.encrypt&&!a?s.getObj(this.encrypt.createCipherTransform(i,r)):s.getObj();L(t)||(this.cache[i]=t);return t},fetchCompressed:function(e,t){var a=e.offset,r=this.fetch(new S(a,0));L(r)||d("bad ObjStm stream");var i=r.dict.get("First"),n=r.dict.get("N");m(i)&&m(n)||d("invalid first and n parameters for ObjStm stream");var s=new D(new E(r),!1,this);s.allowStreams=!0;var o,c,l=[],h=[];for(o=0;n>o;++o){c=s.getObj();m(c)||d("invalid object number in the ObjStm stream: "+c);h.push(c);var u=s.getObj();m(u)||d("invalid object offset in the ObjStm stream: "+u)}for(o=0;n>o;++o){l.push(s.getObj());R(s.buf1,"endobj")&&s.shift();c=h[o];var f=this.entries[c];f&&f.offset===a&&f.gen===o&&(this.cache[c]=l[o])}e=l[e.gen];void 0===e&&d("bad XRef entry for compressed object");return e},fetchIfRefAsync:function(e){return O(e)?this.fetchAsync(e):Promise.resolve(e)},fetchAsync:function(e,t){var a=this.stream.manager,r=this;return new Promise(function i(n,s){try{n(r.fetch(e,t))}catch(o){if(o instanceof c){a.requestRange(o.begin,o.end).then(function(){i(n,s)},s);return}s(o)}})},getCatalogObj:function(){return this.root}};return e}(),N=function(){function e(e,t){throw new Error("Cannot initialize NameOrNumberTree.")}e.prototype={getAll:function(){var e=Object.create(null);if(!this.root)return e;var t=this.xref,a=new A;a.put(this.root);for(var r=[this.root];r.length>0;){var i,n,s=t.fetchIfRef(r.shift());if(T(s))if(s.has("Kids")){var o=s.get("Kids");for(i=0,n=o.length;n>i;i++){var c=o[i];h(!a.has(c),'Duplicate entry in "'+this._type+'" tree.');r.push(c);a.put(c)}}else{var l=s.get(this._type);if(p(l))for(i=0,n=l.length;n>i;i+=2)e[t.fetchIfRef(l[i])]=t.fetchIfRef(l[i+1])}}return e},get:function(e){if(!this.root)return null;for(var t,a,r,i=this.xref,n=i.fetchIfRef(this.root),s=0,o=10;n.has("Kids");){if(++s>o){w('Search depth limit reached for "'+this._type+'" tree.');return null}var c=n.get("Kids");if(!p(c))return null;t=0;a=c.length-1;for(;a>=t;){r=t+a>>1;var l=i.fetchIfRef(c[r]),h=l.get("Limits");if(ei.fetchIfRef(h[1]))){n=i.fetchIfRef(c[r]);break}t=r+1}}if(t>a)return null}var u=n.get(this._type);if(p(u)){t=0;a=u.length-2;for(;a>=t;){r=t+a&-2;var f=i.fetchIfRef(u[r]);if(f>e)a=r-2;else{if(!(e>f))return i.fetchIfRef(u[r+1]);t=r+2}}}return null}};return e}(),_=function(){function e(e,t){this.root=e;this.xref=t;this._type="Names"}C.inherit(e,N,{});return e}(),z=function(){function e(e,t){this.root=e;this.xref=t;this._type="Nums"}C.inherit(e,N,{});return e}(),H=function(){function e(e,t){if(e&&T(e)){this.xref=t;this.root=e;e.has("FS")&&(this.fs=e.get("FS"));this.description=e.has("Desc")?y(e.get("Desc")):"";e.has("RF")&&w("Related file specifications are not supported");this.contentAvailable=!0;if(!e.has("EF")){this.contentAvailable=!1;w("Non-embedded file specifications are not supported")}}}function t(e){return e.has("UF")?e.get("UF"):e.has("F")?e.get("F"):e.has("Unix")?e.get("Unix"):e.has("Mac")?e.get("Mac"):e.has("DOS")?e.get("DOS"):null}e.prototype={get filename(){if(!this._filename&&this.root){var e=t(this.root)||"unnamed";this._filename=y(e).replace(/\\\\/g,"\\").replace(/\\\//g,"/").replace(/\\/g,"/")}return this._filename},get content(){if(!this.contentAvailable)return null;!this.contentRef&&this.root&&(this.contentRef=t(this.root.get("EF")));var e=null;if(this.contentRef){var a=this.xref,r=a.fetchIfRef(this.contentRef);r&&L(r)?e=r.getBytes():w("Embedded file specification points to non-existing/invalid content")}else w("Embedded file specification does not have a content");return e},get serializable(){return{filename:this.filename,content:this.content}}};return e}(),G=function(){function e(e){return O(e)||T(e)||p(e)||L(e)}function t(t,a){var r;if(T(t)||L(t)){var i;i=T(t)?t.map:t.dict.map;for(var n in i){r=i[n];e(r)&&a.push(r)}}else if(p(t))for(var s=0,o=t.length;o>s;s++){r=t[s];e(r)&&a.push(r)}}function a(e,t,a){this.obj=e;this.keys=t;this.xref=a;this.refSet=null;this.capability=null}a.prototype={load:function(){var e=this.keys;this.capability=f();if(!(this.xref.stream instanceof q)||0===this.xref.stream.getMissingChunks().length){this.capability.resolve();return this.capability.promise}this.refSet=new A;for(var t=[],a=0;a=k&&k+S>=C&&f("Unsupported radial gradient.")}this.extendStart=l;this.extendEnd=h;var A=e.get("Function"),I=g.parseArray(a,A),B=s-n,R=B/10,T=this.colorStops=[];if(n>=s||0>=R)u("Bad shading domain.");else{for(var O,P=new Float32Array(i.numComps),L=new Float32Array(1),M=n;s>=M;M+=R){L[0]=M;I(L,0,P,0);O=i.getRgb(P,0);var E=c.makeCssRgb(O[0],O[1],O[2]);T.push([(M-n)/B,E])}var D="transparent";if(e.has("Background")){O=i.getRgb(e.get("Background"),0);D=c.makeCssRgb(O[0],O[1],O[2])}if(!l){T.unshift([0,D]);T[1][0]+=v.SMALL_NUMBER}if(!h){T[T.length-1][0]-=v.SMALL_NUMBER;T.push([1,D])}this.colorStops=T}}e.prototype={getIR:function(){var e,t,a,r,i,n=this.coordsArr,s=this.shadingType;if(s===m.AXIAL){t=[n[0],n[1]];a=[n[2],n[3]];r=null;i=null;e="axial"}else if(s===m.RADIAL){t=[n[0],n[1]];a=[n[3],n[4]];r=n[2];i=n[5];e="radial"}else h("getPattern type unknown: "+s);var o=this.matrix;if(o){t=c.applyTransform(t,o);a=c.applyTransform(a,o);if(s===m.RADIAL){var l=c.singularValueDecompose2dScale(o);r*=l[0];i*=l[1]}}return["RadialAxial",e,this.colorStops,t,a,r,i]}};return e}();v.Mesh=function(){function e(e,t){this.stream=e;this.context=t;this.buffer=0;this.bufferLength=0;var a=t.numComps;this.tmpCompsBuf=new Float32Array(a);var r=t.colorSpace.numComps;this.tmpCsCompsBuf=t.colorFn?new Float32Array(r):this.tmpCompsBuf}function t(e,t){for(var a=e.coords,r=e.colors,i=[],n=[],s=0;t.hasData;){var o=t.readFlag(),c=t.readCoordinate(),h=t.readComponents();if(0===s){l(o>=0&&2>=o,"Unknown type4 flag");switch(o){case 0:s=3;break;case 1:n.push(n[n.length-2],n[n.length-1]);s=1;break;case 2:n.push(n[n.length-3],n[n.length-1]);s=1}i.push(o)}n.push(a.length);a.push(c);r.push(h);s--;t.align()}e.figures.push({type:"triangles",coords:new Int32Array(n),colors:new Int32Array(n)})}function a(e,t,a){for(var r=e.coords,i=e.colors,n=[];t.hasData;){var s=t.readCoordinate(),o=t.readComponents();n.push(r.length);r.push(s);i.push(o)}e.figures.push({type:"lattice",coords:new Int32Array(n),colors:new Int32Array(n),verticesPerRow:a})}function r(e,t){var a=e.figures[t];l("patch"===a.type,"Unexpected patch mesh figure");var r=e.coords,i=e.colors,n=a.coords,s=a.colors,o=Math.min(r[n[0]][0],r[n[3]][0],r[n[12]][0],r[n[15]][0]),c=Math.min(r[n[0]][1],r[n[3]][1],r[n[12]][1],r[n[15]][1]),h=Math.max(r[n[0]][0],r[n[3]][0],r[n[12]][0],r[n[15]][0]),d=Math.max(r[n[0]][1],r[n[3]][1],r[n[12]][1],r[n[15]][1]),g=Math.ceil((h-o)*b/(e.bounds[2]-e.bounds[0]));g=Math.max(u,Math.min(f,g));var p=Math.ceil((d-c)*b/(e.bounds[3]-e.bounds[1]));p=Math.max(u,Math.min(f,p));for(var m=g+1,y=new Int32Array((p+1)*m),k=new Int32Array((p+1)*m),w=0,x=new Uint8Array(3),C=new Uint8Array(3),S=i[s[0]],A=i[s[1]],I=i[s[2]],B=i[s[3]],R=v(p),T=v(g),O=0;p>=O;O++){x[0]=(S[0]*(p-O)+I[0]*O)/p|0;x[1]=(S[1]*(p-O)+I[1]*O)/p|0;x[2]=(S[2]*(p-O)+I[2]*O)/p|0;C[0]=(A[0]*(p-O)+B[0]*O)/p|0;C[1]=(A[1]*(p-O)+B[1]*O)/p|0;C[2]=(A[2]*(p-O)+B[2]*O)/p|0;for(var P=0;g>=P;P++,w++)if(0!==O&&O!==p||0!==P&&P!==g){for(var L=0,M=0,E=0,D=0;3>=D;D++)for(var q=0;3>=q;q++,E++){var j=R[O][D]*T[P][q];L+=r[n[E]][0]*j;M+=r[n[E]][1]*j}y[w]=r.length;r.push([L,M]);k[w]=i.length;var F=new Uint8Array(3);F[0]=(x[0]*(g-P)+C[0]*P)/g|0;F[1]=(x[1]*(g-P)+C[1]*P)/g|0;F[2]=(x[2]*(g-P)+C[2]*P)/g|0;i.push(F)}}y[0]=n[0];k[0]=s[0];y[g]=n[3];k[g]=s[1];y[m*p]=n[12];k[m*p]=s[2];y[m*p+g]=n[15];k[m*p+g]=s[3];e.figures[t]={type:"lattice",coords:y,colors:k,verticesPerRow:m}}function i(e,t){for(var a=e.coords,r=e.colors,i=new Int32Array(16),n=new Int32Array(4);t.hasData;){var s=t.readFlag();l(s>=0&&3>=s,"Unknown type6 flag");var o,c,h=a.length;for(o=0,c=0!==s?8:12;c>o;o++)a.push(t.readCoordinate());var u=r.length;for(o=0,c=0!==s?2:4;c>o;o++)r.push(t.readComponents());var f,d,g,p;switch(s){case 0:i[12]=h+3;i[13]=h+4;i[14]=h+5;i[15]=h+6;i[8]=h+2;i[11]=h+7;i[4]=h+1;i[7]=h+8;i[0]=h;i[1]=h+11;i[2]=h+10;i[3]=h+9;n[2]=u+1;n[3]=u+2;n[0]=u;n[1]=u+3;break;case 1:f=i[12];d=i[13];g=i[14];p=i[15];i[12]=p;i[13]=h+0;i[14]=h+1;i[15]=h+2;i[8]=g;i[11]=h+3;i[4]=d;i[7]=h+4;i[0]=f;i[1]=h+7;i[2]=h+6;i[3]=h+5;f=n[2];d=n[3];n[2]=d;n[3]=u;n[0]=f;n[1]=u+1;break;case 2:f=i[15];d=i[11];i[12]=i[3];i[13]=h+0;i[14]=h+1;i[15]=h+2;i[8]=i[7];i[11]=h+3;i[4]=d;i[7]=h+4;i[0]=f;i[1]=h+7;i[2]=h+6;i[3]=h+5;f=n[3];n[2]=n[1];n[3]=u;n[0]=f;n[1]=u+1;break;case 3:i[12]=i[0];i[13]=h+0;i[14]=h+1;i[15]=h+2;i[8]=i[1];i[11]=h+3;i[4]=i[2];i[7]=h+4;i[0]=i[3];i[1]=h+7;i[2]=h+6;i[3]=h+5;n[2]=n[0];n[3]=u;n[0]=n[1];n[1]=u+1}i[5]=a.length;a.push([(-4*a[i[0]][0]-a[i[15]][0]+6*(a[i[4]][0]+a[i[1]][0])-2*(a[i[12]][0]+a[i[3]][0])+3*(a[i[13]][0]+a[i[7]][0]))/9,(-4*a[i[0]][1]-a[i[15]][1]+6*(a[i[4]][1]+a[i[1]][1])-2*(a[i[12]][1]+a[i[3]][1])+3*(a[i[13]][1]+a[i[7]][1]))/9]);i[6]=a.length;a.push([(-4*a[i[3]][0]-a[i[12]][0]+6*(a[i[2]][0]+a[i[7]][0])-2*(a[i[0]][0]+a[i[15]][0])+3*(a[i[4]][0]+a[i[14]][0]))/9,(-4*a[i[3]][1]-a[i[12]][1]+6*(a[i[2]][1]+a[i[7]][1])-2*(a[i[0]][1]+a[i[15]][1])+3*(a[i[4]][1]+a[i[14]][1]))/9]);i[9]=a.length;a.push([(-4*a[i[12]][0]-a[i[3]][0]+6*(a[i[8]][0]+a[i[13]][0])-2*(a[i[0]][0]+a[i[15]][0])+3*(a[i[11]][0]+a[i[1]][0]))/9,(-4*a[i[12]][1]-a[i[3]][1]+6*(a[i[8]][1]+a[i[13]][1])-2*(a[i[0]][1]+a[i[15]][1])+3*(a[i[11]][1]+a[i[1]][1]))/9]);i[10]=a.length;a.push([(-4*a[i[15]][0]-a[i[0]][0]+6*(a[i[11]][0]+a[i[14]][0])-2*(a[i[12]][0]+a[i[3]][0])+3*(a[i[2]][0]+a[i[8]][0]))/9,(-4*a[i[15]][1]-a[i[0]][1]+6*(a[i[11]][1]+a[i[14]][1])-2*(a[i[12]][1]+a[i[3]][1])+3*(a[i[2]][1]+a[i[8]][1]))/9]);e.figures.push({type:"patch",coords:new Int32Array(i),colors:new Int32Array(n)})}}function n(e,t){for(var a=e.coords,r=e.colors,i=new Int32Array(16),n=new Int32Array(4);t.hasData;){var s=t.readFlag();l(s>=0&&3>=s,"Unknown type7 flag");var o,c,h=a.length;for(o=0,c=0!==s?12:16;c>o;o++)a.push(t.readCoordinate());var u=r.length;for(o=0,c=0!==s?2:4;c>o;o++)r.push(t.readComponents());var f,d,g,p;switch(s){case 0:i[12]=h+3;i[13]=h+4;i[14]=h+5;i[15]=h+6;i[8]=h+2;i[9]=h+13;i[10]=h+14;i[11]=h+7;i[4]=h+1;i[5]=h+12;i[6]=h+15;i[7]=h+8;i[0]=h;i[1]=h+11;i[2]=h+10;i[3]=h+9;n[2]=u+1;n[3]=u+2;n[0]=u;n[1]=u+3;break;case 1:f=i[12];d=i[13];g=i[14];p=i[15];i[12]=p;i[13]=h+0;i[14]=h+1;i[15]=h+2;i[8]=g;i[9]=h+9;i[10]=h+10;i[11]=h+3;i[4]=d;i[5]=h+8;i[6]=h+11;i[7]=h+4;i[0]=f;i[1]=h+7;i[2]=h+6;i[3]=h+5;f=n[2];d=n[3];n[2]=d;n[3]=u;n[0]=f;n[1]=u+1;break;case 2:f=i[15];d=i[11];i[12]=i[3];i[13]=h+0;i[14]=h+1;i[15]=h+2;i[8]=i[7];i[9]=h+9;i[10]=h+10;i[11]=h+3;i[4]=d;i[5]=h+8;i[6]=h+11;i[7]=h+4;i[0]=f;i[1]=h+7;i[2]=h+6;i[3]=h+5;f=n[3];n[2]=n[1];n[3]=u;n[0]=f;n[1]=u+1;break;case 3:i[12]=i[0];i[13]=h+0;i[14]=h+1;i[15]=h+2;i[8]=i[1];i[9]=h+9;i[10]=h+10;i[11]=h+3;i[4]=i[2];i[5]=h+8;i[6]=h+11;i[7]=h+4;i[0]=i[3];i[1]=h+7;i[2]=h+6;i[3]=h+5;n[2]=n[0];n[3]=u;n[0]=n[1];n[1]=u+1}e.figures.push({type:"patch",coords:new Int32Array(i),colors:new Int32Array(n)})}}function s(e){for(var t=e.coords[0][0],a=e.coords[0][1],r=t,i=a,n=1,s=e.coords.length;s>n;n++){var o=e.coords[n][0],c=e.coords[n][1];t=t>o?o:t;a=a>c?c:a;r=o>r?o:r;i=c>i?c:i}e.bounds=[t,a,r,i]}function o(e){var t,a,r,i,n=e.coords,s=new Float32Array(2*n.length);for(t=0,r=0,a=n.length;a>t;t++){var o=n[t];s[r++]=o[0];s[r++]=o[1]}e.coords=s;var c=e.colors,l=new Uint8Array(3*c.length);for(t=0,r=0,a=c.length;a>t;t++){var h=c[t];l[r++]=h[0];l[r++]=h[1];l[r++]=h[2]}e.colors=l;var u=e.figures;for(t=0,a=u.length;a>t;t++){var f=u[t],d=f.coords,g=f.colors;for(r=0,i=d.length;i>r;r++){d[r]*=2;g[r]*=3}}}function c(c,u,f,b){l(d(c),"Mesh data is not a stream");var v=c.dict;this.matrix=u;this.shadingType=v.get("ShadingType");this.type="Pattern";this.bbox=v.getArray("BBox");var y=v.get("ColorSpace","CS");y=p.parse(y,f,b);this.cs=y;this.background=v.has("Background")?y.getRgb(v.get("Background"),0):null;var k=v.get("Function"),w=k?g.parseArray(f,k):null;this.coords=[];this.colors=[];this.figures=[];var x={bitsPerCoordinate:v.get("BitsPerCoordinate"),bitsPerComponent:v.get("BitsPerComponent"),bitsPerFlag:v.get("BitsPerFlag"),decode:v.getArray("Decode"),colorFn:w,colorSpace:y,numComps:w?1:y.numComps},C=new e(c,x),S=!1;switch(this.shadingType){case m.FREE_FORM_MESH:t(this,C);break;case m.LATTICE_FORM_MESH:var A=0|v.get("VerticesPerRow");l(A>=2,"Invalid VerticesPerRow");a(this,C,A);break;case m.COONS_PATCH_MESH:i(this,C);S=!0;break;case m.TENSOR_PATCH_MESH:n(this,C);S=!0;break;default:h("Unsupported mesh type.")}if(S){s(this);for(var I=0,B=this.figures.length;B>I;I++)r(this,I)}s(this);o(this)}e.prototype={get hasData(){if(this.stream.end)return this.stream.pos0)return!0;var e=this.stream.getByte();if(0>e)return!1;this.buffer=e;this.bufferLength=8;return!0},readBits:function(e){var t=this.buffer,a=this.bufferLength;if(32===e){if(0===a)return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0;t=t<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();var r=this.stream.getByte();this.buffer=r&(1<>a)>>>0}if(8===e&&0===a)return this.stream.getByte();for(;e>a;){t=t<<8|this.stream.getByte();a+=8}a-=e;this.bufferLength=a;this.buffer=t&(1<>a},align:function(){this.buffer=0;this.bufferLength=0},readFlag:function(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function(){var e=this.context.bitsPerCoordinate,t=this.readBits(e),a=this.readBits(e),r=this.context.decode,i=32>e?1/((1<t?1/((1<n;n++,s+=2){var o=this.readBits(t);i[n]=o*a*(r[s+1]-r[s])+r[s]}var c=this.tmpCsCompsBuf;this.context.colorFn&&this.context.colorFn(i,0,c,0);return this.context.colorSpace.getRgb(c,0)}};var u=3,f=20,b=20,v=function(){function e(e){for(var t=[],a=0;e>=a;a++){var r=a/e,i=1-r;t.push(new Float32Array([i*i*i,3*r*i*i,3*r*r*i,r*r*r]))}return t}var t=[];return function(a){t[a]||(t[a]=e(a));return t[a]}}();c.prototype={getIR:function(){return["Mesh",this.shadingType,this.coords,this.colors,this.figures,this.bounds,this.matrix,this.bbox,this.background]}};return c}();v.Dummy=function(){function e(){this.type="Pattern"}e.prototype={getIR:function(){return["Dummy"]}};return e}();e.Pattern=b;e.getTilingPatternIR=n});!function(e,t){t(e.pdfjsCoreEvaluator={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreStream,e.pdfjsCoreParser,e.pdfjsCoreImage,e.pdfjsCoreColorSpace,e.pdfjsCoreMurmurHash3,e.pdfjsCoreFonts,e.pdfjsCoreFunction,e.pdfjsCorePattern,e.pdfjsCoreCMap,e.pdfjsCoreMetrics,e.pdfjsCoreBidi,e.pdfjsCoreEncodings,e.pdfjsCoreStandardFonts,e.pdfjsCoreUnicode,e.pdfjsCoreGlyphList)}(this,function(e,t,a,r,i,n,s,o,c,l,h,u,f,d,g,p,m,b){var v=t.FONT_IDENTITY_MATRIX,y=t.IDENTITY_MATRIX,k=t.UNSUPPORTED_FEATURES,w=t.ImageKind,x=t.OPS,C=t.TextRenderingMode,S=t.Util,A=t.assert,I=t.createPromiseCapability,B=t.error,R=t.info,T=t.isArray,O=t.isNum,P=t.isString,L=t.getLookupTableFactory,M=t.warn,E=a.Dict,D=a.Name,q=a.isCmd,j=a.isDict,F=a.isName,U=a.isRef,N=a.isStream,_=r.DecodeStream,z=r.JpegStream,H=r.Stream,G=i.Lexer,X=i.Parser,W=i.isEOF,V=n.PDFImage,K=s.ColorSpace,Y=o.MurmurHash3_64,J=c.ErrorFont,Z=c.FontFlags,Q=c.Font,$=c.IdentityToUnicodeMap,ee=c.ToUnicodeMap,te=c.getFontType,ae=l.isPDFFunction,re=l.PDFFunction,ie=h.Pattern,ne=h.getTilingPatternIR,se=u.CMapFactory,oe=u.IdentityCMap,ce=f.getMetrics,le=d.bidi,he=g.WinAnsiEncoding,ue=g.StandardEncoding,fe=g.MacRomanEncoding,de=g.SymbolSetEncoding,ge=g.ZapfDingbatsEncoding,pe=g.getEncoding,me=p.getStdFontMap,be=p.getSerifFonts,ve=p.getSymbolsFonts,ye=m.getNormalizedUnicodes,ke=m.reverseIfRtl,we=m.getUnicodeForGlyph,xe=b.getGlyphsUnicode,Ce=function(){function e(e,t,a,r){this.xref=e;this.resources=t;this.handler=a;this.forceDataSchema=r}function t(e,t,a,i,n,s,o,c){this.pdfManager=e;this.xref=t;this.handler=a;this.pageIndex=i;this.uniquePrefix=n;this.idCounters=s;this.fontCache=o;this.options=c||r}function a(){this.reset()}var r={forceDataSchema:!1,maxImageSize:-1,disableFontFace:!1,cMapOptions:{url:null,packed:!1}};e.prototype={canDecode:function(t){return t instanceof z&&e.isDecodable(t,this.xref,this.resources)},decode:function(e){var t=e.dict,a=t.get("ColorSpace","CS");a=K.parse(a,this.xref,this.resources);var r=a.numComps,i=this.handler.sendWithPromise("JpegDecode",[e.getIR(this.forceDataSchema),r]);return i.then(function(t){var a=t.data;return new H(a,0,a.length,e.dict)})}};e.isSupported=function(e,t,a){var r=K.parse(e.dict.get("ColorSpace","CS"),t,a);return("DeviceGray"===r.name||"DeviceRGB"===r.name)&&r.isDefaultDecode(e.dict.getArray("Decode","D"))};e.isDecodable=function(e,t,a){var r=K.parse(e.dict.get("ColorSpace","CS"),t,a);return(1===r.numComps||3===r.numComps)&&r.isDefaultDecode(e.dict.getArray("Decode","D"))};var i=20,n=100;a.prototype={check:function(){if(++this.checkedn;n++){i=l[n];var h=c.get(i),u=h.get("BM");if(F(u)&&"Normal"!==u.name)return!0}}var f=o.get("XObject");if(j(f)){var d=f.getKeys();for(n=0,s=d.length;s>n;n++){i=d[n];var g=f.getRaw(i);if(U(g)){if(t[g.toString()])continue;g=r.fetch(g)}if(N(g)){if(g.dict.objId){if(t[g.dict.objId])continue;t[g.dict.objId]=!0}var p=g.dict.get("Resources");if(j(p)&&(!p.objId||!t[p.objId])){a.push(p);p.objId&&(t[p.objId]=!0)}}}}}return!1},buildFormXObject:function(e,t,a,r,i,n){var s=t.dict.getArray("Matrix"),o=t.dict.getArray("BBox"),c=t.dict.get("Group");if(c){var l,h={matrix:s,bbox:o,smask:a,isolated:!1,knockout:!1},u=c.get("S");if(F(u)&&"Transparency"===u.name){h.isolated=c.get("I")||!1;h.knockout=c.get("K")||!1;l=c.has("CS")?K.parse(c.get("CS"),this.xref,e):null}if(a&&a.backdrop){l=l||K.singletons.rgb;a.backdrop=l.getRgb(a.backdrop,0)}r.addOp(x.beginGroup,[h])}r.addOp(x.paintFormXObjectBegin,[s,o]);return this.getOperatorList(t,i,t.dict.get("Resources")||e,r,n).then(function(){r.addOp(x.paintFormXObjectEnd,[]);c&&r.addOp(x.endGroup,[h])})},buildPaintImageXObject:function(t,a,r,i,n,s){var o=this,c=a.dict,l=c.get("Width","W"),h=c.get("Height","H");if(l&&O(l)&&h&&O(h)){var u=this.options.maxImageSize;if(-1!==u&&l*h>u)M("Image exceeded maximum allowed size and was removed.");else{var f,d,g=c.get("ImageMask","IM")||!1;if(g){var p=c.get("Width","W"),m=c.get("Height","H"),b=p+7>>3,v=a.getBytes(b*m),y=c.getArray("Decode","D"),k=!!y&&y[0]>0;f=V.createMask(v,p,m,a instanceof _,k);f.cached=!0;d=[f];i.addOp(x.paintImageMaskXObject,d);n&&(s[n]={fn:x.paintImageMaskXObject,args:d})}else{var w=c.get("SMask","SM")||!1,C=c.get("Mask")||!1,S=200;if(!r||w||C||a instanceof z||!(S>l+h)){var A=this.uniquePrefix||"",I="img_"+A+ ++this.idCounters.obj;i.addDependency(I);d=[I,l,h];if(!w&&!C&&a instanceof z&&e.isSupported(a,this.xref,t)){i.addOp(x.paintJpegXObject,d);this.handler.send("obj",[I,this.pageIndex,"JpegStream",a.getIR(this.options.forceDataSchema)]); +}else{var B=null;(a instanceof z||C instanceof z||w instanceof z)&&(B=new e(o.xref,t,o.handler,o.options.forceDataSchema));V.buildImage(o.handler,o.xref,t,a,r,B).then(function(e){var t=e.createImageData(!1);o.handler.send("obj",[I,o.pageIndex,"Image",t],[t.data.buffer])}).then(void 0,function(e){M("Unable to decode image: "+e);o.handler.send("obj",[I,o.pageIndex,"Image",null])});i.addOp(x.paintImageXObject,d);n&&(s[n]={fn:x.paintImageXObject,args:d})}}else{var R=new V(this.xref,t,a,r,null,null);f=R.createImageData(!0);i.addOp(x.paintInlineImageXObject,[f])}}}}else M("Image dimensions are missing, or not numbers.")},handleSMask:function(e,t,a,r,i){var n=e.get("G"),s={subtype:e.get("S").name,backdrop:e.get("BC")},o=e.get("TR");if(ae(o)){for(var c=re.parse(this.xref,o),l=new Uint8Array(256),h=new Float32Array(1),u=0;256>u;u++){h[0]=u/255;c(h,0,h,0);l[u]=255*h[0]|0}s.transferMap=l}return this.buildFormXObject(t,n,s,a,r,i.state.clone())},handleTilingType:function(e,t,a,r,i,n,s){var o=new Ae,c=[i.get("Resources"),a],l=E.merge(this.xref,c);return this.getOperatorList(r,s,l,o).then(function(){n.addDependencies(o.dependencies);n.addOp(e,ne({fnArray:o.fnArray,argsArray:o.argsArray},i,t))})},handleSetFont:function(e,t,a,r,i,n){var s;if(t){t=t.slice();s=t[0].name}var o=this;return this.loadFont(s,a,this.xref,e).then(function(t){return t.font.isType3Font?t.loadType3Data(o,e,r,i).then(function(){return t},function(e){o.handler.send("UnsupportedFeature",{featureId:k.font});return new Se("g_font_error",new J("Type3 font load error: "+e),t.font)}):t}).then(function(e){n.font=e.font;e.send(o.handler);return e.loadedName})},handleText:function(e,t){var a=t.font,r=a.charsToGlyphs(e),i=!!(t.textRenderingMode&C.ADD_TO_PATH_FLAG);if(a.data&&(i||this.options.disableFontFace))for(var n=function(e){if(!a.renderer.hasBuiltPath(e)){var t=a.renderer.getPathJs(e);this.handler.send("commonobj",[a.loadedName+"_path_"+e,"FontPath",t])}}.bind(this),s=0,o=r.length;o>s;s++){var c=r[s];n(c.fontChar);var l=c.accent;l&&l.fontChar&&n(l.fontChar)}return r},setGState:function(e,t,a,r,i,n){for(var s=[],o=t.getKeys(),c=this,l=Promise.resolve(),h=0,u=o.length;u>h;h++){var f=o[h],d=t.get(f);switch(f){case"Type":break;case"LW":case"LC":case"LJ":case"ML":case"D":case"RI":case"FL":case"CA":case"ca":s.push([f,d]);break;case"Font":l=l.then(function(){return c.handleSetFont(e,null,d[0],a,r,n.state).then(function(e){a.addDependency(e);s.push([f,[e,d[1]]])})});break;case"BM":s.push([f,d]);break;case"SMask":if(F(d)&&"None"===d.name){s.push([f,!1]);break}if(j(d)){l=l.then(function(t){return c.handleSMask(t,e,a,r,n)}.bind(this,d));s.push([f,!0])}else M("Unsupported SMask type");break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":R("graphic state operator "+f);break;default:R("Unknown graphic state operator "+f)}}return l.then(function(){s.length>0&&a.addOp(x.setGState,[s])})},loadFont:function(e,t,a,r){function i(){return Promise.resolve(new Se("g_font_error",new J("Font "+e+" is not available"),t))}var n;if(t){A(U(t));n=t}else{var s=r.get("Font");if(!s){M("fontRes not available");return i()}n=s.getRaw(e)}if(!n){M("fontRef not available");return i()}if(this.fontCache.has(n))return this.fontCache.get(n);t=a.fetchIfRef(n);if(!j(t))return i();if(t.translated)return t.translated;var o=I(),c=this.preEvaluateFont(t,a),l=c.descriptor,h=n.num+"_"+n.gen;if(j(l)){l.fontAliases||(l.fontAliases=Object.create(null));var u=l.fontAliases,f=c.hash;if(u[f]){var d=u[f].aliasRef;if(d&&this.fontCache.has(d)){this.fontCache.putAlias(n,d);return this.fontCache.get(n)}}u[f]||(u[f]={fontID:Q.getFontID()});u[f].aliasRef=n;h=u[f].fontID}var g=j(n);g||this.fontCache.put(n,o.promise);t.loadedName="g_"+this.pdfManager.docId+"_f"+(g?e.replace(/\W/g,""):h);t.translated=o.promise;var p;try{p=this.translateFont(c,a)}catch(m){p=Promise.reject(m)}var b=this;p.then(function(e){if(void 0!==e.fontType){var r=a.stats.fontTypes;r[e.fontType]=!0}o.resolve(new Se(t.loadedName,e,t))},function(e){b.handler.send("UnsupportedFeature",{featureId:k.font});try{var r=c.descriptor,i=r&&r.get("FontFile3"),n=i&&i.get("Subtype"),s=te(c.type,n&&n.name),l=a.stats.fontTypes;l[s]=!0}catch(h){}o.resolve(new Se(t.loadedName,new J(e instanceof Error?e.message:e),t))});return o.promise},buildPath:function(e,t,a){var r=e.length-1;a||(a=[]);if(0>r||e.fnArray[r]!==x.constructPath)e.addOp(x.constructPath,[[t],a]);else{var i=e.argsArray[r];i[0].push(t);Array.prototype.push.apply(i[1],a)}},handleColorN:function(e,t,a,r,i,n,s,l){var h,u=a[a.length-1];if(F(u)&&(h=i.get(u.name))){var f=N(h)?h.dict:h,d=f.get("PatternType");if(d===o){var g=r.base?r.base.getRgb(a,0):null;return this.handleTilingType(t,g,n,h,f,e,s)}if(d===c){var p=f.get("Shading"),m=f.getArray("Matrix");h=ie.parseShading(p,m,l,n,this.handler);e.addOp(t,h.getIR());return Promise.resolve()}return Promise.reject("Unknown PatternType: "+d)}e.addOp(t,a);return Promise.resolve()},getOperatorList:function(e,t,r,i,n){var o=this,c=this.xref,l=Object.create(null);A(i);r=r||E.empty;var h=r.get("XObject")||E.empty,u=r.get("Pattern")||E.empty,f=new Ie(n||new Re),d=new Te(e,c,f),g=new a;return new Promise(function p(e,a){var n=function(t){t.then(function(){try{p(e,a)}catch(t){a(t)}},a)};t.ensureNotTerminated();g.reset();for(var m,b,v,y,k={};!(m=g.check());){k.args=null;if(!d.read(k))break;var w=k.args,C=k.fn;switch(0|C){case x.paintXObject:if(w[0].code)break;var S=w[0].name;if(!S){M("XObject must be referred to by name.");continue}if(void 0!==l[S]){i.addOp(l[S].fn,l[S].args);w=null;continue}var I=h.get(S);if(I){A(N(I),"XObject should be a stream");var T=I.dict.get("Subtype");A(F(T),"XObject should have a Name subtype");if("Form"===T.name){f.save();n(o.buildFormXObject(r,I,null,i,t,f.state.clone()).then(function(){f.restore()}));return}if("Image"===T.name){o.buildPaintImageXObject(r,I,!1,i,S,l);w=null;continue}if("PS"===T.name){R("Ignored XObject subtype PS");continue}B("Unhandled XObject subtype "+T.name)}break;case x.setFont:var L=w[1];n(o.handleSetFont(r,w,null,i,t,f.state).then(function(e){i.addDependency(e);i.addOp(x.setFont,[e,L])}));return;case x.endInlineImage:var D=w[0].cacheKey;if(D){var q=l[D];if(void 0!==q){i.addOp(q.fn,q.args);w=null;continue}}o.buildPaintImageXObject(r,w[0],!0,i,D,l);w=null;continue;case x.showText:w[0]=o.handleText(w[0],f.state);break;case x.showSpacedText:var U=w[0],_=[],z=U.length,H=f.state;for(b=0;z>b;++b){var G=U[b];P(G)?Array.prototype.push.apply(_,o.handleText(G,H)):O(G)&&_.push(G)}w[0]=_;C=x.showText;break;case x.nextLineShowText:i.addOp(x.nextLine);w[0]=o.handleText(w[0],f.state);C=x.showText;break;case x.nextLineSetSpacingShowText:i.addOp(x.nextLine);i.addOp(x.setWordSpacing,[w.shift()]);i.addOp(x.setCharSpacing,[w.shift()]);w[0]=o.handleText(w[0],f.state);C=x.showText;break;case x.setTextRenderingMode:f.state.textRenderingMode=w[0];break;case x.setFillColorSpace:f.state.fillColorSpace=K.parse(w[0],c,r);continue;case x.setStrokeColorSpace:f.state.strokeColorSpace=K.parse(w[0],c,r);continue;case x.setFillColor:y=f.state.fillColorSpace;w=y.getRgb(w,0);C=x.setFillRGBColor;break;case x.setStrokeColor:y=f.state.strokeColorSpace;w=y.getRgb(w,0);C=x.setStrokeRGBColor;break;case x.setFillGray:f.state.fillColorSpace=K.singletons.gray;w=K.singletons.gray.getRgb(w,0);C=x.setFillRGBColor;break;case x.setStrokeGray:f.state.strokeColorSpace=K.singletons.gray;w=K.singletons.gray.getRgb(w,0);C=x.setStrokeRGBColor;break;case x.setFillCMYKColor:f.state.fillColorSpace=K.singletons.cmyk;w=K.singletons.cmyk.getRgb(w,0);C=x.setFillRGBColor;break;case x.setStrokeCMYKColor:f.state.strokeColorSpace=K.singletons.cmyk;w=K.singletons.cmyk.getRgb(w,0);C=x.setStrokeRGBColor;break;case x.setFillRGBColor:f.state.fillColorSpace=K.singletons.rgb;w=K.singletons.rgb.getRgb(w,0);break;case x.setStrokeRGBColor:f.state.strokeColorSpace=K.singletons.rgb;w=K.singletons.rgb.getRgb(w,0);break;case x.setFillColorN:y=f.state.fillColorSpace;if("Pattern"===y.name){n(o.handleColorN(i,x.setFillColorN,w,y,u,r,t,c));return}w=y.getRgb(w,0);C=x.setFillRGBColor;break;case x.setStrokeColorN:y=f.state.strokeColorSpace;if("Pattern"===y.name){n(o.handleColorN(i,x.setStrokeColorN,w,y,u,r,t,c));return}w=y.getRgb(w,0);C=x.setStrokeRGBColor;break;case x.shadingFill:var X=r.get("Shading");X||B("No shading resource found");var W=X.get(w[0].name);W||B("No shading object found");var V=ie.parseShading(W,null,c,r,o.handler),Y=V.getIR();w=[Y];C=x.shadingFill;break;case x.setGState:var J=w[0],Z=r.get("ExtGState");if(!j(Z)||!Z.has(J.name))break;var Q=Z.get(J.name);n(o.setGState(r,Q,i,t,c,f));return;case x.moveTo:case x.lineTo:case x.curveTo:case x.curveTo2:case x.curveTo3:case x.closePath:o.buildPath(i,C,w);continue;case x.rectangle:o.buildPath(i,C,w);continue;case x.markPoint:case x.markPointProps:case x.beginMarkedContent:case x.beginMarkedContentProps:case x.endMarkedContent:case x.beginCompat:case x.endCompat:continue;default:if(null!==w){for(b=0,v=w.length;v>b&&!(w[b]instanceof E);b++);if(v>b){M("getOperatorList - ignoring operator: "+C);continue}}}i.addOp(C,w)}if(m)n(s);else{for(b=0,v=d.savedStatesDepth;v>b;b++)i.addOp(x.restore,[]);e()}})},getTextContent:function(e,t,r,i,n){function o(){if(m.initialized)return m;var e=B.font;e.loadedName in p.styles||(p.styles[e.loadedName]={fontFamily:e.fallbackName,ascent:e.ascent,descent:e.descent,vertical:e.vertical});m.fontName=e.loadedName;var t=[B.fontSize*B.textHScale,0,0,B.fontSize,0,B.textRise];if(e.isType3Font&&B.fontMatrix!==v&&1===B.fontSize){var a=e.bbox[3]-e.bbox[1];if(a>0){a*=B.fontMatrix[3];t[3]*=a}}var r=S.transform(B.ctm,S.transform(B.textMatrix,t));m.transform=r;if(e.vertical){m.width=Math.sqrt(r[0]*r[0]+r[1]*r[1]);m.height=0;m.vertical=!0}else{m.width=0;m.height=Math.sqrt(r[2]*r[2]+r[3]*r[3]);m.vertical=!1}var i=B.textLineMatrix[0],n=B.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=B.ctm[0];n=B.ctm[1];var o=Math.sqrt(i*i+n*n);m.textAdvanceScale=o*s;m.lastAdvanceWidth=0;m.lastAdvanceHeight=0;var c=e.spaceWidth/1e3*B.fontSize;if(c){m.spaceWidth=c;m.fakeSpaceMin=c*b;m.fakeMultiSpaceMin=c*k;m.fakeMultiSpaceMax=c*w;m.textRunBreakAllowed=!e.isMonospace}else{m.spaceWidth=0;m.fakeSpaceMin=1/0;m.fakeMultiSpaceMin=1/0;m.fakeMultiSpaceMax=0;m.textRunBreakAllowed=!1}m.initialized=!0;return m}function c(e){for(var t,a=0,r=e.length;r>a&&(t=e.charCodeAt(a))>=32&&127>=t;)a++;return r>a?e.replace(g," "):e}function l(e){var t=e.str.join(""),a=le(t,-1,e.vertical);return{str:n?c(a.str):a.str,dir:a.dir,width:e.width,height:e.height,transform:e.transform,fontName:e.fontName}}function h(e,t){return C.loadFont(e,t,I,r).then(function(e){B.font=e.font;B.fontMatrix=e.font.fontMatrix||v})}function u(e){for(var t=B.font,a=o(),r=0,i=0,n=t.charsToGlyphs(e),s=t.defaultVMetrics,c=0;c0&&f(b,a.str)}var v=0,y=0;if(t.vertical){var k=d*B.fontMatrix[0];y=k*B.fontSize+m;i+=y}else{var w=d*B.fontMatrix[0];v=(w*B.fontSize+m)*B.textHScale;r+=v}B.translateTextMatrix(v,y);a.str.push(g)}if(t.vertical){a.lastAdvanceHeight=i;a.height+=Math.abs(i*a.textAdvanceScale)}else{a.lastAdvanceWidth=r;a.width+=r*a.textAdvanceScale}return a}function f(e,t){if(!(e0;)t.push(" ")}function d(){if(m.initialized){p.items.push(l(m));m.initialized=!1;m.str.length=0}}i=i||new Ie(new Be);var g=/\s/g,p={items:[],styles:Object.create(null)},m={initialized:!1,str:[],width:0,height:0,vertical:!1,lastAdvanceWidth:0,lastAdvanceHeight:0,textAdvanceScale:0,spaceWidth:0,fakeSpaceMin:1/0,fakeMultiSpaceMin:1/0,fakeMultiSpaceMax:-0,textRunBreakAllowed:!1,transform:null,fontName:null},b=.3,k=1.5,w=4,C=this,I=this.xref;r=I.fetchIfRef(r)||E.empty;var B,R=null,O=Object.create(null),P=new Te(e,I,i),L=new a;return new Promise(function M(e,a){var c=function(t){t.then(function(){try{M(e,a)}catch(t){a(t)}},a)};t.ensureNotTerminated();L.reset();for(var l,g={},b=[];!(l=L.check());){b.length=0;g.args=b;if(!P.read(g))break;B=i.state;var v=g.fn;b=g.args;var k,w;switch(0|v){case x.setFont:d();B.fontSize=b[1];c(h(b[0].name,null));return;case x.setTextRise:d();B.textRise=b[0];break;case x.setHScale:d();B.textHScale=b[0]/100;break;case x.setLeading:d();B.leading=b[0];break;case x.moveText:var I=B.font?0===(B.font.vertical?b[0]:b[1]):!1;k=b[0]-b[1];if(I&&m.initialized&&k>0&&k<=m.fakeMultiSpaceMax){B.translateTextLineMatrix(b[0],b[1]);m.width+=b[0]-m.lastAdvanceWidth;m.height+=b[1]-m.lastAdvanceHeight;w=b[0]-m.lastAdvanceWidth-(b[1]-m.lastAdvanceHeight);f(w,m.str);break}d();B.translateTextLineMatrix(b[0],b[1]);B.textMatrix=B.textLineMatrix.slice();break;case x.setLeadingMoveText:d();B.leading=-b[1];B.translateTextLineMatrix(b[0],b[1]);B.textMatrix=B.textLineMatrix.slice();break;case x.nextLine:d();B.carriageReturn();break;case x.setTextMatrix:k=B.calcTextLineMatrixAdvance(b[0],b[1],b[2],b[3],b[4],b[5]);if(null!==k&&m.initialized&&k.value>0&&k.value<=m.fakeMultiSpaceMax){B.translateTextLineMatrix(k.width,k.height);m.width+=k.width-m.lastAdvanceWidth;m.height+=k.height-m.lastAdvanceHeight;w=k.width-m.lastAdvanceWidth-(k.height-m.lastAdvanceHeight);f(w,m.str);break}d();B.setTextMatrix(b[0],b[1],b[2],b[3],b[4],b[5]);B.setTextLineMatrix(b[0],b[1],b[2],b[3],b[4],b[5]);break;case x.setCharSpacing:B.charSpacing=b[0];break;case x.setWordSpacing:B.wordSpacing=b[0];break;case x.beginText:d();B.textMatrix=y.slice();B.textLineMatrix=y.slice();break;case x.showSpacedText:for(var D,q=b[0],U=0,_=q.length;_>U;U++)if("string"==typeof q[U])u(q[U]);else{o();k=q[U]*B.fontSize/1e3;var z=!1;if(B.font.vertical){D=k*(B.textHScale*B.textMatrix[2]+B.textMatrix[3]);B.translateTextMatrix(0,k);z=m.textRunBreakAllowed&&k>m.fakeMultiSpaceMax;z||(m.height+=D)}else{k=-k;D=k*(B.textHScale*B.textMatrix[0]+B.textMatrix[1]);B.translateTextMatrix(k,0);z=m.textRunBreakAllowed&&k>m.fakeMultiSpaceMax;z||(m.width+=D)}z?d():k>0&&f(k,m.str)}break;case x.showText:u(b[0]);break;case x.nextLineShowText:d();B.carriageReturn();u(b[0]);break;case x.nextLineSetSpacingShowText:d();B.wordSpacing=b[0];B.charSpacing=b[1];B.carriageReturn();u(b[2]);break;case x.paintXObject:d();if(b[0].code)break;R||(R=r.get("XObject")||E.empty);var H=b[0].name;if(O.key===H){if(O.texts){S.appendToArray(p.items,O.texts.items);S.extendObj(p.styles,O.texts.styles)}break}var G=R.get(H);if(!G)break;A(N(G),"XObject should be a stream");var X=G.dict.get("Subtype");A(F(X),"XObject should have a Name subtype");if("Form"!==X.name){O.key=H;O.texts=null;break}i.save();var W=G.dict.getArray("Matrix");T(W)&&6===W.length&&i.transform(W);c(C.getTextContent(G,t,G.dict.get("Resources")||r,i,n).then(function(e){S.appendToArray(p.items,e.items);S.extendObj(p.styles,e.styles);i.restore();O.key=H;O.texts=e}));return;case x.setGState:d();var V=b[0],K=r.get("ExtGState");if(!j(K)||!F(V))break;var Y=K.get(V.name);if(!j(Y))break;var J=Y.get("Font");if(J){B.fontSize=J[1];c(h(null,J[0]));return}}}if(l)c(s);else{d();e(p)}})},extractDataStructures:function(e,t,a,r){var i=e.get("ToUnicode")||t.get("ToUnicode"),n=i?this.readToUnicode(i):Promise.resolve(void 0);if(r.composite){var s=e.get("CIDSystemInfo");j(s)&&(r.cidSystemInfo={registry:s.get("Registry"),ordering:s.get("Ordering"),supplement:s.get("Supplement")});var o=e.get("CIDToGIDMap");N(o)&&(r.cidToGidMap=this.readCidToGidMap(o))}var c,l=[],h=null;if(e.has("Encoding")){c=e.get("Encoding");if(j(c)){h=c.get("BaseEncoding");h=F(h)?h.name:null;if(c.has("Differences"))for(var u=c.get("Differences"),f=0,d=0,g=u.length;g>d;d++){var p=a.fetchIfRef(u[d]);O(p)?f=p:F(p)?l[f++]=p.name:B("Invalid entry in 'Differences' array: "+p)}}else F(c)?h=c.name:B("Encoding is not a Name nor a Dict");"MacRomanEncoding"!==h&&"MacExpertEncoding"!==h&&"WinAnsiEncoding"!==h&&(h=null)}if(h)r.defaultEncoding=pe(h).slice();else{c="TrueType"===r.type?he:ue;if(r.flags&Z.Symbolic){c=fe;r.file||(/Symbol/i.test(r.name)?c=de:/Dingbats/i.test(r.name)&&(c=ge))}r.defaultEncoding=c}r.differences=l;r.baseEncodingName=h;r.dict=e;return n.then(function(e){r.toUnicode=e;return this.buildToUnicode(r)}.bind(this)).then(function(e){r.toUnicode=e;return r})},buildToUnicode:function(e){if(e.toUnicode&&0!==e.toUnicode.length)return Promise.resolve(e.toUnicode);var t,a;if(!e.composite){t=[];var r=e.defaultEncoding.slice(),i=e.baseEncodingName,n=e.differences;for(a in n)r[a]=n[a];var s=xe();for(a in r){var o=r[a];if(""!==o)if(void 0!==s[o])t[a]=String.fromCharCode(s[o]);else{var c=0;switch(o[0]){case"G":3===o.length&&(c=parseInt(o.substr(1),16));break;case"g":5===o.length&&(c=parseInt(o.substr(1),16));break;case"C":case"c":o.length>=3&&(c=+o.substr(1));break;default:var l=we(o,s);-1!==l&&(c=l)}if(c){if(i&&c===+a){var h=pe(i);if(h&&(o=h[a])){t[a]=String.fromCharCode(s[o]);continue}}t[a]=String.fromCharCode(c)}}}return Promise.resolve(new ee(t))}if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof oe)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){var u=e.cidSystemInfo.registry,f=e.cidSystemInfo.ordering,d=D.get(u+"-"+f+"-UCS2");return se.create(d,this.options.cMapOptions,null).then(function(a){var r=e.cMap;t=[];r.forEach(function(e,r){A(65535>=r,"Max size of CID is 65,535");var i=a.lookup(r);i&&(t[e]=String.fromCharCode((i.charCodeAt(0)<<8)+i.charCodeAt(1)))});return new ee(t)})}return Promise.resolve(new $(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return F(t)?se.create(t,this.options.cMapOptions,null).then(function(e){return e instanceof oe?new $(0,65535):new ee(e.getMap())}):N(t)?se.create(t,this.options.cMapOptions,null).then(function(e){if(e instanceof oe)return new $(0,65535);var t=new Array(e.length);e.forEach(function(e,a){for(var r=[],i=0;ir;r++){var n=t[r++]<<8|t[r];if(0!==n){var s=r>>1;a[s]=n}}return a},extractWidths:function(e,t,a,r){var i,n,s,o,c,l,h,u,f=[],d=0,g=[];if(r.composite){d=e.get("DW")||1e3;u=e.get("W");if(u)for(n=0,s=u.length;s>n;n++){l=u[n++];h=t.fetchIfRef(u[n]);if(T(h))for(o=0,c=h.length;c>o;o++)f[l++]=h[o];else{var p=u[++n];for(o=l;h>=o;o++)f[o]=p}}if(r.vertical){var m=e.get("DW2")||[880,-1e3];i=[m[1],.5*d,m[0]];m=e.get("W2");if(m)for(n=0,s=m.length;s>n;n++){l=m[n++];h=t.fetchIfRef(m[n]);if(T(h))for(o=0,c=h.length;c>o;o++)g[l++]=[h[o++],h[o++],h[o]];else{var b=[m[++n],m[++n],m[++n]];for(o=l;h>=o;o++)g[o]=b}}}}else{var v=r.firstChar;u=e.get("Widths");if(u){o=v;for(n=0,s=u.length;s>n;n++)f[o++]=u[n];d=parseFloat(a.get("MissingWidth"))||0}else{var y=e.get("BaseFont");if(F(y)){var k=this.getBaseFontMetrics(y.name);f=this.buildCharCodeToWidth(k.widths,r);d=k.defaultWidth}}}var w=!0,x=d;for(var C in f){var S=f[C];if(S)if(x){if(x!==S){w=!1;break}}else x=S}w&&(r.flags|=Z.FixedPitch);r.defaultWidth=d;r.widths=f;r.defaultVMetrics=i;r.vmetrics=g},isSerifFont:function(e){var t=e.split("-")[0];return t in be()||-1!==t.search(/serif/gi)},getBaseFontMetrics:function(e){var t=0,a=[],r=!1,i=me(),n=i[e]||e,s=ce();n in s||(n=this.isSerifFont(e)?"Times-Roman":"Helvetica");var o=s[n];if(O(o)){t=o;r=!0}else a=o();return{defaultWidth:t,monospace:r,widths:a}},buildCharCodeToWidth:function(e,t){for(var a=Object.create(null),r=t.differences,i=t.defaultEncoding,n=0;256>n;n++)n in r&&e[r[n]]?a[n]=e[r[n]]:n in i&&e[i[n]]&&(a[n]=e[i[n]]);return a},preEvaluateFont:function(e,t){var a=e,r=e.get("Subtype");A(F(r),"invalid font Subtype");var i,n=!1;if("Type0"===r.name){var s=e.get("DescendantFonts");s||B("Descendant fonts are not specified");e=T(s)?t.fetchIfRef(s[0]):s;r=e.get("Subtype");A(F(r),"invalid font Subtype");n=!0}var o=e.get("FontDescriptor");if(o){var c=new Y,l=a.getRaw("Encoding");if(F(l))c.update(l.name);else if(U(l))c.update(l.num+"_"+l.gen);else if(j(l))for(var h=l.getKeys(),u=0,f=h.length;f>u;u++){var d=l.getRaw(h[u]);F(d)?c.update(d.name):U(d)?c.update(d.num+"_"+d.gen):T(d)&&c.update(d.length.toString())}var g=e.get("ToUnicode")||a.get("ToUnicode");if(N(g)){var p=g.str||g;i=p.buffer?new Uint8Array(p.buffer.buffer,0,p.bufferLength):new Uint8Array(p.bytes.buffer,p.start,p.end-p.start);c.update(i)}else F(g)&&c.update(g.name);var m=e.get("Widths")||a.get("Widths");if(m){i=new Uint8Array(new Uint32Array(m).buffer);c.update(i)}}return{descriptor:o,dict:e,baseDict:a,composite:n,type:r.name,hash:c?c.hexdigest():""}},translateFont:function(e,t){var a,r=e.baseDict,i=e.dict,n=e.composite,s=e.descriptor,o=e.type,c=n?65535:255,l=this.options.cMapOptions;if(!s){if("Type3"!==o){var h=i.get("BaseFont");F(h)||B("Base font is not specified");h=h.name.replace(/[,_]/g,"-");var u=this.getBaseFontMetrics(h),f=h.split("-")[0],d=(this.isSerifFont(f)?Z.Serif:0)|(u.monospace?Z.FixedPitch:0)|(ve()[f]?Z.Symbolic:Z.Nonsymbolic);a={type:o,name:h,widths:u.widths,defaultWidth:u.defaultWidth,flags:d,firstChar:0,lastChar:c};return this.extractDataStructures(i,i,t,a).then(function(e){e.widths=this.buildCharCodeToWidth(u.widths,e);return new Q(h,null,e)}.bind(this))}s=new E(null);s.set("FontName",D.get(o));s.set("FontBBox",i.getArray("FontBBox"))}var g=i.get("FirstChar")||0,p=i.get("LastChar")||c,m=s.get("FontName"),b=i.get("BaseFont");P(m)&&(m=D.get(m));P(b)&&(b=D.get(b));if("Type3"!==o){var y=m&&m.name,k=b&&b.name;if(y!==k){R("The FontDescriptor's FontName is \""+y+'" but should be the same as the Font\'s BaseFont "'+k+'"');y&&k&&0===k.indexOf(y)&&(m=b)}}m=m||b;A(F(m),"invalid font name");var w=s.get("FontFile","FontFile2","FontFile3");if(w&&w.dict){var x=w.dict.get("Subtype");x&&(x=x.name);var C=w.dict.get("Length1"),S=w.dict.get("Length2"),I=w.dict.get("Length3")}a={type:o,name:m.name,subtype:x,file:w,length1:C,length2:S,length3:I,loadedName:r.loadedName,composite:n,wideChars:n,fixedPitch:!1,fontMatrix:i.getArray("FontMatrix")||v,firstChar:g||0,lastChar:p||c,bbox:s.getArray("FontBBox"),ascent:s.get("Ascent"),descent:s.get("Descent"),xHeight:s.get("XHeight"),capHeight:s.get("CapHeight"),flags:s.get("Flags"),italicAngle:s.get("ItalicAngle"),coded:!1};var T;if(n){var O=r.get("Encoding");F(O)&&(a.cidEncoding=O.name);T=se.create(O,l,null).then(function(e){a.cMap=e;a.vertical=a.cMap.vertical})}else T=Promise.resolve(void 0);return T.then(function(){return this.extractDataStructures(i,r,t,a)}.bind(this)).then(function(e){this.extractWidths(i,t,s,e);"Type3"===o&&(e.isType3Font=!0);return new Q(m.name,w,e)}.bind(this))}};return t}(),Se=function(){function e(e,t,a){this.loadedName=e;this.font=t;this.dict=a;this.type3Loaded=null;this.sent=!1}e.prototype={send:function(e){if(!this.sent){var t=this.font.exportData();e.send("commonobj",[this.loadedName,"Font",t]);this.sent=!0}},loadType3Data:function(e,t,a,r){A(this.font.isType3Font);if(this.type3Loaded)return this.type3Loaded;for(var i=this.font,n=Promise.resolve(),s=this.dict.get("CharProcs"),o=this.dict.get("Resources")||t,c=s.getKeys(),l=Object.create(null),h=0,u=c.length;u>h;++h)n=n.then(function(t){var i=s.get(t),n=new Ae;return e.getOperatorList(i,r,o,n).then(function(){l[t]=n.getIR();a.addDependencies(n.dependencies)},function(e){M('Type3 font resource "'+t+'" is not available');var a=new Ae;l[t]=a.getIR()})}.bind(this,c[h]));this.type3Loaded=n.then(function(){i.charProcOperatorList=l});return this.type3Loaded}};return e}(),Ae=function(){function e(e){for(var t=[],a=e.fnArray,r=e.argsArray,i=0,n=e.length;n>i;i++)switch(a[i]){case x.paintInlineImageXObject:case x.paintInlineImageXObjectGroup:case x.paintImageMaskXObject:var s=r[i][0];s.cached||t.push(s.data.buffer)}return t}function t(e,t,a){this.messageHandler=t;this.fnArray=[];this.argsArray=[];this.dependencies=Object.create(null);this._totalLength=0;this.pageIndex=a;this.intent=e}var a=1e3,r=a-5;t.prototype={get length(){return this.argsArray.length},get totalLength(){return this._totalLength+this.length},addOp:function(e,t){this.fnArray.push(e);this.argsArray.push(t);this.messageHandler&&(this.fnArray.length>=a?this.flush():this.fnArray.length>=r&&(e===x.restore||e===x.endText)&&this.flush())},addDependency:function(e){if(!(e in this.dependencies)){this.dependencies[e]=!0;this.addOp(x.dependency,[e])}},addDependencies:function(e){for(var t in e)this.addDependency(t)},addOpList:function(e){S.extendObj(this.dependencies,e.dependencies);for(var t=0,a=e.length;a>t;t++)this.addOp(e.fnArray[t],e.argsArray[t])},getIR:function(){return{fnArray:this.fnArray,argsArray:this.argsArray,length:this.length}},flush:function(t){"oplist"!==this.intent&&(new Oe).optimize(this);var a=e(this),r=this.length;this._totalLength+=r;this.messageHandler.send("RenderPageChunk",{operatorList:{fnArray:this.fnArray,argsArray:this.argsArray,lastChunk:t,length:r},pageIndex:this.pageIndex,intent:this.intent},a);this.dependencies=Object.create(null);this.fnArray.length=0;this.argsArray.length=0}};return t}(),Ie=function(){function e(e){this.state=e;this.stateStack=[]}e.prototype={save:function(){var e=this.state;this.stateStack.push(this.state);this.state=e.clone()},restore:function(){var e=this.stateStack.pop();e&&(this.state=e)},transform:function(e){this.state.ctm=S.transform(this.state.ctm,e)}};return e}(),Be=function(){function e(){this.ctm=new Float32Array(y);this.fontSize=0;this.font=null;this.fontMatrix=v;this.textMatrix=y.slice();this.textLineMatrix=y.slice();this.charSpacing=0;this.wordSpacing=0;this.leading=0;this.textHScale=1;this.textRise=0}e.prototype={setTextMatrix:function(e,t,a,r,i,n){var s=this.textMatrix;s[0]=e;s[1]=t;s[2]=a;s[3]=r;s[4]=i;s[5]=n},setTextLineMatrix:function(e,t,a,r,i,n){var s=this.textLineMatrix;s[0]=e;s[1]=t;s[2]=a;s[3]=r;s[4]=i;s[5]=n},translateTextMatrix:function(e,t){var a=this.textMatrix;a[4]=a[0]*e+a[2]*t+a[4];a[5]=a[1]*e+a[3]*t+a[5]},translateTextLineMatrix:function(e,t){var a=this.textLineMatrix;a[4]=a[0]*e+a[2]*t+a[4];a[5]=a[1]*e+a[3]*t+a[5]},calcTextLineMatrixAdvance:function(e,t,a,r,i,n){var s=this.font;if(!s)return null;var o=this.textLineMatrix;if(e!==o[0]||t!==o[1]||a!==o[2]||r!==o[3])return null;var c=i-o[4],l=n-o[5];if(s.vertical&&0!==c||!s.vertical&&0!==l)return null;var h,u,f=e*r-t*a;if(s.vertical){h=-l*a/f;u=l*e/f}else{h=c*r/f;u=-c*t/f}return{width:h,height:u,value:s.vertical?u:h}},calcRenderMatrix:function(e){var t=[this.fontSize*this.textHScale,0,0,this.fontSize,0,this.textRise];return S.transform(e,S.transform(this.textMatrix,t))},carriageReturn:function(){this.translateTextLineMatrix(0,-this.leading);this.textMatrix=this.textLineMatrix.slice()},clone:function(){var e=Object.create(this);e.textMatrix=this.textMatrix.slice();e.textLineMatrix=this.textLineMatrix.slice();e.fontMatrix=this.fontMatrix.slice();return e}};return e}(),Re=function(){function e(){this.ctm=new Float32Array(y);this.font=null;this.textRenderingMode=C.FILL;this.fillColorSpace=K.singletons.gray;this.strokeColorSpace=K.singletons.gray}e.prototype={clone:function(){return Object.create(this)}};return e}(),Te=function(){function e(e,a,r){this.opMap=t();this.parser=new X(new G(e,this.opMap),!1,a);this.stateManager=r;this.nonProcessedArgs=[]}var t=L(function(e){e.w={id:x.setLineWidth,numArgs:1,variableArgs:!1};e.J={id:x.setLineCap,numArgs:1,variableArgs:!1};e.j={id:x.setLineJoin,numArgs:1,variableArgs:!1};e.M={id:x.setMiterLimit,numArgs:1,variableArgs:!1};e.d={id:x.setDash,numArgs:2,variableArgs:!1};e.ri={id:x.setRenderingIntent,numArgs:1,variableArgs:!1};e.i={id:x.setFlatness,numArgs:1,variableArgs:!1};e.gs={id:x.setGState,numArgs:1,variableArgs:!1};e.q={id:x.save,numArgs:0,variableArgs:!1};e.Q={id:x.restore,numArgs:0,variableArgs:!1};e.cm={id:x.transform,numArgs:6,variableArgs:!1};e.m={id:x.moveTo,numArgs:2,variableArgs:!1};e.l={id:x.lineTo,numArgs:2,variableArgs:!1};e.c={id:x.curveTo,numArgs:6,variableArgs:!1};e.v={id:x.curveTo2,numArgs:4,variableArgs:!1};e.y={id:x.curveTo3,numArgs:4,variableArgs:!1};e.h={id:x.closePath,numArgs:0,variableArgs:!1};e.re={id:x.rectangle,numArgs:4,variableArgs:!1};e.S={id:x.stroke,numArgs:0,variableArgs:!1};e.s={id:x.closeStroke,numArgs:0,variableArgs:!1};e.f={id:x.fill,numArgs:0,variableArgs:!1};e.F={id:x.fill,numArgs:0,variableArgs:!1};e["f*"]={id:x.eoFill,numArgs:0,variableArgs:!1};e.B={id:x.fillStroke,numArgs:0,variableArgs:!1};e["B*"]={id:x.eoFillStroke,numArgs:0,variableArgs:!1};e.b={id:x.closeFillStroke,numArgs:0,variableArgs:!1};e["b*"]={id:x.closeEOFillStroke,numArgs:0,variableArgs:!1};e.n={id:x.endPath,numArgs:0,variableArgs:!1};e.W={id:x.clip,numArgs:0,variableArgs:!1};e["W*"]={id:x.eoClip,numArgs:0,variableArgs:!1};e.BT={id:x.beginText,numArgs:0,variableArgs:!1};e.ET={id:x.endText,numArgs:0,variableArgs:!1};e.Tc={id:x.setCharSpacing,numArgs:1,variableArgs:!1};e.Tw={id:x.setWordSpacing,numArgs:1,variableArgs:!1};e.Tz={id:x.setHScale,numArgs:1,variableArgs:!1};e.TL={id:x.setLeading,numArgs:1,variableArgs:!1};e.Tf={id:x.setFont,numArgs:2,variableArgs:!1};e.Tr={id:x.setTextRenderingMode,numArgs:1,variableArgs:!1};e.Ts={id:x.setTextRise,numArgs:1,variableArgs:!1};e.Td={id:x.moveText,numArgs:2,variableArgs:!1};e.TD={id:x.setLeadingMoveText,numArgs:2,variableArgs:!1};e.Tm={id:x.setTextMatrix,numArgs:6,variableArgs:!1};e["T*"]={id:x.nextLine,numArgs:0,variableArgs:!1};e.Tj={id:x.showText,numArgs:1,variableArgs:!1};e.TJ={id:x.showSpacedText,numArgs:1,variableArgs:!1};e["'"]={id:x.nextLineShowText,numArgs:1,variableArgs:!1};e['"']={id:x.nextLineSetSpacingShowText,numArgs:3,variableArgs:!1};e.d0={id:x.setCharWidth,numArgs:2,variableArgs:!1};e.d1={id:x.setCharWidthAndBounds,numArgs:6,variableArgs:!1};e.CS={id:x.setStrokeColorSpace,numArgs:1,variableArgs:!1};e.cs={id:x.setFillColorSpace,numArgs:1,variableArgs:!1};e.SC={id:x.setStrokeColor,numArgs:4,variableArgs:!0};e.SCN={id:x.setStrokeColorN,numArgs:33,variableArgs:!0};e.sc={id:x.setFillColor,numArgs:4,variableArgs:!0};e.scn={id:x.setFillColorN,numArgs:33,variableArgs:!0};e.G={id:x.setStrokeGray,numArgs:1,variableArgs:!1};e.g={id:x.setFillGray,numArgs:1,variableArgs:!1};e.RG={id:x.setStrokeRGBColor,numArgs:3,variableArgs:!1};e.rg={id:x.setFillRGBColor,numArgs:3,variableArgs:!1};e.K={id:x.setStrokeCMYKColor,numArgs:4,variableArgs:!1};e.k={id:x.setFillCMYKColor,numArgs:4,variableArgs:!1};e.sh={id:x.shadingFill,numArgs:1,variableArgs:!1};e.BI={id:x.beginInlineImage,numArgs:0,variableArgs:!1};e.ID={id:x.beginImageData,numArgs:0,variableArgs:!1};e.EI={id:x.endInlineImage,numArgs:1,variableArgs:!1};e.Do={id:x.paintXObject,numArgs:1,variableArgs:!1};e.MP={id:x.markPoint,numArgs:1,variableArgs:!1};e.DP={id:x.markPointProps,numArgs:2,variableArgs:!1};e.BMC={id:x.beginMarkedContent,numArgs:1,variableArgs:!1};e.BDC={id:x.beginMarkedContentProps,numArgs:2,variableArgs:!1};e.EMC={id:x.endMarkedContent,numArgs:0,variableArgs:!1};e.BX={id:x.beginCompat,numArgs:0,variableArgs:!1};e.EX={id:x.endCompat,numArgs:0,variableArgs:!1};e.BM=null;e.BD=null;e["true"]=null;e.fa=null;e.fal=null;e.fals=null;e["false"]=null;e.nu=null;e.nul=null;e["null"]=null});e.prototype={get savedStatesDepth(){return this.stateManager.stateStack.length},read:function(e){for(var t=e.args;;){var a=this.parser.getObj();if(q(a)){var r=a.cmd,i=this.opMap[r];if(!i){M('Unknown command "'+r+'"');continue}var n=i.id,s=i.numArgs,o=null!==t?t.length:0;if(i.variableArgs)o>s&&R("Command "+n+": expected [0,"+s+"] args, but received "+o+" args");else{if(o!==s){for(var c=this.nonProcessedArgs;o>s;){c.push(t.shift());o--}for(;s>o&&0!==c.length;){t||(t=[]);t.unshift(c.pop());o++}}if(s>o){R("Command "+n+": because expected "+s+" args, but received "+o+" args; skipping");t=null;continue}}this.preprocessCommand(n,t); +e.fn=n;e.args=t;return!0}if(W(a))return!1;if(null!==a){t||(t=[]);t.push(a);A(t.length<=33,"Too many arguments")}}},preprocessCommand:function(e,t){switch(0|e){case x.save:this.stateManager.save();break;case x.restore:this.stateManager.restore();break;case x.transform:this.stateManager.transform(t)}}};return e}(),Oe=function(){function e(e,t,a){for(var r=e,i=0,n=t.length-1;n>i;i++){var s=t[i];r=r[s]||(r[s]=[])}r[t[t.length-1]]=a}function t(e,t,a,r){for(var i=e+2,n=0;t>n;n++){var s=r[i+4*n],o=1===s.length&&s[0];if(!o||1!==o.width||1!==o.height||o.data.length&&(1!==o.data.length||0!==o.data[0]))break;a[i+4*n]=x.paintSolidColorImageMask}return t-n}function a(){}var r=[];e(r,[x.save,x.transform,x.paintInlineImageXObject,x.restore],function(e){for(var t=10,a=200,r=1e3,i=1,n=e.fnArray,s=e.argsArray,o=e.iCurr,c=o-3,l=o-2,h=o-1,u=c+4,f=n.length;f>u+3&&n[u]===x.save&&n[u+1]===x.transform&&n[u+2]===x.paintInlineImageXObject&&n[u+3]===x.restore;)u+=4;var d=Math.min((u-c)/4,a);if(t>d)return u;var g,p=0,m=[],b=0,v=i,y=i;for(g=0;d>g;g++){var k=s[l+(g<<2)],C=s[h+(g<<2)][0];if(v+C.width>r){p=Math.max(p,v);y+=b+2*i;v=0;b=0}m.push({transform:k,x:v,y:y,w:C.width,h:C.height});v+=C.width+2*i;b=Math.max(b,C.height)}var S=Math.max(p,v)+i,A=y+b+i,I=new Uint8Array(S*A*4),B=S<<2;for(g=0;d>g;g++){var R=s[h+(g<<2)][0].data,T=m[g].w<<2,O=0,P=m[g].x+m[g].y*S<<2;I.set(R.subarray(0,T),P-B);for(var L=0,M=m[g].h;M>L;L++){I.set(R.subarray(O,O+T),P);O+=T;P+=B}I.set(R.subarray(O-T,O),P);for(;P>=0;){R[P-4]=R[P];R[P-3]=R[P+1];R[P-2]=R[P+2];R[P-1]=R[P+3];R[P+T]=R[P+T-4];R[P+T+1]=R[P+T-3];R[P+T+2]=R[P+T-2];R[P+T+3]=R[P+T-1];P-=B}}n.splice(c,4*d,x.paintInlineImageXObjectGroup);s.splice(c,4*d,[{width:S,height:A,kind:w.RGBA_32BPP,data:I},m]);return c+1});e(r,[x.save,x.transform,x.paintImageMaskXObject,x.restore],function(e){for(var a=10,r=100,i=1e3,n=e.fnArray,s=e.argsArray,o=e.iCurr,c=o-3,l=o-2,h=o-1,u=c+4,f=n.length;f>u+3&&n[u]===x.save&&n[u+1]===x.transform&&n[u+2]===x.paintImageMaskXObject&&n[u+3]===x.restore;)u+=4;var d=(u-c)/4;d=t(c,d,n,s);if(a>d)return u;var g,p,m,b=!1,v=s[h][0];if(0===s[l][1]&&0===s[l][2]){b=!0;var y=s[l][0],k=s[l][3];p=l+4;var w=h+4;for(g=1;d>g;g++,p+=4,w+=4){m=s[p];if(s[w][0]!==v||m[0]!==y||0!==m[1]||0!==m[2]||m[3]!==k){a>g?b=!1:d=g;break}}}if(b){d=Math.min(d,i);var C=new Float32Array(2*d);p=l;for(g=0;d>g;g++,p+=4){m=s[p];C[g<<1]=m[4];C[(g<<1)+1]=m[5]}n.splice(c,4*d,x.paintImageMaskXObjectRepeat);s.splice(c,4*d,[v,y,k,C])}else{d=Math.min(d,r);var S=[];for(g=0;d>g;g++){m=s[l+(g<<2)];var A=s[h+(g<<2)][0];S.push({data:A.data,width:A.width,height:A.height,transform:m})}n.splice(c,4*d,x.paintImageMaskXObjectGroup);s.splice(c,4*d,[S])}return c+1});e(r,[x.save,x.transform,x.paintImageXObject,x.restore],function(e){var t=3,a=1e3,r=e.fnArray,i=e.argsArray,n=e.iCurr,s=n-3,o=n-2,c=n-1,l=n;if(0!==i[o][1]||0!==i[o][2])return l+1;for(var h=i[c][0],u=i[o][0],f=i[o][3],d=s+4,g=r.length;g>d+3&&r[d]===x.save&&r[d+1]===x.transform&&r[d+2]===x.paintImageXObject&&r[d+3]===x.restore&&i[d+1][0]===u&&0===i[d+1][1]&&0===i[d+1][2]&&i[d+1][3]===f&&i[d+2][0]===h;)d+=4;var p=Math.min((d-s)/4,a);if(t>p)return d;for(var m=new Float32Array(2*p),b=o,v=0;p>v;v++,b+=4){var y=i[b];m[v<<1]=y[4];m[(v<<1)+1]=y[5]}var k=[h,u,f,m];r.splice(s,4*p,x.paintImageXObjectRepeat);i.splice(s,4*p,k);return s+1});e(r,[x.beginText,x.setFont,x.setTextMatrix,x.showText,x.endText],function(e){for(var t=3,a=1e3,r=e.fnArray,i=e.argsArray,n=e.iCurr,s=n-4,o=n-3,c=n-2,l=n-1,h=n,u=i[o][0],f=i[o][1],d=s+5,g=r.length;g>d+4&&r[d]===x.beginText&&r[d+1]===x.setFont&&r[d+2]===x.setTextMatrix&&r[d+3]===x.showText&&r[d+4]===x.endText&&i[d+1][0]===u&&i[d+1][1]===f;)d+=5;var p=Math.min((d-s)/5,a);if(t>p)return d;var m=s;if(s>=4&&r[s-4]===r[o]&&r[s-3]===r[c]&&r[s-2]===r[l]&&r[s-1]===r[h]&&i[s-4][0]===u&&i[s-4][1]===f){p++;m-=5}for(var b=m+4,v=1;p>v;v++){r.splice(b,3);i.splice(b,3);b+=2}return b+1});a.prototype={optimize:function(e){for(var t,a=e.fnArray,i=e.argsArray,n={iCurr:0,fnArray:a,argsArray:i},s=0,o=a.length;o>s;){t=(t||r)[a[s]];if("function"==typeof t){n.iCurr=s;s=t(n);t=void 0;o=n.fnArray.length}else s++}}};return a}();e.OperatorList=Ae;e.PartialEvaluator=Ce});!function(e,t){t(e.pdfjsCoreAnnotation={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreStream,e.pdfjsCoreColorSpace,e.pdfjsCoreObj,e.pdfjsCoreEvaluator)}(this,function(e,t,a,r,i,n,s){function o(){}var c=t.AnnotationBorderStyleType,l=t.AnnotationFlag,h=t.AnnotationType,u=t.OPS,f=t.Util,d=t.isBool,g=t.isString,p=t.isArray,m=t.isInt,b=t.isValidUrl,v=t.stringToBytes,y=t.stringToPDFString,k=t.stringToUTF8String,w=t.warn,x=a.Dict,C=a.isDict,S=a.isName,A=r.Stream,I=i.ColorSpace,B=n.ObjectLoader,R=n.FileSpec,T=s.OperatorList;o.prototype={create:function(e,t){var a=e.fetchIfRef(t);if(C(a)){var r=a.get("Subtype");r=S(r)?r.name:"";var i={xref:e,dict:a,ref:t};switch(r){case"Link":return new D(i);case"Text":return new E(i);case"Widget":var n=f.getInheritableProperty(a,"FT");return S(n)&&"Tx"===n.name?new M(i):new L(i);case"Popup":return new q(i);case"Highlight":return new j(i);case"Underline":return new F(i);case"Squiggly":return new U(i);case"StrikeOut":return new N(i);case"FileAttachment":return new _(i);default:w('Unimplemented annotation type "'+r+'", falling back to base annotation');return new O(i)}}}};var O=function(){function e(e,t,a){var r=f.getAxialAlignedBoundingBox(t,a),i=r[0],n=r[1],s=r[2],o=r[3];if(i===s||n===o)return[1,0,0,1,e[0],e[1]];var c=(e[2]-e[0])/(s-i),l=(e[3]-e[1])/(o-n);return[c,0,0,l,e[0]-i*c,e[1]-n*l]}function t(e){var t=e.get("AP");if(C(t)){var a,r=t.get("N");if(C(r)){var i=e.get("AS");i&&r.has(i.name)&&(a=r.get(i.name))}else a=r;return a}}function a(e){var a=e.dict;this.setFlags(a.get("F"));this.setRectangle(a.getArray("Rect"));this.setColor(a.getArray("C"));this.setBorderStyle(a);this.appearance=t(a);this.data={};this.data.id=e.ref.toString();this.data.subtype=a.get("Subtype").name;this.data.annotationFlags=this.flags;this.data.rect=this.rectangle;this.data.color=this.color;this.data.borderStyle=this.borderStyle;this.data.hasAppearance=!!this.appearance}a.prototype={_hasFlag:function(e,t){return!!(e&t)},_isViewable:function(e){return!this._hasFlag(e,l.INVISIBLE)&&!this._hasFlag(e,l.HIDDEN)&&!this._hasFlag(e,l.NOVIEW)},_isPrintable:function(e){return this._hasFlag(e,l.PRINT)&&!this._hasFlag(e,l.INVISIBLE)&&!this._hasFlag(e,l.HIDDEN)},get viewable(){return 0===this.flags?!0:this._isViewable(this.flags)},get printable(){return 0===this.flags?!1:this._isPrintable(this.flags)},setFlags:function(e){this.flags=m(e)&&e>0?e:0},hasFlag:function(e){return this._hasFlag(this.flags,e)},setRectangle:function(e){p(e)&&4===e.length?this.rectangle=f.normalizeRect(e):this.rectangle=[0,0,0,0]},setColor:function(e){var t=new Uint8Array(3);if(p(e))switch(e.length){case 0:this.color=null;break;case 1:I.singletons.gray.getRgbItem(e,0,t,0);this.color=t;break;case 3:I.singletons.rgb.getRgbItem(e,0,t,0);this.color=t;break;case 4:I.singletons.cmyk.getRgbItem(e,0,t,0);this.color=t;break;default:this.color=t}else this.color=t},setBorderStyle:function(e){this.borderStyle=new P;if(C(e))if(e.has("BS")){var t,a=e.get("BS");if(!a.has("Type")||S(t=a.get("Type"))&&"Border"===t.name){this.borderStyle.setWidth(a.get("W"));this.borderStyle.setStyle(a.get("S"));this.borderStyle.setDashArray(a.getArray("D"))}}else if(e.has("Border")){var r=e.getArray("Border");if(p(r)&&r.length>=3){this.borderStyle.setHorizontalCornerRadius(r[0]);this.borderStyle.setVerticalCornerRadius(r[1]);this.borderStyle.setWidth(r[2]);4===r.length&&this.borderStyle.setDashArray(r[3])}}else this.borderStyle.setWidth(0)},_preparePopup:function(e){e.has("C")||(this.data.color=null);this.data.hasPopup=e.has("Popup");this.data.title=y(e.get("T")||"");this.data.contents=y(e.get("Contents")||"")},loadResources:function(e){return new Promise(function(t,a){this.appearance.dict.getAsync("Resources").then(function(r){if(r){var i=new B(r.map,e,r.xref);i.load().then(function(){t(r)},a)}else t()},a)}.bind(this))},getOperatorList:function(t,a){if(!this.appearance)return Promise.resolve(new T);var r=this.data,i=this.appearance.dict,n=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),s=i.getArray("BBox")||[0,0,1,1],o=i.getArray("Matrix")||[1,0,0,1,0,0],c=e(r.rect,s,o),l=this;return n.then(function(e){var i=new T;i.addOp(u.beginAnnotation,[r.rect,c,o]);return t.getOperatorList(l.appearance,a,e,i).then(function(){i.addOp(u.endAnnotation,[]);l.appearance.reset();return i})})}};a.appendToOperatorList=function(e,t,a,r,i){for(var n=[],s=0,o=e.length;o>s;++s)("display"===i&&e[s].viewable||"print"===i&&e[s].printable)&&n.push(e[s].getOperatorList(a,r));return Promise.all(n).then(function(e){t.addOp(u.beginAnnotations,[]);for(var a=0,r=e.length;r>a;++a)t.addOpList(e[a]);t.addOp(u.endAnnotations,[])})};return a}(),P=function(){function e(){this.width=1;this.style=c.SOLID;this.dashArray=[3];this.horizontalCornerRadius=0;this.verticalCornerRadius=0}e.prototype={setWidth:function(e){e===(0|e)&&(this.width=e)},setStyle:function(e){if(e)switch(e.name){case"S":this.style=c.SOLID;break;case"D":this.style=c.DASHED;break;case"B":this.style=c.BEVELED;break;case"I":this.style=c.INSET;break;case"U":this.style=c.UNDERLINE}},setDashArray:function(e){if(p(e)&&e.length>0){for(var t=!0,a=!0,r=0,i=e.length;i>r;r++){var n=e[r],s=+n>=0;if(!s){t=!1;break}n>0&&(a=!1)}t&&!a?this.dashArray=e:this.width=0}else e&&(this.width=0)},setHorizontalCornerRadius:function(e){e===(0|e)&&(this.horizontalCornerRadius=e)},setVerticalCornerRadius:function(e){e===(0|e)&&(this.verticalCornerRadius=e)}};return e}(),L=function(){function e(e){O.call(this,e);var t=e.dict,a=this.data;a.annotationType=h.WIDGET;a.fieldValue=y(f.getInheritableProperty(t,"V")||"");a.alternativeText=y(t.get("TU")||"");a.defaultAppearance=f.getInheritableProperty(t,"DA")||"";var r=f.getInheritableProperty(t,"FT");a.fieldType=S(r)?r.name:"";a.fieldFlags=f.getInheritableProperty(t,"Ff")||0;this.fieldResources=f.getInheritableProperty(t,"DR")||x.empty;if("Sig"===a.fieldType){w("unimplemented annotation type: Widget signature");this.setFlags(l.HIDDEN)}for(var i=[],n=t,s=e.ref;n;){var o=n.get("Parent"),c=n.getRaw("Parent"),u=n.get("T");if(u)i.unshift(y(u));else if(o&&s){var d,g,p=o.get("Kids");for(d=0,g=p.length;g>d;d++){var m=p[d];if(m.num===s.num&&m.gen===s.gen)break}i.unshift("`"+d)}n=o;s=c}a.fullName=i.join(".")}f.inherit(e,O,{});return e}(),M=function(){function e(e){L.call(this,e);this.data.textAlignment=f.getInheritableProperty(e.dict,"Q");this.data.maxLen=f.getInheritableProperty(e.dict,"MaxLen")}f.inherit(e,L,{getOperatorList:function(e,t){if(this.appearance)return O.prototype.getOperatorList.call(this,e,t);var a=new T,r=this.data;if(!r.defaultAppearance)return Promise.resolve(a);var i=new A(v(r.defaultAppearance));return e.getOperatorList(i,t,this.fieldResources,a).then(function(){return a})}});return e}(),E=function(){function e(e){O.call(this,e);this.data.annotationType=h.TEXT;if(this.data.hasAppearance)this.data.name="NoIcon";else{this.data.rect[1]=this.data.rect[3]-t;this.data.rect[2]=this.data.rect[0]+t;this.data.name=e.dict.has("Name")?e.dict.get("Name").name:"Note"}this._preparePopup(e.dict)}var t=22;f.inherit(e,O,{});return e}(),D=function(){function e(e){O.call(this,e);var r=e.dict,i=this.data;i.annotationType=h.LINK;var n,s,o=r.get("A");if(o&&C(o)){var c=o.get("S").name;switch(c){case"URI":n=o.get("URI");S(n)?n="/"+n.name:n&&(n=t(n));break;case"GoTo":s=o.get("D");break;case"GoToR":var l=o.get("F");C(l)?n=l.get("F")||null:g(l)&&(n=l);var u=o.get("D");if(u){S(u)&&(u=u.name);if(g(n)){var f=n.split("#")[0];g(u)?n=f+"#"+(/^\d+$/.test(u)?"nameddest=":"")+u:p(u)&&(n=f+"#"+JSON.stringify(u))}}var m=o.get("NewWindow");d(m)&&(i.newWindow=m);break;case"Named":i.action=o.get("N").name;break;default:w("unrecognized link type: "+c)}}else r.has("Dest")&&(s=r.get("Dest"));n&&b(n,!1)&&(i.url=a(n));s&&(i.dest=S(s)?s.name:s)}function t(e){return g(e)&&0===e.indexOf("www.")?"http://"+e:e}function a(e){try{return k(e)}catch(t){return e}}f.inherit(e,O,{});return e}(),q=function(){function e(e){O.call(this,e);this.data.annotationType=h.POPUP;var t=e.dict,a=t.get("Parent");if(a){this.data.parentId=t.getRaw("Parent").toString();this.data.title=y(a.get("T")||"");this.data.contents=y(a.get("Contents")||"");if(a.has("C")){this.setColor(a.getArray("C"));this.data.color=this.color}else this.data.color=null;if(!this.viewable){var r=a.get("F");this._isViewable(r)&&this.setFlags(r)}}else w("Popup annotation has a missing or invalid parent annotation.")}f.inherit(e,O,{});return e}(),j=function(){function e(e){O.call(this,e);this.data.annotationType=h.HIGHLIGHT;this._preparePopup(e.dict);this.data.borderStyle.setWidth(0)}f.inherit(e,O,{});return e}(),F=function(){function e(e){O.call(this,e);this.data.annotationType=h.UNDERLINE;this._preparePopup(e.dict);this.data.borderStyle.setWidth(0)}f.inherit(e,O,{});return e}(),U=function(){function e(e){O.call(this,e);this.data.annotationType=h.SQUIGGLY;this._preparePopup(e.dict);this.data.borderStyle.setWidth(0)}f.inherit(e,O,{});return e}(),N=function(){function e(e){O.call(this,e);this.data.annotationType=h.STRIKEOUT;this._preparePopup(e.dict);this.data.borderStyle.setWidth(0)}f.inherit(e,O,{});return e}(),_=function(){function e(e){O.call(this,e);var t=new R(e.dict.get("FS"),e.xref);this.data.annotationType=h.FILEATTACHMENT;this.data.file=t.serializable;this._preparePopup(e.dict)}f.inherit(e,O,{});return e}();e.Annotation=O;e.AnnotationBorderStyle=P;e.AnnotationFactory=o});!function(e,t){t(e.pdfjsCoreDocument={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCoreStream,e.pdfjsCoreObj,e.pdfjsCoreParser,e.pdfjsCoreCrypto,e.pdfjsCoreEvaluator,e.pdfjsCoreAnnotation)}(this,function(e,t,a,r,i,n,s,o,c){var l=t.MissingDataException,h=t.Util,u=t.assert,f=t.error,d=t.info,g=t.isArray,p=t.isArrayBuffer,m=t.isString,b=t.shadow,v=t.stringToBytes,y=t.stringToPDFString,k=t.warn,w=t.isSpace,x=a.Dict,C=a.isDict,S=a.isName,A=a.isStream,I=r.NullStream,B=r.Stream,R=r.StreamsSequenceStream,T=i.Catalog,O=i.ObjectLoader,P=i.XRef,L=n.Linearization,M=s.calculateMD5,E=o.OperatorList,D=o.PartialEvaluator,q=c.Annotation,j=c.AnnotationFactory,F=function(){function e(e,t,a,r,i,n){this.pdfManager=e;this.pageIndex=a;this.pageDict=r;this.xref=t;this.ref=i;this.fontCache=n;this.idCounters={obj:0};this.evaluatorOptions=e.evaluatorOptions;this.resourcesPromise=null}var t=[0,0,612,792];e.prototype={getPageProp:function(e){return this.pageDict.get(e)},getInheritedPageProp:function(e){for(var t=this.pageDict,a=null,r=0,i=100;t;){var n=t.get(e);if(n){a||(a=[]);a.push(n)}if(++r>i){k("Page_getInheritedPageProp: maximum loop count exceeded.");break}t=t.get("Parent")}return a?1===a.length||!C(a[0])||r>i?a[0]:x.merge(this.xref,a):x.empty},get content(){return this.getPageProp("Contents")},get resources(){return b(this,"resources",this.getInheritedPageProp("Resources"))},get mediaBox(){var e=this.getInheritedPageProp("MediaBox");g(e)&&4===e.length||(e=t);return b(this,"mediaBox",e)},get view(){var e=this.mediaBox,t=this.getInheritedPageProp("CropBox");if(!g(t)||4!==t.length)return b(this,"view",e);t=h.intersect(t,e);return t?b(this,"view",t):b(this,"view",e)},get rotate(){var e=this.getInheritedPageProp("Rotate")||0;e%90!==0?e=0:e>=360?e%=360:0>e&&(e=(e%360+360)%360);return b(this,"rotate",e)},getContentStream:function(){var e,t=this.content;if(g(t)){var a,r=this.xref,i=t.length,n=[];for(a=0;i>a;++a)n.push(r.fetchIfRef(t[a]));e=new R(n)}else e=A(t)?t:new I;return e},loadResources:function(e){this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources"));return this.resourcesPromise.then(function(){var t=new O(this.resources.map,e,this.xref);return t.load()}.bind(this))},getOperatorList:function(e,t,a){var r=this,i=this.pdfManager,n=i.ensure(this,"getContentStream",[]),s=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),o=new D(i,this.xref,e,this.pageIndex,"p"+this.pageIndex+"_",this.idCounters,this.fontCache,this.evaluatorOptions),c=Promise.all([n,s]),l=c.then(function(i){var n=i[0],s=new E(a,e,r.pageIndex);e.send("StartRenderPage",{transparency:o.hasBlendModes(r.resources),pageIndex:r.pageIndex,intent:a});return o.getOperatorList(n,t,r.resources,s).then(function(){return s})}),h=i.ensure(this,"annotations");return Promise.all([l,h]).then(function(e){var r=e[0],i=e[1];if(0===i.length){r.flush(!0);return r}var n=q.appendToOperatorList(i,r,o,t,a);return n.then(function(){r.flush(!0);return r})})},extractTextContent:function(e,t){var a={on:function(){},send:function(){}},r=this,i=this.pdfManager,n=i.ensure(this,"getContentStream",[]),s=this.loadResources(["ExtGState","XObject","Font"]),o=Promise.all([n,s]);return o.then(function(n){var s=n[0],o=new D(i,r.xref,a,r.pageIndex,"p"+r.pageIndex+"_",r.idCounters,r.fontCache,r.evaluatorOptions);return o.getTextContent(s,e,r.resources,null,t)})},getAnnotationsData:function(e){for(var t=this.annotations,a=[],r=0,i=t.length;i>r;++r)(!e||"display"===e&&t[r].viewable||"print"===e&&t[r].printable)&&a.push(t[r].data);return a},get annotations(){for(var e=[],t=this.getInheritedPageProp("Annots")||[],a=new j,r=0,i=t.length;i>r;++r){var n=t[r],s=a.create(this.xref,n);s&&e.push(s)}return b(this,"annotations",e)}};return e}(),U=function(){function e(e,a,r){A(a)?t.call(this,e,a,r):p(a)?t.call(this,e,new B(a),r):f("PDFDocument: Unknown argument type")}function t(e,t,a){u(t.length>0,"stream must have data");this.pdfManager=e;this.stream=t;var r=new P(this.stream,a,e);this.xref=r}function a(e,t,a,r){var i=e.pos,n=e.end,s=[];i+a>n&&(a=n-i);for(var o=0;a>o;++o)s.push(String.fromCharCode(e.getByte()));var c=s.join("");e.pos=i;var l=r?c.lastIndexOf(t):c.indexOf(t);if(-1===l)return!1;e.pos+=l;return!0}var r=1024,i="\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",n={get entries(){return b(this,"entries",{Title:m,Author:m,Subject:m,Keywords:m,Creator:m,Producer:m,CreationDate:m,ModDate:m,Trapped:S})}};e.prototype={parse:function(e){this.setup(e);var t=this.catalog.catDict.get("Version");S(t)&&(this.pdfFormatVersion=t.name);try{this.acroForm=this.catalog.catDict.get("AcroForm");if(this.acroForm){this.xfa=this.acroForm.get("XFA");var a=this.acroForm.get("Fields");a&&g(a)&&0!==a.length||this.xfa||(this.acroForm=null)}}catch(r){d("Something wrong with AcroForm entry");this.acroForm=null}},get linearization(){var e=null;if(this.stream.length)try{e=L.create(this.stream)}catch(t){if(t instanceof l)throw t;d(t)}return b(this,"linearization",e)},get startXRef(){var e=this.stream,t=0,r=this.linearization;if(r){e.reset();a(e,"endobj",1024)&&(t=e.pos+6)}else{for(var i=1024,n=!1,s=e.end;!n&&s>0;){s-=i-"startxref".length;0>s&&(s=0);e.pos=s;n=a(e,"startxref",i,!0)}if(n){e.skip(9);var o;do o=e.getByte();while(w(o));for(var c="";o>=32&&57>=o;){c+=String.fromCharCode(o);o=e.getByte()}t=parseInt(c,10);isNaN(t)&&(t=0)}}return b(this,"startXRef",t)},get mainXRefEntriesOffset(){var e=0,t=this.linearization;t&&(e=t.mainXRefEntriesOffset);return b(this,"mainXRefEntriesOffset",e)},checkHeader:function(){var e=this.stream;e.reset();if(a(e,"%PDF-",1024)){e.moveStart();for(var t,r=12,i="";(t=e.getByte())>32&&!(i.length>=r);)i+=String.fromCharCode(t);this.pdfFormatVersion||(this.pdfFormatVersion=i.substring(5))}else;},parseStartXRef:function(){var e=this.startXRef;this.xref.setStartXRef(e)},setup:function(e){this.xref.parse(e);var t=this,a={createPage:function(e,a,r,i){return new F(t.pdfManager,t.xref,e,a,r,i)}};this.catalog=new T(this.pdfManager,this.xref,a)},get numPages(){var e=this.linearization,t=e?e.numPages:this.catalog.numPages;return b(this,"numPages",t)},get documentInfo(){var e,t={PDFFormatVersion:this.pdfFormatVersion,IsAcroFormPresent:!!this.acroForm,IsXFAPresent:!!this.xfa};try{e=this.xref.trailer.get("Info")}catch(a){d("The document information dictionary is invalid.")}if(e){var r=n.entries;for(var i in r)if(e.has(i)){var s=e.get(i);r[i](s)?t[i]="string"!=typeof s?s:y(s):d('Bad value in document info for "'+i+'"')}}return b(this,"documentInfo",t)},get fingerprint(){var e,t=this.xref,a="",n=t.trailer.get("ID");if(n&&g(n)&&n[0]&&m(n[0])&&n[0]!==i)e=v(n[0]);else{this.stream.ensureRange&&this.stream.ensureRange(0,Math.min(r,this.stream.end));e=M(this.stream.bytes.subarray(0,r),0,r)}for(var s=0,o=e.length;o>s;s++){var c=e[s].toString(16);a+=1===c.length?"0"+c:c}return b(this,"fingerprint",a)},getPage:function(e){return this.catalog.getPage(e)},cleanup:function(){return this.catalog.cleanup()}};return e}();e.Page=F;e.PDFDocument=U});!function(e,t){t(e.pdfjsCorePdfManager={},e.pdfjsSharedUtil,e.pdfjsCoreStream,e.pdfjsCoreChunkedStream,e.pdfjsCoreDocument)}(this,function(e,t,a,r,i){var n=t.NotImplementedException,s=t.MissingDataException,o=t.createPromiseCapability,c=t.Util,l=a.Stream,h=r.ChunkedStreamManager,u=i.PDFDocument,f=function(){function e(){throw new Error("Cannot initialize BaseManagerManager")}e.prototype={get docId(){return this._docId},onLoadedStream:function(){throw new n},ensureDoc:function(e,t){return this.ensure(this.pdfDocument,e,t)},ensureXRef:function(e,t){return this.ensure(this.pdfDocument.xref,e,t)},ensureCatalog:function(e,t){return this.ensure(this.pdfDocument.catalog,e,t)},getPage:function(e){return this.pdfDocument.getPage(e)},cleanup:function(){return this.pdfDocument.cleanup()},ensure:function(e,t,a){return new n},requestRange:function(e,t){return new n},requestLoadedStream:function(){return new n},sendProgressiveData:function(e){return new n},updatePassword:function(e){this.pdfDocument.xref.password=this.password=e;this._passwordChangedCapability&&this._passwordChangedCapability.resolve()},passwordChanged:function(){this._passwordChangedCapability=o();return this._passwordChangedCapability.promise},terminate:function(){return new n}};return e}(),d=function(){function e(e,t,a,r){this._docId=e;this.evaluatorOptions=r;var i=new l(t);this.pdfDocument=new u(this,i,a);this._loadedStreamCapability=o();this._loadedStreamCapability.resolve(i)}c.inherit(e,f,{ensure:function(e,t,a){return new Promise(function(r,i){try{var n,s=e[t];n="function"==typeof s?s.apply(e,a):s;r(n)}catch(o){i(o)}})},requestRange:function(e,t){return Promise.resolve()},requestLoadedStream:function(){},onLoadedStream:function(){return this._loadedStreamCapability.promise},terminate:function(){}});return e}(),g=function(){function e(e,t,a,r){this._docId=e;this.msgHandler=a.msgHandler;this.evaluatorOptions=r;var i={msgHandler:a.msgHandler,url:a.url,length:a.length,disableAutoFetch:a.disableAutoFetch,rangeChunkSize:a.rangeChunkSize};this.streamManager=new h(t,i);this.pdfDocument=new u(this,this.streamManager.getStream(),a.password)}c.inherit(e,f,{ensure:function(e,t,a){var r=this;return new Promise(function(i,n){function o(){try{var c,l=e[t];c="function"==typeof l?l.apply(e,a):l;i(c)}catch(h){if(!(h instanceof s)){n(h);return}r.streamManager.requestRange(h.begin,h.end).then(o,n)}}o()})},requestRange:function(e,t){return this.streamManager.requestRange(e,t)},requestLoadedStream:function(){this.streamManager.requestAllChunks()},sendProgressiveData:function(e){this.streamManager.onReceiveData({chunk:e})},onLoadedStream:function(){return this.streamManager.onLoadedStream()},terminate:function(){this.streamManager.abort()}});return e}();e.LocalPdfManager=d;e.NetworkPdfManager=g});!function(e,t){t(e.pdfjsCoreWorker={},e.pdfjsSharedUtil,e.pdfjsCorePrimitives,e.pdfjsCorePdfManager)}(this,function(e,t,a,r){function i(e){s=e}function n(){if(!("console"in B)){var e={},t={log:function(){var e=Array.prototype.slice.call(arguments);B.postMessage({targetName:"main",action:"console_log",data:e})},error:function(){var e=Array.prototype.slice.call(arguments);B.postMessage({targetName:"main",action:"console_error",data:e});throw"pdf.js execution error"},time:function(t){e[t]=Date.now()},timeEnd:function(t){var a=e[t];a||k("Unknown timer name "+t);this.log("Timer:",t,Date.now()-a)}};B.console=t}var a=new l("worker","main",self);O.setup(a,self);a.send("ready",null)}var s,o=t.UNSUPPORTED_FEATURES,c=t.InvalidPDFException,l=t.MessageHandler,h=t.MissingPDFException,u=t.UnexpectedResponseException,f=t.PasswordException,d=t.PasswordResponses,g=t.UnknownErrorException,p=t.XRefParseException,m=t.arrayByteLength,b=t.arraysToBytes,v=t.assert,y=t.createPromiseCapability,k=t.error,w=t.info,x=t.warn,C=t.setVerbosityLevel,S=a.Ref,A=r.LocalPdfManager,I=r.NetworkPdfManager,B=t.globalScope,R=function(){function e(e){this.name=e;this.terminated=!1;this._capability=y()}e.prototype={get finished(){return this._capability.promise},finish:function(){this._capability.resolve()},terminate:function(){this.terminated=!0},ensureNotTerminated:function(){if(this.terminated)throw new Error("Worker task was terminated")}};return e}(),T=function(){function e(e,t){this._queuedChunks=[];var a=e.initialData;a&&a.length>0&&this._queuedChunks.push(a);this._msgHandler=t;this._isRangeSupported=!e.disableRange;this._isStreamingSupported=!e.disableStream;this._contentLength=e.length;this._fullRequestReader=null;this._rangeReaders=[];t.on("OnDataRange",this._onReceiveData.bind(this));t.on("OnDataProgress",this._onProgress.bind(this))}function t(e,t){this._stream=e;this._done=!1;this._queuedChunks=t||[];this._requests=[];this._headersReady=Promise.resolve();e._fullRequestReader=this;this.onProgress=null}function a(e,t,a){this._stream=e;this._begin=t;this._end=a;this._queuedChunk=null;this._requests=[];this._done=!1;this.onProgress=null}e.prototype={_onReceiveData:function(e){if(void 0===e.begin)this._fullRequestReader?this._fullRequestReader._enqueue(e.chunk):this._queuedChunks.push(e.chunk);else{var t=this._rangeReaders.some(function(t){if(t._begin!==e.begin)return!1;t._enqueue(e.chunk);return!0});v(t)}},_onProgress:function(e){if(this._rangeReaders.length>0){var t=this._rangeReaders[0];t.onProgress&&t.onProgress({loaded:e.loaded})}},_removeRangeReader:function(e){var t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)},getFullReader:function(){v(!this._fullRequestReader);var e=this._queuedChunks;this._queuedChunks=null;return new t(this,e)},getRangeReader:function(e,t){var r=new a(this,e,t);this._msgHandler.send("RequestDataRange",{begin:e,end:t});this._rangeReaders.push(r);return r},cancelAllRequests:function(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);var t=this._rangeReaders.slice(0);t.forEach(function(t){t.cancel(e)})}};t.prototype={_enqueue:function(e){if(!this._done)if(this._requests.length>0){var t=this._requests.shift();t.resolve({value:e,done:!1})}else this._queuedChunks.push(e)},get headersReady(){return this._headersReady},get isRangeSupported(){return this._stream._isRangeSupported},get isStreamingSupported(){return this._stream._isStreamingSupported},get contentLength(){return this._stream._contentLength},read:function(){if(this._queuedChunks.length>0){var e=this._queuedChunks.shift();return Promise.resolve({value:e,done:!1})}if(this._done)return Promise.resolve({value:void 0,done:!0});var t=y();this._requests.push(t);return t.promise},cancel:function(e){this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[]}};a.prototype={_enqueue:function(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{var t=this._requests.shift();t.resolve({value:e,done:!1});this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[]}this._done=!0;this._stream._removeRangeReader(this)}},get isStreamingSupported(){return!1},read:function(){if(this._queuedChunk)return Promise.resolve({value:this._queuedChunk,done:!1});if(this._done)return Promise.resolve({value:void 0,done:!0});var e=y();this._requests.push(e);return e.promise},cancel:function(e){this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._stream._removeRangeReader(this)}};return e}(),O={setup:function(e,t){var a=!1;e.on("test",function(t){if(!a){a=!0;if(t instanceof Uint8Array){var r=255===t[0];e.postMessageTransfers=r;var i=new XMLHttpRequest,n="response"in i;try{i.responseType}catch(s){n=!1}n?e.send("test",{supportTypedArray:!0,supportTransfers:r}):e.send("test",!1)}else e.send("test","main",!1)}});e.on("configure",function(e){C(e.verbosity)});e.on("GetDocRequest",function(e){return O.createDocumentHandler(e,t)})},createDocumentHandler:function(e,t){function a(){if(B)throw new Error("Worker was terminated")}function r(e){P.push(e)}function i(e){e.finish();var t=P.indexOf(e);P.splice(t,1)}function n(e){var t=y(),a=function(){var e=C.ensureDoc("numPages"),a=C.ensureDoc("fingerprint"),i=C.ensureXRef("encrypt");Promise.all([e,a,i]).then(function(e){var a={numPages:e[0],fingerprint:e[1],encrypted:!!e[2]};t.resolve(a)},r)},r=function(e){t.reject(e)};C.ensureDoc("checkHeader",[]).then(function(){C.ensureDoc("parseStartXRef",[]).then(function(){C.ensureDoc("parse",[e]).then(a,r)},r)},r);return t.promise}function k(e,t){var r,i=y(),n=e.source;if(n.data){try{r=new A(L,n.data,n.password,t);i.resolve(r)}catch(o){i.reject(o)}return i.promise}var c;try{if(n.chunkedViewerLoading)c=new T(n,E);else{v(s,"pdfjs/core/network module is not loaded");c=new s(e)}}catch(o){i.reject(o);return i.promise}var l=c.getFullReader();l.headersReady.then(function(){l.isStreamingSupported&&l.isRangeSupported||(l.onProgress=function(e){E.send("DocProgress",{loaded:e.loaded,total:e.total})});if(l.isRangeSupported){var e=n.disableAutoFetch||l.isStreamingSupported;r=new I(L,c,{msgHandler:E,url:n.url,password:n.password,length:l.contentLength,disableAutoFetch:e,rangeChunkSize:n.rangeChunkSize},t);i.resolve(r);O=null}})["catch"](function(e){i.reject(e);O=null});var h=[],u=0,f=function(){var e=b(h);n.length&&e.length!==n.length&&x("reported HTTP length is different from actual");try{r=new A(L,e,n.password,t);i.resolve(r)}catch(a){i.reject(a)}h=[]},d=new Promise(function(e,t){var i=function(e){try{a();if(e.done){r||f();O=null;return}var n=e.value;u+=m(n);l.isStreamingSupported||E.send("DocProgress",{loaded:u,total:Math.max(u,l.contentLength||0)});r?r.sendProgressiveData(n):h.push(n);l.read().then(i,t)}catch(s){t(s)}};l.read().then(i,t)});d["catch"](function(e){i.reject(e);O=null});O=function(){c.cancelAllRequests("abort")};return i.promise}var C,B=!1,O=null,P=[],L=e.docId,M=e.docId+"_worker",E=new l(M,L,t);E.postMessageTransfers=e.postMessageTransfers;var D=function(e){var t=function(e){a();E.send("GetDoc",{pdfInfo:e})},r=function(e){e instanceof f?e.code===d.NEED_PASSWORD?E.send("NeedPassword",e):e.code===d.INCORRECT_PASSWORD&&E.send("IncorrectPassword",e):e instanceof c?E.send("InvalidPDF",e):e instanceof h?E.send("MissingPDF",e):e instanceof u?E.send("UnexpectedResponse",e):E.send("UnknownError",new g(e.message,e.toString()))};a();var i={url:void 0===e.cMapUrl?null:e.cMapUrl,packed:e.cMapPacked===!0},s={forceDataSchema:e.disableCreateObjectURL,maxImageSize:void 0===e.maxImageSize?-1:e.maxImageSize,disableFontFace:e.disableFontFace,cMapOptions:i};k(e,s).then(function(e){if(B){e.terminate();throw new Error("Worker was terminated")}C=e;E.send("PDFManagerReady",null);C.onLoadedStream().then(function(e){E.send("DataLoaded",{length:e.bytes.byteLength})})}).then(function o(){a();n(!1).then(t,function(e){a();if(e instanceof p){C.requestLoadedStream();C.onLoadedStream().then(function(){a();n(!0).then(t,r)})}else{e instanceof f&&C.passwordChanged().then(o);r(e)}},r)},r)};E.on("GetPage",function(e){return C.getPage(e.pageIndex).then(function(e){var t=C.ensure(e,"rotate"),a=C.ensure(e,"ref"),r=C.ensure(e,"view");return Promise.all([t,a,r]).then(function(e){return{rotate:e[0],ref:e[1],view:e[2]}})})});E.on("GetPageIndex",function(e){var t=new S(e.ref.num,e.ref.gen),a=C.pdfDocument.catalog;return a.getPageIndex(t)});E.on("GetDestinations",function(e){return C.ensureCatalog("destinations")});E.on("GetDestination",function(e){return C.ensureCatalog("getDestination",[e.id])});E.on("GetPageLabels",function(e){return C.ensureCatalog("pageLabels")});E.on("GetAttachments",function(e){ +return C.ensureCatalog("attachments")});E.on("GetJavaScript",function(e){return C.ensureCatalog("javaScript")});E.on("GetOutline",function(e){return C.ensureCatalog("documentOutline")});E.on("GetMetadata",function(e){return Promise.all([C.ensureDoc("documentInfo"),C.ensureCatalog("metadata")])});E.on("GetData",function(e){C.requestLoadedStream();return C.onLoadedStream().then(function(e){return e.bytes})});E.on("GetStats",function(e){return C.pdfDocument.xref.stats});E.on("UpdatePassword",function(e){C.updatePassword(e)});E.on("GetAnnotations",function(e){return C.getPage(e.pageIndex).then(function(t){return C.ensure(t,"getAnnotationsData",[e.intent])})});E.on("RenderPageRequest",function(e){var t=e.pageIndex;C.getPage(t).then(function(a){var n=new R("RenderPageRequest: page "+t);r(n);var s=t+1,c=Date.now();a.getOperatorList(E,n,e.intent).then(function(e){i(n);w("page="+s+" - getOperatorList: time="+(Date.now()-c)+"ms, len="+e.totalLength)},function(t){i(n);if(!n.terminated){E.send("UnsupportedFeature",{featureId:o.unknown});var a,r="worker.js: while trying to getPage() and getOperatorList()";a="string"==typeof t?{message:t,stack:r}:"object"==typeof t?{message:t.message||t.toString(),stack:t.stack||r}:{message:"Unknown exception type: "+typeof t,stack:r};E.send("PageError",{pageNum:s,error:a,intent:e.intent})}})})},this);E.on("GetTextContent",function(e){var t=e.pageIndex,a=e.normalizeWhitespace;return C.getPage(t).then(function(e){var n=new R("GetTextContent: page "+t);r(n);var s=t+1,o=Date.now();return e.extractTextContent(n,a).then(function(e){i(n);w("text indexing: page="+s+" - time="+(Date.now()-o)+"ms");return e},function(e){i(n);if(!n.terminated)throw e})})});E.on("Cleanup",function(e){return C.cleanup()});E.on("Terminate",function(e){B=!0;if(C){C.terminate();C=null}O&&O();var t=[];P.forEach(function(e){t.push(e.finished);e.terminate()});return Promise.all(t).then(function(){E.destroy();E=null})});E.on("Ready",function(t){D(e);e=null});return M}};"undefined"!=typeof window||"undefined"!=typeof module&&module.require||n();e.setPDFNetworkStreamClass=i;e.WorkerTask=R;e.WorkerMessageHandler=O});var e=function(){function e(e,t){this.url=e;t=t||{};this.isHttp=/^https?:/i.test(e);this.httpHeaders=this.isHttp&&t.httpHeaders||{};this.withCredentials=t.withCredentials||!1;this.getXhr=t.getXhr||function(){return new XMLHttpRequest};this.currXhrId=0;this.pendingRequests=Object.create(null);this.loadedRequests=Object.create(null)}function t(e){var t=e.response;if("string"!=typeof t)return t;for(var a=t.length,r=new Uint8Array(a),i=0;a>i;i++)r[i]=255&t.charCodeAt(i);return r.buffer}var a=200,r=206,i=function(){try{var e=new XMLHttpRequest;e.open("GET","https://example.com");e.responseType="moz-chunked-arraybuffer";return"moz-chunked-arraybuffer"===e.responseType}catch(t){return!1}}();e.prototype={requestRange:function(e,t,a){var r={begin:e,end:t};for(var i in a)r[i]=a[i];return this.request(r)},requestFull:function(e){return this.request(e)},request:function(e){var t=this.getXhr(),a=this.currXhrId++,r=this.pendingRequests[a]={xhr:t};t.open("GET",this.url);t.withCredentials=this.withCredentials;for(var n in this.httpHeaders){var s=this.httpHeaders[n];"undefined"!=typeof s&&t.setRequestHeader(n,s)}if(this.isHttp&&"begin"in e&&"end"in e){var o=e.begin+"-"+(e.end-1);t.setRequestHeader("Range","bytes="+o);r.expectedStatus=206}else r.expectedStatus=200;var c=i&&!!e.onProgressiveData;if(c){t.responseType="moz-chunked-arraybuffer";r.onProgressiveData=e.onProgressiveData;r.mozChunked=!0}else t.responseType="arraybuffer";e.onError&&(t.onerror=function(a){e.onError(t.status)});t.onreadystatechange=this.onStateChange.bind(this,a);t.onprogress=this.onProgress.bind(this,a);r.onHeadersReceived=e.onHeadersReceived;r.onDone=e.onDone;r.onError=e.onError;r.onProgress=e.onProgress;t.send(null);return a},onProgress:function(e,a){var r=this.pendingRequests[e];if(r){if(r.mozChunked){var i=t(r.xhr);r.onProgressiveData(i)}var n=r.onProgress;n&&n(a)}},onStateChange:function(e,i){var n=this.pendingRequests[e];if(n){var s=n.xhr;if(s.readyState>=2&&n.onHeadersReceived){n.onHeadersReceived();delete n.onHeadersReceived}if(4===s.readyState&&e in this.pendingRequests){delete this.pendingRequests[e];if(0===s.status&&this.isHttp)n.onError&&n.onError(s.status);else{var o=s.status||a,c=o===a&&n.expectedStatus===r;if(c||o===n.expectedStatus){this.loadedRequests[e]=!0;var l=t(s);if(o===r){var h=s.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(h),f=parseInt(u[1],10);n.onDone({begin:f,chunk:l})}else n.onProgressiveData?n.onDone(null):l?n.onDone({begin:0,chunk:l}):n.onError&&n.onError(s.status)}else n.onError&&n.onError(s.status)}}}},hasPendingRequests:function(){for(var e in this.pendingRequests)return!0;return!1},getRequestXhr:function(e){return this.pendingRequests[e].xhr},isStreamingRequest:function(e){return!!this.pendingRequests[e].onProgressiveData},isPendingRequest:function(e){return e in this.pendingRequests},isLoadedRequest:function(e){return e in this.loadedRequests},abortAllRequests:function(){for(var e in this.pendingRequests)this.abortRequest(0|e)},abortRequest:function(e){var t=this.pendingRequests[e].xhr;delete this.pendingRequests[e];t.abort()}};return e}();!function(e,t){t(e.pdfjsCoreNetwork={},e.pdfjsSharedUtil,e.pdfjsCoreWorker)}(this,function(t,a,r){function i(t){this._options=t;var a=t.source;this._manager=new e(a.url,{httpHeaders:a.httpHeaders,withCredentials:a.withCredentials});this._rangeChunkSize=a.rangeChunkSize;this._fullRequestReader=null;this._rangeRequestReaders=[]}function n(e,t){this._manager=e;var a=t.source,r={onHeadersReceived:this._onHeadersReceived.bind(this),onProgressiveData:a.disableStream?null:this._onProgressiveData.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=a.url;this._fullRequestId=e.requestFull(r);this._headersReceivedCapability=c();this._disableRange=t.disableRange||!1;this._contentLength=a.length;this._rangeChunkSize=a.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!1;this._isRangeSupported=!1;this._cachedChunks=[];this._requests=[];this._done=!1;this._storedError=void 0;this.onProgress=null}function s(e,t,a){this._manager=e;var r={onDone:this._onDone.bind(this),onProgress:this._onProgress.bind(this)};this._requestId=e.requestRange(t,a,r);this._requests=[];this._queuedChunk=null;this._done=!1;this.onProgress=null;this.onClosed=null}var o=a.assert,c=a.createPromiseCapability,l=a.isInt,h=a.MissingPDFException,u=a.UnexpectedResponseException;i.prototype={_onRangeRequestReaderClosed:function(e){var t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)},getFullReader:function(){o(!this._fullRequestReader);this._fullRequestReader=new n(this._manager,this._options);return this._fullRequestReader},getRangeReader:function(e,t){var a=new s(this._manager,e,t);a.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(a);return a},cancelAllRequests:function(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);var t=this._rangeRequestReaders.slice(0);t.forEach(function(t){t.cancel(e)})}};n.prototype={_validateRangeRequestCapabilities:function(){if(this._disableRange)return!1;var e=this._manager,t=this._fullRequestId,a=e.getRequestXhr(t);if("bytes"!==a.getResponseHeader("Accept-Ranges"))return!1;var r=a.getResponseHeader("Content-Encoding")||"identity";if("identity"!==r)return!1;var i=a.getResponseHeader("Content-Length");i=parseInt(i,10);if(!l(i))return!1;this._contentLength=i;return!(i<=2*this._rangeChunkSize)},_onHeadersReceived:function(){this._validateRangeRequestCapabilities()&&(this._isRangeSupported=!0);var e=this._manager,t=this._fullRequestId;e.isStreamingRequest(t)?this._isStreamingSupported=!0:this._isRangeSupported&&e.abortRequest(t);this._headersReceivedCapability.resolve()},_onProgressiveData:function(e){if(this._requests.length>0){var t=this._requests.shift();t.resolve({value:e,done:!1})}else this._cachedChunks.push(e)},_onDone:function(e){e&&this._onProgressiveData(e.chunk);this._done=!0;if(!(this._cachedChunks.length>0)){this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[]}},_onError:function(e){var t,a=this._url;t=404===e||0===e&&/^file:/.test(a)?new h('Missing PDF "'+a+'".'):new u("Unexpected server response ("+e+') while retrieving PDF "'+a+'".',e);this._storedError=t;this._headersReceivedCapability.reject(t);this._requests.forEach(function(e){e.reject(t)});this._requests=[];this._cachedChunks=[]},_onProgress:function(e){this.onProgress&&this.onProgress({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})},get isRangeSupported(){return this._isRangeSupported},get isStreamingSupported(){return this._isStreamingSupported},get contentLength(){return this._contentLength},get headersReady(){return this._headersReceivedCapability.promise},read:function(){if(this._storedError)return Promise.reject(this._storedError);if(this._cachedChunks.length>0){var e=this._cachedChunks.shift();return Promise.resolve(e)}if(this._done)return Promise.resolve({value:void 0,done:!0});var t=c();this._requests.push(t);return t.promise},cancel:function(e){this._done=!0;this._headersReceivedCapability.reject(e);this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId);this._fullRequestReader=null}};s.prototype={_close:function(){this.onClosed&&this.onClosed(this)},_onDone:function(e){var t=e.chunk;if(this._requests.length>0){var a=this._requests.shift();a.resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._close()},_onProgress:function(e){!this.isStreamingSupported&&this.onProgress&&this.onProgress({loaded:e.loaded})},get isStreamingSupported(){return!1},read:function(){if(null!==this._queuedChunk){var e=this._queuedChunk;this._queuedChunk=null;return Promise.resolve({value:e,done:!1})}if(this._done)return Promise.resolve({value:void 0,done:!0});var t=c();this._requests.push(t);return t.promise},cancel:function(e){this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId);this._close()}};r.setPDFNetworkStreamClass(i);t.PDFNetworkStream=i;t.NetworkManager=e})}).call(t);e.WorkerMessageHandler=t.pdfjsCoreWorker.WorkerMessageHandler}); \ No newline at end of file diff --git a/wp/wp-content/plugins/wp-media-folder/assets/js/script.js b/wp/wp-content/plugins/wp-media-folder/assets/js/script.js index 59b7c050..e73e9997 100644 --- a/wp/wp-content/plugins/wp-media-folder/assets/js/script.js +++ b/wp/wp-content/plugins/wp-media-folder/assets/js/script.js @@ -340,14 +340,16 @@ var wpmfFoldersModule = void 0, } }; - // Create an observer instance linked to the callback function - const observer = new MutationObserver(callback); + if (targetNode){ + // Create an observer instance linked to the callback function + const observer = new MutationObserver(callback); + + // Start observing the target node for configured mutations + observer.observe(targetNode, config); - // Start observing the target node for configured mutations - observer.observe(targetNode, config); - - // Later, you can stop observing - // observer.disconnect(); + // Later, you can stop observing + // observer.disconnect(); + } // Add the creation gallery from folder button diff --git a/wp/wp-content/plugins/wp-media-folder/assets/js/snackbar.js b/wp/wp-content/plugins/wp-media-folder/assets/js/snackbar.js index 74f2cd0b..c1683b7b 100644 --- a/wp/wp-content/plugins/wp-media-folder/assets/js/snackbar.js +++ b/wp/wp-content/plugins/wp-media-folder/assets/js/snackbar.js @@ -91,7 +91,7 @@ var wpmfSnackbarModule = void 0; // Reset the close function as we've done an undo wpmfSnackbarModule.snackbar_ids[snack_id].onClose = function () {}; // Finally close the snackbar - wpmfSnackbarModule.snackbar_ids[snack_id].close(snack_id); + wpmfSnackbarModule.close(snack_id); }); Object.keys(wpmfSnackbarModule.snackbar_ids).map(function (snack_id, index) { diff --git a/wp/wp-content/plugins/wp-media-folder/class/class-folder-post-type.php b/wp/wp-content/plugins/wp-media-folder/class/class-folder-post-type.php new file mode 100644 index 00000000..74981f06 --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/class/class-folder-post-type.php @@ -0,0 +1,2027 @@ + $taxonomy)); + } + } + + /** + * Display custom taxonomy radio buttons + * + * @param WP_Post $post Current post object + * @param array $box Meta box arguments + * + * @return void + */ + public function customTaxonomyRadioButtons($post, $box) + { + $taxonomy = $box['args']['taxonomy']; + $terms = get_terms(array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + 'parent' => 0 + )); + + $post_terms = wp_get_post_terms($post->ID, $taxonomy, array('fields' => 'ids')); + + echo '
    '; + echo '
    '; + echo '
      '; + echo '
    • '; + echo ''; + echo '
    • '; + + $this->customTermsTree($terms, $post_terms, $taxonomy); + + echo '
    '; + echo '
    '; + echo '
    '; + } + + /** + * Recursive function to display terms as a tree list + * + * @param WP_Term[] $terms Array of term objects + * @param int[] $post_terms Array of term IDs associated with the post + * @param string $taxonomy Taxonomy slug + * @param integer $depth Current depth in the tree + * + * @return void + */ + public function customTermsTree($terms, $post_terms, $taxonomy, $depth = 0) + { + if (!is_array($post_terms)) { + return; + } + foreach ($terms as $term) { + $checked = in_array($term->term_id, $post_terms) ? 'checked="checked"' : ''; + echo '
  • '; + echo ''; + + $child_terms = get_terms(array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + 'parent' => $term->term_id + )); + + if (!empty($child_terms)) { + echo '
      '; + $this->customTermsTree($child_terms, $post_terms, $taxonomy, $depth + 1); + echo '
    '; + } + + echo '
  • '; + } + } + + /** + * Save custom taxonomy radio buttons + * + * @param integer $post_id The ID of the post being saved + * + * @return void + */ + public function saveCustomTaxonomyRadioButtons($post_id) + { + global $typenow; + if (WpmfHelper::isForThisPostType($typenow)) { + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { + return; + } + + // phpcs:ignore + if (!isset($_POST['tax_input'])) { + return; + } + + $wpmf_taxonomy = 'wpmf-folder-type-' . $typenow; + // phpcs:ignore + foreach ($_POST['tax_input'] as $taxonomy => $terms) { + if ($taxonomy === $wpmf_taxonomy) { + $terms = (array) $terms; + if (!empty($terms)) { + wp_set_object_terms($post_id, (int)end($terms), $taxonomy); + } else { + wp_set_object_terms($post_id, array(), $taxonomy); + } + } + } + } + } + + + /** + * Add folders data to footer + * + * @return void + */ + public function adminFooter() + { + if (self::isActiveForScreen()) { + global $typenow; + $taxonomy = 'wpmf-folder-type-'.$typenow; + $terms = self::getTermsHierarchical($taxonomy); + include_once dirname(dirname(__FILE__)).'/class/templates/folder-tree-tpl.php'; + } + } + + /** + * Add Folder Styles + * + * @return void + */ + public function foldersAdminStyles() + { + if (self::isActiveForScreen()) { + global $typenow; + $width = get_option('wpmf_dynamic_width_for_'.$typenow); + $width = empty($width)||!is_numeric($width) ? 290 : intval($width); + if ($width > 1200) { + $width = 290; + } + + $minimize_folder_tree_post_type = wpmfGetOption('wpmf_minimize_folder_tree_post_type'); + $folder_tree_status_option = wpmfGetOption('wpmf_folder_tree_status'); + $wpmf_folder_tree_status = 'hide'; + if (!empty($minimize_folder_tree_post_type) && $minimize_folder_tree_post_type) { + $wpmf_folder_tree_status = 'hide'; + } + if (!empty($folder_tree_status_option) && isset($folder_tree_status_option[$typenow])) { + $wpmf_folder_tree_status = $folder_tree_status_option[$typenow]; + } + $wpmf_folder_tree_status === 'show' ? $css = 'body.wp-admin #wpcontent {padding-left:'.($width + 20).'px}' : $css = 'body.wp-admin #wpcontent {padding-left: 25px} .wpmf-hide-folder-tree .wpmf-main-tree'; + wp_register_style('wpmf-css-handle', false); + wp_enqueue_style('wpmf-css-handle'); + wp_add_inline_style('wpmf-css-handle', $css); + + $postType = $typenow; + $this->loadAssets($postType); + } + } + + /** + * Check is folder active for current screen + * + * @return boolean + */ + public function isActiveForScreen() + { + global $typenow, $current_screen; + + if (WpmfHelper::isForThisPostType($typenow) && 'edit' == $current_screen->base) { + return true; + } + + return false; + } + + /** + * Run ajax + * + * @return void + */ + public function startProcess() + { + if (empty($_REQUEST['wpmf_nonce']) + || !wp_verify_nonce($_REQUEST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_REQUEST['task'])) { + switch ($_REQUEST['task']) { + case 'reload_folder_tree': + $this->reloadFolderTree(); + break; + case 'add_folder': + $this->addFolder(); + break; + case 'edit_folder': + $this->editFolder(); + break; + case 'delete_folder': + $this->deleteFolder(); + break; + case 'delete_multiple_folders': + $this->deleteMultipleFolders(); + break; + case 'move_folder': + $this->moveFolder(); + break; + case 'set_folder_color': + $this->setFolderColor(); + break; + case 'assign_folder_to_post': + $this->assignFolderToPost(); + break; + case 'get_folder_permissions': + $this->getFolderPermissions(); + break; + case 'save_folder_permissions': + $this->saveFolderPermissions(); + break; + case 'reorderfolder': + $this->reorderfolder(); + break; + case 'change_folder_tree_display_status': + $this->changeFolderTreeDisplayStatus(); + break; + } + } + } + + /** + * Create folder taxonomies + * + * @return void + */ + public function createFolderTerms() + { + $settings = get_option('wpmf_settings'); + if (isset($settings) && isset($settings['wpmf_active_folders_post_types'])) { + $post_types = $settings['wpmf_active_folders_post_types']; + $post_types = is_array($post_types) ? $post_types : []; + } else { + $post_types = array(); + } + if (!empty($post_types)) { + foreach ($post_types as $postType) { + $taxonomy = 'wpmf-folder-type-'.$postType; + + $labels = [ + 'name' => esc_html__('Folders', 'wpmf'), + 'singular_name' => esc_html__('Folder', 'wpmf'), + 'all_items' => esc_html__('All Folders', 'wpmf'), + 'edit_item' => esc_html__('Edit Folder', 'wpmf'), + 'update_item' => esc_html__('Update Folder', 'wpmf'), + 'add_new_item' => esc_html__('Add New Folder', 'wpmf'), + 'new_item_name' => esc_html__('Add folder name', 'wpmf'), + 'menu_name' => esc_html__('Folders', 'wpmf'), + 'search_items' => esc_html__('Search Folders', 'wpmf'), + 'parent_item' => esc_html__('Parent Folder', 'wpmf'), + ]; + + $args = array( + 'label' => esc_html__('Folder', 'wpmf'), + 'labels' => $labels, + 'show_tagcloud' => false, + 'hierarchical' => true, + 'public' => false, + 'show_ui' => true, + 'show_in_menu' => false, + 'show_in_rest' => false, + 'show_admin_column' => true, + 'update_count_callback' => '_update_post_term_count', + 'query_var' => true, + 'rewrite' => false, + 'capabilities' => array( + 'manage_terms' => 'manage_categories', + 'edit_terms' => 'manage_categories', + 'delete_terms' => 'manage_categories', + 'assign_terms' => 'manage_categories', + ), + ); + + register_taxonomy( + $taxonomy, + $postType, + $args + ); + + switch ($postType) { + case 'post': + add_filter('manage_posts_columns', array($this, 'manageColumnsHead')); + add_action('manage_posts_custom_column', array($this, 'manageColumnsContent'), 10, 2); + break; + case 'page': + add_filter('manage_page_posts_columns', array($this, 'manageColumnsHead')); + add_action('manage_page_posts_custom_column', array($this, 'manageColumnsContent'), 10, 2); + break; + default: + add_filter('manage_edit-'.$postType.'_columns', array($this, 'manageColumnsHead'), 99999); + add_action('manage_'.$postType.'_posts_custom_column', array($this, 'manageColumnsContent'), 2, 2); + break; + } + } + } + } + + /** + * Add a new folder via ajax + * + * @return void + */ + public function addFolder() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['name']) && $_POST['name'] !== '') { + $term = esc_attr(trim($_POST['name'])); + } else { + $term = __('New folder', 'wpmf'); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + + $termParent = (int)$_POST['parent'] | 0; + $termParent = $this->getFolderParent($termParent, $termParent); + + $user_id = get_current_user_id(); + $is_access = self::getAccess($termParent, $user_id, 'add_folder', $taxonomy); + if (!$is_access) { + wp_send_json(array('status' => false, 'msg' => esc_html__('You not have a permission to create folder!', 'wpmf'))); + } + + // insert new term + $inserted = wp_insert_term($term, $taxonomy, array('parent' => $termParent)); + if (is_wp_error($inserted)) { + wp_send_json(array('status' => false, 'msg' => $inserted->get_error_message())); + } else { + // update term_group for new term + $updateted = wp_update_term($inserted['term_id'], $taxonomy, array('term_group' => $user_id)); + $termInfos = get_term($updateted['term_id'], $taxonomy); + $terms = self::getTermsHierarchical($taxonomy); + do_action('wpmf_create_folder_post_type', $inserted['term_id'], $term, $termParent, array('trigger' => 'folder_post_type_action')); + wp_send_json(array( + 'status' => true, + 'term' => $termInfos, + 'categories' => $terms, + )); + } + } + + /** + * After create folder + * + * @param integer $folder_id Folder ID + * @param string $folder_name Folder name + * @param integer $parent Folder parent + * @param array $params Params details + * + * @return void + */ + public function afterCreateFolder($folder_id, $folder_name, $parent, $params) + { + $user_id = get_current_user_id(); + // add permission + $role = WpmfHelper::getRoles($user_id); + if ($role === 'administrator') { + $role = 0; + $user_id = 0; + } + + add_term_meta((int)$folder_id, 'inherit_folder', 1); + add_term_meta((int)$folder_id, 'wpmf_folder_role_permissions', array($role, 'add_media', 'move_media', 'view_folder', 'add_folder', 'update_folder', 'remove_folder', 'view_media', 'remove_media', 'update_media')); + add_term_meta((int)$folder_id, 'wpmf_folder_user_permissions', array($user_id, 'add_media', 'move_media', 'view_folder', 'add_folder', 'update_folder', 'remove_folder', 'view_media', 'remove_media', 'update_media')); + } + + /** + * Change a folder name from ajax request + * + * @return void + */ + public function editFolder() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + $folder_id = $this->getFolderParent($_POST['id'], $_POST['id']); + $user_id = get_current_user_id(); + $is_access = self::getAccess($folder_id, $user_id, 'update_folder', $taxonomy); + if (!$is_access) { + wp_send_json(array('status' => false, 'msg' => esc_html__('You not have a permission to edit folder!', 'wpmf'))); + } + + $term_name = esc_attr($_POST['name']); + if (!$term_name) { + wp_send_json(array('status' => false, 'msg' => esc_html__('Folder names can\'t be empty', 'wpmf'))); + } + + $type = get_term_meta((int)$folder_id, 'wpmf_drive_root_type', true); + if (!empty($type)) { + wp_send_json(array('status' => false, 'msg' => esc_html__('Can\'t edit cloud root folder!', 'wpmf'))); + } + + // Retrieve term informations + $term = get_term((int)$folder_id, $taxonomy); + + // check duplicate name + $siblings = get_categories( + array( + 'taxonomy' => $taxonomy, + 'fields' => 'names', + 'get' => 'all', + 'parent' => $term->parent + ) + ); + + if (in_array($term_name, $siblings)) { + // Another folder with the same name exists + wp_send_json(array('status' => false, 'msg' => esc_html__('A folder already exists here with the same name. Please try with another name, thanks :)', 'wpmf'))); + } + + $updated_term = wp_update_term((int)$folder_id, $taxonomy, array('name' => $term_name)); + if ($updated_term instanceof WP_Error) { + wp_send_json(array('status' => false, 'msg' => $updated_term->get_error_messages())); + } else { + // Retrieve more information than wp_update_term function returns + $term_details = get_term($updated_term['term_id'], $taxonomy); + + /** + * Update folder name + * + * @param integer Folder ID + * @param string Updated name + */ + do_action('wpmf_update_folder_name', $folder_id, $term_name); + wp_send_json(array('status' => true, 'details' => $term_details)); + } + } + + /** + * Delete folder via ajax + * + * @return void + */ + public function deleteFolder() + { + if (empty($_POST['wpmf_nonce']) || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + $folder_id = $this->getFolderParent($_POST['id'], $_POST['id']); + $user_id = get_current_user_id(); + $is_access = self::getAccess($folder_id, $user_id, 'remove_folder', $taxonomy); + if (!$is_access) { + wp_send_json(array('status' => false, 'error' => esc_html__('You don\'t have permission to delete this folder!', 'wpmf'))); + } + + // delete current folder + $this->doRemoveChildFolders((int) $_POST['id'], $taxonomy, $user_id); + if (wp_delete_term((int)$folder_id, $taxonomy)) { + $terms = self::getTermsHierarchical($taxonomy); + wp_send_json(array( + 'status' => true, + 'categories' => $terms + )); + } else { + wp_send_json(array('status' => false, 'error' => esc_html__('You don\'t have permission to delete this folder!', 'wpmf'))); + } + } + + /** + * Delete multiple folders + * + * @return void + */ + public function deleteMultipleFolders() + { + if (empty($_POST['wpmf_nonce']) || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + $folder_ids = isset($_POST['id']) ? $_POST['id'] : 0; + if (empty($folder_ids)) { + wp_send_json(array( + 'status' => true + )); + } + $return = $this->doRemoveFolders($folder_ids, $taxonomy); + if ($return) { + wp_send_json(array( + 'status' => false, + 'msg' => 'limit' + )); + } else { + $terms = self::getTermsHierarchical($taxonomy); + wp_send_json( + array( + 'status' => true, + 'categories' => $terms + ) + ); + } + } + + /** + * Do remove multiple folders + * + * @param string $folder_list Folder list id + * @param string $taxonomy Taxonomy + * + * @return boolean + */ + public function doRemoveFolders($folder_list, $taxonomy) + { + $user_id = get_current_user_id(); + // delete all subfolder and subfile + $folders = explode(',', $folder_list); + $sub_folders = array(); + foreach ($folders as $folder_id) { + $is_access = self::getAccess($folder_id, $user_id, 'remove_folder', $taxonomy); + if (!$is_access) { + wp_send_json(array('status' => false, 'error' => esc_html__('You don\'t have permission to delete this folder!', 'wpmf'))); + } + $this->doRemoveChildFolders($folder_id, $taxonomy, $user_id); + if (!wp_delete_term((int)$folder_id, $taxonomy)) { + return false; + } + } + + return true; + } + + /** + * Do remove child folders + * + * @param string $folder_id Parent folder id + * @param string $taxonomy Taxonomy + * @param integer $user_id Current user id + * + * @return boolean + */ + public function doRemoveChildFolders($folder_id, $taxonomy, $user_id) + { + $childs = get_term_children($folder_id, $taxonomy); + if (!empty($childs)) { + foreach ($childs as $key => $child) { + $is_access = self::getAccess($child, $user_id, 'remove_folder', $taxonomy); + if (!$is_access) { + wp_send_json(array('status' => false, 'error' => esc_html__('You don\'t have permission to delete this folder!', 'wpmf'))); + } + wp_delete_term($child, $taxonomy); + } + } + + return true; + } + + /** + * Move a folder via ajax + * + * @return void + */ + public function moveFolder() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + $parent = $this->getFolderParent($_POST['id_category'], $_POST['id_category']); + + // Check that the folder we move into is not a child of the folder we're moving + $wpmf_childs = $this->getFolderChild($_POST['id'], array(), $taxonomy); + if (in_array((int)$parent, $wpmf_childs)) { + wp_send_json(array('status' => false, 'msg' => esc_html__('A folder already exists here with the same name. Please try with another name, thanks :)', 'wpmf'))); + } + + /* + * Check if there is another folder with the same name + * in the folder we moving into + */ + $term = get_term($parent); + $siblings = get_categories( + array( + 'taxonomy' => $taxonomy, + 'fields' => 'names', + 'get' => 'all', + 'parent' => (int)$parent + ) + ); + if (in_array($term->name, $siblings)) { + wp_send_json(array('status' => false, 'msg' => esc_html__('Error, can\'t move', 'wpmf'))); + } + + $r = wp_update_term((int) $_POST['id'], $taxonomy, array('parent' => (int)$parent)); + if ($r instanceof WP_Error) { + wp_send_json(array('status' => false, 'msg' => esc_html__('Error, can\'t move', 'wpmf'))); + } else { + // Retrieve the updated folders hierarchy + $terms = self::getTermsHierarchical($taxonomy); + wp_send_json( + array( + 'status' => true, + 'categories' => $terms + ) + ); + } + } + + /** + * Assign folder to multiple posts, pages, ... + * + * @return void + */ + public function assignFolderToPost() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + if (isset($_POST['post_type']) && $_POST['post_type'] !== '') { + $postType = esc_attr(trim($_POST['post_type'])); + } else { + die(); + } + + if (isset($_POST['type']) && $_POST['type'] !== '') { + $type = esc_attr(trim($_POST['type'])); + } else { + die(); + } + + $term_id = $_POST['folder_id']; + if ($term_id === '-1') { + $term_id = 0; + } + $status = true; + + $user_id = get_current_user_id(); + $is_access = self::getAccess($term_id, $user_id, 'update_folder', $taxonomy); + if (!$is_access) { + wp_send_json(array('status' => false, 'error' => esc_html__('You don\'t have permission to add the item(s) to this folder!', 'wpmf'))); + } + + if ($type === 'single') { + $postID = $_POST['post_id']; + $terms = get_the_terms($postID, $taxonomy); + if (!empty($terms)) { + foreach ($terms as $term) { + wp_remove_object_terms($postID, $term->term_id, $taxonomy); + } + } + wp_set_post_terms($postID, $term_id, $taxonomy, $status); + } elseif ($type === 'multiple') { + $postIDs = trim($_POST['post_id'], ','); + $postArray = explode(',', $postIDs); + if (is_array($postArray)) { + foreach ($postArray as $postID) { + $terms = get_the_terms($postID, $taxonomy); + if (!empty($terms)) { + foreach ($terms as $term) { + wp_remove_object_terms($postID, $term->term_id, $taxonomy); + } + } + wp_set_post_terms($postID, $term_id, $taxonomy, $status); + } + } + } + + $terms = self::getTermsHierarchical($taxonomy); + wp_send_json(array( + 'status' => true, + 'categories' => $terms + )); + } + + /** + * Ajax set folder color + * + * @return void + */ + public function setFolderColor() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + $colors_option = wpmfGetOption('folder_color'); + if (isset($_POST['folder_id']) && isset($_POST['color'])) { + if (empty($colors_option)) { + $colors_option = array(); + $colors_option[$_POST['folder_id']] = $_POST['color']; + } else { + $colors_option[$_POST['folder_id']] = $_POST['color']; + } + wpmfSetOption('folder_color', $colors_option); + wp_send_json(array('status' => true)); + } + wp_send_json(array('status' => false)); + } + + /** + * Save folder permissions + * + * @return void + */ + public function getFolderPermissions() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + wp_send_json(array('status' => false)); + } + + if (empty($_POST['folder_id'])) { + wp_send_json(array('status' => false)); + } + + $role_permissions = get_term_meta((int)$_POST['folder_id'], 'wpmf_folder_role_permissions'); + $user_permissions = get_term_meta((int)$_POST['folder_id'], 'wpmf_folder_user_permissions'); + $inherit_folder = get_term_meta((int)$_POST['folder_id'], 'inherit_folder', true); + if ($inherit_folder === '' && $role_permissions === '' && $user_permissions === '') { + $inherit_folder = 1; + } + wp_send_json(array('status' => true, 'role_permissions' => $role_permissions, 'user_permissions' => $user_permissions, 'inherit_folder' => $inherit_folder)); + } + + /** + * Save folder permissions + * + * @return void + */ + public function saveFolderPermissions() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + wp_send_json(array('status' => false)); + } + + if (empty($_POST['folder_id'])) { + wp_send_json(array('status' => false)); + } + + $inherit_folder = isset($_POST['inherit_folder']) ? $_POST['inherit_folder'] : 1; + update_term_meta((int)$_POST['folder_id'], 'inherit_folder', $inherit_folder); + $role_permissions = (isset($_POST['role_permissions'])) ? json_decode(stripslashes($_POST['role_permissions']), true) : array(); + delete_term_meta((int)$_POST['folder_id'], 'wpmf_folder_role_permissions'); + foreach ($role_permissions as $role_permission) { + add_term_meta((int)$_POST['folder_id'], 'wpmf_folder_role_permissions', $role_permission); + } + + $user_permissions = (isset($_POST['user_permissions'])) ? json_decode(stripslashes($_POST['user_permissions']), true) : array(); + delete_term_meta((int)$_POST['folder_id'], 'wpmf_folder_user_permissions'); + foreach ($user_permissions as $user_permission) { + add_term_meta((int)$_POST['folder_id'], 'wpmf_folder_user_permissions', $user_permission); + } + + wp_send_json(array('status' => true)); + } + + /** + * Ajax change folder tree display status + * + * @return void + */ + public function changeFolderTreeDisplayStatus() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['status']) && isset($_POST['post_type'])) { + $status_option = wpmfGetOption('wpmf_folder_tree_status'); + if (empty($status_option)) { + $status_option = array(); + $status_option[$_POST['post_type']] = $_POST['status']; + } else { + $status_option[$_POST['post_type']] = $_POST['status']; + } + wpmfSetOption('wpmf_folder_tree_status', $status_option); + wp_send_json(array('status' => true)); + } + + wp_send_json(array('status' => false)); + } + + /** + * Get folder parent root ID + * + * @param integer $parent Current ID + * @param integer $folder Folder ID + * + * @return mixed + */ + public function getFolderParent($parent, $folder) + { + // $wpmf_active_media = get_option('wpmf_active_media'); + // if ((int)$wpmf_active_media === 1 && empty($folder)) { + // $wpmfterm = $this->termRoot(); + // if (!empty($wpmfterm)) { + // $parent = $wpmfterm['term_rootId']; + // } + // } + + return $parent; + } + + /** + * Get folders by hierarchy + * + * @param string $taxonomy Taxonomy + * + * @return array + */ + public function getTermsHierarchical($taxonomy) + { + global $wp_post_types; + + $terms = get_terms( + array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + 'parent' => 0, + 'hierarchical' => false + ) + ); + + $type = str_replace('wpmf-folder-type-', '', $taxonomy); + + $hierarchical_terms = []; + + $root = new stdClass(); + $unassign = new stdClass(); + if (isset($wp_post_types[$type])) { + $root->label = esc_html__('All', 'wpmf') . ' ' .$wp_post_types[$type]->labels->name; + $unassign->label = esc_html__('Unassigned', 'wpmf') . ' ' .$wp_post_types[$type]->labels->name; + } else { + $root->label = esc_html__('All', 'wpmf'); + $unassign->label = esc_html__('Unassigned', 'wpmf'); + } + $root->id = 0; + $root->term_id = 0; + $root->parent_id = 0; + $root->slug = ''; + $root->getTermAdminLink = self::getTermAdminLink(0, $taxonomy); + $root->item_count = wp_count_posts($type)->publish + wp_count_posts($type)->draft + wp_count_posts($type)->future + wp_count_posts($type)->private + wp_count_posts($type)->pending; + $root->lower_label = strtolower($root->label); + $root->drive_type = ''; + $root->order = ''; + $hierarchical_terms[0] = $root; + + $args = array( + 'post_type' => $type, + 'post_status' => array('publish', 'draft', 'future', 'private', 'pending'), + 'tax_query' => array( + array( + 'taxonomy' => $taxonomy, + 'field' => 'term_id', + 'operator' => 'NOT EXISTS' + ) + ), + 'fields' => 'ids' + ); + $queryUnassignPost = new WP_Query($args); + $countUnassignPost = $queryUnassignPost->found_posts; + + $unassign->id = -1; + $unassign->term_id = -1; + $unassign->parent_id = 0; + $unassign->slug = 'wpmf-unassigned'; + $unassign->getTermAdminLink = self::getTermAdminLink(-1, $taxonomy); + $unassign->item_count = $countUnassignPost; + $unassign->lower_label = strtolower($unassign->label); + $unassign->drive_type = ''; + $unassign->order = ''; + + $hierarchical_terms[-1] = $unassign; + + if (!empty($terms)) { + foreach ($terms as $term) { + if (!empty($term) && isset($term->term_id)) { + $is_access = self::getAccess($term->term_id, get_current_user_id(), 'view_folder', $taxonomy); + $role_permissions = get_term_meta($term->term_id, 'wpmf_folder_role_permissions'); + if (!$is_access) { + continue; + } + $folder_count = 0; + $postArray = self::getPostsExcludeChildTerms($type, $taxonomy, $term->term_id); + + if (!empty($postArray)) { + $folder_count = count($postArray); + } + + $order = get_term_meta($term->term_id, $taxonomy.'_order', true); + + $term->label = $term->name; + $term->lower_label = strtolower($term->name); + $term->depth = 0; + $term->id = $term->term_id; + $term->parent_id = $term->parent; + $term->item_count = $folder_count; + $term->drive_type = ''; + $term->order = $order ?? ''; + $term->getTermAdminLink = self::getTermAdminLink($term->term_id, $taxonomy); + $hierarchical_terms[$term->term_id] = $term; + $hierarchical_terms = self::getChildTerms($taxonomy, $hierarchical_terms, $term->term_id, $term->depth); + } + } + } + + return $hierarchical_terms; + } + + + /** + * Get Child folders + * + * @param string $taxonomy Taxonomy + * @param string $hierarchical_terms Hierarchical terms + * @param integer $term_id Term ID + * @param integer $depth Depth + * + * @return array + */ + public static function getChildTerms($taxonomy, $hierarchical_terms, $term_id, $depth = 0) + { + $terms = get_terms( + array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + 'parent' => $term_id, + 'hierarchical' => false + ) + ); + if (!empty($terms)) { + $type = str_replace('wpmf-folder-type-', '', $taxonomy); + $depth++; + foreach ($terms as $term) { + if (isset($term->name)) { + $is_access = self::getAccess($term->term_id, get_current_user_id(), 'view_folder', $taxonomy); + $role_permissions = get_term_meta($term->term_id, 'wpmf_folder_role_permissions'); + if (!$is_access) { + continue; + } + $folder_count = 0; + + $postArray = self::getPostsExcludeChildTerms($type, $taxonomy, $term->term_id); + + if (!empty($postArray)) { + $folder_count = count($postArray); + } + + $order = get_term_meta($term->term_id, $taxonomy.'_order', true); + $term->label = $term->name; + $term->lower_label = strtolower($term->name); + $term->depth = $depth; + $term->id = $term->term_id; + $term->parent_id = $term->parent; + $term->item_count = $folder_count; + $term->drive_type = ''; + $term->order = $order ?? ''; + $term->getTermAdminLink = self::getTermAdminLink($term->term_id, $taxonomy); + $hierarchical_terms[$term->term_id] = $term; + $hierarchical_terms = self::getChildTerms($taxonomy, $hierarchical_terms, $term->term_id, $depth); + } + } + } + + return $hierarchical_terms; + } + + /** + * Reload folder tree + * + * @param string $type Post type + * @param string $taxonomy Taxonomy + * @param integer $term_id Term ID + * + * @return array + */ + public static function getPostsExcludeChildTerms($type, $taxonomy, $term_id) + { + // Retrieve all child terms of the specified parent term + $child_terms = get_terms(array( + 'taxonomy' => $taxonomy, + 'child_of' => $term_id, + 'fields' => 'ids', + 'hide_empty' => false + )); + + // Include the parent term in the exclusion list + $exclude_terms = $child_terms; + + // Query to get posts associated with the parent term but not the child terms + $posts = get_posts(array( + 'posts_per_page' => -1, + 'post_type' => $type, + 'post_status' => array('publish', 'draft', 'future', 'private', 'pending'), + 'tax_query' => array( + 'relation' => 'AND', + array( + 'taxonomy' => $taxonomy, + 'field' => 'term_id', + 'terms' => $term_id, + ), + array( + 'taxonomy' => $taxonomy, + 'field' => 'term_id', + 'terms' => $exclude_terms, + 'operator' => 'NOT IN', + ), + ), + )); + + return $posts; + } + + /** + * Reload folder tree + * + * @return void + */ + public function reloadFolderTree() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + $terms = self::getTermsHierarchical($taxonomy); + wp_send_json( + array( + 'status' => true, + 'categories' => $terms + ) + ); + } + + /** + * Ajax custom order for folder + * + * @return void + */ + public function reorderfolder() + { + if (empty($_POST['wpmf_nonce']) + || !wp_verify_nonce($_POST['wpmf_nonce'], 'wpmf_nonce')) { + die(); + } + + if (isset($_POST['folder_post_type_name']) && $_POST['folder_post_type_name'] !== '') { + $taxonomy = esc_attr(trim($_POST['folder_post_type_name'])); + } else { + die(); + } + + if (isset($_POST['order'])) { + $orders = (array) json_decode(stripslashes_deep($_POST['order'])); + if (is_array($orders) && !empty($orders)) { + foreach ($orders as $position => $id) { + update_term_meta( + (int) $id, + $taxonomy.'_order', + (int) $position + ); + } + } + + $terms = self::getTermsHierarchical($taxonomy); + wp_send_json( + array( + 'status' => true, + 'categories' => $terms + ) + ); + } + } + + /** + * Generate a custom admin link for a specific term in a custom taxonomy. + * + * @param integer $term_id The ID of the term + * @param string $taxonomy Taxonomy + * + * @return string + */ + public static function getTermAdminLink($term_id, $taxonomy) + { + $type = str_replace('wpmf-folder-type-', '', $taxonomy); + if ($term_id === 0) { + return admin_url('edit.php?post_type='.$type); + } + + if ($term_id > 0) { + $term = get_term($term_id, $taxonomy); + if (is_wp_error($term) || !$term) { + return ''; + } + $term_slug = $term->slug; + } elseif ($term_id === -1) { + $term_slug = 'wpmf-unassigned'; + } + + $admin_url = admin_url('edit.php'); + + $query_args = array( + 'post_type' => $type, + $taxonomy => $term_slug + ); + + $admin_link = add_query_arg($query_args, $admin_url); + + return $admin_link; + } + + /** + * Get access + * + * @param integer $term_id Folder ID + * @param integer $user_id User ID + * @param string $capability Capability + * @param string $taxonomy Taxonomy + * + * @return boolean + */ + public static function getAccess($term_id, $user_id, $capability, $taxonomy) + { + $is_access = false; + $roles = WpmfHelper::getAllRoles($user_id); + if (in_array('administrator', $roles)) { + return true; + } + + if (empty($term_id)) { + return false; + } + + global $current_user; + $term = get_term($term_id, $taxonomy); + // inherit folder permissions + $role_permissions = get_term_meta((int)$term_id, 'wpmf_folder_role_permissions', true); + $user_permissions = get_term_meta((int)$term_id, 'wpmf_folder_user_permissions', true); + $inherit_folder = get_term_meta((int)$term_id, 'inherit_folder', true); + if ((($inherit_folder === '' && ($role_permissions === '' || empty($role_permissions[0])) && ($user_permissions === '' || empty($user_permissions[0]))) || !empty($inherit_folder)) && $term->parent !== 0) { + $ancestors = get_ancestors($term_id, $taxonomy, 'taxonomy'); + if (!empty($ancestors)) { + $t = false; + foreach ($ancestors as $ancestor) { + $inherit_folder = get_term_meta((int)$ancestor, 'inherit_folder', true); + if ((int)$inherit_folder === 0) { + $t = true; + $term_id = $ancestor; + break; + } + } + + if (!$t) { + $term_id = $ancestors[count($ancestors) - 1]; + } + } + } + + if ($capability !== 'view_folder' && !$term_id) { + return false; + } + + // only show role folder when access type is 'role' + $access_type = get_option('wpmf_create_folder'); + if ($access_type === 'role') { + if (in_array($term->name, $roles) && strpos($term->slug, '-wpmf-role') !== false) { + return true; + } + } + + // get access by role + $permissions = get_term_meta((int)$term_id, 'wpmf_folder_role_permissions'); + if (!empty($permissions)) { + foreach ($permissions as $permission) { + if (!empty($permission[0]) && in_array($permission[0], $roles) && in_array($capability, $permission)) { + $is_access = true; + break; + } + } + } + + if ($is_access) { + return true; + } else { + // get access by user + $permissions = get_term_meta((int)$term_id, 'wpmf_folder_user_permissions'); + if ($term->name === $current_user->user_login && (int) $term->term_group === (int) get_current_user_id()) { + return true; + } + + if (!empty($permissions)) { + foreach ($permissions as $permission) { + if ((int)$permission[0] === get_current_user_id() && in_array($capability, $permission)) { + $is_access = true; + break; + } + } + } + } + + return $is_access; + } + + /** + * Query post in folder + * + * @param object $query Params use to query post + * + * @return object $query + */ + public function restrictPostsByTaxonomy($query) + { + if (!is_admin() || !$query->is_main_query() || !isset($query->query_vars['post_type'])) { + return $query; + } + + global $typenow; + if (self::isActiveForScreen()) { + $user_id = get_current_user_id(); + $role = WpmfHelper::getRoles($user_id); + $tax = 'wpmf-folder-type-'.$typenow; + + $current_term_id = get_queried_object_id(); + $parse_url = parse_url(site_url()); + $host = md5($parse_url['host']); + if (isset($_COOKIE['lastAccessFolder_'.$host]) && is_int($current_term_id)) { + $lastAccessFolder = $current_term_id; + // phpcs:ignore + if (isset($_GET[$tax]) && $_GET[$tax] == 'wpmf-unassigned') { + $lastAccessFolder = -1; + } + if ($current_term_id !== 0) { + setcookie('lastAccessFolder_'.$host, $lastAccessFolder, time() + (365 * 24 * 60 * 60), '/', COOKIE_DOMAIN); + $current_term_id = $lastAccessFolder; + } else { + if (is_numeric($_COOKIE['lastAccessFolder_'.$host])) { + $current_term_id = $_COOKIE['lastAccessFolder_'.$host]; + } + } + } + + if (!$current_term_id) { + return $query; + } + + if ($current_term_id === '-1') { + $query->set('tax_query', array( + array( + 'taxonomy' => $tax, + 'field' => 'term_id', + 'terms' => array(), + 'operator' => 'NOT EXISTS' + ), + )); + + return $query; + } + + $current_term = get_term($current_term_id, $tax); + if (is_wp_error($current_term) || !$current_term) { + return $query; + } + + $child_terms = get_terms(array( + 'taxonomy' => $tax, + 'child_of' => $current_term_id, + 'fields' => 'ids', + 'hide_empty' => false, + )); + + if (!empty($child_terms)) { + $query->set('tax_query', array( + array( + 'taxonomy' => $tax, + 'field' => 'term_id', + 'terms' => $current_term_id, + 'include_children' => false, + ) + )); + } else { + $query->set('tax_query', array( + array( + 'taxonomy' => $tax, + 'field' => 'term_id', + 'terms' => $current_term_id, + ) + )); + } + + if ($role === 'administrator') { + return $query; + } + + $current_user = wp_get_current_user(); + $terms = self::getTermsHierarchical($tax); + $access_terms = array(); + foreach ($terms as $key => $value) { + if ($value->term_id !== 0) { + $access_terms[] = $value->term_id; + } + } + + if (!empty($access_terms)) { + $tax_query = array( + array( + 'taxonomy' => $tax, + 'field' => 'term_id', + 'terms' => $access_terms, + ), + ); + + $query->set('tax_query', $tax_query); + } + } + + return $query; + } + + /** + * Query unassigned posts in folder + * + * @param object $query Params use to query post + * + * @return object $query + */ + public function filterPostsByUnassignedFolder($query) + { + if (!is_admin() || !$query->is_main_query() || !isset($query->query_vars['post_type'])) { + return $query; + } + + global $typenow; + $tax = 'wpmf-folder-type-'.$typenow; + // phpcs:ignore + if (self::isActiveForScreen() && isset($_GET[$tax]) && $_GET[$tax] == 'wpmf-unassigned') { + if (isset($query->query_vars['tax_query'])) { + $tax_query = $query->query_vars['tax_query']; + $tax_query = array_filter($tax_query, function ($tax) { + if (isset($tax['taxonomy']) && $tax['taxonomy'] === $tax) { + return false; + } + return true; + }); + + $query->set('tax_query', $tax_query); + } + + if (isset($query->query_vars[$tax])) { + $query->set($tax, ''); + } + + $tax_query = array( + array( + 'taxonomy' => $tax, + 'field' => 'term_id', + 'terms' => array(), + 'operator' => 'NOT EXISTS' + ), + ); + $query->set('tax_query', $tax_query); + $query->set('post_status', array('publish', 'draft', 'future', 'private', 'pending')); + } + } + + /** + * Filter input data + * + * @param string $var The name of the variable to retrieve from the request + * + * @return mixed + */ + public function getRequestVar($var) + { + $response = filter_input(INPUT_POST, $var); + if (empty($response)) { + $response = filter_input(INPUT_GET, $var); + } + + return $response; + } + + /** + * Sanitize input options + * + * @param mixed $value The value to be sanitized + * @param string $type The type of sanitization to apply ('int', 'email', or default to text). + * + * @return mixed + */ + public static function sanitizeOptions($value, $type = '') + { + $value = stripslashes($value); + if ($type == 'int') { + $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT); + } elseif ($type == 'email') { + $value = filter_var($value, FILTER_SANITIZE_EMAIL); + } else { + $value = sanitize_text_field($value); + } + + return $value; + } + + /** + * Add Checkbox to table head for post types + * + * @param array $defaults An array of default columns in the table head + * @param string $d A placeholder parameter with no current use + * + * @return array + */ + public function manageColumnsHead($defaults, $d = '') + { + global $typenow; + $type = $typenow; + $action = $this->getRequestVar('action'); + if ($action == 'inline-save') { + $post_type = $this->getRequestVar('post_type'); + $type = self::sanitizeOptions($post_type); + } + + $options = wpmfGetOption('wpmf_active_folders_post_types'); + if (is_array($options) && in_array($type, $options)) { + $columns = ([ + 'wpmf_folder_move' => '
    ', + ] + $defaults); + return $columns; + } + + return $defaults; + } + + /** + * Add Checkbox to table body content for page, post, attachments + * + * @param string $column_name The name of the current column + * @param integer $post_ID The ID of the current post + * + * @return void + */ + public function manageColumnsContent($column_name, $post_ID) + { + $postIDs = self::$postIds; + if (!is_array($postIDs)) { + $postIDs = []; + } + + if (!in_array($post_ID, $postIDs)) { + $postIDs[] = $post_ID; + self::$postIds = $postIDs; + global $typenow; + $type = $typenow; + $action = $this->getRequestVar('action'); + if ($action == 'inline-save') { + $post_type = $this->getRequestVar('post_type'); + $type = self::sanitizeOptions($post_type); + } + + $options = wpmfGetOption('wpmf_active_folders_post_types'); + if (is_array($options) && in_array($type, $options)) { + if ($column_name == 'wpmf_folder_move') { + $title = get_the_title(); + if (strlen($title) > 20) { + $title = substr($title, 0, 20).'...'; + } + + echo "
    ".esc_attr($title).'
    '; + } + } + } + } + + /** + * Get children categories + * + * @param integer $id_parent Parent of attachment + * @param array $lists List childrens folder + * @param string $taxonomy Taxonomy + * + * @return array + */ + public function getFolderChild($id_parent, $lists, $taxonomy) + { + if (empty($lists)) { + $lists = array(); + } + $folder_childs = get_categories( + array( + 'taxonomy' => $taxonomy, + 'parent' => (int) $id_parent, + 'hide_empty' => false + ) + ); + if (count($folder_childs) > 0) { + foreach ($folder_childs as $child) { + $lists[] = $child->term_id; + $lists = $this->getFolderChild($child->term_id, $lists, $taxonomy); + } + } + + return $lists; + } + + /** + * Load styles + * + * @param string $post_type Post type name + * + * @return void + */ + public function loadAssets($post_type) + { + wp_enqueue_script('jquery'); + wp_enqueue_script('jquery-ui-sortable'); + wp_enqueue_script('jquery-ui-draggable'); + wp_enqueue_script('jquery-ui-droppable'); + wp_enqueue_style( + 'wpmf-material-icon', + plugins_url('/assets/css/google-material-icon.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_style( + 'wpmf-jaofiletree', + plugins_url('/assets/css/jaofiletree.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_style( + 'wpmf-style', + plugins_url('/assets/css/style.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_style( + 'wpmf-mdl', + plugins_url('/assets/css/modal-dialog/mdl-jquery-modal-dialog.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_style( + 'wpmf-deep_orange', + plugins_url('/assets/css/modal-dialog/material.deep_orange-amber.min.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_style( + 'wpmf-style-tippy', + plugins_url('/assets/js/tippy/tippy.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_script( + 'wpmf-material', + plugins_url('/assets/js/modal-dialog/material.min.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION + ); + + wp_enqueue_script( + 'wpmf-mdl', + plugins_url('/assets/js/modal-dialog/mdl-jquery-modal-dialog.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION + ); + + wp_enqueue_style( + 'wpmf-gallery-popup-style', + plugins_url('/assets/css/display-gallery/magnific-popup.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_enqueue_script( + 'wpmf-gallery-popup', + plugins_url('/assets/js/display-gallery/jquery.magnific-popup.min.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION, + true + ); + + wp_register_script( + 'wpmf-folder-post-type', + plugins_url('/assets/js/folder-post-type.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION + ); + + wp_enqueue_script('wpmf-folder-post-type'); + + wp_enqueue_script( + 'wpmf-scrollbar', + plugins_url('/assets/js/scrollbar/jquery.scrollbar.min.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION + ); + wp_enqueue_style( + 'wpmf-scrollbar', + plugins_url('/assets/js/scrollbar/jquery.scrollbar.css', dirname(__FILE__)), + array(), + WPMF_VERSION + ); + + wp_register_script( + 'wpmf-folder-post-type-tree', + plugins_url('/assets/js/folder-tree-for-post-type.js', dirname(__FILE__)), + array('wpmf-folder-post-type'), + WPMF_VERSION + ); + wp_enqueue_script('wpmf-folder-post-type-tree'); + + wp_register_script( + 'wpmf-folder-snackbar', + plugins_url('/assets/js/snackbar.js', dirname(__FILE__)), + array('wpmf-folder-post-type'), + WPMF_VERSION + ); + wp_enqueue_script('wpmf-folder-snackbar'); + + wp_enqueue_script( + 'wpmf-tippy-core', + plugins_url('/assets/js/tippy/tippy-core.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION + ); + + wp_enqueue_script( + 'wpmf-tippy', + plugins_url('/assets/js/tippy/tippy.js', dirname(__FILE__)), + array('jquery'), + WPMF_VERSION + ); + + $params = $this->localizeScript($post_type); + wp_localize_script('wpmf-folder-post-type', 'wpmf', $params); + wp_enqueue_script('wplink'); + wp_enqueue_style('editor-buttons'); + } + + /** + * Localize a script. + * Works only if the script has already been added. + * + * @param string $post_type Post type name + * + * @return array + */ + public function localizeScript($post_type) + { + global $pagenow, $wpdb, $typenow, $wp_roles, $current_user; + $parse_url = parse_url(site_url()); + $host = md5($parse_url['host']); + $hide_tree = wpmfGetOption('hide_tree'); + + /** + * Filter to set limit of the folder number loaded + * + * @param integer Limit folder number + * + * @return integer + */ + $limit_folders_number = apply_filters('wpmf_limit_folders', 99999); + + $enable_folders = wpmfGetOption('enable_folders'); + $show_folder_id = wpmfGetOption('show_folder_id'); + // get colors folder option + $colors_option = wpmfGetOption('folder_color'); + // get folder tree status option + $minimize_folder_tree_post_type = wpmfGetOption('wpmf_minimize_folder_tree_post_type'); + $folder_tree_status_option = wpmfGetOption('wpmf_folder_tree_status'); + + $admin_url = get_admin_url(null, basename($_SERVER['REQUEST_URI'])); + $getData = filter_input_array(INPUT_GET); + if (is_null($getData)) { + $admin_url = admin_url('edit.php?post_type='.$typenow); + } + + // phpcs:ignore + if (!isset($_GET['wpmf-folder-type-'.$post_type])) { + $admin_url .= '&wpmf-folder-type-'.esc_attr($post_type).'='; + $post_value = filter_input(INPUT_GET, $post_type); + if (!empty($post_value)) { + $admin_url .= esc_attr($post_value); + } + } + $current_url = $admin_url; + + $tax = 'wpmf-folder-type-'.$post_type; + $terms = self::getTermsHierarchical($tax); + + if (!empty($current_user->ID)) { + $enable_permissions_settings = ((isset($current_user->allcaps['wpmf_enable_permissions_settings']) && $current_user->allcaps['wpmf_enable_permissions_settings']) || in_array('administrator', $current_user->roles)); + } + + $current_role = WpmfHelper::getRoles(get_current_user_id()); + + $roles = $wp_roles->roles; + $role_in = array(); + foreach ($roles as $role_name => $r) { + if (isset($r['capabilities']['upload_files']) && $r['capabilities']['upload_files']) { + $role_in[] = $role_name; + } + } + unset($roles['administrator']); + + $args = array ( + 'role__in' => $role_in, + 'order' => 'ASC', + 'orderby' => 'display_name', + 'fields' => array('ID', 'display_name') + ); + $wp_user_query = new WP_User_Query($args); + $users = $wp_user_query->get_results(); + + $lastAccessFolder = 0; + $current_term_id = get_queried_object_id(); + if (isset($_COOKIE['lastAccessFolder_'.$host]) && is_int($current_term_id)) { + $lastAccessFolder = $current_term_id; + // phpcs:ignore + if (isset($_GET[$tax]) && $_GET[$tax] == 'wpmf-unassigned') { + $lastAccessFolder = -1; + } + } + + $l18n = $this->translation(); + $vars = array( + 'site_url' => site_url(), + 'current_url' => $current_url, + 'host' => $host, + 'taxo' => $tax, + 'post_type' => $post_type, + 'ajaxurl' => admin_url('admin-ajax.php'), + 'colors' => $colors_option, + 'hide_tree' => $hide_tree, + 'minimize_folder_tree' => $minimize_folder_tree_post_type, + 'folder_tree_status' => $folder_tree_status_option, + 'limit_folders_number' => $limit_folders_number, + 'enable_folders' => $enable_folders, + 'show_folder_id' => ((int) $show_folder_id === 1) ? true : false, + 'wpmf_categories' => $terms, + 'wpmf_addon_active' => (is_plugin_active('wp-media-folder-addon/wp-media-folder-addon.php')) ? 1 : 0, + 'wpmf_nonce' => wp_create_nonce('wpmf_nonce'), + 'wpmf_pagenow' => $pagenow, + 'wpmf_post_type' => 'wpmf-folder-post-type', + 'wpmf_role' => $current_role, + 'roles' => $roles, + 'users' => $users, + 'enable_permissions_settings' => $enable_permissions_settings, + 'lastAccessFolder' => $lastAccessFolder + ); + + return array('l18n' => $l18n, 'vars' => $vars); + } + + /** + * Get translation string + * + * @return array + */ + public function translation() + { + $l18n = array( + 'bulk_select' => __('Bulk select folders', 'wpmf'), + 'view_folder' => __('View folder', 'wpmf'), + 'add_folder' => __('Add Folder', 'wpmf'), + 'update_folder' => __('Update folder', 'wpmf'), + 'remove_folder' => __('Remove folder', 'wpmf'), + 'inherit_folder' => __('Inherit permissions', 'wpmf'), + 'add_media' => __('Add item', 'wpmf'), + 'view_media' => __('View item', 'wpmf'), + 'move_media' => __('Move item', 'wpmf'), + 'remove_media' => __('Remove item', 'wpmf'), + 'update_media' => __('Update item', 'wpmf'), + 'permissions_list_of' => __('Permission lists of', 'wpmf'), + 'folder' => __('folder', 'wpmf'), + 'user' => __('User', 'wpmf'), + 'role' => __('Role', 'wpmf'), + 'add_role' => __('Add another role permission', 'wpmf'), + 'add_user' => __('Add another user permission', 'wpmf'), + 'change_folder' => __('Move to / Multi folders', 'wpmf'), + 'create_folder' => __('Add new folder', 'wpmf'), + 'load_more' => __('Load More', 'wpmf'), + 'refresh' => __('Refresh', 'wpmf'), + 'new_folder' => __('New Folder', 'wpmf'), + 'media_folder' => __('Media Library', 'wpmf'), + 'promt' => __('New folder name:', 'wpmf'), + 'edit_file_lb' => __('Please enter a new name for the item:', 'wpmf'), + 'edit_media' => __('Edit media', 'wpmf'), + 'title_media' => __('Title', 'wpmf'), + 'caption_media' => __('Caption', 'wpmf'), + 'alt_media' => __('Alternative Text', 'wpmf'), + 'desc_media' => __('Description', 'wpmf'), + 'new_folder_tree' => __('NEW FOLDER', 'wpmf'), + 'alert_add' => __('A folder already exists here with the same name. Please try with another name, thanks :)', 'wpmf'), + 'alert_delete_file' => __('Are you sure to want to delete this file?', 'wpmf'), + 'update_file_msg' => __('Update failed. Please try with another name, thanks :)', 'wpmf'), + 'alert_delete' => __('Are you sure to want to delete this folder?', 'wpmf'), + 'delete_multiple_folder'=> __('Are you sure to want to delete %d folder? Note that some folders contain subfolders or files.', 'wpmf'), + 'alert_delete_all' => __('Are you sure to want to delete this folder? Note that this folder contain subfolders or files.', 'wpmf'), + 'alert_delete1' => __('This folder contains media and/or subfolders, please delete them before or activate the setting that allows to remove a folder with its media', 'wpmf'), + 'display_own_media' => __('Display only my own medias', 'wpmf'), + 'create_gallery_folder' => __('Create a gallery from folder', 'wpmf'), + 'home' => __('Media Library', 'wpmf'), + 'youarehere' => __('You are here', 'wpmf'), + 'back' => __('Back', 'wpmf'), + 'dragdrop' => __('Drag and Drop me hover a folder', 'wpmf'), + 'pdf' => __('PDF', 'wpmf'), + 'other' => __('Other', 'wpmf'), + 'link_to' => __('Link To', 'wpmf'), + 'duplicate_text' => __('Duplicate', 'wpmf'), + 'wpmf_undo' => __('Undo.', 'wpmf'), + 'wpmf_undo_remove' => __('Folder removed.', 'wpmf'), + 'wpmf_undo_movefolder' => __('Moved a folder.', 'wpmf'), + 'wpmf_undo_editfolder' => __('Folder name updated', 'wpmf'), + 'cancel' => __('Cancel', 'wpmf'), + 'create' => __('Create', 'wpmf'), + 'save' => __('Save', 'wpmf'), + 'save_close' => __('Save and close', 'wpmf'), + 'ok' => __('OK', 'wpmf'), + 'delete' => __('Delete', 'wpmf'), + 'remove' => __('Remove', 'wpmf'), + 'edit_folder' => __('Rename', 'wpmf'), + 'proceed' => __('proceed', 'wpmf'), + 'copy_folder_id' => __('Copy folder ID: ', 'wpmf'), + 'copy_folderID_msg' => __('Folder ID copied to clipboard', 'wpmf'), + 'change_color' => __('Change color', 'wpmf'), + 'permissions_setting' => __('Permissions settings', 'wpmf'), + 'information' => __('Information', 'wpmf'), + 'clear_filters' => __('Clear filters and sorting', 'wpmf'), + 'label_filter_order' => __('Filter or order media', 'wpmf'), + 'label_remove_filter' => __('Remove all filters', 'wpmf'), + 'wpmf_addfolder' => __('Folder added', 'wpmf'), + 'wpmf_folder_adding' => __('Adding folder...', 'wpmf'), + 'wpmf_folder_deleting' => __('Removing folder...', 'wpmf'), + 'folder_editing' => __('Editing folder...', 'wpmf'), + 'folder_moving' => __('Moving folder...', 'wpmf'), + 'folder_moving_text' => __('Moving folder', 'wpmf'), + 'moving' => __('Moving', 'wpmf'), + 'label_apply' => __('Apply', 'wpmf'), + 'folder_selection' => __('New folder selection applied to media', 'wpmf'), + 'select_folder_label' => __('Select folder:', 'wpmf'), + 'filter_label' => __('Filtering', 'wpmf'), + 'sort_label' => __('Sorting', 'wpmf'), + 'order_folder' => array( + 'name-ASC' => __('Name (Ascending)', 'wpmf'), + 'name-DESC' => __('Name (Descending)', 'wpmf'), + 'id-ASC' => __('ID (Ascending)', 'wpmf'), + 'id-DESC' => __('ID (Descending)', 'wpmf'), + 'custom' => __('Custom order', 'wpmf'), + ), + 'order_media' => array( + 'date|asc' => __('Date (Ascending)', 'wpmf'), + 'date|desc' => __('Date (Descending)', 'wpmf'), + 'title|asc' => __('Title (Ascending)', 'wpmf'), + 'title|desc' => __('Title (Descending)', 'wpmf'), + 'size|asc' => __('Size (Ascending)', 'wpmf'), + 'size|desc' => __('Size (Descending)', 'wpmf'), + 'filetype|asc' => __('File type (Ascending)', 'wpmf'), + 'filetype|desc' => __('File type (Descending)', 'wpmf'), + 'custom' => __('Custom order', 'wpmf'), + ), + 'colorlists' => array( + '#ac725e' => __('Chocolate ice cream', 'wpmf'), + '#d06b64' => __('Old brick red', 'wpmf'), + '#f83a22' => __('Cardinal', 'wpmf'), + '#fa573c' => __('Wild strawberries', 'wpmf'), + '#ff7537' => __('Mars orange', 'wpmf'), + '#ffad46' => __('Yellow cab', 'wpmf'), + '#42d692' => __('Spearmint', 'wpmf'), + '#16a765' => __('Vern fern', 'wpmf'), + '#7bd148' => __('Asparagus', 'wpmf'), + '#b3dc6c' => __('Slime green', 'wpmf'), + '#fbe983' => __('Desert sand', 'wpmf'), + '#fad165' => __('Macaroni', 'wpmf'), + '#92e1c0' => __('Sea foam', 'wpmf'), + '#9fe1e7' => __('Pool', 'wpmf'), + '#9fc6e7' => __('Denim', 'wpmf'), + '#4986e7' => __('Rainy sky', 'wpmf'), + '#9a9cff' => __('Blue velvet', 'wpmf'), + '#b99aff' => __('Purple dino', 'wpmf'), + '#8f8f8f' => __('Mouse', 'wpmf'), + '#cabdbf' => __('Mountain grey', 'wpmf'), + '#cca6ac' => __('Earthworm', 'wpmf'), + '#f691b2' => __('Bubble gum', 'wpmf'), + '#cd74e6' => __('Purple rain', 'wpmf'), + '#a47ae2' => __('Toy eggplant', 'wpmf'), + ), + 'placegolder_color' => __('Custom color #8f8f8f', 'wpmf'), + 'bgcolorerror' => __('Change background folder has failed', 'wpmf'), + 'search_folder' => __('Search folders...', 'wpmf'), + 'msg_upload_folder' => __('You are uploading media to folder: ', 'wpmf'), + 'addon_ajax_button' => __('Use ajax link', 'wpmf'), + 'orderby' => esc_html__('Order by', 'wpmf'), + 'custom' => esc_html__('Custom', 'wpmf'), + 'random' => esc_html__('Random', 'wpmf'), + 'title' => esc_html__('Title', 'wpmf'), + 'order' => esc_html__('Order', 'wpmf'), + 'ascending' => esc_html__('Ascending', 'wpmf'), + 'descending' => esc_html__('Descending', 'wpmf'), + 'update_with_new_folder' => esc_html__('Update with new folder content', 'wpmf'), + 'yes' => esc_html__('Yes', 'wpmf'), + 'no' => esc_html__('No', 'wpmf'), + 'caption' => esc_html__('Caption', 'wpmf'), + 'custom_link' => esc_html__('Custom link', 'wpmf'), + 'create_gallery' => esc_html__('CREATE GALLERY', 'wpmf'), + 'select_folder' => esc_html__('Select a folder', 'wpmf'), + 'search_no_result' => esc_html__('Sorry, no folder found', 'wpmf'), + 'select_item' => esc_html__('Select items to move', 'wpmf'), + 'select_this_item' => esc_html__('Drag this item into a folder', 'wpmf'), + 'item_selected' => esc_html__('Item selected', 'wpmf'), + 'items_selected' => esc_html__('Items selected', 'wpmf'), + 'by_role' => esc_html__('By Role', 'wpmf'), + 'by_user' => esc_html__('By User', 'wpmf'), + 'select_role' => esc_html__('Select a role', 'wpmf'), + 'select_user' => esc_html__('Select a user', 'wpmf'), + ); + + return $l18n; + } +} diff --git a/wp/wp-content/plugins/wp-media-folder/class/class-helper.php b/wp/wp-content/plugins/wp-media-folder/class/class-helper.php index 733d5782..de3abb1a 100644 --- a/wp/wp-content/plugins/wp-media-folder/class/class-helper.php +++ b/wp/wp-content/plugins/wp-media-folder/class/class-helper.php @@ -2297,4 +2297,24 @@ class WpmfHelper return 'application/octet-stream'; } } + + /** + * Check is folder active for post type + * + * @param string $post_type Post type name + * + * @return boolean + */ + public static function isForThisPostType($post_type) + { + $settings = get_option('wpmf_settings'); + if (isset($settings) && isset($settings['wpmf_active_folders_post_types'])) { + $post_types = $settings['wpmf_active_folders_post_types']; + $post_types = is_array($post_types) ? $post_types : []; + } else { + $post_types = array(); + } + + return in_array($post_type, $post_types); + } } diff --git a/wp/wp-content/plugins/wp-media-folder/class/class-main.php b/wp/wp-content/plugins/wp-media-folder/class/class-main.php index 7634344f..b23443a8 100644 --- a/wp/wp-content/plugins/wp-media-folder/class/class-main.php +++ b/wp/wp-content/plugins/wp-media-folder/class/class-main.php @@ -1016,6 +1016,12 @@ class WpMediaFolder */ public function loadAssets() { + global $typenow, $current_screen; + + if (WpmfHelper::isForThisPostType($typenow) && 'edit' == $current_screen->base) { + return; + } + wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-draggable'); @@ -2042,7 +2048,8 @@ class WpMediaFolder continue; } - if (defined('WPMFAD_PLUGIN_DIR')) { + // Todo: Upon disconnection, remove cloud folder data from the database. This will bypass the unnecessary 'exclude' check, enhancing overall performance + if (false && defined('WPMFAD_PLUGIN_DIR')) { $type = $this->getTermMeta($term->term_id, 'wpmf_drive_type'); if ((in_array('Dropbox', $exclude) && $type === 'dropbox') || (in_array('Google Drive', $exclude) && $type === 'google_drive') diff --git a/wp/wp-content/plugins/wp-media-folder/class/class-pdf-embed.php b/wp/wp-content/plugins/wp-media-folder/class/class-pdf-embed.php index 73424e83..604f7792 100644 --- a/wp/wp-content/plugins/wp-media-folder/class/class-pdf-embed.php +++ b/wp/wp-content/plugins/wp-media-folder/class/class-pdf-embed.php @@ -201,22 +201,29 @@ class WpmfPdfEmbed $width = (!empty($attrs['width']) && strpos($attrs['width'], '%') === false) ? $attrs['width'] : '100%'; $height = (!empty($attrs['height']) && strpos($attrs['height'], '%') === false) ? $attrs['height'] : '800'; $download = (!empty($attrs['download'])) ? $attrs['download'] : 'off'; - $plugin_dir_url = plugin_dir_url(__DIR__); - $viewer_base_url = $plugin_dir_url . 'class/templates/pdf-embed.php'; - $response = wp_remote_head($url); - if (is_wp_error($response)) { - $url = $plugin_dir_url . 'assets/pdf-loading-error.pdf'; - } - - $status_code = wp_remote_retrieve_response_code($response); - if ($status_code === 404) { - $url = $plugin_dir_url . 'assets/pdf-loading-error.pdf'; - } + $wpmf_pdf_embed_old = apply_filters('wpmf_pdf_embed_old', false); + if ($wpmf_pdf_embed_old) { + $width = (!empty($attrs['width']) && strpos($attrs['width'], '%') === false) ? $attrs['width'] : ''; + $return = ''.esc_html($title).''; + } else { + $plugin_dir_url = plugin_dir_url(__DIR__); + $viewer_base_url = $plugin_dir_url . 'class/templates/pdf-embed.php'; - $attachment_info = '?file=' . urlencode($url); - $final_url = $viewer_base_url . $attachment_info . '&plugins_url=' . urlencode($plugin_dir_url); - $return = '
    '; + $response = wp_remote_head($url); + if (is_wp_error($response)) { + $url = $plugin_dir_url . 'assets/pdf-loading-error.pdf'; + } + + $status_code = wp_remote_retrieve_response_code($response); + if ($status_code === 404) { + $url = $plugin_dir_url . 'assets/pdf-loading-error.pdf'; + } + + $attachment_info = '?file=' . urlencode($url); + $final_url = $viewer_base_url . $attachment_info . '&plugins_url=' . urlencode($plugin_dir_url); + $return = '
    '; + } } else { $return = ''.esc_html($title).''; } @@ -257,7 +264,13 @@ class WpmfPdfEmbed */ public function enqueue() { - wp_enqueue_script('wpmf_compat_js'); + $wpmf_pdf_embed_old = apply_filters('wpmf_pdf_embed_old', false); + if ($wpmf_pdf_embed_old) { + wp_enqueue_script('wpmf_embed_pdf_js'); + wp_enqueue_script('wpmf_compat_js'); + wp_enqueue_script('wpmf_pdf_js'); + wp_enqueue_style('pdfemb_embed_pdf_css'); + } } /** @@ -269,7 +282,6 @@ class WpmfPdfEmbed public function getTranslation() { $array = array( - // 'worker_src' => plugins_url('assets/js/pdf-embed/pdf.worker.min.js', dirname(__FILE__)), 'worker_src' => plugins_url('assets/js/pdf-embed/pdf.worker.js', dirname(__FILE__)), 'cmap_url' => plugins_url('assets/js/pdf-embed/cmaps/', dirname(__FILE__)), 'pdf_sandbox'=> plugins_url('assets/js/pdf-embed/pdf.sandbox.js', dirname(__FILE__)), @@ -292,6 +304,11 @@ class WpmfPdfEmbed 'poweredby' => 1 ) ); + $wpmf_pdf_embed_old = apply_filters('wpmf_pdf_embed_old', false); + if ($wpmf_pdf_embed_old) { + $array['worker_src'] = plugins_url('assets/js/pdf-embed/pdf.worker.min.js', dirname(__FILE__)); + unset($array['pdf_sandbox']); + } return $array; } @@ -404,22 +421,33 @@ class WpmfPdfEmbed */ public function registerScript() { - wp_register_script( - 'wpmf_compat_js', - plugins_url('assets/js/pdf-embed/compatibility.js', dirname(__FILE__)), - array('jquery') - ); - } - - /** - * Add script - * - * @return void - */ - public function addCustomPdfL10nLink() - { - $locale_url = plugins_url('assets/js/pdf-embed/locale/locale.properties', dirname(__FILE__)); - echo ''; + $wpmf_pdf_embed_old = apply_filters('wpmf_pdf_embed_old', false); + if ($wpmf_pdf_embed_old) { + wp_register_script( + 'wpmf_embed_pdf_js', + plugins_url('assets/js/pdf-embed/all-pdfemb-basic.min.js', dirname(__FILE__)), + array('jquery') + ); + wp_localize_script( + 'wpmf_embed_pdf_js', + 'wpmf_pdfemb_trans', + $this->getTranslation() + ); + wp_register_script( + 'wpmf_compat_js', + plugins_url('assets/js/pdf-embed/compatibility.js', dirname(__FILE__)), + array('jquery') + ); + wp_register_script( + 'wpmf_pdf_js', + plugins_url('assets/js/pdf-embed/pdf-old.js', dirname(__FILE__)), + array() + ); + wp_register_style( + 'pdfemb_embed_pdf_css', + plugins_url('assets/css/pdfemb-embed-pdf.css', dirname(__FILE__)) + ); + } } /** diff --git a/wp/wp-content/plugins/wp-media-folder/class/class-wp-folder-option.php b/wp/wp-content/plugins/wp-media-folder/class/class-wp-folder-option.php index b635d537..114d5e0e 100644 --- a/wp/wp-content/plugins/wp-media-folder/class/class-wp-folder-option.php +++ b/wp/wp-content/plugins/wp-media-folder/class/class-wp-folder-option.php @@ -1693,6 +1693,22 @@ class WpmfMediaFolderOption if (!get_option('wpmf_gallery_settings', false)) { add_option('wpmf_gallery_settings', $gallery_settings, '', 'yes'); } + + if (!get_option('wpmf_minimize_folder_tree_post_type', false)) { + add_option('wpmf_minimize_folder_tree_post_type', 1, '', 'yes'); + } + + $post_types = $this->getAllPostTypes(); + foreach ($post_types as $post_type) { + $option_name = 'wpmf_option_folder_'.$post_type->name; + if (!get_option($option_name, false)) { + if ($option_name === 'wpmf_option_folder_post') { + add_option($option_name, 1, '', 'yes'); + } else { + add_option($option_name, 0, '', 'yes'); + } + } + } } /** @@ -2474,7 +2490,8 @@ class WpmfMediaFolderOption 'root_media_count', 'watermark_exclude_public_gallery', 'watermark_exclude_photograph_gallery', - 'connect_nextcloud' + 'connect_nextcloud', + 'wpmf_minimize_folder_tree_post_type' ); if (isset($_POST['btn_wpmf_save'])) { if (empty($_POST['wpmf_nonce']) @@ -2743,6 +2760,19 @@ class WpmfMediaFolderOption } } + $post_types = $this->getAllPostTypes(); + $wpmf_active_folders_post_types = array(); + foreach ($post_types as $post_type) { + $option = 'wpmf_option_folder_'.$post_type->name; + if (isset($_POST[$option])) { + wpmfSetOption($option, $_POST[$option]); + if ((int) $_POST[$option] === 1) { + $wpmf_active_folders_post_types[] = $post_type->name; + } + } + } + wpmfSetOption('wpmf_active_folders_post_types', $wpmf_active_folders_post_types); + if (isset($_POST['wpmf_active_media']) && (int) $_POST['wpmf_active_media'] === 1) { $wpmf_checkbox_tree = get_option('wpmf_checkbox_tree'); if (!empty($wpmf_checkbox_tree)) { @@ -4404,4 +4434,29 @@ class WpmfMediaFolderOption ); } } + + /** + * Get all post types + * + * @return array + */ + public function getAllPostTypes() + { + $post_types = get_post_types(array( 'show_in_menu' => true ), 'objects'); + // List of post types to exclude + $page_builder_post_types = array( + 'elementor_library', + 'e-landing-page', + 'wpb', + 'attachment' + ); + + foreach ($page_builder_post_types as $page_builder_post_type) { + if (isset($post_types[$page_builder_post_type])) { + unset($post_types[$page_builder_post_type]); + } + } + + return $post_types; + } } diff --git a/wp/wp-content/plugins/wp-media-folder/class/pages/settings/general.php b/wp/wp-content/plugins/wp-media-folder/class/pages/settings/general.php index 959fece0..61a194f3 100644 --- a/wp/wp-content/plugins/wp-media-folder/class/pages/settings/general.php +++ b/wp/wp-content/plugins/wp-media-folder/class/pages/settings/general.php @@ -601,3 +601,81 @@ $featured_image_folder = wpmfGetOption('featured_image_folder'); + + + true ), 'objects'); + // List of post types to exclude + $exclude_post_types = array( + 'elementor_library', + 'e-landing-page', + 'wpb', + 'attachment', + 'shop_order', + 'shop_coupon' + ); + + foreach ($exclude_post_types as $exclude_post_type) { + if (isset($post_types[$exclude_post_type])) { + unset($post_types[$exclude_post_type]); + } + } + + $countPostTypes = 0; + ?> +
    +
    +
    +
    + + +
    + +
    +
    +
    + + + label).' '.esc_html__('(ie. classify', 'wpmf').' '.strtolower($value->label).' '.esc_html__('in folders, like virtual categories)', 'wpmf'); + ?> + +
    +
    + + +
    + +
    +
    +
    + + +
    +
    \ No newline at end of file diff --git a/wp/wp-content/plugins/wp-media-folder/class/pages/settings/wp-folder-options.php b/wp/wp-content/plugins/wp-media-folder/class/pages/settings/wp-folder-options.php index aaf37742..c771bbde 100644 --- a/wp/wp-content/plugins/wp-media-folder/class/pages/settings/wp-folder-options.php +++ b/wp/wp-content/plugins/wp-media-folder/class/pages/settings/wp-folder-options.php @@ -9,7 +9,7 @@ $tabs_data = array( 'sub_tabs' => array( 'additional_features' => __('Main settings', 'wpmf'), 'media_filtering' => __('Media filtering', 'wpmf'), -// 'advanced' => __('Advanced', 'wpmf') + 'folder_settings' => __('Folder settings', 'wpmf') ) ), array( diff --git a/wp/wp-content/plugins/wp-media-folder/class/templates/folder-tree-tpl.php b/wp/wp-content/plugins/wp-media-folder/class/templates/folder-tree-tpl.php new file mode 100644 index 00000000..bae9c5a4 --- /dev/null +++ b/wp/wp-content/plugins/wp-media-folder/class/templates/folder-tree-tpl.php @@ -0,0 +1,24 @@ + $post_type_name], 'objects'); + if (!empty($post_types) && is_array($post_types) && isset($post_types[$post_type_name]) && isset($post_types[$post_type_name]->label)) { + $label = $post_types[$post_type_name]->label; + } +} + +$folder_tree_status_option = wpmfGetOption('wpmf_folder_tree_status'); +$class_name = ''; +if (!empty($folder_tree_status_option) && (isset($folder_tree_status_option[$typenow]) && $folder_tree_status_option[$typenow] === 'hide') || !isset($folder_tree_status_option[$typenow])) { + $class_name = 'wpmf-hide-folder-tree'; +} +?> +
    +
    +
    \ No newline at end of file diff --git a/wp/wp-content/plugins/wp-media-folder/languages/wpmf-en_US.mo b/wp/wp-content/plugins/wp-media-folder/languages/wpmf-en_US.mo index dce74de6..f790ca7c 100644 Binary files a/wp/wp-content/plugins/wp-media-folder/languages/wpmf-en_US.mo and b/wp/wp-content/plugins/wp-media-folder/languages/wpmf-en_US.mo differ diff --git a/wp/wp-content/plugins/wp-media-folder/readme.txt b/wp/wp-content/plugins/wp-media-folder/readme.txt index 692dfea1..d8c3d349 100644 --- a/wp/wp-content/plugins/wp-media-folder/readme.txt +++ b/wp/wp-content/plugins/wp-media-folder/readme.txt @@ -3,7 +3,7 @@ Tags: media, folder Requires at least: 4.7.0 Tested up to: 6.6 Requires PHP: 5.6 -Stable tag: 5.8.9 +Stable tag: 5.9.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -20,6 +20,20 @@ Stop searching for an image through thousand of media, just navigate like you do = Changelog = += 5.9.3 = + * Fix : The Screen Options dropdown menu on the admin screen is not working + += 5.9.2 = + * Fix : Error when saving post with some post type + += 5.9.1 = + * Fix : Error with some custom post type. + += 5.9.0 = + * Add : Possibility to organize posts with folders (activated by default) + * Add : Possibility to organize pages with folders (not enabled by default) + * Add : Possibility to organize custom post with folders (not enabled by default) + = 5.8.9 = * Fix : Drop and drag issue on Chrome browser (v127) diff --git a/wp/wp-content/plugins/wp-media-folder/wp-media-folder.php b/wp/wp-content/plugins/wp-media-folder/wp-media-folder.php index a3ccb6e7..64b81c40 100644 --- a/wp/wp-content/plugins/wp-media-folder/wp-media-folder.php +++ b/wp/wp-content/plugins/wp-media-folder/wp-media-folder.php @@ -4,7 +4,7 @@ Plugin URI: http://www.joomunited.com Description: WP media Folder is a WordPress plugin that enhance the WordPress media manager by adding a folder manager inside. Author: Joomunited - Version: 5.8.9 + Version: 5.9.3 Update URI: https://www.joomunited.com/juupdater_files/wp-media-folder.json Author URI: http://www.joomunited.com Text Domain: wpmf @@ -79,7 +79,7 @@ if (!defined('WPMF_TAXO')) { define('_WPMF_GALLERY_PREFIX', '_wpmf_gallery_'); define('WPMF_PLUGIN_URL', plugin_dir_url(__FILE__)); define('WPMF_DOMAIN', 'wpmf'); -define('WPMF_VERSION', '5.8.9'); +define('WPMF_VERSION', '5.9.3'); define('WPMF_HIDE_USER_MEDIA_FOLDER_ROOT', true); include_once(ABSPATH . 'wp-admin/includes/plugin.php'); @@ -219,30 +219,6 @@ function wpmfSyncServerFolder() } } -/** - * Modify script tags to use type="module" for specific scripts. - * - * This function hooks into the 'script_loader_tag' filter to modify the script - * tags for specific handles ('wpmf_pdf_js', 'wpmf_embed_pdf_js'). If a script's - * handle matches one of these, the function changes the script tag to include - * type="module", which is necessary for ES6 module scripts. - * - * @param string $tag The original HTML script tag. - * @param string $handle The handle of the script. - * @param string $src The source URL of the script. - * - * @return string The modified script tag. - */ -function add_module_to_my_script($tag, $handle, $src) -{ - if ('wpmf_pdf_js' === $handle || 'wpmf_embed_pdf_js' === $handle || 'wpmf_embed_pdf_js' === $handle) { - $tag = '';//phpcs:ignore - } - - return $tag; -} -add_filter('script_loader_tag', 'add_module_to_my_script', 10, 3); - // Reintegrate WP Media Folders if (is_admin()) { if (!class_exists('\Joomunited\Queue\JuMainQueue')) { @@ -962,7 +938,11 @@ function wpmfGetOption($option_name) 'border_color' => '#f4f6ff', 'icon_image' => 'download_style_0', 'icon_color' => '#f4f6ff' - ), $media_download) + ), $media_download), + 'wpmf_minimize_folder_tree_post_type' => 1, + 'wpmf_option_folder_post' => 0, + 'wpmf_folder_tree_status' => array(), + 'wpmf_active_folders_post_types' => array() ); $settings = get_option('wpmf_settings'); if (isset($settings) && isset($settings[$option_name])) { @@ -977,6 +957,10 @@ function wpmfGetOption($option_name) } } + if (!isset($default_settings[$option_name])) { + return false; + } + return $default_settings[$option_name]; } @@ -1220,7 +1204,7 @@ function wpmfVcBeforeInit() array(), WPMF_VERSION ); - if (file_exists(WP_PLUGIN_DIR . '/wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) { + if (is_plugin_active(WP_PLUGIN_DIR . '/wp-media-folder-gallery-addon/wp-media-folder-gallery-addon.php')) { wp_enqueue_style( 'wpmf-bakery-download-all-style', WP_PLUGIN_URL . '/wp-media-folder-gallery-addon/assets/css/download_gallery.css', @@ -1370,6 +1354,9 @@ if (isset($load_gif) && (int) $load_gif === 0) { new WpmfLoadGif(); } +require_once(WP_MEDIA_FOLDER_PLUGIN_DIR . 'class/class-folder-post-type.php'); +new WpmfMediaFolderPostType(); + /** * Get cloud folder ID *