import { jsx as c } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useMemo as d } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { TimelineDateFormat as e } from "../types.js";
import T from "../../../../hooks/useTimezoneAwareDateFormatting.js";
import { Fragment as h } from "../../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
function g(t) {
  switch (t) {
    case e.FULL_DATE:
      return {
        year: "numeric",
        month: "short",
        day: "numeric"
      };
    case e.FULL_DATE_EXACT_TIME:
    case e.FULL_DATE_EXACT_TIME_WITHOUT_PERIOD:
      return {
        year: "numeric",
        month: "short",
        day: "numeric",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit",
        hour12: !1
      };
    case e.FULL_DATE_EXACT_TIME_WITHOUT_SECONDS:
      return {
        year: "numeric",
        month: "short",
        day: "numeric",
        hour: "2-digit",
        minute: "2-digit",
        hour12: !1
      };
    case e.SHORT_DATE:
      return {
        year: "numeric",
        month: "2-digit",
        day: "2-digit"
      };
    case e.SHORT_DATE_TIME:
      return {
        year: "numeric",
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        hour12: !1
      };
    default:
      return {
        year: "numeric",
        month: "short",
        day: "numeric",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit",
        hour12: !1
      };
  }
}
function p({ date: t, format: r, timezone: a }) {
  const { dateFormat: n } = T(a), u = d(() => {
    const o = g(r);
    return n(t, o);
  }, [t, n, r]);
  return /* @__PURE__ */ c(h, { children: u });
}
function L(t, r, a) {
  const n = t.getTime(), u = r.getTime(), o = Math.abs(n - u), s = 1e3 * 60 * 60 * 24;
  let i, m;
  switch (a.unit) {
    case "day":
      i = o / s, m = "day";
      break;
    default:
      i = o / s, m = "day";
  }
  return i = Math.round(i), { value: i, unit: m };
}
export {
  p as DateText,
  L as formatDistanceStrict
};
