import e, { useContext as t, useCallback as o } from "react";
import { a8 as s, e8 as r, ek as a, fp as i, fq as m, dz as p, fr as n, eB as c, fs as l, ft as d, fu as u } from "./index-f927b013.js";
import { g as j } from "./shortcutConfigs-5a4b23c3.js";
import { lz as g } from "./ant-design-icons-6bfdc7d5.js";
import "./axios-04f95181.js";
import "./redux-devtools-8dd21e4f.js";
import "./alasql-f60045ee.js";
import "./antd-2abdded3.js";
import "react-dom";
import "./dayjs-2035e031.js";
import "./lodash-b5661970.js";
import "./fontawesome-3904a214.js";
import "./dnd-kit-8227a2db.js";
import "./moment-059406e8.js";
import "./styled-components-7cfa37e6.js";
import "./numbro-47982265.js";
import "./papaparse-07642d76.js";
import "./uuid-bd83cae2.js";
import "./supabase-b2e314d0.js";
import "./fetch-648a91f6.js";
import "./react-draggable-ed505bfc.js";
import "./remark-gfm-18306abe.js";
import "./buffer-d3713d77.js";
import "./rehype-raw-6ebcba88.js";
import "./parse5-f837f753.js";
import "./rehype-sanitize-953d0761.js";
import "./simplebar-react-2133d981.js";
import "./react-best-gradient-color-picker-92c01739.js";
import "./ua-parser-js-c952c07b.js";
import "./clsx-469c2c43.js";
import "./loglevel-b4003767.js";
import "./file-saver-55285fc1.js";
import "./codemirror-8412b963.js";
import "./really-relaxed-json-056be70b.js";
import "./immer-c0428a8d.js";
import "./hotkeys-js-699906bc.js";
import "./cnchar-e1339167.js";
import "./react-documents-041601c7.js";
import "./react-sortable-hoc-4fbe0c32.js";
import "./sql-formatter-577b4ab0.js";
import "./rc-trigger-3f038851.js";
import "./react-json-view-5330ce92.js";
import "./qrcode-react-d377d762.js";
function f(e2, t2) {
  e2.setForceShowGrid(!!t2 && l(t2)), e2.setDisableInteract(!!t2 && d(t2));
}
const h = e.memo((e2) => {
  const m2 = t(s), { history: d2 } = t(r), { togglePanel: h2, panelStatus: C2, toggleShortcutList: b2 } = e2, y = a(), v = o((e3) => {
    f(m2, e3), function(e4, t2, o2, s2, r2, a2) {
      switch (j(e4, "global")) {
        case "toggleLeftPanel":
          s2("left");
          break;
        case "toggleBottomPanel":
          s2("bottom");
          break;
        case "toggleRightPanel":
          s2("right");
          break;
        case "toggleAllPanels":
          s2();
          break;
        case "preview":
          c(a2);
          break;
        case "undo":
          o2 == null ? void 0 : o2.undo();
          break;
        case "redo":
          o2 == null ? void 0 : o2.redo();
          break;
        case "deleteComps":
          return void n.deleteComp(t2, t2.selectedComps());
        case "toggleShortcutList":
          return void r2();
        case "executeQuery": {
          const e5 = t2.selectedQueryComp();
          e5 == null ? void 0 : e5.dispatch(p({ afterExecFunc: () => t2.setShowResultCompName(e5.children.name.getView()) }));
          break;
        }
        default:
          return;
      }
      e4.stopPropagation(), e4.preventDefault();
    }(e3, m2, d2, h2, b2, y), m2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3);
  }, [m2, d2, h2, b2, y]), w = o((e3) => f(m2, e3), [m2]), S = o((e3) => {
    f(m2, e3), function(e4, t2, o2) {
      if (!l(e4))
        return;
      const s2 = e4.target || e4.srcElement;
      if (!s2)
        return;
      if (s2.className !== u) {
        const e5 = s2.parentElement;
        if (!e5 || e5.className !== u)
          return;
      }
      o2();
      const r2 = s2.innerText;
      if (t2.getUICompByName(r2))
        return void t2.setSelectedCompNames(/* @__PURE__ */ new Set([r2]));
      const a2 = t2.getBottomResComp(r2);
      a2 && t2.setSelectedBottomRes(r2, a2.type());
    }(e3, m2, () => !C2.left && h2("left"));
  }, [m2, C2, h2]);
  return g(i, { disabled: e2.disabled, onKeyDownCapture: v, onKeyUpCapture: w, onMouseMoveCapture: w, onMouseDownCapture: S, children: e2.children });
});
const C = e.memo((e2) => {
  const r2 = t(s), a2 = o((e3) => function(e4, t2) {
    switch (j(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 n.copyComp(t2, t2.selectedComps());
      case "pasteComps":
        return void n.pasteComp(t2);
      case "cutComps":
        return void n.cutComp(t2, t2.selectedComps());
      case "deselectComps":
        return void t2.setSelectedCompNames(/* @__PURE__ */ new Set());
    }
  }(e3, r2), [r2]);
  return g(m, { disabled: e2.disabled, onKeyDown: a2, style: { width: "100%", height: "100%" }, children: e2.children });
}), b = e.memo((e2) => {
  const r2 = t(s), a2 = o((e3) => {
    r2.getAppSettingsComp().children.customShortcuts.handleKeyEvent(e3);
  }, [r2]);
  return g(i, { onKeyDownCapture: a2, children: e2.children });
});
export {
  b as CustomShortcutWrapper,
  h as EditorGlobalHotKeys,
  C as EditorHotKeys
};
