/*!
 * KoliBri - The accessible HTML-Standard
 */
import{s as t,t as i}from"./events-29e84d75.js";import{A as s}from"./associated.controller-bce3d721.js";import{b as e,o,p as h,w as a,c as r,a as n,i as l,j as d,s as c}from"./prop.validators-c5e6ad2d.js";import{v as u,a as f,b as v,c as p}from"./access-and-short-key-864aafba.js";import{v as b}from"./tooltip-align-c001aae2.js";import{v as m}from"./hide-label-db0db59c.js";import{a as y}from"./label-d70e7c34.js";const g=(t,o)=>{e(t,"_adjustHeight",o)},j=(t,o,n)=>{e(t,"_hideError",o,n)},_=(t,e)=>{o(e,(()=>{try{e=h(e)}catch(t){}a(t,"_msg",(t=>"object"==typeof t),new Set(["Object"]),e)}))},k=(t,o)=>{e(t,"_touched",o)},x=t=>{var o,e;const n=Boolean("error"===(null===(o=t._msg)||void 0===o?void 0:o._type)&&t._msg._description&&(null===(e=t._msg._description)||void 0===e?void 0:e.length)>0)&&!0===t._touched,i="string"==typeof t._hint&&t._hint.length>0,s=[];return!0===n&&s.push(`${t._id}-error`),!0===i&&s.push(`${t._id}-hint`),{hasError:n,hasHint:i,ariaDescribedBy:s}};class A extends s{constructor(t,o,e){super(t,o,e),this.component=t}validateAlert(t){e(this.component,"_alert",t)}validateTouched(t){k(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAlert(this.component._alert),this.validateTouched(this.component._touched)}}class B extends A{constructor(t,o,e){super(t,o,e),this.valueChangeListeners=[],this.onFacade={onBlur:this.onBlur.bind(this),onChange:this.onChange.bind(this),onClick:this.onClick.bind(this),onFocus:this.onFocus.bind(this),onInput:this.onInput.bind(this)},this.component=t}validateAccessKey(t){u(this.component,t),f(t,this.component._shortKey)}validateAdjustHeight(t){g(this.component,t)}validateDisabled(t){e(this.component,"_disabled",t),!0===t&&r()}validateTooltipAlign(t){b(this.component,t)}validateError(t){const o={_description:t||"",_type:"error"};this.validateMsg(o)}validateHideError(t){j(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideError&&n("Property hide-error for inputs: Only use when the error message is shown outside of the input component.")}}})}validateHideLabel(t){m(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideLabel&&n("Property hide-label for inputs: Only use for exceptions like search inputs that are clearly identifiable by their context.")}}})}validateHint(t){l(this.component,"_hint",t)}validateId(t){l(this.component,"_id",t,{minLength:1}),""!==t&&void 0!==t||d("A unique ID on the input fields is not strictly required, but it might be relevant for E2E tests.")}validateLabel(t){y(this.component,t,{required:!0})}validateMsg(t){_(this.component,t)}validateOn(t){"object"==typeof t&&c(this.component,"_on",t)}validateShortKey(t){v(this.component,t),f(this.component._accessKey,t)}validateSmartButton(t){o(t,(()=>{try{t=h(t)}catch(t){}c(this.component,"_smartButton",t)}))}validateTabIndex(t){p(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAccessKey(this.component._accessKey),this.validateAdjustHeight(this.component._adjustHeight),this.validateError(this.component._error),this.validateMsg(this.component._msg),this.validateDisabled(this.component._disabled),this.validateHideError(this.component._hideError),this.validateHideLabel(this.component._hideLabel),this.validateHint(this.component._hint),this.validateId(this.component._id),this.validateLabel(this.component._label),this.validateShortKey(this.component._shortKey),this.validateSmartButton(this.component._smartButton),this.validateOn(this.component._on),this.validateTabIndex(this.component._tabIndex),f(this.component._accessKey,this.component._shortKey)}onBlur(o){var e;this.component._touched=!0,t(o),i("blur",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onBlur)&&this.component._on.onBlur(o)}onChange(t,o){var e;o=null!=o?o:t.target.value,i("change",this.host,o),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onChange)&&this.component._on.onChange(t,o),this.valueChangeListeners.forEach((t=>t(o)))}onInput(o,e=!0,n){var s;n=null!=n?n:o.target.value,t(o),i("input",this.host,n),e&&this.setFormAssociatedValue(n),"function"==typeof(null===(s=this.component._on)||void 0===s?void 0:s.onInput)&&this.component._on.onInput(o,n)}onClick(o){var e;t(o),i("click",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onClick)&&this.component._on.onClick(o)}onFocus(o){var e;t(o),i("focus",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onFocus)&&this.component._on.onFocus(o)}addValueChangeListener(t){this.valueChangeListeners.push(t)}}export{B as I,x as g};