import { jsx as y } from "react/jsx-runtime";
import { useState as F } from "react";
import { AnimatePresence as O, motion as R } from "motion/react";
import { noop as h } from "es-toolkit/compat";
import C from "../../hooks/useAfterMount.js";
const M = {
  fromLeft: {
    initial: { x: -10, y: 0, opacity: 0 },
    animate: { x: 0, y: 0, opacity: 1 },
    exit: { x: -10, y: 0, opacity: 0 }
  },
  fromRight: {
    initial: { x: 10, y: 0, opacity: 0 },
    animate: { x: 0, y: 0, opacity: 1 },
    exit: { x: 10, y: 0, opacity: 0 }
  },
  fromTop: {
    initial: { y: -10, x: 0, opacity: 0 },
    animate: { y: 0, x: 0, opacity: 1 },
    exit: { y: -10, x: 0, opacity: 0 }
  },
  fromBottom: {
    initial: { y: 10, x: 0, opacity: 0 },
    animate: { y: 0, x: 0, opacity: 1 },
    exit: { y: 10, x: 0, opacity: 0 }
  },
  fade: {
    initial: { x: 0, y: 0, opacity: 0 },
    animate: { x: 0, y: 0, opacity: 1 },
    exit: { x: 0, y: 0, opacity: 0 }
  },
  tabs: {
    initial: { x: 2, y: 0, opacity: 0 },
    animate: { x: 0, y: 0, opacity: 1 },
    exit: { x: -2, y: 0, opacity: 0 }
  },
  page: {
    initial: "pageEnter",
    animate: "pageCenter",
    exit: "pageExit"
  },
  pageBack: {
    initial: "pageEnter",
    animate: "pageCenter",
    exit: "pageExit"
  }
}, k = (i) => i === "pageBack" ? -1 : 1, I = {
  pageEnter: (i) => ({ x: `${i * 60}%`, opacity: 0 }),
  pageCenter: { x: 0, opacity: 1 },
  pageExit: (i) => ({ zIndex: 0, x: `${-i * 60}%`, opacity: 0 })
}, t = (i) => {
  const {
    show: s = !0,
    initial: m = !1,
    duration: l = 0.2,
    exitBeforeEnter: x = !1,
    animationStyle: a = "fade",
    animatePresenceProps: f,
    motionProps: g,
    onExitComplete: d = h,
    children: e
  } = i, [o, A] = F(m);
  C(() => {
    o || A(!0);
  });
  let n = "fade";
  if (Array.isArray(e)) {
    const [T] = e.filter(Boolean);
    n = `fade-${T.key}`;
  }
  const r = a === "page" || a === "pageBack", P = k(a), p = r ? P : null, u = r ? { variants: I } : null, c = M[a], E = o ? c.initial : !1, B = { ...c, initial: E };
  return /* @__PURE__ */ y(
    O,
    {
      initial: o,
      mode: x ? "wait" : "sync",
      onExitComplete: d,
      custom: p,
      ...f,
      children: s && /* @__PURE__ */ y(
        R.div,
        {
          transition: { duration: l },
          custom: p,
          ...B,
          ...u,
          ...g,
          children: e
        },
        n
      )
    }
  );
};
t.FADE = "fade";
t.FROM_LEFT = "fromLeft";
t.FROM_RIGHT = "fromRight";
t.FROM_TOP = "fromTop";
t.FROM_BOTTOM = "fromBottom";
t.TABS = "tabs";
t.PAGE = "page";
t.PAGE_BACK = "pageBack";
export {
  t as default
};
//# sourceMappingURL=Fade.js.map
