import { jsx } from "react/jsx-runtime";
import { Suspense, act } from "react";
import { render } from "@testing-library/react";
import { ReactRuntime } from "../../../../react";
import * as Testing from "../../../testing";
import { MakeswiftComponent } from "../../../../runtimes/react/components/MakeswiftComponent";
import { Checkbox, TextInput } from "@makeswift/controls";
const CustomComponentType = "CustomComponent";
const componentId = "component-id";
const containerId = "container-id";
const fallbackId = "fallback-id";
function CustomComponent({ text, suspend }) {
  if (suspend) {
    throw new Promise(() => {
    });
  }
  return /* @__PURE__ */ jsx("div", { "data-testid": componentId, children: text });
}
function CustomComponentWithFallback(props) {
  return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { "data-testid": fallbackId, children: "Loading..." }), children: /* @__PURE__ */ jsx(CustomComponent, { ...props }) });
}
const elementData = (props) => ({
  type: CustomComponentType,
  key: "0000-0000-0000-0000",
  props
});
async function renderComponentSnapshot(snapshot, component = CustomComponent, { builtinSuspense } = {}) {
  const runtime = new ReactRuntime();
  runtime.registerComponent(component, {
    type: CustomComponentType,
    label: "Custom Component",
    builtinSuspense,
    props: {
      text: TextInput({ defaultValue: "Default Text" }),
      suspend: Checkbox({ defaultValue: false, label: "Suspend" })
    }
  });
  await act(
    async () => render(
      /* @__PURE__ */ jsx(Testing.ReactProvider, { runtime, siteVersion: null, children: /* @__PURE__ */ jsx("div", { "data-testid": containerId, children: /* @__PURE__ */ jsx(
        MakeswiftComponent,
        {
          label: "Embedded Component",
          type: CustomComponentType,
          snapshot
        }
      ) }) })
    )
  );
}
export {
  CustomComponent,
  CustomComponentType,
  CustomComponentWithFallback,
  componentId,
  containerId,
  elementData,
  fallbackId,
  renderComponentSnapshot
};
//# sourceMappingURL=fixtures.js.map