// packages/block-library/src/form-submission-notification/edit.js
import { __ } from "@wordpress/i18n";
import {
  InnerBlocks,
  useBlockProps,
  useInnerBlocksProps,
  store as blockEditorStore
} from "@wordpress/block-editor";
import { useSelect } from "@wordpress/data";
import clsx from "clsx";
import { jsx } from "react/jsx-runtime";
var TEMPLATE = [
  [
    "core/paragraph",
    {
      content: __(
        "Enter the message you wish displayed for form submission error/success, and select the type of the message (success/error) from the block's options."
      )
    }
  ]
];
var Edit = ({ attributes, clientId }) => {
  const { type } = attributes;
  const blockProps = useBlockProps({
    className: clsx("wp-block-form-submission-notification", {
      [`form-notification-type-${type}`]: type
    })
  });
  const { hasInnerBlocks } = useSelect(
    (select) => {
      const { getBlock } = select(blockEditorStore);
      const block = getBlock(clientId);
      return {
        hasInnerBlocks: !!(block && block.innerBlocks.length)
      };
    },
    [clientId]
  );
  const innerBlocksProps = useInnerBlocksProps(blockProps, {
    template: TEMPLATE,
    renderAppender: hasInnerBlocks ? void 0 : InnerBlocks.ButtonBlockAppender
  });
  return /* @__PURE__ */ jsx(
    "div",
    {
      ...innerBlocksProps,
      "data-message-success": __("Submission success notification"),
      "data-message-error": __("Submission error notification")
    }
  );
};
var edit_default = Edit;
export {
  edit_default as default
};
//# sourceMappingURL=edit.js.map
