@thms-rmb/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
2 lines (1 loc) • 28.3 kB
JavaScript
import{a as fe}from"./chunk-RZF4ZNAC.js";import{a as se}from"./chunk-VSOYKBBB.js";import"./chunk-2SUYJOML.js";import{b as oe,c as re,f as ie,g as ae,h as A,i as le,k as ue,l as ce,m as de}from"./chunk-KSHTREFB.js";import"./chunk-UYLDA6E6.js";import{a as k,n as ne,p as g}from"./chunk-2YE6NNA6.js";import{g as U}from"./chunk-MP7EINQY.js";import"./chunk-YAXTLTJC.js";var y=class{},p=y;p.namespace="ebookExtension.",p.CFI_FRAGMENT_CHANGE=y.namespace+"cfiFragmentChange",p.ITEM_CLICKED=y.namespace+"itemClicked",p.LOADED_NAVIGATION=y.namespace+"loadedNavigation",p.RELOCATED=y.namespace+"relocated",p.RENDITION_ATTACHED=y.namespace+"renditionAttached",p.TOC_READY=y.namespace+"tocReady";function T(){var t=window,e=[];(!t.customElements||t.Element&&(!t.Element.prototype.closest||!t.Element.prototype.matches||!t.Element.prototype.remove))&&e.push(import("./dom-ITI5BMGR.js"));function n(){try{var o=new URL("b","http://a");return o.pathname="c%20d",o.href==="http://a/c%20d"&&o.searchParams}catch{return!1}}return(typeof Object.assign!="function"||!Object.entries||!Array.prototype.find||!Array.prototype.includes||!String.prototype.startsWith||!String.prototype.endsWith||t.NodeList&&!t.NodeList.prototype.forEach||!t.fetch||!n()||typeof WeakMap=="undefined")&&e.push(import("./core-js-66EU3Z5G.js")),Promise.all(e)}var Be=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,r){o.__proto__=r}||function(o,r){for(var i in r)r.hasOwnProperty(i)&&(o[i]=r[i])},t(e,n)};return function(e,n){t(e,n);function o(){this.constructor=e}e.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)}}(),Ue=function(t,e,n,o){function r(i){return i instanceof n?i:new n(function(a){a(i)})}return new(n||(n=Promise))(function(i,a){function l(c){try{s(o.next(c))}catch(d){a(d)}}function u(c){try{s(o.throw(c))}catch(d){a(d)}}function s(c){c.done?i(c.value):r(c.value).then(l,u)}s((o=o.apply(t,e||[])).next())})},je=function(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,r,i,a;return a={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(s){return function(c){return u([s,c])}}function u(s){if(o)throw new TypeError("Generator is already executing.");for(;n;)try{if(o=1,r&&(i=s[0]&2?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[s[0]&2,i.value]),s[0]){case 0:case 1:i=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,r=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1],i=s;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(s);break}i[2]&&n.ops.pop(),n.trys.pop();continue}s=e.call(t,n)}catch(c){s=[6,c],r=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},Me=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var o=Array(t),r=0,e=0;e<n;e++)for(var i=arguments[e],a=0,l=i.length;a<l;a++,r++)o[r]=i[a];return o};var j=0,M=!1,he=!1,P=window,v=document,f={$flags$:0,$resourcesUrl$:"",jmp:function(t){return t()},raf:function(t){return requestAnimationFrame(t)},ael:function(t,e,n,o){return t.addEventListener(e,n,o)},rel:function(t,e,n,o){return t.removeEventListener(e,n,o)}},ze=function(){var t=!1;try{v.addEventListener("e",null,Object.defineProperty({},"passive",{get:function(){t=!0}}))}catch{}return t}(),Ge=function(){try{return new CSSStyleSheet,!0}catch{}return!1}(),$e=new WeakMap,S=function(t){return $e.get(t)};var Ne=function(t){var e={$flags$:0,$hostElement$:t,$instanceValues$:new Map};return e.$onInstancePromise$=new Promise(function(n){return e.$onInstanceResolve$=n}),e.$onReadyPromise$=new Promise(function(n){return e.$onReadyResolve$=n}),t["s-p"]=[],t["s-rc"]=[],$e.set(t,e)},pe=function(t,e){return e in t},I=function(t){return console.error(t)},me=new Map,We=function(t,e,n){var o=t.$tagName$.replace(/-/g,"_"),r=t.$lazyBundleIds$,i=me.get(r);return i?i[o]:import("./"+r+".entry.js").then(function(a){return me.set(r,a),a[o]},I)},C=new Map,ge=[],D=[],O=[],Je=function(t,e){return function(n){t.push(n),M||(M=!0,e&&f.$flags$&4?G(z):f.raf(z))}},Qe=function(t){for(var e=0;e<t.length;e++)try{t[e](performance.now())}catch(n){I(n)}t.length=0},ve=function(t,e){for(var n=0,o=0;n<t.length&&(o=performance.now())<e;)try{t[n++](o)}catch(r){I(r)}n===t.length?t.length=0:n!==0&&t.splice(0,n)},z=function(){j++,Qe(ge);var t=(f.$flags$&6)==2?performance.now()+10*Math.ceil(j*(1/22)):1/0;ve(D,t),ve(O,t),D.length>0&&(O.push.apply(O,D),D.length=0),(M=ge.length+D.length+O.length>0)?f.raf(z):j=0},G=function(t){return Promise.resolve().then(t)},qe=Je(D,!0),be={},N=function(t){return t=typeof t,t==="object"||t==="function"};var Ee=function(){return P.CSS&&P.CSS.supports&&P.CSS.supports("color","var(--c)")?Promise.resolve():import("./css-shim-978387b1-1e75855f-O4PYI7RC.js").then(function(){if(f.$cssShim$=P.__stencil_cssshim,f.$cssShim$)return f.$cssShim$.initShim()})};var Ke=function(t,e){return t!=null&&!N(t)?e&4?t==="false"?!1:t===""||!!t:e&2?parseFloat(t):e&1?String(t):t:t},ye="hydrated",b=function(t,e){return e===void 0&&(e=""),function(){}},Xe=function(t,e){return function(){}},we=new WeakMap,Ye=function(t,e,n){var o=C.get(t);Ge&&n?(o=o||new CSSStyleSheet,o.replace(e)):o=e,C.set(t,o)},Ze=function(t,e,n,o){var r=xe(e.$tagName$),i=C.get(r);if(t=t.nodeType===11?t:v,i)if(typeof i=="string"){t=t.head||t;var a=we.get(t),l=void 0;if(a||we.set(t,a=new Set),!a.has(r)){{if(f.$cssShim$){l=f.$cssShim$.createHostStyle(o,r,i,!!(e.$flags$&10));var u=l["s-sc"];u&&(r=u,a=null)}else l=v.createElement("style"),l.innerHTML=i;t.insertBefore(l,t.querySelector("link"))}a&&a.add(r)}}else t.adoptedStyleSheets.includes(i)||(t.adoptedStyleSheets=Me(t.adoptedStyleSheets,[i]));return r},Ve=function(t,e,n){var o=b("attachStyles",e.$tagName$),r=Ze(t.getRootNode(),e,n,t);o()},xe=function(t,e){return"sc-"+t},et=function(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var r=null,i=!1,a=!1,l=[],u=function(d){for(var h=0;h<d.length;h++)r=d[h],Array.isArray(r)?u(r):r!=null&&typeof r!="boolean"&&((i=typeof t!="function"&&!N(r))&&(r=String(r)),i&&a?l[l.length-1].$text$+=r:l.push(i?W(null,r):r),a=i)};if(u(n),e){var s=e.className||e.class;s&&(e.class=typeof s!="object"?s:Object.keys(s).filter(function(d){return s[d]}).join(" "))}var c=W(t,null);return c.$attrs$=e,l.length>0&&(c.$children$=l),c},W=function(t,e){var n={$flags$:0,$tag$:t,$text$:e,$elm$:null,$children$:null};return n.$attrs$=null,n},tt={},nt=function(t){return t&&t.$tag$===tt},Pe=function(t,e,n,o,r,i){if(n!==o){var a=pe(t,e),l=e.toLowerCase();if(e==="class"){var u=t.classList,s=Se(n),c=Se(o);u.remove.apply(u,s.filter(function(m){return m&&!c.includes(m)})),u.add.apply(u,c.filter(function(m){return m&&!s.includes(m)}))}else if(e==="ref")o&&o(t);else if(!a&&e[0]==="o"&&e[1]==="n")e[2]==="-"?e=e.slice(3):pe(P,l)?e=l.slice(2):e=l[2]+e.slice(3),n&&f.rel(t,e,n,!1),o&&f.ael(t,e,o,!1);else{var d=N(o);if((a||d&&o!==null)&&!r)try{if(t.tagName.includes("-"))t[e]=o;else{var h=o??"";e==="list"?a=!1:(n==null||t[e]!=h)&&(t[e]=h)}}catch{}o==null||o===!1?t.removeAttribute(e):(!a||i&4||r)&&!d&&(o=o===!0?"":o,t.setAttribute(e,o))}}},ot=/\s/,Se=function(t){return t?t.split(ot):[]},ke=function(t,e,n,o){var r=e.$elm$.nodeType===11&&e.$elm$.host?e.$elm$.host:e.$elm$,i=t&&t.$attrs$||be,a=e.$attrs$||be;for(o in i)o in a||Pe(r,o,i[o],void 0,n,e.$flags$);for(o in a)Pe(r,o,i[o],a[o],n,e.$flags$)},J=function(t,e,n,o){var r=e.$children$[n],i=0,a,l;if(r.$text$!==null)a=r.$elm$=v.createTextNode(r.$text$);else if(a=r.$elm$=v.createElement(r.$tag$),ke(null,r,he),r.$children$)for(i=0;i<r.$children$.length;++i)l=J(t,r,i),l&&a.appendChild(l);return a},Ie=function(t,e,n,o,r,i){for(var a=t,l;r<=i;++r)o[r]&&(l=J(null,n,r),l&&(o[r].$elm$=l,a.insertBefore(l,e)))},De=function(t,e,n,o,r){for(;e<=n;++e)(o=t[e])&&(r=o.$elm$,_e(o),r.remove())},rt=function(t,e,n,o){for(var r=0,i=0,a=e.length-1,l=e[0],u=e[a],s=o.length-1,c=o[0],d=o[s],h;r<=a&&i<=s;)l==null?l=e[++r]:u==null?u=e[--a]:c==null?c=o[++i]:d==null?d=o[--s]:H(l,c)?(_(l,c),l=e[++r],c=o[++i]):H(u,d)?(_(u,d),u=e[--a],d=o[--s]):H(l,d)?(_(l,d),t.insertBefore(l.$elm$,u.$elm$.nextSibling),l=e[++r],d=o[--s]):H(u,c)?(_(u,c),t.insertBefore(u.$elm$,l.$elm$),u=e[--a],c=o[++i]):(h=J(e&&e[i],n,i),c=o[++i],h&&l.$elm$.parentNode.insertBefore(h,l.$elm$));r>a?Ie(t,o[s+1]==null?null:o[s+1].$elm$,n,o,i,s):i>s&&De(e,r,a)},H=function(t,e){return t.$tag$===e.$tag$},_=function(t,e){var n=e.$elm$=t.$elm$,o=t.$children$,r=e.$children$;e.$text$===null?(ke(t,e,he),o!==null&&r!==null?rt(n,o,e,r):r!==null?(t.$text$!==null&&(n.textContent=""),Ie(n,null,e,r,0,r.length-1)):o!==null&&De(o,0,o.length-1)):t.$text$!==e.$text$&&(n.data=e.$text$)},_e=function(t){t.$attrs$&&t.$attrs$.ref&&t.$attrs$.ref(null),t.$children$&&t.$children$.forEach(_e)},it=function(t,e,n,o){var r=e.$vnode$||W(null,null),i=nt(o)?o:et(null,null,o);i.$tag$=null,i.$flags$|=4,e.$vnode$=i,i.$elm$=r.$elm$=t,_(r,i)},Le=function(t,e){e&&!t.$onRenderResolve$&&e["s-p"].push(new Promise(function(n){return t.$onRenderResolve$=n}))},R=function(t,e,n,o){if(e.$flags$|=16,e.$flags$&4){e.$flags$|=512;return}var r=b("scheduleUpdate",n.$tagName$),i=e.$ancestorComponent$,a=e.$lazyInstance$,l=function(){return at(t,e,n,a,o)};Le(e,i);var u;return o&&(e.$flags$|=256,e.$queuedListeners$&&(e.$queuedListeners$.forEach(function(s){var c=s[0],d=s[1];return Ae(a,c,d)}),e.$queuedListeners$=null)),r(),ut(u,function(){return qe(l)})},at=function(t,e,n,o,r){var i=b("update",n.$tagName$),a=t["s-rc"];r&&Ve(t,n,e.$modeName$);var l=b("render",n.$tagName$);try{it(t,e,n,o.render())}catch(c){I(c)}f.$cssShim$&&f.$cssShim$.updateHost(t),e.$flags$&=~16,e.$flags$|=2,a&&(a.forEach(function(c){return c()}),t["s-rc"]=void 0),l(),i();{var u=t["s-p"],s=function(){return st(t,e,n)};u.length===0?s():(Promise.all(u).then(s),e.$flags$|=4,u.length=0)}},st=function(t,e,n){var o=b("postUpdate",n.$tagName$),r=e.$lazyInstance$,i=e.$ancestorComponent$;e.$flags$&64?(Ae(r,"componentDidUpdate"),o()):(e.$flags$|=64,t.classList.add(ye),o(),e.$onReadyResolve$(t),i||Fe()),e.$onInstanceResolve$(t),e.$onRenderResolve$&&(e.$onRenderResolve$(),e.$onRenderResolve$=void 0),e.$flags$&512&&G(function(){return R(t,e,n,!1)}),e.$flags$&=~(4|512)},lt=function(t,e){{var n=S(t);(n.$flags$&(2|16))==2&&R(t,n,e,!1)}},Fe=function(t){v.documentElement.classList.add(ye),f.$flags$|=2},Ae=function(t,e,n){if(t&&t[e])try{return t[e](n)}catch(o){I(o)}},ut=function(t,e){return t&&t.then?t.then(e):e()},ct=function(t,e){return S(t).$instanceValues$.get(e)},dt=function(t,e,n,o){var r=S(t),i=r.$hostElement$,a=r.$instanceValues$.get(e),l=r.$flags$,u=r.$lazyInstance$;n=Ke(n,o.$members$[e][0]),n!==a&&(!(l&8)||a===void 0)&&(r.$instanceValues$.set(e,n),u&&(l&(2|16))==2&&R(i,r,o,!1))},Te=function(t,e,n){if(e.$members$){var o=Object.entries(e.$members$),r=t.prototype;if(o.forEach(function(a){var l=a[0],u=a[1][0];u&31||n&2&&u&32?Object.defineProperty(r,l,{get:function(){return ct(this,l)},set:function(s){dt(this,l,s,e)},configurable:!0,enumerable:!0}):n&1&&u&64&&Object.defineProperty(r,l,{value:function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];var d=S(this);return d.$onInstancePromise$.then(function(){var h;return(h=d.$lazyInstance$)[l].apply(h,s)})}})}),n&1){var i=new Map;r.attributeChangedCallback=function(a,l,u){var s=this;f.jmp(function(){var c=i.get(a);s[c]=u===null&&typeof s[c]=="boolean"?!1:u})},t.observedAttributes=o.filter(function(a){var l=a[0],u=a[1];return u[0]&15}).map(function(a){var l=a[0],u=a[1],s=u[1]||l;return i.set(s,l),s})}}return t},ft=function(t,e,n){e.$queuedListeners$=e.$queuedListeners$||[];var o=n.map(function(r){var i=r[0],a=r[1],l=r[2],u=$t(t,i),s=ht(e,l),c=pt(i);return f.ael(u,a,s,c),function(){return f.rel(u,a,s,c)}});return function(){return o.forEach(function(r){return r()})}},ht=function(t,e){return function(n){t.$flags$&256?t.$lazyInstance$[e](n):t.$queuedListeners$.push([e,n])}},$t=function(t,e){return e&8?P:t},pt=function(t){return ze?{passive:(t&1)!=0,capture:(t&2)!=0}:(t&2)!=0},mt=function(t,e,n,o,r){return Ue(void 0,void 0,void 0,function(){var i,a,l,u,s,c,d;return je(this,function(h){switch(h.label){case 0:return(e.$flags$&32)!=0?[3,3]:(e.$flags$|=32,r=We(n),r.then?(i=Xe(),[4,r]):[3,2]);case 1:r=h.sent(),i(),h.label=2;case 2:r.isProxied||(Te(r,n,2),r.isProxied=!0),a=b("createInstance",n.$tagName$),e.$flags$|=8;try{new r(e)}catch(m){I(m)}e.$flags$&=~8,a(),l=xe(n.$tagName$),!C.has(l)&&r.style&&(u=b("registerStyles",n.$tagName$),s=r.style,Ye(l,s,!!(n.$flags$&1)),u()),h.label=3;case 3:return c=e.$ancestorComponent$,d=function(){return R(t,e,n,!0)},c&&c["s-rc"]?c["s-rc"].push(d):d(),[2]}})})},gt=function(t,e){if((f.$flags$&1)==0){var n=b("connectedCallback",e.$tagName$),o=S(t);if(e.$listeners$&&(o.$rmListeners$=ft(t,o,e.$listeners$)),!(o.$flags$&1)){o.$flags$|=1;for(var r=t;r=r.parentNode||r.host;)if(r["s-p"]){Le(o,o.$ancestorComponent$=r);break}e.$members$&&Object.entries(e.$members$).forEach(function(i){var a=i[0],l=i[1][0];if(l&31&&t.hasOwnProperty(a)){var u=t[a];delete t[a],t[a]=u}}),G(function(){return mt(t,o,e)})}n()}},vt=function(t){if((f.$flags$&1)==0){var e=S(t);e.$rmListeners$&&(e.$rmListeners$(),e.$rmListeners$=void 0),f.$cssShim$&&f.$cssShim$.removeHost(t)}},Ce=function(t,e){e===void 0&&(e={});var n=b(),o=[],r=e.exclude||[],i=v.head,a=P.customElements,l=i.querySelector("meta[charset]"),u=v.createElement("style"),s=[],c,d=!0;Object.assign(f,e),f.$resourcesUrl$=new URL(e.resourcesUrl||"./",v.baseURI).href,e.syncQueue&&(f.$flags$|=4),t.forEach(function(h){return h[1].forEach(function(m){var w={$flags$:m[0],$tagName$:m[1],$members$:m[2],$listeners$:m[3]};w.$members$=m[2],w.$listeners$=m[3];var F=w.$tagName$,Re=function(ee){Be(x,ee);function x(E){var te=ee.call(this,E)||this;return E=te,Ne(E),te}return x.prototype.connectedCallback=function(){var E=this;c&&(clearTimeout(c),c=null),d?s.push(this):f.jmp(function(){return gt(E,w)})},x.prototype.disconnectedCallback=function(){var E=this;f.jmp(function(){return vt(E)})},x.prototype["s-hmr"]=function(E){},x.prototype.forceUpdate=function(){lt(this,w)},x.prototype.componentOnReady=function(){return S(this).$onReadyPromise$},x}(HTMLElement);w.$lazyBundleIds$=h[0],!r.includes(F)&&!a.get(F)&&(o.push(F),a.define(F,Te(Re,w,1)))})}),u.innerHTML=o+"{visibility:hidden}.hydrated{visibility:inherit}",u.setAttribute("data-styles",""),i.insertBefore(u,l?l.nextSibling:i.firstChild),d=!1,s.length>0?s.forEach(function(h){return h.connectedCallback()}):f.jmp(function(){return c=setTimeout(Fe,30,"timeout")}),n()};var B=function(t,e){return Ee().then(function(){Ce([["uv-ebook-reader_2",[[0,"uv-ebook-reader",{width:[1],height:[1],mobileWidth:[2,"mobile-width"],minSpreadWidth:[2,"min-spread-width"],_bookPath:[32],_bookReady:[32],_prevEnabled:[32],_mobile:[32],_nextEnabled:[32],_showDivider:[32],load:[64],resize:[64],display:[64],getBook:[64]},[[8,"keydown","handleKeyDown"]]],[0,"uv-ebook-toc",{toc:[16],selected:[1025],disabled:[4]}]]]],e)})};(function(){if(!(window.Reflect===void 0||window.customElements===void 0)){var t=HTMLElement;window.HTMLElement=function(){return Reflect.construct(t,[],this.constructor)},HTMLElement.prototype=t.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,t)}})();var Oe=window.$,Q=class extends ae{constructor(e){super(e)}async create(){this.setConfig("leftPanel"),super.create(),this._$container=Oe('<div class="container"></div>'),await T(),B(window),this._ebookTOC=document.createElement("uv-ebook-toc"),this._$ebookTOC=Oe(this._ebookTOC),this.$main.addClass("disabled"),this.$main.append(this._$container),this._$container.append(this._$ebookTOC),this.setTitle(this.content.title),this.extensionHost.subscribe(p.LOADED_NAVIGATION,e=>{this.$main.removeClass("disabled"),this._ebookTOC.toc=e.toc}),this.extensionHost.subscribe(p.RELOCATED,e=>{this._ebookTOC.selected=e.start.href}),this._ebookTOC.addEventListener("itemClicked",e=>{this.extensionHost.publish(p.ITEM_CLICKED,e.detail)},!1),k.waitFor(()=>window.customElements!==void 0,()=>{customElements.whenDefined("uv-ebook-toc").then(()=>{this.extensionHost.publish(p.TOC_READY)})})}expandFullStart(){super.expandFullStart(),this.extensionHost.publish(g.LEFTPANEL_EXPAND_FULL_START)}expandFullFinish(){super.expandFullFinish(),this.extensionHost.publish(g.LEFTPANEL_EXPAND_FULL_FINISH)}collapseFullStart(){super.collapseFullStart(),this.extensionHost.publish(g.LEFTPANEL_COLLAPSE_FULL_START)}collapseFullFinish(){super.collapseFullFinish(),this.extensionHost.publish(g.LEFTPANEL_COLLAPSE_FULL_FINISH)}resize(){super.resize(),this._$container.height(this.$main.height()-this._$container.verticalPadding())}};var q=class extends se{constructor(e){super(e)}create(){this.setConfig("downloadDialogue"),super.create()}open(e){super.open(e),this.addEntireFileDownloadOptions(),this.updateNoneAvailable(),this.resize()}isDownloadOptionAvailable(e){return super.isDownloadOptionAvailable(e)}};var K=class extends re{constructor(e){super(e);this._ebookReaderReady=!1;this._state={};this._prevState={};this.attributionPosition=oe.BOTTOM_RIGHT}async create(){this.setConfig("centerPanel"),super.create(),await T(),B(window),this._ebookReader=document.createElement("uv-ebook-reader"),this.$content.prepend(this._ebookReader),this._ebookReader.setAttribute("width","100%"),this._ebookReader.setAttribute("height","100%"),this._ebookReader.addEventListener("loadedNavigation",n=>{this.extensionHost.publish(p.LOADED_NAVIGATION,n.detail)},!1),this._ebookReader.addEventListener("relocated",n=>{this.extensionHost.publish(p.RELOCATED,n.detail),this._cfi=n.detail.start.cfi,this.extensionHost.publish(p.CFI_FRAGMENT_CHANGE,this._cfi)},!1),k.waitFor(()=>window.customElements!==void 0,()=>{customElements.whenDefined("uv-ebook-reader").then(()=>{this._ebookReaderReady=!0})});let e=this;this.extensionHost.subscribe(g.OPEN_EXTERNAL_RESOURCE,n=>{e.openMedia(n)}),this.extensionHost.subscribe(p.ITEM_CLICKED,n=>{this._nextState({cfi:n})}),this.extensionHost.subscribe(p.CFI_FRAGMENT_CHANGE,n=>{k.waitFor(()=>this._ebookReaderReady,()=>{n!==this._cfi&&this._nextState({cfi:n})})})}openMedia(e){this.extension.getExternalResources(e).then(()=>{let o=this.extension.helper.getCurrentCanvas().getContent();if(o.length){let i=o[0].getBody();if(i.length){let a=i[0];this._nextState({bookPath:a.id})}}this.extensionHost.publish(U.EXTERNAL_RESOURCE_OPENED),this.extensionHost.publish(U.LOAD)})}_nextState(e){this._state=Object.assign({},this._state,e),k.waitFor(()=>this._ebookReaderReady,()=>{this._state.bookPath&&this._state.bookPath!==this._prevState.bookPath&&this._ebookReader.load(this._state.bookPath),this._state.cfi&&this._state.cfi!==this._prevState.cfi&&this._ebookReader.display(this._state.cfi),this._prevState=Object.assign({},this._state)})}resize(){super.resize(),this._ebookReaderReady&&setTimeout(()=>{this._ebookReader.resize()},10)}};var X=class extends A{constructor(e){super(e)}create(){this.setConfig("mobileFooterPanel"),super.create()}resize(){super.resize(),this.$options.css("left",Math.floor(this.$element.width()/2-this.$options.width()/2))}};var Y=class extends ce{constructor(e){super(e)}create(){this.setConfig("settingsDialogue"),super.create()}};var Z=class extends de{constructor(e){super(e)}create(){this.setConfig("shareDialogue"),super.create()}update(){super.update(),this.code=this.extension.getEmbedScript(this.options.embedTemplate,this.currentWidth,this.currentHeight),this.$code.val(this.code)}resize(){super.resize()}};var bt={allowStealFocus:!1,authAPIVersion:1,bookmarkThumbHeight:150,bookmarkThumbWidth:90,dropEnabled:!0,footerPanelEnabled:!0,headerPanelEnabled:!0,leftPanelEnabled:!0,limitLocales:!1,metrics:[{type:"sm",minWidth:0},{type:"md",minWidth:768},{type:"lg",minWidth:1024},{type:"xl",minWidth:1280}],multiSelectionMimeType:"application/zip",navigatorEnabled:!0,openTemplate:"http://universalviewer.io?manifest={0}",overrideFullScreen:!1,pagingEnabled:!0,pagingOptionEnabled:!0,pessimisticAccessControl:!1,preserveViewport:!1,rightPanelEnabled:!0,saveUserSettings:!1,clickToZoomEnabled:!0,searchWithinEnabled:!0,termsOfUseEnabled:!1,theme:"uv-en-GB-theme",tokenStorage:"session",useArrowKeysToNavigate:!1,zoomToSearchResultEnabled:!0},Et={leftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1},content:{title:"$contents",collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},dialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close"}},footerPanel:{options:{bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0},content:{bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",moreInfo:"$moreInfo",open:"$open",share:"$share"}},genericDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",emptyValue:"$emptyValue",invalidNumber:"$invalidNumber",noMatches:"$noMatches",ok:"$ok",pageNotFound:"$pageNotFound",refresh:"$refresh"}},headerPanel:{options:{centerOptionsEnabled:!0,localeToggleEnabled:!1,settingsButtonEnabled:!0},content:{close:"$close",settings:"$settings"}},helpDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",text:"$placeholder_text",title:"$help"}},moreInfoRightPanel:{options:{canvasDisplayOrder:"",canvasExclude:"",copyToClipboardEnabled:!1,expandFullEnabled:!1,limitToRange:!1,manifestDisplayOrder:"",manifestExclude:"",panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",showAllLanguages:!1,textLimit:4,textLimitType:"lines",topCloseButtonEnabled:!1},content:{attribution:"$attribution",canvasHeader:"$aboutTheImage",close:"$close",collapse:"$collapseInformation",collapseFull:"$collapseGallery",copiedToClipboard:"$copiedToClipboard",copyToClipboard:"$copyToClipboard",description:"$description",expand:"$expandInformation",expandFull:"$expandGallery",holdingText:"$moduleGoesHere",less:"$less",license:"$license",logo:"$logo",manifestHeader:"$aboutTheItem",more:"$more",noData:"$noDataToDisplay",page:"$page",rangeHeader:"$aboutThisSection",title:"$moreInformation"}},centerPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution"}},settingsDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",locale:"$locale",navigatorEnabled:"$navigatorEnabled",clickToZoomEnabled:"$clickToZoomEnabled",pagingEnabled:"$twoPageView",reducedMotion:"$reducedMotion",preserveViewport:"$preserveViewport",title:"$settings",website:"$uvWebsite"}},shareDialogue:{options:{embedEnabled:!0,shareEnabled:!0,embedTemplate:'<iframe src="{0}" width="{1}" height="{2}" allowfullscreen frameborder="0"></iframe>',instructionsEnabled:!1,shareFrameEnabled:!0,shareManifestsEnabled:!0,topCloseButtonEnabled:!1},content:{close:"$close",customSize:"custom",embed:"Embed",embedInstructions:"To embed this item in your own website, copy and paste the code below.",height:"Height",iiif:"IIIF Manifest",share:"Share",shareInstructions:"To share this item, copy the URL below.",size:"Size:",width:"Width",shareUrl:"$shareUrl"}},authDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close",confirm:"$confirm"}},clickThroughDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",viewTerms:"$viewTerms"}},downloadDialogue:{options:{topCloseButtonEnabled:!1},content:{allPages:"$allPages",close:"$close",currentViewAsJpg:"$currentViewAsJpg",currentViewAsJpgExplanation:"$openNewWindow",download:"$download",downloadSelection:"$downloadSelection",downloadSelectionExplanation:"$downloadSelectionExplanation",editSettings:"$editSettings",entireDocument:"$entireDocument",entireFileAsOriginal:"$entireFile",entireFileAsOriginalWithFormat:"$entireFileAsOriginalWithFormat",individualPages:"$individualPages",noneAvailable:"$noDownloadOptionsAvailable",pagingNote:"$pagingNote",preview:"$preview",selection:"$selection",termsOfUse:"$termsOfUse",title:"$download",wholeImageHighRes:"$wholeImageHighRes",wholeImageHighResExplanation:"$openNewWindow",wholeImageLowResAsJpg:"$wholeImageLowResAsJpg",wholeImageLowResAsJpgExplanation:"$openNewWindow",wholeImagesHighRes:"$wholeImagesHighRes",wholeImagesHighResExplanation:"$wholeImagesHighResExplanation"}},loginDialogue:{options:{topCloseButtonEnabled:!1},content:{login:"$login",logout:"$logout",cancel:"$cancel",close:"$close"}},restrictedDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close"}},mobileFooterPanel:{options:{bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0},content:{rotateRight:"$rotateRight",moreInfo:"$moreInfo",zoomIn:"$zoomIn",zoomOut:"$zoomOut",bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",open:"$open",share:"$share"}}},yt={label:"English (GB)",locales:[{name:"cy-GB",label:"Cymraeg"},{name:"en-GB",label:"English (GB)"},{name:"fr-FR",label:"Fran\xE7ais (FR)"},{name:"pl-PL",label:"Polski"},{name:"sv-SE",label:"Svenska"}]},wt={authCORSError:"$authCORSError",authorisationFailedMessage:"$authorisationFailedMessage",canvasIndexOutOfRange:"$canvasIndexOutOfRange",fallbackDegradedLabel:"$fallbackDegradedLabel",fallbackDegradedMessage:"$fallbackDegradedMessage",forbiddenResourceMessage:"$forbiddenResourceMessage",termsOfUse:"$termsOfUse",mediaViewer:"$mediaViewer",skipToDownload:"$skipToDownload"},V={options:bt,modules:Et,localisation:yt,content:wt};var He=class extends ie{constructor(){super(...arguments);this.defaultConfig=V;this.locales={"en-GB":V}}create(){super.create(),this.extensionHost.subscribe(g.CANVAS_INDEX_CHANGE,e=>{this.viewCanvas(e)}),this.extensionHost.subscribe(p.CFI_FRAGMENT_CHANGE,e=>{this.cfiFragement=e,this.fire(p.CFI_FRAGMENT_CHANGE,this.cfiFragement)})}createModules(){super.createModules(),this.isHeaderPanelEnabled()?this.headerPanel=new le(this.shell.$headerPanel):this.shell.$headerPanel.hide(),this.isLeftPanelEnabled()?this.leftPanel=new Q(this.shell.$leftPanel):this.shell.$leftPanel.hide(),this.centerPanel=new K(this.shell.$centerPanel),this.isRightPanelEnabled()?this.rightPanel=new ue(this.shell.$rightPanel):this.shell.$rightPanel.hide(),this.isFooterPanelEnabled()?(this.footerPanel=new A(this.shell.$footerPanel),this.mobileFooterPanel=new X(this.shell.$mobileFooterPanel)):this.shell.$footerPanel.hide(),this.$moreInfoDialogue=$('<div class="overlay moreInfo" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$moreInfoDialogue),this.moreInfoDialogue=new fe(this.$moreInfoDialogue),this.$shareDialogue=$('<div class="overlay share" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$shareDialogue),this.shareDialogue=new Z(this.$shareDialogue),this.$downloadDialogue=$('<div class="overlay download" aria-hidden="true" role="region"></div>'),this.shell.$overlays.append(this.$downloadDialogue),this.downloadDialogue=new q(this.$downloadDialogue),this.$settingsDialogue=$('<div class="overlay settings" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$settingsDialogue),this.settingsDialogue=new Y(this.$settingsDialogue),this.isHeaderPanelEnabled()&&this.headerPanel.init(),this.isLeftPanelEnabled()&&this.leftPanel.init(),this.isRightPanelEnabled()&&this.rightPanel.init(),this.isFooterPanelEnabled()&&this.footerPanel.init()}isLeftPanelEnabled(){return!0}render(){super.render(),this.checkForCFIParam()}getEmbedScript(e,n,o){let i=`${this.getAppUri()}#?manifest=${this.helper.manifestUri}&cfi=${this.cfiFragement}`;return ne.format(e,i,n.toString(),o.toString())}checkForCFIParam(){let e=this.data.cfi;e&&this.extensionHost.publish(p.CFI_FRAGMENT_CHANGE,e)}};export{He as default};