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