import { r as reactExports } from "./vendor-react-DYNCg6N5.js";
import { cP as useChangeCommonSettingsMutation, b as useActions, cQ as useLazyCommonSettingsQuery } from "./index-DfebxkL9.js";
import { s as showNotification } from "./vendor-mantine-h0WlM2Mj.js";
var ICommonSettingsEnum = /* @__PURE__ */ ((ICommonSettingsEnum2) => {
  ICommonSettingsEnum2[ICommonSettingsEnum2["Commands"] = 1] = "Commands";
  ICommonSettingsEnum2[ICommonSettingsEnum2["CommonViewSettings"] = 2] = "CommonViewSettings";
  return ICommonSettingsEnum2;
})(ICommonSettingsEnum || {});
var IFileAccessModifier = /* @__PURE__ */ ((IFileAccessModifier2) => {
  IFileAccessModifier2[IFileAccessModifier2["Public"] = 0] = "Public";
  IFileAccessModifier2[IFileAccessModifier2["Protected"] = 1] = "Protected";
  IFileAccessModifier2[IFileAccessModifier2["Private"] = 2] = "Private";
  return IFileAccessModifier2;
})(IFileAccessModifier || {});
const useSaveCommonSettings = () => {
  const [updateSettings] = useChangeCommonSettingsMutation();
  const {
    setCommonSettings
  } = useActions();
  const [getUpdatedValue] = useLazyCommonSettingsQuery();
  return reactExports.useCallback(async (Type, values) => {
    var _a, _b;
    try {
      const res = await updateSettings({
        Type,
        Data: values
      });
      if ("error" in res) {
        showNotification({
          title: `${(_b = (_a = res == null ? void 0 : res.error) == null ? void 0 : _a.data) == null ? void 0 : _b.Response.Data}`,
          message: "",
          autoClose: true,
          color: "red"
        });
      } else {
        showNotification({
          title: `Настройки успешно сохранены!`,
          message: "",
          autoClose: true,
          color: "green"
        });
        const updatedResult = await getUpdatedValue();
        if ("data" in updatedResult && updatedResult.data) {
          setCommonSettings(updatedResult.data);
        }
      }
    } catch (err) {
      console.warn("Ошибка сохранения настроек", err);
    }
  }, [updateSettings, getUpdatedValue, setCommonSettings]);
};
export {
  ICommonSettingsEnum as I,
  IFileAccessModifier as a,
  useSaveCommonSettings as u
};
//# sourceMappingURL=useSaveCommonSettings-DdirtcwG.js.map
