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 { gz as e, gA as r, av as o, gB as i, f9 as t, f as n, e as a, cG as s, gC as c, v as l, gD as d, gE as p, cs as h, ct as m, gF as u, d_ as f, gG as g, fv as y, gH as b } from "./index-0c01125c.js";
import "./lodash-226cb5b1.js";
import { lA as x, lR as v, lS as w } from "./ant-design-icons-14ab96af.js";
import "./loglevel-5e7e37fc.js";
import k, { useState as C, useContext as L, useEffect as V, Fragment as q } from "react";
import { d as I } from "./styled-components-c6abe9a3.js";
class A {
  constructor(e2, r2) {
    __publicField(this, "queryLibraryComp");
    __publicField(this, "setQueryLibraryState");
    this.queryLibraryComp = e2, this.setQueryLibraryState = r2;
  }
  changeStateFn(r2) {
    this.setQueryLibraryState((o2) => {
      const i2 = r2(o2);
      return e(o2, i2);
    });
  }
  setComp(e2) {
    this.changeStateFn((r2) => ({ queryLibraryComp: e2(r2.queryLibraryComp) }));
  }
  getNameGenerator() {
    const e2 = new t(), r2 = this.nameAndExposingInfo();
    return e2.init(Object.keys(r2)), e2;
  }
  nameAndExposingInfo() {
    return this.queryLibraryComp.nameAndExposingInfo();
  }
  checkRename(e2, i2) {
    const t2 = r(i2);
    return t2 || (i2 !== e2 && this.nameAndExposingInfo().hasOwnProperty(i2) ? o("query.nameExists", { name: i2 }) : "");
  }
  rename(e2, r2) {
    return !this.checkRename(e2, r2) && (r2 !== e2 && this.queryLibraryComp.dispatch(i(e2, r2)), true);
  }
}
const j = k.createContext(void 0), S = { name: c, description: l(""), value: d }, E = (e2) => {
  const [r2, i2] = C(e2.showPopover), t2 = L(j), n2 = e2.comp.children.name.getView();
  return v("div", { style: { position: "relative", width: "100%" }, children: [e2.comp.children.value.propertyView({ key: n2, label: x(p, { visible: r2, setVisible: i2, content: v(w, { children: [e2.comp.children.name.propertyView({ label: o("queryLibrary.inputName"), onValidate: (e3, r3) => t2.checkRename(e3, r3), onFinish: (e3, r3) => t2.rename(e3, r3) }), x(h, { label: o("queryLibrary.inputDesc"), children: x(m, { value: e2.comp.children.description.getView(), onChange: (r3) => {
    e2.comp.children.description.dispatchChangeValueAction(r3.target.value);
  } }) })] }), title: o("edit"), children: x("div", { style: { cursor: "pointer" }, children: n2 }) }), layout: "vertical", tooltip: e2.comp.children.description.getView() }), x(u, { items: [{ text: o("edit"), onClick: () => i2(true) }], del: e2.onDelete, children: x(R, { tabIndex: -1 }) })] });
}, F = b(class extends n(S) {
  propertyView(e2) {
    return x(E, { comp: this, ...e2 });
  }
}, {}, (e2) => e2.children.value.exposingNode()), N = I.div`
  padding: 0 16px;
`, R = I(g)`
  cursor: pointer;
  flex-shrink: 0;
  position: absolute;
  top: 0;
  right: 0;

  g {
    fill: #8b8fa3;
  }

  &:hover {
    background: #eef0f3;
    border-radius: 4px;
    cursor: pointer;

    g {
      fill: #3377ff;
    }
  }
`, _ = I(y)`
  height: 28px;
  width: 70px;
  background-color: #fafbff;
  color: #4965f2;
  border-color: #c9d1fc;
  display: flex;
  align-items: center;
  box-shadow: none;

  &:hover {
    color: #315efb;
    background-color: #f5faff;
    border-color: #c2d6ff;
  }

  &:focus {
    color: #315efb;
    background-color: #f5faff;
    border-color: #c2d6ff;
  }

  &:disabled,
  &:disabled:hover {
    background: #f9fbff;
    border: 1px solid #dee9ff;
    border-radius: 4px;
  }
`, D = I.div`
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
`, G = a(s(F), (e2) => {
  const r2 = L(j), [i2, t2] = C(void 0);
  V(() => {
    t2(void 0);
  }, [e2]);
  const n2 = () => {
    e2.dispatch(e2.pushAction({ name: r2.getNameGenerator().genItemName("queryInput") })), t2(e2.getView().length);
  };
  return x(N, { children: e2.getView().length > 0 ? v(D, { children: [e2.getView().map((r3, o2) => x(q, { children: r3.propertyView({ onDelete: () => e2.dispatch(e2.deleteAction(o2)), showPopover: o2 === i2 }) }, o2)), x(_, { onClick: n2, children: o("addItem") })] }) : x(f, { text: v(w, { children: [x("div", { children: o("queryLibrary.emptyInputs") }), x("span", { style: { color: "#4965f2", cursor: "pointer", margin: "0 4px" }, onClick: n2, children: o("queryLibrary.clickToAdd") })] }) }) });
}), O = Object.freeze(Object.defineProperty({ __proto__: null, InputListComp: G }, Symbol.toStringTag, { value: "Module" }));
export {
  G as I,
  j as Q,
  A as a,
  O as i
};
