const DEFAULT_SETTINGS = {
  pageSize: 5,
  datePeriod: "last24h"
};
const VALID_PERIODS = ["last24h", "last7d", "last30d", "custom"];
function isValidDateString(value) {
  const parsed = new Date(value);
  return !Number.isNaN(parsed.getTime());
}
function hydrateSalesNewOrdersSettings(raw) {
  if (!raw || typeof raw !== "object") return { ...DEFAULT_SETTINGS };
  const input = raw;
  const parsedPageSize = Number(input.pageSize);
  const pageSize = Number.isFinite(parsedPageSize) && parsedPageSize >= 1 && parsedPageSize <= 20 ? Math.floor(parsedPageSize) : DEFAULT_SETTINGS.pageSize;
  const datePeriod = VALID_PERIODS.includes(input.datePeriod) ? input.datePeriod : DEFAULT_SETTINGS.datePeriod;
  let customFrom;
  let customTo;
  if (datePeriod === "custom") {
    if (typeof input.customFrom === "string" && isValidDateString(input.customFrom)) {
      customFrom = input.customFrom;
    }
    if (typeof input.customTo === "string" && isValidDateString(input.customTo)) {
      customTo = input.customTo;
    }
  }
  return {
    pageSize,
    datePeriod,
    customFrom,
    customTo
  };
}
export {
  DEFAULT_SETTINGS,
  hydrateSalesNewOrdersSettings
};
//# sourceMappingURL=config.js.map
