import { DataBindingProvider, EntitySubTree } from "@contember/binding";
import { memo } from "react";
import { useOnPersistSuccess } from "../useOnPersistSuccess.js";
import { NotFoundWrapper } from "./NotFoundWrapper.js";
import { getPageName } from "./getPageName.js";
import { jsx } from "react/jsx-runtime";
import { FeedbackRenderer } from "../../bindingFacade/renderers/FeedbackRenderer.js";
import { LayoutRenderer } from "../../bindingFacade/renderers/LayoutRenderer.js";
import { PersistButton } from "../../bindingFacade/buttons/PersistButton.js";
const EditPage = memo(({
  pageName,
  children,
  rendererProps,
  redirectOnSuccess,
  onPersistSuccess,
  refreshDataBindingOnPersist,
  skipBindingStateUpdateAfterPersist,
  ...entityProps
}) => /* @__PURE__ */ jsx(DataBindingProvider, {
  stateComponent: FeedbackRenderer,
  refreshOnPersist: refreshDataBindingOnPersist ?? true,
  skipStateUpdateAfterPersist: skipBindingStateUpdateAfterPersist,
  children: /* @__PURE__ */ jsx(EntitySubTree, {
    ...entityProps,
    onPersistSuccess: useOnPersistSuccess({
      redirectOnSuccess,
      onPersistSuccess
    }),
    children: /* @__PURE__ */ jsx(NotFoundWrapper, {
      title: rendererProps?.title,
      children: /* @__PURE__ */ jsx(LayoutRenderer, {
        ...rendererProps,
        actions: rendererProps?.actions ?? /* @__PURE__ */ jsx(PersistButton, {}),
        children
      })
    })
  })
}));
EditPage.displayName = "EditPage";
EditPage.getPageName = getPageName;
export {
  EditPage
};
//# sourceMappingURL=EditPage.js.map
