/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";var tslib_es6=require("./tslib.es6-7DbU_BSw.js"),index=require("./index-D0FxsaCe.js"),clsx=require("./clsx-CkZlkaek.js"),componentNames=require("./component-names-CuI-0Pbo.js"),i18n=require("./i18n-DNWGj4j8.js"),bem=require("./bem-CWXmxX43.js"),Heading=require("./Heading-CsroEQcs.js");const translateError=i18n.translate("kol-error"),translateInfo=i18n.translate("kol-info"),translateWarning=i18n.translate("kol-warning"),translateSuccess=i18n.translate("kol-success"),translateMessage=i18n.translate("kol-message"),Icon=({ariaLabel:e,icon:a})=>index.h(index.Fragment,null,index.h("span",{class:"visually-hidden"},e),index.h(componentNames.KolIconTag,{class:bem.BEM_CLASS_ALERT__ICON,_label:"",_icons:a})),AlertIcon=({type:e,label:a})=>{switch(e){case"error":return index.h(Icon,{ariaLabel:translateError,icon:"codicon codicon-error",label:a});case"info":return index.h(Icon,{ariaLabel:translateInfo,icon:"codicon codicon-info",label:a});case"warning":return index.h(Icon,{ariaLabel:translateWarning,icon:"codicon codicon-warning",label:a});case"success":return index.h(Icon,{ariaLabel:translateSuccess,icon:"codicon codicon-pass",label:a});default:return index.h(Icon,{ariaLabel:translateMessage,icon:"codicon codicon-comment",label:a})}},translateCloseAlert=i18n.translate("kol-close-alert"),vibrateOnError=()=>{if("undefined"==typeof navigator||"function"!=typeof navigator.vibrate)return;const e=navigator.userActivation;if(((null==e?void 0:e.isActive)||(null==e?void 0:e.hasBeenActive))&&matchMedia("(any-pointer: coarse)").matches)try{navigator.vibrate([100,75,100,75,100])}catch(e){}},KolAlertFc=(e,a)=>{const{class:n={},alert:i=!1,hasCloser:l=!1,label:t,level:r=0,type:o="default",variant:s="msg",onAlertTimeout:c,onCloserClick:d}=e,b=tslib_es6.__rest(e,["class","alert","hasCloser","label","level","type","variant","onAlertTimeout","onCloserClick"]);i&&(vibrateOnError(),setTimeout(()=>{null==c||c()},1e4));const u=bem.bem("kol-alert",{hasCloser:!!l,[`type-${o}`]:!0,[`variant-${s}`]:!0}),_=bem.bem("kol-alert","heading",{[`h${r}`]:!0}),h=Object.assign({class:clsx.clsx(n,u)},b);return index.h("div",Object.assign({role:i?"alert":void 0},h,{"data-testid":"alert"}),index.h("div",{class:"kol-alert__container"},index.h(AlertIcon,{label:t,type:o}),index.h("div",{class:"kol-alert__container-content"},t&&index.h(Heading.KolHeadingFc,{class:_,level:r,id:"heading"},t),"msg"===s&&index.h("span",{class:bem.BEM_CLASS_ALERT__CONTENT,"aria-describedby":t?"heading":void 0},a)),l&&index.h(componentNames.KolButtonWcTag,{class:bem.BEM_CLASS_ALERT__CLOSER,"data-testid":"alert-close-button",_ariaDescription:(null==t?void 0:t.trim())||"",_hideLabel:!0,_icons:{left:{icon:"codicon codicon-close"}},_label:translateCloseAlert,_on:{onClick:d},_tooltipAlign:"left"})),"card"===s&&index.h("div",{class:bem.BEM_CLASS_ALERT__CONTENT,"aria-describedby":t?"heading":void 0},a))};exports.KolAlertFc=KolAlertFc;