@tindtechnologies/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.2 kB
JavaScript
import{a as de}from"./chunk-YLQOZZ6G.js";import{a as ae}from"./chunk-QBSATBVB.js";import"./chunk-2SUYJOML.js";import{b as ne,c as ie,f as oe,g as re,h as _,i as se,k as le,l as ue,m as ce}from"./chunk-BIWUBEGG.js";import"./chunk-UYLDA6E6.js";import{a as k,n as te,p as g}from"./chunk-2YE6NNA6.js";import{g as U}from"./chunk-R6HAKAEO.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 A(){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 i=new URL("b","http://a");return i.pathname="c%20d",i.href==="http://a/c%20d"&&i.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(i,o){i.__proto__=o}||function(i,o){for(var r in o)o.hasOwnProperty(r)&&(i[r]=o[r])},t(e,n)};return function(e,n){t(e,n);function i(){this.constructor=e}e.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)}}(),Ue=function(t,e,n,i){function o(r){return r instanceof n?r:new n(function(a){a(r)})}return new(n||(n=Promise))(function(r,a){function l(c){try{s(i.next(c))}catch(d){a(d)}}function u(c){try{s(i.throw(c))}catch(d){a(d)}}function s(c){c.done?r(c.value):o(c.value).then(l,u)}s((i=i.apply(t,e||[])).next())})},je=function(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,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(i)throw new TypeError("Generator is already executing.");for(;n;)try{if(i=1,o&&(r=s[0]&2?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[s[0]&2,r.value]),s[0]){case 0:case 1:r=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,o=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(r=n.trys,!(r=r.length>0&&r[r.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!r||s[1]>r[0]&&s[1]<r[3])){n.label=s[1];break}if(s[0]===6&&n.label<r[1]){n.label=r[1],r=s;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(s);break}r[2]&&n.ops.pop(),n.trys.pop();continue}s=e.call(t,n)}catch(c){s=[6,c],o=0}finally{i=r=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 i=Array(t),o=0,e=0;e<n;e++)for(var r=arguments[e],a=0,l=r.length;a<l;a++,o++)i[o]=r[a];return i};var j=0,M=!1,fe=!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,i){return t.addEventListener(e,n,i)},rel:function(t,e,n,i){return t.removeEventListener(e,n,i)}},We=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}(),he=new WeakMap,S=function(t){return he.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"]=[],he.set(t,e)},$e=function(t,e){return e in t},I=function(t){return console.error(t)},pe=new Map,ze=function(t,e,n){var i=t.$tagName$.replace(/-/g,"_"),o=t.$lazyBundleIds$,r=pe.get(o);return r?r[i]:import("./"+o+".entry.js").then(function(a){return pe.set(o,a),a[i]},I)},T=new Map,me=[],D=[],O=[],Je=function(t,e){return function(n){t.push(n),M||(M=!0,e&&f.$flags$&4?G(W):f.raf(W))}},qe=function(t){for(var e=0;e<t.length;e++)try{t[e](performance.now())}catch(n){I(n)}t.length=0},ge=function(t,e){for(var n=0,i=0;n<t.length&&(i=performance.now())<e;)try{t[n++](i)}catch(o){I(o)}n===t.length?t.length=0:n!==0&&t.splice(0,n)},W=function(){j++,qe(me);var t=(f.$flags$&6)==2?performance.now()+10*Math.ceil(j*(1/22)):1/0;ge(D,t),ge(O,t),D.length>0&&(O.push.apply(O,D),D.length=0),(M=me.length+D.length+O.length>0)?f.raf(W):j=0},G=function(t){return Promise.resolve().then(t)},Qe=Je(D,!0),ve={},N=function(t){return t=typeof t,t==="object"||t==="function"};var be=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},Ee="hydrated",b=function(t,e){return e===void 0&&(e=""),function(){}},Xe=function(t,e){return function(){}},ye=new WeakMap,Ye=function(t,e,n){var i=T.get(t);Ge&&n?(i=i||new CSSStyleSheet,i.replace(e)):i=e,T.set(t,i)},Ze=function(t,e,n,i){var o=we(e.$tagName$),r=T.get(o);if(t=t.nodeType===11?t:v,r)if(typeof r=="string"){t=t.head||t;var a=ye.get(t),l=void 0;if(a||ye.set(t,a=new Set),!a.has(o)){{if(f.$cssShim$){l=f.$cssShim$.createHostStyle(i,o,r,!!(e.$flags$&10));var u=l["s-sc"];u&&(o=u,a=null)}else l=v.createElement("style"),l.innerHTML=r;t.insertBefore(l,t.querySelector("link"))}a&&a.add(o)}}else t.adoptedStyleSheets.includes(r)||(t.adoptedStyleSheets=Me(t.adoptedStyleSheets,[r]));return o},Ve=function(t,e,n){var i=b("attachStyles",e.$tagName$),o=Ze(t.getRootNode(),e,n,t);i()},we=function(t,e){return"sc-"+t},et=function(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var o=null,r=!1,a=!1,l=[],u=function(d){for(var h=0;h<d.length;h++)o=d[h],Array.isArray(o)?u(o):o!=null&&typeof o!="boolean"&&((r=typeof t!="function"&&!N(o))&&(o=String(o)),r&&a?l[l.length-1].$text$+=o:l.push(r?z(null,o):o),a=r)};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=z(t,null);return c.$attrs$=e,l.length>0&&(c.$children$=l),c},z=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},xe=function(t,e,n,i,o,r){if(n!==i){var a=$e(t,e),l=e.toLowerCase();if(e==="class"){var u=t.classList,s=Pe(n),c=Pe(i);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")i&&i(t);else if(!a&&e[0]==="o"&&e[1]==="n")e[2]==="-"?e=e.slice(3):$e(P,l)?e=l.slice(2):e=l[2]+e.slice(3),n&&f.rel(t,e,n,!1),i&&f.ael(t,e,i,!1);else{var d=N(i);if((a||d&&i!==null)&&!o)try{if(t.tagName.includes("-"))t[e]=i;else{var h=i??"";e==="list"?a=!1:(n==null||t[e]!=h)&&(t[e]=h)}}catch{}i==null||i===!1?t.removeAttribute(e):(!a||r&4||o)&&!d&&(i=i===!0?"":i,t.setAttribute(e,i))}}},it=/\s/,Pe=function(t){return t?t.split(it):[]},Se=function(t,e,n,i){var o=e.$elm$.nodeType===11&&e.$elm$.host?e.$elm$.host:e.$elm$,r=t&&t.$attrs$||ve,a=e.$attrs$||ve;for(i in r)i in a||xe(o,i,r[i],void 0,n,e.$flags$);for(i in a)xe(o,i,r[i],a[i],n,e.$flags$)},J=function(t,e,n,i){var o=e.$children$[n],r=0,a,l;if(o.$text$!==null)a=o.$elm$=v.createTextNode(o.$text$);else if(a=o.$elm$=v.createElement(o.$tag$),Se(null,o,fe),o.$children$)for(r=0;r<o.$children$.length;++r)l=J(t,o,r),l&&a.appendChild(l);return a},ke=function(t,e,n,i,o,r){for(var a=t,l;o<=r;++o)i[o]&&(l=J(null,n,o),l&&(i[o].$elm$=l,a.insertBefore(l,e)))},Ie=function(t,e,n,i,o){for(;e<=n;++e)(i=t[e])&&(o=i.$elm$,De(i),o.remove())},ot=function(t,e,n,i){for(var o=0,r=0,a=e.length-1,l=e[0],u=e[a],s=i.length-1,c=i[0],d=i[s],h;o<=a&&r<=s;)l==null?l=e[++o]:u==null?u=e[--a]:c==null?c=i[++r]:d==null?d=i[--s]:H(l,c)?(L(l,c),l=e[++o],c=i[++r]):H(u,d)?(L(u,d),u=e[--a],d=i[--s]):H(l,d)?(L(l,d),t.insertBefore(l.$elm$,u.$elm$.nextSibling),l=e[++o],d=i[--s]):H(u,c)?(L(u,c),t.insertBefore(u.$elm$,l.$elm$),u=e[--a],c=i[++r]):(h=J(e&&e[r],n,r),c=i[++r],h&&l.$elm$.parentNode.insertBefore(h,l.$elm$));o>a?ke(t,i[s+1]==null?null:i[s+1].$elm$,n,i,r,s):r>s&&Ie(e,o,a)},H=function(t,e){return t.$tag$===e.$tag$},L=function(t,e){var n=e.$elm$=t.$elm$,i=t.$children$,o=e.$children$;e.$text$===null?(Se(t,e,fe),i!==null&&o!==null?ot(n,i,e,o):o!==null?(t.$text$!==null&&(n.textContent=""),ke(n,null,e,o,0,o.length-1)):i!==null&&Ie(i,0,i.length-1)):t.$text$!==e.$text$&&(n.data=e.$text$)},De=function(t){t.$attrs$&&t.$attrs$.ref&&t.$attrs$.ref(null),t.$children$&&t.$children$.forEach(De)},rt=function(t,e,n,i){var o=e.$vnode$||z(null,null),r=nt(i)?i:et(null,null,i);r.$tag$=null,r.$flags$|=4,e.$vnode$=r,r.$elm$=o.$elm$=t,L(o,r)},Le=function(t,e){e&&!t.$onRenderResolve$&&e["s-p"].push(new Promise(function(n){return t.$onRenderResolve$=n}))},R=function(t,e,n,i){if(e.$flags$|=16,e.$flags$&4){e.$flags$|=512;return}var o=b("scheduleUpdate",n.$tagName$),r=e.$ancestorComponent$,a=e.$lazyInstance$,l=function(){return at(t,e,n,a,i)};Le(e,r);var u;return i&&(e.$flags$|=256,e.$queuedListeners$&&(e.$queuedListeners$.forEach(function(s){var c=s[0],d=s[1];return Fe(a,c,d)}),e.$queuedListeners$=null)),o(),ut(u,function(){return Qe(l)})},at=function(t,e,n,i,o){var r=b("update",n.$tagName$),a=t["s-rc"];o&&Ve(t,n,e.$modeName$);var l=b("render",n.$tagName$);try{rt(t,e,n,i.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(),r();{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 i=b("postUpdate",n.$tagName$),o=e.$lazyInstance$,r=e.$ancestorComponent$;e.$flags$&64?(Fe(o,"componentDidUpdate"),i()):(e.$flags$|=64,t.classList.add(Ee),i(),e.$onReadyResolve$(t),r||Ce()),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)}},Ce=function(t){v.documentElement.classList.add(Ee),f.$flags$|=2},Fe=function(t,e,n){if(t&&t[e])try{return t[e](n)}catch(i){I(i)}},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,i){var o=S(t),r=o.$hostElement$,a=o.$instanceValues$.get(e),l=o.$flags$,u=o.$lazyInstance$;n=Ke(n,i.$members$[e][0]),n!==a&&(!(l&8)||a===void 0)&&(o.$instanceValues$.set(e,n),u&&(l&(2|16))==2&&R(r,o,i,!1))},_e=function(t,e,n){if(e.$members$){var i=Object.entries(e.$members$),o=t.prototype;if(i.forEach(function(a){var l=a[0],u=a[1][0];u&31||n&2&&u&32?Object.defineProperty(o,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(o,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 r=new Map;o.attributeChangedCallback=function(a,l,u){var s=this;f.jmp(function(){var c=r.get(a);s[c]=u===null&&typeof s[c]=="boolean"?!1:u})},t.observedAttributes=i.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 r.set(s,l),s})}}return t},ft=function(t,e,n){e.$queuedListeners$=e.$queuedListeners$||[];var i=n.map(function(o){var r=o[0],a=o[1],l=o[2],u=$t(t,r),s=ht(e,l),c=pt(r);return f.ael(u,a,s,c),function(){return f.rel(u,a,s,c)}});return function(){return i.forEach(function(o){return o()})}},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 We?{passive:(t&1)!=0,capture:(t&2)!=0}:(t&2)!=0},mt=function(t,e,n,i,o){return Ue(void 0,void 0,void 0,function(){var r,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,o=ze(n),o.then?(r=Xe(),[4,o]):[3,2]);case 1:o=h.sent(),r(),h.label=2;case 2:o.isProxied||(_e(o,n,2),o.isProxied=!0),a=b("createInstance",n.$tagName$),e.$flags$|=8;try{new o(e)}catch(m){I(m)}e.$flags$&=~8,a(),l=we(n.$tagName$),!T.has(l)&&o.style&&(u=b("registerStyles",n.$tagName$),s=o.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$),i=S(t);if(e.$listeners$&&(i.$rmListeners$=ft(t,i,e.$listeners$)),!(i.$flags$&1)){i.$flags$|=1;for(var o=t;o=o.parentNode||o.host;)if(o["s-p"]){Le(i,i.$ancestorComponent$=o);break}e.$members$&&Object.entries(e.$members$).forEach(function(r){var a=r[0],l=r[1][0];if(l&31&&t.hasOwnProperty(a)){var u=t[a];delete t[a],t[a]=u}}),G(function(){return mt(t,i,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)}},Ae=function(t,e){e===void 0&&(e={});var n=b(),i=[],o=e.exclude||[],r=v.head,a=P.customElements,l=r.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(V){Be(x,V);function x(E){var ee=V.call(this,E)||this;return E=ee,Ne(E),ee}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],!o.includes(F)&&!a.get(F)&&(i.push(F),a.define(F,_e(Re,w,1)))})}),u.innerHTML=i+"{visibility:hidden}.hydrated{visibility:inherit}",u.setAttribute("data-styles",""),r.insertBefore(u,l?l.nextSibling:r.firstChild),d=!1,s.length>0?s.forEach(function(h){return h.connectedCallback()}):f.jmp(function(){return c=setTimeout(Ce,30,"timeout")}),n()};var B=function(t,e){return be().then(function(){Ae([["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 Te=window.$,q=class extends re{constructor(e){super(e)}async create(){this.setConfig("ebookLeftPanel"),super.create(),this._$container=Te('<div class="container"></div>'),await A(),B(window),this._ebookTOC=document.createElement("uv-ebook-toc"),this._$ebookTOC=Te(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 ae{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 ie{constructor(e){super(e);this._ebookReaderReady=!1;this._state={};this._prevState={};this.attributionPosition=ne.BOTTOM_RIGHT}async create(){this.setConfig("ebookCenterPanel"),super.create(),await A(),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 i=this.extension.helper.getCurrentCanvas().getContent();if(i.length){let r=i[0].getBody();if(r.length){let a=r[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 _{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 ue{constructor(e){super(e)}create(){this.setConfig("settingsDialogue"),super.create()}};var Z=class extends ce{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:{collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},ebookLeftPanel:{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"}},ebookCenterPanel:{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"}}},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"},Oe={options:bt,modules:Et,localisation:yt,content:wt};var He=class extends oe{constructor(){super(...arguments);this.defaultConfig=Oe}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 se(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 le(this.shell.$rightPanel):this.shell.$rightPanel.hide(),this.isFooterPanelEnabled()?(this.footerPanel=new _(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 de(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,i){let r=`${this.getAppUri()}#?manifest=${this.helper.manifestUri}&cfi=${this.cfiFragement}`;return te.format(e,r,n.toString(),i.toString())}checkForCFIParam(){let e=this.data.cfi;e&&this.extensionHost.publish(p.CFI_FRAGMENT_CHANGE,e)}};export{He as default};