@prose-reader/core 0.0.49 → 0.0.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/createReaderWithEnhancer.d.ts +41 -41
- package/dist/index.d.ts +4 -3
- package/dist/prose.js +5504 -0
- package/dist/prose.js.map +1 -0
- package/dist/prose.umd.cjs +299 -0
- package/dist/prose.umd.cjs.map +1 -0
- package/dist/reader.d.ts +3 -3
- package/dist/spine/cfiLocator.d.ts +2 -2
- package/dist/spine/createSpine.d.ts +2 -2
- package/dist/spine/locationResolver.d.ts +4 -4
- package/dist/spineItem/createSpineItem.d.ts +1 -1
- package/dist/spineItemManager.d.ts +7 -7
- package/dist/types/index.d.ts +2 -2
- package/dist/utils/dom.d.ts +1 -1
- package/dist/viewportNavigator/manualViewportNavigator.d.ts +8 -8
- package/dist/viewportNavigator/panViewportNavigator.d.ts +1 -1
- package/package.json +18 -14
- package/dist/enhancers/firefox.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/utils/layout.test.d.ts +0 -1
- package/dist/utils/objects.test.d.ts +0 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
(function(K,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("rxjs"),require("@prose-reader/shared")):typeof define=="function"&&define.amd?define(["exports","rxjs","@prose-reader/shared"],v):(K=typeof globalThis<"u"?globalThis:K||self,v(K.prose={},K.rxjs,K["@prose-reader/shared"]))})(this,function(K,v,st){"use strict";const nn=e=>t=>{const n=e(t);return n.manipulateContainer(o=>{const i=()=>{n.context.getSettings().computedPageTurnMode==="controlled"&&o.scrollTo(0,0)};return o.addEventListener("scroll",i),!1}),n.registerHook("item.onLoad",({frame:o})=>{var i;(i=o.contentDocument)==null||i.body.setAttribute("tabindex","-1")}),n};function X(e){return typeof e=="function"}function on(e){return X(e==null?void 0:e.lift)}function G(e){return function(t){if(on(t))return t.lift(function(n){try{return e(n,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}var Le=function(e,t){return Le=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])},Le(e,t)};function oe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Le(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function rn(e,t,n,o){function i(r){return r instanceof n?r:new n(function(s){s(r)})}return new(n||(n=Promise))(function(r,s){function a(d){try{u(o.next(d))}catch(l){s(l)}}function c(d){try{u(o.throw(d))}catch(l){s(l)}}function u(d){d.done?r(d.value):i(d.value).then(a,c)}u((o=o.apply(e,t||[])).next())})}function at(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(u){return function(d){return c([u,d])}}function c(u){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(n=0)),n;)try{if(o=1,i&&(r=u[0]&2?i.return:u[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,u[1])).done)return r;switch(i=0,r&&(u=[u[0]&2,r.value]),u[0]){case 0:case 1:r=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,i=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(r=n.trys,!(r=r.length>0&&r[r.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!r||u[1]>r[0]&&u[1]<r[3])){n.label=u[1];break}if(u[0]===6&&n.label<r[1]){n.label=r[1],r=u;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(u);break}r[2]&&n.ops.pop(),n.trys.pop();continue}u=t.call(e,n)}catch(d){u=[6,d],i=0}finally{o=r=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function ge(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ie(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),i,r=[],s;try{for(;(t===void 0||t-- >0)&&!(i=o.next()).done;)r.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(s)throw s.error}}return r}function re(e,t,n){if(n||arguments.length===2)for(var o=0,i=t.length,r;o<i;o++)(r||!(o in t))&&(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function pe(e){return this instanceof pe?(this.v=e,this):new pe(e)}function sn(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(e,t||[]),i,r=[];return i={},s("next"),s("throw"),s("return"),i[Symbol.asyncIterator]=function(){return this},i;function s(f){o[f]&&(i[f]=function(g){return new Promise(function(y,b){r.push([f,g,y,b])>1||a(f,g)})})}function a(f,g){try{c(o[f](g))}catch(y){l(r[0][3],y)}}function c(f){f.value instanceof pe?Promise.resolve(f.value.v).then(u,d):l(r[0][2],f)}function u(f){a("next",f)}function d(f){a("throw",f)}function l(f,g){f(g),r.shift(),r.length&&a(r[0][0],r[0][1])}}function an(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ge=="function"?ge(e):e[Symbol.iterator](),n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n);function o(r){n[r]=e[r]&&function(s){return new Promise(function(a,c){s=e[r](s),i(a,c,s.done,s.value)})}}function i(r,s,a,c){Promise.resolve(c).then(function(u){r({value:u,done:a})},s)}}var ct=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};function ut(e){return X(e==null?void 0:e.then)}function lt(e){var t=function(o){Error.call(o),o.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var De=lt(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
|
+
`+n.map(function(o,i){return i+1+") "+o.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function we(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var ve=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,o,i,r;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=ge(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(b){t={error:b}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else s.remove(this);var d=this.initialTeardown;if(X(d))try{d()}catch(b){r=b instanceof De?b.errors:[b]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var f=ge(l),g=f.next();!g.done;g=f.next()){var y=g.value;try{gt(y)}catch(b){r=r??[],b instanceof De?r=re(re([],ie(r)),ie(b.errors)):r.push(b)}}}catch(b){o={error:b}}finally{try{g&&!g.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}}if(r)throw new De(r)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)gt(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&we(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&we(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),dt=ve.EMPTY;function ft(e){return e instanceof ve||e&&"closed"in e&&X(e.remove)&&X(e.add)&&X(e.unsubscribe)}function gt(e){X(e)?e():e.unsubscribe()}var _e={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Pe={setTimeout:function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var i=Pe.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,re([e,t],ie(n))):setTimeout.apply(void 0,re([e,t],ie(n)))},clearTimeout:function(e){var t=Pe.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function pt(e){Pe.setTimeout(function(){throw e})}function he(){}var cn=function(){return Me("C",void 0,void 0)}();function un(e){return Me("E",void 0,e)}function ln(e){return Me("N",e,void 0)}function Me(e,t,n){return{kind:e,value:t,error:n}}function Ie(e){e()}var Ve=function(e){oe(t,e);function t(n){var o=e.call(this)||this;return o.isStopped=!1,n?(o.destination=n,ft(n)&&n.add(o)):o.destination=pn,o}return t.create=function(n,o,i){return new be(n,o,i)},t.prototype.next=function(n){this.isStopped?Be(ln(n),this):this._next(n)},t.prototype.error=function(n){this.isStopped?Be(un(n),this):(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped?Be(cn,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ve),dn=Function.prototype.bind;function ke(e,t){return dn.call(e,t)}var fn=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(o){$e(o)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(o){$e(o)}else $e(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){$e(n)}},e}(),be=function(e){oe(t,e);function t(n,o,i){var r=e.call(this)||this,s;if(X(n)||!n)s={next:n??void 0,error:o??void 0,complete:i??void 0};else{var a;r&&_e.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return r.unsubscribe()},s={next:n.next&&ke(n.next,a),error:n.error&&ke(n.error,a),complete:n.complete&&ke(n.complete,a)}):s=n}return r.destination=new fn(s),r}return t}(Ve);function $e(e){pt(e)}function gn(e){throw e}function Be(e,t){var n=_e.onStoppedNotification;n&&Pe.setTimeout(function(){return n(e,t)})}var pn={closed:!0,next:he,error:gn,complete:he},ze=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Se(e){return e}function hn(e){return e.length===0?Se:e.length===1?e[0]:function(n){return e.reduce(function(o,i){return i(o)},n)}}var Q=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,o){var i=this,r=yn(t)?t:new be(t,n,o);return Ie(function(){var s=i,a=s.operator,c=s.source;r.add(a?a.call(r,c):c?i._subscribe(r):i._trySubscribe(r))}),r},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var o=this;return n=ht(n),new n(function(i,r){var s=new be({next:function(a){try{t(a)}catch(c){r(c),s.unsubscribe()}},error:r,complete:i});o.subscribe(s)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[ze]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return hn(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=ht(t),new t(function(o,i){var r;n.subscribe(function(s){return r=s},function(s){return i(s)},function(){return o(r)})})},e.create=function(t){return new e(t)},e}();function ht(e){var t;return(t=e??_e.Promise)!==null&&t!==void 0?t:Promise}function mn(e){return e&&X(e.next)&&X(e.error)&&X(e.complete)}function yn(e){return e&&e instanceof Ve||mn(e)&&ft(e)}function mt(e){return X(e[ze])}function yt(e){return Symbol.asyncIterator&&X(e==null?void 0:e[Symbol.asyncIterator])}function vt(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function vn(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var bt=vn();function St(e){return X(e==null?void 0:e[bt])}function wt(e){return sn(this,arguments,function(){var n,o,i,r;return at(this,function(s){switch(s.label){case 0:n=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,pe(n.read())];case 3:return o=s.sent(),i=o.value,r=o.done,r?[4,pe(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,pe(i)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Pt(e){return X(e==null?void 0:e.getReader)}function J(e){if(e instanceof Q)return e;if(e!=null){if(mt(e))return bn(e);if(ct(e))return Sn(e);if(ut(e))return wn(e);if(yt(e))return It(e);if(St(e))return Pn(e);if(Pt(e))return In(e)}throw vt(e)}function bn(e){return new Q(function(t){var n=e[ze]();if(X(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Sn(e){return new Q(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function wn(e){return new Q(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,pt)})}function Pn(e){return new Q(function(t){var n,o;try{for(var i=ge(e),r=i.next();!r.done;r=i.next()){var s=r.value;if(t.next(s),t.closed)return}}catch(a){n={error:a}}finally{try{r&&!r.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}t.complete()})}function It(e){return new Q(function(t){$n(e,t).catch(function(n){return t.error(n)})})}function In(e){return It(wt(e))}function $n(e,t){var n,o,i,r;return rn(this,void 0,void 0,function(){var s,a;return at(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=an(e),c.label=1;case 1:return[4,n.next()];case 2:if(o=c.sent(),!!o.done)return[3,4];if(s=o.value,t.next(s),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),o&&!o.done&&(r=n.return)?[4,r.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function q(e,t,n,o,i){return new Tn(e,t,n,o,i)}var Tn=function(e){oe(t,e);function t(n,o,i,r,s,a){var c=e.call(this,n)||this;return c.onFinalize=s,c.shouldUnsubscribe=a,c._next=o?function(u){try{o(u)}catch(d){n.error(d)}}:e.prototype._next,c._error=r?function(u){try{r(u)}catch(d){n.error(d)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;e.prototype.unsubscribe.call(this),!o&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t}(Ve),Cn=function(e){oe(t,e);function t(n,o){return e.call(this)||this}return t.prototype.schedule=function(n,o){return this},t}(ve),Te={setInterval:function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];var i=Te.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,re([e,t],ie(n))):setInterval.apply(void 0,re([e,t],ie(n)))},clearInterval:function(e){var t=Te.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},En=function(e){oe(t,e);function t(n,o){var i=e.call(this,n,o)||this;return i.scheduler=n,i.work=o,i.pending=!1,i}return t.prototype.schedule=function(n,o){var i;if(o===void 0&&(o=0),this.closed)return this;this.state=n;var r=this.id,s=this.scheduler;return r!=null&&(this.id=this.recycleAsyncId(s,r,o)),this.pending=!0,this.delay=o,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,o),this},t.prototype.requestAsyncId=function(n,o,i){return i===void 0&&(i=0),Te.setInterval(n.flush.bind(n,this),i)},t.prototype.recycleAsyncId=function(n,o,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return o;o!=null&&Te.clearInterval(o)},t.prototype.execute=function(n,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(n,o);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,o){var i=!1,r;try{this.work(n)}catch(s){i=!0,r=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,o=n.id,i=n.scheduler,r=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,we(r,this),o!=null&&(this.id=this.recycleAsyncId(i,o,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Cn),Ue={now:function(){return(Ue.delegate||Date).now()},delegate:void 0},$t=function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,o){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(o,n)},e.now=Ue.now,e}(),Fn=function(e){oe(t,e);function t(n,o){o===void 0&&(o=$t.now);var i=e.call(this,n,o)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(n){var o=this.actions;if(this._active){o.push(n);return}var i;this._active=!0;do if(i=n.execute(n.state,n.delay))break;while(n=o.shift());if(this._active=!1,i){for(;n=o.shift();)n.unsubscribe();throw i}},t}($t),We=new Fn(En),xn=We;function Tt(e){return e&&X(e.schedule)}function An(e){return e instanceof Date&&!isNaN(e)}function On(e,t,n){e===void 0&&(e=0),n===void 0&&(n=xn);var o=-1;return t!=null&&(Tt(t)?n=t:o=t),new Q(function(i){var r=An(e)?+e-n.now():e;r<0&&(r=0);var s=0;return n.schedule(function(){i.closed||(i.next(s++),0<=o?this.schedule(void 0,o):i.complete())},r)})}function Ct(e){return e[e.length-1]}function Nn(e){return X(Ct(e))?e.pop():void 0}function Et(e){return Tt(Ct(e))?e.pop():void 0}function ce(e,t,n,o,i){o===void 0&&(o=0),i===void 0&&(i=!1);var r=t.schedule(function(){n(),i?e.add(this.schedule(null,o)):this.unsubscribe()},o);if(e.add(r),!i)return r}function Ce(e){return G(function(t,n){var o=null,i=!1,r;o=t.subscribe(q(n,void 0,void 0,function(s){r=J(e(s,Ce(e)(t))),o?(o.unsubscribe(),o=null,r.subscribe(n)):i=!0})),i&&(o.unsubscribe(),o=null,r.subscribe(n))})}function Ft(e,t){return t===void 0&&(t=0),G(function(n,o){n.subscribe(q(o,function(i){return ce(o,e,function(){return o.next(i)},t)},function(){return ce(o,e,function(){return o.complete()},t)},function(i){return ce(o,e,function(){return o.error(i)},t)}))})}function xt(e,t){return t===void 0&&(t=0),G(function(n,o){o.add(e.schedule(function(){return n.subscribe(o)},t))})}function Rn(e,t){return J(e).pipe(xt(t),Ft(t))}function Ln(e,t){return J(e).pipe(xt(t),Ft(t))}function Dn(e,t){return new Q(function(n){var o=0;return t.schedule(function(){o===e.length?n.complete():(n.next(e[o++]),n.closed||this.schedule())})})}function _n(e,t){return new Q(function(n){var o;return ce(n,t,function(){o=e[bt](),ce(n,t,function(){var i,r,s;try{i=o.next(),r=i.value,s=i.done}catch(a){n.error(a);return}s?n.complete():n.next(r)},0,!0)}),function(){return X(o==null?void 0:o.return)&&o.return()}})}function At(e,t){if(!e)throw new Error("Iterable cannot be null");return new Q(function(n){ce(n,t,function(){var o=e[Symbol.asyncIterator]();ce(n,t,function(){o.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function Mn(e,t){return At(wt(e),t)}function Vn(e,t){if(e!=null){if(mt(e))return Rn(e,t);if(ct(e))return Dn(e,t);if(ut(e))return Ln(e,t);if(yt(e))return At(e,t);if(St(e))return _n(e,t);if(Pt(e))return Mn(e,t)}throw vt(e)}function kn(e,t){return t?Vn(e,t):J(e)}function B(e,t){return G(function(n,o){var i=0;n.subscribe(q(o,function(r){o.next(e.call(t,r,i++))}))})}function Bn(e,t,n,o,i,r,s,a){var c=[],u=0,d=0,l=!1,f=function(){l&&!c.length&&!u&&t.complete()},g=function(b){return u<o?y(b):c.push(b)},y=function(b){r&&t.next(b),u++;var w=!1;J(n(b,d++)).subscribe(q(t,function(p){i==null||i(p),r?g(p):t.next(p)},function(){w=!0},void 0,function(){if(w)try{u--;for(var p=function(){var F=c.shift();s?ce(t,s,function(){return y(F)}):y(F)};c.length&&u<o;)p();f()}catch(F){t.error(F)}}))};return e.subscribe(q(t,g,function(){l=!0,f()})),function(){a==null||a()}}function se(e,t,n){return n===void 0&&(n=1/0),X(t)?se(function(o,i){return B(function(r,s){return t(o,r,i,s)})(J(e(o,i)))},n):(typeof t=="number"&&(n=t),G(function(o,i){return Bn(o,i,e,n)}))}function zn(e){return e===void 0&&(e=1/0),se(Se,e)}function Un(){return zn(1)}var Wn=lt(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),He=function(e){oe(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var o=new Ot(this,this);return o.operator=n,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new Wn},t.prototype.next=function(n){var o=this;Ie(function(){var i,r;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var s=ge(o.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(n)}}catch(u){i={error:u}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(n){var o=this;Ie(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=n;for(var i=o.observers;i.length;)i.shift().error(n)}})},t.prototype.complete=function(){var n=this;Ie(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var o=n.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var o=this,i=this,r=i.hasError,s=i.isStopped,a=i.observers;return r||s?dt:(this.currentObservers=null,a.push(n),new ve(function(){o.currentObservers=null,we(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var o=this,i=o.hasError,r=o.thrownError,s=o.isStopped;i?n.error(r):s&&n.complete()},t.prototype.asObservable=function(){var n=new Q;return n.source=this,n},t.create=function(n,o){return new Ot(n,o)},t}(Q),Ot=function(e){oe(t,e);function t(n,o){var i=e.call(this)||this;return i.destination=n,i.source=o,i}return t.prototype.next=function(n){var o,i;(i=(o=this.destination)===null||o===void 0?void 0:o.next)===null||i===void 0||i.call(o,n)},t.prototype.error=function(n){var o,i;(i=(o=this.destination)===null||o===void 0?void 0:o.error)===null||i===void 0||i.call(o,n)},t.prototype.complete=function(){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||o===void 0||o.call(n)},t.prototype._subscribe=function(n){var o,i;return(i=(o=this.source)===null||o===void 0?void 0:o.subscribe(n))!==null&&i!==void 0?i:dt},t}(He);function Hn(e){return G(function(t,n){var o=!1,i=null,r=null,s=function(){if(r==null||r.unsubscribe(),r=null,o){o=!1;var a=i;i=null,n.next(a)}};t.subscribe(q(n,function(a){r==null||r.unsubscribe(),o=!0,i=a,r=q(n,s,he),J(e(a)).subscribe(r)},function(){s(),n.complete()},void 0,function(){i=r=null}))})}function je(e,t){return t===void 0&&(t=We),G(function(n,o){var i=null,r=null,s=null,a=function(){if(i){i.unsubscribe(),i=null;var u=r;r=null,o.next(u)}};function c(){var u=s+e,d=t.now();if(d<u){i=this.schedule(void 0,u-d),o.add(i);return}a()}n.subscribe(q(o,function(u){r=u,s=t.now(),i||(i=t.schedule(c,e),o.add(i))},function(){a(),o.complete()},void 0,function(){r=i=null}))})}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Un()(kn(e,Et(e)))}var jn=new Q(function(e){return e.complete()});function le(e){return e<=0?function(){return jn}:G(function(t,n){var o=0;t.subscribe(q(n,function(i){++o<=e&&(n.next(i),e<=o&&n.complete())}))})}function Yn(){return G(function(e,t){e.subscribe(q(t,he))})}function de(e){return B(function(){return e})}function Nt(e,t){return t?function(n){return Ye(t.pipe(le(1),Yn()),n.pipe(Nt(e)))}:se(function(n,o){return J(e(n,o)).pipe(le(1),de(n))})}function Xe(e,t){t===void 0&&(t=We);var n=On(e,t);return Nt(function(){return n})}function Z(e,t){return t===void 0&&(t=Se),e=e??Xn,G(function(n,o){var i,r=!0;n.subscribe(q(o,function(s){var a=t(s);(r||!e(i,a))&&(r=!1,i=a,o.next(s))}))})}function Xn(e,t){return e===t}function j(e,t){return G(function(n,o){var i=0;n.subscribe(q(o,function(r){return e.call(t,r,i++)&&o.next(r)}))})}function Rt(e,t){return t?function(n){return n.pipe(Rt(function(o,i){return J(e(o,i)).pipe(B(function(r,s){return t(o,r,i,s)}))}))}:G(function(n,o){var i=0,r=null,s=!1;n.subscribe(q(o,function(a){r||(r=q(o,void 0,function(){r=null,s&&o.complete()}),J(e(a,i++)).subscribe(r))},function(){s=!0,!r&&o.complete()}))})}function Lt(){return G(function(e,t){var n,o=!1;e.subscribe(q(t,function(i){var r=n;n=i,o&&t.next([r,i]),o=!0}))})}var qn=function(e){oe(t,e);function t(n,o,i){n===void 0&&(n=1/0),o===void 0&&(o=1/0),i===void 0&&(i=Ue);var r=e.call(this)||this;return r._bufferSize=n,r._windowTime=o,r._timestampProvider=i,r._buffer=[],r._infiniteTimeWindow=!0,r._infiniteTimeWindow=o===1/0,r._bufferSize=Math.max(1,n),r._windowTime=Math.max(1,o),r}return t.prototype.next=function(n){var o=this,i=o.isStopped,r=o._buffer,s=o._infiniteTimeWindow,a=o._timestampProvider,c=o._windowTime;i||(r.push(n),!s&&r.push(a.now()+c)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var o=this._innerSubscribe(n),i=this,r=i._infiniteTimeWindow,s=i._buffer,a=s.slice(),c=0;c<a.length&&!n.closed;c+=r?1:2)n.next(a[c]);return this._checkFinalizedStatuses(n),o},t.prototype._trimBuffer=function(){var n=this,o=n._bufferSize,i=n._timestampProvider,r=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*o;if(o<1/0&&a<r.length&&r.splice(0,r.length-a),!s){for(var c=i.now(),u=0,d=1;d<r.length&&r[d]<=c;d+=2)u=d;u&&r.splice(0,u+1)}},t}(He);function ee(e){e===void 0&&(e={});var t=e.connector,n=t===void 0?function(){return new He}:t,o=e.resetOnError,i=o===void 0?!0:o,r=e.resetOnComplete,s=r===void 0?!0:r,a=e.resetOnRefCountZero,c=a===void 0?!0:a;return function(u){var d,l,f,g=0,y=!1,b=!1,w=function(){l==null||l.unsubscribe(),l=void 0},p=function(){w(),d=f=void 0,y=b=!1},F=function(){var N=d;p(),N==null||N.unsubscribe()};return G(function(N,$){g++,!b&&!y&&w();var P=f=f??n();$.add(function(){g--,g===0&&!b&&!y&&(l=qe(F,c))}),P.subscribe($),!d&&g>0&&(d=new be({next:function(m){return P.next(m)},error:function(m){b=!0,w(),l=qe(p,i,m),P.error(m)},complete:function(){y=!0,w(),l=qe(p,s),P.complete()}}),J(N).subscribe(d))})(u)}}function qe(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];if(t===!0){e();return}if(t!==!1){var i=new be({next:function(){i.unsubscribe(),e()}});return J(t.apply(void 0,re([],ie(n)))).subscribe(i)}}function Ge(e,t,n){var o,i,r,s,a=!1;return e&&typeof e=="object"?(o=e.bufferSize,s=o===void 0?1/0:o,i=e.windowTime,t=i===void 0?1/0:i,r=e.refCount,a=r===void 0?!1:r,n=e.scheduler):s=e??1/0,ee({connector:function(){return new qn(s,t,n)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:a})}function Ee(e){return j(function(t,n){return e<=n})}function Ze(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Et(e);return G(function(o,i){(n?Ye(e,o,n):Ye(e,o)).subscribe(i)})}function H(e,t){return G(function(n,o){var i=null,r=0,s=!1,a=function(){return s&&!i&&o.complete()};n.subscribe(q(o,function(c){i==null||i.unsubscribe();var u=0,d=r++;J(e(c,d)).subscribe(i=q(o,function(l){return o.next(t?t(c,l,d,u++):l)},function(){i=null,a()}))},function(){s=!0,a()}))})}function k(e){return G(function(t,n){J(e).subscribe(q(n,function(){return n.complete()},he)),!n.closed&&t.subscribe(n)})}function W(e,t,n){var o=X(e)||t||n?{next:e,error:t,complete:n}:e;return o?G(function(i,r){var s;(s=o.subscribe)===null||s===void 0||s.call(o);var a=!0;i.subscribe(q(r,function(c){var u;(u=o.next)===null||u===void 0||u.call(o,c),r.next(c)},function(){var c;a=!1,(c=o.complete)===null||c===void 0||c.call(o),r.complete()},function(c){var u;a=!1,(u=o.error)===null||u===void 0||u.call(o,c),r.error(c)},function(){var c,u;a&&((c=o.unsubscribe)===null||c===void 0||c.call(o)),(u=o.finalize)===null||u===void 0||u.call(o)}))}):Se}function te(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Nn(e);return G(function(o,i){for(var r=e.length,s=new Array(r),a=e.map(function(){return!1}),c=!1,u=function(l){J(e[l]).subscribe(q(i,function(f){s[l]=f,!c&&!a[l]&&(a[l]=!0,(c=a.every(Se))&&(a=null))},he))},d=0;d<r;d++)u(d);o.subscribe(q(i,function(l){if(c){var f=re([l],ie(s));i.next(n?n.apply(void 0,re([],ie(f))):f)}}))})}const Gn=e=>({fontScale:t=1,lineHeight:n="publisher",fontWeight:o="publisher",fontJustification:i="publisher",...r})=>{const s=new v.BehaviorSubject({fontScale:t,lineHeight:n,fontWeight:o,fontJustification:i}),a=e(r),c=()=>`
|
|
4
|
+
|
|
5
|
+
body {
|
|
6
|
+
${s.value.fontScale!==1?`font-size: ${s.value.fontScale}em !important;`:""}
|
|
7
|
+
${s.value.lineHeight!=="publisher"?`line-height: ${s.value.lineHeight} !important;`:""}
|
|
8
|
+
${s.value.fontWeight!=="publisher"?`font-weight: ${s.value.fontWeight} !important;`:""}
|
|
9
|
+
${s.value.fontJustification!=="publisher"?`text-align: ${s.value.fontJustification} !important;`:""}
|
|
10
|
+
}
|
|
11
|
+
`,u=l=>{a.manipulateSpineItems(({removeStyle:f,addStyle:g,item:y})=>(y.renditionLayout!=="pre-paginated"&&(f("prose-reader-fonts"),g("prose-reader-fonts",c())),l))};a.registerHook("item.onLoad",({removeStyle:l,addStyle:f,item:g})=>{g.renditionLayout!=="pre-paginated"&&(l("prose-reader-fonts"),f("prose-reader-fonts",c()))});const d=l=>l.pipe(Lt(),v.map(([f,g])=>g.fontScale!==f.fontScale||g.lineHeight!==f.lineHeight));return s.asObservable().pipe(d,W(u),v.takeUntil(a.$.destroy$)).subscribe(),{...a,setSettings:l=>{const{fontJustification:f=s.value.fontJustification,fontScale:g=s.value.fontScale,fontWeight:y=s.value.fontWeight,lineHeight:b=s.value.lineHeight,...w}=l;Zn(l,["fontJustification","fontScale","fontWeight","lineHeight"])&&s.next({fontJustification:f,fontScale:g,fontWeight:y,lineHeight:b}),a.setSettings(w)},$:{...a.$,settings$:v.combineLatest([a.$.settings$,s]).pipe(v.map(([l,f])=>({...l,...f})))}}},Zn=(e,t)=>t.some(n=>n in e),Jn=e=>t=>{const n=e(t),o=r=>{r.key==="ArrowRight"&&n.turnRight(),r.key==="ArrowLeft"&&n.turnLeft()};return document.addEventListener("keyup",o),n.registerHook("item.onLoad",({frame:r})=>{var s;return(s=r.contentDocument)==null||s.addEventListener("keyup",o),()=>{var a;(a=r.contentDocument)==null||a.removeEventListener("keyup",o)}}),{...n,destroy:()=>{document.removeEventListener("keyup",o),n.destroy()}}},Kn=!1,Qn=e=>{let t;e.manipulateContainer(u=>(t=u.ownerDocument.createElement("div"),t.style.cssText=`
|
|
12
|
+
position: absolute;
|
|
13
|
+
left: 0;
|
|
14
|
+
top: 0;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
visibility: hidden;
|
|
18
|
+
`,u.appendChild(t),Kn));const n=u=>v.scheduled(u,v.animationFrameScheduler).pipe(W(()=>{t==null||t.style.setProperty("visibility","hidden")})),o=e.$.viewportState$.pipe(j(u=>u==="free")),r=e.$.viewportState$.pipe(j(u=>u==="busy")).pipe(W(()=>{t==null||t.style.setProperty("visibility","visible")})),s=n(o).pipe(le(1));return e.context.$.settings$.pipe(B(()=>e.context.getSettings().computedPageTurnMode),Z()).pipe(H(u=>u==="controlled"?r.pipe(H(()=>s)):n(v.of(void 0))),k(e.$.destroy$))},Dt=e=>B(t=>Object.entries(t).reduce((n,[o,i])=>e.includes(o)?{...n,[o]:i}:n,{})),eo=Object.prototype.hasOwnProperty,to=(e,t)=>e===t?e!==0||t!==0||1/e===1/t:!1,ne=(e,t,n)=>{if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;const r=n&&typeof n.customEqual=="function"?n.customEqual:to;for(let s=0;s<o.length;s++){const a=o[s]||"";if(!eo.call(t,a)||!r(e[a],t[a]))return!1}return!0},no=(e,t)=>e.reduce((n,o)=>{const i=t(o);return n[i]||(n[i]=[]),n[i].push(o),n},{}),oo=e=>{const t=new FileReader;return new Promise(n=>{t.addEventListener("load",function(){n(t.result)},!1),t.readAsDataURL(e)})},io=e=>{e.registerHook("item.onAfterLayout",({item:t,blankPagePosition:n,minimumWidth:o})=>{var c;const i=e.getSpineItem(t.id);if((i==null?void 0:i.item.renditionLayout)!=="reflowable")return;const{viewportDimensions:r}=(i==null?void 0:i.getViewPortInformation())??{},{width:s}=e.context.getPageSize(),a=(c=i==null?void 0:i.spineItemFrame.getManipulableFrame())==null?void 0:c.frame;if(r){const u=s<o;n==="none"&&u&&(a==null||a.style.setProperty("left",e.context.isRTL()?"75%":"25%"))}})},ro=!1,so=e=>({pageHorizontalMargin:t=24,pageVerticalMargin:n=24,...o})=>{const i=e(o),r=new v.BehaviorSubject({pageHorizontalMargin:t,pageVerticalMargin:n});i.registerHook("onViewportOffsetAdjust",()=>{let c=!1;i.manipulateSpineItems(({frame:u})=>(!c&&u&&(u.getBoundingClientRect().left,c=!0),ro))}),i.registerHook("item.onLayoutBeforeMeasurement",({frame:c,minimumWidth:u,item:d,isImageType:l})=>{var b,w;const{pageHorizontalMargin:f=0,pageVerticalMargin:g=0}=r.value,y=i.context.getPageSize();if(d.renditionLayout==="reflowable"&&c.getIsReady()&&!l()&&!c.getViewportDimensions()){let p=y.width-f*2;const F=y.height-g*2;let N=y.width-f*2,$=f*2;c.isUsingVerticalWriting()&&(N=u-f*2,p=F,$=g*2),(b=c.getManipulableFrame())==null||b.removeStyle("prose-layout-enhancer-css"),(w=c.getManipulableFrame())==null||w.addStyle("prose-layout-enhancer-css",`
|
|
19
|
+
body {
|
|
20
|
+
width: ${N}px !important;
|
|
21
|
+
margin: ${g}px ${f}px !important;
|
|
22
|
+
column-gap: ${$}px !important;
|
|
23
|
+
column-width: ${p}px !important;
|
|
24
|
+
height: ${F}px !important;
|
|
25
|
+
}
|
|
26
|
+
img, video, audio, object, svg {
|
|
27
|
+
max-width: ${p}px !important;
|
|
28
|
+
max-height: ${F}px !important;
|
|
29
|
+
}
|
|
30
|
+
table {
|
|
31
|
+
max-width: ${p}px !important;
|
|
32
|
+
}
|
|
33
|
+
td {
|
|
34
|
+
max-width: ${p}px;
|
|
35
|
+
}
|
|
36
|
+
`)}}),io(i);let s;return o.layoutAutoResize==="container"&&(s=new ResizeObserver(()=>{i==null||i.layout()}),s.observe(o.containerElement)),Qn(i).subscribe(),r.pipe(Dt(["pageHorizontalMargin","pageVerticalMargin"]),Z(ne),Ee(1),W(()=>{i.layout()}),k(i.$.destroy$)).subscribe(),{...i,destroy:()=>{i.destroy(),s==null||s.disconnect()},setSettings:({pageVerticalMargin:c,pageHorizontalMargin:u,...d})=>{(u!==void 0||c!==void 0)&&r.next({pageHorizontalMargin:u??r.value.pageHorizontalMargin,pageVerticalMargin:c??r.value.pageVerticalMargin}),i.setSettings(d)},$:{...i.$,settings$:v.combineLatest([i.$.settings$,r.asObservable()]).pipe(B(([c,u])=>({...c,...u})))}}},Fe="@prose-reader/core",me=e=>`[${e}]`,ao=(e,t=0)=>{let n=0;const o=performance.now();return()=>{n++;const i=performance.now();L.logMetric({name:`${e} - tick ${n}`,duration:i-o},t)}},_t=e=>({log:(...t)=>{window.__PROSE_READER_DEBUG&&(e?console.log(me(Fe),me(e),...t):console.log(me(Fe),...t))},warn:(...t)=>{window.__PROSE_READER_DEBUG&&(e?console.warn(me(Fe),me(e),...t):console.warn(me(Fe),...t))},error:(...t)=>{console.error(...t)},time:ao,logMetric:(t,n=0)=>{window.__PROSE_READER_DEBUG&&(t.duration<=n||console.warn("[prose-reader] [metric] ",`${t.name} took ${t.duration}ms which is above the ${n}ms target for this function`))},measurePerformance:(t,n=10,o,{disable:i}={})=>i||!window.__PROSE_READER_DEBUG?o:(...r)=>{const s=performance.now(),a=o(...r);if(a&&a.then)return a.then(u=>{const d=performance.now();return L.logMetric({name:t,duration:d-s},n),u});const c=performance.now();return L.logMetric({name:t,duration:c-s},n),a}}),L={..._t(),namespace:e=>_t(e)},co=e=>t=>{const n=e(t),o=new v.Subject,i=r=>{var u;if(!r.href)return;const s=new URL(r.href),a=`${s.origin}${s.pathname}`;((u=n.context.getManifest())==null?void 0:u.spineItems.some(d=>d.href===a))&&n.goToUrl(s)};return n.registerHook("item.onLoad",({frame:r})=>{r.contentDocument&&Array.from(r.contentDocument.querySelectorAll("a")).forEach(s=>s.addEventListener("click",a=>{a.target&&"style"in a.target&&"ELEMENT_NODE"in a.target&&(L.warn("prevented click on",s,a),a.preventDefault(),i(s),o.next({event:"linkClicked",data:s}))}))}),{...n,$:{...n.$,links$:o.asObservable()}}},uo=e=>t=>{const n=e(t),o=()=>{var u;const r=n.getFocusedSpineItemIndex()||0,{end:s=r}=n.locator.getSpineItemsFromReadingOrderPosition(n.getCurrentNavigationPosition())||{},a=((u=n.context.getManifest())==null?void 0:u.spineItems.length)??0,c=s+1;c<a&&n.goToSpineItem(c)},i=()=>{const r=n.getFocusedSpineItemIndex()||0,{begin:s=r}=n.locator.getSpineItemsFromReadingOrderPosition(n.getCurrentNavigationPosition())||{},a=s-1;a>=0&&n.goToSpineItem(a)};return{...n,goToLeftSpineItem:()=>n.context.isRTL()?o():i(),goToRightSpineItem:()=>n.context.isRTL()?i():o()}},lo="pagination",fo=({context:e})=>{const t=new v.BehaviorSubject({beginPageIndex:void 0,beginNumberOfPages:0,beginCfi:void 0,beginSpineItemIndex:void 0,endPageIndex:void 0,endNumberOfPages:0,endCfi:void 0,endSpineItemIndex:void 0}),n=c=>{const u=c.spineItemFrame.getWritingMode(),{width:d,height:l}=c.getElementDimensions();return u==="vertical-rl"?ae(l,e.getPageSize().height):ae(d,e.getPageSize().width)},o=c=>({numberOfPages:n(c.spineItem),pageIndex:c.pageIndex,cfi:c.cfi}),i=L.measurePerformance(`${lo} updateBeginAndEnd`,1,(c,u)=>{const d=o(c),l=o(u),f={beginPageIndex:d.pageIndex,beginNumberOfPages:d.numberOfPages,beginCfi:d.cfi,beginSpineItemIndex:c.spineItemIndex,endPageIndex:l.pageIndex,endNumberOfPages:l.numberOfPages,endCfi:l.cfi,endSpineItemIndex:u.spineItemIndex};t.next({...t.value,...f})},{disable:!0}),r=()=>t.value,s=t.asObservable().pipe(v.distinctUntilChanged(ne));return{destroy:()=>{t.complete()},updateBeginAndEnd:i,getInfo:r,$:{info$:s}}},Mt=(e,t,n)=>{const o=n-e,i=n*(t*e)/n;return Math.max(0,Math.min(o,i))},ae=(e,t)=>(t||0)===0||(e||0)===0?1:Math.floor(Math.max(1,e/t)),xe=(e,t,n)=>{const o=ae(n,t),i=[...Array(o)].map((r,s)=>s*t);return e>=o*t?i[i.length-1]||0:i.find(r=>e<r+t)||0},go="paginationEnhancer",po=L.namespace(go),ho=e=>t=>{const n=e(t),o={},i=l=>{const f=n.context.getManifest();return l&&f&&mo(f,l)},r=l=>{const f=n.context,g=l.beginSpineItemIndex!==void 0?n.getSpineItem(l.beginSpineItemIndex):void 0,y=l.endSpineItemIndex!==void 0?n.getSpineItem(l.endSpineItemIndex):void 0;return{beginPageIndexInChapter:l.beginPageIndex,beginNumberOfPagesInChapter:l.beginNumberOfPages,beginChapterInfo:g?o[g.item.id]:void 0,beginSpineItemIndex:l.beginSpineItemIndex,beginCfi:l.beginCfi,beginSpineItemReadingDirection:g==null?void 0:g.getReadingDirection(),endChapterInfo:y?o[y.item.id]:void 0,endPageIndexInChapter:l.endPageIndex,endNumberOfPagesInChapter:l.endNumberOfPages,endSpineItemIndex:l.endSpineItemIndex,endSpineItemReadingDirection:y==null?void 0:y.getReadingDirection(),endCfi:l.endCfi,percentageEstimateOfBook:y?n.progression.getPercentageEstimate(f,l.endSpineItemIndex??0,l.endNumberOfPages,l.endPageIndex||0,n.getCurrentViewportPosition(),y):0,isUsingSpread:f.shouldDisplaySpread()}},s=l=>{const f=l.spineItemFrame.getWritingMode(),{width:g,height:y}=l.getElementDimensions(),b=n.context.getSettings();return b.pageTurnDirection==="vertical"&&b.pageTurnMode==="scrollable"?1:f==="vertical-rl"?ae(y,n.context.getPageSize().height):ae(g,n.context.getPageSize().width)},a=()=>n.getSpineItems().map(l=>s(l),0);n.$.itemsCreated$.pipe(W(l=>l.forEach(({item:f})=>{o[f.id]=i(f)})),k(n.$.destroy$)).subscribe();const c=n.$.pagination$.pipe(B(r),Z(ne)),u=n.$.layout$.pipe(je(10,v.animationFrameScheduler),te(n.$.pagination$),B(()=>{const l=a();return{numberOfPagesPerItems:l,numberOfTotalPages:l.reduce((f,g)=>f+g,0)}}),Z(ne),Ze({numberOfPagesPerItems:[],numberOfTotalPages:0})),d=v.combineLatest([c,u]).pipe(B(([l,f])=>({...l,...f,beginAbsolutePageIndex:f.numberOfPagesPerItems.slice(0,l.beginSpineItemIndex).reduce((g,y)=>g+y,l.beginPageIndexInChapter??0),endAbsolutePageIndex:f.numberOfPagesPerItems.slice(0,l.endSpineItemIndex).reduce((g,y)=>g+y,l.endPageIndexInChapter??0)})),W(l=>{po.log("pagination",l)}),Ge(1),k(n.$.destroy$));return{...n,$:{...n.$,pagination$:d}}},mo=(e,t)=>{const{path:n}=t;return Vt(n,e.nav.toc)},Vt=(e,t)=>t.reduce((n,o)=>{const i=o.path.indexOf("#"),r=i>0?o.path.substr(0,i):o.path;if(e.endsWith(r))return{title:o.title,path:o.path};const s=Vt(e,o.contents);return s?{subChapter:s,title:o.title,path:o.path}:n},void 0),kt=[{name:"bright",backgroundColor:"white"},{name:"sepia",backgroundColor:"#eaddc7",foregroundColor:"black"},{name:"night",backgroundColor:"#191717",foregroundColor:"#f1ebeb"}],yo=e=>t=>{const n=e(t),o=new v.BehaviorSubject(t.theme??"bright"),i=()=>{const a=kt.find(c=>c.name===o.value);return`
|
|
37
|
+
body {
|
|
38
|
+
${a!==void 0?`background-color: ${a.backgroundColor} !important;`:""}
|
|
39
|
+
}
|
|
40
|
+
${a!=null&&a.foregroundColor?`
|
|
41
|
+
body * {
|
|
42
|
+
|
|
43
|
+
color: ${a.foregroundColor};
|
|
44
|
+
}
|
|
45
|
+
`:""}
|
|
46
|
+
`},r=({container:a})=>{const c=kt.find(u=>u.name===o.value);return c&&a.style.setProperty("background-color",c.backgroundColor),()=>{}},s=()=>{n.manipulateSpineItems(({removeStyle:a,addStyle:c,container:u})=>(a("prose-reader-theme"),c("prose-reader-theme",i()),r({container:u}),!1))};return n.registerHook("item.onLoad",({removeStyle:a,addStyle:c})=>{a("prose-reader-theme"),c("prose-reader-theme",i())}),n.$.itemsCreated$.pipe(W(a=>a.map(({element:c})=>r({container:c}))),k(n.$.destroy$)).subscribe(),o.pipe(W(()=>{s()}),k(n.$.destroy$)).subscribe(),{...n,theme:{set:a=>{a!==o.value&&o.next(a)},get:()=>o.value,$:{theme$:o.asObservable()}}}};function Bt(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,n)=>(...o)=>n(t(...o)))}function Je(...e){return Bt(...e)}const zt=!1,vo=e=>{const t=new v.BehaviorSubject(!1);let n,o={x:0,y:0},i={x:0,y:0},r=1,s=1;const a=y=>{t.next(!0),o={x:0,y:0},r=1,s=1,e.manipulateContainer(b=>{n=b.ownerDocument.createElement("div"),n.style.cssText=`
|
|
47
|
+
top: 0;
|
|
48
|
+
left: 0;
|
|
49
|
+
display: block;
|
|
50
|
+
position: absolute;
|
|
51
|
+
z-index: 1;
|
|
52
|
+
background: black;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
`;const w=y.cloneNode();return w.src=y.src,w.style.setProperty("height","100%"),w.style.setProperty("width","100%"),w.style.setProperty("object-fit","contain"),w.style.setProperty("pointer-events","none"),n.appendChild(w),b.appendChild(n),zt}),u(1.2),c()},c=()=>{r=s},u=y=>{const b=n==null?void 0:n.querySelector("img"),w=Math.ceil((y<1?r-(1-y):r+(y-1))*100)/100,p=Math.max(w,1);w<1&&(o={x:0,y:0}),b==null||b.style.setProperty("transform",`translate3d(${o.x}px, ${o.y}px, 0px) scale3d(${p}, ${p}, 1)`),s=p};return{enter:a,exit:()=>{s=1,e.manipulateContainer(()=>(n==null||n.remove(),n=void 0,zt)),t.next(!1)},move:(y,{isFirst:b,isLast:w})=>{const p=n==null?void 0:n.querySelector("img");if(b&&(i={x:0,y:0}),y){const F=y.x-((i==null?void 0:i.x)||0),N=y.y-((i==null?void 0:i.y)||0);o={x:o.x+F,y:o.y+N},p==null||p.style.setProperty("transform",`translate3d(${o.x}px, ${o.y}px, 0px) scale3d(${r}, ${r}, 1)`),i=y}w&&(i=void 0)},scale:u,setCurrentScaleAsBase:c,getScaleValue:()=>s,isZooming:()=>t.value,destroy:()=>{n==null||n.remove(),n=void 0,t.complete()},isZooming$:t.asObservable()}},Ae=({newScale:e,oldScale:t,screenSize:n,scrollOffset:o})=>{const i=n*e/2-n+n/2,r=n*t/2-n+n/2,s=e/t,a=o-r;return Math.max(i+a*s,0)},bo=e=>{const t=new v.BehaviorSubject(!1);let n=1,o=1;const i=()=>{a(0-n),o=1,n=1},r=()=>{i(),e.spine.element.style.transformOrigin="0 0",t.next(!0),a(1),s()},s=()=>{n=o},a=f=>{const g=Math.ceil((f<1?n-(1-f):n+(f-1))*100)/100,y=Math.max(g,1),b=e.spine.element.getBoundingClientRect().width/e.spine.element.offsetWidth,w=e.viewportNavigator.element.scrollTop;e.spine.element.style.transform=`scale(${y})`,e.viewportNavigator.element.scrollLeft=Ae({newScale:y,oldScale:b,pageSize:e.viewportNavigator.element.clientWidth,screenSize:e.spine.element.offsetWidth,scrollOffset:e.viewportNavigator.element.scrollLeft}),e.viewportNavigator.element.scrollTop=Ae({newScale:y,oldScale:b,pageSize:e.viewportNavigator.element.clientHeight,screenSize:e.spine.element.offsetHeight,scrollOffset:w}),o=y};return{enter:r,exit:()=>{i(),t.next(!1)},move:(f,g)=>{},scale:a,setCurrentScaleAsBase:s,getScaleValue:()=>o,isZooming:()=>t.value,destroy:()=>{t.complete()},isZooming$:t.asObservable()}},So=e=>t=>{const n=e(t),o=vo(n),i=bo(n),r=new v.BehaviorSubject(void 0),s=()=>n.context.getSettings().computedPageTurnMode==="scrollable";return{...n,destroy:()=>{o.destroy(),i.destroy(),r.complete(),n.destroy()},zoom:{enter:g=>{var y;if((y=r==null?void 0:r.value)==null||y.exit(),s()){i.enter(),r==null||r.next(i);return}if(!g){L.warn("You should specify an element to zoom at");return}o.enter(g),r==null||r.next(o)},exit:()=>{var g;(g=r.value)==null||g.exit()},move:(g,y)=>{var b;(b=r.value)==null||b.move(g,y)},isZooming:()=>{var g;return((g=r.value)==null?void 0:g.isZooming())||!1},getScaleValue:()=>{var g;return((g=r.value)==null?void 0:g.getScaleValue())||1},scale:g=>{var y;if(!((y=r.value)!=null&&y.isZooming())){L.warn("You need to start zoom before being able to call this fn");return}r.value.scale(g)},isUsingScrollableZoom:s,setCurrentScaleAsBase:()=>{var g;(g=r.value)==null||g.setCurrentScaleAsBase()},$:{isZooming$:r.pipe(v.switchMap(g=>(g==null?void 0:g.isZooming$)||v.of(!1)))}}}},wo=e=>{const t={forceSinglePageMode:!1,pageTurnAnimation:"none",computedPageTurnAnimation:"none",pageTurnDirection:"horizontal",computedPageTurnDirection:"horizontal",pageTurnAnimationDuration:void 0,computedPageTurnAnimationDuration:0,pageTurnMode:"controlled",computedPageTurnMode:"controlled",computedSnapAnimationDuration:300,navigationSnapThreshold:.3,numberOfAdjacentSpineItemToPreLoad:0,...e};Ke(void 0,t,!1);const n=new v.BehaviorSubject(t);return{getSettings:()=>n.value,setSettings:(s,a)=>{if(Object.keys(s).length===0)return;const c={...n.value,...s};Ke(a.manifest,c,a.hasVerticalWritingSubject),n.next(c)},recompute:s=>{const a={...n.value};Ke(s.manifest,a,s.hasVerticalWritingSubject),n.next(a)},destroy:()=>{n.complete()},$:{settings$:n.asObservable().pipe(Z(ne))}}},Po=e=>!(e!=null&&e.spineItems.some(t=>t.renditionLayout==="reflowable")),Ke=(e,t,n)=>{t.computedPageTurnDirection=t.pageTurnDirection,t.computedPageTurnAnimation=t.pageTurnAnimation,t.computedPageTurnMode="controlled",(e==null?void 0:e.renditionFlow)==="scrolled-continuous"?(t.computedPageTurnMode="scrollable",t.computedPageTurnDirection="vertical"):e&&t.pageTurnMode==="scrollable"&&(e.renditionLayout!=="pre-paginated"||!Po(e))?(L.warn(`pageTurnMode ${t.pageTurnMode} incompatible with current book, switching back to default`),t.computedPageTurnAnimation="none",t.computedPageTurnMode="controlled"):t.pageTurnMode==="scrollable"&&(t.computedPageTurnMode="scrollable",t.computedPageTurnDirection="vertical"),n&&t.computedPageTurnAnimation==="slide"&&(L.warn(`pageTurnAnimation ${t.computedPageTurnAnimation} incompatible with current book, switching back to default`),t.computedPageTurnAnimation="none"),t.computedPageTurnMode==="scrollable"?(t.computedPageTurnAnimationDuration=0,t.computedPageTurnAnimation="none"):t.computedPageTurnAnimationDuration=t.pageTurnAnimationDuration!==void 0?t.pageTurnAnimationDuration:300},Io=e=>{let t,n;const o=new v.BehaviorSubject(!1),i=new v.Subject,r={width:0,height:0,x:0,y:0},s=0,a=0,c=new v.Subject,u=wo(e),d=()=>{const{height:b,width:w}=r,p=w>b;return u.getSettings().forceSinglePageMode||(t==null?void 0:t.renditionFlow)==="scrolled-continuous"?!1:!p&&(t==null?void 0:t.renditionSpread)==="portrait"?!0:p&&((t==null?void 0:t.renditionSpread)===void 0||(t==null?void 0:t.renditionSpread)==="auto"||(t==null?void 0:t.renditionSpread)==="landscape"||(t==null?void 0:t.renditionSpread)==="both")},l=(b,w)=>{t=b,n=w,u.recompute({manifest:t,hasVerticalWritingSubject:o.value}),i.next(b)},f=()=>(t==null?void 0:t.readingDirection)==="rtl",g=()=>o.next(!0);return o.pipe(Ee(1),Z(),W(()=>{u.recompute({manifest:t,hasVerticalWritingSubject:o.value})}),k(c)).subscribe(),{load:l,isRTL:f,areAllItemsPrePaginated:()=>$o(t),destroy:()=>{u.destroy(),i.complete(),c.next(),c.complete(),o.complete()},getLoadOptions:()=>n,getCalculatedInnerMargin:()=>0,getVisibleAreaRect:()=>r,shouldDisplaySpread:d,setHasVerticalWriting:g,setVisibleAreaRect:(b,w,p,F)=>{r.width=p,r.height=F-s-a,r.x=b,r.y=w},getManifest:()=>t,getReadingDirection:()=>t==null?void 0:t.readingDirection,getPageSize:()=>({width:d()?r.width/2:r.width,height:r.height}),getSettings:u.getSettings,setSettings:b=>u.setSettings(b,{hasVerticalWritingSubject:o.value,manifest:t}),$:{hasVerticalWriting$:o.asObservable().pipe(Z()),destroy$:c.asObservable(),settings$:u.$.settings$,load$:i.asObservable()}}},$o=e=>!(e!=null&&e.spineItems.some(t=>t.renditionLayout==="reflowable")),Ut="__UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT",To=[".xhtml",".html",".htm"],Oe="prose-reader",Co=e=>t=>{if(e&&e.contentDocument&&e.contentDocument.head){const n=e.contentDocument.getElementById(t);n&&n.remove()}},Eo=e=>(t,n,o=!1)=>{if(e&&e.contentDocument&&e.contentDocument.head){const i=document.createElement("style");i.id=t,i.innerHTML=n,o?e.contentDocument.head.prepend(i):e.contentDocument.head.appendChild(i)}},Wt=(e,t)=>{const n=new RegExp(t+"\\s*=\\s*([0-9.]+)","i"),o=e.match(n)||[],i=o[1]||"0";return o&&parseFloat(i)||0},Fo=e=>e[Ut],xo=(e,t)=>{Object.defineProperty(e,Ut,{value:t,enumerable:!0})},Ao=L.measurePerformance("SpineItemFrame createFrame",1/0,()=>{const e=document.createElement("iframe");return e.frameBorder="no",e.tabIndex=0,e.setAttribute("sandbox","allow-same-origin allow-scripts"),e.scrolling="no",e.style.cssText=`
|
|
56
|
+
visibility: hidden;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
border: 0px none transparent;
|
|
60
|
+
padding: 0px;
|
|
61
|
+
transition: opacity 300ms;
|
|
62
|
+
opacity: 0;
|
|
63
|
+
`,v.of(e)}),Ht=e=>({frame:e,removeStyle:Co(e),addStyle:Eo(e)}),jt=async(e,t)=>{if(typeof e=="string")return e;const n=st.parseContentType(e.headers.get("Content-Type")||"")||st.detectContentType(t.href);if(["image/jpg","image/jpeg","image/png","image/webp"].some(i=>i===n)){const i=await oo(await e.blob());return`
|
|
64
|
+
<html>
|
|
65
|
+
<head>
|
|
66
|
+
${t.renditionLayout!=="reflowable"?'<meta name="viewport" content="width=device-width, minimum-scale=0.1">':""}
|
|
67
|
+
</head>
|
|
68
|
+
<body style="margin: 0px;" tab-index="-1;">
|
|
69
|
+
<img
|
|
70
|
+
src="${i}"
|
|
71
|
+
style="max-width: 100%;height:100%;object-fit:contain;"
|
|
72
|
+
>
|
|
73
|
+
</body>
|
|
74
|
+
</html>
|
|
75
|
+
`}return["text/plain"].some(i=>i===n)?`
|
|
76
|
+
<!DOCTYPE html>
|
|
77
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
|
|
78
|
+
<head>
|
|
79
|
+
<style>
|
|
80
|
+
pre {
|
|
81
|
+
white-space: pre;
|
|
82
|
+
white-space: pre-wrap;
|
|
83
|
+
word-wrap: break-word;
|
|
84
|
+
}
|
|
85
|
+
</style>
|
|
86
|
+
</head>
|
|
87
|
+
<body>
|
|
88
|
+
<pre>${await e.text()}</pre>
|
|
89
|
+
</body>
|
|
90
|
+
</html>
|
|
91
|
+
`:await e.text()},Oo=e=>e.name==="item.onLoad",No=({item:e,parent:t,fetchResource:n,hooks$:o,context:i,viewportState$:r})=>{const s=new v.Subject,a=new v.Subject,c=new v.Subject,u=new v.BehaviorSubject(void 0),d=new v.BehaviorSubject(!1),l=new v.BehaviorSubject(!1);let f=[],g;const y=$=>($.pipe(k(i.$.destroy$)).subscribe(),$),b=$=>jt($,e),w=r.pipe(j($=>$==="free"),le(1)),p=c.asObservable().pipe(te(u),j(([$,P])=>!!P),B(([,$])=>{f.forEach(P=>{P&&"unsubscribe"in P?P.unsubscribe():P&&P()}),f=[],$==null||$.remove(),u.next(void 0)}),ee(),k(s)),F=a.asObservable().pipe(te(d),j(([$,P])=>!P),Rt(()=>Ao().pipe(se($=>w.pipe(de($))),se($=>{if(t.appendChild($),u.next($),!n&&e.href.startsWith(window.location.origin)&&(e.mediaType&&["application/xhtml+xml","application/xml","text/html","text/xml"].includes(e.mediaType)||!e.mediaType&&To.some(P=>e.href.endsWith(P))))return $==null||$.setAttribute("src",e.href),v.of($);{const P=n||(()=>fetch(e.href));return v.from(P(e)).pipe(se(m=>b(m)),W(m=>{$==null||$.setAttribute("srcdoc",m)}),B(()=>$))}}),se($=>$?($.setAttribute("sandbox","allow-same-origin allow-scripts"),v.fromEvent($,"load").pipe(le(1),te(o),se(([P,m])=>{var C,T;const h=(C=$.contentDocument)==null?void 0:C.body;if(!h)return L.error(`Something went wrong on iframe load ${e.id}`),v.EMPTY;$.setAttribute("role","main"),$!=null&&$.contentDocument&&h&&(g=(T=$==null?void 0:$.contentWindow)==null?void 0:T.getComputedStyle(h)),i.getSettings().computedPageTurnMode!=="scrollable"&&$.setAttribute("tab-index","0");const S=Ht($);return f=m.filter(Oo).map(E=>{const O=E.fn({...S,item:e});return O&&"subscribe"in O?O.subscribe():O}),v.of($)}))):v.EMPTY),k(c))),ee(),y,k(s)),N=F.pipe(H($=>{var P;return v.from(((P=$==null?void 0:$.contentDocument)==null?void 0:P.fonts.ready)||v.of(void 0)).pipe(k(c))}),ee(),y,k(s));return v.merge(F.pipe(de(!0)),c.pipe(de(!1))).pipe(Z(),k(s)).subscribe(d),v.merge(N.pipe(de(!0)),c.pipe(de(!1))).pipe(Z(),k(s)).subscribe(l),p.subscribe(),{load:()=>a.next(),unload:()=>c.next(),destroy:()=>{a.complete(),c.complete(),u.complete(),s.next(),s.complete(),l.complete(),d.complete()},getComputedStyleAfterLoad:()=>g,$:{load$:a.asObservable(),unload$:c.asObservable(),loaded$:F,isLoaded$:d.asObservable(),isReady$:l.asObservable().pipe(Z()),ready$:N,unloaded$:p,frameElement$:u}}},Ro=({item:e,parent:t,fetchResource:n,context:o,hooks$:i,viewportState$:r})=>{const s=new v.Subject,{$:{unload$:a,loaded$:c,isLoaded$:u,isReady$:d,unloaded$:l,frameElement$:f,ready$:g},load:y,unload:b,destroy:w,getComputedStyleAfterLoad:p}=No({context:o,hooks$:i,item:e,parent:t,fetchResource:n,viewportState$:r}),F=new v.BehaviorSubject(!1),N=new v.BehaviorSubject(!1);u.subscribe(F),d.subscribe(N);const $=()=>{const E=f.getValue();if(F.value&&E)return Ht(E)},P=()=>{const E=f.getValue();if(E&&(E!=null&&E.contentDocument)){const A=E.contentDocument.querySelector("meta[name='viewport']");if(A){const R=A.getAttribute("content");if(R){const M=Wt(R,"width"),x=Wt(R,"height");return M>0&&x>0?{width:M,height:x}:void 0}}}},m=()=>{var E;return(E=p())==null?void 0:E.writingMode},h=()=>{var E;return!!((E=m())!=null&&E.startsWith("vertical"))},S=E=>jt(E,e),C=v.merge(l.pipe(B(()=>({isFirstLayout:!1}))),g.pipe(B(()=>({isFirstLayout:!0}))));return{getIsLoaded:()=>F.value,getIsReady:()=>N.value,getViewportDimensions:P,getFrameElement:()=>f.getValue(),getHtmlFromResource:S,load:y,unload:b,staticLayout:E=>{const O=f.getValue();O&&(O.style.width=`${E.width}px`,O.style.height=`${E.height}px`,o.getSettings().computedPageTurnMode!=="scrollable"&&O.setAttribute("tab-index","0"))},getManipulableFrame:$,getReadingDirection:()=>{var A;if(m()==="vertical-rl")return"rtl";const O=(A=p())==null?void 0:A.direction;if(["ltr","rtl"].includes(O||""))return O},isUsingVerticalWriting:h,getWritingMode:m,destroy:()=>{b(),w(),s.next(),s.complete()},$:{unload$:a,unloaded$:l,loaded$:c,ready$:g,isReady$:N.asObservable(),contentLayoutChange$:C}}},Lo=()=>{const e={x:void 0,y:void 0},t=new v.Subject;let n=!1;return{track:i=>{var r,s,a;e.x=void 0,e.y=void 0,(r=i.contentDocument)==null||r.addEventListener("mousedown",c=>{n=!0,e.x=c.x,e.y=c.y,t.next({event:"fingermove",data:{x:c.x,y:c.y}})}),(s=i.contentDocument)==null||s.addEventListener("mouseup",()=>{n=!1,e.x=void 0,e.y=void 0,t.next({event:"fingerout",data:void 0})}),(a=i.contentDocument)==null||a.addEventListener("mousemove",c=>{n&&t.next({event:"fingermove",data:{x:c.x,y:c.y}})})},getFingerPositionInIframe(){return e.x===void 0||e.y===void 0?void 0:e},destroy:()=>{},$:t.asObservable()}},Do=()=>{let e=!1,t;const n=new v.Subject,o=["mouseup","pointerup"];return{track:s=>{var a,c;t=s,o.forEach(u=>{var d;(d=s.contentWindow)==null||d.addEventListener(u,()=>{e=!1})}),(a=s.contentDocument)==null||a.addEventListener("selectionchange",()=>{var u;n.next({event:"selectionchange",data:((u=t==null?void 0:t.contentWindow)==null?void 0:u.getSelection())||null})}),(c=s.contentWindow)==null||c.addEventListener("selectstart",()=>{e=!0})},destroy:()=>{},isSelecting:()=>e,getSelection:()=>{var a;const s=(a=t==null?void 0:t.contentWindow)==null?void 0:a.getSelection();if(!(!(s!=null&&s.anchorNode)||s.type==="None"||s.type==="Caret"))return s},$:n.asObservable()}},_o=e=>typeof e=="object"&&!!e&&"nodeType"in e&&(e==null?void 0:e.nodeType)===Node.ELEMENT_NODE&&"innerText"in e;function Mo(e,t,n){if("caretPositionFromPoint"in e)return e.caretPositionFromPoint(t,n);if(typeof e.caretRangeFromPoint<"u")return e.caretRangeFromPoint(t,n)}const Vo=L.measurePerformance("getFirstVisibleNodeForViewport",1,(e,t)=>{const n="body"in e?Qe(e.body,t):Qe(e,t),o="createRange"in e?e:e.ownerDocument;if(n){let i,r=0;const s=o.createRange();return Array.from(n.childNodes).some(a=>{s.selectNodeContents(a);const c=s.getClientRects(),u=ko(c,t);if(u){i=s.cloneRange();const d=Mo(o,Math.ceil(u.left),Math.ceil(u.top));return d&&"startContainer"in d&&d.startContainer===i.startContainer&&(r=d.startOffset),d&&"offsetNode"in d&&d.offsetNode===i.startContainer&&(r=d.offset),!0}return!1}),i?{node:i.startContainer,offset:r}:{node:n,offset:0}}}),Qe=(e,t)=>{let n;const o=Yt(e.getBoundingClientRect(),t);return o!=="before"&&o!=="after"&&(n=e),Array.from(e.children).some(i=>{const r=Qe(i,t);return r?(n=r,!0):!1}),n};function Yt(e,{left:t,right:n}){return e.left<=t&&e.right<=t?"before":e.left<=t&&e.right>t&&e.right<=n?"partially-before":e.left<=n&&e.right>n?"partially-after":e.left>n?"after":"within"}function ko(e,t){return Array.from(e).find(n=>{const o=Yt(n,t);return o!=="before"&&o!=="after"})}const Bo=(e,t)=>{var n;if(e.nodeType!==Node.CDATA_SECTION_NODE&&e.nodeType!==Node.DOCUMENT_TYPE_NODE){const o=(n=e.ownerDocument)==null?void 0:n.createRange();o==null||o.selectNodeContents(e);try{t<=((o==null?void 0:o.endOffset)||0)&&(o==null||o.setStart(e,t||0))}catch(i){L.error(i)}return o}},et=e=>{var t,n,o,i,r;if(e!=null&&e.target&&((n=(t=e==null?void 0:e.target)==null?void 0:t.ownerDocument)!=null&&n.defaultView)){const s=(i=(o=e==null?void 0:e.target)==null?void 0:o.ownerDocument)==null?void 0:i.defaultView;if(s.PointerEvent)return e instanceof s.PointerEvent}if(e!=null&&e.view&&((r=e==null?void 0:e.view)!=null&&r.window)){const s=e==null?void 0:e.view;if(s.PointerEvent)return e instanceof s.PointerEvent}return!1},Xt=e=>{var t,n,o,i,r;if(et(e))return!1;if(e!=null&&e.target&&((n=(t=e==null?void 0:e.target)==null?void 0:t.ownerDocument)!=null&&n.defaultView)){const s=(i=(o=e==null?void 0:e.target)==null?void 0:o.ownerDocument)==null?void 0:i.defaultView;if(s.MouseEvent)return e instanceof s.MouseEvent}if(e!=null&&e.view&&((r=e==null?void 0:e.view)!=null&&r.window)){const s=e==null?void 0:e.view;if(s.MouseEvent)return e instanceof s.MouseEvent}return!1},zo=e=>{var t,n,o,i,r;if(e!=null&&e.target&&((n=(t=e==null?void 0:e.target)==null?void 0:t.ownerDocument)!=null&&n.defaultView)){const s=(i=(o=e==null?void 0:e.target)==null?void 0:o.ownerDocument)==null?void 0:i.defaultView;if(s.TouchEvent)return e instanceof s.TouchEvent}if(e!=null&&e.view&&((r=e==null?void 0:e.view)!=null&&r.window)){const s=e==null?void 0:e.view;if(s.TouchEvent)return e instanceof s.TouchEvent}return!1},Uo=["pointercancel","pointerdown","pointerenter","pointerleave","pointermove","pointerout","pointerover","pointerup"],Wo=["mousedown","mouseup","mouseenter","mouseleave","mousemove","mouseout","mouseover"],Ho=[...Uo,...Wo],qt=({item:e,context:t,parentElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r})=>{var M;const s=new v.Subject,a=jo(n,e,i),c=Yo(n,e),u=Lo(),d=Do(),l=Xo(o,u,d),f=Ro({parent:a,item:e,context:t,fetchResource:(M=t.getLoadOptions())==null?void 0:M.fetchResource,hooks$:i.asObservable().pipe(B(x=>[...x,...l])),viewportState$:r});a.appendChild(c),n.appendChild(a);let g;const y=()=>{if(g)return g;const x=a.getBoundingClientRect();return g={...x,width:Math.round(x.width*10)/10,height:Math.round(x.height*10)/10},g},b=()=>{var x;return!!((x=e.mediaType)!=null&&x.startsWith("image/"))},w=x=>{var _,z;(_=f.getManipulableFrame())==null||_.removeStyle("prose-reader-css"),(z=f.getManipulableFrame())==null||z.addStyle("prose-reader-css",x)},p=({right:x,left:_,top:z})=>{x!==void 0?a.style.right=`${x}px`:a.style.removeProperty("right"),_!==void 0?a.style.left=`${_}px`:a.style.removeProperty("left"),z!==void 0?a.style.top=`${z}px`:a.style.removeProperty("top")},F=()=>{var D;const{width:x,height:_}=t.getPageSize(),z=f.getViewportDimensions(),I=(D=f.getManipulableFrame())==null?void 0:D.frame;if(a&&(I!=null&&I.contentDocument)&&(I!=null&&I.contentWindow)&&z){const V=x/z.width;return{computedScale:Math.min(V,_/z.height),computedWidthScale:V,viewportDimensions:z}}},N=()=>f.load(),$=()=>f.unload(),P=x=>{var z,I,D,V,U;const _=(z=f.getManipulableFrame())==null?void 0:z.frame;if(_&&x)return x.startsWith("#")?(D=(I=_.contentDocument)==null?void 0:I.getElementById(x.replace("#","")))==null?void 0:D.getBoundingClientRect():(U=(V=_.contentDocument)==null?void 0:V.querySelector(x))==null?void 0:U.getBoundingClientRect()},m=()=>{g=void 0},h=()=>{const x=t.getPageSize(),_=x.width;return{columnHeight:x.height,columnWidth:_}},S=(x,_)=>{const z=t.getPageSize(),I=0,D=0;let V=z.width-I*2;const U=z.height-D*2;let Y=z.width-I*2;return x&&(Y=_-I*2,V=U),{columnHeight:U,columnWidth:V,width:Y}},C=({height:x,width:_,blankPagePosition:z,minimumWidth:I})=>{a.style.width=`${_}px`,a.style.height=`${x}px`,i.getValue().forEach(D=>{D.name==="item.onAfterLayout"&&D.fn({blankPagePosition:z,item:e,minimumWidth:I})}),m()},T=x=>{var U,Y;const{left:_=0,top:z=0}=((U=f.getFrameElement())==null?void 0:U.getBoundingClientRect())||{},I=((Y=F())==null?void 0:Y.computedScale)??1,D=x.clientX*I+_,V=x.clientY*I+z;return{clientX:D,clientY:V}},E=async()=>{const x=t.getLoadOptions(),_=I=>x!=null&&x.fetchResource?x.fetchResource(e):fetch(e.href);return await i.getValue().reduce((I,D)=>D.name==="item.onGetResource"?D.fn(I):I,_)(e)},O=x=>{const _=f.getManipulableFrame();return x(_?{..._,container:a,item:e,overlayElement:c}:{container:a,item:e,frame:void 0,removeStyle:()=>{},addStyle:()=>{},overlayElement:c})},A=x=>i.getValue().forEach(_=>{_.name==="item.onLayoutBeforeMeasurement"&&_.fn({frame:f,container:a,item:e,isImageType:b,...x})}),R=f.$.contentLayoutChange$.pipe(te(f.$.isReady$),B(([x,_])=>({isFirstLayout:x.isFirstLayout,isReady:_})));return{item:e,load:()=>{m()},layout:C,adjustPositionOfElement:p,getElementDimensions:y,getHtmlFromResource:f.getHtmlFromResource,getResource:E,translateFramePositionIntoPage:T,setLayoutDirty:m,injectStyle:w,loadContent:N,unloadContent:$,spineItemFrame:f,element:a,getBoundingRectOfElementFromSelector:P,getViewPortInformation:F,isImageType:b,isReady:f.getIsReady,destroy:()=>{s.next(),a.remove(),f==null||f.destroy(),u.destroy(),d.destroy(),s.complete()},isUsingVerticalWriting:()=>{var x;return(x=f.getWritingMode())==null?void 0:x.startsWith("vertical")},getReadingDirection:()=>f.getReadingDirection()||t.getReadingDirection(),manipulateSpineItem:O,executeOnLayoutBeforeMeasurementHook:A,selectionTracker:d,fingerTracker:u,getDimensionsForReflowableContent:S,getDimensionsForPaginatedContent:h,$:{contentLayout$:R,loaded$:f.$.loaded$,isReady$:f.$.isReady$}}},jo=(e,t,n)=>{const o=e.ownerDocument.createElement("div");return o.classList.add("spineItem"),o.classList.add(`spineItem-${t.renditionLayout}`),o.style.cssText=`
|
|
92
|
+
position: absolute;
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
`,n.getValue().reduce((i,r)=>r.name==="item.onBeforeContainerCreated"?r.fn(i):i,o)},Yo=(e,t)=>{const n=e.ownerDocument.createElement("div");return n.classList.add("spineItemOverlay"),n.classList.add(`spineItemOverlay-${t.renditionLayout}`),n.style.cssText=`
|
|
95
|
+
position: absolute;
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
background-color: transparent;
|
|
100
|
+
`,n},Xo=(e,t,n)=>[{name:"item.onLoad",fn:({frame:o})=>{const i=Ho.map(r=>{var a;const s=c=>{let u=c;et(c)&&(u=new PointerEvent(c.type,c)),Xt(c)&&(u=new MouseEvent(c.type,c)),u!==c&&(xo(u,c),e.dispatchEvent(u))};return(a=o.contentDocument)==null||a.addEventListener(r,s),()=>{var c;(c=o.contentDocument)==null||c.removeEventListener(r,s)}});return n.track(o),t.track(o),()=>{i.forEach(r=>r())}}}],Gt=()=>`
|
|
101
|
+
body {
|
|
102
|
+
margin: 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`,qo=({item:e,context:t,containerElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r})=>{const s=qt({context:t,item:e,parentElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r}),a=s.spineItemFrame;return{...s,layout:({blankPagePosition:u,minimumWidth:d,spreadPosition:l})=>{var F;const{width:f,height:g}=t.getPageSize(),{viewportDimensions:y,computedScale:b=1}=s.getViewPortInformation()??{},w=t.getVisibleAreaRect(),p=(F=a.getManipulableFrame())==null?void 0:F.frame;if(a!=null&&a.getIsLoaded()&&(p!=null&&p.contentDocument)&&(p!=null&&p.contentWindow)){const N=f,$=w.height+t.getCalculatedInnerMargin(),P=Go({...s.getDimensionsForPaginatedContent(),enableTouch:t.getSettings().computedPageTurnMode!=="scrollable",spreadPosition:l},y);if(p==null||p.style.setProperty("visibility","visible"),p==null||p.style.setProperty("opacity","1"),y){s.injectStyle(P),a.staticLayout({width:y.width,height:y.height}),p==null||p.style.setProperty("position","absolute"),p==null||p.style.setProperty("top","50%"),l==="left"?(p==null||p.style.setProperty("right","0"),p==null||p.style.removeProperty("left")):u==="before"&&t.isRTL()?(p==null||p.style.setProperty("right","50%"),p==null||p.style.removeProperty("left")):l==="right"?(p==null||p.style.setProperty("left","0"),p==null||p.style.removeProperty("right")):(p==null||p.style.setProperty("left",u==="before"?t.isRTL()?"25%":"75%":u==="after"?t.isRTL()?"75%":"25%":"50%"),p==null||p.style.removeProperty("right"));const m=l!=="none"?"0":"-50%",h=l==="right"&&u!=="before"?"left":l==="left"||u==="before"&&t.isRTL()?"right":"center";p==null||p.style.setProperty("transform",`translate(${m}, -50%) scale(${b})`),p==null||p.style.setProperty("transform-origin",`${h} center`),s.executeOnLayoutBeforeMeasurementHook({minimumWidth:d})}else s.injectStyle(P),a.staticLayout({width:N,height:$}),u==="before"?t.isRTL()?p==null||p.style.setProperty("margin-right",`${f}px`):p==null||p.style.setProperty("margin-left",`${f}px`):(p==null||p.style.removeProperty("margin-left"),p==null||p.style.removeProperty("margin-right"));return s.executeOnLayoutBeforeMeasurementHook({minimumWidth:d}),s.layout({width:d,height:$,blankPagePosition:u,minimumWidth:d}),{width:d,height:$}}else s.executeOnLayoutBeforeMeasurementHook({minimumWidth:d}),s.layout({width:d,height:g,blankPagePosition:u,minimumWidth:d});return{width:d,height:g}}}},Go=({columnWidth:e,enableTouch:t,spreadPosition:n},o)=>`
|
|
106
|
+
${Gt()}
|
|
107
|
+
body {
|
|
108
|
+
${o?"":`
|
|
109
|
+
display: flex;
|
|
110
|
+
justify-content: ${n==="left"?"flex-end":n==="right"?"flex-start":"center"};
|
|
111
|
+
`}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
html, body {
|
|
115
|
+
height: 100%;
|
|
116
|
+
width: 100%;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
html, body {
|
|
120
|
+
-max-width: ${e}px !important;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
html, body {
|
|
124
|
+
${t?`
|
|
125
|
+
touch-action: none
|
|
126
|
+
`:""}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
img {
|
|
130
|
+
user-select: none;
|
|
131
|
+
-webkit-user-drag: none;
|
|
132
|
+
-khtml-user-drag: none;
|
|
133
|
+
-moz-user-drag: none;
|
|
134
|
+
-o-user-drag: none;
|
|
135
|
+
user-drag: none;
|
|
136
|
+
|
|
137
|
+
display: flex;
|
|
138
|
+
|
|
139
|
+
${o?"":`
|
|
140
|
+
-width: 100%;
|
|
141
|
+
max-width: 100%;
|
|
142
|
+
height:100%;
|
|
143
|
+
object-fit:contain;
|
|
144
|
+
`}
|
|
145
|
+
}
|
|
146
|
+
`,Zo=({item:e,context:t,containerElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r})=>{const s=qt({context:t,item:e,parentElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r}),a=s.spineItemFrame;let c;return{...s,layout:({blankPagePosition:d,minimumWidth:l})=>{var $,P,m,h,S,C,T,E;const{width:f,height:g}=t.getPageSize();(P=($=a.getManipulableFrame())==null?void 0:$.frame)==null||P.style.setProperty("width",`${f}px`),(h=(m=a.getManipulableFrame())==null?void 0:m.frame)==null||h.style.setProperty("height",`${g}px`);const{viewportDimensions:y,computedScale:b=1}=s.getViewPortInformation()??{},w=t.getVisibleAreaRect(),p=(S=a.getManipulableFrame())==null?void 0:S.frame,F=((C=t.getManifest())==null?void 0:C.renditionLayout)==="pre-paginated";if(a!=null&&a.getIsLoaded()&&(p!=null&&p.contentDocument)&&(p!=null&&p.contentWindow)){let O=f,A=w.height+t.getCalculatedInnerMargin();if(p==null||p.style.setProperty("visibility","visible"),p==null||p.style.setProperty("opacity","1"),y)s.injectStyle(Jo()),s.executeOnLayoutBeforeMeasurementHook({minimumWidth:l}),a.staticLayout({width:y.width,height:y.height}),p==null||p.style.setProperty("position","absolute"),p==null||p.style.setProperty("top","50%"),p==null||p.style.setProperty("left",d==="before"?t.isRTL()?"25%":"75%":d==="after"?t.isRTL()?"75%":"25%":"50%"),p==null||p.style.setProperty("transform",`translate(-50%, -50%) scale(${b})`),p==null||p.style.setProperty("transform-origin","center center");else{const M=s.isImageType()?Ko({isScrollable:((T=t.getManifest())==null?void 0:T.renditionFlow)==="scrolled-continuous",enableTouch:t.getSettings().computedPageTurnMode!=="scrollable"}):Qo(s.getDimensionsForReflowableContent(a.isUsingVerticalWriting(),l));if(s.injectStyle(M),s.executeOnLayoutBeforeMeasurementHook({minimumWidth:l}),a.isUsingVerticalWriting())A=Math.ceil(p.contentDocument.documentElement.scrollHeight/g)*g,a.staticLayout({width:l,height:A});else if(((E=t.getManifest())==null?void 0:E.renditionFlow)==="scrolled-continuous")A=p.contentDocument.documentElement.scrollHeight,c=A,a.staticLayout({width:l,height:A});else{const x=Math.ceil(p.contentDocument.documentElement.scrollWidth/f);F?O=f:O=x*f,a.staticLayout({width:O,height:A})}}return O%l===0?p==null||p.style.setProperty("margin-left","0px"):(O=O+f,t.isRTL()&&!s.isUsingVerticalWriting()&&(p==null||p.style.setProperty("margin-left",`${f}px`))),s.layout({width:O,height:A,blankPagePosition:d,minimumWidth:l}),{width:O,height:A}}else s.executeOnLayoutBeforeMeasurementHook({minimumWidth:l});const N=c||g;return s.layout({width:l,height:N,blankPagePosition:d,minimumWidth:l}),{width:l,height:N}}}},Jo=()=>`
|
|
147
|
+
${Gt()}
|
|
148
|
+
html {
|
|
149
|
+
width: 100%;
|
|
150
|
+
height: 100%;
|
|
151
|
+
}
|
|
152
|
+
body {
|
|
153
|
+
width: 100%;
|
|
154
|
+
height: 100%;
|
|
155
|
+
margin: 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
html, body {
|
|
159
|
+
touch-action: none;
|
|
160
|
+
}
|
|
161
|
+
`,Ko=({isScrollable:e,enableTouch:t})=>`
|
|
162
|
+
|
|
163
|
+
html, body {
|
|
164
|
+
width: 100%;
|
|
165
|
+
margin: 0;
|
|
166
|
+
padding: 0;
|
|
167
|
+
${t?`
|
|
168
|
+
touch-action: none
|
|
169
|
+
`:""}
|
|
170
|
+
}
|
|
171
|
+
${e?`
|
|
172
|
+
img {
|
|
173
|
+
height: auto !important;
|
|
174
|
+
margin: 0;
|
|
175
|
+
padding: 0;
|
|
176
|
+
box-sizing: border-box;
|
|
177
|
+
|
|
178
|
+
width: 100%;
|
|
179
|
+
|
|
180
|
+
display: block;
|
|
181
|
+
}
|
|
182
|
+
`:""}
|
|
183
|
+
`,Qo=({width:e,columnHeight:t,columnWidth:n})=>`
|
|
184
|
+
parsererror {
|
|
185
|
+
display: none !important;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
html, body {
|
|
189
|
+
margin: 0;
|
|
190
|
+
padding: 0 !important;
|
|
191
|
+
-max-width: ${n}px !important;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
body {
|
|
195
|
+
padding: 0 !important;
|
|
196
|
+
width: ${e}px !important;
|
|
197
|
+
height: ${t}px !important;
|
|
198
|
+
overflow-y: hidden;
|
|
199
|
+
column-gap: 0px !important;
|
|
200
|
+
column-width: ${n}px !important;
|
|
201
|
+
column-fill: auto !important;
|
|
202
|
+
word-wrap: break-word;
|
|
203
|
+
box-sizing: border-box;
|
|
204
|
+
}
|
|
205
|
+
body {
|
|
206
|
+
margin: 0;
|
|
207
|
+
}
|
|
208
|
+
body:focus-visible {
|
|
209
|
+
|
|
210
|
+
outline: none;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
html, body {
|
|
214
|
+
touch-action: none;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
* {
|
|
218
|
+
-max-width: ${n}px !important;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
img, video, audio, object, svg {
|
|
222
|
+
max-width: 100%;
|
|
223
|
+
max-width: ${n}px !important;
|
|
224
|
+
max-height: ${t}px !important;
|
|
225
|
+
-pointer-events: none;
|
|
226
|
+
-webkit-column-break-inside: avoid;
|
|
227
|
+
page-break-inside: avoid;
|
|
228
|
+
break-inside: avoid;
|
|
229
|
+
}
|
|
230
|
+
figure {
|
|
231
|
+
d-max-width: ${n}px !important;
|
|
232
|
+
}
|
|
233
|
+
img {
|
|
234
|
+
object-fit: contain;
|
|
235
|
+
break-inside: avoid;
|
|
236
|
+
box-sizing: border-box;
|
|
237
|
+
d-max-width: ${n}px !important;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
table {
|
|
241
|
+
max-width: ${n}px !important;
|
|
242
|
+
table-layout: fixed;
|
|
243
|
+
}
|
|
244
|
+
td {
|
|
245
|
+
max-width: ${n}px;
|
|
246
|
+
}
|
|
247
|
+
`,ei=({item:e,context:t,containerElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r})=>e.renditionLayout==="pre-paginated"?qo({item:e,context:t,containerElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r}):Zo({item:e,context:t,containerElement:n,iframeEventBridgeElement:o,hooks$:i,viewportState$:r}),ti=({iframeEventBridgeElement:e,locator:t})=>({normalizeEventForViewport:o=>{var c;const i=o.target===e,r=Fo(o),s=(c=r==null?void 0:r.view)==null?void 0:c.frameElement;if(!i||!r||!s)return o;const a=t.getSpineItemFromIframe(s);if(!a)return o;if(et(o)){const{clientX:u,clientY:d}=a.translateFramePositionIntoPage(o),l=new PointerEvent(o.type,{...o,clientX:u,clientY:d});return Object.defineProperty(l,"target",{value:r.target,enumerable:!0}),l}if(Xt(o)){const{clientX:u,clientY:d}=a.translateFramePositionIntoPage(o),l=new MouseEvent(o.type,{...o,clientX:u,clientY:d});return Object.defineProperty(l,"target",{value:r.target,enumerable:!0}),l}if(zo(o)){const u=Array.from(o.touches).map(l=>{const{clientX:f,clientY:g}=a.translateFramePositionIntoPage(l);return new Touch({identifier:l.identifier,target:l.target,clientX:f,clientY:g})}),d=new TouchEvent(o.type,{touches:u,changedTouches:u,targetTouches:u});return Object.defineProperty(d,"target",{value:r.target,enumerable:!0}),d}return o}}),tt=Node.ELEMENT_NODE,nt=Node.TEXT_NODE,ot=Node.CDATA_SECTION_NODE;function ni(e){return e.replace(/[\[\]\^,();]/g,"^$&")}function oi(e,t,n){n=n||0;const o=[];let i=0,r;do{if(r=e.match(t),!r)break;o.push(r.index+n),i+=r.index+r.length,e=e.slice(r.index+r.length)}while(i<e.length);return o}function ii(e,t){let n,o,i,r;for(i=0;i<e.length;i++)r=Math.abs(e[i]-t),(!i||r<n)&&(r=n,o=e[i]);return o}function ri(e,t,n){let o=0,i,r=0,s=!0,a,c;for(a=0;a<e.length;a++)if(c=e[a],c.nodeType===tt){if(i||s?(o+=2,s=!1):o++,t===c)return c.tagName.toLowerCase()==="img"?{count:o,offset:n}:{count:o};r=0,i=!0}else if((c==null?void 0:c.nodeType)===nt||(c==null?void 0:c.nodeType)===ot){if((i||s)&&(o++,s=!1),t===c)return{count:o,offset:n+r};r+=c.textContent.length,i=!1}else continue;throw new Error("The specified node was not found in the array of siblings")}function si(e,t){const n=typeof e=="number",o=typeof t=="number";return!n&&!o?0:!n&&o?-1:n&&!o?1:(e||0)-(t||0)}function ai(e,t){if(!e&&!t)return 0;if(!e&&t)return-1;if(e&&!t)return 1;const n=(e.y||0)-(t.y||0);return n||(e.x||0)-(t.x||0)}class ye{constructor(t,n){this.isRange=!1,this.opts=Object.assign({flattenRange:!1,stricter:!0},n||{}),this.cfi=t,this.parts=[];const o=/^epubcfi\((.*)\)$/;t=t.trim();const i=t.match(o);if(!i)throw new Error("Not a valid CFI");if(i.length<2)return;t=i[1]||"";let r,s,a,c=[],u=0;for(;t.length;){if({parsed:r,offset:s,newDoc:a}=this.parse(t),!r||s===null)throw new Error("Parsing failed");if(u&&a)throw new Error("CFI is a range that spans multiple documents. This is not allowed");c.push(r),(a||t.length-s<=0)&&(u===2?this.to=c:this.parts.push(c),c=[]),t=t.slice(s),t[0]===","&&(u===0?(c.length&&this.parts.push(c),c=[]):u===1&&(c.length&&(this.from=c),c=[]),t=t.slice(1),u++)}this.from&&this.from.length&&(this.opts.flattenRange||!this.to||!this.to.length?(this.parts=this.parts.concat(this.from),delete this.from,delete this.to):this.isRange=!0),this.opts.stricter&&this.removeIllegalOpts()}removeIllegalOpts(t){if(!t)if(this.from){if(this.removeIllegalOpts(this.from),!this.to)return;t=this.to}else t=this.parts;let n,o,i,r;for(n=0;n<t.length;n++)for(i=t[n],o=0;o<i.length-1;o++)r=i[o],delete r.temporal,delete r.spatial,delete r.offset,delete r.textLocationAssertion}static generatePart(t,n,o){let i="",r;for(;t.parentNode;)r=ri(t.parentNode.childNodes,t,n),!i&&r.offset&&(i=":"+r.offset),i="/"+r.count+(t.id?"["+ni(t.id)+"]":"")+i,t=t.parentNode;return i}static generate(t,n,o){let i;if(Array.isArray(t)){const r=[];for(const s of t)r.push(this.generatePart(s.node,s.offset,o));i=r.join("!")}else i=this.generatePart(t,n,o);return o&&(i+=o),"epubcfi("+i+")"}static toParsed(t){return t.isRange?t.getFrom():t.get()}static comparePath(t,n){const o=Math.max(t.length,n.length);let i,r,s,a;for(i=0;i<o;i++){if(r=t[i],s=n[i],!r)return-1;if(!s)return 1;if(a=this.compareParts(r,s),a)return a}return 0}static sort(t){t.sort((n,o)=>this.compare(n,o))}static compare(t,n){let o=t.get(),i=n.get();if(t.isRange||n.isRange){if(t.isRange&&n.isRange){const r=this.comparePath(o.from,i.from);return r||this.comparePath(o.to,i.to)}return t.isRange&&(o=o.from),n.isRange&&(i=i.from),this.comparePath(o,i)}else return this.comparePath(o,i)}static compareParts(t,n){const o=Math.max(t.length,n.length);let i,r,s,a;for(i=0;i<o;i++){if(r=t[i],s=n[i],!r)return-1;if(!s)return 1;if(a=r.nodeIndex-s.nodeIndex,a)return a;if(r.nodeIndex===0)return 0;if(!(i<o-1)&&(r.nodeIndex%2===0&&(a=si(r.temporal,s.temporal),a||(a=ai(r.spatial,s.spatial),a))||(a=(r.offset||0)-(s.offset||0),a)))return a}return 0}decodeEntities(t,n){try{const o=t.createElement("textarea");return o.innerHTML=n,o.value||""}catch{return n}}trueLength(t,n){return this.decodeEntities(t,n).length}getFrom(){if(!this.isRange)throw new Error("Trying to get beginning of non-range CFI");if(!this.from)return this.deepClone(this.parts);const t=this.deepClone(this.parts);return t[t.length-1]=t[t.length-1].concat(this.from),t}getTo(){if(!this.isRange)throw new Error("Trying to get end of non-range CFI");const t=this.deepClone(this.parts);return t[t.length-1]=t[t.length-1].concat(this.to),t}get(){return this.isRange?{from:this.getFrom(),to:this.getTo(),isRange:!0}:this.deepClone(this.parts)}parseSideBias(t,n){if(!n)return;const o=n.trim().match(/^(.*);s=([ba])$/);if(!o||o.length<3){typeof t.textLocationAssertion=="object"?t.textLocationAssertion.post=n:t.textLocationAssertion=n;return}o[1]&&(typeof t.textLocationAssertion=="object"?t.textLocationAssertion.post=o[1]:t.textLocationAssertion=o[1]),o[2]==="a"?t.sideBias="after":t.sideBias="before"}parseSpatialRange(t){if(!t)return;const n=t.trim().match(/^([\d\.]+):([\d\.]+)$/);if(!n||n.length<3)return;const o={x:parseInt(n[1]),y:parseInt(n[2])};if(!(typeof o.x!="number"||typeof o.y!="number"))return o}parse(t){const n={},o=/[\d]/;let i,r,s,a,c,u=!1,d=!1,l;for(l=0;l<=t.length;l++){if(l<t.length?a=t[l]:a="",a==="^"&&!c){c=!0;continue}if(r==="/")if(a.match(o)){i?i+=a:i=a,c=!1;continue}else i&&(n.nodeIndex=parseInt(i),i=null),s=r,r=null;if(r===":")if(a.match(o)){i?i+=a:i=a,c=!1;continue}else i&&(n.offset=parseInt(i),i=null),s=r,r=null;if(r==="@"){let f=!1;if(a.match(o)||a==="."||a===":"?a===":"&&(u?f=!0:u=!0):f=!0,f)s=r,r=null,i&&u&&(n.spatial=this.parseSpatialRange(i)),i=null;else{i?i+=a:i=a,c=!1;continue}}if(r==="~")if(a.match(o)||a==="."){i?i+=a:i=a,c=!1;continue}else i&&(n.temporal=parseFloat(i)),s=r,r=null,i=null;if(!r){if(a==="!"){l++,r=a;break}if(a===",")break;if(a==="/"){if(d)break;d=!0,s=r,r=a,c=!1;continue}if(a===":"||a==="~"||a==="@"){if(this.opts.stricter&&(a===":"&&(typeof n.temporal<"u"||typeof n.spatial<"u")||(a==="~"||a==="@")&&typeof n.offset<"u"))break;s=r,r=a,c=!1,u=!1;continue}if(a==="["&&!c&&s===":"){s=r,r="[",c=!1;continue}if(a==="["&&!c&&s==="/"){s=r,r="nodeID",c=!1;continue}}if(r==="["){a==="]"&&!c?(s=r,r=null,this.parseSideBias(n,i),i=null):a===","&&!c?(n.textLocationAssertion={},i&&(n.textLocationAssertion.pre=i),i=null):i?i+=a:i=a,c=!1;continue}if(r==="nodeID"){a==="]"&&!c?(s=r,r=null,n.nodeID=i,i=null):i?i+=a:i=a,c=!1;continue}c=!1}if(!n.nodeIndex&&n.nodeIndex!==0)throw new Error("Missing child node index in CFI");return{parsed:n,offset:l,newDoc:r==="!"}}getChildNodeByCFIIndex(t,n,o,i){const r=n.childNodes;if(!r.length)return{node:n,offset:0};if(o<=0)return{node:r[0],relativeToNode:"before",offset:0};let s=0,a,c,u;for(c=0;c<r.length;c++)switch(u=r[c],u.nodeType){case tt:if(s%2===0){if(s+=2,s>=o)return u.tagName.toLowerCase()==="img"&&i?{node:u,offset:i}:{node:u,offset:0}}else{if(s+=1,s===o)return u.tagName.toLowerCase()==="img"&&i?{node:u,offset:i}:{node:u,offset:0};if(s>o)return a?{node:a,offset:this.trueLength(t,a.textContent)}:{node:n,offset:0}}a=u;break;case nt:case ot:if((s===0||s%2===0)&&(s+=1),s===o){const d=this.trueLength(t,u.textContent);if(i>=d)i-=d;else return{node:u,offset:i}}a=u;break;default:continue}if(o>s){const d={relativeToNode:"after",offset:0};return a?d.node=a:d.node=n,this.isTextNode(d.node)&&(d.offset=this.trueLength(t,d.node.textContent.length)),d}}isTextNode(t){return t?t.nodeType===nt||t.nodeType===ot:!1}correctOffset(t,n,o,i){let r=n,s;if(typeof i=="string"?s=this.decodeEntities(t,i):(i.pre=this.decodeEntities(t,i.pre),i.post=this.decodeEntities(t,i.post),s=i.pre+"."+i.post),!this.isTextNode(n))return{node:n,offset:0};for(;this.isTextNode(r.previousSibling);)r=r.previousSibling;const a=r;let c;const u=[];let d="",l=0;for(;this.isTextNode(r)&&(c=this.decodeEntities(t,r.textContent),u[l]=c.length,d+=c,!!r.nextSibling);)r=r.nextSibling,l++;const f=i.pre?i.pre.length:0,g=oi(d,new RegExp(s),f);if(!g.length)return{node:n,offset:o};let y=ii(g,o);if(r===n&&y===o)return{node:n,offset:o};for(l=0,r=a;y>=u[l];){if(y-=u[l],y<0)return{node:n,offset:o};const b=[];if(!r.nextSibling||l+1>=b.length)return{node:n,offset:o};l++,r=r.nextSibling}return{node:r,offset:y}}resolveNode(t,n,o,i){if(i=Object.assign({},i||{}),!o)throw new Error("Missing DOM argument");let r;if(t===0&&(r=o.querySelector("package")),!r){for(const l of o.childNodes)if(l.nodeType===tt){r=l;break}}if(r=o,!r)throw new Error("Document incompatible with CFIs");let s=r,a=0,c,u;for(c=n.length-1;c>=0;c--)if(u=n[c],!i.ignoreIDs&&u.nodeID&&(s=o.getElementById(u.nodeID))){a=c+1;break}s||(s=r);let d={node:s,offset:0};for(c=a;c<n.length;c++)u=n[c],u&&(d=this.getChildNodeByCFIIndex(o,d.node,u.nodeIndex,u.offset),u.textLocationAssertion&&(d=this.correctOffset(o,d.node,u.offset,u.textLocationAssertion)));return d}resolveURI(t,n,o){if(o=o||{},t<0||t>this.parts.length-2)throw new Error("index is out of bounds");const i=this.parts[t];if(!i)throw new Error("Missing CFI part for index: "+t);let s=this.resolveNode(t,i,n,o).node;const a=s.tagName.toLowerCase();if(a==="itemref"&&s.parentNode.tagName.toLowerCase()==="spine"){const c=s.getAttribute("idref");if(!c)throw new Error("Referenced node had not 'idref' attribute");if(s=n.getElementById(c),!s)throw new Error("Specified node is missing from manifest");const u=s.getAttribute("href");if(!u)throw new Error("Manifest item is missing href attribute");return u}if(a==="iframe"||a==="embed"){const c=s.getAttribute("src");if(!c)throw new Error(a+" element is missing 'src' attribute");return c}if(a==="object"){const c=s.getAttribute("data");if(!c)throw new Error(a+" element is missing 'data' attribute");return c}if(a==="image"||a==="use"){const c=s.getAttribute("xlink:href");if(!c)throw new Error(a+" element is missing 'xlink:href' attribute");return c}throw new Error("No URI found")}deepClone(t){return JSON.parse(JSON.stringify(t))}resolveLocation(t,n){const o=n.length-1,i=n[o];if(!i)throw new Error("Missing CFI part for index: "+o);const r=this.resolveNode(o,i,t),s=this.deepClone(i[i.length-1]);return delete s.nodeIndex,s.offset||delete r.offset,{...s,...r}}resolveLast(t,n){if(n=Object.assign({range:!1},n||{}),!this.isRange)return this.resolveLocation(t,this.parts);if(n.range){const o=t.createRange(),i=this.getFrom();i.relativeToNode==="before"?o.setStartBefore(i.node,i.offset):i.relativeToNode==="after"?o.setStartAfter(i.node,i.offset):o.setStart(i.node,i.offset);const r=this.getTo();return r.relativeToNode==="before"?o.setEndBefore(r.node,r.offset):r.relativeToNode==="after"?o.setEndAfter(r.node,r.offset):o.setEnd(r.node,r.offset),o}return{from:this.resolveLocation(t,this.getFrom()),to:this.resolveLocation(t,this.getTo()),isRange:!0}}resolve(t,n){return this.resolveLast(t,n)}}const it=e=>{var r,s;const[t]=((r=e.match(/\|(\[prose\~anchor[^\]]*\])+/gi))==null?void 0:r.map(a=>a.replace(/\|\[prose\~anchor\~/,"").replace(/\]/,"")))||[],[n]=((s=e.match(/\|(\[prose\~offset[^\]]*\])+/gi))==null?void 0:s.map(a=>a.replace(/\|\[prose\~offset\~/,"").replace(/\]/,"")))||[],o=e.replace(/\|(\[prose\~[^\]]*\~[^\]]*\])+/gi,""),i=parseInt(n||"");return{cleanedCfi:o,itemId:t&&decodeURIComponent(t),offset:isNaN(i)?void 0:i}},ci=(e,t)=>{const n=e.toString();return{toString:()=>n,getAnchorCfi:()=>{if(e.anchorNode)return ye.generate(e.anchorNode,e.anchorOffset,`|[prose~anchor~${encodeURIComponent(t.id)}]`)},getFocusCfi:()=>{if(e.focusNode)return ye.generate(e.focusNode,e.focusOffset,`|[prose~anchor~${encodeURIComponent(t.id)}]`)}}},Ne=L.namespace("spine"),ui=({ownerDocument:e,context:t,pagination:n,iframeEventBridgeElement:o,spineItemManager:i,hooks$:r,spineItemLocator:s,spineLocator:a,cfiLocator:c,navigation$:u,navigationAdjusted$:d,currentNavigationPosition$:l,viewportState$:f})=>{const g=new v.Subject,y=new v.Subject,b=new v.Subject,w=li(e,r),p=ti({context:t,spineItemManager:i,iframeEventBridgeElement:o,locator:a});let F;const N=()=>{var C;y.next(),i.destroyItems(),(C=t.getManifest())==null||C.spineItems.map(async T=>{const E=ei({item:T,containerElement:w,iframeEventBridgeElement:o,context:t,hooks$:r,viewportState$:f});i.add(E)}),g.next(i.getAll())},$=C=>{let T=!1;i.getAll().forEach((E,O)=>{T=E.manipulateSpineItem(A=>C({index:O,...A}))||T}),T&&i.layout()},P=(C,T)=>{var E;(E=i.get(C))==null||E.manipulateSpineItem(T)};t.$.load$.pipe(W(N),k(t.$.destroy$)).subscribe();const m=f.pipe(j(C=>C==="free"),le(1)),h=C=>m.pipe(W(Ne.measurePerformance("adjustPagination",1,()=>{const T=a.getSpineItemsFromReadingOrderPosition(C),E=T?i.get(T.begin):void 0,O=T?i.get(T.end):void 0,A=n.getInfo().beginCfi,R=n.getInfo().endCfi,M=n.getInfo().beginSpineItemIndex!==(T==null?void 0:T.begin)||A===void 0||(A==null?void 0:A.startsWith("epubcfi(/0")),x=n.getInfo().endSpineItemIndex!==(T==null?void 0:T.end)||R===void 0||(R==null?void 0:R.startsWith("epubcfi(/0"));if(E&&O&&T){const _=a.getSpineItemPositionFromSpinePosition(T.beginPosition,E),z=s.getSpineItemPageIndexFromPosition(_,E),I=a.getSpineItemPositionFromSpinePosition(T.endPosition,O),D=s.getSpineItemPageIndexFromPosition(I,O);n.updateBeginAndEnd({spineItem:E,spineItemIndex:i.getSpineItemIndex(E)??0,pageIndex:s.getSpineItemPageIndexFromPosition(_,E),cfi:M?c.getCfi(z,E):A,options:{isAtEndOfChapter:!1}},{spineItem:O,spineItemIndex:i.getSpineItemIndex(O)??0,pageIndex:s.getSpineItemPageIndexFromPosition(I,O),cfi:x?c.getCfi(D,O):R,options:{isAtEndOfChapter:!1}})}},{disable:!0})));v.merge(i.$.focus$.pipe(W(C=>{const T=C.data,E=T.fingerTracker.$,O=T.selectionTracker.$;F==null||F.unsubscribe(),F=v.merge(O.pipe(j(A=>A.event==="selectionchange"),W(A=>{b.next({type:"onSelectionChange",data:A.data?ci(A.data,T.item):null})})),O.pipe(j(({event:A})=>A==="selectstart"),H(A=>E.pipe(j(({event:R})=>R==="fingermove"),Hn(()=>v.interval(1e3)),k(E.pipe(j(({event:R})=>R==="fingerout"),W(()=>{}))),W(({data:R})=>{}))))).subscribe()}),Ce(C=>(L.error(C),v.EMPTY)),k(t.$.destroy$))).subscribe();const S=u.pipe(W(C=>{const T=Ne.time("navigation",1),E=i.getFocusedSpineItem(),O=a.getSpineItemsFromReadingOrderPosition(C.position);let A=O?i.get(O.begin):void 0,R=O?i.get(O.end):void 0;A=A||E,R=R||E;const M=C.position.spineItem||A;if(M&&M!==E?i.focus(M):M||i.focus(0),M&&A&&R&&O){const x=C.lastUserExpectedNavigation,_=i.getSpineItemIndex(A)??0,z=a.getSpineItemPositionFromSpinePosition(O.beginPosition,A),I=s.getSpineItemPageIndexFromPosition(z,A),D=a.getSpineItemPositionFromSpinePosition(O.endPosition,R),V=s.getSpineItemPageIndexFromPosition(D,R),U=i.getSpineItemIndex(R)??0;n.updateBeginAndEnd({spineItem:A,spineItemIndex:_,pageIndex:I,cfi:(x==null?void 0:x.type)==="navigate-from-cfi"&&M===A?x.data:C.triggeredBy==="adjust"&&t.getSettings().computedPageTurnMode==="controlled"?n.getInfo().beginCfi:(_!==n.getInfo().beginSpineItemIndex,c.getRootCfi(A)),options:{isAtEndOfChapter:!1}},{spineItem:R,spineItemIndex:U,pageIndex:V,cfi:(x==null?void 0:x.type)==="navigate-from-cfi"&&M===R?x.data:C.triggeredBy==="adjust"&&t.getSettings().computedPageTurnMode==="controlled"?n.getInfo().endCfi:(U!==n.getInfo().endSpineItemIndex,c.getRootCfi(R)),options:{isAtEndOfChapter:!1}}),Ne.log("navigation$",{spineItemHasChanged:M!==E,item:M,spineItemToFocus:M,index:i.getSpineItemIndex(M),offset:C,endSpineItem:R,beginSpineItem:A,lastExpectedNavigation:x,spineItemsFromPosition:O})}T()}),ee(),k(t.$.destroy$));return S.pipe(H(C=>h(C.position).pipe(k(i.$.layout$))),k(t.$.destroy$)).subscribe(),v.merge(S,d).pipe(H(()=>m.pipe(te(l),B(([,C])=>{const T=i.getFocusedSpineItemIndex();if(Ne.log("update contents",{focusedSpineItemIndex:T}),T===void 0)return;const{begin:E=T,end:O=T}=a.getSpineItemsFromReadingOrderPosition(C)||{};E!==T&&O!==T?(L.warn("Current viewport is not in sync with focus item, load from focus item rather than viewport"),i.loadContents([T,T])):i.loadContents([E,O])}),le(1))),k(t.$.destroy$)).subscribe(),{element:w,locator:a,spineItemLocator:s,cfiLocator:c,normalizeEventForViewport:p.normalizeEventForViewport,manipulateSpineItems:$,manipulateSpineItem:P,destroy:()=>{g.complete(),y.next(),y.complete(),b.complete(),i.destroy(),F==null||F.unsubscribe(),w.remove()},adjustPagination:h,isSelecting:()=>{var C;return(C=i.getFocusedSpineItem())==null?void 0:C.selectionTracker.isSelecting()},getSelection:()=>{var C;return(C=i.getFocusedSpineItem())==null?void 0:C.selectionTracker.getSelection()},$:{$:b.asObservable(),layout$:i.$.layout$,itemsCreated$:g.asObservable(),itemsBeforeDestroy$:y.asObservable()}}},li=(e,t)=>{const n=e.createElement("div");return n.style.cssText=`
|
|
248
|
+
height: 100%;
|
|
249
|
+
position: relative;
|
|
250
|
+
`,n.className=`${Oe}-spine`,t.getValue().reduce((o,i)=>i.name==="spine.onBeforeContainerCreated"?i.fn(o):o,n)},di=e=>{var n;const t=(n=e.guide)==null?void 0:n.find(o=>o.type==="cover");return e.spineItems.findIndex(o=>t==null?void 0:t.href.endsWith(o.path))},fi="spineItemManager",gi=({context:e})=>{const t=new v.Subject,n=new v.Subject;let o=[];const i=new v.BehaviorSubject([]);let r;const s=()=>{const P=e.getManifest(),m=[],h=(P==null?void 0:P.renditionLayout)==="pre-paginated",S=P?di(P):void 0;i.value.reduce((T,E,O)=>{const A=S===O;let R=e.getPageSize().width,M="none";const x=T.edgeX%e.getVisibleAreaRect().width===0,_=O===i.value.length-1;if(e.shouldDisplaySpread()){!h&&E.item.renditionLayout==="reflowable"&&!_&&(R=e.getPageSize().width*2),!h&&E.item.renditionLayout==="reflowable"&&_&&x&&(R=e.getPageSize().width*2);const V=x&&_&&h;E.item.pageSpreadRight&&x&&!e.isRTL()||E.item.pageSpreadLeft&&x&&e.isRTL()?(M="before",R=e.getPageSize().width*2):V&&(e.isRTL()?M="before":M="after",R=e.getPageSize().width*2),h&&A&&(R=e.getPageSize().width*2)}const{width:z,height:I}=E.layout({minimumWidth:R,blankPagePosition:M,spreadPosition:e.shouldDisplaySpread()?x?e.isRTL()?"right":"left":e.isRTL()?"left":"right":"none"});if(e.getSettings().computedPageTurnDirection==="vertical"){const V=x?T.edgeY:T.edgeY-e.getVisibleAreaRect().height,U=x?0:T.edgeX;e.isRTL()?E.adjustPositionOfElement({top:V,left:U}):E.adjustPositionOfElement({top:V,left:U});const Y=z+U,ue=I+V;return m.push({leftStart:U,leftEnd:Y,topStart:V,topEnd:ue,height:I,width:z}),{edgeX:Y,edgeY:ue}}e.isRTL()?E.adjustPositionOfElement({right:T.edgeX,top:0}):E.adjustPositionOfElement({left:T.edgeX,top:0});const D=z+T.edgeX;return m.push({leftStart:T.edgeX,leftEnd:D,topStart:T.edgeY,topEnd:I,height:I,width:z}),{edgeX:D,edgeY:0}},{edgeX:0,edgeY:0});const C=o.some((T,E)=>!ne(T,m[E]));o=m,L.log(fi,"layout",{hasLayoutChanges:C,itemLayoutInformation:o}),n.next(C)},a=P=>{const m=typeof P=="number"?u(P):P;if(!m)return;const h=i.value.indexOf(m);h!==r&&(r=h,t.next({data:m}))},c=L.measurePerformance("loadContents",10,P=>{var E;const[m,h]=P,S=e.getSettings().numberOfAdjacentSpineItemToPreLoad,C=((E=e.getManifest())==null?void 0:E.renditionLayout)==="pre-paginated",T=e.getSettings().computedPageTurnMode==="scrollable";i.value.forEach((O,A)=>{const R=A<m&&!C&&T?!0:A<m-S,M=A>h+S;!R&&!M?O.loadContent():O.unloadContent()})}),u=P=>typeof P=="number"?i.value[P]:i.value.find(({item:m})=>m.id===P),d=L.measurePerformance("getAbsolutePositionOf",10,P=>{e.getSettings().computedPageTurnDirection;const m=typeof P=="number"?P:i.value.indexOf(P);return o[m]?o[m]||{leftStart:0,leftEnd:0,topStart:0,topEnd:0,width:0,height:0}:{leftStart:0,leftEnd:0,topStart:0,topEnd:0,width:0,height:0}},{disable:!0}),l=()=>r!==void 0?i.value[r]:void 0,f=(P,m)=>i.value.indexOf(P)>i.value.indexOf(m)?"after":"before",g=P=>{if(!P)return;const m=i.value.indexOf(P);return m<0?void 0:m},y=P=>{i.value.push(P),P.$.contentLayout$.pipe(k(e.$.destroy$)).subscribe(()=>{s()}),P.$.loaded$.pipe(W(()=>{P.isUsingVerticalWriting()&&e.setHasVerticalWriting()}),k(e.$.destroy$)).subscribe(),P.load()},b=()=>i.value,w=()=>i.value.length,p=()=>{const P=l();return P&&g(P)},F=L.measurePerformance("getSpineItemAtPosition",10,P=>{const m=i.value.find(h=>{const{leftStart:S,leftEnd:C,topEnd:T,topStart:E}=d(h),O=P.x>=S&&P.x<C;return e.getSettings().computedPageTurnDirection==="horizontal"?O:O&&P.y>=E&&P.y<T});return P.x===0&&!m?i.value[0]:m},{disable:!0}),N=()=>{i.value.forEach(P=>P.destroy())};return{destroyItems:N,add:y,get:u,getAll:b,getLength:w,layout:s,focus:a,loadContents:c,comparePositionOf:f,getAbsolutePositionOf:d,getSpineItemAtPosition:F,getFocusedSpineItem:l,getFocusedSpineItemIndex:p,getSpineItemIndex:g,destroy:()=>{N(),t.complete(),n.complete()},$:{focus$:t.asObservable(),layout$:n.asObservable(),itemIsReady$:i.asObservable().pipe(H(P=>{const m=P.map(h=>h.$.isReady$.pipe(B(S=>({item:h.item,isReady:S}))));return v.merge(...m)}))}}},Zt=({context:e})=>{const t=(u,d)=>{const{width:l,height:f}=d.getElementDimensions(),g=d.getReadingDirection();if(d.isUsingVerticalWriting())return{x:0,y:Mt(e.getPageSize().height,u,f)};const y=Mt(e.getPageSize().width,u,l);return g==="rtl"?{x:l-y-e.getPageSize().width,y:0}:{x:y,y:0}},n=(u,d)=>{const{width:l,height:f}=d.getElementDimensions(),g=d.getReadingDirection(),y=e.getPageSize().width,b=e.getPageSize().height;let w=Math.min(l,Math.max(0,u.x));if(g==="rtl"&&(w=l-w-e.getPageSize().width),d.isUsingVerticalWriting()){const p=ae(f,b);return c(u.y,b,p)}else{const p=ae(l,y);return c(w,y,p)}},o=(u,d)=>{var b;const l=((b=d.getElementDimensions())==null?void 0:b.width)||0,f=e.getPageSize().width,g=d.getBoundingRectOfElementFromSelector(u),y=(g==null?void 0:g.x)||0;return xe(y,f,l)},i=(u,d,l)=>{var b;let f;if((u==null?void 0:u.nodeName)==="img"||(u==null?void 0:u.textContent)===""&&u.nodeType===Node.ELEMENT_NODE)f=u.getBoundingClientRect().x;else if(u){const w=u?Bo(u,d):void 0;f=(w==null?void 0:w.getBoundingClientRect().x)||f}const g=((b=l.getElementDimensions())==null?void 0:b.width)||0,y=e.getPageSize().width;if(f)return{x:xe(f,y,g),y:0}},r=(u,d)=>{var g,y,b;const l=e.getPageSize(),f=(y=(g=d.spineItemFrame)==null?void 0:g.getManipulableFrame())==null?void 0:y.frame;if((b=f==null?void 0:f.contentWindow)!=null&&b.document&&f.contentWindow.document.body!==null){const{x:w,y:p}=t(u,d),F={left:w,right:w+l.width,top:p,bottom:p+l.height};return Vo(f.contentWindow.document,F)}},s=(u,d)=>{const{width:l,height:f}=d.getElementDimensions();return{x:xe(u.x,e.getPageSize().width,l),y:xe(u.y,e.getPageSize().height,f)}},a=(u,d,l)=>{const f=i(u,d,l);return f?n(f,l):void 0},c=(u,d,l)=>{const f=[...Array(l)].map((g,y)=>y*d);return u<=0?0:u>=l*d?l-1:Math.max(0,f.findIndex(g=>u<g+d))};return{getSpineItemPositionFromNode:i,getSpineItemPositionFromPageIndex:t,getSpineItemOffsetFromAnchor:o,getSpineItemPageIndexFromPosition:n,getSpineItemPageIndexFromNode:a,getSpineItemClosestPositionFromUnsafePosition:s,getFirstNodeOrRangeAtPage:r}},pi=({context:e})=>{const t=Zt({context:e}),n=(c,u)=>{let d={x:c.x-e.getPageSize().width,y:c.y};return u.isUsingVerticalWriting()&&(d={x:c.x,y:c.y+e.getPageSize().height}),t.getSpineItemClosestPositionFromUnsafePosition(d,u)},o=(c,u)=>{let d={x:c.x+e.getPageSize().width,y:c.y};return u.isUsingVerticalWriting()&&(d={x:c.x,y:c.y-e.getPageSize().height}),t.getSpineItemClosestPositionFromUnsafePosition(d,u)},i=c=>{if(c.isUsingVerticalWriting()){const u=e.getPageSize().height,d=ae(c.getElementDimensions().height,u);return r(d-1,c)}else{const u=e.getPageSize().width,d=ae(c.getElementDimensions().width,u);return r(d-1,c)}},r=(c,u)=>t.getSpineItemPositionFromPageIndex(c,u);return{getNavigationForLeftPage:n,getNavigationForRightPage:o,getNavigationForLastPage:i,getNavigationForPage:r,getNavigationForPosition:(c,u)=>t.getSpineItemClosestPositionFromUnsafePosition(u,c),getNavigationFromNode:(c,u,d)=>t.getSpineItemPositionFromNode(u,d,c)||{x:0,y:0}}},Jt="spineNavigator",hi=({context:e,spineItemManager:t,cfiLocator:n,locator:o})=>{const i=pi({context:e}),r=(m,h)=>m.x!==h.x||m.y!==h.y,s=(m,h)=>r(m,h)||!!m.spineItem&&!!h.spineItem&&m.spineItem!==h.spineItem,a=L.measurePerformance(`${Jt} wrapPositionWithSafeEdge`,1,m=>{const h=t.get(t.getLength()-1),S=t.getAbsolutePositionOf(h||0),C=S.leftEnd-e.getPageSize().width,T=S.topEnd-e.getPageSize().height;return{x:Math.min(Math.max(0,m.x),C),y:Math.min(Math.max(0,m.y),T)}},{disable:!0}),c=({x:m,y:h})=>({x:m%e.getVisibleAreaRect().width!==0?m-e.getPageSize().width:m,y:h}),u=m=>{const h=n.getSpineItemFromCfi(m),{node:S,offset:C=0}=n.resolveCfi(m)||{};if(!h)L.warn(Jt,`unable to detect item id from cfi ${m}`);else{const T=S?i.getNavigationFromNode(h,S,C):{x:0,y:0},E=o.getSpinePositionFromSpineItemPosition(T,h);return{...c(E),spineItem:h}}return{x:0,y:0}},d=(m,h)=>{if(!h){const T=m*e.getPageSize().width;return N({x:T,y:0})}const S=i.getNavigationForPage(m,h),C=o.getSpinePositionFromSpineItemPosition(S,h);return c(C)},l=m=>{const h=i.getNavigationForLastPage(m),S=o.getSpinePositionFromSpineItemPosition(h,m);return c(S)},f=m=>{const h=t.get(m);if(h){const S=o.getSpinePositionFromSpineItem(h);return{...c(S),spineItem:h}}return{x:0,y:0}},g=m=>{const h=e.getSettings().computedPageTurnDirection,S=o.getSpineItemFromPosition(m)||t.getFocusedSpineItem(),C=m;if(!S)return C;const T=o.getSpineItemPositionFromSpinePosition(m,S),E=i.getNavigationForRightPage(T,S);return!T.outsideOfBoundaries&&r(E,T)?o.getSpinePositionFromSpineItemPosition(E,S):a(e.isRTL()?h==="horizontal"?{x:m.x-e.getPageSize().width,y:0}:{y:m.y+e.getPageSize().height,x:0}:h==="horizontal"?{x:m.x+e.getPageSize().width,y:0}:{y:m.y+e.getPageSize().height,x:0})},y=m=>{const h=e.getSettings().computedPageTurnDirection,S=o.getSpineItemFromPosition(m)||t.getFocusedSpineItem(),C={...m,spineItem:S};if(!S)return C;const T=o.getSpineItemPositionFromSpinePosition(m,S),E=i.getNavigationForLeftPage(T,S);return!T.outsideOfBoundaries&&r(E,T)?o.getSpinePositionFromSpineItemPosition(E,S):a(e.isRTL()?h==="horizontal"?{x:m.x+e.getPageSize().width,y:0}:{y:m.y-e.getPageSize().height,x:0}:h==="horizontal"?{x:m.x-e.getPageSize().width,y:0}:{y:m.y-e.getPageSize().height,x:0})},b=m=>{const h=o.getSpineItemFromPosition(m)||t.getFocusedSpineItem();let S=g(m);if(h!=null&&h.isUsingVerticalWriting()&&m.x===S.x)return c(S);if(e.shouldDisplaySpread()){if(h!=null&&h.isUsingVerticalWriting()&&m.x!==S.x)return c(a(e.isRTL()?{...S,x:S.x-e.getPageSize().width}:{...S,x:S.x+e.getPageSize().width}));if(e.getSettings().computedPageTurnDirection==="vertical"&&m.y!==S.y)return c(S);S=g(S)}return c(S)},w=m=>{const h=o.getSpineItemFromPosition(m)||t.getFocusedSpineItem();let S=y(m);if(h!=null&&h.isUsingVerticalWriting()&&m.x===S.x)return c(S);if(e.shouldDisplaySpread()){if(h!=null&&h.isUsingVerticalWriting()&&m.x!==S.x)return c(a(e.isRTL()?{...S,x:S.x+e.getPageSize().width}:{...S,x:S.x-e.getPageSize().width}));if(e.getSettings().computedPageTurnDirection==="vertical"&&m.y!==S.y)return c(S);S=y(S)}return c(S)},p=m=>{var S;let h;try{h=m instanceof URL?m:new URL(m)}catch(C){L.error(C)}if(h){const C=`${h.origin}${h.pathname}`,T=(S=e.getManifest())==null?void 0:S.spineItems.find(E=>E.href===C);if(T){const E=t.get(T.id);if(E){const O=F(h.hash,E);return{...c(O),url:h}}}}},F=(m,h)=>{const S=o.getSpinePositionFromSpineItemAnchor(m,h);return c(S)},N=m=>{const h=o.getSpineItemFromPosition(m);if(h){const S=o.getSpineItemPositionFromSpinePosition(m,h),C=i.getNavigationForPosition(h,S),T=o.getSpinePositionFromSpineItemPosition(C,h);return c(T)}return{x:0,y:0}};return{getNavigationForCfi:u,getNavigationForPage:d,getNavigationForLastPage:l,getNavigationForSpineIndexOrId:f,getNavigationForRightPage:b,getNavigationForLeftPage:w,getNavigationForUrl:p,getNavigationForAnchor:F,getNavigationForPosition:N,getMostPredominantNavigationForPosition:m=>{const h=e.getSettings().computedPageTurnDirection,S=.5,C=h==="horizontal"?m.x+e.getVisibleAreaRect().width*S:0,T=h==="horizontal"?0:m.y+e.getVisibleAreaRect().height*S,E=a({x:C,y:T});return N(E)},wrapPositionWithSafeEdge:a,isNavigationGoingForwardFrom:(m,h)=>e.getSettings().computedPageTurnDirection==="vertical"?m.y>h.y:m.x>h.x,areNavigationDifferent:s,arePositionsDifferent:r}},Kt=200,mi=({context:e,element:t,navigator:n,currentNavigationSubject$:o,spine:i})=>{let r=!1;const s=w=>w.pipe(j(()=>r?(r=!1,!1):!0)),a=({x:w,y:p})=>e.getSettings().computedPageTurnMode==="scrollable"?(r=!0,t.scrollTo({left:w,top:p}),!0):!1,u=(w=>e.$.settings$.pipe(B(()=>e.getSettings().computedPageTurnMode),Z(),H(p=>v.iif(()=>p==="controlled",v.EMPTY,w))))(v.fromEvent(t,"scroll")).pipe(s,ee(),k(e.$.destroy$)),d=({x:w,y:p})=>{const F=i.element.getBoundingClientRect().width/i.element.offsetWidth;return{x:Ae({newScale:1,oldScale:F,screenSize:t.clientWidth,pageSize:i.element.scrollWidth,scrollOffset:w}),y:Ae({newScale:1,oldScale:F,screenSize:t.clientHeight,pageSize:i.element.scrollHeight,scrollOffset:p})}},l=w=>n.getMostPredominantNavigationForPosition(w),f=()=>d({x:t.scrollLeft,y:t.scrollTop}),g=u.pipe(je(Kt,v.animationFrameScheduler),te(o),H(()=>{const w=l(d({x:t.scrollLeft,y:t.scrollTop}));return v.of({position:w,animate:!1,lastUserExpectedNavigation:void 0})}),ee()),y=u.pipe(je(Kt,v.animationFrameScheduler),ee(),k(e.$.destroy$)),b=v.merge(u.pipe(B(()=>"start"),Z()),y.pipe(B(()=>"end"))).pipe(Ze("end"));return{destroy:()=>{},adjustReadingOffset:a,getNavigationForPosition:l,getCurrentViewportPosition:f,$:{state$:b,navigation$:g}}},Re="manualViewportNavigator",yi=({navigator:e,spineItemManager:t,currentNavigationSubject$:n,locator:o,context:i})=>{const r=new v.BehaviorSubject("end"),s=new v.Subject,a=({allowSpineItemChange:h=!0}={})=>s.next({type:"leftPage",data:{allowSpineItemChange:h}}),c=({allowSpineItemChange:h=!0}={})=>{s.next({type:"rightPage",data:{allowSpineItemChange:h}})},u=h=>s.next({type:"chapterPage",data:{pageIndex:h}}),d=h=>s.next({type:"pageIndex",data:{pageIndex:h}}),l=(h,S={animate:!0})=>s.next({type:"cfi",data:{cfi:h,...S}}),f=h=>s.next({type:"url",data:h}),g=(h,S={animate:!0})=>{s.next({type:"spineItem",data:{indexOrId:h,...S}})},y=s.pipe(j(h=>h.type==="url"),H(({data:h})=>{const S=e.getNavigationForUrl(h);return S?v.of({...S,animate:!0,lastUserExpectedNavigation:{type:"navigate-from-anchor",data:S.url.hash}}):v.EMPTY})),b=s.pipe(j(h=>h.type==="spineItem"),H(({data:{animate:h,indexOrId:S}})=>{const C=e.getNavigationForSpineIndexOrId(S),T={type:"navigate-from-previous-item"};return L.log(Re,"goToSpineItem",{indexOrId:S,animate:h,navigation:C}),v.of({...C,animate:h,lastUserExpectedNavigation:T})})),w=s.pipe(j(h=>h.type==="cfi"),B(({data:{animate:h,cfi:S}})=>{const C=e.getNavigationForCfi(S);return L.log(Re,"goToCfi",{cfi:S,animate:h,navigation:C}),{...C,animate:h,lastUserExpectedNavigation:{type:"navigate-from-cfi",data:S}}})),p=s.pipe(j(h=>h.type==="chapterPage"),H(({data:{pageIndex:h}})=>{const S=t.getFocusedSpineItem();if(S){const C=e.getNavigationForPage(h,S);return v.of({...C,lastUserExpectedNavigation:void 0,animate:!0})}return v.EMPTY})),F=s.pipe(j(h=>h.type==="pageIndex"),j(h=>{var S;return((S=i.getManifest())==null?void 0:S.renditionLayout)==="reflowable"?(L.warn("This method only works for pre-paginated content"),!1):!0}),H(({data:{pageIndex:h}})=>v.of({...e.getNavigationForPage(h),lastUserExpectedNavigation:void 0,animate:!0}))),N=L.measurePerformance("turnTo",10,(h,{allowSpineItemChange:S=!0}={})=>{const C=t.getFocusedSpineItem();if(!C)return v.EMPTY;const T=o.getSpineItemFromPosition(h)||C;if(T!==C){if(S)return t.comparePositionOf(T,C)==="before"?v.of({...h,lastUserExpectedNavigation:{type:"navigate-from-next-item"},animate:!0}):v.of({...h,lastUserExpectedNavigation:{type:"navigate-from-previous-item"},animate:!0})}else return v.of({...h,lastUserExpectedNavigation:void 0,animate:!0});return v.EMPTY}),$=s.pipe(j(h=>h.type==="leftPage"),te(n),H(([{data:{allowSpineItemChange:h}},S])=>{const C=e.getNavigationForLeftPage(S);return L.log(Re,"turnLeft"),N(C,{allowSpineItemChange:h})})),P=s.pipe(j(h=>h.type==="rightPage"),te(n),H(([{data:{allowSpineItemChange:h}},S])=>{const C=e.getNavigationForRightPage(S);return L.log(Re,"turnRight"),N(C,{allowSpineItemChange:h})})),m=v.merge(y,b,p,$,P,v.merge(w,F)).pipe(te(n),j(([h,S])=>e.areNavigationDifferent(h,S)),B(([h])=>h));return{destroy:()=>{},adjustReadingOffset:h=>!1,turnLeft:a,turnRight:c,goToCfi:l,goToPageOfCurrentChapter:u,goToSpineItem:g,goToUrl:f,goToPage:d,$:{state$:r.asObservable(),navigation$:m}}},vi="panViewportNavigator",bi=({getCurrentViewportPosition:e,navigator:t,spineItemManager:n,locator:o,context:i,currentNavigationSubject$:r})=>{const s=new v.Subject,a=new v.BehaviorSubject("end");let c={x:0,y:0},u={x:0,y:0};const d=new v.Subject,l=L.measurePerformance(`${vi} moveTo`,5,(w,{final:p,start:F}={})=>{if(i.getSettings().computedPageTurnMode==="scrollable"){L.warn("pan control is not available on free page turn mode");return}const N=i.getSettings().computedPageTurnDirection;F&&(a.next("start"),c={x:0,y:0},u=e());let $=r.value;if(w){const P=w.x-((c==null?void 0:c.x)||0),m=w.y-((c==null?void 0:c.y)||0);$=t.wrapPositionWithSafeEdge({x:N==="horizontal"?i.isRTL()?u.x+P:u.x-P:0,y:N==="horizontal"?0:u.y-m}),c=w}else $=e();if(u=$,p){c={x:0,y:0},f({from:r.value,to:$,pan:u}),a.next("end");return}d.next({position:$})},{disable:!1}),f=w=>{s.next({type:"snap",data:w})},g=L.measurePerformance("turnTo",10,(w,{allowSpineItemChange:p=!0}={})=>{const F=n.getFocusedSpineItem();if(!F)return;const N=o.getSpineItemFromPosition(w)||F;if(N!==F){if(p)return n.comparePositionOf(N,F)==="before"?{type:"navigate-from-next-item"}:{type:"navigate-from-previous-item"}}else return}),y=s.pipe(j(w=>w.type==="snap"),v.withLatestFrom(i.$.settings$),H(([{data:{from:w,to:p}},{navigationSnapThreshold:F}])=>{const N=i.getSettings().computedPageTurnDirection,P=t.isNavigationGoingForwardFrom(p,w)?1-F:F,m=N==="horizontal"?p.x+i.getVisibleAreaRect().width*P:0,h=N==="horizontal"?0:p.y+i.getVisibleAreaRect().height*P,S=t.wrapPositionWithSafeEdge({x:m,y:h}),C=t.getNavigationForPosition(S),T=g(C);return v.of({...C,lastUserExpectedNavigation:T})}));return{moveTo:l,destroy:()=>{d.complete(),a.complete()},adjustReadingOffset:w=>!1,$:{moveToSubject$:d,state$:a.asObservable(),navigation$:v.merge(y)}}},fe="viewportNavigator",Si=({spineItemManager:e,context:t,pagination:n,parentElement:o,cfiLocator:i,spineLocator:r,hooks$:s,spine:a})=>{const c=wi(o.ownerDocument,s);c.appendChild(a.element);const u=new v.Subject;let d;const l=new v.BehaviorSubject({x:-1,y:0}),f=hi({context:t,spineItemManager:e,cfiLocator:i,locator:r}),g=new v.Subject;o.appendChild(c);const y=L.measurePerformance(`${fe} getCurrentViewportPosition`,1,()=>{if(d&&(d==null||d.x,~~(Math.abs(c.getBoundingClientRect().x)*10)/10),t.getSettings().computedPageTurnMode==="scrollable")return w.getCurrentViewportPosition();const{x:I,y:D}=c.getBoundingClientRect();return d={x:~~(Math.abs(I)*10)/10,y:~~(Math.abs(D)*10)/10},d}),b=bi({context:t,element:c,navigator:f,spineItemManager:e,locator:r,getCurrentViewportPosition:y,currentNavigationSubject$:l}),w=mi({context:t,element:c,navigator:f,currentNavigationSubject$:l,spine:a,spineItemManager:e}),p=yi({context:t,element:c,navigator:f,currentNavigationSubject$:l,spineItemManager:e,locator:r}),F=[w,b,p],N=v.merge(...F.map(({$:{state$:I}})=>I));let $;const P=I=>(I.pipe(k(t.$.destroy$)).subscribe(),I),m=L.measurePerformance("adjustReadingOffset",2,({x:I,y:D},V)=>{d=void 0,F.reduce((Y,ue)=>ue.adjustReadingOffset({x:I,y:D})||Y,!1)||(t.isRTL()?c.style.transform=`translate3d(${I}px, -${D}px, 0)`:c.style.transform=`translate3d(-${I}px, -${D}px, 0)`),V.forEach(Y=>{Y.name==="onViewportOffsetAdjust"&&Y.fn()})},{disable:!0}),h=I=>{const D=n.getInfo().beginCfi;let V=l.value;const U=0;if(t.getSettings().computedPageTurnMode==="scrollable")V=w.getNavigationForPosition(y());else if(($==null?void 0:$.type)==="navigate-from-cfi")V=f.getNavigationForCfi($.data),L.log(fe,"adjustNavigation","navigate-from-cfi","use last cfi");else if(($==null?void 0:$.type)==="navigate-from-next-item")V=f.getNavigationForLastPage(I),L.log(fe,"adjustNavigation","navigate-from-next-item",{});else if(($==null?void 0:$.type)==="navigate-from-previous-item")V=f.getNavigationForPage(0,I),L.log(fe,"adjustNavigation","navigate-from-previous-item",{});else if(($==null?void 0:$.type)==="navigate-from-anchor"){const ue=$.data;V=f.getNavigationForAnchor(ue,I)}else if(D)V=f.getNavigationForCfi(D),L.log(fe,"adjustNavigation","use last cfi");else{const ue=n.getInfo().beginPageIndex||0;V=f.getNavigationForPage(ue,I),L.log(fe,"adjustNavigation","use guess strategy",{})}const Y=f.arePositionsDifferent(V,l.value);return L.log(fe,"adjustNavigation",{areDifferent:Y,offsetInSpineItem:U,expectedSpineOffset:V,currentNavigationPosition:l.value,lastUserExpectedNavigation:$}),Y&&g.next({position:V,animate:!1}),v.of({previousNavigationPosition:l.value,adjustedSpinePosition:V,areDifferent:Y})};u.subscribe(()=>{d=void 0});const S=t.$.settings$.pipe(Dt(["computedPageTurnDirection","computedPageTurnMode","numberOfAdjacentSpineItemToPreLoad"]),Z(ne),Ee(1));v.merge(u,S).pipe(W(()=>{t.getSettings().computedPageTurnMode==="scrollable"?(c.style.removeProperty("transform"),c.style.removeProperty("transition"),c.style.overflow="scroll"):(c.style.removeProperty("overflow"),c.style.removeProperty("overflowY")),e.layout()})).subscribe();const T=v.merge(b.$.navigation$.pipe(B(I=>({...I,position:{x:I.x,y:I.y,spineItem:I.spineItem},animation:"snap",triggeredBy:"manual"}))),p.$.navigation$.pipe(B(I=>({...I,position:{x:I.x,y:I.y,spineItem:I.spineItem},animation:I.animate?"turn":!1,triggeredBy:"manual"}))),g.pipe(B(I=>({...I,triggeredBy:"adjust",animation:I.animate?"turn":!1}))),w.$.navigation$.pipe(B(I=>({...I,triggeredBy:"scroll",animation:I.animate?"turn":!1})))).pipe(B(I=>("lastUserExpectedNavigation"in I&&($=I.lastUserExpectedNavigation),l.next(I.position),{...I,lastUserExpectedNavigation:$})),ee(),k(t.$.destroy$)),E=T.pipe(j(({triggeredBy:I})=>!(I==="scroll"||t.getSettings().computedPageTurnMode==="scrollable"&&I==="adjust"))),O=v.merge(b.$.moveToSubject$.asObservable().pipe(B(I=>({...I,animation:!1}))),E).pipe(B(({animation:I,position:D})=>({type:"manualAdjust",shouldAnimate:!(!I||I==="turn"&&t.getSettings().computedPageTurnAnimation==="none"),animation:I,position:D})),ee()),A=v.merge(O).pipe(Ze(void 0),Lt(),W(([I,D])=>{(I==null?void 0:I.type)==="manualAdjust"&&(D==null?void 0:D.type)!=="manualAdjust"&&(c.style.setProperty("transition","none"),c.style.setProperty("opacity","1"))}),H(([,I])=>{if((I==null?void 0:I.type)!=="manualAdjust")return v.EMPTY;const D=I.animation==="snap"?t.getSettings().computedSnapAnimationDuration:t.getSettings().computedPageTurnAnimationDuration,V=I.animation==="snap"?"slide":t.getSettings().computedPageTurnAnimation;return v.of(I).pipe(I.shouldAnimate?Xe(1,v.animationFrameScheduler):v.identity,W(U=>{U.shouldAnimate?V==="fade"?(c.style.setProperty("transition",`opacity ${D/2}ms`),c.style.setProperty("opacity","0")):(I.animation==="snap"||V==="slide")&&(c.style.setProperty("transition",`transform ${D}ms`),c.style.setProperty("opacity","1")):(c.style.setProperty("transition","none"),c.style.setProperty("opacity","1"))}),te(s),W(([U,Y])=>{V!=="fade"&&m(U.position,Y)}),I.shouldAnimate?Xe(D/2,v.animationFrameScheduler):v.identity,W(([U,Y])=>{V==="fade"&&(m(U.position,Y),c.style.setProperty("opacity","1"))}),I.shouldAnimate?Xe(D/2,v.animationFrameScheduler):v.identity,W(([U,Y])=>{V==="fade"&&m(U.position,Y)}),k(N.pipe(j(U=>U==="start"),Ee(1))))}),ee(),k(t.$.destroy$)),R=v.merge(v.merge(O).pipe(B(()=>"start")),v.merge(A).pipe(B(()=>"end"))),M=v.combineLatest([...F.map(({$:{state$:I}})=>I),R]).pipe(B(I=>I.every(D=>D==="end")?"free":"busy"),Z(),Ge(1),P),x=M.pipe(j(I=>I==="free"),v.take(1)),_=a.$.layout$.pipe(H(()=>x.pipe(H(()=>{const I=e.getFocusedSpineItem();return I?h(I):v.EMPTY}),k(T))),ee());return{destroy:()=>{u.complete(),g.complete(),l.complete(),F.forEach(I=>I.destroy())},layout:()=>u.next(),getCurrentNavigationPosition:()=>l.value,getCurrentViewportPosition:y,turnLeft:p.turnLeft,turnRight:p.turnRight,goToPage:p.goToPage,goToSpineItem:p.goToSpineItem,goToUrl:p.goToUrl,goToCfi:p.goToCfi,goToPageOfCurrentChapter:p.goToPageOfCurrentChapter,adjustNavigation:h,moveTo:b.moveTo,getLastUserExpectedNavigation:()=>$,element:c,$:{state$:M,navigation$:T,navigationAdjustedAfterLayout$:_,currentNavigationPosition$:l.asObservable()}}},wi=(e,t)=>{const n=e.createElement("div");return n.style.cssText=`
|
|
251
|
+
height: 100%;
|
|
252
|
+
position: relative;
|
|
253
|
+
`,n.className=`${Oe}-viewport-navigator`,t.getValue().reduce((o,i)=>i.name==="viewportNavigator.onBeforeContainerCreated"?i.fn(o):o,n)},Pi=({spineItemManager:e,context:t,spineItemLocator:n})=>{const o=L.measurePerformance("getSpineItemPositionFromSpinePosition",10,(l,f)=>{const{leftEnd:g,leftStart:y,topStart:b,topEnd:w}=e.getAbsolutePositionOf(f);return t.isRTL()?{x:g-l.x-t.getPageSize().width,y:Math.max(0,l.y-b)}:{x:Math.max(0,l.x-y),y:Math.max(0,l.y-b)}},{disable:!0}),i=(l,f)=>{const{leftEnd:g,leftStart:y,topStart:b,topEnd:w}=e.getAbsolutePositionOf(f);return t.isRTL()?{x:g-l.x-t.getPageSize().width,y:b+l.y}:{x:y+l.x,y:b+l.y}},r=L.measurePerformance("getSpineItemFromOffset",10,l=>e.getSpineItemAtPosition(l),{disable:!0});return{getSpinePositionFromSpineItemPosition:i,getSpinePositionFromSpineItem:l=>i({x:0,y:0},l),getSpinePositionFromSpineItemAnchor:(l,f)=>{const g=n.getSpineItemOffsetFromAnchor(l,f);return i({x:g,y:0},f)},getSpineItemPositionFromSpinePosition:o,getSpineItemFromPosition:r,getSpineItemFromIframe:l=>e.getAll().find(f=>f.spineItemFrame.getFrameElement()===l),getSpineItemPageIndexFromNode:(l,f,g)=>{if(typeof g=="number"){const y=e.get(g);return y?n.getSpineItemPageIndexFromNode(l,f||0,y):void 0}return n.getSpineItemPageIndexFromNode(l,f||0,g)},getSpineItemsFromReadingOrderPosition:l=>{const f=r(l)||e.getFocusedSpineItem(),g=e.getSpineItemIndex(f);if(g===void 0)return;let y=l;t.shouldDisplaySpread()&&(y={x:l.x+t.getPageSize().width,y:l.y});const b=e.getSpineItemIndex(r(y)||e.getFocusedSpineItem())??g,[w=g,p=g]=[g,b].sort((F,N)=>F-N);return{begin:g,beginPosition:l,end:b,endPosition:y,left:w,right:p}}}},Ii=({spineItemManager:e,spineItemLocator:t})=>{const n=u=>`|[prose~anchor~${encodeURIComponent(u.item.id)}]`,o=L.measurePerformance("getCfi",10,(u,d)=>{var b,w,p;const l=t.getFirstNodeOrRangeAtPage(u,d),f=(p=(w=(b=d.spineItemFrame.getManipulableFrame())==null?void 0:b.frame)==null?void 0:w.contentWindow)==null?void 0:p.document,g=n(d),y=`|[prose~offset~${(l==null?void 0:l.offset)||0}]`;return l&&f?ye.generate(l.node,0,`${g}${y}`):i(d)}),i=u=>`epubcfi(/0${n(u)}) `,r=u=>{const{itemId:d}=it(u);if(d){const{itemId:l}=it(u);return(l?e.get(l):void 0)||e.get(0)}};return{getSpineItemFromCfi:r,getCfiMetaInformation:u=>{const d=r(u);if(d)return{spineItemIndex:e.getSpineItemIndex(d)}},getCfi:o,getRootCfi:i,resolveCfi:u=>{var w,p,F;if(!u)return;const d=r(u),l=e.getSpineItemIndex(d)||0;if(!d)return;const{cleanedCfi:f,offset:g}=it(u),y=new ye(f,{}),b=(F=(p=(w=d.spineItemFrame.getManipulableFrame())==null?void 0:w.frame)==null?void 0:p.contentWindow)==null?void 0:F.document;if(b)try{const{node:N,offset:$}=y.resolve(b,{});return{node:N,offset:g??$,spineItemIndex:l}}catch(N){return L.error(N),{spineItemIndex:l}}return{spineItemIndex:l}},generateFromRange:({startNode:u,start:d,end:l,endNode:f},g)=>{const y=ye.generate(u,d,`|[prose~anchor~${encodeURIComponent(g.id)}]`),b=ye.generate(f,l,`|[prose~anchor~${encodeURIComponent(g.id)}]`);return{start:y,end:b}}}},$i="proseReaderIframeEventBridgeElement",Qt=({containerElement:e,hooks:t,...n})=>{const o=new v.BehaviorSubject({supportedPageTurnAnimation:["fade","none","slide"],supportedPageTurnMode:["controlled","scrollable"],supportedPageTurnDirection:["horizontal","vertical"],supportedComputedPageTurnDirection:["horizontal","vertical"]}),i=new v.Subject,r=new v.Subject,s=new v.Subject,a=new v.BehaviorSubject(t||[]),c=new v.Subject,u=new v.Subject,d=new v.BehaviorSubject({x:0,y:0}),l=new v.BehaviorSubject("free"),f=Io(n),g=gi({context:f}),y=fo({context:f,spineItemManager:g}),b=Ti(e),w=Ci(e),p=Zt({context:f}),F=Pi({context:f,spineItemManager:g,spineItemLocator:p}),N=Ii({spineItemManager:g,context:f,spineItemLocator:p}),$=c.asObservable(),P=ui({ownerDocument:b.ownerDocument,iframeEventBridgeElement:w,context:f,pagination:y,spineItemManager:g,hooks$:a,navigation$:$,spineLocator:F,spineItemLocator:p,cfiLocator:N,navigationAdjusted$:u.asObservable(),viewportState$:l.asObservable(),currentNavigationPosition$:d.asObservable()}),m=Si({context:f,pagination:y,spineItemManager:g,parentElement:b,cfiLocator:N,spineLocator:F,hooks$:a,spine:P});e.appendChild(b),b.appendChild(w),m.$.state$.subscribe(l),m.$.navigation$.subscribe(c),m.$.navigationAdjustedAfterLayout$.subscribe(u),m.$.currentNavigationPosition$.subscribe(d);const h=()=>{const A={width:e.offsetWidth,height:e.offsetHeight},R=0,M=0,x=0,_=!0,z=A.width,I=z%2===0||_?z:z-1;b.style.setProperty("overflow","hidden"),b.style.height=`${A.height-M-x}px`,b.style.width=`${I-2*R}px`;const D=b.getBoundingClientRect();f.setVisibleAreaRect(D.x,D.y,I,A.height),m.layout()},S=(A,R={})=>{if(f.getManifest()){L.warn("loading a new book is not supported yet");return}L.log("load",{manifest:A,loadOptions:R}),f.load(A,R),h(),R.cfi?m.goToCfi(R.cfi,{animate:!1}):m.goToSpineItem(0,{animate:!1}),i.next()},C=(A,R)=>{a.next([...a.getValue(),{name:A,fn:R}])},T=A=>{A(b)};P.$.$.pipe(W(A=>{A.type==="onSelectionChange"&&s.next(A.data)}),k(r)).subscribe(),m.$.navigationAdjustedAfterLayout$.pipe(v.switchMap(({adjustedSpinePosition:A})=>P.adjustPagination(A).pipe(k($))),k(f.$.destroy$)).subscribe(),v.merge(f.$.load$,f.$.settings$,f.$.hasVerticalWriting$).pipe(de(void 0),te(f.$.hasVerticalWriting$),B(([,A])=>{const R=f.getSettings(),M=f.getManifest();return{hasVerticalWriting:A,renditionFlow:M==null?void 0:M.renditionFlow,renditionLayout:M==null?void 0:M.renditionLayout,computedPageTurnMode:R.computedPageTurnMode}}),Z(ne),B(({hasVerticalWriting:A,renditionFlow:R,renditionLayout:M,computedPageTurnMode:x})=>({...o.value,supportedPageTurnMode:R==="scrolled-continuous"?["scrollable"]:f.areAllItemsPrePaginated()?["controlled","scrollable"]:["controlled"],supportedPageTurnAnimation:R==="scrolled-continuous"||x==="scrollable"?["none"]:A?["fade","none"]:["fade","none","slide"],supportedPageTurnDirection:x==="scrollable"?["vertical"]:M==="reflowable"?["horizontal"]:["horizontal","vertical"]})),k(r)).subscribe(o);const E=()=>{a.next([]),a.complete(),y.destroy(),f.destroy(),m.destroy(),P.destroy(),b.remove(),w.remove(),i.complete(),o.complete(),s.complete(),r.next(),r.complete()};return{context:f,registerHook:C,spine:P,viewportNavigator:m,manipulateSpineItems:P.manipulateSpineItems,manipulateSpineItem:P.manipulateSpineItem,manipulateContainer:T,moveTo:m.moveTo,turnLeft:m.turnLeft,turnRight:m.turnRight,goToPageOfCurrentChapter:m.goToPageOfCurrentChapter,goToPage:m.goToPage,goToUrl:m.goToUrl,goToCfi:m.goToCfi,goToSpineItem:m.goToSpineItem,getFocusedSpineItemIndex:g.getFocusedSpineItemIndex,getSpineItem:g.get,getSpineItems:g.getAll,getAbsolutePositionOf:g.getAbsolutePositionOf,getSelection:P.getSelection,isSelecting:P.isSelecting,normalizeEventForViewport:P.normalizeEventForViewport,getCfiMetaInformation:P.cfiLocator.getCfiMetaInformation,resolveCfi:P.cfiLocator.resolveCfi,generateCfi:P.cfiLocator.generateFromRange,locator:P.locator,getCurrentNavigationPosition:m.getCurrentNavigationPosition,getCurrentViewportPosition:m.getCurrentViewportPosition,layout:h,load:S,destroy:E,setSettings:f.setSettings,$:{pagination$:y.$.info$,settings$:f.$.settings$,state$:o.asObservable(),ready$:i.asObservable(),selection$:s.asObservable(),viewportState$:m.$.state$,layout$:P.$.layout$,itemsCreated$:P.$.itemsCreated$,itemsBeforeDestroy$:P.$.itemsBeforeDestroy$,itemIsReady$:g.$.itemIsReady$,destroy$:r},__debug:{pagination:y,context:f,spineItemManager:g}}},Ti=e=>{const t=e.ownerDocument.createElement("div");return t.style.cssText=`
|
|
254
|
+
background-color: white;
|
|
255
|
+
position: relative;
|
|
256
|
+
`,t.className=`${Oe}-reader`,t},Ci=e=>{const t=e.ownerDocument.createElement("div");return t.id=$i,t.style.cssText=`
|
|
257
|
+
position: absolute;
|
|
258
|
+
height: 100%;
|
|
259
|
+
width: 100%;
|
|
260
|
+
top: 0;
|
|
261
|
+
left: 0;
|
|
262
|
+
z-index: -1;
|
|
263
|
+
`,t},Ei=e=>t=>({...e(t),utils:{isOrIsWithinValidLink:i=>{if(_o(i)){const r=i.nodeName==="a"?i:i.closest("a");if(r!=null&&r.getAttribute("href"))return!0}return!1}}}),Fi=e=>({put:(r,s)=>new Promise((a,c)=>{const u=e.transaction(["store"],"readwrite");u.onerror=function(f){c(f)},u.oncomplete=function(){a()};const l=u.objectStore("store").put(s,r);l.onsuccess=()=>{a()},l.onerror=f=>{c(f)}}),keys:()=>new Promise((r,s)=>{const a=e.transaction(["store"],"readonly");a.onerror=function(l){s(l)};const u=a.objectStore("store").openKeyCursor(),d=[];u.onsuccess=()=>{const l=u.result;if(!l){r(d);return}d.push(l.key),l.continue()},u.onerror=()=>{s(u.error)}}),get:r=>new Promise((s,a)=>{const c=e.transaction(["store"],"readwrite"),d=c.objectStore("store").get(r);d.onsuccess=()=>{let l=d.result;l===void 0&&(l=null),s(l)},c.onerror=function(){a(d.error)}}),remove:r=>new Promise((s,a)=>{const c=e.transaction(["store"],"readwrite"),d=c.objectStore("store").delete(r);c.onerror=function(){a(d.error)},c.oncomplete=function(){s()},c.onabort=function(){var f;const l=d.error?d.error:(f=d.transaction)==null?void 0:f.error;a(l)}})}),rt=async e=>new Promise((t,n)=>{const o=window.indexedDB.open(e);o.onerror=function(i){n(i)},o.onsuccess=function(){t(Fi(o.result))},o.onupgradeneeded=()=>{o.result.createObjectStore("store")}}),xi=e=>{let t=Date.now().toString();const n=new v.Subject,o=c=>{var u,d;if(typeof c=="string"||typeof c=="object"){const l=typeof c=="object"?c.id:void 0;return(u=e.getManifest())==null?void 0:u.spineItems.find(f=>f.id===l)}else return(d=e.getManifest())==null?void 0:d.spineItems[c]},i=async(c,u)=>{const d=o(c);if(!d)return new Response("Item not found",{status:404});const f=await(await rt("prose-reader")).get(`${t}_${d.id}`);if(f)return new Response(f,{status:200});const g=u&&await u(d)||await fetch(d.href);return r(d,g.clone()),g},r=(c,u)=>{n.next({id:c,data:u})};n.asObservable().pipe(se(({id:c,data:u})=>{const d=o(c);return d?v.from(v.forkJoin([rt("prose-reader"),v.from(u.blob())])).pipe(H(([l,f])=>v.from(l.put(`${t}_${d.id}`,f))),Ce(l=>(L.error(l),v.EMPTY))):v.EMPTY}),k(e.$.destroy$)).subscribe();const s=e.$.load$.pipe(W(()=>{t=Date.now().toString()}));return v.merge(s).pipe(H(()=>(L.log("Cleanup up old cache..."),v.from(rt("prose-reader")).pipe(H(c=>v.from(c.keys()).pipe(B(u=>u.filter(d=>!d.toString().startsWith(t))),H(u=>{const d=u.map(l=>c.remove(l));return v.from(Promise.all(d))}))),Ce(c=>(L.error(c),v.EMPTY))))),k(e.$.destroy$)).subscribe(),{get:i,destroy:()=>{n.complete()}}},Ai=e=>t=>{const n=e(t),o=xi(n.context),i=(s,a)=>{n.load(s,{...a})};return n.registerHook("item.onGetResource",s=>async a=>o.get(a,s)),{...n,destroy:()=>{o.destroy(),n.destroy()},load:i}},Oi=e=>t=>{const n=e(t),o=new IntersectionObserver(s=>{s.forEach(a=>{var d;const c=a.target,u=Array.from(((d=c.contentDocument)==null?void 0:d.body.getElementsByTagName("audio"))||[]);a.isIntersecting?u.forEach(l=>{l.hasAttribute("autoplay")&&l.paused&&l.readyState>=2&&l.play().catch(console.error)}):u.forEach(l=>{l.pause(),l.currentTime=0})})},{threshold:.01}),i=new IntersectionObserver(s=>{s.forEach(a=>{if(a.target.tagName==="video"){const c=a.target;a.isIntersecting?c.hasAttribute("autoplay")&&c.paused&&c.readyState>=2&&c.play().catch(console.error):(c.pause(),c.currentTime=0)}})},{threshold:.5});return n.registerHook("item.onLoad",({frame:s})=>{var u;o.observe(s);const a=(u=s.contentDocument)==null?void 0:u.body.getElementsByTagName("video"),c=Array.from(a||[]).map(d=>(i.observe(d),()=>i.unobserve(d)));return()=>{o.unobserve(s),c.forEach(d=>d())}}),{...n,destroy:()=>{o.disconnect(),i.disconnect(),n.destroy()}}},Ni=e=>t=>{const n=e(t),o=(s,a,c,u,d,l)=>{var F,N,$,P,m,h;const f=((F=s.getManifest())==null?void 0:F.renditionLayout)==="pre-paginated",g=((N=s.getManifest())==null?void 0:N.spineItems.length)||0,y=(($=s.getManifest())==null?void 0:$.spineItems.slice(0,a).reduce((S,C)=>S+C.progressionWeight,0))||0,b=((m=(P=s.getManifest())==null?void 0:P.spineItems[a])==null?void 0:m.progressionWeight)||0;let w=(u+1)*(b/c);!f&&l.item.renditionLayout==="reflowable"&&!l.isReady()&&(w=0);let p=y+w;return((h=s.getManifest())==null?void 0:h.renditionFlow)==="scrolled-continuous"&&(l.isReady()?w=r(s,d,l):w=0,p=i(y,b,w)),a===g-1&&u===c-1&&p>.99?1:p},i=(s,a,c)=>s+a*c,r=(s,a,c)=>{const{height:u,width:d}=c.getElementDimensions(),{topStart:l,leftStart:f}=n.getAbsolutePositionOf(c);return s.getSettings().computedPageTurnDirection==="vertical"?Math.max(0,Math.min(1,(a.y-l+s.getVisibleAreaRect().height)/u)):Math.max(0,Math.min(1,(a.x-f+s.getVisibleAreaRect().width)/d))};return{...n,progression:{getPercentageEstimate:o,getScrollPercentageWithinItem:r}}},Ri=e=>t=>{const n=e(t),o=new IntersectionObserver(i=>{i.forEach(r=>{r.isIntersecting?r.target.removeAttribute("tab-index"):r.target.setAttribute("tab-index","-1")})},{});return n.registerHook("item.onLoad",({addStyle:i,frame:r})=>{var a;i("prose-reader-accessibility",`
|
|
264
|
+
:focus-visible {
|
|
265
|
+
|
|
266
|
+
outline: -webkit-focus-ring-color auto 1px;
|
|
267
|
+
}
|
|
268
|
+
`);const s=(a=r.contentDocument)==null?void 0:a.body.querySelectorAll("a");return s==null||s.forEach(c=>{o.observe(c)}),()=>{s==null||s.forEach(c=>{o.unobserve(c)})}}),{...n}},Li=navigator.userAgent.indexOf("")>-1&&navigator.userAgent.indexOf("Chrome")<=-1,Di=e=>t=>{const n=[{name:"viewportNavigator.onBeforeContainerCreated",fn:i=>(i.style.cssText=`
|
|
269
|
+
${i.style.cssText}
|
|
270
|
+
-webkit-transform-style: preserve-3d;
|
|
271
|
+
`,i)},{name:"item.onBeforeContainerCreated",fn:i=>(i.style.cssText=`
|
|
272
|
+
${i.style.cssText}
|
|
273
|
+
-webkit-transform-style: preserve-3d;
|
|
274
|
+
-webkit-backface-visibility: hidden;
|
|
275
|
+
`,i)}];return e({...t,...Li&&{hooks:[...t.hooks||[],...n]}})},_i=`${`${Oe}-enhancer-loading`}-container`,Mi=e=>t=>{const{loadingElementCreate:n=ki,...o}=t,i=e(o),r=d=>v.of(d.reduce((l,{item:f,element:g})=>{const y=n({container:Vi(g,i.context),item:f});return g.appendChild(y),{...l,[f.id]:y}},{})),s=d=>v.combineLatest([i.$.layout$,i.theme.$.theme$]).pipe(B(([,l])=>({width:i.context.getVisibleAreaRect().width,theme:l})),Z(ne),W(({width:l,theme:f})=>{Object.values(d).forEach(g=>{g.style.setProperty("max-width",`${l}px`),g.style.setProperty("color",f==="sepia"?"#939393":"rgb(202, 202, 202)")})})),a=d=>i.$.itemIsReady$.pipe(W(({item:l,isReady:f})=>{var g;(g=d[l.id])==null||g.style.setProperty("visibility",f?"hidden":"visible")})),c=d=>i.$.itemsBeforeDestroy$.pipe(B(()=>(Object.values(d).forEach(l=>l.remove()),{}))),u=i.$.itemsCreated$.pipe(H(d=>r(d)),Ge(1),k(i.context.$.destroy$));return u.pipe(H(d=>v.merge(v.of(d),c(d))),H(d=>v.merge(s(d),a(d))),k(i.$.destroy$)).subscribe(),{...i,loading:{$:{items$:u}}}},Vi=(e,t)=>{const n=e.ownerDocument.createElement("div");return n.classList.add(_i),n.style.cssText=`
|
|
276
|
+
height: 100%;
|
|
277
|
+
width: 100%;
|
|
278
|
+
max-width: ${t.getVisibleAreaRect().width}px;
|
|
279
|
+
text-align: center;
|
|
280
|
+
display: flex;
|
|
281
|
+
justify-content: center;
|
|
282
|
+
align-items: center;
|
|
283
|
+
flex-direction: column;
|
|
284
|
+
position: absolute;
|
|
285
|
+
left: 0;
|
|
286
|
+
top: 0;
|
|
287
|
+
color: rgb(202, 202, 202);
|
|
288
|
+
-background-color: white;
|
|
289
|
+
`,n},ki=({container:e,item:t})=>{const n=e.ownerDocument.createElement("div");n.innerText="prose",n.style.cssText=`
|
|
290
|
+
font-size: 4em;
|
|
291
|
+
`;const o=e.ownerDocument.createElement("div");return o.innerText=`loading ${t.id}`,o.style.cssText=`
|
|
292
|
+
font-size: 1.2em;
|
|
293
|
+
text-overflow: ellipsis;
|
|
294
|
+
white-space: nowrap;
|
|
295
|
+
overflow: hidden;
|
|
296
|
+
max-width: 300px;
|
|
297
|
+
width: 80%;
|
|
298
|
+
`,e.appendChild(n),e.appendChild(o),e},en=e=>{const{context:t,manipulateContainer:n,manipulateSpineItems:o,getFocusedSpineItemIndex:i,getCurrentNavigationPosition:r,getSpineItem:s,locator:a,getAbsolutePositionOf:c,generateCfi:u,resolveCfi:d,getCfiMetaInformation:l,spine:f,...g}=e;return g},tn=Je(Ni,ho,Jn,yo,uo,nn,Oi,So,so,Ei,Ai,Ri,co,Gn,Di,Mi);function Bi(e,t){if(!t){const i=tn(Qt);return en(i(e))}const o=Je(tn,t)(Qt);return en(o(e))}K.Report=L,K.compose=Bt,K.composeEnhancer=Je,K.createReader=Bi,K.groupBy=no,K.isShallowEqual=ne,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})});
|
|
299
|
+
//# sourceMappingURL=prose.umd.cjs.map
|