import {S,A}from'./chunk-C-UoRr_7.js';import {J,c as tS,H as ul,G as vl,a7 as si,bJ as F,w as wo,N as Sr,M as ie,Y,ac as Dr,bW as JT,bu as dy,cF as rD,bv as Vy,bw as y_,bx as v_}from'./main-WUGO6e7n.js';var Q,b,j,L=J(()=>{S();tS();ul();vl();si();Q=["dt"],b=[10,20,50,100],j=(()=>{class s extends A{constructor(e,t,r,i){super(),this.translatorService=e,this.route=t,this.router=r,this.currentUserService=i,this.items=[],this.lazyLoadOnInit=!0,this.pageSizeOptions=[],this.selectedSortOrder=1,this.defaultSortFieldName="name",this.defaultSortParamName="name",this.useQueryParams=!0,this.initializeColumns();}ngOnInit(){this.initializePageSizeOptions(),this.first=this.getFirst();}ngOnChanges(e){e.paging&&(this.tableOptions.defaultSortField=this.sortParamToField(this.paging.sortField),this.tableOptions.defaultSortOrder=this.paging.sortOrder),this.first=this.getFirst();}lazyLoad(e){this.selectedSortField=this.arrayOrStringToString(e.sortField),this.selectedSortOrder=e.sortOrder,this.updateQueryParameters();}onPageSizeOptionsChange(){this.paging.pageNumber=1,this.updateQueryParameters();}onPageChange(e){this.paging.pageNumber=e.first/e.rows+1,this.updateQueryParameters();}onSort(e){this.selectedSortField=e.field,this.selectedSortOrder=e.order,this.updateQueryParameters();}onParametersChange(e){this.parameters=e,this.paging.pageNumber=1,this.updateQueryParameters();}getFirst(){return (this.paging.pageNumber-1)*this.paging.pageSize}updateParameters(){this.updatePagingParameters();}fieldToSortParam(e){let t=this.findColumn(e);return t?.sortParam||t?.field||this.defaultSortParamName}initializePageSizeOptions(){this.pageSizeOptions=b;}updateQueryParameters(){this.useQueryParams?this.router.navigate([this.url],{queryParams:F(F({},this.getPagingQueryParameters()),this.getQueryParameters())}):this.updateParameters();}getPagingQueryParameters(){let e={pagenumber:this.paging?.pageNumber.toString(),pagesize:this.paging?.pageSize.toString()};return this.paging?.pageNumber>1&&(e.pagenumber=this.paging.pageNumber.toString()),this.paging?.pageSize!==this.defaultPageSize&&(e.pagesize=this.paging.pageSize.toString()),this.selectedSortField&&(e.sortfield=this.fieldToSortParam(this.selectedSortField)),this.selectedSortOrder&&(e.sortorder=this.selectedSortOrder.toString()),e}sortParamToField(e){return this.findColumn(e)?.field||this.defaultSortFieldName}findColumn(e){if(!e)return null;let t=e.toLowerCase(),r=i=>i&&i.toLowerCase()===t;return this.cols.find(i=>r(i.field)||r(i.sortParam))}updatePagingParameters(){this.selectedSortField&&(this.paging.sortField=this.fieldToSortParam(this.selectedSortField)),this.selectedSortOrder&&(this.paging.sortOrder=this.selectedSortOrder);}arrayOrStringToString(e){return Array.isArray(e)?e[0].toString():e}static{this.\u0275fac=function(t){return new(t||s)(wo(Sr),wo(ie),wo(Y),wo(Dr))};}static{this.\u0275dir=JT({type:s,viewQuery:function(t,r){if(t&1&&Vy(Q,5),t&2){let i;y_(i=v_())&&(r.table=i.first);}},inputs:{paging:"paging",items:"items",totalCount:"totalCount",parameters:"parameters"},features:[dy,rD]});}}return s})();});export{L,b,j};