import{r as registerInstance,c as createEvent,h,H as Host,g as getElement}from"./index-611fd21e.js";import{g as getScrollParent}from"./position-element-a18074c8.js";var paginationCss=":host{display:block}:host .actions{display:-ms-flexbox;display:flex;gap:8px}:host .actions_select{width:74px}";var Pagination=function(){function t(t){var e=this;registerInstance(this,t);this.bdsPaginationChange=createEvent(this,"bdsPaginationChange",7);this.previewPage=function(t){var n=e.value;if(n>1){t.preventDefault();e.value=e.value-1}};this.nextPage=function(t){var n=e.value;if(n<e.pages){t.preventDefault();e.value=e.value+1}};this.firstPage=function(t){var n=e.value;if(n>1){t.preventDefault();e.value=e.paginationNumbers[0]}};this.lastPage=function(t){var n=e.value;if(n<e.pages){t.preventDefault();e.value=e.pages}};this.openOptions=function(){e.openSelect=!e.openSelect};this.onBlur=function(){e.openSelect=false};this.value=this.startedPage;this.openSelect=undefined;this.paginationNumbers=[];this.intoView=null;this.pages=undefined;this.startedPage=undefined;this.optionsPosition="auto";this.dtButtonInitial=null;this.dtButtonPrev=null;this.dtSelectNumber=null;this.dtButtonNext=null;this.dtButtonEnd=null}t.prototype.componentWillLoad=function(){this.countPage();this.intoView=getScrollParent(this.el)};t.prototype.pagesChanged=function(){this.countPage()};t.prototype.valueChanged=function(){this.bdsPaginationChange.emit(this.value)};t.prototype.countPage=function(){if(this.paginationNumbers.length!==0){this.paginationNumbers=[]}if(this.paginationNumbers.length===0){for(var t=1;t<=this.pages;t++){this.paginationNumbers.push(t)}if(this.startedPage&&this.startedPage<this.pages){this.value=this.startedPage}else{this.value=this.paginationNumbers[0]}}};t.prototype.optionSelected=function(t){this.value=t;this.openOptions()};t.prototype.render=function(){var t=this;return h(Host,null,h("div",{class:"actions"},h("bds-button-icon",{onBdsClick:function(e){return t.firstPage(e)},size:"short",variant:"secondary",icon:"arrow-first",dataTest:this.dtButtonInitial}),h("bds-button-icon",{onBdsClick:function(e){return t.previewPage(e)},size:"short",variant:"secondary",icon:"arrow-left",dataTest:this.dtButtonPrev}),h("bds-select",{class:"actions_select",value:this.value,"options-position":this.optionsPosition},this.paginationNumbers.map((function(e,n){return h("bds-select-option",{key:n,value:e,onClick:function(){return t.optionSelected(e)}},e)}))),h("bds-button-icon",{onBdsClick:function(e){return t.nextPage(e)},size:"short",variant:"secondary",icon:"arrow-right",dataTest:this.dtButtonNext}),h("bds-button-icon",{onBdsClick:function(e){return t.lastPage(e)},size:"short",variant:"secondary",icon:"arrow-last",dataTest:this.dtButtonEnd})))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{pages:["pagesChanged"],startedPage:["pagesChanged"],value:["valueChanged"]}},enumerable:false,configurable:true});return t}();Pagination.style=paginationCss;export{Pagination as bds_pagination};