import { jsx, Fragment, jsxs } from "react/jsx-runtime";
import { Component } from "@contember/react-binding";
import { AddNewBlockButton } from "./AddNewBlockButton.js";
import { SortableBlock } from "./SortableBlock.js";
import { useNormalizedBlocks } from "../../blocks/useNormalizedBlocks.js";
import { Repeater } from "../Repeater/Repeater.js";
import { DiscriminatedBlocks } from "../../blocks/DiscriminatedBlocks.js";
const BlockRepeater = Component(
  ({ discriminationField, ...props }) => {
    const normalizedBlocks = useNormalizedBlocks(props.children);
    const extraProps = {
      normalizedBlocks,
      discriminationField
    };
    return /* @__PURE__ */ jsx(
      Repeater,
      {
        ...props,
        addButtonComponent: AddNewBlockButton,
        addButtonComponentExtraProps: extraProps,
        itemComponent: SortableBlock,
        itemComponentExtraProps: extraProps,
        children: /* @__PURE__ */ jsx(Fragment, {})
      }
    );
  },
  (props) => /* @__PURE__ */ jsxs(Repeater, { ...props, initialEntityCount: 0, children: [
    typeof props.discriminationField === "string" && /* @__PURE__ */ jsx(DiscriminatedBlocks, { field: props.discriminationField, label: props.label, children: props.children }),
    typeof props.discriminationField === "string" || /* @__PURE__ */ jsx(DiscriminatedBlocks, { ...props.discriminationField, label: props.label, children: props.children })
  ] }),
  "SortableBlockRepeater"
);
export {
  BlockRepeater
};
//# sourceMappingURL=BlockRepeater.js.map
