/*!
 * KoliBri - The accessible HTML-Standard
 */
import{r as registerInstance,h,F as Fragment,H as Host,g as getElement}from"./index-9ca46203.js";import{aI as handleSlotContent,I as showExpertSlot}from"./index-0489af72.js";import{t as translate}from"./i18n-3bac791b.js";import{F as FormFieldMsg}from"./form-field-msg-4b406780.js";import{a as KolTooltipWcTag,g as KolIconTag,c as KolButtonWcTag}from"./component-names-61247f2f.js";import"./i18n-fddf0324.js";function r(t){var i,s,e="";if("string"==typeof t||"number"==typeof t)e+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(i=0;i<o;i++)t[i]&&(s=r(t[i]))&&(e&&(e+=" "),e+=s)}else for(s in t)t[s]&&(e&&(e+=" "),e+=s);return e}function clsx(){for(var t,i,s=0,e="",o=arguments.length;s<o;s++)(t=arguments[s])&&(i=r(t))&&(e&&(e+=" "),e+=i);return e}const KolInput=class{constructor(t){registerInstance(this,t),this.slotName="input",this.catchInputSlot=t=>{handleSlotContent(this.host,t,this.slotName)},this._accessKey=void 0,this._alert=!0,this._currentLength=void 0,this._disabled=!1,this._hasCounter=!1,this._hideError=!1,this._hideLabel=!1,this._hint="",this._icons=void 0,this._id=void 0,this._label=void 0,this._maxLength=void 0,this._msg=void 0,this._readOnly=!1,this._renderNoLabel=!1,this._required=!1,this._slotName=void 0,this._suggestions=void 0,this._smartButton=void 0,this._tooltipAlign="top",this._touched=!1}componentWillRender(){this.slotName=this._slotName?this._slotName:"input"}getIconStyles(t){return t&&"object"==typeof t&&t.style?t.style:{}}render(){var t,i,s,e,o,l,n,a,r,d,_,c;const u=Boolean("error"===(null===(t=this._msg)||void 0===t?void 0:t._type)&&this._msg._description&&(null===(i=this._msg._description)||void 0===i?void 0:i.length)>0),g=!this._readOnly&&u&&!0===this._touched,m=Boolean(g||"error"!==(null===(s=this._msg)||void 0===s?void 0:s._type)&&(null===(e=this._msg)||void 0===e?void 0:e._description)),p=showExpertSlot(this._label),b="string"==typeof this._hint&&this._hint.length>0,f=!p&&this._hideLabel;return h(Host,{key:"acb6294dbb3bb30298be633a4728d890d24c6dc7",class:clsx("kol-input",this.getModifierClassNameByMsgType(),{disabled:!0===this._disabled,error:!0===g,"read-only":!0===this._readOnly,required:!0===this._required,touched:!0===this._touched,"hidden-error":!0===this._hideError})},h("label",{key:"356dbae7d6b7b02202e1020131dc7e8bb70a69c2",class:"input-label",id:f?void 0:`${this._id}-label`,hidden:f,htmlFor:this._id},h("span",{key:"c5ee06729ca4bb5c1458085068ac6a64fcfeae1a",class:"input-label-span"},h("slot",{key:"146aeb9bef32ebc54b1fcbf282841d7d44fd5730",name:"label"}))),b&&h("span",{class:"hint",id:`${this._id}-hint`},this._hint),h("div",{key:"755e40c1da91b382387ddea16935235e793fff1b",class:{input:!0,"icon-left":"object"==typeof(null===(o=this._icons)||void 0===o?void 0:o.left),"icon-right":"object"==typeof(null===(l=this._icons)||void 0===l?void 0:l.right)}},(null===(n=this._icons)||void 0===n?void 0:n.left)&&h(KolIconTag,{_label:"",_icons:(null===(a=this._icons)||void 0===a?void 0:a.left).icon,style:this.getIconStyles(null===(r=this._icons)||void 0===r?void 0:r.left)}),h("div",{key:"49c2557719125b83a696987ee88ec72a254b5077",ref:this.catchInputSlot,id:this.slotName,class:"input-slot"}),"object"==typeof this._smartButton&&null!==this._smartButton&&h(KolButtonWcTag,{_customClass:this._smartButton._customClass,_disabled:this._smartButton._disabled,_icons:this._smartButton._icons,_hideLabel:!0,_id:this._smartButton._id,_label:this._smartButton._label,_on:this._smartButton._on,_tooltipAlign:this._smartButton._tooltipAlign,_variant:this._smartButton._variant}),(null===(d=this._icons)||void 0===d?void 0:d.right)&&h(KolIconTag,{_label:"",_icons:(null===(_=this._icons)||void 0===_?void 0:_.right).icon,style:this.getIconStyles(null===(c=this._icons)||void 0===c?void 0:c.right)})),f&&h(KolTooltipWcTag,{"aria-hidden":"true",class:"input-tooltip",_accessKey:this._accessKey,_align:this._tooltipAlign,_id:this._hideLabel?`${this._id}-label`:void 0,_label:this._label}),m&&h(FormFieldMsg,{_alert:this._alert,_hideError:this._hideError,_msg:this._msg,_id:this._id}),Array.isArray(this._suggestions)&&this._suggestions.length>0&&h("datalist",{id:`${this._id}-list`},this._suggestions.map((t=>h("option",{value:t})))),this._hasCounter&&h("span",{class:"counter","aria-atomic":"true","aria-live":"polite"},this._currentLength,this._maxLength&&h(Fragment,null,h("span",{"aria-label":translate("kol-of"),role:"img"},"/"),this._maxLength)," ",h("span",null,translate("kol-characters"))))}getModifierClassNameByMsgType(){var t,i;if(null===(t=this._msg)||void 0===t?void 0:t._type)return{default:"msg-type-default",info:"msg-type-info",success:"msg-type-success",warning:"msg-type-warning",error:"msg-type-error"}[null===(i=this._msg)||void 0===i?void 0:i._type]}get host(){return getElement(this)}};export{KolInput as kol_input};