!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/wagtail_advanced_form_builder/static/wagtail_advanced_form_builder/",n(n.s=2)}({2:function(e,t){function n(e,t=!1){const n=document.getElementsByName(e);return n.length?t?n[0]:n:null}function r(e){const t=e.getAttribute("type");return"checkbox"===t||"radio"===t}function a(e){if(function(e){return void 0!==e.length&&void 0!==e.item&&e.length>1}(e)){let t="";return e.forEach(e=>{r(e)&&e.checked&&(t+=e.value.trim()+",")}),t=t.replace(/[,/]\s*$/,""),t}return r(e=e[0])?e.checked?"on":"":function(e){return e.hasAttribute("multiple")}(e)?function(e){const t=e&&e.options;let n="";for(let e=0;e<t.length;e++){const r=t[e];r.selected&&(n+=r.value+",")}return n=n.replace(/[,/]\s*$/,""),n}(e):e.value.trim()}function i(e,t){e&&(e.style.display="show"===t?"block":"none")}function o(e,t,n){let r=null,a=null;switch(e){case"is":if(n.value!==t)return!1;break;case"is_not":if(n.value===t)return!1;break;case"is_blank":if(""!==n.value)return!1;break;case"is_not_blank":if(""===n.value)return!1;break;case"greater_than":if(r=parseFloat(n.value),a=parseFloat(t),isNaN(r)||r<=a)return!1;break;case"greater_than_equal":if(r=parseFloat(n.value),a=parseFloat(t),isNaN(r)||r<a)return!1;break;case"less_than":if(r=parseFloat(n.value),a=parseFloat(t),isNaN(r)||r>=a)return!1;break;case"less_than_equal":if(r=parseFloat(n.value),a=parseFloat(t),isNaN(r)||r>a)return!1;break;case"contains":if(!n.value.includes(t))return!1;break;case"starts-with":if(!n.value.startsWith(t))return!1;break;case"ends-with":if(!n.value.endsWith(t))return!1}return!0}function l(){window.wafFormConditions.forEach(e=>{let t=!0;const r={};r.action=e.action,r.type=e.field_type,r.field=n(e.field_name,!0),r.parent=function(e){if(e){const t=e.closest("[data-waf-field]");if(t)return t}return null}(r.field),r.required="checkboxes"!==r.type&&e.required;for(let r=0;r<e.conditions.length;r++){const i=e.conditions[r],l=i.rule,u=i.value,c={};if(c.field=n(i.field_name),c.value=a(c.field),t=o(l,u,c),!t)break}t?"show"===r.action?(i(r.parent,"show"),r.required&&(r.field.required=!0)):(i(r.parent,"hide"),r.field.required=!1):"show"===r.action?(i(r.parent,"hide"),r.field.required=!1):(i(r.parent,"show"),r.required&&(r.field.required=!0))})}!function(){if(window.wafFormConditions){const e=document.getElementById("waf--form-page-form");!function(e){["input","select","textarea"].forEach(t=>{const n=e.getElementsByTagName(t);if(n.length)for(let e=0;e<n.length;e++)n[e].addEventListener("keyup",()=>{l()}),n[e].addEventListener("change",()=>{l()})})}(e),l(),e.style.display="block",function(){const e=document.getElementsByClassName("waf--field-container--error");e.length&&e[0].scrollIntoView()}()}}()}});