/*!
 * KoliBri - The accessible HTML-Standard
 */
import{a as o}from"./tslib.es6-QNbPBOk5.js";import{h as e,F as l}from"./index-Brmny3Vg.js";import{c as t}from"./clsx-COFh-Vc8.js";import{b as n}from"./component-names-Dy77vq43.js";import{t as a}from"./i18n-CaL2ODdQ.js";import{b as s}from"./bem-registry-B9CzNnO1.js";import{I as i}from"./component-DHo2YdSx.js";import{K as r}from"./Heading-Hh3eykel.js";const c=s.forBlock("kol-alert");const d=c("icon");const u={error:{label:a("kol-error"),icon:"kolicon-alert-error"},info:{label:a("kol-info"),icon:"kolicon-alert-info"},warning:{label:a("kol-warning"),icon:"kolicon-alert-warning"},success:{label:a("kol-success"),icon:"kolicon-alert-success"},default:{label:a("kol-message"),icon:"kolicon-alert-info"}};const f=({type:o="default"})=>{const t=u[o||"default"];return e(l,null,e("span",{class:"visually-hidden"},t.label),e(i,{class:d,label:"",icons:t.icon}))};const m=s.forBlock("kol-alert");const b=m("closer");const v=m("content");const p=()=>{if(typeof navigator==="undefined"||typeof navigator.vibrate!=="function"){return}const o=navigator.userActivation;const e=(o===null||o===void 0?void 0:o.isActive)||(o===null||o===void 0?void 0:o.hasBeenActive);if(!e){return}if(!matchMedia("(any-pointer: coarse)").matches){return}try{navigator.vibrate([100,75,100,75,100])}catch(o){}};const k=(l,s)=>{const{class:i={},alert:c=false,hasCloser:d=false,label:u,level:k=0,type:g="default",variant:y="msg",onAlertTimeout:h,onCloserClick:C}=l,j=o(l,["class","alert","hasCloser","label","level","type","variant","onAlertTimeout","onCloserClick"]);const _=a("kol-close-alert");if(c){p();setTimeout((()=>{h===null||h===void 0?void 0:h()}),1e4)}const O=m({hasCloser:!!d,[`type-${g}`]:true,[`variant-${y}`]:true});const x=m("heading",{[`h${k}`]:true});const D=Object.assign({class:t(i,O)},j);return e("div",Object.assign({role:c?"alert":undefined},D,{"data-testid":"alert"}),e("div",{class:"kol-alert__container"},e(f,{label:u,type:g}),e("div",{class:"kol-alert__container-content"},u&&e(r,{class:x,level:k,id:"heading"},u),y==="msg"&&e("span",{class:v,"aria-describedby":u?"heading":undefined},s)),d&&e(n,{class:b+" kol-close-button","data-testid":"alert-close-button",_ariaDescription:(u===null||u===void 0?void 0:u.trim())||"",_hideLabel:true,_icons:{left:{icon:"kolicon-cross"}},_label:_,_on:{onClick:C},_tooltipAlign:"left"})),y==="card"&&e("div",{class:v,"aria-describedby":u?"heading":undefined},s))};export{k as K};
//# sourceMappingURL=Alert-COvq80W3.js.map