import { useEditor } from "@cmpd/editor";
import { useCallback } from "react";
import { exportAs } from "../../utils/export/exportAs.mjs";
import { useToasts } from "./useToastsProvider.mjs";
import { useTranslation } from "./useTranslation/useTranslation.mjs";
function useExportAs() {
  const editor = useEditor();
  const { addToast } = useToasts();
  const msg = useTranslation();
  return useCallback(
    (ids, format = "png") => {
      exportAs(editor, ids, format, {
        scale: 1,
        background: editor.getInstanceState().exportBackground
      }).catch((e) => {
        console.error(e.message);
        addToast({
          id: "export-fail",
          // icon: 'error',
          title: msg("toast.error.export-fail.title"),
          description: msg("toast.error.export-fail.desc")
        });
      });
    },
    [editor, addToast, msg]
  );
}
export {
  useExportAs
};
//# sourceMappingURL=useExportAs.mjs.map
