{"version":3,"file":"index.mjs","sources":["../../../../src/components/Calendar/index.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport {\n  subMonths,\n  addMonths,\n  setYear as setFnsYear,\n  setMonth as setFnsMonth,\n  format,\n  isSameDay,\n  getDaysInMonth,\n  min,\n  max,\n  set,\n  addYears,\n  subYears,\n  isBefore,\n  isAfter,\n  endOfWeek,\n  startOfWeek,\n  eachDayOfInterval,\n  addDays,\n} from 'date-fns';\nimport {\n  computed,\n  nextTick,\n  onMounted,\n  PropType,\n  ref,\n  toRefs,\n  watch,\n} from 'vue';\nimport { PhCaretLeft, PhCaretRight } from '@phosphor-icons/vue';\nimport defaultPresets, { Filter, Preset } from './presets';\nimport variants from './variants';\nimport { RobustDatePicker, RobustSelect } from '..';\nimport { validate } from 'vee-validate';\n\nconst props = defineProps({\n  future: {\n    type: Boolean,\n    default: true,\n  },\n  past: {\n    type: Boolean,\n    default: true,\n  },\n  today: {\n    type: Boolean,\n    default: true,\n  },\n  variant: {\n    type: String,\n    default: 'primary',\n  },\n  modelValue: {\n    type: Object as PropType<[Date, Date] | Date | [Date, Date][]>,\n    default: () => new Date(),\n  },\n  enablePreset: {\n    type: Boolean,\n    default: () => false,\n  },\n  readOnly: {\n    type: Boolean,\n    default: () => false,\n  },\n  presets: {\n    type: Array as PropType<Array<Preset>>,\n    default: () => defaultPresets.filter((d) => d.type === 'range'),\n  },\n  preset: {\n    type: String,\n    default: () => undefined,\n  },\n  filters: {\n    type: Array as PropType<Array<Filter>>,\n    default: () => [],\n  },\n  filter: {\n    type: String || Number,\n    default: () => undefined,\n  },\n  presetReferenceDate: {\n    type: Object as PropType<[Date, Date]>,\n    default: () => undefined,\n  },\n  multiplePeriod: {\n    type: Boolean,\n    default: false,\n  },\n  fixed: {\n    type: Boolean,\n    default: false,\n  },\n  cursorMonth: {\n    type: Number,\n    default: () => undefined,\n  },\n  cursorYear: {\n    type: Number,\n    default: () => undefined,\n  },\n  title: {\n    type: String,\n    default: () => undefined,\n  },\n  dualCalendar: {\n    type: Boolean,\n    default: () => false,\n  },\n  hideCalendar: {\n    type: Boolean,\n    default: () => false,\n  },\n});\n\nconst emit = defineEmits([\n  'update:modelValue',\n  'update:preset',\n  'update:filter',\n  'dayClick',\n  'dayHover',\n]);\n\nconst {\n  future,\n  past,\n  today,\n  modelValue,\n  presets,\n  preset: currentPreset,\n  filters,\n  filter: currentFilter,\n  multiplePeriod,\n  fixed,\n  title,\n  cursorMonth,\n  cursorYear,\n  dualCalendar,\n  presetReferenceDate,\n  readOnly,\n} = toRefs(props);\n\nconst useMondayFirstWeekday = true;\nconst now = ref();\n// const cursor = ref<Date>()\nconst cursor = Array.isArray(modelValue.value)\n  ? ref<Date>(new Date())\n  : ref<Date>(new Date(modelValue.value));\n\nconst selectedDate = ref<Date>(new Date());\nconst refYearEntry = ref({});\n\nconst variantStyling = computed(() => {\n  return variants[props.variant];\n});\n\nconst filtersOptions = computed(() => {\n  const mappedFilters = [];\n  for (const filter of filters.value as any[]) {\n    if (!filter.value) {\n      mappedFilters.push({ ...filter, value: filter.key });\n    } else {\n      mappedFilters.push(filter);\n    }\n  }\n  return mappedFilters;\n});\n\nconst daysInMonth = computed(() => {\n  const date = new Date(cursor.value);\n  const dateMonthDays = getDaysInMonth(date);\n  if (dualCalendar.value) {\n    const secondMonth = new Date(\n      date.getFullYear(),\n      date.getMonth() + 1,\n      date.getDate()\n    );\n    const secondMonthDays = getDaysInMonth(secondMonth);\n    const mappedMonth = mapDaysInMonth(\n      dateMonthDays,\n      date.getMonth(),\n      date.getFullYear()\n    );\n    const mappedSecondMonth = mapDaysInMonth(\n      secondMonthDays,\n      secondMonth.getMonth(),\n      secondMonth.getFullYear()\n    );\n    return [mappedMonth, mappedSecondMonth];\n  }\n  return dateMonthDays;\n});\n\nconst monthHeading = computed(() => {\n  try {\n    const formattedMonth = format(cursor.value, 'MMM');\n    if (dualCalendar.value) {\n      const date = new Date(cursor.value);\n      const secondMonth = new Date(\n        date.getFullYear(),\n        date.getMonth() + 1,\n        date.getDate()\n      );\n      return [formattedMonth, format(secondMonth, 'MMM')];\n    }\n    return format(cursor.value, 'MMM');\n  } catch (e) {\n    return undefined;\n  }\n});\nconst yearHeading = computed(() => {\n  try {\n    const formattedMonth = format(cursor.value, 'yyyy');\n    if (dualCalendar.value) {\n      const date = new Date(cursor.value);\n      const secondMonth = new Date(\n        date.getFullYear(),\n        date.getMonth() + 1,\n        date.getDate()\n      );\n      return [formattedMonth, format(secondMonth, 'yyyy')];\n    }\n    return format(cursor.value, 'yyyy');\n  } catch (e) {\n    return undefined;\n  }\n});\n\nconst firstWeekday = computed(() => {\n  const date = new Date(cursor.value);\n  if (dualCalendar.value) {\n    const dateSecondMonth = new Date(\n      date.getFullYear(),\n      date.getMonth() + 1,\n      date.getDate()\n    );\n    date.setDate(1);\n    dateSecondMonth.setDate(1);\n    const day = date.getDay();\n    const daySecondMonth = dateSecondMonth.getDay();\n    return useMondayFirstWeekday\n      ? [\n          (day === 0 ? 7 : day) - 1,\n          (daySecondMonth === 0 ? 7 : daySecondMonth) - 1,\n        ]\n      : [day, daySecondMonth];\n  }\n  date.setDate(1);\n  const day = date.getDay();\n  return useMondayFirstWeekday ? (day === 0 ? 7 : day) - 1 : day;\n});\n\nconst activeMonth = computed(() => {\n  const date = new Date(cursor.value);\n  return date.getMonth();\n});\n\nconst activeYear = computed(() => {\n  const date = new Date(cursor.value);\n  return date.getFullYear();\n});\n\n// const applyTime = () => {\n//   console.log('applying time');\n\n//   if (from.value != '' && !isValid(new Date(from.value))) {\n//     errorFrom.value = 'Please enter a valid date.';\n//   }\n//   if (to.value != '' && !isValid(new Date(to.value))) {\n//     errorTo.value = 'Please enter a valid date.';\n//   }\n//   if (isValid(new Date(from.value)) && isValid(new Date(to.value))) {\n//     errorFrom.value = '';\n//     errorTo.value = '';\n//     const newModelValue = [new Date(from.value), new Date(to.value)];\n//     emit('update:modelValue', newModelValue);\n//   }\n// };\n\nconst formatDateToUTC = (date: Date) => {\n  const newDate = new Date(\n    date.getFullYear(),\n    date.getMonth(),\n    date.getDate(),\n    12\n  );\n\n  newDate.setUTCHours(12);\n  newDate.setMinutes(0);\n  newDate.setSeconds(0);\n\n  return newDate;\n};\n\nconst mapDaysInMonth = (days: number, month: number, year: number) => {\n  const mappedMonth = [];\n  for (const day in Array(days).fill(0)) {\n    mappedMonth.push({\n      display: +day + 1,\n      value: new Date(year, month, +day + 1),\n    });\n  }\n  return mappedMonth;\n};\n\nconst compareDates = (dateOne, dateTwo) => {\n  const diff = dayDiff(dateOne, dateTwo);\n\n  if (diff < 0) {\n    return 1;\n  } else if (diff > 0) {\n    return -1;\n  }\n  return 0;\n};\n\nconst dayDiff = (d1, d2) => {\n  const endDate = Date.UTC(d2.getFullYear(), d2.getMonth(), d2.getDate());\n  const startDate = Date.UTC(d1.getFullYear(), d1.getMonth(), d1.getDate());\n  return (endDate - startDate) / 86400000;\n};\n\nconst isFirst = (day) => {\n  // checking if it is daterange or only datepicker\n  if (!Array.isArray(modelValue.value)) {\n    return false;\n  }\n\n  if (multiplePeriod.value) {\n    for (const period of modelValue.value as [Date, Date][]) {\n      if (!compareDates(...period)) {\n        return false;\n      }\n\n      const values = {\n        year: cursor.value.getFullYear(),\n        month: cursor.value.getMonth(),\n        day,\n      };\n      const tmpDate = dualCalendar.value\n        ? day.value\n        : new Date(values.year, values.month, values.day);\n\n      const minDate = min(period as [Date, Date]);\n\n      // minimal value\n      if (!compareDates(tmpDate, minDate)) {\n        return true;\n      }\n    }\n  } else {\n    // doesn't do any actions if you've choosen only one date\n    if (modelValue.value.length < 2) {\n      return false;\n    }\n\n    if (!compareDates(...(modelValue.value as [Date, Date]))) {\n      return false;\n    }\n\n    const values = {\n      year: cursor.value.getFullYear(),\n      month: cursor.value.getMonth(),\n      day,\n    };\n    const tmpDate = dualCalendar.value\n      ? day.value\n      : new Date(values.year, values.month, values.day);\n\n    const minDate = min(modelValue.value as [Date, Date]);\n\n    // minimal value\n    if (!compareDates(tmpDate, minDate)) {\n      return true;\n    }\n  }\n  return false;\n};\n\nconst isLast = (day) => {\n  // checking if it is daterange or only datepicker\n  if (!Array.isArray(modelValue.value)) {\n    return false;\n  }\n\n  if (multiplePeriod.value) {\n    for (const period of modelValue.value as [Date, Date][]) {\n      if (!compareDates(...period)) {\n        return false;\n      }\n\n      const values = {\n        year: cursor.value.getFullYear(),\n        month: cursor.value.getMonth(),\n        day,\n      };\n      const tmpDate = dualCalendar.value\n        ? day.value\n        : new Date(values.year, values.month, values.day);\n\n      const maxDate = max(period as [Date, Date]);\n\n      // maximal value\n      if (!compareDates(tmpDate, maxDate)) {\n        return true;\n      }\n    }\n  } else {\n    // doesn't do any actions if you've choosen only one date\n    if (modelValue.value.length < 2) {\n      return false;\n    }\n\n    if (!compareDates(...(modelValue.value as [Date, Date]))) {\n      return false;\n    }\n\n    const values = {\n      year: cursor.value.getFullYear(),\n      month: cursor.value.getMonth(),\n      day,\n    };\n    const tmpDate = dualCalendar.value\n      ? day.value\n      : new Date(values.year, values.month, values.day);\n\n    const maxDate = max(modelValue.value as [Date, Date]);\n\n    // maximal value\n    if (!compareDates(tmpDate, maxDate)) {\n      return true;\n    }\n  }\n  return false;\n};\n\nconst isBetweenRange = (day) => {\n  if (!Array.isArray(modelValue.value)) {\n    return false;\n  }\n\n  if (multiplePeriod.value) {\n    for (const period of modelValue.value as [Date, Date][]) {\n      const values = {\n        year: cursor.value.getFullYear(),\n        month: cursor.value.getMonth(),\n        day,\n      };\n      const tmpDate = dualCalendar.value\n        ? day.value\n        : new Date(values.year, values.month, values.day);\n      const minDate = min(period);\n      const maxDate = max(period);\n\n      if (\n        compareDates(tmpDate, maxDate) === -1 &&\n        compareDates(tmpDate, minDate) === 1\n      ) {\n        return true;\n      }\n    }\n  } else {\n    if (modelValue.value.length < 2) {\n      return false;\n    }\n\n    const values = {\n      year: cursor.value.getFullYear(),\n      month: cursor.value.getMonth(),\n      day,\n    };\n    const tmpDate = dualCalendar.value\n      ? day.value\n      : new Date(values.year, values.month, values.day);\n    const minDate = min(modelValue.value as [Date, Date]);\n    const maxDate = max(modelValue.value as [Date, Date]);\n\n    if (\n      compareDates(tmpDate, maxDate) === -1 &&\n      compareDates(tmpDate, minDate) === 1\n    ) {\n      return true;\n    }\n  }\n  return false;\n};\n\nconst isSelectedDay = (day) => {\n  if (dualCalendar.value) {\n    if (Array.isArray(modelValue.value)) {\n      const selectedDates: Date[] = multiplePeriod.value\n        ? modelValue.value\n            .map((period) => period.map((date) => new Date(date)))\n            .flat()\n        : modelValue.value.map((date) => new Date(date));\n      for (let i = 0; i < selectedDates.length; i++) {\n        if (!compareDates(selectedDates[i], day.value)) {\n          return true;\n        }\n      }\n    } else {\n      if (isSameDay(selectedDate.value, day.value)) {\n        return true;\n      }\n    }\n  } else {\n    const tmpDate = new Date(cursor.value);\n    tmpDate.setDate(day);\n\n    if (Array.isArray(modelValue.value)) {\n      const selectedDates: Date[] = multiplePeriod.value\n        ? modelValue.value\n            .map((period) => period.map((date) => new Date(date)))\n            .flat()\n        : modelValue.value.map((date) => new Date(date));\n      for (let i = 0; i < selectedDates.length; i++) {\n        if (!compareDates(selectedDates[i], tmpDate)) {\n          return true;\n        }\n      }\n    } else {\n      if (isSameDay(selectedDate.value, tmpDate)) {\n        return true;\n      }\n    }\n  }\n};\n\nfunction setQuickAction(preset: Preset) {\n  const presetValue = preset.eval(presetReferenceDate.value);\n  emit('update:modelValue', presetValue);\n  emit('update:preset', preset.key);\n\n  if (Array.isArray(presetValue)) {\n    cursor.value = presetValue[1];\n  } else {\n    cursor.value = presetValue;\n  }\n}\nfunction addYear() {\n  cursor.value = addYears(cursor.value, 1);\n}\n\nfunction subYear() {\n  cursor.value = subYears(cursor.value, 1);\n}\n\nfunction setYear(year) {\n  cursor.value = setFnsYear(cursor.value, year);\n}\n\nfunction addMonth() {\n  cursor.value = addMonths(cursor.value, 1);\n}\n\nfunction subMonth() {\n  cursor.value = subMonths(cursor.value, 1);\n}\n\nfunction setMonth(month) {\n  cursor.value = setFnsMonth(cursor.value, month);\n}\n\nconst isPast = (date: Date) => {\n  const today = new Date();\n  today.setHours(0, 0, 0, 0);\n  return isBefore(date, today);\n};\n\nconst isFuture = (date: Date) => {\n  const today = new Date();\n  today.setHours(23, 59, 59, 999);\n  return isAfter(date, today);\n};\n\nconst dayAllowed = (day) => {\n  const date = dualCalendar.value\n    ? new Date(day.value)\n    : new Date(cursor.value).setDate(day);\n  if (!today.value && isSameDay(now.value, date)) {\n    return false;\n  }\n  if (!past.value && isPast(new Date(date))) {\n    return false;\n  }\n  if (!future.value && isFuture(new Date(date))) {\n    return false;\n  }\n  return true;\n};\n\nconst dayHover = (day) => {\n  return emit('dayHover', day);\n};\n\nconst daySelect = (day) => {\n  if (readOnly.value || !dayAllowed(day)) {\n    return;\n  }\n\n  const values = {\n    year: cursor.value.getFullYear(),\n    month: cursor.value.getMonth(),\n    day,\n  };\n  const tmpDate = dualCalendar.value\n    ? day.value\n    : new Date(values.year, values.month, values.day);\n\n  !dualCalendar.value && (cursor.value = tmpDate);\n\n  if (Array.isArray(modelValue.value)) {\n    if (multiplePeriod.value) {\n      return emit('dayClick', tmpDate);\n    } else {\n      let newModelValue = [];\n      if (modelValue.value.length >= 2) {\n        newModelValue.push(new Date(tmpDate));\n      } else {\n        newModelValue = modelValue.value;\n        newModelValue.push(new Date(tmpDate));\n        if (newModelValue.length > 1) {\n          newModelValue = [\n            formatDateToUTC(min(newModelValue)),\n            formatDateToUTC(max(newModelValue)),\n          ];\n        }\n      }\n      emit('update:modelValue', newModelValue);\n      emit('update:preset', undefined);\n    }\n  } else {\n    selectedDate.value = new Date(tmpDate);\n    emit('update:modelValue', tmpDate);\n    emit('update:preset', undefined);\n  }\n};\n\nconst reset = () => {\n  cursor.value = new Date(new Date().setHours(12));\n};\n\n// const fromChanged = (value: string) => {\n//   const fromDate = value;\n//   const toDate = to.value;\n//   const regexp = /^(0?[1-9]|1[012])[/-](0?[1-9]|[12][0-9]|3[01])[/-]\\d{4}$/;\n//   if (regexp.test(fromDate) && regexp.test(toDate)) {\n//     console.log('changed valid');\n//     emit('update:modelValue', [new Date(fromDate), new Date(toDate)]);\n//   }\n// };\n\n// const toChanged = (value: string) => {\n//   const toDate = value;\n//   const fromDate = from.value;\n//   const regexp = /^(0?[1-9]|1[012])[/-](0?[1-9]|[12][0-9]|3[01])[/-]\\d{4}$/;\n//   if (regexp.test(fromDate) && regexp.test(toDate)) {\n//     emit('update:modelValue', [new Date(fromDate), new Date(toDate)]);\n//   }\n// };\n\nonMounted(() => {\n  if (cursorMonth.value || cursorMonth.value === 0 || cursorYear.value) {\n    cursor.value = new Date(\n      cursorYear.value || new Date().getFullYear(),\n      cursorMonth.value || cursorMonth.value === 0\n        ? cursorMonth.value\n        : new Date().getMonth(),\n      1\n    );\n    selectedDate.value = cursor.value;\n  } else {\n    if (Array.isArray(modelValue.value)) {\n      if (multiplePeriod.value && modelValue.value[0]) {\n        cursor.value = new Date(modelValue.value[0][1] || new Date());\n        selectedDate.value = cursor.value;\n      } else {\n        cursor.value = new Date((modelValue.value[0] as Date) || new Date());\n        selectedDate.value = cursor.value;\n      }\n    } else {\n      cursor.value = new Date(modelValue.value || new Date());\n      selectedDate.value = cursor.value;\n    }\n  }\n});\n\nconst yearSelectionYears = computed(() => {\n  const years = [];\n  for (let year = 1900; year <= 2100; year++) {\n    years.push(year);\n  }\n  return years;\n});\n\nconst showMonthSelectionActive = ref(false);\n\nfunction showMonthSelection() {\n  showMonthSelectionActive.value = true;\n}\nfunction hideMonthSelection() {\n  showMonthSelectionActive.value = false;\n}\n\nconst showYearSelectionActive = ref(false);\nfunction showYearSelection() {\n  showYearSelectionActive.value = true;\n  nextTick(() => {\n    const yearEntry = refYearEntry.value[activeYear.value];\n    yearEntry.scrollIntoView({ block: 'start', behavior: 'auto' });\n  });\n}\nfunction hideYearSelection() {\n  showYearSelectionActive.value = false;\n}\n\nconst capitalize = (str: string) => {\n  const s = str.charAt(0).toUpperCase();\n\n  return s + str.slice(1, str.length);\n};\n\nconst getShortMonthName = (month: number) => {\n  const formatter = Intl.DateTimeFormat(navigator.language, {\n    month: 'long',\n  });\n  const objDate = new Date();\n  objDate.setDate(1);\n  objDate.setMonth(month - 1);\n  return capitalize(formatter.format(objDate).slice(0, 3));\n};\n\nconst getDayNames = () => {\n  const days = eachDayOfInterval({\n    start: useMondayFirstWeekday\n      ? addDays(startOfWeek(new Date()), 1)\n      : startOfWeek(new Date()),\n    end: useMondayFirstWeekday\n      ? addDays(endOfWeek(new Date()), 1)\n      : endOfWeek(new Date()),\n  });\n  return days.map((date) =>\n    date.toLocaleString(navigator.language, {\n      weekday: 'long',\n    })\n  );\n};\n\nconst months = computed(() => {\n  return [\n    {\n      title: getShortMonthName(1),\n    },\n    {\n      title: getShortMonthName(2),\n    },\n    {\n      title: getShortMonthName(3),\n    },\n    {\n      title: getShortMonthName(4),\n    },\n    {\n      title: getShortMonthName(5),\n    },\n    {\n      title: getShortMonthName(6),\n    },\n    {\n      title: getShortMonthName(7),\n    },\n    {\n      title: getShortMonthName(8),\n    },\n    {\n      title: getShortMonthName(9),\n    },\n    {\n      title: getShortMonthName(10),\n    },\n    {\n      title: getShortMonthName(11),\n    },\n    {\n      title: getShortMonthName(12),\n    },\n  ];\n});\n\nconst getPresetStyle = (preset: Preset) => {\n  if (!currentPreset.value) {\n    return '';\n  }\n  if (preset.key === currentPreset.value) {\n    if (props.variant === 'secondary') {\n      return 'bg-emerald-500 hover:bg-emerald-500 text-white';\n    }\n    return 'bg-primary-500 hover:bg-primary-500 text-white';\n  }\n  return '';\n};\n\nconst changeFilter = (filter: number | string) => {\n  const foundFilter = filters.value.find(\n    (filterObj) => filterObj.key === filter\n  );\n\n  if (!foundFilter || foundFilter.type === 'disabled') {\n    return;\n  }\n\n  emit('update:filter', filter);\n  if (foundFilter.eval) {\n    const presetValue = foundFilter.eval(presetReferenceDate.value);\n\n    if (Array.isArray(presetValue)) {\n      cursor.value = presetValue[1];\n    } else {\n      cursor.value = presetValue;\n    }\n    emit('update:modelValue', presetValue);\n  }\n};\n\n// watch(currentPreset, (newVal, oldValue) => {\n//   if (newVal !== oldValue && currentPreset.value) {\n//     const preset = defaultPresets.find((d) => d.key === currentPreset.value);\n//     if (preset) {\n//       setQuickAction(preset);\n//     }\n//   }\n// });\n\ndefineExpose({\n  addYear,\n  subYear,\n  addMonth,\n  subMonth,\n  reset,\n});\n</script>\n\n<template>\n  <div\n    class=\"relative flex w-full select-none\"\n    :class=\"enablePreset ? 'flex-col sm:flex-row' : 'flex-col'\"\n  >\n    <div\n      class=\"flex flex-col relative w-48\"\n      :class=\"!enablePreset ? 'w-full px-4' : 'pl-1'\"\n    >\n      <div v-if=\"filters.length\">\n        <RobustSelect\n          :options=\"filtersOptions\"\n          :model-value=\"currentFilter\"\n          :border=\"false\"\n          @update:model-value=\"changeFilter\"\n          class=\"w-full border-b border-gray-200 dark:border-gray-700 pt-3\"\n        />\n      </div>\n      <div\n        v-if=\"presets.length && enablePreset && !fixed\"\n        class=\"relative hidden min-h-0 h-full w-full border-r border-gray-200 dark:border-gray-700 lg:block\"\n      >\n        <div class=\"absolute inset-0 overflow-auto py-2\">\n          <button\n            v-for=\"(preset, index) in presets\"\n            :key=\"index\"\n            type=\"button\"\n            class=\"w-full rounded-lg px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/5\"\n            :class=\"getPresetStyle(preset)\"\n            @click=\"setQuickAction(preset)\"\n          >\n            {{ preset.title }}\n          </button>\n        </div>\n      </div>\n    </div>\n\n    <section v-if=\"!props.hideCalendar\" class=\"p-4 dark:border-gray-700\">\n      <div\n        v-if=\"!dualCalendar\"\n        class=\"mb-4 flex items-center text-center text-lg font-semibold\"\n      >\n        <div v-if=\"!fixed\" class=\"flex flex-1\">\n          <button\n            type=\"button\"\n            class=\"flex h-8 items-center rounded-lg px-2 tabular-nums hover:bg-gray-100 dark:hover:bg-white/5\"\n            @click=\"\n              () => {\n                showMonthSelection();\n                hideYearSelection();\n              }\n            \"\n          >\n            {{ monthHeading }}\n          </button>\n          <button\n            type=\"button\"\n            class=\"flex h-8 items-center rounded-lg px-2 tabular-nums hover:bg-gray-100 dark:hover:bg-white/5\"\n            @click=\"\n              () => {\n                showYearSelection();\n                hideMonthSelection();\n              }\n            \"\n          >\n            {{ yearHeading }}\n          </button>\n        </div>\n        <div v-else class=\"flex flex-1\">\n          <div v-if=\"title\" class=\"h-8 items-center px-2 tabular-nums\">\n            {{ title }}\n          </div>\n          <div v-else class=\"flex\">\n            <div class=\"h-8 px-2 tabular-nums\">\n              {{ monthHeading }}\n            </div>\n            <div class=\"h-8 px-2 tabular-nums\">\n              {{ yearHeading }}\n            </div>\n          </div>\n        </div>\n        <button\n          v-if=\"!fixed\"\n          type=\"button\"\n          class=\"flex h-8 w-8 items-center justify-center rounded-lg text-gray-800 hover:bg-gray-100 hover:text-gray-800 active:bg-gray-100 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-100\"\n          @click=\"subMonth\"\n        >\n          <PhCaretLeft type=\"chevron-left\" size=\"14\" weight=\"bold\" />\n        </button>\n\n        <button\n          v-if=\"!fixed\"\n          type=\"button\"\n          class=\"flex h-8 w-8 items-center justify-center rounded-lg text-gray-800 hover:bg-gray-100 hover:text-gray-800 active:bg-gray-100 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-100\"\n          @click=\"addMonth\"\n        >\n          <PhCaretRight type=\"chevron-right\" size=\"14\" weight=\"bold\" />\n        </button>\n      </div>\n\n      <div v-if=\"!dualCalendar\" class=\"relative w-full\">\n        <div\n          v-if=\"showMonthSelectionActive\"\n          class=\"absolute inset-0 z-10 grid grid-cols-3 gap-4\"\n        >\n          <button\n            v-for=\"(month, index) in months\"\n            :key=\"index\"\n            type=\"button\"\n            class=\"flex items-center justify-center rounded-lg py-2 text-center\"\n            :class=\"[\n              activeMonth === index\n                ? variantStyling.background\n                : 'hover:bg-gray-100 dark:hover:bg-gray-700',\n            ]\"\n            @click=\"\n              () => {\n                setMonth(index);\n                hideMonthSelection();\n              }\n            \"\n          >\n            {{ month.title }}\n          </button>\n        </div>\n\n        <div\n          v-if=\"showYearSelectionActive\"\n          class=\"absolute inset-0 z-10 flex flex-col gap-2 overflow-y-auto\"\n        >\n          <button\n            v-for=\"year in yearSelectionYears\"\n            :ref=\"(ref) => (refYearEntry[year] = ref)\"\n            :key=\"year\"\n            type=\"button\"\n            class=\"rounded-lg py-2 text-center tabular-nums\"\n            :class=\"[\n              activeYear === year\n                ? variantStyling.background\n                : 'hover:bg-gray-100 dark:hover:bg-gray-700',\n            ]\"\n            :data-year=\"year\"\n            @click=\"\n              () => {\n                setYear(year);\n                hideYearSelection();\n              }\n            \"\n          >\n            {{ year }}\n          </button>\n        </div>\n\n        <div\n          class=\"grid grid-cols-7 gap-y-1\"\n          :class=\"[\n            {\n              'opacity-0': showMonthSelectionActive || showYearSelectionActive,\n            },\n          ]\"\n        >\n          <div\n            v-for=\"(day, idx) in getDayNames()\"\n            :key=\"idx\"\n            class=\"pb-2 text-center text-sm text-gray-400 dark:text-gray-400\"\n          >\n            {{ day.charAt(0).toUpperCase() }}\n          </div>\n          <div v-for=\"offset in firstWeekday\" :key=\"offset + '_offset'\"></div>\n          <button\n            v-for=\"day in daysInMonth\"\n            :key=\"day + '_day'\"\n            type=\"button\"\n            class=\"relative\"\n            :disabled=\"!dayAllowed(day)\"\n            :class=\"[isBetweenRange(day) ? variantStyling.background : '']\"\n            @click=\"daySelect(day)\"\n            @mouseover=\"dayHover(day)\"\n          >\n            <div\n              v-if=\"isLast(day) || isFirst(day)\"\n              class=\"absolute z-0 h-full\"\n              :class=\"[\n                variantStyling.background,\n                isFirst(day)\n                  ? 'right-0 w-1/2'\n                  : isLast(day)\n                    ? 'left-0 w-1/2'\n                    : '',\n              ]\"\n            ></div>\n            <div\n              class=\"relative z-10 flex h-8 w-8 min-w-8 items-center justify-center rounded-lg text-sm font-medium tabular-nums\"\n              :class=\"[\n                isBetweenRange(day) ||\n                isLast(day) ||\n                isFirst(day) ||\n                isSelectedDay(day)\n                  ? `rounded-0 ${variantStyling.background}`\n                  : 'hover:bg-gray-100 dark:hover:bg-white/5',\n              ]\"\n            >\n              {{ day }}\n            </div>\n          </button>\n        </div>\n      </div>\n      <div v-else class=\"flex gap-x-4 relative\">\n        <div\n          v-if=\"showMonthSelectionActive\"\n          class=\"absolute inset-0 z-10 top-10 grid grid-cols-3 gap-4\"\n        >\n          <button\n            v-for=\"(month, index) in months\"\n            :key=\"index\"\n            type=\"button\"\n            class=\"flex items-center justify-center rounded-lg py-2 text-center\"\n            :class=\"[\n              activeMonth === index\n                ? variantStyling.background\n                : 'hover:bg-gray-100 dark:hover:bg-gray-700',\n            ]\"\n            @click=\"\n              () => {\n                setMonth(index);\n                hideMonthSelection();\n              }\n            \"\n          >\n            {{ month.title }}\n          </button>\n        </div>\n\n        <div\n          v-if=\"showYearSelectionActive\"\n          class=\"absolute inset-0 z-10 top-10 flex flex-col gap-2 overflow-y-auto\"\n        >\n          <button\n            v-for=\"year in yearSelectionYears\"\n            :ref=\"(ref) => (refYearEntry[year] = ref)\"\n            :key=\"year\"\n            type=\"button\"\n            class=\"rounded-lg py-2 text-center tabular-nums\"\n            :class=\"[\n              activeYear === year\n                ? variantStyling.background\n                : 'hover:bg-gray-100 dark:hover:bg-gray-700',\n            ]\"\n            :data-year=\"year\"\n            @click=\"\n              () => {\n                setYear(year);\n                hideYearSelection();\n              }\n            \"\n          >\n            {{ year }}\n          </button>\n        </div>\n        <div>\n          <div class=\"mb-4 flex items-center text-center text-lg font-semibold\">\n            <div class=\"flex flex-1\">\n              <button\n                v-if=\"!fixed\"\n                type=\"button\"\n                class=\"flex h-8 w-8 items-center justify-center rounded-lg text-gray-800 hover:bg-gray-100 hover:text-gray-800 active:bg-gray-100 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-100\"\n                @click=\"subMonth\"\n              >\n                <PhCaretLeft type=\"chevron-left\" size=\"14\" weight=\"bold\" />\n              </button>\n              <div v-if=\"!fixed\" class=\"flex flex-1 justify-center mr-8\">\n                <button\n                  type=\"button\"\n                  class=\"flex h-8 items-center rounded-lg px-2 tabular-nums hover:bg-gray-100 dark:hover:bg-white/5\"\n                  @click=\"\n                    () => {\n                      showMonthSelection();\n                      hideYearSelection();\n                    }\n                  \"\n                >\n                  {{ monthHeading[0] }}\n                </button>\n                <button\n                  type=\"button\"\n                  class=\"flex h-8 items-center rounded-lg px-2 tabular-nums hover:bg-gray-100 dark:hover:bg-white/5\"\n                  @click=\"\n                    () => {\n                      showYearSelection();\n                      hideMonthSelection();\n                    }\n                  \"\n                >\n                  {{ yearHeading[0] }}\n                </button>\n              </div>\n              <div v-else class=\"flex flex-1 justify-center mr-8\">\n                <div v-if=\"title\" class=\"h-8 items-center px-2 tabular-nums\">\n                  {{ title }}\n                </div>\n                <div v-else class=\"flex\">\n                  <div class=\"h-8 px-2 tabular-nums\">\n                    {{ monthHeading[0] }}\n                  </div>\n                  <div class=\"h-8 px-2 tabular-nums\">\n                    {{ yearHeading[0] }}\n                  </div>\n                </div>\n              </div>\n            </div>\n          </div>\n          <div\n            class=\"grid grid-cols-7 gap-y-1\"\n            :class=\"[\n              {\n                'opacity-0':\n                  showMonthSelectionActive || showYearSelectionActive,\n              },\n            ]\"\n          >\n            <div\n              v-for=\"(day, idx) in getDayNames()\"\n              :key=\"idx\"\n              class=\"pb-2 text-center text-sm text-gray-400 dark:text-gray-400\"\n            >\n              {{ day.charAt(0).toUpperCase() }}\n            </div>\n            <div\n              v-for=\"offset in firstWeekday[0]\"\n              :key=\"offset + '_offset'\"\n            ></div>\n            <button\n              v-for=\"day in daysInMonth[0]\"\n              :key=\"day.display + '_day'\"\n              type=\"button\"\n              class=\"relative\"\n              :disabled=\"!dayAllowed(day)\"\n              :class=\"[isBetweenRange(day) ? variantStyling.background : '']\"\n              @click=\"daySelect(day)\"\n              @mouseover=\"dayHover(day)\"\n            >\n              <div\n                v-if=\"isLast(day) || isFirst(day)\"\n                class=\"absolute z-0 h-full\"\n                :class=\"[\n                  variantStyling.background,\n                  isFirst(day)\n                    ? 'right-0 w-1/2'\n                    : isLast(day)\n                      ? 'left-0 w-1/2'\n                      : '',\n                ]\"\n              ></div>\n              <div\n                class=\"relative z-10 flex h-8 w-8 min-w-8 items-center justify-center rounded-lg text-sm font-medium tabular-nums\"\n                :class=\"[\n                  isBetweenRange(day) ||\n                  isLast(day) ||\n                  isFirst(day) ||\n                  isSelectedDay(day)\n                    ? `rounded-0 ${variantStyling.background}`\n                    : 'hover:bg-gray-100 dark:hover:bg-white/5',\n                ]\"\n              >\n                {{ day.display }}\n              </div>\n            </button>\n          </div>\n        </div>\n        <div>\n          <div class=\"mb-4 flex items-center text-center text-lg font-semibold\">\n            <div class=\"flex flex-1\">\n              <div v-if=\"!fixed\" class=\"flex flex-1 justify-center ml-8\">\n                <button\n                  type=\"button\"\n                  class=\"flex h-8 items-center rounded-lg px-2 tabular-nums hover:bg-gray-100 dark:hover:bg-white/5\"\n                  @click=\"\n                    () => {\n                      showMonthSelection();\n                      hideYearSelection();\n                    }\n                  \"\n                >\n                  {{ monthHeading[1] }}\n                </button>\n                <button\n                  type=\"button\"\n                  class=\"flex h-8 items-center rounded-lg px-2 tabular-nums hover:bg-gray-100 dark:hover:bg-white/5\"\n                  @click=\"\n                    () => {\n                      showYearSelection();\n                      hideMonthSelection();\n                    }\n                  \"\n                >\n                  {{ yearHeading[1] }}\n                </button>\n              </div>\n              <div v-else class=\"flex flex-1 justify-center ml-8\">\n                <div v-if=\"title\" class=\"h-8 items-center px-2 tabular-nums\">\n                  {{ title }}\n                </div>\n                <div v-else class=\"flex\">\n                  <div class=\"h-8 px-2 tabular-nums\">\n                    {{ monthHeading[1] }}\n                  </div>\n                  <div class=\"h-8 px-2 tabular-nums\">\n                    {{ yearHeading[1] }}\n                  </div>\n                </div>\n              </div>\n              <button\n                v-if=\"!fixed\"\n                type=\"button\"\n                class=\"flex h-8 w-8 items-center justify-center rounded-lg text-gray-800 hover:bg-gray-100 hover:text-gray-800 active:bg-gray-100 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-100\"\n                @click=\"addMonth\"\n              >\n                <PhCaretRight type=\"chevron-right\" size=\"14\" weight=\"bold\" />\n              </button>\n            </div>\n          </div>\n          <div\n            class=\"grid grid-cols-7 gap-y-1\"\n            :class=\"[\n              {\n                'opacity-0':\n                  showMonthSelectionActive || showYearSelectionActive,\n              },\n            ]\"\n          >\n            <div\n              v-for=\"(day, idx) in getDayNames()\"\n              :key=\"idx\"\n              class=\"pb-2 text-center text-sm text-gray-400 dark:text-gray-400\"\n            >\n              {{ day.charAt(0).toUpperCase() }}\n            </div>\n            <div\n              v-for=\"offset in firstWeekday[1]\"\n              :key=\"offset + '_offset'\"\n            ></div>\n            <button\n              v-for=\"day in daysInMonth[1]\"\n              :key=\"day + '_day'\"\n              type=\"button\"\n              class=\"relative\"\n              :disabled=\"!dayAllowed(day)\"\n              :class=\"[isBetweenRange(day) ? variantStyling.background : '']\"\n              @click=\"daySelect(day)\"\n              @mouseover=\"dayHover(day)\"\n            >\n              <div\n                v-if=\"isLast(day) || isFirst(day)\"\n                class=\"absolute z-0 h-full\"\n                :class=\"[\n                  variantStyling.background,\n                  isFirst(day)\n                    ? 'right-0 w-1/2'\n                    : isLast(day)\n                      ? 'left-0 w-1/2'\n                      : '',\n                ]\"\n              ></div>\n              <div\n                class=\"relative z-10 flex h-8 w-8 min-w-8 items-center justify-center rounded-lg text-sm font-medium tabular-nums\"\n                :class=\"[\n                  isBetweenRange(day) ||\n                  isLast(day) ||\n                  isFirst(day) ||\n                  isSelectedDay(day)\n                    ? `rounded-0 ${variantStyling.background}`\n                    : 'hover:bg-gray-100 dark:hover:bg-white/5',\n                ]\"\n              >\n                {{ day.display }}\n              </div>\n            </button>\n          </div>\n        </div>\n      </div>\n    </section>\n  </div>\n</template>\n"],"names":["props","__props","emit","__emit","future","past","today","modelValue","presets","currentPreset","filters","currentFilter","multiplePeriod","fixed","title","cursorMonth","cursorYear","dualCalendar","presetReferenceDate","readOnly","toRefs","now","ref","cursor","selectedDate","refYearEntry","variantStyling","computed","variants","filtersOptions","mappedFilters","filter","daysInMonth","date","dateMonthDays","getDaysInMonth","secondMonth","secondMonthDays","mappedMonth","mapDaysInMonth","mappedSecondMonth","monthHeading","formattedMonth","format","yearHeading","firstWeekday","dateSecondMonth","day","daySecondMonth","activeMonth","activeYear","formatDateToUTC","newDate","days","month","year","compareDates","dateOne","dateTwo","diff","dayDiff","d1","d2","endDate","startDate","isFirst","period","values","tmpDate","minDate","min","isLast","maxDate","max","isBetweenRange","isSelectedDay","selectedDates","i","isSameDay","setQuickAction","preset","presetValue","addYear","addYears","subYear","subYears","setYear","setFnsYear","addMonth","addMonths","subMonth","subMonths","setMonth","setFnsMonth","isPast","isBefore","isFuture","isAfter","dayAllowed","dayHover","daySelect","newModelValue","reset","onMounted","yearSelectionYears","years","showMonthSelectionActive","showMonthSelection","hideMonthSelection","showYearSelectionActive","showYearSelection","nextTick","hideYearSelection","capitalize","str","getShortMonthName","formatter","objDate","getDayNames","eachDayOfInterval","addDays","startOfWeek","endOfWeek","months","getPresetStyle","changeFilter","foundFilter","filterObj","__expose"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,UAAMA,IAAQC,GA+ERC,IAAOC,IAQP;AAAA,MACJ,QAAAC;AAAA,MACA,MAAAC;AAAA,MACA,OAAAC;AAAA,MACA,YAAAC;AAAA,MACA,SAAAC;AAAA,MACA,QAAQC;AAAA,MACR,SAAAC;AAAA,MACA,QAAQC;AAAA,MACR,gBAAAC;AAAA,MACA,OAAAC;AAAA,MACA,OAAAC;AAAA,MACA,aAAAC;AAAA,MACA,YAAAC;AAAA,MACA,cAAAC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