/*!
 * KoliBri - The accessible HTML-Standard
 */
import{I as t}from"./getRenderStates-d2dc42b2.js";import{a as s,g as e,b as i,w as a,m as r,s as o}from"./prop.validators-9feb1d92.js";import{b as n,c as f}from"./label-d0315384.js";const l=t=>{if("object"==typeof t&&null!==t){if("string"==typeof t.label&&t.label.length>0)return t.disabled=!0===t.disabled,t.label=`${t.label}`.trim(),!1===n(t.label,3)&&!1===f(t.label)&&s(`A differing Aria-Label (${t.label}) is not accessible. A differing Aria-Label should consist of at least three readable characters.`),!Array.isArray(t.options)||void 0===t.options.find((t=>!1===l(t)));if("number"==typeof t.label)return!0}return!1},h=(t,o,a={})=>{e(t,"_options",(t=>"object"==typeof t&&null!==t&&"string"==typeof t.label&&t.label.length>0),o,void 0,a)},c=(t,o,a={})=>{e(t,"_options",l,o,void 0,a)},u=(t,e)=>{i(t,"_required",e)},d=["horizontal","vertical"],p=(t,e,o="")=>{e.forEach(((e,a)=>{const i=`${o}-${a}`;"object"==typeof e&&null!==e&&"string"==typeof e.label&&e.label.length>0&&(Array.isArray(e.options)?p(t,e.options,i):t.set(i,e))}))};class b extends t{constructor(t,e,o){super(t,e,o),this.component=t}validateRequired(t){u(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateRequired(this.component._required)}}class y extends b{constructor(t,e,o){super(t,e,o),this.keyOptionMap=new Map,this.getOptionByKey=t=>this.keyOptionMap.get(t),this.afterPatchOptions=(t,e,o,a)=>{"_value"===a&&this.setFormAssociatedValue(t)},this.beforePatchOptions=(t,e)=>{const o=e.has("_options")?e.get("_options"):this.component.state._options;Array.isArray(o)&&o.length>0&&(this.keyOptionMap.clear(),p(this.keyOptionMap,o))},this.component=t}validateOrientation(t){a(this.component,"_orientation",(t=>"string"==typeof t&&d.includes(t)),new Set([`Orientation {${d.join(", ")}`]),t,{defaultValue:"vertical"})}validateOptions(t){h(this.component,t,{hooks:{afterPatch:this.afterPatchOptions,beforePatch:this.beforePatchOptions}})}validateValue(t){t=r(t),t=Array.isArray(t)?t[0]:t,o(this.component,"_value",t,{afterPatch:this.afterPatchOptions,beforePatch:this.beforePatchOptions})}componentWillLoad(){super.componentWillLoad(),this.validateOrientation(this.component._orientation),this.validateOptions(this.component._options),this.validateValue(this.component._value)}}export{b as I,y as a,h as b,p as f,c as v};