import e, { useContext as t, useRef as r, useEffect as o, useCallback as s } from "react";
import { cr as a, f7 as m, fh as i, gk as p, gl as n, gm as c, dG as l, gn as d, fy as u, go as j, gp as g, gq as h } from "./index-6d97e67f.js";
import { g as f } from "./shortcutConfigs-24c6eb1a.js";
import { lA as C } from "./ant-design-icons-a81e6d18.js";
import "./axios-0ffd51b8.js";
import "./redux-devtools-36ca30b8.js";
import "./alasql-f59e855e.js";
import "./react-router-38313ddc.js";
import "./antd-eb0b81b8.js";
import "react-dom";
import "./dayjs-63343308.js";
import "./lodash-226cb5b1.js";
import "./fontawesome-7bcd29b1.js";
import "./dnd-kit-e0a0bf75.js";
import "./moment-d731d247.js";
import "./crypto-js-8020edb5.js";
import "./styled-components-b776227d.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-6aa220db.js";
import "./websockets-80729b50.js";
import "./fetch-03ca8116.js";
import "./react-draggable-1ced44e5.js";
import "./clsx-b06d39d3.js";
import "./remark-gfm-72b87c7d.js";
import "./buffer-f89d742d.js";
import "./rehype-raw-49057806.js";
import "./parse5-31d0cb5d.js";
import "./rehype-sanitize-38a120e4.js";
import "./simplebar-react-a37a9b2a.js";
import "./react-best-gradient-color-picker-2e7ff36d.js";
import "./ua-parser-js-1d18a3f8.js";
import "./loglevel-5e7e37fc.js";
import "./codemirror-8fe65581.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./redux-saga-3b3a9c7b.js";
import "./hotkeys-js-216206c9.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-a03b99c9.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-7d152aa4.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-417e3716.js";
import "./katex-05fb1c31.js";
import "./ecogis-maps-10e82de5.js";
import "./devextreme-be18bda8.js";
import "./exceljs-1678d36b.js";
import "./file-saver-es-c18fae8f.js";
function b(e2, t2) {
  e2.setForceShowGrid(!!t2 && j(t2)), e2.setDisableInteract(!!t2 && g(t2));
}
const y = e.memo((e2) => {
  const c2 = t(a), { history: g2 } = t(m), { togglePanel: y2, panelStatus: v2, toggleShortcutList: w2 } = e2, k = i(), S = r(true);
  o(() => () => {
    S.current = false;
  }, []);
  const x = s((e3) => {
    S.current && (b(c2, e3), function(e4, t2, r2, o2, s2, a2) {
      switch (f(e4, "global")) {
        case "toggleLeftPanel":
          o2("left");
          break;
        case "toggleBottomPanel":
          o2("bottom");
          break;
        case "toggleRightPanel":
          o2("right");
          break;
        case "toggleAllPanels":
          o2();
          break;
        case "preview":
          u(a2);
          break;
        case "undo":
          r2 == null ? void 0 : r2.undo();
          break;
        case "redo":
          r2 == null ? void 0 : r2.redo();
          break;
        case "deleteComps":
          return void d.deleteComp(t2, t2.selectedComps());
        case "toggleShortcutList":
          return void s2();
        case "executeQuery": {
          const e5 = t2.selectedQueryComp();
          e5 == null ? void 0 : e5.dispatch(l({ afterExecFunc: () => t2.setShowResultCompName(e5.children.name.getView()) }));
          break;
        }
        default:
          return;
      }
      e4.stopPropagation(), e4.preventDefault();
    }(e3, c2, g2, y2, w2, k), c2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3));
  }, [c2, g2, y2, w2, k]), D = s((e3) => {
    S.current && b(c2, e3);
  }, [c2]), N = s((e3) => {
    S.current && (b(c2, e3), function(e4, t2, r2) {
      if (!j(e4))
        return;
      const o2 = e4.target || e4.srcElement;
      if (!o2)
        return;
      if (o2.className !== h) {
        const e5 = o2.parentElement;
        if (!e5 || e5.className !== h)
          return;
      }
      r2();
      const s2 = o2.innerText;
      if (t2.getUICompByName(s2))
        return void t2.setSelectedCompNames(/* @__PURE__ */ new Set([s2]));
      const a2 = t2.getBottomResComp(s2);
      a2 && t2.setSelectedBottomRes(s2, a2.type());
    }(e3, c2, () => !v2.left && y2("left")));
  }, [c2, v2, y2]);
  return p(() => {
    S.current = false;
  }), C(n, { disabled: e2.disabled, onKeyDownCapture: x, onKeyUpCapture: D, onMouseMoveCapture: D, onMouseDownCapture: N, children: e2.children });
});
const v = e.memo((e2) => {
  const m2 = t(a), i2 = r(true);
  o(() => () => {
    i2.current = false;
  }, []);
  const n2 = s((e3) => {
    i2.current && function(e4, t2) {
      switch (f(e4, "editor")) {
        case "selectAllComps":
          return t2.setSelectedCompNames(new Set(Object.values(t2.getUIComp().getTopCompItems()).map((e5) => e5.children.name.getView()))), e4.preventDefault(), void e4.stopPropagation();
        case "copyComps":
          return void d.copyComp(t2, t2.selectedComps());
        case "pasteComps":
          return void d.pasteComp(t2);
        case "cutComps":
          return void d.cutComp(t2, t2.selectedComps());
        case "deselectComps":
          t2.setSelectedCompNames(/* @__PURE__ */ new Set());
      }
    }(e3, m2);
  }, [m2]);
  return p(() => {
    i2.current = false;
  }), C(c, { disabled: e2.disabled, onKeyDown: n2, style: { width: "100%", height: "100%" }, children: e2.children });
}), w = e.memo((e2) => {
  const m2 = t(a), i2 = r(true);
  o(() => () => {
    i2.current = false;
  }, []);
  const c2 = s((e3) => {
    i2.current && m2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3);
  }, [m2]);
  return p(() => {
    i2.current = false;
  }), C(n, { onKeyDownCapture: c2, children: e2.children });
});
export {
  w as CustomShortcutWrapper,
  y as EditorGlobalHotKeys,
  v as EditorHotKeys
};
