import { T as t, _ as e, eb as a, cw as i, d8 as o } from "./index-f50c05c4.js";
import { _ as r } from "./lodash-f1e42446.js";
import "./axios-84bb1c75.js";
import "./redux-devtools-d38e5b33.js";
import "./alasql-0ff6dabf.js";
import "./ant-design-icons-b1480d8d.js";
import "react";
import "./react-router-a1807b5b.js";
import "./antd-04a23d13.js";
import "react-dom";
import "./dayjs-844325ae.js";
import "./fontawesome-2445f580.js";
import "./dnd-kit-56a2f36f.js";
import "./styled-components-1e696d6b.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 "./loglevel-6fb66d22.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 "./hotkeys-js-0dddb21a.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";
const s = (t2, e2) => {
  const i2 = t2.children.columns.getView().map((t3) => t3.getView());
  expect(e2.length).toEqual(i2.length), e2.forEach((t3) => {
    const e3 = i2.find((e4) => e4.dataIndex === t3.dataIndex);
    if (!e3)
      throw new Error(`expect column: ${JSON.stringify(t3)}, but not found.`);
    Object.keys(t3).forEach((a2) => {
      const i3 = e3[a2], o3 = t3[a2];
      if (void 0 !== o3 && !r.isEqual(i3, o3))
        throw new Error(`ColumnKey:${a2}, expect: "${o3}", but found: "${i3}"`);
    });
  });
  const o2 = t2.children.dynamicColumnConfig.getView();
  if ((o2 == null ? void 0 : o2.length) > 0) {
    const e3 = (t3) => {
    }, r2 = a(i2, t2.children.sort.getView(), t2.children.toolbar.getView().columnSetting, t2.children.size.getView(), t2.children.dynamicColumn.getView(), o2, t2.columnAggrData, t2.children.editModeClicks.getView(), e3);
    expect(i2.length).toBeGreaterThanOrEqual(r2.length), r2.forEach((t3) => {
      const e4 = t3.dataIndex, a2 = i2.find((t4) => t4.dataIndex === e4);
      if (!a2)
        throw new Error(`Error, column should not be undefined, column: ${JSON.stringify(t3)}`);
      const r3 = a2.isCustom ? a2.title : a2.dataIndex;
      if (!o2.includes(r3))
        throw new Error(`dynamic config test fail: unexpect column: ${r3}`);
    });
  }
};
function n() {
  const t2 = { query1: i({ data: [{ q1: 1 }] }), query2: i({ data: [{ q2: 2 }] }) };
  return { tableData: { data: JSON.stringify([{ a: 1 }]), columns: [{ dataIndex: "a", title: "a", hide: true }, { title: "custom", dataIndex: "custom1", isCustom: true }] }, exposingInfo: t2, initColumns: [{ dataIndex: "a", hide: true, title: "a" }, { dataIndex: "custom1", hide: false, title: "custom", isCustom: true }] };
}
async function c() {
  await new Promise((t2) => setTimeout(t2, 20));
}
async function d(a2, r2, d2) {
  const { initColumns: m, tableData: l, exposingInfo: u } = n();
  let p = new t({ dispatch: (t2) => {
    let a3;
    a3 = r2 ? o({ readOnly: r2 }, () => p.reduce(t2)) : p.reduce(t2), p = e(a3, u);
  }, value: { ...l, dynamicColumn: a2, ...a2 && d2 && { dynamicColumnConfig: JSON.stringify(d2) } } });
  p = e(p);
  const j = async () => {
    p = e(p.reduce(p.changeChildAction("data", "{{query1.data}}")), u), await c();
  }, g = [{ dataIndex: "q1", title: "q1" }, { dataIndex: "custom1", title: "custom", isCustom: true }];
  await j(), s(p, !a2 && r2 ? m : g);
  const h = [{ q1: 1, a: 2 }];
  u.query1 = i({ data: h }), await j();
  const f = [...g, { dataIndex: "a", title: "a" }];
  expect(p.children.data.getView()).toEqual(h), s(p, !a2 && r2 ? m : f);
  const w = [{ a: 2 }];
  u.query1 = i({ data: w }), await j(), expect(p.children.data.getView()).toEqual(w), s(p, a2 ? f.filter((t2) => "q1" !== t2.dataIndex) : r2 ? m : f);
}
test("test table dynamic columns: Change unEvalValue", async () => {
  const { initColumns: a2, tableData: i2, exposingInfo: o2 } = n();
  let r2 = new t({ dispatch: (t2) => {
    r2 = e(r2.reduce(t2), o2);
  }, value: i2 });
  r2 = e(r2), s(r2, a2), r2 = e(r2.reduce(r2.changeChildAction("data", JSON.stringify([{ a: 1, c: 2, d: 3 }])))), await c();
  const d2 = [...a2, { dataIndex: "c", hide: false, title: "c" }, { dataIndex: "d", title: "d" }];
  s(r2, d2), r2 = e(r2.reduce(r2.changeChildAction("data", JSON.stringify([{ c: 2, d: 3 }])))), await c(), s(r2, d2.filter((t2) => "a" !== t2.dataIndex));
}, 1e3), test("test table dynamic columns", async () => {
  await d(false, false), await d(false, true), await d(true, false), await d(true, true), await d(true, false, ["custom", "q1"]), await d(true, true, ["custom", "q1"]);
}, 2e3);
