@snippetify/book-reader-component
Version:
Book Reader Component
1 lines • 10.4 kB
JavaScript
let e,t=!1;const n="undefined"!=typeof window?window:{},l=n.document||{head:{}},s={t:0,l:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,l)=>e.addEventListener(t,n,l),rel:(e,t,n,l)=>e.removeEventListener(t,n,l),ce:(e,t)=>new CustomEvent(e,t)},o=e=>Promise.resolve(e),i=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replace}catch(e){}return!1})(),r=(e,t,n)=>{n&&n.map((([n,l,o])=>{const i=u(e,n),r=c(t,o),$=a(n);s.ael(i,l,r,$),(t.o=t.o||[]).push((()=>s.rel(i,l,r,$)))}))},c=(e,t)=>n=>{try{256&e.t?e.i[t](n):(e.u=e.u||[]).push([t,n])}catch(e){ee(e)}},u=(e,t)=>8&t?n:16&t?l.body:e,a=e=>0!=(2&e),$=new WeakMap,f=e=>"sc-"+e.$,d={},h=e=>"object"==(e=typeof e)||"function"===e,m=(e,t,...n)=>{let l=null,s=!1,o=!1,i=[];const r=t=>{for(let n=0;n<t.length;n++)l=t[n],Array.isArray(l)?r(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof e&&!h(l))&&(l+=""),s&&o?i[i.length-1].h+=l:i.push(s?p(null,l):l),o=s)};if(r(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}if("function"==typeof e)return e(null===t?{}:t,i,b);const c=p(e,null);return c.m=t,i.length>0&&(c.p=i),c},p=(e,t)=>({t:0,g:e,h:t,v:null,p:null,m:null}),y={},b={forEach:(e,t)=>e.map(w).forEach(t),map:(e,t)=>e.map(w).map(t).map(g)},w=e=>({vattrs:e.m,vchildren:e.p,vkey:e.S,vname:e.j,vtag:e.g,vtext:e.h}),g=e=>{if("function"==typeof e.vtag){const t=Object.assign({},e.vattrs);return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),m(e.vtag,t,...e.vchildren||[])}const t=p(e.vtag,e.vtext);return t.m=e.vattrs,t.p=e.vchildren,t.S=e.vkey,t.j=e.vname,t},v=(e,t,l,o,i,r)=>{if(l!==o){let c=Z(e,t),u=t.toLowerCase();if("class"===t){const t=e.classList,n=j(l),s=j(o);t.remove(...n.filter((e=>e&&!s.includes(e)))),t.add(...s.filter((e=>e&&!n.includes(e))))}else if("ref"===t)o&&o(e);else if(c||"o"!==t[0]||"n"!==t[1]){const n=h(o);if((c||n&&null!==o)&&!i)try{if(e.tagName.includes("-"))e[t]=o;else{let n=null==o?"":o;"list"===t?c=!1:null!=l&&e[t]==n||(e[t]=n)}}catch(e){}null==o||!1===o?!1===o&&""!==e.getAttribute(t)||e.removeAttribute(t):(!c||4&r||i)&&!n&&e.setAttribute(t,o=!0===o?"":o)}else t="-"===t[2]?t.slice(3):Z(n,u)?u.slice(2):u[2]+t.slice(3),l&&s.rel(e,t,l,!1),o&&s.ael(e,t,o,!1)}},S=/\s/,j=e=>e?e.split(S):[],k=(e,t,n,l)=>{const s=11===t.v.nodeType&&t.v.host?t.v.host:t.v,o=e&&e.m||d,i=t.m||d;for(l in o)l in i||v(s,l,o[l],void 0,n,t.t);for(l in i)v(s,l,o[l],i[l],n,t.t)},M=(t,n,s)=>{let o,i,r=n.p[s],c=0;if(null!==r.h)o=r.v=l.createTextNode(r.h);else if(o=r.v=l.createElement(r.g),k(null,r,!1),null!=e&&o["s-si"]!==e&&o.classList.add(o["s-si"]=e),r.p)for(c=0;c<r.p.length;++c)i=M(t,r,c),i&&o.appendChild(i);return o},x=(e,t,n,l,s,o)=>{let i,r=e;for(;s<=o;++s)l[s]&&(i=M(null,n,s),i&&(l[s].v=i,r.insertBefore(i,t)))},O=(e,t,n,l,s)=>{for(;t<=n;++t)(l=e[t])&&(s=l.v,E(l),s.remove())},C=(e,t)=>e.g===t.g,P=(e,t)=>{const n=t.v=e.v,l=e.p,s=t.p,o=t.h;null===o?(k(e,t,!1),null!==l&&null!==s?((e,t,n,l)=>{let s,o=0,i=0,r=t.length-1,c=t[0],u=t[r],a=l.length-1,$=l[0],f=l[a];for(;o<=r&&i<=a;)null==c?c=t[++o]:null==u?u=t[--r]:null==$?$=l[++i]:null==f?f=l[--a]:C(c,$)?(P(c,$),c=t[++o],$=l[++i]):C(u,f)?(P(u,f),u=t[--r],f=l[--a]):C(c,f)?(P(c,f),e.insertBefore(c.v,u.v.nextSibling),c=t[++o],f=l[--a]):C(u,$)?(P(u,$),e.insertBefore(u.v,c.v),u=t[--r],$=l[++i]):(s=M(t&&t[i],n,i),$=l[++i],s&&c.v.parentNode.insertBefore(s,c.v));o>r?x(e,null==l[a+1]?null:l[a+1].v,n,l,i,a):i>a&&O(t,o,r)})(n,l,t,s):null!==s?(null!==e.h&&(n.textContent=""),x(n,null,t,s,0,s.length-1)):null!==l&&O(l,0,l.length-1)):e.h!==o&&(n.data=o)},E=e=>{e.m&&e.m.ref&&e.m.ref(null),e.p&&e.p.map(E)},I=(e,t,n)=>{const l=(e=>Q(e).k)(e);return{emit:e=>L(l,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},L=(e,t,n)=>{const l=s.ce(t,n);return e.dispatchEvent(l),l},D=(e,t)=>{t&&!e.M&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.M=t)))},N=(e,t)=>{if(e.t|=16,!(4&e.t))return D(e,e.O),ae((()=>R(e,t)));e.t|=512},R=(e,t)=>{const n=e.i;let l;return t&&(e.t|=256,e.u&&(e.u.map((([e,t])=>F(n,e,t))),e.u=null),l=F(n,"componentWillLoad")),H(l,(()=>T(e,n,t)))},T=async(e,t,n)=>{const s=e.k,o=s["s-rc"];n&&(e=>{const t=e.C,n=e.k,s=t.t,o=((e,t)=>{let n=f(t),s=le.get(n);if(e=11===e.nodeType?e:l,s)if("string"==typeof s){let t,o=$.get(e=e.head||e);o||$.set(e,o=new Set),o.has(n)||(e.host&&(t=e.querySelector(`[sty-id="${n}"]`))?t.innerHTML=s:(t=l.createElement("style"),t.innerHTML=s,e.insertBefore(t,e.querySelector("link"))),o&&o.add(n))}else e.adoptedStyleSheets.includes(s)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,s]);return n})(n.getRootNode(),t);10&s&&(n["s-sc"]=o,n.classList.add(o+"-h"),2&s&&n.classList.add(o+"-s"))})(e);U(e,t),o&&(o.map((e=>e())),s["s-rc"]=void 0);{const t=s["s-p"],n=()=>W(e);0===t.length?n():(Promise.all(t).then(n),e.t|=4,t.length=0)}},U=(t,n)=>{try{n=n.render(),t.t&=-17,t.t|=2,((t,n)=>{const l=t.k,s=t.P||p(null,null),o=(e=>e&&e.g===y)(n)?n:m(null,null,n);o.g=null,o.t|=4,t.P=o,o.v=s.v=l,e=l["s-sc"],P(s,o)})(t,n)}catch(e){ee(e,t.k)}return null},W=e=>{const t=e.k,n=e.i,l=e.O;F(n,"componentDidRender"),64&e.t?F(n,"componentDidUpdate"):(e.t|=64,q(t),F(n,"componentDidLoad"),e.I(t),l||A()),e.L(t),e.M&&(e.M(),e.M=void 0),512&e.t&&ue((()=>N(e,!1))),e.t&=-517},A=()=>{q(l.documentElement),ue((()=>L(n,"appload",{detail:{namespace:"book-reader-component"}})))},F=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){ee(e)}},H=(e,t)=>e&&e.then?e.then(t):t(),q=e=>e.classList.add("hydrated"),V=(e,t,n,l,s,o,i)=>{let r,c,u,a;if(1===o.nodeType){for(r=o.getAttribute("c-id"),r&&(c=r.split("."),c[0]!==i&&"0"!==c[0]||(u={t:0,D:c[0],N:c[1],R:c[2],T:c[3],g:o.tagName.toLowerCase(),v:o,m:null,p:null,S:null,j:null,h:null},t.push(u),o.removeAttribute("c-id"),e.p||(e.p=[]),e.p[u.T]=u,e=u,l&&"0"===u.R&&(l[u.T]=u.v))),a=o.childNodes.length-1;a>=0;a--)V(e,t,n,l,s,o.childNodes[a],i);if(o.shadowRoot)for(a=o.shadowRoot.childNodes.length-1;a>=0;a--)V(e,t,n,l,s,o.shadowRoot.childNodes[a],i)}else if(8===o.nodeType)c=o.nodeValue.split("."),c[1]!==i&&"0"!==c[1]||(r=c[0],u={t:0,D:c[1],N:c[2],R:c[3],T:c[4],v:o,m:null,p:null,S:null,j:null,g:null,h:null},"t"===r?(u.v=o.nextSibling,u.v&&3===u.v.nodeType&&(u.h=u.v.textContent,t.push(u),o.remove(),e.p||(e.p=[]),e.p[u.T]=u,l&&"0"===u.R&&(l[u.T]=u.v))):u.D===i&&"s"===r&&(u.g="slot",o["s-sn"]=c[5]?u.j=c[5]:"",o["s-sr"]=!0,n.push(u),e.p||(e.p=[]),e.p[u.T]=u));else if(e&&"style"===e.g){const t=p(null,o.textContent);t.v=o,t.T="0",e.p=[t]}},_=(e,t)=>{if(1===e.nodeType){let n=0;for(;n<e.childNodes.length;n++)_(e.childNodes[n],t);if(e.shadowRoot)for(n=0;n<e.shadowRoot.childNodes.length;n++)_(e.shadowRoot.childNodes[n],t)}else if(8===e.nodeType){const n=e.nodeValue.split(".");"o"===n[0]&&(t.set(n[1]+"."+n[2],e),e.nodeValue="",e["s-en"]=n[3])}},z=(e,t,n)=>{if(t.U){const l=Object.entries(t.U),o=e.prototype;if(l.map((([e,[l]])=>{31&l||2&n&&32&l?Object.defineProperty(o,e,{get(){return((e,t)=>Q(this).W.get(t))(0,e)},set(n){((e,t,n,l)=>{const s=Q(e),o=s.W.get(t),i=s.t,r=s.i;n=((e,t)=>null==e||h(e)?e:1&t?e+"":e)(n,l.U[t][0]),8&i&&void 0!==o||n===o||Number.isNaN(o)&&Number.isNaN(n)||(s.W.set(t,n),r&&2==(18&i)&&N(s,!1))})(this,e,n,t)},configurable:!0,enumerable:!0}):1&n&&64&l&&Object.defineProperty(o,e,{value(...t){const n=Q(this);return n.A.then((()=>n.i[e](...t)))}})})),1&n){const t=new Map;o.attributeChangedCallback=function(e,n,l){s.jmp((()=>{const n=t.get(e);if(this.hasOwnProperty(n))l=this[n],delete this[n];else if(o.hasOwnProperty(n)&&"number"==typeof this[n]&&this[n]==l)return;this[n]=(null!==l||"boolean"!=typeof this[n])&&l}))},e.observedAttributes=l.filter((([e,t])=>15&t[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))}}return e},B=e=>{if(0==(1&s.t)){const t=Q(e),n=t.C,o=()=>{};if(1&t.t)r(e,t,n.F);else{let o;t.t|=1,o=e.getAttribute("s-id"),o&&((e,t,n,o)=>{const i=e.shadowRoot,r=[],c=o.P=p(t,null);s.H||_(l.body,s.H=new Map),e["s-id"]=n,e.removeAttribute("s-id"),V(c,r,[],null,e,e,n),r.map((e=>{const n=e.D+"."+e.N,l=s.H.get(n),o=e.v;l&&""===l["s-en"]&&l.parentNode.insertBefore(o,l.nextSibling),i||(o["s-hn"]=t,l&&(o["s-ol"]=l,o["s-ol"]["s-nr"]=o)),s.H.delete(n)}))})(e,n.$,o,t);{let n=e;for(;n=n.parentNode||n.host;)if(1===n.nodeType&&n.hasAttribute("s-id")&&n["s-p"]||n["s-p"]){D(t,t.O=n);break}}n.U&&Object.entries(n.U).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,l,s)=>{if(0==(32&t.t)){{if(t.t|=32,(s=ne(n)).then){const e=()=>{};s=await s,e()}s.isProxied||(z(s,n,2),s.isProxied=!0);const e=()=>{};t.t|=8;try{new s(t)}catch(e){ee(e)}t.t&=-9,e()}if(s.style){let e=s.style;const t=f(n);if(!le.has(t)){const l=()=>{};((e,t,n)=>{let l=le.get(e);i&&n?(l=l||new CSSStyleSheet,l.replace(t)):l=t,le.set(e,l)})(t,e,!!(1&n.t)),l()}}}const o=t.O,r=()=>N(t,!0);o&&o["s-rc"]?o["s-rc"].push(r):r()})(0,t,n)}o()}},G=(e,t={})=>{const o=[],i=t.exclude||[],r=n.customElements,c=l.head,u=c.querySelector("meta[charset]"),a=l.createElement("style"),$=[];let f,d=!0;Object.assign(s,t),s.l=new URL(t.resourcesUrl||"./",l.baseURI).href,s.t|=2,e.map((e=>{e[1].map((t=>{const n={t:t[0],$:t[1],U:t[2],F:t[3]};n.U=t[2],n.F=t[3];const l=n.$,c=class extends HTMLElement{constructor(e){super(e),Y(e=this,n)}connectedCallback(){f&&(clearTimeout(f),f=null),d?$.push(this):s.jmp((()=>B(this)))}disconnectedCallback(){s.jmp((()=>(()=>{if(0==(1&s.t)){const e=Q(this);e.o&&(e.o.map((e=>e())),e.o=void 0)}})()))}componentOnReady(){return Q(this).q}};n.V=e[0],i.includes(l)||r.get(l)||(o.push(l),r.define(l,z(c,n,1)))}))})),a.innerHTML=o+"{visibility:hidden}.hydrated{visibility:inherit}",a.setAttribute("data-styles",""),c.insertBefore(a,u?u.nextSibling:c.firstChild),d=!1,$.length?$.map((e=>e.connectedCallback())):s.jmp((()=>f=setTimeout(A,30)))},J=(e,t)=>t,K=new WeakMap,Q=e=>K.get(e),X=(e,t)=>K.set(t.i=e,t),Y=(e,t)=>{const n={t:0,k:e,C:t,W:new Map};return n.A=new Promise((e=>n.L=e)),n.q=new Promise((e=>n.I=e)),e["s-p"]=[],e["s-rc"]=[],r(e,n,t.F),K.set(e,n)},Z=(e,t)=>t in e,ee=(e,t)=>(0,console.error)(e,t),te=new Map,ne=e=>{const t=e.$.replace(/-/g,"_"),n=e.V,l=te.get(n);return l?l[t]:import(`./${n}.entry.js`).then((e=>(te.set(n,e),e[t])),ee)},le=new Map,se=[],oe=[],ie=(e,n)=>l=>{e.push(l),t||(t=!0,n&&4&s.t?ue(ce):s.raf(ce))},re=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){ee(e)}e.length=0},ce=()=>{re(se),re(oe),(t=se.length>0)&&s.raf(ce)},ue=e=>o().then(e),ae=ie(oe,!0);export{J as F,y as H,G as b,I as c,m as h,o as p,X as r}