import { jsx, jsxs } from "react/jsx-runtime";
import { Fragment } from "react";
import { colorToString } from "../../../../utils/colorToString";
import { Times16 } from "../../../../icons/Times16";
import Button from "../../../Button";
import DropDownButton from "./components/MobileDropDownButton";
import { useResponsiveColor } from "../../../../hooks";
import { cx } from "@emotion/css";
import { useStyle } from "../../../../../runtimes/react/use-style";
import { useResponsiveStyle } from "../../../../utils/responsive-style";
function ButtonLink({
  className,
  textColor,
  color,
  ...restOfProps
}) {
  return /* @__PURE__ */ jsx(
    Button,
    {
      ...restOfProps,
      className: cx(useStyle({ margin: "8px 0" }), className),
      textColor: useResponsiveColor(textColor),
      color: useResponsiveColor(color)
    }
  );
}
function Container({
  className,
  animation,
  backgroundColor,
  open,
  ...restOfProps
}) {
  return /* @__PURE__ */ jsx(
    "div",
    {
      ...restOfProps,
      className: cx(
        useStyle({
          position: "fixed",
          flexDirection: "column",
          width: "100%",
          padding: "40px 15px",
          transition: "transform 300ms ease-in-out",
          overflowY: "auto",
          zIndex: 9999,
          maxWidth: 575
        }),
        useStyle(
          useResponsiveStyle(
            [animation, backgroundColor],
            ([animation2, backgroundColor2]) => {
              if (animation2 == null)
                return { display: "none" };
              return {
                display: "flex",
                backgroundColor: backgroundColor2 == null ? "black" : colorToString(backgroundColor2),
                transform: open ? `translate3d(0,0,0)` : `translate3d(${{ coverRight: "", coverLeft: "-" }[animation2]}100%, 0, 0)`,
                ...{
                  coverRight: { top: 0, bottom: 0, right: 0 },
                  coverLeft: { top: 0, bottom: 0, left: 0 }
                }[animation2]
              };
            }
          )
        ),
        className
      )
    }
  );
}
function CloseIconContainer({ className, color, ...restOfProps }) {
  return /* @__PURE__ */ jsx(
    "button",
    {
      ...restOfProps,
      className: cx(
        useStyle({
          position: "absolute",
          top: 15,
          right: 15,
          padding: 0,
          border: 0,
          outline: 0,
          background: "none",
          fill: "currentcolor"
        }),
        useStyle(
          useResponsiveStyle([color], ([color2]) => ({
            color: color2 == null ? "rgba(161, 168, 194, 0.5)" : colorToString(color2)
          }))
        ),
        className
      )
    }
  );
}
function MobileMenu({
  animation,
  backgroundColor,
  open = false,
  closeIconColor,
  links = [],
  onClose = () => {
  }
}) {
  return /* @__PURE__ */ jsxs(Container, { animation, backgroundColor, open, children: [
    /* @__PURE__ */ jsx(CloseIconContainer, { color: closeIconColor, onClick: onClose, children: /* @__PURE__ */ jsx(Times16, {}) }),
    /* @__PURE__ */ jsx(
      "div",
      {
        style: { display: "flex", flexDirection: "column", alignItems: "center", flexShrink: 0 },
        children: links.map((link) => /* @__PURE__ */ jsxs(Fragment, { children: [
          link.type === "button" && /* @__PURE__ */ jsx(ButtonLink, { ...link.payload, onClick: onClose, children: link.payload.label }),
          link.type === "dropdown" && /* @__PURE__ */ jsx(DropDownButton, { ...link.payload, onClose })
        ] }, link.id))
      }
    )
  ] });
}
export {
  MobileMenu as default
};
//# sourceMappingURL=index.js.map