import { memo, createElement } from "react";
import { FieldContainer, Stack } from "@contember/ui";
import { CreateNewEntityButton } from "../helpers/CreateNewEntityButton.js";
import { AccessorErrors } from "../../errors/AccessorErrors.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__ */ createElement(FieldContainer, {
    label,
    useLabelElement: false
  }, /* @__PURE__ */ createElement(Stack, {
    direction: "vertical",
    gap: "small"
  }, /* @__PURE__ */ createElement(AccessorErrors, {
    accessor
  }), isEmpty && /* @__PURE__ */ createElement(EmptyMessage, {
    component: emptyMessageComponent
  }, formatMessage(emptyMessage, "repeater.emptyMessage.text")), isEmpty || children, enableAddingNew && /* @__PURE__ */ createElement(AddButton, {
    ...addButtonComponentExtraProps,
    ...addButtonProps,
    createNewEntity
  }, addButtonText ?? label ?? formatMessage("repeater.addButton.text"))));
});
RepeaterFieldContainer.displayName = "RepeaterFieldContainer";
export { RepeaterFieldContainer };
//# sourceMappingURL=RepeaterFieldContainer.js.map
