/*!
 * KoliBri - The accessible HTML-Standard
 */
import{I as t}from"./controller-1a0e05c9.js";import{a as e,g as s,b as i,w as a,s as r}from"./prop.validators-64749272.js";import{b as o,c as n}from"./label-e8ec0e3a.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===o(t.label,3)&&!1===n(t.label)&&e(`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},f=(t,e,o={})=>{s(t,"_options",(t=>"object"==typeof t&&null!==t&&"string"==typeof t.label&&t.label.length>0),e,void 0,o)},h=(t,e,o={})=>{s(t,"_options",l,e,void 0,o)},c=(t,e)=>{i(t,"_required",e)},u=["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 d extends t{constructor(t,e,o){super(t,e,o),this.component=t}validateRequired(t){c(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateRequired(this.component._required)}}class b extends d{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&&u.includes(t)),new Set([`Orientation {${u.join(", ")}`]),t,{defaultValue:"vertical"})}validateOptions(t){f(this.component,t,{hooks:{afterPatch:this.afterPatchOptions,beforePatch:this.beforePatchOptions}})}validateValue(t){t=Array.isArray(t)?t[0]:t,r(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{d as I,b as a,f as b,p as f,h as v};