/*!
 * KoliBri - The accessible HTML-Standard
 */
import{proxyCustomElement,HTMLElement,h,Host}from"@stencil/core/internal/client";import{t as translate}from"./i18n2.js";import{v as validateImageSource}from"./image-source.js";import{v as validateLabel}from"./label.js";const formatNameAsInitial=e=>0===e.length?"":e[0].toUpperCase(),formatLabelAsInitials=e=>{const a=e.split(/\s+/),t=a.at(0),l=a.at(-1);return a.length>=2&&t&&l?`${formatNameAsInitial(t)}${formatNameAsInitial(l)}`:formatNameAsInitial(e)},KolAvatarWc$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this._src=void 0,this._label=void 0,this.state={_src:"",_label:""}}render(){return h(Host,{key:"bae5c6360b2eee7a2981083377c588892541ebd7",class:"kol-avatar-wc"},h("div",{key:"4ded87fb86a5cbe89329637817145fed01efcc1e","aria-label":translate("kol-avatar-alt",{placeholders:{name:this.state._label}}),class:"container",role:"img"},this.state._src?h("img",{alt:"","aria-hidden":"true",class:"image",src:this.state._src}):h("span",{"aria-hidden":"true",class:"initials"},formatLabelAsInitials(this.state._label.trim()))))}validateSrc(e){validateImageSource(this,e)}validateLabel(e){validateLabel(this,e,{required:!0})}componentWillLoad(){this.validateSrc(this._src),this.validateLabel(this._label)}static get watchers(){return{_src:["validateSrc"],_label:["validateLabel"]}}},[0,"kol-avatar-wc",{_src:[1],_label:[1],state:[32]},void 0,{_src:["validateSrc"],_label:["validateLabel"]}]);function defineCustomElement$1(){if("undefined"==typeof customElements)return;["kol-avatar-wc"].forEach((e=>{if("kol-avatar-wc"===e)customElements.get(e)||customElements.define(e,KolAvatarWc$1)}))}const KolAvatarWc=KolAvatarWc$1,defineCustomElement=defineCustomElement$1;export{KolAvatarWc,defineCustomElement};