/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const index=require("./index-f0fde70b.js"),index$1=require("./index-cb2ce614.js"),i18n=require("./i18n-9f4d1694.js"),validation=require("./validation-dd7406a2.js"),componentNames=require("./component-names-4cf3e7f5.js");require("./i18n-c3fa5bd7.js");const Icon=e=>index.h(componentNames.KolIconTag,{class:"heading-icon",_label:"string"==typeof e.label&&e.label.length>0?"":e.ariaLabel,_icons:e.icon}),AlertIcon=e=>{switch(e.type){case"error":return index.h(Icon,{ariaLabel:i18n.translate("kol-error"),icon:"codicon codicon-error",label:e.label});case"info":return index.h(Icon,{ariaLabel:i18n.translate("kol-info"),icon:"codicon codicon-info",label:e.label});case"warning":return index.h(Icon,{ariaLabel:i18n.translate("kol-warning"),icon:"codicon codicon-warning",label:e.label});case"success":return index.h(Icon,{ariaLabel:i18n.translate("kol-success"),icon:"codicon codicon-pass",label:e.label});default:return index.h(Icon,{ariaLabel:i18n.translate("kol-message"),icon:"codicon codicon-comment",label:e.label})}},KolAlertWc=class{constructor(e){index.registerInstance(this,e),this.close=()=>{var e;void 0!==(null===(e=this._on)||void 0===e?void 0:e.onClose)&&this._on.onClose(new Event("Close"))},this.on={onClick:this.close},this.validateOnValue=e=>"object"==typeof e&&null!==e&&"function"==typeof e.onClose,this._alert=!1,this._hasCloser=!1,this._label=void 0,this._level=1,this._on=void 0,this._type="default",this._variant="msg",this.state={_level:1}}render(){var e;if(this.state._alert){try{index$1.Log.debug(["Navigator should vibrate ...",navigator.vibrate([100,75,100,75,100])])}catch(e){index$1.Log.debug("Navigator does not support vibration.")}setTimeout((()=>{this.validateAlert(!1)}),1e4)}return index.h(index.Host,{key:"056ebeba8b0ebc0d76a98e3855a0022e1c689e09",class:{"kol-alert-wc":!0,alert:!0,[this.state._type]:!0,[this.state._variant]:!0,hasCloser:!!this.state._hasCloser},role:this.state._alert?"alert":void 0},index.h("div",{key:"e2807b51c729dc7814aa46bc40f371d9b785b590",class:"heading"},index.h(AlertIcon,{key:"207367acb5c59e0977feb68adefb0a7cdb0f4668",label:this.state._label,type:this.state._type}),index.h("div",{key:"1d9b3c352e84393eb31fbd056a6aa9ec639d13cd",class:"heading-content"},"string"==typeof this.state._label&&(null===(e=this.state._label)||void 0===e?void 0:e.length)>0&&index.h(componentNames.KolHeadingWcTag,{_label:this.state._label,_level:this.state._level}),"msg"===this.state._variant&&index.h("div",{class:"content"},index.h("slot",null))),this.state._hasCloser&&index.h(componentNames.KolButtonWcTag,{class:"close",_hideLabel:!0,_icons:{left:{icon:"codicon codicon-close"}},_label:i18n.translate("kol-close"),_on:this.on,_tooltipAlign:"left"})),"card"===this.state._variant&&index.h("div",{class:"content"},index.h("slot",null)))}validateAlert(e){index$1.watchBoolean(this,"_alert",e)}validateHasCloser(e){index$1.validateHasCloser(this,e)}validateLabel(e){index$1.validateLabel(this,e)}validateLevel(e){validation.watchHeadingLevel(this,e)}validateOn(e){this.validateOnValue(e)&&index$1.setState(this,"_on",{onClose:e.onClose})}validateType(e){index$1.watchValidator(this,"_type",(e=>"string"==typeof e&&index$1.alertTypeOptions.includes(e)),new Set(`String {${index$1.alertTypeOptions.join(", ")}`),e)}validateVariant(e){index$1.watchValidator(this,"_variant",(e=>"string"==typeof e&&index$1.alertVariantOptions.includes(e)),new Set(`AlertVariant {${index$1.alertVariantOptions.join(", ")}`),e)}componentWillLoad(){this.validateAlert(this._alert),this.validateHasCloser(this._hasCloser),this.validateLabel(this._label),this.validateLevel(this._level),this.validateOn(this._on),this.validateType(this._type),this.validateVariant(this._variant)}static get watchers(){return{_alert:["validateAlert"],_hasCloser:["validateHasCloser"],_label:["validateLabel"],_level:["validateLevel"],_on:["validateOn"],_type:["validateType"],_variant:["validateVariant"]}}};exports.kol_alert_wc=KolAlertWc;