import { jsxDEV } from "react/jsx-dev-runtime";
import { useMutationState, useDirtinessState } from "@contember/binding";
import { SaveButton } from "@contember/ui";
import { memo, forwardRef, useCallback } from "react";
import { usePersistWithFeedback } from "../../ui/usePersistWithFeedback.js";
const PersistButton = memo(
  forwardRef((props, ref) => {
    const isMutating = useMutationState();
    const isDirty = useDirtinessState();
    const triggerPersist = usePersistWithFeedback();
    const onClick = useCallback(() => {
      triggerPersist().catch(() => {
      });
    }, [triggerPersist]);
    const isDisabled = isMutating || !isDirty;
    if (!triggerPersist) {
      return null;
    }
    return /* @__PURE__ */ jsxDEV(
      SaveButton,
      {
        ref,
        disabled: isDisabled,
        intent: isDisabled ? "default" : props.intent,
        isDirty,
        loading: isMutating,
        onClick,
        size: "large",
        ...props
      },
      void 0,
      false,
      {
        fileName: "/__w/interface/interface/packages/admin/src/components/bindingFacade/buttons/PersistButton.tsx",
        lineNumber: 33,
        columnNumber: 3
      },
      globalThis
    );
  })
);
PersistButton.displayName = "PersistButton";
export {
  PersistButton
};
//# sourceMappingURL=PersistButton.js.map
