jQuery((function(e){AutomateWoo.Variables={$meta_box:e("#aw_variables_box"),init(){this.init_clipboard(),e(document.body).on("change keyup",".aw-workflow-variable-parameter",this.update_preview_field),e(document.body).on("keypress","input.aw-workflow-variable-parameter",this.restrict_parameter_chars),this.$meta_box.on("click",".aw-workflow-variable",this.open_modal)},init_clipboard(){new ClipboardJS(".aw-clipboard-btn",{text(){let a=e("#aw_workflow_variable_preview_field").text();return e(".aw-workflow-variable-parameter").each((function(t,r){if(e(r).prop("required")&&!e(r).get(0).checkValidity())return e(r).get(0).reportValidity(),a=!1,!1})),a}}).on("success",(function(){e(".aw-clipboard-btn").html("Copied!"),setTimeout((function(){AutomateWoo.Modal.close()}),500)}))},open_modal(){AutomateWoo.Modal.open(),AutomateWoo.Modal.loading();const a={action:"aw_modal_variable_info",variable:e(this).text()};e.post(ajaxurl,a,(function(e){AutomateWoo.Modal.contents(e),AutomateWoo.Variables.update_preview_field()}))},update_preview_field(){const a=e("#aw_workflow_variable_preview_field"),t=a.data("variable"),r=[];e(".aw-workflow-variable-parameter").each((function(){const a=e(this),t=a.parents(".aw-workflow-variables-parameter-row:first"),o=Boolean(t.data("is-required"));if(t.data("parameter-show")){const r=t.data("parameter-show").split("="),i=e('.aw-workflow-variable-parameter[name="'+r[0]+'"]');if(!i.length||i.val()!==r[1])return a.prop("required",!1),void t.hide();a.prop("required",o),t.show()}const i={name:a.attr("name"),required:o,value:a.val()};r.push(i)}));const o=AutomateWoo.Variables.generate_variable_string(t,r);a.text(o)},generate_variable_string(a,t){let r="{{ "+a;if(t.length){const a=[];e.each(t,(function(e,t){t.value?a.push(t.name+": '"+t.value+"'"):t.required&&a.push(t.name+": '...'")})),a.length>0&&(r+=" | ",r+=a.join(", "))}return r+" }}"},restrict_parameter_chars(a){if(-1!==e.inArray(a.which,[39,123,124,125]))return!1}},AutomateWoo.Variables.init()})); //# sourceMappingURL=variables.min.js.map