import { reactive as X, shallowRef as ve, computed as M, watch as W, watchEffect as $e, onMounted as Fe, onUnmounted as De, onDeactivated as Ce, toRefs as ce, defineComponent as Y, resolveComponent as S, openBlock as m, createElementBlock as k, normalizeClass as T, unref as s, createVNode as y, withCtx as p, Fragment as U, renderList as Q, createBlock as L, createElementVNode as C, toDisplayString as j, createSlots as ye, createTextVNode as F, createCommentVNode as D, withModifiers as he, ref as We, isRef as oe } from "vue";
import { u as Ue, i as Be, f as Me, g as Qe, b as Z } from "./layer-select-Ba4IEiWY.js";
import { i as ue, a as xe, u as Ee, _ as ee } from "./utils-B4smQbM-.js";
import "./vendor-D4icwOYu.js";
import "ant-design-vue";
import "@mapgis/webclient-common";
const Ke = {
  /**
   * @description 图层ID
   * @type String
   */
  layerId: {
    type: String
  },
  /**
   * @description 子图层ID
   * @type String
   */
  sublayerId: {
    type: String
  },
  /**
   * @description 图层对象，可以是webclient-common库的图层对象或者子图层对象
   * @type zondy.layer.Layer | zondy.layer.Sublayer
   */
  layer: {
    type: Object
  },
  /**
   * @description 过滤表达式
   */
  filterExpression: {
    type: String,
    default: ""
  },
  /**
   * @description 是否显示属性过滤查询方式
   */
  showAttributeSearchType: {
    type: Boolean,
    default: !1
  },
  /**
   * @description 要素id过滤条件
   */
  featureIds: {
    type: Array,
    default: () => []
  },
  /**
   * @description 查询参数
   */
  layerQueryOptions: {
    type: Object
  }
}, Ve = {
  "update:filterExpression": (e) => ue(e),
  submit: (e, t) => ue(e) && xe(t),
  reset: (e, t) => ue(e) && xe(t)
};
function A(e, t, i, n = "literal") {
  return {
    id: Ee(),
    type: "base",
    field: e ?? void 0,
    operator: t ?? void 0,
    value: i ?? null,
    valueType: n ?? "literal"
  };
}
function Ne(e, t) {
  return {
    id: Ee(),
    type: "group",
    operator: e,
    expressions: t,
    activeId: ""
  };
}
function G(e, t) {
  return {
    type: "compound",
    operator: e,
    expressions: t
  };
}
function pe(e) {
  const { field: t, operator: i, value: n, valueType: a } = e;
  if (t === null || t === "")
    return "";
  switch (i) {
    case "IS NULL":
    case "IS NOT NULL":
      return `${t} ${i}`;
    case "BETWEEN AND":
      if (Array.isArray(n) && n.length === 2 && n[0] !== null && n[1] !== null)
        return `${t} BETWEEN ${n[0]} AND ${n[1]}`;
      break;
    case "NOT BETWEEN AND":
      if (Array.isArray(n) && n.length === 2 && n[0] !== null && n[1] !== null)
        return `${t} NOT BETWEEN ${n[0]} AND ${n[1]}`;
      break;
    case "LIKE 'x%'":
      if (n !== null)
        return `${t} LIKE '${n}%'`;
      break;
    case "LIKE '%x'":
      if (n !== null)
        return `${t} LIKE '%${n}'`;
      break;
    case "LIKE '%x%'":
      if (n !== null)
        return `${t} LIKE '%${n}%'`;
      break;
    case "NOT LIKE '%x%'":
      if (n !== null)
        return `${t} NOT LIKE '%${n}%'`;
      break;
    default:
      if (n !== null && i !== null && i !== "")
        return a === "field" ? `${t} ${i} ${n}` : typeof n == "number" ? `${t} ${i} ${n}` : `${t} ${i} '${n}'`;
      break;
  }
  return "";
}
function de(e) {
  const { operator: t, expressions: i } = e;
  if (!i || i.length === 0)
    return "";
  const n = i.map((a) => a.type === "base" ? pe(a) : `(${de(a)})`).filter((a) => a.length > 0);
  return n.length === 0 ? "" : `(${n.join(` ${t} `)})`;
}
function be(e) {
  const { operator: t, expressions: i } = e;
  return !i || i.length === 0 ? "" : i.map((a) => a.type === "base" ? pe(a) : de(a)).filter((a) => a.length > 0).join(` ${t} `);
}
function J(e) {
  if (!e || !e.trim()) return G("AND", []);
  const t = e.trim();
  if (t.startsWith("(") && t.endsWith(")")) {
    let l = 0, u = !0;
    for (let o = 0; o < t.length; o++)
      if (t[o] === "(")
        l++;
      else if (t[o] === ")" && (l--, l === 0 && o < t.length - 1)) {
        u = !1;
        break;
      }
    if (u)
      return J(t.slice(1, -1));
  }
  let i = 0;
  const n = [], a = [], d = (l, u, o) => u < 0 || u + o.length > l.length ? !1 : l.substring(u, u + o.length).toUpperCase() === o.toUpperCase(), h = (l, u) => {
    if (u < 0 || u >= l.length) return !0;
    const o = l[u];
    return /\s/.test(o) || o === "(" || o === ")";
  }, r = ge(t);
  if (r && (r.operator === "BETWEEN AND" || r.operator === "NOT BETWEEN AND"))
    return G("AND", [r]);
  for (let l = 0; l < t.length; l++) {
    const u = t[l];
    if (u === "(")
      i++;
    else if (u === ")")
      i--;
    else if (i === 0)
      if (d(t, l, "AND") && h(t, l - 1) && h(t, l + 3)) {
        const o = t.substring(0, l).toUpperCase(), v = o.match(/\bBETWEEN\s+[^AND]+$/), N = o.match(/\bNOT\s+BETWEEN\s+[^AND]+$/);
        !v && !N && n.push(l);
      } else d(t, l, "OR") && h(t, l - 1) && h(t, l + 2) && a.push(l);
  }
  if (a.length > 0) {
    const l = [];
    let u = 0;
    for (const N of a.sort((b, c) => b - c)) {
      const b = t.slice(u, N).trim(), c = le(b);
      c && l.push(c), u = N + 2;
    }
    const o = t.slice(u).trim(), v = le(o);
    return v && l.push(v), G("OR", l);
  }
  if (n.length > 0) {
    const l = [];
    let u = 0;
    for (const N of n.sort((b, c) => b - c)) {
      const b = t.slice(u, N).trim(), c = le(b);
      c && l.push(c), u = N + 3;
    }
    const o = t.slice(u).trim(), v = le(o);
    return v && l.push(v), G("AND", l);
  }
  return r ? G("AND", [r]) : G("AND", []);
}
function le(e) {
  if (!e.trim()) return null;
  const t = e.trim();
  if (t.startsWith("(") && t.endsWith(")")) {
    let i = 0, n = !0;
    for (let a = 0; a < t.length; a++)
      if (t[a] === "(")
        i++;
      else if (t[a] === ")" && (i--, i === 0 && a < t.length - 1)) {
        n = !1;
        break;
      }
    if (n) {
      const a = J(t.slice(1, -1));
      if (a)
        return Ne(a.operator, a.expressions || []);
    }
  }
  return ge(t);
}
function ge(e) {
  const t = e.trim(), i = t.match(/^([^\(\)]+?)\s+(IS\s+NOT\s+NULL)$/i);
  if (i) {
    const c = i[1].trim();
    return A(c, "IS NOT NULL");
  }
  const n = t.match(/^([^\(\)]+?)\s+(IS\s+NULL)$/i);
  if (n) {
    const c = n[1].trim();
    return A(c, "IS NULL");
  }
  const a = t.match(/^([^\(\)]+?)\s+(NOT\s+BETWEEN)\s+([^\s]+?)\s+(AND)\s+([^\s]+?)$/i);
  if (a) {
    const c = a[1].trim(), x = a[3].trim(), g = a[5].trim(), _ = parseFloat(x), O = parseFloat(g);
    if (!isNaN(_) && !isNaN(O))
      return A(c, "NOT BETWEEN AND", [_, O]);
  }
  const d = t.match(/^([^\(\)]+?)\s+(BETWEEN)\s+([^\s]+?)\s+(AND)\s+([^\s]+?)$/i), h = t.match(/^([^\(\)]+?)\s+(NOT\s+BETWEEN)\s+([^\s]+?)\s+(AND)\s+([^\s]+?)$/i);
  if (d && !h) {
    const c = d[1].trim(), x = d[3].trim(), g = d[5].trim(), _ = parseFloat(x), O = parseFloat(g);
    if (!isNaN(_) && !isNaN(O))
      return A(c, "BETWEEN AND", [_, O]);
  }
  const r = t.match(/^([^\(\)]+?)\s+(between)\s+([^\s]+?)\s+(and)\s+([^\s]+?)$/i), l = t.match(/^([^\(\)]+?)\s+(not\s+between)\s+([^\s]+?)\s+(and)\s+([^\s]+?)$/i);
  if (r && !l) {
    const c = r[1].trim(), x = r[3].trim(), g = r[5].trim(), _ = parseFloat(x), O = parseFloat(g);
    if (!isNaN(_) && !isNaN(O))
      return A(c, "BETWEEN AND", [_, O]);
  }
  const u = t.match(/^([^\(\)]+?)\s+(not\s+between)\s+([^\s]+?)\s+(and)\s+([^\s]+?)$/i);
  if (u) {
    const c = u[1].trim(), x = u[3].trim(), g = u[5].trim(), _ = parseFloat(x), O = parseFloat(g);
    if (!isNaN(_) && !isNaN(O))
      return A(c, "NOT BETWEEN AND", [_, O]);
  }
  const o = t.match(/^([^\(\)]+?)\s+(NOT\s+LIKE)\s+(.+)$/i);
  if (o) {
    const c = o[1].trim(), x = o[3].trim();
    if (x.startsWith("'%") && x.endsWith("%'")) {
      const g = x.slice(2, -2);
      return A(c, "NOT LIKE '%x%'", g);
    }
  }
  const v = t.match(/^([^\(\)]+?)\s+(LIKE)\s+(.+)$/i), N = t.match(/^([^\(\)]+?)\s+(NOT\s+LIKE)\s+(.+)$/i);
  if (v && !N) {
    const c = v[1].trim(), x = v[3].trim();
    if (x.startsWith("'%") && x.endsWith("%'")) {
      const g = x.slice(2, -2);
      return A(c, "LIKE '%x%'", g);
    } else if (x.startsWith("'") && x.endsWith("%'")) {
      const g = x.slice(1, -2);
      return A(c, "LIKE 'x%'", g);
    } else if (x.startsWith("'%") && x.endsWith("'")) {
      const g = x.slice(2, -1);
      return A(c, "LIKE '%x'", g);
    }
  }
  const b = [">=", "<=", "<>", "!=", ">", "<", "="];
  for (const c of b) {
    const x = c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), g = new RegExp(`^([^\\(\\)]+?)\\s+(${x})\\s+(.+)$`, "i"), _ = t.match(g);
    if (_) {
      const O = _[1].trim(), $ = _[3].trim(), K = $.startsWith("'") && $.endsWith("'") || $.startsWith('"') && $.endsWith('"'), f = K ? $.slice(1, -1) : $;
      let V;
      const z = "literal";
      if (K)
        V = f;
      else {
        const R = Number(f);
        !isNaN(R) ? V = R : V = f;
      }
      return A(O, c === "<>" ? "!=" : c, V, z);
    }
  }
  return null;
}
const ze = (e, t, i) => {
  const { zondy: n, map: a } = Ue(), { LayerType: d, SubLayerType: h } = n.enum, r = X({
    // 选择的图层ID
    selectedLayerId: "",
    // 图层ID
    layerId: e.layerId,
    // 子图层ID
    sublayerId: e.sublayerId,
    // 过滤表达式（字符串类型）
    filterExpression: "",
    // 符合表达式（对象类型）
    compoundExpression: J(e.filterExpression),
    // 字段列表
    fields: [],
    // 图层类型列表
    layerTypes: [d.ArcGISMapImage, d.IGSMapImage, d.IGSFeature],
    // 子图层类型列表
    sublayerTypes: [h.ArcGISMapImageSub, h.IGSMapImageSub],
    // 要素id过滤条件
    featureIds: e.featureIds,
    // 要素id可选值
    valueOptions: [],
    // 查询类型
    searchType: "condition"
  }), l = ve(e.layer), u = ve(null), o = M(() => l.value ? Be(l.value, n) ? {
    title: l.value.title,
    tip: `${l.value.layer.title}/${l.value.title}`
  } : {
    title: l.value.title,
    tip: l.value.title
  } : null), v = M(() => !!l.value), N = M(() => !(e.layer || e.layerId && e.layerId !== "")), b = M(() => r.searchType === "condition"), c = M(() => r.searchType === "featureId");
  W([() => e.layerId, () => e.sublayerId], () => {
    z();
  }), W(
    () => e.layer,
    () => {
      l.value = e.layer, z();
    }
  ), W(
    () => r.searchType,
    () => {
      c.value && H();
    }
  ), $e(async () => {
    R(), l.value && (u.value = Me(l.value), r.fields = await u.value.getFields(), $(), c.value && await H());
  }), W(
    () => r.compoundExpression,
    () => {
      r.filterExpression = be(r.compoundExpression);
    },
    {
      immediate: !0,
      deep: !0
    }
  ), W(
    () => e.filterExpression,
    () => {
      r.compoundExpression = J(e.filterExpression);
    }
  ), W(
    () => e.featureIds,
    () => {
      r.featureIds = e.featureIds;
    }
  ), Fe(() => {
    z();
  }), De(() => {
  }), Ce(() => {
  });
  function x() {
  }
  function g() {
    t("update:filterExpression", r.filterExpression), t(
      "submit",
      b.value ? r.filterExpression : "",
      c.value ? r.featureIds : []
    );
  }
  function _() {
    r.compoundExpression = J(e.filterExpression), r.filterExpression = be(r.compoundExpression), r.featureIds = e.featureIds, t("update:filterExpression", r.filterExpression), t("reset", r.filterExpression, r.featureIds);
  }
  function O() {
    l.value = i.value.getSelectLayers()[0], z(), r.compoundExpression = G("AND", []), r.featureIds = [];
  }
  function $() {
    const w = A();
    r.compoundExpression.activeId = w.id, r.compoundExpression.expressions.push(w);
  }
  function K() {
    const w = [];
    w.push(A());
    const B = Ne("AND", w);
    B.activeId = w[0].id, r.compoundExpression.activeId = B.id, r.compoundExpression.expressions.push(B);
  }
  function f(w) {
    r.compoundExpression.expressions.splice(w, 1);
  }
  function V() {
    r.compoundExpression = G("AND", []);
  }
  function z() {
    l.value || Qe({
      layerId: e.layerId,
      sublayerId: e.sublayerId,
      map: a,
      callback: (w) => {
        l.value = w;
      }
    });
  }
  async function H() {
    if (!l.value) return;
    let w;
    [h.IGSMapImageSub, d.IGSFeature].includes(l.value.type) ? w = "FID" : w = "objectid";
    const B = e.layerQueryOptions ? { ...e.layerQueryOptions } : {}, te = await u.value.queryFeaturesCount(B);
    B.pageSize = te;
    const se = await u.value.queryFeatures(B);
    r.valueOptions = se.map((q) => q.attributes[w]);
  }
  function R() {
    r.fields = [], u.value = null;
  }
  return {
    ...ce(r),
    layerService: u,
    // 下面是计算属性
    attributeFilterLayerTitlePair: o,
    attributeFilterEnabled: v,
    showLayerSelect: N,
    isConditionSearch: b,
    isFeatureIdSearch: c,
    // 下面是方法
    clearState: x,
    apply: g,
    reset: _,
    handleLayerSelectChange: O,
    handleAddExpression: $,
    handleAddExpressionGroup: K,
    handleDeleteExpression: f,
    handleClearExpressions: V
  };
}, Ge = (e, t) => {
  const i = X({
    valueOptions: [],
    isNumberValue: !1,
    isUniqueField: !1,
    numberOperators: [
      { label: "等于", value: "=" },
      { label: "不等于", value: "!=" },
      { label: "大于", value: ">" },
      { label: "小于", value: "<" },
      { label: "最大为", value: "<=" },
      { label: "最小为", value: ">=" },
      { label: "介于", value: "BETWEEN AND" },
      { label: "不介于", value: "NOT BETWEEN AND" },
      { label: "为空", value: "IS NULL" },
      { label: "不为空", value: "IS NOT NULL" }
    ],
    stringOperators: [
      { label: "等于", value: "=" },
      { label: "不等于", value: "!=" },
      { label: "为空", value: "IS NULL" },
      { label: "不为空", value: "IS NOT NULL" },
      { label: "开头是", value: "LIKE 'x%'" },
      { label: "结尾是", value: "LIKE '%x'" },
      { label: "包含", value: "LIKE '%x%'" },
      { label: "不包含", value: "NOT LIKE '%x%'" }
    ],
    supportedNumberFieldTypes: ["long", "short", "int", "float", "double"],
    supportedStringFieldTypes: ["string"],
    supportedUniqueFieldTypes: ["long", "short", "int", "string"]
  }), n = M(() => e.fields.filter((o) => i.supportedNumberFieldTypes.concat(i.supportedStringFieldTypes).includes(o.type))), a = M(() => {
    const o = n.value.find((v) => v.name === e.expression.field);
    if (o) {
      if (i.supportedNumberFieldTypes.includes(o.type))
        return i.numberOperators;
      if (i.supportedStringFieldTypes.includes(o.type))
        return i.stringOperators;
    }
    return [];
  }), d = M(() => e.expression.operator === "BETWEEN AND" || e.expression.operator === "NOT BETWEEN AND"), h = M(() => e.expression.operator === "IS NULL" || e.expression.operator === "IS NOT NULL");
  W(
    () => e.expression.field,
    () => {
      const o = n.value.find((v) => v.name === e.expression.field);
      o ? (i.isNumberValue = i.supportedNumberFieldTypes.includes(o.type), i.isUniqueField = i.supportedUniqueFieldTypes.includes(o.type)) : (i.isNumberValue = !1, i.isUniqueField = !1), l();
    },
    { immediate: !0 }
  ), W(
    () => e.layerService,
    () => {
      l();
    }
  );
  function r() {
    u();
  }
  async function l() {
    if (i.valueOptions = [], e.layerService && e.expression.field) {
      let o = await e.layerService.getUniqueValues(e.expression.field, e.layerQueryOptions);
      (i.isNumberValue || i.isUniqueField) && n.value.find((N) => N.name === e.expression.field).type !== "string" && (o = o.map((N) => Number(N))), i.valueOptions = o;
    }
  }
  function u() {
    d.value ? e.expression.value = [null, null] : e.expression.value = null;
  }
  return {
    ...ce(i),
    // 下面是计算属性
    validFields: n,
    validOperators: a,
    isBetweenOperator: d,
    isNullOperator: h,
    // 下面是方法
    handleExpressionChange: r
  };
}, je = ["title"], Re = ["title"], He = /* @__PURE__ */ Y({
  name: "MapgisAttributeFilterItem",
  __name: "attribute-filter-item",
  props: {
    expression: {
      type: Object
    },
    fields: {
      type: Array
    },
    layerService: {
      type: Object
    },
    layerQueryOptions: {
      type: Object
    }
  },
  emits: {},
  setup(e, { emit: t }) {
    const i = e, n = Z("attribute-filter-item"), {
      valueOptions: a,
      isNumberValue: d,
      isUniqueField: h,
      // 下面是计算属性
      validFields: r,
      validOperators: l,
      isBetweenOperator: u,
      isNullOperator: o,
      // 下面是方法
      handleExpressionChange: v
    } = Ge(i);
    return (N, b) => {
      const c = S("a-select-option"), x = S("a-select"), g = S("a-input-number"), _ = S("a-col"), O = S("a-row"), $ = S("a-input"), K = S("a-space");
      return m(), k("div", {
        class: T([s(n).b()])
      }, [
        y(K, {
          direction: "vertical",
          class: T(s(n).e("expression")),
          size: 4
        }, {
          default: p(() => [
            y(x, {
              value: e.expression.field,
              "onUpdate:value": b[0] || (b[0] = (f) => e.expression.field = f),
              placeholder: "请选择字段",
              dropdownMatchSelectWidth: !1,
              onChange: s(v)
            }, {
              default: p(() => [
                (m(!0), k(U, null, Q(s(r), (f) => (m(), L(c, {
                  key: f.name
                }, {
                  default: p(() => [
                    C("span", {
                      title: f.alias || f.name
                    }, j(f.alias || f.name), 9, je)
                  ]),
                  _: 2
                }, 1024))), 128))
              ]),
              _: 1
            }, 8, ["value", "onChange"]),
            y(x, {
              value: e.expression.operator,
              "onUpdate:value": b[1] || (b[1] = (f) => e.expression.operator = f),
              placeholder: "请选择运算符",
              dropdownMatchSelectWidth: !1,
              onChange: s(v)
            }, {
              default: p(() => [
                (m(!0), k(U, null, Q(s(l), (f) => (m(), L(c, {
                  key: f.value
                }, {
                  default: p(() => [
                    C("span", {
                      title: f.label
                    }, j(f.label), 9, Re)
                  ]),
                  _: 2
                }, 1024))), 128))
              ]),
              _: 1
            }, 8, ["value", "onChange"]),
            s(o) ? D("", !0) : (m(), L(O, { key: 0 }, {
              default: p(() => [
                y(_, { span: 24 }, {
                  default: p(() => [
                    s(u) ? (m(), L(O, {
                      key: 0,
                      gutter: 4,
                      class: T(s(n).e("expression"))
                    }, {
                      default: p(() => [
                        y(_, { span: 12 }, {
                          default: p(() => [
                            y(g, {
                              placeholder: "起始值",
                              value: e.expression.value[0],
                              "onUpdate:value": b[2] || (b[2] = (f) => e.expression.value[0] = f)
                            }, null, 8, ["value"])
                          ]),
                          _: 1
                        }),
                        y(_, { span: 12 }, {
                          default: p(() => [
                            y(g, {
                              placeholder: "结束值",
                              value: e.expression.value[1],
                              "onUpdate:value": b[3] || (b[3] = (f) => e.expression.value[1] = f)
                            }, null, 8, ["value"])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    }, 8, ["class"])) : s(d) ? (m(), L(g, {
                      key: 1,
                      placeholder: "请输入值",
                      value: e.expression.value,
                      "onUpdate:value": b[5] || (b[5] = (f) => e.expression.value = f),
                      class: T(s(n).e("options"))
                    }, ye({ _: 2 }, [
                      s(h) ? {
                        name: "addonAfter",
                        fn: p(() => [
                          y(x, {
                            value: e.expression.value,
                            "onUpdate:value": b[4] || (b[4] = (f) => e.expression.value = f),
                            dropdownStyle: {
                              minWidth: "100px"
                            }
                          }, {
                            default: p(() => [
                              (m(!0), k(U, null, Q(s(a), (f) => (m(), L(c, {
                                key: f,
                                title: f
                              }, {
                                default: p(() => [
                                  F(j(f), 1)
                                ]),
                                _: 2
                              }, 1032, ["title"]))), 128))
                            ]),
                            _: 1
                          }, 8, ["value"])
                        ]),
                        key: "0"
                      } : void 0
                    ]), 1032, ["value", "class"])) : (m(), L($, {
                      key: 2,
                      placeholder: "请输入值",
                      value: e.expression.value,
                      "onUpdate:value": b[7] || (b[7] = (f) => e.expression.value = f),
                      class: T(s(n).e("options"))
                    }, ye({ _: 2 }, [
                      s(h) ? {
                        name: "addonAfter",
                        fn: p(() => [
                          y(x, {
                            value: e.expression.value,
                            "onUpdate:value": b[6] || (b[6] = (f) => e.expression.value = f),
                            dropdownStyle: {
                              minWidth: "100px"
                            }
                          }, {
                            default: p(() => [
                              (m(!0), k(U, null, Q(s(a), (f) => (m(), L(c, {
                                key: f,
                                title: f
                              }, {
                                default: p(() => [
                                  F(j(f), 1)
                                ]),
                                _: 2
                              }, 1032, ["title"]))), 128))
                            ]),
                            _: 1
                          }, 8, ["value"])
                        ]),
                        key: "0"
                      } : void 0
                    ]), 1032, ["value", "class"]))
                  ]),
                  _: 1
                })
              ]),
              _: 1
            }))
          ]),
          _: 1
        }, 8, ["class"])
      ], 2);
    };
  }
}), Ie = /* @__PURE__ */ ee(He, [["__scopeId", "data-v-21817179"]]), qe = (e, t) => {
  const i = X({});
  function n(a) {
    e.expression.expressions.splice(a, 1);
  }
  return {
    ...ce(i),
    // 下面是计算属性
    // 下面是方法
    handleDeleteExpression: n
  };
}, Pe = ["title"], Je = ["title", "onClick"], Xe = /* @__PURE__ */ Y({
  name: "MapgisAttributeFilterItemHeader",
  __name: "attribute-filter-item-header",
  props: {
    expression: {
      type: Object
    }
  },
  emits: {
    delete: () => !0
  },
  setup(e, { emit: t }) {
    const i = e, n = t, a = Z("attribute-filter-item-header"), d = X({
      commands: [
        {
          id: "delete",
          icon: "mapgis-delete",
          label: "删除",
          action: h
        }
      ],
      baseExpression: "",
      icon: '<svg t="1756292572702" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13162" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M902.4 123v778.4H124V123h778.4m28.8-58.8h-836c-16.6 0-30 13.4-30 30v836c0 16.6 13.4 30 30 30h836c16.6 0 30-13.4 30-30v-836c0-16.5-13.4-30-30-30z" p-id="13163"></path><path d="M288.8 627.6c-25.6 0-46-6.3-61.4-18.8S203 579.7 200.5 559h53.3c1.9 8.5 5.8 15.1 12 19.6 6.9 5.2 15.4 7.8 25.4 7.8h10c22.8 0 36.2-10.7 36.2-30.5 0-13.2-7.8-22-23.2-26.2l-50.6-14c-38.1-10.7-57-31.3-57-62.1 0-20.6 7.8-37.6 23.5-50.6s36.7-19.6 63-19.6h11.7c22.5 0 41.1 4.9 55.9 14.7 16.2 10.7 26.2 26.7 30 48.1h-53.1c-3.6-14.4-15.1-21.5-34.2-21.5h-11c-8.3 0-15.2 2-20.6 6.3-5.9 4.6-9 10.8-9 19 0 10.3 6.1 17.3 18.4 20.6l54.8 15.1c38.4 10.5 57.5 32.2 57.5 65 0 24.9-9.8 44.3-29.6 58.4-17.4 12.4-39.3 18.6-65.2 18.6l-9.9-0.1zM423.1 497c0-38.1 11-66.9 33-86.5 20.3-18.1 45.7-27.1 76-27.1 30.5 0 55.9 9.1 76.3 27.3 21.8 19.5 32.7 48.2 32.7 86.3v17.1c0 38.3-10.8 67-32.7 86.3-3.9 3.6-7.4 6.3-10.7 8.3l43.3 49.6h-58.6L554.1 626c-6.9 1.2-14.4 1.7-22.2 1.7-30.3 0-55.7-9-76.2-27.1-21.8-19.5-32.8-48.4-32.8-86.8V497h0.2z m58.7 17.4c0 34.5 10.2 56.5 30.6 66.2 5.6 2.7 12 4.1 19.6 4.1 14 0 25.6-5.1 34.7-15.4 10.3-11.7 15.6-30 15.6-54.8v-17.8c0-14.4-1.5-26.4-4.7-35.9-4.9-14.6-13.4-24.7-25.6-30.3-5.6-2.5-12.4-3.9-20-3.9-13.9 0-25.4 5.1-34.5 15.2-10.5 11.7-15.7 30-15.7 54.8v17.8zM743.1 386.4V581h96.3v43.2h-154V386.4h57.7z" p-id="13164"></path></svg>'
    });
    W(
      () => i.expression,
      () => {
        d.baseExpression = pe(i.expression);
      },
      {
        immediate: !0,
        deep: !0
      }
    );
    function h() {
      n("delete");
    }
    return (r, l) => {
      const u = S("mapgis-ui-icon-identity");
      return m(), k("div", {
        class: T([s(a).b()])
      }, [
        y(u, {
          class: T([s(a).e("icon")]),
          icon: d.icon,
          width: 18,
          height: 18
        }, null, 8, ["class", "icon"]),
        C("span", {
          title: d.baseExpression
        }, j(d.baseExpression), 9, Pe),
        C("div", {
          class: T([s(a).e("actions")])
        }, [
          (m(!0), k(U, null, Q(d.commands, (o) => (m(), k("div", {
            key: o.id,
            class: T([s(a).e("action")]),
            title: o.label,
            onClick: he(o.action, ["prevent"])
          }, [
            y(u, {
              class: T(s(a).em("action", "icon")),
              icon: o.icon,
              width: 14,
              height: 14
            }, null, 8, ["class", "icon"])
          ], 10, Je))), 128))
        ], 2)
      ], 2);
    };
  }
}), _e = /* @__PURE__ */ ee(Xe, [["__scopeId", "data-v-c0f6ec0a"]]), Ye = /* @__PURE__ */ Y({
  name: "MapgisAttributeFilterGroup",
  __name: "attribute-filter-group",
  props: {
    expression: {
      type: Object
    },
    fields: {
      type: Array
    },
    layerService: {
      type: Object
    },
    layerQueryOptions: {
      type: Object
    }
  },
  emits: {},
  setup(e, { emit: t }) {
    const i = e, n = Z("attribute-filter-group"), { handleDeleteExpression: a } = qe(i);
    return (d, h) => {
      const r = S("a-select-option"), l = S("a-select"), u = S("a-collapse-panel"), o = S("a-collapse");
      return m(), k("div", {
        class: T([s(n).b()])
      }, [
        C("div", {
          class: T(s(n).e("operator-switch"))
        }, [
          e.expression.expressions.length > 1 ? (m(), L(l, {
            key: 0,
            value: e.expression.operator,
            "onUpdate:value": h[0] || (h[0] = (v) => e.expression.operator = v)
          }, {
            default: p(() => [
              y(r, { value: "AND" }, {
                default: p(() => [...h[2] || (h[2] = [
                  F(" 匹配所有表达式 ", -1)
                ])]),
                _: 1
              }),
              y(r, { value: "OR" }, {
                default: p(() => [...h[3] || (h[3] = [
                  F(" 匹配任意表达式 ", -1)
                ])]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["value"])) : D("", !0)
        ], 2),
        y(o, {
          accordion: "",
          activeKey: e.expression.activeId,
          "onUpdate:activeKey": h[1] || (h[1] = (v) => e.expression.activeId = v)
        }, {
          default: p(() => [
            (m(!0), k(U, null, Q(e.expression.expressions, (v, N) => (m(), L(u, {
              key: v.id
            }, {
              header: p(() => [
                v.type === "base" ? (m(), L(_e, {
                  key: 0,
                  expression: v,
                  onDelete: (b) => s(a)(N)
                }, null, 8, ["expression", "onDelete"])) : D("", !0)
              ]),
              default: p(() => [
                v.type === "base" ? (m(), L(Ie, {
                  key: 0,
                  expression: v,
                  fields: e.fields,
                  layerService: e.layerService,
                  layerQueryOptions: e.layerQueryOptions
                }, null, 8, ["expression", "fields", "layerService", "layerQueryOptions"])) : D("", !0)
              ]),
              _: 2
            }, 1024))), 128))
          ]),
          _: 1
        }, 8, ["activeKey"])
      ], 2);
    };
  }
}), Ze = /* @__PURE__ */ ee(Ye, [["__scopeId", "data-v-85a835d5"]]), et = ["title"], tt = ["title", "onClick"], st = /* @__PURE__ */ Y({
  name: "MapgisAttributeFilterGroupHeader",
  __name: "attribute-filter-group-header",
  props: {
    expression: {
      type: Object
    }
  },
  emits: {
    add: () => !0,
    delete: () => !0
  },
  setup(e, { emit: t }) {
    const i = e, n = t, a = Z("attribute-filter-group-header"), d = X({
      commands: [
        {
          id: "plus",
          icon: "mapgis-plus",
          label: "添加表达式",
          action: h
        },
        {
          id: "delete",
          icon: "mapgis-delete",
          label: "删除",
          action: r
        }
      ],
      logicalExpressionGroup: "",
      icon: '<svg t="1756292493596" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10316" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M857.09375 924.59375H294.734375c-37.96875 0-68.34375-30.796875-68.34375-68.34375V293.890625c0-37.96875 30.796875-68.34375 68.34375-68.34375h561.9375c37.96875 0 68.34375 30.796875 68.34375 68.34375v561.9375c0.421875 37.96875-30.375 68.765625-67.921875 68.765625zM294.734375 277.859375c-8.859375 0-16.03125 7.171875-16.03125 16.03125v561.9375c0 8.859375 7.171875 16.03125 16.03125 16.03125h561.9375c8.859375 0 16.03125-7.171875 16.03125-16.03125V293.890625c0-8.859375-7.171875-16.03125-16.03125-16.03125H294.734375z" p-id="10317"></path><path d="M229.34375 795.921875c-72.140625 0-130.78125-58.640625-130.78125-130.78125V165.640625c0-37.96875 30.796875-68.34375 68.34375-68.34375h499.921875c72.140625 0 130.78125 58.640625 130.78125 130.78125h-52.734375c0-43.03125-35.015625-78.046875-78.046875-78.046875H166.90625c-8.859375 0-16.03125 7.171875-16.03125 16.03125v499.921875c0 43.03125 35.015625 78.046875 78.046875 78.046875v51.890625z" p-id="10318"></path><path d="M432.6875 560.515625c-30.796875-20.25-45.140625-29.953125-45.140625-42.1875 0-12.65625 11.8125-13.078125 18.5625-12.65625 7.171875 0.421875 58.640625 0.421875 58.640625 0.421875V465.59375H386.28125c-13.078125 0-38.8125 15.1875-45.984375 39.65625-4.640625 16.875 2.109375 33.328125 3.375 36.703125 2.109375 5.0625 5.90625 12.65625 16.453125 23.203125 28.6875 29.53125 59.90625 34.171875 63.703125 52.734375 0.421875 1.6875 1.265625 6.328125-1.265625 10.546875-3.375 5.484375-10.96875 7.59375-16.03125 7.59375H339.453125v42.1875s48.9375 0.421875 78.046875 0 53.15625-24.46875 53.15625-53.15625-7.59375-44.296875-37.96875-64.546875zM590.046875 461.796875c-59.0625 0-107.15625 49.359375-107.15625 110.109375 0 45.140625 26.15625 85.21875 67.078125 102.09375l14.765625-35.859375c-26.15625-10.96875-43.453125-37.125-43.453125-66.65625 0-39.234375 30.796875-71.296875 68.765625-71.296875s68.765625 32.0625 68.765625 71.296875c0 29.53125-17.296875 55.265625-42.609375 66.234375v-38.390625h-38.390625v125.296875h38.390625v-46.40625c48.09375-12.234375 81.421875-55.6875 81.421875-106.734375-0.421875-60.328125-48.515625-109.6875-107.578125-109.6875zM773.5625 638.140625c-11.8125 0-21.515625-9.703125-21.515625-21.515625V465.59375h-38.390625v151.03125c0 32.90625 27 59.90625 59.90625 59.90625h38.8125v-38.390625H773.5625z" p-id="10319"></path></svg>'
    });
    W(
      () => i.expression,
      () => {
        d.logicalExpressionGroup = de(i.expression);
      },
      {
        immediate: !0,
        deep: !0
      }
    );
    function h() {
      const l = A();
      i.expression.activeId = l.id, i.expression.expressions.push(l), n("add");
    }
    function r() {
      n("delete");
    }
    return (l, u) => {
      const o = S("mapgis-ui-icon-identity");
      return m(), k("div", {
        class: T([s(a).b()])
      }, [
        y(o, {
          class: T([s(a).e("icon")]),
          icon: d.icon,
          width: 20,
          height: 20
        }, null, 8, ["class", "icon"]),
        C("span", {
          title: d.logicalExpressionGroup
        }, j(d.logicalExpressionGroup), 9, et),
        C("div", {
          class: T([s(a).e("actions")])
        }, [
          (m(!0), k(U, null, Q(d.commands, (v) => (m(), k("div", {
            key: v.id,
            class: T([s(a).e("action")]),
            title: v.label,
            onClick: he(v.action, ["stop"])
          }, [
            y(o, {
              class: T(s(a).em("action", "icon")),
              icon: v.icon,
              width: 14,
              height: 14
            }, null, 8, ["class", "icon"])
          ], 10, tt))), 128))
        ], 2)
      ], 2);
    };
  }
}), nt = /* @__PURE__ */ ee(st, [["__scopeId", "data-v-2d470e96"]]), it = ["title"], lt = /* @__PURE__ */ Y({
  name: "MapgisAttributeFilter",
  __name: "attribute-filter",
  props: Ke,
  emits: Ve,
  setup(e, { expose: t, emit: i }) {
    const n = e, a = i, d = Z("attribute-filter"), h = We(), {
      selectedLayerId: r,
      layerTypes: l,
      sublayerTypes: u,
      fields: o,
      filterExpression: v,
      compoundExpression: N,
      layerService: b,
      searchType: c,
      featureIds: x,
      valueOptions: g,
      // 下面是计算属性
      attributeFilterLayerTitlePair: _,
      attributeFilterEnabled: O,
      showLayerSelect: $,
      isConditionSearch: K,
      isFeatureIdSearch: f,
      // 下面是方法
      clearState: V,
      apply: z,
      reset: H,
      handleLayerSelectChange: R,
      handleAddExpression: w,
      handleAddExpressionGroup: B,
      handleDeleteExpression: te,
      handleClearExpressions: se
    } = ze(n, a, h);
    return t({
      clearState: V
    }), (q, E) => {
      const Se = S("mapgis-layer-select"), ne = S("a-form-item"), P = S("a-select-option"), ae = S("a-select"), re = S("mapgis-ui-iconfont"), ie = S("a-button"), Te = S("a-collapse-panel"), Oe = S("a-collapse"), Le = S("mapgis-ui-group-tab"), ke = S("a-textarea"), we = S("mapgis-ui-setting-form"), Ae = S("a-button-group");
      return m(), k("div", {
        class: T([s(d).b()])
      }, [
        y(we, {
          layout: "horizontal",
          itemLayout: "grid",
          size: "default",
          class: T(s(d).e("form"))
        }, {
          default: p(() => [
            s($) ? (m(), L(ne, {
              key: 0,
              label: "过滤图层"
            }, {
              default: p(() => [
                y(Se, {
                  ref_key: "layerSelectRef",
                  ref: h,
                  value: s(r),
                  "onUpdate:value": E[0] || (E[0] = (I) => oe(r) ? r.value = I : null),
                  layerTypes: s(l),
                  sublayerTypes: s(u),
                  multiple: !1,
                  treeDefaultExpandAll: "",
                  onChange: s(R)
                }, null, 8, ["value", "layerTypes", "sublayerTypes", "onChange"])
              ]),
              _: 1
            })) : (m(), L(ne, {
              key: 1,
              label: "过滤图层"
            }, {
              default: p(() => [
                s(_) ? (m(), k("div", {
                  key: 0,
                  title: s(_).tip,
                  class: T(s(d).e("layer-name"))
                }, j(s(_).title), 11, it)) : D("", !0)
              ]),
              _: 1
            })),
            q.showAttributeSearchType ? (m(), L(ne, {
              key: 2,
              label: "过滤方式",
              tooltip: "两种查询方式不能同时生效，只生效当前选择的过滤的方式"
            }, {
              default: p(() => [
                y(ae, {
                  value: s(c),
                  "onUpdate:value": E[1] || (E[1] = (I) => oe(c) ? c.value = I : null)
                }, {
                  default: p(() => [
                    y(P, { value: "condition" }, {
                      default: p(() => [...E[6] || (E[6] = [
                        F("属性条件", -1)
                      ])]),
                      _: 1
                    }),
                    y(P, { value: "featureId" }, {
                      default: p(() => [...E[7] || (E[7] = [
                        F("要素ID", -1)
                      ])]),
                      _: 1
                    })
                  ]),
                  _: 1
                }, 8, ["value"])
              ]),
              _: 1
            })) : D("", !0),
            s(K) ? (m(), k(U, { key: 3 }, [
              C("div", {
                class: T(s(d).e("filter-actions"))
              }, [
                C("div", null, [
                  y(ie, {
                    type: "primary",
                    size: "small",
                    disabled: !s(O),
                    onClick: s(w)
                  }, {
                    icon: p(() => [
                      y(re, { type: "mapgis-plus" })
                    ]),
                    default: p(() => [
                      E[8] || (E[8] = F(" 添加表达式 ", -1))
                    ]),
                    _: 1
                  }, 8, ["disabled", "onClick"]),
                  y(ie, {
                    size: "small",
                    disabled: !s(O),
                    onClick: s(B)
                  }, {
                    icon: p(() => [
                      y(re, { type: "mapgis-plus" })
                    ]),
                    default: p(() => [
                      E[9] || (E[9] = F(" 添加集合 ", -1))
                    ]),
                    _: 1
                  }, 8, ["disabled", "onClick"])
                ]),
                C("div", {
                  class: T([
                    s(d).e("filter-action"),
                    s(d).e("filter-action-clear"),
                    !s(O) && s(d).em("filter-action", "disabled")
                  ]),
                  onClick: E[2] || (E[2] = //@ts-ignore
                  (...I) => s(se) && s(se)(...I))
                }, [
                  y(re, {
                    type: "mapgis-clear",
                    title: "全部清除"
                  })
                ], 2)
              ], 2),
              C("div", {
                class: T(s(d).e("operator-switch"))
              }, [
                s(N).expressions.length > 1 ? (m(), L(ae, {
                  key: 0,
                  value: s(N).operator,
                  "onUpdate:value": E[3] || (E[3] = (I) => s(N).operator = I)
                }, {
                  default: p(() => [
                    y(P, { value: "AND" }, {
                      default: p(() => [...E[10] || (E[10] = [
                        F(" 匹配所有表达式 ", -1)
                      ])]),
                      _: 1
                    }),
                    y(P, { value: "OR" }, {
                      default: p(() => [...E[11] || (E[11] = [
                        F(" 匹配任意表达式 ", -1)
                      ])]),
                      _: 1
                    })
                  ]),
                  _: 1
                }, 8, ["value"])) : D("", !0)
              ], 2),
              y(Oe, {
                accordion: "",
                activeKey: s(N).activeId,
                "onUpdate:activeKey": E[4] || (E[4] = (I) => s(N).activeId = I)
              }, {
                default: p(() => [
                  (m(!0), k(U, null, Q(s(N).expressions, (I, fe) => (m(), L(Te, {
                    key: I.id
                  }, {
                    header: p(() => [
                      I.type === "base" ? (m(), L(_e, {
                        key: 0,
                        expression: I,
                        onDelete: (me) => s(te)(fe)
                      }, null, 8, ["expression", "onDelete"])) : D("", !0),
                      I.type === "group" ? (m(), L(nt, {
                        key: 1,
                        expression: I,
                        onAdd: (me) => s(N).activeId = I.id,
                        onDelete: (me) => s(te)(fe)
                      }, null, 8, ["expression", "onAdd", "onDelete"])) : D("", !0)
                    ]),
                    default: p(() => [
                      I.type === "base" ? (m(), L(Ie, {
                        key: 0,
                        expression: I,
                        fields: s(o),
                        layerService: s(b),
                        layerQueryOptions: q.layerQueryOptions
                      }, null, 8, ["expression", "fields", "layerService", "layerQueryOptions"])) : D("", !0),
                      I.type === "group" ? (m(), L(Ze, {
                        key: 1,
                        expression: I,
                        fields: s(o),
                        layerService: s(b),
                        layerQueryOptions: q.layerQueryOptions
                      }, null, 8, ["expression", "fields", "layerService", "layerQueryOptions"])) : D("", !0)
                    ]),
                    _: 2
                  }, 1024))), 128))
                ]),
                _: 1
              }, 8, ["activeKey"]),
              y(Le, {
                title: "生成SQL",
                isTitleBold: !1
              }),
              y(ke, {
                value: s(v),
                "auto-size": { minRows: 3, maxRows: 3 },
                readonly: ""
              }, null, 8, ["value"])
            ], 64)) : D("", !0),
            s(f) ? (m(), L(ne, {
              key: 4,
              label: "要素ID",
              tooltip: "根据要素唯一ID快速查询"
            }, {
              default: p(() => [
                y(ae, {
                  value: s(x),
                  "onUpdate:value": E[5] || (E[5] = (I) => oe(x) ? x.value = I : null),
                  placeholder: "请输入或选择查询值",
                  mode: "multiple",
                  allowClear: "",
                  disabled: !s(g).length,
                  class: T(s(d).e("options"))
                }, {
                  default: p(() => [
                    (m(!0), k(U, null, Q(s(g), (I) => (m(), L(P, {
                      key: I,
                      title: I
                    }, {
                      default: p(() => [
                        F(j(I), 1)
                      ]),
                      _: 2
                    }, 1032, ["title"]))), 128))
                  ]),
                  _: 1
                }, 8, ["value", "disabled", "class"])
              ]),
              _: 1
            })) : D("", !0)
          ]),
          _: 1
        }, 8, ["class"]),
        y(Ae, {
          class: T(s(d).e("footer"))
        }, {
          default: p(() => [
            y(ie, {
              type: "primary",
              block: "",
              disabled: !s(O),
              onClick: s(z)
            }, {
              default: p(() => [...E[12] || (E[12] = [
                F("应用", -1)
              ])]),
              _: 1
            }, 8, ["disabled", "onClick"]),
            y(ie, {
              block: "",
              disabled: !s(O),
              onClick: s(H)
            }, {
              default: p(() => [...E[13] || (E[13] = [
                F("重置", -1)
              ])]),
              _: 1
            }, 8, ["disabled", "onClick"])
          ]),
          _: 1
        }, 8, ["class"])
      ], 2);
    };
  }
}), dt = /* @__PURE__ */ ee(lt, [["__scopeId", "data-v-8cd8dcb0"]]);
export {
  dt as A,
  Ve as a,
  Ke as b,
  ze as u
};
