(()=>{"use strict";const{strict_mode:t=!1}=window?.JetFormBuilderSettings,e=Boolean(t),{InputData:s,ReactiveHook:i}=JetFormBuilderAbstract,{getParsedName:o}=JetFormBuilderFunctions;function r(){s.call(this),this.wrapper=null}r.prototype=Object.create(s.prototype),r.prototype.wrapper=null,r.prototype.isSupported=function(t){return t.classList.contains("checkradio-wrap")&&t.querySelector(".radio-wrap")},r.prototype.addListeners=function(){this.enterKey=new i,this.wrapper.addEventListener("change",this.onChangeValue.bind(this)),this.wrapper.addEventListener("keydown",this.handleEnterKey.bind(this));const t=this.getCustomInput();this.wrapper.addEventListener("focusout",(e=>{[...this.nodes].includes(e?.relatedTarget)||[e.relatedTarget,e.target].includes(t)||this.reportOnBlur()})),t?.addEventListener?.("blur",(t=>{const e=this.value.current;this.setValue(),e===this.value.current&&this.onChange(e)})),!e&&jQuery(this.wrapper).on("change",(t=>{this.value.current==t.target.value||t.target?.dataset?.custom||(this.callable.lockTrigger(),this.setValue(),this.callable.unlockTrigger())}))},r.prototype.setValue=function(){this.value.current=this.getActiveValue()},r.prototype.onChangeValue=function(t){t.target.dataset.custom?this.toggleCustomOption():this.setValue()},r.prototype.toggleCustomOption=function(){const t=this.lastNode(),e=this.getCustomInput();e.disabled===t.checked&&(e.disabled=!t.checked),t.checked&&e.focus()},r.prototype.getActiveValue=function(){for(const t of this.nodes)if(!t.dataset.custom&&t.checked)return t.value;return this.hasCustom?this.getCustomInput().value:""},r.prototype.setNode=function(t){t.jfbSync=this,this.nodes=t.getElementsByClassName("jet-form-builder__field radio-field"),this.rawName=this.nodes[0].name,this.name=o(this.rawName),this.inputType="radio",this.wrapper=t,this.hasCustom=!!this.lastNode()?.dataset?.custom},r.prototype.lastNode=function(){return this.nodes[this.nodes.length-1]},r.prototype.getCustomInput=function(){const t=this.lastNode().closest(".custom-option");return t?.querySelector?.("input.text-field")};const n=r,{BaseSignal:a}=JetFormBuilderAbstract;function u(){a.call(this),this.isSupported=function(t,e){return"radio"===t.type},this.runSignal=function(){this.input.calcValue=0;for(const e of this.input.nodes){var t;if(!e.dataset.custom&&(e.checked=this.input.value.current===e.value,e.checked)){this.input.calcValue+=parseFloat(null!==(t=e.dataset?.calculate)&&void 0!==t?t:e.value),this.triggerJQuery(e);break}}if(!this.input.hasCustom)return;const e=this.input.lastNode(),s=this.input.getCustomInput();s.disabled===e.checked&&(s.disabled=!e.checked);const i=this.input.value.current;e.checked&&s.value!==i&&(s.value=i)}}u.prototype=Object.create(a.prototype);const c=u,{addFilter:l}=JetPlugins.hooks;window.JetFormBuilderAbstract={...window.JetFormBuilderAbstract,RadioData:n,SignalRadio:c},l("jet.fb.inputs","jet-form-builder/radio-field",(function(t){return[n,...t]})),l("jet.fb.signals","jet-form-builder/radio-field",(function(t){return[c,...t]}))})();