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, iK as t, iL as i, iF as r, iJ as o, f as n, fV as s, av as d, dV as a, iM as l, iN as p, iO as h, d6 as c, fp as m, gB as u, gF as y, fs as f, iP as g, fU as x, e as b, iQ as w, iR as j, Q as v, dG as K, gG as k, iS as q, fv as V } from "./index-6d97e67f.js";
import "./lodash-226cb5b1.js";
import { lA as E, lR as L, lS as D } from "./ant-design-icons-a81e6d18.js";
import "./loglevel-5e7e37fc.js";
import C, { useState as P, useEffect as T, useRef as R } from "react";
import { Q as I, a as S, I as U } from "./inputListComp-cd869951.js";
import { d as z } from "./styled-components-b776227d.js";
import { p as H } from "./fontawesome-7bcd29b1.js";
import { h as N } from "./hotkeys-js-216206c9.js";
import { D as M } from "./BottomMetaDrawer-0d8ad1f3.js";
import { u as F, H as Q } from "./index-4bbbae28.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 "./dnd-kit-e0a0bf75.js";
import "./moment-d731d247.js";
import "./crypto-js-8020edb5.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 "./codemirror-8fe65581.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./redux-saga-3b3a9c7b.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";
class A extends C.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 E("div", { style: t2, tabIndex: -1, onFocus: () => !e2 && this.setState({ enableHotKey: true }), onBlur: () => {
      !e2 && this.setState({ enableHotKey: false });
    }, children: this.props.children || null });
  }
}
__publicField(A, "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(A, "propTypes", { keyName: H.string, filter: H.func, onKeyDown: H.func, onKeyUp: H.func, disabled: H.bool, splitKey: H.string });
const B = z.div`
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-width: min-content;
`, G = z.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;
`, J = z.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;
    }
  }
`, O = z.div`
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: #b8b9bf;
`, W = z.div`
  display: flex;
  align-items: center;
  gap: 12px;
`, X = z.div`
  position: relative;
  display: flex;
  height: calc(100% - 95px);
  width: 100%;
`, Z = z.div`
  position: relative;
  padding: 16px 16px 80px;
  flex-grow: 1;
  width: calc(100% - 297px);
`, $ = z.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 S(o2, (e3) => {
      m2((t2) => t2 ? e3(t2) : void 0);
    });
    m2(e2);
  }, []), T(() => {
    null != c2 && c2.setComp(() => o2);
  }, [o2]), c2 ? E(I.Provider, { value: c2, children: L(B, { children: [L(G, { children: [L(J, { children: [n2, L(O, { children: [i((_a = h2[p2.children.id.getView()]) == null ? void 0 : _a.createTime, 2592e6), s2] })] }), E(W, { children: d2 })] }), L(X, { children: [E(Z, { children: a2 }), E($, { children: l2 })] })] }) }) : null;
}, _ = z(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 = z.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 } = F({ ...t2 ?? { data: "", dataType: "default", success: true }, onClose: e2.onClose });
  if (!t2)
    return null;
  const s2 = document.documentElement.clientHeight;
  return E(_, { 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: [E(Q, { style: { cursor: "default" }, children: o2 }), n2] }) });
}, oe = n({ query: b(v, (e2) => E(w.Provider, { value: { datasourceId: e2.children.datasourceId.getView(), disableJSCompletion: true, placement: "queryLibrary" }, children: E(j, { comp: e2, placement: "queryLibrary" }) })), inputs: U }), ne = class extends oe {
  propertyView(e2) {
    return E(se, { comp: this, onPublish: e2.onPublish, onHistoryShow: e2.onHistoryShow, setModify: e2.setModify, modify: e2.modify });
  }
  getQueryPropertyView() {
    return this.children.query.getPropertyView();
  }
  getRightPropertyView() {
    return L(D, { children: [E(s, { name: d("prop.inputs"), width: 296, noMargin: true, children: this.children.inputs.getPropertyView() }, "inputs"), E(s, { name: d("prop.meta"), width: 296, noMargin: true, children: E("div", { style: { padding: " 0 8px" }, children: E(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 = R(null), v2 = t2.children.query.children.datasourceId.getView(), k2 = l(v2);
  T(() => {
    w2(false);
  }, [t2.children.query.children.id.getView()]);
  const q2 = () => t2.children.query.dispatch(K({ afterExecFunc: () => w2(true) }));
  return T(() => () => {
    null !== j2.current && (window.clearTimeout(j2.current), j2.current = null);
  }, []), E(p.Provider, { value: k2, children: E(h.Provider, { value: c(t2.nameAndExposingInfo(), false), children: E(A, { global: true, keyName: "command+enter", onKeyDown: q2, allowRepeat: true, wrapperStyle: { width: "100%" }, children: E(Y, { comp: t2, title: E(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(D, { children: [E(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: E(ae, { children: E(de, { tabIndex: -1 }) }) }), L(pe, { onClick: q2, loading: t2.children.query.children.isFetching.getView(), buttonType: "primary", children: [E(le, {}), d("queryLibrary.run")] })] }), bodyLeft: L(D, { children: [t2.getQueryPropertyView(), b2 && E(re, { comp: t2.children.query, onClose: () => w2(false) })] }), bodyRight: E(x, { children: t2.getRightPropertyView() }) }) }) }) });
}, de = z(k)`
  flex-shrink: 0;

  g {
    fill: #8b8fa3;
  }
`, ae = z.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 = z(q)`
  transform: rotate(-90deg);
  display: inline-block;
  padding-right: 2px;
  margin-right: 4px;
`, pe = z(V)`
  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
};
