/*!
 * KoliBri - The accessible HTML-Standard
 */
import{V as validateRequired,w as watchValidator,W as orientationOptions,X as validateOptions,Y as mapString2Unknown,k as setState}from"./index-0489af72.js";import{I as InputController}from"./controller-19ccfc94.js";const fillKeyOptionMap=(t,o,e="")=>{o.forEach(((o,n)=>{const i=`${e}-${n}`;"object"==typeof o&&null!==o&&"string"==typeof o.label&&o.label.length>0&&(Array.isArray(o.options)?fillKeyOptionMap(t,o.options,i):t.set(i,o))}))};class InputCheckboxRadioController extends InputController{constructor(t,o,e){super(t,o,e),this.component=t}validateRequired(t){validateRequired(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateRequired(this.component._required)}}class InputRadioController extends InputCheckboxRadioController{constructor(t,o,e){super(t,o,e),this.keyOptionMap=new Map,this.getOptionByKey=t=>this.keyOptionMap.get(t),this.afterPatchOptions=(t,o,e,n)=>{"_value"===n&&this.setFormAssociatedValue(t)},this.component=t}validateOrientation(t){watchValidator(this.component,"_orientation",(t=>"string"==typeof t&&orientationOptions.includes(t)),new Set([`Orientation {${orientationOptions.join(", ")}`]),t,{defaultValue:"vertical"})}validateOptions(t){validateOptions(this.component,t,{hooks:{afterPatch:this.afterPatchOptions}})}validateValue(t){t=mapString2Unknown(t),t=Array.isArray(t)?t[0]:t,setState(this.component,"_value",t,{afterPatch:this.afterPatchOptions})}componentWillLoad(){super.componentWillLoad(),this.validateOrientation(this.component._orientation),this.validateOptions(this.component._options),this.validateValue(this.component._value)}}export{InputCheckboxRadioController as I,InputRadioController as a,fillKeyOptionMap as f};