UNPKG

@sbseguros/design-system

Version:

A Vue 3 design system with Tailwind CSS and Lucide icons.

102 lines 2.96 MB
"use strict";var mo=Object.defineProperty;var h0=b=>{throw TypeError(b)};var Bo=(b,I,g)=>I in b?mo(b,I,{enumerable:!0,configurable:!0,writable:!0,value:g}):b[I]=g;var S=(b,I,g)=>Bo(b,typeof I!="symbol"?I+"":I,g),NG=(b,I,g)=>I.has(b)||h0("Cannot "+g);var l=(b,I,g)=>(NG(b,I,"read from private field"),g?g.call(b):I.get(b)),Y=(b,I,g)=>I.has(b)?h0("Cannot add the same private member more than once"):I instanceof WeakSet?I.add(b):I.set(b,g),W=(b,I,g,C)=>(NG(b,I,"write to private field"),C?C.call(b,g):I.set(b,g),g),a=(b,I,g)=>(NG(b,I,"access private method"),g);var Cg=(b,I,g,C)=>({set _(A){W(b,I,A,g)},get _(){return l(b,I,C)}});/*! berea-ui v0.0.39 | (c) 2025 SBS Seguros Design System | MIT License | https://github.com/sbs-seguros-col/sbs-common-components */Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");var tG=typeof document<"u"?document.currentScript:null;const x0=t.defineComponent({__name:"Button",props:{label:{},primary:{type:Boolean,default:!1},size:{},backgroundColor:{}},emits:["click"],setup(b,{emit:I}){const g=b,C=I,A=t.computed(()=>({"storybook-button":!0,"storybook-button--primary":g.primary,"storybook-button--secondary":!g.primary,[`storybook-button--${g.size||"medium"}`]:!0})),i=t.computed(()=>({backgroundColor:g.backgroundColor})),Z=()=>{C("click",1)};return(s,d)=>(t.openBlock(),t.createElementBlock("button",{type:"button",class:t.normalizeClass(A.value),onClick:Z,style:t.normalizeStyle(i.value)},t.toDisplayString(s.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 Y0=b=>b.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),oo=b=>b.replace(/^([A-Z])|[\s-_]+(\w)/g,(I,g,C)=>C?C.toUpperCase():g.toLowerCase()),Wo=b=>{const I=oo(b);return I.charAt(0).toUpperCase()+I.slice(1)},wo=(...b)=>b.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 Ic={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 ho=({size:b,strokeWidth:I=2,absoluteStrokeWidth:g,color:C,iconNode:A,name:i,class:Z,...s},{slots:d})=>t.h("svg",{...Ic,width:b||Ic.width,height:b||Ic.height,stroke:C||Ic.stroke,"stroke-width":g?Number(I)*24/Number(b):I,class:wo("lucide",...i?[`lucide-${Y0(Wo(i))}-icon`,`lucide-${Y0(i)}`]:["lucide-icon"]),...s},[...A.map(c=>t.h(...c)),...d.default?[d.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 qb=(b,I)=>(g,{slots:C})=>t.h(ho,{...g,iconNode:I,name:b},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 Yo=qb("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 r0=qb("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 DG=qb("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),ao={class:"h-6 w-6 flex p-[5px] justify-center items-center shrink-0"},Vo={class:"text-sm font-medium leading-6 underline text-grey-grey-900 font-inter"},No={class:"inline-flex items-center gap-1 px-4 py-2 rounded bg-fill min-w-[161px]"},to={class:"text-sm font-medium leading-6 text-grey-grey-700 font-inter"},$b=t.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(b,{emit:I}){const g=b,C=I,A=t.computed(()=>g.label),i=t.computed(()=>g.page),Z=t.computed(()=>g.width),s=t.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))}),d=()=>{console.log("Back button clicked"),C("back")};return(c,G)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(`flex gap-10 w-[${Z.value}]`)},[t.createElementVNode("button",{onClick:d,class:"flex items-center gap-1"},[t.createElementVNode("span",ao,[t.createVNode(t.unref(Yo),{class:"w-6 h-6 shrink-0"})]),t.createElementVNode("span",Vo,t.toDisplayString(A.value),1)]),t.createElementVNode("div",No,[t.createElementVNode("span",to,t.toDisplayString(i.value),1),t.createVNode(t.unref(DG),{class:"w-4 h-4 text-grey-grey-300"}),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value,(B,o)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:B},[t.createElementVNode("span",{class:t.normalizeClass({"text-status-focus":o===s.value.length-1,"text-grey-grey-700":o!==s.value.length-1,"font-inter text-sm font-medium leading-6 flex-[1_0_0]":!0})},t.toDisplayString(B),3),o<s.value.length-1?(t.openBlock(),t.createBlock(t.unref(DG),{key:0,class:"w-4 h-4 text-grey-grey-300"})):t.createCommentVNode("",!0)],64))),128))])],2))}}),no=["src"],eo={class:"font-inter text-[42px] leading-[52px] font-extrabold text-grey-grey-700 flex h-[40.5px] flex-col justify-center self-stretch tracking-[-0.31px]"},yo={class:"self-stretch text-xl font-normal leading-[30px] font-inter text-grey-grey-600 mr-2"},U0=t.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:""},src:{type:String,default:""},stretch:{type:Boolean,default:!1},contract:{type:Boolean,default:!1}},emits:["back"],setup(b,{emit:I}){const g=b;console.log("Banner props:",g);const C=I,A=t.computed(()=>g.label),i=t.computed(()=>g.width),Z=t.computed(()=>g.path),s=t.computed(()=>g.title),d=t.computed(()=>g.description),c=t.computed(()=>g.src),G=t.computed(()=>g.page),B=t.computed(()=>g.stretch),o=t.computed(()=>g.contract),h=()=>{C("back")};return(V,N)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["bg-grey-grey-100 w-full left-0 z-[99] absolute top-40 shrink-0 aspect-[18/5]",B.value?"h-[312px]":"h-[399px]"])},[c.value?(t.openBlock(),t.createElementBlock("img",{key:0,src:c.value,alt:"Profile Header",class:"object-contain w-full h-full"},null,8,no)):t.createCommentVNode("",!0),t.createVNode($b,{label:A.value,width:i.value,path:Z.value,page:G.value,class:"absolute top-10 left-[120px] z-[100]",onBack:h},null,8,["label","width","path","page"]),t.createElementVNode("div",{class:t.normalizeClass(["absolute left-[119.2px] flex flex-col h-[125px] items-start text-left gap-4",{"top-[166px] w-[789px]":!B.value&&!o.value,"top-[138px] w-[719px]":o.value,"top-[120px] w-[789px]":B.value}])},[t.createElementVNode("span",eo,t.toDisplayString(s.value),1),t.createElementVNode("span",yo,t.toDisplayString(d.value),1)],2)],2))}}),Ro={class:"flex flex-col w-full gap-8"},Xo=["onClick","aria-expanded","aria-controls","aria-label"],Ho={class:"self-stretch w-full h-8"},uo={class:"flex items-center gap-2"},Mo=["src"],Do={key:0,class:"w-6 h-6"},Ko=["id"],So={class:"flex flex-col self-stretch gap-4 px-10 py-4"},po=["onClick","aria-label"],Fo=t.defineComponent({__name:"collapsed",props:{items:{type:Array,required:!0,validator:b=>b.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(b,{emit:I}){const g=b,C=I,A=o=>d.value===o.key&&o.icon_active?o.icon_active:o.icon,i=o=>{const h=A(o);return typeof h=="string"?h:void 0},Z=o=>typeof o=="string",s=t.computed(()=>g.items),d=t.computed(()=>g.activeForm),c=o=>{var V;const h=((V=g.activeChild)==null?void 0:V.parentKey)===o.key;d.value===o.key&&o.collapsed&&!h?C("click",""):C("click",o.key)},G=(o,h)=>{d.value!==h.key&&C("click",h.key),C("child-click",{parentKey:h.key,childKey:o.key})},B=(o,h)=>{var V,N;return((V=g.activeChild)==null?void 0:V.parentKey)===h.key&&((N=g.activeChild)==null?void 0:N.childKey)===o.key};return(o,h)=>(t.openBlock(),t.createElementBlock("div",Ro,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value,V=>(t.openBlock(),t.createElementBlock("div",{key:V.key,class:"flex flex-col items-center justify-center w-full h-full"},[t.createElementVNode("button",{type:"button",onClick:N=>c(V),"aria-expanded":b.activeForm===V.key&&V.collapsed,"aria-controls":`submenu-${V.key}`,"aria-label":`Toggle ${V.name} menu`,class:t.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)]",d.value===V.key?"bg-status-focus":"bg-bandn-white"])},[t.createElementVNode("div",Ho,[t.createElementVNode("div",uo,[t.createElementVNode("div",{class:t.normalizeClass(["flex w-8 h-8 py-1 px-0.5 items-center justify-center",{"text-grey-grey-900":d.value!==V.key,"text-bandn-white":d.value===V.key}])},[Z(A(V))?(t.openBlock(),t.createElementBlock("img",{key:0,src:i(V),alt:"",class:t.normalizeClass(["object-contain w-8 h-8",{"brightness-0 invert":d.value===V.key,"opacity-100":d.value===V.key,"opacity-70":d.value!==V.key}])},null,10,Mo)):(t.openBlock(),t.createBlock(t.resolveDynamicComponent(A(V)),{key:1,class:t.normalizeClass(["w-8 h-8",{"text-grey-grey-900":d.value!==V.key,"text-bandn-white":d.value===V.key}])},null,8,["class"]))],2),t.createElementVNode("span",{class:t.normalizeClass(["flex-[1_0_0] font-inter text-lg font-semibold text-left",{"text-grey-grey-900":d.value!==V.key,"text-bandn-white":d.value===V.key}])},t.toDisplayString(V.name),3),V.collapsed?(t.openBlock(),t.createElementBlock("div",Do,[t.createVNode(t.unref(r0),{class:t.normalizeClass(["transition-transform duration-200",{"text-bandn-white":d.value===V.key,"text-grey-grey-900":d.value!==V.key,"rotate-180":d.value===V.key&&V.collapsed}])},null,8,["class"])])):t.createCommentVNode("",!0)])])],10,Xo),t.createVNode(t.Transition,{name:"fade-slide",mode:"out-in"},{default:t.withCtx(()=>[V.children&&V.children.length?(t.openBlock(),t.createElementBlock("div",{key:0,id:`submenu-${V.key}`,class:t.normalizeClass(["overflow-hidden transition-all duration-500 w-[276px]",b.activeForm===V.key&&V.collapsed?"max-h-[500px]":"max-h-0"])},[t.createElementVNode("div",So,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(V.children,N=>(t.openBlock(),t.createElementBlock("button",{type:"button",key:N.key,onClick:e=>G(N,V),"aria-label":N.name,class:t.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,V),"text-grey-grey-900 border-grey-grey-50":!B(N,V)}])},[t.createElementVNode("span",{class:t.normalizeClass(["flex w-[158px] min-h-[22px] flex-col justify-center font-inter text-sm leading-[22px]",{"font-semibold":B(N,V),"font-normal":!B(N,V)}])},t.toDisplayString(N.name),3)],10,po))),128))])],10,Ko)):t.createCommentVNode("",!0)]),_:2},1024)]))),128))]))}}),rZ=(b,I)=>{const g=b.__vccOpts||b;for(const[C,A]of I)g[C]=A;return g},v0=rZ(Fo,[["__scopeId","data-v-62b8d769"]]);var _Z={exports:{}},zo=_Z.exports,a0;function Jo(){return a0||(a0=1,function(b,I){(function(g,C){C(I)})(zo,function(g){class C{constructor(m,w){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0},this.createdDensity=w,this.nowDrawingDensity=this.createdDensity,this.render=m}setDensity(m){this.createdDensity=m,this.nowDrawingDensity=m}setDrawingDensity(m){this.nowDrawingDensity=m}setPosition(m){this.state.position=m}setAngle(m){this.state.angle=m}setArea(m){this.state.area=m}setHardDrawingAngle(m){this.state.hardDrawingAngle=m}setHardAngle(m){this.state.hardAngle=m,this.state.hardDrawingAngle=m}setOrientation(m){this.orientation=m}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class A extends C{constructor(m,w,n){super(m,n),this.image=null,this.isLoad=!1,this.loadingAngle=0,this.image=new Image,this.image.src=w}draw(m){const w=this.render.getContext(),n=this.render.convertToGlobal(this.state.position),R=this.render.getRect().pageWidth,H=this.render.getRect().height;w.save(),w.translate(n.x,n.y),w.beginPath();for(let M of this.state.area)M!==null&&(M=this.render.convertToGlobal(M),w.lineTo(M.x-n.x,M.y-n.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(m){const w=this.render.getRect(),n=this.render.getContext(),R=w.pageWidth,H=w.height,M=m===1?w.left+w.pageWidth:w.left,K=w.top;this.isLoad?n.drawImage(this.image,M,K,R,H):this.drawLoader(n,{x:M,y:K},R,H)}drawLoader(m,w,n,R){m.beginPath(),m.strokeStyle="rgb(200, 200, 200)",m.fillStyle="rgb(255, 255, 255)",m.lineWidth=1,m.rect(w.x+1,w.y+1,n-1,R-1),m.stroke(),m.fill();const H={x:w.x+n/2,y:w.y+R/2};m.beginPath(),m.lineWidth=10,m.arc(H.x,H.y,20,this.loadingAngle,3*Math.PI/2+this.loadingAngle),m.stroke(),m.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(m,w){this.pages=[],this.currentPageIndex=0,this.currentSpreadIndex=0,this.landscapeSpread=[],this.portraitSpread=[],this.render=w,this.app=m,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 m=0;this.isShowCover&&(this.pages[0].setDensity("hard"),this.landscapeSpread.push([m]),m++);for(let w=m;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(m){const w=this.getSpread();for(let n=0;n<w.length;n++)if(m===w[n][0]||m===w[n][1])return n;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(m){if(m>=0&&m<this.pages.length)return this.pages[m];throw new Error("Invalid page number")}nextBy(m){const w=this.pages.indexOf(m);return w<this.pages.length-1?this.pages[w+1]:null}prevBy(m){const w=this.pages.indexOf(m);return w>0?this.pages[w-1]:null}getFlippingPage(m){const w=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return m===0?this.pages[w].newTemporaryCopy():this.pages[w-1];{const n=m===0?this.getSpread()[w+1]:this.getSpread()[w-1];return n.length===1||m===0?this.pages[n[0]]:this.pages[n[1]]}}getBottomPage(m){const w=this.currentSpreadIndex;if(this.render.getOrientation()==="portrait")return m===0?this.pages[w+1]:this.pages[w-1];{const n=m===0?this.getSpread()[w+1]:this.getSpread()[w-1];return n.length===1?this.pages[n[0]]:m===0?this.pages[n[1]]:this.pages[n[0]]}}showNext(){this.currentSpreadIndex<this.getSpread().length&&(this.currentSpreadIndex++,this.showSpread())}showPrev(){this.currentSpreadIndex>0&&(this.currentSpreadIndex--,this.showSpread())}getCurrentPageIndex(){return this.currentPageIndex}show(m=null){if(m===null&&(m=this.currentPageIndex),m<0||m>=this.pages.length)return;const w=this.getSpreadIndexByPage(m);w!==null&&(this.currentSpreadIndex=w,this.showSpread())}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(m){if(!(m>=0&&m<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=m}showSpread(){const m=this.getSpread()[this.currentSpreadIndex];m.length===2?(this.render.setLeftPage(this.pages[m[0]]),this.render.setRightPage(this.pages[m[1]])):this.render.getOrientation()==="landscape"&&m[0]===this.pages.length-1?(this.render.setLeftPage(this.pages[m[0]]),this.render.setRightPage(null)):(this.render.setLeftPage(null),this.render.setRightPage(this.pages[m[0]])),this.currentPageIndex=m[0],this.app.updatePageIndex(this.currentPageIndex)}}class Z extends i{constructor(m,w,n){super(m,w),this.imagesHref=n}load(){for(const m of this.imagesHref){const w=new A(this.render,m,"soft");w.load(),this.pages.push(w)}this.createSpread()}}class s{static GetDistanceBetweenTwoPoint(m,w){return m===null||w===null?1/0:Math.sqrt(Math.pow(w.x-m.x,2)+Math.pow(w.y-m.y,2))}static GetSegmentLength(m){return s.GetDistanceBetweenTwoPoint(m[0],m[1])}static GetAngleBetweenTwoLine(m,w){const n=m[0].y-m[1].y,R=w[0].y-w[1].y,H=m[1].x-m[0].x,M=w[1].x-w[0].x;return Math.acos((n*R+H*M)/(Math.sqrt(n*n+H*H)*Math.sqrt(R*R+M*M)))}static PointInRect(m,w){return w===null?null:w.x>=m.left&&w.x<=m.width+m.left&&w.y>=m.top&&w.y<=m.top+m.height?w:null}static GetRotatedPoint(m,w,n){return{x:m.x*Math.cos(n)+m.y*Math.sin(n)+w.x,y:m.y*Math.cos(n)-m.x*Math.sin(n)+w.y}}static LimitPointToCircle(m,w,n){if(s.GetDistanceBetweenTwoPoint(m,n)<=w)return n;const R=m.x,H=m.y,M=n.x,K=n.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;n.x<0&&(D*=-1);let p=(D-R)*(H-K)/(R-M)+H;return R-M+H===0&&(p=w),{x:D,y:p}}static GetIntersectBetweenTwoSegment(m,w,n){return s.PointInRect(m,s.GetIntersectBeetwenTwoLine(w,n))}static GetIntersectBeetwenTwoLine(m,w){const n=m[0].y-m[1].y,R=w[0].y-w[1].y,H=m[1].x-m[0].x,M=w[1].x-w[0].x,K=m[0].x*m[1].y-m[1].x*m[0].y,D=w[0].x*w[1].y-w[1].x*w[0].y,p=n*D-R*K,O=H*D-M*K,r=-(K*M-D*H)/(n*M-R*H),$=-(n*D-R*K)/(n*M-R*H);if(isFinite(r)&&isFinite($))return{x:r,y:$};if(Math.abs(p-O)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(m,w){const n=Math.abs(m.x-w.x),R=Math.abs(m.y-w.y),H=Math.max(n,R),M=[m];function K(D,p,O,r,$){return p>D?D+$*(O/r):p<D?D-$*(O/r):D}for(let D=1;D<=H;D+=1)M.push({x:K(m.x,w.x,n,H,D),y:K(m.y,w.y,R,H,D)});return M}}class d extends C{constructor(m,w,n){super(m,n),this.copiedElement=null,this.temporaryCopy=null,this.isLoad=!1,this.element=w,this.element.classList.add("stf__item"),this.element.classList.add("--"+n)}newTemporaryCopy(){return this.nowDrawingDensity==="hard"?this:(this.temporaryCopy===null&&(this.copiedElement=this.element.cloneNode(!0),this.element.parentElement.appendChild(this.copiedElement),this.temporaryCopy=new d(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(m){const w=m||this.nowDrawingDensity,n=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(n,M)}drawHard(m=""){const w=this.render.getRect().left+this.render.getRect().width/2,n=this.state.hardDrawingAngle,R=m+` 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(${n}deg);`:`transform-origin: 0 0; transform: translate3d(${w}px, 0, 0) rotateY(${n}deg);`);this.element.style.cssText=R}drawSoft(m,w=""){let n="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),n+=M.x+"px "+M.y+"px, "}n=n.slice(0,-2),n+=")";const R=w+`transform-origin: 0 0; clip-path: ${n}; -webkit-clip-path: ${n};`+(this.render.isSafari()&&this.state.angle===0?`transform: translate(${m.x}px, ${m.y}px);`:`transform: translate3d(${m.x}px, ${m.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=R}simpleDraw(m){const w=this.render.getRect(),n=w.pageWidth,R=w.height,H=m===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: ${n}px; z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(m){super.setOrientation(m),this.element.classList.remove("--left","--right"),this.element.classList.add(m===1?"--right":"--left")}setDrawingDensity(m){this.element.classList.remove("--soft","--hard"),this.element.classList.add("--"+m),super.setDrawingDensity(m)}}class c extends i{constructor(m,w,n,R){super(m,w),this.element=n,this.pagesElement=R}load(){for(const m of this.pagesElement){const w=new d(this.render,m,m.dataset.density==="hard"?"hard":"soft");w.load(),this.pages.push(w)}this.createSpread()}}class G{constructor(m,w,n,R){this.direction=m,this.corner=w,this.topIntersectPoint=null,this.sideIntersectPoint=null,this.bottomIntersectPoint=null,this.pageWidth=parseInt(n,10),this.pageHeight=parseInt(R,10)}calc(m){try{return this.position=this.calcAngleAndPosition(m),this.calculateIntersectPoint(this.position),!0}catch{return!1}}getFlippingClipArea(){const m=[];let w=!1;return m.push(this.rect.topLeft),m.push(this.topIntersectPoint),this.sideIntersectPoint===null?w=!0:(m.push(this.sideIntersectPoint),this.bottomIntersectPoint===null&&(w=!1)),m.push(this.bottomIntersectPoint),(w||this.corner==="bottom")&&m.push(this.rect.bottomLeft),m}getBottomClipArea(){const m=[];return m.push(this.topIntersectPoint),this.corner==="top"?m.push({x:this.pageWidth,y:0}):(this.topIntersectPoint!==null&&m.push({x:this.pageWidth,y:0}),m.push({x:this.pageWidth,y:this.pageHeight})),this.sideIntersectPoint!==null?s.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&m.push(this.sideIntersectPoint):this.corner==="top"&&m.push({x:this.pageWidth,y:this.pageHeight}),m.push(this.bottomIntersectPoint),m.push(this.topIntersectPoint),m}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 m=s.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return this.direction===0?m:Math.PI-m}calcAngleAndPosition(m){let w=m;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(m){this.angle=this.calculateAngle(m),this.rect=this.getPageRect(m)}calculateAngle(m){const w=this.pageWidth-m.x+1,n=this.corner==="bottom"?this.pageHeight-m.y:m.y;let R=2*Math.acos(w/Math.sqrt(n*n+w*w));n<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(m){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}],m):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],m)}getRectFromBasePoint(m,w){return{topLeft:this.getRotatedPoint(m[0],w),topRight:this.getRotatedPoint(m[1],w),bottomLeft:this.getRotatedPoint(m[2],w),bottomRight:this.getRotatedPoint(m[3],w)}}getRotatedPoint(m,w){return{x:m.x*Math.cos(this.angle)+m.y*Math.sin(this.angle)+w.x,y:m.y*Math.cos(this.angle)-m.x*Math.sin(this.angle)+w.y}}calculateIntersectPoint(m){const w={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};this.corner==="top"?(this.topIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[m,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]),this.sideIntersectPoint=s.GetIntersectBetweenTwoSegment(w,[m,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,[m,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(m,w,n){let R=m;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 p=s.LimitPointToCircle(n,M,D);p!==R&&(R=p,this.updateAngleAndGeometry(R))}return R}getSegmentToShadowLine(){const m=this.getShadowStartPoint();return[m,m!==this.sideIntersectPoint&&this.sideIntersectPoint!==null?this.sideIntersectPoint:this.bottomIntersectPoint]}}class B{constructor(m,w){this.flippingPage=null,this.bottomPage=null,this.calc=null,this.state="read",this.render=m,this.app=w}fold(m){this.setState("user_fold"),this.calc===null&&this.start(m),this.do(this.render.convertToPage(m))}flip(m){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(m)||(this.calc!==null&&this.render.finishAnimation(),!this.start(m)))return;const w=this.getBoundsRect();this.setState("flipping");const n=w.height/10,R=this.calc.getCorner()==="bottom"?w.height-n:n,H=this.calc.getCorner()==="bottom"?w.height:0;this.calc.calc({x:w.pageWidth-n,y:R}),this.animateFlippingTo({x:w.pageWidth-n,y:R},{x:-w.pageWidth,y:H},!0)}start(m){this.reset();const w=this.render.convertToBook(m),n=this.getBoundsRect(),R=this.getDirectionByPoint(w),H=w.y>=n.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,n.pageWidth.toString(10),n.height.toString(10)),!0}catch{return!1}}do(m){if(this.calc!==null&&this.calc.calc(m)){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(m,w){const n=this.app.getPageCollection().getCurrentSpreadIndex(),R=this.app.getPageCollection().getSpreadIndexByPage(m);try{R>n&&(this.app.getPageCollection().setCurrentSpreadIndex(R-1),this.flipNext(w)),R<n&&(this.app.getPageCollection().setCurrentSpreadIndex(R+1),this.flipPrev(w))}catch{}}flipNext(m){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:m==="top"?1:this.render.getRect().height-2})}flipPrev(m){this.flip({x:10,y:m==="top"?1:this.render.getRect().height-2})}stopMove(){if(this.calc===null)return;const m=this.calc.getPosition(),w=this.getBoundsRect(),n=this.calc.getCorner()==="bottom"?w.height:0;m.x<=0?this.animateFlippingTo(m,{x:-w.pageWidth,y:n},!0):this.animateFlippingTo(m,{x:w.pageWidth,y:n},!1)}showCorner(m){if(!this.checkState("read","fold_corner"))return;const w=this.getBoundsRect(),n=w.pageWidth;if(this.isPointOnCorners(m))if(this.calc===null){if(!this.start(m))return;this.setState("fold_corner"),this.calc.calc({x:n-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:n-1,y:H},{x:n-R,y:M},!1,!1)}else this.do(this.render.convertToPage(m));else this.setState("read"),this.render.finishAnimation(),this.stopMove()}animateFlippingTo(m,w,n,R=!0){const H=s.GetCordsFromTwoPoint(m,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&&(n&&(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(m){this.state!==m&&(this.app.updateState(m),this.state=m)}getDirectionByPoint(m){const w=this.getBoundsRect();if(this.render.getOrientation()==="portrait"){if(m.x-w.pageWidth<=w.width/5)return 1}else if(m.x<w.width/2)return 1;return 0}getAnimationDuration(m){const w=this.app.getSettings().flippingTime;return m>=1e3?w:m/1e3*w}checkDirection(m){return m===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(...m){for(const w of m)if(this.state===w)return!0;return!1}isPointOnCorners(m){const w=this.getBoundsRect(),n=w.pageWidth,R=Math.sqrt(Math.pow(n,2)+Math.pow(w.height,2))/5,H=this.render.convertToBook(m);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 o{constructor(m,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=m;const n=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=n.exec(window.navigator.userAgent)!==null}render(m){if(this.animation!==null){const w=Math.round((m-this.animation.startedAt)/this.animation.durationFrame);w<this.animation.frames.length?this.animation.frames[w]():(this.animation.onAnimateEnd(),this.animation=null)}this.timer=m,this.drawFrame()}start(){this.update();const m=w=>{this.render(w),requestAnimationFrame(m)};requestAnimationFrame(m)}startAnimation(m,w,n){this.finishAnimation(),this.animation={frames:m,duration:w,durationFrame:w/m.length,onAnimateEnd:n,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 m=this.calculateBoundsRect();this.orientation!==m&&(this.orientation=m,this.app.updateOrientation(m))}calculateBoundsRect(){let m="landscape";const w=this.getBlockWidth(),n=w/2,R=this.getBlockHeight()/2,H=this.setting.width/this.setting.height;let M=this.setting.width,K=this.setting.height,D=n-M;return this.setting.size==="stretch"?(w<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(m="portrait"),M=m==="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=m==="portrait"?n-M/2-M:n-M):w<2*M&&this.app.getSettings().usePortrait&&(m="portrait",D=n-M/2-M),this.boundsRect={left:D,top:R-K/2,width:2*M,height:K,pageWidth:M},m}setShadowData(m,w,n,R){if(!this.app.getSettings().drawShadow)return;const H=100*this.getSettings().maxShadowOpacity;this.shadow={pos:m,angle:w,width:3*this.getRect().pageWidth/4*n/100,opacity:(100-n)*H/100/100,direction:R,progress:2*n}}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(m){this.pageRect=m}setDirection(m){this.direction=m}setRightPage(m){m!==null&&m.setOrientation(1),this.rightPage=m}setLeftPage(m){m!==null&&m.setOrientation(0),this.leftPage=m}setBottomPage(m){m!==null&&m.setOrientation(this.direction===1?0:1),this.bottomPage=m}setFlippingPage(m){m!==null&&m.setOrientation(this.direction===0&&this.orientation!=="portrait"?0:1),this.flippingPage=m}convertToBook(m){const w=this.getRect();return{x:m.x-w.left,y:m.y-w.top}}isSafari(){return this.safari}convertToPage(m,w){w||(w=this.direction);const n=this.getRect();return{x:w===0?m.x-n.left-n.width/2:n.width/2-m.x+n.left,y:m.y-n.top}}convertToGlobal(m,w){if(w||(w=this.direction),m==null)return null;const n=this.getRect();return{x:w===0?m.x+n.left+n.width/2:n.width/2-m.x+n.left,y:m.y+n.top}}convertRectToGlobal(m,w){return w||(w=this.direction),{topLeft:this.convertToGlobal(m.topLeft,w),topRight:this.convertToGlobal(m.topRight,w),bottomLeft:this.convertToGlobal(m.bottomLeft,w),bottomRight:this.convertToGlobal(m.bottomRight,w)}}}class h extends o{constructor(m,w,n){super(m,w),this.canvas=n,this.ctx=n.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 m=this.getRect();this.orientation==="portrait"&&(this.ctx.beginPath(),this.ctx.rect(m.left+m.pageWidth,m.top,m.width,m.height),this.ctx.clip())}drawBookShadow(){const m=this.getRect();this.ctx.save(),this.ctx.beginPath();const w=m.width/20;this.ctx.rect(m.left,m.top,m.width,m.height);const n={x:m.left+m.width/2-w/2,y:0};this.ctx.translate(n.x,n.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*m.height),this.ctx.restore()}drawOuterShadow(){const m=this.getRect();this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(m.left,m.top,m.width,m.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 n=this.ctx.createLinearGradient(0,0,this.shadow.width,0);this.shadow.direction===0?(this.ctx.translate(0,-100),n.addColorStop(0,"rgba(0, 0, 0, "+this.shadow.opacity+")"),n.addColorStop(1,"rgba(0, 0, 0, 0)")):(this.ctx.translate(-this.shadow.width,-100),n.addColorStop(0,"rgba(0, 0, 0, 0)"),n.addColorStop(1,"rgba(0, 0, 0, "+this.shadow.opacity+")")),this.ctx.clip(),this.ctx.fillStyle=n,this.ctx.fillRect(0,0,this.shadow.width,2*m.height),this.ctx.restore()}drawInnerShadow(){const m=this.getRect();this.ctx.save(),this.ctx.beginPath();const w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),n=this.convertRectToGlobal(this.pageRect);this.ctx.moveTo(n.topLeft.x,n.topLeft.y),this.ctx.lineTo(n.topRight.x,n.topRight.y),this.ctx.lineTo(n.bottomRight.x,n.bottomRight.y),this.ctx.lineTo(n.bottomLeft.x,n.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*m.height),this.ctx.restore()}clear(){this.ctx.fillStyle="white",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}}class V{constructor(m,w,n){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 p=K.x-this.touchPoint.point.x,O=Math.abs(K.y-this.touchPoint.point.y);Math.abs(p)>this.swipeDistance&&O<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout&&(p>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=m,m.classList.add("stf__parent"),m.insertAdjacentHTML("afterbegin",'<div class="stf__wrapper"></div>'),this.wrapper=m.querySelector(".stf__wrapper"),this.app=w;const R=this.app.getSettings().usePortrait?1:2;m.style.minWidth=n.minWidth*R+"px",m.style.minHeight=n.minHeight+"px",n.size==="fixed"&&(m.style.minWidth=n.width*R+"px",m.style.minHeight=n.height+"px"),n.autoSize&&(m.style.width="100%",m.style.maxWidth=2*n.maxWidth+"px"),m.style.display="block",window.addEventListener("resize",this.onResize,!1),this.swipeDistance=n.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers(),this.distElement.remove(),this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(m){this.wrapper.classList.remove("--portrait","--landscape"),m==="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(m,w){const n=this.distElement.getBoundingClientRect();return{x:m-n.left,y:w-n.top}}checkTarget(m){return!this.app.getSettings().clickEventForward||!["a","button"].includes(m.tagName.toLowerCase())}}class N extends V{constructor(m,w,n,R){super(m,w,n),this.wrapper.insertAdjacentHTML("afterbegin",'<div class="stf__block"></div>'),this.distElement=m.querySelector(".stf__block"),this.items=R;for(const H of R)this.distElement.appendChild(H);this.setHandlers()}clear(){for(const m of this.items)this.parentElement.appendChild(m)}updateItems(m){this.removeHandlers(),this.distElement.innerHTML="";for(const w of m)this.distElement.appendChild(w);this.items=m,this.setHandlers()}update(){this.app.getRender().update()}}class e extends V{constructor(m,w,n){super(m,w,n),this.wrapper.innerHTML='<canvas class="stf__canvas"></canvas>',this.canvas=m.querySelectorAll("canvas")[0],this.distElement=this.canvas,this.resizeCanvas(),this.setHandlers()}resizeCanvas(){const m=getComputedStyle(this.canvas),w=parseInt(m.getPropertyValue("width"),10),n=parseInt(m.getPropertyValue("height"),10);this.canvas.width=w,this.canvas.height=n}getCanvas(){return this.canvas}update(){this.resizeCanvas(),this.app.getRender().update()}}class X extends o{constructor(m,w,n){super(m,w),this.outerShadow=null,this.innerShadow=null,this.hardShadow=null,this.hardInnerShadow=null,this.element=n,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 m=this.getRect(),w=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let n=(100-w)*(2.5*m.pageWidth)/100+20;n>m.pageWidth&&(n=m.pageWidth);let R=` display: block; z-index: ${(this.getSettings().startZIndex+5).toString(10)}; width: ${n}px; height: ${m.height}px; background: linear-gradient(to right, rgba(0, 0, 0, ${this.shadow.opacity*w/100}) 5%, rgba(0, 0, 0, 0) 100%); left: ${m.left+m.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 m=this.getRect();let w=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*m.pageWidth)/100+20;w>m.pageWidth&&(w=m.pageWidth);let n=` display: block; z-index: ${(this.getSettings().startZIndex+4).toString(10)}; width: ${w}px; height: ${m.height}px; background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%); left: ${m.left+m.width/2}px; transform-origin: 0 0; `;n+=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=n}drawInnerShadow(){const m=this.getRect(),w=3*this.shadow.width/4,n=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,this.pageRect.bottomRight,this.pageRect.bottomLeft];let D="polygon( ";for(const O of K){let r=this.getDirection()===1?{x:-O.x+this.shadow.pos.x,y:O.y-this.shadow.pos.y}:{x:O.x-this.shadow.pos.x,y:O.y-this.shadow.pos.y};r=s.GetRotatedPoint(r,{x:n,y:100},M),D+=r.x+"px "+r.y+"px, "}D=D.slice(0,-2),D+=")";const p=` display: block; z-index: ${(this.getSettings().startZIndex+10).toString(10)}; width: ${w}px; height: ${2*m.height}px; background: linear-gradient(${R}, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0.05) 15%, rgba(0, 0, 0, ${this.shadow.opacity}) 35%, rgba(0, 0, 0, 0) 100%); transform-origin: ${n}px 100px; transform: translate3d(${H.x-n}px, ${H.y-100}px, 0) rotate(${M}rad); clip-path: ${D}; -webkit-clip-path: ${D}; `;this.innerShadow.style.cssText=p}drawOuterShadow(){const m=this.getRect(),w=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),n=this.shadow.angle+3*Math.PI/2,R=this.getDirection()===1?this.shadow.width:0,H=this.getDirection()===0?"to right":"to left",M=[{x:0,y:0},{x:m.pageWidth,y:0},{x:m.pageWidth,y:m.height},{x:0,y:m.height}];let K="polygon( ";for(const p of M)if(p!==null){let O=this.getDirection()===1?{x:-p.x+this.shadow.pos.x,y:p.y-this.shadow.pos.y}:{x:p.x-this.shadow.pos.x,y:p.y-this.shadow.pos.y};O=s.GetRotatedPoint(O,{x:R,y:100},n),K+=O.x+"px "+O.y+"px, "}K=K.slice(0,-2),K+=")";const D=` display: block; z-index: ${(this.getSettings().startZIndex+10).toString(10)}; width: ${this.shadow.width}px; height: ${2*m.height}px; background: linear-gradient(${H}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0)); transform-origin: ${R}px 100px; transform: translate3d(${w.x-R}px, ${w.y-100}px, 0) rotate(${n}rad); clip-path: ${K}; -webkit-clip-path: ${K}; `;this.outerShadow.style.cssText=D}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 m=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(m))}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.flip