@sbseguros/design-system
Version:
A Vue 3 design system with Tailwind CSS and Lucide icons.
78 lines • 3.08 MB
JavaScript
(function(v,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],h):(v=typeof globalThis<"u"?globalThis:v||self,h(v.SBSDesignSystem={},v.Vue))})(this,(function(v,h){"use strict";var kt=Object.defineProperty;var UB=v=>{throw TypeError(v)};var Lt=(v,h,uI)=>h in v?kt(v,h,{enumerable:!0,configurable:!0,writable:!0,value:uI}):v[h]=uI;var p=(v,h,uI)=>Lt(v,typeof h!="symbol"?h+"":h,uI),tm=(v,h,uI)=>h.has(v)||UB("Cannot "+uI);var l=(v,h,uI)=>(tm(v,h,"read from private field"),uI?uI.call(v):h.get(v)),e=(v,h,uI)=>h.has(v)?UB("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(v):h.set(v,uI),W=(v,h,uI,bi)=>(tm(v,h,"write to private field"),bi?bi.call(v,uI):h.set(v,uI),uI),t=(v,h,uI)=>(tm(v,h,"access private method"),uI);var fI=(v,h,uI,bi)=>({set _(rG){W(v,h,rG,uI)},get _(){return l(v,h,bi)}});/*! berea-ui v0.0.67 | (c) 2025 SBS Seguros Design System | MIT License | https://github.com/sbs-seguros-col/sbs-common-components */var YA,k0,Ym,rZ,Bl,Wl,mC,oC,QZ,hl,rd,Qd,jZ,e0,OB,sg,vB,EB,hZ,nG,xZ,ai,VA,NA,PB,fB,nm,t0,jd,UZ,Bg,xd,L0,kI,wl,OZ,DI,Y0,_B,Ud,jg,Od,SI,UI,vd,BC,Ed,WC,Wg,al,el,Pd,tl,EC,hC,ei,vZ,EZ,fd,PZ,PC,Yl,_d,nl,fC,V0,Vl,qd,fZ,Nl,ti,$d,Xl,_Z,QI,cI,XA,yl,Rl,qZ,Is,$Z,ul,_C,yA,Ic,gc,wC,F,T0,Vm,qB,$B,VG,IW,gW,CW,Nm,AW,Xm,ym,lW,Hg,cl,iW,dW,Rm,sW,NG,um,_I,qC,yC,Cs,$C,xg,As,IA,Kg,RA,Yi,gA,Hl,RC,XG,r0,Zg,aC,ni,VI,Cc,Vi,uC,Ni,Xi,yi,Ac,Hm,ls,Ri,lc,ic,dc,sc,Zc,uA,ui,HA,Hi,MA,Ml,ZW,cW,GW,Mi,HC,XI,eI,DA,is,Dl,cc,cg,Di,KA,CA,Kl,Gc,Ki,Ug,bc,Si,SA,AA,ds,ss,eC,pi,mc,N0,O,Mm,oc,Dm,Q0,bW,mW,Km,j0,Sm,oW,BW,WW,pm,hW,Fm,wW,aW,eW,zm,yG,Fi,zi,pA,Gg,X0,tW,Bc,Zs,bI,FA,y0,cs,tC,YW,nW,VW,x0,Wc,Ji,Gs,zA,JA,hg,ki,Li,z,tg,RG,wZ,U0,aZ,NW,Jm,eZ,uG,HG,km,MG,bs,Sl,Sg,pg,Ti,MC,ri,kA,GI,mI,LA,Fg,hc,ms,Qi,ji,TA,wg,lA,wc,Lm,tI,pI,DC,os,Bs,KC,Tm,rm,Qm,Ws,hs,ac,ws,O0,pl,iA,xi,Ui,DG,ts,Ys,ns,Vs,Og,dA,ec,oI,FI,jC,v0,KG,tc,Yc,Ns,nc,Vc,Nc,Xc,Xs,Fl,BI,ys,Rs,yc,jm,vg,Rc,xm,jB,zl,zg,uc,Hc,Oi,rA,Mc,Dc,vi,us,Hs,Jl,Ms,Kc,Ds,Ei,Sc,pc,Ks,Pi,Fc,kl,Ss,QA,XW,yW,Um,Eg,E0,Om,RW,uW,u0,fi,zc,Jc,kc,Lc,jA,_i,SG,Ll,SC,xA,qi,M0,$i,Id,Ng,P0,HW,MW,pG,ps,f0,UA,sA,Fs,zs,OA,gd,FG,Tl,rl,Cd,Pg,ld,Js,vI,Tc,ks,vA,rc,Ql,pC,Qc,WI,vm,Em,Pm,Sd,DW,Gi,ZA,jc,Ls,xc,dd,Ts,YC,Uc,fm,fg,pd,KW,SW,Oc,_m,_g,jl,D0,K0,rs,Qs,zI,cA,xl,sd,js,xs,GA,qg,EA,PA,qI,fA,Ul,vc,_A,Us,Zd,Ol,ag,vl,q,_0,qm,$m,Io,q0,go,pW,FW,zW,JW,$0,Ib,Co,Ec,Pc,fc,_c,qc,cd,$c,Ao,IG,gG,lo,Os,Gd,vs,El,CG,bd,Pl,io,so,$g,AG,md,IC,jI,kW,LW,TW,gb,qA,Cb,Ab,rW,Zo,QW,gC,FC,Es,Ps,bA,gI,od,Bd,lG,iG,fs,_s,fl,dG,S0,p0,EI,zG,jW,xW,UW,OW,vW,EW,qs,Wd,Il,sG,CC,ZG,LI,F0,PW,cG,GG,bG,_l,zC,Xg,fW,lb,_W,qW,co,mG,$s,IZ,oG,gl,hd,BG,kg,WG,hG,wd,AC,lC,bg,gZ,CZ,eg,AZ,nC,wG,$,Go,ib,$W,Ih,gh,bo,Fd,VC,tZ,Ch,db,sb,Ah,lh,ih,dh,sh,ad,iC,lZ,$I,ed,td,ql,$l,Ii,Yd,lI,mo,oo,Bo,JG,Zh,Zb,kG,YZ,mA,Ig,gg,nd,iZ,yg,mg,NC,Vd,Nd,Xd,dZ,cb,Rg,aG,eG,dC,oA,BA,sZ,ZZ,yd,og,Gl,ch,Gh,bh,z0,mh,Rd,ZI,Wo,JC,oh,Bh,ho,Gb,Wh,hh,wh,wo,ao,ah,gi,WA,Ci,ud,RI,Cg,Ai,Cl,li,GZ,Al,Hd,hA,ZC,bZ,iI,LG,TG,bb,mb,ob,eo,Bb,eh,Md,mZ,ii,di,ll,Lg,si,oZ,BZ,kC,il,Ag,dl,Zi,WZ,r,ci,YI,to,th,aA,Yo,no,Wb,TC,ug,Dd,tG,J0,Yh,wA,Vo,nh,No;var uI=typeof document<"u"?document.currentScript:null;const bi=h.defineComponent({__name:"Button",props:{label:{},primary:{type:Boolean,default:!1},size:{},backgroundColor:{}},emits:["click"],setup(m,{emit:I}){const g=m,C=I,A=h.computed(()=>({"storybook-button":!0,"storybook-button--primary":g.primary,"storybook-button--secondary":!g.primary,[`storybook-button--${g.size||"medium"}`]:!0})),i=h.computed(()=>({backgroundColor:g.backgroundColor})),d=()=>{C("click",1)};return(s,Z)=>(h.openBlock(),h.createElementBlock("button",{type:"button",class:h.normalizeClass(A.value),onClick:d,style:h.normalizeStyle(i.value)},h.toDisplayString(m.label),7))}});/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rG=m=>m.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Vh=m=>m.replace(/^([A-Z])|[\s-_]+(\w)/g,(I,g,C)=>C?C.toUpperCase():g.toLowerCase()),Nh=m=>{const I=Vh(m);return I.charAt(0).toUpperCase()+I.slice(1)},Xh=(...m)=>m.filter((I,g,C)=>!!I&&I.trim()!==""&&C.indexOf(I)===g).join(" ").trim();/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var QG={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yh=({size:m,strokeWidth:I=2,absoluteStrokeWidth:g,color:C,iconNode:A,name:i,class:d,...s},{slots:Z})=>h.h("svg",{...QG,width:m||QG.width,height:m||QG.height,stroke:C||QG.stroke,"stroke-width":g?Number(I)*24/Number(m):I,class:Xh("lucide",...i?[`lucide-${rG(Nh(i))}-icon`,`lucide-${rG(i)}`]:["lucide-icon"]),...s},[...A.map(c=>h.h(...c)),...Z.default?[Z.default()]:[]]);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hb=(m,I)=>(g,{slots:C})=>h.h(yh,{...g,iconNode:I,name:m},C);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rh=hb("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xo=hb("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-vue-next v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wb=hb("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),uh={class:"h-6 w-6 flex p-[5px] justify-center items-center shrink-0"},Hh={class:"text-sm font-medium leading-6 underline text-grey-grey-900 font-inter whitespace-nowrap"},Mh={class:"flex items-center flex-grow min-w-0 gap-1 px-4 py-2 rounded bg-fill"},Dh={class:"flex-shrink-0 text-sm font-medium leading-6 text-grey-grey-700 font-inter whitespace-nowrap"},ab=h.defineComponent({__name:"breadcrumb",props:{label:{type:String,required:!0},page:{type:String,default:"Home"},width:{type:String,default:"100%"},path:{type:String,default:""}},emits:["back"],setup(m,{emit:I}){const g=m,C=I,A=h.computed(()=>g.label),i=h.computed(()=>g.page),d=h.computed(()=>g.width),s=h.computed(()=>{let c;return g.path?c=g.path:typeof window<"u"?c=window.location.pathname:c="/",c.split("/").filter(G=>G).map(G=>G[0].toUpperCase()+G.slice(1))}),Z=()=>{C("back")};return(c,G)=>(h.openBlock(),h.createElementBlock("div",{class:h.normalizeClass(["flex items-center gap-10",d.value])},[h.createElementVNode("button",{onClick:Z,class:"flex items-center flex-shrink-0 gap-1"},[h.createElementVNode("span",uh,[h.createVNode(h.unref(Rh),{class:"w-6 h-6 shrink-0"})]),h.createElementVNode("span",Hh,h.toDisplayString(A.value),1)]),h.createElementVNode("div",Mh,[h.createElementVNode("span",Dh,h.toDisplayString(i.value),1),h.createVNode(h.unref(wb),{class:"flex-shrink-0 w-4 h-4 text-grey-grey-300"}),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(s.value,(b,B)=>(h.openBlock(),h.createElementBlock(h.Fragment,{key:b},[h.createElementVNode("span",{class:h.normalizeClass({"text-status-focus":B===s.value.length-1,"text-grey-grey-700":B!==s.value.length-1,"font-inter text-sm font-medium leading-6 whitespace-nowrap flex-grow":B===s.value.length-1,"font-inter text-sm font-medium leading-6 whitespace-nowrap flex-shrink-0":B!==s.value.length-1})},h.toDisplayString(b),3),B<s.value.length-1?(h.openBlock(),h.createBlock(h.unref(wb),{key:0,class:"flex-shrink-0 w-4 h-4 text-grey-grey-300"})):h.createCommentVNode("",!0)],64))),128))])],2))}}),Kh={class:"self-stretch text-xl font-normal leading-[30px] font-inter text-grey-grey-600 mr-2"},Sh={class:"self-stretch text-sm font-bold font-inter leading-[30px] ml-2"},ph=["href"],yo=h.defineComponent({__name:"banner",props:{label:{type:String,required:!0},width:{type:String,default:"100%"},page:{type:String,default:"Home"},path:{type:String,default:""},title:{type:String,default:""},description:{type:String,default:""},description_content:{type:String,default:""},category:{type:String,default:""},src:{type:String,default:""},stretch:{type:Boolean,default:!1},contract:{type:Boolean,default:!1},products:{type:Boolean,default:!1},description_clausula:{type:String,default:""},url_clausula:{type:String,default:""},relative:{type:Boolean,default:!1}},emits:["back"],setup(m,{emit:I}){const g=m,C=I,A=h.computed(()=>g.label),i=h.computed(()=>g.width),d=h.computed(()=>g.path),s=h.computed(()=>g.title),Z=h.computed(()=>g.description),c=h.computed(()=>g.description_content),G=h.computed(()=>g.category),b=h.computed(()=>g.src),B=h.computed(()=>g.page),a=h.computed(()=>g.stretch),Y=h.computed(()=>g.contract),n=h.computed(()=>g.products),X=h.computed(()=>g.description_clausula),N=h.computed(()=>g.url_clausula),u=h.computed(()=>g.relative),y=()=>{C("back")};return(o,w)=>(h.openBlock(),h.createElementBlock("div",{class:h.normalizeClass(["bg-grey-grey-100 w-full z-[99] shrink-0 aspect-[18/5] bg-cover bg-center bg-no-repeat",a.value?"h-[312px]":"h-[400px]",u.value?"relative":"absolute top-40 left-0"]),style:h.normalizeStyle(b.value?{backgroundImage:`url('${b.value}')`}:{})},[h.createVNode(ab,{label:A.value,width:i.value,path:d.value,page:B.value,class:"absolute top-10 left-[120px] z-[100]",onBack:y},null,8,["label","width","path","page"]),h.createElementVNode("div",{class:h.normalizeClass(["absolute flex flex-col items-start text-left",{"top-[166px] w-[789px] gap-4 h-[125px] left-[119.2px]":!a.value&&!Y.value&&!n.value,"top-[138px] w-[719px] gap-4 h-[125px] left-[119.2px]":Y.value,"top-[120px] w-[789px] gap-4 h-[125px] left-[119.2px]":a.value,"top-[162px] w-[677px] gap-6 left-[130px]":n.value}])},[h.createElementVNode("span",{class:h.normalizeClass(["font-inter text-[42px] leading-[52px] font-extrabold flex flex-col justify-center self-stretch tracking-[-0.31px]",{"bg-purple-purple-500 px-6 py-2 w-min text-grey-grey-50 h-[68px] rounded-lg":n.value,"text-grey-grey-700 h-[40.5px]":!n.value}])},h.toDisplayString(s.value),3),h.createElementVNode("span",Kh,[h.createTextVNode(h.toDisplayString(Z.value)+" ",1),h.createElementVNode("strong",null,h.toDisplayString(G.value),1),h.createTextVNode(" "+h.toDisplayString(c.value),1)]),h.createElementVNode("span",Sh,[h.createTextVNode(h.toDisplayString(X.value)+" ",1),h.createElementVNode("a",{href:N.value,target:"_blank",rel:"noopener noreferrer"},h.toDisplayString(N.value),9,ph)])],2)],6))}}),Fh={class:"flex flex-col w-full gap-8"},zh=["onClick","aria-expanded","aria-controls","aria-label"],Jh={class:"self-stretch w-full h-8"},kh={class:"flex items-center gap-2"},Lh=["src"],Th={key:0,class:"w-6 h-6"},rh=["id"],Qh={class:"flex flex-col self-stretch gap-4 px-10 py-4"},jh=["onClick","aria-label"],xh=h.defineComponent({__name:"collapsed",props:{items:{type:Array,required:!0,validator:m=>m.every(I=>typeof I.key=="string"&&typeof I.name=="string"&&(I.icon===void 0||typeof I.icon=="string"||typeof I.icon=="function")&&(I.icon_active===void 0||typeof I.icon_active=="string"||typeof I.icon_active=="function")&&(I.collapsed===void 0||typeof I.collapsed=="boolean")&&(I.children===void 0||Array.isArray(I.children)&&I.children.every(g=>typeof g.key=="string"&&typeof g.name=="string")))},activeForm:{type:String,required:!0},activeChild:{type:Object,default:null}},emits:["click","child-click"],setup(m,{emit:I}){const g=m,C=I,A=B=>Z.value===B.key&&B.icon_active?B.icon_active:B.icon,i=B=>{const a=A(B);return typeof a=="string"?a:void 0},d=B=>typeof B=="string",s=h.computed(()=>g.items),Z=h.computed(()=>g.activeForm),c=B=>{var Y;const a=((Y=g.activeChild)==null?void 0:Y.parentKey)===B.key;Z.value===B.key&&B.collapsed&&!a?C("click",""):C("click",B.key)},G=(B,a)=>{Z.value!==a.key&&C("click",a.key),C("child-click",{parentKey:a.key,childKey:B.key})},b=(B,a)=>{var Y,n;return((Y=g.activeChild)==null?void 0:Y.parentKey)===a.key&&((n=g.activeChild)==null?void 0:n.childKey)===B.key};return(B,a)=>(h.openBlock(),h.createElementBlock("div",Fh,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(s.value,Y=>(h.openBlock(),h.createElementBlock("div",{key:Y.key,class:"flex flex-col items-center justify-center w-full h-full"},[h.createElementVNode("button",{type:"button",onClick:n=>c(Y),"aria-expanded":m.activeForm===Y.key&&Y.collapsed,"aria-controls":`submenu-${Y.key}`,"aria-label":`Toggle ${Y.name} menu`,class:h.normalizeClass(["flex py-2 px-4 flex-col items-start gap-2.5 self-stretch rounded-lg shadow-[0_2px_5px_0_rgba(0,_0,_0,_0.08)]",Z.value===Y.key?"bg-status-focus":"bg-bandn-white"])},[h.createElementVNode("div",Jh,[h.createElementVNode("div",kh,[h.createElementVNode("div",{class:h.normalizeClass(["flex w-8 h-8 py-1 px-0.5 items-center justify-center",{"text-grey-grey-900":Z.value!==Y.key,"text-bandn-white":Z.value===Y.key}])},[d(A(Y))?(h.openBlock(),h.createElementBlock("img",{key:0,src:i(Y),alt:"",class:h.normalizeClass(["object-contain w-8 h-8",{"brightness-0 invert":Z.value===Y.key,"opacity-100":Z.value===Y.key,"opacity-70":Z.value!==Y.key}])},null,10,Lh)):(h.openBlock(),h.createBlock(h.resolveDynamicComponent(A(Y)),{key:1,class:h.normalizeClass(["w-8 h-8",{"text-grey-grey-900":Z.value!==Y.key,"text-bandn-white":Z.value===Y.key}])},null,8,["class"]))],2),h.createElementVNode("span",{class:h.normalizeClass(["flex-[1_0_0] font-inter text-lg font-semibold text-left",{"text-grey-grey-900":Z.value!==Y.key,"text-bandn-white":Z.value===Y.key}])},h.toDisplayString(Y.name),3),Y.collapsed?(h.openBlock(),h.createElementBlock("div",Th,[h.createVNode(h.unref(Xo),{class:h.normalizeClass(["transition-transform duration-200",{"text-bandn-white":Z.value===Y.key,"text-grey-grey-900":Z.value!==Y.key,"rotate-180":Z.value===Y.key&&Y.collapsed}])},null,8,["class"])])):h.createCommentVNode("",!0)])])],10,zh),h.createVNode(h.Transition,{name:"fade-slide",mode:"out-in"},{default:h.withCtx(()=>[Y.children&&Y.children.length?(h.openBlock(),h.createElementBlock("div",{key:0,id:`submenu-${Y.key}`,class:h.normalizeClass(["overflow-hidden transition-all duration-500 w-[276px]",m.activeForm===Y.key&&Y.collapsed?"max-h-[500px]":"max-h-0"])},[h.createElementVNode("div",Qh,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(Y.children,n=>(h.openBlock(),h.createElementBlock("button",{type:"button",key:n.key,onClick:X=>G(n,Y),"aria-label":n.name,class:h.normalizeClass(["flex w-[196px] py-1 text-left px-6 flex-col justify-center items-center border-b border-solid",{"text-status-focus border-status-focus":b(n,Y),"text-grey-grey-900 border-grey-grey-50":!b(n,Y)}])},[h.createElementVNode("span",{class:h.normalizeClass(["flex w-[158px] min-h-[22px] flex-col justify-center font-inter text-sm leading-[22px]",{"font-semibold":b(n,Y),"font-normal":!b(n,Y)}])},h.toDisplayString(n.name),3)],10,jh))),128))])],10,rh)):h.createCommentVNode("",!0)]),_:2},1024)]))),128))]))}}),XC=(m,I)=>{const g=m.__vccOpts||m;for(const[C,A]of I)g[C]=A;return g},Ro=XC(xh,[["__scopeId","data-v-62b8d769"]]);var nZ={exports:{}},Uh=nZ.exports,uo;function Oh(){return uo||(uo=1,(function(m,I){(function(g,C){C(I)})(Uh,(function(g){class C{constructor(o,w){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=w,this.nowDrawingDensity=this.createdDensity,this.render=o}setDensity(o){this.createdDensity=o,this.nowDrawingDensity=o}setDrawingDensity(o){this.nowDrawingDensity=o}setPosition(o){this.state.position=o}setAngle(o){this.state.angle=o}setArea(o){this.state.area=o}setHardDrawingAngle(o){this.state.hardDrawingAngle=o}setHardAngle(o){this.state.hardAngle=o,this.state.hardDrawingAngle=o}setOrientation(o){this.orientation=o}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class A extends C{constructor(o,w,V){super(o,V),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=w}draw(o){const w=this.render.getContext(),V=this.render.convertToGlobal(this.state.position),R=this.render.getRect().pageWidth,H=this.render.getRect().height;w.save(),w.translate(V.x,V.y),w.beginPath();for(let M of this.state.area)M!==null&&(M=this.render.convertToGlobal(M),w.lineTo(M.x-V.x,M.y-V.y));w.rotate(this.state.angle),w.clip(),this.isLoad?w.drawImage(this.image,0,0,R,H):this.drawLoader(w,{x:0,y:0},R,H),w.restore()}simpleDraw(o){const w=this.render.getRect(),V=this.render.getContext(),R=w.pageWidth,H=w.height,M=o===1?w.left+w.pageWidth:w.left,K=w.top;this.isLoad?V.drawImage(this.image,M,K,R,H):this.drawLoader(V,{x:M,y:K},R,H)}drawLoader(o,w,V,R){o.beginPath(),o.strokeStyle="rgb(200, 200, 200)",o.fillStyle="rgb(255, 255, 255)",o.lineWidth=1,o.rect(w.x+1,w.y+1,V-1,R-1),o.stroke(),o.fill();const H={x:w.x+V/2,y:w.y+R/2};o.beginPath(),o.lineWidth=10,o.arc(H.x,H.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),o.stroke(),o.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 i{constructor(o,w){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=w,this.app=o,this.currentPageIndex=0,this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[],this.portraitSpread=[];for(let w=0;w<this.pages.length;w++)this.portraitSpread.push([w]);let o=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([o]),o++);for(let w=o;w<this.pages.length;w+=2)w<this.pages.length-1?this.landscapeSpread.push([w,w+1]):(this.landscapeSpread.push([w]),this.pages[w].setDensity("hard"))}getSpread(){return this.render.getOrientation()==="landscape"?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(o){const w=this.getSpread();for(let V=0;V<w.length;V++)if(o===w[V][0]||o===w[V][1])return V;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(o){if(o>=0&&o<this.pages.length)return this.pages[o];throw new Error("Invalid page number")}nextBy(o){const w=this.pages.indexOf(o);return w<this.pages.length-1?this.pages[w+1]:null}prevBy(o){const w=this.pages.indexOf(o);return w>0?this.pages[w-1]:null}getFlippingPage(o){const w=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return o===0?this.pages[w].newTemporaryCopy():this.pages[w-1];{const V=o===0?this.getSpread()[w+1]:this.getSpread()[w-1];return V.length===1||o===0?this.pages[V[0]]:this.pages[V[1]]}}getBottomPage(o){const w=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return o===0?this.pages[w+1]:this.pages[w-1];{const V=o===0?this.getSpread()[w+1]:this.getSpread()[w-1];return V.length===1?this.pages[V[0]]:o===0?this.pages[V[1]]:this.pages[V[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(o=null){if(o===null&&(o=this.currentPageIndex),o<0||o>=this.pages.length)return;const w=this.getSpreadIndexByPage(o);w!==null&&(this.currentSpreadIndex=w,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(o){if(!(o>=0&&o<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=o}showSpread(){const o=this.getSpread()[this.currentSpreadIndex];o.length===2?(this.render.setLeftPage(this.pages[o[0]]),this.render.setRightPage(this.pages[o[1]])):this.render.getOrientation()==="landscape"&&o[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[o[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[o[0]])),this.currentPageIndex=o[0],this.app.updatePageIndex(this.currentPageIndex)}}class d extends i{constructor(o,w,V){super(o,w),this.imagesHref=V}load(){for(const o of this.imagesHref){const w=new A(this.render,o,"soft");w.load(),this.pages.push(w)}this.createSpread()}}class s{static GetDistanceBetweenTwoPoint(o,w){return o===null||w===null?1/0:Math.sqrt(Math.pow(w.x-o.x,2)+Math.pow(w.y-o.y,2))}static GetSegmentLength(o){return s.GetDistanceBetweenTwoPoint(o[0],o[1])}static GetAngleBetweenTwoLine(o,w){const V=o[0].y-o[1].y,R=w[0].y-w[1].y,H=o[1].x-o[0].x,M=w[1].x-w[0].x;return Math.acos((V*R+H*M)/(Math.sqrt(V*V+H*H)*Math.sqrt(R*R+M*M)))}static PointInRect(o,w){return w===null?null:w.x>=o.left&&w.x<=o.width+o.left&&w.y>=o.top&&w.y<=o.top+o.height?w:null}static GetRotatedPoint(o,w,V){return{x:o.x*Math.cos(V)+o.y*Math.sin(V)+w.x,y:o.y*Math.cos(V)-o.x*Math.sin(V)+w.y}}static LimitPointToCircle(o,w,V){if(s.GetDistanceBetweenTwoPoint(o,V)<=w)return V;const R=o.x,H=o.y,M=V.x,K=V.y;let D=Math.sqrt(Math.pow(w,2)*Math.pow(R-M,2)/(Math.pow(R-M,2)+Math.pow(H-K,2)))+R;V.x<0&&(D*=-1);let S=(D-R)*(H-K)/(R-M)+H;return R-M+H===0&&(S=w),{x:D,y:S}}static GetIntersectBetweenTwoSegment(o,w,V){return s.PointInRect(o,s.GetIntersectBeetwenTwoLine(w,V))}static GetIntersectBeetwenTwoLine(o,w){const V=o[0].y-o[1].y,R=w[0].y-w[1].y,H=o[1].x-o[0].x,M=w[1].x-w[0].x,K=o[0].x*o[1].y-o[1].x*o[0].y,D=w[0].x*w[1].y-w[1].x*w[0].y,S=V*D-R*K,k=H*D-M*K,Q=-(K*M-D*H)/(V*M-R*H),U=-(V*D-R*K)/(V*M-R*H);if(isFinite(Q)&&isFinite(U))return{x:Q,y:U};if(Math.abs(S-k)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(o,w){const V=Math.abs(o.x-w.x),R=Math.abs(o.y-w.y),H=Math.max(V,R),M=[o];function K(D,S,k,Q,U){return S>D?D+U*(k/Q):S<D?D-U*(k/Q):D}for(let D=1;D<=H;D+=1)M.push({x:K(o.x,w.x,V,H,D),y:K(o.y,w.y,R,H,D)});return M}}class Z extends C{constructor(o,w,V){super(o,V),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=w,this.element.classList.add("stf__item"),this.element.classList.add("--"+V)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new Z(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(o){const w=o||this.nowDrawingDensity,V=this.render.convertToGlobal(this.state.position),R=this.render.getRect().pageWidth,H=this.render.getRect().height;this.element.classList.remove("--simple");const M=`
display: block;
z-index: ${this.element.style.zIndex};
left: 0;
top: 0;
width: ${R}px;
height: ${H}px;
`;w==="hard"?this.drawHard(M):this.drawSoft(V,M)}drawHard(o=""){const w=this.render.getRect().left+this.render.getRect().width/2,V=this.state.hardDrawingAngle,R=o+`
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
clip-path: none;
-webkit-clip-path: none;
`+(this.orientation===0?`transform-origin: ${this.render.getRect().pageWidth}px 0;
transform: translate3d(0, 0, 0) rotateY(${V}deg);`:`transform-origin: 0 0;
transform: translate3d(${w}px, 0, 0) rotateY(${V}deg);`);this.element.style.cssText=R}drawSoft(o,w=""){let V="polygon( ";for(const H of this.state.area)if(H!==null){let M=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};M=s.GetRotatedPoint(M,{x:0,y:0},this.state.angle),V+=M.x+"px "+M.y+"px, "}V=V.slice(0,-2),V+=")";const R=w+`transform-origin: 0 0; clip-path: ${V}; -webkit-clip-path: ${V};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${o.x}px, ${o.y}px);`:`transform: translate3d(${o.x}px, ${o.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=R}simpleDraw(o){const w=this.render.getRect(),V=w.pageWidth,R=w.height,H=o===1?w.left+w.pageWidth:w.left,M=w.top;this.element.classList.add("--simple"),this.element.style.cssText=`
position: absolute;
display: block;
height: ${R}px;
left: ${H}px;
top: ${M}px;
width: ${V}px;
z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(o){super.setOrientation(o),this.element.classList.remove("--left","--right"),this.element.classList.add(o===1?"--right":"--left")}setDrawingDensity(o){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+o),super.setDrawingDensity(o)}}class c extends i{constructor(o,w,V,R){super(o,w),this.element=V,this.pagesElement=R}load(){for(const o of this.pagesElement){const w=new Z(this.render,o,o.dataset.density==="hard"?"hard":"soft");w.load(),this.pages.push(w)}this.createSpread()}}class G{constructor(o,w,V,R){this.direction=o,this.corner=w,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(V,10),this.pageHeight=parseInt(R,10)}calc(o){try{return this.position=this.calcAngleAndPosition(o),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const o=[];let w=!1;return o.push(this.rect.topLeft),o.push(this.topIntersectPoint),this.sideIntersectPoint===null?w=!0:(o.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(w=!1)),o.push(this.bottomIntersectPoint),(w||this.corner==="bottom")&&o.push(this.rect.bottomLeft),o}getBottomClipArea(){const o=[];return o.push(this.topIntersectPoint),this.corner==="top"?o.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&o.push({x:this.pageWidth,y:0}),o.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?s.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&o.push(this.sideIntersectPoint):this.corner==="top"&&o.push({x:this.pageWidth,y:this.pageHeight}),o.push(this.bottomIntersectPoint),o.push(this.topIntersectPoint),o}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 o=s.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?o:Math.PI-o}calcAngleAndPosition(o){let w=o;if(this.updateAngleAndGeometry(w),w=this.corner==="top"?this.checkPositionAtCenterLine(w,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(w,{x:0,y:this.pageHeight},{x:0,y:0}),Math.abs(w.x-this.pageWidth)<1&&Math.abs(w.y)<1)throw new Error("Point is too small");return w}updateAngleAndGeometry(o){this.angle=this.calculateAngle(o),this.rect=this.getPageRect(o)}calculateAngle(o){const w=this.pageWidth-o.x+1,V=this.corner==="bottom"?this.pageHeight-o.y:o.y;let R=2*Math.acos(w/Math.sqrt(V*V+w*w));V<0&&(R=-R);const H=Math.PI-R;if(!isFinite(R)||H>=0&&H<.003)throw new Error("The G point is too small");return this.corner==="bottom"&&(R=-R),R}getPageRect(o){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}],o):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],o)}getRectFromBasePoint(o,w){return{topLeft:this.getRotatedPoint(o[0],w),topRight:this.getRotatedPoint(o[1],w),bottomLeft:this.getRotatedPoint(o[2],w),bottomRight:this.getRotatedPoint(o[3],w)}}getRotatedPoint(o,w){return{x:o.x*Math.cos(this.angle)+o.y*Math.sin(this.angle)+w.x,y:o.y*Math.cos(this.angle)-o.x*Math.sin(this.angle)+w.y}}calculateIntersectPoint(o){const w={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[o,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[o,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])):(this.topIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[o,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]),this.bottomIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}]))}checkPositionAtCenterLine(o,w,V){let R=o;const H=s.LimitPointToCircle(w,this.pageWidth,R);R!==H&&(R=H,this.updateAngleAndGeometry(R));const M=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let K=this.rect.bottomRight,D=this.rect.topLeft;if(this.corner==="bottom"&&(K=this.rect.topRight,D=this.rect.bottomLeft),K.x<=0){const S=s.LimitPointToCircle(V,M,D);S!==R&&(R=S,this.updateAngleAndGeometry(R))}return R}getSegmentToShadowLine(){const o=this.getShadowStartPoint();return[o,o!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class b{constructor(o,w){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=o,this.app=w}fold(o){this.setState("user_fold"),this.calc===null&&this.start(o),this.do(this.render.convertToPage(o))}flip(o){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(o)||(this.calc!==null&&this.render.finishAnimation(),!this.start(o)))return;const w=this.getBoundsRect();this.setState("flipping");const V=w.height/10,R=this.calc.getCorner()==="bottom"?w.height-V:V,H=this.calc.getCorner()==="bottom"?w.height:0;this.calc.calc({x:w.pageWidth-V,y:R}),this.animateFlippingTo({x:w.pageWidth-V,y:R},{x:-w.pageWidth,y:H},!0)}start(o){this.reset();const w=this.render.convertToBook(o),V=this.getBoundsRect(),R=this.getDirectionByPoint(w),H=w.y>=V.height/2?"bottom":"top";if(!this.checkDirection(R))return!1;try{if(this.flippingPage=this.app.getPageCollection().getFlippingPage(R),this.bottomPage=this.app.getPageCollection().getBottomPage(R),this.render.getOrientation()==="landscape")if(R===1){const M=this.app.getPageCollection().nextBy(this.flippingPage);M!==null&&this.flippingPage.getDensity()!==M.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),M.setDrawingDensity("hard"))}else{const M=this.app.getPageCollection().prevBy(this.flippingPage);M!==null&&this.flippingPage.getDensity()!==M.getDensity()&&(this.flippingPage.setDrawingDensity("hard"),M.setDrawingDensity("hard"))}return this.render.setDirection(R),this.calc=new G(R,H,V.pageWidth.toString(10),V.height.toString(10)),!0}catch{return!1}}do(o){if(this.calc!==null&&this.calc.calc(o)){const w=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*w)/100):this.flippingPage.setHardAngle(-90*(200-2*w)/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(),w,this.calc.getDirection())}}flipToPage(o,w){const V=this.app.getPageCollection().getCurrentSpreadIndex(),R=this.app.getPageCollection().getSpreadIndexByPage(o);try{R>V&&(this.app.getPageCollection().setCurrentSpreadIndex(R-1),this.flipNext(w)),R<V&&(this.app.getPageCollection().setCurrentSpreadIndex(R+1),this.flipPrev(w))}catch{}}flipNext(o){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:o==="top"?1:this.render.getRect().height-2})}flipPrev(o){this.flip({x:10,y:o==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const o=this.calc.getPosition(),w=this.getBoundsRect(),V=this.calc.getCorner()==="bottom"?w.height:0;o.x<=0?this.animateFlippingTo(o,{x:-w.pageWidth,y:V},!0):this.animateFlippingTo(o,{x:w.pageWidth,y:V},!1)}showCorner(o){if(!this.checkState("read","fold_corner"))return;const w=this.getBoundsRect(),V=w.pageWidth;if(this.isPointOnCorners(o))if(this.calc===null){if(!this.start(o))return;this.setState("fold_corner"),this.calc.calc({x:V-1,y:1});const R=50,H=this.calc.getCorner()==="bottom"?w.height-1:1,M=this.calc.getCorner()==="bottom"?w.height-R:R;this.animateFlippingTo({x:V-1,y:H},{x:V-R,y:M},!1,!1)}else this.do(this.render.convertToPage(o));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(o,w,V,R=!0){const H=s.GetCordsFromTwoPoint(o,w),M=[];for(const D of H)M.push(()=>this.do(D));const K=this.getAnimationDuration(H.length);this.render.startAnimation(M,K,()=>{this.calc&&(V&&(this.calc.getDirection()===1?this.app.turnToPrevPage():this.app.turnToNextPage()),R&&(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(o){this.state!==o&&(this.app.updateState(o),this.state=o)}getDirectionByPoint(o){const w=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(o.x-w.pageWidth<=w.width/5)return 1}else if(o.x<w.width/2)return 1;return 0}getAnimationDuration(o){const w=this.app.getSettings().flippingTime;return o>=1e3?w:o/1e3*w}checkDirection(o){return o===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(...o){for(const w of o)if(this.state===w)return!0;return!1}isPointOnCorners(o){const w=this.getBoundsRect(),V=w.pageWidth,R=Math.sqrt(Math.pow(V,2)+Math.pow(w.height,2))/5,H=this.render.convertToBook(o);return H.x>0&&H.y>0&&H.x<w.width&&H.y<w.height&&(H.x<R||H.x>w.width-R)&&(H.y<R||H.y>w.height-R)}}class B{constructor(o,w){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=w,this.app=o;const V=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=V.exec(window.navigator.userAgent)!==null}render(o){if(this.animation!==null){const w=Math.round((o-this.animation.startedAt)/this.animation.durationFrame);w<this.animation.frames.length?this.animation.frames[w]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=o,this.drawFrame()}start(){this.update();const o=w=>{this.render(w),requestAnimationFrame(o)};requestAnimationFrame(o)}startAnimation(o,w,V){this.finishAnimation(),this.animation={frames:o,duration:w,durationFrame:w/o.length,onAnimateEnd:V,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 o=this.calculateBoundsRect();this.orientation!==o&&(this.orientation=o,this.app.updateOrientation(o))}calculateBoundsRect(){let o="landscape";const w=this.getBlockWidth(),V=w/2,R=this.getBlockHeight()/2,H=this.setting.width/this.setting.height;let M=this.setting.width,K=this.setting.height,D=V-M;return this.setting.size==="stretch"?(w<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(o="portrait"),M=o==="portrait"?this.getBlockWidth():this.getBlockWidth()/2,M>this.setting.maxWidth&&(M=this.setting.maxWidth),K=M/H,K>this.getBlockHeight()&&(K=this.getBlockHeight(),M=K*H),D=o==="portrait"?V-M/2-M:V-M):w<2*M&&this.app.getSettings().usePortrait&&(o="portrait",D=V-M/2-M),this.boundsRect={left:D,top:R-K/2,width:2*M,height:K,pageWidth:M},o}setShadowData(o,w,V,R){if(!this.app.getSettings().drawShadow)return;const H=100*this.getSettings().maxShadowOpacity;this.shadow={pos:o,angle:w,width:3*this.getRect().pageWidth/4*V/100,opacity:(100-V)*H/100/100,direction:R,progress:2*V}}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(o){this.pageRect=o}setDirection(o){this.direction=o}setRightPage(o){o!==null&&o.setOrientation(1),this.rightPage=o}setLeftPage(o){o!==null&&o.setOrientation(0),this.leftPage=o}setBottomPage(o){o!==null&&o.setOrientation(this.direction===1?0:1),this.bottomPage=o}setFlippingPage(o){o!==null&&o.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=o}convertToBook(o){const w=this.getRect();return{x:o.x-w.left,y:o.y-w.top}}isSafari(){return this.safari}convertToPage(o,w){w||(w=this.direction);const V=this.getRect();return{x:w===0?o.x-V.left-V.width/2:V.width/2-o.x+V.left,y:o.y-V.top}}convertToGlobal(o,w){if(w||(w=this.direction),o==null)return null;const V=this.getRect();return{x:w===0?o.x+V.left+V.width/2:V.width/2-o.x+V.left,y:o.y+V.top}}convertRectToGlobal(o,w){return w||(w=this.direction),{topLeft:this.convertToGlobal(o.topLeft,w),topRight:this.convertToGlobal(o.topRight,w),bottomLeft:this.convertToGlobal(o.bottomLeft,w),bottomRight:this.convertToGlobal(o.bottomRight,w)}}}class a extends B{constructor(o,w,V){super(o,w),this.canvas=V,this.ctx=V.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 o=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(o.left+o.pageWidth,o.top,o.width,o.height),this.ctx.clip())}drawBookShadow(){const o=this.getRect();this.ctx.save(),this.ctx.beginPath();const w=o.width/20;this.ctx.rect(o.left,o.top,o.width,o.height);const V={x:o.left+o.width/2-w/2,y:0};this.ctx.translate(V.x,V.y);const R=this.ctx.createLinearGradient(0,0,w,0);R.addColorStop(0,"rgba(0, 0, 0, 0)"),R.addColorStop(.4,"rgba(0, 0, 0, 0.2)"),R.addColorStop(.49,"rgba(0, 0, 0, 0.1)"),R.addColorStop(.5,"rgba(0, 0, 0, 0.5)"),R.addColorStop(.51,"rgba(0, 0, 0, 0.4)"),R.addColorStop(1,"rgba(0, 0, 0, 0)"),this.ctx.clip(),this.ctx.fillStyle=R,this.ctx.fillRect(0,0,w,2*o.height),this.ctx.restore()}drawOuterShadow(){const o=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(o.left,o.top,o.width,o.height);const w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y});this.ctx.translate(w.x,w.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const V=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),V.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),V.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),V.addColorStop(0,"rgba(0, 0, 0, 0)"),V.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=V,this.ctx.fillRect(0,0,this.shadow.width,2*o.height),this.ctx.restore()}drawInnerShadow(){const o=this.getRect();this.ctx.save(),this.ctx.beginPath();const w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),V=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(V.topLeft.x,V.topLeft.y),this.ctx.lineTo(V.topRight.x,V.topRight.y),this.ctx.lineTo(V.bottomRight.x,V.bottomRight.y),this.ctx.lineTo(V.bottomLeft.x,V.bottomLeft.y),this.ctx.translate(w.x,w.y),this.ctx.rotate(Math.PI+this.shadow.angle+Math.PI/2);const R=3*this.shadow.width/4,H=this.ctx.createLinearGradient(0,0,R,0);this.shadow.direction===0?(this.ctx.translate(-R,-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,R,2*o.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class Y{constructor(o,w,V){this.touchPoint=null,this.swipeTimeout=250,this.onResize=()=>{this.update()},this.onMouseDown=H=>{if(this.checkTarget(H.target)){const M=this.getMousePos(H.clientX,H.clientY);this.app.startUserTouch(M),H.preventDefault()}},this.onTouchStart=H=>{if(this.checkTarget(H.target)&&H.changedTouches.length>0){const M=H.changedTouches[0],K=this.getMousePos(M.clientX,M.clientY);this.touchPoint={point:K,time:Date.now()},setTimeout(()=>{this.touchPoint!==null&&this.app.startUserTouch(K)},this.swipeTimeout),this.app.getSettings().mobileScrollSupport||H.preventDefault()}},this.onMouseUp=H=>{const M=this.getMousePos(H.clientX,H.clientY);this.app.userStop(M)},this.onMouseMove=H=>{const M=this.getMousePos(H.clientX,H.clientY);this.app.userMove(M,!1)},this.onTouchMove=H=>{if(H.changedTouches.length>0){const M=H.changedTouches[0],K=this.getMousePos(M.clientX,M.clientY);this.app.getSettings().mobileScrollSupport?(this.touchPoint!==null&&(Math.abs(this.touchPoint.point.x-K.x)>10||this.app.getState()!=="read")&&H.cancelable&&this.app.userMove(K,!0),this.app.getState()!=="read"&&H.preventDefault()):this.app.userMove(K,!0)}},this.onTouchEnd=H=>{if(H.changedTouches.length>0){const M=H.changedTouches[0],K=this.getMousePos(M.clientX,M.clientY);let D=!1;if(this.touchPoint!==null){const S=K.x-this.touchPoint.point.x,k=Math.abs(K.y-this.touchPoint.point.y);Math.abs(S)>this.swipeDistance&&k<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(S>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"),D=!0),this.touchPoint=null}this.app.userStop(K,D)}},this.parentElement=o,o.classList.add("stf__parent"),o.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=o.querySelector(".stf__wrapper"),this.app=w;const R=this.app.getSettings().usePortrait?1:2;o.style.minWidth=V.minWidth*R+"px",o.style.minHeight=V.minHeight+"px",V.size==="fixed"&&(o.style.minWidth=V.width*R+"px",o.style.minHeight=V.height+"px"),V.autoSize&&(o.style.width="100%",o.style.maxWidth=2*V.maxWidth+"px"),o.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=V.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(o){this.wrapper.classList.remove("--portrait","--landscape"),o==="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(o,w){const V=this.distElement.getBoundingClientRect();return{x:o-V.left,y:w-V.top}}checkTarget(o){return!this.app.getSettings().clickEventForward||!["a","button"].includes(o.tagName.toLowerCase())}}class n extends Y{constructor(o,w,V,R){super(o,w,V),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=o.querySelector(".stf__block"),this.items=R;for(const H of R)this.distElement.appendChild(H);this.setHandlers()}clear(){for(const o of this.items)this.parentElement.appendChild(o)}updateItems(o){this.removeHandlers(),this.distElement.innerHTML="";for(const w of o)this.distElement.appendChild(w);this.items=o,this.setHandlers()}update(){this.app.getRender().update()}}class X extends Y{constructor(o,w,V){super(o,w,V),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=o.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const o=getComputedStyle(this.canvas),w=parseInt(o.getPropertyValue("width"),10),V=parseInt(o.getPropertyValue("height"),10);this.canvas.width=w,this.canvas.height=V}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class N extends B{constructor(o,w,V){super(o,w),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=V,this.createShadows()}createShadows(){this.element.insertAdjacentHTML("beforeend",`<div class="stf__outerShadow"></div>
<div class="stf__innerShadow"></div>
<div class="stf__hardShadow"></div>
<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 o=this.getRect(),w=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let V=(100-w)*(2.5*o.pageWidth)/100+20;V>o.pageWidth&&(V=o.pageWidth);let R=`
display: block;
z-index: ${(this.getSettings().startZIndex+5).toString(10)};
width: ${V}px;
height: ${o.height}px;
background: linear-gradient(to right,
rgba(0, 0, 0, ${this.shadow.opacity*w/100}) 5%,
rgba(0, 0, 0, 0) 100%);
left: ${o.left+o.width/2}px;
transform-origin: 0 0;
`;R+=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=R}drawHardOuterShadow(){const o=this.getRect();let w=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*o.pageWidth)/100+20;w>o.pageWidth&&(w=o.pageWidth);let V=`
display: block;
z-index: ${(this.getSettings().startZIndex+4).toString(10)};
width: ${w}px;
height: ${o.height}px;
background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);
left: ${o.left+o.width/2}px;
transform-origin: 0 0;
`;V+=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=V}drawInnerShadow(){const o=this.getRect(),w=3*this.shadow.width/4,V=this.getDirection()===0?w:0,R=this.getDirection()===0?"to left":"to right",H=this.convertToGlobal(this.shadow.pos),M=this.shadow.angle+3*Math.PI/2,K=[this.pageRect.topLeft,this.pageRect.topRight,