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 n, gl as p, gm as c, dG as l, gn as d, fy as u, go as j, gp as g, gq as h } from "./index-8935f1b4.js";
import { g as f } from "./shortcutConfigs-3b2e9995.js";
import { lA as C } from "./ant-design-icons-14ab96af.js";
import "./axios-125479b5.js";
import "./redux-devtools-f8b1cd80.js";
import "./alasql-f59e855e.js";
import "./react-router-8d1fc2f1.js";
import "./antd-97b654da.js";
import "react-dom";
import "./dayjs-7fc5ce65.js";
import "./lodash-226cb5b1.js";
import "./fontawesome-89eb6278.js";
import "./dnd-kit-e67c9595.js";
import "./moment-d8baa15a.js";
import "./crypto-js-8020edb5.js";
import "./styled-components-c6abe9a3.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-2e4a9112.js";
import "./fetch-6a200310.js";
import "./react-draggable-fda4f1cb.js";
import "./remark-gfm-e9b5dec7.js";
import "./buffer-e20f80c8.js";
import "./rehype-raw-41b6145f.js";
import "./parse5-6476676e.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-cab52c82.js";
import "./react-best-gradient-color-picker-812be7ee.js";
import "./ua-parser-js-1d18a3f8.js";
import "./clsx-469c2c43.js";
import "./loglevel-5e7e37fc.js";
import "./codemirror-edf161cb.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./redux-saga-1b0a458d.js";
import "./hotkeys-js-0dddb21a.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-ae08f8b5.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-9e54e169.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-e4f7745b.js";
import "./katex-cda5b990.js";
import "./ecogis-maps-10bb29cf.js";
import "./devextreme-28d23085.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, S = i(), k = r(true);
  o(() => () => {
    k.current = false;
  }, []);
  const x = s((e3) => {
    k.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, S), c2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3));
  }, [c2, g2, y2, w2, S]), D = s((e3) => {
    k.current && b(c2, e3);
  }, [c2]), K = s((e3) => {
    k.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 n(() => {
    k.current = false;
  }), C(p, { disabled: e2.disabled, onKeyDownCapture: x, onKeyUpCapture: D, onMouseMoveCapture: D, onMouseDownCapture: K, children: e2.children });
});
const v = e.memo((e2) => {
  const m2 = t(a), i2 = r(true);
  o(() => () => {
    i2.current = false;
  }, []);
  const p2 = 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 n(() => {
    i2.current = false;
  }), C(c, { disabled: e2.disabled, onKeyDown: p2, 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 n(() => {
    i2.current = false;
  }), C(p, { onKeyDownCapture: c2, children: e2.children });
});
export {
  w as CustomShortcutWrapper,
  y as EditorGlobalHotKeys,
  v as EditorHotKeys
};
