import B from "./index-objectWithoutPropertiesLoose.js";
import n from "./index-extends.js";
import * as v from "react";
import r from "./index-_virtual16.js";
import { clsx as m } from "./index-clsx.js";
import { useRtl as H } from "./index-RtlProvider.js";
import F from "./index-useTheme.js";
import P from "./index-styled.js";
import { getDrawerUtilityClass as L } from "./index-drawerClasses.js";
import { jsx as p } from "react/jsx-runtime";
import { useDefaultProps as U } from "./index-DefaultPropsProvider.js";
import V from "./index-Slide.js";
import f from "./index-capitalize.js";
import W from "./index-composeClasses.js";
import q from "./index-Paper.js";
import Y from "./index-rootShouldForwardProp.js";
import G from "./index-Modal2.js";
import J from "./index-integerPropType.js";
const K = ["BackdropProps"], Q = ["anchor", "BackdropProps", "children", "className", "elevation", "hideBackdrop", "ModalProps", "onClose", "open", "PaperProps", "SlideProps", "TransitionComponent", "transitionDuration", "variant"], T = (e, o) => {
  const {
    ownerState: t
  } = e;
  return [o.root, (t.variant === "permanent" || t.variant === "persistent") && o.docked, o.modal];
}, X = (e) => {
  const {
    classes: o,
    anchor: t,
    variant: a
  } = e, c = {
    root: ["root"],
    docked: [(a === "permanent" || a === "persistent") && "docked"],
    modal: ["modal"],
    paper: ["paper", `paperAnchor${f(t)}`, a !== "temporary" && `paperAnchorDocked${f(t)}`]
  };
  return W(c, L, o);
}, Z = P(G, {
  name: "MuiDrawer",
  slot: "Root",
  overridesResolver: T
})(({
  theme: e
}) => ({
  zIndex: (e.vars || e).zIndex.drawer
})), R = P("div", {
  shouldForwardProp: Y,
  name: "MuiDrawer",
  slot: "Docked",
  skipVariantsResolver: !1,
  overridesResolver: T
})({
  flex: "0 0 auto"
}), oo = P(q, {
  name: "MuiDrawer",
  slot: "Paper",
  overridesResolver: (e, o) => {
    const {
      ownerState: t
    } = e;
    return [o.paper, o[`paperAnchor${f(t.anchor)}`], t.variant !== "temporary" && o[`paperAnchorDocked${f(t.anchor)}`]];
  }
})(({
  theme: e,
  ownerState: o
}) => n({
  overflowY: "auto",
  display: "flex",
  flexDirection: "column",
  height: "100%",
  flex: "1 0 auto",
  zIndex: (e.vars || e).zIndex.drawer,
  // Add iOS momentum scrolling for iOS < 13.0
  WebkitOverflowScrolling: "touch",
  // temporary style
  position: "fixed",
  top: 0,
  // We disable the focus ring for mouse, touch and keyboard users.
  // At some point, it would be better to keep it for keyboard users.
  // :focus-ring CSS pseudo-class will help.
  outline: 0
}, o.anchor === "left" && {
  left: 0
}, o.anchor === "top" && {
  top: 0,
  left: 0,
  right: 0,
  height: "auto",
  maxHeight: "100%"
}, o.anchor === "right" && {
  right: 0
}, o.anchor === "bottom" && {
  top: "auto",
  left: 0,
  bottom: 0,
  right: 0,
  height: "auto",
  maxHeight: "100%"
}, o.anchor === "left" && o.variant !== "temporary" && {
  borderRight: `1px solid ${(e.vars || e).palette.divider}`
}, o.anchor === "top" && o.variant !== "temporary" && {
  borderBottom: `1px solid ${(e.vars || e).palette.divider}`
}, o.anchor === "right" && o.variant !== "temporary" && {
  borderLeft: `1px solid ${(e.vars || e).palette.divider}`
}, o.anchor === "bottom" && o.variant !== "temporary" && {
  borderTop: `1px solid ${(e.vars || e).palette.divider}`
})), M = {
  left: "right",
  right: "left",
  top: "down",
  bottom: "up"
};
function ro(e) {
  return ["left", "right"].indexOf(e) !== -1;
}
function eo({
  direction: e
}, o) {
  return e === "rtl" && ro(o) ? M[o] : o;
}
const to = /* @__PURE__ */ v.forwardRef(function(o, t) {
  const a = U({
    props: o,
    name: "MuiDrawer"
  }), c = F(), N = H(), j = {
    enter: c.transitions.duration.enteringScreen,
    exit: c.transitions.duration.leavingScreen
  }, {
    anchor: b = "left",
    BackdropProps: C,
    children: O,
    className: u,
    elevation: x = 16,
    hideBackdrop: $ = !1,
    ModalProps: {
      BackdropProps: z
    } = {},
    onClose: A,
    open: h = !1,
    PaperProps: g = {},
    SlideProps: I,
    // eslint-disable-next-line react/prop-types
    TransitionComponent: _ = V,
    transitionDuration: D = j,
    variant: d = "temporary"
  } = a, S = B(a.ModalProps, K), l = B(a, Q), k = v.useRef(!1);
  v.useEffect(() => {
    k.current = !0;
  }, []);
  const E = eo({
    direction: N ? "rtl" : "ltr"
  }, b), s = n({}, a, {
    anchor: b,
    elevation: x,
    open: h,
    variant: d
  }, l), i = X(s), w = /* @__PURE__ */ p(oo, n({
    elevation: d === "temporary" ? x : 0,
    square: !0
  }, g, {
    className: m(i.paper, g.className),
    ownerState: s,
    children: O
  }));
  if (d === "permanent")
    return /* @__PURE__ */ p(R, n({
      className: m(i.root, i.docked, u),
      ownerState: s,
      ref: t
    }, l, {
      children: w
    }));
  const y = /* @__PURE__ */ p(_, n({
    in: h,
    direction: M[E],
    timeout: D,
    appear: k.current
  }, I, {
    children: w
  }));
  return d === "persistent" ? /* @__PURE__ */ p(R, n({
    className: m(i.root, i.docked, u),
    ownerState: s,
    ref: t
  }, l, {
    children: y
  })) : /* @__PURE__ */ p(Z, n({
    BackdropProps: n({}, C, z, {
      transitionDuration: D
    }),
    className: m(i.root, i.modal, u),
    open: h,
    ownerState: s,
    onClose: A,
    hideBackdrop: $,
    ref: t
  }, l, S, {
    children: y
  }));
});
process.env.NODE_ENV !== "production" && (to.propTypes = {
  // ┌────────────────────────────── Warning ──────────────────────────────┐
  // │ These PropTypes are generated from the TypeScript type definitions. │
  // │    To update them, edit the d.ts file and run `pnpm proptypes`.     │
  // └─────────────────────────────────────────────────────────────────────┘
  /**
   * Side from which the drawer will appear.
   * @default 'left'
   */
  anchor: r.oneOf(["bottom", "left", "right", "top"]),
  /**
   * @ignore
   */
  BackdropProps: r.object,
  /**
   * The content of the component.
   */
  children: r.node,
  /**
   * Override or extend the styles applied to the component.
   */
  classes: r.object,
  /**
   * @ignore
   */
  className: r.string,
  /**
   * The elevation of the drawer.
   * @default 16
   */
  elevation: J,
  /**
   * If `true`, the backdrop is not rendered.
   * @default false
   */
  hideBackdrop: r.bool,
  /**
   * Props applied to the [`Modal`](/material-ui/api/modal/) element.
   * @default {}
   */
  ModalProps: r.object,
  /**
   * Callback fired when the component requests to be closed.
   * The `reason` parameter can optionally be used to control the response to `onClose`.
   *
   * @param {object} event The event source of the callback.
   * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
   */
  onClose: r.func,
  /**
   * If `true`, the component is shown.
   * @default false
   */
  open: r.bool,
  /**
   * Props applied to the [`Paper`](/material-ui/api/paper/) element.
   * @default {}
   */
  PaperProps: r.object,
  /**
   * Props applied to the [`Slide`](/material-ui/api/slide/) element.
   */
  SlideProps: r.object,
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx: r.oneOfType([r.arrayOf(r.oneOfType([r.func, r.object, r.bool])), r.func, r.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,
   * }
   */
  transitionDuration: r.oneOfType([r.number, r.shape({
    appear: r.number,
    enter: r.number,
    exit: r.number
  })]),
  /**
   * The variant to use.
   * @default 'temporary'
   */
  variant: r.oneOf(["permanent", "persistent", "temporary"])
});
export {
  to as default,
  eo as getAnchor,
  ro as isHorizontal
};
