@internetarchive/bookreader 5.0.0-29 → 5.0.0-30-c

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. package/BookReader/BookReader.js +32267 -2
  2. package/BookReader/BookReader.js.map +1 -1
  3. package/BookReader/ia-bookreader-bundle.js +15232 -0
  4. package/BookReader/ia-bookreader-bundle.js.map +1 -0
  5. package/BookReader/jquery-1.10.1.js +108 -2
  6. package/BookReader/plugins/plugin.archive_analytics.js +170 -1
  7. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  8. package/BookReader/plugins/plugin.autoplay.js +163 -1
  9. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  10. package/BookReader/plugins/plugin.chapters.js +333 -1
  11. package/BookReader/plugins/plugin.chapters.js.map +1 -1
  12. package/BookReader/plugins/plugin.iframe.js +72 -1
  13. package/BookReader/plugins/plugin.iframe.js.map +1 -1
  14. package/BookReader/plugins/plugin.mobile_nav.js +332 -1
  15. package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
  16. package/BookReader/plugins/plugin.resume.js +241 -1
  17. package/BookReader/plugins/plugin.resume.js.map +1 -1
  18. package/BookReader/plugins/plugin.search.js +1261 -1
  19. package/BookReader/plugins/plugin.search.js.map +1 -1
  20. package/BookReader/plugins/plugin.text_selection.js +839 -1
  21. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  22. package/BookReader/plugins/plugin.tts.js +9115 -2
  23. package/BookReader/plugins/plugin.tts.js.map +1 -1
  24. package/BookReader/plugins/plugin.url.js +811 -1
  25. package/BookReader/plugins/plugin.url.js.map +1 -1
  26. package/BookReader/plugins/plugin.vendor-fullscreen.js +326 -1
  27. package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
  28. package/BookReader/webcomponents-bundle.js +411 -2
  29. package/BookReader/webcomponents-bundle.js.map +1 -1
  30. package/BookReaderDemo/IADemoBr.js +3 -0
  31. package/BookReaderDemo/demo-internetarchive.html +6 -8
  32. package/package.json +4 -4
  33. package/src/BookNavigator/book-navigator.js +7 -0
  34. package/src/BookReader/Mode1Up.js +1 -0
  35. package/src/BookReader/Mode1UpLit.js +5 -1
  36. package/src/{BookReaderComponent/BookReaderComponent.js → ia-bookreader/ia-bookreader.js} +93 -17
  37. package/webpack.config.js +2 -2
  38. package/BookReader/BookReader.js.LICENSE.txt +0 -117
  39. package/BookReader/bookreader-component-bundle.js +0 -1464
  40. package/BookReader/bookreader-component-bundle.js.LICENSE.txt +0 -50
  41. package/BookReader/bookreader-component-bundle.js.map +0 -1
  42. package/BookReader/jquery-1.10.1.js.LICENSE.txt +0 -24
  43. package/BookReader/plugins/plugin.tts.js.LICENSE.txt +0 -27
  44. package/BookReader/webcomponents-bundle.js.LICENSE.txt +0 -9
@@ -1,2 +1,812 @@
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(4916),r(5306),r(2222),r(6992),r(1539),r(8783),r(3948),r(285),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(8559),r(4723),r(3123),r(9720),r(4765),r(7042),r(1038);var i,l=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,l,u,s=e.urlSchema.find((function(t){return t.name===o}));null!==(a=s)&&void 0!==a&&a.deprecated_for&&(s=e.urlSchema.find((function(t){return t.name===s.deprecated_for}))),"path"==(null===(i=s)||void 0===i?void 0:i.position)?n[null===(l=s)||void 0===l?void 0:l.name]=t[o]:r.append((null===(u=s)||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("/")}))):{},l=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=l(i,t.name);l(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,l=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){l=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(l)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],l=a[1];e[i]=l})),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);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),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 s(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(t,e,r){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(r):o.value}})(t,e,r||t)}function f(t,e){return(f=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 p(t){return(p=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),l=this.urlReadFragment(),u=this.getLocationSearch(),s=this.queryStringFromParams(a,u,r);if(l!==i||u!==s)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(s);window.history.replaceState({},null,f),this.oldLocationHash=i+s}}else{var d=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+i+d),this.oldLocationHash=i+d}},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 y=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}(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=p(n);if(o){var r=p(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return d(this,t)});function i(){return s(this,i),a.apply(this,arguments)}return e=i,(r=[{key:"init",value:function(){var t=this;this.options.enableUrlPlugin&&(this.urlPlugin=new l(this.options),this.bind(BookReader.eventNames.PostInit,(function(){"hash"===t.options.urlMode&&t.urlPlugin.listenForHashChanges()}))),h(p(i.prototype),"init",this).call(this)}}])&&c(e.prototype,r),i}();window.BookReader=y},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(7007),o=r(9670),a=r(7466),i=r(1340),l=r(4488),u=r(1530),s=r(7651);n("match",(function(t,e,r){return[function(e){var r=l(this),n=null==e?void 0:e[t];return void 0!==n?n.call(e,r):new RegExp(e)[t](i(r))},function(t){var n=o(this),l=i(t),c=r(e,n,l);if(c.done)return c.value;if(!n.global)return s(n,l);var h=n.unicode;n.lastIndex=0;for(var f,d=[],p=0;null!==(f=s(n,l));){var y=i(f[0]);d[p]=y,""===y&&(n.lastIndex=u(l,a(n.lastIndex),h)),p++}return 0===p?null:d}]}))}},function(t){t(t.s=1226)}]);
1
+ (self["webpackChunk_internetarchive_bookreader"] = self["webpackChunk_internetarchive_bookreader"] || []).push([["plugins/plugin.url.js"],{
2
+
3
+ /***/ "./src/plugins/url/UrlPlugin.js":
4
+ /*!**************************************!*\
5
+ !*** ./src/plugins/url/UrlPlugin.js ***!
6
+ \**************************************/
7
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
8
+
9
+ "use strict";
10
+ __webpack_require__.r(__webpack_exports__);
11
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
+ /* harmony export */ "UrlPlugin": function() { return /* binding */ UrlPlugin; }
13
+ /* harmony export */ });
14
+ /* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "./node_modules/core-js/modules/es.array.iterator.js");
15
+ /* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_0__);
16
+ /* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "./node_modules/core-js/modules/es.object.to-string.js");
17
+ /* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_1__);
18
+ /* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "./node_modules/core-js/modules/es.string.iterator.js");
19
+ /* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_2__);
20
+ /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "./node_modules/core-js/modules/web.dom-collections.iterator.js");
21
+ /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_3__);
22
+ /* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/web.url.js */ "./node_modules/core-js/modules/web.url.js");
23
+ /* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_4__);
24
+ /* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/web.dom-collections.for-each.js */ "./node_modules/core-js/modules/web.dom-collections.for-each.js");
25
+ /* harmony import */ var core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_for_each_js__WEBPACK_IMPORTED_MODULE_5__);
26
+ /* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.object.keys.js */ "./node_modules/core-js/modules/es.object.keys.js");
27
+ /* harmony import */ var core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_keys_js__WEBPACK_IMPORTED_MODULE_6__);
28
+ /* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/es.array.find.js */ "./node_modules/core-js/modules/es.array.find.js");
29
+ /* harmony import */ var core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_find_js__WEBPACK_IMPORTED_MODULE_7__);
30
+ /* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ "./node_modules/core-js/modules/es.function.name.js");
31
+ /* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_8__);
32
+ /* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.array.join.js */ "./node_modules/core-js/modules/es.array.join.js");
33
+ /* harmony import */ var core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_join_js__WEBPACK_IMPORTED_MODULE_9__);
34
+ /* harmony import */ var core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.array.map.js */ "./node_modules/core-js/modules/es.array.map.js");
35
+ /* harmony import */ var core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_map_js__WEBPACK_IMPORTED_MODULE_10__);
36
+ /* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.array.filter.js */ "./node_modules/core-js/modules/es.array.filter.js");
37
+ /* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_11__);
38
+ /* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.array.concat.js */ "./node_modules/core-js/modules/es.array.concat.js");
39
+ /* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_12__);
40
+ /* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "./node_modules/core-js/modules/es.regexp.exec.js");
41
+ /* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_13__);
42
+ /* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/es.string.replace.js */ "./node_modules/core-js/modules/es.string.replace.js");
43
+ /* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_14__);
44
+ /* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! core-js/modules/es.regexp.to-string.js */ "./node_modules/core-js/modules/es.regexp.to-string.js");
45
+ /* harmony import */ var core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_to_string_js__WEBPACK_IMPORTED_MODULE_15__);
46
+ /* harmony import */ var core_js_modules_es_object_from_entries_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! core-js/modules/es.object.from-entries.js */ "./node_modules/core-js/modules/es.object.from-entries.js");
47
+ /* harmony import */ var core_js_modules_es_object_from_entries_js__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_from_entries_js__WEBPACK_IMPORTED_MODULE_16__);
48
+ /* harmony import */ var core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! core-js/modules/es.string.match.js */ "./node_modules/core-js/modules/es.string.match.js");
49
+ /* harmony import */ var core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_match_js__WEBPACK_IMPORTED_MODULE_17__);
50
+ /* harmony import */ var core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! core-js/modules/es.string.split.js */ "./node_modules/core-js/modules/es.string.split.js");
51
+ /* harmony import */ var core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_split_js__WEBPACK_IMPORTED_MODULE_18__);
52
+ /* harmony import */ var core_js_modules_es_object_entries_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! core-js/modules/es.object.entries.js */ "./node_modules/core-js/modules/es.object.entries.js");
53
+ /* harmony import */ var core_js_modules_es_object_entries_js__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_entries_js__WEBPACK_IMPORTED_MODULE_19__);
54
+ /* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! core-js/modules/es.string.search.js */ "./node_modules/core-js/modules/es.string.search.js");
55
+ /* harmony import */ var core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_search_js__WEBPACK_IMPORTED_MODULE_20__);
56
+ /* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "./node_modules/core-js/modules/es.symbol.js");
57
+ /* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_21__);
58
+ /* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "./node_modules/core-js/modules/es.symbol.description.js");
59
+ /* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_22__);
60
+ /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "./node_modules/core-js/modules/es.symbol.iterator.js");
61
+ /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_23__);
62
+ /* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! core-js/modules/es.array.slice.js */ "./node_modules/core-js/modules/es.array.slice.js");
63
+ /* harmony import */ var core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_slice_js__WEBPACK_IMPORTED_MODULE_24__);
64
+ /* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! core-js/modules/es.array.from.js */ "./node_modules/core-js/modules/es.array.from.js");
65
+ /* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_25__);
66
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
67
+
68
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
69
+
70
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
71
+
72
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
73
+
74
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
75
+
76
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
106
+
107
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
108
+
109
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
110
+
111
+ var UrlPlugin = /*#__PURE__*/function () {
112
+ function UrlPlugin() {
113
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
114
+
115
+ _classCallCheck(this, UrlPlugin);
116
+
117
+ this.bookReaderOptions = options; // the canonical order of elements is important in the path and query string
118
+
119
+ this.urlSchema = [{
120
+ name: 'page',
121
+ position: 'path',
122
+ default: 'n0'
123
+ }, {
124
+ name: 'mode',
125
+ position: 'path',
126
+ default: '2up'
127
+ }, {
128
+ name: 'search',
129
+ position: 'path',
130
+ deprecated_for: 'q'
131
+ }, {
132
+ name: 'q',
133
+ position: 'query_param'
134
+ }, {
135
+ name: 'sort',
136
+ position: 'query_param'
137
+ }, {
138
+ name: 'view',
139
+ position: 'query_param'
140
+ }, {
141
+ name: 'admin',
142
+ position: 'query_param'
143
+ }];
144
+ this.urlState = {};
145
+ this.urlMode = this.bookReaderOptions.urlMode || 'hash';
146
+ this.urlHistoryBasePath = this.bookReaderOptions.urlHistoryBasePath || '/';
147
+ this.urlLocationPollId = null;
148
+ this.oldLocationHash = null;
149
+ this.oldUserHash = null;
150
+ }
151
+ /**
152
+ * Parse JSON object URL state to string format
153
+ * Arrange path names in an order that it is positioned on the urlSchema
154
+ * @param {Object} urlState
155
+ * @returns {string}
156
+ */
157
+
158
+
159
+ _createClass(UrlPlugin, [{
160
+ key: "urlStateToUrlString",
161
+ value: function urlStateToUrlString(urlState) {
162
+ var _this = this;
163
+
164
+ var searchParams = new URLSearchParams();
165
+ var pathParams = {};
166
+ Object.keys(urlState).forEach(function (key) {
167
+ var _schema, _schema2;
168
+
169
+ var schema = _this.urlSchema.find(function (schema) {
170
+ return schema.name === key;
171
+ });
172
+
173
+ if ((_schema = schema) !== null && _schema !== void 0 && _schema.deprecated_for) {
174
+ schema = _this.urlSchema.find(function (schemaKey) {
175
+ return schemaKey.name === schema.deprecated_for;
176
+ });
177
+ }
178
+
179
+ if (((_schema2 = schema) === null || _schema2 === void 0 ? void 0 : _schema2.position) == 'path') {
180
+ var _schema3;
181
+
182
+ pathParams[(_schema3 = schema) === null || _schema3 === void 0 ? void 0 : _schema3.name] = urlState[key];
183
+ } else {
184
+ var _schema4;
185
+
186
+ searchParams.append(((_schema4 = schema) === null || _schema4 === void 0 ? void 0 : _schema4.name) || key, urlState[key]);
187
+ }
188
+ });
189
+ var strPathParams = this.urlSchema.filter(function (s) {
190
+ return s.position == 'path';
191
+ }).map(function (schema) {
192
+ return pathParams[schema.name] ? "".concat(schema.name, "/").concat(pathParams[schema.name]) : '';
193
+ }).join('/'); // replace consecutive slashes with a single slash + remove trailing slashes
194
+
195
+ var strStrippedTrailingSlash = "".concat(strPathParams.replace(/\/+/g, '/').replace(/\/+$/, ''));
196
+ var concatenatedPath = "".concat(strStrippedTrailingSlash, "?").concat(searchParams.toString());
197
+ return searchParams.toString() ? concatenatedPath : "".concat(strStrippedTrailingSlash);
198
+ }
199
+ /**
200
+ * Parse string URL and add it in the current urlState
201
+ * Example:
202
+ * /page/n7/mode/2up => {page: 'n7', mode: '2up'}
203
+ * /page/n7/mode/2up/search/hello => {page: 'n7', mode: '2up', q: 'hello'}
204
+ * @param {string} urlString
205
+ * @returns {object}
206
+ */
207
+
208
+ }, {
209
+ key: "urlStringToUrlState",
210
+ value: function urlStringToUrlState(urlString) {
211
+ var urlState = {}; // Fetch searchParams from given {str}
212
+ // Note: whole URL path is needed for URL parsing
213
+
214
+ var urlPath = new URL(urlString, 'http://example.com');
215
+ var urlSearchParamsObj = Object.fromEntries(urlPath.searchParams.entries());
216
+ var splitUrlMatches = urlPath.pathname.match(/[^\\/]+\/[^\\/]+/g);
217
+ var urlStrSplitSlashObj = splitUrlMatches ? Object.fromEntries(splitUrlMatches.map(function (x) {
218
+ return x.split('/');
219
+ })) : {};
220
+
221
+ var doesKeyExists = function doesKeyExists(_object, _key) {
222
+ return Object.keys(_object).some(function (value) {
223
+ return value == _key;
224
+ });
225
+ }; // Add path objects to urlState
226
+
227
+
228
+ this.urlSchema.filter(function (schema) {
229
+ return schema.position == 'path';
230
+ }).forEach(function (schema) {
231
+ var hasPropertyKey = doesKeyExists(urlStrSplitSlashObj, schema.name);
232
+ var hasDeprecatedKey = doesKeyExists(schema, 'deprecated_for') && hasPropertyKey;
233
+
234
+ if (hasDeprecatedKey) {
235
+ urlState[schema.deprecated_for] = urlStrSplitSlashObj[schema.name];
236
+ return;
237
+ }
238
+
239
+ if (hasPropertyKey) {
240
+ urlState[schema.name] = urlStrSplitSlashObj[schema.name];
241
+ return;
242
+ }
243
+ }); // Add searchParams to urlState
244
+
245
+ Object.entries(urlSearchParamsObj).forEach(function (_ref) {
246
+ var _ref2 = _slicedToArray(_ref, 2),
247
+ key = _ref2[0],
248
+ value = _ref2[1];
249
+
250
+ urlState[key] = value;
251
+ });
252
+ return urlState;
253
+ }
254
+ /**
255
+ * Add or update key-value to the urlState
256
+ * @param {string} key
257
+ * @param {string} val
258
+ */
259
+
260
+ }, {
261
+ key: "setUrlParam",
262
+ value: function setUrlParam(key, value) {
263
+ this.urlState[key] = value;
264
+ this.pushToAddressBar();
265
+ }
266
+ /**
267
+ * Delete key-value to the urlState
268
+ * @param {string} key
269
+ */
270
+
271
+ }, {
272
+ key: "removeUrlParam",
273
+ value: function removeUrlParam(key) {
274
+ delete this.urlState[key];
275
+ this.pushToAddressBar();
276
+ }
277
+ /**
278
+ * Get key-value from the urlState
279
+ * @param {string} key
280
+ * @return {string}
281
+ */
282
+
283
+ }, {
284
+ key: "getUrlParam",
285
+ value: function getUrlParam(key) {
286
+ return this.urlState[key];
287
+ }
288
+ /**
289
+ * Push URL params to addressbar
290
+ */
291
+
292
+ }, {
293
+ key: "pushToAddressBar",
294
+ value: function pushToAddressBar() {
295
+ var urlStrPath = this.urlStateToUrlString(this.urlState);
296
+ var concatenatedPath = urlStrPath !== '/' ? urlStrPath : '';
297
+
298
+ if (this.urlMode == 'history') {
299
+ if (window.history && window.history.replaceState) {
300
+ var newUrlPath = "".concat(this.urlHistoryBasePath).concat(concatenatedPath);
301
+ window.history.replaceState({}, null, newUrlPath);
302
+ }
303
+ } else {
304
+ window.location.replace('#' + concatenatedPath);
305
+ }
306
+
307
+ this.oldLocationHash = urlStrPath;
308
+ }
309
+ /**
310
+ * Get the url and check if it has changed
311
+ * If it was changeed, update the urlState
312
+ */
313
+
314
+ }, {
315
+ key: "listenForHashChanges",
316
+ value: function listenForHashChanges() {
317
+ var _this2 = this;
318
+
319
+ this.oldLocationHash = window.location.hash.substr(1);
320
+
321
+ if (this.urlLocationPollId) {
322
+ clearInterval(this.urlLocationPollId);
323
+ this.urlLocationPollId = null;
324
+ } // check if the URL changes
325
+
326
+
327
+ var updateHash = function updateHash() {
328
+ var newFragment = window.location.hash.substr(1);
329
+ var hasFragmentChange = newFragment != _this2.oldLocationHash;
330
+
331
+ if (!hasFragmentChange) {
332
+ return;
333
+ }
334
+
335
+ _this2.urlState = _this2.urlStringToUrlState(newFragment);
336
+ };
337
+
338
+ this.urlLocationPollId = setInterval(updateHash, 500);
339
+ }
340
+ /**
341
+ * Will read either the hash or URL and return the bookreader fragment
342
+ */
343
+
344
+ }, {
345
+ key: "pullFromAddressBar",
346
+ value: function pullFromAddressBar() {
347
+ var location = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location;
348
+ var path = this.urlMode === 'history' ? location.pathname.substr(this.urlHistoryBasePath.length) + location.search : location.hash.substr(1);
349
+ this.urlState = this.urlStringToUrlState(path);
350
+ }
351
+ }]);
352
+
353
+ return UrlPlugin;
354
+ }();
355
+
356
+ /***/ }),
357
+
358
+ /***/ "./src/plugins/url/plugin.url.js":
359
+ /*!***************************************!*\
360
+ !*** ./src/plugins/url/plugin.url.js ***!
361
+ \***************************************/
362
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
363
+
364
+ "use strict";
365
+ __webpack_require__.r(__webpack_exports__);
366
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
367
+ /* harmony export */ "BookreaderUrlPlugin": function() { return /* binding */ BookreaderUrlPlugin; }
368
+ /* harmony export */ });
369
+ /* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.reduce.js */ "./node_modules/core-js/modules/es.array.reduce.js");
370
+ /* harmony import */ var core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_reduce_js__WEBPACK_IMPORTED_MODULE_0__);
371
+ /* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.regexp.exec.js */ "./node_modules/core-js/modules/es.regexp.exec.js");
372
+ /* harmony import */ var core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_regexp_exec_js__WEBPACK_IMPORTED_MODULE_1__);
373
+ /* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.string.replace.js */ "./node_modules/core-js/modules/es.string.replace.js");
374
+ /* harmony import */ var core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_replace_js__WEBPACK_IMPORTED_MODULE_2__);
375
+ /* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.array.concat.js */ "./node_modules/core-js/modules/es.array.concat.js");
376
+ /* harmony import */ var core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_concat_js__WEBPACK_IMPORTED_MODULE_3__);
377
+ /* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.array.iterator.js */ "./node_modules/core-js/modules/es.array.iterator.js");
378
+ /* harmony import */ var core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_iterator_js__WEBPACK_IMPORTED_MODULE_4__);
379
+ /* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/es.object.to-string.js */ "./node_modules/core-js/modules/es.object.to-string.js");
380
+ /* harmony import */ var core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string_js__WEBPACK_IMPORTED_MODULE_5__);
381
+ /* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! core-js/modules/es.string.iterator.js */ "./node_modules/core-js/modules/es.string.iterator.js");
382
+ /* harmony import */ var core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_iterator_js__WEBPACK_IMPORTED_MODULE_6__);
383
+ /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! core-js/modules/web.dom-collections.iterator.js */ "./node_modules/core-js/modules/web.dom-collections.iterator.js");
384
+ /* harmony import */ var core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_dom_collections_iterator_js__WEBPACK_IMPORTED_MODULE_7__);
385
+ /* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! core-js/modules/web.url.js */ "./node_modules/core-js/modules/web.url.js");
386
+ /* harmony import */ var core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_web_url_js__WEBPACK_IMPORTED_MODULE_8__);
387
+ /* harmony import */ var core_js_modules_es_object_get_prototype_of_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! core-js/modules/es.object.get-prototype-of.js */ "./node_modules/core-js/modules/es.object.get-prototype-of.js");
388
+ /* harmony import */ var core_js_modules_es_object_get_prototype_of_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_prototype_of_js__WEBPACK_IMPORTED_MODULE_9__);
389
+ /* harmony import */ var core_js_modules_es_reflect_construct_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! core-js/modules/es.reflect.construct.js */ "./node_modules/core-js/modules/es.reflect.construct.js");
390
+ /* harmony import */ var core_js_modules_es_reflect_construct_js__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_reflect_construct_js__WEBPACK_IMPORTED_MODULE_10__);
391
+ /* harmony import */ var core_js_modules_es_reflect_get_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! core-js/modules/es.reflect.get.js */ "./node_modules/core-js/modules/es.reflect.get.js");
392
+ /* harmony import */ var core_js_modules_es_reflect_get_js__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_reflect_get_js__WEBPACK_IMPORTED_MODULE_11__);
393
+ /* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! core-js/modules/es.object.get-own-property-descriptor.js */ "./node_modules/core-js/modules/es.object.get-own-property-descriptor.js");
394
+ /* harmony import */ var core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_get_own_property_descriptor_js__WEBPACK_IMPORTED_MODULE_12__);
395
+ /* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "./node_modules/core-js/modules/es.symbol.js");
396
+ /* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_13__);
397
+ /* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "./node_modules/core-js/modules/es.symbol.description.js");
398
+ /* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_14__);
399
+ /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "./node_modules/core-js/modules/es.symbol.iterator.js");
400
+ /* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_15__);
401
+ /* harmony import */ var _UrlPlugin__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./UrlPlugin */ "./src/plugins/url/UrlPlugin.js");
402
+ /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery");
403
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
404
+
405
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
406
+
407
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
408
+
409
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
410
+
411
+ function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
412
+
413
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
414
+
415
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
416
+
417
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
418
+
419
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
420
+
421
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
422
+
423
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
424
+
425
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
426
+
427
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+ /* global BookReader */
447
+
448
+ /**
449
+ * Plugin for URL management in BookReader
450
+ * Note read more about the url "fragment" here:
451
+ * https://openlibrary.org/dev/docs/bookurls
452
+ */
453
+
454
+ jQuery.extend(BookReader.defaultOptions, {
455
+ enableUrlPlugin: true,
456
+ bookId: '',
457
+
458
+ /** @type {string} Defaults can be a urlFragment string */
459
+ defaults: null,
460
+ updateWindowTitle: false,
461
+
462
+ /** @type {'history' | 'hash'} */
463
+ urlMode: 'hash',
464
+
465
+ /**
466
+ * When using 'history' mode, this part of the URL is kept constant
467
+ * @example /details/plato/
468
+ */
469
+ urlHistoryBasePath: '/',
470
+
471
+ /** Only these params will be reflected onto the URL */
472
+ urlTrackedParams: ['page', 'search', 'mode', 'region', 'highlight', 'view'],
473
+
474
+ /** If true, don't update the URL when `page == n0 (eg "/page/n0")` */
475
+ urlTrackIndex0: false
476
+ });
477
+ /** @override */
478
+
479
+ BookReader.prototype.setup = function (super_) {
480
+ return function (options) {
481
+ super_.call(this, options);
482
+ this.bookId = options.bookId;
483
+ this.defaults = options.defaults;
484
+ this.locationPollId = null;
485
+ this.oldLocationHash = null;
486
+ this.oldUserHash = null;
487
+ };
488
+ }(BookReader.prototype.setup);
489
+ /** @override */
490
+
491
+
492
+ BookReader.prototype.init = function (super_) {
493
+ return function () {
494
+ var _this = this;
495
+
496
+ if (this.options.enableUrlPlugin) {
497
+ this.bind(BookReader.eventNames.PostInit, function () {
498
+ var _this$options = _this.options,
499
+ updateWindowTitle = _this$options.updateWindowTitle,
500
+ urlMode = _this$options.urlMode;
501
+
502
+ if (updateWindowTitle) {
503
+ document.title = _this.shortTitle(_this.bookTitle, 50);
504
+ }
505
+
506
+ if (urlMode === 'hash') {
507
+ _this.urlStartLocationPolling();
508
+ }
509
+ });
510
+ this.bind(BookReader.eventNames.fragmentChange, this.urlUpdateFragment.bind(this));
511
+ }
512
+
513
+ super_.call(this);
514
+ };
515
+ }(BookReader.prototype.init);
516
+ /**
517
+ * Returns a shortened version of the title with the maximum number of characters
518
+ * @param {number} maximumCharacters
519
+ * @return {string}
520
+ */
521
+
522
+
523
+ BookReader.prototype.shortTitle = function (maximumCharacters) {
524
+ if (this.bookTitle.length < maximumCharacters) {
525
+ return this.bookTitle;
526
+ }
527
+
528
+ var title = "".concat(this.bookTitle.substr(0, maximumCharacters - 3), "...");
529
+ return title;
530
+ };
531
+ /**
532
+ * Starts polling of window.location to see hash fragment changes
533
+ */
534
+
535
+
536
+ BookReader.prototype.urlStartLocationPolling = function () {
537
+ var _this2 = this;
538
+
539
+ this.oldLocationHash = this.urlReadFragment();
540
+
541
+ if (this.locationPollId) {
542
+ clearInterval(this.locationPollId);
543
+ this.locationPollId = null;
544
+ }
545
+
546
+ var updateHash = function updateHash() {
547
+ var newFragment = _this2.urlReadFragment();
548
+
549
+ var hasFragmentChange = newFragment != _this2.oldLocationHash && newFragment != _this2.oldUserHash;
550
+
551
+ if (!hasFragmentChange) {
552
+ return;
553
+ }
554
+
555
+ var params = _this2.paramsFromFragment(newFragment);
556
+
557
+ var updateParams = function updateParams() {
558
+ return _this2.updateFromParams(params);
559
+ };
560
+
561
+ _this2.trigger(BookReader.eventNames.stop);
562
+
563
+ if (_this2.animating) {
564
+ // Queue change if animating
565
+ if (_this2.autoStop) _this2.autoStop();
566
+ _this2.animationFinishedCallback = updateParams;
567
+ } else {
568
+ // update immediately
569
+ updateParams();
570
+ }
571
+
572
+ _this2.oldUserHash = newFragment;
573
+ };
574
+
575
+ this.locationPollId = setInterval(updateHash, 500);
576
+ };
577
+ /**
578
+ * Update URL from the current parameters.
579
+ * Call this instead of manually using window.location.replace
580
+ */
581
+
582
+
583
+ BookReader.prototype.urlUpdateFragment = function () {
584
+ var allParams = this.paramsFromCurrent();
585
+ var _this$options2 = this.options,
586
+ urlMode = _this$options2.urlMode,
587
+ urlTrackIndex0 = _this$options2.urlTrackIndex0,
588
+ urlTrackedParams = _this$options2.urlTrackedParams;
589
+
590
+ if (!urlTrackIndex0 && typeof allParams.index !== 'undefined' && allParams.index === 0) {
591
+ delete allParams.index;
592
+ delete allParams.page;
593
+ }
594
+
595
+ var params = urlTrackedParams.reduce(function (validParams, paramName) {
596
+ if (paramName in allParams) {
597
+ validParams[paramName] = allParams[paramName];
598
+ }
599
+
600
+ return validParams;
601
+ }, {});
602
+ var newFragment = this.fragmentFromParams(params, urlMode);
603
+ var currFragment = this.urlReadFragment();
604
+ var currQueryString = this.getLocationSearch();
605
+ var newQueryString = this.queryStringFromParams(params, currQueryString, urlMode);
606
+
607
+ if (currFragment === newFragment && currQueryString === newQueryString) {
608
+ return;
609
+ }
610
+
611
+ if (urlMode === 'history') {
612
+ if (window.history && window.history.replaceState) {
613
+ var baseWithoutSlash = this.options.urlHistoryBasePath.replace(/\/+$/, '');
614
+ var newFragmentWithSlash = newFragment === '' ? '' : "/".concat(newFragment);
615
+ var newUrlPath = "".concat(baseWithoutSlash).concat(newFragmentWithSlash).concat(newQueryString);
616
+ window.history.replaceState({}, null, newUrlPath);
617
+ this.oldLocationHash = newFragment + newQueryString;
618
+ }
619
+ } else {
620
+ var newQueryStringSearch = this.urlParamsFiltersOnlySearch(this.readQueryString());
621
+ window.location.replace('#' + newFragment + newQueryStringSearch);
622
+ this.oldLocationHash = newFragment + newQueryStringSearch;
623
+ }
624
+ };
625
+ /**
626
+ * @private
627
+ * Filtering query parameters to select only book search param (?q=foo)
628
+ This needs to be updated/URL system modified if future query params are to be added
629
+ * @param {string} url
630
+ * @return {string}
631
+ * */
632
+
633
+
634
+ BookReader.prototype.urlParamsFiltersOnlySearch = function (url) {
635
+ var params = new URLSearchParams(url);
636
+ return params.has('q') ? "?".concat(new URLSearchParams({
637
+ q: params.get('q')
638
+ })) : '';
639
+ };
640
+ /**
641
+ * Will read either the hash or URL and return the bookreader fragment
642
+ * @return {string}
643
+ */
644
+
645
+
646
+ BookReader.prototype.urlReadFragment = function () {
647
+ var _this$options3 = this.options,
648
+ urlMode = _this$options3.urlMode,
649
+ urlHistoryBasePath = _this$options3.urlHistoryBasePath;
650
+
651
+ if (urlMode === 'history') {
652
+ return window.location.pathname.substr(urlHistoryBasePath.length);
653
+ } else {
654
+ return window.location.hash.substr(1);
655
+ }
656
+ };
657
+ /**
658
+ * Will read the hash return the bookreader fragment
659
+ * @return {string}
660
+ */
661
+
662
+
663
+ BookReader.prototype.urlReadHashFragment = function () {
664
+ return window.location.hash.substr(1);
665
+ };
666
+
667
+ var BookreaderUrlPlugin = /*#__PURE__*/function (_BookReader) {
668
+ _inherits(BookreaderUrlPlugin, _BookReader);
669
+
670
+ var _super = _createSuper(BookreaderUrlPlugin);
671
+
672
+ function BookreaderUrlPlugin() {
673
+ _classCallCheck(this, BookreaderUrlPlugin);
674
+
675
+ return _super.apply(this, arguments);
676
+ }
677
+
678
+ _createClass(BookreaderUrlPlugin, [{
679
+ key: "init",
680
+ value: function init() {
681
+ var _this3 = this;
682
+
683
+ if (this.options.enableUrlPlugin) {
684
+ this.urlPlugin = new _UrlPlugin__WEBPACK_IMPORTED_MODULE_16__.UrlPlugin(this.options);
685
+ this.bind(BookReader.eventNames.PostInit, function () {
686
+ var urlMode = _this3.options.urlMode;
687
+
688
+ if (urlMode === 'hash') {
689
+ _this3.urlPlugin.listenForHashChanges();
690
+ }
691
+ });
692
+ }
693
+
694
+ _get(_getPrototypeOf(BookreaderUrlPlugin.prototype), "init", this).call(this);
695
+ }
696
+ }]);
697
+
698
+ return BookreaderUrlPlugin;
699
+ }(BookReader);
700
+ window.BookReader = BookreaderUrlPlugin;
701
+ /* harmony default export */ __webpack_exports__["default"] = (BookreaderUrlPlugin);
702
+
703
+ /***/ }),
704
+
705
+ /***/ "./node_modules/core-js/modules/es.object.entries.js":
706
+ /*!***********************************************************!*\
707
+ !*** ./node_modules/core-js/modules/es.object.entries.js ***!
708
+ \***********************************************************/
709
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
710
+
711
+ var $ = __webpack_require__(/*! ../internals/export */ "./node_modules/core-js/internals/export.js");
712
+ var $entries = __webpack_require__(/*! ../internals/object-to-array */ "./node_modules/core-js/internals/object-to-array.js").entries;
713
+
714
+ // `Object.entries` method
715
+ // https://tc39.es/ecma262/#sec-object.entries
716
+ $({ target: 'Object', stat: true }, {
717
+ entries: function entries(O) {
718
+ return $entries(O);
719
+ }
720
+ });
721
+
722
+
723
+ /***/ }),
724
+
725
+ /***/ "./node_modules/core-js/modules/es.object.from-entries.js":
726
+ /*!****************************************************************!*\
727
+ !*** ./node_modules/core-js/modules/es.object.from-entries.js ***!
728
+ \****************************************************************/
729
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
730
+
731
+ var $ = __webpack_require__(/*! ../internals/export */ "./node_modules/core-js/internals/export.js");
732
+ var iterate = __webpack_require__(/*! ../internals/iterate */ "./node_modules/core-js/internals/iterate.js");
733
+ var createProperty = __webpack_require__(/*! ../internals/create-property */ "./node_modules/core-js/internals/create-property.js");
734
+
735
+ // `Object.fromEntries` method
736
+ // https://github.com/tc39/proposal-object-from-entries
737
+ $({ target: 'Object', stat: true }, {
738
+ fromEntries: function fromEntries(iterable) {
739
+ var obj = {};
740
+ iterate(iterable, function (k, v) {
741
+ createProperty(obj, k, v);
742
+ }, { AS_ENTRIES: true });
743
+ return obj;
744
+ }
745
+ });
746
+
747
+
748
+ /***/ }),
749
+
750
+ /***/ "./node_modules/core-js/modules/es.string.match.js":
751
+ /*!*********************************************************!*\
752
+ !*** ./node_modules/core-js/modules/es.string.match.js ***!
753
+ \*********************************************************/
754
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
755
+
756
+ "use strict";
757
+
758
+ var fixRegExpWellKnownSymbolLogic = __webpack_require__(/*! ../internals/fix-regexp-well-known-symbol-logic */ "./node_modules/core-js/internals/fix-regexp-well-known-symbol-logic.js");
759
+ var anObject = __webpack_require__(/*! ../internals/an-object */ "./node_modules/core-js/internals/an-object.js");
760
+ var toLength = __webpack_require__(/*! ../internals/to-length */ "./node_modules/core-js/internals/to-length.js");
761
+ var toString = __webpack_require__(/*! ../internals/to-string */ "./node_modules/core-js/internals/to-string.js");
762
+ var requireObjectCoercible = __webpack_require__(/*! ../internals/require-object-coercible */ "./node_modules/core-js/internals/require-object-coercible.js");
763
+ var advanceStringIndex = __webpack_require__(/*! ../internals/advance-string-index */ "./node_modules/core-js/internals/advance-string-index.js");
764
+ var regExpExec = __webpack_require__(/*! ../internals/regexp-exec-abstract */ "./node_modules/core-js/internals/regexp-exec-abstract.js");
765
+
766
+ // @@match logic
767
+ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) {
768
+ return [
769
+ // `String.prototype.match` method
770
+ // https://tc39.es/ecma262/#sec-string.prototype.match
771
+ function match(regexp) {
772
+ var O = requireObjectCoercible(this);
773
+ var matcher = regexp == undefined ? undefined : regexp[MATCH];
774
+ return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](toString(O));
775
+ },
776
+ // `RegExp.prototype[@@match]` method
777
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
778
+ function (string) {
779
+ var rx = anObject(this);
780
+ var S = toString(string);
781
+ var res = maybeCallNative(nativeMatch, rx, S);
782
+
783
+ if (res.done) return res.value;
784
+
785
+ if (!rx.global) return regExpExec(rx, S);
786
+
787
+ var fullUnicode = rx.unicode;
788
+ rx.lastIndex = 0;
789
+ var A = [];
790
+ var n = 0;
791
+ var result;
792
+ while ((result = regExpExec(rx, S)) !== null) {
793
+ var matchStr = toString(result[0]);
794
+ A[n] = matchStr;
795
+ if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
796
+ n++;
797
+ }
798
+ return n === 0 ? null : A;
799
+ }
800
+ ];
801
+ });
802
+
803
+
804
+ /***/ })
805
+
806
+ },
807
+ /******/ function(__webpack_require__) { // webpackRuntimeModules
808
+ /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
809
+ /******/ var __webpack_exports__ = (__webpack_exec__("./src/plugins/url/plugin.url.js"));
810
+ /******/ }
811
+ ]);
2
812
  //# sourceMappingURL=plugin.url.js.map