import { E as compilerRuntimeExports, r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DYNCg6N5.js";
import { S as SelectQuotas } from "./index-BoQKW1g7.js";
import { S as SectionTemplate } from "./index-CbTPqI7c.js";
import { c as useAppSelector, bT as isAdmin } from "./index-DfebxkL9.js";
import "./options-CRIRDAK6.js";
import "./index-leRPH4yM.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import "./index.es-BTZFX8B-.js";
import "./index-C-CFogWu.js";
import "./index-3c9En-DB.js";
import { g as getValidateErrors } from "./validation-Ds00Zghx.js";
import "./date-bOIw2uwV.js";
import { u as useUpdateInfo, a as ProfileUpdateTypeEnum, P as ProfileSectionEnum } from "./useUpdateUser-innD962A.js";
import "./papaparse.min-Ds9XhCoe.js";
import { E as EditUserInfoContext } from "./index-TL41xEJi.js";
import { e as validateSchemeDataStorageQuota } from "./validate-Bw-sUlFj.js";
import "./ru-Bush41s2.js";
import "./index-CfN7Ll0p.js";
import "./index-CUcivY9l.js";
import "./passwordUtils-B3CN2t6O.js";
import "./index-DnphFLKH.js";
import "./index-C2HWmCvh.js";
import { z as useForm, a0 as SimpleGrid, a4 as Select, B as Button, V as LoadingOverlay } from "./vendor-mantine-h0WlM2Mj.js";
import "./errorIcon-PZO0f1IY.js";
import "./vendor-icons-xWhXK_Ui.js";
import "./format-CMT-x-V3.js";
import "./index-C6QQOvbB.js";
import "./index-CcqTjOWY.js";
import "./useDebounce-DTubzIUC.js";
import "./index-C_Fw_IUU.js";
import "./index-_NgMYV3i.js";
import "./index-D4BAIihc.js";
import "./useCopyToClipboard-C-S2RacD.js";
import "./useTerminateSessions-Cb3ukMTY.js";
import "./index-DqcA8P_y.js";
import "./styles-3NoIlzov.js";
import "./index-DMTgSMwy.js";
import "./index-DFEP7Sv_.js";
import "./index-woYEqWvh.js";
import "./index-Ds4Bnwmy.js";
import "./types-espwwxTQ.js";
import "./index-B7nmdYVM.js";
import "./utils-D5kCyTRM.js";
import "./types-B9VC9FeZ.js";
import "./useGeneratePolicy-B4rO5xUa.js";
import "./index-BvQfhnV_.js";
import "./styles-C9HVNQJ0.js";
import "./index-72JBTuLT.js";
import "./index-CslanKI5.js";
import "./styles-Dnu4P1Zm.js";
import "./index-BWhdniX1.js";
const DiskData = () => {
  var _a;
  const $ = compilerRuntimeExports.c(45);
  const {
    t
  } = useTranslation();
  const {
    isLimitedAccess,
    userInfoCommon,
    currentId
  } = reactExports.useContext(EditUserInfoContext);
  const currentUser = useAppSelector(_temp);
  const {
    Quota,
    Customer
  } = userInfoCommon;
  const {
    saveUpdate,
    isLoading
  } = useUpdateInfo();
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = {
      Name: "",
      Id: null
    };
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== t) {
    t1 = {
      initialValues: t0,
      validateInputOnChange: true,
      validate: (values) => getValidateErrors(validateSchemeDataStorageQuota(t), values)
    };
    $[1] = t;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const userQuotaForm = useForm(t1);
  const errors = userQuotaForm.errors;
  let t2;
  if ($[3] !== userQuotaForm) {
    t2 = userQuotaForm.isDirty();
    $[3] = userQuotaForm;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const isDirtyForm = t2;
  let t3;
  if ($[5] !== errors || $[6] !== isDirtyForm) {
    t3 = Object.keys(errors).length !== 0 || !isDirtyForm;
    $[5] = errors;
    $[6] = isDirtyForm;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  const isDisabled = t3;
  const t4 = (Quota == null ? void 0 : Quota.Name) || "";
  const t5 = (Quota == null ? void 0 : Quota.Id) || null;
  let t6;
  if ($[8] !== t4 || $[9] !== t5) {
    t6 = {
      Name: t4,
      Id: t5
    };
    $[8] = t4;
    $[9] = t5;
    $[10] = t6;
  } else {
    t6 = $[10];
  }
  const fromData = t6;
  let t7;
  if ($[11] !== fromData || $[12] !== userQuotaForm) {
    t7 = () => {
      userQuotaForm.setValues(fromData);
      userQuotaForm.resetDirty(fromData);
    };
    $[11] = fromData;
    $[12] = userQuotaForm;
    $[13] = t7;
  } else {
    t7 = $[13];
  }
  let t8;
  if ($[14] !== Quota) {
    t8 = [Quota];
    $[14] = Quota;
    $[15] = t8;
  } else {
    t8 = $[15];
  }
  reactExports.useEffect(t7, t8);
  let t9;
  if ($[16] !== currentId || $[17] !== saveUpdate) {
    t9 = async (values_0) => {
      await saveUpdate({
        Type: ProfileUpdateTypeEnum.Quota,
        Data: {
          [ProfileSectionEnum.Quota]: !(values_0 == null ? void 0 : values_0.Id) ? null : values_0,
          Id: currentId
        }
      });
    };
    $[16] = currentId;
    $[17] = saveUpdate;
    $[18] = t9;
  } else {
    t9 = $[18];
  }
  const handleSubmit = t9;
  let t10;
  if ($[19] !== handleSubmit || $[20] !== userQuotaForm) {
    t10 = userQuotaForm.onSubmit(handleSubmit);
    $[19] = handleSubmit;
    $[20] = userQuotaForm;
    $[21] = t10;
  } else {
    t10 = $[21];
  }
  let t11;
  if ($[22] !== t) {
    t11 = t("profile.retentionPolicy");
    $[22] = t;
    $[23] = t11;
  } else {
    t11 = $[23];
  }
  let t12;
  if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
    t12 = {
      base: 1,
      xs: 2
    };
    $[24] = t12;
  } else {
    t12 = $[24];
  }
  let t13;
  if ($[25] !== (Customer == null ? void 0 : Customer.Id) || $[26] !== (Quota == null ? void 0 : Quota.Id) || $[27] !== isLimitedAccess || $[28] !== t || $[29] !== userQuotaForm) {
    t13 = /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleGrid, { cols: t12, w: "100%", children: isLimitedAccess ? /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { data: [{
      value: ((_a = userQuotaForm.values.Id) == null ? void 0 : _a.toString()) || "",
      label: userQuotaForm.values.Name || t("profile.noQuota")
    }], value: `${(Quota == null ? void 0 : Quota.Id) || ""}`, readOnly: true, sx: {
      width: "100%"
    }, disabled: true }) : /* @__PURE__ */ jsxRuntimeExports.jsx(SelectQuotas, { isLimitedAccess, defaultValue: userQuotaForm.values.Id, form: userQuotaForm, fieldName: "Id", quotaField: "Name", value: userQuotaForm.values.Id, QuotaName: userQuotaForm.values.Name, Customer: Customer == null ? void 0 : Customer.Id }) });
    $[25] = Customer == null ? void 0 : Customer.Id;
    $[26] = Quota == null ? void 0 : Quota.Id;
    $[27] = isLimitedAccess;
    $[28] = t;
    $[29] = userQuotaForm;
    $[30] = t13;
  } else {
    t13 = $[30];
  }
  let t14;
  if ($[31] !== currentUser || $[32] !== isDisabled || $[33] !== t) {
    t14 = isAdmin(currentUser) && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "sm", radius: 8, disabled: isDisabled, mt: "md", style: {
      padding: "0 20px"
    }, children: t("profile.save") });
    $[31] = currentUser;
    $[32] = isDisabled;
    $[33] = t;
    $[34] = t14;
  } else {
    t14 = $[34];
  }
  let t15;
  if ($[35] !== isLoading) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading });
    $[35] = isLoading;
    $[36] = t15;
  } else {
    t15 = $[36];
  }
  let t16;
  if ($[37] !== t11 || $[38] !== t13 || $[39] !== t14 || $[40] !== t15) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SectionTemplate, { title: t11, children: [
      t13,
      t14,
      t15
    ] });
    $[37] = t11;
    $[38] = t13;
    $[39] = t14;
    $[40] = t15;
    $[41] = t16;
  } else {
    t16 = $[41];
  }
  let t17;
  if ($[42] !== t10 || $[43] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx("form", { onSubmit: t10, children: t16 });
    $[42] = t10;
    $[43] = t16;
    $[44] = t17;
  } else {
    t17 = $[44];
  }
  return t17;
};
function _temp(state) {
  return state.userInfo.User;
}
export {
  DiskData as default
};
//# sourceMappingURL=index-9yT4-U2s.js.map
