// packages/block-library/src/index.js
import {
  setDefaultBlockName,
  setFreeformContentHandlerName,
  setUnregisteredTypeHandlerName,
  setGroupingBlockName,
  registerBlockType,
  store as blocksStore
} from "@wordpress/blocks";
import { select } from "@wordpress/data";
import { useBlockProps } from "@wordpress/block-editor";
import { useServerSideRender } from "@wordpress/server-side-render";
import { __, sprintf } from "@wordpress/i18n";
import * as accordion from "./accordion";
import * as accordionItem from "./accordion-item";
import * as accordionHeading from "./accordion-heading";
import * as accordionPanel from "./accordion-panel";
import * as archives from "./archives";
import * as avatar from "./avatar";
import * as audio from "./audio";
import * as breadcrumbs from "./breadcrumbs";
import * as button from "./button";
import * as buttons from "./buttons";
import * as calendar from "./calendar";
import * as categories from "./categories";
import * as classic from "./freeform";
import * as code from "./code";
import * as column from "./column";
import * as columns from "./columns";
import * as comments from "./comments";
import * as commentAuthorAvatar from "./comment-author-avatar";
import * as commentAuthorName from "./comment-author-name";
import * as commentContent from "./comment-content";
import * as commentDate from "./comment-date";
import * as commentEditLink from "./comment-edit-link";
import * as commentReplyLink from "./comment-reply-link";
import * as commentTemplate from "./comment-template";
import * as commentsPaginationPrevious from "./comments-pagination-previous";
import * as commentsPagination from "./comments-pagination";
import * as commentsPaginationNext from "./comments-pagination-next";
import * as commentsPaginationNumbers from "./comments-pagination-numbers";
import * as commentsTitle from "./comments-title";
import * as cover from "./cover";
import * as details from "./details";
import * as embed from "./embed";
import * as file from "./file";
import * as form from "./form";
import * as formInput from "./form-input";
import * as formSubmitButton from "./form-submit-button";
import * as formSubmissionNotification from "./form-submission-notification";
import * as gallery from "./gallery";
import * as group from "./group";
import * as heading from "./heading";
import * as homeLink from "./home-link";
import * as html from "./html";
import * as image from "./image";
import * as latestComments from "./latest-comments";
import * as latestPosts from "./latest-posts";
import * as list from "./list";
import * as math from "./math";
import * as listItem from "./list-item";
import * as logInOut from "./loginout";
import * as mediaText from "./media-text";
import * as missing from "./missing";
import * as more from "./more";
import * as navigation from "./navigation";
import * as navigationLink from "./navigation-link";
import * as navigationSubmenu from "./navigation-submenu";
import * as nextpage from "./nextpage";
import * as pattern from "./pattern";
import * as pageList from "./page-list";
import * as pageListItem from "./page-list-item";
import * as paragraph from "./paragraph";
import * as postAuthor from "./post-author";
import * as postAuthorName from "./post-author-name";
import * as postAuthorBiography from "./post-author-biography";
import * as postComment from "./post-comment";
import * as postCommentsCount from "./post-comments-count";
import * as postCommentsForm from "./post-comments-form";
import * as postCommentsLink from "./post-comments-link";
import * as postContent from "./post-content";
import * as postDate from "./post-date";
import * as postExcerpt from "./post-excerpt";
import * as postFeaturedImage from "./post-featured-image";
import * as postNavigationLink from "./post-navigation-link";
import * as postTemplate from "./post-template";
import * as postTerms from "./post-terms";
import * as postTimeToRead from "./post-time-to-read";
import * as postTitle from "./post-title";
import * as preformatted from "./preformatted";
import * as pullquote from "./pullquote";
import * as query from "./query";
import * as queryNoResults from "./query-no-results";
import * as queryPagination from "./query-pagination";
import * as queryPaginationNext from "./query-pagination-next";
import * as queryPaginationNumbers from "./query-pagination-numbers";
import * as queryPaginationPrevious from "./query-pagination-previous";
import * as queryTitle from "./query-title";
import * as queryTotal from "./query-total";
import * as quote from "./quote";
import * as reusableBlock from "./block";
import * as readMore from "./read-more";
import * as rss from "./rss";
import * as search from "./search";
import * as separator from "./separator";
import * as shortcode from "./shortcode";
import * as siteLogo from "./site-logo";
import * as siteTagline from "./site-tagline";
import * as siteTitle from "./site-title";
import * as socialLink from "./social-link";
import * as socialLinks from "./social-links";
import * as spacer from "./spacer";
import * as tab from "./tab";
import * as table from "./table";
import * as tableOfContents from "./table-of-contents";
import * as tabs from "./tabs";
import * as tagCloud from "./tag-cloud";
import * as templatePart from "./template-part";
import * as termCount from "./term-count";
import * as termDescription from "./term-description";
import * as termName from "./term-name";
import * as termsQuery from "./terms-query";
import * as termTemplate from "./term-template";
import * as textColumns from "./text-columns";
import * as verse from "./verse";
import * as video from "./video";
import * as footnotes from "./footnotes";
import isBlockMetadataExperimental from "./utils/is-block-metadata-experimental";
import { unlock } from "./lock-unlock";
import { privateApis } from "./private-apis";
import { jsx } from "react/jsx-runtime";
var getAllBlocks = () => {
  const blocks = [
    // Common blocks are grouped at the top to prioritize their display
    // in various contexts — like the inserter and auto-complete components.
    paragraph,
    image,
    heading,
    gallery,
    list,
    listItem,
    quote,
    // Register all remaining core blocks.
    accordion,
    accordionItem,
    accordionHeading,
    accordionPanel,
    archives,
    audio,
    button,
    buttons,
    calendar,
    categories,
    code,
    column,
    columns,
    commentAuthorAvatar,
    cover,
    details,
    embed,
    file,
    group,
    html,
    math,
    latestComments,
    latestPosts,
    mediaText,
    missing,
    more,
    nextpage,
    pageList,
    pageListItem,
    pattern,
    preformatted,
    pullquote,
    reusableBlock,
    rss,
    search,
    separator,
    shortcode,
    socialLink,
    socialLinks,
    spacer,
    table,
    tagCloud,
    textColumns,
    verse,
    video,
    footnotes,
    // theme blocks
    navigation,
    navigationLink,
    navigationSubmenu,
    siteLogo,
    siteTitle,
    siteTagline,
    query,
    templatePart,
    avatar,
    postTitle,
    postExcerpt,
    postFeaturedImage,
    postContent,
    postAuthor,
    postAuthorName,
    postComment,
    postCommentsCount,
    postCommentsLink,
    postDate,
    postTerms,
    postNavigationLink,
    postTemplate,
    postTimeToRead,
    queryPagination,
    queryPaginationNext,
    queryPaginationNumbers,
    queryPaginationPrevious,
    queryNoResults,
    queryTotal,
    readMore,
    comments,
    commentAuthorName,
    commentContent,
    commentDate,
    commentEditLink,
    commentReplyLink,
    commentTemplate,
    commentsTitle,
    commentsPagination,
    commentsPaginationNext,
    commentsPaginationNumbers,
    commentsPaginationPrevious,
    postCommentsForm,
    tableOfContents,
    homeLink,
    logInOut,
    termCount,
    termDescription,
    termName,
    termsQuery,
    termTemplate,
    queryTitle,
    postAuthorBiography
  ];
  if (window?.__experimentalEnableBlockExperiments) {
    blocks.push(breadcrumbs);
    blocks.push(tab);
    blocks.push(tabs);
  }
  if (window?.__experimentalEnableFormBlocks) {
    blocks.push(form);
    blocks.push(formInput);
    blocks.push(formSubmitButton);
    blocks.push(formSubmissionNotification);
  }
  if (window?.wp?.oldEditor && (window?.wp?.needsClassicBlock || !window?.__experimentalDisableTinymce || !!new URLSearchParams(window?.location?.search).get(
    "requiresTinymce"
  ))) {
    blocks.push(classic);
  }
  return blocks.filter(Boolean);
};
var __experimentalGetCoreBlocks = () => getAllBlocks().filter(
  ({ metadata }) => !isBlockMetadataExperimental(metadata)
);
var registerCoreBlocks = (blocks = __experimentalGetCoreBlocks()) => {
  blocks.forEach(({ init }) => init());
  if (window.__unstableAutoRegisterBlocks) {
    window.__unstableAutoRegisterBlocks.forEach((blockName) => {
      const bootstrappedBlockType = unlock(
        select(blocksStore)
      ).getBootstrappedBlockType(blockName);
      const bootstrappedApiVersion = bootstrappedBlockType.apiVersion;
      registerBlockType(blockName, {
        title: blockName,
        ...bootstrappedApiVersion < 3 && { apiVersion: 3 },
        edit: function Edit({ attributes }) {
          const blockProps = useBlockProps();
          const { content, status, error } = useServerSideRender({
            block: blockName,
            attributes
          });
          if (status === "loading") {
            return /* @__PURE__ */ jsx("div", { ...blockProps, children: __("Loading\u2026") });
          }
          if (status === "error") {
            return /* @__PURE__ */ jsx("div", { ...blockProps, children: sprintf(
              /* translators: %s: error message describing the problem */
              __("Error loading block: %s"),
              error
            ) });
          }
          return /* @__PURE__ */ jsx(
            "div",
            {
              ...blockProps,
              dangerouslySetInnerHTML: {
                __html: content || ""
              }
            }
          );
        },
        save: () => null
      });
    });
  }
  setDefaultBlockName(paragraph.name);
  if (window.wp && window.wp.oldEditor && blocks.some(({ name: name5 }) => name5 === classic.name)) {
    setFreeformContentHandlerName(classic.name);
  }
  setUnregisteredTypeHandlerName(missing.name);
  setGroupingBlockName(group.name);
};
var __experimentalRegisterExperimentalCoreBlocks = globalThis.IS_GUTENBERG_PLUGIN ? ({ enableFSEBlocks } = {}) => {
  const enabledExperiments = [enableFSEBlocks ? "fse" : null];
  getAllBlocks().filter(
    ({ metadata }) => isBlockMetadataExperimental(metadata)
  ).filter(
    ({ metadata: { __experimental } }) => __experimental === true || enabledExperiments.includes(__experimental)
  ).forEach(({ init }) => init());
} : void 0;
export {
  __experimentalGetCoreBlocks,
  __experimentalRegisterExperimentalCoreBlocks,
  privateApis,
  registerCoreBlocks
};
//# sourceMappingURL=index.js.map
