flipbookengine 0.4.0 → 0.5.0
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/CHANGELOG.md +11 -1
- package/README.md +43 -43
- package/dist/adapters/PageFlipAdapter.d.ts +2 -0
- package/dist/core/PdfRenderCache.d.ts +22 -0
- package/dist/core/PdfRenderer.d.ts +8 -0
- package/dist/{engine-G9HiVpA-.js → engine-BuVkDIh-.js} +797 -672
- package/dist/engine-BuVkDIh-.js.map +1 -0
- package/dist/engine.d.ts +7 -0
- package/dist/flipbook-engine.css +1 -1
- package/dist/flipbook-engine.iife.js +24 -24
- package/dist/flipbook-engine.iife.js.map +1 -1
- package/dist/flipbook-engine.js +1 -1
- package/dist/flipbook-engine.react.js +1 -1
- package/dist/flipbook-engine.vue.js +1 -1
- package/package.json +5 -4
- package/dist/engine-G9HiVpA-.js.map +0 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var Se=S=>{throw TypeError(S)};var vi=(S,C,R)=>C in S?wi(S,C,{enumerable:!0,configurable:!0,writable:!0,value:R}):S[C]=R;var v=(S,C,R)=>vi(S,typeof C!="symbol"?C+"":C,R),Bt=(S,C,R)=>C.has(S)||Se("Cannot "+R);var U=(S,C,R)=>(Bt(S,C,"read from private field"),R?R.call(S):C.get(S)),St=(S,C,R)=>C.has(S)?Se("Cannot add the same private member more than once"):C instanceof WeakSet?C.add(S):C.set(S,R),Pt=(S,C,R,et)=>(Bt(S,C,"write to private field"),et?et.call(S,R):C.set(S,R),R),lt=(S,C,R)=>(Bt(S,C,"access private method"),R);var at,$,B,_t,Gt,xe;function R(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const et=R(C);var Pe=Symbol.for("preact-signals");function kt(){if(V>1)V--;else{var e,t=!1;for(function(){var r=ut;for(ut=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();it!==void 0;){var s=it;for(it=void 0,dt++;s!==void 0;){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&Vt(s))try{s.c()}catch(r){t||(e=r,t=!0)}s=o}}if(dt=0,V--,t)throw e}}var T=void 0;function ct(e){var t=T;T=void 0;try{return e()}finally{T=t}}var it=void 0,V=0,dt=0,jt=0,ut=void 0,gt=0;function Ut(e){if(T!==void 0){var t=e.n;if(t===void 0||t.t!==T)return t={i:0,S:e,p:T.s,n:void 0,t:T,e:void 0,x:void 0,r:t},T.s!==void 0&&(T.s.n=t),T.s=t,e.n=t,32&T.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=T.s,t.n=void 0,T.s.n=t,T.s=t),t}}function z(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}z.prototype.brand=Pe,z.prototype.h=function(){return!0},z.prototype.S=function(e){var t=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:ct(function(){var o;(o=t.W)==null||o.call(t)}))},z.prototype.U=function(e){var t=this;if(this.t!==void 0){var s=e.e,o=e.x;s!==void 0&&(s.x=o,e.e=void 0),o!==void 0&&(o.e=s,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&ct(function(){var r;(r=t.Z)==null||r.call(t)}))}},z.prototype.subscribe=function(e){var t=this;return X(function(){var s=t.value;ct(function(){return e(s)})},{name:"sub"})},z.prototype.valueOf=function(){return this.value},z.prototype.toString=function(){return this.value+""},z.prototype.toJSON=function(){return this.value},z.prototype.peek=function(){var e=this;return ct(function(){return e.value})},Object.defineProperty(z.prototype,"value",{get:function(){var e=Ut(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(dt>100)throw new Error("Cycle detected");(function(s){V!==0&&dt===0&&s.l!==jt&&(s.l=jt,ut={S:s,v:s.v,i:s.i,o:ut})})(this),this.v=e,this.i++,gt++,V++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{kt()}}}});function I(e,t){return new z(e,t)}function Vt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Zt(e){for(var t=e.s;t!==void 0;t=t.n){var s=t.S.n;if(s!==void 0&&(t.r=s),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Xt(e){for(var t=e.s,s=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):s=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=s}function Z(e,t){z.call(this,void 0,t),this.x=e,this.s=void 0,this.g=gt-1,this.f=4}Z.prototype=new z,Z.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===gt))return!0;if(this.g=gt,this.f|=1,this.i>0&&!Vt(this))return this.f&=-2,!0;var e=T;try{Zt(this),T=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return T=e,Xt(this),this.f&=-2,!0},Z.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}z.prototype.S.call(this,e)},Z.prototype.U=function(e){if(this.t!==void 0&&(z.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Z.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Z.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ut(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function m(e,t){return new Z(e,t)}function qt(e){var t=e.m;if(e.m=void 0,typeof t=="function"){V++;var s=T;T=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Ct(e),o}finally{T=s,kt()}}}function Ct(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,qt(e)}function ke(e){if(T!==this)throw new Error("Out-of-order effect");Xt(this),T=e,this.f&=-2,8&this.f&&Ct(this),kt()}function K(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}K.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}},K.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,qt(this),Zt(this),V++;var e=T;return T=this,ke.bind(this,e)},K.prototype.N=function(){2&this.f||(this.f|=2,this.u=it,it=this)},K.prototype.d=function(){this.f|=8,1&this.f||Ct(this)},K.prototype.dispose=function(){this.d()};function X(e,t){var s=new K(e,t);try{s.c()}catch(r){throw s.d(),r}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}var Yt=Symbol.for("Serenity.initPropHook");function Ce(e){return!!(e&&typeof e.nodeType=="number")}function pt(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function W(e){return typeof e=="object"&&e!==null}function Te(e){return!!(e&&e.isComponent)}function Tt(e){return W(e)&&typeof e.length=="number"&&typeof e.nodeType!="number"}function Ae(e){return typeof e=="function"&&typeof e[Yt]=="function"}function st(e){return e!=null&&typeof e!="boolean"}function nt(e){return Array.isArray(e)?e.map(nt).filter(Boolean).join(" "):W(e)?Symbol.iterator in e?nt(Array.from(e)):Object.keys(e).filter(t=>e[t]).join(" "):st(e)?""+e:""}function Ee(e){return e!=null&&typeof e=="object"&&"current"in e}function At(e,t){Ee(e)?e.current=t:typeof e=="function"&&e(t)}function Me(e,t,s){t={...t,children:s};const o=new e(t),r=o.render();return"ref"in t&&At(t.ref,o),r}var De="http://www.w3.org/1998/Math/MathML",Ie=new Set(["math","annotation","annotation-xml","maction","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics","menclose","mfenced"]),Re=new Set(["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view"]),Kt=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/,Le="http://www.w3.org/2000/svg",Jt=Symbol.for("Serenity.jsxNamespaceURI");function ze(e){const t=globalThis[Jt];return arguments.length&&(globalThis[Jt]=e),t}var Fe=Symbol.for("Serenity.jsxTypeKey"),Oe="ShadowRoot";function We(e){return e!=null&&e[Fe]===Oe}var Et=Symbol.for("Serenity.disposingListeners"),Mt=Symbol.for("Serenity.lifecycleRoot");function Dt(){return globalThis[Et]||(globalThis[Et]=new WeakMap)}function It(e){e&&e.target&&(!e.currentTarget||e.currentTarget===e.target)&&$e(e==null?void 0:e.target)}function $e(e,t){if(!e)return;const s=Dt();function o(r){const c=s.get(r);if(c){s.delete(r),r.removeEventListener("disposing",It);for(const g of c)try{g.callback(r)}catch{}}}o(e)}function Rt(e,t,s){if(!e||!t)return e;const o=Dt();let r=o.get(e);if(!r)return typeof e.addEventListener!="function"||(o.set(e,r=[{callback:t,regKey:s}]),e.addEventListener("disposing",It,{once:!0})),e;const c=r.find(g=>g.callback===t);return c?(c.regKey,e):(r.push({callback:t,regKey:s}),e)}function te(e,t,s){if(!e||!t)return e;const o=Dt(),r=o.get(e);if(r){for(let c=r.length-1;c>=0;c--){const g=r[c];t&&t===g.callback&&r.splice(c,1)}r.length===0&&(o.delete(e),typeof e.removeEventListener=="function"&&e.removeEventListener("disposing",It))}return e}function Ne(...e){if(e.length>0){const t=globalThis[Mt]||null;return globalThis[Mt]=e[0]||null,t}return globalThis[Mt]||null}function q(e){return e!=null&&typeof e=="object"&&typeof e.subscribe=="function"&&typeof e.peek=="function"&&"value"in e}var He=(xe=class{constructor(e,t,s){St(this,B);St(this,at);St(this,$);this.signal=e,this.isInitial=!0,this.hasChanged=!1,this.lifecycleRoot=t,Pt(this,$,s)}get lifecycleNode(){return U(this,$)}get effectDisposer(){return U(this,at)}set effectDisposer(e){lt(this,B,_t).call(this),Pt(this,at,e),lt(this,B,Gt).call(this)}set lifecycleNode(e){e!==U(this,$)&&(lt(this,B,_t).call(this),Pt(this,$,e),lt(this,B,Gt).call(this))}},at=new WeakMap,$=new WeakMap,B=new WeakSet,_t=function(){var e;te(U(this,$),this.effectDisposer),te(U(this,$),(e=this.signal)==null?void 0:e.derivedDisposer)},Gt=function(){var e;Rt(U(this,$),this.effectDisposer),Rt(U(this,$),(e=this.signal)==null?void 0:e.derivedDisposer)},xe);function ot(e,t,s){const o=s!=null&&s.useLifecycleRoot?Ne():void 0,r=new He(e,o,s==null?void 0:s.lifecycleNode),c=r.signal.subscribe(function(g){r.newValue=g,r.isInitial&&(this!=null&&this.dispose)&&(r.effectDisposer=this.dispose.bind(this)),r.hasChanged=!r.isInitial&&r.prevValue!==r.newValue;try{t(r)}finally{r.prevValue=r.newValue,r.isInitial=!1}});return c&&!r.effectDisposer&&(r.effectDisposer=c),r.effectDisposer}function ee(e,t){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}var Lt=0,zt="__domwisefrag_";function ie(e){return e instanceof Comment&&e.data.startsWith(zt)}function se(e){return e instanceof DocumentFragment&&ie(e.firstChild)}function Be(e,t){var s;typeof e.replaceWith=="function"?e.replaceWith(t):(s=e.parentNode)==null||s.replaceChild(t,e)}function ne(e){return e instanceof DocumentFragment?(++Lt,e.prepend(document.createComment(zt+Lt)),e.append(document.createComment(zt+Lt)),e):e instanceof Node?e:st(e)?document.createTextNode(e):document.createComment("")}function _e(e,t){let s;ot(t,o=>{var g;if(o.isInitial){s=ne(o.newValue);let f=se(s)?s.firstChild:s;ft(e,s),o.lifecycleNode=(s=f)??e;return}if(!o.hasChanged)return;const r=ne(o.newValue);if(ie(s)){let f;for(;(f=s.nextSibling)&&((g=f.parentNode)==null||g.removeChild(f),!(f instanceof Comment&&f.data===s.data)););}let c=se(r)?r.firstChild:r;Be(s,r),o.lifecycleNode=(s=c)??e})}function ft(e,t){if(st(t))if(Tt(t))for(const s of[...t])ft(e,s);else if(pt(t)||Qt(t))ee(e,document.createTextNode(t));else if(Ce(t))ee(e,t);else if(We(t)){const s=e.attachShadow(t.attr);ft(s,t.children),At(t.ref,s)}else q(t)&&_e(e,t)}function oe(e){return e==null||(Tt(e)?e=Array.from(e).map(t=>q(t)?t.peek():t):W(e)&&(e={...e},Object.entries(e).forEach(([t,s])=>{q(s)&&(e[t]=s.peek())}))),e}function Ge(e,t){if(t==null||t===!1||t===!0)return;t=oe(t);const s=(nt(t)??"").split(" ");for(let o of s)o&&e.classList.remove(o)}function je(e,t,s){if(t==null||t===!1){Ge(e,s);return}s=oe(s),Tt(t)?t=Array.from(t).map(o=>{let r=o;return q(o)&&ot(o,c=>{if(c.isInitial){r=c.newValue;return}Ft(e,c.newValue,c.prevValue)},{lifecycleNode:e}),r}):W(t)&&(t={...t},Object.entries(t).forEach(([o,r])=>{q(r)&&ot(r,c=>{if(c.isInitial){t[o]=c.newValue;return}Ft(e,!!c.newValue&&o,!!c.prevValue&&o)},{lifecycleNode:e})})),Ft(e,t,s)}function Ft(e,t,s){const o=(nt(t)??"").split(" ");if(s){const r=(nt(s)??"").split(" ");for(let c of r)c&&!o.includes(c)&&e.classList.remove(c)}for(let r of o)r&&e.classList.add(r)}function Ue(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var Ve=(()=>{let e={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};const t=["Webkit","ms","Moz","O"];return Object.keys(e).forEach(s=>{t.forEach(o=>{e[Ue(o,s)]=0})}),e})();function Ot(e,t,s){t.indexOf("-")===0?e.style.setProperty(t,s):Qt(s)&&Ve[t]!==0?e.style[t]=s+"px":e.style[t]=s}function re(e,t){if(!(t==null||t===!1||t===!0)){if(pt(t)){e.removeAttribute("style");return}W(t)&&Object.keys(t).forEach(s=>{Ot(e,s,"")})}}function Ze(e,t,s){if(t==null||t===!1||t===!0){re(e,s);return}if(pt(t)){e.setAttribute("style",t);return}if(W(t)){W(s)?(t={...t},Object.keys(s).forEach(o=>{o in t||(t[o]="")})):re(e,s),Object.entries(t).forEach(([o,r])=>{q(r)?ot(r,c=>Ot(e,o,c.newValue),{lifecycleNode:e}):Ot(e,o,r)});return}}var Xe="http://www.w3.org/1999/xlink",qe="http://www.w3.org/XML/1998/namespace";function mt(e,t){return e.replace(/[A-Z]/g,s=>t+s.toLowerCase())}var Ye=new Map([["autoComplete","autocomplete"],["autoFocus","autofocus"],["className","class"],["colSpan","colspan"],["contentEditable","contenteditable"],["formNoValidate","formnovalidate"],["htmlFor","for"],["innerText","textContent"],["minLength","minlength"],["maxLength","maxlength"],["readOnly","readonly"],["reffererPolicy","referrerpolicy"],["rowSpan","rowspan"],["spellCheck","spellcheck"],["tabIndex","tabindex"],["onDoubleClick","onDblClick"],["onDoubleClickCapture","onDblClickCapture"]]);function ae(e,t,s,o){switch(t){case"dataset":o!=null&&Object.entries(o).forEach(([c,g])=>{g!=null&&delete e.dataset[c]}),Object.entries(s).forEach(([c,g])=>{g!=null&&(e.dataset[c]=g)});return;case"textContent":st(s)?e[t]=s:st(o)&&(e[t]="");return;case"dangerouslySetInnerHTML":W(s)?e.innerHTML=s.__html:W(o)&&(e.innerHTML="");return;case"value":if(s==null){o!=null&&(e[t]=null);return}else{if(e instanceof window.HTMLSelectElement)return;if(e instanceof window.HTMLTextAreaElement){e.value=s;return}}break;case"class":je(e,s,o);return;case"spellcheck":e.spellcheck=s===""||s===!0||s==="true"?!0:s===!1||s==="false"?!1:s;return;case"draggable":s===!1||s==="false"?s="false":s===""?s=null:(s===!0||s==="true")&&(s="true");break;case"contenteditable":s===!1?s="false":(s===""||s===!0)&&(s="true");break;case"ref":case"namespaceURI":return;case"style":Ze(e,s,o);return;case"on":case"onCapture":const r=t==="onCapture";o!=null&&Object.entries(o).forEach(([c,g])=>{(s==null||s[c]!==g)&&e.removeEventListener(c,g,r)}),Object.entries(s).forEach(([c,g])=>{(o==null||o[c]!==g)&&e.addEventListener(c,g,r)});return;case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":e.setAttributeNS(Xe,mt(t,":"),s);return;case"xmlnsXlink":e.setAttribute("xmlns:xlink",s);return;case"xmlBase":case"xmlLang":case"xmlSpace":e.setAttributeNS(qe,mt(t,":"),s);return}if(typeof s=="function"){if(t[0]==="o"&&t[1]==="n"){if(o!=null&&o===s)return;let r=t.toLowerCase();const c=r.endsWith("capture");let g;!c&&(e[r]===null||o!=null&&e[r]===o)?(e[r]=s,Rt(e,Ke.bind(e,r))):c?(g=r.substring(2,r.length-7),o!=null&&e.removeEventListener(g,o,!0),e.addEventListener(g,s,!0)):(r in window?g=r.substring(2):g=r[2]+t.slice(3),o!=null&&e.removeEventListener(g,o),e.addEventListener(g,s))}else console.warn(`A function was provided for JSX ${e.tagName} element ${t} which does not start with "on":`,s,e.tagName);return}if(W(o)){if(o===s)return;delete e[t]}if(o===!0){if(o===s)return;e.removeAttribute(t)}if(o!==!1&&o!=null){if(o===s)return;e instanceof SVGElement&&!Kt.test(t)?e.removeAttributeNS(mt(t,"-"),s):e.removeAttribute(t)}if(W(s)){e[t]=s;return}if(s===!0){e.setAttribute(t,"");return}s!==!1&&s!=null&&(e instanceof SVGElement&&!Kt.test(t)?e.setAttribute(mt(t,"-"),s):e.setAttribute(t,s))}function Qe(e,t){for(let[s,o]of Object.entries(t))s=Ye.get(s)??s,q(o)?ot(o,r=>ae(e,s,r.newValue,r.prevValue),{lifecycleNode:e}):Ae(o)?o[Yt](e,s):ae(e,s,o);return e}function Ke(e){this[e]=null}function u(e,t){let{children:s,...o}=t||{},r=o.namespaceURI;r||(Re.has(e)?r=Le:Ie.has(e)?r=De:r=ze());let c;if(pt(e)){if(c=r?document.createElementNS(r,e):document.createElement(e),Qe(c,o),ft(c,s),c instanceof window.HTMLSelectElement&&o.value!=null)if(o.multiple===!0&&Array.isArray(o.value)){const g=o.value.map(f=>String(f));c.querySelectorAll("option").forEach(f=>f.selected=g.includes(f.value))}else c.value=o.value;At(o.ref,c)}else if(typeof e=="function")W(e.defaultProps)&&(o={...e.defaultProps,...o}),c=Te(e)?Me(e,o,s):e({...o,children:s});else throw new TypeError(`Invalid JSX element type: ${e}`);return c}var Je=Symbol.for("preact-signals");function Wt(){if(Y>1)Y--;else{var e,t=!1;for(function(){var r=vt;for(vt=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();rt!==void 0;){var s=rt;for(rt=void 0,wt++;s!==void 0;){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&de(s))try{s.c()}catch(r){t||(e=r,t=!0)}s=o}}if(wt=0,Y--,t)throw e}}var b=void 0;function he(e){var t=b;b=void 0;try{return e()}finally{b=t}}var rt=void 0,Y=0,wt=0,le=0,vt=void 0,yt=0;function ce(e){if(b!==void 0){var t=e.n;if(t===void 0||t.t!==b)return t={i:0,S:e,p:b.s,n:void 0,t:b,e:void 0,x:void 0,r:t},b.s!==void 0&&(b.s.n=t),b.s=t,e.n=t,32&b.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=b.s,t.n=void 0,b.s.n=t,b.s=t),t}}function F(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}F.prototype.brand=Je,F.prototype.h=function(){return!0},F.prototype.S=function(e){var t=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:he(function(){var o;(o=t.W)==null||o.call(t)}))},F.prototype.U=function(e){var t=this;if(this.t!==void 0){var s=e.e,o=e.x;s!==void 0&&(s.x=o,e.e=void 0),o!==void 0&&(o.e=s,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&he(function(){var r;(r=t.Z)==null||r.call(t)}))}},F.prototype.subscribe=function(e){var t=this;return ei(function(){var s=t.value,o=b;b=void 0;try{e(s)}finally{b=o}},{name:"sub"})},F.prototype.valueOf=function(){return this.value},F.prototype.toString=function(){return this.value+""},F.prototype.toJSON=function(){return this.value},F.prototype.peek=function(){var e=b;b=void 0;try{return this.value}finally{b=e}},Object.defineProperty(F.prototype,"value",{get:function(){var e=ce(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(wt>100)throw new Error("Cycle detected");(function(s){Y!==0&&wt===0&&s.l!==le&&(s.l=le,vt={S:s,v:s.v,i:s.i,o:vt})})(this),this.v=e,this.i++,yt++,Y++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Wt()}}}});function de(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function ue(e){for(var t=e.s;t!==void 0;t=t.n){var s=t.S.n;if(s!==void 0&&(t.r=s),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ge(e){for(var t=e.s,s=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):s=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=s}function J(e,t){F.call(this,void 0),this.x=e,this.s=void 0,this.g=yt-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}J.prototype=new F,J.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===yt))return!0;if(this.g=yt,this.f|=1,this.i>0&&!de(this))return this.f&=-2,!0;var e=b;try{ue(this),b=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return b=e,ge(this),this.f&=-2,!0},J.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}F.prototype.S.call(this,e)},J.prototype.U=function(e){if(this.t!==void 0&&(F.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},J.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(J.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=ce(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function pe(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Y++;var s=b;b=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,$t(e),o}finally{b=s,Wt()}}}function $t(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,pe(e)}function ti(e){if(b!==this)throw new Error("Out-of-order effect");ge(this),b=e,this.f&=-2,8&this.f&&$t(this),Wt()}function tt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}tt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}},tt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,pe(this),ue(this),Y++;var e=b;return b=this,ti.bind(this,e)},tt.prototype.N=function(){2&this.f||(this.f|=2,this.u=rt,rt=this)},tt.prototype.d=function(){this.f|=8,1&this.f||$t(this)},tt.prototype.dispose=function(){this.d()};function ei(e,t){var s=new tt(e,t);try{s.c()}catch(r){throw s.d(),r}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}const Nt={en:{emptyStateTitle:"No data available.",thumbnails:"Thumbnails",singlePageMode:"Single Page Mode",pages:"Pages",previous:"Previous",next:"Next",zoomOut:"Zoom Out",zoomIn:"Zoom In",fullscreen:"Fullscreen",settings:"Settings",downloadCatalog:"Download Catalog",play:"Play",pause:"Pause"},tr:{emptyStateTitle:"Veri bulunamadi.",thumbnails:"Küçük Resimler",singlePageMode:"Tek Sayfa Modu",pages:"Sayfalar",previous:"Önceki",next:"Sonraki",zoomOut:"Uzaklaş",zoomIn:"Yaklaş",fullscreen:"Tam Ekran",settings:"Ayarlar",downloadCatalog:"Kataloğu İndir",play:"Otomatik Oynat",pause:"Duraklat"}};function ii(e={}){var r;const t=e.locale??"en",s=Nt[t]??Nt.en,o=((r=e.messages)==null?void 0:r[t])??{};return{...Nt.en,...s,...o}}function si(e){const t=m(()=>ii({locale:e.store.locale.value,messages:e.store.messages.value}));return u("div",{class:"bk-toolbar",role:"toolbar","aria-label":"Flipbook controls",children:[u("div",{class:"bk-btn-group",children:[u("button",{type:"button",class:m(()=>`bk-btn ${e.store.showThumbs.value?"active":""}`),onClick:e.onToggleThumbs,"aria-label":m(()=>t.value.thumbnails||"Thumbnails"),"aria-pressed":m(()=>e.store.showThumbs.value?"true":"false"),title:m(()=>t.value.thumbnails||"Thumbnails"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("rect",{x:"3",y:"3",width:"7",height:"7"}),u("rect",{x:"14",y:"3",width:"7",height:"7"}),u("rect",{x:"14",y:"14",width:"7",height:"7"}),u("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),u("button",{type:"button",class:m(()=>`bk-btn bz-hide-mobile ${e.store.isSingleMode.value?"active":""}`),onClick:e.onToggleSingleMode,"aria-label":m(()=>t.value.singlePageMode||"Single Page"),"aria-pressed":m(()=>e.store.isSingleMode.value?"true":"false"),title:m(()=>t.value.singlePageMode||"Single Page"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u("polyline",{points:"14 2 14 8 20 8"}),u("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),u("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),u("polyline",{points:"10 9 9 9 8 9"})]})}),u("button",{type:"button",class:m(()=>`bk-btn ${e.store.isAutoPlaying.value?"active":""}`),onClick:e.onToggleAutoPlay,"aria-label":m(()=>e.store.isAutoPlaying.value?t.value.pause||"Pause":t.value.play||"Play"),"aria-pressed":m(()=>e.store.isAutoPlaying.value?"true":"false"),title:m(()=>e.store.isAutoPlaying.value?t.value.pause||"Pause":t.value.play||"Play"),children:[u("svg",{style:{display:m(()=>e.store.isAutoPlaying.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("rect",{x:"6",y:"4",width:"4",height:"16"}),u("rect",{x:"14",y:"4",width:"4",height:"16"})]}),u("svg",{style:{display:m(()=>e.store.isAutoPlaying.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:u("polygon",{points:"5 3 19 12 5 21 5 3"})})]})]}),u("div",{class:"bk-btn-group bk-btn-group--center",children:[u("button",{type:"button",class:"bk-btn",onClick:e.onPrevPage,"aria-label":m(()=>t.value.previous||"Previous"),title:m(()=>t.value.previous||"Previous"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:u("polyline",{points:"15 18 9 12 15 6"})})}),u("span",{class:"bz-page-info","aria-live":"polite","aria-atomic":"true",children:m(()=>{const s=e.store.currentPage.value,o=e.store.totalPages.value;if(e.store.isSingleMode.value||s===0||s>=o-1)return`${s+1} / ${o}`;const r=s%2===1?s:s-1;return`${r+1}-${r+2} / ${o}`})}),u("button",{type:"button",class:"bk-btn",onClick:e.onNextPage,"aria-label":m(()=>t.value.next||"Next"),title:m(()=>t.value.next||"Next"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:u("polyline",{points:"9 18 15 12 9 6"})})})]}),u("div",{class:"bk-btn-group",children:[u("button",{type:"button",class:"bk-btn",onClick:e.onZoomIn,"aria-label":m(()=>t.value.zoomIn||"Zoom In"),title:m(()=>t.value.zoomIn||"Zoom In"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("circle",{cx:"11",cy:"11",r:"8"}),u("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),u("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),u("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),u("button",{type:"button",class:m(()=>`bk-btn ${e.store.isZoomed.value?"active":""}`),onClick:e.onZoomOut,"aria-label":m(()=>t.value.zoomOut||"Zoom Out"),title:m(()=>t.value.zoomOut||"Zoom Out"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("circle",{cx:"11",cy:"11",r:"8"}),u("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),u("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),u("button",{type:"button",class:"bk-btn bk-btn--fullscreen",onClick:e.onToggleFullscreen,"aria-label":m(()=>t.value.fullscreen||"Fullscreen"),title:m(()=>t.value.fullscreen||"Fullscreen"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:u("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),m(()=>e.store.allowDownload.value&&e.store.hasDownloadUrl.value&&e.onDownload?u("button",{type:"button",class:"bk-btn bk-btn--download",onClick:e.onDownload,"aria-label":m(()=>t.value.downloadCatalog||"Download"),title:m(()=>t.value.downloadCatalog||"Download"),children:u("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u("polyline",{points:"7 10 12 15 17 10"}),u("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}):null),u("button",{type:"button",class:m(()=>`bk-btn ${e.store.soundEnabled.value?"":"muted"}`),onClick:e.onSoundToggle,"aria-label":"Sound","aria-pressed":m(()=>e.store.soundEnabled.value?"true":"false"),title:"Sound",children:[u("svg",{style:{display:m(()=>e.store.soundEnabled.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),u("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),u("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}),u("svg",{style:{display:m(()=>e.store.soundEnabled.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[u("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),u("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),u("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]})]})]})}function ni(e){return u("div",{class:"bk-thumbs",style:m(()=>e.store.showThumbs.value?"display:flex;":"display:none;"),children:e.store.pages.value.map((t,s)=>{const o=()=>{const r=e.store.currentPage.value;if(e.store.isSingleMode.value||r===0||r>=e.store.pages.value.length-1)return r===s;const c=r%2===1?r:r-1;return s===c||s===c+1};return u("div",{class:m(()=>`thumb-item ${o()?"active":""}`),role:"button",tabindex:"0","aria-label":`Go to page ${s+1}`,"aria-current":m(()=>o()?"page":void 0),onClick:()=>e.onThumbClick(s),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),e.onThumbClick(s))},children:[u("div",{class:"thumb-img-wrapper",children:u("img",{class:"thumb-img",src:t.thumb||t.low||t.normal,alt:`Page ${s+1}`,loading:"lazy",onError:r=>{r.currentTarget.style.display="none"}})}),u("span",{children:s+1})]})})})}function oi(e){return u("div",{role:"region","aria-label":"Flipbook viewer",class:m(()=>{let t="bk-book-wrapper ";return e.store.isDoublePageLayout.value&&(t+="double-mode "),e.store.isFrontCover.value&&(t+="bk-is-cover "),e.store.isBackCover.value&&(t+="bk-is-back-cover "),e.store.zoomState.value.isActive&&(t+="zoomed "),t.trim()}),ref:e.bookWrapperRef,children:u("div",{class:"bk-book-sizer",ref:e.bookSizerRef,children:[u("div",{ref:e.bookContainerRef,class:m(()=>"bk-book "+(e.store.flipState.value!=="read"?"is-flipping":"")),style:m(()=>`display: ${e.store.isSingleMode.value?"none":"block"};`),children:e.store.pages.value.map((t,s)=>{const o=s===0||s===e.store.pages.value.length-1;return u("div",{class:`bz-page ${s===0?"bz-page--cover":""} ${s===e.store.pages.value.length-1?"bz-page--back":""}`,"data-density":o?"hard":"soft","data-idx":s,children:u("div",{class:"bz-page-content",style:"position:relative; width:100%; height:100%; overflow:hidden;",children:[u("img",{src:t.low||t.normal,"data-src":t.normal,class:`page-content ${t.cropMode!=="full"?"page-content--split page-content--"+t.cropMode:""}`,alt:`Page ${s+1}`,loading:"lazy"}),u("div",{class:"page-shadow"})]})})})}),u("div",{class:"bk-single-view",style:m(()=>`display: ${e.store.isSingleMode.value?"flex":"none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),children:m(()=>{const t=e.store.pages.value[e.store.currentPage.value];return t?u("img",{class:`bk-single-img page-content ${t.cropMode!=="full"?"page-content--split page-content--"+t.cropMode:""}`,src:e.store.zoomState.value.isActive?t.normal:t.low||t.normal,alt:`Page ${e.store.currentPage.value+1}`,style:"opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"}):null})})]})})}function ri(e){const t=m(()=>e.store.showArrows.value&&e.store.currentPage.value>0),s=m(()=>!e.store.showArrows.value||e.store.totalPages.value<=1?!1:e.store.currentPage.value<e.store.totalPages.value-1);return u("div",{class:"bk-nav-arrows",style:m(()=>e.store.showArrows.value?"display: flex;":"display: none;"),children:[u("button",{type:"button",class:"bk-nav-arrow bk-nav-prev",style:m(()=>t.value?"visibility: visible;":"visibility: hidden;"),onClick:o=>{o.preventDefault(),e.onPrevPage()},"aria-label":"Previous Page",children:u("div",{class:"bk-arrow-icon bk-arrow-left"})}),u("button",{type:"button",class:"bk-nav-arrow bk-nav-next",style:m(()=>s.value?"visibility: visible;":"visibility: hidden;"),onClick:o=>{o.preventDefault(),e.onNextPage()},"aria-label":"Next Page",children:u("div",{class:"bk-arrow-icon bk-arrow-right"})})]})}function ai(e){const t=()=>{e.store.showThumbs.value=!e.store.showThumbs.value},s=()=>{e.store.isSingleMode.value=!e.store.isSingleMode.value},o=()=>{e.store.isAutoPlaying.value=!e.store.isAutoPlaying.value},r=()=>{var x;(x=e.interactionManagerRef.current)==null||x.zoomIn()},c=()=>{var x;(x=e.interactionManagerRef.current)==null||x.zoomOut()},g=()=>e.onToggleFullscreen(),f=x=>{var O;e.store.currentPage.value!==x&&(e.store.currentPage.value=x,(O=e.pageFlipAdapterRef.current)==null||O.playSound())},k=()=>{var x;(x=e.pageFlipAdapterRef.current)==null||x.turnToNextPage()},P=()=>{var x;(x=e.pageFlipAdapterRef.current)==null||x.turnToPrevPage()};return u("div",{class:m(()=>`bk-wrapper bk-theme-${e.store.themeMode.value} ${e.className||""}`),children:[u("div",{class:"bk-main-area",children:[u(oi,{store:e.store,bookWrapperRef:e.bookWrapperRef,bookSizerRef:e.bookSizerRef,bookContainerRef:e.bookContainerRef}),u(ri,{store:e.store,onPrevPage:P,onNextPage:k}),e.store.whiteLabel.value?null:u("div",{class:"bk-watermark",children:["Powered by ",u("a",{href:"https://flipbookengine.com",target:"_blank",rel:"noopener",style:"text-decoration: underline;",children:"FlipbookEngine"})]})]}),u(si,{store:e.store,onToggleThumbs:t,onToggleSingleMode:s,onZoomIn:r,onZoomOut:c,onDownload:e.onDownload,onNextPage:k,onPrevPage:P,onSoundToggle:()=>e.store.soundEnabled.value=!e.store.soundEnabled.value,onToggleAutoPlay:o,onToggleFullscreen:g}),u(ni,{store:e.store,onThumbClick:f})]})}var hi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ht={exports:{}};(function(e,t){(function(s,o){o(t)})(hi,function(s){class o{constructor(i,n){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=n,this.nowDrawingDensity=this.createdDensity,this.render=i}setDensity(i){this.createdDensity=i,this.nowDrawingDensity=i}setDrawingDensity(i){this.nowDrawingDensity=i}setPosition(i){this.state.position=i}setAngle(i){this.state.angle=i}setArea(i){this.state.area=i}setHardDrawingAngle(i){this.state.hardDrawingAngle=i}setHardAngle(i){this.state.hardAngle=i,this.state.hardDrawingAngle=i}setOrientation(i){this.orientation=i}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class r extends o{constructor(i,n,a){super(i,a),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=n}draw(i){const n=this.render.getContext(),a=this.render.convertToGlobal(this.state.position),l=this.render.getRect().pageWidth,h=this.render.getRect().height;n.save(),n.translate(a.x,a.y),n.beginPath();for(let d of this.state.area)d!==null&&(d=this.render.convertToGlobal(d),n.lineTo(d.x-a.x,d.y-a.y));n.rotate(this.state.angle),n.clip(),this.isLoad?n.drawImage(this.image,0,0,l,h):this.drawLoader(n,{x:0,y:0},l,h),n.restore()}simpleDraw(i){const n=this.render.getRect(),a=this.render.getContext(),l=n.pageWidth,h=n.height,d=i===1?n.left+n.pageWidth:n.left,w=n.top;this.isLoad?a.drawImage(this.image,d,w,l,h):this.drawLoader(a,{x:d,y:w},l,h)}drawLoader(i,n,a,l){i.beginPath(),i.strokeStyle="rgb(200, 200, 200)",i.fillStyle="rgb(255, 255, 255)",i.lineWidth=1,i.rect(n.x+1,n.y+1,a-1,l-1),i.stroke(),i.fill();const h={x:n.x+a/2,y:n.y+l/2};i.beginPath(),i.lineWidth=10,i.arc(h.x,h.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),i.stroke(),i.closePath(),this.loadingAngle+=.07,this.loadingAngle>=2*Math.PI&&(this.loadingAngle=0)}load(){this.isLoad||(this.image.onload=()=>{this.isLoad=!0})}newTemporaryCopy(){return this}getTemporaryCopy(){return this}hideTemporaryCopy(){}}class c{constructor(i,n){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=n,this.app=i,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let n=0;n<this.pages.length;n++)this.portraitSpread.push([n]);let i=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([i]),i++);for(let n=i;n<this.pages.length;n+=2)n<this.pages.length-1?this.landscapeSpread.push([n,n+1]):(this.landscapeSpread.push([n]),this.pages[n].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(i){const n=this.getSpread();for(let a=0;a<n.length;a++)if(i===n[a][0]||i===n[a][1])return a;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(i){if(i>=0&&i<this.pages.length)return this.pages[i];throw new Error("Invalid page number")}nextBy(i){const n=this.pages.indexOf(i);return n<this.pages.length-1?this.pages[n+1]:null}prevBy(i){const n=this.pages.indexOf(i);return n>0?this.pages[n-1]:null}getFlippingPage(i){const n=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return i===0?this.pages[n].newTemporaryCopy():this.pages[n-1];{const a=i===0?this.getSpread()[n+1]:this.getSpread()[n-1];return a.length===1||i===0?this.pages[a[0]]:this.pages[a[1]]}}getBottomPage(i){const n=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return i===0?this.pages[n+1]:this.pages[n-1];{const a=i===0?this.getSpread()[n+1]:this.getSpread()[n-1];return a.length===1?this.pages[a[0]]:i===0?this.pages[a[1]]:this.pages[a[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(i=null){if(i===null&&(i=this.currentPageIndex),i<0||i>=this.pages.length)return;const n=this.getSpreadIndexByPage(i);n!==null&&(this.currentSpreadIndex=n,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(i){if(!(i>=0&&i<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=i}showSpread(){const i=this.getSpread()[this.currentSpreadIndex];i.length===2?(this.render.setLeftPage(this.pages[i[0]]),this.render.setRightPage(this.pages[i[1]])):this.render.getOrientation()==="landscape"&&i[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[i[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[i[0]])),this.currentPageIndex=i[0],this.app.updatePageIndex(this.currentPageIndex)}}class g extends c{constructor(i,n,a){super(i,n),this.imagesHref=a}load(){for(const i of this.imagesHref){const n=new r(this.render,i,"soft");n.load(),this.pages.push(n)}this.createSpread()}}class f{static GetDistanceBetweenTwoPoint(i,n){return i===null||n===null?1/0:Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2))}static GetSegmentLength(i){return f.GetDistanceBetweenTwoPoint(i[0],i[1])}static GetAngleBetweenTwoLine(i,n){const a=i[0].y-i[1].y,l=n[0].y-n[1].y,h=i[1].x-i[0].x,d=n[1].x-n[0].x;return Math.acos((a*l+h*d)/(Math.sqrt(a*a+h*h)*Math.sqrt(l*l+d*d)))}static PointInRect(i,n){return n===null?null:n.x>=i.left&&n.x<=i.width+i.left&&n.y>=i.top&&n.y<=i.top+i.height?n:null}static GetRotatedPoint(i,n,a){return{x:i.x*Math.cos(a)+i.y*Math.sin(a)+n.x,y:i.y*Math.cos(a)-i.x*Math.sin(a)+n.y}}static LimitPointToCircle(i,n,a){if(f.GetDistanceBetweenTwoPoint(i,a)<=n)return a;const l=i.x,h=i.y,d=a.x,w=a.y;let y=Math.sqrt(Math.pow(n,2)*Math.pow(l-d,2)/(Math.pow(l-d,2)+Math.pow(h-w,2)))+l;a.x<0&&(y*=-1);let D=(y-l)*(h-w)/(l-d)+h;return l-d+h===0&&(D=n),{x:y,y:D}}static GetIntersectBetweenTwoSegment(i,n,a){return f.PointInRect(i,f.GetIntersectBeetwenTwoLine(n,a))}static GetIntersectBeetwenTwoLine(i,n){const a=i[0].y-i[1].y,l=n[0].y-n[1].y,h=i[1].x-i[0].x,d=n[1].x-n[0].x,w=i[0].x*i[1].y-i[1].x*i[0].y,y=n[0].x*n[1].y-n[1].x*n[0].y,D=a*y-l*w,L=h*y-d*w,H=-(w*d-y*h)/(a*d-l*h),ht=-(a*y-l*w)/(a*d-l*h);if(isFinite(H)&&isFinite(ht))return{x:H,y:ht};if(Math.abs(D-L)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(i,n){const a=Math.abs(i.x-n.x),l=Math.abs(i.y-n.y),h=Math.max(a,l),d=[i];function w(y,D,L,H,ht){return D>y?y+ht*(L/H):D<y?y-ht*(L/H):y}for(let y=1;y<=h;y+=1)d.push({x:w(i.x,n.x,a,h,y),y:w(i.y,n.y,l,h,y)});return d}}class k extends o{constructor(i,n,a){super(i,a),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=n,this.element.classList.add("stf__item"),this.element.classList.add("--"+a)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new k(this.render,this.copiedElement,this.nowDrawingDensity)),this.getTemporaryCopy())}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){this.temporaryCopy!==null&&(this.copiedElement.remove(),this.copiedElement=null,this.temporaryCopy=null)}draw(i){const n=i||this.nowDrawingDensity,a=this.render.convertToGlobal(this.state.position),l=this.render.getRect().pageWidth,h=this.render.getRect().height;this.element.classList.remove("--simple");const d=`
|
|
1
|
+
var FlipbookEngine=function(S,C){"use strict";var bi=Object.defineProperty;var xe=S=>{throw TypeError(S)};var Pi=(S,C,I)=>C in S?bi(S,C,{enumerable:!0,configurable:!0,writable:!0,value:I}):S[C]=I;var w=(S,C,I)=>Pi(S,typeof C!="symbol"?C+"":C,I),Bt=(S,C,I)=>C.has(S)||xe("Cannot "+I);var V=(S,C,I)=>(Bt(S,C,"read from private field"),I?I.call(S):C.get(S)),xt=(S,C,I)=>C.has(S)?xe("Cannot add the same private member more than once"):C instanceof WeakSet?C.add(S):C.set(S,I),St=(S,C,I,et)=>(Bt(S,C,"write to private field"),et?et.call(S,I):C.set(S,I),I),lt=(S,C,I)=>(Bt(S,C,"access private method"),I);var at,$,_,_t,Gt,Pe;function I(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const et=I(C);var Se=Symbol.for("preact-signals");function kt(){if(Z>1)Z--;else{var e,t=!1;for(function(){var r=ut;for(ut=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();it!==void 0;){var s=it;for(it=void 0,dt++;s!==void 0;){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&Vt(s))try{s.c()}catch(r){t||(e=r,t=!0)}s=o}}if(dt=0,Z--,t)throw e}}var T=void 0;function ct(e){var t=T;T=void 0;try{return e()}finally{T=t}}var it=void 0,Z=0,dt=0,jt=0,ut=void 0,gt=0;function Ut(e){if(T!==void 0){var t=e.n;if(t===void 0||t.t!==T)return t={i:0,S:e,p:T.s,n:void 0,t:T,e:void 0,x:void 0,r:t},T.s!==void 0&&(T.s.n=t),T.s=t,e.n=t,32&T.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=T.s,t.n=void 0,T.s.n=t,T.s=t),t}}function F(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}F.prototype.brand=Se,F.prototype.h=function(){return!0},F.prototype.S=function(e){var t=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:ct(function(){var o;(o=t.W)==null||o.call(t)}))},F.prototype.U=function(e){var t=this;if(this.t!==void 0){var s=e.e,o=e.x;s!==void 0&&(s.x=o,e.e=void 0),o!==void 0&&(o.e=s,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&ct(function(){var r;(r=t.Z)==null||r.call(t)}))}},F.prototype.subscribe=function(e){var t=this;return B(function(){var s=t.value;ct(function(){return e(s)})},{name:"sub"})},F.prototype.valueOf=function(){return this.value},F.prototype.toString=function(){return this.value+""},F.prototype.toJSON=function(){return this.value},F.prototype.peek=function(){var e=this;return ct(function(){return e.value})},Object.defineProperty(F.prototype,"value",{get:function(){var e=Ut(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(dt>100)throw new Error("Cycle detected");(function(s){Z!==0&&dt===0&&s.l!==jt&&(s.l=jt,ut={S:s,v:s.v,i:s.i,o:ut})})(this),this.v=e,this.i++,gt++,Z++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{kt()}}}});function R(e,t){return new F(e,t)}function Vt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Zt(e){for(var t=e.s;t!==void 0;t=t.n){var s=t.S.n;if(s!==void 0&&(t.r=s),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function qt(e){for(var t=e.s,s=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):s=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=s}function q(e,t){F.call(this,void 0,t),this.x=e,this.s=void 0,this.g=gt-1,this.f=4}q.prototype=new F,q.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===gt))return!0;if(this.g=gt,this.f|=1,this.i>0&&!Vt(this))return this.f&=-2,!0;var e=T;try{Zt(this),T=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return T=e,qt(this),this.f&=-2,!0},q.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}F.prototype.S.call(this,e)},q.prototype.U=function(e){if(this.t!==void 0&&(F.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},q.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(q.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ut(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function m(e,t){return new q(e,t)}function Xt(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Z++;var s=T;T=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,Ct(e),o}finally{T=s,kt()}}}function Ct(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Xt(e)}function ke(e){if(T!==this)throw new Error("Out-of-order effect");qt(this),T=e,this.f&=-2,8&this.f&&Ct(this),kt()}function K(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}K.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}},K.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Xt(this),Zt(this),Z++;var e=T;return T=this,ke.bind(this,e)},K.prototype.N=function(){2&this.f||(this.f|=2,this.u=it,it=this)},K.prototype.d=function(){this.f|=8,1&this.f||Ct(this)},K.prototype.dispose=function(){this.d()};function B(e,t){var s=new K(e,t);try{s.c()}catch(r){throw s.d(),r}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}var Yt=Symbol.for("Serenity.initPropHook");function Ce(e){return!!(e&&typeof e.nodeType=="number")}function pt(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function W(e){return typeof e=="object"&&e!==null}function Te(e){return!!(e&&e.isComponent)}function Tt(e){return W(e)&&typeof e.length=="number"&&typeof e.nodeType!="number"}function Ae(e){return typeof e=="function"&&typeof e[Yt]=="function"}function st(e){return e!=null&&typeof e!="boolean"}function nt(e){return Array.isArray(e)?e.map(nt).filter(Boolean).join(" "):W(e)?Symbol.iterator in e?nt(Array.from(e)):Object.keys(e).filter(t=>e[t]).join(" "):st(e)?""+e:""}function Ee(e){return e!=null&&typeof e=="object"&&"current"in e}function At(e,t){Ee(e)?e.current=t:typeof e=="function"&&e(t)}function Me(e,t,s){t={...t,children:s};const o=new e(t),r=o.render();return"ref"in t&&At(t.ref,o),r}var De="http://www.w3.org/1998/Math/MathML",Re=new Set(["math","annotation","annotation-xml","maction","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics","menclose","mfenced"]),Ie=new Set(["animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view"]),Kt=/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/,Le="http://www.w3.org/2000/svg",Jt=Symbol.for("Serenity.jsxNamespaceURI");function ze(e){const t=globalThis[Jt];return arguments.length&&(globalThis[Jt]=e),t}var Fe=Symbol.for("Serenity.jsxTypeKey"),Oe="ShadowRoot";function We(e){return e!=null&&e[Fe]===Oe}var Et=Symbol.for("Serenity.disposingListeners"),Mt=Symbol.for("Serenity.lifecycleRoot");function Dt(){return globalThis[Et]||(globalThis[Et]=new WeakMap)}function Rt(e){e&&e.target&&(!e.currentTarget||e.currentTarget===e.target)&&$e(e==null?void 0:e.target)}function $e(e,t){if(!e)return;const s=Dt();function o(r){const l=s.get(r);if(l){s.delete(r),r.removeEventListener("disposing",Rt);for(const d of l)try{d.callback(r)}catch{}}}o(e)}function It(e,t,s){if(!e||!t)return e;const o=Dt();let r=o.get(e);if(!r)return typeof e.addEventListener!="function"||(o.set(e,r=[{callback:t,regKey:s}]),e.addEventListener("disposing",Rt,{once:!0})),e;const l=r.find(d=>d.callback===t);return l?(l.regKey,e):(r.push({callback:t,regKey:s}),e)}function te(e,t,s){if(!e||!t)return e;const o=Dt(),r=o.get(e);if(r){for(let l=r.length-1;l>=0;l--){const d=r[l];t&&t===d.callback&&r.splice(l,1)}r.length===0&&(o.delete(e),typeof e.removeEventListener=="function"&&e.removeEventListener("disposing",Rt))}return e}function He(...e){if(e.length>0){const t=globalThis[Mt]||null;return globalThis[Mt]=e[0]||null,t}return globalThis[Mt]||null}function X(e){return e!=null&&typeof e=="object"&&typeof e.subscribe=="function"&&typeof e.peek=="function"&&"value"in e}var Ne=(Pe=class{constructor(e,t,s){xt(this,_);xt(this,at);xt(this,$);this.signal=e,this.isInitial=!0,this.hasChanged=!1,this.lifecycleRoot=t,St(this,$,s)}get lifecycleNode(){return V(this,$)}get effectDisposer(){return V(this,at)}set effectDisposer(e){lt(this,_,_t).call(this),St(this,at,e),lt(this,_,Gt).call(this)}set lifecycleNode(e){e!==V(this,$)&&(lt(this,_,_t).call(this),St(this,$,e),lt(this,_,Gt).call(this))}},at=new WeakMap,$=new WeakMap,_=new WeakSet,_t=function(){var e;te(V(this,$),this.effectDisposer),te(V(this,$),(e=this.signal)==null?void 0:e.derivedDisposer)},Gt=function(){var e;It(V(this,$),this.effectDisposer),It(V(this,$),(e=this.signal)==null?void 0:e.derivedDisposer)},Pe);function ot(e,t,s){const o=s!=null&&s.useLifecycleRoot?He():void 0,r=new Ne(e,o,s==null?void 0:s.lifecycleNode),l=r.signal.subscribe(function(d){r.newValue=d,r.isInitial&&(this!=null&&this.dispose)&&(r.effectDisposer=this.dispose.bind(this)),r.hasChanged=!r.isInitial&&r.prevValue!==r.newValue;try{t(r)}finally{r.prevValue=r.newValue,r.isInitial=!1}});return l&&!r.effectDisposer&&(r.effectDisposer=l),r.effectDisposer}function ee(e,t){e instanceof window.HTMLTemplateElement?e.content.appendChild(t):e.appendChild(t)}var Lt=0,zt="__domwisefrag_";function ie(e){return e instanceof Comment&&e.data.startsWith(zt)}function se(e){return e instanceof DocumentFragment&&ie(e.firstChild)}function Be(e,t){var s;typeof e.replaceWith=="function"?e.replaceWith(t):(s=e.parentNode)==null||s.replaceChild(t,e)}function ne(e){return e instanceof DocumentFragment?(++Lt,e.prepend(document.createComment(zt+Lt)),e.append(document.createComment(zt+Lt)),e):e instanceof Node?e:st(e)?document.createTextNode(e):document.createComment("")}function _e(e,t){let s;ot(t,o=>{var d;if(o.isInitial){s=ne(o.newValue);let p=se(s)?s.firstChild:s;ft(e,s),o.lifecycleNode=(s=p)??e;return}if(!o.hasChanged)return;const r=ne(o.newValue);if(ie(s)){let p;for(;(p=s.nextSibling)&&((d=p.parentNode)==null||d.removeChild(p),!(p instanceof Comment&&p.data===s.data)););}let l=se(r)?r.firstChild:r;Be(s,r),o.lifecycleNode=(s=l)??e})}function ft(e,t){if(st(t))if(Tt(t))for(const s of[...t])ft(e,s);else if(pt(t)||Qt(t))ee(e,document.createTextNode(t));else if(Ce(t))ee(e,t);else if(We(t)){const s=e.attachShadow(t.attr);ft(s,t.children),At(t.ref,s)}else X(t)&&_e(e,t)}function oe(e){return e==null||(Tt(e)?e=Array.from(e).map(t=>X(t)?t.peek():t):W(e)&&(e={...e},Object.entries(e).forEach(([t,s])=>{X(s)&&(e[t]=s.peek())}))),e}function Ge(e,t){if(t==null||t===!1||t===!0)return;t=oe(t);const s=(nt(t)??"").split(" ");for(let o of s)o&&e.classList.remove(o)}function je(e,t,s){if(t==null||t===!1){Ge(e,s);return}s=oe(s),Tt(t)?t=Array.from(t).map(o=>{let r=o;return X(o)&&ot(o,l=>{if(l.isInitial){r=l.newValue;return}Ft(e,l.newValue,l.prevValue)},{lifecycleNode:e}),r}):W(t)&&(t={...t},Object.entries(t).forEach(([o,r])=>{X(r)&&ot(r,l=>{if(l.isInitial){t[o]=l.newValue;return}Ft(e,!!l.newValue&&o,!!l.prevValue&&o)},{lifecycleNode:e})})),Ft(e,t,s)}function Ft(e,t,s){const o=(nt(t)??"").split(" ");if(s){const r=(nt(s)??"").split(" ");for(let l of r)l&&!o.includes(l)&&e.classList.remove(l)}for(let r of o)r&&e.classList.add(r)}function Ue(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)}var Ve=(()=>{let e={animationIterationCount:0,borderImageOutset:0,borderImageSlice:0,borderImageWidth:0,boxFlex:0,boxFlexGroup:0,boxOrdinalGroup:0,columnCount:0,columns:0,flex:0,flexGrow:0,flexPositive:0,flexShrink:0,flexNegative:0,flexOrder:0,gridArea:0,gridRow:0,gridRowEnd:0,gridRowSpan:0,gridRowStart:0,gridColumn:0,gridColumnEnd:0,gridColumnSpan:0,gridColumnStart:0,fontWeight:0,lineClamp:0,lineHeight:0,opacity:0,order:0,orphans:0,tabSize:0,widows:0,zIndex:0,zoom:0,fillOpacity:0,floodOpacity:0,stopOpacity:0,strokeDasharray:0,strokeDashoffset:0,strokeMiterlimit:0,strokeOpacity:0,strokeWidth:0};const t=["Webkit","ms","Moz","O"];return Object.keys(e).forEach(s=>{t.forEach(o=>{e[Ue(o,s)]=0})}),e})();function Ot(e,t,s){t.indexOf("-")===0?e.style.setProperty(t,s):Qt(s)&&Ve[t]!==0?e.style[t]=s+"px":e.style[t]=s}function re(e,t){if(!(t==null||t===!1||t===!0)){if(pt(t)){e.removeAttribute("style");return}W(t)&&Object.keys(t).forEach(s=>{Ot(e,s,"")})}}function Ze(e,t,s){if(t==null||t===!1||t===!0){re(e,s);return}if(pt(t)){e.setAttribute("style",t);return}if(W(t)){W(s)?(t={...t},Object.keys(s).forEach(o=>{o in t||(t[o]="")})):re(e,s),Object.entries(t).forEach(([o,r])=>{X(r)?ot(r,l=>Ot(e,o,l.newValue),{lifecycleNode:e}):Ot(e,o,r)});return}}var qe="http://www.w3.org/1999/xlink",Xe="http://www.w3.org/XML/1998/namespace";function mt(e,t){return e.replace(/[A-Z]/g,s=>t+s.toLowerCase())}var Ye=new Map([["autoComplete","autocomplete"],["autoFocus","autofocus"],["className","class"],["colSpan","colspan"],["contentEditable","contenteditable"],["formNoValidate","formnovalidate"],["htmlFor","for"],["innerText","textContent"],["minLength","minlength"],["maxLength","maxlength"],["readOnly","readonly"],["reffererPolicy","referrerpolicy"],["rowSpan","rowspan"],["spellCheck","spellcheck"],["tabIndex","tabindex"],["onDoubleClick","onDblClick"],["onDoubleClickCapture","onDblClickCapture"]]);function ae(e,t,s,o){switch(t){case"dataset":o!=null&&Object.entries(o).forEach(([l,d])=>{d!=null&&delete e.dataset[l]}),Object.entries(s).forEach(([l,d])=>{d!=null&&(e.dataset[l]=d)});return;case"textContent":st(s)?e[t]=s:st(o)&&(e[t]="");return;case"dangerouslySetInnerHTML":W(s)?e.innerHTML=s.__html:W(o)&&(e.innerHTML="");return;case"value":if(s==null){o!=null&&(e[t]=null);return}else{if(e instanceof window.HTMLSelectElement)return;if(e instanceof window.HTMLTextAreaElement){e.value=s;return}}break;case"class":je(e,s,o);return;case"spellcheck":e.spellcheck=s===""||s===!0||s==="true"?!0:s===!1||s==="false"?!1:s;return;case"draggable":s===!1||s==="false"?s="false":s===""?s=null:(s===!0||s==="true")&&(s="true");break;case"contenteditable":s===!1?s="false":(s===""||s===!0)&&(s="true");break;case"ref":case"namespaceURI":return;case"style":Ze(e,s,o);return;case"on":case"onCapture":const r=t==="onCapture";o!=null&&Object.entries(o).forEach(([l,d])=>{(s==null||s[l]!==d)&&e.removeEventListener(l,d,r)}),Object.entries(s).forEach(([l,d])=>{(o==null||o[l]!==d)&&e.addEventListener(l,d,r)});return;case"xlinkActuate":case"xlinkArcrole":case"xlinkHref":case"xlinkRole":case"xlinkShow":case"xlinkTitle":case"xlinkType":e.setAttributeNS(qe,mt(t,":"),s);return;case"xmlnsXlink":e.setAttribute("xmlns:xlink",s);return;case"xmlBase":case"xmlLang":case"xmlSpace":e.setAttributeNS(Xe,mt(t,":"),s);return}if(typeof s=="function"){if(t[0]==="o"&&t[1]==="n"){if(o!=null&&o===s)return;let r=t.toLowerCase();const l=r.endsWith("capture");let d;!l&&(e[r]===null||o!=null&&e[r]===o)?(e[r]=s,It(e,Ke.bind(e,r))):l?(d=r.substring(2,r.length-7),o!=null&&e.removeEventListener(d,o,!0),e.addEventListener(d,s,!0)):(r in window?d=r.substring(2):d=r[2]+t.slice(3),o!=null&&e.removeEventListener(d,o),e.addEventListener(d,s))}else console.warn(`A function was provided for JSX ${e.tagName} element ${t} which does not start with "on":`,s,e.tagName);return}if(W(o)){if(o===s)return;delete e[t]}if(o===!0){if(o===s)return;e.removeAttribute(t)}if(o!==!1&&o!=null){if(o===s)return;e instanceof SVGElement&&!Kt.test(t)?e.removeAttributeNS(mt(t,"-"),s):e.removeAttribute(t)}if(W(s)){e[t]=s;return}if(s===!0){e.setAttribute(t,"");return}s!==!1&&s!=null&&(e instanceof SVGElement&&!Kt.test(t)?e.setAttribute(mt(t,"-"),s):e.setAttribute(t,s))}function Qe(e,t){for(let[s,o]of Object.entries(t))s=Ye.get(s)??s,X(o)?ot(o,r=>ae(e,s,r.newValue,r.prevValue),{lifecycleNode:e}):Ae(o)?o[Yt](e,s):ae(e,s,o);return e}function Ke(e){this[e]=null}function g(e,t){let{children:s,...o}=t||{},r=o.namespaceURI;r||(Ie.has(e)?r=Le:Re.has(e)?r=De:r=ze());let l;if(pt(e)){if(l=r?document.createElementNS(r,e):document.createElement(e),Qe(l,o),ft(l,s),l instanceof window.HTMLSelectElement&&o.value!=null)if(o.multiple===!0&&Array.isArray(o.value)){const d=o.value.map(p=>String(p));l.querySelectorAll("option").forEach(p=>p.selected=d.includes(p.value))}else l.value=o.value;At(o.ref,l)}else if(typeof e=="function")W(e.defaultProps)&&(o={...e.defaultProps,...o}),l=Te(e)?Me(e,o,s):e({...o,children:s});else throw new TypeError(`Invalid JSX element type: ${e}`);return l}var Je=Symbol.for("preact-signals");function Wt(){if(Y>1)Y--;else{var e,t=!1;for(function(){var r=vt;for(vt=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();rt!==void 0;){var s=rt;for(rt=void 0,wt++;s!==void 0;){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&de(s))try{s.c()}catch(r){t||(e=r,t=!0)}s=o}}if(wt=0,Y--,t)throw e}}var x=void 0;function he(e){var t=x;x=void 0;try{return e()}finally{x=t}}var rt=void 0,Y=0,wt=0,le=0,vt=void 0,yt=0;function ce(e){if(x!==void 0){var t=e.n;if(t===void 0||t.t!==x)return t={i:0,S:e,p:x.s,n:void 0,t:x,e:void 0,x:void 0,r:t},x.s!==void 0&&(x.s.n=t),x.s=t,e.n=t,32&x.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=x.s,t.n=void 0,x.s.n=t,x.s=t),t}}function O(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}O.prototype.brand=Je,O.prototype.h=function(){return!0},O.prototype.S=function(e){var t=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:he(function(){var o;(o=t.W)==null||o.call(t)}))},O.prototype.U=function(e){var t=this;if(this.t!==void 0){var s=e.e,o=e.x;s!==void 0&&(s.x=o,e.e=void 0),o!==void 0&&(o.e=s,e.x=void 0),e===this.t&&(this.t=o,o===void 0&&he(function(){var r;(r=t.Z)==null||r.call(t)}))}},O.prototype.subscribe=function(e){var t=this;return ei(function(){var s=t.value,o=x;x=void 0;try{e(s)}finally{x=o}},{name:"sub"})},O.prototype.valueOf=function(){return this.value},O.prototype.toString=function(){return this.value+""},O.prototype.toJSON=function(){return this.value},O.prototype.peek=function(){var e=x;x=void 0;try{return this.value}finally{x=e}},Object.defineProperty(O.prototype,"value",{get:function(){var e=ce(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(wt>100)throw new Error("Cycle detected");(function(s){Y!==0&&wt===0&&s.l!==le&&(s.l=le,vt={S:s,v:s.v,i:s.i,o:vt})})(this),this.v=e,this.i++,yt++,Y++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{Wt()}}}});function de(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function ue(e){for(var t=e.s;t!==void 0;t=t.n){var s=t.S.n;if(s!==void 0&&(t.r=s),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ge(e){for(var t=e.s,s=void 0;t!==void 0;){var o=t.p;t.i===-1?(t.S.U(t),o!==void 0&&(o.n=t.n),t.n!==void 0&&(t.n.p=o)):s=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=o}e.s=s}function J(e,t){O.call(this,void 0),this.x=e,this.s=void 0,this.g=yt-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}J.prototype=new O,J.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===yt))return!0;if(this.g=yt,this.f|=1,this.i>0&&!de(this))return this.f&=-2,!0;var e=x;try{ue(this),x=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return x=e,ge(this),this.f&=-2,!0},J.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}O.prototype.S.call(this,e)},J.prototype.U=function(e){if(this.t!==void 0&&(O.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},J.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(J.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=ce(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function pe(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Y++;var s=x;x=void 0;try{t()}catch(o){throw e.f&=-2,e.f|=8,$t(e),o}finally{x=s,Wt()}}}function $t(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,pe(e)}function ti(e){if(x!==this)throw new Error("Out-of-order effect");ge(this),x=e,this.f&=-2,8&this.f&&$t(this),Wt()}function tt(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}tt.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}},tt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,pe(this),ue(this),Y++;var e=x;return x=this,ti.bind(this,e)},tt.prototype.N=function(){2&this.f||(this.f|=2,this.u=rt,rt=this)},tt.prototype.d=function(){this.f|=8,1&this.f||$t(this)},tt.prototype.dispose=function(){this.d()};function ei(e,t){var s=new tt(e,t);try{s.c()}catch(r){throw s.d(),r}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}const Ht={en:{emptyStateTitle:"No data available.",thumbnails:"Thumbnails",singlePageMode:"Single Page Mode",pages:"Pages",previous:"Previous",next:"Next",zoomOut:"Zoom Out",zoomIn:"Zoom In",fullscreen:"Fullscreen",settings:"Settings",downloadCatalog:"Download Catalog",play:"Play",pause:"Pause"},tr:{emptyStateTitle:"Veri bulunamadi.",thumbnails:"Küçük Resimler",singlePageMode:"Tek Sayfa Modu",pages:"Sayfalar",previous:"Önceki",next:"Sonraki",zoomOut:"Uzaklaş",zoomIn:"Yaklaş",fullscreen:"Tam Ekran",settings:"Ayarlar",downloadCatalog:"Kataloğu İndir",play:"Otomatik Oynat",pause:"Duraklat"}};function ii(e={}){var r;const t=e.locale??"en",s=Ht[t]??Ht.en,o=((r=e.messages)==null?void 0:r[t])??{};return{...Ht.en,...s,...o}}function si(e){const t=m(()=>ii({locale:e.store.locale.value,messages:e.store.messages.value}));return g("div",{class:"bk-toolbar",role:"toolbar","aria-label":"Flipbook controls",children:[g("div",{class:"bk-btn-group",children:[g("button",{type:"button",class:m(()=>`bk-btn ${e.store.showThumbs.value?"active":""}`),onClick:e.onToggleThumbs,"aria-label":m(()=>t.value.thumbnails||"Thumbnails"),"aria-pressed":m(()=>e.store.showThumbs.value?"true":"false"),title:m(()=>t.value.thumbnails||"Thumbnails"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("rect",{x:"3",y:"3",width:"7",height:"7"}),g("rect",{x:"14",y:"3",width:"7",height:"7"}),g("rect",{x:"14",y:"14",width:"7",height:"7"}),g("rect",{x:"3",y:"14",width:"7",height:"7"})]})}),g("button",{type:"button",class:m(()=>`bk-btn bz-hide-mobile ${e.store.isSingleMode.value?"active":""}`),onClick:e.onToggleSingleMode,"aria-label":m(()=>t.value.singlePageMode||"Single Page"),"aria-pressed":m(()=>e.store.isSingleMode.value?"true":"false"),title:m(()=>t.value.singlePageMode||"Single Page"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),g("polyline",{points:"14 2 14 8 20 8"}),g("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),g("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),g("polyline",{points:"10 9 9 9 8 9"})]})}),g("button",{type:"button",class:m(()=>`bk-btn ${e.store.isAutoPlaying.value?"active":""}`),onClick:e.onToggleAutoPlay,"aria-label":m(()=>e.store.isAutoPlaying.value?t.value.pause||"Pause":t.value.play||"Play"),"aria-pressed":m(()=>e.store.isAutoPlaying.value?"true":"false"),title:m(()=>e.store.isAutoPlaying.value?t.value.pause||"Pause":t.value.play||"Play"),children:[g("svg",{style:{display:m(()=>e.store.isAutoPlaying.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("rect",{x:"6",y:"4",width:"4",height:"16"}),g("rect",{x:"14",y:"4",width:"4",height:"16"})]}),g("svg",{style:{display:m(()=>e.store.isAutoPlaying.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("polygon",{points:"5 3 19 12 5 21 5 3"})})]})]}),g("div",{class:"bk-btn-group bk-btn-group--center",children:[g("button",{type:"button",class:"bk-btn",onClick:e.onPrevPage,"aria-label":m(()=>t.value.previous||"Previous"),title:m(()=>t.value.previous||"Previous"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("polyline",{points:"15 18 9 12 15 6"})})}),g("span",{class:"bz-page-info","aria-live":"polite","aria-atomic":"true",children:m(()=>{const s=e.store.currentPage.value,o=e.store.totalPages.value;if(e.store.isSingleMode.value||s===0||s>=o-1)return`${s+1} / ${o}`;const r=s%2===1?s:s-1;return`${r+1}-${r+2} / ${o}`})}),g("button",{type:"button",class:"bk-btn",onClick:e.onNextPage,"aria-label":m(()=>t.value.next||"Next"),title:m(()=>t.value.next||"Next"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("polyline",{points:"9 18 15 12 9 6"})})})]}),g("div",{class:"bk-btn-group",children:[g("button",{type:"button",class:"bk-btn",onClick:e.onZoomIn,"aria-label":m(()=>t.value.zoomIn||"Zoom In"),title:m(()=>t.value.zoomIn||"Zoom In"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("circle",{cx:"11",cy:"11",r:"8"}),g("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),g("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),g("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),g("button",{type:"button",class:m(()=>`bk-btn ${e.store.isZoomed.value?"active":""}`),onClick:e.onZoomOut,"aria-label":m(()=>t.value.zoomOut||"Zoom Out"),title:m(()=>t.value.zoomOut||"Zoom Out"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("circle",{cx:"11",cy:"11",r:"8"}),g("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),g("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),g("button",{type:"button",class:"bk-btn bk-btn--fullscreen",onClick:e.onToggleFullscreen,"aria-label":m(()=>t.value.fullscreen||"Fullscreen"),title:m(()=>t.value.fullscreen||"Fullscreen"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:g("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),m(()=>e.store.allowDownload.value&&e.store.hasDownloadUrl.value&&e.onDownload?g("button",{type:"button",class:"bk-btn bk-btn--download",onClick:e.onDownload,"aria-label":m(()=>t.value.downloadCatalog||"Download"),title:m(()=>t.value.downloadCatalog||"Download"),children:g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),g("polyline",{points:"7 10 12 15 17 10"}),g("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}):null),g("button",{type:"button",class:m(()=>`bk-btn ${e.store.soundEnabled.value?"":"muted"}`),onClick:e.onSoundToggle,"aria-label":"Sound","aria-pressed":m(()=>e.store.soundEnabled.value?"true":"false"),title:"Sound",children:[g("svg",{style:{display:m(()=>e.store.soundEnabled.value?"block":"none")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),g("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),g("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}),g("svg",{style:{display:m(()=>e.store.soundEnabled.value?"none":"block")},xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[g("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),g("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),g("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]})]})]})}function ni(e){return g("div",{class:"bk-thumbs",style:m(()=>e.store.showThumbs.value?"display:flex;":"display:none;"),children:e.store.pages.value.map((t,s)=>{const o=()=>{const r=e.store.currentPage.value;if(e.store.isSingleMode.value||r===0||r>=e.store.pages.value.length-1)return r===s;const l=r%2===1?r:r-1;return s===l||s===l+1};return g("div",{class:m(()=>`thumb-item ${o()?"active":""}`),role:"button",tabindex:"0","aria-label":`Go to page ${s+1}`,"aria-current":m(()=>o()?"page":void 0),onClick:()=>e.onThumbClick(s),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),e.onThumbClick(s))},children:[g("div",{class:"thumb-img-wrapper",children:g("img",{"data-pdf-page":t.assetId.startsWith("pdf-page-")?t.pageNumber:void 0,class:"thumb-img",src:t.thumb||t.low||t.normal,alt:`Page ${s+1}`,loading:"lazy",onError:r=>{r.currentTarget.style.display="none"}})}),g("span",{children:s+1})]})})})}function oi(e){return g("div",{role:"region","aria-label":"Flipbook viewer",class:m(()=>{let t="bk-book-wrapper ";return e.store.isDoublePageLayout.value&&(t+="double-mode "),e.store.isFrontCover.value&&(t+="bk-is-cover "),e.store.isBackCover.value&&(t+="bk-is-back-cover "),e.store.zoomState.value.isActive&&(t+="zoomed "),t.trim()}),ref:e.bookWrapperRef,children:g("div",{class:"bk-book-sizer",ref:e.bookSizerRef,children:[g("div",{ref:e.bookContainerRef,class:m(()=>"bk-book "+(e.store.flipState.value!=="read"?"is-flipping":"")),style:m(()=>`display: ${e.store.isSingleMode.value?"none":"block"};`),children:e.store.pages.value.map((t,s)=>{const o=s===0||s===e.store.pages.value.length-1;return g("div",{class:`bz-page ${s===0?"bz-page--cover":""} ${s===e.store.pages.value.length-1?"bz-page--back":""}`,"data-density":o?"hard":"soft","data-idx":s,children:g("div",{class:"bz-page-content",style:"position:relative; width:100%; height:100%; overflow:hidden;",children:[g("img",{"data-pdf-page":t.assetId.startsWith("pdf-page-")?t.pageNumber:void 0,src:t.low||t.normal,"data-src":t.normal,class:`page-content ${t.cropMode!=="full"?"page-content--split page-content--"+t.cropMode:""}`,alt:`Page ${s+1}`,loading:"lazy"}),g("div",{class:"page-shadow"})]})})})}),g("div",{class:"bk-single-view",style:m(()=>`display: ${e.store.isSingleMode.value?"flex":"none"}; width: 100%; height: 100%; justify-content: center; align-items: center; position: absolute; top: 0; left: 0; z-index: 10;`),children:m(()=>{const t=e.store.pages.value[e.store.currentPage.value];return t?g("img",{"data-pdf-page":t.assetId.startsWith("pdf-page-")?t.pageNumber:void 0,class:`bk-single-img page-content ${t.cropMode!=="full"?"page-content--split page-content--"+t.cropMode:""}`,src:e.store.zoomState.value.isActive?t.normal:t.low||t.normal,alt:`Page ${e.store.currentPage.value+1}`,style:"opacity: 1; transition: opacity 0.3s; box-shadow: var(--flipbook-shadow);"}):null})})]})})}function ri(e){const t=m(()=>e.store.showArrows.value&&e.store.currentPage.value>0),s=m(()=>!e.store.showArrows.value||e.store.totalPages.value<=1?!1:e.store.currentPage.value<e.store.totalPages.value-1);return g("div",{class:"bk-nav-arrows",style:m(()=>e.store.showArrows.value?"display: flex;":"display: none;"),children:[g("button",{type:"button",class:"bk-nav-arrow bk-nav-prev",style:m(()=>t.value?"visibility: visible;":"visibility: hidden;"),onClick:o=>{o.preventDefault(),e.onPrevPage()},"aria-label":"Previous Page",children:g("div",{class:"bk-arrow-icon bk-arrow-left"})}),g("button",{type:"button",class:"bk-nav-arrow bk-nav-next",style:m(()=>s.value?"visibility: visible;":"visibility: hidden;"),onClick:o=>{o.preventDefault(),e.onNextPage()},"aria-label":"Next Page",children:g("div",{class:"bk-arrow-icon bk-arrow-right"})})]})}function ai(e){const t=()=>{e.store.showThumbs.value=!e.store.showThumbs.value},s=()=>{e.store.isSingleMode.value=!e.store.isSingleMode.value},o=()=>{e.store.isAutoPlaying.value=!e.store.isAutoPlaying.value},r=()=>{var b;(b=e.interactionManagerRef.current)==null||b.zoomIn()},l=()=>{var b;(b=e.interactionManagerRef.current)==null||b.zoomOut()},d=()=>e.onToggleFullscreen(),p=b=>{var L;e.store.currentPage.value!==b&&(e.store.currentPage.value=b,(L=e.pageFlipAdapterRef.current)==null||L.playSound())},P=()=>{var b;(b=e.pageFlipAdapterRef.current)==null||b.turnToNextPage()},k=()=>{var b;(b=e.pageFlipAdapterRef.current)==null||b.turnToPrevPage()};return g("div",{class:m(()=>`bk-wrapper bk-theme-${e.store.themeMode.value} ${e.className||""}`),children:[g("div",{class:"bk-main-area",children:[g(oi,{store:e.store,bookWrapperRef:e.bookWrapperRef,bookSizerRef:e.bookSizerRef,bookContainerRef:e.bookContainerRef}),g(ri,{store:e.store,onPrevPage:k,onNextPage:P}),e.store.whiteLabel.value?null:g("div",{class:"bk-watermark",children:["Powered by ",g("a",{href:"https://flipbookengine.com",target:"_blank",rel:"noopener",style:"text-decoration: underline;",children:"FlipbookEngine"})]})]}),g(si,{store:e.store,onToggleThumbs:t,onToggleSingleMode:s,onZoomIn:r,onZoomOut:l,onDownload:e.onDownload,onNextPage:P,onPrevPage:k,onSoundToggle:()=>e.store.soundEnabled.value=!e.store.soundEnabled.value,onToggleAutoPlay:o,onToggleFullscreen:d}),g(ni,{store:e.store,onThumbClick:p})]})}var hi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Nt={exports:{}};(function(e,t){(function(s,o){o(t)})(hi,function(s){class o{constructor(i,n){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=n,this.nowDrawingDensity=this.createdDensity,this.render=i}setDensity(i){this.createdDensity=i,this.nowDrawingDensity=i}setDrawingDensity(i){this.nowDrawingDensity=i}setPosition(i){this.state.position=i}setAngle(i){this.state.angle=i}setArea(i){this.state.area=i}setHardDrawingAngle(i){this.state.hardDrawingAngle=i}setHardAngle(i){this.state.hardAngle=i,this.state.hardDrawingAngle=i}setOrientation(i){this.orientation=i}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class r extends o{constructor(i,n,a){super(i,a),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=n}draw(i){const n=this.render.getContext(),a=this.render.convertToGlobal(this.state.position),c=this.render.getRect().pageWidth,h=this.render.getRect().height;n.save(),n.translate(a.x,a.y),n.beginPath();for(let u of this.state.area)u!==null&&(u=this.render.convertToGlobal(u),n.lineTo(u.x-a.x,u.y-a.y));n.rotate(this.state.angle),n.clip(),this.isLoad?n.drawImage(this.image,0,0,c,h):this.drawLoader(n,{x:0,y:0},c,h),n.restore()}simpleDraw(i){const n=this.render.getRect(),a=this.render.getContext(),c=n.pageWidth,h=n.height,u=i===1?n.left+n.pageWidth:n.left,v=n.top;this.isLoad?a.drawImage(this.image,u,v,c,h):this.drawLoader(a,{x:u,y:v},c,h)}drawLoader(i,n,a,c){i.beginPath(),i.strokeStyle="rgb(200, 200, 200)",i.fillStyle="rgb(255, 255, 255)",i.lineWidth=1,i.rect(n.x+1,n.y+1,a-1,c-1),i.stroke(),i.fill();const h={x:n.x+a/2,y:n.y+c/2};i.beginPath(),i.lineWidth=10,i.arc(h.x,h.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),i.stroke(),i.closePath(),this.loadingAngle+=.07,this.loadingAngle>=2*Math.PI&&(this.loadingAngle=0)}load(){this.isLoad||(this.image.onload=()=>{this.isLoad=!0})}newTemporaryCopy(){return this}getTemporaryCopy(){return this}hideTemporaryCopy(){}}class l{constructor(i,n){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=n,this.app=i,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let n=0;n<this.pages.length;n++)this.portraitSpread.push([n]);let i=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([i]),i++);for(let n=i;n<this.pages.length;n+=2)n<this.pages.length-1?this.landscapeSpread.push([n,n+1]):(this.landscapeSpread.push([n]),this.pages[n].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(i){const n=this.getSpread();for(let a=0;a<n.length;a++)if(i===n[a][0]||i===n[a][1])return a;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(i){if(i>=0&&i<this.pages.length)return this.pages[i];throw new Error("Invalid page number")}nextBy(i){const n=this.pages.indexOf(i);return n<this.pages.length-1?this.pages[n+1]:null}prevBy(i){const n=this.pages.indexOf(i);return n>0?this.pages[n-1]:null}getFlippingPage(i){const n=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return i===0?this.pages[n].newTemporaryCopy():this.pages[n-1];{const a=i===0?this.getSpread()[n+1]:this.getSpread()[n-1];return a.length===1||i===0?this.pages[a[0]]:this.pages[a[1]]}}getBottomPage(i){const n=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return i===0?this.pages[n+1]:this.pages[n-1];{const a=i===0?this.getSpread()[n+1]:this.getSpread()[n-1];return a.length===1?this.pages[a[0]]:i===0?this.pages[a[1]]:this.pages[a[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(i=null){if(i===null&&(i=this.currentPageIndex),i<0||i>=this.pages.length)return;const n=this.getSpreadIndexByPage(i);n!==null&&(this.currentSpreadIndex=n,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(i){if(!(i>=0&&i<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=i}showSpread(){const i=this.getSpread()[this.currentSpreadIndex];i.length===2?(this.render.setLeftPage(this.pages[i[0]]),this.render.setRightPage(this.pages[i[1]])):this.render.getOrientation()==="landscape"&&i[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[i[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[i[0]])),this.currentPageIndex=i[0],this.app.updatePageIndex(this.currentPageIndex)}}class d extends l{constructor(i,n,a){super(i,n),this.imagesHref=a}load(){for(const i of this.imagesHref){const n=new r(this.render,i,"soft");n.load(),this.pages.push(n)}this.createSpread()}}class p{static GetDistanceBetweenTwoPoint(i,n){return i===null||n===null?1/0:Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2))}static GetSegmentLength(i){return p.GetDistanceBetweenTwoPoint(i[0],i[1])}static GetAngleBetweenTwoLine(i,n){const a=i[0].y-i[1].y,c=n[0].y-n[1].y,h=i[1].x-i[0].x,u=n[1].x-n[0].x;return Math.acos((a*c+h*u)/(Math.sqrt(a*a+h*h)*Math.sqrt(c*c+u*u)))}static PointInRect(i,n){return n===null?null:n.x>=i.left&&n.x<=i.width+i.left&&n.y>=i.top&&n.y<=i.top+i.height?n:null}static GetRotatedPoint(i,n,a){return{x:i.x*Math.cos(a)+i.y*Math.sin(a)+n.x,y:i.y*Math.cos(a)-i.x*Math.sin(a)+n.y}}static LimitPointToCircle(i,n,a){if(p.GetDistanceBetweenTwoPoint(i,a)<=n)return a;const c=i.x,h=i.y,u=a.x,v=a.y;let y=Math.sqrt(Math.pow(n,2)*Math.pow(c-u,2)/(Math.pow(c-u,2)+Math.pow(h-v,2)))+c;a.x<0&&(y*=-1);let D=(y-c)*(h-v)/(c-u)+h;return c-u+h===0&&(D=n),{x:y,y:D}}static GetIntersectBetweenTwoSegment(i,n,a){return p.PointInRect(i,p.GetIntersectBeetwenTwoLine(n,a))}static GetIntersectBeetwenTwoLine(i,n){const a=i[0].y-i[1].y,c=n[0].y-n[1].y,h=i[1].x-i[0].x,u=n[1].x-n[0].x,v=i[0].x*i[1].y-i[1].x*i[0].y,y=n[0].x*n[1].y-n[1].x*n[0].y,D=a*y-c*v,z=h*y-u*v,N=-(v*u-y*h)/(a*u-c*h),ht=-(a*y-c*v)/(a*u-c*h);if(isFinite(N)&&isFinite(ht))return{x:N,y:ht};if(Math.abs(D-z)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(i,n){const a=Math.abs(i.x-n.x),c=Math.abs(i.y-n.y),h=Math.max(a,c),u=[i];function v(y,D,z,N,ht){return D>y?y+ht*(z/N):D<y?y-ht*(z/N):y}for(let y=1;y<=h;y+=1)u.push({x:v(i.x,n.x,a,h,y),y:v(i.y,n.y,c,h,y)});return u}}class P extends o{constructor(i,n,a){super(i,a),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=n,this.element.classList.add("stf__item"),this.element.classList.add("--"+a)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new P(this.render,this.copiedElement,this.nowDrawingDensity)),this.getTemporaryCopy())}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){this.temporaryCopy!==null&&(this.copiedElement.remove(),this.copiedElement=null,this.temporaryCopy=null)}draw(i){const n=i||this.nowDrawingDensity,a=this.render.convertToGlobal(this.state.position),c=this.render.getRect().pageWidth,h=this.render.getRect().height;this.element.classList.remove("--simple");const u=`
|
|
2
2
|
display: block;
|
|
3
3
|
z-index: ${this.element.style.zIndex};
|
|
4
4
|
left: 0;
|
|
5
5
|
top: 0;
|
|
6
|
-
width: ${
|
|
6
|
+
width: ${c}px;
|
|
7
7
|
height: ${h}px;
|
|
8
|
-
`;n==="hard"?this.drawHard(
|
|
8
|
+
`;n==="hard"?this.drawHard(u):this.drawSoft(a,u)}drawHard(i=""){const n=this.render.getRect().left+this.render.getRect().width/2,a=this.state.hardDrawingAngle,c=i+`
|
|
9
9
|
backface-visibility: hidden;
|
|
10
10
|
-webkit-backface-visibility: hidden;
|
|
11
11
|
clip-path: none;
|
|
12
12
|
-webkit-clip-path: none;
|
|
13
13
|
`+(this.orientation===0?`transform-origin: ${this.render.getRect().pageWidth}px 0;
|
|
14
14
|
transform: translate3d(0, 0, 0) rotateY(${a}deg);`:`transform-origin: 0 0;
|
|
15
|
-
transform: translate3d(${n}px, 0, 0) rotateY(${a}deg);`);this.element.style.cssText=
|
|
15
|
+
transform: translate3d(${n}px, 0, 0) rotateY(${a}deg);`);this.element.style.cssText=c}drawSoft(i,n=""){let a="polygon( ";for(const h of this.state.area)if(h!==null){let u=this.render.getDirection()===1?{x:-h.x+this.state.position.x,y:h.y-this.state.position.y}:{x:h.x-this.state.position.x,y:h.y-this.state.position.y};u=p.GetRotatedPoint(u,{x:0,y:0},this.state.angle),a+=u.x+"px "+u.y+"px, "}a=a.slice(0,-2),a+=")";const c=n+`transform-origin: 0 0; clip-path: ${a}; -webkit-clip-path: ${a};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${i.x}px, ${i.y}px);`:`transform: translate3d(${i.x}px, ${i.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=c}simpleDraw(i){const n=this.render.getRect(),a=n.pageWidth,c=n.height,h=i===1?n.left+n.pageWidth:n.left,u=n.top;this.element.classList.add("--simple"),this.element.style.cssText=`
|
|
16
16
|
position: absolute;
|
|
17
17
|
display: block;
|
|
18
|
-
height: ${
|
|
18
|
+
height: ${c}px;
|
|
19
19
|
left: ${h}px;
|
|
20
|
-
top: ${
|
|
20
|
+
top: ${u}px;
|
|
21
21
|
width: ${a}px;
|
|
22
|
-
z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(i){super.setOrientation(i),this.element.classList.remove("--left","--right"),this.element.classList.add(i===1?"--right":"--left")}setDrawingDensity(i){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+i),super.setDrawingDensity(i)}}class P extends c{constructor(i,n,a,l){super(i,n),this.element=a,this.pagesElement=l}load(){for(const i of this.pagesElement){const n=new k(this.render,i,i.dataset.density==="hard"?"hard":"soft");n.load(),this.pages.push(n)}this.createSpread()}}class x{constructor(i,n,a,l){this.direction=i,this.corner=n,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(a,10),this.pageHeight=parseInt(l,10)}calc(i){try{return this.position=this.calcAngleAndPosition(i),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const i=[];let n=!1;return i.push(this.rect.topLeft),i.push(this.topIntersectPoint),this.sideIntersectPoint===null?n=!0:(i.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(n=!1)),i.push(this.bottomIntersectPoint),(n||this.corner==="bottom")&&i.push(this.rect.bottomLeft),i}getBottomClipArea(){const i=[];return i.push(this.topIntersectPoint),this.corner==="top"?i.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&i.push({x:this.pageWidth,y:0}),i.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?f.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&i.push(this.sideIntersectPoint):this.corner==="top"&&i.push({x:this.pageWidth,y:this.pageHeight}),i.push(this.bottomIntersectPoint),i.push(this.topIntersectPoint),i}getAngle(){return this.direction===0?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return this.direction===0?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return this.direction===1?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return this.corner==="top"?this.topIntersectPoint:this.sideIntersectPoint!==null?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const i=f.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?i:Math.PI-i}calcAngleAndPosition(i){let n=i;if(this.updateAngleAndGeometry(n),n=this.corner==="top"?this.checkPositionAtCenterLine(n,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(n,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(n.x-this.pageWidth)<1&&Math.abs(n.y)<1)throw new Error("Point is too small");return n}updateAngleAndGeometry(i){this.angle=this.calculateAngle(i),this.rect=this.getPageRect(i)}calculateAngle(i){const n=this.pageWidth-i.x+1,a=this.corner==="bottom"?this.pageHeight-i.y:i.y;let l=2*Math.acos(n/Math.sqrt(a*a+n*n));a<0&&(l=-l);const h=Math.PI-l;if(!isFinite(l)||h>=0&&h<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(l=-l),l}getPageRect(i){return this.corner==="top"?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],i):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],i)}getRectFromBasePoint(i,n){return{topLeft:this.getRotatedPoint(i[0],n),topRight:this.getRotatedPoint(i[1],n),bottomLeft:this.getRotatedPoint(i[2],n),bottomRight:this.getRotatedPoint(i[3],n)}}getRotatedPoint(i,n){return{x:i.x*Math.cos(this.angle)+i.y*Math.sin(this.angle)+n.x,y:i.y*Math.cos(this.angle)-i.x*Math.sin(this.angle)+n.y}}calculateIntersectPoint(i){const n={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=f.GetIntersectBetweenTwoSegment(n,[i,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=f.GetIntersectBetweenTwoSegment(n,[i,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=f.GetIntersectBetweenTwoSegment(n,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=f.GetIntersectBetweenTwoSegment(n,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=f.GetIntersectBetweenTwoSegment(n,[i,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=f.GetIntersectBetweenTwoSegment(n,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(i,n,a){let l=i;const h=f.LimitPointToCircle(n,this.pageWidth,l);l!==h&&(l=h,this.updateAngleAndGeometry(l));const d=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let w=this.rect.bottomRight,y=this.rect.topLeft;if(this.corner==="bottom"&&(w=this.rect.topRight,y=this.rect.bottomLeft),w.x<=0){const D=f.LimitPointToCircle(a,d,y);D!==l&&(l=D,this.updateAngleAndGeometry(l))}return l}getSegmentToShadowLine(){const i=this.getShadowStartPoint();return[i,i!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class O{constructor(i,n){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=i,this.app=n}fold(i){this.setState("user_fold"),this.calc===null&&this.start(i),this.do(this.render.convertToPage(i))}flip(i){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(i)||(this.calc!==null&&this.render.finishAnimation(),!this.start(i)))return;const n=this.getBoundsRect();this.setState("flipping");const a=n.height/10,l=this.calc.getCorner()==="bottom"?n.height-a:a,h=this.calc.getCorner()==="bottom"?n.height:0;this.calc.calc({x:n.pageWidth-a,y:l}),this.animateFlippingTo({x:n.pageWidth-a,y:l},{x:-n.pageWidth,y:h},!0)}start(i){this.reset();const n=this.render.convertToBook(i),a=this.getBoundsRect(),l=this.getDirectionByPoint(n),h=n.y>=a.height/2?"bottom":"top";if(!this.checkDirection(l))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(l),this.bottomPage=this.app.getPageCollection().getBottomPage(l),this.render.getOrientation()==="landscape")if(l===1){const d=this.app.getPageCollection().nextBy(this.flippingPage);d!==null&&this.flippingPage.getDensity()!==d.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),d.setDrawingDensity("hard"))}else{const d=this.app.getPageCollection().prevBy(this.flippingPage);d!==null&&this.flippingPage.getDensity()!==d.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),d.setDrawingDensity("hard"))}return this.render.setDirection(l),this.calc=new x(l,h,a.pageWidth.toString(10),a.height.toString(10)),!0}catch{return!1}}do(i){if(this.calc!==null&&this.calc.calc(i)){const n=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardAngle(0),this.flippingPage.setArea(this.calc.getFlippingClipArea()),this.flippingPage.setPosition(this.calc.getActiveCorner()),this.flippingPage.setAngle(this.calc.getAngle()),this.calc.getDirection()===0?this.flippingPage.setHardAngle(90*(200-2*n)/100):this.flippingPage.setHardAngle(-90*(200-2*n)/100),this.render.setPageRect(this.calc.getRect()),this.render.setBottomPage(this.bottomPage),this.render.setFlippingPage(this.flippingPage),this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),n,this.calc.getDirection())}}flipToPage(i,n){const a=this.app.getPageCollection().getCurrentSpreadIndex(),l=this.app.getPageCollection().getSpreadIndexByPage(i);try{l>a&&(this.app.getPageCollection().setCurrentSpreadIndex(l-1),this.flipNext(n)),l<a&&(this.app.getPageCollection().setCurrentSpreadIndex(l+1),this.flipPrev(n))}catch{}}flipNext(i){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:i==="top"?1:this.render.getRect().height-2})}flipPrev(i){this.flip({x:10,y:i==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const i=this.calc.getPosition(),n=this.getBoundsRect(),a=this.calc.getCorner()==="bottom"?n.height:0;i.x<=0?this.animateFlippingTo(i,{x:-n.pageWidth,y:a},!0):this.animateFlippingTo(i,{x:n.pageWidth,y:a},!1)}showCorner(i){if(!this.checkState("read","fold_corner"))return;const n=this.getBoundsRect(),a=n.pageWidth;if(this.isPointOnCorners(i))if(this.calc===null){if(!this.start(i))return;this.setState("fold_corner"),this.calc.calc({x:a-1,y:1});const l=50,h=this.calc.getCorner()==="bottom"?n.height-1:1,d=this.calc.getCorner()==="bottom"?n.height-l:l;this.animateFlippingTo({x:a-1,y:h},{x:a-l,y:d},!1,!1)}else this.do(this.render.convertToPage(i));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(i,n,a,l=!0){const h=f.GetCordsFromTwoPoint(i,n),d=[];for(const y of h)d.push(()=>this.do(y));const w=this.getAnimationDuration(h.length);this.render.startAnimation(d,w,()=>{this.calc&&(a&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),l&&(this.render.setBottomPage(null),this.render.setFlippingPage(null),this.render.clearShadow(),this.setState("read"),this.reset()))})}getCalculation(){return this.calc}getState(){return this.state}setState(i){this.state!==i&&(this.app.updateState(i),this.state=i)}getDirectionByPoint(i){const n=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(i.x-n.pageWidth<=n.width/5)return 1}else if(i.x<n.width/2)return 1;return 0}getAnimationDuration(i){const n=this.app.getSettings().flippingTime;return i>=1e3?n:i/1e3*n}checkDirection(i){return i===0?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null,this.flippingPage=null,this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...i){for(const n of i)if(this.state===n)return!0;return!1}isPointOnCorners(i){const n=this.getBoundsRect(),a=n.pageWidth,l=Math.sqrt(Math.pow(a,2)+Math.pow(n.height,2))/5,h=this.render.convertToBook(i);return h.x>0&&h.y>0&&h.x<n.width&&h.y<n.height&&(h.x<l||h.x>n.width-l)&&(h.y<l||h.y>n.height-l)}}class _{constructor(i,n){this.leftPage=null,this.rightPage=null,this.flippingPage=null,this.bottomPage=null,this.direction=null,this.orientation=null,this.shadow=null,this.animation=null,this.pageRect=null,this.boundsRect=null,this.timer=0,this.safari=!1,this.setting=n,this.app=i;const a=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=a.exec(window.navigator.userAgent)!==null}render(i){if(this.animation!==null){const n=Math.round((i-this.animation.startedAt)/this.animation.durationFrame);n<this.animation.frames.length?this.animation.frames[n]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=i,this.drawFrame()}start(){this.update();const i=n=>{this.render(n),requestAnimationFrame(i)};requestAnimationFrame(i)}startAnimation(i,n,a){this.finishAnimation(),this.animation={frames:i,duration:n,durationFrame:n/i.length,onAnimateEnd:a,startedAt:this.timer}}finishAnimation(){this.animation!==null&&(this.animation.frames[this.animation.frames.length-1](),this.animation.onAnimateEnd!==null&&this.animation.onAnimateEnd()),this.animation=null}update(){this.boundsRect=null;const i=this.calculateBoundsRect();this.orientation!==i&&(this.orientation=i,this.app.updateOrientation(i))}calculateBoundsRect(){let i="landscape";const n=this.getBlockWidth(),a=n/2,l=this.getBlockHeight()/2,h=this.setting.width/this.setting.height;let d=this.setting.width,w=this.setting.height,y=a-d;return this.setting.size==="stretch"?(n<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(i="portrait"),d=i==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,d>this.setting.maxWidth&&(d=this.setting.maxWidth),w=d/h,w>this.getBlockHeight()&&(w=this.getBlockHeight(),d=w*h),y=i==="portrait"?a-d/2-d:a-d):n<2*d&&this.app.getSettings().usePortrait&&(i="portrait",y=a-d/2-d),this.boundsRect={left:y,top:l-w/2,width:2*d,height:w,pageWidth:d},i}setShadowData(i,n,a,l){if(!this.app.getSettings().drawShadow)return;const h=100*this.getSettings().maxShadowOpacity;this.shadow={pos:i,angle:n,width:3*this.getRect().pageWidth/4*a/100,opacity:(100-a)*h/100/100,direction:l,progress:2*a}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){return this.boundsRect===null&&this.calculateBoundsRect(),this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(i){this.pageRect=i}setDirection(i){this.direction=i}setRightPage(i){i!==null&&i.setOrientation(1),this.rightPage=i}setLeftPage(i){i!==null&&i.setOrientation(0),this.leftPage=i}setBottomPage(i){i!==null&&i.setOrientation(this.direction===1?0:1),this.bottomPage=i}setFlippingPage(i){i!==null&&i.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=i}convertToBook(i){const n=this.getRect();return{x:i.x-n.left,y:i.y-n.top}}isSafari(){return this.safari}convertToPage(i,n){n||(n=this.direction);const a=this.getRect();return{x:n===0?i.x-a.left-a.width/2:a.width/2-i.x+a.left,y:i.y-a.top}}convertToGlobal(i,n){if(n||(n=this.direction),i==null)return null;const a=this.getRect();return{x:n===0?i.x+a.left+a.width/2:a.width/2-i.x+a.left,y:i.y+a.top}}convertRectToGlobal(i,n){return n||(n=this.direction),{topLeft:this.convertToGlobal(i.topLeft,n),topRight:this.convertToGlobal(i.topRight,n),bottomLeft:this.convertToGlobal(i.bottomLeft,n),bottomRight:this.convertToGlobal(i.bottomRight,n)}}}class E extends _{constructor(i,n,a){super(i,n),this.canvas=a,this.ctx=a.getContext("2d")}getContext(){return this.ctx}reload(){}drawFrame(){this.clear(),this.orientation!=="portrait"&&this.leftPage!=null&&this.leftPage.simpleDraw(0),this.rightPage!=null&&this.rightPage.simpleDraw(1),this.bottomPage!=null&&this.bottomPage.draw(),this.drawBookShadow(),this.flippingPage!=null&&this.flippingPage.draw(),this.shadow!=null&&(this.drawOuterShadow(),this.drawInnerShadow());const i=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(i.left+i.pageWidth,i.top,i.width,i.height),this.ctx.clip())}drawBookShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath();const n=i.width/20;this.ctx.rect(i.left,i.top,i.width,i.height);const a={x:i.left+i.width/2-n/2,y:0};this.ctx.translate(a.x,a.y);const l=this.ctx.createLinearGradient(0,0,n,0);l.addColorStop(0,"rgba(0, 0, 0, 0)"),l.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),l.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),l.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),l.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),l.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=l,this.ctx.fillRect(0,0,n,2*i.height),this.ctx.restore()}drawOuterShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(i.left,i.top,i.width,i.height);const n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(n.x,n.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const a=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),a.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),a.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),a.addColorStop(0,"rgba(0, 0, 0, 0)"),a.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=a,this.ctx.fillRect(0,0,this.shadow.width,2*i.height),this.ctx.restore()}drawInnerShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath();const n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),a=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(a.topLeft.x,a.topLeft.y),this.ctx.lineTo(a.topRight.x,a.topRight.y),this.ctx.lineTo(a.bottomRight.x,a.bottomRight.y),this.ctx.lineTo(a.bottomLeft.x,a.bottomLeft.y),this.ctx.translate(n.x,n.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const l=3*this.shadow.width/4,h=this.ctx.createLinearGradient(0,0,l,0);this.shadow.direction===0?(this.ctx.translate(-l,-100),h.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),h.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),h.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),h.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=h,this.ctx.fillRect(0,0,l,2*i.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class M{constructor(i,n,a){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=h=>{if(this.checkTarget(h.target)){const d=this.getMousePos(h.clientX,h.clientY);this.app.startUserTouch(d),h.preventDefault()}},this.onTouchStart=h=>{if(this.checkTarget(h.target)&&h.changedTouches.length>0){const d=h.changedTouches[0],w=this.getMousePos(d.clientX,d.clientY);this.touchPoint={point:w,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(w)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||h.preventDefault()}},this.onMouseUp=h=>{const d=this.getMousePos(h.clientX,h.clientY);this.app.userStop(d)},this.onMouseMove=h=>{const d=this.getMousePos(h.clientX,h.clientY);this.app.userMove(d,!1)},this.onTouchMove=h=>{if(h.changedTouches.length>0){const d=h.changedTouches[0],w=this.getMousePos(d.clientX,d.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-w.x)>10||this.app.getState()!=="read")&&h.cancelable&&this.app.userMove(w,!0),this.app.getState()!=="read"&&h.preventDefault()):this.app.userMove(w,!0)}},this.onTouchEnd=h=>{if(h.changedTouches.length>0){const d=h.changedTouches[0],w=this.getMousePos(d.clientX,d.clientY);let y=!1;if(this.touchPoint!==null){const D=w.x-this.touchPoint.point.x,L=Math.abs(w.y-this.touchPoint.point.y);Math.abs(D)>this.swipeDistance&&L<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(D>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"),y=!0),this.touchPoint=null}this.app.userStop(w,y)}},this.parentElement=i,i.classList.add("stf__parent"),i.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=i.querySelector(".stf__wrapper"),this.app=n;const l=this.app.getSettings().usePortrait?1:2;i.style.minWidth=a.minWidth*l+"px",i.style.minHeight=a.minHeight+"px",a.size==="fixed"&&(i.style.minWidth=a.width*l+"px",i.style.minHeight=a.height+"px"),a.autoSize&&(i.style.width="100%",i.style.maxWidth=2*a.maxWidth+"px"),i.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=a.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(i){this.wrapper.classList.remove("--portrait","--landscape"),i==="portrait"?(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%"),this.wrapper.classList.add("--portrait")):(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%"),this.wrapper.classList.add("--landscape")),this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize),this.distElement.removeEventListener("mousedown",this.onMouseDown),this.distElement.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1),this.app.getSettings().useMouseEvents&&(this.distElement.addEventListener("mousedown",this.onMouseDown),this.distElement.addEventListener("touchstart",this.onTouchStart),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onTouchEnd))}getMousePos(i,n){const a=this.distElement.getBoundingClientRect();return{x:i-a.left,y:n-a.top}}checkTarget(i){return!this.app.getSettings().clickEventForward||!["a","button"].includes(i.tagName.toLowerCase())}}class N extends M{constructor(i,n,a,l){super(i,n,a),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=i.querySelector(".stf__block"),this.items=l;for(const h of l)this.distElement.appendChild(h);this.setHandlers()}clear(){for(const i of this.items)this.parentElement.appendChild(i)}updateItems(i){this.removeHandlers(),this.distElement.innerHTML="";for(const n of i)this.distElement.appendChild(n);this.items=i,this.setHandlers()}update(){this.app.getRender().update()}}class Q extends M{constructor(i,n,a){super(i,n,a),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=i.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const i=getComputedStyle(this.canvas),n=parseInt(i.getPropertyValue("width"),10),a=parseInt(i.getPropertyValue("height"),10);this.canvas.width=n,this.canvas.height=a}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class G extends _{constructor(i,n,a){super(i,n),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=a,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
|
|
22
|
+
z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(i){super.setOrientation(i),this.element.classList.remove("--left","--right"),this.element.classList.add(i===1?"--right":"--left")}setDrawingDensity(i){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+i),super.setDrawingDensity(i)}}class k extends l{constructor(i,n,a,c){super(i,n),this.element=a,this.pagesElement=c}load(){for(const i of this.pagesElement){const n=new P(this.render,i,i.dataset.density==="hard"?"hard":"soft");n.load(),this.pages.push(n)}this.createSpread()}}class b{constructor(i,n,a,c){this.direction=i,this.corner=n,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(a,10),this.pageHeight=parseInt(c,10)}calc(i){try{return this.position=this.calcAngleAndPosition(i),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const i=[];let n=!1;return i.push(this.rect.topLeft),i.push(this.topIntersectPoint),this.sideIntersectPoint===null?n=!0:(i.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(n=!1)),i.push(this.bottomIntersectPoint),(n||this.corner==="bottom")&&i.push(this.rect.bottomLeft),i}getBottomClipArea(){const i=[];return i.push(this.topIntersectPoint),this.corner==="top"?i.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&i.push({x:this.pageWidth,y:0}),i.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?p.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&i.push(this.sideIntersectPoint):this.corner==="top"&&i.push({x:this.pageWidth,y:this.pageHeight}),i.push(this.bottomIntersectPoint),i.push(this.topIntersectPoint),i}getAngle(){return this.direction===0?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return this.direction===0?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return this.direction===1?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return this.corner==="top"?this.topIntersectPoint:this.sideIntersectPoint!==null?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const i=p.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?i:Math.PI-i}calcAngleAndPosition(i){let n=i;if(this.updateAngleAndGeometry(n),n=this.corner==="top"?this.checkPositionAtCenterLine(n,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(n,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(n.x-this.pageWidth)<1&&Math.abs(n.y)<1)throw new Error("Point is too small");return n}updateAngleAndGeometry(i){this.angle=this.calculateAngle(i),this.rect=this.getPageRect(i)}calculateAngle(i){const n=this.pageWidth-i.x+1,a=this.corner==="bottom"?this.pageHeight-i.y:i.y;let c=2*Math.acos(n/Math.sqrt(a*a+n*n));a<0&&(c=-c);const h=Math.PI-c;if(!isFinite(c)||h>=0&&h<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(c=-c),c}getPageRect(i){return this.corner==="top"?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],i):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],i)}getRectFromBasePoint(i,n){return{topLeft:this.getRotatedPoint(i[0],n),topRight:this.getRotatedPoint(i[1],n),bottomLeft:this.getRotatedPoint(i[2],n),bottomRight:this.getRotatedPoint(i[3],n)}}getRotatedPoint(i,n){return{x:i.x*Math.cos(this.angle)+i.y*Math.sin(this.angle)+n.x,y:i.y*Math.cos(this.angle)-i.x*Math.sin(this.angle)+n.y}}calculateIntersectPoint(i){const n={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=p.GetIntersectBetweenTwoSegment(n,[i,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=p.GetIntersectBetweenTwoSegment(n,[i,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=p.GetIntersectBetweenTwoSegment(n,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=p.GetIntersectBetweenTwoSegment(n,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=p.GetIntersectBetweenTwoSegment(n,[i,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=p.GetIntersectBetweenTwoSegment(n,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(i,n,a){let c=i;const h=p.LimitPointToCircle(n,this.pageWidth,c);c!==h&&(c=h,this.updateAngleAndGeometry(c));const u=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let v=this.rect.bottomRight,y=this.rect.topLeft;if(this.corner==="bottom"&&(v=this.rect.topRight,y=this.rect.bottomLeft),v.x<=0){const D=p.LimitPointToCircle(a,u,y);D!==c&&(c=D,this.updateAngleAndGeometry(c))}return c}getSegmentToShadowLine(){const i=this.getShadowStartPoint();return[i,i!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class L{constructor(i,n){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=i,this.app=n}fold(i){this.setState("user_fold"),this.calc===null&&this.start(i),this.do(this.render.convertToPage(i))}flip(i){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(i)||(this.calc!==null&&this.render.finishAnimation(),!this.start(i)))return;const n=this.getBoundsRect();this.setState("flipping");const a=n.height/10,c=this.calc.getCorner()==="bottom"?n.height-a:a,h=this.calc.getCorner()==="bottom"?n.height:0;this.calc.calc({x:n.pageWidth-a,y:c}),this.animateFlippingTo({x:n.pageWidth-a,y:c},{x:-n.pageWidth,y:h},!0)}start(i){this.reset();const n=this.render.convertToBook(i),a=this.getBoundsRect(),c=this.getDirectionByPoint(n),h=n.y>=a.height/2?"bottom":"top";if(!this.checkDirection(c))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(c),this.bottomPage=this.app.getPageCollection().getBottomPage(c),this.render.getOrientation()==="landscape")if(c===1){const u=this.app.getPageCollection().nextBy(this.flippingPage);u!==null&&this.flippingPage.getDensity()!==u.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),u.setDrawingDensity("hard"))}else{const u=this.app.getPageCollection().prevBy(this.flippingPage);u!==null&&this.flippingPage.getDensity()!==u.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),u.setDrawingDensity("hard"))}return this.render.setDirection(c),this.calc=new b(c,h,a.pageWidth.toString(10),a.height.toString(10)),!0}catch{return!1}}do(i){if(this.calc!==null&&this.calc.calc(i)){const n=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea()),this.bottomPage.setPosition(this.calc.getBottomPagePosition()),this.bottomPage.setAngle(0),this.bottomPage.setHardAngle(0),this.flippingPage.setArea(this.calc.getFlippingClipArea()),this.flippingPage.setPosition(this.calc.getActiveCorner()),this.flippingPage.setAngle(this.calc.getAngle()),this.calc.getDirection()===0?this.flippingPage.setHardAngle(90*(200-2*n)/100):this.flippingPage.setHardAngle(-90*(200-2*n)/100),this.render.setPageRect(this.calc.getRect()),this.render.setBottomPage(this.bottomPage),this.render.setFlippingPage(this.flippingPage),this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),n,this.calc.getDirection())}}flipToPage(i,n){const a=this.app.getPageCollection().getCurrentSpreadIndex(),c=this.app.getPageCollection().getSpreadIndexByPage(i);try{c>a&&(this.app.getPageCollection().setCurrentSpreadIndex(c-1),this.flipNext(n)),c<a&&(this.app.getPageCollection().setCurrentSpreadIndex(c+1),this.flipPrev(n))}catch{}}flipNext(i){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:i==="top"?1:this.render.getRect().height-2})}flipPrev(i){this.flip({x:10,y:i==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const i=this.calc.getPosition(),n=this.getBoundsRect(),a=this.calc.getCorner()==="bottom"?n.height:0;i.x<=0?this.animateFlippingTo(i,{x:-n.pageWidth,y:a},!0):this.animateFlippingTo(i,{x:n.pageWidth,y:a},!1)}showCorner(i){if(!this.checkState("read","fold_corner"))return;const n=this.getBoundsRect(),a=n.pageWidth;if(this.isPointOnCorners(i))if(this.calc===null){if(!this.start(i))return;this.setState("fold_corner"),this.calc.calc({x:a-1,y:1});const c=50,h=this.calc.getCorner()==="bottom"?n.height-1:1,u=this.calc.getCorner()==="bottom"?n.height-c:c;this.animateFlippingTo({x:a-1,y:h},{x:a-c,y:u},!1,!1)}else this.do(this.render.convertToPage(i));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(i,n,a,c=!0){const h=p.GetCordsFromTwoPoint(i,n),u=[];for(const y of h)u.push(()=>this.do(y));const v=this.getAnimationDuration(h.length);this.render.startAnimation(u,v,()=>{this.calc&&(a&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),c&&(this.render.setBottomPage(null),this.render.setFlippingPage(null),this.render.clearShadow(),this.setState("read"),this.reset()))})}getCalculation(){return this.calc}getState(){return this.state}setState(i){this.state!==i&&(this.app.updateState(i),this.state=i)}getDirectionByPoint(i){const n=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(i.x-n.pageWidth<=n.width/5)return 1}else if(i.x<n.width/2)return 1;return 0}getAnimationDuration(i){const n=this.app.getSettings().flippingTime;return i>=1e3?n:i/1e3*n}checkDirection(i){return i===0?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null,this.flippingPage=null,this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...i){for(const n of i)if(this.state===n)return!0;return!1}isPointOnCorners(i){const n=this.getBoundsRect(),a=n.pageWidth,c=Math.sqrt(Math.pow(a,2)+Math.pow(n.height,2))/5,h=this.render.convertToBook(i);return h.x>0&&h.y>0&&h.x<n.width&&h.y<n.height&&(h.x<c||h.x>n.width-c)&&(h.y<c||h.y>n.height-c)}}class G{constructor(i,n){this.leftPage=null,this.rightPage=null,this.flippingPage=null,this.bottomPage=null,this.direction=null,this.orientation=null,this.shadow=null,this.animation=null,this.pageRect=null,this.boundsRect=null,this.timer=0,this.safari=!1,this.setting=n,this.app=i;const a=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=a.exec(window.navigator.userAgent)!==null}render(i){if(this.animation!==null){const n=Math.round((i-this.animation.startedAt)/this.animation.durationFrame);n<this.animation.frames.length?this.animation.frames[n]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=i,this.drawFrame()}start(){this.update();const i=n=>{this.render(n),requestAnimationFrame(i)};requestAnimationFrame(i)}startAnimation(i,n,a){this.finishAnimation(),this.animation={frames:i,duration:n,durationFrame:n/i.length,onAnimateEnd:a,startedAt:this.timer}}finishAnimation(){this.animation!==null&&(this.animation.frames[this.animation.frames.length-1](),this.animation.onAnimateEnd!==null&&this.animation.onAnimateEnd()),this.animation=null}update(){this.boundsRect=null;const i=this.calculateBoundsRect();this.orientation!==i&&(this.orientation=i,this.app.updateOrientation(i))}calculateBoundsRect(){let i="landscape";const n=this.getBlockWidth(),a=n/2,c=this.getBlockHeight()/2,h=this.setting.width/this.setting.height;let u=this.setting.width,v=this.setting.height,y=a-u;return this.setting.size==="stretch"?(n<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(i="portrait"),u=i==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,u>this.setting.maxWidth&&(u=this.setting.maxWidth),v=u/h,v>this.getBlockHeight()&&(v=this.getBlockHeight(),u=v*h),y=i==="portrait"?a-u/2-u:a-u):n<2*u&&this.app.getSettings().usePortrait&&(i="portrait",y=a-u/2-u),this.boundsRect={left:y,top:c-v/2,width:2*u,height:v,pageWidth:u},i}setShadowData(i,n,a,c){if(!this.app.getSettings().drawShadow)return;const h=100*this.getSettings().maxShadowOpacity;this.shadow={pos:i,angle:n,width:3*this.getRect().pageWidth/4*a/100,opacity:(100-a)*h/100/100,direction:c,progress:2*a}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){return this.boundsRect===null&&this.calculateBoundsRect(),this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(i){this.pageRect=i}setDirection(i){this.direction=i}setRightPage(i){i!==null&&i.setOrientation(1),this.rightPage=i}setLeftPage(i){i!==null&&i.setOrientation(0),this.leftPage=i}setBottomPage(i){i!==null&&i.setOrientation(this.direction===1?0:1),this.bottomPage=i}setFlippingPage(i){i!==null&&i.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=i}convertToBook(i){const n=this.getRect();return{x:i.x-n.left,y:i.y-n.top}}isSafari(){return this.safari}convertToPage(i,n){n||(n=this.direction);const a=this.getRect();return{x:n===0?i.x-a.left-a.width/2:a.width/2-i.x+a.left,y:i.y-a.top}}convertToGlobal(i,n){if(n||(n=this.direction),i==null)return null;const a=this.getRect();return{x:n===0?i.x+a.left+a.width/2:a.width/2-i.x+a.left,y:i.y+a.top}}convertRectToGlobal(i,n){return n||(n=this.direction),{topLeft:this.convertToGlobal(i.topLeft,n),topRight:this.convertToGlobal(i.topRight,n),bottomLeft:this.convertToGlobal(i.bottomLeft,n),bottomRight:this.convertToGlobal(i.bottomRight,n)}}}class E extends G{constructor(i,n,a){super(i,n),this.canvas=a,this.ctx=a.getContext("2d")}getContext(){return this.ctx}reload(){}drawFrame(){this.clear(),this.orientation!=="portrait"&&this.leftPage!=null&&this.leftPage.simpleDraw(0),this.rightPage!=null&&this.rightPage.simpleDraw(1),this.bottomPage!=null&&this.bottomPage.draw(),this.drawBookShadow(),this.flippingPage!=null&&this.flippingPage.draw(),this.shadow!=null&&(this.drawOuterShadow(),this.drawInnerShadow());const i=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(i.left+i.pageWidth,i.top,i.width,i.height),this.ctx.clip())}drawBookShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath();const n=i.width/20;this.ctx.rect(i.left,i.top,i.width,i.height);const a={x:i.left+i.width/2-n/2,y:0};this.ctx.translate(a.x,a.y);const c=this.ctx.createLinearGradient(0,0,n,0);c.addColorStop(0,"rgba(0, 0, 0, 0)"),c.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),c.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),c.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),c.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),c.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=c,this.ctx.fillRect(0,0,n,2*i.height),this.ctx.restore()}drawOuterShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(i.left,i.top,i.width,i.height);const n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(n.x,n.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const a=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),a.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),a.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),a.addColorStop(0,"rgba(0, 0, 0, 0)"),a.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=a,this.ctx.fillRect(0,0,this.shadow.width,2*i.height),this.ctx.restore()}drawInnerShadow(){const i=this.getRect();this.ctx.save(),this.ctx.beginPath();const n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),a=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(a.topLeft.x,a.topLeft.y),this.ctx.lineTo(a.topRight.x,a.topRight.y),this.ctx.lineTo(a.bottomRight.x,a.bottomRight.y),this.ctx.lineTo(a.bottomLeft.x,a.bottomLeft.y),this.ctx.translate(n.x,n.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const c=3*this.shadow.width/4,h=this.ctx.createLinearGradient(0,0,c,0);this.shadow.direction===0?(this.ctx.translate(-c,-100),h.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(.9,"rgba(0, 0, 0, 0.05)"),h.addColorStop(.7,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(0,"rgba(0, 0, 0, 0)")):(this.ctx.translate(0,-100),h.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(.1,"rgba(0, 0, 0, 0.05)"),h.addColorStop(.3,"rgba(0, 0, 0, "+this.shadow.opacity+")"),h.addColorStop(1,"rgba(0, 0, 0, 0)")),this.ctx.clip(),this.ctx.fillStyle=h,this.ctx.fillRect(0,0,c,2*i.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class M{constructor(i,n,a){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=h=>{if(this.checkTarget(h.target)){const u=this.getMousePos(h.clientX,h.clientY);this.app.startUserTouch(u),h.preventDefault()}},this.onTouchStart=h=>{if(this.checkTarget(h.target)&&h.changedTouches.length>0){const u=h.changedTouches[0],v=this.getMousePos(u.clientX,u.clientY);this.touchPoint={point:v,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(v)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||h.preventDefault()}},this.onMouseUp=h=>{const u=this.getMousePos(h.clientX,h.clientY);this.app.userStop(u)},this.onMouseMove=h=>{const u=this.getMousePos(h.clientX,h.clientY);this.app.userMove(u,!1)},this.onTouchMove=h=>{if(h.changedTouches.length>0){const u=h.changedTouches[0],v=this.getMousePos(u.clientX,u.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-v.x)>10||this.app.getState()!=="read")&&h.cancelable&&this.app.userMove(v,!0),this.app.getState()!=="read"&&h.preventDefault()):this.app.userMove(v,!0)}},this.onTouchEnd=h=>{if(h.changedTouches.length>0){const u=h.changedTouches[0],v=this.getMousePos(u.clientX,u.clientY);let y=!1;if(this.touchPoint!==null){const D=v.x-this.touchPoint.point.x,z=Math.abs(v.y-this.touchPoint.point.y);Math.abs(D)>this.swipeDistance&&z<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(D>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"),y=!0),this.touchPoint=null}this.app.userStop(v,y)}},this.parentElement=i,i.classList.add("stf__parent"),i.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=i.querySelector(".stf__wrapper"),this.app=n;const c=this.app.getSettings().usePortrait?1:2;i.style.minWidth=a.minWidth*c+"px",i.style.minHeight=a.minHeight+"px",a.size==="fixed"&&(i.style.minWidth=a.width*c+"px",i.style.minHeight=a.height+"px"),a.autoSize&&(i.style.width="100%",i.style.maxWidth=2*a.maxWidth+"px"),i.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=a.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(i){this.wrapper.classList.remove("--portrait","--landscape"),i==="portrait"?(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%"),this.wrapper.classList.add("--portrait")):(this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%"),this.wrapper.classList.add("--landscape")),this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize),this.distElement.removeEventListener("mousedown",this.onMouseDown),this.distElement.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1),this.app.getSettings().useMouseEvents&&(this.distElement.addEventListener("mousedown",this.onMouseDown),this.distElement.addEventListener("touchstart",this.onTouchStart),window.addEventListener("mousemove",this.onMouseMove),window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport}),window.addEventListener("mouseup",this.onMouseUp),window.addEventListener("touchend",this.onTouchEnd))}getMousePos(i,n){const a=this.distElement.getBoundingClientRect();return{x:i-a.left,y:n-a.top}}checkTarget(i){return!this.app.getSettings().clickEventForward||!["a","button"].includes(i.tagName.toLowerCase())}}class H extends M{constructor(i,n,a,c){super(i,n,a),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=i.querySelector(".stf__block"),this.items=c;for(const h of c)this.distElement.appendChild(h);this.setHandlers()}clear(){for(const i of this.items)this.parentElement.appendChild(i)}updateItems(i){this.removeHandlers(),this.distElement.innerHTML="";for(const n of i)this.distElement.appendChild(n);this.items=i,this.setHandlers()}update(){this.app.getRender().update()}}class Q extends M{constructor(i,n,a){super(i,n,a),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=i.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const i=getComputedStyle(this.canvas),n=parseInt(i.getPropertyValue("width"),10),a=parseInt(i.getPropertyValue("height"),10);this.canvas.width=n,this.canvas.height=a}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class j extends G{constructor(i,n,a){super(i,n),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=a,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
|
|
23
23
|
<div class="stf__innerShadow"></div>
|
|
24
24
|
<div class="stf__hardShadow"></div>
|
|
25
|
-
<div class="stf__hardInnerShadow"></div>`),this.outerShadow=this.element.querySelector(".stf__outerShadow"),this.innerShadow=this.element.querySelector(".stf__innerShadow"),this.hardShadow=this.element.querySelector(".stf__hardShadow"),this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow(),this.outerShadow.style.cssText="display: none",this.innerShadow.style.cssText="display: none",this.hardShadow.style.cssText="display: none",this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const i=this.getRect(),n=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let a=(100-n)*(2.5*i.pageWidth)/100+20;a>i.pageWidth&&(a=i.pageWidth);let
|
|
25
|
+
<div class="stf__hardInnerShadow"></div>`),this.outerShadow=this.element.querySelector(".stf__outerShadow"),this.innerShadow=this.element.querySelector(".stf__innerShadow"),this.hardShadow=this.element.querySelector(".stf__hardShadow"),this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow(),this.outerShadow.style.cssText="display: none",this.innerShadow.style.cssText="display: none",this.hardShadow.style.cssText="display: none",this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const i=this.getRect(),n=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let a=(100-n)*(2.5*i.pageWidth)/100+20;a>i.pageWidth&&(a=i.pageWidth);let c=`
|
|
26
26
|
display: block;
|
|
27
27
|
z-index: ${(this.getSettings().startZIndex+5).toString(10)};
|
|
28
28
|
width: ${a}px;
|
|
@@ -32,7 +32,7 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
32
32
|
rgba(0, 0, 0, 0) 100%);
|
|
33
33
|
left: ${i.left+i.width/2}px;
|
|
34
34
|
transform-origin: 0 0;
|
|
35
|
-
`;
|
|
35
|
+
`;c+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);",this.hardInnerShadow.style.cssText=c}drawHardOuterShadow(){const i=this.getRect();let n=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*i.pageWidth)/100+20;n>i.pageWidth&&(n=i.pageWidth);let a=`
|
|
36
36
|
display: block;
|
|
37
37
|
z-index: ${(this.getSettings().startZIndex+4).toString(10)};
|
|
38
38
|
width: ${n}px;
|
|
@@ -40,31 +40,31 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
40
40
|
background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
|
|
41
41
|
left: ${i.left+i.width/2}px;
|
|
42
42
|
transform-origin: 0 0;
|
|
43
|
-
`;a+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=a}drawInnerShadow(){const i=this.getRect(),n=3*this.shadow.width/4,a=this.getDirection()===0?n:0,
|
|
43
|
+
`;a+=this.getDirection()===0&&this.shadow.progress>100||this.getDirection()===1&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);",this.hardShadow.style.cssText=a}drawInnerShadow(){const i=this.getRect(),n=3*this.shadow.width/4,a=this.getDirection()===0?n:0,c=this.getDirection()===0?"to left":"to right",h=this.convertToGlobal(this.shadow.pos),u=this.shadow.angle+3*Math.PI/2,v=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let y="polygon( ";for(const z of v){let N=this.getDirection()===1?{x:-z.x+this.shadow.pos.x,y:z.y-this.shadow.pos.y}:{x:z.x-this.shadow.pos.x,y:z.y-this.shadow.pos.y};N=p.GetRotatedPoint(N,{x:a,y:100},u),y+=N.x+"px "+N.y+"px, "}y=y.slice(0,-2),y+=")";const D=`
|
|
44
44
|
display: block;
|
|
45
45
|
z-index: ${(this.getSettings().startZIndex+10).toString(10)};
|
|
46
46
|
width: ${n}px;
|
|
47
47
|
height: ${2*i.height}px;
|
|
48
|
-
background: linear-gradient(${
|
|
48
|
+
background: linear-gradient(${c},
|
|
49
49
|
rgba(0, 0, 0, ${this.shadow.opacity}) 5%,
|
|
50
50
|
rgba(0, 0, 0, 0.05) 15%,
|
|
51
51
|
rgba(0, 0, 0, ${this.shadow.opacity}) 35%,
|
|
52
52
|
rgba(0, 0, 0, 0) 100%);
|
|
53
53
|
transform-origin: ${a}px 100px;
|
|
54
|
-
transform: translate3d(${h.x-a}px, ${h.y-100}px, 0) rotate(${
|
|
54
|
+
transform: translate3d(${h.x-a}px, ${h.y-100}px, 0) rotate(${u}rad);
|
|
55
55
|
clip-path: ${y};
|
|
56
56
|
-webkit-clip-path: ${y};
|
|
57
|
-
`;this.innerShadow.style.cssText=D}drawOuterShadow(){const i=this.getRect(),n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),a=this.shadow.angle+3*Math.PI/2,
|
|
57
|
+
`;this.innerShadow.style.cssText=D}drawOuterShadow(){const i=this.getRect(),n=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),a=this.shadow.angle+3*Math.PI/2,c=this.getDirection()===1?this.shadow.width:0,h=this.getDirection()===0?"to right":"to left",u=[{x:0,y:0},{x:i.pageWidth,y:0},{x:i.pageWidth,y:i.height},{x:0,y:i.height}];let v="polygon( ";for(const D of u)if(D!==null){let z=this.getDirection()===1?{x:-D.x+this.shadow.pos.x,y:D.y-this.shadow.pos.y}:{x:D.x-this.shadow.pos.x,y:D.y-this.shadow.pos.y};z=p.GetRotatedPoint(z,{x:c,y:100},a),v+=z.x+"px "+z.y+"px, "}v=v.slice(0,-2),v+=")";const y=`
|
|
58
58
|
display: block;
|
|
59
59
|
z-index: ${(this.getSettings().startZIndex+10).toString(10)};
|
|
60
60
|
width: ${this.shadow.width}px;
|
|
61
61
|
height: ${2*i.height}px;
|
|
62
62
|
background: linear-gradient(${h}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));
|
|
63
|
-
transform-origin: ${
|
|
64
|
-
transform: translate3d(${n.x-
|
|
65
|
-
clip-path: ${
|
|
66
|
-
-webkit-clip-path: ${
|
|
67
|
-
`;this.outerShadow.style.cssText=y}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.leftPage.draw(this.flippingPage.getDrawingDensity())):this.leftPage.simpleDraw(0))}drawRightPage(){this.rightPage!==null&&(this.direction===0&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.rightPage.draw(this.flippingPage.getDrawingDensity())):this.rightPage.simpleDraw(1))}drawBottomPage(){if(this.bottomPage===null)return;const i=this.flippingPage!=null?this.flippingPage.getDrawingDensity():null;this.orientation==="portrait"&&this.direction===1||(this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10),this.bottomPage.draw(i))}drawFrame(){this.clear(),this.drawLeftPage(),this.drawRightPage(),this.drawBottomPage(),this.flippingPage!=null&&(this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.flippingPage.draw()),this.shadow!=null&&this.flippingPage!==null&&(this.flippingPage.getDrawingDensity()==="soft"?(this.drawOuterShadow(),this.drawInnerShadow()):(this.drawHardOuterShadow(),this.drawHardInnerShadow()))}clear(){for(const i of this.app.getPageCollection().getPages())i!==this.leftPage&&i!==this.rightPage&&i!==this.flippingPage&&i!==this.bottomPage&&(i.getElement().style.cssText="display: none"),i.getTemporaryCopy()!==this.flippingPage&&i.hideTemporaryCopy()}update(){super.update(),this.rightPage!==null&&this.rightPage.setOrientation(1),this.leftPage!==null&&this.leftPage.setOrientation(0)}}class
|
|
63
|
+
transform-origin: ${c}px 100px;
|
|
64
|
+
transform: translate3d(${n.x-c}px, ${n.y-100}px, 0) rotate(${a}rad);
|
|
65
|
+
clip-path: ${v};
|
|
66
|
+
-webkit-clip-path: ${v};
|
|
67
|
+
`;this.outerShadow.style.cssText=y}drawLeftPage(){this.orientation!=="portrait"&&this.leftPage!==null&&(this.direction===1&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.leftPage.draw(this.flippingPage.getDrawingDensity())):this.leftPage.simpleDraw(0))}drawRightPage(){this.rightPage!==null&&(this.direction===0&&this.flippingPage!==null&&this.flippingPage.getDrawingDensity()==="hard"?(this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle()),this.rightPage.draw(this.flippingPage.getDrawingDensity())):this.rightPage.simpleDraw(1))}drawBottomPage(){if(this.bottomPage===null)return;const i=this.flippingPage!=null?this.flippingPage.getDrawingDensity():null;this.orientation==="portrait"&&this.direction===1||(this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10),this.bottomPage.draw(i))}drawFrame(){this.clear(),this.drawLeftPage(),this.drawRightPage(),this.drawBottomPage(),this.flippingPage!=null&&(this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10),this.flippingPage.draw()),this.shadow!=null&&this.flippingPage!==null&&(this.flippingPage.getDrawingDensity()==="soft"?(this.drawOuterShadow(),this.drawInnerShadow()):(this.drawHardOuterShadow(),this.drawHardInnerShadow()))}clear(){for(const i of this.app.getPageCollection().getPages())i!==this.leftPage&&i!==this.rightPage&&i!==this.flippingPage&&i!==this.bottomPage&&(i.getElement().style.cssText="display: none"),i.getTemporaryCopy()!==this.flippingPage&&i.hideTemporaryCopy()}update(){super.update(),this.rightPage!==null&&this.rightPage.setOrientation(1),this.leftPage!==null&&this.leftPage.setOrientation(0)}}class U{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1}}getSettings(i){const n=this._default;if(Object.assign(n,i),n.size!=="stretch"&&n.size!=="fixed")throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(n.width<=0||n.height<=0)throw new Error("Invalid width or height");if(n.flippingTime<=0)throw new Error("Invalid flipping time");return n.size==="stretch"?(n.minWidth<=0&&(n.minWidth=100),n.maxWidth<n.minWidth&&(n.maxWidth=2e3),n.minHeight<=0&&(n.minHeight=100),n.maxHeight<n.minHeight&&(n.maxHeight=2e3)):(n.minWidth=n.width,n.maxWidth=n.width,n.minHeight=n.height,n.maxHeight=n.height),n}}(function(f,i){i===void 0&&(i={});var n=i.insertAt;if(typeof document<"u"){var a=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.type="text/css",n==="top"&&a.firstChild?a.insertBefore(c,a.firstChild):a.appendChild(c),c.styleSheet?c.styleSheet.cssText=f:c.appendChild(document.createTextNode(f))}})(`.stf__parent {
|
|
68
68
|
position: relative;
|
|
69
69
|
display: block;
|
|
70
70
|
box-sizing: border-box;
|
|
@@ -124,7 +124,7 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
124
124
|
position: absolute;
|
|
125
125
|
left: 0;
|
|
126
126
|
top: 0;
|
|
127
|
-
}`),s.PageFlip=class extends class{constructor(){this.events=new Map}on(
|
|
127
|
+
}`),s.PageFlip=class extends class{constructor(){this.events=new Map}on(f,i){return this.events.has(f)?this.events.get(f).push(i):this.events.set(f,[i]),this}off(f){this.events.delete(f)}trigger(f,i,n=null){if(this.events.has(f))for(const a of this.events.get(f))a({data:n,object:i})}}{constructor(f,i){super(),this.isUserTouch=!1,this.isUserMove=!1,this.setting=null,this.pages=null,this.setting=new U().getSettings(i),this.block=f}destroy(){this.ui.destroy(),this.block.remove()}update(){this.render.update(),this.pages.show()}loadFromImages(f){this.ui=new Q(this.block,this,this.setting);const i=this.ui.getCanvas();this.render=new E(this,this.setting,i),this.flipController=new L(this.render,this),this.pages=new d(this,this.render,f),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}loadFromHTML(f){this.ui=new H(this.block,this,this.setting,f),this.render=new j(this,this.setting,this.ui.getDistElement()),this.flipController=new L(this.render,this),this.pages=new k(this,this.render,this.ui.getDistElement(),f),this.pages.load(),this.render.start(),this.pages.show(this.setting.startPage),setTimeout(()=>{this.ui.update(),this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromImages(f){const i=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new d(this,this.render,f),this.pages.load(),this.pages.show(i),this.trigger("update",this,{page:i,mode:this.render.getOrientation()})}updateFromHtml(f){const i=this.pages.getCurrentPageIndex();this.pages.destroy(),this.pages=new k(this,this.render,this.ui.getDistElement(),f),this.pages.load(),this.ui.updateItems(f),this.render.reload(),this.pages.show(i),this.trigger("update",this,{page:i,mode:this.render.getOrientation()})}clear(){this.pages.destroy(),this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(f){this.pages.show(f)}flipNext(f="top"){this.flipController.flipNext(f)}flipPrev(f="top"){this.flipController.flipPrev(f)}flip(f,i="top"){this.flipController.flipToPage(f,i)}updateState(f){this.trigger("changeState",this,f)}updatePageIndex(f){this.trigger("flip",this,f)}updateOrientation(f){this.ui.setOrientationStyle(f),this.update(),this.trigger("changeOrientation",this,f)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(f){return this.pages.getPage(f)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(f){this.mousePosition=f,this.isUserTouch=!0,this.isUserMove=!1}userMove(f,i){this.isUserTouch||i||!this.setting.showPageCorners?this.isUserTouch&&p.GetDistanceBetweenTwoPoint(this.mousePosition,f)>5&&(this.isUserMove=!0,this.flipController.fold(f)):this.flipController.showCorner(f)}userStop(f,i=!1){this.isUserTouch&&(this.isUserTouch=!1,i||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(f)))}},Object.defineProperty(s,"__esModule",{value:!0})})})(Nt,Nt.exports);var li=Nt.exports;/**
|
|
128
128
|
* @license FlipbookEngine v0.2.4
|
|
129
129
|
* Copyright (c) 2026 Murat Dogan
|
|
130
130
|
*
|
|
@@ -137,7 +137,7 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
137
137
|
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
138
138
|
* you must purchase a Commercial License from:
|
|
139
139
|
* https://flipbookengine.com/pricing
|
|
140
|
-
*/
|
|
140
|
+
*/function ci(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function di(e,t=ci()){return t?0:typeof e=="number"&&e>=0?e:1e3}class ui{constructor(t,s,o){w(this,"pageFlip",null);w(this,"bookContainer");w(this,"options");w(this,"store");w(this,"unsubs",[]);w(this,"audioEl",null);w(this,"audioUnlockHandler",null);w(this,"isLibraryFlipping",!1);w(this,"autoPlayTimer",null);this.bookContainer=t,this.options=s,this.store=o,s.soundUrl&&(this.audioEl=new Audio(s.soundUrl),this.unlockAudio())}unlockAudio(){if(!this.audioEl)return;const t=()=>{if(this.audioEl){const s=this.audioEl.play();s&&typeof s.then=="function"&&s.then(()=>{this.audioEl.pause(),this.audioEl.currentTime=0}).catch(()=>{})}document.removeEventListener("touchstart",t),document.removeEventListener("click",t),this.audioUnlockHandler=null};this.audioUnlockHandler=t,document.addEventListener("touchstart",t,{once:!0}),document.addEventListener("click",t,{once:!0})}init(t,s){this.pageFlip=new li.PageFlip(this.bookContainer,{width:t,height:s,size:"stretch",minWidth:100,maxWidth:3e3,minHeight:100,maxHeight:3e3,drawShadow:!0,showCover:!0,usePortrait:!0,mobileScrollSupport:!1,maxShadowOpacity:this.options.maxShadowOpacity||.5,flippingTime:di(this.options.flippingTime)});const o=this.bookContainer.querySelectorAll(".bz-page");this.pageFlip.loadFromHTML(Array.from(o)),this.bindEvents(),this.setupSignalSync()}bindEvents(){this.pageFlip.on("flip",t=>{this.store.currentPage.value!==t.data&&(this.isLibraryFlipping=!0,this.store.currentPage.value=t.data,this.playSound(),this.isLibraryFlipping=!1)}),this.pageFlip.on("changeState",t=>{this.store.flipState.value=t.data}),this.pageFlip.on("changeOrientation",t=>{this.store.orientation.value!==t.data&&(this.store.orientation.value=t.data)})}setupSignalSync(){this.unsubs.push(B(()=>{const t=this.store.currentPage.value,s=this.store.flipState.peek();if(!this.pageFlip||this.isLibraryFlipping||s!=="read")return;const o=this.pageFlip.getCurrentPageIndex();if(o!==t&&!this.store.isSingleMode.value){const r=p=>p===0?0:Math.ceil(p/2),l=r(t),d=r(o);l===d+1?this.pageFlip.flipNext():l===d-1?this.pageFlip.flipPrev():l!==d&&this.pageFlip.turnToPage(t)}})),this.unsubs.push(B(()=>{this.store.isSingleMode.value,this.pageFlip&&setTimeout(()=>{this.pageFlip&&this.pageFlip.update(),window.dispatchEvent(new Event("resize"))},50)})),this.unsubs.push(B(()=>{const t=this.store.isAutoPlaying.value,s=this.store.autoPlayInterval.value||3e3;this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),t&&(this.autoPlayTimer=setInterval(()=>{const o=this.store.pages.value.length-1;if(this.store.currentPage.peek()>=o||this.store.currentPage.peek()>=o-1&&!this.store.isSingleMode.peek()){this.store.isAutoPlaying.value=!1;return}this.turnToNextPage()},s))}))}turnToNextPage(){if(this.store.isSingleMode.value){const t=this.store.currentPage.value+1;t<this.store.pages.value.length&&(this.store.currentPage.value=t,this.playSound())}else this.pageFlip&&this.pageFlip.flipNext()}turnToPrevPage(){if(this.store.isSingleMode.value){const t=this.store.currentPage.value-1;t>=0&&(this.store.currentPage.value=t,this.playSound())}else this.pageFlip&&this.pageFlip.flipPrev()}playSound(){if(this.store.soundEnabled.value&&this.audioEl){this.audioEl.currentTime=0;const t=this.audioEl.play();t&&typeof t.catch=="function"&&t.catch(s=>console.warn("Flipbook Audio Play Error:",s))}}update(){this.pageFlip&&this.pageFlip.update()}destroy(){this.autoPlayTimer&&(clearInterval(this.autoPlayTimer),this.autoPlayTimer=null),this.audioUnlockHandler&&(document.removeEventListener("touchstart",this.audioUnlockHandler),document.removeEventListener("click",this.audioUnlockHandler),this.audioUnlockHandler=null),this.unsubs.forEach(t=>t()),this.unsubs=[],this.pageFlip&&(this.pageFlip.destroy(),this.pageFlip=null)}}/**
|
|
141
141
|
* @license FlipbookEngine v0.2.4
|
|
142
142
|
* Copyright (c) 2026 Murat Dogan
|
|
143
143
|
*
|
|
@@ -150,7 +150,7 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
150
150
|
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
151
151
|
* you must purchase a Commercial License from:
|
|
152
152
|
* https://flipbookengine.com/pricing
|
|
153
|
-
*/class
|
|
153
|
+
*/class gi{constructor(t,s){w(this,"wrapperElement",null);w(this,"sizerElement",null);w(this,"pageViewport");w(this,"store");w(this,"resizeObserver",null);w(this,"orientationMediaQuery",null);w(this,"orientationChangeHandler",null);w(this,"unsubs",[]);w(this,"onResizeCallback");this.pageViewport=t,this.store=s}init(t,s){this.wrapperElement=t,this.sizerElement=s,this.setupResizeObserver(),this.setupOrientationMedia(),this.setupStateSync(),this.updateBookAspectRatio()}setupStateSync(){this.unsubs.push(B(()=>{this.store.isSingleMode.value,this.store.orientation.value,setTimeout(()=>this.updateBookAspectRatio(),10)}))}setupResizeObserver(){typeof ResizeObserver<"u"&&this.wrapperElement&&(this.resizeObserver=new ResizeObserver(()=>{this.updateBookAspectRatio()}),this.resizeObserver.observe(this.wrapperElement))}setupOrientationMedia(){if(typeof window<"u"&&window.matchMedia){this.orientationMediaQuery=window.matchMedia("(orientation: portrait)");const t=s=>{s.matches,this.updateBookAspectRatio()};this.orientationChangeHandler=t,this.orientationMediaQuery.addEventListener?this.orientationMediaQuery.addEventListener("change",t):this.orientationMediaQuery.addListener(t),t(this.orientationMediaQuery)}}updateBookAspectRatio(){if(!this.wrapperElement||!this.sizerElement)return;const t=this.wrapperElement.clientWidth,s=this.wrapperElement.clientHeight;if(t===0||s===0)return;const o=this.pageViewport.width,r=this.pageViewport.height,d=this.store.isDoublePageLayout.value?o*2/r:o/r;let p=t,P=t/d;P>s&&(P=s,p=s*d);let k=Math.ceil(p);k%2!==0&&(k+=1),this.sizerElement.style.width=`${k}px`,this.sizerElement.style.height=`${Math.floor(P)}px`,this.sizerElement.style.aspectRatio="",this.onResizeCallback&&this.onResizeCallback()}destroy(){this.unsubs.forEach(t=>t()),this.unsubs=[],this.resizeObserver&&this.wrapperElement&&(this.resizeObserver.unobserve(this.wrapperElement),this.resizeObserver.disconnect(),this.resizeObserver=null),this.orientationMediaQuery&&(this.orientationChangeHandler&&(this.orientationMediaQuery.removeEventListener?this.orientationMediaQuery.removeEventListener("change",this.orientationChangeHandler):this.orientationMediaQuery.removeListener(this.orientationChangeHandler)),this.orientationChangeHandler=null,this.orientationMediaQuery=null)}}/**
|
|
154
154
|
* @license FlipbookEngine v0.2.4
|
|
155
155
|
* Copyright (c) 2026 Murat Dogan
|
|
156
156
|
*
|
|
@@ -163,12 +163,12 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
163
163
|
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
164
164
|
* you must purchase a Commercial License from:
|
|
165
165
|
* https://flipbookengine.com/pricing
|
|
166
|
-
*/class
|
|
166
|
+
*/class pi{constructor(t,s,o){w(this,"container");w(this,"pageFlipAdapter");w(this,"store");w(this,"touchStartX",null);w(this,"unsubs",[]);w(this,"listenerAbortController");var l;this.container=t,this.pageFlipAdapter=s,this.store=o;const r=((l=t.ownerDocument.defaultView)==null?void 0:l.AbortController)??globalThis.AbortController;this.listenerAbortController=new r}init(){this.bindWheel(),this.bindMouseDrag(),this.bindTouch(),this.setupStateSync()}setupStateSync(){this.unsubs.push(B(()=>{this.store.isZoomed.value=this.store.zoomState.value.isActive,this.store.zoomState.value.isActive?(this.container.style.transform=`translate(${this.store.zoomState.value.translateX}px, ${this.store.zoomState.value.translateY}px) scale(${this.store.zoomState.value.scale})`,this.container.style.transition="none"):(this.container.style.transform="",this.container.style.transition="transform 0.3s ease")}))}bindWheel(){this.container.addEventListener("wheel",t=>{this.store.zoomState.value.isActive&&(t.preventDefault(),this.updateZoomPan(this.store.zoomState.value.translateX-t.deltaX,this.store.zoomState.value.translateY-t.deltaY))},{passive:!1,signal:this.listenerAbortController.signal})}bindMouseDrag(){let t=!1,s=0,o=0,r=0,l=0;this.container.addEventListener("mousedown",d=>{this.store.zoomState.value.isActive&&(t=!0,s=d.clientX,o=d.clientY,r=this.store.zoomState.value.translateX,l=this.store.zoomState.value.translateY,this.container.style.cursor="grabbing")},{signal:this.listenerAbortController.signal}),window.addEventListener("mousemove",d=>{if(!t||!this.store.zoomState.value.isActive)return;const p=d.clientX-s,P=d.clientY-o;this.updateZoomPan(r+p,l+P)},{signal:this.listenerAbortController.signal}),window.addEventListener("mouseup",()=>{t&&(t=!1,this.container.style.cursor=this.store.zoomState.value.isActive?"grab":"")},{signal:this.listenerAbortController.signal})}bindTouch(){let t=!1,s=0,o=0;this.container.addEventListener("touchstart",r=>{if(r.touches.length===1)if(!this.store.zoomState.value.isActive)this.touchStartX=r.touches[0].clientX;else{t=!0,this.touchStartX=r.touches[0].clientX;const l=r.touches[0].clientY;s=this.store.zoomState.value.translateX,o=this.store.zoomState.value.translateY,this.container._touchStartY=l}},{passive:!0,signal:this.listenerAbortController.signal}),this.container.addEventListener("touchmove",r=>{if(t&&this.store.zoomState.value.isActive&&r.touches.length===1&&this.touchStartX!==null){r.preventDefault();const l=r.touches[0].clientX-this.touchStartX,d=r.touches[0].clientY-this.container._touchStartY;this.updateZoomPan(s+l,o+d)}},{passive:!1,signal:this.listenerAbortController.signal}),this.container.addEventListener("touchend",r=>{if(this.touchStartX!==null&&!this.store.zoomState.value.isActive&&this.store.isSingleMode.value&&r.changedTouches.length===1){const l=r.changedTouches[0].clientX-this.touchStartX;l>50&&this.store.currentPage.value>0?this.pageFlipAdapter.turnToPrevPage():l<-50&&this.store.currentPage.value<this.store.totalPages.value-1&&this.pageFlipAdapter.turnToNextPage()}this.touchStartX=null,t=!1},{passive:!0,signal:this.listenerAbortController.signal})}zoomIn(){let t=this.store.zoomState.value.scale+.5;t>5&&(t=5),this.store.zoomState.value={...this.store.zoomState.value,isActive:t>1,scale:t},t>1&&(this.container.style.cursor="grab")}zoomOut(){let t=this.store.zoomState.value.scale-.5;t<=1?(t=1,this.store.zoomState.value={...this.store.zoomState.value,isActive:!1,translateX:0,translateY:0,scale:1},this.container.style.cursor=""):this.store.zoomState.value={...this.store.zoomState.value,isActive:!0,scale:t}}updateZoomPan(t,s){this.store.zoomState.value={...this.store.zoomState.value,translateX:t,translateY:s}}destroy(){this.listenerAbortController.abort(),this.unsubs.forEach(t=>t()),this.unsubs=[]}}/**
|
|
167
167
|
* @license FlipbookEngine v0.2.4
|
|
168
168
|
* Copyright (c) 2026 Murat Dogan
|
|
169
169
|
*
|
|
170
170
|
* This source code is dual-licensed under the AGPLv3 and a Commercial License.
|
|
171
|
-
*/const
|
|
171
|
+
*/const fi=()=>({isActive:!1,translateX:0,translateY:0,isDragging:!1,scale:1});function fe(){const e=R(0),t=R(0),s=R(!1),o=R(!0),r=R(!0),l=R("landscape"),d=R("read"),p=R("auto"),P=R(!0),k=R(!1),b=R("#7367f0"),L=R(!1),G=R(!1),E=R(!1),M=R(3e3),H=R(!0),Q=R("en"),j=R({}),U=R(fi()),f=R([]),i=m(()=>!s.value&&l.value==="landscape"),n=m(()=>i.value&&e.value===0),a=m(()=>i.value&&e.value>=t.value-1);return{currentPage:e,totalPages:t,isSingleMode:s,showThumbs:o,showArrows:r,orientation:l,flipState:d,themeMode:p,allowDownload:P,hasDownloadUrl:k,primaryColor:b,whiteLabel:L,isZoomed:G,isAutoPlaying:E,autoPlayInterval:M,soundEnabled:H,locale:Q,messages:j,zoomState:U,pages:f,isDoublePageLayout:i,isFrontCover:n,isBackCover:a,init:(h,u,v,y)=>{t.value=u,f.value=v,k.value=y,h.theme!==void 0&&(p.value=h.theme),h.primaryColor!==void 0&&(b.value=h.primaryColor),h.showThumbs!==void 0&&(o.value=h.showThumbs),h.showArrows!==void 0&&(r.value=h.showArrows),h.allowDownload!==void 0&&(P.value=h.allowDownload),h.whiteLabel!==void 0&&(L.value=h.whiteLabel),h.soundEnabled!==void 0&&(H.value=h.soundEnabled),h.locale!==void 0&&(Q.value=h.locale),h.messages!==void 0&&(j.value=h.messages),h.isSingleMode!==void 0&&(s.value=h.isSingleMode),h.singleMode!==void 0&&(s.value=h.singleMode),h.autoPlay!==void 0&&(E.value=h.autoPlay),h.autoPlayInterval!==void 0&&(M.value=h.autoPlayInterval),e.value=0}}}const A=fe();A.currentPage,A.totalPages,A.isSingleMode,A.showThumbs,A.showArrows,A.orientation,A.flipState,A.themeMode,A.allowDownload,A.hasDownloadUrl,A.primaryColor,A.whiteLabel,A.isZoomed,A.isAutoPlaying,A.autoPlayInterval,A.soundEnabled,A.locale,A.messages,A.zoomState,A.pages,A.isDoublePageLayout,A.isFrontCover,A.isBackCover;function me(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.normal=="string"&&typeof t.low=="string"&&typeof t.thumb=="string"}function mi(e){return Array.isArray(e.pageNumbers)&&e.pageNumbers.length>0?e.pageNumbers:typeof e.pageNumber=="number"?e.kind==="spread"?[e.pageNumber,e.pageNumber+1]:[e.pageNumber]:[]}function wi(e){return e==="rtl"?["right","left"]:["left","right"]}function we(e){const t=[];let s=1;return e.forEach((o,r)=>{const l=o.kind??"single",d=o.id??`asset-${r}`,p=o.splitDirection??"ltr",P=mi(o);if(l==="spread"){const b=P.length>=2?P.slice(0,2):[s,s+1],L=wi(p);b.forEach((G,E)=>{t.push({index:t.length,assetId:d,pageNumber:G,cropMode:L[E]??"full",normal:o.normal,low:o.low,thumb:o.thumb})}),s=b[b.length-1]+1;return}const k=P[0]??s;t.push({index:t.length,assetId:d,pageNumber:k,cropMode:"full",normal:o.normal,low:o.low,thumb:o.thumb}),s=k+1}),t}function ve(e,t){e.classList.add("bk-container"),e.classList.remove("bk-theme-light","bk-theme-dark"),t.theme==="light"&&e.classList.add("bk-theme-light"),t.theme==="dark"&&e.classList.add("bk-theme-dark"),t.primaryColor&&e.style.setProperty("--flipbook-accent",t.primaryColor);const s=t.cssVariables??{};Object.entries(s).forEach(([o,r])=>{const l=o.startsWith("--")?o:`--${o}`;e.style.setProperty(l,r)})}class vi{constructor(t=32){w(this,"entries",new Map);w(this,"hits",0);w(this,"misses",0);if(this.maxEntries=t,!Number.isInteger(t)||t<0)throw new RangeError("PDF render cache size must be a non-negative integer.")}get(t){const s=this.entries.get(t);if(s===void 0){this.misses++;return}return this.hits++,this.entries.delete(t),this.entries.set(t,s),s}set(t,s){if(!(this.maxEntries===0||!s))for(this.entries.delete(t),this.entries.set(t,s);this.entries.size>this.maxEntries;){const o=this.entries.keys().next().value;if(o===void 0)break;this.entries.delete(o)}}clear(){this.entries.clear(),this.hits=0,this.misses=0}get size(){return this.entries.size}getStats(){return{size:this.size,maxEntries:this.maxEntries,hits:this.hits,misses:this.misses}}}class yi{constructor(t={}){w(this,"pdfDoc",null);w(this,"loadingTask",null);w(this,"options");w(this,"cache");const s=Number.isFinite(t.cacheSize)?Math.max(0,Math.floor(t.cacheSize)):32;this.options={scale:t.scale||1.5,quality:t.quality||.85,format:t.format||"image/webp",workerSrc:t.workerSrc||"",concurrency:Math.max(1,Math.floor(t.concurrency||3)),cacheSize:s},this.cache=new vi(this.options.cacheSize),this.options.workerSrc&&(et.GlobalWorkerOptions.workerSrc=this.options.workerSrc)}async loadDocument(t,s){this.throwIfAborted(s),this.cache.clear();const o=et.getDocument(t);this.loadingTask=o;const r=()=>{var l;return(l=o.destroy)==null?void 0:l.call(o)};s==null||s.addEventListener("abort",r,{once:!0});try{return this.pdfDoc=await o.promise,this.throwIfAborted(s),this.pdfDoc.numPages}catch(l){throw s!=null&&s.aborted?this.createAbortError():l}finally{s==null||s.removeEventListener("abort",r),this.loadingTask===o&&(this.loadingTask=null)}}async renderPageToDataUrl(t,s){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");this.throwIfAborted(s);const o=this.cache.get(t);if(o!==void 0)return o;try{const r=await this.pdfDoc.getPage(t);this.throwIfAborted(s);const l=r.getViewport({scale:this.options.scale}),d=document.createElement("canvas");d.width=l.width,d.height=l.height;const p=d.getContext("2d");if(p){const P=r.render({canvasContext:p,viewport:l}),k=()=>{var L;return(L=P.cancel)==null?void 0:L.call(P)};s==null||s.addEventListener("abort",k,{once:!0});try{await P.promise,this.throwIfAborted(s)}finally{s==null||s.removeEventListener("abort",k)}const b=d.toDataURL(this.options.format,this.options.quality);return this.cache.set(t,b),b}}catch(r){if(s!=null&&s.aborted)throw this.createAbortError();console.error(`PDF page ${t} render error:`,r)}return""}async calculateViewportDimensions(t=420){if(!this.pdfDoc)throw new Error("PDF document is not loaded.");const o=(await this.pdfDoc.getPage(1)).getViewport({scale:1}),r=o.width/o.height;return r>=1?{width:Math.round(t*r),height:t}:{width:t,height:Math.round(t/r)}}async renderAllPages(t,s){if(!this.pdfDoc)return[];this.throwIfAborted(t);const o=this.pdfDoc.numPages,r=new Array(o);let l=1,d=0;const p=async()=>{for(;;){this.throwIfAborted(t);const k=l++;if(k>o)return;const b=await this.renderPageToDataUrl(k,t);r[k-1]={index:k-1,assetId:`pdf-page-${k}`,pageNumber:k,cropMode:"full",normal:b,low:b,thumb:b},d++,s==null||s({completed:d,total:o})}},P=Math.min(this.options.concurrency,o);return await Promise.all(Array.from({length:P},()=>p())),this.throwIfAborted(t),r}getCacheStats(){return this.cache.getStats()}throwIfAborted(t){if(t!=null&&t.aborted)throw this.createAbortError()}createAbortError(){const t=new Error("PDF rendering was aborted.");return t.name="AbortError",t}destroy(){var t,s,o,r;(s=(t=this.loadingTask)==null?void 0:t.destroy)==null||s.call(t),this.loadingTask=null,this.pdfDoc&&((r=(o=this.pdfDoc).destroy)==null||r.call(o),this.pdfDoc=null),this.cache.clear()}}/**
|
|
172
172
|
* @license FlipbookEngine v0.2.4
|
|
173
173
|
* Copyright (c) 2026 Murat Dogan
|
|
174
174
|
*
|
|
@@ -181,5 +181,5 @@ var FlipbookEngine=function(S,C){"use strict";var wi=Object.defineProperty;var S
|
|
|
181
181
|
* closed-source, or SaaS products without the AGPLv3 obligations,
|
|
182
182
|
* you must purchase a Commercial License from:
|
|
183
183
|
* https://flipbookengine.com/pricing
|
|
184
|
-
*/const xt=class xt{constructor(t,s={}){v(this,"container",null);v(this,"options");v(this,"store",fe());v(this,"pageFlipAdapter",null);v(this,"layoutManager",null);v(this,"interactionManager",null);v(this,"pdfRenderer",null);v(this,"listeners",{});v(this,"initializationTimer",null);v(this,"initGeneration",0);v(this,"initAbortController",null);v(this,"eventsReady",!1);v(this,"lastEventState",{currentPage:0,zoom:1,zoomActive:!1,showThumbs:!0,isSingle:!1,orientation:""});v(this,"eventSyncStop",null);v(this,"qualityObserver",null);this.selector=t,this.options={allowDownload:!0,showThumbs:!0,primaryColor:"#7367f0",theme:"auto",soundUrl:"https://flipbookengine.com/Content/page-flip.mp3",autoPlayInterval:3e3,pdfRenderScale:1.5,pdfRenderQuality:.85,pdfRenderFormat:"image/webp",pdfRenderConcurrency:3,...s},this.setupEventSync()}async init(t,s){if(typeof this.selector=="string"?this.container=document.querySelector(this.selector):this.container=this.selector,!this.container)return;this.destroy(!0),this.eventsReady=!1;const o=this.initGeneration,r=new AbortController;this.initAbortController=r;let c=[],g={...xt.DEFAULT_PAGE_VIEWPORT};if(s&&s.length>0){if(r.signal.aborted)return;const E=s.filter(me);c=we(E);const M=c[0];if(M){const N=await this.loadImageSize(M.low||M.normal);if(N){const G=(M.cropMode!=="full"?N.width/2:N.width)/N.height,j=420;g=G>=1?{width:Math.round(j*G),height:j}:{width:j,height:Math.round(j/G)}}}}else if(t){if(r.signal.aborted)return;let E="load";try{this.pdfRenderer=new mi({scale:this.options.pdfRenderScale,quality:this.options.pdfRenderQuality,format:this.options.pdfRenderFormat,concurrency:this.options.pdfRenderConcurrency,workerSrc:this.options.pdfWorkerSrc}),this.emit("progress",{phase:"loading",completed:0,total:0});const M=await this.pdfRenderer.loadDocument(t,r.signal);E="render",this.emit("progress",{phase:"loading",completed:1,total:M}),c=await this.pdfRenderer.renderAllPages(r.signal,({completed:N,total:Q})=>{this.emit("progress",{phase:"rendering",completed:N,total:Q})}),g=await this.pdfRenderer.calculateViewportDimensions()}catch(M){r.signal.aborted||(console.error("PDF load failed:",M),this.emit("error",{code:E==="load"?"PDF_LOAD_FAILED":"PDF_RENDER_FAILED",message:M instanceof Error?M.message:"Unable to load PDF.",cause:M}));return}}if(r.signal.aborted||o!==this.initGeneration||!c.length)return;this.store.init(this.options,c.length,c,!!t),ve(this.container,this.options),this.container.innerHTML="";let f,k,P;const x={current:null},O={current:null},_=ai({pageFlipAdapterRef:x,interactionManagerRef:O,bookWrapperRef:E=>f=E,bookSizerRef:E=>k=E,bookContainerRef:E=>P=E,className:this.options.className,store:this.store,onToggleFullscreen:()=>this.toggleFullscreen(),onDownload:()=>{t&&(this.options.onDownload?this.options.onDownload(t):window.open(t,"_blank"))}});this.container.appendChild(_),this.setupQualityLoading(),this.layoutManager=new di(g,this.store),this.layoutManager.onResizeCallback=()=>{this.pageFlipAdapter&&this.pageFlipAdapter.update()},this.layoutManager.init(f,k),this.pageFlipAdapter=new ci(P,this.options,this.store),x.current=this.pageFlipAdapter,await new Promise(E=>{const M=()=>{r.signal.removeEventListener("abort",M),E()};r.signal.addEventListener("abort",M,{once:!0}),this.initializationTimer=setTimeout(()=>{if(this.initializationTimer=null,r.signal.removeEventListener("abort",M),r.signal.aborted||o!==this.initGeneration||!this.pageFlipAdapter){E();return}this.pageFlipAdapter.init(g.width,g.height),this.interactionManager=new ui(f,this.pageFlipAdapter,this.store),this.interactionManager.init(),O.current=this.interactionManager,this.eventsReady=!0,this.captureEventState(),this.emit("init",{totalPages:c.length}),E()},10)}),this.initAbortController===r&&(this.initAbortController=null)}loadImageSize(t){return new Promise(s=>{const o=new Image;o.onload=()=>s({width:o.naturalWidth||o.width,height:o.naturalHeight||o.height}),o.onerror=()=>s(null),o.src=t})}goToPage(t){const s=Math.max(0,this.store.totalPages.value-1);this.store.currentPage.value=Math.max(0,Math.min(s,Math.trunc(t)))}getTotalPages(){return this.store.totalPages.value}getCurrentPage(){return this.store.currentPage.value}getZoom(){return this.store.zoomState.value.scale}setZoom(t){const s=Number.isFinite(t)?t:1,o=Math.max(.5,Math.min(5,s));this.store.zoomState.value={...this.store.zoomState.value,scale:o,isActive:o>1,...o<=1?{translateX:0,translateY:0}:{}},this.store.isZoomed.value=o>1}nextPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToNextPage()}toggleFullscreen(){var s,o;const t=this.container;t&&(document.fullscreenElement?(o=document.exitFullscreen)==null||o.call(document).catch(r=>console.warn("Exit fullscreen err:",r)):(s=t.requestFullscreen)==null||s.call(t).catch(r=>console.warn("Fullscreen err:",r)))}setLocale(t,s){const o=s?{...this.options.messages,[t]:s[t]??s}:this.options.messages;this.options={...this.options,locale:t,messages:o},this.store.locale.value=t,o&&(this.store.messages.value=o)}prevPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToPrevPage()}setSingleMode(t){this.store.isSingleMode.value=t}updateOptions(t){this.options={...this.options,...t},t.theme!==void 0&&(this.store.themeMode.value=t.theme),t.primaryColor!==void 0&&(this.store.primaryColor.value=t.primaryColor),t.showThumbs!==void 0&&(this.store.showThumbs.value=t.showThumbs),t.showArrows!==void 0&&(this.store.showArrows.value=t.showArrows),t.allowDownload!==void 0&&(this.store.allowDownload.value=t.allowDownload),t.whiteLabel!==void 0&&(this.store.whiteLabel.value=t.whiteLabel),t.soundEnabled!==void 0&&(this.store.soundEnabled.value=t.soundEnabled),t.locale!==void 0&&(this.store.locale.value=t.locale),t.messages!==void 0&&(this.store.messages.value=t.messages),t.singleMode!==void 0&&(this.store.isSingleMode.value=t.singleMode),t.isSingleMode!==void 0&&(this.store.isSingleMode.value=t.isSingleMode),t.autoPlay!==void 0&&(this.store.isAutoPlaying.value=t.autoPlay),t.autoPlayInterval!==void 0&&(this.store.autoPlayInterval.value=t.autoPlayInterval),this.container&&ve(this.container,this.options)}async setPages(t,s){if(!(t!=null&&t.length)){s&&await this.init(s);return}await this.init(s||"",t)}setupQualityLoading(){var r;if(this.teardownQualityLoading(),!this.container)return;const t=Array.from(this.container.querySelectorAll("img[data-src]")),s=c=>{const g=c.dataset.src;g&&(c.src=g,delete c.dataset.src)},o=(r=this.container.ownerDocument.defaultView)==null?void 0:r.IntersectionObserver;if(!o){t.forEach(s);return}this.qualityObserver=new o(c=>{c.forEach(g=>{var f;g.isIntersecting&&(s(g.target),(f=this.qualityObserver)==null||f.unobserve(g.target))})},{root:this.container,rootMargin:"240px"}),t.forEach(c=>{var g;return(g=this.qualityObserver)==null?void 0:g.observe(c)})}teardownQualityLoading(){var t;(t=this.qualityObserver)==null||t.disconnect(),this.qualityObserver=null}setupEventSync(){this.eventSyncStop=X(()=>{const t={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value};if(!this.eventsReady){this.lastEventState=t;return}t.currentPage!==this.lastEventState.currentPage&&this.emit("pageChange",{currentPage:t.currentPage,pageNumber:t.currentPage+1,totalPages:this.store.totalPages.value,isSingle:t.isSingle}),(t.zoom!==this.lastEventState.zoom||t.zoomActive!==this.lastEventState.zoomActive)&&this.emit("zoomChange",{zoom:t.zoom,isActive:t.zoomActive}),t.showThumbs!==this.lastEventState.showThumbs&&this.emit("thumbsToggle",{showThumbs:t.showThumbs}),t.isSingle!==this.lastEventState.isSingle&&this.emit("singlePageModeChange",{isSingle:t.isSingle}),t.orientation!==this.lastEventState.orientation&&this.emit("orientationChange",{orientation:t.orientation}),this.lastEventState=t})}captureEventState(){this.lastEventState={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value}}destroy(t=!1){var s;this.initGeneration++,(s=this.initAbortController)==null||s.abort(),this.initAbortController=null,this.initializationTimer&&(clearTimeout(this.initializationTimer),this.initializationTimer=null),this.pageFlipAdapter&&this.pageFlipAdapter.destroy(),this.layoutManager&&this.layoutManager.destroy(),this.interactionManager&&this.interactionManager.destroy(),this.teardownQualityLoading(),this.pdfRenderer&&this.pdfRenderer.destroy(),this.pageFlipAdapter=null,this.layoutManager=null,this.interactionManager=null,this.pdfRenderer=null,!t&&this.container&&(this.container.innerHTML=""),this.emit("destroy",void 0)}on(t,s){const o=this.listeners[t]??new Set;return o.add(s),this.listeners[t]=o,()=>this.off(t,s)}off(t,s){var o;(o=this.listeners[t])==null||o.delete(s)}emit(t,s){var o;(o=this.listeners[t])==null||o.forEach(r=>{r(s)})}};v(xt,"DEFAULT_PAGE_VIEWPORT",{width:420,height:594});let bt=xt;const ye=globalThis,be=ye.FlipbookEngine||{};return be.FlipbookEngine=bt,ye.FlipbookEngine=be,S.FlipbookEngine=bt,S.isFlipbookPageAsset=me,S.normalizeFlipbookPages=we,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"}),S}({},pdfjsLib);
|
|
184
|
+
*/const Pt=class Pt{constructor(t,s={}){w(this,"container",null);w(this,"options");w(this,"store",fe());w(this,"pageFlipAdapter",null);w(this,"layoutManager",null);w(this,"interactionManager",null);w(this,"pdfRenderer",null);w(this,"listeners",{});w(this,"initializationTimer",null);w(this,"initGeneration",0);w(this,"initAbortController",null);w(this,"eventsReady",!1);w(this,"lastEventState",{currentPage:0,zoom:1,zoomActive:!1,showThumbs:!0,isSingle:!1,orientation:""});w(this,"eventSyncStop",null);w(this,"qualityObserver",null);w(this,"pdfLazyStop",null);w(this,"pdfPageRequests",new Map);w(this,"pdfRenderedPages",new Set);this.selector=t,this.options={allowDownload:!0,showThumbs:!0,primaryColor:"#7367f0",theme:"auto",soundUrl:"https://flipbookengine.com/Content/page-flip.mp3",autoPlayInterval:3e3,pdfRenderScale:1.5,pdfRenderQuality:.85,pdfRenderFormat:"image/webp",pdfRenderConcurrency:3,pdfRenderCacheSize:32,...s},this.setupEventSync()}async init(t,s){if(typeof this.selector=="string"?this.container=document.querySelector(this.selector):this.container=this.selector,!this.container)return;this.destroy(!0),this.eventsReady=!1;const o=this.initGeneration,r=new AbortController;this.initAbortController=r;let l=[],d={...Pt.DEFAULT_PAGE_VIEWPORT};if(s&&s.length>0){if(r.signal.aborted)return;const E=s.filter(me);l=we(E);const M=l[0];if(M){const H=await this.loadImageSize(M.low||M.normal);if(H){const j=(M.cropMode!=="full"?H.width/2:H.width)/H.height,U=420;d=j>=1?{width:Math.round(U*j),height:U}:{width:U,height:Math.round(U/j)}}}}else if(t){if(r.signal.aborted)return;let E="load";try{this.pdfRenderer=new yi({scale:this.options.pdfRenderScale,quality:this.options.pdfRenderQuality,format:this.options.pdfRenderFormat,concurrency:this.options.pdfRenderConcurrency,cacheSize:this.options.pdfRenderCacheSize,workerSrc:this.options.pdfWorkerSrc}),this.emit("progress",{phase:"loading",completed:0,total:0});const M=await this.pdfRenderer.loadDocument(t,r.signal);E="render",this.emit("progress",{phase:"loading",completed:1,total:M}),d=await this.pdfRenderer.calculateViewportDimensions(),l=Array.from({length:M},(H,Q)=>this.createPdfPlaceholder(Q+1))}catch(M){r.signal.aborted||(console.error("PDF load failed:",M),this.emit("error",{code:E==="load"?"PDF_LOAD_FAILED":"PDF_RENDER_FAILED",message:M instanceof Error?M.message:"Unable to load PDF.",cause:M}));return}}if(r.signal.aborted||o!==this.initGeneration||!l.length)return;this.store.init(this.options,l.length,l,!!t),ve(this.container,this.options),this.container.innerHTML="";let p,P,k;const b={current:null},L={current:null},G=ai({pageFlipAdapterRef:b,interactionManagerRef:L,bookWrapperRef:E=>p=E,bookSizerRef:E=>P=E,bookContainerRef:E=>k=E,className:this.options.className,store:this.store,onToggleFullscreen:()=>this.toggleFullscreen(),onDownload:()=>{t&&(this.options.onDownload?this.options.onDownload(t):window.open(t,"_blank"))}});this.container.appendChild(G),this.setupQualityLoading(),this.layoutManager=new gi(d,this.store),this.layoutManager.onResizeCallback=()=>{this.pageFlipAdapter&&this.pageFlipAdapter.update()},this.layoutManager.init(p,P),this.pageFlipAdapter=new ui(k,this.options,this.store),b.current=this.pageFlipAdapter,await new Promise(E=>{const M=()=>{r.signal.removeEventListener("abort",M),E()};r.signal.addEventListener("abort",M,{once:!0}),this.initializationTimer=setTimeout(async()=>{if(this.initializationTimer=null,r.signal.removeEventListener("abort",M),r.signal.aborted||o!==this.initGeneration||!this.pageFlipAdapter){E();return}if(this.pageFlipAdapter.init(d.width,d.height),this.interactionManager=new pi(p,this.pageFlipAdapter,this.store),this.interactionManager.init(),L.current=this.interactionManager,this.setupPdfLazyLoading(),this.pdfRenderer&&t)try{await this.renderPdfPage(1,r.signal)}catch{E();return}if(r.signal.aborted||o!==this.initGeneration){E();return}this.eventsReady=!0,this.captureEventState(),this.emit("init",{totalPages:l.length}),E()},10)}),this.initAbortController===r&&(this.initAbortController=null)}createPdfPlaceholder(t){const s="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";return{index:t-1,assetId:"pdf-page-"+t,pageNumber:t,cropMode:"full",normal:s,low:s,thumb:s}}renderPdfPage(t,s){const o=this.pdfRenderer;if(!o)return Promise.resolve("");const r=this.pdfPageRequests.get(t);if(r)return r;if(this.pdfRenderedPages.has(t))return Promise.resolve("");const l=o.renderPageToDataUrl(t,s).then(d=>{var p;if(!d)throw new Error("PDF page "+t+" produced no image.");return this.pdfRenderedPages.add(t),(p=this.container)==null||p.querySelectorAll('img[data-pdf-page="'+t+'"]').forEach(P=>{P.src=d,delete P.dataset.pdfPage}),this.emit("progress",{phase:"rendering",completed:this.pdfRenderedPages.size,total:this.store.totalPages.value}),d}).catch(d=>{throw(d==null?void 0:d.name)==="AbortError"||this.emit("error",{code:"PDF_RENDER_FAILED",message:d instanceof Error?d.message:"Unable to render PDF page.",cause:d}),d}).finally(()=>{this.pdfPageRequests.get(t)===l&&this.pdfPageRequests.delete(t)});return this.pdfPageRequests.set(t,l),l}setupPdfLazyLoading(){var t;(t=this.pdfLazyStop)==null||t.call(this),this.pdfLazyStop=null,this.pdfRenderer&&(this.pdfLazyStop=B(()=>{const s=this.store.currentPage.value+1,o=this.store.totalPages.value;[s,s+1].filter(r=>r<=o).forEach(r=>{this.renderPdfPage(r).catch(()=>{})})}))}loadImageSize(t){return new Promise(s=>{const o=new Image;o.onload=()=>s({width:o.naturalWidth||o.width,height:o.naturalHeight||o.height}),o.onerror=()=>s(null),o.src=t})}goToPage(t){const s=Math.max(0,this.store.totalPages.value-1);this.store.currentPage.value=Math.max(0,Math.min(s,Math.trunc(t)))}getTotalPages(){return this.store.totalPages.value}getCurrentPage(){return this.store.currentPage.value}getZoom(){return this.store.zoomState.value.scale}setZoom(t){const s=Number.isFinite(t)?t:1,o=Math.max(.5,Math.min(5,s));this.store.zoomState.value={...this.store.zoomState.value,scale:o,isActive:o>1,...o<=1?{translateX:0,translateY:0}:{}},this.store.isZoomed.value=o>1}nextPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToNextPage()}toggleFullscreen(){var s,o;const t=this.container;t&&(document.fullscreenElement?(o=document.exitFullscreen)==null||o.call(document).catch(r=>console.warn("Exit fullscreen err:",r)):(s=t.requestFullscreen)==null||s.call(t).catch(r=>console.warn("Fullscreen err:",r)))}setLocale(t,s){const o=s?{...this.options.messages,[t]:s[t]??s}:this.options.messages;this.options={...this.options,locale:t,messages:o},this.store.locale.value=t,o&&(this.store.messages.value=o)}prevPage(){this.pageFlipAdapter&&this.pageFlipAdapter.turnToPrevPage()}setSingleMode(t){this.store.isSingleMode.value=t}updateOptions(t){this.options={...this.options,...t},t.theme!==void 0&&(this.store.themeMode.value=t.theme),t.primaryColor!==void 0&&(this.store.primaryColor.value=t.primaryColor),t.showThumbs!==void 0&&(this.store.showThumbs.value=t.showThumbs),t.showArrows!==void 0&&(this.store.showArrows.value=t.showArrows),t.allowDownload!==void 0&&(this.store.allowDownload.value=t.allowDownload),t.whiteLabel!==void 0&&(this.store.whiteLabel.value=t.whiteLabel),t.soundEnabled!==void 0&&(this.store.soundEnabled.value=t.soundEnabled),t.locale!==void 0&&(this.store.locale.value=t.locale),t.messages!==void 0&&(this.store.messages.value=t.messages),t.singleMode!==void 0&&(this.store.isSingleMode.value=t.singleMode),t.isSingleMode!==void 0&&(this.store.isSingleMode.value=t.isSingleMode),t.autoPlay!==void 0&&(this.store.isAutoPlaying.value=t.autoPlay),t.autoPlayInterval!==void 0&&(this.store.autoPlayInterval.value=t.autoPlayInterval),this.container&&ve(this.container,this.options)}async setPages(t,s){if(!(t!=null&&t.length)){s&&await this.init(s);return}await this.init(s||"",t)}setupQualityLoading(){var r;if(this.teardownQualityLoading(),!this.container)return;const t=Array.from(this.container.querySelectorAll("img[data-src], img[data-pdf-page]")),s=l=>{const d=Number(l.dataset.pdfPage);if(Number.isInteger(d)&&d>0){this.renderPdfPage(d).catch(()=>{});return}const p=l.dataset.src;p&&(l.src=p,delete l.dataset.src)},o=(r=this.container.ownerDocument.defaultView)==null?void 0:r.IntersectionObserver;if(!o){const l=new Set;t.forEach(d=>{const p=Number(d.dataset.pdfPage);Number.isInteger(p)&&p>0?l.size<2&&(l.add(p),s(d)):s(d)});return}this.qualityObserver=new o(l=>{l.forEach(d=>{var p;d.isIntersecting&&(s(d.target),(p=this.qualityObserver)==null||p.unobserve(d.target))})},{root:this.container,rootMargin:"240px"}),t.forEach(l=>{var d;return(d=this.qualityObserver)==null?void 0:d.observe(l)})}teardownQualityLoading(){var t;(t=this.qualityObserver)==null||t.disconnect(),this.qualityObserver=null}setupEventSync(){this.eventSyncStop=B(()=>{const t={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value};if(!this.eventsReady){this.lastEventState=t;return}t.currentPage!==this.lastEventState.currentPage&&this.emit("pageChange",{currentPage:t.currentPage,pageNumber:t.currentPage+1,totalPages:this.store.totalPages.value,isSingle:t.isSingle}),(t.zoom!==this.lastEventState.zoom||t.zoomActive!==this.lastEventState.zoomActive)&&this.emit("zoomChange",{zoom:t.zoom,isActive:t.zoomActive}),t.showThumbs!==this.lastEventState.showThumbs&&this.emit("thumbsToggle",{showThumbs:t.showThumbs}),t.isSingle!==this.lastEventState.isSingle&&this.emit("singlePageModeChange",{isSingle:t.isSingle}),t.orientation!==this.lastEventState.orientation&&this.emit("orientationChange",{orientation:t.orientation}),this.lastEventState=t})}captureEventState(){this.lastEventState={currentPage:this.store.currentPage.value,zoom:this.store.zoomState.value.scale,zoomActive:this.store.zoomState.value.isActive,showThumbs:this.store.showThumbs.value,isSingle:this.store.isSingleMode.value,orientation:this.store.orientation.value}}destroy(t=!1){var s,o;this.initGeneration++,(s=this.initAbortController)==null||s.abort(),this.initAbortController=null,this.initializationTimer&&(clearTimeout(this.initializationTimer),this.initializationTimer=null),this.pageFlipAdapter&&this.pageFlipAdapter.destroy(),this.layoutManager&&this.layoutManager.destroy(),this.interactionManager&&this.interactionManager.destroy(),this.teardownQualityLoading(),(o=this.pdfLazyStop)==null||o.call(this),this.pdfLazyStop=null,this.pdfPageRequests.clear(),this.pdfRenderedPages.clear(),this.pdfRenderer&&this.pdfRenderer.destroy(),this.pageFlipAdapter=null,this.layoutManager=null,this.interactionManager=null,this.pdfRenderer=null,!t&&this.container&&(this.container.innerHTML=""),this.emit("destroy",void 0)}on(t,s){const o=this.listeners[t]??new Set;return o.add(s),this.listeners[t]=o,()=>this.off(t,s)}off(t,s){var o;(o=this.listeners[t])==null||o.delete(s)}emit(t,s){var o;(o=this.listeners[t])==null||o.forEach(r=>{r(s)})}};w(Pt,"DEFAULT_PAGE_VIEWPORT",{width:420,height:594});let bt=Pt;const ye=globalThis,be=ye.FlipbookEngine||{};return be.FlipbookEngine=bt,ye.FlipbookEngine=be,S.FlipbookEngine=bt,S.isFlipbookPageAsset=me,S.normalizeFlipbookPages=we,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"}),S}({},pdfjsLib);
|
|
185
185
|
//# sourceMappingURL=flipbook-engine.iife.js.map
|