var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import styled, { css } from "styled-components";
import { Skeleton } from "@gympass/yoga";
import Text from "../../../Text";
import Actions from "./Actions";
import Box from "../../../Box";
const StyledSwitcher = styled(Box)`
  ${({
  fill,
  theme: {
    yoga: {
      colors,
      components: {
        navigationmenu: { border, gap, height, padding, width }
      }
    }
  }
}) => css`
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      gap: ${gap.xxsmall}px;
      padding: ${padding.xsmall}px;
      background-color: ${colors[fill]};
      border-radius: ${border.radius.default}px;

      > div:first-child {
        height: ${height.xlarge}px;
        width: ${width.xlarge}px;
      }
    `}
`;
const StyledTextContainer = styled.div`
  flex: 1;
  overflow: hidden;
`;
const StyledTitle = styled(Text.Body2)`
  ${({
  theme: {
    yoga: {
      components: {
        navigationmenu: { font }
      }
    }
  }
}) => css`
      font-weight: ${font.weight.bold};
      flex: 1;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    `}
`;
const StyledSubtitle = styled(Text.Tiny)`
  ${({
  theme: {
    yoga: {
      components: {
        navigationmenu: { font }
      }
    }
  }
}) => css`
      color: ${font.color.default};
    `}
`;
const Switcher = (_a) => {
  var _b = _a, {
    actions,
    avatar: Avatar,
    fill = "transparent",
    isLoading = false,
    subtitle,
    title
  } = _b, actionsProps = __objRest(_b, [
    "actions",
    "avatar",
    "fill",
    "isLoading",
    "subtitle",
    "title"
  ]);
  const hasActions = !!(actions == null ? void 0 : actions.length);
  return /* @__PURE__ */ jsxs(StyledSwitcher, { fill, children: [
    Avatar,
    /* @__PURE__ */ jsx(StyledTextContainer, { children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
      /* @__PURE__ */ jsx(
        Skeleton,
        {
          type: "text",
          variant: "overline",
          width: "100%",
          marginBottom: "4px"
        }
      ),
      /* @__PURE__ */ jsx(Skeleton, { type: "text", variant: "overline", width: "100%" })
    ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
      title && /* @__PURE__ */ jsx(StyledTitle, { children: title }),
      subtitle && /* @__PURE__ */ jsx(StyledSubtitle, { children: subtitle })
    ] }) }),
    hasActions && /* @__PURE__ */ jsx(Actions, __spreadValues({ actions }, actionsProps))
  ] });
};
var Switcher_default = Switcher;
export {
  Switcher_default as default
};
