import { jsx, jsxs } from "react/jsx-runtime";
import { FieldContainer, Stack } from "@contember/ui";
import { memo } from "react";
import { AccessorErrors } from "../../errors/AccessorErrors.js";
import { CreateNewEntityButton } from "../helpers/CreateNewEntityButton.js";
import { EmptyMessage } from "../helpers/EmptyMessage.js";
const RepeaterFieldContainer = memo(
  ({
    accessor,
    addButtonText,
    children,
    createNewEntity,
    addButtonComponent: AddButton = CreateNewEntityButton,
    addButtonComponentExtraProps,
    addButtonProps,
    emptyMessage,
    emptyMessageComponent,
    enableAddingNew = true,
    formatMessage,
    isEmpty,
    label
  }) => {
    return /* @__PURE__ */ jsx(FieldContainer, { label, useLabelElement: false, children: /* @__PURE__ */ jsxs(
      Stack,
      {
        direction: "vertical",
        gap: "small",
        children: [
          /* @__PURE__ */ jsx(AccessorErrors, { accessor }),
          isEmpty && /* @__PURE__ */ jsx(EmptyMessage, { component: emptyMessageComponent, children: formatMessage(emptyMessage, "repeater.emptyMessage.text") }),
          isEmpty || children,
          enableAddingNew && /* @__PURE__ */ jsx(
            AddButton,
            {
              ...addButtonComponentExtraProps,
              ...addButtonProps,
              createNewEntity,
              children: addButtonText ?? label ?? formatMessage("repeater.addButton.text")
            }
          )
        ]
      }
    ) });
  }
);
RepeaterFieldContainer.displayName = "RepeaterFieldContainer";
export {
  RepeaterFieldContainer
};
//# sourceMappingURL=RepeaterFieldContainer.js.map
