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