import { aj as requireInteropRequireDefault, ak as requireCreateSvgIcon, al as requireJsxRuntime, am as getDefaultExportFromCjs, r as reactExports, a6 as GridLoader, j as jsxRuntimeExports, aw as Params, ah as AxiosRequest, G as Grid, I as IconButton, ax as SplitterLocal, ay as ClearIcon, B as Button, ab as formEdit } from "./index-D15x63tD.js";
var CleaningServices = {};
var hasRequiredCleaningServices;
function requireCleaningServices() {
  if (hasRequiredCleaningServices) return CleaningServices;
  hasRequiredCleaningServices = 1;
  var _interopRequireDefault = requireInteropRequireDefault();
  Object.defineProperty(CleaningServices, "__esModule", {
    value: true
  });
  CleaningServices.default = void 0;
  var _createSvgIcon = _interopRequireDefault(/* @__PURE__ */ requireCreateSvgIcon());
  var _jsxRuntime = requireJsxRuntime();
  CleaningServices.default = (0, _createSvgIcon.default)(/* @__PURE__ */ (0, _jsxRuntime.jsx)("path", {
    d: "M16 11h-1V3c0-1.1-.9-2-2-2h-2c-1.1 0-2 .9-2 2v8H8c-2.76 0-5 2.24-5 5v7h18v-7c0-2.76-2.24-5-5-5m3 10h-2v-3c0-.55-.45-1-1-1s-1 .45-1 1v3h-2v-3c0-.55-.45-1-1-1s-1 .45-1 1v3H9v-3c0-.55-.45-1-1-1s-1 .45-1 1v3H5v-5c0-1.65 1.35-3 3-3h8c1.65 0 3 1.35 3 3z"
  }), "CleaningServices");
  return CleaningServices;
}
var CleaningServicesExports = /* @__PURE__ */ requireCleaningServices();
const CleaningServicesIcon = /* @__PURE__ */ getDefaultExportFromCjs(CleaningServicesExports);
var ManageSearch = {};
var hasRequiredManageSearch;
function requireManageSearch() {
  if (hasRequiredManageSearch) return ManageSearch;
  hasRequiredManageSearch = 1;
  var _interopRequireDefault = requireInteropRequireDefault();
  Object.defineProperty(ManageSearch, "__esModule", {
    value: true
  });
  ManageSearch.default = void 0;
  var _createSvgIcon = _interopRequireDefault(/* @__PURE__ */ requireCreateSvgIcon());
  var _jsxRuntime = requireJsxRuntime();
  ManageSearch.default = (0, _createSvgIcon.default)(/* @__PURE__ */ (0, _jsxRuntime.jsx)("path", {
    d: "M7 9H2V7h5zm0 3H2v2h5zm13.59 7-3.83-3.83c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L22 17.59zM17 11c0-1.65-1.35-3-3-3s-3 1.35-3 3 1.35 3 3 3 3-1.35 3-3M2 19h10v-2H2z"
  }), "ManageSearch");
  return ManageSearch;
}
var ManageSearchExports = /* @__PURE__ */ requireManageSearch();
const ManageSearchIcon = /* @__PURE__ */ getDefaultExportFromCjs(ManageSearchExports);
function DialogAcctools({ props }) {
  const gridpanelRef = reactExports.useRef(null);
  const [params, setParams] = reactExports.useState(null);
  const [filter, setFilter] = reactExports.useState(false);
  const [mainGrid, setMainGrid] = reactExports.useState();
  const [selectRecordID, setSelectRecordID] = reactExports.useState(props.ObjRef);
  const [colapsedParams, setColapsedParams] = reactExports.useState(false);
  reactExports.useLayoutEffect(() => {
    GridLoader(gridpanelRef.current, props, {
      setSelectedRecord: setSelectRecordID
    }).then((res) => {
      setMainGrid(res);
    });
  }, []);
  reactExports.useEffect(() => {
    if (params === null) {
      getFilterParams(props.Module).then((res) => {
        setParams(
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            Params,
            {
              Module: props.Module,
              reqCommand: "GetFilterParams",
              GroupID: "0",
              SectionID: props.SectionID,
              data: res,
              NoTitle: true,
              NoHistory: true
            }
          )
        );
      });
    }
  }, [params]);
  function colapseParams() {
    updateGridSize();
    setColapsedParams(!colapsedParams);
  }
  function onCollapseParams() {
    setColapsedParams(true);
  }
  function onExpandParams() {
    setColapsedParams(false);
  }
  function updateGridSize() {
    setTimeout(() => {
      if (mainGrid) mainGrid.grid.updateGridSize();
    }, 251);
  }
  function onResizeParams() {
    updateGridSize();
  }
  function getFilterParams(module) {
    const params2 = /* @__PURE__ */ new Map();
    params2.set("prefix", module).set("comand", "GetFilterParams").set("GroupID", "0").set("SectionID", props.SectionID).set("NeedRefresh", "1");
    const json = AxiosRequest(true, params2);
    return json;
  }
  async function ApplyCorrFilter(module) {
    const params2 = /* @__PURE__ */ new Map();
    params2.set("prefix", module).set("comand", "ApplyCorrFilter").set("SectionID", props.SectionID);
    await AxiosRequest(true, params2);
    setFilter(true);
    if (mainGrid) await mainGrid.grid.refreshSource();
  }
  async function ResetFilter(module) {
    const params2 = /* @__PURE__ */ new Map();
    params2.set("prefix", module).set("comand", "ResetFilter").set("SectionID", props.SectionID);
    await AxiosRequest(true, params2);
    setParams(null);
    setFilter(false);
    if (mainGrid) await mainGrid.grid.refreshSource();
  }
  async function onSelect() {
    if (props.onEdit) {
      props.onEdit({
        value: null,
        tag: selectRecordID,
        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: selectRecordID }, props.RequestID, props.from);
    }
  }
  const styleButton = {
    margin: "2px 2px 2px 2px",
    width: "30px",
    height: "80%"
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
    Grid,
    {
      id: "mainElement",
      container: true,
      direction: "column",
      justifyContent: "flex-start",
      alignItems: "stretch",
      style: { position: "relative", height: "100%" },
      children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          Grid,
          {
            item: true,
            style: {
              border: "1px solid #C8B58F",
              height: "35px"
            },
            children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton, { title: "Фильтр операций", style: styleButton, onClick: colapseParams, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ManageSearchIcon, {}) })
          }
        ),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(
          Grid,
          {
            container: true,
            item: true,
            direction: "row",
            justifyContent: "flex-start",
            alignItems: "stretch",
            style: {
              height: "calc(100% - 35px - 42px)",
              width: "100%"
            },
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsxs(
                SplitterLocal,
                {
                  style: {
                    height: "100%",
                    width: "100%",
                    borderRight: "1px solid #C8B58F",
                    borderLeft: "1px solid #C8B58F"
                  },
                  onResizeEnd: onResizeParams,
                  onCollapse: onCollapseParams,
                  onExpand: onExpandParams,
                  primaryIndex: 1,
                  orientation: "vertical",
                  minSize: 175,
                  collapsed: colapsedParams,
                  children: [
                    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "org_splitter_item_1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
                      Grid,
                      {
                        style: {
                          height: "100%",
                          width: "100%"
                        },
                        children: [
                          /* @__PURE__ */ jsxRuntimeExports.jsxs(
                            Grid,
                            {
                              container: true,
                              direction: "row",
                              justifyContent: "flex-start",
                              alignItems: "center",
                              style: {
                                height: "25px",
                                width: "100%",
                                background: "linear-gradient(to top, #cccccc, 30%, #f9f9f9)"
                              },
                              children: [
                                /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { whiteSpace: "nowrap", marginLeft: "5px" }, children: "Фильтр операций" }),
                                /* @__PURE__ */ jsxRuntimeExports.jsx(
                                  IconButton,
                                  {
                                    title: "Очистить фильтр операций",
                                    disabled: !filter,
                                    style: {
                                      position: "absolute",
                                      left: "calc(100% - 50px)",
                                      height: "25px",
                                      width: "25px",
                                      fontSize: "100%",
                                      borderRadius: "0px"
                                    },
                                    onClick: () => ResetFilter(props.Module),
                                    children: /* @__PURE__ */ jsxRuntimeExports.jsx(CleaningServicesIcon, {})
                                  }
                                ),
                                /* @__PURE__ */ jsxRuntimeExports.jsx(
                                  IconButton,
                                  {
                                    title: "Скрыть фильтр операций",
                                    style: {
                                      position: "absolute",
                                      left: "calc(100% - 25px)",
                                      height: "25px",
                                      width: "25px",
                                      fontSize: "100%",
                                      borderRadius: "0px"
                                    },
                                    onClick: colapseParams,
                                    children: /* @__PURE__ */ jsxRuntimeExports.jsx(ClearIcon, {})
                                  }
                                )
                              ]
                            }
                          ),
                          /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { style: { height: "calc(100% - 50px)" }, children: params }),
                          /* @__PURE__ */ jsxRuntimeExports.jsx(
                            "div",
                            {
                              style: {
                                borderRight: "1px solid #C8B58F",
                                borderTop: "1px solid #C8B58F",
                                height: "25px",
                                width: "100%",
                                overflow: "hidden"
                              },
                              children: /* @__PURE__ */ jsxRuntimeExports.jsx(
                                IconButton,
                                {
                                  onClick: () => ApplyCorrFilter(props.Module),
                                  style: {
                                    border: "0px",
                                    borderRadius: "0",
                                    backgroundColor: "#f9f9f9",
                                    fontSize: "100%",
                                    height: "100%",
                                    width: "100%",
                                    whiteSpace: "nowrap",
                                    cursor: "pointer"
                                  },
                                  children: "Применить"
                                }
                              )
                            }
                          )
                        ]
                      }
                    ) }),
                    /* @__PURE__ */ jsxRuntimeExports.jsx(
                      Grid,
                      {
                        item: true,
                        id: `rcgrid_panel`,
                        ref: gridpanelRef,
                        style: {
                          height: "100%",
                          width: "100%"
                        }
                      }
                    )
                  ]
                }
              ),
              /* @__PURE__ */ jsxRuntimeExports.jsxs(
                Grid,
                {
                  container: true,
                  item: true,
                  direction: "row",
                  justifyContent: "flex-start",
                  alignItems: "center",
                  style: {
                    height: "42px",
                    width: "100%",
                    border: "1px solid #C8B58F",
                    display: props.hiddenFutter ? "none" : ""
                  },
                  children: [
                    /* @__PURE__ */ jsxRuntimeExports.jsx(
                      Grid,
                      {
                        item: true,
                        style: {
                          margin: "8px",
                          width: props.hiddenButton || props.Buttons && (props.Button & 1) === 0 ? "calc(100% - 99px)" : "calc(100% - 178px)"
                        }
                      }
                    ),
                    /* @__PURE__ */ jsxRuntimeExports.jsx(Grid, { item: true, style: { width: "fit-content" }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
                      Grid,
                      {
                        container: true,
                        item: true,
                        direction: "row",
                        justifyContent: "flex-end",
                        alignItems: "center",
                        style: { height: "100%", width: "100%" },
                        children: [
                          /* @__PURE__ */ jsxRuntimeExports.jsx(
                            Button,
                            {
                              onClick: onSelect,
                              size: "small",
                              variant: "outlined",
                              style: {
                                textTransform: "none",
                                marginRight: "10px",
                                display: props.Buttons && (props.Button & 1) === 0 ? "none" : ""
                              },
                              value: "1",
                              className: "button_Modal_Select",
                              children: "Выбрать"
                            }
                          ),
                          /* @__PURE__ */ jsxRuntimeExports.jsx(
                            Button,
                            {
                              size: "small",
                              variant: "outlined",
                              style: { textTransform: "none" },
                              value: "2",
                              className: "button_Modal_Close",
                              children: "Закрыть"
                            }
                          )
                        ]
                      }
                    ) })
                  ]
                }
              )
            ]
          }
        )
      ]
    }
  ) });
}
export {
  DialogAcctools as default
};
//# sourceMappingURL=DialogAcctools-B-L-ZBRp.js.map
