").parent().html()).replace(/\[conditionals\]\[(\d+)\]\[(\d+)\]/g,"[conditionals][0][0]"),i.before(t),i.prev());"confirmation"===f&&(k.prepareChoicesJSField(e,l),k.confirmationFieldsToggle(b(".wpforms-panel-field-confirmations-type").first())),"undefined"!=typeof tinymce&&void 0!==wp.editor&&"confirmation"===f&&wp.editor.initialize("wpforms-panel-field-confirmations-message-"+l,m.tinymceDefaults),wpf.initTooltips(),v.trigger("wpformsSettingsBlockAdded",[e]),a.attr("data-next-id",l+1)}},cancel:{text:wpforms_builder.cancel}}});v.on("keypress","#settings-block-name",function(e){13===e.keyCode&&b(t.buttons.confirm.el).trigger("click")})},prepareChoicesJSField:function(e,i){var o,e=e.find(`#wpforms-panel-field-confirmations-${i}-page-wrap`);e.length<=0||(i=e.find(`#wpforms-panel-field-confirmations-${i}-page`)).length<=0&&!i.hasClass("choicesjs-select")||(o=e.find(".choices")).length<=0||((i=i.first()).removeAttr("data-choice"),i.removeAttr("hidden"),i.removeClass("choices__input"),b(i).appendTo(e.first()),o.first().remove(),k.dropdownField.events.choicesInit(i))},settingsBlockNameEditingShow:function(e){e=e.parents(".wpforms-builder-settings-block-header");e.find(".wpforms-builder-settings-block-name").addClass("editing").hide(),e.find(".wpforms-builder-settings-block-name-edit").addClass("active"),wpf.focusCaretToEnd(e.find("input"))},settingsBlockNameEditingHide:function(e){var i=e.parents(".wpforms-builder-settings-block-header"),o=i.find(".wpforms-builder-settings-block-name"),i=i.find(".wpforms-builder-settings-block-name-edit"),t=i.find("input").val().trim(),e=e.closest(".wpforms-builder-settings-block").data("block-type");t.length||(t=wpforms_builder[e+"_def_name"]),i.find("input").val(t),o.text(t),o.removeClass("editing").show(),i.removeClass("active")},settingsBlockPanelClone:function(e){var i=e.closest(".wpforms-panel-content-section").find(".wpforms-builder-settings-block-add"),e=e.closest(".wpforms-builder-settings-block"),o=e.find(".wpforms-builder-settings-block-content"),t=parseInt(i.attr("data-next-id"),10),r=e.data("block-type"),n=e.find(".wpforms-builder-settings-block-name").text().trim()+wpforms_builder[r+"_clone"],o=o.is(":hidden"),s=(wpf.restoreTooltips(e),e.clone(!1,!0));k.settingsBlockUpdateState(o,t,r),s.data("block-id",t),s.find(".wpforms-builder-settings-block-header span").text(n),s.find(".wpforms-builder-settings-block-header input").val(n),s.removeClass("wpforms-builder-settings-block-default"),i.attr("data-next-id",t+1),s.find("input, textarea, select").each(function(){var e=b(this);e.attr("name")&&e.attr("name",e.attr("name").replace(/\[(\d+)\]/,"["+t+"]")),e.data("name")&&e.data("name",e.data("name").replace(/\[(\d+)\]/,"["+t+"]")),e.attr("class")&&e.attr("class",e.attr("class").replace(/-(\d+)/,"-"+t)),e.attr("data-radio-group")&&e.attr("data-radio-group",e.attr("data-radio-group").replace(/(\d+)-/,t+"-"))}),s.find("*").each(function(){var e=b(this);e.attr("id")&&e.attr("id",e.attr("id").replace(/-(\d+)/,"-"+t)),e.attr("for")&&e.attr("for",e.attr("for").replace(/-(\d+)-/,"-"+t+"-")),e.data("input-name")&&e.data("input-name",e.data("input-name").replace(/\[(\d+)\]/,"["+t+"]"))}),e.find("select").each(function(){var e=b(this).attr("name"),i=b(this).attr("name").replace(/\[(\d+)\]/,"["+t+"]");s.find('select[name="'+i+'"]').val(b(this).attr("name",e).val())}),s.css("display","none").insertBefore(e).show("fast",function(){wpf.initTooltips()}),v.trigger("wpformsSettingsBlockCloned",[s,e.data("block-id")])},settingsBlockPanelToggle:function(e){var i=e.closest(".wpforms-builder-settings-block"),o=i.data("block-id"),t=i.data("block-type"),r=i.find(".wpforms-builder-settings-block-content"),n=r.is(":visible");r.stop().slideToggle({duration:400,start:function(){k.settingsBlockUpdateState(n,o,t)},always:function(){r.is(":visible")?e.html('
'):e.html('
')}})},settingsBlockDelete:function(e){var i=e.closest(".wpforms-panel-content-section"),o=e.closest(".wpforms-builder-settings-block"),t=o.data("block-type");i.find(".wpforms-builder-settings-block").length<2||b.confirm({title:!1,content:wpforms_builder[t+"_delete"],icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"],action:function(){var e=o.data("block-id"),i=o.data("block-type");b.post(wpforms_builder.ajax_url,{action:"wpforms_builder_settings_block_state_remove",nonce:wpforms_builder.nonce,block_id:e,block_type:i,form_id:m.formID}),o.remove(),v.trigger("wpformsSettingsBlockDeleted",[t,e])}},cancel:{text:wpforms_builder.cancel}}})},settingsBlockUpdateState:function(e,i,o){b.post(wpforms_builder.ajax_url,{action:"wpforms_builder_settings_block_state_save",state:e?"closed":"opened",form_id:m.formID,block_id:i,block_type:o,nonce:wpforms_builder.nonce})},bindUIActionsRevisions:function(){v.on("wpformsPanelSwitched",function(e,i){"revisions"===i&&(k.updateRevisionsList(),k.updateRevisionPreview())}),v.on("wpformsSaved",function(e){"revisions"===wpf.getQueryString("view")&&k.updateRevisionsList()})},updateRevisionsList:function(){var t=b("#wpforms-panel-revisions .wpforms-revisions-content"),i=b(".wpforms-panel-revisions-button .badge-exclamation");i.length&&b.post(wpforms_builder.ajax_url,{action:"wpforms_mark_panel_viewed",form_id:m.formID,nonce:wpforms_builder.nonce}).done(function(e){e.success?i.remove():wpf.debug(e)}).fail(function(e,i,o){wpf.debug(e.responseText||i||"")}),v.hasClass("wpforms-revisions-enabled")&&t.fadeTo(250,.25,function(){b.post(wpforms_builder.ajax_url,{action:"wpforms_get_form_revisions",form_id:m.formID,revision_id:wpf.getQueryString("revision_id"),nonce:wpforms_builder.nonce}).done(function(e){e.success?t.replaceWith(e.data.html):wpf.debug(e)}).fail(function(e,i,o){wpf.debug(e.responseText||i||""),t.fadeTo(250,1)})})},updateRevisionPreview:function(){var e=y.$formPreview.clone();e.find(".wpforms-field-duplicate, .wpforms-field-delete, .wpforms-field-helper, .wpforms-debug").remove().end(),e.find(".wpforms-field-wrap").removeClass("ui-sortable").addClass("ui-sortable-disabled"),e.find(".wpforms-field").removeClass("ui-sortable-handle ui-draggable ui-draggable-handle active").removeAttr("id data-field-id data-field-type").removeData(),e.find(".wpforms-field-submit-button").prop("disabled",!0),y.$revisionPreview.hasClass("has-preview")?y.$revisionPreview.find(".wpforms-preview-wrap").replaceWith(e):y.$revisionPreview.append(e).addClass("has-preview")},confirmSaveRevision:function(){b.confirm({title:wpforms_builder.heads_up,content:wpforms_builder.revision_update_confirm,icon:"fa fa-exclamation-circle",type:"orange",closeIcon:!1,buttons:{confirm:{text:wpforms_builder.save,btnClass:"btn-confirm",keys:["enter"],action:function(){v.addClass("wpforms-revision-is-saving"),WPFormsBuilder.formSave(!1).done(k.revisionSavedReload)}},cancel:{text:wpforms_builder.cancel,action:function(){WPFormsBuilder.setCloseConfirmation(!0)}}}})},revisionSavedReload:function(){wpf.updateQueryString("view",wpf.getQueryString("view")),wpf.removeQueryParam("revision_id"),a.location.reload()},bindUIActionsSaveExit:function(){v.on("click","#wpforms-embed",function(e){e.preventDefault(),b(this).hasClass("wpforms-disabled")||WPFormsFormEmbedWizard.openPopup()}),v.on("click","#wpforms-save",function(e){e.preventDefault(),k.formSave(!1)}),v.on("click","#wpforms-exit",function(e){e.preventDefault(),k.formExit()}),v.on("wpformsSaved",function(e,i){wpf.removeQueryParam("newform")})},formSave:function(i){var e=y.$saveButton,o=e.find("i.fa-check"),t=e.find("i.wpforms-loading-spinner"),r=e.find("span"),n=r.text();if(v.hasClass("wpforms-is-revision")&&!v.hasClass("wpforms-revision-is-saving"))k.confirmSaveRevision();else{"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave();var s=WPFormsUtils.triggerEvent(v,"wpformsBeforeSave");if(!s.isDefaultPrevented())return r.text(wpforms_builder.saving),e.prop("disabled",!0),o.addClass("wpforms-hidden"),t.removeClass("wpforms-hidden"),s={action:"wpforms_save_form",data:JSON.stringify(b("#wpforms-builder-form").serializeArray()),id:m.formID,nonce:wpforms_builder.nonce},b.post(wpforms_builder.ajax_url,s,function(e){e.success?(wpf.savedState=wpf.getFormState("#wpforms-builder-form"),wpf.initialSave=!1,v.trigger("wpformsSaved",e.data),!0===i&&k.isBuilderInPopup()?k.builderInPopupClose("saved"):!0===i&&(a.location.href=wpforms_builder.exit_url)):(wpf.debug(e),k.formSaveError(e.data))}).fail(function(e,i,o){wpf.debug(e),k.formSaveError()}).always(function(){r.text(n),e.prop("disabled",!1),t.addClass("wpforms-hidden"),o.removeClass("wpforms-hidden")})}},formSaveError:function(e){wpf.empty(e)&&(e=wpforms_builder.error_save_form),b.confirm({title:wpforms_builder.heads_up,content:"
"+e+"
"+wpforms_builder.error_contact_support+"
",icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}})},formExit:function(){k.isBuilderInPopup()&&k.formIsSaved()?k.builderInPopupClose("saved"):k.formIsSaved()?a.location.href=wpforms_builder.exit_url:b.confirm({title:!1,content:wpforms_builder.exit_confirm,icon:"fa fa-exclamation-circle",type:"orange",closeIcon:!0,buttons:{confirm:{text:wpforms_builder.save_exit,btnClass:"btn-confirm",keys:["enter"],action:function(){k.formSave(!0)}},cancel:{text:wpforms_builder.exit,action:function(){i=!1,k.isBuilderInPopup()?k.builderInPopupClose("canceled"):a.location.href=wpforms_builder.exit_url}}}})},setCloseConfirmation:function(e){i=!!e},formIsSaved:function(){return wpf.savedState==wpf.getFormState("#wpforms-builder-form")},isBuilderInPopup:function(){return a.self!==a.parent&&"wpforms-builder-iframe"===a.self.frameElement.id},builderInPopupClose:function(e){var i=a.parent.jQuery(".wpforms-builder-popup"),o=b(".wpforms-center-form-name").text();i.find("#wpforms-builder-iframe").attr("src","about:blank"),i.fadeOut(),i.trigger("wpformsBuilderInPopupClose",[e,m.formID,o])},bindUIActionsGeneral:function(){v.on("click",".toggle-smart-tag-display",k.smartTagToggle),v.on("click",".smart-tags-list-display a",k.smartTagInsert),v.on("click",".wpforms-panel-fields-group.unfoldable .wpforms-panel-fields-group-title",k.toggleUnfoldableGroup),v.on("click",".wpforms-field-helper-hide ",k.hideFieldHelper),v.on("input",".wpforms-field-map-table .key-source",function(){var e=b(this).val(),i=b(this).parent().parent().find(".key-destination"),o=i.data("name");e&&i.attr("name",o.replace("{source}",e.replace(/[^0-9a-zA-Z_-]/gi,"")))}),v.on("click",".wpforms-field-map-table .remove",function(e){e.preventDefault(),k.fieldMapTableDeleteRow(e,b(this))}),v.on("click",".wpforms-field-map-table .add",function(e){e.preventDefault(),k.fieldMapTableAddRow(e,b(this))}),b(r).on("wpformsFieldUpdate",k.fieldMapSelect),v.on("input",".wpforms-money-input",function(e){var i=b(this),o=i.val(),t=i[0].selectionStart,r=i[0].selectionEnd;i.val(o.replace(/[^0-9.,]/g,"")),i[0].setSelectionRange(t,r)}),v.on("focusout",".wpforms-money-input",function(e){var i=b(this),o=i.val();if(!o)return o;o=wpf.amountSanitize(o),o=wpf.amountFormat(o);i.val(o)}),v.on("change",".wpforms-panel-field-toggle",function(){var e=b(this);e.prop("disabled")||(e.prop("disabled",!0),k.toggleOptionsGroup(e))}),v.on("change",k.getPaymentsTogglesSelector(),function(e){var i=b(this),o=i.attr("id").replace(/wpforms-panel-field-|-enable|_one_time|_recurring/gi,""),t=b('.wpforms-panel-content-section-notifications [id*="-'+o+'-wrap"]');i.prop("checked")||b("#wpforms-panel-field-"+o+"-enable_one_time").prop("checked")||b("#wpforms-panel-field-"+o+"-enable_recurring").prop("checked")?b("#wpforms-panel-field-settings-disable_entries").prop("checked")?(b.confirm({title:wpforms_builder.heads_up,content:wpforms_builder.payments_entries_off,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}}),i.prop("checked",!1)):t.removeClass("wpforms-hidden"):(t.addClass("wpforms-hidden"),t.find('input[id*="-'+o+'"]').prop("checked",!1))}),v.on("change","#wpforms-panel-field-settings-disable_entries",function(e){var i=b(this);i.prop("checked")&&(k.isPaymentsEnabled()?(b.confirm({title:wpforms_builder.heads_up,content:wpforms_builder.payments_on_entries_off,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}}),i.prop("checked",!1)):b.alert({title:wpforms_builder.heads_up,content:wpforms_builder.disable_entries,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}}))}),v.on("click",".wpforms-image-upload-add",function(e){e.preventDefault();var i=b(this),o=i.parent(),t=wp.media.frames.wpforms_media_frame=wp.media({className:"media-frame wpforms-media-frame",frame:"select",multiple:!1,title:wpforms_builder.upload_image_title,library:{type:"image"},button:{text:wpforms_builder.upload_image_button}});t.on("select",function(){var e=t.state().get("selection").first().toJSON();o.find(".source").val(e.url),o.find(".preview").empty(),o.find(".preview").prepend('
'),"hide"===i.data("after-upload")&&i.hide(),v.trigger("wpformsImageUploadAdd",[i,o])}),t.open()}),v.on("click",".wpforms-image-upload-remove",function(e){e.preventDefault();e=b(this).parent().parent();e.find(".preview").empty(),e.find(".wpforms-image-upload-add").show(),e.find(".source").val(""),v.trigger("wpformsImageUploadRemove",[b(this),e])}),v.on("blur",".wpforms-notification .wpforms-panel-field-text input",function(){k.validateEmailSmartTags(b(this))}),v.on("blur",".wpforms-notification .wpforms-panel-field-textarea textarea",function(){k.validateEmailSmartTags(b(this))}),v.on("focusout",".wpforms-notification .wpforms-panel-field.js-wpforms-from-email-validation input",k.validateFromEmail),v.on("wpformsPanelSectionSwitch",k.notificationsPanelSectionSwitch),v.on("click","#wpforms-builder-mobile-notice .wpforms-fullscreen-notice-button-primary, #wpforms-builder-mobile-notice .close",function(){a.location.href=wpforms_builder.exit_url}),v.on("click","#wpforms-builder-mobile-notice .wpforms-fullscreen-notice-button-secondary",function(){a.location.href=wpf.updateQueryString("force_desktop_view",1,a.location.href)}),b("#wpforms-builder-license-alert .close").on("click",function(){a.location.href=wpforms_builder.exit_url}),b("#wpforms-builder-license-alert .dismiss").on("click",function(e){e.preventDefault(),b("#wpforms-builder-license-alert").remove(),wpCookies.set("wpforms-builder-license-alert","true",3600)}),v.on("change","#wpforms-panel-field-settings-akismet.wpforms-akismet-disabled",function(e){const i=b(this),o=i.data("akismet-status");i.prop("checked")&&b.alert({title:wpforms_builder.heads_up,content:wpforms_builder[o],icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}},onClose:function(){i.prop("checked",!1)}})})},notificationsPanelSectionSwitch:function(e,i){"notifications"===i&&b(".wpforms-notification .wpforms-panel-field.js-wpforms-from-email-validation input").trigger("focusout")},isPaymentsEnabled:function(){var e=!1;return b(k.getPaymentsTogglesSelector()).each(function(){if(b(this).prop("checked"))return!(e=!0)}),e},getPaymentsTogglesSelector:function(){return`.wpforms-panel-content-section-payment-toggle-one-time input,
.wpforms-panel-content-section-payment-toggle-recurring input,
#wpforms-panel-field-stripe-enable,
#wpforms-panel-field-paypal_standard-enable,
#wpforms-panel-field-authorize_net-enable,
#wpforms-panel-field-square-enable`},toggleOptionsGroup:function(e){function i(){e.prop("disabled",!1)}var o=e.attr("name"),t=e.attr("type"),r="",o=b('.wpforms-panel-field-toggle-body[data-toggle="'+o+'"]');0===o.length?i():(r="checkbox"!==t&&"radio"!==t||e.prop("checked")?e.val():"0",o.each(function(){var e=b(this);e.attr("data-toggle-value").toString()===r.toString()?e.slideDown("",i):e.slideUp("",i)}))},toggleAllOptionGroups:function(e){(e=e||v||b("#wpforms-builder")||b("body"))&&e.find(".wpforms-panel-field-toggle").each(function(){var e=b(this);e.prop("disabled",!0),k.toggleOptionsGroup(e)})},toggleUnfoldableGroup:function(e){e.preventDefault();var i=b(e.target).closest(".wpforms-panel-fields-group"),e=i.find(".wpforms-panel-fields-group-inner"),o="wpforms_fields_group_"+i.data("group");i.hasClass("opened")?(wpCookies.remove(o),e.stop().slideUp(150,function(){i.removeClass("opened")})):(wpCookies.set(o,"true",2592e3),i.addClass("opened"),e.stop().slideDown(150))},hideFieldHelper:function(e){e.preventDefault(),e.stopPropagation();e=b(".wpforms-field-helper");wpCookies.set("wpforms_field_helper_hide","true",2592e3),e.hide()},smartTagToggle:function(e){e.preventDefault(),y.$focusOutTarget=null;var e=b(this),i=e.closest(".wpforms-panel-field,.wpforms-field-option-row");i.hasClass("smart-tags-toggling")||(i.addClass("smart-tags-toggling"),e.hasClass("smart-tag-showing")?k.removeSmartTagsList(e):k.insertSmartTagsList(e))},removeSmartTagsList:function(e){var i=e.closest(".wpforms-panel-field,.wpforms-field-option-row"),o=i.find(".smart-tags-list-display");e.find("span").text(wpforms_builder.smart_tags_show),o.slideUp("",function(){o.remove(),e.removeClass("smart-tag-showing"),i.removeClass("smart-tags-toggling")})},insertSmartTagsList:function(e){var i,o=e.closest(".wpforms-panel-field,.wpforms-field-option-row"),t=e.closest("label"),r=!0;t.length||(t=o.find("label"),r=!1),i=k.getSmartTagsList(e,-1!==t.attr("for").indexOf("wpforms-field-option-")),(r?t:e).after(i),e.find("span").text(wpforms_builder.smart_tags_hide),o.find(".smart-tags-list-display").slideDown("",function(){e.addClass("smart-tag-showing"),o.removeClass("smart-tags-toggling")})},getSmartTagsList:function(e,i){var o='
"},getSmartTagsListFieldsElements:function(e){var i,o=e.data("type"),t=k.getSmartTagsFields(e),r="";if(!["fields","all"].includes(o))return"";if(!t)return'
'+wpforms_builder.fields_unavailable+"";for(i in r+='
'+wpforms_builder.fields_available+"",wpf.orders.fields){var n=wpf.orders.fields[i];t[n]&&(r+=k.getSmartTagsListFieldsElement(t[n]))}return r},getSmartTagsFields:function(e){e=e.data("fields");return e&&e.length?wpf.getFields(e.split(","),!0):wpf.getFields(!1,!0)},getSmartTagsListFieldsElement:function(e){var i=e.label?wpf.encodeHTMLEntities(wpf.sanitizeHTML(e.label)):wpforms_builder.field+" #"+e.id;return'
"+i+""},getSmartTagsListOtherElements:function(e,i){var o,t,e=e.data("type");if("other"!==e&&"all"!==e)return"";for(t in o='
'+wpforms_builder.other+"",wpforms_builder.smart_tags)i&&-1
"+wpforms_builder.smart_tags[t]+"");return o},smartTagInsert:function(e){e.preventDefault();var i,e=b(this),o=e.closest(".smart-tags-list-display"),t=o.closest(".wpforms-panel-field,.wpforms-field-option-row"),r=t.find(".toggle-smart-tag-display"),n=t.find("input[type=text], textarea"),s=e.data("meta"),e="field"===e.data("type")?'{field_id="'+s+'"}':"{"+s+"}";"undefined"!=typeof tinyMCE&&(i=tinyMCE.get(n.prop("id")))&&!i.hasFocus()&&i.focus(!0),i&&!i.isHidden()?i.insertContent(e):(n.insertAtCaret(" "+e+" "),n.val(n.val().trim().replace(" "," ")),n.trigger("focus").trigger("input")),o.slideUp("",function(){o.remove()}),r.find("span").text(wpforms_builder.smart_tags_show),t.find(".toggle-smart-tag-display").removeClass("smart-tag-showing")},fieldMapTableDeleteRow:function(e,i){var i=b(i),o=i.closest("tr"),i=i.closest("table"),t=o.closest(".wpforms-builder-settings-block");"1"",{value:"",text:s})),void 0!==n&&n){if(n=n.split(" "),l&&!b.isEmptyObject(l))for(var a in wpf.orders.fields)Object.prototype.hasOwnProperty.call(wpf.orders.fields,a)&&(a=wpf.orders.fields[a],o="",l[a])&&(o=void 0!==l[a].label&&""!==l[a].label.toString().trim()?wpf.sanitizeHTML(l[a].label.toString().trim()):wpforms_builder.field+" #"+a,0<=b.inArray(l[a].type,n)||0<=b.inArray("all-fields",n))&&t.append(b("