import { jsxs as N, jsx as o } from "@emotion/react/jsx-runtime";
import { forwardRef as A } from "react";
import n from "clsx";
import { useModuleDictionary as R, useEnvironment as v } from "@m4l/core";
import { TEST_PROP_ID as E } from "../../../../test/constants_no_mock.js";
import { ActionsContainer as I } from "../../../CommonActions/components/ActionsContainer/ActionsContainer.js";
import { ActionFormIntro as O } from "../../../CommonActions/components/ActionFormIntro/ActionFormIntro.js";
import { useDynamicFormConditionals as W } from "../../hooks/useDynamicFormConditionals/useDynamicFormConditionals.js";
import { DYNAMIC_FORM_CLASSES as s } from "../../constants.js";
import { DynamicFormContentRootStyled as x, DynamicFormFieldWrapperStyled as P } from "../../slots/DynamicFormSlots.js";
import { useFieldsWithFetchedOptions as z } from "../../hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.js";
import { resolveFieldComponent as M } from "../../helpers/resolveFieldComponent/resolveFieldComponent.js";
const T = A((m, a) => {
  const {
    data: c,
    ownerState: p,
    currentSize: t,
    fieldWrapperClassName: l,
    dataTestId: d,
    coupled: f = !1,
    actionFormIntroProps: F,
    renderActions: e
  } = m, { getLabel: u } = R(), { host_static_assets: h, environment_assets: C, host_api_remote: _ } = v(), y = `${h}/${C}`, { visibleFields: D } = W(c), { fields: S } = z({ fields: D });
  return /* @__PURE__ */ N(
    x,
    {
      ref: a,
      className: n(s.contentRoot),
      ...process.env.NODE_ENV !== "production" ? { [E]: d } : {},
      children: [
        S.map((r) => {
          const i = M(r, {
            size: t,
            getLabel: u,
            assetBasePath: y,
            hostApiRemote: _
          });
          return i ? /* @__PURE__ */ o(
            P,
            {
              ownerState: p,
              className: n(l, s.fieldWrapper),
              children: i
            },
            r.id
          ) : null;
        }),
        !f && /* @__PURE__ */ o(I, { children: e ? e() : /* @__PURE__ */ o(
          O,
          {
            size: t,
            ...F
          }
        ) })
      ]
    }
  );
});
T.displayName = "DynamicFormContent";
export {
  T as DynamicFormContent
};
