import { useCallback as c } from "../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import a from "../useMutation/useMutation.js";
import { encodeAnalyticsEvent as i } from "../../core/Analytics/analytics/utils.js";
import { useConfigContext as m } from "../../core/ConfigContext/preact/context.js";
import { EMPTY_OBJECT as p } from "../../utils/value/constants.js";
const E = () => {
  const { sendTrackEvent: s } = m().endpoints, { mutate: o } = a({
    queryFn: s
  }), n = c(
    (t, e) => o?.(
      {
        body: t.toString(),
        contentType: "application/x-www-form-urlencoded",
        keepalive: !0
      },
      {
        ...e ? {
          query: {
            component: e
          }
        } : p
      }
    ),
    [o]
  );
  return c(
    (t) => {
      const e = t.properties.componentName, r = i(t);
      r && n(r, e);
    },
    [n]
  );
};
export {
  E as usePushAnalyticEvent
};
