import p from "./index-extends.js";
import S from "./index-objectWithoutPropertiesLoose.js";
import * as f from "react";
import n from "./index-_virtual16.js";
import q from "./index-useTheme.js";
import { reflow as z, getTransitionProps as y } from "./index-utils6.js";
import { jsx as D } from "react/jsx-runtime";
import V from "./index-Transition.js";
import W from "./index-useForkRef.js";
import B from "./index-getReactElementRef.js";
import G from "./index-elementAcceptingRef.js";
const H = ["addEndListener", "appear", "children", "easing", "in", "onEnter", "onEntered", "onEntering", "onExit", "onExited", "onExiting", "style", "timeout", "TransitionComponent"], J = {
  entering: {
    opacity: 1
  },
  entered: {
    opacity: 1
  }
}, K = /* @__PURE__ */ f.forwardRef(function(m, h) {
  const i = q(), T = {
    enter: i.transitions.duration.enteringScreen,
    exit: i.transitions.duration.leavingScreen
  }, {
    addEndListener: E,
    appear: R = !0,
    children: a,
    easing: l,
    in: u,
    onEnter: x,
    onEntered: b,
    onEntering: L,
    onExit: g,
    onExited: P,
    onExiting: v,
    style: d,
    timeout: c = T,
    // eslint-disable-next-line react/prop-types
    TransitionComponent: w = V
  } = m, _ = S(m, H), s = f.useRef(null), j = W(s, B(a), h), o = (e) => (t) => {
    if (e) {
      const r = s.current;
      t === void 0 ? e(r) : e(r, t);
    }
  }, C = o(L), F = o((e, t) => {
    z(e);
    const r = y({
      style: d,
      timeout: c,
      easing: l
    }, {
      mode: "enter"
    });
    e.style.webkitTransition = i.transitions.create("opacity", r), e.style.transition = i.transitions.create("opacity", r), x && x(e, t);
  }), O = o(b), k = o(v), A = o((e) => {
    const t = y({
      style: d,
      timeout: c,
      easing: l
    }, {
      mode: "exit"
    });
    e.style.webkitTransition = i.transitions.create("opacity", t), e.style.transition = i.transitions.create("opacity", t), g && g(e);
  }), N = o(P);
  return /* @__PURE__ */ D(w, p({
    appear: R,
    in: u,
    nodeRef: s,
    onEnter: F,
    onEntered: O,
    onEntering: C,
    onExit: A,
    onExited: N,
    onExiting: k,
    addEndListener: (e) => {
      E && E(s.current, e);
    },
    timeout: c
  }, _, {
    children: (e, t) => /* @__PURE__ */ f.cloneElement(a, p({
      style: p({
        opacity: 0,
        visibility: e === "exited" && !u ? "hidden" : void 0
      }, J[e], d, a.props.style),
      ref: j
    }, t))
  }));
});
process.env.NODE_ENV !== "production" && (K.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: G.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.
   * @default {
   *   enter: theme.transitions.duration.enteringScreen,
   *   exit: theme.transitions.duration.leavingScreen,
   * }
   */
  timeout: n.oneOfType([n.number, n.shape({
    appear: n.number,
    enter: n.number,
    exit: n.number
  })])
});
export {
  K as default
};
