import { jsxDEV } from "react/jsx-dev-runtime";
import { useDesugaredRelativeSingleField } from "@contember/react-binding";
import { ButtonGroup, Button } from "@contember/ui";
import { memo } from "react";
const AddNewBlockButtonInner = memo((props) => {
  const desugaredDiscriminationField = useDesugaredRelativeSingleField(props.discriminationField);
  return /* @__PURE__ */ jsxDEV(ButtonGroup, { direction: "vertical", children: Array.from(props.normalizedBlocks.values(), ({ discriminateBy, datum: blockProps }, i) => /* @__PURE__ */ jsxDEV(
    Button,
    {
      disabled: props.isMutating,
      display: "block",
      distinction: "seamless",
      onClick: () => {
        props.requestClose();
        const targetValue = discriminateBy;
        props.createNewEntity((getNewlyAdded) => {
          const discriminationField = getNewlyAdded().getRelativeSingleField(desugaredDiscriminationField);
          discriminationField.updateValue(targetValue);
        });
      },
      padding: "padding",
      children: [
        !!blockProps.description && /* @__PURE__ */ jsxDEV("span", { children: [
          blockProps.label,
          /* @__PURE__ */ jsxDEV("br", {}, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
            lineNumber: 40,
            columnNumber: 8
          }, void 0),
          /* @__PURE__ */ jsxDEV("small", { children: blockProps.description }, void 0, false, {
            fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
            lineNumber: 41,
            columnNumber: 8
          }, void 0)
        ] }, void 0, true, {
          fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
          lineNumber: 38,
          columnNumber: 7
        }, void 0),
        !blockProps.description && blockProps.label
      ]
    },
    i,
    true,
    {
      fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
      lineNumber: 21,
      columnNumber: 5
    },
    void 0
  )) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/collections/BlockRepeater/AddNewBlockButtonInner.tsx",
    lineNumber: 19,
    columnNumber: 3
  }, void 0);
});
AddNewBlockButtonInner.displayName = "AddNewBlockButtonInner";
export {
  AddNewBlockButtonInner
};
//# sourceMappingURL=AddNewBlockButtonInner.js.map
