(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(e,n,a){var i;return i=function(e,n){if("object"!=t(e)||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var i=a.call(e,n||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(n,"string"),(n="symbol"==t(i)?i:String(i))in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function n(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);n<e;n++)a[n]=t[n];return a}function i(a,i,r,f){var o=0,s="";r.stepAnimationDuration=parseInt(r.stepAnimationDuration);var l="yes"==i.find(".ff-step-container").attr("data-enable_step_data_persistency"),c=!1;l&&(c="yes"==i.find(".ff-step-container").attr("data-enable_step_page_resume"));var d=!!window.fluentFormVars.is_rtl,u=!1,p=function(){return window.fluentFormApp(i)},v=function(t){var e=t.response,n=t.step_completed,i=[];if(jQuery.each(e,(function(t,e){if(e){var n=Object.prototype.toString.call(e);if("[object Object]"===n){var f=jQuery("[data-name=".concat(t,"]"));if(f.length&&"tabular-element"===f.attr("data-type"))jQuery.each(e,(function(e,n){var i=jQuery('[name="'.concat(t,"[").concat(e,']\\[\\]"]'));i.length||(i=jQuery('[name="'.concat(t,"[").concat(e,']"]'))),jQuery.each(i,(function(t,e){var i=a(e).val();-1===jQuery.inArray(i,n)&&i!==n||a(e).prop("checked",!0).change()}))}));else if("chained-select"===f.attr("data-type")){var o={meta_key:f.find("select:first").attr("data-meta_key"),form_id:f.closest("form").attr("data-form_id"),action:"fluentform_get_chained_select_options",filter_options:"all",keys:e};jQuery.getJSON(r.ajaxUrl,o).then((function(t){jQuery.each(t,(function(t,n){var a=f.find("select[data-key='".concat(t,"']"));0!=a.attr("data-index")&&jQuery.each(n,(function(t,e){a.append(jQuery("<option />",{value:e,text:e}))})),a.attr("disabled",!1).val(e[t])}))}))}else jQuery.each(e,(function(e,n){jQuery('[name="'.concat(t,"[").concat(e,']"]')).val(n).change()}))}else if("[object Array]"===n){var s=jQuery("[name=".concat(t,"]"));if("file"==(s=(s=s.length?s:jQuery("[data-name=".concat(t,"]"))).length?s:jQuery("[name=".concat(t,"\\[\\]]"))).attr("type"))x(s,e);else if(s.prop("multiple"))if(a.isFunction(window.Choices)){var l=s.data("choicesjs");i.push({handler:l,values:e})}else s.val(e).change();else if("repeater_field"===s.attr("data-type")){var c=s.find("tbody"),d=s.attr("data-name");jQuery.each(e,(function(t,e){0!=t?c.find("tr:last").clone().appendTo(c).find(".ff-el-form-control").each((function(n,i){var r="ffrpt-"+(new Date).getTime()+n;a(i).val(e[n]),a(i).attr({id:r,name:"".concat(d,"[").concat(t,"][]"),value:e[n]}).change()})):c.find("tr:first .ff-el-form-control").each((function(t,n){a(n).val(e[t]).change()}))}))}else s.each((function(t,n){-1!=jQuery.inArray(a(n).val(),e)&&a(n).prop("checked",!0).change()}))}else{var u=jQuery("[name=".concat(t,"]"));if(u.hasClass("fluentform-post-content")&&window.wp&&window.wp.editor){var p=u.attr("id");window.tinymce.get(p).setContent(e)}if("undefined"!=typeof flatpickr&&u.prop("_flatpickr")){var v=u.prop("_flatpickr");v&&(v.config.altInput?v.setDate(e,!0):u.val(e).trigger("change"))}if("radio"===u.prop("type")||"checkbox"===u.prop("type"))jQuery("[name=".concat(t,'][value="').concat(e,'"]')).prop("checked",!0).change();else{var m=u.closest(".ff-el-group").find(".fluentform-signature-pad");if(m.length){var _=m[0].getContext("2d"),h=new Image;h.src=e,h.onload=function(){_.drawImage(h,0,0)}}u.val(e).change()}}}})),i.length>0)for(var f=0;f<i.length;f++)i[f].handler.setValue(i[f].values).change();u=!0;var o=r.stepAnimationDuration;c&&g(n,o,!0).then((function(){b(o)})).catch((function(t){console.error("An error occurred during the slider update:",t)})),u=!1},m=function(t,e){0!==t.length&&(a.each(t,(function(t,e){a(e).attr("data-step-number",t)})),t.on("click",(function(t){var n=p(),i=a(this),f=0,o=r.stepAnimationDuration;try{var s=i.data("step-number");if(isNaN(s))return;a.each(e,(function(t,e){if(f=t,t<s){var i=a(e).find(":input").not(":button").filter((function(t,e){return!a(e).closest(".has-conditions").hasClass("ff_excluded")}));i.length&&n.validate(i)}})),g(s,o,!0).then((function(){b(o)})).catch((function(t){console.error("An error occurred during the slider update:",t)}))}catch(t){if(!(t instanceof window.ffValidationError))throw t;g(f,o,!0).then((function(){b(o)})).catch((function(t){console.error("An error occurred during the slider update:",t)})),n.showErrorMessages(t.messages),n.scrollToFirstError(350)}})))},_=function(t){if(i.find(".ff-el-progress").length){var e=t.totalSteps,n=t.activeStep,f=100/e*(n+1),o=i.find(".ff-el-progress-title li"),s=i.find(".ff-step-header .ff-el-progress-bar"),l=s.find("span");s.css({width:f+"%"}),f?s.append(l.text(parseInt(f)+"%")):l.empty();var c=r.step_text,d=a(o[n]).text();c=c.replace("%activeStep%",n+1).replace("%totalStep%",e).replace("%stepTitle%",d),i.find(".ff-el-progress-status").html(c),o.css("display","none"),a(o[n]).css("display","inline")}},h=function(t){b(t),a(f).on("click",".fluentform-step .step-nav button, .fluentform-step .step-nav img",(function(e){var n=a(this).data("action"),r="next",f=a(this).closest(".fluentform-step"),s=p();if("next"==n){try{var l=f.find(":input").not(":button").filter((function(t,e){return!a(e).closest(".has-conditions").hasClass("ff_excluded")}));l.length&&s.validate(l),o++}catch(e){if(!(e instanceof window.ffValidationError))throw e;return s.showErrorMessages(e.messages),void s.scrollToFirstError(350)}i.trigger("ff_to_next_page",o),jQuery(document).trigger("ff_to_next_page",{step:o,form:i});var c=i.find(".fluentform-step");i.trigger("ff_render_dynamic_smartcodes",a(c[o]))}else o--,r="prev",i.trigger("ff_to_prev_page",o),jQuery(document).trigger("ff_to_prev_page",{step:o,form:i});var d="yes"!=i.find(".ff-step-container").attr("data-disable_auto_focus");g(o,t,d,r).then((function(){b(t)})).catch((function(t){console.error("An error occurred during the slider update:",t)}))}))},g=function(t,r){var s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"next";return new Promise((function(p){a("div"+f+"_errors").empty(),o=t;var v=i.find(".ff-step-body"),m=i.find(".ff-step-titles li"),h=i.find(".fluentform-step"),g=h.length;h.removeClass("active"),a(h[o]).addClass("active"),m.removeClass("ff_active ff_completed"),a.each(n(Array(o).keys()),(function(t){a(a(m[t])).addClass("ff_completed")})),a(m[o]).addClass("ff_active");var y,b=d?{right:-100*o+"%"}:{left:-100*o+"%"},x=a(h[o]).closest(".ff-step-container").data("animation_type");v.css("pointer-events","none");switch(x){case"slide":var j=d?"right":"left";v.css("transition","none");var k="prev"===c?o+1:o-1;v.css(e({},j,-100*k+"%")),v[0].offsetHeight,v.css("transition","".concat(j," ").concat(r,"ms")),v.css(b),y=new Promise((function(t){return setTimeout(t,r)}));break;case"fade":v.css(b),v.css("transition","none"),v.css("opacity",0),v[0].offsetHeight,v.css("transition","opacity ".concat(r,"ms")),requestAnimationFrame((function(){v.css("opacity",1)})),y=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return new Promise((function(n){var a=function a(i){e&&i.propertyName!==e||(t.off("transitionend",a),n())};setTimeout((function(){t.off("transitionend",a),n()}),r+100),t.on("transitionend",a)}))}(v,"opacity");break;case"slide_down":v.css(b),v.hide(),y=v.slideDown(r).promise();break;default:v.css(b),y=Promise.resolve()}y.then((function(){if(v.css("pointer-events",""),s&&function(){if(!window.ff_disable_step_scroll){var t,e,n,f,o,s,l=i.find(".ff_step_start");t=window.ff_scroll_top_offset?window.ff_scroll_top_offset:l.offset().top-20,f=(n=(e=l).offset().top)+e.outerHeight(),s=(o=a(window).scrollTop())+a(window).height(),f>o&&n<s&&!window.ff_force_scroll||a("html, body").delay(r).animate({scrollTop:t},0)}}(),!l||u||o===g||w(i,o).then((function(t){console.log(t)})),_({activeStep:o,totalSteps:g}),h.last().hasClass("active")?i.find('button[type="submit"]').css("visibility","visible"):i.find('button[type="submit"]').css("visibility","hidden"),!window.ff_disable_auto_step){var t=i.find(".fluentform-step.active"),e=i.find(".fluentform-step.active > div").length-1,n=i.find(".fluentform-step.active > .ff_excluded").length;if(i.find(".fluentform-step.active > .ff-t-container").length&&(e-=i.find(".fluentform-step.active > .ff-t-container").length,e+=i.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > div").length,n+=i.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > .ff_excluded").length,i.find(".fluentform-step.active > .ff-t-container.ff_excluded").length&&(n-=i.find(".fluentform-step.active > .ff-t-container.ff_excluded").length,n-=i.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > .ff_excluded").length,n+=i.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > div").length)),e===n)return t.find(".step-nav button[data-action="+c+"], .step-nav img[data-action="+c+"]").click(),void p()}i.find(".fluentform-step.active").find('.step-nav button[data-action="next"]').css("visibility","visible"),i.find(".fluentform-step.active").find('.step-nav button[data-action="prev"]').css("visibility","visible"),i.find(".fluentform-step.active").find('.step-nav img[data-action="next"]').css("visibility","visible"),i.find(".fluentform-step.active").find('.step-nav img[data-action="prev"]').css("visibility","visible"),p()}))}))},y=!0;function b(t){var e=!1;function n(){return i.find(".fluentform-step").index(i.find(".fluentform-step.active"))}function r(){return i.find(".fluentform-step").length}function o(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="yes"!=i.find(".ff-step-container").attr("data-disable_auto_focus");if(!y)if(r){var o=e.find("input, .ff-custom_html, select, textarea, button, a").filter(":visible");o.length&&n&&setTimeout((function(){o.first().focus()}),t+50),y=!1}else{var s;!(null===(s=window.fluentFormVars)||void 0===s||!s.step_change_focus)&&setTimeout((function(){a("".concat(f," .fluentform-step.active")).attr("tabindex","-1").focus().removeAttr("tabindex")}),t),y=!1}}function s(){e=!0,setTimeout((function(){e=!1,o(i.find(".fluentform-step.active"),!0)}),t+50)}function l(t,i){if(!e){var o=n(),l=0===o,c=o===r()-1;if(!("prev"===i&&l||"next"===i&&c)){t.preventDefault(),t.stopPropagation();var d="prev"===i?".ff-btn-prev":".ff-btn-next",u=a("".concat(f," .fluentform-step.active")).find(".step-nav ".concat(d));u.length&&(u.click(),s())}}}i.off("keydown.stepNavigation").on("keydown.stepNavigation",(function(t){if(!e&&("Tab"===t.key||9===t.keyCode)){var i=a("".concat(f," .fluentform-step.active")).find("input, select, textarea, button, a").filter(":visible"),o=i.first(),s=i.last(),c=n(),d=0===c,u=c===r()-1;t.shiftKey?document.activeElement===o[0]&&(d||l(t,"prev")):document.activeElement===s[0]&&(u||l(t,"next"))}})),i.on("ff_to_next_page ff_to_prev_page",(function(){s()})),"yes"!=i.find(".ff-step-container").attr("data-disable_auto_focus")&&0!==n()&&!y&&o(a("".concat(f," .fluentform-step.active")),!0),y=!1}var w=function(t,e){var n=t.find(":input").filter((function(t,e){return!a(e).closest(".has-conditions").hasClass("ff_excluded")}));n.filter((function(t,e){var n=a(e);return n.parents().hasClass("ff_repeater_table")&&"select"==n.attr("type")&&!n.val()})).prepend("<option selected disabled />");var i=n.serialize();a.each(t.find("[type=file]"),(function(t,e){var n={},r=e.name+"[]";n[r]=[],a(e).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each((function(t,e){n[r][t]=a(this).data("src")})),a.each(n,(function(t,e){if(e.length){var n={};n[t]=e,i+="&"+a.param(n),!0}}))}));var f={active_step:e,data:i,form_id:t.data("form_id"),action:"fluentform_step_form_save_data"};return jQuery.post(r.ajaxUrl,f)},x=function(e,n){var i=e.closest(".ff-el-input--content").find(".ff-uploaded-list");a.each(n,(function(e,n){n="object"===t(n)?n:{url:n,data_src:n};var f=a("<div/>",{class:"ff-upload-preview","data-src":n.data_src,style:"border: 1px solid rgb(111, 117, 125)"}),o=a("<div/>",{class:"ff-upload-thumb"});o.append(a("<div/>",{class:"ff-upload-preview-img",style:"background-image: url('".concat(j(n.url),"');")}));var s=a("<div/>",{class:"ff-upload-details"}),l=a("<span/>",{html:r.upload_completed_txt,class:"ff-upload-progress-inline-text ff-inline-block"}),c=n.url.substring(n.url.lastIndexOf("/")+1);c.includes("-ff-")&&(c=c.substring(c.lastIndexOf("-ff-")+4));var d=a("<div/>",{class:"ff-upload-filename",html:c}),u=a('\n <div class="ff-upload-progress-inline ff-el-progress">\n <div style="width: 100%;" class="ff-el-progress-bar"></div>\n </div>\n '),p=a("<span/>",{"data-href":"#",html:"×",class:"ff-upload-remove"}),v=a("<div>",{class:"ff-upload-filesize ff-inline-block",html:""}),m=a("<div>",{class:"ff-upload-error",style:"color:red;"});s.append(d,u,l,v,m,p),f.append(o,s),i.append(f)})),e.trigger("change_remaining",-n.length),e.trigger("change")},j=function(t){var e=t.split(/[#?]/)[0].split(".").pop().trim().toLowerCase();if(-1!=["jpg","jpeg","gif","png"].indexOf(e))return t;var n=document.createElement("canvas");n.width=60,n.height=60,n.style.zIndex=8,n.style.position="absolute",n.style.border="1px solid";var a=n.getContext("2d");return a.fillStyle="rgba(0, 0, 0, 0.2)",a.fillRect(0,0,60,60),a.font="13px Arial",a.fillStyle="white",a.textAlign="center",a.fillText(e,30,30,60),n.toDataURL()};return{init:function(){l&&jQuery(document).ready((function(t){jQuery.getJSON(r.ajaxUrl,{form_id:i.data("form_id"),action:"fluentform_step_form_get_data",nonce:null==r?void 0:r.nonce,hash:null==r?void 0:r.hash}).then((function(t){t&&v(t)}))})),i.find(".fluentform-step:first").find('.step-nav [data-action="prev"]').remove(),function(){var t=i.find(".ff-step-body"),e=i.find(".fluentform-step"),n=e.length,f=i.find(".ff-step-titles li");s=100*n+"%",t.css({width:s}),e.css({width:100/n+"%"}),a(e[o]).addClass("active"),a(f[o]).addClass("active");var l=e.first();l.hasClass("active")&&l.find('button[data-action="next"]').css("visibility","visible"),e.length&&!e.last().hasClass("active")&&i.find('button[type="submit"]').css("visibility","hidden"),_({activeStep:o,totalSteps:n}),h(r.stepAnimationDuration),m(f,e)}(),function(){function t(t){if(1==t.closest(".fluentform-step.active").find(".ff-el-group:not(.ff_excluded):not(.ff-custom_html)").length)if(t.closest(".fluentform-step.active").find(".ff_excluded").length){var e=window.ffTransitionTimeOut||400;setTimeout((function(){t.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")}),e)}else t.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")}"yes"==i.find(".ff-step-container").attr("data-enable_auto_slider")&&(i.find(".ff-el-form-check-radio,.ff-el-net-label, .ff-el-ratings label").on("click",(function(){t(a(this))})),i.find("select").on("change",(function(){t(a(this))})))}()},updateSlider:g,populateFormDataAndSetActiveStep:v}}var r;(r=jQuery)(document.body).on("fluentform_init",(function(t,e,n){var a="."+n.form_instance,f=-1,o="no";if(r(a).hasClass("ff-form-has-save-progress")){r(a).hasClass("ff-form-has-steps")&&(e.on("ff_to_next_page",(function(t,e){o=e})),e.on("ff_to_prev_page",(function(t,e){o=e}))),r(a).find(".ff-btn-save-progress").each((function(t,n){var a=r(n);a.on("click",(function(t){var n,i=this;t.preventDefault(),a.addClass("ff-working");var s=e.find(":input").filter((function(t,e){return!r(e).closest(".has-conditions").hasClass("ff_excluded")}));s.filter((function(t,e){var n=r(e);return n.parents().hasClass("ff_repeater_table")&&"select"==n.attr("type")&&!n.val()})).prepend("<option selected disabled />");var l=s.serialize();r.each(e.find("[type=file]"),(function(t,e){var n={},a=e.name+"[]";n[a]=[],r(e).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each((function(t,e){n[a][t]=r(this).data("src")})),r.each(n,(function(t,e){if(e.length){var n={};n[t]=e,l+="&"+r.param(n)}}))})),f=null===(n=window.form_state_save_vars)||void 0===n?void 0:n.key;var c={source_url:window.form_state_save_vars.source_url,action:"fluentform_save_form_progress_with_link",data:l,form_id:e.data("form_id"),hash:f,active_step:o,nonce:window.form_state_save_vars.nonce,save_progress_btn_name:r(a).attr("name")},d=c.form_id+"_save_progress_msg",u="#"+d;jQuery.post(fluentFormVars.ajaxUrl,c).then((function(t){if(t){var n;f=t.data.hash,e.find(".ff-saved-state-link"),""!=(null===(n=t.data)||void 0===n?void 0:n.message)&&(r(u).length&&r(u).slideUp("fast"),r("<div/>",{id:d,class:"ff-message-success ff-el-group"}).html(t.data.message).insertBefore(a.closest(".ff-el-group")));var o=window.form_state_save_vars.copy_button||"Copy",s='<div class="ff-el-input--content">\n <div class="ff_input-group">\n <input readonly value="'.concat(t.data.saved_url,'" class="ff-el-form-control" >\n <div class="ff_input-group-append">\n <button class="ff-btn ff-btn-md ff_btn_style ff_btn_copy_link ff_input-group-text">').concat(o,"</button>\n </div>\n </div>\n </div>"),l=r("<div/>",{class:"ff-el-group ff-saved-state-input ff-saved-state-link ff-hide-group",html:s});r(i).closest(".ff-el-group").after(l),l.fadeIn();var c=window.form_state_save_vars.email_placeholder_str||"Your Email Here",p=window.form_state_save_vars.email_button||"Email";if(r(i).hasClass("ff_resume_email_enabled")){var v='<div class="ff-el-input--content">\n <div class="ff_input-group">\n <input type="email" class="ff-el-form-control" placeholder="'.concat(c,'" class="ff-el-form-control">\n <div class="ff_input-group-append">\n <button class="ff-btn ff-btn-md ff_btn_style ff_btn_is_email ff_input-group-text">').concat(p,"</button>\n </div>\n </div>\n </div>"),m=r("<div/>",{class:"ff-el-group ff-saved-state-input ff-email-address ff-hide-group",html:v});r(l).after(m),m.fadeIn()}}})).fail((function(t){r(u).length&&r(u).slideUp("fast"),r("<div/>",{id:d,class:"ff-message-success ff-el-group text-danger"}).html(t.responseJSON.data.message).insertBefore(a.closest(".ff-el-group"))})).always((function(){a.parent().hide()}))}))})),r(a).on("click",".ff_btn_copy_link",(function(t){t.preventDefault();var e=r(this).closest(".ff-el-input--content").find(".ff-el-form-control").val();navigator.clipboard.writeText(e);var n=window.form_state_save_vars.copy_success_button||"Copied";r(this).html("".concat(n))})),r(a).on("click",".ff_btn_is_email",(function(t){t.preventDefault();var n=r(this).closest(".ff-el-group"),a=r(this).closest(".ff-email-address").find("input").val();r(".ff-email-address").find("input").val("");var i=r(".ff-saved-state-link").find("input").val(),o={source_url:window.form_state_save_vars.source_url,action:"fluentform_email_progress_link",form_id:e.data("form_id"),to_email:a,link:i,hash:f,nonce:window.form_state_save_vars.nonce},s=o.form_id+"_save_progress_email_response",l="#"+s;jQuery.post(fluentFormVars.ajaxUrl,o).then((function(t){t&&(n.removeClass("ff-el-is-error"),r(l).length&&r(l).slideUp("fast"),r("<div/>",{id:s,class:"ff-message-success ff-el-group"}).html(t.data.response).insertAfter(n))})).fail((function(t){t&&(n.addClass("ff-el-is-error"),r(l).length&&r(l).slideUp("fast"),r("<div/>",{id:s,class:"ff-message-success ff-el-group text-danger"}).html(t.responseJSON.data.Error).insertAfter(n))}))}));var s=!1;void 0!==window.form_state_save_vars&&(s=window.form_state_save_vars.key),s&&(e.append('<input type="hidden" value="'.concat(s,'" class="__fluent_state_hash" name="__fluent_state_hash"/>')),"yes"==e.find(".ff-step-container").attr("data-enable_step_data_persistency")||jQuery.getJSON(fluentFormVars.ajaxUrl,{form_id:e.data("form_id"),action:"fluentform_get_form_state",hash:s,nonce:window.form_state_save_vars.nonce}).then((function(t){t&&i(r,e,window.fluentFormVars,a).populateFormDataAndSetActiveStep(t)})))}}))})();