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{CloseSmall as i}from"@vibe/icons";import{AlertBannerBackgroundColor as l}from"./AlertBannerConstants.js";import{NOOP as m}from"../../utils/function-utils.js";import{ComponentDefaultTestId as c,ComponentVibeId as p}from"../../tests/constants.js";import{getTestId as d}from"../../tests/testIds.js";import{withStaticProps as u}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import f from"./AlertBanner.module.scss.js";import v from"../Text/Text.js";import{AlertBannerContext as B}from"./AlertBannerContext.js";var b=u(o((function(o,l){var u=o.children,b=o.className,A=o.backgroundColor,j=void 0===A?"primary":A,y=o.onClose,E=void 0===y?m:y,C=o.ariaLabel,N=void 0===C?"":C,k=o.closeButtonAriaLabel,x=void 0===k?"Close":k,g=o.isCloseHidden,T=void 0!==g&&g,I=o.id,L=o["data-testid"],h=a((function(){return r(b,f.alertBanner,t(f,j))}),[b,j]),P="dark"===j,R="warning"===j,_=a((function(){return R?"fixedDark":P?"onInverted":"onPrimary"}),[P,R]),D=a((function(){return n.Children.toArray(u).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}))}))}),[u,P]);return n.createElement(v,{type:"text2",color:_,ref:l,className:h,role:"banner","aria-label":N||"banner",id:I,"data-testid":L||d(c.ALERT_BANNER,I),"data-vibe":p.ALERT_BANNER},n.createElement(B.Provider,{value:{textColor:_}},n.createElement("div",{className:r(f.content)},D.map((function(t,o){var a=t.type.isAlertBannerText;return n.createElement("div",{key:o,className:r(f.contentItem,e({},f.contentItemText,a))},a?n.createElement("div",{className:r(f.ellipsis)},t):t)})))),n.createElement("div",{className:r(f.closeButtonWrapper)},T?null:n.createElement(s,{"data-testid":"alert-banner-close-button",icon:i,className:r(f.closeBtn),hideTooltip:!0,onClick:E,size:"small",kind:"tertiary",color:P?"on-inverted-background":"on-primary-color",ariaLabel:x})))})),{backgroundColors:l});export{b as default};
//# sourceMappingURL=AlertBanner.js.map
