/*!
 * KoliBri - The accessible HTML-Standard
 */
import{ae as validateRequired,w as watchValidator,af as orientationOptions,ag as validateOptions,ah as mapString2Unknown,k as setState}from"./index2.js";import{I as InputController}from"./controller2.js";const fillKeyOptionMap=(t,o,e="")=>{o.forEach(((o,a)=>{const n=`${e}-${a}`;"object"==typeof o&&null!==o&&"string"==typeof o.label&&o.label.length>0&&(Array.isArray(o.options)?fillKeyOptionMap(t,o.options,n):t.set(n,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,a)=>{"_value"===a&&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};