// packages/components/src/date-time/time/timezone.tsx
import { __ } from "@wordpress/i18n";
import { getSettings as getDateSettings } from "@wordpress/date";
import Tooltip from "../../tooltip/index.js";
import { TimeZone as StyledComponent } from "./styles.js";
import { jsx as _jsx } from "react/jsx-runtime";
var TimeZone = () => {
  const {
    timezone
  } = getDateSettings();
  const userTimezoneOffset = -1 * ((/* @__PURE__ */ new Date()).getTimezoneOffset() / 60);
  if (Number(timezone.offset) === userTimezoneOffset) {
    return null;
  }
  const offsetSymbol = Number(timezone.offset) >= 0 ? "+" : "";
  const zoneAbbr = "" !== timezone.abbr && isNaN(Number(timezone.abbr)) ? timezone.abbr : `UTC${offsetSymbol}${timezone.offsetFormatted}`;
  const prettyTimezoneString = timezone.string.replace("_", " ");
  const timezoneDetail = "UTC" === timezone.string ? __("Coordinated Universal Time") : `(${zoneAbbr}) ${prettyTimezoneString}`;
  const hasNoAdditionalTimezoneDetail = prettyTimezoneString.trim().length === 0;
  return hasNoAdditionalTimezoneDetail ? /* @__PURE__ */ _jsx(StyledComponent, {
    className: "components-datetime__timezone",
    children: zoneAbbr
  }) : /* @__PURE__ */ _jsx(Tooltip, {
    placement: "top",
    text: timezoneDetail,
    children: /* @__PURE__ */ _jsx(StyledComponent, {
      className: "components-datetime__timezone",
      children: zoneAbbr
    })
  });
};
var timezone_default = TimeZone;
export {
  timezone_default as default
};
//# sourceMappingURL=timezone.js.map
