import r from "./index-extends.js";
import n from "./index-objectWithoutPropertiesLoose.js";
import T from "./index-resolveComponentProps.js";
import v from "./index-mergeSlotProps.js";
import b from "./index-useForkRef.js";
import h from "./index-appendOwnerState.js";
const j = ["className", "elementType", "ownerState", "externalForwardedProps", "getSlotOwnerState", "internalForwardedProps"], k = ["component", "slots", "slotProps"], E = ["component"];
function B(e, o) {
  const {
    className: u,
    elementType: S,
    ownerState: s,
    externalForwardedProps: p,
    getSlotOwnerState: l,
    internalForwardedProps: w
  } = o, x = n(o, j), {
    component: L,
    slots: d = {
      [e]: void 0
    },
    slotProps: F = {
      [e]: void 0
    }
  } = p;
  n(p, k);
  const a = d[e] || S, t = T(F[e], s), c = v(r({
    className: u
  }, x, {
    externalForwardedProps: void 0,
    externalSlotProps: t
  })), {
    props: {
      component: O
    },
    internalRef: _
  } = c, m = n(c.props, E), g = b(_, t == null ? void 0 : t.ref, o.ref), i = l ? l(m) : {}, y = r({}, s, i), f = O, P = h(a, r({}, e === "root", !d[e] && w, m, f && {
    as: f
  }, {
    ref: g
  }), y);
  return Object.keys(i).forEach((C) => {
    delete P[C];
  }), [a, P];
}
export {
  B as default
};
