function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
import dayjs from 'dayjs';
import { Tag as AntdTag } from 'antd';
export var Tag = AntdTag;
export var formatAmount = function formatAmount(value, currencySymbol) {
  var num = Number(value || 0);
  var symbol = currencySymbol || '$';
  return "".concat(symbol).concat(num.toLocaleString(undefined, {
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  }));
};
export var getDisplayLines = function getDisplayLines(items) {
  return items.filter(function (item) {
    return item != null && item !== '';
  });
};
export var textStyles = {
  text: {
    fontSize: 12,
    color: '#475467',
    lineHeight: '18px'
  }
};
export var formatDateTime = function formatDateTime(value) {
  if (!value) return '';
  var parsed = dayjs(value);
  if (!parsed.isValid()) return value;
  return parsed.format('HH:mm ddd, D MMM');
};
export var buildDateTime = function buildDateTime(date, time) {
  if (date && time) return "".concat(date, " ").concat(time);
  return date || time || '';
};
export var normalizeList = function normalizeList(value) {
  if (Array.isArray(value)) return value;
  if (value == null) return [];
  return [value];
};
export var parseJson = function parseJson(value) {
  if (typeof value !== 'string') return value;
  try {
    return JSON.parse(value);
  } catch (_unused) {
    return value;
  }
};
export var formatPhone = function formatPhone(value, countryCallingCode) {
  if (value == null || value === '') return '';
  if (typeof value === 'string' || typeof value === 'number') {
    var text = String(value).trim();
    if (!text) return '';
    var code = countryCallingCode != null && countryCallingCode !== '' ? String(countryCallingCode).trim() : '';
    if (code && !text.startsWith('+') && !text.startsWith(code)) {
      var normalizedCode = code.startsWith('+') ? code : "+".concat(code);
      return "".concat(normalizedCode, " ").concat(text);
    }
    return text;
  }
  if (_typeof(value) === 'object') {
    var phoneValue = (value === null || value === void 0 ? void 0 : value.phone) || (value === null || value === void 0 ? void 0 : value.number);
    var _code = (value === null || value === void 0 ? void 0 : value.country_calling_code) || (value === null || value === void 0 ? void 0 : value.countryCallingCode);
    return formatPhone(phoneValue, _code !== null && _code !== void 0 ? _code : countryCallingCode);
  }
  return '';
};