import{r as s,d as t,h as i,e as o}from"./p-d00c3523.js";import{p as e}from"./p-42da9819.js";import"./p-b66a001a.js";e.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.5.207/pdf.worker.min.js";let a=class{constructor(i){s(this,i),this.pageRendered=t(this,"pageRendered",7),this.pageChange=t(this,"pageChange",7),this.pageNum=1,this.pageNumPending=null,this.scale=.9,this.rotation=0,this.darkMode=!1}doSrc(s,t){s!==t&&this.loadAndRender(s)}async pageNext(s){s.preventDefault(),this.pageNum>=this.pdfDocument.numPages||(this.pageNum+=1,this.queueRenderPage(this.pageNum),this.handleMouseEnter())}async pagePrev(s){s.preventDefault(),this.pageNum<=1||(this.pageNum-=1,this.queueRenderPage(this.pageNum),this.handleMouseEnter())}renderPage(s){this.isPageRendering=!0,this.pdfDocument.getPage(s).then((s=>{const t=s.getViewport({scale:this.scale,rotation:this.rotation});this.canvas.height=t.height,this.canvas.width=t.width,s.render({viewport:t,canvasContext:this.ctx}).promise.then((()=>{this.isPageRendering=!1,this.pageRendered.emit(this.pageNum),null!==this.pageNumPending&&(this.renderPage(this.pageNumPending),this.pageChange.emit(this.pageNumPending),this.pageNumPending=null)}))}))}queueRenderPage(s){this.isPageRendering?this.pageNumPending=s:this.renderPage(s)}componentDidLoad(){this.ctx=this.canvas.getContext("2d"),this.src&&this.loadAndRender(this.src)}loadAndRender(s){e.getDocument(s).promise.then((s=>{this.pdfDocument=s,this.renderPage(this.pageNum)}))}handleMouseEnter(){var s;null===(s=this.btns)||void 0===s||s.classList.add("active"),clearTimeout(this.zoomButtonsHideTimeout)}handleMouseLeave(){this.zoomButtonsHideTimeout=setTimeout((()=>{var s;return null===(s=this.btns)||void 0===s?void 0:s.classList.remove("active")}),1e3)}handleMouseMove(){this.handleMouseEnter(),this.handleMouseLeave()}render(){var s;return i("div",{class:this.containerClass,style:{height:`${this.height}px`},onMouseMove:()=>this.handleMouseMove()},i("canvas",{ref:s=>this.canvas=s,class:this.darkMode?"dark-mode":"light-mode"}),i("ion-buttons",{ref:s=>this.btns=s,class:"pdf-nav-buttons",onMouseEnter:()=>this.handleMouseEnter(),onMouseLeave:()=>this.handleMouseLeave()},i("ion-button",{class:"events-prevent",disabled:1===this.pageNum,fill:"clear",size:"small",onClick:this.pagePrev.bind(this)},i("ion-icon",{slot:"icon-only",src:"/assets/arrow_left.svg"})),i("ion-button",{class:"events-prevent",disabled:this.pageNum===(null===(s=this.pdfDocument)||void 0===s?void 0:s.numPages),fill:"clear",size:"small",onClick:this.pageNext.bind(this)},i("ion-icon",{slot:"icon-only",src:"/assets/arrow_right.svg"}))))}get component(){return o(this)}static get watchers(){return{src:["doSrc"]}}};a.style='akord-pdf-viewer-spa{--cursor-dark:url("/assets/dark_zoom.svg"), zoom-in;--cursor-light:url("/assets/light_zoom.svg"), zoom-in}akord-pdf-viewer-spa .dark-mode{cursor:var(--cursor-dark)}akord-pdf-viewer-spa .light-mode{cursor:var(--cursor-light)}akord-pdf-viewer-spa canvas{margin:auto;display:block;width:100%;height:100%}akord-pdf-viewer-spa .pdf-nav-buttons{position:sticky;display:inline-block;bottom:5px;left:50%;background-color:rgba(60, 60, 60, 0.4);border-radius:10px;opacity:0;transform:translate(-50%, 0);transition:opacity ease-out 0.5s}akord-pdf-viewer-spa .pdf-nav-buttons.active{opacity:1}akord-pdf-viewer-spa ion-buttons ion-button ion-icon{background:transparent;fill:black !important}';export{a as akord_pdf_viewer_spa}