"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.StyledDateText = exports.StyledDateLabel = void 0;
var _react = _interopRequireDefault(require("react"));
var _native = _interopRequireDefault(require("styled-components/native"));
var _StyledComponents = require("./StyledComponents");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const Container = _native.default.View`
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 100%;
  background-color: transparent;
  gap: 16px;
  margin: 16px 0;
`;
const StyledDateLabel = exports.StyledDateLabel = _native.default.View`
  margin: 0;
  border-radius: 118px;
  padding: 5px 8px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background-color: ${props => '#e7edf9'};
`;
const StyledDateText = exports.StyledDateText = _native.default.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__*/(0, _jsxRuntime.jsxs)(Container, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledComponents.Line, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDateLabel, {
      secondary: colors?.secondary,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDateText, {
        primary: colors?.primary,
        children: label
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledComponents.Line, {})]
  });
};
var _default = exports.default = DateLabel;
//# sourceMappingURL=DateLabel.js.map