@internetarchive/bookreader 5.0.0-49-a1 → 5.0.0-49

Sign up to get free protection for your applications and to get access to all the features.
@@ -1142,7 +1142,7 @@
1142
1142
  .stroke-color {
1143
1143
  stroke: var(--iconStrokeColor);
1144
1144
  }
1145
- `}render(){return hn}}function pn(e){return(pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function vn(e){return function(e){if(Array.isArray(e))return bn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return bn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bn(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function gn(e,t){return(gn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function kn(e,t){if(t&&("object"===pn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function wn(e){return(wn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("ia-icon-magnify-plus",fn);var Cn,On,Sn=function(e){return"visualAdjustment".concat(e)},xn={optionChange:Sn("OptionChanged"),zoomIn:Sn("ZoomIn"),zoomOut:Sn("ZoomOut")},Bn=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&gn(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=wn(i);if(a){var n=wn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return kn(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).activeCount=0,e.options=[],e.renderHeader=!1,e.showZoomControls=!0,e}return t=l,o=[{key:"properties",get:function(){return{activeCount:{type:Number},options:{type:Array},renderHeader:{type:Boolean},showZoomControls:{type:Boolean}}}},{key:"styles",get:function(){return(0,r.iv)(dn||(dn=mn(['\n :host {\n display: block;\n height: 100%;\n overflow-y: auto;\n font-size: 1.4rem;\n box-sizing: border-box;\n }\n\n header {\n display: flex;\n align-items: baseline;\n }\n\n h3 {\n padding: 0;\n margin: 0 1rem 0 0;\n font-size: 1.6rem;\n }\n\n header p {\n padding: 0;\n margin: 0;\n font-size: 1.2rem;\n font-weight: bold;\n font-style: italic;\n }\n\n ul {\n padding: 1rem 2rem 0 0;\n list-style: none;\n margin-top: 0;\n }\n\n [type="checkbox"] {\n display: none;\n }\n\n label {\n display: flex;\n justify-content: space-between;\n align-items: baseline;\n font-size: 1.4rem;\n font-weight: bold;\n line-height: 150%;\n vertical-align: middle;\n }\n\n .icon {\n display: inline-block;\n width: 14px;\n height: 14px;\n margin-left: .7rem;\n border: 1px solid var(--primaryTextColor);\n border-radius: 2px;\n background: var(--activeButtonBg) 50% 50% no-repeat;\n }\n :checked + .icon {\n background-image: url(\'',"');\n }\n\n .range {\n display: none;\n padding-top: .5rem;\n }\n .range.visible {\n display: flex;\n }\n\n .range p {\n margin-left: 1rem;\n }\n\n h4 {\n padding: 1rem 0;\n margin: 0;\n font-size: 1.4rem;\n }\n\n button {\n -webkit-appearance: none;\n appearance: none;\n border: none;\n border-radius: 0;\n background: transparent;\n outline: none;\n cursor: pointer;\n --iconFillColor: var(--primaryTextColor);\n --iconStrokeColor: var(--primaryTextColor);\n height: 4rem;\n width: 4rem;\n }\n\n button * {\n display: inline-block;\n }"])),Ve)}}],(n=[{key:"firstUpdated",value:function(){this.activeCount=this.activeOptions.length,this.emitOptionChangedEvent()}},{key:"activeOptions",get:function(){return this.options.reduce((function(e,t){return t.active?[].concat(vn(e),[t.id]):e}),[])}},{key:"prepareEventDetails",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{options:this.options,activeCount:this.activeCount,changedOptionId:e}}},{key:"emitOptionChangedEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.prepareEventDetails(e);this.dispatchEvent(new CustomEvent(xn.optionChange,{bubbles:!0,composed:!0,detail:t}))}},{key:"emitZoomIn",value:function(){this.dispatchEvent(new CustomEvent(xn.zoomIn))}},{key:"emitZoomOut",value:function(){this.dispatchEvent(new CustomEvent(xn.zoomOut))}},{key:"changeActiveStateFor",value:function(e){var t=vn(this.options),n=t.find((function(t){return t.id===e}));n.active=!n.active,this.options=t,this.activeCount=this.activeOptions.length,this.emitOptionChangedEvent(n.id)}},{key:"setRangeValue",value:function(e,t){var n=vn(this.options);n.find((function(t){return t.id===e})).value=t,this.options=vn(n)}},{key:"rangeSlider",value:function(e){var t=this;return(0,r.dy)(on||(on=mn(["\n <div class=",'>\n <input\n type="range"\n name="','_range"\n min=',"\n max=","\n step=","\n .value=","\n @input=","\n @change=","\n />\n <p>","%</p>\n </div>\n "])),"range".concat(e.active?" visible":""),e.id,e.min||0,e.max||100,e.step||1,e.value,(function(n){return t.setRangeValue(e.id,n.target.value)}),(function(){return t.emitOptionChangedEvent()}),e.value)}},{key:"adjustmentCheckbox",value:function(e){var t=this,n="adjustment_".concat(e.id);return(0,r.dy)(an||(an=mn(['<li>\n <label for="','">\n <span class="name">','</span>\n <input\n type="checkbox"\n name="','"\n id="','"\n @change=',"\n ?checked=",'\n />\n <span class="icon"></span>\n </label>\n ',"\n </li>"])),n,e.name,n,n,(function(){return t.changeActiveStateFor(e.id)}),e.active,void 0!==e.value?this.rangeSlider(e):r.Ld)}},{key:"headerSection",get:function(){var e=this.activeCount?(0,r.dy)(sn||(sn=mn(["<p>("," active)</p>"])),this.activeCount):r.Ld,t=(0,r.dy)(ln||(ln=mn(["<header>\n <h3>Visual adjustments</h3>\n ","\n </header>"])),e);return this.renderHeader?t:r.Ld}},{key:"zoomControls",get:function(){return(0,r.dy)(cn||(cn=mn(['\n <h4>Zoom</h4>\n <button class="zoom_out" @click=',' title="zoom out">\n <ia-icon-magnify-minus></ia-icon-magnify-minus>\n </button>\n <button class="zoom_in" @click=',' title="zoom in">\n <ia-icon-magnify-plus></ia-icon-magnify-plus>\n </button>\n '])),this.emitZoomOut,this.emitZoomIn)}},{key:"render",value:function(){return(0,r.dy)(un||(un=mn(["\n ","\n <ul>\n ","\n </ul>\n ","\n "])),this.headerSection,tn(this.options,(function(e){return e.id}),this.adjustmentCheckbox.bind(this)),this.showZoomControls?this.zoomControls:r.Ld)}}])&&yn(t.prototype,n),o&&yn(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function En(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}customElements.define("ia-book-visual-adjustments",Bn);var Ln,In,Mn=[{id:"brightness",name:"Adjust brightness",active:!1,min:0,max:150,step:1,value:100},{id:"contrast",name:"Adjust contrast",active:!1,min:0,max:150,step:1,value:100},{id:"invert",name:"Inverted colors (dark mode)",active:!1},{id:"grayscale",name:"Grayscale",active:!1}],zn=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=t.onProviderChange,o=t.bookreader;this.onProviderChange=n,this.bookContainer=o.refs.$brContainer,this.bookreader=o,this.onAdjustmentChange=this.onAdjustmentChange.bind(this),this.optionUpdateComplete=this.optionUpdateComplete.bind(this),this.updateOptionsCount=this.updateOptionsCount.bind(this),this.onZoomIn=this.onZoomIn.bind(this),this.onZoomOut=this.onZoomOut.bind(this),this.activeCount=0,this.icon=(0,r.dy)(Cn||(Cn=Pn(['<ia-icon-visual-adjustment style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-visual-adjustment>']))),this.label="Visual Adjustments",this.menuDetails=this.updateOptionsCount(),this.id="adjustment",this.component=(0,r.dy)(On||(On=Pn(["\n <ia-book-visual-adjustments\n .options=","\n @visualAdjustmentOptionChanged=","\n @visualAdjustmentZoomIn=","\n @visualAdjustmentZoomOut=","\n ></ia-book-visual-adjustments>\n "])),Mn,this.onAdjustmentChange,this.onZoomIn,this.onZoomOut)}var t,n;return t=e,(n=[{key:"onZoomIn",value:function(){this.bookreader.zoom(1)}},{key:"onZoomOut",value:function(){this.bookreader.zoom(-1)}},{key:"onAdjustmentChange",value:function(e){var t=e.detail,n={brightness:function(e){return"brightness(".concat(e,"%)")},contrast:function(e){return"contrast(".concat(e,"%)")},grayscale:function(){return"grayscale(100%)"},invert:function(){return"invert(100%)"}},r=t.options.reduce((function(e,t){var r,o="".concat(t.active?n[t.id](t.value):"");return o?[].concat(function(e){if(Array.isArray(e))return jn(e)}(r=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jn(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[o]):e}),[]).join(" ");this.bookContainer.css("filter",r),this.optionUpdateComplete(e)}},{key:"optionUpdateComplete",value:function(e){this.activeCount=e.detail.activeCount,this.updateOptionsCount(e),this.onProviderChange()}},{key:"updateOptionsCount",value:function(){this.menuDetails="(".concat(this.activeCount," active)")}}])&&En(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Dn(e){return(Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function An(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Tn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Rn(e,t){return(Rn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $n(e,t){if(t&&("object"===Dn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Hn(e){return(Hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Fn,Nn,Un=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Rn(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=Hn(i);if(a){var n=Hn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return $n(this,e)});function l(){return Tn(this,l),s.apply(this,arguments)}return t=l,o=[{key:"styles",get:function(){return(0,r.iv)(In||(In=An(['\n div {\n display: flex;\n justify-content: center;\n padding-top: 2rem;\n }\n\n button {\n appearance: none;\n padding: 0.5rem 1rem;\n margin: 0 .5rem;\n box-sizing: border-box;\n font: 1.3rem "Helvetica Neue", Helvetica, Arial, sans-serif;\n color: var(--primaryTextColor);\n border: none;\n border-radius: 4px;\n cursor: pointer;\n background: var(--primaryCTAFill);\n }\n\n .delete {\n background: var(--primaryErrorCTAFill);\n }\n '])))}},{key:"properties",get:function(){return{cancelAction:{type:Function},deleteAction:{type:Function},pageID:{type:String}}}}],(n=[{key:"render",value:function(){var e=this;return(0,r.dy)(Ln||(Ln=An(['\n <div>\n <button class="delete" @click=',">Delete</button>\n <button @click=",">Cancel</button>\n </div>\n "])),(function(){return e.deleteAction({detail:{id:"".concat(e.pageID)}})}),(function(){return e.cancelAction()}))}}])&&_n(t.prototype,n),o&&_n(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function qn(e){return(qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Vn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Zn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Wn(e,t){return(Wn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Gn(e,t){if(t&&("object"===qn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Yn(e){return(Yn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("delete-modal-actions",Un);var Xn,Jn=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Wn(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=Yn(i);if(a){var n=Yn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Gn(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).state="hollow",e.side=void 0,e}return t=l,o=[{key:"styles",get:function(){return(0,r.iv)(Nn||(Nn=Vn(["\n button {\n -webkit-appearance: none;\n appearance: none;\n outline: 0;\n border: none;\n padding: 0;\n height: 4rem;\n width: 4rem;\n background: transparent;\n cursor: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 24' width='16'%3E%3Cg fill='%23333' fill-rule='evenodd'%3E%3Cpath d='m15 0c.5522847 0 1 .44771525 1 1v23l-8-5.4545455-8 5.4545455v-23c0-.55228475.44771525-1 1-1zm-2 2h-10c-.51283584 0-.93550716.38604019-.99327227.88337887l-.00672773.11662113v18l6-4.3181818 6 4.3181818v-18c0-.51283584-.3860402-.93550716-.8833789-.99327227z'/%3E%3Cpath d='m8.75 6v2.25h2.25v1.5h-2.25v2.25h-1.5v-2.25h-2.25v-1.5h2.25v-2.25z' fill-rule='nonzero'/%3E%3C/g%3E%3C/svg%3E\"), pointer;\n position: relative;\n }\n button > * {\n display: block;\n position: absolute;\n top: 0.2rem;\n }\n button.left > * {\n left: 0.2rem;\n }\n\n button.right > * {\n right: 0.2rem;\n }\n "])))}},{key:"properties",get:function(){return{side:{type:String},state:{type:String}}}}],(n=[{key:"handleClick",value:function(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("bookmarkButtonClicked"))}},{key:"title",get:function(){return"".concat("hollow"===this.state?"Add":"Remove"," bookmark")}},{key:"render",value:function(){var e=this.side||"right";return(0,r.dy)(Fn||(Fn=Vn(["\n <button title="," @click="," class=",">\n <icon-bookmark state=","></icon-bookmark>\n </button>\n "])),this.title,this.handleClick,e,this.state)}}])&&Zn(t.prototype,n),o&&Zn(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function Qn(e){return(Qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Kn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function er(e,t){return(er=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tr(e,t){if(t&&("object"===Qn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function nr(e){return(nr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("bookmark-button",Jn),n(5666),n(8674),n(1058),n(6699),n(2023);var rr,or,ir,ar,sr,lr,cr,ur,dr,hr=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&er(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=nr(i);if(a){var n=nr(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return tr(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).url="https://archive.org/account/login",e}return t=l,o=[{key:"properties",get:function(){return{url:{type:String}}}},{key:"styles",get:function(){return We}}],(n=[{key:"render",value:function(){return(0,r.dy)(Xn||(Xn=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(['\n <p>A free account is required to save and access bookmarks.</p>\n <a class="ia-button link primary" href="','">Log in</a>\n '])),this.url)}}])&&Kn(t.prototype,n),o&&Kn(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function fr(e){return(fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pr(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function vr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mr(Object(n),!0).forEach((function(t){br(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function br(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yr(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function gr(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){yr(i,r,o,a,s,"next",e)}function s(e){yr(i,r,o,a,s,"throw",e)}a(void 0)}))}}function kr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function wr(e,t){return(wr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Cr(e,t){if(t&&("object"===fr(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Or(e){return(Or=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("bookmarks-login",hr);var Sr,xr={endpoint:"/services/bookmarks.php",headers:{"Content-Type":"application/json"},delete:function(e){return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier,"&page_num=").concat(e),{credentials:"same-origin",method:"DELETE",headers:this.headers})},get:function(e){return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier,"&page_num=").concat(e),{credentials:"same-origin",method:"GET",headers:this.headers})},getAll:function(){return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier),{credentials:"same-origin",method:"GET",headers:this.headers})},post:function(e){return this.sendBookmarkData(e,"POST")},put:function(e){return this.sendBookmarkData(e,"POST")},sendBookmarkData:function(e,t){var n={note:e.note,color:e.color};return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier,"&page_num=").concat(e.id),{credentials:"same-origin",method:t,headers:this.headers,body:JSON.stringify({notes:n})})}},Br=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&wr(e,t)}(u,e);var t,n,o,i,a,s,l,c=(s=u,l=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(e){return!1}}(),function(){var e,t=Or(s);if(l){var n=Or(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Cr(this,e)});function u(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(e=c.call(this)).bookmarks=[],e.bookreader={},e.editedBookmark={},e.modal=void 0,e.loginOptions={loginClicked:function(){},loginUrl:""},e.displayMode="bookmarks",e.bookmarkColors=[{id:0,className:"red"},{id:1,className:"blue"},{id:2,className:"green"}],e.defaultColor=e.bookmarkColors[0],e.api=xr,e.deleteModalConfig=new G({title:"Delete Bookmark",headline:"This bookmark contains a note. Deleting it will permanently delete the note. Are you sure?",headerColor:"#194880"}),e}return t=u,o=[{key:"properties",get:function(){return{activeBookmarkID:{type:String},bookmarks:{type:Array},bookreader:{type:Object},displayMode:{type:String},editedBookmark:{type:Object},deleteModalConfig:{type:Object},modal:{attribute:!1},loginOptions:{type:Object,attribute:!1}}}},{key:"styles",get:function(){var e=(0,r.iv)(dr||(dr=pr(["\n .bookmarks {\n height: 100%;\n overflow: hidden;\n padding-bottom: 20px;\n }\n\n .list ia-bookmark-edit {\n display: none;\n }\n\n .edit ia-bookmarks-list {\n display: none;\n }\n "])));return[We,e]}},{key:"formatPage",value:function(e){return isNaN(+e)?"(".concat(e.replace(/\D/g,""),")"):e}}],(n=[{key:"updated",value:function(e){e.has("displayMode")&&this.updateDisplay(),this.emitBookmarksChanged()}},{key:"setup",value:function(){this.api.identifier=this.bookreader.bookId,"login"!==this.displayMode&&(this.fetchUserBookmarks(),this.setBREventListeners())}},{key:"updateDisplay",value:function(){"bookmarks"===this.displayMode&&this.fetchUserBookmarks()}},{key:"fetchUserBookmarks",value:(a=gr(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.api.identifier){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.fetchBookmarks();case 4:this.initializeBookmarks();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setBREventListeners",value:function(){var e=this;["3PageViewSelected"].forEach((function(t){window.addEventListener("BookReader:".concat(t),(function(t){setTimeout((function(){e.renderBookmarkButtons()}),100)}))})),["pageChanged","1PageViewSelected","2PageViewSelected"].forEach((function(t){window.addEventListener("BookReader:".concat(t),(function(t){setTimeout((function(){e.renderBookmarkButtons(),e.markActiveBookmark()}),100)}))})),["zoomOut","zoomIn","resize"].forEach((function(t){window.addEventListener("BookReader:".concat(t),(function(){e.renderBookmarkButtons()}))}))}},{key:"initializeBookmarks",value:function(){this.renderBookmarkButtons(),this.markActiveBookmark(!0),this.emitBookmarksChanged()}},{key:"formatBookmark",value:function(e){var t=e.leafNum,n=void 0===t?"":t,r=e.notes,o=void 0===r?{}:r,i=o.note,a=void 0===i?"":i,s=o.color,l={note:a,color:this.getBookmarkColor(s)?s:this.defaultColor.id},c=u.formatPage(this.bookreader.getPageNum(n)),d=this.bookreader.getPageURI("".concat(n).replace(/\D/g,""),32);return vr(vr({},l),{},{id:n,leafNum:n,page:c,thumbnail:d})}},{key:"fetchBookmarks",value:(i=gr(regeneratorRuntime.mark((function e(){var t,n,r,o,i,a,s,l,c,u,d=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.api.getAll().then((function(e){return e.text()}));case 2:t=e.sent;try{n=JSON.parse(t)}catch(e){n={error:e.message}}return o=(r=n).success,i=r.error,a=void 0===i?"Something happened while fetching bookmarks.":i,s=r.value,l=void 0===s?[]:s,o||null===(c=console)||void 0===c||c.warn("Error fetching bookmarks",a),u={},Object.keys(l).forEach((function(e){var t=l[e],n=parseInt(e,10),r=d.formatBookmark(vr(vr({},t),{},{leafNum:n}));u[e]=r})),this.bookmarks=u,e.abrupt("return",u);case 10:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"emitBookmarksChanged",value:function(){this.dispatchEvent(new CustomEvent("bookmarksChanged",{bubbles:!0,composed:!0,detail:{bookmarks:this.bookmarks}}))}},{key:"emitBookmarkButtonClicked",value:function(){this.dispatchEvent(new CustomEvent("bookmarkButtonClicked",{bubbles:!0,composed:!0,detail:{editedBookmark:this.editedBookmark}}))}},{key:"bookmarkButtonClicked",value:function(e){this.getBookmark(e)?this.confirmDeletion(e):this.createBookmark(e)}},{key:"renderBookmarkButtons",value:function(){var e=this;this.bookreader.$(".BRpagecontainer").not(".BRemptypage").get().forEach((function(t){var n=t.querySelector(".bookmark-button");n&&n.remove();var o=+t.classList.value.match(/pagediv\d+/)[0].replace(/\D/g,""),i=e.getBookmark(o),a=i?"filled":"hollow";if(e.bookreader._models.book.getPage(o).isViewable){var s=document.createElement("div");["mousedown","mouseup"].forEach((function(e){s.addEventListener(e,(function(e){return e.stopPropagation()}))})),s.classList.add("bookmark-button",a),i&&s.classList.add(e.getBookmarkColor(i.color));var l="L"===t.getAttribute("data-side")&&e.bookreader.mode===e.bookreader.constMode2up?"left":"right";(0,r.sY)((0,r.dy)(rr||(rr=pr(["\n <bookmark-button\n @bookmarkButtonClicked=","\n state=","\n side=","\n ></bookmark-button>"])),(function(){return e.bookmarkButtonClicked(o)}),a,l),s),t.appendChild(s)}}))}},{key:"markActiveBookmark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.bookreader,n=t.mode,r=t.constMode2up,o=t.constModeThumb,i=this.bookreader.currentIndex();if(n!==o){if(n===r){var a=this.bookreader.displayedIndices,s=a.includes(+this.activeBookmarkID);if(s)return}this.bookmarks[i]?this.activeBookmarkID=i:this.activeBookmarkID=""}else{var l=this.bookmarks[i];e&&l&&(this.activeBookmarkID=i)}}},{key:"bookmarkEdited",value:function(e){var t=e.detail,n=t.bookmark.id===this.editedBookmark.id;this.editedBookmark=n?{}:t.bookmark}},{key:"getBookmark",value:function(e){return this.bookmarks[e]}},{key:"getBookmarkColor",value:function(e){var t;return null===(t=this.bookmarkColors.find((function(t){return t.id===e})))||void 0===t?void 0:t.className}},{key:"addBookmark",value:function(){var e=this.bookreader.currentIndex();if(this.bookreader.mode===this.bookreader.constMode2up){var t=this.bookreader.displayedIndices;e=t[t.length-1]}this.createBookmark(e)}},{key:"createBookmark",value:function(e){var t=this.getBookmark(e);if(t)return this.bookmarkEdited({detail:{bookmark:t}}),void this.emitBookmarkButtonClicked();this.editedBookmark=this.formatBookmark({leafNum:e}),this.api.post(this.editedBookmark),this.bookmarks[e]=this.editedBookmark,this.activeBookmarkID=e,this.disableAddBookmarkButton=!0,this.renderBookmarkButtons(),this.emitBookmarkButtonClicked()}},{key:"bookmarkSelected",value:function(e){var t=e.detail.bookmark.leafNum;this.bookreader.jumpToPage("".concat(this.bookreader.getPageNum("".concat(t).replace(/\D/g,"")))),this.activeBookmarkID=t}},{key:"saveBookmark",value:function(e){var t=e.detail,n=this.bookmarks[t.bookmark.id];Object.assign(n,t.bookmark),this.api.put(n),this.editedBookmark={},this.renderBookmarkButtons()}},{key:"confirmDeletion",value:function(e){this.getBookmark(e).note?this.displayDeletionModal(e):this.deleteBookmark({detail:{id:"".concat(e)}})}},{key:"displayDeletionModal",value:function(e){var t=this,n=(0,r.dy)(or||(or=pr(["\n <delete-modal-actions\n .deleteAction=","\n .cancelAction=","\n .pageID=","\n ></delete-modal-actions>\n "])),(function(){return t.deleteBookmark({detail:{id:"".concat(e)}})}),(function(){return t.modal.closeModal()}),e);this.modal.showModal({config:this.deleteModalConfig,customModalContent:n})}},{key:"deleteBookmark",value:function(e){var t=e.detail,n=t.id,r=this.bookmarks;delete r[n],this.bookmarks=vr({},r),this.api.delete(t.id),this.editedBookmark={},this.modal.closeModal(),this.renderBookmarkButtons()}},{key:"shouldEnableAddBookmarkButton",get:function(){var e=this.bookreader.mode===this.bookreader.constMode2up?this.bookreader.displayedIndices[this.bookreader.displayedIndices.length-1]:this.bookreader.currentIndex();return!!this.getBookmark(e)}},{key:"allowAddingBookmark",get:function(){return this.bookreader.mode!==this.bookreader.constModeThumb}},{key:"addBookmarkButton",get:function(){return(0,r.dy)(ir||(ir=pr(['\n <button\n class="ia-button primary"\n tabindex="-1"\n ?disabled=',"\n @click=",">\n Add bookmark\n </button>\n "])),this.shouldEnableAddBookmarkButton,this.addBookmark)}},{key:"bookmarksList",get:function(){return(0,r.dy)(ar||(ar=pr(["\n <ia-bookmarks-list\n @bookmarkEdited=","\n @bookmarkSelected=","\n @saveBookmark=","\n @deleteBookmark=","\n .editedBookmark=","\n .bookmarks=","\n .activeBookmarkID=","\n .bookmarkColors=","\n .defaultBookmarkColor=",">\n </ia-bookmarks-list>\n "])),this.bookmarkEdited,this.bookmarkSelected,this.saveBookmark,this.deleteBookmark,this.editedBookmark,vr({},this.bookmarks),this.activeBookmarkID,this.bookmarkColors,this.defaultColor)}},{key:"bookmarkHelperMessage",get:function(){return(0,r.dy)(sr||(sr=pr(["<p>Please use 1up or 2up view modes to add bookmark.</p>"])))}},{key:"render",value:function(){var e=this,t=(0,r.dy)(lr||(lr=pr(["\n ","\n ","\n "])),this.bookmarksList,this.allowAddingBookmark?this.addBookmarkButton:this.bookmarkHelperMessage);return(0,r.dy)(cr||(cr=pr(['\n <section class="bookmarks">\n ',"\n </section>\n "])),"login"===this.displayMode?(0,r.dy)(ur||(ur=pr(["<bookmarks-login\n @click=","\n .url=","></bookmarks-login>"])),(function(){return e.loginOptions.loginClicked()}),this.loginOptions.loginUrl):t)}}])&&kr(t.prototype,n),o&&kr(t,o),Object.defineProperty(t,"prototype",{writable:!1}),u}(r.oi);customElements.define("ia-bookmarks",Br);var jr,Pr,Er,Lr,Ir,Mr=(0,r.iv)(Sr||(Sr=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n .blue {\n --iconFillColor: var(--blueBookmarkColor, #0023f5);\n }\n\n .red {\n --iconFillColor: var(--redBookmarkColor, #eb3223);\n }\n\n .green {\n --iconFillColor: var(--greenBookmarkColor, #75ef4c);\n }\n"])));function zr(e){return(zr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Dr(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Ar(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Tr(e,t){return(Tr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _r(e,t){if(t&&("object"===zr(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Rr(e){return(Rr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var $r=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Tr(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=Rr(i);if(a){var n=Rr(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return _r(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).bookmark={},e.bookmarkColors=[],e.renderHeader=!1,e.showBookmark=!0,e}return t=l,o=[{key:"properties",get:function(){return{bookmark:{type:Object},bookmarkColors:{type:Array},renderHeader:{type:Boolean},showBookmark:{type:Boolean}}}},{key:"headerSection",get:function(){return(0,r.dy)(Lr||(Lr=Dr(["<header>\n <h3>Edit Bookmark</h3>\n </header>"])))}},{key:"styles",get:function(){var e=(0,r.iv)(Ir||(Ir=Dr(['\n :host {\n display: block;\n padding: 0 1rem 2rem 1rem;\n color: var(--primaryTextColor);\n }\n\n small {\n font-style: italic;\n }\n\n .bookmark {\n display: grid;\n grid-template-columns: 37px 1fr;\n grid-gap: 0 1rem;\n align-items: center;\n }\n\n h4 {\n margin: 0;\n font-size: 1.4rem;\n }\n\n fieldset {\n padding: 2rem 0 0 0;\n border: none;\n }\n\n label {\n display: block;\n font-weight: bold;\n }\n\n p {\n padding: 0;\n margin: .5rem 0;\n font-size: 1.2rem;\n line-height: 120%;\n }\n\n textarea {\n width: 100%;\n margin-bottom: 2rem;\n box-sizing: border-box;\n font: normal 1.4rem "Helvetica Neue", Helvetica, Arial, sans-serif;\n resize: vertical;\n }\n\n ul {\n display: grid;\n grid-template-columns: repeat(3, auto);\n grid-gap: 0 2rem;\n justify-content: start;\n padding: 1rem 0 0 0;\n margin: 0 0 2rem 0;\n list-style: none;\n }\n\n li input {\n display: none;\n }\n\n li label {\n display: block;\n min-width: 50px;\n padding-top: .4rem;\n text-align: center;\n border: 1px solid transparent;\n border-radius: 4px;\n cursor: pointer;\n }\n\n li input:checked + label {\n border-color: var(--primaryTextColor);\n }\n\n input[type="submit"] {\n background: var(--primaryCTAFill);\n border-color: var(--primaryCTABorder);\n }\n\n button {\n background: var(--primaryErrorCTAFill);\n border-color: var(--primaryErrorCTABorder);\n }\n\n .button {\n -webkit-appearance: none;\n appearance: none;\n padding: .5rem 1rem;\n box-sizing: border-box;\n color: var(--primaryTextColor);\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n\n .actions {\n display: grid;\n grid-template-columns: auto auto;\n grid-gap: 0 1rem;\n justify-items: stretch;\n }\n '])));return[We,Mr,e]}}],(n=[{key:"emitSaveEvent",value:function(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("saveBookmark",{detail:{bookmark:this.bookmark}}))}},{key:"emitDeleteEvent",value:function(){this.dispatchEvent(new CustomEvent("deleteBookmark",{detail:{id:this.bookmark.id}}))}},{key:"emitColorChangedEvent",value:function(e){this.dispatchEvent(new CustomEvent("bookmarkColorChanged",{detail:{bookmarkId:this.bookmark.id,colorId:e}}))}},{key:"changeColorTo",value:function(e){this.bookmark.color=e,this.emitColorChangedEvent(e)}},{key:"updateNote",value:function(e){this.bookmark.note=e.currentTarget.value}},{key:"bookmarkColor",value:function(e){var t=this;return(0,r.dy)(jr||(jr=Dr(['\n <li>\n <input type="radio" name="color" id="color_','" .value='," @change="," ?checked=",'>\n <label for="color_','">\n <icon-bookmark class=',"></icon-bookmark>\n </label>\n </li>\n "])),e.id,e.id,(function(){return t.changeColorTo(e.id)}),this.bookmark.color===e.id,e.id,e.className)}},{key:"bookmarkTemplate",get:function(){return(0,r.dy)(Pr||(Pr=Dr(['\n <div class="bookmark">\n <img src='," />\n <h4>Page ","</h4>\n </div>\n "])),this.bookmark.thumbnail,this.bookmark.page)}},{key:"render",value:function(){return(0,r.dy)(Er||(Er=Dr(["\n ","\n ",'\n <form action="" method="put" @submit=','>\n <fieldset>\n <label for="note">Note <small>(optional)</small></label>\n <textarea rows="4" cols="80" name="note" id="note" @change=',">",'</textarea>\n <label for="color">Bookmark color</label>\n <ul>\n ','\n </ul>\n <div class="actions">\n <button type="button" class="ia-button cancel" @click=','>Delete</button>\n <input class="ia-button" type="submit" value="Save">\n </div>\n </fieldset>\n </form>\n '])),this.renderHeader?l.headerSection:r.Ld,this.showBookmark?this.bookmarkTemplate:r.Ld,this.emitSaveEvent,this.updateNote,this.bookmark.note,tn(this.bookmarkColors,(function(e){return e.id}),this.bookmarkColor.bind(this)),this.emitDeleteEvent)}}])&&Ar(t.prototype,n),o&&Ar(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);customElements.define("ia-bookmark-edit",$r),n(2707);var Hr,Fr,Nr,Ur,qr,Vr,Zr,Wr,Gr=r.dy`
1145
+ `}render(){return hn}}function pn(e){return(pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function vn(e){return function(e){if(Array.isArray(e))return bn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return bn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bn(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function gn(e,t){return(gn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function kn(e,t){if(t&&("object"===pn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function wn(e){return(wn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("ia-icon-magnify-plus",fn);var Cn,On,Sn=function(e){return"visualAdjustment".concat(e)},xn={optionChange:Sn("OptionChanged"),zoomIn:Sn("ZoomIn"),zoomOut:Sn("ZoomOut")},Bn=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&gn(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=wn(i);if(a){var n=wn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return kn(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).activeCount=0,e.options=[],e.renderHeader=!1,e.showZoomControls=!0,e}return t=l,o=[{key:"properties",get:function(){return{activeCount:{type:Number},options:{type:Array},renderHeader:{type:Boolean},showZoomControls:{type:Boolean}}}},{key:"styles",get:function(){return(0,r.iv)(dn||(dn=mn(['\n :host {\n display: block;\n height: 100%;\n overflow-y: auto;\n font-size: 1.4rem;\n box-sizing: border-box;\n }\n\n header {\n display: flex;\n align-items: baseline;\n }\n\n h3 {\n padding: 0;\n margin: 0 1rem 0 0;\n font-size: 1.6rem;\n }\n\n header p {\n padding: 0;\n margin: 0;\n font-size: 1.2rem;\n font-weight: bold;\n font-style: italic;\n }\n\n ul {\n padding: 1rem 2rem 0 0;\n list-style: none;\n margin-top: 0;\n }\n\n [type="checkbox"] {\n display: none;\n }\n\n label {\n display: flex;\n justify-content: space-between;\n align-items: baseline;\n font-size: 1.4rem;\n font-weight: bold;\n line-height: 150%;\n vertical-align: middle;\n }\n\n .icon {\n display: inline-block;\n width: 14px;\n height: 14px;\n margin-left: .7rem;\n border: 1px solid var(--primaryTextColor);\n border-radius: 2px;\n background: var(--activeButtonBg) 50% 50% no-repeat;\n }\n :checked + .icon {\n background-image: url(\'',"');\n }\n\n .range {\n display: none;\n padding-top: .5rem;\n }\n .range.visible {\n display: flex;\n }\n\n .range p {\n margin-left: 1rem;\n }\n\n h4 {\n padding: 1rem 0;\n margin: 0;\n font-size: 1.4rem;\n }\n\n button {\n -webkit-appearance: none;\n appearance: none;\n border: none;\n border-radius: 0;\n background: transparent;\n outline: none;\n cursor: pointer;\n --iconFillColor: var(--primaryTextColor);\n --iconStrokeColor: var(--primaryTextColor);\n height: 4rem;\n width: 4rem;\n }\n\n button * {\n display: inline-block;\n }"])),Ve)}}],(n=[{key:"firstUpdated",value:function(){this.activeCount=this.activeOptions.length,this.emitOptionChangedEvent()}},{key:"activeOptions",get:function(){return this.options.reduce((function(e,t){return t.active?[].concat(vn(e),[t.id]):e}),[])}},{key:"prepareEventDetails",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return{options:this.options,activeCount:this.activeCount,changedOptionId:e}}},{key:"emitOptionChangedEvent",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=this.prepareEventDetails(e);this.dispatchEvent(new CustomEvent(xn.optionChange,{bubbles:!0,composed:!0,detail:t}))}},{key:"emitZoomIn",value:function(){this.dispatchEvent(new CustomEvent(xn.zoomIn))}},{key:"emitZoomOut",value:function(){this.dispatchEvent(new CustomEvent(xn.zoomOut))}},{key:"changeActiveStateFor",value:function(e){var t=vn(this.options),n=t.find((function(t){return t.id===e}));n.active=!n.active,this.options=t,this.activeCount=this.activeOptions.length,this.emitOptionChangedEvent(n.id)}},{key:"setRangeValue",value:function(e,t){var n=vn(this.options);n.find((function(t){return t.id===e})).value=t,this.options=vn(n)}},{key:"rangeSlider",value:function(e){var t=this;return(0,r.dy)(on||(on=mn(["\n <div class=",'>\n <input\n type="range"\n name="','_range"\n min=',"\n max=","\n step=","\n .value=","\n @input=","\n @change=","\n />\n <p>","%</p>\n </div>\n "])),"range".concat(e.active?" visible":""),e.id,e.min||0,e.max||100,e.step||1,e.value,(function(n){return t.setRangeValue(e.id,n.target.value)}),(function(){return t.emitOptionChangedEvent()}),e.value)}},{key:"adjustmentCheckbox",value:function(e){var t=this,n="adjustment_".concat(e.id);return(0,r.dy)(an||(an=mn(['<li>\n <label for="','">\n <span class="name">','</span>\n <input\n type="checkbox"\n name="','"\n id="','"\n @change=',"\n ?checked=",'\n />\n <span class="icon"></span>\n </label>\n ',"\n </li>"])),n,e.name,n,n,(function(){return t.changeActiveStateFor(e.id)}),e.active,void 0!==e.value?this.rangeSlider(e):r.Ld)}},{key:"headerSection",get:function(){var e=this.activeCount?(0,r.dy)(sn||(sn=mn(["<p>("," active)</p>"])),this.activeCount):r.Ld,t=(0,r.dy)(ln||(ln=mn(["<header>\n <h3>Visual adjustments</h3>\n ","\n </header>"])),e);return this.renderHeader?t:r.Ld}},{key:"zoomControls",get:function(){return(0,r.dy)(cn||(cn=mn(['\n <h4>Zoom</h4>\n <button class="zoom_out" @click=',' title="zoom out">\n <ia-icon-magnify-minus></ia-icon-magnify-minus>\n </button>\n <button class="zoom_in" @click=',' title="zoom in">\n <ia-icon-magnify-plus></ia-icon-magnify-plus>\n </button>\n '])),this.emitZoomOut,this.emitZoomIn)}},{key:"render",value:function(){return(0,r.dy)(un||(un=mn(["\n ","\n <ul>\n ","\n </ul>\n ","\n "])),this.headerSection,tn(this.options,(function(e){return e.id}),this.adjustmentCheckbox.bind(this)),this.showZoomControls?this.zoomControls:r.Ld)}}])&&yn(t.prototype,n),o&&yn(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Pn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function En(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}customElements.define("ia-book-visual-adjustments",Bn);var Ln,In,Mn=[{id:"brightness",name:"Adjust brightness",active:!1,min:0,max:150,step:1,value:100},{id:"contrast",name:"Adjust contrast",active:!1,min:0,max:150,step:1,value:100},{id:"invert",name:"Inverted colors (dark mode)",active:!1},{id:"grayscale",name:"Grayscale",active:!1}],zn=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=t.onProviderChange,o=t.bookreader;this.onProviderChange=n,this.bookContainer=o.refs.$brContainer,this.bookreader=o,this.onAdjustmentChange=this.onAdjustmentChange.bind(this),this.optionUpdateComplete=this.optionUpdateComplete.bind(this),this.updateOptionsCount=this.updateOptionsCount.bind(this),this.onZoomIn=this.onZoomIn.bind(this),this.onZoomOut=this.onZoomOut.bind(this),this.activeCount=0,this.icon=(0,r.dy)(Cn||(Cn=Pn(['<ia-icon-visual-adjustment style="width: var(--iconWidth); height: var(--iconHeight);"></ia-icon-visual-adjustment>']))),this.label="Visual Adjustments",this.menuDetails=this.updateOptionsCount(),this.id="adjustment",this.component=(0,r.dy)(On||(On=Pn(["\n <ia-book-visual-adjustments\n .options=","\n @visualAdjustmentOptionChanged=","\n @visualAdjustmentZoomIn=","\n @visualAdjustmentZoomOut=","\n ></ia-book-visual-adjustments>\n "])),Mn,this.onAdjustmentChange,this.onZoomIn,this.onZoomOut)}var t,n;return t=e,(n=[{key:"onZoomIn",value:function(){this.bookreader.zoom(1)}},{key:"onZoomOut",value:function(){this.bookreader.zoom(-1)}},{key:"onAdjustmentChange",value:function(e){var t=e.detail,n={brightness:function(e){return"brightness(".concat(e,"%)")},contrast:function(e){return"contrast(".concat(e,"%)")},grayscale:function(){return"grayscale(100%)"},invert:function(){return"invert(100%)"}},r=t.options.reduce((function(e,t){var r,o="".concat(t.active?n[t.id](t.value):"");return o?[].concat(function(e){if(Array.isArray(e))return jn(e)}(r=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jn(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),[o]):e}),[]).join(" ");this.bookContainer.css("filter",r),this.optionUpdateComplete(e)}},{key:"optionUpdateComplete",value:function(e){this.activeCount=e.detail.activeCount,this.updateOptionsCount(e),this.onProviderChange()}},{key:"updateOptionsCount",value:function(){this.menuDetails="(".concat(this.activeCount," active)")}}])&&En(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Dn(e){return(Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function An(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Tn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Rn(e,t){return(Rn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function $n(e,t){if(t&&("object"===Dn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Hn(e){return(Hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Fn,Nn,Un=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Rn(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=Hn(i);if(a){var n=Hn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return $n(this,e)});function l(){return Tn(this,l),s.apply(this,arguments)}return t=l,o=[{key:"styles",get:function(){return(0,r.iv)(In||(In=An(['\n div {\n display: flex;\n justify-content: center;\n padding-top: 2rem;\n }\n\n button {\n appearance: none;\n padding: 0.5rem 1rem;\n margin: 0 .5rem;\n box-sizing: border-box;\n font: 1.3rem "Helvetica Neue", Helvetica, Arial, sans-serif;\n color: var(--primaryTextColor);\n border: none;\n border-radius: 4px;\n cursor: pointer;\n background: var(--primaryCTAFill);\n }\n\n .delete {\n background: var(--primaryErrorCTAFill);\n }\n '])))}},{key:"properties",get:function(){return{cancelAction:{type:Function},deleteAction:{type:Function},pageID:{type:String}}}}],(n=[{key:"render",value:function(){var e=this;return(0,r.dy)(Ln||(Ln=An(['\n <div>\n <button class="delete" @click=',">Delete</button>\n <button @click=",">Cancel</button>\n </div>\n "])),(function(){return e.deleteAction({detail:{id:"".concat(e.pageID)}})}),(function(){return e.cancelAction()}))}}])&&_n(t.prototype,n),o&&_n(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function qn(e){return(qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Vn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Zn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Wn(e,t){return(Wn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Gn(e,t){if(t&&("object"===qn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Yn(e){return(Yn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("delete-modal-actions",Un);var Xn,Jn=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Wn(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=Yn(i);if(a){var n=Yn(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Gn(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).state="hollow",e.side=void 0,e}return t=l,o=[{key:"styles",get:function(){return(0,r.iv)(Nn||(Nn=Vn(["\n button {\n -webkit-appearance: none;\n appearance: none;\n outline: 0;\n border: none;\n padding: 0;\n height: 4rem;\n width: 4rem;\n background: transparent;\n cursor: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 24' width='16'%3E%3Cg fill='%23333' fill-rule='evenodd'%3E%3Cpath d='m15 0c.5522847 0 1 .44771525 1 1v23l-8-5.4545455-8 5.4545455v-23c0-.55228475.44771525-1 1-1zm-2 2h-10c-.51283584 0-.93550716.38604019-.99327227.88337887l-.00672773.11662113v18l6-4.3181818 6 4.3181818v-18c0-.51283584-.3860402-.93550716-.8833789-.99327227z'/%3E%3Cpath d='m8.75 6v2.25h2.25v1.5h-2.25v2.25h-1.5v-2.25h-2.25v-1.5h2.25v-2.25z' fill-rule='nonzero'/%3E%3C/g%3E%3C/svg%3E\"), pointer;\n position: relative;\n }\n button > * {\n display: block;\n position: absolute;\n top: 0.2rem;\n }\n button.left > * {\n left: 0.2rem;\n }\n\n button.right > * {\n right: 0.2rem;\n }\n "])))}},{key:"properties",get:function(){return{side:{type:String},state:{type:String}}}}],(n=[{key:"handleClick",value:function(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("bookmarkButtonClicked"))}},{key:"title",get:function(){return"".concat("hollow"===this.state?"Add":"Remove"," bookmark")}},{key:"render",value:function(){var e=this.side||"right";return(0,r.dy)(Fn||(Fn=Vn(["\n <button title="," @click="," class=",">\n <icon-bookmark state=","></icon-bookmark>\n </button>\n "])),this.title,this.handleClick,e,this.state)}}])&&Zn(t.prototype,n),o&&Zn(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function Qn(e){return(Qn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Kn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function er(e,t){return(er=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tr(e,t){if(t&&("object"===Qn(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function nr(e){return(nr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("bookmark-button",Jn),n(5666),n(8674),n(1058),n(6699),n(2023);var rr,or,ir,ar,sr,lr,cr,ur,dr,hr=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&er(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=nr(i);if(a){var n=nr(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return tr(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).url="https://archive.org/account/login",e}return t=l,o=[{key:"properties",get:function(){return{url:{type:String}}}},{key:"styles",get:function(){return We}}],(n=[{key:"render",value:function(){return(0,r.dy)(Xn||(Xn=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(['\n <p>A free account is required to save and access bookmarks.</p>\n <a class="ia-button link primary" href="','">Log in</a>\n '])),this.url)}}])&&Kn(t.prototype,n),o&&Kn(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);function fr(e){return(fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pr(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function vr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mr(Object(n),!0).forEach((function(t){br(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function br(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yr(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function gr(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){yr(i,r,o,a,s,"next",e)}function s(e){yr(i,r,o,a,s,"throw",e)}a(void 0)}))}}function kr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function wr(e,t){return(wr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Cr(e,t){if(t&&("object"===fr(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Or(e){return(Or=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}customElements.define("bookmarks-login",hr);var Sr,xr={endpoint:"/services/bookmarks.php",headers:{"Content-Type":"application/json"},delete:function(e){return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier,"&page_num=").concat(e),{credentials:"same-origin",method:"DELETE",headers:this.headers})},get:function(e){return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier,"&page_num=").concat(e),{credentials:"same-origin",method:"GET",headers:this.headers})},getAll:function(){return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier),{credentials:"same-origin",method:"GET",headers:this.headers})},post:function(e){return this.sendBookmarkData(e,"POST")},put:function(e){return this.sendBookmarkData(e,"POST")},sendBookmarkData:function(e,t){var n={note:e.note,color:e.color};return fetch("".concat(this.endpoint,"?identifier=").concat(this.identifier,"&page_num=").concat(e.id),{credentials:"same-origin",method:t,headers:this.headers,body:JSON.stringify({notes:n})})}},Br=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&wr(e,t)}(u,e);var t,n,o,i,a,s,l,c=(s=u,l=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(e){return!1}}(),function(){var e,t=Or(s);if(l){var n=Or(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return Cr(this,e)});function u(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),(e=c.call(this)).bookmarks=[],e.bookreader={},e.editedBookmark={},e.modal=void 0,e.loginOptions={loginClicked:function(){},loginUrl:""},e.displayMode="bookmarks",e.bookmarkColors=[{id:0,className:"red"},{id:1,className:"blue"},{id:2,className:"green"}],e.defaultColor=e.bookmarkColors[0],e.api=xr,e.deleteModalConfig=new G({title:"Delete Bookmark",headline:"This bookmark contains a note. Deleting it will permanently delete the note. Are you sure?",headerColor:"#194880"}),e}return t=u,o=[{key:"properties",get:function(){return{activeBookmarkID:{type:String},bookmarks:{type:Array},bookreader:{type:Object},displayMode:{type:String},editedBookmark:{type:Object},deleteModalConfig:{type:Object},modal:{attribute:!1},loginOptions:{type:Object,attribute:!1}}}},{key:"styles",get:function(){var e=(0,r.iv)(dr||(dr=pr(["\n .bookmarks {\n height: 100%;\n overflow: hidden;\n padding-bottom: 20px;\n }\n\n .list ia-bookmark-edit {\n display: none;\n }\n\n .edit ia-bookmarks-list {\n display: none;\n }\n "])));return[We,e]}},{key:"formatPage",value:function(e){return isNaN(+e)?"(".concat(e.replace(/\D/g,""),")"):e}}],(n=[{key:"updated",value:function(e){e.has("displayMode")&&this.updateDisplay(),this.emitBookmarksChanged()}},{key:"setup",value:function(){this.api.identifier=this.bookreader.bookId,"login"!==this.displayMode&&(this.fetchUserBookmarks(),this.setBREventListeners())}},{key:"updateDisplay",value:function(){"bookmarks"===this.displayMode&&this.fetchUserBookmarks()}},{key:"fetchUserBookmarks",value:(a=gr(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.api.identifier){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.fetchBookmarks();case 4:this.initializeBookmarks();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"setBREventListeners",value:function(){var e=this;["3PageViewSelected"].forEach((function(t){window.addEventListener("BookReader:".concat(t),(function(t){setTimeout((function(){e.renderBookmarkButtons()}),100)}))})),["pageChanged","1PageViewSelected","2PageViewSelected"].forEach((function(t){window.addEventListener("BookReader:".concat(t),(function(t){setTimeout((function(){e.renderBookmarkButtons(),e.markActiveBookmark()}),100)}))})),["zoomOut","zoomIn","resize"].forEach((function(t){window.addEventListener("BookReader:".concat(t),(function(){e.renderBookmarkButtons()}))}))}},{key:"initializeBookmarks",value:function(){this.renderBookmarkButtons(),this.markActiveBookmark(!0),this.emitBookmarksChanged()}},{key:"formatBookmark",value:function(e){var t=e.leafNum,n=void 0===t?"":t,r=e.notes,o=void 0===r?{}:r,i=o.note,a=void 0===i?"":i,s=o.color,l={note:a,color:this.getBookmarkColor(s)?s:this.defaultColor.id},c=u.formatPage(this.bookreader.book.getPageNum(n)),d=this.bookreader.book.getPageURI("".concat(n).replace(/\D/g,""),32);return vr(vr({},l),{},{id:n,leafNum:n,page:c,thumbnail:d})}},{key:"fetchBookmarks",value:(i=gr(regeneratorRuntime.mark((function e(){var t,n,r,o,i,a,s,l,c,u,d=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.api.getAll().then((function(e){return e.text()}));case 2:t=e.sent;try{n=JSON.parse(t)}catch(e){n={error:e.message}}return o=(r=n).success,i=r.error,a=void 0===i?"Something happened while fetching bookmarks.":i,s=r.value,l=void 0===s?[]:s,o||null===(c=console)||void 0===c||c.warn("Error fetching bookmarks",a),u={},Object.keys(l).forEach((function(e){var t=l[e],n=parseInt(e,10),r=d.formatBookmark(vr(vr({},t),{},{leafNum:n}));u[e]=r})),this.bookmarks=u,e.abrupt("return",u);case 10:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"emitBookmarksChanged",value:function(){this.dispatchEvent(new CustomEvent("bookmarksChanged",{bubbles:!0,composed:!0,detail:{bookmarks:this.bookmarks}}))}},{key:"emitBookmarkButtonClicked",value:function(){this.dispatchEvent(new CustomEvent("bookmarkButtonClicked",{bubbles:!0,composed:!0,detail:{editedBookmark:this.editedBookmark}}))}},{key:"bookmarkButtonClicked",value:function(e){this.getBookmark(e)?this.confirmDeletion(e):this.createBookmark(e)}},{key:"renderBookmarkButtons",value:function(){var e=this;this.bookreader.$(".BRpagecontainer").not(".BRemptypage").get().forEach((function(t){var n=t.querySelector(".bookmark-button");n&&n.remove();var o=+t.classList.value.match(/pagediv\d+/)[0].replace(/\D/g,""),i=e.getBookmark(o),a=i?"filled":"hollow";if(e.bookreader.book.getPage(o).isViewable){var s=document.createElement("div");["mousedown","mouseup"].forEach((function(e){s.addEventListener(e,(function(e){return e.stopPropagation()}))})),s.classList.add("bookmark-button",a),i&&s.classList.add(e.getBookmarkColor(i.color));var l="L"===t.getAttribute("data-side")&&e.bookreader.mode===e.bookreader.constMode2up?"left":"right";(0,r.sY)((0,r.dy)(rr||(rr=pr(["\n <bookmark-button\n @bookmarkButtonClicked=","\n state=","\n side=","\n ></bookmark-button>"])),(function(){return e.bookmarkButtonClicked(o)}),a,l),s),t.appendChild(s)}}))}},{key:"markActiveBookmark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.bookreader,n=t.mode,r=t.constMode2up,o=t.constModeThumb,i=this.bookreader.currentIndex();if(n!==o){if(n===r){var a=this.bookreader.displayedIndices,s=a.includes(+this.activeBookmarkID);if(s)return}this.bookmarks[i]?this.activeBookmarkID=i:this.activeBookmarkID=""}else{var l=this.bookmarks[i];e&&l&&(this.activeBookmarkID=i)}}},{key:"bookmarkEdited",value:function(e){var t=e.detail,n=t.bookmark.id===this.editedBookmark.id;this.editedBookmark=n?{}:t.bookmark}},{key:"getBookmark",value:function(e){return this.bookmarks[e]}},{key:"getBookmarkColor",value:function(e){var t;return null===(t=this.bookmarkColors.find((function(t){return t.id===e})))||void 0===t?void 0:t.className}},{key:"addBookmark",value:function(){var e=this.bookreader.currentIndex();if(this.bookreader.mode===this.bookreader.constMode2up){var t=this.bookreader.displayedIndices;e=t[t.length-1]}this.createBookmark(e)}},{key:"createBookmark",value:function(e){var t=this.getBookmark(e);if(t)return this.bookmarkEdited({detail:{bookmark:t}}),void this.emitBookmarkButtonClicked();this.editedBookmark=this.formatBookmark({leafNum:e}),this.api.post(this.editedBookmark),this.bookmarks[e]=this.editedBookmark,this.activeBookmarkID=e,this.disableAddBookmarkButton=!0,this.renderBookmarkButtons(),this.emitBookmarkButtonClicked()}},{key:"bookmarkSelected",value:function(e){var t=e.detail.bookmark.leafNum;this.bookreader.jumpToPage("".concat(this.bookreader.book.getPageNum("".concat(t).replace(/\D/g,"")))),this.activeBookmarkID=t}},{key:"saveBookmark",value:function(e){var t=e.detail,n=this.bookmarks[t.bookmark.id];Object.assign(n,t.bookmark),this.api.put(n),this.editedBookmark={},this.renderBookmarkButtons()}},{key:"confirmDeletion",value:function(e){this.getBookmark(e).note?this.displayDeletionModal(e):this.deleteBookmark({detail:{id:"".concat(e)}})}},{key:"displayDeletionModal",value:function(e){var t=this,n=(0,r.dy)(or||(or=pr(["\n <delete-modal-actions\n .deleteAction=","\n .cancelAction=","\n .pageID=","\n ></delete-modal-actions>\n "])),(function(){return t.deleteBookmark({detail:{id:"".concat(e)}})}),(function(){return t.modal.closeModal()}),e);this.modal.showModal({config:this.deleteModalConfig,customModalContent:n})}},{key:"deleteBookmark",value:function(e){var t=e.detail,n=t.id,r=this.bookmarks;delete r[n],this.bookmarks=vr({},r),this.api.delete(t.id),this.editedBookmark={},this.modal.closeModal(),this.renderBookmarkButtons()}},{key:"shouldEnableAddBookmarkButton",get:function(){var e=this.bookreader.mode===this.bookreader.constMode2up?this.bookreader.displayedIndices[this.bookreader.displayedIndices.length-1]:this.bookreader.currentIndex();return!!this.getBookmark(e)}},{key:"allowAddingBookmark",get:function(){return this.bookreader.mode!==this.bookreader.constModeThumb}},{key:"addBookmarkButton",get:function(){return(0,r.dy)(ir||(ir=pr(['\n <button\n class="ia-button primary"\n tabindex="-1"\n ?disabled=',"\n @click=",">\n Add bookmark\n </button>\n "])),this.shouldEnableAddBookmarkButton,this.addBookmark)}},{key:"bookmarksList",get:function(){return(0,r.dy)(ar||(ar=pr(["\n <ia-bookmarks-list\n @bookmarkEdited=","\n @bookmarkSelected=","\n @saveBookmark=","\n @deleteBookmark=","\n .editedBookmark=","\n .bookmarks=","\n .activeBookmarkID=","\n .bookmarkColors=","\n .defaultBookmarkColor=",">\n </ia-bookmarks-list>\n "])),this.bookmarkEdited,this.bookmarkSelected,this.saveBookmark,this.deleteBookmark,this.editedBookmark,vr({},this.bookmarks),this.activeBookmarkID,this.bookmarkColors,this.defaultColor)}},{key:"bookmarkHelperMessage",get:function(){return(0,r.dy)(sr||(sr=pr(["<p>Please use 1up or 2up view modes to add bookmark.</p>"])))}},{key:"render",value:function(){var e=this,t=(0,r.dy)(lr||(lr=pr(["\n ","\n ","\n "])),this.bookmarksList,this.allowAddingBookmark?this.addBookmarkButton:this.bookmarkHelperMessage);return(0,r.dy)(cr||(cr=pr(['\n <section class="bookmarks">\n ',"\n </section>\n "])),"login"===this.displayMode?(0,r.dy)(ur||(ur=pr(["<bookmarks-login\n @click=","\n .url=","></bookmarks-login>"])),(function(){return e.loginOptions.loginClicked()}),this.loginOptions.loginUrl):t)}}])&&kr(t.prototype,n),o&&kr(t,o),Object.defineProperty(t,"prototype",{writable:!1}),u}(r.oi);customElements.define("ia-bookmarks",Br);var jr,Pr,Er,Lr,Ir,Mr=(0,r.iv)(Sr||(Sr=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n .blue {\n --iconFillColor: var(--blueBookmarkColor, #0023f5);\n }\n\n .red {\n --iconFillColor: var(--redBookmarkColor, #eb3223);\n }\n\n .green {\n --iconFillColor: var(--greenBookmarkColor, #75ef4c);\n }\n"])));function zr(e){return(zr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Dr(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Ar(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Tr(e,t){return(Tr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _r(e,t){if(t&&("object"===zr(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function Rr(e){return(Rr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var $r=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Tr(e,t)}(l,e);var t,n,o,i,a,s=(i=l,a=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(e){return!1}}(),function(){var e,t=Rr(i);if(a){var n=Rr(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return _r(this,e)});function l(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),(e=s.call(this)).bookmark={},e.bookmarkColors=[],e.renderHeader=!1,e.showBookmark=!0,e}return t=l,o=[{key:"properties",get:function(){return{bookmark:{type:Object},bookmarkColors:{type:Array},renderHeader:{type:Boolean},showBookmark:{type:Boolean}}}},{key:"headerSection",get:function(){return(0,r.dy)(Lr||(Lr=Dr(["<header>\n <h3>Edit Bookmark</h3>\n </header>"])))}},{key:"styles",get:function(){var e=(0,r.iv)(Ir||(Ir=Dr(['\n :host {\n display: block;\n padding: 0 1rem 2rem 1rem;\n color: var(--primaryTextColor);\n }\n\n small {\n font-style: italic;\n }\n\n .bookmark {\n display: grid;\n grid-template-columns: 37px 1fr;\n grid-gap: 0 1rem;\n align-items: center;\n }\n\n h4 {\n margin: 0;\n font-size: 1.4rem;\n }\n\n fieldset {\n padding: 2rem 0 0 0;\n border: none;\n }\n\n label {\n display: block;\n font-weight: bold;\n }\n\n p {\n padding: 0;\n margin: .5rem 0;\n font-size: 1.2rem;\n line-height: 120%;\n }\n\n textarea {\n width: 100%;\n margin-bottom: 2rem;\n box-sizing: border-box;\n font: normal 1.4rem "Helvetica Neue", Helvetica, Arial, sans-serif;\n resize: vertical;\n }\n\n ul {\n display: grid;\n grid-template-columns: repeat(3, auto);\n grid-gap: 0 2rem;\n justify-content: start;\n padding: 1rem 0 0 0;\n margin: 0 0 2rem 0;\n list-style: none;\n }\n\n li input {\n display: none;\n }\n\n li label {\n display: block;\n min-width: 50px;\n padding-top: .4rem;\n text-align: center;\n border: 1px solid transparent;\n border-radius: 4px;\n cursor: pointer;\n }\n\n li input:checked + label {\n border-color: var(--primaryTextColor);\n }\n\n input[type="submit"] {\n background: var(--primaryCTAFill);\n border-color: var(--primaryCTABorder);\n }\n\n button {\n background: var(--primaryErrorCTAFill);\n border-color: var(--primaryErrorCTABorder);\n }\n\n .button {\n -webkit-appearance: none;\n appearance: none;\n padding: .5rem 1rem;\n box-sizing: border-box;\n color: var(--primaryTextColor);\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n\n .actions {\n display: grid;\n grid-template-columns: auto auto;\n grid-gap: 0 1rem;\n justify-items: stretch;\n }\n '])));return[We,Mr,e]}}],(n=[{key:"emitSaveEvent",value:function(e){e.preventDefault(),this.dispatchEvent(new CustomEvent("saveBookmark",{detail:{bookmark:this.bookmark}}))}},{key:"emitDeleteEvent",value:function(){this.dispatchEvent(new CustomEvent("deleteBookmark",{detail:{id:this.bookmark.id}}))}},{key:"emitColorChangedEvent",value:function(e){this.dispatchEvent(new CustomEvent("bookmarkColorChanged",{detail:{bookmarkId:this.bookmark.id,colorId:e}}))}},{key:"changeColorTo",value:function(e){this.bookmark.color=e,this.emitColorChangedEvent(e)}},{key:"updateNote",value:function(e){this.bookmark.note=e.currentTarget.value}},{key:"bookmarkColor",value:function(e){var t=this;return(0,r.dy)(jr||(jr=Dr(['\n <li>\n <input type="radio" name="color" id="color_','" .value='," @change="," ?checked=",'>\n <label for="color_','">\n <icon-bookmark class=',"></icon-bookmark>\n </label>\n </li>\n "])),e.id,e.id,(function(){return t.changeColorTo(e.id)}),this.bookmark.color===e.id,e.id,e.className)}},{key:"bookmarkTemplate",get:function(){return(0,r.dy)(Pr||(Pr=Dr(['\n <div class="bookmark">\n <img src='," />\n <h4>Page ","</h4>\n </div>\n "])),this.bookmark.thumbnail,this.bookmark.page)}},{key:"render",value:function(){return(0,r.dy)(Er||(Er=Dr(["\n ","\n ",'\n <form action="" method="put" @submit=','>\n <fieldset>\n <label for="note">Note <small>(optional)</small></label>\n <textarea rows="4" cols="80" name="note" id="note" @change=',">",'</textarea>\n <label for="color">Bookmark color</label>\n <ul>\n ','\n </ul>\n <div class="actions">\n <button type="button" class="ia-button cancel" @click=','>Delete</button>\n <input class="ia-button" type="submit" value="Save">\n </div>\n </fieldset>\n </form>\n '])),this.renderHeader?l.headerSection:r.Ld,this.showBookmark?this.bookmarkTemplate:r.Ld,this.emitSaveEvent,this.updateNote,this.bookmark.note,tn(this.bookmarkColors,(function(e){return e.id}),this.bookmarkColor.bind(this)),this.emitDeleteEvent)}}])&&Ar(t.prototype,n),o&&Ar(t,o),Object.defineProperty(t,"prototype",{writable:!1}),l}(r.oi);customElements.define("ia-bookmark-edit",$r),n(2707);var Hr,Fr,Nr,Ur,qr,Vr,Zr,Wr,Gr=r.dy`
1146
1146
  <svg height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg" aria-labelledby="editPencilTitleID editPencilDescID"><title id="editPencilTitleID">Pencil icon</title><desc id="editPencilDescID">An illustration of a pencil, used to represent an edit action</desc><path class="fill-color" d="m15.6111048 9.3708338-9.52237183 9.5222966-5.14363353 1.0897111c-.42296707.0896082-.83849202-.1806298-.92810097-.6035935-.02266463-.1069795-.02266463-.2175207 0-.3245001l1.08971974-5.1435929 9.52237189-9.52229656zm-10.89310224 5.9110366-2.78094924-.5403869-.67567462 3.166657.83033407.8303275 3.16668096-.6756703zm14.82724244-12.05935921c.6114418.61143705.6055516 1.6086709-.0131615 2.22737904l-2.2405581 2.24054036-4.9820147-4.98197536 2.2405581-2.24054036c.618713-.61870814 1.6159506-.62460252 2.2273925-.01316547z" fill-rule="evenodd"/></svg>
1147
1147
  `;class Yr extends r.oi{static get styles(){return r.iv`
1148
1148
  :host {