import { b1 as getParamColumnsOptions, b2 as defaultFieldInfo, b3 as getDateOfInt, t as React, j as jsxRuntimeExports, a3 as Tree, a6 as GridLoader, ax as SplitterLocal, b4 as updateGridData, G as Grid, aU as ContextMenu, aV as getDefaultMenu, ah as AxiosRequest, b5 as createConfirmation, a7 as TabItem, aK as LoadingMask, a9 as ContentOrganization, ab as formEdit, b6 as ApplyFilter, aw as Params } from "./index-D15x63tD.js";
function getColumns1() {
  return {
    title: [
      {
        fieldName: "Text",
        title: "Период",
        width: 200,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "2040",
          EditStyle: "17",
          options: getParamColumnsOptions(0),
          Module: "persons"
        }
      }
    ]
  };
}
function getDefaultFields1() {
  return [
    {
      Name: "ID",
      Title: "ID",
      Width: "10"
    },
    {
      Name: "UsedDate",
      Title: "Дата",
      Width: "10"
    },
    {
      Name: "Text",
      Title: "Значение",
      Width: "20"
    }
  ];
}
function getColumns2() {
  return {
    title: [
      {
        fieldName: "StartRange",
        title: "От",
        width: 70,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "6",
          options: getParamColumnsOptions(0)
        }
      },
      {
        fieldName: "EndRange",
        title: "До",
        width: 70,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "6",
          options: getParamColumnsOptions(0)
        }
      },
      {
        fieldName: "FirstDate",
        title: "Начало",
        width: 70,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "6",
          EditStyle: "2",
          options: getParamColumnsOptions(0)
        }
      },
      {
        fieldName: "Value",
        title: "Значение",
        width: 70,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "6",
          options: getParamColumnsOptions(0)
        }
      },
      {
        fieldName: "Info",
        title: "Дополнительно",
        width: 70,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "6",
          EditStyle: "16",
          options: getParamColumnsOptions(0)
        }
      },
      {
        fieldName: "LastDate",
        title: "Конец",
        width: 70,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "6",
          EditStyle: "2",
          options: getParamColumnsOptions(0)
        }
      },
      {
        fieldName: "OrgTypeClsName",
        title: "Учреждение",
        width: 100,
        fieldInfo: {
          ...defaultFieldInfo,
          DataType: "2773",
          EditStyle: "17",
          options: getParamColumnsOptions(0),
          Module: "departments"
        }
      }
    ]
  };
}
function getDefaultFields2() {
  return [
    {
      Name: "ID",
      Title: "ID",
      Width: "7"
    },
    {
      Name: "StartRange",
      title: "От",
      Width: "10"
    },
    {
      Name: "EndRange",
      title: "До",
      Width: "10"
    },
    {
      Name: "FirstDate",
      title: "Начало",
      Width: "10"
    },
    {
      Name: "Value",
      title: "Значение",
      Width: "10"
    },
    {
      Name: "Info",
      title: "Дополнительно",
      Width: "10"
    },
    {
      Name: "LastDate",
      title: "Конец",
      Width: "10"
    },
    {
      Name: "OrgTypeClsName",
      title: "Учреждение",
      Width: "10"
    },
    {
      Name: "OrgTypeCls",
      title: "OrgTypeCls",
      Width: "10"
    }
  ];
}
function getRecords1(data) {
  if (!data.items || data.items.length === 0) return [];
  return data.items.map((item, index) => {
    return { ID: `${index}`, UsedDate: item.UsedDate, Text: item.Text };
  });
}
function getGradesText(req, data) {
  const records = data.records;
  if (!records) return { Text: "" };
  const rec = records[req.RecordIndex];
  if (!rec) return { Text: "" };
  let text = rec[req.FieldName];
  return { Text: typeof text === "object" ? text.text : text };
}
function getRecords2(data, selectedRec) {
  if (!data.innerRecords || data.innerRecords.length === 0 || !data.innerRecords[selectedRec]) {
    return [];
  }
  const records = data.innerRecords[selectedRec];
  records.forEach((item) => {
    if (item.FirstDate !== void 0 && !isNaN(Number(item.FirstDate))) {
      item.FirstDate = {
        id: item.FirstDate,
        text: getDateOfInt(item.FirstDate)
      };
    }
    if (item.LastDate !== void 0 && !isNaN(Number(item.LastDate))) {
      item.LastDate = { id: item.LastDate, text: getDateOfInt(item.LastDate) };
    }
  });
  return records;
}
function GetGradeScope(GroupID, Department) {
  const params = /* @__PURE__ */ new Map();
  params.set("prefix", "grades").set("comand", "GetGradeScope").set("GroupID", GroupID).set("Department", Department);
  return AxiosRequest(true, params);
}
function GradesGrid({ props }) {
  const [tree, setTree] = React.useState();
  const [groupID, setGroupID] = React.useState(0);
  const [data, setData] = React.useState(props.data);
  const [title, setTitle] = React.useState(null);
  const [gridPeriod, setGridPeriod] = React.useState();
  const [gridData, setGridData] = React.useState();
  const [selectedRecordID1, setSelectedRecordID1] = React.useState();
  const [selectedRecordID2, setSelectedRecordID2] = React.useState();
  const gridPanel1 = React.useRef();
  const gridPanel2 = React.useRef();
  const treeRef = React.useRef();
  const localGridBox = React.useRef();
  React.useEffect(() => {
    if (props && props.data) setData(props.data);
    if (tree === void 0) setTree(null);
    localGridBox.current.update = (data2) => {
      setGroupID();
      setData(data2);
      setTree(null);
    };
  }, [props]);
  React.useEffect(() => {
    if (tree === null) {
      setTree(
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          Tree,
          {
            props: {
              Module: "grades",
              SectionID: "145",
              multiCheck: false,
              ObjType: "0",
              Current: groupID,
              ObjRef: groupID,
              selectID: setGroupID,
              UsedDate: "0",
              Info: "0",
              ref: treeRef
            }
          }
        )
      );
    }
  }, [tree]);
  React.useEffect(() => {
    if (groupID !== void 0) {
      GetGradeScope(groupID, props.data.Department).then((res) => {
        const innerRec = {};
        if (res.items && res.items.length) {
          res.items.forEach((item, index) => {
            innerRec[index] = item.items;
          });
        }
        setData({ ...res, innerRecords: innerRec });
      });
      if (treeRef.current) {
        let info = treeRef.current.getCurrentInfo(groupID);
        if (info.title) setTitle(info.title);
      }
    }
  }, [groupID]);
  React.useEffect(() => {
    if (data) {
      const refresh = gridPeriod !== void 0;
      GridLoader(gridPanel1.current, props, {
        localGrid: true,
        refresh,
        // обновление данных таблицы без изменения grid
        source: refresh ? gridPeriod.source : void 0,
        Columns: getColumns1(),
        defaultFields: getDefaultFields1(),
        keyField: "ID",
        getRecords: () => getRecords1(data),
        recordKeys: ["ID", "UsedDate", "Text"],
        titleKey: "Text",
        setSelectedRecord: setSelectedRecordID1,
        showIndicator: false,
        Rights: "0"
      }).then((res) => {
        setGridPeriod(res);
      });
    }
  }, [data]);
  React.useEffect(() => {
    if (gridPeriod && selectedRecordID1 !== void 0) {
      const refresh = gridData !== void 0;
      GridLoader(gridPanel2.current, props, {
        localGrid: true,
        refresh,
        // обновление данных таблицы без изменения grid
        source: refresh ? gridData.source : void 0,
        Columns: getColumns2(),
        defaultFields: getDefaultFields2(),
        keyField: "ID",
        getRecords: () => getRecords2(data, selectedRecordID1),
        getFieldText: getGradesText,
        onPostRecord,
        recordKeys: [
          "ID",
          "StartRange",
          "EndRange",
          "FirstDate",
          "Value",
          "Info",
          "LastDate",
          "OrgTypeClsName",
          "OrgTypeCls"
        ],
        titleKey: "StartRange",
        setSelectedRecord: setSelectedRecordID2,
        showIndicator: false,
        Rights: "-1"
      }).then((res) => {
        setGridData(res);
      });
    }
  }, [selectedRecordID1, gridPeriod]);
  async function onPostRecord(req, recData, postData) {
    const editFieldName = req.RecordSet.Attributes[0];
    let editFieldData;
    if (typeof recData[0] === "object") {
      if (recData[0].id) {
        editFieldData = recData[0].id;
      } else {
        editFieldData = recData[0].text;
      }
    } else {
      editFieldData = recData[0];
    }
    const result = {
      ...postData.records[req.RecordIndex],
      [editFieldName]: editFieldData,
      GroupID: groupID
    };
    const res = await ChangeGradeValue(result);
    const innerRec = {};
    if (res.items && res.items.length) {
      res.items.forEach((item, index) => {
        innerRec[index] = item.items;
      });
    }
    setData({ ...res, innerRecords: innerRec });
  }
  function ChangeGradeValue(reqData) {
    const params = /* @__PURE__ */ new Map();
    params.set("prefix", "grades").set("comand", "ChangeGradeValue").set("ID", reqData.ID ? reqData.ID : "0").set("GroupID", reqData.GroupID).set("Department", reqData.Info ? reqData.Info : "0").set("StartRange", reqData.StartRange ? reqData.StartRange : "0").set("EndRange", reqData.EndRange ? reqData.EndRange : "0").set("FirstDate", reqData.FirstDate ? reqData.FirstDate : "0").set("LastDate", reqData.LastDate ? reqData.LastDate : "0").set("Value", reqData.Value ? reqData.Value : "0").set("Options", reqData.Options ? reqData.Options : "0").set("OrgTypeCls", reqData.OrgTypeClsName ? reqData.OrgTypeClsName : "0").set("Status", reqData.Status ? reqData.Status : "4");
    return AxiosRequest(true, params);
  }
  function RestoreGrade() {
    const params = /* @__PURE__ */ new Map();
    params.set("prefix", "grades").set("comand", "RestoreGrade").set("ID", groupID);
    return AxiosRequest(true, params);
  }
  async function ContextMenuHandler(contextData) {
    const comand = contextData.value;
    switch (comand) {
      case "ConfigRestore":
        await RestoreGrade();
        const res = await GetGradeScope(groupID, props.data.Department);
        const innerRec = {};
        if (res.items && res.items.length) {
          res.items.forEach((item, index) => {
            innerRec[index] = item.items;
          });
        }
        setData({ ...res, innerRecords: innerRec });
        break;
    }
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: "100%", width: "100%" }, ref: localGridBox, id: "localGridBox", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
    SplitterLocal,
    {
      onResizeEnd: () => updateGridData(0),
      onCollapse: () => updateGridData(0),
      onExpand: () => updateGridData(0),
      orientation: "vertical",
      style: { width: "100%", height: "100%" },
      primaryIndex: 1,
      defaultCollapsed: false,
      transitionDuration: 250,
      children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: "100%" }, children: tree }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { height: "calc(100% - 23px)" }, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            Grid,
            {
              item: true,
              style: {
                height: "23px",
                width: "100%",
                justifyContent: "center",
                alignItems: "center",
                display: "flex",
                backgroundColor: "rgb(235,235,235)",
                fontWeight: "bold"
              },
              children: title
            }
          ),
          /* @__PURE__ */ jsxRuntimeExports.jsxs(
            SplitterLocal,
            {
              onResizeEnd: () => updateGridData(0),
              onCollapse: () => updateGridData(0),
              onExpand: () => updateGridData(0),
              orientation: "vertical",
              style: { width: "100%", height: "100%" },
              primaryIndex: 1,
              defaultCollapsed: false,
              transitionDuration: 250,
              children: [
                /* @__PURE__ */ jsxRuntimeExports.jsx(
                  Grid,
                  {
                    container: true,
                    direction: "column",
                    justifyContent: "flex-start",
                    alignItems: "center",
                    style: { height: "100%", width: "100%" },
                    children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                      Grid,
                      {
                        item: true,
                        id: `rcgrid_panel`,
                        ref: gridPanel1,
                        style: {
                          height: "100%",
                          width: "100%",
                          position: "relative"
                        }
                      }
                    )
                  }
                ),
                /* @__PURE__ */ jsxRuntimeExports.jsx(
                  ContextMenu,
                  {
                    for: "grid",
                    Menu: getDefaultMenu("grades"),
                    onMenuItemClick: ContextMenuHandler,
                    children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                      Grid,
                      {
                        container: true,
                        direction: "column",
                        justifyContent: "flex-start",
                        alignItems: "center",
                        style: { height: "100%", width: "100%" },
                        children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                          Grid,
                          {
                            item: true,
                            id: `rcgrid_panel`,
                            ref: gridPanel2,
                            style: {
                              height: "100%",
                              width: "100%",
                              position: "relative"
                            }
                          }
                        )
                      }
                    )
                  }
                )
              ]
            }
          )
        ] })
      ]
    }
  ) });
}
function DialogDepartments({ props }) {
  const [mainGrid, setMainGrid] = React.useState(void 0);
  const [subGrid, setSubGrid] = React.useState(void 0);
  const [collapsedButtons, setCollapsedButtons] = React.useState({});
  const [countRecords, setCountRecords] = React.useState("0");
  const [tabs, setTabs] = React.useState(null);
  const [users, setUsers] = React.useState(null);
  const [needUpdate, setNeedUpdate] = React.useState(false);
  const [timer, setTimer] = React.useState(null);
  const [selectedRecordID, setSelectedRecordID] = React.useState(props.ID);
  const gridPanel = React.useRef();
  const tabsPanel = React.useRef();
  const Pages = React.useRef();
  React.useEffect(() => {
    GridLoader(gridPanel.current, props, {
      setSelectedRecord: setSelectedRecordID,
      Pages,
      setCountRecords
    }).then((res) => {
      setMainGrid(res);
    });
  }, []);
  React.useEffect(() => {
    if (mainGrid) {
      setTabs(getTabs());
      setCountRecords(mainGrid.source.recordCount);
      setTimeout(() => {
        mainGrid.grid.updateGridSize();
      }, 251);
    }
  }, [mainGrid]);
  React.useEffect(() => {
    if (selectedRecordID) {
      setNeedUpdate(true);
    }
  }, [selectedRecordID]);
  React.useEffect(() => {
    if (users === void 0) {
      getUsers(selectedRecordID).then((res) => {
        if (!res || res.length === 0) {
          setUsers(null);
          return;
        }
        setUsers(res);
      });
    }
  }, [users]);
  React.useLayoutEffect(() => {
    if (needUpdate) {
      updateTab(tabsPanel.current.selectedIndex, tabs);
      setNeedUpdate(false);
    }
  }, [needUpdate]);
  React.useLayoutEffect(() => {
    if (!collapsedButtons.detail) {
      setTimeout(() => {
        setNeedUpdate(true);
      }, 251);
    }
  }, [collapsedButtons.detail]);
  React.useLayoutEffect(() => {
    if (!collapsedButtons.users) {
      setUsers(void 0);
      return;
    }
  }, [collapsedButtons.users]);
  async function setSubGridLoader(ObjType, ParentID, panel) {
    const module = "documents";
    if (panel) {
      if (!panel.grid || !subGrid) {
        setSubGrid(
          await GridLoader(
            panel,
            { ...props, Module: module },
            {
              sub: true,
              GroupID: ParentID,
              ObjType,
              DocCfgID: ObjType
            }
          )
        );
        setNeedUpdate(true);
      } else {
        setSubGrid(
          await GridLoader(
            panel,
            { ...props, Module: module },
            {
              sub: true,
              refresh: true,
              source: subGrid.source,
              GroupID: ParentID,
              ObjType,
              DocCfgID: ObjType
            }
          )
        );
      }
    }
  }
  async function getUsers(id) {
    const json = await getDepUsers(id);
    if (json && json.Users && json.Users.items && json.Users.items.length) {
      return json.Users.items.map((item, index) => {
        return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: "20px", whiteSpace: "nowrap" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            "input",
            {
              onChange: (ev) => {
                if (mainGrid.source.getRecordState() === 160 || mainGrid.source.getRecordState() === 161 || mainGrid.source.getRecordState() === 32 || mainGrid.source.getRecordState() === 33) {
                  createConfirmation(
                    "Установить права для всех подразделений в группе?",
                    () => {
                      onChangeCheckBox(ev.target.id, ev.target.checked, "1");
                    },
                    () => {
                      onChangeCheckBox(ev.target.id, ev.target.checked, "0");
                    }
                  );
                  return;
                }
                onChangeCheckBox(ev.target.id, ev.target.checked, "0");
              },
              defaultChecked: item.State === "1",
              id: `${item.ID}`,
              type: "checkbox"
            }
          ),
          item.Name
        ] }) }, `${item.Name}_${item.ID}_${index}`);
      });
    }
    return null;
  }
  function onChangeCheckBox(id, checked, all) {
    const params = /* @__PURE__ */ new Map();
    params.set("prefix", props.Module).set("comand", "LinkUserToDep").set("ID", selectedRecordID).set("User", id).set("Checked", checked ? "1" : "0").set("All", all);
    return AxiosRequest(true, params);
  }
  function getDepUsers(id) {
    const params = /* @__PURE__ */ new Map();
    params.set("prefix", props.Module).set("comand", "GetDepUsers").set("ID", id);
    return AxiosRequest(true, params);
  }
  function getTabs() {
    let details = [];
    if (Pages.current && Pages.current.length) {
      details = Pages.current.map((page) => {
        return getLoadTab(page.Caption);
      });
    }
    return details;
  }
  function getLoadTab(Caption) {
    return /* @__PURE__ */ jsxRuntimeExports.jsx(
      TabItem,
      {
        id: `LoadTab_${Caption}`,
        style: {
          textTransform: "none",
          width: "100%",
          height: "100%",
          padding: "0px",
          display: "inline-block"
        },
        label: Caption,
        children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `item_${Caption}`, load: "true", style: { width: "100%", height: "100%", position: "relative" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingMask, {}) })
      },
      `TabItem_${Caption}`
    );
  }
  function getEmptyTab(Caption) {
    return /* @__PURE__ */ jsxRuntimeExports.jsx(
      TabItem,
      {
        id: `LoadTab_${Caption}`,
        style: {
          textTransform: "none",
          width: "100%",
          height: "100%",
          padding: "0px",
          display: "inline-block"
        },
        label: Caption,
        children: /* @__PURE__ */ jsxRuntimeExports.jsx(
          "div",
          {
            id: `item_${Caption}`,
            style: {
              width: "100%",
              height: "100%",
              position: "relative",
              display: "flex",
              alignItems: "center",
              justifyContent: "center"
            },
            children: "Функционал в разработке"
          }
        )
      },
      `TabItem_${Caption}`
    );
  }
  function getParamsTab(Caption, detailItem) {
    var _a, _b;
    return /* @__PURE__ */ jsxRuntimeExports.jsx(
      TabItem,
      {
        id: `LoadTab_${Caption}`,
        style: {
          textTransform: "none",
          width: "100%",
          height: "100%",
          padding: "0px",
          display: "inline-block"
        },
        label: Caption,
        children: /* @__PURE__ */ jsxRuntimeExports.jsx(
          "div",
          {
            id: `item_${Caption}`,
            style: {
              width: "100%",
              height: "100%",
              position: "relative"
            },
            children: /* @__PURE__ */ jsxRuntimeExports.jsx(
              Params,
              {
                Module: props.Module,
                GroupID: selectedRecordID,
                Path: detailItem.Path,
                data: detailItem,
                NoHistory: true,
                NoTitle: true,
                noEdit: ((_b = (_a = mainGrid == null ? void 0 : mainGrid.source) == null ? void 0 : _a.rights) == null ? void 0 : _b.modify) === false
              }
            )
          }
        )
      },
      `TabItem_${Caption}`
    );
  }
  function getGradesTab(Caption, detailItem) {
    return /* @__PURE__ */ jsxRuntimeExports.jsx(
      TabItem,
      {
        id: `LoadTab_${Caption}`,
        style: {
          textTransform: "none",
          width: "100%",
          height: "100%",
          padding: "0px",
          display: "inline-block"
        },
        label: Caption,
        children: /* @__PURE__ */ jsxRuntimeExports.jsx(
          "div",
          {
            id: `item_${Caption}`,
            style: {
              width: "100%",
              height: "100%",
              position: "relative"
            },
            children: /* @__PURE__ */ jsxRuntimeExports.jsx(GradesGrid, { props: { data: detailItem } })
          }
        )
      },
      `TabItem_${Caption}`
    );
  }
  async function getContentForTab(pages, index) {
    let json;
    let page = pages.current[index];
    if (page.Info !== void 0) {
      json = await GetParamSection({
        Module: props.Module,
        ID: selectedRecordID,
        Info: page.Info,
        ProgID: page.ProgID
      });
      if (json.Props) {
        page.Items = page.Items.map((item) => {
          if (json.Props[item.ShortName]) {
            item = {
              ...item,
              Value: json.Props[item.ShortName].Value,
              EditVal: json.Props[item.ShortName].EditVal,
              ID: json.Props[item.ShortName].ID,
              TextColor: json.Props[item.ShortName].TextColor,
              CheckState: json.Props[item.ShortName].CheckState
            };
            return item;
          }
        });
      }
      page.ObjRef = json.ObjRef;
      page.ParentID = json.ParentID;
      page = pages.current[index] = { ...page, ...json };
    } else {
      json = await GetParamSection({
        Module: props.Module,
        ID: selectedRecordID,
        SectionID: props.SectionID,
        Name: page.Caption
      });
      page = pages.current[index] = { ...page, ...json };
    }
    switch (page.CLSID) {
      case "{D8402CE6-6582-4F0D-A82D-C2D9CA73F79E}":
        return "params";
      case "{48C155C0-1336-11D6-9CF2-DB1D5BC3046D}":
        return "documents";
      case "{C3A20435-640D-4653-A821-C6C6E76A1B63}":
        return "localGrid";
      default:
        return "emptyTab";
    }
  }
  function GetParamSection(data) {
    const params = /* @__PURE__ */ new Map();
    params.set("prefix", data.Module).set("comand", "GetParamSection").set("ID", data.ID);
    if (data.Info) {
      params.set("Info", data.Info);
    } else params.set("SectionID", data.SectionID).set("Name", data.Name);
    if (data.ProgID) params.set("ProgID", data.ProgID);
    return AxiosRequest(true, params);
  }
  function updateParams(data, firstLoad) {
    if (firstLoad) {
      tabs[data.index] = getParamsTab(data.detailItem.Caption, data.detailItem);
      setTabs([...tabs]);
    } else {
      const parambox = data.element.querySelector("#paramsBox");
      if (parambox && parambox.update) {
        parambox.update(data.detailItem);
      }
    }
  }
  function updateLocalGridBox(data, firstLoad) {
    if (firstLoad) {
      tabs[data.index] = getGradesTab(data.detailItem.Caption, data.detailItem);
      setTabs([...tabs]);
    } else {
      const localGridBox = data.element.querySelector("#localGridBox");
      if (localGridBox && localGridBox.update) {
        localGridBox.update(data.detailItem);
      }
    }
  }
  async function updateTab(index, tabs2) {
    if (index !== void 0 && tabs2 && Pages.current && Pages.current.length) {
      if (collapsedButtons.detail) {
        if (collapsedButtons.users === false) setUsers(void 0);
        return;
      }
      clearTimeout(timer);
      const newTimer = setTimeout(async () => {
        const content = await getContentForTab(Pages, index);
        const detailItem = Pages.current[index];
        switch (content) {
          case "params":
            tabsPanel.current.getTabContent(index).then((res) => {
              updateParams(
                { detailItem, index, element: res },
                res.querySelector("div[load='true']")
              );
            });
            break;
          case "documents":
            setSubGridLoader(
              detailItem.ObjType,
              detailItem.ParentID,
              tabsPanel.current.nativeElement.getTabContent(index).firstChild
            );
            break;
          case "localGrid":
            tabsPanel.current.getTabContent(index).then((res) => {
              updateLocalGridBox(
                { detailItem, index, element: res },
                res.querySelector("div[load='true']")
              );
            });
            break;
          case "emptyTab":
            tabs2[index] = getEmptyTab(detailItem.Caption);
            setTabs([...tabs2]);
            break;
        }
        setUsers(void 0);
      }, 100);
      setTimer(newTimer);
    }
  }
  function GetObjectText(objref) {
    const params = /* @__PURE__ */ new Map();
    params.set("prefix", props.Module).set("comand", "GetObjectText").set("Flag", "-1").set("ObjType", props.ObjType).set("ObjRef", objref);
    return AxiosRequest(true, params);
  }
  async function onSelect() {
    const objref = mainGrid.source.getFieldTextSync("Code").split(".").join("");
    const text = await GetObjectText(objref);
    if (props.onEdit) {
      props.onEdit({
        value: text ? text.Text : void 0,
        tag: objref,
        name: props.Name,
        record: props.record,
        textchanged: "0",
        setValue: props.setValue,
        setInputValue: props.setInputValue,
        type: props.Module,
        requestId: props.RequestID,
        addInfo: props.addInfo
      });
    }
    if (props.RequestID) {
      await formEdit("1", props.func, { Name: "ObjRef", Value: objref }, props.RequestID, props.from);
    }
  }
  async function fliterOnEdit(data) {
    await ApplyFilter({
      Filter: data.filter,
      Parents: data.parents,
      SectionID: props.SectionID,
      Module: props.Module
    });
    mainGrid.grid.refreshSource();
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
    ContentOrganization,
    {
      props,
      data: {
        getCollapsed: setCollapsedButtons,
        gridPanel,
        mainGrid,
        countRecords,
        tabs,
        users,
        tabsPanel,
        updateTab,
        onSelect,
        selectedRecordID: selectedRecordID ? selectedRecordID : "0",
        filterProps: { onEdit: fliterOnEdit }
      },
      buttons: { detail: true, filter: true, users: true }
    }
  ) });
}
export {
  DialogDepartments as default
};
//# sourceMappingURL=DialogDepartments-D20amGm6.js.map
