/*!
 * KoliBri - The accessible HTML-Standard
 */
import{z as t,J as i,A as s,M as e,N as h,O as a,P as o,Q as r,R as n,S as d,T as l,k as c,q as u,r as f,U as v}from"./index-0489af72.js";import{s as p,t as y}from"./events-29e84d75.js";import{A as b}from"./associated.controller-fa74caf7.js";const g=t=>{var e,o;const n=Boolean("error"===(null===(e=t._msg)||void 0===e?void 0:e._type)&&t._msg._description&&(null===(o=t._msg._description)||void 0===o?void 0:o.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 m extends b{constructor(t,e,o){super(t,e,o),this.component=t}validateAlert(e){t(this.component,"_alert",e)}validateTouched(t){i(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateAlert(this.component._alert),this.validateTouched(this.component._touched)}}class k extends m{constructor(t,e,o){super(t,e,o),this.valueChangeListeners=[],this.onFacade={onBlur:this.onBlur.bind(this),onChange:this.onChange.bind(this),onClick:this.onClick.bind(this),onFocus:this.onFocus.bind(this)},this.component=t}validateAccessKey(t){s(this.component,"_accessKey",t)}validateAdjustHeight(t){e(this.component,t)}validateDisabled(e){t(this.component,"_disabled",e),!0===e&&h()}validateError(t){const e=t?{_description:t,_type:"error"}:void 0;this.validateMsg(e)}validateHideError(t){a(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideError&&r("Property hide-error for inputs: Only use when the error message is shown outside of the input component.")}}})}validateHideLabel(t){o(this.component,t,{hooks:{afterPatch:()=>{this.component.state._hideLabel&&r("Property hide-label for inputs: Only use for exceptions like search inputs that are clearly identifiable by their context.")}}})}validateHint(t){s(this.component,"_hint",t)}validateId(t){s(this.component,"_id",t,{hooks:{afterPatch:()=>{this.setAttribute("id",this.formAssociated,this.component.state._id)}},minLength:1}),""!==t&&void 0!==t||n("Eine eindeutige ID an den Eingabefeldern ist nicht zwingend erforderlich, könnte aber für die E2E-Tests relevant sein.")}validateLabel(t){d(this.component,t,{required:!0})}validateMsg(t){l(this.component,t)}validateOn(t){"object"==typeof t&&c(this.component,"_on",t)}validateSmartButton(t){u(t,(()=>{try{t=f(t)}catch(t){}c(this.component,"_smartButton",t)}))}validateTabIndex(t){v(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.validateSmartButton(this.component._smartButton),this.validateOn(this.component._on),this.validateTabIndex(this.component._tabIndex)}onBlur(t){var e;this.component._alert=!0,this.component._touched=!0,p(t),y("blur",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onBlur)&&this.component._on.onBlur(t)}onChange(t){var e;const o=t.target.value;y("change",this.host,o),this.setFormAssociatedValue(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)))}onClick(t){var e;p(t),y("click",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onClick)&&this.component._on.onClick(t)}onFocus(t){var e;this.component._alert=!0,p(t),y("focus",this.host),"function"==typeof(null===(e=this.component._on)||void 0===e?void 0:e.onFocus)&&this.component._on.onFocus(t)}addValueChangeListener(t){this.valueChangeListeners.push(t)}}export{k as I,g};