"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var MobileDropDownButton_exports = {};
__export(MobileDropDownButton_exports, {
  default: () => MobileDropDownButton
});
module.exports = __toCommonJS(MobileDropDownButton_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_react = require("react");
var import_react2 = require("react");
var import_colorToString = require("../../../../../../utils/colorToString");
var import_hooks = require("../../../../../../hooks");
var import_CaretDown8 = require("../../../../../../icons/CaretDown8");
var import_Plus8 = require("../../../../../../icons/Plus8");
var import_ArrowDown8 = require("../../../../../../icons/ArrowDown8");
var import_ChevronDown8 = require("../../../../../../icons/ChevronDown8");
var import_Link = require("../../../../../../shared/Link");
var import_Button = __toESM(require("../../../../../Button"));
var import_css = require("@emotion/css");
var import_use_style = require("../../../../../../../runtimes/react/use-style");
var import_responsive_style = require("../../../../../../utils/responsive-style");
function DropDownMenu({ className, open, ...restOfProps }) {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    "div",
    {
      ...restOfProps,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({ display: open ? "flex" : "none", flexDirection: "column", padding: 8 }),
        className
      )
    }
  );
}
function ButtonLink({ className, ...restOfProps }) {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Button.default, { ...restOfProps, className: (0, import_css.cx)((0, import_use_style.useStyle)({ margin: "8px 0" }), className) });
}
function DropDownItem({ color, className, textStyle, ...restOfProps }) {
  const colorData = (0, import_hooks.useResponsiveColor)(color);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    import_Link.Link,
    {
      ...restOfProps,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({
          textDecoration: "none",
          lineHeight: 1.4,
          padding: "8px 16px",
          color: "black"
        }),
        (0, import_use_style.useStyle)((0, import_responsive_style.useResponsiveTextStyle)(textStyle)),
        (0, import_use_style.useStyle)(
          (0, import_responsive_style.useResponsiveStyle)([colorData], ([color2]) => ({
            color: color2 == null ? "black" : (0, import_colorToString.colorToString)(color2)
          }))
        ),
        className
      )
    }
  );
}
function MobileDropDownButton({
  label,
  caret,
  links = [],
  onClose = () => {
  },
  color,
  textColor,
  ...restOfProps
}) {
  const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
      ButtonLink,
      {
        ...restOfProps,
        textColor: (0, import_hooks.useResponsiveColor)(textColor),
        color: (0, import_hooks.useResponsiveColor)(color),
        onPointerDown: () => setIsOpen((prev) => !prev),
        children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center" }, children: [
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { marginRight: 6 }, children: label }),
          /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { display: "inline-flex", fill: "currentColor" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
            caret === "caret" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_CaretDown8.CaretDown8, {}),
            caret === "plus" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Plus8.Plus8, {}),
            caret === "arrow-down" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ArrowDown8.ArrowDown8, {}),
            caret === "chevron-down" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChevronDown8.ChevronDown8, {})
          ] }) })
        ] })
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DropDownMenu, { open: isOpen, children: links.map(({ id, payload }) => /* @__PURE__ */ (0, import_react.createElement)(DropDownItem, { ...payload, key: id, onClick: onClose }, payload.label)) })
  ] });
}
//# sourceMappingURL=index.js.map