"use strict";

import React from 'react';
import styled from 'styled-components/native';
import { Line } from './StyledComponents';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const Container = styled.View`
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 100%;
  background-color: transparent;
  gap: 16px;
  margin: 16px 0;
`;
export const StyledDateLabel = styled.View`
  margin: 0;
  border-radius: 118px;
  padding: 5px 8px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background-color: ${props => '#e7edf9'};
`;
export const StyledDateText = styled.Text`
  color: ${props => '#0052cd'};
  font-size: 12px;
  font-weight: 400;
  line-height: 14px;
  white-space: nowrap;
`;
const DateLabel = ({
  date,
  colors
}) => {
  const today = new Date();
  const yesterday = new Date(today);
  yesterday.setDate(today.getDate() - 1);
  const sameDay = (d1, d2) => d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate();
  const sameYear = (d1, d2) => d1.getFullYear() === d2.getFullYear();
  let label;
  if (sameDay(date, today)) {
    label = 'Today';
  } else if (sameDay(date, yesterday)) {
    label = 'Yesterday';
  } else {
    const options = sameYear(date, today) ? {
      month: 'long',
      day: 'numeric'
    } : {
      month: 'long',
      day: 'numeric',
      year: 'numeric'
    };
    label = date.toLocaleDateString('en-US', options);
  }
  return /*#__PURE__*/_jsxs(Container, {
    children: [/*#__PURE__*/_jsx(Line, {}), /*#__PURE__*/_jsx(StyledDateLabel, {
      secondary: colors?.secondary,
      children: /*#__PURE__*/_jsx(StyledDateText, {
        primary: colors?.primary,
        children: label
      })
    }), /*#__PURE__*/_jsx(Line, {})]
  });
};
export default DateLabel;
//# sourceMappingURL=DateLabel.js.map