import{jsxs as e,jsx as n}from"react/jsx-runtime";import r,{forwardRef as a,useMemo as t}from"react";import o from"classnames";import l from"../Button/Button.js";import s from"../Icon/Icon.js";import i from"../Icon/Icons/components/CloseSmall.js";import{AlertBannerBackgroundColor as c}from"./AlertBannerConstants.js";import{NOOP as m}from"../../utils/function-utils.js";import"./AlertBanner.scss.js";var b=a((function(a,c){var d=a.children,u=a.className,p=a.backgroundColor,f=void 0===p?b.backgroundColors.NORMAL:p,g=a.onClose,j=void 0===g?m:g,_=a.ariaLabel,A=void 0===_?"":_,N=a.isCloseHidden,O=void 0!==N&&N,v=t((function(){return o(u,"l3-alert-banner","l3-alert-banner--background-color-".concat(f))}),[u,f]),C=f===b.backgroundColors.WARNING,k=t((function(){return r.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,n){return r.cloneElement(e,Object.assign(Object.assign({},null==e?void 0:e.props),{marginLeft:n>0,isDarkBackground:C}))}))}),[d,C]);return e("div",Object.assign({ref:c,className:v,role:"banner","aria-label":A||"banner"},{children:[n("div",Object.assign({className:"l3-alert-banner__inner"},{children:k.map((function(e,r){var a=e.type.isAlertBannerText;return n("div",Object.assign({className:o("l3-alert-banner__inner-item",{"l3-alert-banner__inner-item-text":a})},{children:a?n("div",Object.assign({className:"l3-alert-banner__ellipsis"},{children:e})):e}),r)}))})),n("div",Object.assign({className:"l3-alert-banner__close-button-wrapper"},{children:O?null:n(l,Object.assign({className:"l3-alert-banner__alert-banner-close-btn",onClick:j,size:l.sizes.SMALL,kind:l.kinds.TERTIARY,color:C?l.colors.ON_INVERTED_BACKGROUND:l.colors.ON_PRIMARY_COLOR,ariaLabel:"close-toast"},{children:n(s,{iconType:s.type.SVG,clickable:!1,icon:i,iconSize:"20px",ignoreFocusStyle:!0})}))}))]}))}));Object.assign(b,{backgroundColors:c});var d=b;export{d as default};
