function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React from "preact/compat";
import { useState } from "preact/compat";
import classNames from 'classnames';
import useCssDebugger from "../utilities/useCssDebugger";
import useId from "../utilities/useId";
import { t } from "../i18n";
import { LockCircleIcon, LockIcon, UsaFlagIcon, BuildingCircleIcon, ArrowIcon, CloseIconThin } from "../Icons";
/**
 * For information about how and when to use this component,
 * [refer to its full documentation page](https://design.cms.gov/components/usa-banner/).
 */
export var UsaBanner = function UsaBanner(props) {
  useCssDebugger();
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    isBannerOpen = _useState2[0],
    setBannerOpen = _useState2[1];
  var classes = classNames('ds-c-usa-banner', props.className);
  var rootId = useId('usa-banner--', props.id);
  var panelId = "".concat(rootId, "__panel");
  var toggleBanner = function toggleBanner() {
    setBannerOpen(!isBannerOpen);
  };
  var actionText = /*#__PURE__*/React.createElement(React.Fragment, null, t('usaBanner.bannerActionText'), /*#__PURE__*/React.createElement(ArrowIcon, {
    direction: isBannerOpen ? 'up' : 'down',
    className: "ds-c-usa-banner__action-icon"
  }));
  return /*#__PURE__*/React.createElement("section", {
    className: classes,
    "aria-label": t('usaBanner.bannerLabel')
  }, /*#__PURE__*/React.createElement("header", {
    className: classNames('ds-c-usa-banner__header ds-u-font-size--sm', isBannerOpen && 'ds-c-usa-banner__header--expanded')
  }, /*#__PURE__*/React.createElement(UsaFlagIcon, {
    className: "ds-c-usa-banner__header-icon"
  }), /*#__PURE__*/React.createElement("p", {
    className: "ds-c-usa-banner__header-text"
  }, t('usaBanner.bannerText')), /*#__PURE__*/React.createElement("p", {
    className: classNames('ds-c-usa-banner__action ds-u-align-items--center ds-u-md-display--none', !isBannerOpen && 'ds-u-display--flex')
  }, actionText), /*#__PURE__*/React.createElement("button", {
    type: "button",
    onClick: toggleBanner,
    className: "ds-c-usa-banner__button",
    "aria-expanded": isBannerOpen,
    "aria-controls": panelId
  }, /*#__PURE__*/React.createElement("span", {
    className: "ds-c-usa-banner__button-text ds-u-md-display--flex ds-u-align-items--center"
  }, actionText), /*#__PURE__*/React.createElement("span", {
    className: "ds-c-usa-banner__button-icon-container",
    hidden: !isBannerOpen
  }, /*#__PURE__*/React.createElement(CloseIconThin, {
    className: "ds-c-usa-banner__button-icon"
  })))), /*#__PURE__*/React.createElement("div", {
    className: "ds-c-usa-banner__guidance [ ds-u-leading--base ds-u-font-size--base ]"
  }, /*#__PURE__*/React.createElement("div", {
    id: panelId,
    className: "ds-c-usa-banner__guidance-container",
    hidden: !isBannerOpen
  }, /*#__PURE__*/React.createElement("div", {
    className: "ds-c-usa-banner__guidance-item"
  }, /*#__PURE__*/React.createElement(BuildingCircleIcon, {
    className: "ds-c-usa-banner__guidance-icon"
  }), /*#__PURE__*/React.createElement("p", {
    className: "ds-c-usa-banner__guidance-text"
  }, /*#__PURE__*/React.createElement("strong", null, t('usaBanner.domainHeaderText')), /*#__PURE__*/React.createElement("br", null), "".concat(t('usaBanner.domainAText'), " "), /*#__PURE__*/React.createElement("strong", null, " ".concat(t('usaBanner.govText'), " ")), t('usaBanner.domainText'))), /*#__PURE__*/React.createElement("div", {
    className: "ds-c-usa-banner__guidance-item"
  }, /*#__PURE__*/React.createElement(LockCircleIcon, {
    className: "ds-c-usa-banner__guidance-icon"
  }), /*#__PURE__*/React.createElement("p", {
    className: "ds-c-usa-banner__guidance-text"
  }, /*#__PURE__*/React.createElement("strong", null, t('usaBanner.httpsHeaderText')), /*#__PURE__*/React.createElement("br", null), "".concat(t('usaBanner.httpsAText'), " "), /*#__PURE__*/React.createElement("strong", null, "".concat(t('usaBanner.httpsLockText'), " ")), "(", /*#__PURE__*/React.createElement(LockIcon, {
    className: "ds-c-usa-banner__inline-lock-icon"
  }), ")", /*#__PURE__*/React.createElement("span", null, " ".concat(t('usaBanner.httpsOrText'))), /*#__PURE__*/React.createElement("strong", null, " ".concat(t('usaBanner.httpsText'), " ")), t('usaBanner.httpsDetailText'))))));
};
export default UsaBanner;