!function(){"use strict";var e=window.wp.i18n;!function(t,n){jQuery.fn.extend({createRepeater:function(n){if(this.data("mf-repeater-initialized"))return this;this.data("mf-repeater-initialized",!0);var a=n.scope;t(document).on("input",".mf-repeater-textarea",function(){this.style.height="",this.style.height=this.scrollHeight+"px"});var r=function(e){var t=a.find(".mf-input-repeater-items")||[];t.each(function(n,a){var r=a.querySelector(".mf-repeater-remove-btn")||{};return e(t,r)})},i=jQuery("body").find(".metform-form-main-wrapper").children().attr("data-elementor-id"),o=JSON.parse(localStorage.getItem("metform-".concat(i))),f=function(n,o){var f=n,m=f.data("group");f.find("input,select,textarea").each(function(e,n){var a=t(n).data("name");1!=t(n).data("skip-name")?a.lastIndexOf("[]")>0?(a=a.replace("[]",""),t(n).attr("name",m+"["+o+"]["+a+"][]")):t(n).attr("name",m+"["+o+"]["+a+"]"):"undefined"!=a&&t(n).attr("name",a),t(n).attr("value",t(n).data("value"));var r=t(n).attr("id");if(null!=r){var i=(r+"["+o+"]").replace("["+(o-1)+"]","");t(n).attr("id",i),t(n).parent().find("label").attr("for",i)}});var c=n;a.on("click",".remove-btn",function(e){if(a.find(".mf-input-repeater-items").length>1){var n=[];t(e.target).parents(".mf-input-repeater-items").remove();var o=jQuery(e.target).parent().siblings(".mf-input-repeater-content").find(".mf-repeater-field");Array.from(o).forEach(function(e,t){n.push(e.name)});var f=JSON.parse(localStorage.getItem("metform-".concat(i)));if(f||null!==f){for(var d in f)n.includes(d)&&delete f[d];localStorage.setItem("metform-".concat(i),JSON.stringify(f))}}1===a.find(".mf-input-repeater-items").length&&r(function(e,t){return t.style.display="none"})});var l=t("<div class='mf-input-repeater-items attr-items'>"+c.html()+"<div/>");l.attr("data-index",o),l.hide().appendTo(d).fadeIn(),jQuery(l).find(".mf-input-select").each(function(){var n=t(this);n.select2({placeholder:(0,e.__)("Select an option","metform-pro"),dropdownParent:n.parents(".attr-form-group").eq(0)})});var p=l.find('.mf-repater-range-input[type="range"]'),u=p.attr("min"),s=p.attr("max"),h=p.attr("step");jQuery(l).find('.mf-repater-range-input[type="range"]').each(function(){t(this).asRange({step:h,min:u,max:s})}),"function"==typeof window.flatpickr&&jQuery(l).find(".mf-repeater-date-input").each(function(){window.flatpickr(this,{dateFormat:"Y-m-d",disableMobile:!0,onReady:function(e,t,n){n.calendarContainer.classList.add("mf-repeater-date-calendar")}})})},d=this;if(o){var m=0;setTimeout(function(){for(var e in o){var t=e.match(/mf-simple-repeater\[(\d+)\]/);t&&0==t[1]&&m++}0==m&&d.find('[data-index="0"]').remove()},10)}var c=null,l=0;o?setTimeout(function(){c=d.find(".attr-items").last().attr("data-index"),l=c},10):l=0;var p=d.find(".attr-items"),u=d.parent().find(".repeater-add-btn");p.each(function(e,a){p.remove(),(n.hasOwnProperty("showFirstItemToDefault")&&1==n.showFirstItemToDefault||p.length>1)&&(f(t(a),l),l++)}),o?setTimeout(function(){r(function(e,t){return t.style.display=1===e.length?"none":"block"})},10):r(function(e,t){return t.style.display=1===e.length?"none":"block"}),u.on("click",function(){r(function(e,t){return t.style.display="block"}),o?(l++,f(t(p[0]),l)):(f(t(p[0]),l),l++)})}});var a={init:function(){var e={"mf-simple-repeater.default":a.SimpleRepeater};t.each(e,function(e,t){n.hooks.addAction("frontend/element_ready/"+e,t)})},SimpleRepeater:function(e){e.find(".mf-input-repeater").createRepeater({showFirstItemToDefault:!0,scope:e})}};t(window).on("elementor/frontend/init",a.init)}(jQuery,window.elementorFrontend)}();