@internetarchive/bookreader 5.0.0-63 → 5.0.0-64

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. package/.github/workflows/node.js.yml +1 -0
  2. package/BookReader/BookReader.css +45 -58
  3. package/BookReader/BookReader.js +1 -1
  4. package/BookReader/BookReader.js.LICENSE.txt +2 -0
  5. package/BookReader/BookReader.js.map +1 -1
  6. package/BookReader/ia-bookreader-bundle.js +95 -95
  7. package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +2 -0
  8. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  9. package/BookReader/icons/1up.svg +1 -1
  10. package/BookReader/icons/2up.svg +1 -1
  11. package/BookReader/icons/advance.svg +1 -1
  12. package/BookReader/icons/chevron-right.svg +1 -1
  13. package/BookReader/icons/close-circle-dark.svg +1 -1
  14. package/BookReader/icons/close-circle.svg +1 -1
  15. package/BookReader/icons/fullscreen.svg +1 -1
  16. package/BookReader/icons/fullscreen_exit.svg +1 -1
  17. package/BookReader/icons/hamburger.svg +1 -1
  18. package/BookReader/icons/left-arrow.svg +1 -1
  19. package/BookReader/icons/magnify-minus.svg +1 -1
  20. package/BookReader/icons/magnify-plus.svg +1 -1
  21. package/BookReader/icons/magnify.svg +1 -1
  22. package/BookReader/icons/pause.svg +1 -1
  23. package/BookReader/icons/play.svg +1 -1
  24. package/BookReader/icons/playback-speed.svg +1 -1
  25. package/BookReader/icons/read-aloud.svg +1 -1
  26. package/BookReader/icons/review.svg +1 -1
  27. package/BookReader/icons/thumbnails.svg +1 -1
  28. package/BookReader/icons/voice.svg +1 -1
  29. package/BookReader/icons/volume-full.svg +1 -1
  30. package/BookReader/images/BRicons.svg +3 -3
  31. package/BookReader/images/books_graphic.svg +1 -1
  32. package/BookReader/images/icon_book.svg +1 -1
  33. package/BookReader/images/icon_bookmark.svg +1 -1
  34. package/BookReader/images/icon_gear.svg +1 -1
  35. package/BookReader/images/icon_hamburger.svg +1 -1
  36. package/BookReader/images/icon_home.svg +1 -1
  37. package/BookReader/images/icon_info.svg +1 -1
  38. package/BookReader/images/icon_one_page.svg +1 -1
  39. package/BookReader/images/icon_pause.svg +1 -1
  40. package/BookReader/images/icon_play.svg +1 -1
  41. package/BookReader/images/icon_search_button.svg +1 -1
  42. package/BookReader/images/icon_share.svg +1 -1
  43. package/BookReader/images/icon_skip-ahead.svg +1 -1
  44. package/BookReader/images/icon_skip-back.svg +1 -1
  45. package/BookReader/images/icon_speaker.svg +1 -1
  46. package/BookReader/images/icon_speaker_open.svg +1 -1
  47. package/BookReader/images/icon_thumbnails.svg +1 -1
  48. package/BookReader/images/icon_toc.svg +1 -1
  49. package/BookReader/images/icon_two_pages.svg +1 -1
  50. package/BookReader/images/marker_chap-off.svg +1 -1
  51. package/BookReader/images/marker_chap-on.svg +1 -1
  52. package/BookReader/images/marker_srch-on.svg +1 -1
  53. package/BookReader/jquery-3.js +1 -1
  54. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  55. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  56. package/BookReader/plugins/plugin.autoplay.js +1 -1
  57. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  58. package/BookReader/plugins/plugin.chapters.js +2 -1
  59. package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
  60. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  61. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  62. package/BookReader/plugins/plugin.mobile_nav.js +1 -1
  63. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
  64. package/BookReader/plugins/plugin.resume.js +1 -1
  65. package/BookReader/plugins/plugin.resume.js.map +1 -1
  66. package/BookReader/plugins/plugin.search.js +2 -1
  67. package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
  68. package/BookReader/plugins/plugin.search.js.map +1 -1
  69. package/BookReader/plugins/plugin.text_selection.js +2 -1
  70. package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
  71. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  72. package/BookReader/plugins/plugin.tts.js +1 -1
  73. package/BookReader/plugins/plugin.tts.js.LICENSE.txt +2 -0
  74. package/BookReader/plugins/plugin.tts.js.map +1 -1
  75. package/BookReader/plugins/plugin.url.js +1 -1
  76. package/BookReader/plugins/plugin.url.js.map +1 -1
  77. package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
  78. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  79. package/BookReader/webcomponents-bundle.js +1 -1
  80. package/BookReader/webcomponents-bundle.js.map +1 -1
  81. package/CHANGELOG.md +5 -0
  82. package/babel.config.js +5 -4
  83. package/netlify.toml +4 -0
  84. package/package.json +15 -15
  85. package/src/BookNavigator/search/search-results.js +1 -7
  86. package/src/BookReader/utils.js +10 -0
  87. package/src/css/_BRnav.scss +2 -2
  88. package/src/css/_BRsearch.scss +38 -10
  89. package/src/plugins/search/plugin.search.js +14 -21
  90. package/src/plugins/search/utils.js +43 -0
  91. package/src/plugins/search/view.js +11 -24
  92. package/tests/e2e/helpers/desktopSearch.js +3 -3
  93. package/tests/jest/BookNavigator/search/search-results.test.js +6 -1
  94. package/tests/jest/BookReader/utils.test.js +12 -0
  95. package/tests/jest/plugins/search/plugin.search.test.js +2 -39
  96. package/tests/jest/plugins/search/plugin.search.view.test.js +5 -0
  97. package/tests/jest/plugins/search/utils.js +25 -0
  98. package/tests/jest/plugins/search/utils.test.js +29 -0
@@ -1 +1 @@
1
- {"version":3,"file":"plugins/plugin.search.js","mappings":"4iBA6CwCA,EC+XxC,EA1aMC,WASJ,cAAwD,IAA1CC,EAA0C,EAA1CA,GAA0C,IAAtCC,wBAAAA,OAAsC,MAAZ,aAAY,G,4FAAA,SACtDC,KAAKF,GAAKA,EAKVE,KAAKC,QAAU,IAAIC,OAAO,gBAAiB,KAC3CF,KAAKG,QAAU,GACfH,KAAKI,mBACLJ,KAAKK,aACLL,KAAKM,aAAeP,E,qDAGtB,WACEC,KAAKO,IAAM,GAEXP,KAAKO,IAAIC,c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G2I,MAAMiG,MAAK,SAAA/C,GAC7B,IAAM/J,EAAY,EAAKC,KAAKC,eAAe6J,EAAI5L,MAC/C,GAAI2G,EAAOiI,QAAQ/M,EAAW0M,IAAiB,EAC7C,OAAO,SAKN,I,qBE9eT,IAAIM,EAAS,EAAQ,MACjBC,EAAQ,EAAQ,MAChBC,EAAc,EAAQ,MACtBC,EAAW,EAAQ,MACnBC,EAAO,aACPC,EAAc,EAAQ,MAEtBC,EAASJ,EAAY,GAAGI,QACxBC,EAAeP,EAAO9C,WACtBsD,EAASR,EAAOQ,OAChBC,EAAWD,GAAUA,EAAOE,SAC5BC,EAAS,EAAIJ,EAAaF,EAAc,QAAU,KAEhDI,IAAaR,GAAM,WAAcM,EAAa3D,OAAO6D,OAI3DG,EAAOC,QAAUF,EAAS,SAAoBG,GAC5C,IAAIC,EAAgBX,EAAKD,EAASW,IAC9B/B,EAASwB,EAAaQ,GAC1B,OAAkB,IAAXhC,GAA4C,KAA5BuB,EAAOS,EAAe,IAAa,EAAIhC,GAC5DwB,G,qBCrBJ,IAAIhS,EAAI,EAAQ,MACZyS,EAAW,gBAIfzS,EAAE,CAAE0G,OAAQ,SAAUgM,MAAM,GAAQ,CAClC5E,QAAS,SAAiB6E,GACxB,OAAOF,EAASE,O,qBCPpB,IAAI3S,EAAI,EAAQ,MACZ4S,EAAc,EAAQ,MAI1B5S,EAAE,CAAEyR,QAAQ,EAAMoB,OAAQlE,YAAciE,GAAe,CACrDjE,WAAYiE,M","sources":["webpack://@internetarchive/bookreader/./src/plugins/search/plugin.search.js","webpack://@internetarchive/bookreader/./src/plugins/search/view.js","webpack://@internetarchive/bookreader/./node_modules/core-js/internals/number-parse-float.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.object.entries.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.parse-float.js"],"sourcesContent":["// @ts-check\n/* global BookReader */\n/**\n * Plugin for Archive.org book search\n * NOTE: This script must be loaded AFTER `plugin.mobile_nav.js`\n * as it mutates mobile nav drawer\n *\n * Events fired at various points throughout search processing are published\n * on the document DOM element. These can be subscribed to using jQuery's event\n * binding method `$.fn.on`. All of the events are prefixed with a BookReader\n * namespace. The events are:\n *\n * @event BookReader:SearchStarted - When a search form is submitted, immediately\n * before an AJAX call is made to request search results\n * @event BookReader:SearchCallback - When the search AJAX call is returned and at\n * least one result is returned. The event callback receives an object\n * with the `results`, plugin `options`, and the BookReader `instance`\n * @event BookReader:SearchCallbackError - When the AJAX request returns an error.\n * Receives the `results` and `instance`\n * @event BookReader:SearchCallbackNotIndexed - When a message is received that\n * the book has not had OCR text indexed yet. Receives `instance`\n * @event BookReader:SearchCallbackEmpty - When no results found. Receives\n * `instance`\n * @event BookReader:SearchCanceled - When no results found. Receives\n * `instance`\n */\nimport { poll } from '../../BookReader/utils.js';\nimport { renderBoxesInPageContainerLayer } from '../../BookReader/PageContainer.js';\nimport SearchView from './view.js';\n/** @typedef {import('../../BookReader/PageContainer').PageContainer} PageContainer */\n/** @typedef {import('../../BookReader/BookModel').PageIndex} PageIndex */\n/** @typedef {import('../../BookReader/BookModel').LeafNum} LeafNum */\n/** @typedef {import('../../BookReader/BookModel').PageNumString} PageNumString */\n\njQuery.extend(BookReader.defaultOptions, {\n server: 'ia600609.us.archive.org',\n bookId: '',\n subPrefix: '',\n bookPath: '',\n enableSearch: true,\n searchInsideUrl: '/fulltext/inside.php',\n initialSearchTerm: null,\n});\n\n/** @override */\nBookReader.prototype.setup = (function (super_) {\n return function (options) {\n super_.call(this, options);\n\n this.searchTerm = '';\n this.searchResults = null;\n this.searchInsideUrl = options.searchInsideUrl;\n this.enableSearch = options.enableSearch;\n\n // Base server used by some api calls\n this.bookId = options.bookId;\n this.server = options.server;\n this.subPrefix = options.subPrefix;\n this.bookPath = options.bookPath;\n\n this.searchXHR = null;\n this._cancelSearch.bind(this);\n this.cancelSearchRequest.bind(this);\n\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n this._searchBoxesByIndex = {};\n\n this.searchView = undefined;\n };\n})(BookReader.prototype.setup);\n\n/** @override */\nBookReader.prototype.init = (function (super_) {\n return function () {\n super_.call(this);\n // give SearchView the most complete bookreader state\n this.searchView = new SearchView({\n br: this,\n searchCancelledCallback: () => {\n this._cancelSearch();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n });\n if (this.options.enableSearch && this.options.initialSearchTerm) {\n /**\n * this.search() take two parameter\n * 1. this.options.initialSearchTerm - search term\n * 2. {\n * goToFirstResult: this.options.goToFirstResult,\n * suppressFragmentChange: false // always want to change fragment in URL\n * }\n */\n this.search(\n this.options.initialSearchTerm,\n { goToFirstResult: this.options.goToFirstResult, suppressFragmentChange: false }\n );\n }\n };\n})(BookReader.prototype.init);\n\n/** @override */\nBookReader.prototype.buildToolbarElement = (function (super_) {\n return function () {\n const $el = super_.call(this);\n if (!this.enableSearch) { return; }\n if (this.searchView.dom.toolbarSearch) {\n $el.find('.BRtoolbarSectionInfo').after(this.searchView.dom.toolbarSearch);\n }\n return $el;\n };\n})(BookReader.prototype.buildToolbarElement);\n\n/** @override */\nBookReader.prototype._createPageContainer = (function (super_) {\n return function (index) {\n const pageContainer = super_.call(this, index);\n if (this.enableSearch && pageContainer.page && index in this._searchBoxesByIndex) {\n const pageIndex = pageContainer.page.index;\n const boxes = this._searchBoxesByIndex[pageIndex];\n renderBoxesInPageContainerLayer(\n 'searchHiliteLayer',\n boxes,\n pageContainer.page,\n pageContainer.$container[0],\n boxes.map(b => `match-index-${b.matchIndex}`),\n );\n }\n return pageContainer;\n };\n})(BookReader.prototype._createPageContainer);\n\n/**\n * @typedef {object} SearchOptions\n * @property {boolean} goToFirstResult\n * @property {boolean} disablePopup\n * @property {(null|function)} error - @deprecated at v.5.0\n * @property {(null|function)} success - @deprecated at v.5.0\n */\n\n/**\n * Submits search request\n *\n * @param {string} term\n * @param {SearchOptions} overrides\n */\nBookReader.prototype.search = async function(term = '', overrides = {}) {\n /** @type {SearchOptions} */\n const defaultOptions = {\n goToFirstResult: false, /* jump to the first result (default=false) */\n disablePopup: false, /* don't show the modal progress (default=false) */\n suppressFragmentChange: false, /* don't change the URL on initial load */\n error: null, /* optional error handler (default=null) */\n success: null, /* optional success handler (default=null) */\n\n };\n const options = jQuery.extend({}, defaultOptions, overrides);\n this.suppressFragmentChange = options.suppressFragmentChange;\n this.searchCancelled = false;\n\n // strip slashes, since this goes in the url\n this.searchTerm = term.replace(/\\//g, ' ');\n\n if (!options.suppressFragmentChange) {\n this.trigger(BookReader.eventNames.fragmentChange);\n }\n\n // Add quotes to the term. This is to compenstate for the backends default OR query\n // term = term.replace(/['\"]+/g, '');\n // term = '\"' + term + '\"';\n\n // Remove the port and userdir\n const serverPath = this.server.replace(/:.+/, '');\n const baseUrl = `https://${serverPath}${this.searchInsideUrl}?`;\n\n // Remove subPrefix from end of path\n let path = this.bookPath;\n const subPrefixWithSlash = `/${this.subPrefix}`;\n if (this.bookPath.length - this.bookPath.lastIndexOf(subPrefixWithSlash) == subPrefixWithSlash.length) {\n path = this.bookPath.substr(0, this.bookPath.length - subPrefixWithSlash.length);\n }\n\n const urlParams = {\n item_id: this.bookId,\n doc: this.subPrefix,\n path,\n q: term,\n };\n\n // NOTE that the API does not expect / (slashes) to be encoded. (%2F) won't work\n const paramStr = $.param(urlParams).replace(/%2F/g, '/');\n\n const url = `${baseUrl}${paramStr}`;\n\n const callSearchResultsCallback = (searchInsideResults) => {\n if (this.searchCancelled) {\n return;\n }\n const responseHasError = searchInsideResults.error || !searchInsideResults.matches.length;\n const hasCustomError = typeof options.error === 'function';\n const hasCustomSuccess = typeof options.success === 'function';\n\n if (responseHasError) {\n console.error('Search Inside Response Error', searchInsideResults.error || 'matches.length == 0');\n hasCustomError\n ? options.error.call(this, searchInsideResults, options)\n : this.BRSearchCallbackError(searchInsideResults, options);\n } else {\n hasCustomSuccess\n ? options.success.call(this, searchInsideResults, options)\n : this.BRSearchCallback(searchInsideResults, options);\n }\n };\n\n this.trigger('SearchStarted', { term: this.searchTerm, instance: this });\n callSearchResultsCallback(await $.ajax({\n url: url,\n dataType: 'jsonp',\n cache: true,\n beforeSend: xhr => { this.searchXHR = xhr; },\n }));\n};\n\n/**\n * cancels AJAX Call\n * emits custom event\n */\nBookReader.prototype._cancelSearch = function () {\n this.searchXHR?.abort();\n this.searchView.clearSearchFieldAndResults(false);\n this.searchTerm = '';\n this.searchXHR = null;\n this.searchCancelled = true;\n this.searchResults = [];\n};\n\n/**\n * External function to cancel search\n * checks for term & xhr in flight before running\n */\nBookReader.prototype.cancelSearchRequest = function () {\n this.searchCancelled = true;\n if (this.searchXHR !== null) {\n this._cancelSearch();\n this.searchView.toggleSearchPending();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n};\n\n/**\n * @typedef {object} SearchInsideMatchBox\n * @property {number} page\n * @property {number} r\n * @property {number} l\n * @property {number} b\n * @property {number} t\n * @property {HTMLDivElement} [div]\n * @property {number} matchIndex This is a fake field! not part of the API response. The index of the match that contains this box in total search results matches.\n */\n\n/**\n * @typedef {object} SearchInsideMatch\n * @property {number} matchIndex This is a fake field! Not part of the API response. It is added by the JS.\n * @property {string} displayPageNumber (fake field) The page number as it should be displayed in the UI.\n * @property {string} text\n * @property {Array<{ page: number, boxes: SearchInsideMatchBox[] }>} par\n */\n\n/**\n * @typedef {object} SearchInsideResults\n * @property {string} error\n * @property {SearchInsideMatch[]} matches\n * @property {boolean} indexed\n */\n\n/**\n * Attach some fields to search inside results\n * @param {SearchInsideResults} results\n * @param {(pageNum: LeafNum) => PageNumString} displayPageNumberFn\n */\nexport function marshallSearchResults(results, displayPageNumberFn) {\n // Attach matchIndex to a few things to make it easier to identify\n // an active/selected match\n for (const [index, match] of results.matches.entries()) {\n match.matchIndex = index;\n match.displayPageNumber = displayPageNumberFn(match.par[0].page);\n for (const par of match.par) {\n for (const box of par.boxes) {\n box.matchIndex = index;\n }\n }\n }\n}\n\n/**\n * Search Results return handler\n * @param {SearchInsideResults} results\n * @param {object} options\n * @param {boolean} options.goToFirstResult\n */\nBookReader.prototype.BRSearchCallback = function(results, options) {\n marshallSearchResults(results, pageNum => this.book.getPageNum(this.book.leafNumToIndex(pageNum)));\n this.searchResults = results || [];\n\n this.updateSearchHilites();\n this.removeProgressPopup();\n if (options.goToFirstResult) {\n this._searchPluginGoToResult(0);\n }\n this.trigger('SearchCallback', { results, options, instance: this });\n};\n\n/**\n * Main search results error handler\n * @callback\n * @param {SearchInsideResults} results\n */\nBookReader.prototype.BRSearchCallbackError = function(results) {\n this._BRSearchCallbackError(results);\n};\n\n/**\n * @private draws search results error\n * @callback\n * @param {SearchInsideResults} results\n * @param {jQuery} $el\n * @param {boolean} fade\n */\nBookReader.prototype._BRSearchCallbackError = function(results) {\n this.searchResults = results;\n const basePayload = {\n term: this.searchTerm,\n instance: this,\n };\n if (results.error) {\n const payload = Object.assign({}, basePayload, { results });\n this.trigger('SearchCallbackError', payload);\n } else if (0 == results.matches.length) {\n if (false === results.indexed) {\n this.trigger('SearchCallbackBookNotIndexed', basePayload);\n return;\n }\n this.trigger('SearchCallbackEmpty', basePayload);\n }\n};\n\n/**\n * updates search on-page highlights controller\n */\nBookReader.prototype.updateSearchHilites = function() {\n /** @type {SearchInsideMatch[]} */\n const matches = this.searchResults?.matches || [];\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n const boxesByIndex = {};\n\n // Clear any existing svg layers\n this.removeSearchHilites();\n\n // Group by pageIndex\n for (const match of matches) {\n for (const box of match.par[0].boxes) {\n const pageIndex = this.book.leafNumToIndex(box.page);\n const pageBoxes = boxesByIndex[pageIndex] || (boxesByIndex[pageIndex] = []);\n pageBoxes.push(box);\n }\n }\n\n // update any already created pages\n for (const [pageIndexString, boxes] of Object.entries(boxesByIndex)) {\n const pageIndex = parseFloat(pageIndexString);\n const page = this.book.getPage(pageIndex);\n const pageContainers = this.getActivePageContainerElementsForIndex(pageIndex);\n for (const container of pageContainers) {\n renderBoxesInPageContainerLayer('searchHiliteLayer', boxes, page, container, boxes.map(b => `match-index-${b.matchIndex}`));\n }\n }\n\n this._searchBoxesByIndex = boxesByIndex;\n};\n\n/**\n * remove search highlights\n */\nBookReader.prototype.removeSearchHilites = function() {\n $(this.getActivePageContainerElements()).find('.searchHiliteLayer').remove();\n};\n\n/**\n * @private\n * Goes to the page specified. If the page is not viewable, tries to load the page\n * FIXME Most of this logic is IA specific, and should be less integrated into here\n * or at least more configurable.\n * @param {number} matchIndex\n */\nBookReader.prototype._searchPluginGoToResult = async function (matchIndex) {\n const match = this.searchResults?.matches[matchIndex];\n const book = this.book;\n const pageIndex = book.leafNumToIndex(match.par[0].page);\n const page = book.getPage(pageIndex);\n const onNearbyPage = Math.abs(this.currentIndex() - pageIndex) < 3;\n let makeUnviewableAtEnd = false;\n if (!page.isViewable) {\n const resp = await fetch('/services/bookreader/request_page?' + new URLSearchParams({\n id: this.options.bookId,\n subprefix: this.options.subPrefix,\n leafNum: page.leafNum,\n })).then(r => r.json());\n\n for (const leafNum of resp.value) {\n book.getPage(book.leafNumToIndex(leafNum)).makeViewable();\n }\n\n // not able to show page; make the page viewable anyways so that it can\n // actually open. On IA, it has a fallback to a special error page.\n if (!resp.value.length) {\n book.getPage(pageIndex).makeViewable();\n makeUnviewableAtEnd = true;\n }\n\n // Trigger an update of book\n this._modes.mode1Up.mode1UpLit.updatePages();\n if (this.activeMode == this._modes.mode1Up) {\n await this._modes.mode1Up.mode1UpLit.updateComplete;\n }\n }\n /* this updates the URL */\n if (!this._isIndexDisplayed(pageIndex)) {\n this.suppressFragmentChange = false;\n this.jumpToIndex(pageIndex);\n }\n\n // Reset it to unviewable if it wasn't resolved\n if (makeUnviewableAtEnd) {\n book.getPage(pageIndex).makeViewable(false);\n }\n\n // Scroll/flash in the ui\n const $boxes = await poll(() => $(`rect.match-index-${match.matchIndex}`), { until: result => result.length > 0 });\n if ($boxes.length) {\n $boxes.css('animation', 'none');\n $boxes[0].scrollIntoView({\n // Only vertically center the highlight if we're in 1up or in full screen. In\n // 2up, if we're not fullscreen, the whole body gets scrolled around to try to\n // center the highlight 🙄 See:\n // https://stackoverflow.com/questions/11039885/scrollintoview-causing-the-whole-page-to-move/11041376\n // Note: nearest doesn't quite work great, because the ReadAloud toolbar is now\n // full-width, and covers up the last line of the highlight.\n block: this.constMode1up == this.mode || this.isFullscreenActive ? 'center' : 'nearest',\n inline: 'center',\n behavior: onNearbyPage ? 'smooth' : 'auto',\n });\n // wait for animation to start\n await new Promise(resolve => setTimeout(resolve, 100));\n $boxes.removeAttr(\"style\");\n }\n};\n\n/**\n * Removes all search pins\n */\nBookReader.prototype.removeSearchResults = function(suppressFragmentChange = false) {\n this.removeSearchHilites(); //be sure to set all box.divs to null\n this.searchTerm = null;\n this.searchResults = null;\n if (!suppressFragmentChange) {\n this.trigger(BookReader.eventNames.fragmentChange);\n }\n};\n\n/**\n * Returns true if a search highlight is currently being displayed\n * @returns {boolean}\n */\nBookReader.prototype.searchHighlightVisible = function() {\n const results = this.searchResults;\n let visiblePages = [];\n if (null == results) return false;\n\n if (this.constMode2up == this.mode) {\n visiblePages = [this.twoPage.currentIndexL, this.twoPage.currentIndexR];\n } else if (this.constMode1up == this.mode) {\n visiblePages = [this.currentIndex()];\n } else {\n return false;\n }\n\n results.matches.some(match => {\n return match.par[0].boxes.some(box => {\n const pageIndex = this.book.leafNumToIndex(box.page);\n if (jQuery.inArray(pageIndex, visiblePages) >= 0) {\n return true;\n }\n });\n });\n\n return false;\n};\n","import { escapeHTML } from \"../../BookReader/utils.js\";\n\nclass SearchView {\n /**\n * @param {object} params\n * @param {object} params.br The BookReader instance\n * @param {function} params.cancelSearch callback when a user wants to cancel search\n *\n * @event BookReader:SearchResultsCleared - when the search results nav gets cleared\n * @event BookReader:ToggleSearchMenu - when search results menu should toggle\n */\n constructor({ br, searchCancelledCallback = () => {} }) {\n this.br = br;\n\n // Search results are returned as a text blob with the hits wrapped in\n // triple mustaches. Hits occasionally include text beyond the search\n // term, so everything within the staches is captured and wrapped.\n this.matcher = new RegExp('{{{([^]+?)}}}', 'g'); // [^] matches any character, including line breaks\n this.matches = [];\n this.cacheDOMElements();\n this.bindEvents();\n this.cancelSearch = searchCancelledCallback;\n }\n\n cacheDOMElements() {\n this.dom = {};\n // Search input within the top toolbar. Will be removed once the mobile menu is replaced.\n this.dom.toolbarSearch = this.buildToolbarSearch();\n }\n\n /**\n * @param {string} query\n */\n setQuery(query) {\n this.br.$('[name=\"query\"]').val(query);\n }\n\n emptyMatches() {\n this.matches = [];\n }\n\n removeResultPins() {\n this.br.$('.BRnavpos .BRsearch').remove();\n }\n\n clearSearchFieldAndResults(dispatchEventWhenComplete = true) {\n this.br.removeSearchResults();\n this.removeResultPins();\n this.emptyMatches();\n this.setQuery('');\n this.teardownSearchNavigation();\n if (dispatchEventWhenComplete) {\n this.br.trigger('SearchResultsCleared');\n }\n }\n\n toggleSidebar() {\n this.br.trigger('ToggleSearchMenu');\n }\n\n renderSearchNavigation() {\n const selector = 'BRsearch-navigation';\n $('.BRnav').before(`\n <div class=\"${selector}\">\n <button class=\"toggle-sidebar\">\n <h4>\n <span class=\"icon icon-search\"></span> Results\n </h4>\n </button>\n <div class=\"pagination\">\n <button class=\"prev\" title=\"Previous result\"><span class=\"icon icon-chevron hflip\"></span></button>\n <span data-id=\"resultsCount\">${this.resultsPosition()}</span>\n <button class=\"next\" title=\"Next result\"><span class=\"icon icon-chevron\"></button>\n </div>\n <button class=\"clear\" title=\"Clear search results\">\n <span class=\"icon icon-close\"></span>\n </button>\n </div>\n `);\n this.dom.searchNavigation = $(`.${selector}`);\n }\n\n resultsPosition() {\n let positionMessage = `${this.matches.length} result${this.matches.length === 1 ? '' : 's'}`;\n if (~this.currentMatchIndex) {\n positionMessage = `${this.currentMatchIndex + 1} / ${this.matches.length}`;\n }\n return positionMessage;\n }\n\n bindSearchNavigationEvents() {\n if (!this.dom.searchNavigation) { return; }\n const namespace = 'searchNavigation';\n\n this.dom.searchNavigation\n .on(`click.${namespace}`, '.clear', this.clearSearchFieldAndResults.bind(this))\n .on(`click.${namespace}`, '.prev', this.showPrevResult.bind(this))\n .on(`click.${namespace}`, '.next', this.showNextResult.bind(this))\n .on(`click.${namespace}`, '.toggle-sidebar', this.toggleSidebar.bind(this))\n .on(`click.${namespace}`, false);\n }\n\n showPrevResult() {\n if (this.currentMatchIndex === 0) { return; }\n if (this.br.mode === this.br.constModeThumb) { this.br.switchMode(this.br.constMode1up); }\n if (!~this.currentMatchIndex) {\n this.currentMatchIndex = this.getClosestMatchIndex((start, end, comparator) => end[0] > comparator) + 1;\n }\n this.br.$('.BRnavline .BRsearch').eq(--this.currentMatchIndex).click();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n showNextResult() {\n if (this.currentMatchIndex + 1 === this.matches.length) { return; }\n if (this.br.mode === this.br.constModeThumb) { this.br.switchMode(this.br.constMode1up); }\n if (!~this.currentMatchIndex) {\n this.currentMatchIndex = this.getClosestMatchIndex((start, end, comparator) => start[start.length - 1] > comparator) - 1;\n }\n this.br.$('.BRnavline .BRsearch').eq(++this.currentMatchIndex).click();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n /**\n * Obtains closest match based on the logical comparison function passed in.\n * When the comparison function returns true, the starting (left) half of the\n * matches array is used in the binary split, else the ending (right) half is\n * used. A recursive call is made to perform the same split and comparison\n * on the winning half of the matches. This is traditionally known as binary\n * search (https://en.wikipedia.org/wiki/Binary_search_algorithm), and in\n * most cases (medium to large search result arrays) should outperform\n * traversing the array from start to finish. In the case of small arrays,\n * the speed difference is negligible.\n *\n * @param {function} comparisonFn\n * @return {number} matchIndex\n */\n getClosestMatchIndex(comparisonFn) {\n const matchPages = this.matches.map((m) => m.par[0].page);\n const currentPage = this.br.currentIndex() + 1;\n const closestTo = (pool, comparator) => {\n if (pool.length === 1) { return pool[0]; }\n const start = pool.slice(0, pool.length / 2);\n const end = pool.slice(pool.length / 2);\n return closestTo((comparisonFn(start, end, comparator) ? start : end), comparator);\n };\n\n const closestPage = closestTo(matchPages, currentPage);\n return this.matches.indexOf(this.matches.find((m) => m.par[0].page === closestPage));\n }\n\n updateResultsPosition() {\n if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('[data-id=resultsCount]').text(this.resultsPosition());\n }\n\n updateSearchNavigationButtons() {\n if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('.prev').attr('disabled', !this.currentMatchIndex);\n this.dom.searchNavigation.find('.next').attr('disabled', this.currentMatchIndex + 1 === this.matches.length);\n }\n\n teardownSearchNavigation() {\n if (!this.dom.searchNavigation) {\n this.dom.searchNavigation = $('.BRsearch-navigation');\n }\n if (!this.dom.searchNavigation.length) { return; }\n\n this.dom.searchNavigation.off('.searchNavigation').remove();\n this.dom.searchNavigation = null;\n this.br.resize();\n }\n\n setCurrentMatchIndex() {\n let matchingSearchResult;\n if (this.br.mode === this.br.constModeThumb) {\n this.currentMatchIndex = -1;\n return;\n }\n if (this.br.mode === this.br.constMode2up) {\n matchingSearchResult = this.find2upMatchingSearchResult();\n }\n else {\n matchingSearchResult = this.find1upMatchingSearchResult();\n }\n this.currentMatchIndex = this.matches.indexOf(matchingSearchResult);\n }\n\n find1upMatchingSearchResult() {\n return this.matches.find((m) => this.br.currentIndex() === m.par[0].page - 1);\n }\n\n find2upMatchingSearchResult() {\n return this.matches.find((m) => this.br._isIndexDisplayed(m.par[0].page - 1));\n }\n\n updateSearchNavigation() {\n if (!this.matches.length) { return; }\n\n this.setCurrentMatchIndex();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n /**\n * @param {boolean} bool\n */\n togglePinsFor(bool) {\n const pinsVisibleState = bool ? 'visible' : 'hidden';\n this.br.refs.$BRfooter.find('.BRsearch').css({ visibility: pinsVisibleState });\n }\n\n buildToolbarSearch() {\n const toolbarSearch = document.createElement('span');\n toolbarSearch.classList.add('BRtoolbarSection', 'BRtoolbarSectionSearch');\n toolbarSearch.innerHTML = `\n <form class=\"BRbooksearch desktop\">\n <input type=\"search\" name=\"query\" class=\"BRsearchInput\" value=\"\" placeholder=\"Search inside\"/>\n <button type=\"submit\" class=\"BRsearchSubmit\">\n <img src=\"${this.br.imagesBaseURL}icon_search_button.svg\" />\n </button>\n </form>\n `;\n return toolbarSearch;\n }\n\n /**\n * @param {array} matches\n */\n renderPins(matches) {\n matches.forEach((match) => {\n const queryString = match.text;\n const pageIndex = this.br.book.leafNumToIndex(match.par[0].page);\n const uiStringSearch = \"Search result\"; // i18n\n\n const percentThrough = this.br.constructor.util.cssPercentage(pageIndex, this.br.book.getNumLeafs() - 1);\n\n const escapedQueryString = escapeHTML(queryString);\n const queryStringWithB = escapedQueryString.replace(this.matcher, '<b>$1</b>');\n\n let queryStringWithBTruncated = '';\n\n if (queryString.length > 100) {\n queryStringWithBTruncated = queryString.replace(/^(.{100}[^\\s]*).*/, \"$1\");\n\n // If truncating, we must escape *after* truncation occurs (but before wrapping in <b>)\n queryStringWithBTruncated = escapeHTML(queryStringWithBTruncated)\n .replace(this.matcher, '<b>$1</b>')\n + '...';\n }\n\n // draw marker\n $('<div>')\n .addClass('BRsearch')\n .css({\n left: percentThrough,\n })\n .attr('title', uiStringSearch)\n .append(`\n <div class=\"BRquery\">\n <div>${queryStringWithBTruncated || queryStringWithB}</div>\n <div>Page ${match.displayPageNumber}</div>\n </div>\n `)\n .appendTo(this.br.$('.BRnavline'))\n .on(\"mouseenter\", (event) => {\n // remove from other markers then turn on just for this\n // XXX should be done when nav slider moves\n const marker = event.currentTarget;\n const tooltip = marker.querySelector('.BRquery');\n const tooltipOffset = tooltip.getBoundingClientRect();\n const targetOffset = marker.getBoundingClientRect();\n const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;\n if (tooltipOffset.x - boxSizeAdjust < 0) {\n tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);\n }\n $('.BRsearch,.BRchapter').removeClass('front');\n $(event.target).addClass('front');\n })\n .on(\"mouseleave\", (event) => $(event.target).removeClass('front'))\n .on(\"click\", () => { this.br._searchPluginGoToResult(match.matchIndex); });\n });\n }\n\n /**\n * @param {boolean} bool\n */\n toggleSearchPending(bool) {\n if (bool) {\n this.br.showProgressPopup(\"Search results will appear below...\", () => this.progressPopupClosed());\n }\n else {\n this.br.removeProgressPopup();\n }\n }\n\n /**\n * Primary callback when user cancels search popup\n */\n progressPopupClosed() {\n this.toggleSearchPending();\n this.cancelSearch();\n }\n\n renderErrorModal(textIsProcessing = false) {\n const errorDetails = `${!textIsProcessing ? 'The text may still be processing. ' : ''}Please try again.`;\n this.renderModalMessage(`\n Sorry, there was an error with your search.\n <br />\n ${errorDetails}\n `);\n this.delayModalRemovalFor(4000);\n }\n\n renderBookNotIndexedModal() {\n this.renderModalMessage(`\n <p>\n This book hasn't been indexed for searching yet.\n We've just started indexing it, so search should be available soon.\n <br />\n Please try again later. Thanks!\n </p>\n `);\n this.delayModalRemovalFor(5000);\n }\n\n renderResultsEmptyModal() {\n this.renderModalMessage('No matches were found.');\n this.delayModalRemovalFor(2000);\n }\n\n /**\n * @param {string} messageHTML The innerHTML string used to popupate the modal contents\n */\n renderModalMessage(messageHTML) {\n const modal = document.createElement('div');\n modal.classList.add('BRprogresspopup', 'search_modal');\n modal.innerHTML = messageHTML;\n document.querySelector(this.br.el).append(modal);\n }\n\n /**\n * @param {number} timeoutMS\n */\n delayModalRemovalFor(timeoutMS) {\n setTimeout(this.br.removeProgressPopup.bind(this.br), timeoutMS);\n }\n\n /**\n * @param {Event} e\n */\n submitHandler(e) {\n e.preventDefault();\n const query = e.target.querySelector('[name=\"query\"]').value;\n if (!query.length) { return false; }\n this.br.search(query);\n this.emptyMatches();\n this.toggleSearchPending(true);\n return false;\n }\n\n /**\n * @param {Event} e\n * @param {object} properties\n * @param {object} properties.results\n * @param {object} properties.options\n */\n handleSearchCallback(e, { results, options }) {\n this.matches = results.matches;\n this.setCurrentMatchIndex();\n this.teardownSearchNavigation();\n this.renderSearchNavigation();\n this.bindSearchNavigationEvents();\n this.renderPins(results.matches);\n this.toggleSearchPending(false);\n if (options.goToFirstResult) {\n $(document).one('BookReader:pageChanged', () => {\n this.br.resize();\n });\n } else {\n this.br.resize();\n }\n }\n\n handleSearchStarted() {\n this.emptyMatches();\n this.br.removeSearchHilites();\n this.removeResultPins();\n this.toggleSearchPending(true);\n this.teardownSearchNavigation();\n this.setQuery(this.br.searchTerm);\n }\n\n /**\n * Event listener for: `BookReader:SearchCallbackError`\n * @param {CustomEvent} event\n */\n handleSearchCallbackError(event = {}) {\n this.toggleSearchPending(false);\n const isIndexed = event?.detail?.props?.results?.indexed;\n this.renderErrorModal(isIndexed);\n }\n\n handleSearchCallbackBookNotIndexed() {\n this.toggleSearchPending(false);\n this.renderBookNotIndexedModal();\n }\n\n handleSearchCallbackEmpty() {\n this.toggleSearchPending(false);\n this.renderResultsEmptyModal();\n }\n\n bindEvents() {\n const namespace = 'BookReader:';\n\n window.addEventListener(`${namespace}SearchCallbackError`, this.handleSearchCallbackError.bind(this));\n $(document).on(`${namespace}SearchCallback`, this.handleSearchCallback.bind(this))\n .on(`${namespace}SearchStarted`, this.handleSearchStarted.bind(this))\n .on(`${namespace}SearchCallbackBookNotIndexed`, this.handleSearchCallbackBookNotIndexed.bind(this))\n .on(`${namespace}SearchCallbackEmpty`, this.handleSearchCallbackEmpty.bind(this))\n .on(`${namespace}pageChanged`, this.updateSearchNavigation.bind(this));\n\n this.dom.toolbarSearch.querySelector('form').addEventListener('submit', this.submitHandler.bind(this));\n }\n}\n\nexport default SearchView;\n","var global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar toString = require('../internals/to-string');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar charAt = uncurryThis(''.charAt);\nvar n$ParseFloat = global.parseFloat;\nvar Symbol = global.Symbol;\nvar ITERATOR = Symbol && Symbol.iterator;\nvar FORCED = 1 / n$ParseFloat(whitespaces + '-0') !== -Infinity\n // MS Edge 18- broken with boxed symbols\n || (ITERATOR && !fails(function () { n$ParseFloat(Object(ITERATOR)); }));\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(toString(string));\n var result = n$ParseFloat(trimmedString);\n return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;\n} : n$ParseFloat;\n","var $ = require('../internals/export');\nvar $entries = require('../internals/object-to-array').entries;\n\n// `Object.entries` method\n// https://tc39.es/ecma262/#sec-object.entries\n$({ target: 'Object', stat: true }, {\n entries: function entries(O) {\n return $entries(O);\n }\n});\n","var $ = require('../internals/export');\nvar $parseFloat = require('../internals/number-parse-float');\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\n$({ global: true, forced: parseFloat != $parseFloat }, {\n parseFloat: $parseFloat\n});\n"],"names":["super_","SearchView","br","searchCancelledCallback","this","matcher","RegExp","matches","cacheDOMElements","bindEvents","cancelSearch","dom","toolbarSearch","buildToolbarSearch","query","$","val","remove","dispatchEventWhenComplete","removeSearchResults","removeResultPins","emptyMatches","setQuery","teardownSearchNavigation","trigger","selector","before","resultsPosition","searchNavigation","positionMessage","length","currentMatchIndex","namespace","on","clearSearchFieldAndResults","bind","showPrevResult","showNextResult","toggleSidebar","mode","constModeThumb","switchMode","constMode1up","getClosestMatchIndex","start","end","comparator","eq","click","updateResultsPosition","updateSearchNavigationButtons","comparisonFn","closestPage","closestTo","pool","slice","map","m","par","page","currentIndex","indexOf","find","text","attr","off","resize","matchingSearchResult","constMode2up","find2upMatchingSearchResult","find1upMatchingSearchResult","_isIndexDisplayed","setCurrentMatchIndex","bool","pinsVisibleState","refs","$BRfooter","css","visibility","document","createElement","classList","add","innerHTML","imagesBaseURL","forEach","match","queryString","pageIndex","book","leafNumToIndex","percentThrough","constructor","util","cssPercentage","getNumLeafs","queryStringWithB","escapeHTML","replace","queryStringWithBTruncated","addClass","left","append","displayPageNumber","appendTo","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","x","style","setProperty","removeClass","target","_searchPluginGoToResult","matchIndex","showProgressPopup","progressPopupClosed","removeProgressPopup","toggleSearchPending","textIsProcessing","errorDetails","renderModalMessage","delayModalRemovalFor","messageHTML","modal","el","timeoutMS","setTimeout","e","preventDefault","value","search","results","options","renderSearchNavigation","bindSearchNavigationEvents","renderPins","goToFirstResult","one","removeSearchHilites","searchTerm","isIndexed","detail","props","indexed","renderErrorModal","renderBookNotIndexedModal","renderResultsEmptyModal","window","addEventListener","handleSearchCallbackError","handleSearchCallback","handleSearchStarted","handleSearchCallbackBookNotIndexed","handleSearchCallbackEmpty","updateSearchNavigation","submitHandler","jQuery","extend","BookReader","defaultOptions","server","bookId","subPrefix","bookPath","enableSearch","searchInsideUrl","initialSearchTerm","prototype","setup","call","searchResults","searchXHR","_cancelSearch","cancelSearchRequest","_searchBoxesByIndex","searchView","undefined","init","term","instance","suppressFragmentChange","buildToolbarElement","$el","after","_createPageContainer","index","pageContainer","boxes","renderBoxesInPageContainerLayer","$container","b","overrides","disablePopup","error","success","searchCancelled","eventNames","fragmentChange","serverPath","baseUrl","path","subPrefixWithSlash","lastIndexOf","substr","urlParams","item_id","doc","q","paramStr","param","url","callSearchResultsCallback","searchInsideResults","responseHasError","hasCustomError","hasCustomSuccess","console","BRSearchCallbackError","BRSearchCallback","ajax","dataType","cache","beforeSend","xhr","abort","displayPageNumberFn","pageNum","entries","getPageNum","marshallSearchResults","updateSearchHilites","_BRSearchCallbackError","basePayload","payload","Object","assign","boxesByIndex","box","push","pageIndexString","parseFloat","getPage","getActivePageContainerElementsForIndex","container","getActivePageContainerElements","onNearbyPage","Math","abs","makeUnviewableAtEnd","isViewable","fetch","URLSearchParams","id","subprefix","leafNum","then","r","json","resp","makeViewable","_modes","mode1Up","mode1UpLit","updatePages","activeMode","updateComplete","jumpToIndex","poll","until","result","$boxes","scrollIntoView","block","isFullscreenActive","inline","behavior","Promise","resolve","removeAttr","searchHighlightVisible","visiblePages","twoPage","currentIndexL","currentIndexR","some","inArray","global","fails","uncurryThis","toString","trim","whitespaces","charAt","n$ParseFloat","Symbol","ITERATOR","iterator","FORCED","module","exports","string","trimmedString","$entries","stat","O","$parseFloat","forced"],"sourceRoot":""}
1
+ {"version":3,"file":"plugins/plugin.search.js","mappings":";gmCAAMA,EAAU,WASd,SAAAA,EAAAC,GAAwD,IAA1CC,EAAED,EAAFC,GAAEC,EAAAF,EAAEG,wBAAAA,OAAuB,IAAAD,EAAG,WAAO,EAACA,+FAAAE,CAAA,KAAAL,GAClDM,KAAKJ,GAAKA,EACVI,KAAKC,QAAU,GACfD,KAAKE,mBACLF,KAAKG,aACLH,KAAKI,aAAeN,CACtB,SA6YC,SA7YAJ,IAAA,EAAAW,IAAA,mBAAAC,MAED,WACEN,KAAKO,IAAM,CAAC,EAEZP,KAAKO,IAAIC,cAAgBR,KAAKS,oBAChC,GAEA,CAAAJ,IAAA,WAAAC,MAGA,SAASI,GACPV,KAAKJ,GAAGe,EAAE,kBAAkBC,IAAIF,EAClC,GAAC,CAAAL,IAAA,eAAAC,MAED,WACEN,KAAKC,QAAU,EACjB,GAAC,CAAAI,IAAA,mBAAAC,MAED,WACEN,KAAKJ,GAAGe,EAAE,uBAAuBE,QACnC,GAAC,CAAAR,IAAA,6BAAAC,MAED,WAA6D,IAAlCQ,IAAyBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GAClDf,KAAKJ,GAAGsB,sBACRlB,KAAKmB,mBACLnB,KAAKoB,eACLpB,KAAKqB,SAAS,IACdrB,KAAKsB,2BACDR,GACFd,KAAKJ,GAAG2B,QAAQ,uBAEpB,GAAC,CAAAlB,IAAA,gBAAAC,MAED,WACEN,KAAKJ,GAAG2B,QAAQ,mBAClB,GAAC,CAAAlB,IAAA,yBAAAC,MAED,WACE,IAAMkB,EAAW,sBACjBb,EAAE,UAAUc,OAAO,uBAADC,OAC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Aetd,KAAKqd,QAAQE,mBACpD,IAAIvd,KAAKyC,cAAgBzC,KAAKsC,KAGnC,OAAO,EAFP8a,EAAe,CAACpd,KAAK2D,eAGvB,CAWA,OATAqF,EAAQ/I,QAAQud,MAAK,SAAAhY,GACnB,OAAOA,EAAM/B,IAAI,GAAGyS,MAAMsH,MAAK,SAAAlD,GAC7B,IAAM7U,EAAYqC,EAAKpC,KAAKC,eAAe2U,EAAI5W,MAC/C,GAAIyQ,EAAOsJ,QAAQhY,EAAW2X,IAAiB,EAC7C,OAAO,CAEX,GACF,KAEO,CACT,wBCxeA,IAAIM,EAAS,EAAQ,MACjBC,EAAQ,EAAQ,MAChBC,EAAc,EAAQ,MACtBC,EAAW,EAAQ,MACnBC,EAAO,aACPC,EAAc,EAAQ,MAEtBnL,EAASgL,EAAY,GAAGhL,QACxBoL,EAAcN,EAAO/C,WACrB1O,EAASyR,EAAOzR,OAChBgS,EAAWhS,GAAUA,EAAOE,SAC5B+R,EAAS,EAAIF,EAAYD,EAAc,QAAU,KAE/CE,IAAaN,GAAM,WAAcK,EAAYvS,OAAOwS,GAAY,IAItEE,EAAO5S,QAAU2S,EAAS,SAAoBE,GAC5C,IAAIC,EAAgBP,EAAKD,EAASO,IAC9BpP,EAASgP,EAAYK,GACzB,OAAkB,IAAXrP,GAA4C,KAA5B4D,EAAOyL,EAAe,IAAa,EAAIrP,CAChE,EAAIgP,wBCrBJ,IAAIrd,EAAI,EAAQ,MACZ2d,EAAW,gBAIf3d,EAAE,CAAEgH,OAAQ,SAAU4W,MAAM,GAAQ,CAClCnF,QAAS,SAAiBoF,GACxB,OAAOF,EAASE,EAClB,0BCRF,IAAI7d,EAAI,EAAQ,MACZqd,EAAc,EAAQ,MAI1Brd,EAAE,CAAE+c,QAAQ,EAAMe,OAAQ9D,YAAcqD,GAAe,CACrDrD,WAAYqD","sources":["webpack://@internetarchive/bookreader/./src/plugins/search/view.js","webpack://@internetarchive/bookreader/./src/plugins/search/utils.js","webpack://@internetarchive/bookreader/./src/plugins/search/plugin.search.js","webpack://@internetarchive/bookreader/./node_modules/core-js/internals/number-parse-float.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.object.entries.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.parse-float.js"],"sourcesContent":["class SearchView {\n /**\n * @param {object} params\n * @param {object} params.br The BookReader instance\n * @param {function} params.cancelSearch callback when a user wants to cancel search\n *\n * @event BookReader:SearchResultsCleared - when the search results nav gets cleared\n * @event BookReader:ToggleSearchMenu - when search results menu should toggle\n */\n constructor({ br, searchCancelledCallback = () => {} }) {\n this.br = br;\n this.matches = [];\n this.cacheDOMElements();\n this.bindEvents();\n this.cancelSearch = searchCancelledCallback;\n }\n\n cacheDOMElements() {\n this.dom = {};\n // Search input within the top toolbar. Will be removed once the mobile menu is replaced.\n this.dom.toolbarSearch = this.buildToolbarSearch();\n }\n\n /**\n * @param {string} query\n */\n setQuery(query) {\n this.br.$('[name=\"query\"]').val(query);\n }\n\n emptyMatches() {\n this.matches = [];\n }\n\n removeResultPins() {\n this.br.$('.BRnavpos .BRsearch').remove();\n }\n\n clearSearchFieldAndResults(dispatchEventWhenComplete = true) {\n this.br.removeSearchResults();\n this.removeResultPins();\n this.emptyMatches();\n this.setQuery('');\n this.teardownSearchNavigation();\n if (dispatchEventWhenComplete) {\n this.br.trigger('SearchResultsCleared');\n }\n }\n\n toggleSidebar() {\n this.br.trigger('ToggleSearchMenu');\n }\n\n renderSearchNavigation() {\n const selector = 'BRsearch-navigation';\n $('.BRnav').before(`\n <div class=\"${selector}\">\n <button class=\"toggle-sidebar\">\n <h4>\n <span class=\"icon icon-search\"></span> Results\n </h4>\n </button>\n <div class=\"pagination\">\n <button class=\"prev\" title=\"Previous result\"><span class=\"icon icon-chevron hflip\"></span></button>\n <span data-id=\"resultsCount\">${this.resultsPosition()}</span>\n <button class=\"next\" title=\"Next result\"><span class=\"icon icon-chevron\"></button>\n </div>\n <button class=\"clear\" title=\"Clear search results\">\n <span class=\"icon icon-close\"></span>\n </button>\n </div>\n `);\n this.dom.searchNavigation = $(`.${selector}`);\n }\n\n resultsPosition() {\n let positionMessage = `${this.matches.length} result${this.matches.length === 1 ? '' : 's'}`;\n if (~this.currentMatchIndex) {\n positionMessage = `${this.currentMatchIndex + 1} / ${this.matches.length}`;\n }\n return positionMessage;\n }\n\n bindSearchNavigationEvents() {\n if (!this.dom.searchNavigation) { return; }\n const namespace = 'searchNavigation';\n\n this.dom.searchNavigation\n .on(`click.${namespace}`, '.clear', this.clearSearchFieldAndResults.bind(this))\n .on(`click.${namespace}`, '.prev', this.showPrevResult.bind(this))\n .on(`click.${namespace}`, '.next', this.showNextResult.bind(this))\n .on(`click.${namespace}`, '.toggle-sidebar', this.toggleSidebar.bind(this))\n .on(`click.${namespace}`, false);\n }\n\n showPrevResult() {\n if (this.currentMatchIndex === 0) { return; }\n if (this.br.mode === this.br.constModeThumb) { this.br.switchMode(this.br.constMode1up); }\n if (!~this.currentMatchIndex) {\n this.currentMatchIndex = this.getClosestMatchIndex((start, end, comparator) => end[0] > comparator) + 1;\n }\n this.br.$('.BRnavline .BRsearch').eq(--this.currentMatchIndex).click();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n showNextResult() {\n if (this.currentMatchIndex + 1 === this.matches.length) { return; }\n if (this.br.mode === this.br.constModeThumb) { this.br.switchMode(this.br.constMode1up); }\n if (!~this.currentMatchIndex) {\n this.currentMatchIndex = this.getClosestMatchIndex((start, end, comparator) => start[start.length - 1] > comparator) - 1;\n }\n this.br.$('.BRnavline .BRsearch').eq(++this.currentMatchIndex).click();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n /**\n * Obtains closest match based on the logical comparison function passed in.\n * When the comparison function returns true, the starting (left) half of the\n * matches array is used in the binary split, else the ending (right) half is\n * used. A recursive call is made to perform the same split and comparison\n * on the winning half of the matches. This is traditionally known as binary\n * search (https://en.wikipedia.org/wiki/Binary_search_algorithm), and in\n * most cases (medium to large search result arrays) should outperform\n * traversing the array from start to finish. In the case of small arrays,\n * the speed difference is negligible.\n *\n * @param {function} comparisonFn\n * @return {number} matchIndex\n */\n getClosestMatchIndex(comparisonFn) {\n const matchPages = this.matches.map((m) => m.par[0].page);\n const currentPage = this.br.currentIndex() + 1;\n const closestTo = (pool, comparator) => {\n if (pool.length === 1) { return pool[0]; }\n const start = pool.slice(0, pool.length / 2);\n const end = pool.slice(pool.length / 2);\n return closestTo((comparisonFn(start, end, comparator) ? start : end), comparator);\n };\n\n const closestPage = closestTo(matchPages, currentPage);\n return this.matches.indexOf(this.matches.find((m) => m.par[0].page === closestPage));\n }\n\n updateResultsPosition() {\n if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('[data-id=resultsCount]').text(this.resultsPosition());\n }\n\n updateSearchNavigationButtons() {\n if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('.prev').attr('disabled', !this.currentMatchIndex);\n this.dom.searchNavigation.find('.next').attr('disabled', this.currentMatchIndex + 1 === this.matches.length);\n }\n\n teardownSearchNavigation() {\n if (!this.dom.searchNavigation) {\n this.dom.searchNavigation = $('.BRsearch-navigation');\n }\n if (!this.dom.searchNavigation.length) { return; }\n\n this.dom.searchNavigation.off('.searchNavigation').remove();\n this.dom.searchNavigation = null;\n this.br.resize();\n }\n\n setCurrentMatchIndex() {\n let matchingSearchResult;\n if (this.br.mode === this.br.constModeThumb) {\n this.currentMatchIndex = -1;\n return;\n }\n if (this.br.mode === this.br.constMode2up) {\n matchingSearchResult = this.find2upMatchingSearchResult();\n }\n else {\n matchingSearchResult = this.find1upMatchingSearchResult();\n }\n this.currentMatchIndex = this.matches.indexOf(matchingSearchResult);\n }\n\n find1upMatchingSearchResult() {\n return this.matches.find((m) => this.br.currentIndex() === m.par[0].page - 1);\n }\n\n find2upMatchingSearchResult() {\n return this.matches.find((m) => this.br._isIndexDisplayed(m.par[0].page - 1));\n }\n\n updateSearchNavigation() {\n if (!this.matches.length) { return; }\n\n this.setCurrentMatchIndex();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n /**\n * @param {boolean} bool\n */\n togglePinsFor(bool) {\n const pinsVisibleState = bool ? 'visible' : 'hidden';\n this.br.refs.$BRfooter.find('.BRsearch').css({ visibility: pinsVisibleState });\n }\n\n buildToolbarSearch() {\n const toolbarSearch = document.createElement('span');\n toolbarSearch.classList.add('BRtoolbarSection', 'BRtoolbarSectionSearch');\n toolbarSearch.innerHTML = `\n <form class=\"BRbooksearch desktop\">\n <input type=\"search\" name=\"query\" class=\"BRsearchInput\" value=\"\" placeholder=\"Search inside\"/>\n <button type=\"submit\" class=\"BRsearchSubmit\">\n <img src=\"${this.br.imagesBaseURL}icon_search_button.svg\" />\n </button>\n </form>\n `;\n return toolbarSearch;\n }\n\n /**\n * @param {array} matches\n */\n renderPins(matches) {\n matches.forEach((match) => {\n const pageIndex = this.br.book.leafNumToIndex(match.par[0].page);\n const uiStringSearch = \"Search result\"; // i18n\n const percentThrough = this.br.constructor.util.cssPercentage(pageIndex, this.br.book.getNumLeafs() - 1);\n\n let html = match.html;\n if (html.length > 200) {\n const start = Math.max(0, html.indexOf('<mark>') - 100);\n if (start != 0) {\n html = '…' + match.html\n .substring(start)\n // Make sure at word boundary though\n .replace(/^\\S+/, '');\n }\n }\n // draw marker\n $('<div>')\n .addClass('BRsearch')\n .css({\n left: percentThrough,\n })\n .attr('title', uiStringSearch)\n .append(`\n <div class=\"BRquery\">\n <main>${html}</main>\n <footer>Page ${match.displayPageNumber}</footer>\n </div>\n `)\n .appendTo(this.br.$('.BRnavline'))\n .on(\"mouseenter\", (event) => {\n // remove from other markers then turn on just for this\n // XXX should be done when nav slider moves\n const marker = event.currentTarget;\n const tooltip = marker.querySelector('.BRquery');\n const tooltipOffset = tooltip.getBoundingClientRect();\n const targetOffset = marker.getBoundingClientRect();\n const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;\n if (tooltipOffset.x - boxSizeAdjust < 0) {\n tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);\n }\n $('.BRsearch,.BRchapter').removeClass('front');\n $(event.target).addClass('front');\n })\n .on(\"mouseleave\", (event) => $(event.target).removeClass('front'))\n .on(\"click\", () => { this.br._searchPluginGoToResult(match.matchIndex); });\n });\n }\n\n /**\n * @param {boolean} bool\n */\n toggleSearchPending(bool) {\n if (bool) {\n this.br.showProgressPopup(\"Search results will appear below...\", () => this.progressPopupClosed());\n }\n else {\n this.br.removeProgressPopup();\n }\n }\n\n /**\n * Primary callback when user cancels search popup\n */\n progressPopupClosed() {\n this.toggleSearchPending();\n this.cancelSearch();\n }\n\n renderErrorModal(textIsProcessing = false) {\n const errorDetails = `${!textIsProcessing ? 'The text may still be processing. ' : ''}Please try again.`;\n this.renderModalMessage(`\n Sorry, there was an error with your search.\n <br />\n ${errorDetails}\n `);\n this.delayModalRemovalFor(4000);\n }\n\n renderBookNotIndexedModal() {\n this.renderModalMessage(`\n <p>\n This book hasn't been indexed for searching yet.\n We've just started indexing it, so search should be available soon.\n <br />\n Please try again later. Thanks!\n </p>\n `);\n this.delayModalRemovalFor(5000);\n }\n\n renderResultsEmptyModal() {\n this.renderModalMessage('No matches were found.');\n this.delayModalRemovalFor(2000);\n }\n\n /**\n * @param {string} messageHTML The innerHTML string used to popupate the modal contents\n */\n renderModalMessage(messageHTML) {\n const modal = document.createElement('div');\n modal.classList.add('BRprogresspopup', 'search_modal');\n modal.innerHTML = messageHTML;\n document.querySelector(this.br.el).append(modal);\n }\n\n /**\n * @param {number} timeoutMS\n */\n delayModalRemovalFor(timeoutMS) {\n setTimeout(this.br.removeProgressPopup.bind(this.br), timeoutMS);\n }\n\n /**\n * @param {Event} e\n */\n submitHandler(e) {\n e.preventDefault();\n const query = e.target.querySelector('[name=\"query\"]').value;\n if (!query.length) { return false; }\n this.br.search(query);\n this.emptyMatches();\n this.toggleSearchPending(true);\n return false;\n }\n\n /**\n * @param {Event} e\n * @param {object} properties\n * @param {object} properties.results\n * @param {object} properties.options\n */\n handleSearchCallback(e, { results, options }) {\n this.matches = results.matches;\n this.setCurrentMatchIndex();\n this.teardownSearchNavigation();\n this.renderSearchNavigation();\n this.bindSearchNavigationEvents();\n this.renderPins(results.matches);\n this.toggleSearchPending(false);\n if (options.goToFirstResult) {\n $(document).one('BookReader:pageChanged', () => {\n this.br.resize();\n });\n } else {\n this.br.resize();\n }\n }\n\n handleSearchStarted() {\n this.emptyMatches();\n this.br.removeSearchHilites();\n this.removeResultPins();\n this.toggleSearchPending(true);\n this.teardownSearchNavigation();\n this.setQuery(this.br.searchTerm);\n }\n\n /**\n * Event listener for: `BookReader:SearchCallbackError`\n * @param {CustomEvent} event\n */\n handleSearchCallbackError(event = {}) {\n this.toggleSearchPending(false);\n const isIndexed = event?.detail?.props?.results?.indexed;\n this.renderErrorModal(isIndexed);\n }\n\n handleSearchCallbackBookNotIndexed() {\n this.toggleSearchPending(false);\n this.renderBookNotIndexedModal();\n }\n\n handleSearchCallbackEmpty() {\n this.toggleSearchPending(false);\n this.renderResultsEmptyModal();\n }\n\n bindEvents() {\n const namespace = 'BookReader:';\n\n window.addEventListener(`${namespace}SearchCallbackError`, this.handleSearchCallbackError.bind(this));\n $(document).on(`${namespace}SearchCallback`, this.handleSearchCallback.bind(this))\n .on(`${namespace}SearchStarted`, this.handleSearchStarted.bind(this))\n .on(`${namespace}SearchCallbackBookNotIndexed`, this.handleSearchCallbackBookNotIndexed.bind(this))\n .on(`${namespace}SearchCallbackEmpty`, this.handleSearchCallbackEmpty.bind(this))\n .on(`${namespace}pageChanged`, this.updateSearchNavigation.bind(this));\n\n this.dom.toolbarSearch.querySelector('form').addEventListener('submit', this.submitHandler.bind(this));\n }\n}\n\nexport default SearchView;\n","import { escapeHTML, escapeRegExp } from '../../BookReader/utils.js';\n\n/**\n * @param {string} match\n * @param {string} preTag\n * @param {string} postTag\n * @returns {string}\n */\nexport function renderMatch(match, preTag, postTag) {\n // Search results are returned as a text blob with the hits wrapped in\n // triple mustaches. Hits occasionally include text beyond the search\n // term, so everything within the staches is captured and wrapped.\n const preTagRe = escapeRegExp(escapeHTML(preTag));\n const postTagRe = escapeRegExp(escapeHTML(postTag));\n // [^] matches any character, including line breaks\n const regex = new RegExp(`${preTagRe}([^]+?)${postTagRe}`, 'g');\n return escapeHTML(match)\n .replace(regex, '<mark>$1</mark>')\n // Fix trailing hyphens. This over-corrects but is net useful.\n .replace(/(\\b)- /g, '$1');\n}\n\n/**\n * Attach some fields to search inside results\n * @param {SearchInsideResults} results\n * @param {(pageNum: LeafNum) => PageNumString} displayPageNumberFn\n * @param {string} preTag\n * @param {string} postTag\n */\nexport function marshallSearchResults(results, displayPageNumberFn, preTag, postTag) {\n // Attach matchIndex to a few things to make it easier to identify\n // an active/selected match\n for (const [index, match] of results.matches.entries()) {\n match.matchIndex = index;\n match.displayPageNumber = displayPageNumberFn(match.par[0].page);\n match.html = renderMatch(match.text, preTag, postTag);\n for (const par of match.par) {\n for (const box of par.boxes) {\n box.matchIndex = index;\n }\n }\n }\n}\n","// @ts-check\n/* global BookReader */\n/**\n * Plugin for Archive.org book search\n * NOTE: This script must be loaded AFTER `plugin.mobile_nav.js`\n * as it mutates mobile nav drawer\n *\n * Events fired at various points throughout search processing are published\n * on the document DOM element. These can be subscribed to using jQuery's event\n * binding method `$.fn.on`. All of the events are prefixed with a BookReader\n * namespace. The events are:\n *\n * @event BookReader:SearchStarted - When a search form is submitted, immediately\n * before an AJAX call is made to request search results\n * @event BookReader:SearchCallback - When the search AJAX call is returned and at\n * least one result is returned. The event callback receives an object\n * with the `results`, plugin `options`, and the BookReader `instance`\n * @event BookReader:SearchCallbackError - When the AJAX request returns an error.\n * Receives the `results` and `instance`\n * @event BookReader:SearchCallbackNotIndexed - When a message is received that\n * the book has not had OCR text indexed yet. Receives `instance`\n * @event BookReader:SearchCallbackEmpty - When no results found. Receives\n * `instance`\n * @event BookReader:SearchCanceled - When no results found. Receives\n * `instance`\n */\nimport { poll } from '../../BookReader/utils.js';\nimport { renderBoxesInPageContainerLayer } from '../../BookReader/PageContainer.js';\nimport SearchView from './view.js';\nimport { marshallSearchResults } from './utils.js';\n/** @typedef {import('../../BookReader/PageContainer').PageContainer} PageContainer */\n/** @typedef {import('../../BookReader/BookModel').PageIndex} PageIndex */\n/** @typedef {import('../../BookReader/BookModel').LeafNum} LeafNum */\n/** @typedef {import('../../BookReader/BookModel').PageNumString} PageNumString */\n\njQuery.extend(BookReader.defaultOptions, {\n server: 'ia600609.us.archive.org',\n bookId: '',\n subPrefix: '',\n bookPath: '',\n enableSearch: true,\n searchInsideProtocol: 'https',\n searchInsideUrl: '/fulltext/inside.php',\n searchInsidePreTag: '{{{',\n searchInsidePostTag: '}}}',\n initialSearchTerm: null,\n});\n\n/** @override */\nBookReader.prototype.setup = (function (super_) {\n return function (options) {\n super_.call(this, options);\n\n this.searchTerm = '';\n this.searchResults = null;\n this.searchInsideUrl = options.searchInsideUrl;\n this.enableSearch = options.enableSearch;\n\n // Base server used by some api calls\n this.bookId = options.bookId;\n this.server = options.server;\n this.subPrefix = options.subPrefix;\n this.bookPath = options.bookPath;\n\n this.searchXHR = null;\n this._cancelSearch.bind(this);\n this.cancelSearchRequest.bind(this);\n\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n this._searchBoxesByIndex = {};\n\n this.searchView = undefined;\n };\n})(BookReader.prototype.setup);\n\n/** @override */\nBookReader.prototype.init = (function (super_) {\n return function () {\n super_.call(this);\n // give SearchView the most complete bookreader state\n this.searchView = new SearchView({\n br: this,\n searchCancelledCallback: () => {\n this._cancelSearch();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n });\n if (this.options.enableSearch && this.options.initialSearchTerm) {\n /**\n * this.search() take two parameter\n * 1. this.options.initialSearchTerm - search term\n * 2. {\n * goToFirstResult: this.options.goToFirstResult,\n * suppressFragmentChange: false // always want to change fragment in URL\n * }\n */\n this.search(\n this.options.initialSearchTerm,\n { goToFirstResult: this.options.goToFirstResult, suppressFragmentChange: false }\n );\n }\n };\n})(BookReader.prototype.init);\n\n/** @override */\nBookReader.prototype.buildToolbarElement = (function (super_) {\n return function () {\n const $el = super_.call(this);\n if (!this.enableSearch) { return; }\n if (this.searchView.dom.toolbarSearch) {\n $el.find('.BRtoolbarSectionInfo').after(this.searchView.dom.toolbarSearch);\n }\n return $el;\n };\n})(BookReader.prototype.buildToolbarElement);\n\n/** @override */\nBookReader.prototype._createPageContainer = (function (super_) {\n return function (index) {\n const pageContainer = super_.call(this, index);\n if (this.enableSearch && pageContainer.page && index in this._searchBoxesByIndex) {\n const pageIndex = pageContainer.page.index;\n const boxes = this._searchBoxesByIndex[pageIndex];\n renderBoxesInPageContainerLayer(\n 'searchHiliteLayer',\n boxes,\n pageContainer.page,\n pageContainer.$container[0],\n boxes.map(b => `match-index-${b.matchIndex}`),\n );\n }\n return pageContainer;\n };\n})(BookReader.prototype._createPageContainer);\n\n/**\n * @typedef {object} SearchOptions\n * @property {boolean} goToFirstResult\n * @property {boolean} disablePopup\n * @property {(null|function)} error - @deprecated at v.5.0\n * @property {(null|function)} success - @deprecated at v.5.0\n */\n\n/**\n * Submits search request\n *\n * @param {string} term\n * @param {SearchOptions} overrides\n */\nBookReader.prototype.search = async function(term = '', overrides = {}) {\n /** @type {SearchOptions} */\n const defaultOptions = {\n goToFirstResult: false, /* jump to the first result (default=false) */\n disablePopup: false, /* don't show the modal progress (default=false) */\n suppressFragmentChange: false, /* don't change the URL on initial load */\n error: null, /* optional error handler (default=null) */\n success: null, /* optional success handler (default=null) */\n\n };\n const options = jQuery.extend({}, defaultOptions, overrides);\n this.suppressFragmentChange = options.suppressFragmentChange;\n this.searchCancelled = false;\n\n // strip slashes, since this goes in the url\n this.searchTerm = term.replace(/\\//g, ' ');\n\n if (!options.suppressFragmentChange) {\n this.trigger(BookReader.eventNames.fragmentChange);\n }\n\n // Add quotes to the term. This is to compenstate for the backends default OR query\n // term = term.replace(/['\"]+/g, '');\n // term = '\"' + term + '\"';\n\n // Remove the port and userdir\n const serverPath = this.server.replace(/:.+/, '');\n const baseUrl = `${this.options.searchInsideProtocol}://${serverPath}${this.searchInsideUrl}?`;\n\n // Remove subPrefix from end of path\n let path = this.bookPath;\n const subPrefixWithSlash = `/${this.subPrefix}`;\n if (this.bookPath.length - this.bookPath.lastIndexOf(subPrefixWithSlash) == subPrefixWithSlash.length) {\n path = this.bookPath.substr(0, this.bookPath.length - subPrefixWithSlash.length);\n }\n\n const urlParams = {\n item_id: this.bookId,\n doc: this.subPrefix,\n path,\n q: term,\n pre_tag: this.options.searchInsidePreTag,\n post_tag: this.options.searchInsidePostTag,\n };\n\n // NOTE that the API does not expect / (slashes) to be encoded. (%2F) won't work\n const paramStr = $.param(urlParams).replace(/%2F/g, '/');\n\n const url = `${baseUrl}${paramStr}`;\n\n const callSearchResultsCallback = (searchInsideResults) => {\n if (this.searchCancelled) {\n return;\n }\n const responseHasError = searchInsideResults.error || !searchInsideResults.matches.length;\n const hasCustomError = typeof options.error === 'function';\n const hasCustomSuccess = typeof options.success === 'function';\n\n if (responseHasError) {\n console.error('Search Inside Response Error', searchInsideResults.error || 'matches.length == 0');\n hasCustomError\n ? options.error.call(this, searchInsideResults, options)\n : this.BRSearchCallbackError(searchInsideResults, options);\n } else {\n hasCustomSuccess\n ? options.success.call(this, searchInsideResults, options)\n : this.BRSearchCallback(searchInsideResults, options);\n }\n };\n\n this.trigger('SearchStarted', { term: this.searchTerm, instance: this });\n callSearchResultsCallback(await $.ajax({\n url: url,\n dataType: 'jsonp',\n cache: true,\n beforeSend: xhr => { this.searchXHR = xhr; },\n }));\n};\n\n/**\n * cancels AJAX Call\n * emits custom event\n */\nBookReader.prototype._cancelSearch = function () {\n this.searchXHR?.abort();\n this.searchView.clearSearchFieldAndResults(false);\n this.searchTerm = '';\n this.searchXHR = null;\n this.searchCancelled = true;\n this.searchResults = [];\n};\n\n/**\n * External function to cancel search\n * checks for term & xhr in flight before running\n */\nBookReader.prototype.cancelSearchRequest = function () {\n this.searchCancelled = true;\n if (this.searchXHR !== null) {\n this._cancelSearch();\n this.searchView.toggleSearchPending();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n};\n\n/**\n * @typedef {object} SearchInsideMatchBox\n * @property {number} page\n * @property {number} r\n * @property {number} l\n * @property {number} b\n * @property {number} t\n * @property {HTMLDivElement} [div]\n * @property {number} matchIndex This is a fake field! not part of the API response. The index of the match that contains this box in total search results matches.\n */\n\n/**\n * @typedef {object} SearchInsideMatch\n * @property {number} matchIndex This is a fake field! Not part of the API response. It is added by the JS.\n * @property {string} displayPageNumber (fake field) The page number as it should be displayed in the UI.\n * @property {string} html (computed field) The html-escaped raw html to display in the UI.\n * @property {string} text\n * @property {Array<{ page: number, boxes: SearchInsideMatchBox[] }>} par\n */\n\n/**\n * @typedef {object} SearchInsideResults\n * @property {string} error\n * @property {SearchInsideMatch[]} matches\n * @property {boolean} indexed\n */\n\n/**\n * Search Results return handler\n * @param {SearchInsideResults} results\n * @param {object} options\n * @param {boolean} options.goToFirstResult\n */\nBookReader.prototype.BRSearchCallback = function(results, options) {\n marshallSearchResults(\n results,\n pageNum => this.book.getPageNum(this.book.leafNumToIndex(pageNum)),\n this.options.searchInsidePreTag,\n this.options.searchInsidePostTag,\n );\n this.searchResults = results || [];\n\n this.updateSearchHilites();\n this.removeProgressPopup();\n if (options.goToFirstResult) {\n this._searchPluginGoToResult(0);\n }\n this.trigger('SearchCallback', { results, options, instance: this });\n};\n\n/**\n * Main search results error handler\n * @callback\n * @param {SearchInsideResults} results\n */\nBookReader.prototype.BRSearchCallbackError = function(results) {\n this._BRSearchCallbackError(results);\n};\n\n/**\n * @private draws search results error\n * @callback\n * @param {SearchInsideResults} results\n * @param {jQuery} $el\n * @param {boolean} fade\n */\nBookReader.prototype._BRSearchCallbackError = function(results) {\n this.searchResults = results;\n const basePayload = {\n term: this.searchTerm,\n instance: this,\n };\n if (results.error) {\n const payload = Object.assign({}, basePayload, { results });\n this.trigger('SearchCallbackError', payload);\n } else if (0 == results.matches.length) {\n if (false === results.indexed) {\n this.trigger('SearchCallbackBookNotIndexed', basePayload);\n return;\n }\n this.trigger('SearchCallbackEmpty', basePayload);\n }\n};\n\n/**\n * updates search on-page highlights controller\n */\nBookReader.prototype.updateSearchHilites = function() {\n /** @type {SearchInsideMatch[]} */\n const matches = this.searchResults?.matches || [];\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n const boxesByIndex = {};\n\n // Clear any existing svg layers\n this.removeSearchHilites();\n\n // Group by pageIndex\n for (const match of matches) {\n for (const box of match.par[0].boxes) {\n const pageIndex = this.book.leafNumToIndex(box.page);\n const pageBoxes = boxesByIndex[pageIndex] || (boxesByIndex[pageIndex] = []);\n pageBoxes.push(box);\n }\n }\n\n // update any already created pages\n for (const [pageIndexString, boxes] of Object.entries(boxesByIndex)) {\n const pageIndex = parseFloat(pageIndexString);\n const page = this.book.getPage(pageIndex);\n const pageContainers = this.getActivePageContainerElementsForIndex(pageIndex);\n for (const container of pageContainers) {\n renderBoxesInPageContainerLayer('searchHiliteLayer', boxes, page, container, boxes.map(b => `match-index-${b.matchIndex}`));\n }\n }\n\n this._searchBoxesByIndex = boxesByIndex;\n};\n\n/**\n * remove search highlights\n */\nBookReader.prototype.removeSearchHilites = function() {\n $(this.getActivePageContainerElements()).find('.searchHiliteLayer').remove();\n};\n\n/**\n * @private\n * Goes to the page specified. If the page is not viewable, tries to load the page\n * FIXME Most of this logic is IA specific, and should be less integrated into here\n * or at least more configurable.\n * @param {number} matchIndex\n */\nBookReader.prototype._searchPluginGoToResult = async function (matchIndex) {\n const match = this.searchResults?.matches[matchIndex];\n const book = this.book;\n const pageIndex = book.leafNumToIndex(match.par[0].page);\n const page = book.getPage(pageIndex);\n const onNearbyPage = Math.abs(this.currentIndex() - pageIndex) < 3;\n let makeUnviewableAtEnd = false;\n if (!page.isViewable) {\n const resp = await fetch('/services/bookreader/request_page?' + new URLSearchParams({\n id: this.options.bookId,\n subprefix: this.options.subPrefix,\n leafNum: page.leafNum,\n })).then(r => r.json());\n\n for (const leafNum of resp.value) {\n book.getPage(book.leafNumToIndex(leafNum)).makeViewable();\n }\n\n // not able to show page; make the page viewable anyways so that it can\n // actually open. On IA, it has a fallback to a special error page.\n if (!resp.value.length) {\n book.getPage(pageIndex).makeViewable();\n makeUnviewableAtEnd = true;\n }\n\n // Trigger an update of book\n this._modes.mode1Up.mode1UpLit.updatePages();\n if (this.activeMode == this._modes.mode1Up) {\n await this._modes.mode1Up.mode1UpLit.updateComplete;\n }\n }\n /* this updates the URL */\n if (!this._isIndexDisplayed(pageIndex)) {\n this.suppressFragmentChange = false;\n this.jumpToIndex(pageIndex);\n }\n\n // Reset it to unviewable if it wasn't resolved\n if (makeUnviewableAtEnd) {\n book.getPage(pageIndex).makeViewable(false);\n }\n\n // Scroll/flash in the ui\n const $boxes = await poll(() => $(`rect.match-index-${match.matchIndex}`), { until: result => result.length > 0 });\n if ($boxes.length) {\n $boxes.css('animation', 'none');\n $boxes[0].scrollIntoView({\n // Only vertically center the highlight if we're in 1up or in full screen. In\n // 2up, if we're not fullscreen, the whole body gets scrolled around to try to\n // center the highlight 🙄 See:\n // https://stackoverflow.com/questions/11039885/scrollintoview-causing-the-whole-page-to-move/11041376\n // Note: nearest doesn't quite work great, because the ReadAloud toolbar is now\n // full-width, and covers up the last line of the highlight.\n block: this.constMode1up == this.mode || this.isFullscreenActive ? 'center' : 'nearest',\n inline: 'center',\n behavior: onNearbyPage ? 'smooth' : 'auto',\n });\n // wait for animation to start\n await new Promise(resolve => setTimeout(resolve, 100));\n $boxes.removeAttr(\"style\");\n }\n};\n\n/**\n * Removes all search pins\n */\nBookReader.prototype.removeSearchResults = function(suppressFragmentChange = false) {\n this.removeSearchHilites(); //be sure to set all box.divs to null\n this.searchTerm = null;\n this.searchResults = null;\n if (!suppressFragmentChange) {\n this.trigger(BookReader.eventNames.fragmentChange);\n }\n};\n\n/**\n * Returns true if a search highlight is currently being displayed\n * @returns {boolean}\n */\nBookReader.prototype.searchHighlightVisible = function() {\n const results = this.searchResults;\n let visiblePages = [];\n if (null == results) return false;\n\n if (this.constMode2up == this.mode) {\n visiblePages = [this.twoPage.currentIndexL, this.twoPage.currentIndexR];\n } else if (this.constMode1up == this.mode) {\n visiblePages = [this.currentIndex()];\n } else {\n return false;\n }\n\n results.matches.some(match => {\n return match.par[0].boxes.some(box => {\n const pageIndex = this.book.leafNumToIndex(box.page);\n if (jQuery.inArray(pageIndex, visiblePages) >= 0) {\n return true;\n }\n });\n });\n\n return false;\n};\n","var global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar toString = require('../internals/to-string');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar charAt = uncurryThis(''.charAt);\nvar $parseFloat = global.parseFloat;\nvar Symbol = global.Symbol;\nvar ITERATOR = Symbol && Symbol.iterator;\nvar FORCED = 1 / $parseFloat(whitespaces + '-0') !== -Infinity\n // MS Edge 18- broken with boxed symbols\n || (ITERATOR && !fails(function () { $parseFloat(Object(ITERATOR)); }));\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(toString(string));\n var result = $parseFloat(trimmedString);\n return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;\n} : $parseFloat;\n","var $ = require('../internals/export');\nvar $entries = require('../internals/object-to-array').entries;\n\n// `Object.entries` method\n// https://tc39.es/ecma262/#sec-object.entries\n$({ target: 'Object', stat: true }, {\n entries: function entries(O) {\n return $entries(O);\n }\n});\n","var $ = require('../internals/export');\nvar $parseFloat = require('../internals/number-parse-float');\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\n$({ global: true, forced: parseFloat != $parseFloat }, {\n parseFloat: $parseFloat\n});\n"],"names":["SearchView","_ref","br","_ref$searchCancelledC","searchCancelledCallback","_classCallCheck","this","matches","cacheDOMElements","bindEvents","cancelSearch","key","value","dom","toolbarSearch","buildToolbarSearch","query","$","val","remove","dispatchEventWhenComplete","arguments","length","undefined","removeSearchResults","removeResultPins","emptyMatches","setQuery","teardownSearchNavigation","trigger","selector","before","concat","resultsPosition","searchNavigation","positionMessage","currentMatchIndex","namespace","on","clearSearchFieldAndResults","bind","showPrevResult","showNextResult","toggleSidebar","mode","constModeThumb","switchMode","constMode1up","getClosestMatchIndex","start","end","comparator","eq","click","updateResultsPosition","updateSearchNavigationButtons","comparisonFn","closestPage","closestTo","pool","slice","map","m","par","page","currentIndex","indexOf","find","text","attr","off","resize","matchingSearchResult","constMode2up","find2upMatchingSearchResult","find1upMatchingSearchResult","_this","_this2","_isIndexDisplayed","setCurrentMatchIndex","bool","pinsVisibleState","refs","$BRfooter","css","visibility","document","createElement","classList","add","innerHTML","imagesBaseURL","_this3","forEach","match","pageIndex","book","leafNumToIndex","percentThrough","constructor","util","cssPercentage","getNumLeafs","html","Math","max","substring","replace","addClass","left","append","displayPageNumber","appendTo","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","x","style","setProperty","removeClass","target","_searchPluginGoToResult","matchIndex","_this4","showProgressPopup","progressPopupClosed","removeProgressPopup","toggleSearchPending","errorDetails","renderModalMessage","delayModalRemovalFor","messageHTML","modal","el","timeoutMS","setTimeout","e","preventDefault","search","_ref2","_this5","results","options","renderSearchNavigation","bindSearchNavigationEvents","renderPins","goToFirstResult","one","removeSearchHilites","searchTerm","_event$detail","_event$detail$props","_event$detail$props$r","isIndexed","detail","props","indexed","renderErrorModal","renderBookNotIndexedModal","renderResultsEmptyModal","window","addEventListener","handleSearchCallbackError","handleSearchCallback","handleSearchStarted","handleSearchCallbackBookNotIndexed","handleSearchCallbackEmpty","updateSearchNavigation","submitHandler","renderMatch","preTag","postTag","preTagRe","escapeRegExp","escapeHTML","postTagRe","regex","RegExp","super_","_regeneratorRuntime","exports","Op","Object","prototype","hasOwn","hasOwnProperty","defineProperty","obj","desc","$Symbol","Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","define","enumerable","configurable","writable","err","wrap","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","create","context","Context","makeInvokeMethod","tryCatch","fn","arg","type","call","ContinueSentinel","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","values","Gp","defineIteratorMethods","method","_invoke","AsyncIterator","PromiseImpl","invoke","resolve","reject","record","result","_typeof","__await","then","unwrapped","error","previousPromise","callInvokeWithMethodAndArg","state","Error","done","delegate","delegateResult","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","methodName","return","TypeError","info","resultName","next","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","iterable","iteratorMethod","isNaN","i","doneResult","displayName","isGeneratorFunction","genFun","ctor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","iter","keys","object","reverse","pop","skipTempReset","prev","charAt","stop","rootRecord","rval","exception","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","catch","thrown","delegateYield","asyncGeneratorStep","gen","_next","_throw","_asyncToGenerator","args","apply","jQuery","extend","BookReader","defaultOptions","server","bookId","subPrefix","bookPath","enableSearch","searchInsideProtocol","searchInsideUrl","searchInsidePreTag","searchInsidePostTag","initialSearchTerm","setup","searchResults","searchXHR","_cancelSearch","cancelSearchRequest","_searchBoxesByIndex","searchView","init","term","instance","suppressFragmentChange","buildToolbarElement","$el","after","_createPageContainer","index","pageContainer","boxes","renderBoxesInPageContainerLayer","$container","b","_callee","overrides","serverPath","baseUrl","path","subPrefixWithSlash","urlParams","paramStr","url","callSearchResultsCallback","_args","_context","disablePopup","success","searchCancelled","eventNames","fragmentChange","lastIndexOf","substr","item_id","doc","q","pre_tag","post_tag","param","searchInsideResults","responseHasError","hasCustomError","hasCustomSuccess","console","BRSearchCallbackError","BRSearchCallback","t0","ajax","dataType","cache","beforeSend","xhr","t1","_this$searchXHR","abort","displayPageNumberFn","_step","pageNum","_iterator","_createForOfIteratorHelper","entries","s","n","_step$value","getPageNum","_step2","_iterator2","_step3","_iterator3","f","marshallSearchResults","updateSearchHilites","_BRSearchCallbackError","basePayload","payload","assign","_this$searchResults","boxesByIndex","box","_i","_Object$entries","_Object$entries$_i","pageIndexString","parseFloat","getPage","getActivePageContainerElementsForIndex","container","getActivePageContainerElements","_callee2","_this$searchResults2","onNearbyPage","makeUnviewableAtEnd","resp","_iterator4","_step4","leafNum","$boxes","_context2","abs","isViewable","fetch","URLSearchParams","id","subprefix","r","json","makeViewable","_modes","mode1Up","mode1UpLit","updatePages","activeMode","updateComplete","jumpToIndex","poll","until","scrollIntoView","block","isFullscreenActive","inline","behavior","removeAttr","_x2","searchHighlightVisible","visiblePages","twoPage","currentIndexL","currentIndexR","some","inArray","global","fails","uncurryThis","toString","trim","whitespaces","$parseFloat","ITERATOR","FORCED","module","string","trimmedString","$entries","stat","O","forced"],"sourceRoot":""}
@@ -1,2 +1,3 @@
1
- (self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[423],{4742:function(t,e,n){"use strict";n(5666),n(6992),n(1539),n(3948),n(9826),n(9714),n(2222),n(4678),n(8674),n(1249),n(4916),n(3123),n(2707),n(1038),n(8783),n(7852),n(3210),n(7042),n(9601),n(1532),n(2165),n(2526),n(1817),n(9600),n(8309),n(489),n(2419),n(4819),n(5003);var r=n(9860),o=n(3609);function a(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var l=function(){function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),i(this,"selecting",!1),i(this,"startedInSelector",!1),i(this,"target",null),i(this,"_onSelectionChange",(function(){var t=window.getSelection();!r.selecting&&t.toString()&&(r.selecting=!0,r.target=o(t.anchorNode).closest(r.selector)[0],r.handler("started",r.target)),!r.selecting||!t.isCollapsed&&t.toString()&&o(t.anchorNode).closest(r.selector)[0]||(r.selecting=!1,r.handler("cleared",r.target))})),this.selector=e,this.handler=n}var e,n;return e=t,(n=[{key:"attach",value:function(){document.addEventListener("selectionchange",this._onSelectionChange)}},{key:"detach",value:function(){document.removeEventListener("selectionchange",this._onSelectionChange)}}])&&a(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function c(t){return function(t){if(Array.isArray(t))return t}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:f;return null==t?void 0:t.replace(/\{\{([^}]*?)\}\}/g,(function(t,o){if(!o)return t;var a=c(o.split("|").map((function(t){return t.trim()}))),i=a[0],l=a.slice(1);if(!(i in n)&&!(i in e))return t;var s=i in n?n[i]:i in e?e[i]:null;return l.map((function(t){return r[t]})).reduce((function(t,e){return e(t)}),s&&s.toString())}))}n(5306),n(5827);var f={urlencode:encodeURIComponent},p=n(3609);function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var h=regeneratorRuntime.mark(W),y=regeneratorRuntime.mark(U),v=regeneratorRuntime.mark(H);function g(){return(g="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=m(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}}).apply(this,arguments)}function m(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=w(t)););return t}function b(t,e){return(b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function x(t,e){if(e&&("object"===d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function w(t){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function S(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,a=[],i=!0,l=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);i=!0);}catch(t){l=!0,o=t}finally{try{i||null==n.return||n.return()}finally{if(l)throw o}}return a}}(t,e)||P(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=P(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,l=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){l=!0,a=t},f:function(){try{i||null==n.return||n.return()}finally{if(l)throw a}}}}function P(t,e){if(t){if("string"==typeof t)return k(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?k(t,e):void 0}}function k(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function E(t,e,n,r,o,a,i){try{var l=t[a](i),c=l.value}catch(t){return void n(t)}l.done?e(c):Promise.resolve(c).then(r,o)}function C(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function i(t){E(a,r,o,i,l,"next",t)}function l(t){E(a,r,o,i,l,"throw",t)}i(void 0)}))}}function j(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function A(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function O(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function B(t,e,n){return e&&O(t.prototype,e),n&&O(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}var T=window.BookReader,D={enabled:!0,fullDjvuXmlUrl:null,singlePageDjvuXmlUrl:null,jsonp:!1},I=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;A(this,t),this.maxSize=e,this.entries=[]}return B(t,[{key:"add",value:function(t){this.entries.length>=this.maxSize&&this.entries.shift(),this.entries.push(t)}}]),t}(),L=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:D,r=arguments.length>1?arguments[1]:void 0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"lr";A(this,t),j(this,"_onSelectionChange",(function(t,n){if("started"===t)e.textSelectingMode(n);else{if("cleared"!==t)throw new Error("Unknown type ".concat(t));e.defaultMode(n)}})),this.options=n,this.optionVariables=r,this.djvuPagesPromise=null,this.rtl="rl"===o,this.pageTextCache=new I,this.maxWordRendered=2500,this.selectionObserver=new l(".BRtextLayer",this._onSelectionChange)}var e,n;return B(t,[{key:"init",value:function(){this.selectionObserver.attach(),this.options.singlePageDjvuXmlUrl||(this.djvuPagesPromise=p.ajax({type:"GET",url:u(this.options.fullDjvuXmlUrl,this.optionVariables),dataType:this.options.jsonp?"jsonp":"html",cache:!0,error:function(t){}}).then((function(t){try{var e=p.parseXML(t);return e&&p(e).find("OBJECT")}catch(t){return}})))}},{key:"getPageText",value:(n=C(regeneratorRuntime.mark((function t(e){var n,r,o,a,i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.options.singlePageDjvuXmlUrl){t.next=19;break}if(!(n=this.pageTextCache.entries.find((function(t){return t.index==e})))){t.next=4;break}return t.abrupt("return",n.response);case 4:return t.next=6,p.ajax({type:"GET",url:u(this.options.singlePageDjvuXmlUrl,this.optionVariables,{pageIndex:e}),dataType:this.options.jsonp?"jsonp":"html",cache:!0,error:function(t){}});case 6:return r=t.sent,t.prev=7,o=p.parseXML(r),a=o&&p(o).find("OBJECT")[0],this.pageTextCache.add({index:e,response:a}),t.abrupt("return",a);case 14:return t.prev=14,t.t0=t.catch(7),t.abrupt("return",void 0);case 17:t.next=24;break;case 19:return t.next=21,this.djvuPagesPromise;case 21:if(!(i=t.sent)){t.next=24;break}return t.abrupt("return",i[e]);case 24:case"end":return t.stop()}}),t,this,[[7,14]])}))),function(t){return n.apply(this,arguments)})},{key:"interceptCopy",value:function(t){t[0].addEventListener("copy",(function(t){var e=document.getSelection();t.clipboardData.setData("text/plain",e.toString()),t.preventDefault()}))}},{key:"defaultMode",value:function(t){var e=this,n=p(t).closest(".BRpagecontainer");t.style.pointerEvents="none",n.find("img").css("pointer-events","auto"),p(t).off(".textSelectPluginHandler");var r=this.mouseIsDown,o=this.mouseIsDown;r&&(t.style.pointerEvents="auto"),p(t).on("mousedown.textSelectPluginHandler",(function(t){e.mouseIsDown=!0,p(t.target).is(".BRwordElement, .BRspace")&&t.stopPropagation()})),p(t).on("mouseup.textSelectPluginHandler",(function(n){e.mouseIsDown=!1,t.style.pointerEvents="none",o&&(o=!1,n.stopPropagation())}))}},{key:"textSelectingMode",value:function(t){var e=this,n=p(t).closest(".BRpagecontainer");t.style.pointerEvents="all",n.find("img").css("pointer-events","none"),p(t).off(".textSelectPluginHandler"),p(t).on("mousedown.textSelectPluginHandler",(function(t){e.mouseIsDown=!0,t.stopPropagation()})),p(t).on("mouseup.textSelectPluginHandler",(function(t){e.mouseIsDown=!1,t.stopPropagation()}))}},{key:"stopPageFlip",value:function(t){var e=this,n=t.find(".BRtextLayer");n.length&&(n.each((function(t,n){return e.defaultMode(n)})),this.interceptCopy(t))}},{key:"createTextLayer",value:(e=C(regeneratorRuntime.mark((function t(e){var n,o,a,i,l,c,s,u,f,d,h,y,v,g,m,b,x,w,P,k,E,C,j,A,O=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.page.index,!(o=e.$container).find(".BRtextLayer").length){t.next=5;break}return t.abrupt("return");case 5:return t.next=7,this.getPageText(n);case 7:if(a=t.sent){t.next=10;break}return t.abrupt("return");case 10:if(X(a),!((i=p(a).find("WORD").length)>this.maxWordRendered)){t.next=15;break}return console.log("Page ".concat(n," has too many words (").concat(i," > ").concat(this.maxWordRendered,"). Not rendering text layer.")),t.abrupt("return");case 15:l=(0,r.RS)(e.page,"BRtextLayer"),c=parseFloat(e.$container[0].style.width)/e.page.width,s=parseFloat(e.$container[0].style.height)/e.page.height,l.style.transform="scale(".concat(c,", ").concat(s,")"),l.setAttribute("dir",this.rtl?"rtl":"ltr"),u=p(a).find("PARAGRAPH[coords]").toArray(),f=u.map((function(t){var e=O.renderParagraph(t);return l.appendChild(e),e})),d=_(l,".BRparagraphElement"),h=0,y=R(H(u,f));try{for(y.s();!(v=y.n()).done;)g=S(v.value,2),m=g[0],b=g[1],x=p(m).attr("coords").split(",").map(parseFloat),w=d.get(b),P=S(x,4),k=P[0],E=P[2],C=P[3],j=this.rtl?w.right-E:k-w.left,A=C-(w.top+h),b.style[this.rtl?"marginRight":"marginLeft"]="".concat(j,"px"),b.style.marginTop="".concat(A,"px"),h+=A,l.appendChild(b)}catch(t){y.e(t)}finally{y.f()}o.append(l),this.stopPageFlip(o);case 28:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"renderParagraph",value:function(t){var e=document.createElement("p");e.classList.add("BRparagraphElement");var n=S(p(t).attr("coords").split(",").map(parseFloat),4),r=n[0],o=n[1],a=n[2],i=n[3],l=[],c=p(t).find("LINE[coords]").toArray();if(!c.length)return e;var s,u=R(U(W(c,F)));try{for(u.s();!(s=u.n()).done;){var f=S(s.value,3),d=f[0],h=f[1],y=f[2],v=h.ocrElement==c[c.length-1],g=document.createElement("span");g.classList.add("BRlineElement");var m,b=R(h.words.entries());try{for(b.s();!(m=b.n()).done;){var x=S(m.value,2),w=x[0],E=x[1],C=S(p(E).attr("coords").split(",").map(parseFloat),4),j=C[1],A=C[2],O=C[3],B=j-O;if(l.push(B),0==w&&null!=d&&d.lastWord.textContent.trim().endsWith("-")){var T=S(p((y||d).firstWord).attr("coords").split(",").map(parseFloat),3)[0];p(E).attr("coords","".concat(T,",").concat(j,",").concat(A,",").concat(O))}var D=document.createElement("span");if(D.setAttribute("class","BRwordElement"),D.textContent=E.textContent.trim(),w>0){var I=document.createElement("span");I.classList.add("BRspace"),I.textContent=" ",g.append(I),g.appendChild(document.createTextNode(" "))}g.appendChild(D)}}catch(t){b.e(t)}finally{b.f()}var L=h.lastWord.textContent.trim().endsWith("-"),M=g.children[g.children.length-1];L&&!v&&(M.textContent=M.textContent.trim().slice(0,-1),M.classList.add("BRwordElement--hyphen")),e.appendChild(g),v||L||e.appendChild(document.createTextNode(" "))}}catch(t){u.e(t)}finally{u.f()}l.sort((function(t,e){return t-e}));var X=l[Math.floor(.85*l.length)]+4;e.style.left="".concat(r,"px"),e.style.top="".concat(i,"px"),e.style.width="".concat(a-r,"px"),e.style.height="".concat(o-i,"px"),e.style.fontSize="".concat(X,"px");var N,$=_(e,".BRwordElement"),q=R(H(p(t).find("WORD").toArray(),e.querySelectorAll(".BRwordElement")));try{for(q.s();!(N=q.n()).done;){var z=S(N.value,2),G=z[0],V=z[1],J=$.get(V),Y=S(p(G).attr("coords").split(",").map(parseFloat),3),K=Y[0],Q=Y[2]-K;G.textContent.endsWith(" ")&&(Q=Q*(G.textContent.length-1)/G.textContent.length);var Z=Q-J.width;V.style.letterSpacing="".concat(Z/(G.textContent.length-1),"px")}}catch(t){q.e(t)}finally{q.f()}$=_(e,".BRwordElement");var tt,et,nt=_(e,".BRspace"),rt=p(t).find("LINE[coords]").toArray(),ot=Array.from(e.querySelectorAll(".BRlineElement")),at=i,it=R(H(rt,ot));try{for(it.s();!(tt=it.n()).done;){var lt,ct=S(tt.value,2),st=ct[0],ut=ct[1],ft=p(st).find("WORD").toArray(),pt=this.rtl?a:r,dt=R(H(ft,ut.querySelectorAll(".BRwordElement")));try{for(dt.s();!(lt=dt.n()).done;){var ht=S(lt.value,2),yt=ht[0],vt=ht[1],gt=$.get(vt),mt=S(p(yt).attr("coords").split(",").map(parseFloat),3),bt=mt[0],xt=mt[2],wt=this.rtl?-(xt-pt):bt-pt;if(vt.previousElementSibling){var St=vt.previousElementSibling;St.style.letterSpacing="".concat(wt-nt.get(St).width,"px")}else vt.style[this.rtl?"paddingRight":"paddingLeft"]="".concat(wt,"px");this.rtl?pt-=wt+gt.width:pt+=wt+gt.width}}catch(t){dt.e(t)}finally{dt.f()}var Rt=Math.min.apply(Math,function(t){if(Array.isArray(t))return k(t)}(et=ft.map((function(t){return parseFloat(p(t).attr("coords").split(",")[3])})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(et)||P(et)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())-at;ut.previousElementSibling&&(ut.previousElementSibling.style.lineHeight="".concat(Rt,"px"),at+=Rt)}}catch(t){it.e(t)}finally{it.f()}return ot[ot.length-1].style.lineHeight="".concat(o-at,"px"),e.appendChild(document.createElement("br")),e}}]),t}(),M=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(o,t);var e,n,r=(e=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,r=w(e);if(n){var o=w(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return x(this,t)});function o(){return A(this,o),r.apply(this,arguments)}return B(o,[{key:"init",value:function(){var t=this,e=Object.assign({},D,this.options.plugins.textSelection);e.enabled&&(this.textSelectionPlugin=new L(e,this.options.vars,this.pageProgression),this.options.plugins.textSelection=e,this.textSelectionPlugin.init(),new l(".BRtextLayer",(function(e){var n;"started"==e&&(null===(n=t.archiveAnalyticsSendEvent)||void 0===n||n.call(t,"BookReader","SelectStart"),t.refs.$br.find(".BRpagecontainer--hasSelection").removeClass("BRpagecontainer--hasSelection"),p(window.getSelection().anchorNode).closest(".BRpagecontainer").addClass("BRpagecontainer--hasSelection"))})).attach()),g(w(o.prototype),"init",this).call(this)}},{key:"_createPageContainer",value:function(t){var e,n=g(w(o.prototype),"_createPageContainer",this).call(this,t);return this.mode!==this.constModeThumb&&n.page&&(null===(e=this.textSelectionPlugin)||void 0===e||e.createTextLayer(n)),n}}]),o}(T);function _(t,e){var n={position:t.style.position,visibility:t.style.visibility,top:t.style.top,left:t.style.left,transform:t.style.transform};t.style.position="absolute",t.style.visibility="hidden",t.style.top="0",t.style.left="0",t.style.transform="none",document.body.appendChild(t);var r=new Map(Array.from(t.querySelectorAll(e)).map((function(t){var e=t.getBoundingClientRect();return[t,new N(e.left+window.scrollX,e.top+window.scrollY,e.width,e.height)]})));return document.body.removeChild(t),Object.assign(t.style,n),r}function F(t){var e=p(t).find("WORD").toArray();return{ocrElement:t,words:e,firstWord:e[0],lastWord:e[e.length-1]}}function W(t,e){var n,r,o;return regeneratorRuntime.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:n=R(t),a.prev=1,n.s();case 3:if((r=n.n()).done){a.next=9;break}return o=r.value,a.next=7,e(o);case 7:a.next=3;break;case 9:a.next=14;break;case 11:a.prev=11,a.t0=a.catch(1),n.e(a.t0);case 14:return a.prev=14,n.f(),a.finish(14);case 17:case"end":return a.stop()}}),h,null,[[1,11,14,17]])}function U(t){var e,n,r,o,a,i;return regeneratorRuntime.wrap((function(l){for(;;)switch(l.prev=l.next){case 0:e=void 0,n=void 0,r=void 0,o=R(t),l.prev=4,o.s();case 6:if((a=o.n()).done){l.next=17;break}if(i=a.value,void 0===n){l.next=12;break}return r=i,l.next=12,[e,n,r];case 12:e=n,n=i,r=void 0;case 15:l.next=6;break;case 17:l.next=22;break;case 19:l.prev=19,l.t0=l.catch(4),o.e(l.t0);case 22:return l.prev=22,o.f(),l.finish(22);case 25:if(void 0===n){l.next=28;break}return l.next=28,[e,n,r];case 28:case"end":return l.stop()}}),y,null,[[4,19,22,25]])}function H(t,e){var n,r,o,a;return regeneratorRuntime.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:n=t[Symbol.iterator](),r=e[Symbol.iterator]();case 2:if(o=n.next(),a=r.next(),!o.done||!a.done){i.next=7;break}return i.abrupt("return");case 7:if(!o.done&&!a.done){i.next=9;break}throw new Error("zip: one of the iterators is done");case 9:return i.next=11,[o.value,a.value];case 11:i.next=2;break;case 13:case"end":return i.stop()}}),v)}function X(t){if(!p(t).attr("coords")&&t.children){var e=p(t).children().toArray();if(0!==e.length){var n,r=R(e);try{for(r.s();!(n=r.n()).done;)X(n.value)}catch(t){r.e(t)}finally{r.f()}var o,a=[],i=R(e);try{for(i.s();!(o=i.n()).done;){var l=o.value;p(l).attr("coords")&&a.push(p(l).attr("coords").split(",").map(parseFloat))}}catch(t){i.e(t)}finally{i.f()}var c=function(t){var e,n=1/0,r=-1/0,o=-1/0,a=1/0,i=R(t);try{for(i.s();!(e=i.n()).done;){var l=S(e.value,4),c=l[0],s=l[1],u=l[2],f=l[3];n=Math.min(n,c),r=Math.max(r,s),o=Math.max(o,u),a=Math.min(a,f)}}catch(t){i.e(t)}finally{i.f()}return[n,r,o,a]}(a);Math.abs(c[0])!=1/0&&p(t).attr("coords",c.join(","))}}}window.BookReader=M;var N=function(){function t(e,n,r,o){A(this,t),this.x=e,this.y=n,this.width=r,this.height=o}return B(t,[{key:"right",get:function(){return this.x+this.width}},{key:"bottom",get:function(){return this.y+this.height}},{key:"top",get:function(){return this.y}},{key:"left",get:function(){return this.x}}]),t}()},2814:function(t,e,n){var r=n(7854),o=n(7293),a=n(1702),i=n(1340),l=n(3111).trim,c=n(1361),s=a("".charAt),u=r.parseFloat,f=r.Symbol,p=f&&f.iterator,d=1/u(c+"-0")!=-1/0||p&&!o((function(){u(Object(p))}));t.exports=d?function(t){var e=l(i(t)),n=u(e);return 0===n&&"-"==s(e,0)?-0:n}:u},6091:function(t,e,n){var r=n(6530).PROPER,o=n(7293),a=n(1361);t.exports=function(t){return o((function(){return!!a[t]()||"​…᠎"!=="​…᠎"[t]()||r&&a[t].name!==t}))}},4678:function(t,e,n){var r=n(2109),o=n(2814);r({global:!0,forced:parseFloat!=o},{parseFloat:o})},3210:function(t,e,n){"use strict";var r=n(2109),o=n(3111).trim;r({target:"String",proto:!0,forced:n(6091)("trim")},{trim:function(){return o(this)}})}},function(t){t(t.s=4742)}]);
1
+ /*! For license information please see plugin.text_selection.js.LICENSE.txt */
2
+ (self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[423],{4742:function(t,e,r){"use strict";r(6992),r(1539),r(3948),r(9826),r(9714),r(2222),r(4678),r(8674),r(1249),r(2707),r(1038),r(8783),r(7852),r(3210),r(7042),r(9601),r(1532),r(2165),r(2526),r(1817),r(9600),r(6649),r(6078),r(9653),r(2443),r(3680),r(3706),r(2703),r(489),r(4747),r(8309),r(5069),r(4916),r(2419),r(4819),r(5003);var n=r(9860),o=r(5311);function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function c(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t){var e=function(t,e){if("object"!==i(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===i(e)?e:String(e)}var u=function(){function t(e,r){var n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,"selecting",!1),c(this,"startedInSelector",!1),c(this,"target",null),c(this,"_onSelectionChange",(function(){var t=window.getSelection();!n.selecting&&t.toString()&&(n.selecting=!0,n.target=o(t.anchorNode).closest(n.selector)[0],n.handler("started",n.target)),!n.selecting||!t.isCollapsed&&t.toString()&&o(t.anchorNode).closest(n.selector)[0]||(n.selecting=!1,n.handler("cleared",n.target))})),this.selector=e,this.handler=r}var e,r;return e=t,(r=[{key:"attach",value:function(){document.addEventListener("selectionchange",this._onSelectionChange)}},{key:"detach",value:function(){document.removeEventListener("selectionchange",this._onSelectionChange)}}])&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function f(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:h;return null==t?void 0:t.replace(/\{\{([^}]*?)\}\}/g,(function(t,o){if(!o)return t;var i,a=function(t){if(Array.isArray(t))return t}(i=o.split("|").map((function(t){return t.trim()})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(t,e):void 0}}(i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=a[0],l=a.slice(1);if(!(c in r)&&!(c in e))return t;var u=c in r?r[c]:c in e?e[c]:null;return l.map((function(t){return n[t]})).reduce((function(t,e){return e(t)}),u&&u.toString())}))}r(5306),r(5827);var h={urlencode:encodeURIComponent},p=r(5311);function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}var y=j().mark(N),v=j().mark(W),g=j().mark(G);function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=w(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},m.apply(this,arguments)}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function w(t){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},w(t)}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],l=!0,u=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);l=!0);}catch(t){u=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(t,e)||E(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=E(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){c=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(c)throw i}}}}function E(t,e){if(t){if("string"==typeof t)return P(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(t,e):void 0}}function P(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function j(){j=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function u(t,e,r,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),c=new O(o||[]);return n(a,"_invoke",{value:S(t,r,c)}),a}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var f={};function h(){}function p(){}function y(){}var v={};l(v,i,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(R([])));m&&m!==e&&r.call(m,i)&&(v=m);var b=y.prototype=h.prototype=Object.create(v);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function o(n,i,a,c){var l=s(t[n],t,i);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==d(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,a,c)}),(function(t){o("throw",t,a,c)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return o("throw",t,a,c)}))}c(l.arg)}var i;n(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}})}function S(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=E(a,r);if(c){if(c===f)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var l=s(t,e,r);if("normal"===l.type){if(n=r.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n="completed",r.method="throw",r.arg=l.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=s(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function R(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return p.prototype=y,n(b,"constructor",{value:y,configurable:!0}),n(y,"constructor",{value:p,configurable:!0}),p.displayName=l(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),l(x.prototype,a,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),l(b,c,"Generator"),l(b,i,(function(){return this})),l(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=R,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),l=r.call(i,"finallyLoc");if(c&&l){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function k(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}function O(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){k(i,n,o,a,c,"next",t)}function c(t){k(i,n,o,a,c,"throw",t)}a(void 0)}))}}function R(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function L(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,A(n.key),n)}}function C(t,e,r){return e&&L(t.prototype,e),r&&L(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){var e=function(t,e){if("object"!==d(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!==d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===d(e)?e:String(e)}var _=window.BookReader,B={enabled:!0,fullDjvuXmlUrl:null,singlePageDjvuXmlUrl:null,jsonp:!1},T=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;R(this,t),this.maxSize=e,this.entries=[]}return C(t,[{key:"add",value:function(t){this.entries.length>=this.maxSize&&this.entries.shift(),this.entries.push(t)}}]),t}(),I=function(){function t(){var e,r,n,o=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:B,a=arguments.length>1?arguments[1]:void 0,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"lr";R(this,t),e=this,n=function(t,e){if("started"===t)o.textSelectingMode(e);else{if("cleared"!==t)throw new Error("Unknown type ".concat(t));o.defaultMode(e)}},(r=A(r="_onSelectionChange"))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,this.options=i,this.optionVariables=a,this.djvuPagesPromise=null,this.rtl="rl"===c,this.pageTextCache=new T,this.maxWordRendered=2500,this.selectionObserver=new u(".BRtextLayer",this._onSelectionChange)}var e,r;return C(t,[{key:"init",value:function(){this.selectionObserver.attach(),this.options.singlePageDjvuXmlUrl||(this.djvuPagesPromise=p.ajax({type:"GET",url:f(this.options.fullDjvuXmlUrl,this.optionVariables),dataType:this.options.jsonp?"jsonp":"html",cache:!0,error:function(t){}}).then((function(t){try{var e=p.parseXML(t);return e&&p(e).find("OBJECT")}catch(t){return}})))}},{key:"getPageText",value:(r=O(j().mark((function t(e){var r,n,o,i,a;return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.options.singlePageDjvuXmlUrl){t.next=19;break}if(!(r=this.pageTextCache.entries.find((function(t){return t.index==e})))){t.next=4;break}return t.abrupt("return",r.response);case 4:return t.next=6,p.ajax({type:"GET",url:f(this.options.singlePageDjvuXmlUrl,this.optionVariables,{pageIndex:e}),dataType:this.options.jsonp?"jsonp":"html",cache:!0,error:function(t){}});case 6:return n=t.sent,t.prev=7,o=p.parseXML(n),i=o&&p(o).find("OBJECT")[0],this.pageTextCache.add({index:e,response:i}),t.abrupt("return",i);case 14:return t.prev=14,t.t0=t.catch(7),t.abrupt("return",void 0);case 17:t.next=24;break;case 19:return t.next=21,this.djvuPagesPromise;case 21:if(!(a=t.sent)){t.next=24;break}return t.abrupt("return",a[e]);case 24:case"end":return t.stop()}}),t,this,[[7,14]])}))),function(t){return r.apply(this,arguments)})},{key:"interceptCopy",value:function(t){t[0].addEventListener("copy",(function(t){var e=document.getSelection();t.clipboardData.setData("text/plain",e.toString()),t.preventDefault()}))}},{key:"defaultMode",value:function(t){var e=this,r=p(t).closest(".BRpagecontainer");t.style.pointerEvents="none",r.find("img").css("pointer-events","auto"),p(t).off(".textSelectPluginHandler");var n=this.mouseIsDown,o=this.mouseIsDown;n&&(t.style.pointerEvents="auto"),p(t).on("mousedown.textSelectPluginHandler",(function(t){e.mouseIsDown=!0,p(t.target).is(".BRwordElement, .BRspace")&&t.stopPropagation()})),p(t).on("mouseup.textSelectPluginHandler",(function(r){e.mouseIsDown=!1,t.style.pointerEvents="none",o&&(o=!1,r.stopPropagation())}))}},{key:"textSelectingMode",value:function(t){var e=this,r=p(t).closest(".BRpagecontainer");t.style.pointerEvents="all",r.find("img").css("pointer-events","none"),p(t).off(".textSelectPluginHandler"),p(t).on("mousedown.textSelectPluginHandler",(function(t){e.mouseIsDown=!0,t.stopPropagation()})),p(t).on("mouseup.textSelectPluginHandler",(function(t){e.mouseIsDown=!1,t.stopPropagation()}))}},{key:"stopPageFlip",value:function(t){var e=this,r=t.find(".BRtextLayer");r.length&&(r.each((function(t,r){return e.defaultMode(r)})),this.interceptCopy(t))}},{key:"createTextLayer",value:(e=O(j().mark((function t(e){var r,o,i,a,c,l,u,s,f,h,d,y,v,g,m,b,w,E,P,k,O,R,L,C,A=this;return j().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.page.index,!(o=e.$container).find(".BRtextLayer").length){t.next=5;break}return t.abrupt("return");case 5:return t.next=7,this.getPageText(r);case 7:if(i=t.sent){t.next=10;break}return t.abrupt("return");case 10:if(U(i),!((a=p(i).find("WORD").length)>this.maxWordRendered)){t.next=15;break}return console.log("Page ".concat(r," has too many words (").concat(a," > ").concat(this.maxWordRendered,"). Not rendering text layer.")),t.abrupt("return");case 15:c=(0,n.RS)(e.page,"BRtextLayer"),l=parseFloat(e.$container[0].style.width)/e.page.width,u=parseFloat(e.$container[0].style.height)/e.page.height,c.style.transform="scale(".concat(l,", ").concat(u,")"),c.setAttribute("dir",this.rtl?"rtl":"ltr"),s=p(i).find("PARAGRAPH[coords]").toArray(),f=s.map((function(t){var e=A.renderParagraph(t);return c.appendChild(e),e})),h=F(c,".BRparagraphElement"),d=0,y=S(G(s,f));try{for(y.s();!(v=y.n()).done;)g=x(v.value,2),m=g[0],b=g[1],w=p(m).attr("coords").split(",").map(parseFloat),E=h.get(b),P=x(w,4),k=P[0],O=P[2],R=P[3],L=this.rtl?E.right-O:k-E.left,C=R-(E.top+d),b.style[this.rtl?"marginRight":"marginLeft"]="".concat(L,"px"),b.style.marginTop="".concat(C,"px"),d+=C,c.appendChild(b)}catch(t){y.e(t)}finally{y.f()}o.append(c),this.stopPageFlip(o);case 28:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"renderParagraph",value:function(t){var e=document.createElement("p");e.classList.add("BRparagraphElement");var r=x(p(t).attr("coords").split(",").map(parseFloat),4),n=r[0],o=r[1],i=r[2],a=r[3],c=[],l=p(t).find("LINE[coords]").toArray();if(!l.length)return e;var u,s=S(W(N(l,M)));try{for(s.s();!(u=s.n()).done;){var f=x(u.value,3),h=f[0],d=f[1],y=f[2],v=d.ocrElement==l[l.length-1],g=document.createElement("span");g.classList.add("BRlineElement");var m,b=S(d.words.entries());try{for(b.s();!(m=b.n()).done;){var w=x(m.value,2),j=w[0],k=w[1],O=x(p(k).attr("coords").split(",").map(parseFloat),4),R=O[1],L=O[2],C=O[3],A=R-C;if(c.push(A),0==j&&null!=h&&h.lastWord.textContent.trim().endsWith("-")){var _=x(p((y||h).firstWord).attr("coords").split(",").map(parseFloat),3)[0];p(k).attr("coords","".concat(_,",").concat(R,",").concat(L,",").concat(C))}var B=document.createElement("span");if(B.setAttribute("class","BRwordElement"),B.textContent=k.textContent.trim(),j>0){var T=document.createElement("span");T.classList.add("BRspace"),T.textContent=" ",g.append(T),g.appendChild(document.createTextNode(" "))}g.appendChild(B)}}catch(t){b.e(t)}finally{b.f()}var I=d.lastWord.textContent.trim().endsWith("-"),D=g.children[g.children.length-1];I&&!v&&(D.textContent=D.textContent.trim().slice(0,-1),D.classList.add("BRwordElement--hyphen")),e.appendChild(g),v||I||e.appendChild(document.createTextNode(" "))}}catch(t){s.e(t)}finally{s.f()}c.sort((function(t,e){return t-e}));var U=c[Math.floor(.85*c.length)]+4;e.style.left="".concat(n,"px"),e.style.top="".concat(a,"px"),e.style.width="".concat(i-n,"px"),e.style.height="".concat(o-a,"px"),e.style.fontSize="".concat(U,"px");var H,X=F(e,".BRwordElement"),$=S(G(p(t).find("WORD").toArray(),e.querySelectorAll(".BRwordElement")));try{for($.s();!(H=$.n()).done;){var q=x(H.value,2),z=q[0],V=q[1],Y=X.get(V),J=x(p(z).attr("coords").split(",").map(parseFloat),3),K=J[0],Q=J[2]-K;z.textContent.endsWith(" ")&&(Q=Q*(z.textContent.length-1)/z.textContent.length);var Z=Q-Y.width;V.style.letterSpacing="".concat(Z/(z.textContent.length-1),"px")}}catch(t){$.e(t)}finally{$.f()}X=F(e,".BRwordElement");var tt,et,rt=F(e,".BRspace"),nt=p(t).find("LINE[coords]").toArray(),ot=Array.from(e.querySelectorAll(".BRlineElement")),it=a,at=S(G(nt,ot));try{for(at.s();!(tt=at.n()).done;){var ct,lt=x(tt.value,2),ut=lt[0],st=lt[1],ft=p(ut).find("WORD").toArray(),ht=this.rtl?i:n,pt=S(G(ft,st.querySelectorAll(".BRwordElement")));try{for(pt.s();!(ct=pt.n()).done;){var dt=x(ct.value,2),yt=dt[0],vt=dt[1],gt=X.get(vt),mt=x(p(yt).attr("coords").split(",").map(parseFloat),3),bt=mt[0],wt=mt[2],xt=this.rtl?-(wt-ht):bt-ht;if(vt.previousElementSibling){var St=vt.previousElementSibling;St.style.letterSpacing="".concat(xt-rt.get(St).width,"px")}else vt.style[this.rtl?"paddingRight":"paddingLeft"]="".concat(xt,"px");this.rtl?ht-=xt+gt.width:ht+=xt+gt.width}}catch(t){pt.e(t)}finally{pt.f()}var Et=Math.min.apply(Math,function(t){if(Array.isArray(t))return P(t)}(et=ft.map((function(t){return parseFloat(p(t).attr("coords").split(",")[3])})))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(et)||E(et)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())-it;st.previousElementSibling&&(st.previousElementSibling.style.lineHeight="".concat(Et,"px"),it+=Et)}}catch(t){at.e(t)}finally{at.f()}return ot[ot.length-1].style.lineHeight="".concat(o-it,"px"),e.appendChild(document.createElement("br")),e}}]),t}(),D=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&b(t,e)}(o,t);var e,r,n=(e=o,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,n=w(e);if(r){var o=w(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return function(t,e){if(e&&("object"===d(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function o(){return R(this,o),n.apply(this,arguments)}return C(o,[{key:"init",value:function(){var t=this,e=Object.assign({},B,this.options.plugins.textSelection);e.enabled&&(this.textSelectionPlugin=new I(e,this.options.vars,this.pageProgression),this.options.plugins.textSelection=e,this.textSelectionPlugin.init(),new u(".BRtextLayer",(function(e){var r;"started"==e&&(null===(r=t.archiveAnalyticsSendEvent)||void 0===r||r.call(t,"BookReader","SelectStart"),t.refs.$br.find(".BRpagecontainer--hasSelection").removeClass("BRpagecontainer--hasSelection"),p(window.getSelection().anchorNode).closest(".BRpagecontainer").addClass("BRpagecontainer--hasSelection"))})).attach()),m(w(o.prototype),"init",this).call(this)}},{key:"_createPageContainer",value:function(t){var e,r=m(w(o.prototype),"_createPageContainer",this).call(this,t);return this.mode!==this.constModeThumb&&r.page&&(null===(e=this.textSelectionPlugin)||void 0===e||e.createTextLayer(r)),r}}]),o}(_);function F(t,e){var r={position:t.style.position,visibility:t.style.visibility,top:t.style.top,left:t.style.left,transform:t.style.transform};t.style.position="absolute",t.style.visibility="hidden",t.style.top="0",t.style.left="0",t.style.transform="none",document.body.appendChild(t);var n=new Map(Array.from(t.querySelectorAll(e)).map((function(t){var e=t.getBoundingClientRect();return[t,new H(e.left+window.scrollX,e.top+window.scrollY,e.width,e.height)]})));return document.body.removeChild(t),Object.assign(t.style,r),n}function M(t){var e=p(t).find("WORD").toArray();return{ocrElement:t,words:e,firstWord:e[0],lastWord:e[e.length-1]}}function N(t,e){var r,n,o;return j().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:r=S(t),i.prev=1,r.s();case 3:if((n=r.n()).done){i.next=9;break}return o=n.value,i.next=7,e(o);case 7:i.next=3;break;case 9:i.next=14;break;case 11:i.prev=11,i.t0=i.catch(1),r.e(i.t0);case 14:return i.prev=14,r.f(),i.finish(14);case 17:case"end":return i.stop()}}),y,null,[[1,11,14,17]])}function W(t){var e,r,n,o,i,a;return j().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:e=void 0,r=void 0,n=void 0,o=S(t),c.prev=4,o.s();case 6:if((i=o.n()).done){c.next=17;break}if(a=i.value,void 0===r){c.next=12;break}return n=a,c.next=12,[e,r,n];case 12:e=r,r=a,n=void 0;case 15:c.next=6;break;case 17:c.next=22;break;case 19:c.prev=19,c.t0=c.catch(4),o.e(c.t0);case 22:return c.prev=22,o.f(),c.finish(22);case 25:if(void 0===r){c.next=28;break}return c.next=28,[e,r,n];case 28:case"end":return c.stop()}}),v,null,[[4,19,22,25]])}function G(t,e){var r,n,o,i;return j().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:r=t[Symbol.iterator](),n=e[Symbol.iterator]();case 2:if(o=r.next(),i=n.next(),!o.done||!i.done){a.next=7;break}return a.abrupt("return");case 7:if(!o.done&&!i.done){a.next=9;break}throw new Error("zip: one of the iterators is done");case 9:return a.next=11,[o.value,i.value];case 11:a.next=2;break;case 13:case"end":return a.stop()}}),g)}function U(t){if(!p(t).attr("coords")&&t.children){var e=p(t).children().toArray();if(0!==e.length){var r,n=S(e);try{for(n.s();!(r=n.n()).done;)U(r.value)}catch(t){n.e(t)}finally{n.f()}var o,i=[],a=S(e);try{for(a.s();!(o=a.n()).done;){var c=o.value;p(c).attr("coords")&&i.push(p(c).attr("coords").split(",").map(parseFloat))}}catch(t){a.e(t)}finally{a.f()}var l=function(t){var e,r=1/0,n=-1/0,o=-1/0,i=1/0,a=S(t);try{for(a.s();!(e=a.n()).done;){var c=x(e.value,4),l=c[0],u=c[1],s=c[2],f=c[3];r=Math.min(r,l),n=Math.max(n,u),o=Math.max(o,s),i=Math.min(i,f)}}catch(t){a.e(t)}finally{a.f()}return[r,n,o,i]}(i);Math.abs(l[0])!=1/0&&p(t).attr("coords",l.join(","))}}}window.BookReader=D;var H=function(){function t(e,r,n,o){R(this,t),this.x=e,this.y=r,this.width=n,this.height=o}return C(t,[{key:"right",get:function(){return this.x+this.width}},{key:"bottom",get:function(){return this.y+this.height}},{key:"top",get:function(){return this.y}},{key:"left",get:function(){return this.x}}]),t}()},2814:function(t,e,r){var n=r(7854),o=r(7293),i=r(1702),a=r(1340),c=r(3111).trim,l=r(1361),u=i("".charAt),s=n.parseFloat,f=n.Symbol,h=f&&f.iterator,p=1/s(l+"-0")!=-1/0||h&&!o((function(){s(Object(h))}));t.exports=p?function(t){var e=c(a(t)),r=s(e);return 0===r&&"-"==u(e,0)?-0:r}:s},6091:function(t,e,r){var n=r(6530).PROPER,o=r(7293),i=r(1361);t.exports=function(t){return o((function(){return!!i[t]()||"​…᠎"!=="​…᠎"[t]()||n&&i[t].name!==t}))}},4678:function(t,e,r){var n=r(2109),o=r(2814);n({global:!0,forced:parseFloat!=o},{parseFloat:o})},3210:function(t,e,r){"use strict";var n=r(2109),o=r(3111).trim;n({target:"String",proto:!0,forced:r(6091)("trim")},{trim:function(){return o(this)}})}},function(t){t(t.s=4742)}]);
2
3
  //# sourceMappingURL=plugin.text_selection.js.map
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */