import{r as i,c as t,h as e}from"./p-23a36bb6.js";import{i as n}from"./p-a61fdd20.js";import"@sankhyalabs/core";const a=class{constructor(e){i(this,e),this.ezPageChange=t(this,"ezPageChange",7),this.handlePreviousPage=()=>{this.currentPage>1&&(this.currentPage--,this.ezPageChange.emit(this.currentPage))},this.handleNextPage=()=>{this.currentPage<this.getTotalPages()&&(this.currentPage++,this.ezPageChange.emit(this.currentPage))},this.handlePageClick=i=>{this.currentPage=i,this.ezPageChange.emit(this.currentPage)},this.type="default",this.currentPage=1,this.totalItems=0,this.pageSize=10,this.hideInfoLabel=!1,this.pageLimit=10}async componentWillLoad(){this.i18n=await n()}getTotalPages(){return Math.ceil(this.totalItems/this.pageSize)}renderNextBtn(){return e("ez-button",{"aria-label":this.i18n("ez-pagination.nextPage"),label:this.i18n("ez-pagination.nextPage"),"data-element-id":"pagination-next-button",size:"small",iconName:"arrow-right",class:"ez-button--primary",mode:"icon",enabled:this.currentPage<this.getTotalPages(),onClick:()=>this.handleNextPage()})}renderPreviousBtn(){return e("ez-button",{label:this.i18n("ez-pagination.previousPage"),"aria-label":this.i18n("ez-pagination.previousPage"),"data-element-id":"pagination-previous-button",size:"small",iconName:"arrow-left",mode:"icon",enabled:this.currentPage>1,onClick:()=>this.handlePreviousPage()})}renderPageButton(i){return e("button",{"aria-label":`page-${i}`,class:{"page-button":!0,"current-page":this.currentPage===i},onClick:()=>this.handlePageClick(i)},i)}renderEllipsis(){return e("span",{"aria-label":"page-ellipsis",class:"ellipsis"},"...")}renderPageButtons(i){return i.map((i=>"..."===i?this.renderEllipsis():this.renderPageButton(i)))}renderInfoLabel(i,t){return!this.hideInfoLabel&&e("div",{class:"info"},e("span",{class:"info-range"},i," até ",t)," de ",this.totalItems)}renderDefault(){const i=(this.currentPage-1)*this.pageSize+1,t=Math.min(this.currentPage*this.pageSize,this.totalItems);return e("div",{class:"pagination-container"},this.renderInfoLabel(i,t),e("div",{class:"controls controls-compact"},this.renderPreviousBtn(),this.renderNextBtn()))}renderNumber(){const i=this.getTotalPages(),{currentPage:t,pageLimit:n}=this,a=[];if(i<=n)for(let t=1;t<=i;t++)a.push(t);else{const e=(i,t)=>Array.from({length:t-i+1},((t,e)=>i+e)),o=n-2;if(t>o)if(t<i-o+1){const o=n-4,s=Math.floor((o-1)/2),r=t-s,p=t+(o-1-s);a.push(1),a.push("..."),a.push(...e(r,p)),a.push("..."),a.push(i)}else a.push(1),a.push("..."),a.push(...e(i-(n-3),i));else a.push(...e(1,n-2)),a.push("..."),a.push(i)}return e("div",{class:"pagination-container"},e("div",{class:"controls"},this.renderPreviousBtn(),e("div",{class:"pages-options"},this.renderPageButtons(a)),this.renderNextBtn()))}render(){return"number"===this.type?this.renderNumber():this.renderDefault()}};a.style=".sc-ez-pagination-h{--ez-pagination__info--color:var(--color--petroleum-500);--ez-pagination__info--margin-right:var(--space--sm);--ez-pagination__info--text-weight:var(--text-weight--medium);--ez-pagination__info--font-size:var(--text--medium);--ez-pagination__info-range--font-weight:var(--font-weight--bold);--ez-pagination__pages-option-padding:var(--space--nano);--ez-pagination__pages-option-color:var(--color--petroleum-500);--ez-pagination__pages-option-weight:var(--text-weight--medium);--ez-pagination__pages-option-size:var(--text--medium)}.pagination-container.sc-ez-pagination{display:flex;align-items:center;justify-content:flex-start;overflow:hidden}.info.sc-ez-pagination{color:var(--ez-pagination__info--color);margin-right:var(--ez-pagination__info--margin-right);font-weight:var(--ez-pagination__info--text-weight);font-size:var(--ez-pagination__info--font-size);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}.info-range.sc-ez-pagination{font-weight:var(--ez-pagination__info-range--font-weight)}.controls.sc-ez-pagination{display:flex;align-items:center;flex-shrink:0}.controls-compact.sc-ez-pagination{gap:var(--space--2xs)}.pages-options.sc-ez-pagination{display:flex;align-items:center;padding:0 var(--ez-pagination__pages-option-padding)}.page-button.sc-ez-pagination{color:var(--ez-pagination__pages-option-color);font-weight:var(--ez-pagination__pages-option-weight);font-size:var(--ez-pagination__pages-option-size);background-color:transparent;padding:0;border:none;cursor:pointer;min-width:24px;height:24px;display:flex;align-items:center;justify-content:center}.current-page.sc-ez-pagination{color:var(--color--primary)}.page-info.sc-ez-pagination{margin:0 8px}.ellipsis.sc-ez-pagination{color:var(--ez-pagination__pages-option-color);font-weight:var(--ez-pagination__pages-option-weight);font-size:var(--ez-pagination__pages-option-size);min-width:24px;height:24px;display:flex;align-items:center;justify-content:center}";export{a as ez_pagination}