import { e as usePHModal, p as useTranslation, r as reactExports, j as jsxRuntimeExports, q as showPHModal, i as closePHModal, v as clearReactorStorage, w as childLogger, s as setSelectedDrive, x as setSelectedNode } from "./index-DEuI3Aoa.js";
import { C as ConnectConfirmationModal } from "./confirmation-modal-JaOmXglG.js";
const logger = childLogger(["ClearStorage"]);
function ClearStorageModal() {
  const phModal = usePHModal();
  const open = phModal?.type === "clearStorage";
  const { t } = useTranslation();
  const [loading, setLoading] = reactExports.useState(false);
  function clearStorage() {
    setLoading(true);
    clearReactorStorage().then(() => {
      logger.info("Storage cleared");
      setSelectedDrive(void 0);
      setSelectedNode(void 0);
      window.location.reload();
    }).catch((error) => {
      logger.error("Error clearing storage", error);
      setLoading(false);
    });
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
    ConnectConfirmationModal,
    {
      open,
      header: t("modals.clearStorage.title"),
      title: t("modals.clearStorage.title"),
      body: t("modals.connectSettings.clearStorage.confirmation.body"),
      cancelLabel: t("common.cancel"),
      continueLabel: t(
        "modals.connectSettings.clearStorage.confirmation.clearButton"
      ),
      onCancel: () => showPHModal({ type: "settings" }),
      onContinue: clearStorage,
      onOpenChange: (status) => {
        if (!status) return closePHModal();
      },
      continueButtonProps: {
        disabled: loading
      }
    }
  );
}
export {
  ClearStorageModal
};
//# sourceMappingURL=ClearStorageModal-nbUdv1iA.js.map
