var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  return value;
};
import { dW as e, iU as t, iV as i, iP as r, iT as o, f as n, g6 as s, av as d, dV as a, iW as l, iX as p, iY as h, d6 as c, fC as m, gO as u, eE as y, fF as f, iZ as g, g5 as x, e as b, i_ as w, i$ as j, Q as v, dG as K, eL as q, j0 as k, fI as E } from "./index-f50c05c4.js";
import "./lodash-f1e42446.js";
import { lA as V, lR as L, lS as C } from "./ant-design-icons-b1480d8d.js";
import "./loglevel-6fb66d22.js";
import D, { useState as P, useEffect as T, useRef as I } from "react";
import { Q as U, a as R, I as S } from "./inputListComp-26048224.js";
import { d as H } from "./styled-components-1e696d6b.js";
import { p as z } from "./fontawesome-2445f580.js";
import { h as N } from "./hotkeys-js-0dddb21a.js";
import { D as M } from "./BottomMetaDrawer-efbb1c6b.js";
import { u as Q, H as A } from "./index-25ace9de.js";
import "./axios-84bb1c75.js";
import "./redux-devtools-d38e5b33.js";
import "./alasql-0ff6dabf.js";
import "./react-router-a1807b5b.js";
import "./antd-04a23d13.js";
import "react-dom";
import "./dayjs-844325ae.js";
import "./dnd-kit-56a2f36f.js";
import "./numbro-c1edb412.js";
import "./papaparse-1bac8e5f.js";
import "./uuid-82f303b2.js";
import "./supabase-c27c62e3.js";
import "./fetch-a3c8ad94.js";
import "./react-draggable-60f59f09.js";
import "./remark-gfm-f2973785.js";
import "./buffer-d3713d77.js";
import "./rehype-raw-41b6145f.js";
import "./parse5-6476676e.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-e1b123a3.js";
import "./react-best-gradient-color-picker-4dd60dac.js";
import "./ua-parser-js-094f59ba.js";
import "./clsx-469c2c43.js";
import "./crypto-js-d5eac8ba.js";
import "./codemirror-73d8c217.js";
import "./really-relaxed-json-49b6a70d.js";
import "./immer-c0428a8d.js";
import "./redux-saga-5514e228.js";
import "./cnchar-5678e6bc.js";
import "./react-documents-eb6de859.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-5125aafe.js";
import "./react-json-view-9403d8a1.js";
import "./qrcode-react-cb73d2b6.js";
import "./katex-a34f0265.js";
import "./ecogis-maps-bb0d63f9.js";
import "./devextreme-2fa5bb9a.js";
class F extends D.Component {
  constructor(e2) {
    super(e2);
    __publicField(this, "isKeyDown", false);
    __publicField(this, "preKey", "");
    __publicField(this, "handle");
    __publicField(this, "state");
    this.onKeyDown = this.onKeyDown.bind(this), this.onKeyUp = this.onKeyUp.bind(this), this.handleKeyUpEvent = this.handleKeyUpEvent.bind(this), this.handle = {}, this.state = { enableHotKey: e2.global || false };
  }
  componentDidMount() {
    const { splitKey: e2, filter: t2 } = this.props;
    t2 && (N.filter = t2), N.unbind(this.props.keyName), N(this.props.keyName, { splitKey: e2 }, this.onKeyDown), document && document.body.addEventListener("keyup", this.handleKeyUpEvent);
  }
  componentWillUnmount() {
    N.unbind(this.props.keyName), this.isKeyDown = true, this.handle = {}, document && document.body.removeEventListener("keyup", this.handleKeyUpEvent);
  }
  onKeyUp(e2, t2) {
    if (!this.state.enableHotKey)
      return;
    const { onKeyUp: i2, disabled: r2 } = this.props;
    !r2 && i2 && i2(t2.shortcut, e2, t2);
  }
  onKeyDown(e2, t2) {
    if (!this.state.enableHotKey)
      return;
    const { onKeyDown: i2, allowRepeat: r2, disabled: o2 } = this.props, n2 = t2.shortcut;
    this.isKeyDown && !r2 && this.preKey === n2 || (this.preKey = n2, this.isKeyDown = true, this.handle = t2, !o2 && i2 && i2(n2, e2, t2));
  }
  handleKeyUpEvent(e2) {
    this.isKeyDown && (this.isKeyDown = false, this.props.keyName && this.props.keyName.indexOf(this.handle.shortcut) < 0 || (this.onKeyUp(e2, this.handle), this.handle = {}));
  }
  render() {
    const { global: e2, wrapperStyle: t2 } = this.props;
    return V("div", { style: t2, tabIndex: -1, onFocus: () => !e2 && this.setState({ enableHotKey: true }), onBlur: () => {
      !e2 && this.setState({ enableHotKey: false });
    }, children: this.props.children || null });
  }
}
__publicField(F, "defaultProps", { filter(e2) {
  const t2 = e2.target || e2.srcElement, i2 = t2.tagName;
  return !(!e2.metaKey || "Enter" !== e2.code) || !(t2.isContentEditable || "INPUT" === i2 || "SELECT" === i2 || "TEXTAREA" === i2);
} });
__publicField(F, "propTypes", { keyName: z.string, filter: z.func, onKeyDown: z.func, onKeyUp: z.func, disabled: z.bool, splitKey: z.string });
const B = H.div`
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-width: min-content;
`, W = H.div`
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  height: 95px;
  flex-shrink: 0;
  padding: 32px 36px 0 16px;
  border-bottom: 1px solid #e1e3eb;
`, G = H.div`
  display: flex;
  flex-direction: column;

  .taco-edit-text-wrapper {
    width: 252px;
    color: #222222;
    font-size: 18px;
    font-weight: 500;
    margin-left: -8px;

    &:hover {
      background-color: #f5f5f6;
    }
  }

  .taco-edit-text-input {
    width: 252px;
    color: #222222;
    font-weight: 500;
    font-size: 18px;
    background-color: #f5f5f6;
    border: 1px solid #3377ff;
    margin-left: -8px;

    &:focus {
      border-color: #3377ff;
      box-shadow: 0 0 0 2px #d6e4ff;
    }
  }
`, J = H.div`
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: #b8b9bf;
`, O = H.div`
  display: flex;
  align-items: center;
  gap: 12px;
`, X = H.div`
  position: relative;
  display: flex;
  height: calc(100% - 95px);
  width: 100%;
`, $ = H.div`
  position: relative;
  padding: 16px 16px 80px;
  flex-grow: 1;
  width: calc(100% - 297px);
`, _ = H.div`
  height: 100%;
  width: 297px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-left: 1px solid #e1e3eb;
`, Y = (r2) => {
  var _a;
  const { comp: o2, title: n2, subTitle: s2, headerRight: d2, bodyLeft: a2, bodyRight: l2 } = r2, p2 = o2.children.query, h2 = e(t), [c2, m2] = P();
  return T(() => {
    const e2 = new R(o2, (e3) => {
      m2((t2) => t2 ? e3(t2) : void 0);
    });
    m2(e2);
  }, []), T(() => {
    null != c2 && c2.setComp(() => o2);
  }, [o2]), c2 ? V(U.Provider, { value: c2, children: L(B, { children: [L(W, { children: [L(G, { children: [n2, L(J, { children: [i((_a = h2[p2.children.id.getView()]) == null ? void 0 : _a.createTime, 2592e6), s2] })] }), V(O, { children: d2 })] }), L(X, { children: [V($, { children: a2 }), V(_, { children: l2 })] })] }) }) : null;
}, Z = H(o)`
  position: absolute;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
  border-top: 1px solid #e1e3eb;
  z-index: ${r.queryResultPanel};
  width: 100%;
  bottom: 0;
  left: 0;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;

  .react-resizable-handle {
    position: absolute;
    border-top: transparent solid 3px;
    width: 100%;
    padding: 0 3px 3px 0;
    top: 0;
    cursor: row-resize;
  }
`, ee = H.div`
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
`, te = (e2) => {
  e2.preventDefault();
}, ie = () => {
  window.addEventListener("mousedown", te);
}, re = (e2) => {
  var _a;
  const t2 = (_a = e2.comp) == null ? void 0 : _a.result(), [i2, r2] = P(360), { header: o2, body: n2 } = Q({ ...t2 ?? { data: "", dataType: "default", success: true }, onClose: e2.onClose });
  if (!t2)
    return null;
  const s2 = document.documentElement.clientHeight;
  return V(Z, { width: 1 / 0, height: i2, resizeHandles: ["n"], minConstraints: [680, 285], maxConstraints: [1 / 0, s2 - 48 - 95], onResizeStart: ie, onResizeStop: (e3, t3) => {
    r2(t3.size.height), window.removeEventListener("mousedown", te);
  }, children: L(ee, { children: [V(A, { style: { cursor: "default" }, children: o2 }), n2] }) });
}, oe = n({ query: b(v, (e2) => V(w.Provider, { value: { datasourceId: e2.children.datasourceId.getView(), disableJSCompletion: true, placement: "queryLibrary" }, children: V(j, { comp: e2, placement: "queryLibrary" }) })), inputs: S }), ne = class extends oe {
  propertyView(e2) {
    return V(se, { comp: this, onPublish: e2.onPublish, onHistoryShow: e2.onHistoryShow, setModify: e2.setModify, modify: e2.modify });
  }
  getQueryPropertyView() {
    return this.children.query.getPropertyView();
  }
  getRightPropertyView() {
    return L(C, { children: [V(s, { name: d("prop.inputs"), width: 296, noMargin: true, children: this.children.inputs.getPropertyView() }, "inputs"), V(s, { name: d("prop.meta"), width: 296, noMargin: true, children: V("div", { style: { padding: " 0 8px" }, children: V(M, { dataSourceId: this.children.query.children.datasourceId.getView(), datasourceType: this.children.query.children.compType.getView() }) }) }, "meta")] });
  }
  nameAndExposingInfo() {
    const e2 = {};
    return this.children.inputs.getView().forEach((t2) => {
      e2[t2.children.name.getView()] = t2.exposingInfo();
    }), e2;
  }
}, se = (e2) => {
  const { comp: t2, onPublish: i2, onHistoryShow: r2, setModify: o2, modify: n2 } = e2, s2 = a(), [b2, w2] = P(false), j2 = I(null), v2 = t2.children.query.children.datasourceId.getView(), q2 = l(v2);
  T(() => {
    w2(false);
  }, [t2.children.query.children.id.getView()]);
  const k2 = () => t2.children.query.dispatch(K({ afterExecFunc: () => w2(true) }));
  return T(() => () => {
    null !== j2.current && (window.clearTimeout(j2.current), j2.current = null);
  }, []), V(p.Provider, { value: q2, children: V(h.Provider, { value: c(t2.nameAndExposingInfo(), false), children: V(F, { global: true, keyName: "command+enter", onKeyDown: k2, allowRepeat: true, wrapperStyle: { width: "100%" }, children: V(Y, { comp: t2, title: V(m, { text: t2.children.query.children.name.getView(), maxLength: 255, onFinish: (e3) => e3 !== t2.children.query.children.name.getView() && t2.dispatch(u(t2.children.query.children.name.getView(), e3)) }), headerRight: L(C, { children: [V(y, { items: [{ text: d("queryLibrary.publish"), onClick: i2 }, { text: d("queryLibrary.historyVersion"), onClick: r2 }], del: () => f.confirm({ title: d("queryLibrary.deleteQueryLabel"), content: d("queryLibrary.deleteQueryContent"), onConfirm: () => {
    s2(g({ queryLibraryId: t2.children.query.children.id.getView() })), null !== j2.current && (window.clearTimeout(j2.current), j2.current = null), j2.current = window.setTimeout(() => {
      o2(!n2);
    }, 500);
  }, confirmBtnType: "delete", okText: d("delete") }), children: V(ae, { children: V(de, { tabIndex: -1 }) }) }), L(pe, { onClick: k2, loading: t2.children.query.children.isFetching.getView(), buttonType: "primary", children: [V(le, {}), d("queryLibrary.run")] })] }), bodyLeft: L(C, { children: [t2.getQueryPropertyView(), b2 && V(re, { comp: t2.children.query, onClose: () => w2(false) })] }), bodyRight: V(x, { children: t2.getRightPropertyView() }) }) }) }) });
}, de = H(q)`
  flex-shrink: 0;

  g {
    fill: #8b8fa3;
  }
`, ae = H.div`
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 32px;
  width: 32px;
  border: 1px solid #d7d9e0;
  border-radius: 4px;

  &:hover {
    background-color: #f5f5f6;
    border: 1px solid #d7d9e0;

    g {
      fill: #222222;
    }
  }
`, le = H(k)`
  transform: rotate(-90deg);
  display: inline-block;
  padding-right: 2px;
  margin-right: 4px;
`, pe = H(E)`
  padding: 0;
  width: 80px;
  height: 32px;
  border: none;

  &:hover {
    padding: 0;
    border: none;
    box-shadow: none;
  }

  &:focus {
    padding: 0;
    border: none;
    box-shadow: none;
  }

  &:after {
    content: "";
  }
`;
export {
  ne as QueryLibraryComp
};
