import { useRef as s, useEffect as u } from "../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import i from "../useComponentTiming.js";
import a from "../../core/Context/analytics/preact/useAnalyticsContext.js";
const d = (t) => {
  const { duration: n } = i(), o = a(), r = s(t);
  u(() => {
    r.current = t;
  }, [t]), u(() => {
    const e = n;
    return () => {
      e.current !== void 0 && o.addEvent?.("Duration", {
        ...r.current,
        duration: Math.floor(e.current)
      });
    };
  }, [n, o]);
};
export {
  d as useDurationEvent
};
