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