"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const types = require("../../../utils/types.js");
const dayjs_min = require("../../../../../../_virtual/dayjs.min.js");
const shared_esmBundler = require("../../../../../@vue/shared/dist/shared.esm-bundler.js");
const buildTimeList = (value, bound) => {
  return [
    value > 0 ? value - 1 : void 0,
    value,
    value < bound ? value + 1 : void 0
  ];
};
const rangeArr = (n) => Array.from(Array.from({ length: n }).keys());
const extractDateFormat = (format) => {
  return format.replace(/\W?m{1,2}|\W?ZZ/g, "").replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, "").trim();
};
const extractTimeFormat = (format) => {
  return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?Y{2,4}/g, "").trim();
};
const dateEquals = function(a, b) {
  const aIsDate = shared_esmBundler.isDate(a);
  const bIsDate = shared_esmBundler.isDate(b);
  if (aIsDate && bIsDate) return a.getTime() === b.getTime();
  if (!aIsDate && !bIsDate) return a === b;
  return false;
};
const valueEquals = function(a, b) {
  const aIsArray = shared_esmBundler.isArray(a);
  const bIsArray = shared_esmBundler.isArray(b);
  if (aIsArray && bIsArray) {
    if (a.length !== b.length) return false;
    return a.every((item, index) => dateEquals(item, b[index]));
  }
  if (!aIsArray && !bIsArray) return dateEquals(a, b);
  return false;
};
const parseDate = function(date, format, lang) {
  const day = types.isEmpty(format) || format === "x" ? dayjs_min.default(date).locale(lang) : dayjs_min.default(date, format).locale(lang);
  return day.isValid() ? day : void 0;
};
const formatter = function(date, format, lang) {
  if (types.isEmpty(format)) return date;
  if (format === "x") return +date;
  return dayjs_min.default(date).locale(lang).format(format);
};
const makeList = (total, method) => {
  const arr = [];
  const disabledArr = method == null ? void 0 : method();
  for (let i = 0; i < total; i++) arr.push((disabledArr == null ? void 0 : disabledArr.includes(i)) ?? false);
  return arr;
};
const dayOrDaysToDate = (dayOrDays) => {
  return shared_esmBundler.isArray(dayOrDays) ? dayOrDays.map((d) => d.toDate()) : dayOrDays.toDate();
};
exports.buildTimeList = buildTimeList;
exports.dateEquals = dateEquals;
exports.dayOrDaysToDate = dayOrDaysToDate;
exports.extractDateFormat = extractDateFormat;
exports.extractTimeFormat = extractTimeFormat;
exports.formatter = formatter;
exports.makeList = makeList;
exports.parseDate = parseDate;
exports.rangeArr = rangeArr;
exports.valueEquals = valueEquals;
