import { useMemo as m, useState as N, useRef as L, useCallback as c, useEffect as I } from "react";
import { useModuleDictionary as b } from "@m4l/core";
import { useInterval as S } from "../../../../hooks/useInterval/index.js";
import { DTNF_DICCTIONARY as e } from "../dictionary.js";
import { formatDistanceToNow as r } from "../../../../utils/formatDistanceToNow/formatDistanteToNow.js";
function D(o) {
  const { presentationTime: n = "present", date: E, delay: T } = o, { getLabel: _ } = b(), s = m(() => ({
    label_sentence_past_seconds: _(e.LABEL_SENTENCE_PAST_SECONDS),
    label_sentence_past_others: _(e.LABEL_SENTENCE_PAST_OTHERS),
    label_sentence_present_seconds: _(e.LABEL_SENTENCE_PRESENT_SECONDS),
    label_sentence_present_others: _(e.LABEL_SENTENCE_PRESENT_OTHERS),
    label_sentence_future_seconds: _(e.LABEL_SENTENCE_FUTURE_SECONDS),
    label_sentence_future_others: _(e.LABEL_SENTENCE_FUTURE_OTHERS),
    label_unit_time_second: _(e.LABEL_UNIT_TIME_SECOND),
    label_unit_time_seconds: _(e.LABEL_UNIT_TIME_SECONDS),
    label_unit_time_minute: _(e.LABEL_UNIT_TIME_MINUTE),
    label_unit_time_minutes: _(e.LABEL_UNIT_TIME_MINUTES),
    label_unit_time_hour: _(e.LABEL_UNIT_TIME_HOUR),
    label_unit_time_hours: _(e.LABEL_UNIT_TIME_HOURS),
    label_unit_time_day: _(e.LABEL_UNIT_TIME_DAY),
    label_unit_time_days: _(e.LABEL_UNIT_TIME_DAYS),
    label_unit_time_month: _(e.LABEL_UNIT_TIME_MONTH),
    label_unit_time_months: _(e.LABEL_UNIT_TIME_MONTHS),
    label_unit_time_year: _(e.LABEL_UNIT_TIME_YEAR),
    label_unit_time_years: _(e.LABEL_UNIT_TIME_YEARS),
    label_unit_time_seconds_short: "ss",
    // getLabel(DTNF_DICCTIONARY.LABEL_UNIT_TIME_SECONDS_SHORT),
    label_unit_time_minutes_short: "mm",
    // getLabel(DTNF_DICCTIONARY.LABEL_UNIT_TIME_MINUTES_SHORT),
    label_unit_time_hours_short: "hh",
    // getLabel(DTNF_DICCTIONARY.LABEL_UNIT_TIME_HOURS_SHORT),
    label_unit_time_days_short: "DD",
    // getLabel(DTNF_DICCTIONARY.LABEL_UNIT_TIME_DAYS_SHORT),
    label_unit_time_months_short: "MM",
    // getLabel(DTNF_DICCTIONARY.LABEL_UNIT_TIME_MONTHS_SHORT),
    label_unit_time_years_short: "YY",
    // getLabel(DTNF_DICCTIONARY.LABEL_UNIT_TIME_YEARS_SHORT),
    label_separator_time: ":",
    // getLabel(DTNF_DICCTIONARY.LABEL_SEPARATOR_TIME),
    label_separator_date: "-"
    // getLabel(DTNF_DICCTIONARY.LABEL_SEPARATOR_DATE),
  }), [_]), [a, u] = N(r(n, new Date(E), s)), i = L({ ...a }), l = c(() => {
    const t = r(n, new Date(E), s);
    (i.current.value !== t.value || i.current.unit !== t.unit) && (i.current = t, u(t));
  }, [E, s, n]);
  return I(() => {
    l();
  }, [l]), S(l, T), a;
}
export {
  D as useDistanceToNowFormatter
};
