import { useRef as c, useMemo as o, useEffect as m } from "../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import f from "./useUniqueId.js";
import l from "../core/Context/preact/useCoreContext.js";
import { EMPTY_OBJECT as E } from "../utils/value/constants.js";
var b = /* @__PURE__ */ ((e) => (e[e.TITLE = 1] = "TITLE", e[e.SUBTITLE = 2] = "SUBTITLE", e))(b || {});
const L = ({ headingType: e = 1, forwardedToRoot: u } = E) => {
  const { componentRef: a } = l(), s = `heading-${f()}`, i = c(null), t = o(() => {
    switch (e) {
      case 1:
        return "aria-labeledby";
      case 2:
        return "aria-describedby";
    }
  }, [e]);
  return m(() => {
    if (u === !1) return;
    const r = a(), n = i.current?.id;
    if (n && r)
      return r.setAttribute(t, n), () => {
        r.getAttribute(t) === n && r.removeAttribute(t);
      };
  }, [t, u, s]), { id: s, ref: i };
};
export {
  b as ComponentHeadingType,
  L as default,
  L as useComponentHeadingElement
};
