import { CommonsExporter } from "../interfaces/IExporterProvider";
import { getSelectedRecordsIDsInfo as getSelectedIDs } from '../../../lib/utils/GetSelectedRecordsIDsInfo';
export default class ServerSideExporterProvider extends CommonsExporter {
  getFilters() {
    var _a;
    return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getAppliedFilters();
  }
  getOrders() {
    var _a;
    return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSort();
  }
  getResourceURI() {
    var _a;
    return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.name;
  }
  getSelectedNumber() {
    return this.dataUnit.getSelectionInfo().length;
  }
  getTotalRecords() {
    var _a, _b, _c;
    const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
    return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
  }
  getSelectedIDs() {
    return getSelectedIDs(this.dataUnit);
  }
  getOffset() {
    return this.getExporterOffset(this.getPaginationInfo());
  }
  getPageSize() {
    var _a;
    return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.pageSize;
  }
  getExportLimit() {
    return 5000;
  }
  getRecordID() {
    var _a, _b, _c;
    return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
  }
  getPaginationInfo() {
    var _a;
    return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo();
  }
  getExporterOffset(paginationInfo) {
    if (paginationInfo == undefined) {
      return;
    }
    const offset = paginationInfo.firstRecord;
    if (offset > 0) {
      return (offset - 1);
    }
    return offset;
  }
}
