@internetarchive/bookreader 5.0.0-8 → 5.0.0-80
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +17 -15
- package/.github/workflows/node.js.yml +73 -10
- package/.github/workflows/npm-publish.yml +6 -20
- package/.testcaferc.js +10 -0
- package/BookReader/BookReader.css +398 -1133
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.LICENSE.txt +20 -20
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +1782 -0
- package/BookReader/ia-bookreader-bundle.js.LICENSE.txt +7 -0
- package/BookReader/ia-bookreader-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -1
- package/BookReader/icons/2up.svg +1 -1
- package/BookReader/icons/advance.svg +1 -1
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -1
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +1 -1
- package/BookReader/icons/fullscreen_exit.svg +1 -1
- package/BookReader/icons/hamburger.svg +1 -1
- package/BookReader/icons/left-arrow.svg +1 -1
- package/BookReader/icons/magnify-minus.svg +1 -1
- package/BookReader/icons/magnify-plus.svg +1 -1
- package/BookReader/icons/magnify.svg +1 -1
- package/BookReader/icons/pause.svg +1 -1
- package/BookReader/icons/play.svg +1 -1
- package/BookReader/icons/playback-speed.svg +1 -1
- package/BookReader/icons/read-aloud.svg +1 -1
- package/BookReader/icons/review.svg +1 -1
- package/BookReader/icons/thumbnails.svg +1 -1
- package/BookReader/icons/voice.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -1
- package/BookReader/images/BRicons.svg +3 -3
- package/BookReader/images/books_graphic.svg +1 -1
- package/BookReader/images/icon_book.svg +1 -1
- package/BookReader/images/icon_bookmark.svg +1 -1
- package/BookReader/images/icon_gear.svg +1 -1
- package/BookReader/images/icon_hamburger.svg +1 -1
- package/BookReader/images/icon_home.svg +1 -1
- package/BookReader/images/icon_info.svg +1 -1
- package/BookReader/images/icon_one_page.svg +1 -1
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +1 -1
- package/BookReader/images/icon_search_button.svg +1 -1
- package/BookReader/images/icon_share.svg +1 -1
- package/BookReader/images/icon_skip-ahead.svg +1 -1
- package/BookReader/images/icon_skip-back.svg +1 -1
- package/BookReader/images/icon_speaker.svg +1 -1
- package/BookReader/images/icon_speaker_open.svg +1 -1
- package/BookReader/images/icon_thumbnails.svg +1 -1
- package/BookReader/images/icon_toc.svg +1 -1
- package/BookReader/images/icon_two_pages.svg +1 -1
- package/BookReader/images/marker_chap-off.svg +1 -1
- package/BookReader/images/marker_chap-on.svg +1 -1
- package/BookReader/images/marker_srch-on.svg +1 -1
- package/BookReader/jquery-3.js +2 -0
- package/BookReader/jquery-3.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +25 -1
- package/BookReader/plugins/plugin.chapters.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +2 -0
- package/BookReader/plugins/plugin.iiif.js.map +1 -0
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +2 -1
- package/BookReader/plugins/plugin.search.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +2 -1
- package/BookReader/plugins/plugin.text_selection.js.LICENSE.txt +1 -0
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +2 -0
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +3 -0
- package/BookReader/webcomponents-bundle.js.LICENSE.txt +9 -0
- package/BookReader/webcomponents-bundle.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +18 -19
- package/BookReaderDemo/BookReaderJSAdvanced.js +0 -3
- package/BookReaderDemo/BookReaderJSAutoplay.js +4 -1
- package/BookReaderDemo/BookReaderJSSimple.js +1 -0
- package/BookReaderDemo/IADemoBr.js +147 -0
- package/BookReaderDemo/demo-advanced.html +2 -2
- package/BookReaderDemo/demo-autoplay.html +2 -3
- package/BookReaderDemo/demo-embed-iframe-src.html +2 -1
- package/BookReaderDemo/demo-fullscreen-mobile.html +3 -5
- package/BookReaderDemo/demo-fullscreen.html +2 -4
- package/BookReaderDemo/demo-iiif.html +99 -12
- package/BookReaderDemo/demo-internetarchive.html +214 -18
- package/BookReaderDemo/demo-multiple.html +2 -1
- package/BookReaderDemo/demo-preview-pages.html +2 -1
- package/BookReaderDemo/demo-simple.html +2 -1
- package/BookReaderDemo/demo-vendor-fullscreen.html +2 -4
- package/BookReaderDemo/ia-multiple-volumes-manifest.js +170 -0
- package/BookReaderDemo/immersion-1up.html +2 -2
- package/BookReaderDemo/immersion-mode.html +2 -4
- package/BookReaderDemo/toggle_controls.html +3 -2
- package/BookReaderDemo/view_mode.html +2 -1
- package/BookReaderDemo/viewmode-cycle.html +2 -3
- package/CHANGELOG.md +536 -33
- package/README.md +14 -1
- package/babel.config.js +20 -0
- package/codecov.yml +6 -0
- package/index.html +4 -1
- package/jsconfig.json +19 -0
- package/netlify.toml +9 -0
- package/package.json +70 -60
- package/renovate.json +52 -0
- package/scripts/preversion.js +0 -1
- package/src/BookNavigator/assets/bookmark-colors.js +1 -1
- package/src/BookNavigator/assets/button-base.js +4 -2
- package/src/BookNavigator/assets/ia-logo.js +17 -0
- package/src/BookNavigator/assets/icon_checkmark.js +1 -1
- package/src/BookNavigator/assets/icon_close.js +1 -1
- package/src/BookNavigator/book-navigator.js +590 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +3 -2
- package/src/BookNavigator/bookmarks/bookmark-edit.js +3 -4
- package/src/BookNavigator/bookmarks/bookmarks-list.js +2 -3
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +3 -8
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +27 -17
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +116 -67
- package/src/BookNavigator/delete-modal-actions.js +1 -1
- package/src/BookNavigator/downloads/downloads-provider.js +36 -21
- package/src/BookNavigator/downloads/downloads.js +41 -25
- package/src/BookNavigator/search/search-provider.js +49 -27
- package/src/BookNavigator/search/search-results.js +23 -9
- package/src/BookNavigator/sharing.js +27 -0
- package/src/BookNavigator/viewable-files.js +95 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +11 -10
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +3 -3
- package/src/BookReader/BookModel.js +64 -34
- package/src/BookReader/DragScrollable.js +233 -0
- package/src/BookReader/Mode1Up.js +56 -351
- package/src/BookReader/Mode1UpLit.js +388 -0
- package/src/BookReader/Mode2Up.js +73 -1318
- package/src/BookReader/Mode2UpLit.js +776 -0
- package/src/BookReader/ModeCoordinateSpace.js +29 -0
- package/src/BookReader/ModeSmoothZoom.js +312 -0
- package/src/BookReader/ModeThumb.js +18 -12
- package/src/BookReader/Navbar/Navbar.js +14 -40
- package/src/BookReader/PageContainer.js +81 -6
- package/src/BookReader/ReduceSet.js +1 -1
- package/src/BookReader/Toolbar/Toolbar.js +10 -37
- package/src/BookReader/events.js +2 -3
- package/src/BookReader/options.js +27 -2
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/ScrollClassAdder.js +31 -0
- package/src/BookReader/utils/SelectionObserver.js +45 -0
- package/src/BookReader/utils.js +118 -13
- package/src/BookReader.js +427 -1061
- package/src/assets/icons/magnify-minus.svg +3 -7
- package/src/assets/icons/magnify-plus.svg +3 -7
- package/src/assets/icons/voice.svg +1 -0
- package/src/css/BookReader.scss +1 -5
- package/src/css/_BRBookmarks.scss +1 -1
- package/src/css/_BRComponent.scss +1 -1
- package/src/css/_BRmain.scss +16 -3
- package/src/css/_BRnav.scss +12 -39
- package/src/css/_BRpages.scss +149 -40
- package/src/css/_BRsearch.scss +68 -25
- package/src/css/_BRtoolbar.scss +5 -5
- package/src/css/_TextSelection.scss +87 -27
- package/src/css/_colorbox.scss +2 -2
- package/src/css/_controls.scss +20 -7
- package/src/css/_icons.scss +1 -1
- package/src/ia-bookreader/ia-bookreader.js +224 -0
- package/src/plugins/plugin.archive_analytics.js +3 -3
- package/src/plugins/plugin.autoplay.js +5 -11
- package/src/plugins/plugin.chapters.js +237 -191
- package/src/plugins/plugin.iiif.js +151 -0
- package/src/plugins/plugin.resume.js +3 -3
- package/src/plugins/plugin.text_selection.js +464 -134
- package/src/plugins/plugin.vendor-fullscreen.js +4 -4
- package/src/plugins/search/plugin.search.js +142 -125
- package/src/plugins/search/utils.js +43 -0
- package/src/plugins/search/view.js +33 -58
- package/src/plugins/tts/AbstractTTSEngine.js +71 -40
- package/src/plugins/tts/FestivalTTSEngine.js +13 -14
- package/src/plugins/tts/PageChunk.js +15 -21
- package/src/plugins/tts/PageChunkIterator.js +8 -12
- package/src/plugins/tts/WebTTSEngine.js +87 -71
- package/src/plugins/tts/plugin.tts.js +96 -127
- package/src/plugins/tts/utils.js +15 -25
- package/src/plugins/url/UrlPlugin.js +191 -0
- package/src/plugins/{plugin.url.js → url/plugin.url.js} +45 -16
- package/src/util/browserSniffing.js +22 -0
- package/src/util/docCookies.js +21 -2
- package/tests/e2e/README.md +37 -0
- package/tests/e2e/autoplay.test.js +2 -2
- package/tests/e2e/base.test.js +8 -16
- package/tests/e2e/helpers/base.js +53 -48
- package/tests/e2e/helpers/debug.js +1 -1
- package/tests/e2e/helpers/params.js +17 -0
- package/tests/e2e/helpers/rightToLeft.js +8 -14
- package/tests/e2e/helpers/search.js +73 -0
- package/tests/e2e/models/Navigation.js +20 -37
- package/tests/e2e/rightToLeft.test.js +4 -5
- package/tests/e2e/viewmode.test.js +40 -33
- package/tests/jest/BookNavigator/book-navigator.test.js +661 -0
- package/tests/jest/BookNavigator/bookmarks/bookmark-button.test.js +43 -0
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmark-edit.test.js +25 -26
- package/tests/{karma → jest}/BookNavigator/bookmarks/bookmarks-list.test.js +41 -42
- package/tests/jest/BookNavigator/bookmarks/ia-bookmarks.test.js +45 -0
- package/tests/jest/BookNavigator/downloads/downloads-provider.test.js +67 -0
- package/tests/jest/BookNavigator/downloads/downloads.test.js +53 -0
- package/tests/jest/BookNavigator/search/search-provider.test.js +167 -0
- package/tests/{karma → jest}/BookNavigator/search/search-results.test.js +109 -60
- package/tests/jest/BookNavigator/sharing/sharing-provider.test.js +49 -0
- package/tests/jest/BookNavigator/viewable-files/viewable-files-provider.test.js +80 -0
- package/tests/jest/BookNavigator/visual-adjustments.test.js +200 -0
- package/tests/{BookReader → jest/BookReader}/BookModel.test.js +74 -14
- package/tests/jest/BookReader/BookReaderPublicFunctions.test.js +193 -0
- package/tests/{BookReader → jest/BookReader}/ImageCache.test.js +4 -4
- package/tests/jest/BookReader/Mode1UpLit.test.js +73 -0
- package/tests/jest/BookReader/Mode2Up.test.js +98 -0
- package/tests/jest/BookReader/Mode2UpLit.test.js +190 -0
- package/tests/jest/BookReader/ModeCoordinateSpace.test.js +16 -0
- package/tests/jest/BookReader/ModeSmoothZoom.test.js +218 -0
- package/tests/jest/BookReader/ModeThumb.test.js +71 -0
- package/tests/{BookReader → jest/BookReader}/Navbar/Navbar.test.js +10 -10
- package/tests/{BookReader → jest/BookReader}/PageContainer.test.js +88 -6
- package/tests/{BookReader → jest/BookReader}/ReduceSet.test.js +1 -1
- package/tests/{BookReader → jest/BookReader}/Toolbar/Toolbar.test.js +2 -2
- package/tests/jest/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/jest/BookReader/utils/ScrollClassAdder.test.js +49 -0
- package/tests/jest/BookReader/utils/SelectionObserver.test.js +57 -0
- package/tests/{BookReader → jest/BookReader}/utils/classes.test.js +1 -1
- package/tests/jest/BookReader/utils.test.js +229 -0
- package/tests/jest/BookReader.keyboard.test.js +190 -0
- package/tests/{BookReader.options.test.js → jest/BookReader.options.test.js} +9 -1
- package/tests/{BookReader.test.js → jest/BookReader.test.js} +26 -37
- package/tests/{plugins → jest/plugins}/plugin.archive_analytics.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.autoplay.test.js +4 -4
- package/tests/jest/plugins/plugin.chapters.test.js +195 -0
- package/tests/{plugins → jest/plugins}/plugin.iframe.test.js +2 -2
- package/tests/{plugins → jest/plugins}/plugin.resume.test.js +3 -3
- package/tests/jest/plugins/plugin.text_selection.test.js +317 -0
- package/tests/{plugins → jest/plugins}/plugin.vendor-fullscreen.test.js +2 -2
- package/tests/{plugins → jest/plugins}/search/plugin.search.test.js +25 -47
- package/tests/{plugins → jest/plugins}/search/plugin.search.view.test.js +39 -6
- package/tests/jest/plugins/search/utils.js +25 -0
- package/tests/jest/plugins/search/utils.test.js +29 -0
- package/tests/{plugins → jest/plugins}/tts/AbstractTTSEngine.test.js +29 -9
- package/tests/{plugins → jest/plugins}/tts/FestivalTTSEngine.test.js +4 -4
- package/tests/{plugins → jest/plugins}/tts/PageChunk.test.js +1 -1
- package/tests/{plugins → jest/plugins}/tts/PageChunkIterator.test.js +3 -3
- package/tests/{plugins → jest/plugins}/tts/WebTTSEngine.test.js +47 -1
- package/tests/{plugins → jest/plugins}/tts/utils.test.js +1 -60
- package/tests/jest/plugins/url/UrlPlugin.test.js +198 -0
- package/tests/{plugins → jest/plugins/url}/plugin.url.test.js +53 -14
- package/tests/jest/setup.js +3 -0
- package/tests/{util → jest/util}/browserSniffing.test.js +1 -1
- package/tests/jest/util/docCookies.test.js +24 -0
- package/tests/{util → jest/util}/strings.test.js +1 -1
- package/tests/{utils.js → jest/utils.js} +38 -0
- package/webpack.config.js +12 -6
- package/.babelrc +0 -12
- package/.dependabot/config.yml +0 -6
- package/.testcaferc.json +0 -5
- package/BookReader/bookreader-component-bundle.js +0 -1450
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -38
- package/BookReader/bookreader-component-bundle.js.map +0 -1
- package/BookReader/jquery-1.10.1.js +0 -2
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
- package/BookReader/plugins/plugin.menu_toggle.js +0 -2
- package/BookReader/plugins/plugin.menu_toggle.js.map +0 -1
- package/BookReader/plugins/plugin.mobile_nav.js +0 -2
- package/BookReader/plugins/plugin.mobile_nav.js.map +0 -1
- package/BookReaderDemo/IIIFBookReader.js +0 -207
- package/BookReaderDemo/bookreader-template-bundle.js +0 -7178
- package/BookReaderDemo/demo-iiif.js +0 -26
- package/BookReaderDemo/demo-plugin-menu-toggle.html +0 -34
- package/karma.conf.js +0 -23
- package/src/BookNavigator/BookModel.js +0 -14
- package/src/BookNavigator/BookNavigator.js +0 -446
- package/src/BookNavigator/assets/book-loader.js +0 -27
- package/src/BookNavigator/br-fullscreen-mgr.js +0 -83
- package/src/BookNavigator/search/a-search-result.js +0 -55
- package/src/BookReader/DebugConsole.js +0 -54
- package/src/BookReaderComponent/BookReaderComponent.js +0 -112
- package/src/ItemNavigator/ItemNavigator.js +0 -376
- package/src/ItemNavigator/providers/sharing.js +0 -29
- package/src/css/_MobileNav.scss +0 -194
- package/src/dragscrollable-br.js +0 -261
- package/src/lit-wrapper.js +0 -2
- package/src/plugins/menu_toggle/plugin.menu_toggle.js +0 -324
- package/src/plugins/plugin.mobile_nav.js +0 -287
- package/tests/BookReader/BookReaderPublicFunctions.test.js +0 -171
- package/tests/BookReader/DebugConsole.test.js +0 -25
- package/tests/BookReader/Mode1Up.test.js +0 -164
- package/tests/BookReader/Mode2Up.test.js +0 -247
- package/tests/BookReader/utils.test.js +0 -109
- package/tests/e2e/helpers/desktopSearch.js +0 -72
- package/tests/e2e/helpers/mobileSearch.js +0 -85
- package/tests/e2e/ia-production/ia-prod-base.js +0 -17
- package/tests/karma/BookNavigator/book-navigator.test.js +0 -132
- package/tests/karma/BookNavigator/search/search-provider.test.js +0 -23
- package/tests/karma/BookNavigator/visual-adjustments.test.js +0 -201
- package/tests/plugins/menu_toggle/plugin.menu_toggle.test.js +0 -68
- package/tests/plugins/plugin.chapters.test.js +0 -130
- package/tests/plugins/plugin.mobile_nav.test.js +0 -66
- package/tests/plugins/plugin.text_selection.test.js +0 -203
- package/tests/util/docCookies.test.js +0 -15
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"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/inherit-if-required.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.object.assign.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.regexp.constructor.js"],"names":["super_","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","leafNumToIndex","pageNumber","getPageNum","percentThrough","constructor","util","cssPercentage","getNumLeafs","queryStringWithB","replace","queryStringWithBTruncated","addClass","left","append","data","appendTo","hover","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","x","style","setProperty","removeClass","target","_searchPluginGoToResult","updateSearchHilites","showProgressPopup","progressPopupClosed","removeProgressPopup","toggleSearchPending","textIsProcessing","errorDetails","renderModalMessage","delayModalRemovalFor","messageHTML","modal","el","timeoutMS","setTimeout","e","preventDefault","value","search","results","options","renderSearchNavigation","bindSearchNavigationEvents","renderPins","goToFirstResult","one","is_visible","navigationIsVisible","togglePinsFor","removeSearchHilites","searchTerm","isIndexed","detail","props","indexed","renderErrorModal","renderBookNotIndexedModal","renderResultsEmptyModal","window","addEventListener","handleSearchCallbackError","handleSearchCallback","handleNavToggledCallback","handleSearchStarted","handleSearchCallbackBookNotIndexed","handleSearchCallbackEmpty","updateSearchNavigation","submitHandler","jQuery","extend","BookReader","defaultOptions","server","bookId","subPrefix","bookPath","enableSearch","searchInsideUrl","initialSearchTerm","prototype","setup","call","searchResults","searchXHR","_cancelSearch","cancelSearchRequest","searchView","SearchView","term","instance","init","suppressFragmentChange","buildToolbarElement","$el","after","overrides","disablePopup","error","success","eventNames","fragmentChange","serverPath","baseUrl","path","subPrefixWithSlash","lastIndexOf","substr","urlParams","item_id","doc","q","paramStr","param","url","cleanup","BRSearchInProgress","processSearchResults","searchInsideResults","responseHasError","hasCustomError","hasCustomSuccess","BRSearchCallbackError","BRSearchCallback","beforeSend","xhr","ajax","dataType","jsonpCallback","then","abort","_BRSearchCallbackError","basePayload","payload","Object","assign","updateSearchHilites1UP","updateSearchHilites2UP","boxes","box","inArray","displayedIndices","div","prop","_models","book","getPage","highlight","width","_modes","mode1Up","physicalInchesToDisplayPixels","r","l","ppi","height","b","t","top","pageIsInView","isViewable","$brTwoPageView","setHilightCss2UP","makeUnviewableAtEnd","fetch","URLSearchParams","id","subprefix","leafNum","json","resp","makeViewable","jumpToIndex","searchHighlightVisible","visiblePages","twoPage","currentIndexL","currentIndexR","some","isObject","setPrototypeOf","module","exports","$this","dummy","Wrapper","NewTarget","NewTargetPrototype","stat","forced","DESCRIPTORS","global","isForced","inheritIfRequired","defineProperty","getOwnPropertyNames","isRegExp","getFlags","stickyHelpers","redefine","fails","enforceInternalState","setSpecies","MATCH","wellKnownSymbol","NativeRegExp","RegExpPrototype","re1","re2","CORRECT_NEW","UNSUPPORTED_Y","RegExpWrapper","pattern","flags","sticky","thisIsRegExp","patternIsRegExp","flagsAreUndefined","undefined","source","result","proxy","key","configurable","get","set","it","keys","index"],"mappings":"6fAsCwCA,ECkZxC,E,WA/aE,cAAwD,IAA1CC,EAA0C,EAA1CA,GAA0C,IAAtCC,+BAAsC,MAAZ,aAAY,G,4FAAA,SACtDC,KAAKF,GAAKA,EAKVE,KAAKC,QAAU,IAAIC,OAAO,cAAe,KACzCF,KAAKG,QAAU,GACfH,KAAKI,mBACLJ,KAAKK,aACLL,KAAKM,aAAeP,E,qDAGtB,WACEC,KAAKO,IAAM,GAEXP,KAAKO,IAAIC,cAAgBR,KAAKS,uB,sBAMhC,SAASC,GACPV,KAAKF,GAAGa,EAAE,kBAAkBC,IAAIF,K,0BAGlC,WACEV,KAAKG,QAAU,K,8BAGjB,WACEH,KAAKF,GAAGa,EAAE,uBAAuBE,W,wCAGnC,WAA6D,IAAlCC,IAAkC,yDAC3Dd,KAAKF,GAAGiB,sBACRf,KAAKgB,mBACLhB,KAAKiB,eACLjB,KAAKkB,SAAS,IACdlB,KAAKmB,2BACDL,GACFd,KAAKF,GAAGsB,QAAQ,0B,2BAIpB,WACEpB,KAAKF,GAAGsB,QAAQ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MACvCtB,EAAgBvN,YAAc4N,EAC9BA,EAAcnI,UAAY8H,EAC1BP,EAASR,EAAQ,SAAUoB,GAI7BT,EAAW,Y","file":"plugins/plugin.search.js","sourcesContent":["/* 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 SearchView from './view.js';\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 this.goToFirstResult = false;\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 if (this.searchView) { return; }\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 };\n})(BookReader.prototype.setup);\n\n/** @override */\nBookReader.prototype.init = (function (super_) {\n return function () {\n super_.call(this);\n\n if (this.options.enableSearch && this.options.initialSearchTerm) {\n this.search(\n this.options.initialSearchTerm,\n { goToFirstResult: this.goToFirstResult, suppressFragmentChange: true }\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/**\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 = 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\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 cleanup = () => {\n this.searchXHR = null\n window.BRSearchInProgress = () => {};\n };\n\n const processSearchResults = (searchInsideResults) => {\n if (!this.searchXHR) {\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 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 cleanup();\n };\n\n const beforeSend = (xhr) => {\n this.searchXHR = xhr;\n window.BRSearchInProgress = processSearchResults;\n };\n\n this.trigger('SearchStarted', { term: this.searchTerm, instance: this });\n return $.ajax({\n url: url,\n dataType: 'jsonp',\n beforeSend,\n jsonpCallback: 'BRSearchInProgress'\n }).then(processSearchResults)\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.searchResults = [];\n window.BRSearchInProgress = () => {};\n}\n\n/**\n * External function to cancel search\n * checks for term & xhr in flight before running\n */\nBookReader.prototype.cancelSearchRequest = function () {\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 */\n\n/**\n * @typedef {object} SearchInsideMatch\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 * @callback\n * @param {SearchInsideResults} results\n * @param {object} options\n * @param {boolean} options.goToFirstResult\n */\nBookReader.prototype.BRSearchCallback = function(results, options) {\n this.searchResults = results || [];\n\n this.updateSearchHilites();\n this.removeProgressPopup();\n if (options.goToFirstResult) {\n this._searchPluginGoToResult(results.matches[0].par[0].page);\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 if (this.constMode2up == this.mode) {\n this.updateSearchHilites2UP();\n return;\n }\n this.updateSearchHilites1UP();\n};\n\n/**\n * update search on-page highlights in 1up mode\n */\nBookReader.prototype.updateSearchHilites1UP = function() {\n const results = this.searchResults;\n if (null == results) return;\n results.matches?.forEach(match => {\n match.par[0].boxes.forEach(box => {\n const pageIndex = this.leafNumToIndex(box.page);\n const pageIsInView = jQuery.inArray(pageIndex, this.displayedIndices) >= 0;\n if (pageIsInView) {\n if (!box.div) {\n //create a div for the search highlight, and stash it in the box object\n box.div = document.createElement('div');\n $(box.div).prop('className', 'BookReaderSearchHilite').appendTo(this.$(`.pagediv${pageIndex}`));\n }\n const page = this._models.book.getPage(pageIndex);\n const highlight = {\n width: this._modes.mode1Up.physicalInchesToDisplayPixels((box.r - box.l) / page.ppi),\n height: this._modes.mode1Up.physicalInchesToDisplayPixels((box.b - box.t) / page.ppi),\n left: this._modes.mode1Up.physicalInchesToDisplayPixels(box.l / page.ppi),\n top: this._modes.mode1Up.physicalInchesToDisplayPixels(box.t / page.ppi),\n };\n $(box.div).css(highlight);\n } else {\n if (box.div) {\n $(box.div).remove();\n box.div = null;\n }\n }\n });\n });\n};\n\n/**\n * update search on-page highlights in 2up mode\n */\nBookReader.prototype.updateSearchHilites2UP = function() {\n const results = this.searchResults;\n\n if (results === null) return;\n\n const { matches = [] } = results;\n matches.forEach((match) => {\n match.par[0].boxes.forEach(box => {\n const pageIndex = this.leafNumToIndex(match.par[0].page);\n const pageIsInView = jQuery.inArray(pageIndex, this.displayedIndices) >= 0;\n const { isViewable } = this._models.book.getPage(pageIndex);\n\n if (pageIsInView && isViewable) {\n if (!box.div) {\n //create a div for the search highlight, and stash it in the box object\n box.div = document.createElement('div');\n $(box.div).addClass('BookReaderSearchHilite')\n .appendTo(this.refs.$brTwoPageView);\n }\n this.setHilightCss2UP(box.div, pageIndex, box.l, box.r, box.t, box.b);\n } else {\n // clear stale reference\n if (box.div) {\n $(box.div).remove();\n box.div = null;\n }\n }\n });\n });\n};\n\n/**\n * remove search highlights\n */\nBookReader.prototype.removeSearchHilites = function() {\n const results = this.searchResults;\n if (null == results || !results.matches) { return; }\n results.matches.forEach(match => {\n match.par[0].boxes.forEach(box => {\n if (null != box.div) {\n $(box.div).remove();\n box.div = null;\n }\n });\n });\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 {PageIndex} pageIndex\n */\nBookReader.prototype._searchPluginGoToResult = async function (pageIndex) {\n const { book } = this._models;\n const page = book.getPage(pageIndex);\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 /* this updates the URL */\n this.suppressFragmentChange = false;\n this.jumpToIndex(pageIndex);\n\n // Reset it to unviewable if it wasn't resolved\n if (makeUnviewableAtEnd) {\n book.getPage(pageIndex).makeViewable(false);\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.leafNumToIndex(box.page);\n if (jQuery.inArray(pageIndex, visiblePages) >= 0) {\n return true;\n }\n });\n });\n\n return false;\n};\n","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\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');\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 this.dom.searchNavigation.find('[data-id=resultsCount]').text(this.resultsPosition());\n }\n\n updateSearchNavigationButtons() {\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.leafNumToIndex(match.par[0].page);\n const pageNumber = this.br.getPageNum(pageIndex);\n const uiStringSearch = \"Search result\"; // i18n\n const uiStringPage = \"Page\"; // i18n\n\n const percentThrough = this.br.constructor.util.cssPercentage(pageIndex, this.br.getNumLeafs() - 1);\n\n const queryStringWithB = queryString.replace(this.matcher, '<b>$1</b>');\n\n let queryStringWithBTruncated = '';\n\n if (queryString.length > 100) {\n queryStringWithBTruncated = queryString\n .replace(/^(.{100}[^\\s]*).*/, \"$1\")\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>${uiStringPage} ${pageNumber}</div>\n </div>\n `)\n .data({ pageIndex })\n .appendTo(this.br.$('.BRnavline'))\n .hover(\n (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 (event) => $(event.target).removeClass('front'))\n .click(function (event) {\n // closures are nested and deep, using an arrow function breaks references.\n // Todo: update to arrow function & clean up closures\n // to remove `bind` dependency\n this.br._searchPluginGoToResult(+$(event.target).data('pageIndex'));\n this.br.updateSearchHilites();\n }.bind(this));\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 /**\n * @param {Event} e\n */\n handleNavToggledCallback(e) {\n const is_visible = this.br.navigationIsVisible();\n this.togglePinsFor(is_visible);\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}navToggled`, this.handleNavToggledCallback.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 isObject = require('../internals/is-object');\nvar setPrototypeOf = require('../internals/object-set-prototype-of');\n\n// makes subclassing work correct for wrapped built-ins\nmodule.exports = function ($this, dummy, Wrapper) {\n var NewTarget, NewTargetPrototype;\n if (\n // it can work only with native `setPrototypeOf`\n setPrototypeOf &&\n // we haven't completely correct pre-ES6 way for getting `new.target`, so use this\n typeof (NewTarget = dummy.constructor) == 'function' &&\n NewTarget !== Wrapper &&\n isObject(NewTargetPrototype = NewTarget.prototype) &&\n NewTargetPrototype !== Wrapper.prototype\n ) setPrototypeOf($this, NewTargetPrototype);\n return $this;\n};\n","var $ = require('../internals/export');\nvar assign = require('../internals/object-assign');\n\n// `Object.assign` method\n// https://tc39.es/ecma262/#sec-object.assign\n// eslint-disable-next-line es/no-object-assign -- required for testing\n$({ target: 'Object', stat: true, forced: Object.assign !== assign }, {\n assign: assign\n});\n","var DESCRIPTORS = require('../internals/descriptors');\nvar global = require('../internals/global');\nvar isForced = require('../internals/is-forced');\nvar inheritIfRequired = require('../internals/inherit-if-required');\nvar defineProperty = require('../internals/object-define-property').f;\nvar getOwnPropertyNames = require('../internals/object-get-own-property-names').f;\nvar isRegExp = require('../internals/is-regexp');\nvar getFlags = require('../internals/regexp-flags');\nvar stickyHelpers = require('../internals/regexp-sticky-helpers');\nvar redefine = require('../internals/redefine');\nvar fails = require('../internals/fails');\nvar enforceInternalState = require('../internals/internal-state').enforce;\nvar setSpecies = require('../internals/set-species');\nvar wellKnownSymbol = require('../internals/well-known-symbol');\n\nvar MATCH = wellKnownSymbol('match');\nvar NativeRegExp = global.RegExp;\nvar RegExpPrototype = NativeRegExp.prototype;\nvar re1 = /a/g;\nvar re2 = /a/g;\n\n// \"new\" should create a new object, old webkit bug\nvar CORRECT_NEW = new NativeRegExp(re1) !== re1;\n\nvar UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;\n\nvar FORCED = DESCRIPTORS && isForced('RegExp', (!CORRECT_NEW || UNSUPPORTED_Y || fails(function () {\n re2[MATCH] = false;\n // RegExp constructor can alter flags and IsRegExp works correct with @@match\n return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i';\n})));\n\n// `RegExp` constructor\n// https://tc39.es/ecma262/#sec-regexp-constructor\nif (FORCED) {\n var RegExpWrapper = function RegExp(pattern, flags) {\n var thisIsRegExp = this instanceof RegExpWrapper;\n var patternIsRegExp = isRegExp(pattern);\n var flagsAreUndefined = flags === undefined;\n var sticky;\n\n if (!thisIsRegExp && patternIsRegExp && pattern.constructor === RegExpWrapper && flagsAreUndefined) {\n return pattern;\n }\n\n if (CORRECT_NEW) {\n if (patternIsRegExp && !flagsAreUndefined) pattern = pattern.source;\n } else if (pattern instanceof RegExpWrapper) {\n if (flagsAreUndefined) flags = getFlags.call(pattern);\n pattern = pattern.source;\n }\n\n if (UNSUPPORTED_Y) {\n sticky = !!flags && flags.indexOf('y') > -1;\n if (sticky) flags = flags.replace(/y/g, '');\n }\n\n var result = inheritIfRequired(\n CORRECT_NEW ? new NativeRegExp(pattern, flags) : NativeRegExp(pattern, flags),\n thisIsRegExp ? this : RegExpPrototype,\n RegExpWrapper\n );\n\n if (UNSUPPORTED_Y && sticky) {\n var state = enforceInternalState(result);\n state.sticky = true;\n }\n\n return result;\n };\n var proxy = function (key) {\n key in RegExpWrapper || defineProperty(RegExpWrapper, key, {\n configurable: true,\n get: function () { return NativeRegExp[key]; },\n set: function (it) { NativeRegExp[key] = it; }\n });\n };\n var keys = getOwnPropertyNames(NativeRegExp);\n var index = 0;\n while (keys.length > index) proxy(keys[index++]);\n RegExpPrototype.constructor = RegExpWrapper;\n RegExpWrapper.prototype = RegExpPrototype;\n redefine(global, 'RegExp', RegExpWrapper);\n}\n\n// https://tc39.es/ecma262/#sec-get-regexp-@@species\nsetSpecies('RegExp');\n"],"sourceRoot":""}
|
1
|
+
{"version":3,"file":"plugins/plugin.search.js","mappings":";4lC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,QAAQE,mBACpD,IAAIpb,KAAKyC,cAAgBzC,KAAKsC,KAGnC,OAAO,EAFP2Y,EAAe,CAACjb,KAAK2D,eAGvB,CAWA,OATAqF,EAAQ/I,QAAQob,MAAK,SAAA7V,GACnB,OAAOA,EAAM/B,IAAI,GAAGyQ,MAAMmH,MAAK,SAAAlD,GAC7B,IAAM1S,EAAYqC,EAAKpC,KAAKC,eAAewS,EAAIzU,MAC/C,GAAIyO,EAAOmJ,QAAQ7V,EAAWwV,IAAiB,EAC7C,OAAO,CAEX,GACF,KAEO,CACT,wBCpeA,IAAIta,EAAI,EAAQ,MACZ4a,EAAW,gBAIf5a,EAAE,CAAEgH,OAAQ,SAAU6T,MAAM,GAAQ,CAClCpE,QAAS,SAAiBqE,GACxB,OAAOF,EAASE,EAClB","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/modules/es.object.entries.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 * 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","'use strict';\nvar $ = 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"],"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","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","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","define","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","displayName","isGeneratorFunction","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","stop","rval","handle","complete","finish","catch","delegateYield","asyncGeneratorStep","gen","reject","_next","_throw","info","error","_asyncToGenerator","fn","self","args","apply","err","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","_step$value","getPageNum","_step2","_iterator2","_step3","_iterator3","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","json","makeViewable","_modes","mode1Up","mode1UpLit","updatePages","activeMode","updateComplete","jumpToIndex","poll","until","result","scrollIntoView","block","isFullscreenActive","inline","behavior","removeAttr","_x","searchHighlightVisible","visiblePages","twoPage","currentIndexL","currentIndexR","some","inArray","$entries","stat","O"],"sourceRoot":""}
|
@@ -1,2 +1,3 @@
|
|
1
|
-
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[423],{7967:function(t,e,n){"use strict";n(5666),n(6992),n(1539),n(3948),n(9826),n(9714),n(2222),n(1249),n(4916),n(3123),n(9601),n(8674),n(2526),n(1817),n(2165),n(8783),n(7042),n(8309),n(1038),n(489),n(2419),n(4819),n(5003);var r=n(7775);function o(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 i(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)?i(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 i(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 a(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:u;return null==t?void 0:t.replace(/\{\{([^}]*?)\}\}/g,(function(t,i){if(!i)return t;var a=o(i.split("|").map((function(t){return t.trim()}))),u=a[0],c=a.slice(1);if(!(u in n)&&!(u in e))return t;var s=u in n?n[u]:u in e?e[u]:null;return c.map((function(t){return r[t]})).reduce((function(t,e){return e(t)}),s&&s.toString())}))}n(5306),n(3210),n(5827);var u={urlencode:encodeURIComponent},c=n(3609);function s(t){return(s="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)}function l(t,e,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var r=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=g(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(n):o.value}})(t,e,n||t)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function p(t,e){return!e||"object"!==s(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=t&&("undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"]);if(null!=n){var r,o,i=[],a=!0,u=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return d(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)?d(t,e):void 0}}(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 d(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 v(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function y(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){v(i,r,o,a,u,"next",t)}function u(t){v(i,r,o,a,u,"throw",t)}a(void 0)}))}}function m(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function b(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 w(t,e,n){return e&&b(t.prototype,e),n&&b(t,n),t}var x=window.BookReader,S={enabled:!0,fullDjvuXmlUrl:null,singlePageDjvuXmlUrl:null},P=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;m(this,t),this.maxSize=e,this.entries=[]}return w(t,[{key:"add",value:function(t){this.entries.length>=this.maxSize&&this.entries.shift(),this.entries.push(t)}}]),t}(),A=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:S,n=arguments.length>1?arguments[1]:void 0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(0,r.vU)(),i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:(0,r.G6)();m(this,t),this.options=e,this.optionVariables=n,this.djvuPagesPromise=null,this.svgParagraphElement="text",this.svgWordElement="tspan",this.insertNewlines=o,this.pointerEventsOnParagraph=i,o&&(this.svgParagraphElement="g",this.svgWordElement="text"),this.pageTextCache=new P,this.maxWordRendered=2500}var e,n;return w(t,[{key:"init",value:function(){this.options.singlePageDjvuXmlUrl||(this.djvuPagesPromise=c.ajax({type:"GET",url:a(this.options.fullDjvuXmlUrl,this.optionVariables),dataType:"html",error:function(t){}}).then((function(t){try{var e=c.parseXML(t);return e&&c(e).find("OBJECT")}catch(t){return}})))}},{key:"getPageText",value:(n=y(regeneratorRuntime.mark((function t(e){var n,r,o=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.options.singlePageDjvuXmlUrl){t.next=7;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.abrupt("return",c.ajax({type:"GET",url:a(this.options.singlePageDjvuXmlUrl,this.optionVariables,{pageIndex:e}),dataType:"html",error:function(t){}}).then((function(t){try{var n=c.parseXML(t),r=n&&c(n).find("OBJECT")[0];return o.pageTextCache.add({index:e,response:r}),r}catch(t){return}})));case 7:return t.next=9,this.djvuPagesPromise;case 9:if(!(r=t.sent)){t.next=12;break}return t.abrupt("return",r[e]);case 12:case"end":return t.stop()}}),t,this)}))),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;t.classList.remove("selectingSVG"),c(t).on("mousedown.textSelectPluginHandler",(function(n){c(n.target).is(".BRwordElement")&&(n.stopPropagation(),t.classList.add("selectingSVG"),c(t).one("mouseup.textSelectPluginHandler",(function(n){""!=window.getSelection().toString()?(n.stopPropagation(),c(t).off(".textSelectPluginHandler"),e.textSelectingMode(t)):t.classList.remove("selectingSVG")})))}))}},{key:"textSelectingMode",value:function(t){var e=this;c(t).on("mousedown.textSelectPluginHandler",(function(t){c(t.target).is(".BRwordElement")||""!=window.getSelection().toString()&&window.getSelection().removeAllRanges(),t.stopPropagation()})),c(t).on("mouseup.textSelectPluginHandler",(function(n){n.stopPropagation(),""==window.getSelection().toString()&&(c(t).off(".textSelectPluginHandler"),e.defaultMode(t))}))}},{key:"stopPageFlip",value:function(t){var e=this,n=t.find("svg.textSelectionSVG");n.length&&(n.each((function(t,n){return e.defaultMode(n)})),this.interceptCopy(t))}},{key:"createTextLayer",value:(e=y(regeneratorRuntime.mark((function t(e,n){var r,o,i,a,u,s=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.find(".textSelectionSVG").length){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,this.getPageText(e);case 5:if(r=t.sent){t.next=8;break}return t.abrupt("return");case 8:if(o=c(r).attr("width"),i=c(r).attr("height"),!((a=c(r).find("WORD").length)>this.maxWordRendered)){t.next=14;break}return console.log("Page ".concat(e," has too many words (").concat(a," > ").concat(this.maxWordRendered,"). Not rendering text layer.")),t.abrupt("return");case 14:(u=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("xmlns","http://www.w3.org/2000/svg"),u.setAttribute("viewBox","0 0 ".concat(o," ").concat(i)),n.append(u),u.setAttribute("class","textSelectionSVG"),u.setAttribute("preserveAspectRatio","none"),c(u).css({width:"100%",position:"absolute",height:"100%",top:"0",left:"0"}),c(r).find("PARAGRAPH").each((function(t,e){var n=c(e).find("WORD");if(n.length){var r=document.createElementNS("http://www.w3.org/2000/svg",s.svgParagraphElement);r.setAttribute("class","BRparagElement"),s.pointerEventsOnParagraph&&(r.style.pointerEvents="all");for(var o=[],i=0;i<n.length;i++){var a=n[i],l=h(c(a).attr("coords").split(",").map(parseFloat),4),f=l[0],p=l[1],g=l[2],d=p-l[3];o.push(d);var v=document.createElementNS("http://www.w3.org/2000/svg",s.svgWordElement);if(v.setAttribute("class","BRwordElement"),v.setAttribute("x",f.toString()),v.setAttribute("y",p.toString()),v.setAttribute("textLength",(g-f).toString()),v.setAttribute("lengthAdjust","spacingAndGlyphs"),v.textContent=a.textContent,r.appendChild(v),i<n.length-1){var y=n[i+1],m=h(c(y).attr("coords").split(",").map(parseFloat),4),b=m[0],w=(m[1],m[2],m[3],document.createElementNS("http://www.w3.org/2000/svg",s.svgWordElement));w.setAttribute("class","BRwordElement"),w.setAttribute("x",g.toString()),w.setAttribute("y",p.toString()),b-g>0&&w.setAttribute("textLength",(b-g).toString()),w.setAttribute("lengthAdjust","spacingAndGlyphs"),w.textContent=" ",r.appendChild(w)}i==n.length-1&&s.insertNewlines&&r.appendChild(document.createTextNode("\n"))}o.sort();var x=o[Math.floor(.85*o.length)];r.setAttribute("font-size",x.toString()),u.appendChild(r)}})),this.stopPageFlip(n);case 23:case"end":return t.stop()}}),t,this)}))),function(t,n){return e.apply(this,arguments)})}]),t}(),R=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}}),e&&f(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=g(e);if(n){var o=g(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return p(this,t)});function o(){return m(this,o),r.apply(this,arguments)}return w(o,[{key:"init",value:function(){var t=Object.assign({},S,this.options.plugins.textSelection);t.enabled&&(this.textSelectionPlugin=new A(t,this.options.vars),this.options.plugins.textSelection=t,this.textSelectionPlugin.init()),l(g(o.prototype),"init",this).call(this)}},{key:"_createPageContainer",value:function(t){var e,n=l(g(o.prototype),"_createPageContainer",this).call(this,t),r=this.getNumLeafs()-1;return this.mode!==this.constModeThumb&&t>=0&&t<=r&&(null===(e=this.textSelectionPlugin)||void 0===e||e.createTextLayer(t,n.$container)),n}}]),o}(x);window.BookReader=R},7775:function(t,e,n){"use strict";function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:navigator.vendor;return/chrome/i.test(t)&&/google inc/i.test(e)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/firefox/i.test(t)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:navigator.userAgent;return/safari/i.test(t)&&!/chrome|chromium/i.test(t)}n.d(e,{i7:function(){return r},vU:function(){return o},G6:function(){return i}})},7065:function(t,e,n){"use strict";var r=n(3099),o=n(111),i=[].slice,a={},u=function(t,e,n){if(!(e in a)){for(var r=[],o=0;o<e;o++)r[o]="a["+o+"]";a[e]=Function("C,a","return new C("+r.join(",")+")")}return a[e](t,n)};t.exports=Function.bind||function(t){var e=r(this),n=i.call(arguments,1),a=function(){var r=n.concat(i.call(arguments));return this instanceof a?u(e,r.length,r):e.apply(t,r)};return o(e.prototype)&&(a.prototype=e.prototype),a}},6091:function(t,e,n){var r=n(7293),o=n(1361);t.exports=function(t){return r((function(){return!!o[t]()||"
"!="
"[t]()||o[t].name!==t}))}},3111:function(t,e,n){var r=n(4488),o="["+n(1361)+"]",i=RegExp("^"+o+o+"*"),a=RegExp(o+o+"*$"),u=function(t){return function(e){var n=String(r(e));return 1&t&&(n=n.replace(i,"")),2&t&&(n=n.replace(a,"")),n}};t.exports={start:u(1),end:u(2),trim:u(3)}},1361:function(t){t.exports="\t\n\v\f\r \u2028\u2029\ufeff"},9601:function(t,e,n){var r=n(2109),o=n(1574);r({target:"Object",stat:!0,forced:Object.assign!==o},{assign:o})},489:function(t,e,n){var r=n(2109),o=n(7293),i=n(7908),a=n(9518),u=n(8544);r({target:"Object",stat:!0,forced:o((function(){a(1)})),sham:!u},{getPrototypeOf:function(t){return a(i(t))}})},2419:function(t,e,n){var r=n(2109),o=n(5005),i=n(3099),a=n(9670),u=n(111),c=n(30),s=n(7065),l=n(7293),f=o("Reflect","construct"),p=l((function(){function t(){}return!(f((function(){}),[],t)instanceof t)})),g=!l((function(){f((function(){}))})),h=p||g;r({target:"Reflect",stat:!0,forced:h,sham:h},{construct:function(t,e){i(t),a(e);var n=arguments.length<3?t:i(arguments[2]);if(g&&!p)return f(t,e,n);if(t==n){switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3])}var r=[null];return r.push.apply(r,e),new(s.apply(t,r))}var o=n.prototype,l=c(u(o)?o:Object.prototype),h=Function.apply.call(t,l,e);return u(h)?h:l}})},4819:function(t,e,n){var r=n(2109),o=n(111),i=n(9670),a=n(6656),u=n(1236),c=n(9518);r({target:"Reflect",stat:!0},{get:function t(e,n){var r,s,l=arguments.length<3?e:arguments[2];return i(e)===l?e[n]:(r=u.f(e,n))?a(r,"value")?r.value:void 0===r.get?void 0:r.get.call(l):o(s=c(e))?t(s,n,l):void 0}})},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){"use strict";t(t.s=7967)}]);
|
1
|
+
/*! For license information please see plugin.text_selection.js.LICENSE.txt */
|
2
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[423],{4742:function(t,e,r){r(752),r(228),r(6265),r(5728),r(2826),r(4338),r(939),r(3964),r(886),r(5137),r(7049),r(1694),r(2918),r(8436),r(9730),r(429),r(6646),r(4254),r(9749),r(6544),r(6203),r(9373),r(9903),r(9288),r(8373),r(6793),r(7629),r(7509),r(8052),r(7522),r(4284),r(3374),r(4043),r(50),r(2349),r(1919);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();if(!n.selecting&&t.toString()){var e=o(t.anchorNode).closest(n.selector)[0];if(!e)return;n.target=e,n.selecting=!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(7267),r(278);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 e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var i=e&&e.prototype instanceof m?e:m,a=Object.create(i.prototype),c=new _(n||[]);return o(a,"_invoke",{value:R(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=s;var h="suspendedStart",p="suspendedYield",y="executing",v="completed",g={};function m(){}function b(){}function w(){}var x={};u(x,a,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(B([])));E&&E!==r&&n.call(E,a)&&(x=E);var P=w.prototype=m.prototype=Object.create(x);function k(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,i,a,c){var l=f(t[o],t,i);if("throw"!==l.type){var u=l.arg,s=u.value;return s&&"object"==d(s)&&n.call(s,"__await")?e.resolve(s.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(s).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(l.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function R(e,r,n){var o=h;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var l=L(c,n);if(l){if(l===g)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?v:p,u.arg===g)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=v,n.method="throw",n.arg=u.arg)}}}function L(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,L(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function C(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 A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function B(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(d(e)+" is not iterable")}return b.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=u(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,u(t,l,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},k(O.prototype),u(O.prototype,c,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new O(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(P),u(P,l,"Generator"),u(P,a,(function(){return this})),u(P,"toString",(function(){return"[object Generator]"})),e.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}},e.values=B,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.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,g):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),g},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),A(r),g}},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;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}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=M(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,F)));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=M(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=M(e,".BRwordElement");var tt,et,rt=M(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 M(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 F(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}()},5984:function(t,e,r){var n=r(1236).PROPER,o=r(3689),i=r(6350);t.exports=function(t){return o((function(){return!!i[t]()||"
"!=="
"[t]()||n&&i[t].name!==t}))}},8436:function(t,e,r){var n=r(9989),o=r(1435).trim;n({target:"String",proto:!0,forced:r(5984)("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 */
|