"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RouteTypeEnum = exports.RangeTypeEnum = exports.MaxNameLength = exports.DateTypeEnum = exports.DateSpanMap = exports.DateSpanEnum = exports.DateSpanDefaultEnum = exports.DateRangeDefaultMap = exports.DateFormatMap = exports.DateFormatEnum = exports.DateDefaultMap = exports.DateDefaultEnum = exports.DateDataEnum = void 0;
var _createEnumMap = _interopRequireDefault(require("../_util/createEnumMap"));
var _dayjs = _interopRequireDefault(require("dayjs"));
var _getDay = function _getDay(day) {
  return day === 0 ? 6 : day - 1;
};
// 时间日期组件数据
var DateDataEnum;
exports.DateDataEnum = DateDataEnum;
(function (DateDataEnum) {
  DateDataEnum["OrgId"] = "orgId";
  DateDataEnum["Code"] = "moduleCode";
  DateDataEnum["Name"] = "name";
  DateDataEnum["Type"] = "type";
  DateDataEnum["TypeName"] = "type_name";
  DateDataEnum["Format"] = "formate";
  DateDataEnum["FormatName"] = "formate_name";
  DateDataEnum["Default"] = "defaultVal";
  DateDataEnum["DefaultName"] = "defaultVal_name";
  DateDataEnum["DefaultRangeName"] = "defaultValRange_name";
  DateDataEnum["TimeSpan"] = "span";
  DateDataEnum["TimeSpanName"] = "span_name";
  DateDataEnum["Remark"] = "remark";
  DateDataEnum["CreateTime"] = "createTime";
  DateDataEnum["UpdateTime"] = "updateTime";
  DateDataEnum["HistoryId"] = "hisUuid";
  DateDataEnum["Creator"] = "creator";
  DateDataEnum["Updator"] = "creatorName";
})(DateDataEnum || (exports.DateDataEnum = DateDataEnum = {}));
// 路由类型
var RouteTypeEnum;
exports.RouteTypeEnum = RouteTypeEnum;
(function (RouteTypeEnum) {
  RouteTypeEnum["Add"] = "add";
  RouteTypeEnum["Edit"] = "edit";
  RouteTypeEnum["Copy"] = "copy";
})(RouteTypeEnum || (exports.RouteTypeEnum = RouteTypeEnum = {}));
// 时间类型
var DateTypeEnum;
exports.DateTypeEnum = DateTypeEnum;
(function (DateTypeEnum) {
  DateTypeEnum["Select"] = "2006-01";
  DateTypeEnum["Span"] = "2006-02";
})(DateTypeEnum || (exports.DateTypeEnum = DateTypeEnum = {}));
// 时间格式
var DateFormatEnum;
exports.DateFormatEnum = DateFormatEnum;
(function (DateFormatEnum) {
  DateFormatEnum["A1"] = "2007-01";
  DateFormatEnum["A2"] = "2007-02";
  DateFormatEnum["A3"] = "2007-03";
  DateFormatEnum["A4"] = "2007-04";
  DateFormatEnum["A5"] = "2007-05";
  DateFormatEnum["A6"] = "2007-06";
  DateFormatEnum["B1"] = "2007-07";
  DateFormatEnum["B2"] = "2007-08";
  DateFormatEnum["B3"] = "2007-09";
  DateFormatEnum["B4"] = "2007-10";
  DateFormatEnum["B5"] = "2007-11";
  DateFormatEnum["C1"] = "2007-12";
  DateFormatEnum["C2"] = "2007-13";
  DateFormatEnum["C3"] = "2007-14";
  DateFormatEnum["C4"] = "2007-15";
  DateFormatEnum["C5"] = "2007-16";
  DateFormatEnum["C6"] = "2007-17";
})(DateFormatEnum || (exports.DateFormatEnum = DateFormatEnum = {}));
// 时间组件默认值
var DateDefaultEnum;
exports.DateDefaultEnum = DateDefaultEnum;
(function (DateDefaultEnum) {
  DateDefaultEnum["Today"] = "2003-01";
  DateDefaultEnum["ThisMonth"] = "2003-02";
  DateDefaultEnum["MonthFirstDay"] = "2003-03";
  DateDefaultEnum["ThisYear"] = "2003-04";
  DateDefaultEnum["LastDay"] = "2003-05";
  DateDefaultEnum["LastYear"] = "2003-06";
  DateDefaultEnum["LastMonth"] = "2003-07";
})(DateDefaultEnum || (exports.DateDefaultEnum = DateDefaultEnum = {}));
// 时间区间默认值
var DateSpanDefaultEnum;
exports.DateSpanDefaultEnum = DateSpanDefaultEnum;
(function (DateSpanDefaultEnum) {
  DateSpanDefaultEnum["LastWeek"] = "2004-01";
  DateSpanDefaultEnum["ThisWeek"] = "2004-02";
  DateSpanDefaultEnum["RecentWeek"] = "2004-03";
  DateSpanDefaultEnum["RecentMonth"] = "2004-04";
  DateSpanDefaultEnum["ThisMonth"] = "2004-05";
  DateSpanDefaultEnum["LastMonth"] = "2004-06";
  DateSpanDefaultEnum["RecentQuarter"] = "2004-07";
  DateSpanDefaultEnum["RecentHalfYear"] = "2004-08";
  DateSpanDefaultEnum["RecentYear"] = "2004-09";
  DateSpanDefaultEnum["LastYear"] = "2004-10";
})(DateSpanDefaultEnum || (exports.DateSpanDefaultEnum = DateSpanDefaultEnum = {}));
// 时间区间跨度默认值
var DateSpanEnum;
exports.DateSpanEnum = DateSpanEnum;
(function (DateSpanEnum) {
  DateSpanEnum["Month"] = "2005-01";
  DateSpanEnum["HalfYear"] = "2005-02";
  DateSpanEnum["Year"] = "2005-03";
})(DateSpanEnum || (exports.DateSpanEnum = DateSpanEnum = {}));
// 时间区间选择类型
var RangeTypeEnum;
exports.RangeTypeEnum = RangeTypeEnum;
(function (RangeTypeEnum) {
  RangeTypeEnum["Cascade"] = "2025-01";
  RangeTypeEnum["Single"] = "2025-02";
})(RangeTypeEnum || (exports.RangeTypeEnum = RangeTypeEnum = {}));
var MaxNameLength = 12;
exports.MaxNameLength = MaxNameLength;
var DateFormatMap = (0, _createEnumMap.default)([{
  name: 'YYYY-MM-DD HH:mm:ss',
  id: DateFormatEnum.A1,
  picker: 'date',
  showTime: 'HH:mm:ss'
}, {
  name: 'YYYY-MM-DD HH:mm',
  id: DateFormatEnum.A2,
  picker: 'date',
  showTime: 'HH:mm'
}, {
  name: 'YYYY-MM-DD HH',
  id: DateFormatEnum.A3,
  picker: 'date',
  showTime: 'HH'
}, {
  name: 'YYYY-MM-DD',
  id: DateFormatEnum.A4,
  picker: 'date',
  showTime: false
}, {
  name: 'YYYY-MM',
  id: DateFormatEnum.A5,
  picker: 'month',
  showTime: false
}, {
  name: 'YYYY',
  id: DateFormatEnum.A6,
  picker: 'year',
  showTime: false
}, {
  name: 'YYYY/MM/DD HH:mm:ss',
  id: DateFormatEnum.B1,
  picker: 'date',
  showTime: 'HH:mm:ss'
}, {
  name: 'YYYY/MM/DD HH:mm',
  id: DateFormatEnum.B2,
  picker: 'date',
  showTime: 'HH:mm'
}, {
  name: 'YYYY/MM/DD HH',
  id: DateFormatEnum.B3,
  picker: 'date',
  showTime: 'HH'
}, {
  name: 'YYYY/MM/DD',
  id: DateFormatEnum.B4,
  picker: 'date',
  showTime: false
}, {
  name: 'YYYY',
  id: DateFormatEnum.B5,
  picker: 'month',
  showTime: false
}, {
  name: 'YYYY年MM月DD日 HH:mm:ss',
  id: DateFormatEnum.C1,
  picker: 'date',
  showTime: 'HH:mm:ss'
}, {
  name: 'YYYY年MM月DD日 HH:mm',
  id: DateFormatEnum.C2,
  picker: 'date',
  showTime: 'HH:mm'
}, {
  name: 'YYYY年MM月DD日 HH',
  id: DateFormatEnum.C3,
  picker: 'date',
  showTime: 'HH'
}, {
  name: 'YYYY年MM月DD日',
  id: DateFormatEnum.C4,
  picker: 'date',
  showTime: false
}, {
  name: 'YYYY年MM月',
  id: DateFormatEnum.C5,
  picker: 'month',
  showTime: false
}, {
  name: 'YYYY年',
  id: DateFormatEnum.C6,
  picker: 'year',
  showTime: false
}]);
exports.DateFormatMap = DateFormatMap;
var DateDefaultMap = (0, _createEnumMap.default)([{
  id: DateDefaultEnum.Today,
  name: '当天',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)();
  },
  notMatchedFormats: [DateFormatEnum.A5, DateFormatEnum.A6, DateFormatEnum.B5, DateFormatEnum.C5, DateFormatEnum.C6]
}, {
  id: DateDefaultEnum.ThisMonth,
  name: '当月',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)();
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}, {
  id: DateDefaultEnum.MonthFirstDay,
  name: '当月首天',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)().startOf('month');
  },
  notMatchedFormats: [DateFormatEnum.A5, DateFormatEnum.A6, DateFormatEnum.B5, DateFormatEnum.C5, DateFormatEnum.C6]
}, {
  id: DateDefaultEnum.ThisYear,
  name: '当年',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)();
  },
  notMatchedFormats: []
}, {
  id: DateDefaultEnum.LastDay,
  name: '前一天',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)().subtract(1, 'day');
  },
  notMatchedFormats: [DateFormatEnum.A5, DateFormatEnum.A6, DateFormatEnum.B5, DateFormatEnum.C5, DateFormatEnum.C6]
}, {
  id: DateDefaultEnum.LastYear,
  name: '前一年',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)().subtract(1, 'year');
  },
  notMatchedFormats: []
}, {
  id: DateDefaultEnum.LastMonth,
  name: '上个月',
  getDefaultValue: function getDefaultValue() {
    return (0, _dayjs.default)().subtract(1, 'month');
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}]);
exports.DateDefaultMap = DateDefaultMap;
var DateRangeDefaultMap = (0, _createEnumMap.default)([{
  id: DateSpanDefaultEnum.LastWeek,
  name: '上一周',
  getDefaultValue: function getDefaultValue() {
    var weekOfDay = _getDay((0, _dayjs.default)().day());
    var lastMonday = (0, _dayjs.default)().subtract(weekOfDay + 7, 'days');
    var lastSunday = (0, _dayjs.default)().subtract(weekOfDay + 1, 'days');
    console.log('lastMonday', lastMonday.format('YYYY-MM-DD'), weekOfDay);
    return [lastMonday, lastSunday];
  },
  notMatchedFormats: [DateFormatEnum.A5, DateFormatEnum.A6, DateFormatEnum.B5, DateFormatEnum.C5, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.ThisWeek,
  name: '本周',
  getDefaultValue: function getDefaultValue() {
    var weekOfDay = _getDay((0, _dayjs.default)().day());
    var monday = (0, _dayjs.default)().subtract(weekOfDay, 'days');
    var sunday = (0, _dayjs.default)().subtract(weekOfDay - 6, 'days');
    return [monday, sunday];
  },
  notMatchedFormats: [DateFormatEnum.A5, DateFormatEnum.A6, DateFormatEnum.B5, DateFormatEnum.C5, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.RecentWeek,
  name: '近一周',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(6, 'days');
    var last = (0, _dayjs.default)();
    return [first, last];
  },
  notMatchedFormats: [DateFormatEnum.A5, DateFormatEnum.A6, DateFormatEnum.B5, DateFormatEnum.C5, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.RecentMonth,
  name: '近一月',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(31 - 1, 'days');
    var last = (0, _dayjs.default)();
    return [first, last];
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.ThisMonth,
  name: '本月',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().startOf('month');
    var last = (0, _dayjs.default)().endOf('month');
    return [first, last];
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.LastMonth,
  name: '上个月',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(1, 'month').startOf('month');
    var last = (0, _dayjs.default)().subtract(1, 'month').endOf('month');
    return [first, last];
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.RecentQuarter,
  name: '近三月',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(31 * 3 - 1, 'days');
    var last = (0, _dayjs.default)();
    return [first, last];
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.RecentHalfYear,
  name: '近半年',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(364 / 2, 'days');
    var last = (0, _dayjs.default)();
    return [first, last];
  },
  notMatchedFormats: [DateFormatEnum.A6, DateFormatEnum.C6]
}, {
  id: DateSpanDefaultEnum.RecentYear,
  name: '近一年',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(365 - 1, 'days');
    var last = (0, _dayjs.default)();
    return [first, last];
  },
  notMatchedFormats: []
}, {
  id: DateSpanDefaultEnum.LastYear,
  name: '去年',
  getDefaultValue: function getDefaultValue() {
    var first = (0, _dayjs.default)().subtract(1, 'year').startOf('year');
    var last = (0, _dayjs.default)().subtract(1, 'year').endOf('year');
    return [first, last];
  },
  notMatchedFormats: []
}]);
// const handleGetDisabledDate = (span: number) => (current: Dayjs, data?: [Dayjs | undefined, Dayjs | undefined]) => {
//   const [start, end] = data || []
//   console.log('start', data, start?.format('YYYY-MM-DD'), current?.diff(start, 'days'), span)
//   const tooLate = start && current.diff(start, 'days') > span
//   const tooEarly = end && end.diff(current, 'days') > span
//   return tooEarly || tooLate
// }
exports.DateRangeDefaultMap = DateRangeDefaultMap;
var DateSpanMap = (0, _createEnumMap.default)([{
  id: DateSpanEnum.Month,
  name: '一个月',
  span: 31
  // getDisabledDate: handleGetDisabledDate(31)
}, {
  id: DateSpanEnum.HalfYear,
  name: '半年',
  span: 182
  // getDisabledDate: handleGetDisabledDate(182)
}, {
  id: DateSpanEnum.Year,
  name: '一年',
  span: 365
  // getDisabledDate: handleGetDisabledDate(365)
}]);
exports.DateSpanMap = DateSpanMap;