import { dD as e, $ as t, cP as o, dE as i, dF as p, dG as a, dH as r, dI as n } from "./index-2be62fff.js";
import { loadComps as m } from "./index-test-fcb69166.js";
import "./axios-125479b5.js";
import "./redux-devtools-f8b1cd80.js";
import "./alasql-f59e855e.js";
import "./ant-design-icons-14ab96af.js";
import "react";
import "./react-router-8d1fc2f1.js";
import "./antd-97b654da.js";
import "react-dom";
import "./dayjs-7fc5ce65.js";
import "./lodash-226cb5b1.js";
import "./fontawesome-89eb6278.js";
import "./dnd-kit-e67c9595.js";
import "./moment-d8baa15a.js";
import "./crypto-js-8020edb5.js";
import "./styled-components-c6abe9a3.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-2e4a9112.js";
import "./fetch-6a200310.js";
import "./react-draggable-fda4f1cb.js";
import "./remark-gfm-e9b5dec7.js";
import "./buffer-e20f80c8.js";
import "./rehype-raw-41b6145f.js";
import "./parse5-6476676e.js";
import "./rehype-sanitize-deb53e9a.js";
import "./simplebar-react-cab52c82.js";
import "./react-best-gradient-color-picker-812be7ee.js";
import "./ua-parser-js-1d18a3f8.js";
import "./clsx-469c2c43.js";
import "./loglevel-5e7e37fc.js";
import "./codemirror-edf161cb.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./redux-saga-1b0a458d.js";
import "./hotkeys-js-0dddb21a.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-ae08f8b5.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-9e54e169.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-e4f7745b.js";
import "./katex-cda5b990.js";
import "./ecogis-maps-10bb29cf.js";
import "./devextreme-28d23085.js";
import "./exceljs-1678d36b.js";
import "./file-saver-es-c18fae8f.js";
const u = { ui: { items: { "2e2d4bf2": { compType: "module", comp: { appId: "123", events: [{ name: "event1", handler: { compType: "executeComp", comp: { name: "outerInput", methodName: "setValue", params: [{ compType: "string", comp: "event1_triggered", name: "value" }] } } }] }, name: "module1" }, "2bb084bf": { compType: "input", comp: { value: "" }, name: "outerInput" } } }, queries: [{ compType: "js", comp: { script: "return 3;" }, id: "dievziawwqy72gszoa42i6m8", name: "jsQuery3", triggerType: "manual" }, { compType: "js", comp: { script: "return 3 + a;" }, id: "dievziawwqy72gszoa42i6m9", name: "jsQuery4", triggerType: "manual" }] }, s = { ui: { compType: "module", comp: { methods: [{ name: "method1", action: { compType: "executeComp", comp: { name: "input1", methodName: "setValue", params: [{ compType: "string", comp: "hello method1", name: "value" }] } } }, { name: "method2", params: [{ name: "param1", type: "string" }], action: { compType: "executeComp", comp: { name: "input1", methodName: "setValue", params: [{ compType: "string", comp: "hello {{param1}}", name: "value" }] } } }], events: { list: [{ name: "event1", description: "" }, { name: "event2", description: "" }], onEvent: [{ name: "event1", handler: { compType: "executeComp", comp: { name: "input1", methodName: "setValue", params: [{ compType: "string", comp: "from_event1", name: "value" }] } } }] }, io: { inputs: [{ name: "inQuery", description: "", type: "query" }, { name: "inNum", description: "", type: "number" }, { name: "inString", description: "", type: "string", defaultValue: { compType: "string", comp: "default_value" }, test: { compType: "string", comp: "test_value" } }], outputs: [{ description: "", value: "{{input1.value}}", name: "out" }] }, containerSize: { height: 20, width: 24 }, container: { items: { "2010af2a": { compType: "input", comp: { value: "hello" }, name: "input1" }, e97d3df7: { compType: "text", comp: { text: "inNum:{{inNum.value}}" }, name: "text1" }, e97d3df8: { compType: "text", comp: { text: "inString:{{inString.value}}" }, name: "text2" }, e97d3df9: { compType: "text", comp: { text: "inQueryData:{{inQuery.data}}" }, name: "text3" } } } } }, queries: [{ compType: "js", comp: { script: "return 1 + 1" }, id: "dievziawwqy72gszoa42i6m7", name: "jsQuery", triggerType: "manual", onEvent: [{ name: "success", handler: { compType: "executeComp", comp: { name: "input1", methodName: "setValue", params: [{ compType: "string", comp: "hello success", name: "value" }] } } }] }, { compType: "js", comp: { script: "inQuery.run({a: 10}); \ninput1.setValue('hello input query'); return 'ok'" }, id: "dievziawwqy72gszoa42i6m8", name: "jsQuery2", triggerType: "manual" }, { compType: "js", comp: { script: "event1.trigger();" }, id: "dievziawwqy72gszoa42i6m9", name: "jsQuery3", triggerType: "manual" }] };
function c(i2) {
  const p2 = e({ Comp: t, initialValue: u, reduceContext: { readOnly: false, applicationId: "123", moduleDSL: { 123: s }, parentApplicationPath: [] } });
  if (!p2)
    throw new Error();
  const a2 = (e2, t2) => e2.children.ui.getAllCompItems()[t2].children.comp, r2 = (e2) => a2(p2.comp, e2), n2 = () => r2("2e2d4bf2"), m2 = (e2) => {
    const t2 = n2().moduleRootComp;
    return a2(t2, e2);
  };
  p2.init().then(() => {
    n2().dispatch(o({ type: "init" }, false)), setTimeout(() => {
      i2({ root: () => p2.comp, moduleRoot: () => n2().moduleRootComp, module: n2, moduleOutputNodes: () => n2().getOutputNodes(), input: () => m2("2010af2a"), inputValue: () => m2("2010af2a").children.value.getView().value, text1: () => m2("e97d3df7"), text2: () => m2("e97d3df8"), text3: () => m2("e97d3df9"), outerInputValue: () => r2("2bb084bf").children.value.getView().value });
    });
  });
}
beforeAll(async () => {
  await m();
}), describe("module comp", () => {
  test("init module to ready", (e2) => {
    c(({ module: t2, text1: o2, text2: i2 }) => {
      expect(Object.keys(t2().getOutputNodes())).toStrictEqual(["out"]), expect(t2().exposingValues.out).toBe("hello"), expect(Object.keys(t2().children.inputs.getInputNodes())).toStrictEqual([]), expect(o2().children.text.getView().value).toBe("inNum:"), t2().children.inputs.children.inNum.dispatchChangeValueAction(1), expect(o2().children.text.getView().value).toBe("inNum:1"), expect(Object.keys(t2().children.inputs.getInputNodes())).toStrictEqual(["inNum"]), expect(i2().children.text.getView().value).toBe("inString:default_value"), t2().children.inputs.children.inString.dispatchChangeValueAction("hello"), expect(i2().children.text.getView().value).toBe("inString:hello"), expect(Object.keys(t2().children.inputs.getInputNodes())).toStrictEqual(["inNum", "inString"]), e2();
    });
  }), test("change value in module", (e2) => {
    c(({ input: t2, inputValue: o2 }) => {
      expect(o2()).toBe("hello"), t2().children.value.dispatchChangeValueAction("world"), expect(o2()).toBe("world");
      i(t2().children.value.dispatch, t2().children.value.changeValueAction("hello world"), { autoHandleAfterReduce: true }).then(() => {
        expect(o2()).toBe("hello world"), e2();
      });
    });
  }), test("exec query in module", (e2) => {
    c(({ moduleRoot: t2, module: o2, inputValue: i2 }) => {
      expect(o2().exposingValues.out).toBe("hello"), t2().dispatch(p("jsQuery", a({}))), setTimeout(() => {
        expect(i2()).toBe("hello success"), expect(o2().exposingValues.out).toBe("hello success"), e2();
      }, 300);
    });
  }), test("input query data", (e2) => {
    c(({ text3: t2, module: o2, root: i2, inputValue: r2 }) => {
      expect(t2().children.text.getView().value).toBe("inQueryData:"), o2().children.inputs.children.inQuery.dispatchChangeValueAction({ value: "jsQuery3" }), expect(Object.keys(o2().children.inputs.getInputNodes())).toStrictEqual(["inQuery"]), expect(t2().children.text.getView().value).toBe("inQueryData:"), i2().dispatch(p("jsQuery3", a({}))), setTimeout(() => {
        expect(t2().children.text.getView().value).toBe("inQueryData:3"), e2();
      }, 1e3);
    });
  }), test("exec input query", (e2) => {
    c(({ text3: t2, module: o2, moduleRoot: i2, inputValue: r2 }) => {
      expect(t2().children.text.getView().value).toBe("inQueryData:"), o2().children.inputs.children.inQuery.dispatchChangeValueAction({ value: "jsQuery4" }), expect(Object.keys(o2().children.inputs.getInputNodes())).toStrictEqual(["inQuery"]), expect(t2().children.text.getView().value).toBe("inQueryData:"), i2().dispatch(p("jsQuery2", a({}))), setTimeout(() => {
        expect(r2()).toBe("hello input query"), expect(t2().children.text.getView().value).toBe("inQueryData:13"), e2();
      }, 1e3);
    });
  }), test("exec methods", (e2) => {
    c(({ root: t2, inputValue: i2 }) => {
      const a2 = t2().nameAndExposingInfo();
      expect(Object.keys(a2.module1.methods)).toStrictEqual(["method1", "method2"]), t2().dispatch(p("module1", o({ type: "execute", methodName: "method1", params: [] }, false))), setTimeout(() => {
        expect(i2()).toBe("hello method1"), e2();
      }, 2e3);
    });
  }), test("exec methods with params", (e2) => {
    c(({ root: t2, inputValue: i2 }) => {
      const a2 = t2().nameAndExposingInfo();
      expect(Object.keys(a2.module1.methods)).toStrictEqual(["method1", "method2"]), t2().dispatch(p("module1", o({ type: "execute", methodName: "method2", params: ["Lucy"] }, false))), setTimeout(() => {
        expect(i2()).toBe("hello Lucy"), e2();
      }, 2e3);
    });
  }), test("trigger events by event", (e2) => {
    c(({ root: t2, text3: o2, module: i2, moduleRoot: a2, outerInputValue: m2 }) => {
      expect(m2()).toBe(""), a2().dispatch(p(n, r("event1"))), setTimeout(() => {
        expect(m2()).toBe("event1_triggered"), e2();
      });
    });
  }), test("trigger events by js query", (e2) => {
    c(({ root: t2, text3: o2, module: i2, moduleRoot: r2, outerInputValue: n2 }) => {
      expect(n2()).toBe(""), r2().dispatch(p("jsQuery3", a({}))), setTimeout(() => {
        expect(n2()).toBe("event1_triggered"), e2();
      }, 1e3);
    });
  });
});
