@internetarchive/bookreader 5.0.0-44 → 5.0.0-44-a4
Sign up to get free protection for your applications and to get access to all the features.
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +87 -87
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/CHANGELOG.md +0 -5
- package/package.json +1 -1
- package/src/BookNavigator/search/search-provider.js +1 -19
- package/src/plugins/search/plugin.search.js +8 -0
- package/src/plugins/url/UrlPlugin.js +1 -0
- package/tests/jest/BookNavigator/search/search-provider.test.js +0 -61
- package/tests/jest/BookNavigator/search/search-results.test.js +0 -13
@@ -1,2 +1,2 @@
|
|
1
|
-
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[73],{8011:function(e,t,r){"use strict";r(5666),r(4916),r(4765),r(9826),r(1539),r(1249),r(5306),r(2222),r(6992),r(3948),r(9601),r(9720),r(4678),r(8674),r(8783),r(1637),r(7042),r(8309),r(1038),r(2526),r(1817),r(2165);var n=r(5685),a=r(9860),i=(r(4603),r(9714),r(4747),r(1058),r(3609));function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o,c=function(){function e(t){var r=t.br,n=t.searchCancelledCallback,a=void 0===n?function(){}:n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.br=r,this.matcher=new RegExp("{{{(.+?)}}}","g"),this.matches=[],this.cacheDOMElements(),this.bindEvents(),this.cancelSearch=a}var t,r;return t=e,(r=[{key:"cacheDOMElements",value:function(){this.dom={},this.dom.toolbarSearch=this.buildToolbarSearch()}},{key:"setQuery",value:function(e){this.br.$('[name="query"]').val(e)}},{key:"emptyMatches",value:function(){this.matches=[]}},{key:"removeResultPins",value:function(){this.br.$(".BRnavpos .BRsearch").remove()}},{key:"clearSearchFieldAndResults",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.br.removeSearchResults(),this.removeResultPins(),this.emptyMatches(),this.setQuery(""),this.teardownSearchNavigation(),e&&this.br.trigger("SearchResultsCleared")}},{key:"toggleSidebar",value:function(){this.br.trigger("ToggleSearchMenu")}},{key:"renderSearchNavigation",value:function(){var e="BRsearch-navigation";i(".BRnav").before('\n <div class="'.concat(e,'">\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">').concat(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 ')),this.dom.searchNavigation=i(".".concat(e))}},{key:"resultsPosition",value:function(){var e="".concat(this.matches.length," result").concat(1===this.matches.length?"":"s");return~this.currentMatchIndex&&(e="".concat(this.currentMatchIndex+1," / ").concat(this.matches.length)),e}},{key:"bindSearchNavigationEvents",value:function(){if(this.dom.searchNavigation){var e="searchNavigation";this.dom.searchNavigation.on("click.".concat(e),".clear",this.clearSearchFieldAndResults.bind(this)).on("click.".concat(e),".prev",this.showPrevResult.bind(this)).on("click.".concat(e),".next",this.showNextResult.bind(this)).on("click.".concat(e),".toggle-sidebar",this.toggleSidebar.bind(this)).on("click.".concat(e),!1)}}},{key:"showPrevResult",value:function(){0!==this.currentMatchIndex&&(this.br.mode===this.br.constModeThumb&&this.br.switchMode(this.br.constMode1up),~this.currentMatchIndex||(this.currentMatchIndex=this.getClosestMatchIndex((function(e,t,r){return t[0]>r}))+1),this.br.$(".BRnavline .BRsearch").eq(--this.currentMatchIndex).click(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"showNextResult",value:function(){this.currentMatchIndex+1!==this.matches.length&&(this.br.mode===this.br.constModeThumb&&this.br.switchMode(this.br.constMode1up),~this.currentMatchIndex||(this.currentMatchIndex=this.getClosestMatchIndex((function(e,t,r){return e[e.length-1]>r}))-1),this.br.$(".BRnavline .BRsearch").eq(++this.currentMatchIndex).click(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"getClosestMatchIndex",value:function(e){var t=function t(r,n){if(1===r.length)return r[0];var a=r.slice(0,r.length/2),i=r.slice(r.length/2);return t(e(a,i,n)?a:i,n)}(this.matches.map((function(e){return e.par[0].page})),this.br.currentIndex()+1);return this.matches.indexOf(this.matches.find((function(e){return e.par[0].page===t})))}},{key:"updateResultsPosition",value:function(){this.dom.searchNavigation&&this.dom.searchNavigation.find("[data-id=resultsCount]").text(this.resultsPosition())}},{key:"updateSearchNavigationButtons",value:function(){this.dom.searchNavigation&&(this.dom.searchNavigation.find(".prev").attr("disabled",!this.currentMatchIndex),this.dom.searchNavigation.find(".next").attr("disabled",this.currentMatchIndex+1===this.matches.length))}},{key:"teardownSearchNavigation",value:function(){this.dom.searchNavigation||(this.dom.searchNavigation=i(".BRsearch-navigation")),this.dom.searchNavigation.length&&(this.dom.searchNavigation.off(".searchNavigation").remove(),this.dom.searchNavigation=null,this.br.resize())}},{key:"setCurrentMatchIndex",value:function(){var e;this.br.mode!==this.br.constModeThumb?(e=this.br.mode===this.br.constMode2up?this.find2upMatchingSearchResult():this.find1upMatchingSearchResult(),this.currentMatchIndex=this.matches.indexOf(e)):this.currentMatchIndex=-1}},{key:"find1upMatchingSearchResult",value:function(){var e=this;return this.matches.find((function(t){return e.br.currentIndex()===t.par[0].page-1}))}},{key:"find2upMatchingSearchResult",value:function(){var e=this;return this.matches.find((function(t){return e.br._isIndexDisplayed(t.par[0].page-1)}))}},{key:"updateSearchNavigation",value:function(){this.matches.length&&(this.setCurrentMatchIndex(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"togglePinsFor",value:function(e){var t=e?"visible":"hidden";this.br.refs.$BRfooter.find(".BRsearch").css({visibility:t})}},{key:"buildToolbarSearch",value:function(){var e=document.createElement("span");return e.classList.add("BRtoolbarSection","BRtoolbarSectionSearch"),e.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="'.concat(this.br.imagesBaseURL,'icon_search_button.svg" />\n </button>\n </form>\n '),e}},{key:"renderPins",value:function(e){var t=this;e.forEach((function(e){var r=e.text,n=t.br.leafNumToIndex(e.par[0].page),a=t.br.constructor.util.cssPercentage(n,t.br.getNumLeafs()-1),s=r.replace(t.matcher,"<b>$1</b>"),o="";r.length>100&&(o=r.replace(/^(.{100}[^\s]*).*/,"$1").replace(t.matcher,"<b>$1</b>")+"..."),i("<div>").addClass("BRsearch").css({left:a}).attr("title","Search result").append('\n <div class="BRquery">\n <div>'.concat(o||s,"</div>\n <div>Page ").concat(e.displayPageNumber,"</div>\n </div>\n ")).appendTo(t.br.$(".BRnavline")).on("mouseenter",(function(e){var t=e.currentTarget,r=t.querySelector(".BRquery"),n=r.getBoundingClientRect(),a=t.getBoundingClientRect(),s=2*parseInt(getComputedStyle(r).paddingLeft);n.x-s<0&&r.style.setProperty("transform","translateX(-".concat(a.left-s,"px)")),i(".BRsearch,.BRchapter").removeClass("front"),i(e.target).addClass("front")})).on("mouseleave",(function(e){return i(e.target).removeClass("front")})).on("click",(function(){t.br._searchPluginGoToResult(e.matchIndex)}))}))}},{key:"toggleSearchPending",value:function(e){var t=this;e?this.br.showProgressPopup("Search results will appear below...",(function(){return t.progressPopupClosed()})):this.br.removeProgressPopup()}},{key:"progressPopupClosed",value:function(){this.toggleSearchPending(),this.cancelSearch()}},{key:"renderErrorModal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t="".concat(e?"":"The text may still be processing. ","Please try again.");this.renderModalMessage("\n Sorry, there was an error with your search.\n <br />\n ".concat(t,"\n ")),this.delayModalRemovalFor(4e3)}},{key:"renderBookNotIndexedModal",value:function(){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 "),this.delayModalRemovalFor(5e3)}},{key:"renderResultsEmptyModal",value:function(){this.renderModalMessage("No matches were found."),this.delayModalRemovalFor(2e3)}},{key:"renderModalMessage",value:function(e){var t=document.createElement("div");t.classList.add("BRprogresspopup","search_modal"),t.innerHTML=e,document.querySelector(this.br.el).append(t)}},{key:"delayModalRemovalFor",value:function(e){setTimeout(this.br.removeProgressPopup.bind(this.br),e)}},{key:"submitHandler",value:function(e){e.preventDefault();var t=e.target.querySelector('[name="query"]').value;return!!t.length&&(this.br.search(t),this.emptyMatches(),this.toggleSearchPending(!0),!1)}},{key:"handleSearchCallback",value:function(e,t){var r=this,n=t.results,a=t.options;this.matches=n.matches,this.setCurrentMatchIndex(),this.teardownSearchNavigation(),this.renderSearchNavigation(),this.bindSearchNavigationEvents(),this.renderPins(n.matches),this.toggleSearchPending(!1),a.goToFirstResult?i(document).one("BookReader:pageChanged",(function(){r.br.resize()})):this.br.resize()}},{key:"handleNavToggledCallback",value:function(e){var t=this.br.navigationIsVisible();this.togglePinsFor(t)}},{key:"handleSearchStarted",value:function(){this.emptyMatches(),this.br.removeSearchHilites(),this.removeResultPins(),this.toggleSearchPending(!0),this.teardownSearchNavigation(),this.setQuery(this.br.searchTerm)}},{key:"handleSearchCallbackError",value:function(){var e,t,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.toggleSearchPending(!1);var a=null==n||null===(e=n.detail)||void 0===e||null===(t=e.props)||void 0===t||null===(r=t.results)||void 0===r?void 0:r.indexed;this.renderErrorModal(a)}},{key:"handleSearchCallbackBookNotIndexed",value:function(){this.toggleSearchPending(!1),this.renderBookNotIndexedModal()}},{key:"handleSearchCallbackEmpty",value:function(){this.toggleSearchPending(!1),this.renderResultsEmptyModal()}},{key:"bindEvents",value:function(){var e="BookReader:";window.addEventListener("".concat(e,"SearchCallbackError"),this.handleSearchCallbackError.bind(this)),i(document).on("".concat(e,"SearchCallback"),this.handleSearchCallback.bind(this)).on("".concat(e,"navToggled"),this.handleNavToggledCallback.bind(this)).on("".concat(e,"SearchStarted"),this.handleSearchStarted.bind(this)).on("".concat(e,"SearchCallbackBookNotIndexed"),this.handleSearchCallbackBookNotIndexed.bind(this)).on("".concat(e,"SearchCallbackEmpty"),this.handleSearchCallbackEmpty.bind(this)).on("".concat(e,"pageChanged"),this.updateSearchNavigation.bind(this)),this.dom.toolbarSearch.querySelector("form").addEventListener("submit",this.submitHandler.bind(this))}}])&&s(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),h=r(3609),l=r(3609);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i=[],s=!0,o=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);s=!0);}catch(e){o=!0,a=e}finally{try{s||null==r.return||r.return()}finally{if(o)throw a}}return i}}(e,t)||v(e,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 d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=v(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}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,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw i}}}}function v(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,i,s){try{var o=e[i](s),c=o.value}catch(e){return void r(e)}o.done?t(c):Promise.resolve(c).then(n,a)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function s(e){f(i,n,a,s,o,"next",e)}function o(e){f(i,n,a,s,o,"throw",e)}s(void 0)}))}}h.extend(BookReader.defaultOptions,{server:"ia600609.us.archive.org",bookId:"",subPrefix:"",bookPath:"",enableSearch:!0,searchInsideUrl:"/fulltext/inside.php",initialSearchTerm:null}),BookReader.prototype.setup=(o=BookReader.prototype.setup,function(e){o.call(this,e),this.searchTerm="",this.searchResults=null,this.searchInsideUrl=e.searchInsideUrl,this.enableSearch=e.enableSearch,this.bookId=e.bookId,this.server=e.server,this.subPrefix=e.subPrefix,this.bookPath=e.bookPath,this.searchXHR=null,this._cancelSearch.bind(this),this.cancelSearchRequest.bind(this),this._searchBoxesByIndex={},this.searchView=void 0}),BookReader.prototype.init=function(e){return function(){var t=this;e.call(this),this.searchView=new c({br:this,searchCancelledCallback:function(){t._cancelSearch(),t.trigger("SearchCanceled",{term:t.searchTerm,instance:t})}}),this.options.enableSearch&&this.options.initialSearchTerm&&this.search(this.options.initialSearchTerm,{goToFirstResult:this.options.goToFirstResult,suppressFragmentChange:!1})}}(BookReader.prototype.init),BookReader.prototype.buildToolbarElement=function(e){return function(){var t=e.call(this);if(this.enableSearch)return this.searchView.dom.toolbarSearch&&t.find(".BRtoolbarSectionInfo").after(this.searchView.dom.toolbarSearch),t}}(BookReader.prototype.buildToolbarElement),BookReader.prototype._createPageContainer=function(e){return function(t){var r=e.call(this,t);if(this.enableSearch&&r.page&&t in this._searchBoxesByIndex){var n=r.page.index,i=this._searchBoxesByIndex[n];(0,a.Tm)("searchHiliteLayer",i,r.page,r.$container[0],i.map((function(e){return"match-index-".concat(e.matchIndex)})))}return r}}(BookReader.prototype._createPageContainer),BookReader.prototype.search=p(regeneratorRuntime.mark((function e(){var t,r,n,a,i,s,o,c,u,d,v,g,f=this,p=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=p.length>0&&void 0!==p[0]?p[0]:"",r=p.length>1&&void 0!==p[1]?p[1]:{},n={goToFirstResult:!1,disablePopup:!1,suppressFragmentChange:!1,error:null,success:null},a=h.extend({},n,r),this.suppressFragmentChange=a.suppressFragmentChange,this.searchCancelled=!1,this.searchTerm=t.replace(/\//g," "),a.suppressFragmentChange||this.trigger(BookReader.eventNames.fragmentChange),i=this.server.replace(/:.+/,""),s="https://".concat(i).concat(this.searchInsideUrl,"?"),o=this.bookPath,c="/".concat(this.subPrefix),this.bookPath.length-this.bookPath.lastIndexOf(c)==c.length&&(o=this.bookPath.substr(0,this.bookPath.length-c.length)),u={item_id:this.bookId,doc:this.subPrefix,path:o,q:t},d=l.param(u).replace(/%2F/g,"/"),v="".concat(s).concat(d),g=function(e){if(!f.searchCancelled){var t=e.error||!e.matches.length,r="function"==typeof a.error,n="function"==typeof a.success;t?r?a.error.call(f,e,a):f.BRSearchCallbackError(e,a):n?a.success.call(f,e,a):f.BRSearchCallback(e,a)}},this.trigger("SearchStarted",{term:this.searchTerm,instance:this}),e.t0=g,e.next=21,l.ajax({url:v,dataType:"jsonp",cache:!0,beforeSend:function(e){f.searchXHR=e}});case 21:e.t1=e.sent,(0,e.t0)(e.t1);case 23:case"end":return e.stop()}}),e,this)}))),BookReader.prototype._cancelSearch=function(){var e;null===(e=this.searchXHR)||void 0===e||e.abort(),this.searchView.clearSearchFieldAndResults(!1),this.searchTerm="",this.searchXHR=null,this.searchCancelled=!0,this.searchResults=[]},BookReader.prototype.cancelSearchRequest=function(){this.searchCancelled=!0,null!==this.searchXHR&&(this._cancelSearch(),this.searchView.toggleSearchPending(),this.trigger("SearchCanceled",{term:this.searchTerm,instance:this}))},BookReader.prototype.BRSearchCallback=function(e,t){var r=this;!function(e,t){var n,a,i=d(e.matches.entries());try{for(i.s();!(n=i.n()).done;){var s=u(n.value,2),o=s[0],c=s[1];c.matchIndex=o,c.displayPageNumber=(a=c.par[0].page,r.getPageNum(r.leafNumToIndex(a)));var h,l=d(c.par);try{for(l.s();!(h=l.n()).done;){var v,g=d(h.value.boxes);try{for(g.s();!(v=g.n()).done;)v.value.matchIndex=o}catch(e){g.e(e)}finally{g.f()}}}catch(e){l.e(e)}finally{l.f()}}}catch(e){i.e(e)}finally{i.f()}}(e),this.searchResults=e||[],this.updateSearchHilites(),this.removeProgressPopup(),t.goToFirstResult&&this._searchPluginGoToResult(0),this.trigger("SearchCallback",{results:e,options:t,instance:this})},BookReader.prototype.BRSearchCallbackError=function(e){this._BRSearchCallbackError(e)},BookReader.prototype._BRSearchCallbackError=function(e){this.searchResults=e;var t={term:this.searchTerm,instance:this};if(e.error){var r=Object.assign({},t,{results:e});this.trigger("SearchCallbackError",r)}else if(0==e.matches.length){if(!1===e.indexed)return void this.trigger("SearchCallbackBookNotIndexed",t);this.trigger("SearchCallbackEmpty",t)}},BookReader.prototype.updateSearchHilites=function(){var e,t=(null===(e=this.searchResults)||void 0===e?void 0:e.matches)||[],r={};this.removeSearchHilites();var n,i=d(t);try{for(i.s();!(n=i.n()).done;){var s,o=d(n.value.par[0].boxes);try{for(o.s();!(s=o.n()).done;){var c=s.value,h=this.leafNumToIndex(c.page);(r[h]||(r[h]=[])).push(c)}}catch(e){o.e(e)}finally{o.f()}}}catch(e){i.e(e)}finally{i.f()}for(var l=0,v=Object.entries(r);l<v.length;l++){var g,f=u(v[l],2),p=f[0],b=f[1],m=parseFloat(p),y=this._models.book.getPage(m),k=d(this.getActivePageContainerElementsForIndex(m));try{for(k.s();!(g=k.n()).done;){var S=g.value;(0,a.Tm)("searchHiliteLayer",b,y,S,b.map((function(e){return"match-index-".concat(e.matchIndex)})))}}catch(e){k.e(e)}finally{k.f()}}this._searchBoxesByIndex=r},BookReader.prototype.removeSearchHilites=function(){l(this.getActivePageContainerElements()).find(".searchHiliteLayer").remove()},BookReader.prototype._searchPluginGoToResult=function(){var e=p(regeneratorRuntime.mark((function e(t){var r,a,i,s,o,c,h,u,v,g,f,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(r=this.searchResults)||void 0===r?void 0:r.matches[t],i=this.leafNumToIndex(a.par[0].page),s=this._models.book,o=s.getPage(i),c=Math.abs(this.currentIndex()-i)<3,h=!1,o.isViewable){e.next=13;break}return e.next=9,fetch("/services/bookreader/request_page?"+new URLSearchParams({id:this.options.bookId,subprefix:this.options.subPrefix,leafNum:o.leafNum})).then((function(e){return e.json()}));case 9:u=e.sent,v=d(u.value);try{for(v.s();!(g=v.n()).done;)f=g.value,s.getPage(s.leafNumToIndex(f)).makeViewable()}catch(e){v.e(e)}finally{v.f()}u.value.length||(s.getPage(i).makeViewable(),h=!0);case 13:return this._isIndexDisplayed(i)||(this.suppressFragmentChange=!1,this.jumpToIndex(i)),h&&s.getPage(i).makeViewable(!1),e.next=17,(0,n.poll)((function(){return l("rect.match-index-".concat(a.matchIndex))}),{until:function(e){return e.length>0}});case 17:if(!(p=e.sent).length){e.next=24;break}return p.css("animation","none"),p[0].scrollIntoView({block:this.constMode1up==this.mode||this.isFullscreenActive?"center":"nearest",inline:"center",behavior:c?"smooth":"auto"}),e.next=23,new Promise((function(e){return setTimeout(e,100)}));case 23:p.removeAttr("style");case 24:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),BookReader.prototype.removeSearchResults=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.removeSearchHilites(),this.searchTerm=null,this.searchResults=null,e||this.trigger(BookReader.eventNames.fragmentChange)},BookReader.prototype.searchHighlightVisible=function(){var e=this,t=this.searchResults,r=[];if(null==t)return!1;if(this.constMode2up==this.mode)r=[this.twoPage.currentIndexL,this.twoPage.currentIndexR];else{if(this.constMode1up!=this.mode)return!1;r=[this.currentIndex()]}return t.matches.some((function(t){return t.par[0].boxes.some((function(t){var n=e.leafNumToIndex(t.page);if(h.inArray(n,r)>=0)return!0}))})),!1}},2814:function(e,t,r){var n=r(7854),a=r(7293),i=r(1702),s=r(1340),o=r(3111).trim,c=r(1361),h=i("".charAt),l=n.parseFloat,u=n.Symbol,d=u&&u.iterator,v=1/l(c+"-0")!=-1/0||d&&!a((function(){l(Object(d))}));e.exports=v?function(e){var t=o(s(e)),r=l(t);return 0===r&&"-"==h(t,0)?-0:r}:l},9720:function(e,t,r){var n=r(2109),a=r(4699).entries;n({target:"Object",stat:!0},{entries:function(e){return a(e)}})},4678:function(e,t,r){var n=r(2109),a=r(2814);n({global:!0,forced:parseFloat!=a},{parseFloat:a})}},function(e){e(e.s=8011)}]);
|
1
|
+
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[73],{8011:function(e,t,r){"use strict";r(5666),r(4916),r(4765),r(9826),r(1539),r(1249),r(5306),r(2222),r(6992),r(3948),r(9601),r(9720),r(4678),r(8674),r(8783),r(1637),r(7042),r(8309),r(1038),r(2526),r(1817),r(2165);var n=r(5685),a=r(9860),i=(r(4603),r(9714),r(4747),r(1058),r(3609));function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o,c=function(){function e(t){var r=t.br,n=t.searchCancelledCallback,a=void 0===n?function(){}:n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.br=r,this.matcher=new RegExp("{{{(.+?)}}}","g"),this.matches=[],this.cacheDOMElements(),this.bindEvents(),this.cancelSearch=a}var t,r;return t=e,(r=[{key:"cacheDOMElements",value:function(){this.dom={},this.dom.toolbarSearch=this.buildToolbarSearch()}},{key:"setQuery",value:function(e){this.br.$('[name="query"]').val(e)}},{key:"emptyMatches",value:function(){this.matches=[]}},{key:"removeResultPins",value:function(){this.br.$(".BRnavpos .BRsearch").remove()}},{key:"clearSearchFieldAndResults",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.br.removeSearchResults(),this.removeResultPins(),this.emptyMatches(),this.setQuery(""),this.teardownSearchNavigation(),e&&this.br.trigger("SearchResultsCleared")}},{key:"toggleSidebar",value:function(){this.br.trigger("ToggleSearchMenu")}},{key:"renderSearchNavigation",value:function(){var e="BRsearch-navigation";i(".BRnav").before('\n <div class="'.concat(e,'">\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">').concat(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 ')),this.dom.searchNavigation=i(".".concat(e))}},{key:"resultsPosition",value:function(){var e="".concat(this.matches.length," result").concat(1===this.matches.length?"":"s");return~this.currentMatchIndex&&(e="".concat(this.currentMatchIndex+1," / ").concat(this.matches.length)),e}},{key:"bindSearchNavigationEvents",value:function(){if(this.dom.searchNavigation){var e="searchNavigation";this.dom.searchNavigation.on("click.".concat(e),".clear",this.clearSearchFieldAndResults.bind(this)).on("click.".concat(e),".prev",this.showPrevResult.bind(this)).on("click.".concat(e),".next",this.showNextResult.bind(this)).on("click.".concat(e),".toggle-sidebar",this.toggleSidebar.bind(this)).on("click.".concat(e),!1)}}},{key:"showPrevResult",value:function(){0!==this.currentMatchIndex&&(this.br.mode===this.br.constModeThumb&&this.br.switchMode(this.br.constMode1up),~this.currentMatchIndex||(this.currentMatchIndex=this.getClosestMatchIndex((function(e,t,r){return t[0]>r}))+1),this.br.$(".BRnavline .BRsearch").eq(--this.currentMatchIndex).click(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"showNextResult",value:function(){this.currentMatchIndex+1!==this.matches.length&&(this.br.mode===this.br.constModeThumb&&this.br.switchMode(this.br.constMode1up),~this.currentMatchIndex||(this.currentMatchIndex=this.getClosestMatchIndex((function(e,t,r){return e[e.length-1]>r}))-1),this.br.$(".BRnavline .BRsearch").eq(++this.currentMatchIndex).click(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"getClosestMatchIndex",value:function(e){var t=function t(r,n){if(1===r.length)return r[0];var a=r.slice(0,r.length/2),i=r.slice(r.length/2);return t(e(a,i,n)?a:i,n)}(this.matches.map((function(e){return e.par[0].page})),this.br.currentIndex()+1);return this.matches.indexOf(this.matches.find((function(e){return e.par[0].page===t})))}},{key:"updateResultsPosition",value:function(){this.dom.searchNavigation&&this.dom.searchNavigation.find("[data-id=resultsCount]").text(this.resultsPosition())}},{key:"updateSearchNavigationButtons",value:function(){this.dom.searchNavigation&&(this.dom.searchNavigation.find(".prev").attr("disabled",!this.currentMatchIndex),this.dom.searchNavigation.find(".next").attr("disabled",this.currentMatchIndex+1===this.matches.length))}},{key:"teardownSearchNavigation",value:function(){this.dom.searchNavigation||(this.dom.searchNavigation=i(".BRsearch-navigation")),this.dom.searchNavigation.length&&(this.dom.searchNavigation.off(".searchNavigation").remove(),this.dom.searchNavigation=null,this.br.resize())}},{key:"setCurrentMatchIndex",value:function(){var e;this.br.mode!==this.br.constModeThumb?(e=this.br.mode===this.br.constMode2up?this.find2upMatchingSearchResult():this.find1upMatchingSearchResult(),this.currentMatchIndex=this.matches.indexOf(e)):this.currentMatchIndex=-1}},{key:"find1upMatchingSearchResult",value:function(){var e=this;return this.matches.find((function(t){return e.br.currentIndex()===t.par[0].page-1}))}},{key:"find2upMatchingSearchResult",value:function(){var e=this;return this.matches.find((function(t){return e.br._isIndexDisplayed(t.par[0].page-1)}))}},{key:"updateSearchNavigation",value:function(){this.matches.length&&(this.setCurrentMatchIndex(),this.updateResultsPosition(),this.updateSearchNavigationButtons())}},{key:"togglePinsFor",value:function(e){var t=e?"visible":"hidden";this.br.refs.$BRfooter.find(".BRsearch").css({visibility:t})}},{key:"buildToolbarSearch",value:function(){var e=document.createElement("span");return e.classList.add("BRtoolbarSection","BRtoolbarSectionSearch"),e.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="'.concat(this.br.imagesBaseURL,'icon_search_button.svg" />\n </button>\n </form>\n '),e}},{key:"renderPins",value:function(e){var t=this;e.forEach((function(e){var r=e.text,n=t.br.leafNumToIndex(e.par[0].page),a=t.br.constructor.util.cssPercentage(n,t.br.getNumLeafs()-1),s=r.replace(t.matcher,"<b>$1</b>"),o="";r.length>100&&(o=r.replace(/^(.{100}[^\s]*).*/,"$1").replace(t.matcher,"<b>$1</b>")+"..."),i("<div>").addClass("BRsearch").css({left:a}).attr("title","Search result").append('\n <div class="BRquery">\n <div>'.concat(o||s,"</div>\n <div>Page ").concat(e.displayPageNumber,"</div>\n </div>\n ")).appendTo(t.br.$(".BRnavline")).on("mouseenter",(function(e){var t=e.currentTarget,r=t.querySelector(".BRquery"),n=r.getBoundingClientRect(),a=t.getBoundingClientRect(),s=2*parseInt(getComputedStyle(r).paddingLeft);n.x-s<0&&r.style.setProperty("transform","translateX(-".concat(a.left-s,"px)")),i(".BRsearch,.BRchapter").removeClass("front"),i(e.target).addClass("front")})).on("mouseleave",(function(e){return i(e.target).removeClass("front")})).on("click",(function(){t.br._searchPluginGoToResult(e.matchIndex)}))}))}},{key:"toggleSearchPending",value:function(e){var t=this;e?this.br.showProgressPopup("Search results will appear below...",(function(){return t.progressPopupClosed()})):this.br.removeProgressPopup()}},{key:"progressPopupClosed",value:function(){this.toggleSearchPending(),this.cancelSearch()}},{key:"renderErrorModal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t="".concat(e?"":"The text may still be processing. ","Please try again.");this.renderModalMessage("\n Sorry, there was an error with your search.\n <br />\n ".concat(t,"\n ")),this.delayModalRemovalFor(4e3)}},{key:"renderBookNotIndexedModal",value:function(){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 "),this.delayModalRemovalFor(5e3)}},{key:"renderResultsEmptyModal",value:function(){this.renderModalMessage("No matches were found."),this.delayModalRemovalFor(2e3)}},{key:"renderModalMessage",value:function(e){var t=document.createElement("div");t.classList.add("BRprogresspopup","search_modal"),t.innerHTML=e,document.querySelector(this.br.el).append(t)}},{key:"delayModalRemovalFor",value:function(e){setTimeout(this.br.removeProgressPopup.bind(this.br),e)}},{key:"submitHandler",value:function(e){e.preventDefault();var t=e.target.querySelector('[name="query"]').value;return!!t.length&&(this.br.search(t),this.emptyMatches(),this.toggleSearchPending(!0),!1)}},{key:"handleSearchCallback",value:function(e,t){var r=this,n=t.results,a=t.options;this.matches=n.matches,this.setCurrentMatchIndex(),this.teardownSearchNavigation(),this.renderSearchNavigation(),this.bindSearchNavigationEvents(),this.renderPins(n.matches),this.toggleSearchPending(!1),a.goToFirstResult?i(document).one("BookReader:pageChanged",(function(){r.br.resize()})):this.br.resize()}},{key:"handleNavToggledCallback",value:function(e){var t=this.br.navigationIsVisible();this.togglePinsFor(t)}},{key:"handleSearchStarted",value:function(){this.emptyMatches(),this.br.removeSearchHilites(),this.removeResultPins(),this.toggleSearchPending(!0),this.teardownSearchNavigation(),this.setQuery(this.br.searchTerm)}},{key:"handleSearchCallbackError",value:function(){var e,t,r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.toggleSearchPending(!1);var a=null==n||null===(e=n.detail)||void 0===e||null===(t=e.props)||void 0===t||null===(r=t.results)||void 0===r?void 0:r.indexed;this.renderErrorModal(a)}},{key:"handleSearchCallbackBookNotIndexed",value:function(){this.toggleSearchPending(!1),this.renderBookNotIndexedModal()}},{key:"handleSearchCallbackEmpty",value:function(){this.toggleSearchPending(!1),this.renderResultsEmptyModal()}},{key:"bindEvents",value:function(){var e="BookReader:";window.addEventListener("".concat(e,"SearchCallbackError"),this.handleSearchCallbackError.bind(this)),i(document).on("".concat(e,"SearchCallback"),this.handleSearchCallback.bind(this)).on("".concat(e,"navToggled"),this.handleNavToggledCallback.bind(this)).on("".concat(e,"SearchStarted"),this.handleSearchStarted.bind(this)).on("".concat(e,"SearchCallbackBookNotIndexed"),this.handleSearchCallbackBookNotIndexed.bind(this)).on("".concat(e,"SearchCallbackEmpty"),this.handleSearchCallbackEmpty.bind(this)).on("".concat(e,"pageChanged"),this.updateSearchNavigation.bind(this)),this.dom.toolbarSearch.querySelector("form").addEventListener("submit",this.submitHandler.bind(this))}}])&&s(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}(),h=r(3609),l=r(3609);function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i=[],s=!0,o=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);s=!0);}catch(e){o=!0,a=e}finally{try{s||null==r.return||r.return()}finally{if(o)throw a}}return i}}(e,t)||v(e,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 d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=v(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}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,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw i}}}}function v(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,i,s){try{var o=e[i](s),c=o.value}catch(e){return void r(e)}o.done?t(c):Promise.resolve(c).then(n,a)}function p(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function s(e){f(i,n,a,s,o,"next",e)}function o(e){f(i,n,a,s,o,"throw",e)}s(void 0)}))}}h.extend(BookReader.defaultOptions,{server:"ia600609.us.archive.org",bookId:"",subPrefix:"",bookPath:"",enableSearch:!0,searchInsideUrl:"/fulltext/inside.php",initialSearchTerm:null}),BookReader.prototype.setup=(o=BookReader.prototype.setup,function(e){o.call(this,e),this.searchTerm="",this.searchResults=null,this.searchInsideUrl=e.searchInsideUrl,this.enableSearch=e.enableSearch,this.bookId=e.bookId,this.server=e.server,this.subPrefix=e.subPrefix,this.bookPath=e.bookPath,this.searchXHR=null,this._cancelSearch.bind(this),this.cancelSearchRequest.bind(this),this._searchBoxesByIndex={},this.searchView=void 0}),BookReader.prototype.init=function(e){return function(){var t=this;e.call(this),this.searchView=new c({br:this,searchCancelledCallback:function(){t._cancelSearch(),t.trigger("SearchCanceled",{term:t.searchTerm,instance:t})}}),this.options.enableSearch&&this.options.initialSearchTerm&&this.search(this.options.initialSearchTerm,{goToFirstResult:this.options.goToFirstResult,suppressFragmentChange:!1})}}(BookReader.prototype.init),BookReader.prototype.buildToolbarElement=function(e){return function(){var t=e.call(this);if(this.enableSearch)return this.searchView.dom.toolbarSearch&&t.find(".BRtoolbarSectionInfo").after(this.searchView.dom.toolbarSearch),t}}(BookReader.prototype.buildToolbarElement),BookReader.prototype._createPageContainer=function(e){return function(t){var r=e.call(this,t);if(this.enableSearch&&r.page&&t in this._searchBoxesByIndex){var n=r.page.index,i=this._searchBoxesByIndex[n];(0,a.Tm)("searchHiliteLayer",i,r.page,r.$container[0],i.map((function(e){return"match-index-".concat(e.matchIndex)})))}return r}}(BookReader.prototype._createPageContainer),BookReader.prototype.search=p(regeneratorRuntime.mark((function e(){var t,r,n,a,i,s,o,c,u,d,v,g,f,p,b,m,y=this,k=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=k.length>0&&void 0!==k[0]?k[0]:"",r=k.length>1&&void 0!==k[1]?k[1]:{},n={goToFirstResult:!1,disablePopup:!1,suppressFragmentChange:!1,error:null,success:null},a=h.extend({},n,r),this.suppressFragmentChange=a.suppressFragmentChange,this.searchCancelled=!1,this.searchTerm=t.replace(/\//g," "),a.suppressFragmentChange||this.trigger(BookReader.eventNames.fragmentChange),i=this.server.replace(/:.+/,""),s="https://".concat(i).concat(this.searchInsideUrl,"?"),o=this.bookPath,c="/".concat(this.subPrefix),this.bookPath.length-this.bookPath.lastIndexOf(c)==c.length&&(o=this.bookPath.substr(0,this.bookPath.length-c.length)),u={item_id:this.bookId,doc:this.subPrefix,path:o,q:t},d=l.param(u).replace(/%2F/g,"/"),v="".concat(s).concat(d),g=function(e){if(!y.searchCancelled){var t=e.error||!e.matches.length,r="function"==typeof a.error,n="function"==typeof a.success;t?r?a.error.call(y,e,a):y.BRSearchCallbackError(e,a):n?a.success.call(y,e,a):y.BRSearchCallback(e,a)}},this.trigger("SearchStarted",{term:this.searchTerm,instance:this}),e.t0=g,e.next=21,l.ajax({url:v,dataType:"jsonp",cache:!0,beforeSend:function(e){y.searchXHR=e}});case 21:e.t1=e.sent,(0,e.t0)(e.t1),this.searchTerm?null===(b=this.bookreader)||void 0===b||null===(m=b.urlPlugin)||void 0===m||m.setUrlParam("q",this.searchTerm):null===(f=this.bookreader)||void 0===f||null===(p=f.urlPlugin)||void 0===p||p.removeUrlParam("q");case 24:case"end":return e.stop()}}),e,this)}))),BookReader.prototype._cancelSearch=function(){var e,t,r;null===(e=this.searchXHR)||void 0===e||e.abort(),this.searchView.clearSearchFieldAndResults(!1),this.searchTerm="",this.searchXHR=null,this.searchCancelled=!0,this.searchResults=[],null===(t=this.bookreader)||void 0===t||null===(r=t.urlPlugin)||void 0===r||r.removeUrlParam("q")},BookReader.prototype.cancelSearchRequest=function(){var e;this.searchCancelled=!0,null!==this.searchXHR&&(this._cancelSearch(),this.searchView.toggleSearchPending(),this.trigger("SearchCanceled",{term:this.searchTerm,instance:this})),null==this||null===(e=this.urlPlugin)||void 0===e||e.removeUrlParam("q")},BookReader.prototype.BRSearchCallback=function(e,t){var r=this;!function(e,t){var n,a,i=d(e.matches.entries());try{for(i.s();!(n=i.n()).done;){var s=u(n.value,2),o=s[0],c=s[1];c.matchIndex=o,c.displayPageNumber=(a=c.par[0].page,r.getPageNum(r.leafNumToIndex(a)));var h,l=d(c.par);try{for(l.s();!(h=l.n()).done;){var v,g=d(h.value.boxes);try{for(g.s();!(v=g.n()).done;)v.value.matchIndex=o}catch(e){g.e(e)}finally{g.f()}}}catch(e){l.e(e)}finally{l.f()}}}catch(e){i.e(e)}finally{i.f()}}(e),this.searchResults=e||[],this.updateSearchHilites(),this.removeProgressPopup(),t.goToFirstResult&&this._searchPluginGoToResult(0),this.trigger("SearchCallback",{results:e,options:t,instance:this})},BookReader.prototype.BRSearchCallbackError=function(e){this._BRSearchCallbackError(e)},BookReader.prototype._BRSearchCallbackError=function(e){this.searchResults=e;var t={term:this.searchTerm,instance:this};if(e.error){var r=Object.assign({},t,{results:e});this.trigger("SearchCallbackError",r)}else if(0==e.matches.length){if(!1===e.indexed)return void this.trigger("SearchCallbackBookNotIndexed",t);this.trigger("SearchCallbackEmpty",t)}},BookReader.prototype.updateSearchHilites=function(){var e,t=(null===(e=this.searchResults)||void 0===e?void 0:e.matches)||[],r={};this.removeSearchHilites();var n,i=d(t);try{for(i.s();!(n=i.n()).done;){var s,o=d(n.value.par[0].boxes);try{for(o.s();!(s=o.n()).done;){var c=s.value,h=this.leafNumToIndex(c.page);(r[h]||(r[h]=[])).push(c)}}catch(e){o.e(e)}finally{o.f()}}}catch(e){i.e(e)}finally{i.f()}for(var l=0,v=Object.entries(r);l<v.length;l++){var g,f=u(v[l],2),p=f[0],b=f[1],m=parseFloat(p),y=this._models.book.getPage(m),k=d(this.getActivePageContainerElementsForIndex(m));try{for(k.s();!(g=k.n()).done;){var S=g.value;(0,a.Tm)("searchHiliteLayer",b,y,S,b.map((function(e){return"match-index-".concat(e.matchIndex)})))}}catch(e){k.e(e)}finally{k.f()}}this._searchBoxesByIndex=r},BookReader.prototype.removeSearchHilites=function(){l(this.getActivePageContainerElements()).find(".searchHiliteLayer").remove()},BookReader.prototype._searchPluginGoToResult=function(){var e=p(regeneratorRuntime.mark((function e(t){var r,a,i,s,o,c,h,u,v,g,f,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(r=this.searchResults)||void 0===r?void 0:r.matches[t],i=this.leafNumToIndex(a.par[0].page),s=this._models.book,o=s.getPage(i),c=Math.abs(this.currentIndex()-i)<3,h=!1,o.isViewable){e.next=13;break}return e.next=9,fetch("/services/bookreader/request_page?"+new URLSearchParams({id:this.options.bookId,subprefix:this.options.subPrefix,leafNum:o.leafNum})).then((function(e){return e.json()}));case 9:u=e.sent,v=d(u.value);try{for(v.s();!(g=v.n()).done;)f=g.value,s.getPage(s.leafNumToIndex(f)).makeViewable()}catch(e){v.e(e)}finally{v.f()}u.value.length||(s.getPage(i).makeViewable(),h=!0);case 13:return this._isIndexDisplayed(i)||(this.suppressFragmentChange=!1,this.jumpToIndex(i)),h&&s.getPage(i).makeViewable(!1),e.next=17,(0,n.poll)((function(){return l("rect.match-index-".concat(a.matchIndex))}),{until:function(e){return e.length>0}});case 17:if(!(p=e.sent).length){e.next=24;break}return p.css("animation","none"),p[0].scrollIntoView({block:this.constMode1up==this.mode||this.isFullscreenActive?"center":"nearest",inline:"center",behavior:c?"smooth":"auto"}),e.next=23,new Promise((function(e){return setTimeout(e,100)}));case 23:p.removeAttr("style");case 24:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),BookReader.prototype.removeSearchResults=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.removeSearchHilites(),this.searchTerm=null,this.searchResults=null,e||this.trigger(BookReader.eventNames.fragmentChange)},BookReader.prototype.searchHighlightVisible=function(){var e=this,t=this.searchResults,r=[];if(null==t)return!1;if(this.constMode2up==this.mode)r=[this.twoPage.currentIndexL,this.twoPage.currentIndexR];else{if(this.constMode1up!=this.mode)return!1;r=[this.currentIndex()]}return t.matches.some((function(t){return t.par[0].boxes.some((function(t){var n=e.leafNumToIndex(t.page);if(h.inArray(n,r)>=0)return!0}))})),!1}},2814:function(e,t,r){var n=r(7854),a=r(7293),i=r(1702),s=r(1340),o=r(3111).trim,c=r(1361),h=i("".charAt),l=n.parseFloat,u=n.Symbol,d=u&&u.iterator,v=1/l(c+"-0")!=-1/0||d&&!a((function(){l(Object(d))}));e.exports=v?function(e){var t=o(s(e)),r=l(t);return 0===r&&"-"==h(t,0)?-0:r}:l},9720:function(e,t,r){var n=r(2109),a=r(4699).entries;n({target:"Object",stat:!0},{entries:function(e){return a(e)}})},4678:function(e,t,r){var n=r(2109),a=r(2814);n({global:!0,forced:parseFloat!=a},{parseFloat:a})}},function(e){e(e.s=8011)}]);
|
2
2
|
//# sourceMappingURL=plugin.search.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plugins/plugin.search.js","mappings":"4iBA6CwCA,ECmYxC,EAhbMC,WASJ,cAAwD,IAA1CC,EAA0C,EAA1CA,GAA0C,IAAtCC,wBAAAA,OAAsC,MAAZ,aAAY,G,4FAAA,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M,GACnB,OAAOA,EAAM5B,IAAI,GAAG6I,MAAM4F,MAAK,SAAA3C,GAC7B,IAAMhK,EAAY,EAAKC,eAAe+J,EAAI7L,MAC1C,GAAI6G,EAAO4H,QAAQ5M,EAAWuM,IAAiB,EAC7C,OAAO,SAKN,I,qBEveT,IAAIM,EAAS,EAAQ,MACjBC,EAAQ,EAAQ,MAChBC,EAAc,EAAQ,MACtBC,EAAW,EAAQ,MACnBC,EAAO,aACPC,EAAc,EAAQ,MAEtBC,EAASJ,EAAY,GAAGI,QACxBC,EAAeP,EAAO1C,WACtBkD,EAASR,EAAOQ,OAChBC,EAAWD,GAAUA,EAAOE,SAC5BC,EAAS,EAAIJ,EAAaF,EAAc,QAAU,KAEhDI,IAAaR,GAAM,WAAcM,EAAavD,OAAOyD,OAI3DG,EAAOC,QAAUF,EAAS,SAAoBG,GAC5C,IAAIC,EAAgBX,EAAKD,EAASW,IAC9B/B,EAASwB,EAAaQ,GAC1B,OAAkB,IAAXhC,GAA4C,KAA5BuB,EAAOS,EAAe,IAAa,EAAIhC,GAC5DwB,G,qBCrBJ,IAAI7R,EAAI,EAAQ,MACZsS,EAAW,gBAIftS,EAAE,CAAEwG,OAAQ,SAAU+L,MAAM,GAAQ,CAClCxE,QAAS,SAAiByE,GACxB,OAAOF,EAASE,O,qBCPpB,IAAIxS,EAAI,EAAQ,MACZyS,EAAc,EAAQ,MAI1BzS,EAAE,CAAEsR,QAAQ,EAAMoB,OAAQ9D,YAAc6D,GAAe,CACrD7D,WAAY6D,M","sources":["webpack://@internetarchive/bookreader/./src/plugins/search/plugin.search.js","webpack://@internetarchive/bookreader/./src/plugins/search/view.js","webpack://@internetarchive/bookreader/./node_modules/core-js/internals/number-parse-float.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.object.entries.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.parse-float.js"],"sourcesContent":["// @ts-check\n/* global BookReader */\n/**\n * Plugin for Archive.org book search\n * NOTE: This script must be loaded AFTER `plugin.mobile_nav.js`\n * as it mutates mobile nav drawer\n *\n * Events fired at various points throughout search processing are published\n * on the document DOM element. These can be subscribed to using jQuery's event\n * binding method `$.fn.on`. All of the events are prefixed with a BookReader\n * namespace. The events are:\n *\n * @event BookReader:SearchStarted - When a search form is submitted, immediately\n * before an AJAX call is made to request search results\n * @event BookReader:SearchCallback - When the search AJAX call is returned and at\n * least one result is returned. The event callback receives an object\n * with the `results`, plugin `options`, and the BookReader `instance`\n * @event BookReader:SearchCallbackError - When the AJAX request returns an error.\n * Receives the `results` and `instance`\n * @event BookReader:SearchCallbackNotIndexed - When a message is received that\n * the book has not had OCR text indexed yet. Receives `instance`\n * @event BookReader:SearchCallbackEmpty - When no results found. Receives\n * `instance`\n * @event BookReader:SearchCanceled - When no results found. Receives\n * `instance`\n */\nimport { poll } from '../../BookReader/utils.js';\nimport { renderBoxesInPageContainerLayer } from '../../BookReader/PageContainer.js';\nimport SearchView from './view.js';\n/** @typedef {import('../../BookReader/PageContainer').PageContainer} PageContainer */\n/** @typedef {import('../../BookReader/BookModel').PageIndex} PageIndex */\n/** @typedef {import('../../BookReader/BookModel').LeafNum} LeafNum */\n/** @typedef {import('../../BookReader/BookModel').PageNumString} PageNumString */\n\njQuery.extend(BookReader.defaultOptions, {\n server: 'ia600609.us.archive.org',\n bookId: '',\n subPrefix: '',\n bookPath: '',\n enableSearch: true,\n searchInsideUrl: '/fulltext/inside.php',\n initialSearchTerm: null,\n});\n\n/** @override */\nBookReader.prototype.setup = (function (super_) {\n return function (options) {\n super_.call(this, options);\n\n this.searchTerm = '';\n this.searchResults = null;\n this.searchInsideUrl = options.searchInsideUrl;\n this.enableSearch = options.enableSearch;\n\n // Base server used by some api calls\n this.bookId = options.bookId;\n this.server = options.server;\n this.subPrefix = options.subPrefix;\n this.bookPath = options.bookPath;\n\n this.searchXHR = null;\n this._cancelSearch.bind(this);\n this.cancelSearchRequest.bind(this);\n\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n this._searchBoxesByIndex = {};\n\n this.searchView = undefined;\n };\n})(BookReader.prototype.setup);\n\n/** @override */\nBookReader.prototype.init = (function (super_) {\n return function () {\n super_.call(this);\n // give SearchView the most complete bookreader state\n this.searchView = new SearchView({\n br: this,\n searchCancelledCallback: () => {\n this._cancelSearch();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n });\n if (this.options.enableSearch && this.options.initialSearchTerm) {\n /**\n * this.search() take two parameter\n * 1. this.options.initialSearchTerm - search term\n * 2. {\n * goToFirstResult: this.options.goToFirstResult,\n * suppressFragmentChange: false // always want to change fragment in URL\n * }\n */\n this.search(\n this.options.initialSearchTerm,\n { goToFirstResult: this.options.goToFirstResult, suppressFragmentChange: false }\n );\n }\n };\n})(BookReader.prototype.init);\n\n/** @override */\nBookReader.prototype.buildToolbarElement = (function (super_) {\n return function () {\n const $el = super_.call(this);\n if (!this.enableSearch) { return; }\n if (this.searchView.dom.toolbarSearch) {\n $el.find('.BRtoolbarSectionInfo').after(this.searchView.dom.toolbarSearch);\n }\n return $el;\n };\n})(BookReader.prototype.buildToolbarElement);\n\n/** @override */\nBookReader.prototype._createPageContainer = (function (super_) {\n return function (index) {\n const pageContainer = super_.call(this, index);\n if (this.enableSearch && pageContainer.page && index in this._searchBoxesByIndex) {\n const pageIndex = pageContainer.page.index;\n const boxes = this._searchBoxesByIndex[pageIndex];\n renderBoxesInPageContainerLayer(\n 'searchHiliteLayer',\n boxes,\n pageContainer.page,\n pageContainer.$container[0],\n boxes.map(b => `match-index-${b.matchIndex}`),\n );\n }\n return pageContainer;\n };\n})(BookReader.prototype._createPageContainer);\n\n/**\n * @typedef {object} SearchOptions\n * @property {boolean} goToFirstResult\n * @property {boolean} disablePopup\n * @property {(null|function)} error - @deprecated at v.5.0\n * @property {(null|function)} success - @deprecated at v.5.0\n */\n\n/**\n * Submits search request\n *\n * @param {string} term\n * @param {SearchOptions} overrides\n */\nBookReader.prototype.search = async function(term = '', overrides = {}) {\n /** @type {SearchOptions} */\n const defaultOptions = {\n goToFirstResult: false, /* jump to the first result (default=false) */\n disablePopup: false, /* don't show the modal progress (default=false) */\n suppressFragmentChange: false, /* don't change the URL on initial load */\n error: null, /* optional error handler (default=null) */\n success: null, /* optional success handler (default=null) */\n\n };\n const options = jQuery.extend({}, defaultOptions, overrides);\n this.suppressFragmentChange = options.suppressFragmentChange;\n this.searchCancelled = false;\n\n // strip slashes, since this goes in the url\n this.searchTerm = term.replace(/\\//g, ' ');\n\n if (!options.suppressFragmentChange) {\n this.trigger(BookReader.eventNames.fragmentChange);\n }\n\n // Add quotes to the term. This is to compenstate for the backends default OR query\n // term = term.replace(/['\"]+/g, '');\n // term = '\"' + term + '\"';\n\n // Remove the port and userdir\n const serverPath = this.server.replace(/:.+/, '');\n const baseUrl = `https://${serverPath}${this.searchInsideUrl}?`;\n\n // Remove subPrefix from end of path\n let path = this.bookPath;\n const subPrefixWithSlash = `/${this.subPrefix}`;\n if (this.bookPath.length - this.bookPath.lastIndexOf(subPrefixWithSlash) == subPrefixWithSlash.length) {\n path = this.bookPath.substr(0, this.bookPath.length - subPrefixWithSlash.length);\n }\n\n const urlParams = {\n item_id: this.bookId,\n doc: this.subPrefix,\n path,\n q: term,\n };\n\n // NOTE that the API does not expect / (slashes) to be encoded. (%2F) won't work\n const paramStr = $.param(urlParams).replace(/%2F/g, '/');\n\n const url = `${baseUrl}${paramStr}`;\n\n const callSearchResultsCallback = (searchInsideResults) => {\n if (this.searchCancelled) {\n return;\n }\n const responseHasError = searchInsideResults.error || !searchInsideResults.matches.length;\n const hasCustomError = typeof options.error === 'function';\n const hasCustomSuccess = typeof options.success === 'function';\n\n if (responseHasError) {\n hasCustomError\n ? options.error.call(this, searchInsideResults, options)\n : this.BRSearchCallbackError(searchInsideResults, options);\n } else {\n hasCustomSuccess\n ? options.success.call(this, searchInsideResults, options)\n : this.BRSearchCallback(searchInsideResults, options);\n }\n };\n\n this.trigger('SearchStarted', { term: this.searchTerm, instance: this });\n callSearchResultsCallback(await $.ajax({\n url: url,\n dataType: 'jsonp',\n cache: true,\n beforeSend: xhr => { this.searchXHR = xhr; },\n }));\n};\n\n/**\n * cancels AJAX Call\n * emits custom event\n */\nBookReader.prototype._cancelSearch = function () {\n this.searchXHR?.abort();\n this.searchView.clearSearchFieldAndResults(false);\n this.searchTerm = '';\n this.searchXHR = null;\n this.searchCancelled = true;\n this.searchResults = [];\n};\n\n/**\n * External function to cancel search\n * checks for term & xhr in flight before running\n */\nBookReader.prototype.cancelSearchRequest = function () {\n this.searchCancelled = true;\n if (this.searchXHR !== null) {\n this._cancelSearch();\n this.searchView.toggleSearchPending();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n};\n\n/**\n * @typedef {object} SearchInsideMatchBox\n * @property {number} page\n * @property {number} r\n * @property {number} l\n * @property {number} b\n * @property {number} t\n * @property {HTMLDivElement} [div]\n * @property {number} matchIndex This is a fake field! not part of the API response. The index of the match that contains this box in total search results matches.\n */\n\n/**\n * @typedef {object} SearchInsideMatch\n * @property {number} matchIndex This is a fake field! Not part of the API response. It is added by the JS.\n * @property {string} displayPageNumber (fake field) The page number as it should be displayed in the UI.\n * @property {string} text\n * @property {Array<{ page: number, boxes: SearchInsideMatchBox[] }>} par\n */\n\n/**\n * @typedef {object} SearchInsideResults\n * @property {string} error\n * @property {SearchInsideMatch[]} matches\n * @property {boolean} indexed\n */\n\n/**\n * Attach some fields to search inside results\n * @param {SearchInsideResults} results\n * @param {(pageNum: LeafNum) => PageNumString} displayPageNumberFn\n */\nexport function marshallSearchResults(results, displayPageNumberFn) {\n // Attach matchIndex to a few things to make it easier to identify\n // an active/selected match\n for (const [index, match] of results.matches.entries()) {\n match.matchIndex = index;\n match.displayPageNumber = displayPageNumberFn(match.par[0].page);\n for (const par of match.par) {\n for (const box of par.boxes) {\n box.matchIndex = index;\n }\n }\n }\n}\n\n/**\n * Search Results return handler\n * @param {SearchInsideResults} results\n * @param {object} options\n * @param {boolean} options.goToFirstResult\n */\nBookReader.prototype.BRSearchCallback = function(results, options) {\n marshallSearchResults(results, pageNum => this.getPageNum(this.leafNumToIndex(pageNum)));\n this.searchResults = results || [];\n\n this.updateSearchHilites();\n this.removeProgressPopup();\n if (options.goToFirstResult) {\n this._searchPluginGoToResult(0);\n }\n this.trigger('SearchCallback', { results, options, instance: this });\n};\n\n/**\n * Main search results error handler\n * @callback\n * @param {SearchInsideResults} results\n */\nBookReader.prototype.BRSearchCallbackError = function(results) {\n this._BRSearchCallbackError(results);\n};\n\n/**\n * @private draws search results error\n * @callback\n * @param {SearchInsideResults} results\n * @param {jQuery} $el\n * @param {boolean} fade\n */\nBookReader.prototype._BRSearchCallbackError = function(results) {\n this.searchResults = results;\n const basePayload = {\n term: this.searchTerm,\n instance: this,\n };\n if (results.error) {\n const payload = Object.assign({}, basePayload, { results });\n this.trigger('SearchCallbackError', payload);\n } else if (0 == results.matches.length) {\n if (false === results.indexed) {\n this.trigger('SearchCallbackBookNotIndexed', basePayload);\n return;\n }\n this.trigger('SearchCallbackEmpty', basePayload);\n }\n};\n\n/**\n * updates search on-page highlights controller\n */\nBookReader.prototype.updateSearchHilites = function() {\n /** @type {SearchInsideMatch[]} */\n const matches = this.searchResults?.matches || [];\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n const boxesByIndex = {};\n\n // Clear any existing svg layers\n this.removeSearchHilites();\n\n // Group by pageIndex\n for (const match of matches) {\n for (const box of match.par[0].boxes) {\n const pageIndex = this.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._models.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 pageIndex = this.leafNumToIndex(match.par[0].page);\n const { book } = this._models;\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 /* 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.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 if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('[data-id=resultsCount]').text(this.resultsPosition());\n }\n\n updateSearchNavigationButtons() {\n if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('.prev').attr('disabled', !this.currentMatchIndex);\n this.dom.searchNavigation.find('.next').attr('disabled', this.currentMatchIndex + 1 === this.matches.length);\n }\n\n teardownSearchNavigation() {\n if (!this.dom.searchNavigation) {\n this.dom.searchNavigation = $('.BRsearch-navigation');\n }\n if (!this.dom.searchNavigation.length) { return; }\n\n this.dom.searchNavigation.off('.searchNavigation').remove();\n this.dom.searchNavigation = null;\n this.br.resize();\n }\n\n setCurrentMatchIndex() {\n let matchingSearchResult;\n if (this.br.mode === this.br.constModeThumb) {\n this.currentMatchIndex = -1;\n return;\n }\n if (this.br.mode === this.br.constMode2up) {\n matchingSearchResult = this.find2upMatchingSearchResult();\n }\n else {\n matchingSearchResult = this.find1upMatchingSearchResult();\n }\n this.currentMatchIndex = this.matches.indexOf(matchingSearchResult);\n }\n\n find1upMatchingSearchResult() {\n return this.matches.find((m) => this.br.currentIndex() === m.par[0].page - 1);\n }\n\n find2upMatchingSearchResult() {\n return this.matches.find((m) => this.br._isIndexDisplayed(m.par[0].page - 1));\n }\n\n updateSearchNavigation() {\n if (!this.matches.length) { return; }\n\n this.setCurrentMatchIndex();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n /**\n * @param {boolean} bool\n */\n togglePinsFor(bool) {\n const pinsVisibleState = bool ? 'visible' : 'hidden';\n this.br.refs.$BRfooter.find('.BRsearch').css({ visibility: pinsVisibleState });\n }\n\n buildToolbarSearch() {\n const toolbarSearch = document.createElement('span');\n toolbarSearch.classList.add('BRtoolbarSection', 'BRtoolbarSectionSearch');\n toolbarSearch.innerHTML = `\n <form class=\"BRbooksearch desktop\">\n <input type=\"search\" name=\"query\" class=\"BRsearchInput\" value=\"\" placeholder=\"Search inside\"/>\n <button type=\"submit\" class=\"BRsearchSubmit\">\n <img src=\"${this.br.imagesBaseURL}icon_search_button.svg\" />\n </button>\n </form>\n `;\n return toolbarSearch;\n }\n\n /**\n * @param {array} matches\n */\n renderPins(matches) {\n matches.forEach((match) => {\n const queryString = match.text;\n const pageIndex = this.br.leafNumToIndex(match.par[0].page);\n const uiStringSearch = \"Search result\"; // 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>Page ${match.displayPageNumber}</div>\n </div>\n `)\n .appendTo(this.br.$('.BRnavline'))\n .on(\"mouseenter\", (event) => {\n // remove from other markers then turn on just for this\n // XXX should be done when nav slider moves\n const marker = event.currentTarget;\n const tooltip = marker.querySelector('.BRquery');\n const tooltipOffset = tooltip.getBoundingClientRect();\n const targetOffset = marker.getBoundingClientRect();\n const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;\n if (tooltipOffset.x - boxSizeAdjust < 0) {\n tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);\n }\n $('.BRsearch,.BRchapter').removeClass('front');\n $(event.target).addClass('front');\n })\n .on(\"mouseleave\", (event) => $(event.target).removeClass('front'))\n .on(\"click\", () => { this.br._searchPluginGoToResult(match.matchIndex); });\n });\n }\n\n /**\n * @param {boolean} bool\n */\n toggleSearchPending(bool) {\n if (bool) {\n this.br.showProgressPopup(\"Search results will appear below...\", () => this.progressPopupClosed());\n }\n else {\n this.br.removeProgressPopup();\n }\n }\n\n /**\n * Primary callback when user cancels search popup\n */\n progressPopupClosed() {\n this.toggleSearchPending();\n this.cancelSearch();\n }\n\n renderErrorModal(textIsProcessing = false) {\n const errorDetails = `${!textIsProcessing ? 'The text may still be processing. ' : ''}Please try again.`;\n this.renderModalMessage(`\n Sorry, there was an error with your search.\n <br />\n ${errorDetails}\n `);\n this.delayModalRemovalFor(4000);\n }\n\n renderBookNotIndexedModal() {\n this.renderModalMessage(`\n <p>\n This book hasn't been indexed for searching yet.\n We've just started indexing it, so search should be available soon.\n <br />\n Please try again later. Thanks!\n </p>\n `);\n this.delayModalRemovalFor(5000);\n }\n\n renderResultsEmptyModal() {\n this.renderModalMessage('No matches were found.');\n this.delayModalRemovalFor(2000);\n }\n\n /**\n * @param {string} messageHTML The innerHTML string used to popupate the modal contents\n */\n renderModalMessage(messageHTML) {\n const modal = document.createElement('div');\n modal.classList.add('BRprogresspopup', 'search_modal');\n modal.innerHTML = messageHTML;\n document.querySelector(this.br.el).append(modal);\n }\n\n /**\n * @param {number} timeoutMS\n */\n delayModalRemovalFor(timeoutMS) {\n setTimeout(this.br.removeProgressPopup.bind(this.br), timeoutMS);\n }\n\n /**\n * @param {Event} e\n */\n submitHandler(e) {\n e.preventDefault();\n const query = e.target.querySelector('[name=\"query\"]').value;\n if (!query.length) { return false; }\n this.br.search(query);\n this.emptyMatches();\n this.toggleSearchPending(true);\n return false;\n }\n\n /**\n * @param {Event} e\n * @param {object} properties\n * @param {object} properties.results\n * @param {object} properties.options\n */\n handleSearchCallback(e, { results, options }) {\n this.matches = results.matches;\n this.setCurrentMatchIndex();\n this.teardownSearchNavigation();\n this.renderSearchNavigation();\n this.bindSearchNavigationEvents();\n this.renderPins(results.matches);\n this.toggleSearchPending(false);\n if (options.goToFirstResult) {\n $(document).one('BookReader:pageChanged', () => {\n this.br.resize();\n });\n } else {\n this.br.resize();\n }\n }\n\n /**\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 global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar toString = require('../internals/to-string');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar charAt = uncurryThis(''.charAt);\nvar n$ParseFloat = global.parseFloat;\nvar Symbol = global.Symbol;\nvar ITERATOR = Symbol && Symbol.iterator;\nvar FORCED = 1 / n$ParseFloat(whitespaces + '-0') !== -Infinity\n // MS Edge 18- broken with boxed symbols\n || (ITERATOR && !fails(function () { n$ParseFloat(Object(ITERATOR)); }));\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(toString(string));\n var result = n$ParseFloat(trimmedString);\n return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;\n} : n$ParseFloat;\n","var $ = require('../internals/export');\nvar $entries = require('../internals/object-to-array').entries;\n\n// `Object.entries` method\n// https://tc39.es/ecma262/#sec-object.entries\n$({ target: 'Object', stat: true }, {\n entries: function entries(O) {\n return $entries(O);\n }\n});\n","var $ = require('../internals/export');\nvar $parseFloat = require('../internals/number-parse-float');\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\n$({ global: true, forced: parseFloat != $parseFloat }, {\n parseFloat: $parseFloat\n});\n"],"names":["super_","SearchView","br","searchCancelledCallback","this","matcher","RegExp","matches","cacheDOMElements","bindEvents","cancelSearch","dom","toolbarSearch","buildToolbarSearch","query","$","val","remove","dispatchEventWhenComplete","removeSearchResults","removeResultPins","emptyMatches","setQuery","teardownSearchNavigation","trigger","selector","before","resultsPosition","searchNavigation","positionMessage","length","currentMatchIndex","namespace","on","clearSearchFieldAndResults","bind","showPrevResult","showNextResult","toggleSidebar","mode","constModeThumb","switchMode","constMode1up","getClosestMatchIndex","start","end","comparator","eq","click","updateResultsPosition","updateSearchNavigationButtons","comparisonFn","closestPage","closestTo","pool","slice","map","m","par","page","currentIndex","indexOf","find","text","attr","off","resize","matchingSearchResult","constMode2up","find2upMatchingSearchResult","find1upMatchingSearchResult","_isIndexDisplayed","setCurrentMatchIndex","bool","pinsVisibleState","refs","$BRfooter","css","visibility","document","createElement","classList","add","innerHTML","imagesBaseURL","forEach","match","queryString","pageIndex","leafNumToIndex","percentThrough","constructor","util","cssPercentage","getNumLeafs","queryStringWithB","replace","queryStringWithBTruncated","addClass","left","append","displayPageNumber","appendTo","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","x","style","setProperty","removeClass","target","_searchPluginGoToResult","matchIndex","showProgressPopup","progressPopupClosed","removeProgressPopup","toggleSearchPending","textIsProcessing","errorDetails","renderModalMessage","delayModalRemovalFor","messageHTML","modal","el","timeoutMS","setTimeout","e","preventDefault","value","search","results","options","renderSearchNavigation","bindSearchNavigationEvents","renderPins","goToFirstResult","one","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","_searchBoxesByIndex","searchView","undefined","init","term","instance","suppressFragmentChange","buildToolbarElement","$el","after","_createPageContainer","index","pageContainer","boxes","renderBoxesInPageContainerLayer","$container","b","overrides","disablePopup","error","success","searchCancelled","eventNames","fragmentChange","serverPath","baseUrl","path","subPrefixWithSlash","lastIndexOf","substr","urlParams","item_id","doc","q","paramStr","param","url","callSearchResultsCallback","searchInsideResults","responseHasError","hasCustomError","hasCustomSuccess","BRSearchCallbackError","BRSearchCallback","ajax","dataType","cache","beforeSend","xhr","abort","displayPageNumberFn","pageNum","entries","getPageNum","marshallSearchResults","updateSearchHilites","_BRSearchCallbackError","basePayload","payload","Object","assign","boxesByIndex","box","push","pageIndexString","parseFloat","_models","book","getPage","getActivePageContainerElementsForIndex","container","getActivePageContainerElements","onNearbyPage","Math","abs","makeUnviewableAtEnd","isViewable","fetch","URLSearchParams","id","subprefix","leafNum","then","r","json","resp","makeViewable","jumpToIndex","poll","until","result","$boxes","scrollIntoView","block","isFullscreenActive","inline","behavior","Promise","resolve","removeAttr","searchHighlightVisible","visiblePages","twoPage","currentIndexL","currentIndexR","some","inArray","global","fails","uncurryThis","toString","trim","whitespaces","charAt","n$ParseFloat","Symbol","ITERATOR","iterator","FORCED","module","exports","string","trimmedString","$entries","stat","O","$parseFloat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AUmM,MAAM,GAAQ,CAClCxE,QAAS,SAAiByE,GACxB,OAAOF,EAASE,O,qBCPpB,IAAI5S,EAAI,EAAQ,MACZ6S,EAAc,EAAQ,MAI1B7S,EAAE,CAAE0R,QAAQ,EAAMoB,OAAQ9D,YAAc6D,GAAe,CACrD7D,WAAY6D,M","sources":["webpack://@internetarchive/bookreader/./src/plugins/search/plugin.search.js","webpack://@internetarchive/bookreader/./src/plugins/search/view.js","webpack://@internetarchive/bookreader/./node_modules/core-js/internals/number-parse-float.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.object.entries.js","webpack://@internetarchive/bookreader/./node_modules/core-js/modules/es.parse-float.js"],"sourcesContent":["// @ts-check\n/* global BookReader */\n/**\n * Plugin for Archive.org book search\n * NOTE: This script must be loaded AFTER `plugin.mobile_nav.js`\n * as it mutates mobile nav drawer\n *\n * Events fired at various points throughout search processing are published\n * on the document DOM element. These can be subscribed to using jQuery's event\n * binding method `$.fn.on`. All of the events are prefixed with a BookReader\n * namespace. The events are:\n *\n * @event BookReader:SearchStarted - When a search form is submitted, immediately\n * before an AJAX call is made to request search results\n * @event BookReader:SearchCallback - When the search AJAX call is returned and at\n * least one result is returned. The event callback receives an object\n * with the `results`, plugin `options`, and the BookReader `instance`\n * @event BookReader:SearchCallbackError - When the AJAX request returns an error.\n * Receives the `results` and `instance`\n * @event BookReader:SearchCallbackNotIndexed - When a message is received that\n * the book has not had OCR text indexed yet. Receives `instance`\n * @event BookReader:SearchCallbackEmpty - When no results found. Receives\n * `instance`\n * @event BookReader:SearchCanceled - When no results found. Receives\n * `instance`\n */\nimport { poll } from '../../BookReader/utils.js';\nimport { renderBoxesInPageContainerLayer } from '../../BookReader/PageContainer.js';\nimport SearchView from './view.js';\n/** @typedef {import('../../BookReader/PageContainer').PageContainer} PageContainer */\n/** @typedef {import('../../BookReader/BookModel').PageIndex} PageIndex */\n/** @typedef {import('../../BookReader/BookModel').LeafNum} LeafNum */\n/** @typedef {import('../../BookReader/BookModel').PageNumString} PageNumString */\n\njQuery.extend(BookReader.defaultOptions, {\n server: 'ia600609.us.archive.org',\n bookId: '',\n subPrefix: '',\n bookPath: '',\n enableSearch: true,\n searchInsideUrl: '/fulltext/inside.php',\n initialSearchTerm: null,\n});\n\n/** @override */\nBookReader.prototype.setup = (function (super_) {\n return function (options) {\n super_.call(this, options);\n\n this.searchTerm = '';\n this.searchResults = null;\n this.searchInsideUrl = options.searchInsideUrl;\n this.enableSearch = options.enableSearch;\n\n // Base server used by some api calls\n this.bookId = options.bookId;\n this.server = options.server;\n this.subPrefix = options.subPrefix;\n this.bookPath = options.bookPath;\n\n this.searchXHR = null;\n this._cancelSearch.bind(this);\n this.cancelSearchRequest.bind(this);\n\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n this._searchBoxesByIndex = {};\n\n this.searchView = undefined;\n };\n})(BookReader.prototype.setup);\n\n/** @override */\nBookReader.prototype.init = (function (super_) {\n return function () {\n super_.call(this);\n // give SearchView the most complete bookreader state\n this.searchView = new SearchView({\n br: this,\n searchCancelledCallback: () => {\n this._cancelSearch();\n this.trigger('SearchCanceled', { term: this.searchTerm, instance: this });\n }\n });\n if (this.options.enableSearch && this.options.initialSearchTerm) {\n /**\n * this.search() take two parameter\n * 1. this.options.initialSearchTerm - search term\n * 2. {\n * goToFirstResult: this.options.goToFirstResult,\n * suppressFragmentChange: false // always want to change fragment in URL\n * }\n */\n this.search(\n this.options.initialSearchTerm,\n { goToFirstResult: this.options.goToFirstResult, suppressFragmentChange: false }\n );\n }\n };\n})(BookReader.prototype.init);\n\n/** @override */\nBookReader.prototype.buildToolbarElement = (function (super_) {\n return function () {\n const $el = super_.call(this);\n if (!this.enableSearch) { return; }\n if (this.searchView.dom.toolbarSearch) {\n $el.find('.BRtoolbarSectionInfo').after(this.searchView.dom.toolbarSearch);\n }\n return $el;\n };\n})(BookReader.prototype.buildToolbarElement);\n\n/** @override */\nBookReader.prototype._createPageContainer = (function (super_) {\n return function (index) {\n const pageContainer = super_.call(this, index);\n if (this.enableSearch && pageContainer.page && index in this._searchBoxesByIndex) {\n const pageIndex = pageContainer.page.index;\n const boxes = this._searchBoxesByIndex[pageIndex];\n renderBoxesInPageContainerLayer(\n 'searchHiliteLayer',\n boxes,\n pageContainer.page,\n pageContainer.$container[0],\n boxes.map(b => `match-index-${b.matchIndex}`),\n );\n }\n return pageContainer;\n };\n})(BookReader.prototype._createPageContainer);\n\n/**\n * @typedef {object} SearchOptions\n * @property {boolean} goToFirstResult\n * @property {boolean} disablePopup\n * @property {(null|function)} error - @deprecated at v.5.0\n * @property {(null|function)} success - @deprecated at v.5.0\n */\n\n/**\n * Submits search request\n *\n * @param {string} term\n * @param {SearchOptions} overrides\n */\nBookReader.prototype.search = async function(term = '', overrides = {}) {\n /** @type {SearchOptions} */\n const defaultOptions = {\n goToFirstResult: false, /* jump to the first result (default=false) */\n disablePopup: false, /* don't show the modal progress (default=false) */\n suppressFragmentChange: false, /* don't change the URL on initial load */\n error: null, /* optional error handler (default=null) */\n success: null, /* optional success handler (default=null) */\n\n };\n const options = jQuery.extend({}, defaultOptions, overrides);\n this.suppressFragmentChange = options.suppressFragmentChange;\n this.searchCancelled = false;\n\n // strip slashes, since this goes in the url\n this.searchTerm = term.replace(/\\//g, ' ');\n\n if (!options.suppressFragmentChange) {\n this.trigger(BookReader.eventNames.fragmentChange);\n }\n\n // Add quotes to the term. This is to compenstate for the backends default OR query\n // term = term.replace(/['\"]+/g, '');\n // term = '\"' + term + '\"';\n\n // Remove the port and userdir\n const serverPath = this.server.replace(/:.+/, '');\n const baseUrl = `https://${serverPath}${this.searchInsideUrl}?`;\n\n // Remove subPrefix from end of path\n let path = this.bookPath;\n const subPrefixWithSlash = `/${this.subPrefix}`;\n if (this.bookPath.length - this.bookPath.lastIndexOf(subPrefixWithSlash) == subPrefixWithSlash.length) {\n path = this.bookPath.substr(0, this.bookPath.length - subPrefixWithSlash.length);\n }\n\n const urlParams = {\n item_id: this.bookId,\n doc: this.subPrefix,\n path,\n q: term,\n };\n\n // NOTE that the API does not expect / (slashes) to be encoded. (%2F) won't work\n const paramStr = $.param(urlParams).replace(/%2F/g, '/');\n\n const url = `${baseUrl}${paramStr}`;\n\n const callSearchResultsCallback = (searchInsideResults) => {\n if (this.searchCancelled) {\n return;\n }\n const responseHasError = searchInsideResults.error || !searchInsideResults.matches.length;\n const hasCustomError = typeof options.error === 'function';\n const hasCustomSuccess = typeof options.success === 'function';\n\n if (responseHasError) {\n 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 if (!this.searchTerm) {\n this.bookreader?.urlPlugin?.removeUrlParam('q');\n } else {\n this.bookreader?.urlPlugin?.setUrlParam('q', this.searchTerm);\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 this.bookreader?.urlPlugin?.removeUrlParam('q');\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 this?.urlPlugin?.removeUrlParam('q');\n};\n\n/**\n * @typedef {object} SearchInsideMatchBox\n * @property {number} page\n * @property {number} r\n * @property {number} l\n * @property {number} b\n * @property {number} t\n * @property {HTMLDivElement} [div]\n * @property {number} matchIndex This is a fake field! not part of the API response. The index of the match that contains this box in total search results matches.\n */\n\n/**\n * @typedef {object} SearchInsideMatch\n * @property {number} matchIndex This is a fake field! Not part of the API response. It is added by the JS.\n * @property {string} displayPageNumber (fake field) The page number as it should be displayed in the UI.\n * @property {string} text\n * @property {Array<{ page: number, boxes: SearchInsideMatchBox[] }>} par\n */\n\n/**\n * @typedef {object} SearchInsideResults\n * @property {string} error\n * @property {SearchInsideMatch[]} matches\n * @property {boolean} indexed\n */\n\n/**\n * Attach some fields to search inside results\n * @param {SearchInsideResults} results\n * @param {(pageNum: LeafNum) => PageNumString} displayPageNumberFn\n */\nexport function marshallSearchResults(results, displayPageNumberFn) {\n // Attach matchIndex to a few things to make it easier to identify\n // an active/selected match\n for (const [index, match] of results.matches.entries()) {\n match.matchIndex = index;\n match.displayPageNumber = displayPageNumberFn(match.par[0].page);\n for (const par of match.par) {\n for (const box of par.boxes) {\n box.matchIndex = index;\n }\n }\n }\n}\n\n/**\n * Search Results return handler\n * @param {SearchInsideResults} results\n * @param {object} options\n * @param {boolean} options.goToFirstResult\n */\nBookReader.prototype.BRSearchCallback = function(results, options) {\n marshallSearchResults(results, pageNum => this.getPageNum(this.leafNumToIndex(pageNum)));\n this.searchResults = results || [];\n\n this.updateSearchHilites();\n this.removeProgressPopup();\n if (options.goToFirstResult) {\n this._searchPluginGoToResult(0);\n }\n this.trigger('SearchCallback', { results, options, instance: this });\n};\n\n/**\n * Main search results error handler\n * @callback\n * @param {SearchInsideResults} results\n */\nBookReader.prototype.BRSearchCallbackError = function(results) {\n this._BRSearchCallbackError(results);\n};\n\n/**\n * @private draws search results error\n * @callback\n * @param {SearchInsideResults} results\n * @param {jQuery} $el\n * @param {boolean} fade\n */\nBookReader.prototype._BRSearchCallbackError = function(results) {\n this.searchResults = results;\n const basePayload = {\n term: this.searchTerm,\n instance: this,\n };\n if (results.error) {\n const payload = Object.assign({}, basePayload, { results });\n this.trigger('SearchCallbackError', payload);\n } else if (0 == results.matches.length) {\n if (false === results.indexed) {\n this.trigger('SearchCallbackBookNotIndexed', basePayload);\n return;\n }\n this.trigger('SearchCallbackEmpty', basePayload);\n }\n};\n\n/**\n * updates search on-page highlights controller\n */\nBookReader.prototype.updateSearchHilites = function() {\n /** @type {SearchInsideMatch[]} */\n const matches = this.searchResults?.matches || [];\n /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */\n const boxesByIndex = {};\n\n // Clear any existing svg layers\n this.removeSearchHilites();\n\n // Group by pageIndex\n for (const match of matches) {\n for (const box of match.par[0].boxes) {\n const pageIndex = this.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._models.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 pageIndex = this.leafNumToIndex(match.par[0].page);\n const { book } = this._models;\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 /* 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.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 if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('[data-id=resultsCount]').text(this.resultsPosition());\n }\n\n updateSearchNavigationButtons() {\n if (!this.dom.searchNavigation) return;\n this.dom.searchNavigation.find('.prev').attr('disabled', !this.currentMatchIndex);\n this.dom.searchNavigation.find('.next').attr('disabled', this.currentMatchIndex + 1 === this.matches.length);\n }\n\n teardownSearchNavigation() {\n if (!this.dom.searchNavigation) {\n this.dom.searchNavigation = $('.BRsearch-navigation');\n }\n if (!this.dom.searchNavigation.length) { return; }\n\n this.dom.searchNavigation.off('.searchNavigation').remove();\n this.dom.searchNavigation = null;\n this.br.resize();\n }\n\n setCurrentMatchIndex() {\n let matchingSearchResult;\n if (this.br.mode === this.br.constModeThumb) {\n this.currentMatchIndex = -1;\n return;\n }\n if (this.br.mode === this.br.constMode2up) {\n matchingSearchResult = this.find2upMatchingSearchResult();\n }\n else {\n matchingSearchResult = this.find1upMatchingSearchResult();\n }\n this.currentMatchIndex = this.matches.indexOf(matchingSearchResult);\n }\n\n find1upMatchingSearchResult() {\n return this.matches.find((m) => this.br.currentIndex() === m.par[0].page - 1);\n }\n\n find2upMatchingSearchResult() {\n return this.matches.find((m) => this.br._isIndexDisplayed(m.par[0].page - 1));\n }\n\n updateSearchNavigation() {\n if (!this.matches.length) { return; }\n\n this.setCurrentMatchIndex();\n this.updateResultsPosition();\n this.updateSearchNavigationButtons();\n }\n\n /**\n * @param {boolean} bool\n */\n togglePinsFor(bool) {\n const pinsVisibleState = bool ? 'visible' : 'hidden';\n this.br.refs.$BRfooter.find('.BRsearch').css({ visibility: pinsVisibleState });\n }\n\n buildToolbarSearch() {\n const toolbarSearch = document.createElement('span');\n toolbarSearch.classList.add('BRtoolbarSection', 'BRtoolbarSectionSearch');\n toolbarSearch.innerHTML = `\n <form class=\"BRbooksearch desktop\">\n <input type=\"search\" name=\"query\" class=\"BRsearchInput\" value=\"\" placeholder=\"Search inside\"/>\n <button type=\"submit\" class=\"BRsearchSubmit\">\n <img src=\"${this.br.imagesBaseURL}icon_search_button.svg\" />\n </button>\n </form>\n `;\n return toolbarSearch;\n }\n\n /**\n * @param {array} matches\n */\n renderPins(matches) {\n matches.forEach((match) => {\n const queryString = match.text;\n const pageIndex = this.br.leafNumToIndex(match.par[0].page);\n const uiStringSearch = \"Search result\"; // 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>Page ${match.displayPageNumber}</div>\n </div>\n `)\n .appendTo(this.br.$('.BRnavline'))\n .on(\"mouseenter\", (event) => {\n // remove from other markers then turn on just for this\n // XXX should be done when nav slider moves\n const marker = event.currentTarget;\n const tooltip = marker.querySelector('.BRquery');\n const tooltipOffset = tooltip.getBoundingClientRect();\n const targetOffset = marker.getBoundingClientRect();\n const boxSizeAdjust = parseInt(getComputedStyle(tooltip).paddingLeft) * 2;\n if (tooltipOffset.x - boxSizeAdjust < 0) {\n tooltip.style.setProperty('transform', `translateX(-${targetOffset.left - boxSizeAdjust}px)`);\n }\n $('.BRsearch,.BRchapter').removeClass('front');\n $(event.target).addClass('front');\n })\n .on(\"mouseleave\", (event) => $(event.target).removeClass('front'))\n .on(\"click\", () => { this.br._searchPluginGoToResult(match.matchIndex); });\n });\n }\n\n /**\n * @param {boolean} bool\n */\n toggleSearchPending(bool) {\n if (bool) {\n this.br.showProgressPopup(\"Search results will appear below...\", () => this.progressPopupClosed());\n }\n else {\n this.br.removeProgressPopup();\n }\n }\n\n /**\n * Primary callback when user cancels search popup\n */\n progressPopupClosed() {\n this.toggleSearchPending();\n this.cancelSearch();\n }\n\n renderErrorModal(textIsProcessing = false) {\n const errorDetails = `${!textIsProcessing ? 'The text may still be processing. ' : ''}Please try again.`;\n this.renderModalMessage(`\n Sorry, there was an error with your search.\n <br />\n ${errorDetails}\n `);\n this.delayModalRemovalFor(4000);\n }\n\n renderBookNotIndexedModal() {\n this.renderModalMessage(`\n <p>\n This book hasn't been indexed for searching yet.\n We've just started indexing it, so search should be available soon.\n <br />\n Please try again later. Thanks!\n </p>\n `);\n this.delayModalRemovalFor(5000);\n }\n\n renderResultsEmptyModal() {\n this.renderModalMessage('No matches were found.');\n this.delayModalRemovalFor(2000);\n }\n\n /**\n * @param {string} messageHTML The innerHTML string used to popupate the modal contents\n */\n renderModalMessage(messageHTML) {\n const modal = document.createElement('div');\n modal.classList.add('BRprogresspopup', 'search_modal');\n modal.innerHTML = messageHTML;\n document.querySelector(this.br.el).append(modal);\n }\n\n /**\n * @param {number} timeoutMS\n */\n delayModalRemovalFor(timeoutMS) {\n setTimeout(this.br.removeProgressPopup.bind(this.br), timeoutMS);\n }\n\n /**\n * @param {Event} e\n */\n submitHandler(e) {\n e.preventDefault();\n const query = e.target.querySelector('[name=\"query\"]').value;\n if (!query.length) { return false; }\n this.br.search(query);\n this.emptyMatches();\n this.toggleSearchPending(true);\n return false;\n }\n\n /**\n * @param {Event} e\n * @param {object} properties\n * @param {object} properties.results\n * @param {object} properties.options\n */\n handleSearchCallback(e, { results, options }) {\n this.matches = results.matches;\n this.setCurrentMatchIndex();\n this.teardownSearchNavigation();\n this.renderSearchNavigation();\n this.bindSearchNavigationEvents();\n this.renderPins(results.matches);\n this.toggleSearchPending(false);\n if (options.goToFirstResult) {\n $(document).one('BookReader:pageChanged', () => {\n this.br.resize();\n });\n } else {\n this.br.resize();\n }\n }\n\n /**\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 global = require('../internals/global');\nvar fails = require('../internals/fails');\nvar uncurryThis = require('../internals/function-uncurry-this');\nvar toString = require('../internals/to-string');\nvar trim = require('../internals/string-trim').trim;\nvar whitespaces = require('../internals/whitespaces');\n\nvar charAt = uncurryThis(''.charAt);\nvar n$ParseFloat = global.parseFloat;\nvar Symbol = global.Symbol;\nvar ITERATOR = Symbol && Symbol.iterator;\nvar FORCED = 1 / n$ParseFloat(whitespaces + '-0') !== -Infinity\n // MS Edge 18- broken with boxed symbols\n || (ITERATOR && !fails(function () { n$ParseFloat(Object(ITERATOR)); }));\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\nmodule.exports = FORCED ? function parseFloat(string) {\n var trimmedString = trim(toString(string));\n var result = n$ParseFloat(trimmedString);\n return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;\n} : n$ParseFloat;\n","var $ = require('../internals/export');\nvar $entries = require('../internals/object-to-array').entries;\n\n// `Object.entries` method\n// https://tc39.es/ecma262/#sec-object.entries\n$({ target: 'Object', stat: true }, {\n entries: function entries(O) {\n return $entries(O);\n }\n});\n","var $ = require('../internals/export');\nvar $parseFloat = require('../internals/number-parse-float');\n\n// `parseFloat` method\n// https://tc39.es/ecma262/#sec-parsefloat-string\n$({ global: true, forced: parseFloat != $parseFloat }, {\n parseFloat: $parseFloat\n});\n"],"names":["super_","SearchView","br","searchCancelledCallback","this","matcher","RegExp","matches","cacheDOMElements","bindEvents","cancelSearch","dom","toolbarSearch","buildToolbarSearch","query","$","val","remove","dispatchEventWhenComplete","removeSearchResults","removeResultPins","emptyMatches","setQuery","teardownSearchNavigation","trigger","selector","before","resultsPosition","searchNavigation","positionMessage","length","currentMatchIndex","namespace","on","clearSearchFieldAndResults","bind","showPrevResult","showNextResult","toggleSidebar","mode","constModeThumb","switchMode","constMode1up","getClosestMatchIndex","start","end","comparator","eq","click","updateResultsPosition","updateSearchNavigationButtons","comparisonFn","closestPage","closestTo","pool","slice","map","m","par","page","currentIndex","indexOf","find","text","attr","off","resize","matchingSearchResult","constMode2up","find2upMatchingSearchResult","find1upMatchingSearchResult","_isIndexDisplayed","setCurrentMatchIndex","bool","pinsVisibleState","refs","$BRfooter","css","visibility","document","createElement","classList","add","innerHTML","imagesBaseURL","forEach","match","queryString","pageIndex","leafNumToIndex","percentThrough","constructor","util","cssPercentage","getNumLeafs","queryStringWithB","replace","queryStringWithBTruncated","addClass","left","append","displayPageNumber","appendTo","event","marker","currentTarget","tooltip","querySelector","tooltipOffset","getBoundingClientRect","targetOffset","boxSizeAdjust","parseInt","getComputedStyle","paddingLeft","x","style","setProperty","removeClass","target","_searchPluginGoToResult","matchIndex","showProgressPopup","progressPopupClosed","removeProgressPopup","toggleSearchPending","textIsProcessing","errorDetails","renderModalMessage","delayModalRemovalFor","messageHTML","modal","el","timeoutMS","setTimeout","e","preventDefault","value","search","results","options","renderSearchNavigation","bindSearchNavigationEvents","renderPins","goToFirstResult","one","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","_searchBoxesByIndex","searchView","undefined","init","term","instance","suppressFragmentChange","buildToolbarElement","$el","after","_createPageContainer","index","pageContainer","boxes","renderBoxesInPageContainerLayer","$container","b","overrides","disablePopup","error","success","searchCancelled","eventNames","fragmentChange","serverPath","baseUrl","path","subPrefixWithSlash","lastIndexOf","substr","urlParams","item_id","doc","q","paramStr","param","url","callSearchResultsCallback","searchInsideResults","responseHasError","hasCustomError","hasCustomSuccess","BRSearchCallbackError","BRSearchCallback","ajax","dataType","cache","beforeSend","xhr","bookreader","urlPlugin","setUrlParam","removeUrlParam","abort","displayPageNumberFn","pageNum","entries","getPageNum","marshallSearchResults","updateSearchHilites","_BRSearchCallbackError","basePayload","payload","Object","assign","boxesByIndex","box","push","pageIndexString","parseFloat","_models","book","getPage","getActivePageContainerElementsForIndex","container","getActivePageContainerElements","onNearbyPage","Math","abs","makeUnviewableAtEnd","isViewable","fetch","URLSearchParams","id","subprefix","leafNum","then","r","json","resp","makeViewable","jumpToIndex","poll","until","result","$boxes","scrollIntoView","block","isFullscreenActive","inline","behavior","Promise","resolve","removeAttr","searchHighlightVisible","visiblePages","twoPage","currentIndexL","currentIndexR","some","inArray","global","fails","uncurryThis","toString","trim","whitespaces","charAt","n$ParseFloat","Symbol","ITERATOR","iterator","FORCED","module","exports","string","trimmedString","$entries","stat","O","$parseFloat","forced"],"sourceRoot":""}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[336],{1226:function(t,e,r){"use strict";function n(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 o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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,n.key,n)}}r(5827),r(1539),r(4916),r(5306),r(2222),r(6992),r(8783),r(3948),r(1637),r(489),r(2419),r(4819),r(5003),r(2526),r(1817),r(2165),r(4747),r(7941),r(9826),r(8309),r(9600),r(1249),r(7327),r(9714),r(285),r(8559),r(4723),r(3123),r(9720),r(3210),r(4765),r(7042),r(1038);var i,s=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.bookReaderOptions=e,this.urlSchema=[{name:"page",position:"path",default:"n0"},{name:"mode",position:"path",default:"2up"},{name:"search",position:"path",deprecated_for:"q"},{name:"q",position:"query_param"},{name:"sort",position:"query_param"},{name:"view",position:"query_param"},{name:"admin",position:"query_param"}],this.urlState={},this.urlMode=this.bookReaderOptions.urlMode||"hash",this.urlHistoryBasePath=this.bookReaderOptions.urlHistoryBasePath||"/",this.urlLocationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}var e,r;return e=t,(r=[{key:"urlStateToUrlString",value:function(t){var e=this,r=new URLSearchParams,n={};Object.keys(t).forEach((function(o){var a,i,s,u,l=e.urlSchema.find((function(t){return t.name===o}));null!==(a=l)&&void 0!==a&&a.deprecated_for&&(l=e.urlSchema.find((function(t){return t.name===l.deprecated_for}))),"path"==(null===(i=l)||void 0===i?void 0:i.position)?n[null===(s=l)||void 0===s?void 0:s.name]=t[o]:r.append((null===(u=l)||void 0===u?void 0:u.name)||o,t[o])}));var o=this.urlSchema.filter((function(t){return"path"==t.position})).map((function(t){return n[t.name]?"".concat(t.name,"/").concat(n[t.name]):""})).join("/"),a="".concat(o.replace(/\/+/g,"/").replace(/\/+$/,"")),i="".concat(a,"?").concat(r.toString());return r.toString()?i:"".concat(a)}},{key:"urlStringToUrlState",value:function(t){var e={},r=new URL(t,"http://example.com"),o=Object.fromEntries(r.searchParams.entries()),a=r.pathname.match(/[^\\/]+\/[^\\/]+/g),i=a?Object.fromEntries(a.map((function(t){return t.split("/")}))):{},s=function(t,e){return Object.keys(t).some((function(t){return t==e}))};return this.urlSchema.filter((function(t){return"path"==t.position})).forEach((function(t){var r=s(i,t.name);s(t,"deprecated_for")&&r?e[t.deprecated_for]=i[t.name]:r&&(e[t.name]=i[t.name])})),Object.entries(o).forEach((function(t){var r,o,a=(o=2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a=[],i=!0,s=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){s=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(s)throw o}}return a}}(r,o)||function(t,e){if(t){if("string"==typeof t)return n(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)?n(t,e):void 0}}(r,o)||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.")}()),i=a[0],s=a[1];e[i]=s})),e}},{key:"setUrlParam",value:function(t,e){this.urlState[t]=e,this.pushToAddressBar()}},{key:"removeUrlParam",value:function(t){delete this.urlState[t],this.pushToAddressBar()}},{key:"getUrlParam",value:function(t){return this.urlState[t]}},{key:"pushToAddressBar",value:function(){var t=this.urlStateToUrlString(this.urlState),e="/"!==t?t:"";if("history"==this.urlMode){if(window.history&&window.history.replaceState){var r="".concat(this.urlHistoryBasePath).concat(e).trim().replace(/(\/+)/g,"/");window.history.replaceState({},null,r)}}else window.location.replace("#"+e);this.oldLocationHash=t}},{key:"listenForHashChanges",value:function(){var t=this;this.oldLocationHash=window.location.hash.substr(1),this.urlLocationPollId&&(clearInterval(this.urlLocationPollId),this.urlLocationPollId=null),this.urlLocationPollId=setInterval((function(){var e=window.location.hash.substr(1);e!=t.oldLocationHash&&(t.urlState=t.urlStringToUrlState(e))}),500)}},{key:"pullFromAddressBar",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,e="history"===this.urlMode?t.pathname.substr(this.urlHistoryBasePath.length)+t.search:t.hash.substr(1);this.urlState=this.urlStringToUrlState(e)}}])&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function u(t){return(u="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){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(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,n.key,n)}}function h(){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=f(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}}).apply(this,arguments)}function f(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=m(t)););return t}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(t,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}r(3609).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view"],urlTrackIndex0:!1}),BookReader.prototype.setup=(i=BookReader.prototype.setup,function(t){i.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var e=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,(function(){var t=e.options,r=t.updateWindowTitle,n=t.urlMode;r&&(document.title=e.shortTitle(e.bookTitle,50)),"hash"===n&&e.urlStartLocationPolling()})),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollId),this.locationPollId=null),this.locationPollId=setInterval((function(){var e=t.urlReadFragment();if(e!=t.oldLocationHash&&e!=t.oldUserHash){var r=t.paramsFromFragment(e),n=function(){return t.updateFromParams(r)};t.trigger(BookReader.eventNames.stop),t.animating?(t.autoStop&&t.autoStop(),t.animationFinishedCallback=n):n(),t.oldUserHash=e}}),500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),e=this.options,r=e.urlMode,n=e.urlTrackIndex0,o=e.urlTrackedParams;n||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var a=o.reduce((function(e,r){return r in t&&(e[r]=t[r]),e}),{}),i=this.fragmentFromParams(a,r),s=this.urlReadFragment(),u=this.getLocationSearch(),l=this.queryStringFromParams(a,u,r);if(s!==i||u!==l)if("history"===r){if(window.history&&window.history.replaceState){var c=this.options.urlHistoryBasePath.replace(/\/+$/,""),h=""===i?"":"/".concat(i),f="".concat(c).concat(h).concat(l);window.history.replaceState({},null,f),this.oldLocationHash=i+l}}else{var p=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+i+p),this.oldLocationHash=i+p}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var e=new URLSearchParams(t);return e.has("q")?"?".concat(new URLSearchParams({q:e.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,e=t.urlMode,r=t.urlHistoryBasePath;return"history"===e?window.location.pathname.substr(r.length):window.location.hash.substr(1)},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)};var g=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&&p(t,e)}(i,BookReader);var e,r,n,o,a=(n=i,o=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,e=m(n);if(o){var r=m(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return d(this,t)});function i(){return l(this,i),a.apply(this,arguments)}return e=i,(r=[{key:"init",value:function(){var t=this;this.options.enableUrlPlugin&&(this.urlPlugin=new s(this.options),this.bind(BookReader.eventNames.PostInit,(function(){"hash"===t.options.urlMode&&t.urlPlugin.listenForHashChanges()}))),h(m(i.prototype),"init",this).call(this)}}])&&c(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),i}();window.BookReader=g},3197:function(t,e,r){"use strict";var n=r(7854),o=r(1702),a=2147483647,i=/[^\0-\u007E]/,s=/[.\u3002\uFF0E\uFF61]/g,u="Overflow: input needs wider integers to process",l=n.RangeError,c=o(s.exec),h=Math.floor,f=String.fromCharCode,p=o("".charCodeAt),d=o([].join),m=o([].push),g=o("".replace),v=o("".split),y=o("".toLowerCase),b=function(t){return t+22+75*(t<26)},w=function(t,e,r){var n=0;for(t=r?h(t/700):t>>1,t+=h(t/e);t>455;)t=h(t/35),n+=36;return h(n+36*t/(t+38))},P=function(t){var e,r,n=[],o=(t=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=p(t,r++);if(o>=55296&&o<=56319&&r<n){var a=p(t,r++);56320==(64512&a)?m(e,((1023&o)<<10)+(1023&a)+65536):(m(e,o),r--)}else m(e,o)}return e}(t)).length,i=128,s=0,c=72;for(e=0;e<t.length;e++)(r=t[e])<128&&m(n,f(r));var g=n.length,v=g;for(g&&m(n,"-");v<o;){var y=a;for(e=0;e<t.length;e++)(r=t[e])>=i&&r<y&&(y=r);var P=v+1;if(y-i>h((a-s)/P))throw l(u);for(s+=(y-i)*P,i=y,e=0;e<t.length;e++){if((r=t[e])<i&&++s>a)throw l(u);if(r==i){for(var S=s,k=36;;){var R=k<=c?1:k>=c+26?26:k-c;if(S<R)break;var U=S-R,B=36-R;m(n,f(b(R+U%B))),S=h(U/B),k+=36}m(n,f(b(S))),c=w(s,P,v==g),s=0,v++}}s++,i++}return d(n,"")};t.exports=function(t){var e,r,n=[],o=v(g(y(t),s,"."),".");for(e=0;e<o.length;e++)r=o[e],m(n,c(i,r)?"xn--"+P(r):r);return d(n,".")}},6091:function(t,e,r){var n=r(6530).PROPER,o=r(7293),a=r(1361);t.exports=function(t){return o((function(){return!!a[t]()||"
"!=="
"[t]()||n&&a[t].name!==t}))}},9720:function(t,e,r){var n=r(2109),o=r(4699).entries;n({target:"Object",stat:!0},{entries:function(t){return o(t)}})},8559:function(t,e,r){var n=r(2109),o=r(408),a=r(6135);n({target:"Object",stat:!0},{fromEntries:function(t){var e={};return o(t,(function(t,r){a(e,t,r)}),{AS_ENTRIES:!0}),e}})},4723:function(t,e,r){"use strict";var n=r(6916),o=r(7007),a=r(9670),i=r(7466),s=r(1340),u=r(4488),l=r(8173),c=r(1530),h=r(7651);o("match",(function(t,e,r){return[function(e){var r=u(this),o=null==e?void 0:l(e,t);return o?n(o,e,r):new RegExp(e)[t](s(r))},function(t){var n=a(this),o=s(t),u=r(e,n,o);if(u.done)return u.value;if(!n.global)return h(n,o);var l=n.unicode;n.lastIndex=0;for(var f,p=[],d=0;null!==(f=h(n,o));){var m=s(f[0]);p[d]=m,""===m&&(n.lastIndex=c(o,i(n.lastIndex),l)),d++}return 0===d?null:p}]}))},3210:function(t,e,r){"use strict";var n=r(2109),o=r(3111).trim;n({target:"String",proto:!0,forced:r(6091)("trim")},{trim:function(){return o(this)}})},8789:function(t,e,r){"use strict";r(8783);var n,o=r(2109),a=r(9781),i=r(590),s=r(7854),u=r(9974),l=r(1702),c=r(6048).f,h=r(1320),f=r(5787),p=r(2597),d=r(1574),m=r(8457),g=r(1589),v=r(8710).codeAt,y=r(3197),b=r(1340),w=r(8003),P=r(8053),S=r(5556),k=r(9909),R=k.set,U=k.getterFor("URL"),B=S.URLSearchParams,H=S.getState,L=s.URL,O=s.TypeError,I=s.parseInt,q=Math.floor,j=Math.pow,T=l("".charAt),A=l(/./.exec),F=l([].join),_=l(1..toString),x=l([].pop),C=l([].push),E=l("".replace),M=l([].shift),z=l("".split),$=l("".slice),N=l("".toLowerCase),D=l([].unshift),W="Invalid scheme",J="Invalid host",Q="Invalid port",G=/[a-z]/i,K=/[\d+-.a-z]/i,V=/\d/,X=/^0x/i,Y=/^[0-7]+$/,Z=/^\d+$/,tt=/^[\da-f]+$/i,et=/[\0\t\n\r #%/:<>?@[\\\]^|]/,rt=/[\0\t\n\r #/:<>?@[\\\]^|]/,nt=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,ot=/[\t\n\r]/g,at=function(t){var e,r,n,o;if("number"==typeof t){for(e=[],r=0;r<4;r++)D(e,t%256),t=q(t/256);return F(e,".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,r=1,n=null,o=0,a=0;a<8;a++)0!==t[a]?(o>r&&(e=n,r=o),n=null,o=0):(null===n&&(n=a),++o);return o>r&&(e=n,r=o),e}(t),r=0;r<8;r++)o&&0===t[r]||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=_(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},it={},st=d({},it,{" ":1,'"':1,"<":1,">":1,"`":1}),ut=d({},st,{"#":1,"?":1,"{":1,"}":1}),lt=d({},ut,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ct=function(t,e){var r=v(t,0);return r>32&&r<127&&!p(e,t)?t:encodeURIComponent(t)},ht={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ft=function(t,e){var r;return 2==t.length&&A(G,T(t,0))&&(":"==(r=T(t,1))||!e&&"|"==r)},pt=function(t){var e;return t.length>1&&ft($(t,0,2))&&(2==t.length||"/"===(e=T(t,2))||"\\"===e||"?"===e||"#"===e)},dt=function(t){return"."===t||"%2e"===N(t)},mt={},gt={},vt={},yt={},bt={},wt={},Pt={},St={},kt={},Rt={},Ut={},Bt={},Ht={},Lt={},Ot={},It={},qt={},jt={},Tt={},At={},Ft={},_t=function(t,e,r){var n,o,a,i=b(t);if(e){if(o=this.parse(i))throw O(o);this.searchParams=null}else{if(void 0!==r&&(n=new _t(r,!0)),o=this.parse(i,null,n))throw O(o);(a=H(new B)).bindURL(this),this.searchParams=a}};_t.prototype={type:"URL",parse:function(t,e,r){var o,a,i,s,u,l=this,c=e||mt,h=0,f="",d=!1,v=!1,y=!1;for(t=b(t),e||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,t=E(t,nt,"")),t=E(t,ot,""),o=m(t);h<=o.length;){switch(a=o[h],c){case mt:if(!a||!A(G,a)){if(e)return W;c=vt;continue}f+=N(a),c=gt;break;case gt:if(a&&(A(K,a)||"+"==a||"-"==a||"."==a))f+=N(a);else{if(":"!=a){if(e)return W;f="",c=vt,h=0;continue}if(e&&(l.isSpecial()!=p(ht,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,e)return void(l.isSpecial()&&ht[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?c=Lt:l.isSpecial()&&r&&r.scheme==l.scheme?c=yt:l.isSpecial()?c=St:"/"==o[h+1]?(c=bt,h++):(l.cannotBeABaseURL=!0,C(l.path,""),c=Tt)}break;case vt:if(!r||r.cannotBeABaseURL&&"#"!=a)return W;if(r.cannotBeABaseURL&&"#"==a){l.scheme=r.scheme,l.path=g(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,c=Ft;break}c="file"==r.scheme?Lt:wt;continue;case yt:if("/"!=a||"/"!=o[h+1]){c=wt;continue}c=kt,h++;break;case bt:if("/"==a){c=Rt;break}c=jt;continue;case wt:if(l.scheme=r.scheme,a==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.query=r.query;else if("/"==a||"\\"==a&&l.isSpecial())c=Pt;else if("?"==a)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.query="",c=At;else{if("#"!=a){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.path.length--,c=jt;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.query=r.query,l.fragment="",c=Ft}break;case Pt:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,c=jt;continue}c=Rt}else c=kt;break;case St:if(c=kt,"/"!=a||"/"!=T(f,h+1))continue;h++;break;case kt:if("/"!=a&&"\\"!=a){c=Rt;continue}break;case Rt:if("@"==a){d&&(f="%40"+f),d=!0,i=m(f);for(var w=0;w<i.length;w++){var P=i[w];if(":"!=P||y){var S=ct(P,lt);y?l.password+=S:l.username+=S}else y=!0}f=""}else if(a==n||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(d&&""==f)return"Invalid authority";h-=m(f).length+1,f="",c=Ut}else f+=a;break;case Ut:case Bt:if(e&&"file"==l.scheme){c=It;continue}if(":"!=a||v){if(a==n||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(l.isSpecial()&&""==f)return J;if(e&&""==f&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(f))return s;if(f="",c=qt,e)return;continue}"["==a?v=!0:"]"==a&&(v=!1),f+=a}else{if(""==f)return J;if(s=l.parseHost(f))return s;if(f="",c=Ht,e==Bt)return}break;case Ht:if(!A(V,a)){if(a==n||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()||e){if(""!=f){var k=I(f,10);if(k>65535)return Q;l.port=l.isSpecial()&&k===ht[l.scheme]?null:k,f=""}if(e)return;c=qt;continue}return Q}f+=a;break;case Lt:if(l.scheme="file","/"==a||"\\"==a)c=Ot;else{if(!r||"file"!=r.scheme){c=jt;continue}if(a==n)l.host=r.host,l.path=g(r.path),l.query=r.query;else if("?"==a)l.host=r.host,l.path=g(r.path),l.query="",c=At;else{if("#"!=a){pt(F(g(o,h),""))||(l.host=r.host,l.path=g(r.path),l.shortenPath()),c=jt;continue}l.host=r.host,l.path=g(r.path),l.query=r.query,l.fragment="",c=Ft}}break;case Ot:if("/"==a||"\\"==a){c=It;break}r&&"file"==r.scheme&&!pt(F(g(o,h),""))&&(ft(r.path[0],!0)?C(l.path,r.path[0]):l.host=r.host),c=jt;continue;case It:if(a==n||"/"==a||"\\"==a||"?"==a||"#"==a){if(!e&&ft(f))c=jt;else if(""==f){if(l.host="",e)return;c=qt}else{if(s=l.parseHost(f))return s;if("localhost"==l.host&&(l.host=""),e)return;f="",c=qt}continue}f+=a;break;case qt:if(l.isSpecial()){if(c=jt,"/"!=a&&"\\"!=a)continue}else if(e||"?"!=a)if(e||"#"!=a){if(a!=n&&(c=jt,"/"!=a))continue}else l.fragment="",c=Ft;else l.query="",c=At;break;case jt:if(a==n||"/"==a||"\\"==a&&l.isSpecial()||!e&&("?"==a||"#"==a)){if(".."===(u=N(u=f))||"%2e."===u||".%2e"===u||"%2e%2e"===u?(l.shortenPath(),"/"==a||"\\"==a&&l.isSpecial()||C(l.path,"")):dt(f)?"/"==a||"\\"==a&&l.isSpecial()||C(l.path,""):("file"==l.scheme&&!l.path.length&&ft(f)&&(l.host&&(l.host=""),f=T(f,0)+":"),C(l.path,f)),f="","file"==l.scheme&&(a==n||"?"==a||"#"==a))for(;l.path.length>1&&""===l.path[0];)M(l.path);"?"==a?(l.query="",c=At):"#"==a&&(l.fragment="",c=Ft)}else f+=ct(a,ut);break;case Tt:"?"==a?(l.query="",c=At):"#"==a?(l.fragment="",c=Ft):a!=n&&(l.path[0]+=ct(a,it));break;case At:e||"#"!=a?a!=n&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":ct(a,it)):(l.fragment="",c=Ft);break;case Ft:a!=n&&(l.fragment+=ct(a,st))}h++}},parseHost:function(t){var e,r,n;if("["==T(t,0)){if("]"!=T(t,t.length-1))return J;if(!(e=function(t){var e,r,n,o,a,i,s,u=[0,0,0,0,0,0,0,0],l=0,c=null,h=0,f=function(){return T(t,h)};if(":"==f()){if(":"!=T(t,1))return;h+=2,c=++l}for(;f();){if(8==l)return;if(":"!=f()){for(e=r=0;r<4&&A(tt,f());)e=16*e+I(f(),16),h++,r++;if("."==f()){if(0==r)return;if(h-=r,l>6)return;for(n=0;f();){if(o=null,n>0){if(!("."==f()&&n<4))return;h++}if(!A(V,f()))return;for(;A(V,f());){if(a=I(f(),10),null===o)o=a;else{if(0==o)return;o=10*o+a}if(o>255)return;h++}u[l]=256*u[l]+o,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==f()){if(h++,!f())return}else if(f())return;u[l++]=e}else{if(null!==c)return;h++,c=++l}}if(null!==c)for(i=l-c,l=7;0!=l&&i>0;)s=u[l],u[l--]=u[c+i-1],u[c+--i]=s;else if(8!=l)return;return u}($(t,1,-1))))return J;this.host=e}else if(this.isSpecial()){if(t=y(t),A(et,t))return J;if(null===(e=function(t){var e,r,n,o,a,i,s,u=z(t,".");if(u.length&&""==u[u.length-1]&&u.length--,(e=u.length)>4)return t;for(r=[],n=0;n<e;n++){if(""==(o=u[n]))return t;if(a=10,o.length>1&&"0"==T(o,0)&&(a=A(X,o)?16:8,o=$(o,8==a?1:2)),""===o)i=0;else{if(!A(10==a?Z:8==a?Y:tt,o))return t;i=I(o,a)}C(r,i)}for(n=0;n<e;n++)if(i=r[n],n==e-1){if(i>=j(256,5-e))return null}else if(i>255)return null;for(s=x(r),n=0;n<r.length;n++)s+=r[n]*j(256,3-n);return s}(t)))return J;this.host=e}else{if(A(rt,t))return J;for(e="",r=m(t),n=0;n<r.length;n++)e+=ct(r[n],it);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return p(ht,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;!e||"file"==this.scheme&&1==e&&ft(t[0],!0)||t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,a=t.port,i=t.path,s=t.query,u=t.fragment,l=e+":";return null!==o?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=at(o),null!==a&&(l+=":"+a)):"file"==e&&(l+="//"),l+=t.cannotBeABaseURL?i[0]:i.length?"/"+F(i,"/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw O(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if("blob"==t)try{return new xt(t.path[0]).origin}catch(t){return"null"}return"file"!=t&&this.isSpecial()?t+"://"+at(this.host)+(null!==e?":"+e:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(b(t)+":",mt)},getUsername:function(){return this.username},setUsername:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=ct(e[r],lt)}},getPassword:function(){return this.password},setPassword:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=ct(e[r],lt)}},getHost:function(){var t=this.host,e=this.port;return null===t?"":null===e?at(t):at(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,Ut)},getHostname:function(){var t=this.host;return null===t?"":at(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Bt)},getPort:function(){var t=this.port;return null===t?"":b(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""==(t=b(t))?this.port=null:this.parse(t,Ht))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+F(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,qt))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""==(t=b(t))?this.query=null:("?"==T(t,0)&&(t=$(t,1)),this.query="",this.parse(t,At)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!=(t=b(t))?("#"==T(t,0)&&(t=$(t,1)),this.fragment="",this.parse(t,Ft)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var xt=function(t){var e=f(this,Ct),r=P(arguments.length,1)>1?arguments[1]:void 0,n=R(e,new _t(t,!1,r));a||(e.href=n.serialize(),e.origin=n.getOrigin(),e.protocol=n.getProtocol(),e.username=n.getUsername(),e.password=n.getPassword(),e.host=n.getHost(),e.hostname=n.getHostname(),e.port=n.getPort(),e.pathname=n.getPathname(),e.search=n.getSearch(),e.searchParams=n.getSearchParams(),e.hash=n.getHash())},Ct=xt.prototype,Et=function(t,e){return{get:function(){return U(this)[t]()},set:e&&function(t){return U(this)[e](t)},configurable:!0,enumerable:!0}};if(a&&c(Ct,{href:Et("serialize","setHref"),origin:Et("getOrigin"),protocol:Et("getProtocol","setProtocol"),username:Et("getUsername","setUsername"),password:Et("getPassword","setPassword"),host:Et("getHost","setHost"),hostname:Et("getHostname","setHostname"),port:Et("getPort","setPort"),pathname:Et("getPathname","setPathname"),search:Et("getSearch","setSearch"),searchParams:Et("getSearchParams"),hash:Et("getHash","setHash")}),h(Ct,"toJSON",(function(){return U(this).serialize()}),{enumerable:!0}),h(Ct,"toString",(function(){return U(this).serialize()}),{enumerable:!0}),L){var Mt=L.createObjectURL,zt=L.revokeObjectURL;Mt&&h(xt,"createObjectURL",u(Mt,L)),zt&&h(xt,"revokeObjectURL",u(zt,L))}w(xt,"URL"),o({global:!0,forced:!i,sham:!a},{URL:xt})},285:function(t,e,r){r(8789)}},function(t){t(t.s=1226)}]);
|
1
|
+
(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[336],{1226:function(t,e,r){"use strict";function n(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 o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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,n.key,n)}}r(5827),r(1539),r(4916),r(5306),r(2222),r(6992),r(8783),r(3948),r(1637),r(489),r(2419),r(4819),r(5003),r(2526),r(1817),r(2165),r(4747),r(7941),r(9826),r(8309),r(9600),r(1249),r(7327),r(9714),r(285),r(8559),r(4723),r(3123),r(9720),r(3210),r(4765),r(7042),r(1038);var i,s=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),this.bookReaderOptions=e,this.urlSchema=[{name:"page",position:"path",default:"n0"},{name:"mode",position:"path",default:"2up"},{name:"search",position:"path",deprecated_for:"q"},{name:"q",position:"query_param"},{name:"sort",position:"query_param"},{name:"view",position:"query_param"},{name:"admin",position:"query_param"}],this.urlState={},this.urlMode=this.bookReaderOptions.urlMode||"hash",this.urlHistoryBasePath=this.bookReaderOptions.urlHistoryBasePath||"/",this.urlLocationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}var e,r;return e=t,(r=[{key:"urlStateToUrlString",value:function(t){var e=this,r=new URLSearchParams,n={};Object.keys(t).forEach((function(o){var a,i,s,u,l=e.urlSchema.find((function(t){return t.name===o}));null!==(a=l)&&void 0!==a&&a.deprecated_for&&(l=e.urlSchema.find((function(t){return t.name===l.deprecated_for}))),"path"==(null===(i=l)||void 0===i?void 0:i.position)?n[null===(s=l)||void 0===s?void 0:s.name]=t[o]:r.append((null===(u=l)||void 0===u?void 0:u.name)||o,t[o])}));var o=this.urlSchema.filter((function(t){return"path"==t.position})).map((function(t){return n[t.name]?"".concat(t.name,"/").concat(n[t.name]):""})).join("/"),a="".concat(o.replace(/\/+/g,"/").replace(/\/+$/,"")),i="".concat(a,"?").concat(r.toString());return r.toString()?i:"".concat(a)}},{key:"urlStringToUrlState",value:function(t){var e={},r=new URL(t,"http://example.com"),o=Object.fromEntries(r.searchParams.entries()),a=r.pathname.match(/[^\\/]+\/[^\\/]+/g),i=a?Object.fromEntries(a.map((function(t){return t.split("/")}))):{},s=function(t,e){return Object.keys(t).some((function(t){return t==e}))};return this.urlSchema.filter((function(t){return"path"==t.position})).forEach((function(t){var r=s(i,t.name);s(t,"deprecated_for")&&r?e[t.deprecated_for]=i[t.name]:r&&(e[t.name]=i[t.name])})),Object.entries(o).forEach((function(t){var r,o,a=(o=2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a=[],i=!0,s=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){s=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(s)throw o}}return a}}(r,o)||function(t,e){if(t){if("string"==typeof t)return n(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)?n(t,e):void 0}}(r,o)||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.")}()),i=a[0],s=a[1];e[i]=s})),e}},{key:"setUrlParam",value:function(t,e){this.urlState[t]=e,this.pushToAddressBar()}},{key:"removeUrlParam",value:function(t){console.log(" removeUrlParam removeUrlParam ",{key:t,urlState:this.urlState}),delete this.urlState[t],this.pushToAddressBar()}},{key:"getUrlParam",value:function(t){return this.urlState[t]}},{key:"pushToAddressBar",value:function(){var t=this.urlStateToUrlString(this.urlState),e="/"!==t?t:"";if("history"==this.urlMode){if(window.history&&window.history.replaceState){var r="".concat(this.urlHistoryBasePath).concat(e).trim().replace(/(\/+)/g,"/");window.history.replaceState({},null,r)}}else window.location.replace("#"+e);this.oldLocationHash=t}},{key:"listenForHashChanges",value:function(){var t=this;this.oldLocationHash=window.location.hash.substr(1),this.urlLocationPollId&&(clearInterval(this.urlLocationPollId),this.urlLocationPollId=null),this.urlLocationPollId=setInterval((function(){var e=window.location.hash.substr(1);e!=t.oldLocationHash&&(t.urlState=t.urlStringToUrlState(e))}),500)}},{key:"pullFromAddressBar",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,e="history"===this.urlMode?t.pathname.substr(this.urlHistoryBasePath.length)+t.search:t.hash.substr(1);this.urlState=this.urlStringToUrlState(e)}}])&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();function u(t){return(u="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){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(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,n.key,n)}}function h(){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=f(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}}).apply(this,arguments)}function f(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=m(t)););return t}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(t,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}r(3609).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view"],urlTrackIndex0:!1}),BookReader.prototype.setup=(i=BookReader.prototype.setup,function(t){i.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var e=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,(function(){var t=e.options,r=t.updateWindowTitle,n=t.urlMode;r&&(document.title=e.shortTitle(e.bookTitle,50)),"hash"===n&&e.urlStartLocationPolling()})),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollId),this.locationPollId=null),this.locationPollId=setInterval((function(){var e=t.urlReadFragment();if(e!=t.oldLocationHash&&e!=t.oldUserHash){var r=t.paramsFromFragment(e),n=function(){return t.updateFromParams(r)};t.trigger(BookReader.eventNames.stop),t.animating?(t.autoStop&&t.autoStop(),t.animationFinishedCallback=n):n(),t.oldUserHash=e}}),500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),e=this.options,r=e.urlMode,n=e.urlTrackIndex0,o=e.urlTrackedParams;n||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var a=o.reduce((function(e,r){return r in t&&(e[r]=t[r]),e}),{}),i=this.fragmentFromParams(a,r),s=this.urlReadFragment(),u=this.getLocationSearch(),l=this.queryStringFromParams(a,u,r);if(s!==i||u!==l)if("history"===r){if(window.history&&window.history.replaceState){var c=this.options.urlHistoryBasePath.replace(/\/+$/,""),h=""===i?"":"/".concat(i),f="".concat(c).concat(h).concat(l);window.history.replaceState({},null,f),this.oldLocationHash=i+l}}else{var p=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+i+p),this.oldLocationHash=i+p}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var e=new URLSearchParams(t);return e.has("q")?"?".concat(new URLSearchParams({q:e.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,e=t.urlMode,r=t.urlHistoryBasePath;return"history"===e?window.location.pathname.substr(r.length):window.location.hash.substr(1)},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)};var g=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&&p(t,e)}(i,BookReader);var e,r,n,o,a=(n=i,o=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,e=m(n);if(o){var r=m(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return d(this,t)});function i(){return l(this,i),a.apply(this,arguments)}return e=i,(r=[{key:"init",value:function(){var t=this;this.options.enableUrlPlugin&&(this.urlPlugin=new s(this.options),this.bind(BookReader.eventNames.PostInit,(function(){"hash"===t.options.urlMode&&t.urlPlugin.listenForHashChanges()}))),h(m(i.prototype),"init",this).call(this)}}])&&c(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),i}();window.BookReader=g},3197:function(t,e,r){"use strict";var n=r(7854),o=r(1702),a=2147483647,i=/[^\0-\u007E]/,s=/[.\u3002\uFF0E\uFF61]/g,u="Overflow: input needs wider integers to process",l=n.RangeError,c=o(s.exec),h=Math.floor,f=String.fromCharCode,p=o("".charCodeAt),d=o([].join),m=o([].push),g=o("".replace),v=o("".split),y=o("".toLowerCase),b=function(t){return t+22+75*(t<26)},w=function(t,e,r){var n=0;for(t=r?h(t/700):t>>1,t+=h(t/e);t>455;)t=h(t/35),n+=36;return h(n+36*t/(t+38))},P=function(t){var e,r,n=[],o=(t=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=p(t,r++);if(o>=55296&&o<=56319&&r<n){var a=p(t,r++);56320==(64512&a)?m(e,((1023&o)<<10)+(1023&a)+65536):(m(e,o),r--)}else m(e,o)}return e}(t)).length,i=128,s=0,c=72;for(e=0;e<t.length;e++)(r=t[e])<128&&m(n,f(r));var g=n.length,v=g;for(g&&m(n,"-");v<o;){var y=a;for(e=0;e<t.length;e++)(r=t[e])>=i&&r<y&&(y=r);var P=v+1;if(y-i>h((a-s)/P))throw l(u);for(s+=(y-i)*P,i=y,e=0;e<t.length;e++){if((r=t[e])<i&&++s>a)throw l(u);if(r==i){for(var S=s,k=36;;){var R=k<=c?1:k>=c+26?26:k-c;if(S<R)break;var U=S-R,B=36-R;m(n,f(b(R+U%B))),S=h(U/B),k+=36}m(n,f(b(S))),c=w(s,P,v==g),s=0,v++}}s++,i++}return d(n,"")};t.exports=function(t){var e,r,n=[],o=v(g(y(t),s,"."),".");for(e=0;e<o.length;e++)r=o[e],m(n,c(i,r)?"xn--"+P(r):r);return d(n,".")}},6091:function(t,e,r){var n=r(6530).PROPER,o=r(7293),a=r(1361);t.exports=function(t){return o((function(){return!!a[t]()||"
"!=="
"[t]()||n&&a[t].name!==t}))}},9720:function(t,e,r){var n=r(2109),o=r(4699).entries;n({target:"Object",stat:!0},{entries:function(t){return o(t)}})},8559:function(t,e,r){var n=r(2109),o=r(408),a=r(6135);n({target:"Object",stat:!0},{fromEntries:function(t){var e={};return o(t,(function(t,r){a(e,t,r)}),{AS_ENTRIES:!0}),e}})},4723:function(t,e,r){"use strict";var n=r(6916),o=r(7007),a=r(9670),i=r(7466),s=r(1340),u=r(4488),l=r(8173),c=r(1530),h=r(7651);o("match",(function(t,e,r){return[function(e){var r=u(this),o=null==e?void 0:l(e,t);return o?n(o,e,r):new RegExp(e)[t](s(r))},function(t){var n=a(this),o=s(t),u=r(e,n,o);if(u.done)return u.value;if(!n.global)return h(n,o);var l=n.unicode;n.lastIndex=0;for(var f,p=[],d=0;null!==(f=h(n,o));){var m=s(f[0]);p[d]=m,""===m&&(n.lastIndex=c(o,i(n.lastIndex),l)),d++}return 0===d?null:p}]}))},3210:function(t,e,r){"use strict";var n=r(2109),o=r(3111).trim;n({target:"String",proto:!0,forced:r(6091)("trim")},{trim:function(){return o(this)}})},8789:function(t,e,r){"use strict";r(8783);var n,o=r(2109),a=r(9781),i=r(590),s=r(7854),u=r(9974),l=r(1702),c=r(6048).f,h=r(1320),f=r(5787),p=r(2597),d=r(1574),m=r(8457),g=r(1589),v=r(8710).codeAt,y=r(3197),b=r(1340),w=r(8003),P=r(8053),S=r(5556),k=r(9909),R=k.set,U=k.getterFor("URL"),B=S.URLSearchParams,H=S.getState,L=s.URL,O=s.TypeError,I=s.parseInt,q=Math.floor,j=Math.pow,T=l("".charAt),A=l(/./.exec),F=l([].join),_=l(1..toString),x=l([].pop),C=l([].push),E=l("".replace),M=l([].shift),z=l("".split),$=l("".slice),N=l("".toLowerCase),D=l([].unshift),W="Invalid scheme",J="Invalid host",Q="Invalid port",G=/[a-z]/i,K=/[\d+-.a-z]/i,V=/\d/,X=/^0x/i,Y=/^[0-7]+$/,Z=/^\d+$/,tt=/^[\da-f]+$/i,et=/[\0\t\n\r #%/:<>?@[\\\]^|]/,rt=/[\0\t\n\r #/:<>?@[\\\]^|]/,nt=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,ot=/[\t\n\r]/g,at=function(t){var e,r,n,o;if("number"==typeof t){for(e=[],r=0;r<4;r++)D(e,t%256),t=q(t/256);return F(e,".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,r=1,n=null,o=0,a=0;a<8;a++)0!==t[a]?(o>r&&(e=n,r=o),n=null,o=0):(null===n&&(n=a),++o);return o>r&&(e=n,r=o),e}(t),r=0;r<8;r++)o&&0===t[r]||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=_(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},it={},st=d({},it,{" ":1,'"':1,"<":1,">":1,"`":1}),ut=d({},st,{"#":1,"?":1,"{":1,"}":1}),lt=d({},ut,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ct=function(t,e){var r=v(t,0);return r>32&&r<127&&!p(e,t)?t:encodeURIComponent(t)},ht={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ft=function(t,e){var r;return 2==t.length&&A(G,T(t,0))&&(":"==(r=T(t,1))||!e&&"|"==r)},pt=function(t){var e;return t.length>1&&ft($(t,0,2))&&(2==t.length||"/"===(e=T(t,2))||"\\"===e||"?"===e||"#"===e)},dt=function(t){return"."===t||"%2e"===N(t)},mt={},gt={},vt={},yt={},bt={},wt={},Pt={},St={},kt={},Rt={},Ut={},Bt={},Ht={},Lt={},Ot={},It={},qt={},jt={},Tt={},At={},Ft={},_t=function(t,e,r){var n,o,a,i=b(t);if(e){if(o=this.parse(i))throw O(o);this.searchParams=null}else{if(void 0!==r&&(n=new _t(r,!0)),o=this.parse(i,null,n))throw O(o);(a=H(new B)).bindURL(this),this.searchParams=a}};_t.prototype={type:"URL",parse:function(t,e,r){var o,a,i,s,u,l=this,c=e||mt,h=0,f="",d=!1,v=!1,y=!1;for(t=b(t),e||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,t=E(t,nt,"")),t=E(t,ot,""),o=m(t);h<=o.length;){switch(a=o[h],c){case mt:if(!a||!A(G,a)){if(e)return W;c=vt;continue}f+=N(a),c=gt;break;case gt:if(a&&(A(K,a)||"+"==a||"-"==a||"."==a))f+=N(a);else{if(":"!=a){if(e)return W;f="",c=vt,h=0;continue}if(e&&(l.isSpecial()!=p(ht,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,e)return void(l.isSpecial()&&ht[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?c=Lt:l.isSpecial()&&r&&r.scheme==l.scheme?c=yt:l.isSpecial()?c=St:"/"==o[h+1]?(c=bt,h++):(l.cannotBeABaseURL=!0,C(l.path,""),c=Tt)}break;case vt:if(!r||r.cannotBeABaseURL&&"#"!=a)return W;if(r.cannotBeABaseURL&&"#"==a){l.scheme=r.scheme,l.path=g(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,c=Ft;break}c="file"==r.scheme?Lt:wt;continue;case yt:if("/"!=a||"/"!=o[h+1]){c=wt;continue}c=kt,h++;break;case bt:if("/"==a){c=Rt;break}c=jt;continue;case wt:if(l.scheme=r.scheme,a==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.query=r.query;else if("/"==a||"\\"==a&&l.isSpecial())c=Pt;else if("?"==a)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.query="",c=At;else{if("#"!=a){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.path.length--,c=jt;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=g(r.path),l.query=r.query,l.fragment="",c=Ft}break;case Pt:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,c=jt;continue}c=Rt}else c=kt;break;case St:if(c=kt,"/"!=a||"/"!=T(f,h+1))continue;h++;break;case kt:if("/"!=a&&"\\"!=a){c=Rt;continue}break;case Rt:if("@"==a){d&&(f="%40"+f),d=!0,i=m(f);for(var w=0;w<i.length;w++){var P=i[w];if(":"!=P||y){var S=ct(P,lt);y?l.password+=S:l.username+=S}else y=!0}f=""}else if(a==n||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(d&&""==f)return"Invalid authority";h-=m(f).length+1,f="",c=Ut}else f+=a;break;case Ut:case Bt:if(e&&"file"==l.scheme){c=It;continue}if(":"!=a||v){if(a==n||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(l.isSpecial()&&""==f)return J;if(e&&""==f&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(f))return s;if(f="",c=qt,e)return;continue}"["==a?v=!0:"]"==a&&(v=!1),f+=a}else{if(""==f)return J;if(s=l.parseHost(f))return s;if(f="",c=Ht,e==Bt)return}break;case Ht:if(!A(V,a)){if(a==n||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()||e){if(""!=f){var k=I(f,10);if(k>65535)return Q;l.port=l.isSpecial()&&k===ht[l.scheme]?null:k,f=""}if(e)return;c=qt;continue}return Q}f+=a;break;case Lt:if(l.scheme="file","/"==a||"\\"==a)c=Ot;else{if(!r||"file"!=r.scheme){c=jt;continue}if(a==n)l.host=r.host,l.path=g(r.path),l.query=r.query;else if("?"==a)l.host=r.host,l.path=g(r.path),l.query="",c=At;else{if("#"!=a){pt(F(g(o,h),""))||(l.host=r.host,l.path=g(r.path),l.shortenPath()),c=jt;continue}l.host=r.host,l.path=g(r.path),l.query=r.query,l.fragment="",c=Ft}}break;case Ot:if("/"==a||"\\"==a){c=It;break}r&&"file"==r.scheme&&!pt(F(g(o,h),""))&&(ft(r.path[0],!0)?C(l.path,r.path[0]):l.host=r.host),c=jt;continue;case It:if(a==n||"/"==a||"\\"==a||"?"==a||"#"==a){if(!e&&ft(f))c=jt;else if(""==f){if(l.host="",e)return;c=qt}else{if(s=l.parseHost(f))return s;if("localhost"==l.host&&(l.host=""),e)return;f="",c=qt}continue}f+=a;break;case qt:if(l.isSpecial()){if(c=jt,"/"!=a&&"\\"!=a)continue}else if(e||"?"!=a)if(e||"#"!=a){if(a!=n&&(c=jt,"/"!=a))continue}else l.fragment="",c=Ft;else l.query="",c=At;break;case jt:if(a==n||"/"==a||"\\"==a&&l.isSpecial()||!e&&("?"==a||"#"==a)){if(".."===(u=N(u=f))||"%2e."===u||".%2e"===u||"%2e%2e"===u?(l.shortenPath(),"/"==a||"\\"==a&&l.isSpecial()||C(l.path,"")):dt(f)?"/"==a||"\\"==a&&l.isSpecial()||C(l.path,""):("file"==l.scheme&&!l.path.length&&ft(f)&&(l.host&&(l.host=""),f=T(f,0)+":"),C(l.path,f)),f="","file"==l.scheme&&(a==n||"?"==a||"#"==a))for(;l.path.length>1&&""===l.path[0];)M(l.path);"?"==a?(l.query="",c=At):"#"==a&&(l.fragment="",c=Ft)}else f+=ct(a,ut);break;case Tt:"?"==a?(l.query="",c=At):"#"==a?(l.fragment="",c=Ft):a!=n&&(l.path[0]+=ct(a,it));break;case At:e||"#"!=a?a!=n&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":ct(a,it)):(l.fragment="",c=Ft);break;case Ft:a!=n&&(l.fragment+=ct(a,st))}h++}},parseHost:function(t){var e,r,n;if("["==T(t,0)){if("]"!=T(t,t.length-1))return J;if(!(e=function(t){var e,r,n,o,a,i,s,u=[0,0,0,0,0,0,0,0],l=0,c=null,h=0,f=function(){return T(t,h)};if(":"==f()){if(":"!=T(t,1))return;h+=2,c=++l}for(;f();){if(8==l)return;if(":"!=f()){for(e=r=0;r<4&&A(tt,f());)e=16*e+I(f(),16),h++,r++;if("."==f()){if(0==r)return;if(h-=r,l>6)return;for(n=0;f();){if(o=null,n>0){if(!("."==f()&&n<4))return;h++}if(!A(V,f()))return;for(;A(V,f());){if(a=I(f(),10),null===o)o=a;else{if(0==o)return;o=10*o+a}if(o>255)return;h++}u[l]=256*u[l]+o,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==f()){if(h++,!f())return}else if(f())return;u[l++]=e}else{if(null!==c)return;h++,c=++l}}if(null!==c)for(i=l-c,l=7;0!=l&&i>0;)s=u[l],u[l--]=u[c+i-1],u[c+--i]=s;else if(8!=l)return;return u}($(t,1,-1))))return J;this.host=e}else if(this.isSpecial()){if(t=y(t),A(et,t))return J;if(null===(e=function(t){var e,r,n,o,a,i,s,u=z(t,".");if(u.length&&""==u[u.length-1]&&u.length--,(e=u.length)>4)return t;for(r=[],n=0;n<e;n++){if(""==(o=u[n]))return t;if(a=10,o.length>1&&"0"==T(o,0)&&(a=A(X,o)?16:8,o=$(o,8==a?1:2)),""===o)i=0;else{if(!A(10==a?Z:8==a?Y:tt,o))return t;i=I(o,a)}C(r,i)}for(n=0;n<e;n++)if(i=r[n],n==e-1){if(i>=j(256,5-e))return null}else if(i>255)return null;for(s=x(r),n=0;n<r.length;n++)s+=r[n]*j(256,3-n);return s}(t)))return J;this.host=e}else{if(A(rt,t))return J;for(e="",r=m(t),n=0;n<r.length;n++)e+=ct(r[n],it);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return p(ht,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;!e||"file"==this.scheme&&1==e&&ft(t[0],!0)||t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,a=t.port,i=t.path,s=t.query,u=t.fragment,l=e+":";return null!==o?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=at(o),null!==a&&(l+=":"+a)):"file"==e&&(l+="//"),l+=t.cannotBeABaseURL?i[0]:i.length?"/"+F(i,"/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw O(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if("blob"==t)try{return new xt(t.path[0]).origin}catch(t){return"null"}return"file"!=t&&this.isSpecial()?t+"://"+at(this.host)+(null!==e?":"+e:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(b(t)+":",mt)},getUsername:function(){return this.username},setUsername:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=ct(e[r],lt)}},getPassword:function(){return this.password},setPassword:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=ct(e[r],lt)}},getHost:function(){var t=this.host,e=this.port;return null===t?"":null===e?at(t):at(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,Ut)},getHostname:function(){var t=this.host;return null===t?"":at(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Bt)},getPort:function(){var t=this.port;return null===t?"":b(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""==(t=b(t))?this.port=null:this.parse(t,Ht))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+F(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,qt))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""==(t=b(t))?this.query=null:("?"==T(t,0)&&(t=$(t,1)),this.query="",this.parse(t,At)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!=(t=b(t))?("#"==T(t,0)&&(t=$(t,1)),this.fragment="",this.parse(t,Ft)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var xt=function(t){var e=f(this,Ct),r=P(arguments.length,1)>1?arguments[1]:void 0,n=R(e,new _t(t,!1,r));a||(e.href=n.serialize(),e.origin=n.getOrigin(),e.protocol=n.getProtocol(),e.username=n.getUsername(),e.password=n.getPassword(),e.host=n.getHost(),e.hostname=n.getHostname(),e.port=n.getPort(),e.pathname=n.getPathname(),e.search=n.getSearch(),e.searchParams=n.getSearchParams(),e.hash=n.getHash())},Ct=xt.prototype,Et=function(t,e){return{get:function(){return U(this)[t]()},set:e&&function(t){return U(this)[e](t)},configurable:!0,enumerable:!0}};if(a&&c(Ct,{href:Et("serialize","setHref"),origin:Et("getOrigin"),protocol:Et("getProtocol","setProtocol"),username:Et("getUsername","setUsername"),password:Et("getPassword","setPassword"),host:Et("getHost","setHost"),hostname:Et("getHostname","setHostname"),port:Et("getPort","setPort"),pathname:Et("getPathname","setPathname"),search:Et("getSearch","setSearch"),searchParams:Et("getSearchParams"),hash:Et("getHash","setHash")}),h(Ct,"toJSON",(function(){return U(this).serialize()}),{enumerable:!0}),h(Ct,"toString",(function(){return U(this).serialize()}),{enumerable:!0}),L){var Mt=L.createObjectURL,zt=L.revokeObjectURL;Mt&&h(xt,"createObjectURL",u(Mt,L)),zt&&h(xt,"revokeObjectURL",u(zt,L))}w(xt,"URL"),o({global:!0,forced:!i,sham:!a},{URL:xt})},285:function(t,e,r){r(8789)}},function(t){t(t.s=1226)}]);
|
2
2
|
//# sourceMappingURL=plugin.url.js.map
|