import { ref, watch } from 'vue';
import { makeList } from '../utils.mjs';

const makeAvailableArr = (disabledList) => {
  const trueOrNumber = (isDisabled, index) => isDisabled || index;
  const getNumber = (predicate) => predicate !== true;
  return disabledList.map(trueOrNumber).filter(getNumber);
};
const getTimeLists = (disabledHours, disabledMinutes, disabledSeconds, acrossDays) => {
  const getHoursList = (role, compare, isSameDate) => {
    return makeList(acrossDays ? 48 : 24, disabledHours && (() => disabledHours == null ? void 0 : disabledHours(role, compare, isSameDate)));
  };
  const getMinutesList = (hour, role, compare, isSameDate) => {
    return makeList(60, !isSameDate && role === "start" ? () => [] : disabledMinutes && (() => disabledMinutes == null ? void 0 : disabledMinutes(hour, role, compare)));
  };
  const getSecondsList = (hour, minute, role, compare, isSameDate) => {
    return makeList(60, !isSameDate ? () => [] : disabledSeconds && (() => disabledSeconds == null ? void 0 : disabledSeconds(hour, minute, role, compare)));
  };
  return {
    getHoursList,
    getMinutesList,
    getSecondsList
  };
};
const buildAvailableTimeSlotGetter = (disabledHours, disabledMinutes, disabledSeconds) => {
  const { getHoursList, getMinutesList, getSecondsList } = getTimeLists(disabledHours, disabledMinutes, disabledSeconds);
  const getAvailableHours = (role, compare) => {
    return makeAvailableArr(getHoursList(role, compare));
  };
  const getAvailableMinutes = (hour, role, compare, isSameDate) => {
    return makeAvailableArr(getMinutesList(hour, role, compare, isSameDate));
  };
  const getAvailableSeconds = (hour, minute, role, compare) => {
    return makeAvailableArr(getSecondsList(hour, minute, role, compare));
  };
  return {
    getAvailableHours,
    getAvailableMinutes,
    getAvailableSeconds
  };
};
const useOldValue = (props) => {
  const oldValue = ref(props.parsedValue);
  watch(() => props.visible, (val) => {
    if (val) {
      oldValue.value = props.parsedValue;
    }
  });
  return oldValue;
};

export { buildAvailableTimeSlotGetter, getTimeLists, useOldValue };
//# sourceMappingURL=use-time-picker.mjs.map
