import { jsx, jsxs } from "react/jsx-runtime";
import { useDesugaredRelativeSingleField } from "@contember/binding";
import { ButtonGroup, Button } from "@contember/ui";
import { memo } from "react";
const AddNewBlockButtonInner = memo((props) => {
  const desugaredDiscriminationField = useDesugaredRelativeSingleField(props.discriminationField);
  return /* @__PURE__ */ jsx(ButtonGroup, { orientation: "vertical", children: Array.from(props.normalizedBlocks.values(), ({ discriminateBy, datum: blockProps }, i) => /* @__PURE__ */ jsxs(
    Button,
    {
      distinction: "seamless",
      flow: "generousBlock",
      disabled: props.isMutating,
      onClick: () => {
        props.requestClose();
        const targetValue = discriminateBy;
        props.createNewEntity((getNewlyAdded) => {
          const discriminationField = getNewlyAdded().getRelativeSingleField(desugaredDiscriminationField);
          discriminationField.updateValue(targetValue);
        });
      },
      children: [
        !!blockProps.description && /* @__PURE__ */ jsxs("span", { children: [
          blockProps.label,
          /* @__PURE__ */ jsx("br", {}),
          /* @__PURE__ */ jsx("small", { children: blockProps.description })
        ] }),
        !blockProps.description && blockProps.label
      ]
    },
    i
  )) });
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
export {
  AddNewBlockButtonInner
};
//# sourceMappingURL=AddNewBlockButtonInner.js.map
