import*as i18n from"../i18n/i18n.js";import{DataGridNode}from"./DataGrid.js";const UIStrings={showDBefore:"Show {PH1} before",showDAfter:"Show {PH1} after",showAllD:"Show all {PH1}"},str_=i18n.i18n.registerUIStrings("data_grid/ShowMoreDataGridNode.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class ShowMoreDataGridNode extends DataGridNode{constructor(t,s,i,e){super({summaryRow:!0},!1),this._callback=t,this._startPosition=s,this._endPosition=i,this._chunkSize=e,this.showNext=document.createElement("button"),this.showNext.classList.add("text-button"),this.showNext.type="button",this.showNext.addEventListener("click",this._showNextChunk.bind(this),!1),this.showNext.textContent=i18nString(UIStrings.showDBefore,{PH1:this._chunkSize}),this.showAll=document.createElement("button"),this.showAll.classList.add("text-button"),this.showAll.type="button",this.showAll.addEventListener("click",this._showAll.bind(this),!1),this.showLast=document.createElement("button"),this.showLast.classList.add("text-button"),this.showLast.type="button",this.showLast.addEventListener("click",this._showLastChunk.bind(this),!1),this.showLast.textContent=i18nString(UIStrings.showDAfter,{PH1:this._chunkSize}),this._updateLabels(),this.selectable=!1}_showNextChunk(){this._callback(this._startPosition,this._startPosition+this._chunkSize)}_showAll(){this._callback(this._startPosition,this._endPosition)}_showLastChunk(){this._callback(this._endPosition-this._chunkSize,this._endPosition)}_updateLabels(){const t=this._endPosition-this._startPosition;t>this._chunkSize?(this.showNext.classList.remove("hidden"),this.showLast.classList.remove("hidden")):(this.showNext.classList.add("hidden"),this.showLast.classList.add("hidden")),this.showAll.textContent=i18nString(UIStrings.showAllD,{PH1:t})}createCells(t){this._hasCells=!1,super.createCells(t)}createCell(t){const s=this.createTD(t);return s.classList.add("show-more"),this._hasCells||(this._hasCells=!0,this.depth&&this.dataGrid&&s.style.setProperty("padding-left",this.depth*this.dataGrid.indentWidth+"px"),s.appendChild(this.showNext),s.appendChild(this.showAll),s.appendChild(this.showLast)),s}setStartPosition(t){this._startPosition=t,this._updateLabels()}setEndPosition(t){this._endPosition=t,this._updateLabels()}nodeSelfHeight(){return 40}dispose(){}}