import { j as p } from "../../../../../../../../../../../_virtual/jsx-runtime.js";
import { forwardRef as v, useContext as f } from "react";
import { LayoutGroupContext as x } from "../context/LayoutGroupContext.js";
import { LazyContext as E } from "../context/LazyContext.js";
import { MotionConfigContext as g } from "../context/MotionConfigContext.js";
import { MotionContext as j } from "../context/MotionContext/index.js";
import { useCreateMotionContext as L } from "../context/MotionContext/create.js";
import { isBrowser as N } from "../utils/is-browser.js";
import { featureDefinitions as P } from "./features/definitions.js";
import { loadFeatures as w } from "./features/load-features.js";
import { motionComponentSymbol as C } from "./utils/symbol.js";
import { useMotionRef as S } from "./utils/use-motion-ref.js";
import { useVisualElement as b } from "./utils/use-visual-element.js";
import { warning as h, invariant as R } from "../../../../motion-utils/dist/es/errors.js";
function K({ preloadedFeatures: t, createVisualElement: o, useRender: e, useVisualState: n, Component: i }) {
  t && w(t);
  function l(a, M) {
    let m;
    const s = {
      ...f(g),
      ...a,
      layoutId: k(a)
    }, { isStatic: u } = s, r = L(a), c = n(a, u);
    if (!u && N) {
      z(s, t);
      const y = D(s);
      m = y.MeasureLayout, r.visualElement = b(i, c, s, o, y.ProjectionNode);
    }
    return p.jsxs(j.Provider, { value: r, children: [m && r.visualElement ? p.jsx(m, { visualElement: r.visualElement, ...s }) : null, e(i, a, S(c, r.visualElement, M), c, u, r.visualElement)] });
  }
  l.displayName = `motion.${typeof i == "string" ? i : `create(${i.displayName ?? i.name ?? ""})`}`;
  const d = v(l);
  return d[C] = i, d;
}
function k({ layoutId: t }) {
  const o = f(x).id;
  return o && t !== void 0 ? o + "-" + t : t;
}
function z(t, o) {
  const e = f(E).strict;
  if (process.env.NODE_ENV !== "production" && o && e) {
    const n = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
    t.ignoreStrict ? h(!1, n) : R(!1, n);
  }
}
function D(t) {
  const { drag: o, layout: e } = P;
  if (!o && !e)
    return {};
  const n = { ...o, ...e };
  return {
    MeasureLayout: o?.isEnabled(t) || e?.isEnabled(t) ? n.MeasureLayout : void 0,
    ProjectionNode: n.ProjectionNode
  };
}
export {
  K as createRendererMotionComponent
};
//# sourceMappingURL=index.js.map
