var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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 __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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 React from "react";
import styled, { withTheme, css } from "styled-components";
import { shape, string, bool, oneOfType, func } from "prop-types";
import { Time } from "@gympass/yoga-icons";
import { TouchableWithoutFeedback } from "react-native";
import theme from "../../../Theme/helpers/themeReader";
import Card from "../Card";
import Text from "../../../Text";
import Box from "../../../Box";
import Button from "../../../Button";
const { spacing, radii, colors, borders } = theme;
const Event = styled(Card).attrs({ hasShadow: false })`
  flex-direction: row;
  height: 104px;
  border-radius: ${radii.regular}px;
  padding: ${spacing.zero};
  width: 280px;
  margin-right: ${spacing.xxsmall};

  ${({ small }) => small ? css`
          width: ${spacing.xxxlarge}px;
        ` : ""}
`;
const DateInfo = styled(Box)`
  justify-content: center;
  align-items: center;
  width: 56px;

  ${({ small, active }) => small ? css`
          border: ${borders.small}px solid
            ${active ? colors.primary : colors.elements.lineAndBorders};
          border-radius: ${radii.regular}px;
        ` : css`
          border: ${borders.small}px solid ${colors.primary};
          border-top-left-radius: ${radii.regular}px;
          border-bottom-left-radius: ${radii.regular}px;
        `}
`;
const EventInfo = styled(Box)`
  flex: 1;
  border-top-right-radius: ${radii.regular}px;
  border-bottom-right-radius: ${radii.regular}px;
  border: ${borders.small}px solid ${colors.elements.lineAndBorders};
`;
const Top = styled(Box)`
  justify-content: center;
  align-items: center;
  height: ${spacing.small}px;
`;
const Name = styled(Text.Body2)`
  margin-bottom: ${spacing.xxxsmall}px;
`;
const Place = styled(Text.Caption)`
  width: 180px;
  margin-bottom: ${spacing.xsmall}px;
`;
const Day = styled(Text.H5).attrs({ bold: true })`
  margin-top: ${spacing.xxxsmall}px;
  margin-bottom: ${spacing.xxxsmall}px;
`;
const getIndicatorColor = (active, event) => {
  if (active)
    return "white";
  return event ? "primary" : "light";
};
const Indicator = styled(Box)`
  width: ${spacing.xxsmall}px;
  height: ${spacing.xxsmall}px;
`;
const Row = styled(Box)`
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
`;
const EventTime = styled(Box)`
  flex-direction: row;
  align-items: center;
`;
const ButtonLink = styled(Button.Link)`
  align-self: flex-end;
`;
const SmallCard = ({
  date: { month, day, dayOfWeek },
  active = false,
  event = void 0,
  onPress = void 0
}) => /* @__PURE__ */ jsxs(DateInfo, { small: true, active, pv: "medium", bg: active ? "primary" : "white", children: [
  /* @__PURE__ */ jsx(Top, { children: onPress ? /* @__PURE__ */ jsx(
    Indicator,
    {
      borderRadius: "small",
      bgColor: getIndicatorColor(active, Boolean(event))
    }
  ) : /* @__PURE__ */ jsx(Text.Caption, { variant: active ? "white" : "deep", children: month }) }),
  /* @__PURE__ */ jsx(Day, { variant: active ? "white" : "secondary", children: day }),
  /* @__PURE__ */ jsx(Text.Caption, { variant: active ? "white" : "deep", children: String(dayOfWeek).toUpperCase() })
] });
const FullCard = withTheme(
  ({
    event,
    date: { month, day, dayOfWeek },
    link,
    onLinkPress,
    theme: {
      yoga: {
        components: {
          card: {
            event: { icon }
          }
        }
      }
    }
  }) => /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsxs(DateInfo, { bg: "primary", children: [
      /* @__PURE__ */ jsx(Top, { children: /* @__PURE__ */ jsx(Text.Caption, { inverted: true, children: month }) }),
      /* @__PURE__ */ jsx(Day, { inverted: true, children: day }),
      /* @__PURE__ */ jsx(Text.Caption, { inverted: true, children: String(dayOfWeek).toUpperCase() })
    ] }),
    /* @__PURE__ */ jsxs(EventInfo, { p: "small", pl: "xsmall", children: [
      /* @__PURE__ */ jsx(Name, { numberOfLines: 1, size: "small", children: event.name }),
      /* @__PURE__ */ jsx(Place, { variant: "deep", numberOfLines: 1, children: event.place }),
      /* @__PURE__ */ jsxs(Row, { children: [
        /* @__PURE__ */ jsxs(EventTime, { children: [
          /* @__PURE__ */ jsx(Time, { fill: icon.fill, style: { marginRight: 5 } }),
          /* @__PURE__ */ jsx(Text.Caption, { children: event.time })
        ] }),
        !!link && /* @__PURE__ */ jsx(ButtonLink, { onPress: onLinkPress, small: true, secondary: true, children: link })
      ] })
    ] })
  ] })
);
const EventCard = (_a) => {
  var _b = _a, {
    onPress,
    small = false,
    active = false,
    event,
    link = "",
    onLinkPress
  } = _b, rest = __objRest(_b, [
    "onPress",
    "small",
    "active",
    "event",
    "link",
    "onLinkPress"
  ]);
  return /* @__PURE__ */ jsx(TouchableWithoutFeedback, { onPress, children: /* @__PURE__ */ jsx(
    Event,
    __spreadProps(__spreadValues({
      small,
      active,
      link,
      event,
      onLinkPress
    }, rest), {
      children: small ? /* @__PURE__ */ jsx(
        SmallCard,
        __spreadValues({
          onPress,
          active,
          link,
          onLinkPress,
          event
        }, rest)
      ) : /* @__PURE__ */ jsx(
        FullCard,
        __spreadValues({
          active,
          link,
          onLinkPress,
          event
        }, rest)
      )
    })
  ) });
};
EventCard.propTypes = {
  /** event information: { name (string), place (string), time (string) } */
  event: oneOfType([
    shape({
      name: string,
      place: string,
      time: string
    }),
    bool
  ]),
  /** date information: { day (string), dayOfWeek (string), month (string) } */
  date: shape({
    day: string,
    dayOfWeek: string,
    month: string
  }).isRequired,
  small: bool,
  active: bool,
  link: string,
  onLinkPress: func,
  onPress: func
};
SmallCard.propTypes = {
  date: shape({
    day: string,
    dayOfWeek: string,
    month: string
  }).isRequired,
  active: bool,
  event: oneOfType([
    shape({
      name: string,
      place: string,
      time: string
    }),
    bool
  ]),
  onPress: func
};
FullCard.propTypes = EventCard.propTypes;
EventCard.displayName = "EventCard";
var EventCard_default = EventCard;
export {
  EventCard_default as default
};
