import React from 'react';
import moment from 'moment';
import { Tooltip, TOOLTIP_DELAY_TYPES, TOOLTIP_PLACEMENT_TYPES } from '../tooltip';
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
export const getLocalTime = (timestamp, standard = 'utc') => moment[standard](timestamp).local();
const TimeFromNow = ({
  timestamp,
  format,
  standard = 'utc',
  hideSuffix = false,
  showTooltip = false,
  tooltipPlacement = TOOLTIP_PLACEMENT_TYPES.TOP,
  tooltipDelayType = TOOLTIP_DELAY_TYPES.FAST
}) => {
  const localTime = getLocalTime(timestamp, standard);
  const content = format ? localTime.format(format) : localTime.fromNow(hideSuffix);
  return showTooltip ? /*#__PURE__*/_jsx(Tooltip, {
    content: timestamp,
    placement: tooltipPlacement,
    delayType: tooltipDelayType,
    children: /*#__PURE__*/_jsx("span", {
      children: content
    })
  }) : /*#__PURE__*/_jsx(_Fragment, {
    children: content
  });
};
export default TimeFromNow;