!function(){"use strict";const e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return t||(t=Math.random().toString(36).substr(2,5)),`${e}.${t}`};window.FormieCheckboxRadio=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.$form=e.$form,this.form=this.$form.form,this.$field=e.$field,this.$field&&(this.initInputs(),this.initRequiredCheckboxes(),this.initToggleCheckboxes())}initInputs(){this.$field.querySelectorAll("[type=checkbox], [type=radio]").forEach((t=>{this.form.addEventListener(t,e("click"),(e=>{if(e.target.checked){if("radio"===e.target.getAttribute("type")){const t=e.target.getAttribute("name");this.$field.querySelectorAll(`[name="${t}"] `).forEach((e=>{e.removeAttribute("checked")}))}e.target.setAttribute("checked","")}else e.target.removeAttribute("checked")}),!1)}))}initRequiredCheckboxes(){const t=this.$field.querySelectorAll('[type="checkbox"][required]');t.forEach((i=>{this.form.addEventListener(i,e("change"),(e=>{this.onCheckboxChanged(t,this.isChecked(t))}),!1),i.checked&&i.dispatchEvent(new Event("change",{bubbles:!0}))}))}initToggleCheckboxes(){const t=this.$field.querySelectorAll('[type="checkbox"]');this.$field.querySelectorAll('[type="checkbox"][data-checkbox-toggle]').forEach((i=>{this.form.addEventListener(i,e("change"),(e=>{const i=e.target.checked;t.forEach((t=>{t!==e.target&&(t.checked=i)}))}),!1)}))}isChecked(e){for(let t=0;t<e.length;t++)if(e[t].checked)return!0;return!1}onCheckboxChanged(e,t){e.forEach((e=>{t?(e.removeAttribute("required"),e.setAttribute("aria-required",!1)):(e.setAttribute("required",!0),e.setAttribute("aria-required",!0))}))}}}();