import { aK as c, v as l, h7 as m, f as p, L as u, ct as r, gn as d } from "./56c67d3b.js";
import "react";
import "react-dom";
const n = {
  isRemote: !0,
  source: "npm",
  packageName: "p",
  packageVersion: "v",
  compName: "n"
}, i = c(n, async () => l(123));
test("remote comp", async () => {
  let e = null;
  e = new i({
    dispatch: (t) => {
      e && (e = e.reduce(t));
    }
  }), expect(e.toJsonValue()).toBe(void 0), await e.load(), expect(e.toJsonValue()).toBe(123), e.dispatchChangeValueAction(345), expect(e.toJsonValue()).toBe(345);
});
test("remote comp keep values", async () => {
  let e = null;
  e = new i({
    dispatch: (t) => {
      e && (e = e.reduce(t));
    },
    value: 456
  }), expect(e.toJsonValue()).toBe(456), await e.load(), expect(e.toJsonValue()).toBe(456);
});
test("remote comp exposing data", async () => {
  const e = c(n, async () => m(p({
    hello: l(123)
  }), (a) => ({
    hello: a.children.hello.getView()
  })));
  let t = null;
  t = new e({
    dispatch: (a) => {
      t && (t = t.reduce(a));
    }
  }), await t.load();
  const o = u(t);
  expect(o.exposingValues.hello).toBe(123);
});
test("remote comp execute method", async () => {
  const e = c(n, async () => r(p({
    hello: l(123)
  }), [{
    method: {
      name: "add",
      params: [{
        name: "value",
        type: "number"
      }]
    },
    execute: (o, a) => {
      const s = o.children.hello;
      s.dispatchChangeValueAction(s.getView() + a[0]);
    }
  }]));
  let t = null;
  t = new e({
    dispatch: (o) => {
      t && (t = t.reduce(o));
    }
  }), await t.load(), t.reduce(d({
    type: "execute",
    methodName: "add",
    params: [10]
  }, !1)), await new Promise((o) => setTimeout(o, 20)), expect(t.children.hello.getView()).toEqual(133);
});
