import g from "./index-extends.js";
import V from "./index-objectWithoutPropertiesLoose.js";
import * as f from "react";
import n from "./index-_virtual16.js";
import k from "./index-useTheme.js";
import { reflow as B, getTransitionProps as v } from "./index-utils6.js";
import { jsx as J } from "react/jsx-runtime";
import M from "./index-Transition.js";
import Q from "./index-useTimeout.js";
import U from "./index-useForkRef.js";
import X from "./index-getReactElementRef.js";
import Y from "./index-elementAcceptingRef.js";
const Z = ["addEndListener", "appear", "children", "easing", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "style", "timeout", "TransitionComponent"];
function y(m) {
  return `scale(${m}, ${m ** 2})`;
}
const I = {
  entering: {
    opacity: 1,
    transform: y(1)
  },
  entered: {
    opacity: 1,
    transform: "none"
  }
}, h = typeof navigator < "u" && /^((?!chrome|android).)*(safari|mobile)/i.test(navigator.userAgent) && /(os |version\/)15(.|_)4/i.test(navigator.userAgent), j = /* @__PURE__ */ f.forwardRef(function(x, D) {
  const {
    addEndListener: T,
    appear: _ = !0,
    children: l,
    easing: R,
    in: b,
    onEnter: A,
    onEntered: w,
    onEntering: H,
    onExit: L,
    onExited: O,
    onExiting: P,
    style: p,
    timeout: r = "auto",
    // eslint-disable-next-line react/prop-types
    TransitionComponent: C = M
  } = x, F = V(x, Z), G = Q(), E = f.useRef(), s = k(), u = f.useRef(null), N = U(u, X(l), D), a = (t) => (i) => {
    if (t) {
      const o = u.current;
      i === void 0 ? t(o) : t(o, i);
    }
  }, S = a(H), W = a((t, i) => {
    B(t);
    const {
      duration: o,
      delay: c,
      easing: e
    } = v({
      style: p,
      timeout: r,
      easing: R
    }, {
      mode: "enter"
    });
    let d;
    r === "auto" ? (d = s.transitions.getAutoHeightDuration(t.clientHeight), E.current = d) : d = o, t.style.transition = [s.transitions.create("opacity", {
      duration: d,
      delay: c
    }), s.transitions.create("transform", {
      duration: h ? d : d * 0.666,
      delay: c,
      easing: e
    })].join(","), A && A(t, i);
  }), $ = a(w), q = a(P), z = a((t) => {
    const {
      duration: i,
      delay: o,
      easing: c
    } = v({
      style: p,
      timeout: r,
      easing: R
    }, {
      mode: "exit"
    });
    let e;
    r === "auto" ? (e = s.transitions.getAutoHeightDuration(t.clientHeight), E.current = e) : e = i, t.style.transition = [s.transitions.create("opacity", {
      duration: e,
      delay: o
    }), s.transitions.create("transform", {
      duration: h ? e : e * 0.666,
      delay: h ? o : o || e * 0.333,
      easing: c
    })].join(","), t.style.opacity = 0, t.style.transform = y(0.75), L && L(t);
  }), K = a(O);
  return /* @__PURE__ */ J(C, g({
    appear: _,
    in: b,
    nodeRef: u,
    onEnter: W,
    onEntered: $,
    onEntering: S,
    onExit: z,
    onExited: K,
    onExiting: q,
    addEndListener: (t) => {
      r === "auto" && G.start(E.current || 0, t), T && T(u.current, t);
    },
    timeout: r === "auto" ? null : r
  }, F, {
    children: (t, i) => /* @__PURE__ */ f.cloneElement(l, g({
      style: g({
        opacity: 0,
        transform: y(0.75),
        visibility: t === "exited" && !b ? "hidden" : void 0
      }, I[t], p, l.props.style),
      ref: N
    }, i))
  }));
});
process.env.NODE_ENV !== "production" && (j.propTypes = {
  // ┌────────────────────────────── Warning ──────────────────────────────┐
  // │ These PropTypes are generated from the TypeScript type definitions. │
  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
  // └─────────────────────────────────────────────────────────────────────┘
  /**
   * Add a custom transition end trigger. Called with the transitioning DOM
   * node and a done callback. Allows for more fine grained transition end
   * logic. Note: Timeouts are still used as a fallback if provided.
   */
  addEndListener: n.func,
  /**
   * Perform the enter transition when it first mounts if `in` is also `true`.
   * Set this to `false` to disable this behavior.
   * @default true
   */
  appear: n.bool,
  /**
   * A single child content element.
   */
  children: Y.isRequired,
  /**
   * The transition timing function.
   * You may specify a single easing or a object containing enter and exit values.
   */
  easing: n.oneOfType([n.shape({
    enter: n.string,
    exit: n.string
  }), n.string]),
  /**
   * If `true`, the component will transition in.
   */
  in: n.bool,
  /**
   * @ignore
   */
  onEnter: n.func,
  /**
   * @ignore
   */
  onEntered: n.func,
  /**
   * @ignore
   */
  onEntering: n.func,
  /**
   * @ignore
   */
  onExit: n.func,
  /**
   * @ignore
   */
  onExited: n.func,
  /**
   * @ignore
   */
  onExiting: n.func,
  /**
   * @ignore
   */
  style: n.object,
  /**
   * The duration for the transition, in milliseconds.
   * You may specify a single timeout for all transitions, or individually with an object.
   *
   * Set to 'auto' to automatically calculate transition time based on height.
   * @default 'auto'
   */
  timeout: n.oneOfType([n.oneOf(["auto"]), n.number, n.shape({
    appear: n.number,
    enter: n.number,
    exit: n.number
  })])
});
j.muiSupportAuto = !0;
export {
  j as default
};
