"use client";
import { Fragment, jsx } from "react/jsx-runtime";
import { memo, useEffect } from "react";
import { useDispatch } from "../hooks/use-dispatch";
import { useDocumentKey } from "../hooks/use-document-context";
import { useDisableRegisterElement } from "../hooks/use-disable-register-element";
import { mountComponentEffect } from "../../../state/builder-api/actions";
import { registerComponentHandleEffect } from "../../../state/actions/internal";
const ElementRegistration = memo(function ElementRegistration2({
  elementKey,
  componentHandle,
  children
}) {
  const dispatch = useDispatch();
  const documentKey = useDocumentKey();
  const isRegisterElementDisabled = useDisableRegisterElement();
  useEffect(() => {
    if (documentKey == null || isRegisterElementDisabled)
      return;
    return dispatch(registerComponentHandleEffect(documentKey, elementKey, componentHandle));
  }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
  useEffect(() => {
    if (documentKey == null || isRegisterElementDisabled)
      return;
    return dispatch(mountComponentEffect(documentKey, elementKey));
  }, [dispatch, documentKey, elementKey, isRegisterElementDisabled]);
  return /* @__PURE__ */ jsx(Fragment, { children });
});
export {
  ElementRegistration
};
//# sourceMappingURL=ElementRegistration.js.map