import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{getStyle as t}from"../../helpers/typesciptCssModulesHelper.js";import r from"classnames";import n,{forwardRef as o,useMemo as a}from"react";import s from"../IconButton/IconButton.js";import{AlertBannerBackgroundColor as i}from"./AlertBannerConstants.js";import{NOOP as l}from"../../utils/function-utils.js";import{ComponentDefaultTestId as m,ComponentVibeId as c}from"../../tests/constants.js";import{getTestId as p}from"../../tests/testIds.js";import{withStaticProps as d}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import u from"./AlertBanner.module.scss.js";import f from"../Text/Text.js";import{AlertBannerContext as v}from"./AlertBannerContext.js";import B from"../../../packages/icons/dist/react/CloseSmall.js";var b=d(o((function(o,i){var d=o.children,b=o.className,j=o.backgroundColor,A=void 0===j?"primary":j,y=o.onClose,C=void 0===y?l:y,E=o.ariaLabel,k=void 0===E?"":E,N=o.closeButtonAriaLabel,g=void 0===N?"Close":N,x=o.isCloseHidden,T=void 0!==x&&x,I=o.id,L=o["data-testid"],h=a((function(){return r(b,u.alertBanner,t(u,A))}),[b,A]),P="dark"===A,R="warning"===A,_=a((function(){return R?"fixedDark":P?"onInverted":"onPrimary"}),[P,R]),D=a((function(){return n.Children.toArray(d).filter((function(e){return!(!e.type.isAlertBannerItem&&"MDXCreateElement"!==e.type.displayName)||(console.error("Alert banner child is not supported. Please use AlertBannerText, AlertBannerLink or AlertBannerButton.",e),!1)})).map((function(e,t){return n.cloneElement(e,Object.assign(Object.assign({},null==e?void 0:e.props),{marginLeft:t>0,isDarkBackground:P}))}))}),[d,P]);return n.createElement(f,{type:"text2",color:_,ref:i,className:h,role:"banner","aria-label":k||"banner",id:I,"data-testid":L||p(m.ALERT_BANNER,I),"data-vibe":c.ALERT_BANNER},n.createElement(v.Provider,{value:{textColor:_}},n.createElement("div",{className:r(u.content)},D.map((function(t,o){var a=t.type.isAlertBannerText;return n.createElement("div",{key:o,className:r(u.contentItem,e({},u.contentItemText,a))},a?n.createElement("div",{className:r(u.ellipsis)},t):t)})))),n.createElement("div",{className:r(u.closeButtonWrapper)},T?null:n.createElement(s,{"data-testid":"alert-banner-close-button",icon:B,className:r(u.closeBtn),hideTooltip:!0,onClick:C,size:"small",kind:"tertiary",color:P?"on-inverted-background":"on-primary-color",ariaLabel:g})))})),{backgroundColors:i});export{b as default};
//# sourceMappingURL=AlertBanner.js.map
