File: /var/www/html/delstar/wp-content/plugins/js_composer/modules/automapper/assets/dist/module.min.js
var vc_am={current_form:!1};window.i18nLocaleVcAutomapper=window.i18nLocaleSettings,(s=>{function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}vc_am.vcGuid=function(){return e()+e()+"-"+e()},_.extend(wp.shortcode.prototype,{taggedString:function(){var a='[<span class="vc_preview-tag">'+_.escape(this.tag)+"</span>";return _.each(this.attrs.numeric,function(e){/\s/.test(e)?a+=' <span class="vc_preview-param">"'+_.escape(e)+'"</span>':a+=' <span class="vc_preview-param">'+_.escape(e)+"</span>"}),_.each(this.attrs.named,function(e,t){a+=' <span class="vc_preview-param">'+_.escape(t)+'="'+_.escape(e)+'"</span>'}),"single"===this.type?a+"]":"self-closing"===this.type?a+" /]":(a+="]",this.content&&(a+='<span class="vc_preview-content">'+_.escape(this.content)+"</span>"),a+'[/<span class="vc_preview-tag">'+_.escape(this.tag)+"</span>]")}}),wp.shortcode.atmPreview=function(e){return new wp.shortcode(e).taggedString()};var r,a,i=s("#vc_settings-automapper");function n(e,t){a&&(window.clearTimeout(a),s(".vc_settings-automapper").remove(),a=!1);t=s('<div class="vc_atm-message updated'+(t?" vc_message-"+t:"")+'" style="display: none;"></div>');t.text(e),t.prependTo(i).fadeIn(500,function(){var e=s(this);window.setTimeout(function(){e.remove()},5e3)})}function c(e,t){var a,i,r;!_.isUndefined(t)&&t.length||(t=s(".tab_intro")),e=e,a="error",(i=void 0)||s(".vc_atm-message").remove(),(r=s('<div class="vc_atm-message '+(a||"")+'" style="display: none;"></div>')).text(e),_.isUndefined(i)||window.setTimeout(function(){r.remove()},i),r.insertBefore(t).fadeIn(500)}var o,m=function(e){return(e=e.replace(/_|-/," ")).charAt(0).toUpperCase()+e.slice(1)},t="?",d=(-1<window.ajaxurl.indexOf("?")&&(t="&"),r=window.ajaxurl+t+"vc_action=automapper",t=function(t,a,i){var e="create"===t?(a.set("id",vc_am.vcGuid()),{vc_action:"create",action:"vc_automapper_create",data:a.toJSON()}):"update"===t?{vc_action:"update",action:"vc_automapper_update",id:a.get("id"),data:a.toJSON()}:"delete"===t?{vc_action:"delete",action:"vc_automapper_delete",id:a.get("id")}:{vc_action:"read",action:"vc_automapper_read"};s.ajax({method:"POST",url:r,dataType:"json",data:_.extend(e,{_vcnonce:window.vcAdminNonce}),context:this}).done(function(e){e.success&&((e=(e=e.data)&&"read"===t?e:a)?"read"===t&&i.success(e):i.error("Not found"))}).fail(function(e){})},Backbone.Model.extend({defaults:function(){return{tag:"",name:"",category:"",description:"",params:[]}},sync:t})),d=Backbone.Collection.extend({model:d,sync:t}),t=(vc_am.shortcodes=new d,Backbone.View.extend({tagName:"li",className:"widget",events:{"click .vc_automapper-edit-btn":"edit","click h4, widget-action":"edit","click .vc_automapper-delete-btn":"clear"},template_html:s("#vc_automapper-item-tpl").html()||"<span>{{ tag }}</span>",initialize:function(){this.listenTo(this.model,"change",this.render),this.listenTo(this.model,"destroy",this.removeView)},render:function(){var e=vc.template(this.template_html,vc.templateOptions.custom);return this.$el.html(e(this.model.toJSON())).attr("data-item-id",this.model.get("id")),this},edit:function(e){e&&e.preventDefault&&e.preventDefault(),new o({model:this.model}).render()},clear:function(e){e&&e.preventDefault&&e.preventDefault(),confirm(window.i18nLocaleVcAutomapper.are_you_sure_delete)&&this.model.destroy()},removeView:function(){this.$el.remove()}}),Backbone.View.extend({render:function(){return vc_am.current_form&&vc_am.current_form.close(),vc_am.current_form=this},getType:function(){return"form"},validate:function(e){var a,i=!1;return e.name?e.tag&&e.tag.match(/^\S+$/)?(a=["param_name","heading","type"],_.each(e.params,function(t){_.each(a,function(e){""!==t[e]&&("param_name"!==e||t[e].match(/^[a-z0-9_]+$/g))||(i=window.i18nLocaleVcAutomapper.error_enter_required_fields)},this)},this),i||null):window.i18nLocaleVcAutomapper.error_enter_valid_shortcode_tag:window.i18nLocaleVcAutomapper.error_shortcode_name_is_required},isValid:function(e){return this.validationError=this.validate(e),!this.validationError},close:function(e){e&&e.preventDefault&&e.preventDefault(),vc_am.current_form=!1,this.remove()}})),l=Backbone.View.extend({_$widget_title:!1,_$form_view:!1,edit_view:!1,tagName:"li",className:"widget",events:{"click .vc_automapper-edit-btn":"edit","click h4, .widget-action":"edit"},template_html:s("#vc_automapper-item-complex-tpl").html()||"<span>{{ tag }}</span>",header_template_html:'<h4>{{ name }}<span class="in-widget-title"></span></h4>',initialize:function(){_.bindAll(this,"removeEditForm"),this.listenTo(this.model,"destroy",this.removeView),this.model.view=this},render:function(){var e=vc.template(this.template_html,vc.templateOptions.custom);return this.$el.html(e(this.model.toJSON())).attr("data-item-id",this.model.get("id")),this},renderTitle:function(){var e=vc.template(this.header_template_html,vc.templateOptions.custom);this.$widgetTitle().html(e(this.model.toJSON()))},edit:function(e){if(e&&e.preventDefault&&e.preventDefault(),this.$editForm().is(":animated"))return!1;this.$el.addClass("vc_opened"),this.edit_view?this.close():this.edit_view=new p({model:this.model}).render()},$widgetTitle:function(){return this._$widget_title||(this._$widget_title=this.$el.find(".widget-title")),this._$widget_title},$editForm:function(){return this._$edit_form||(this._$edit_form=this.$el.find(".widget-inside")),this._$edit_form},removeEditForm:function(){this.edit_view&&this.edit_view.remove(),this.edit_view=!1},beforeSave:function(){this.$el.find("#vc_atm-name").val(s("#vc_atm-header-name").val())},close:function(){vc_am.current_form=!1,this.$el.removeClass("vc_opened"),this.renderTitle(),this.$editForm().slideUp(200),this.removeEditForm()},clear:function(e){e&&e.preventDefault&&e.preventDefault(),this.model.destroy()},removeView:function(){this.remove()}}),v=t.extend({className:"vc_add-form-atm",template_html:s("#vc_automapper-add-form-tpl").html(),events:{"click #vc_atm-parse-string":"parseShortcode","click .vc_atm-cancel":"close"},getType:function(){return"create"},render:function(){v.__super__.render.call(this);var e=vc.template(this.template_html,vc.templateOptions.custom);return this.$el.html(e()),this.$el.insertAfter(".vc_automapper-toolbar"),this},shortcodesRegexp:_.memoize(function(){return new RegExp("\\[(\\[?)([\\w|-]+\\b)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)")}),parseShortcode:function(e){e&&e.preventDefault&&e.preventDefault();var t,a=[],e=s("#vc_atm-shortcode-string").val();return!_.isEmpty(e)&&(e=e.match(this.shortcodesRegexp()))?(t=wp.shortcode.attrs(e[3]),_.each(t.named,function(e,t){a.push({param_name:t,type:"textfield",heading:m(t),description:"Example: "+e,value:e})},this),e[5]&&a.push({param_name:"content",type:"textarea",heading:"Content",description:"",value:e[5]}),t={tag:e[2],name:m(e[2]),category:window.i18nLocaleVcAutomapper.my_shortcodes_category,params:a},void(this.isValid(t)?(vc_am.shortcodes.create(t),n(window.i18nLocaleVcAutomapper.new_shortcode_mapped,"success"),s(".vc_atm-message").remove(),vc_am.shortcodes.last().view.edit()):(this.$el.addClass("form-invalid"),c(this.validationError)))):(this.$el.addClass("form-invalid"),c(window.i18nLocaleVcAutomapper.error_enter_valid_shortcode,this.$el),!1)}}),p=(o=t.extend({className:"vc_edit-form",active_preview:!1,events:{"click #vc_atm-save":"save","click .vc_atm-cancel":"close","click .vc_atm-delete":"clear","click #vc_atm-add-param":"addParam","click .vc_delete-param":"deleteParam","change #vc_atm-is-container":"setContentParam","keyup .vc_param-name, .vc_param-value, #vc_atm-tag":"setPreview","focus #vc_atm-tag":"setTagFieldActive","focus .vc_params input, .vc_params textarea":"setParamFieldActive","focus .vc_param.vc_content input, .vc_param.vc_content textarea":"setContentParamFieldActive","blur #vc_atm-tag, vc_param input":"unsetFieldActive",'change .vc_param-field [name="type"]':"changeParamType"},new:!1,template_html:s("#vc_automapper-form-tpl").html(),param_template_html:s("#vc_atm-form-param-tpl").html(),getType:function(){return"edit"},render:function(){o.__super__.render.call(this);var e=vc.template(this.template_html,vc.templateOptions.custom);return this.$el.html(e(this.model.toJSON())),this.$el.insertAfter(s("[data-item-id="+this.model.id+"]").hide()),this.addAllParams(),this},changeParamType:function(e){var e=s(e.currentTarget),t=e.parents(".vc_fields");"hidden"===e.val()?(t.find('[name="heading"]').attr("disabled",!0),t.find('[name="description"]').attr("disabled",!0)):(t.find('[name="heading"]').attr("disabled",!1),t.find('[name="description"]').attr("disabled",!1))},setTagFieldActive:function(e){this.active_preview&&s(this.active_preview).removeClass("vc_active"),this.active_preview="#vc_shortcode-preview .vc_preview-tag",s(this.active_preview).addClass("vc_active")},setParamFieldActive:function(e){e=s(e.currentTarget).parents(".vc_param:first").index();this.active_preview&&s(this.active_preview).removeClass("vc_active"),this.active_preview="#vc_shortcode-preview .vc_preview-param:eq("+e+")",s(this.active_preview).addClass("vc_active")},setContentParamFieldActive:function(e){this.active_preview&&s(this.active_preview).removeClass("vc_active"),this.active_preview="#vc_shortcode-preview .vc_preview-content",s(this.active_preview).addClass("vc_active")},unsetFieldActive:function(e){s(this.active_preview).removeClass("vc_active"),this.active_preview=!1},escapeParam:function(e){return e&&e.replace(/"/g,"``")},getPreview:function(e){var t=e.params,a=!1,i={};return _.each(t,function(e,t){"content"!==e.param_name?i[e.param_name]=this.escapeParam(e.value):a=e.value},this),wp.shortcode.atmPreview({tag:e.tag,attrs:i,content:a,type:!1===a?"single":""})},setPreview:function(){var e={params:this.getParams(),tag:s("#vc_atm-tag").val()};s("#vc_shortcode-preview").html(this.getPreview(e)),this.active_preview&&s(this.active_preview).addClass("vc_active")},save:function(e){e&&e.preventDefault&&e.preventDefault(),this.$el.find(".vc_error").removeClass("vc_error");e={tag:s("#vc_atm-tag").val(),name:s("#vc_atm-name").val(),category:s("#vc_atm-category").val(),description:s("#vc_atm-description").val(),params:this.getParams()};this.isValid(e)?(this.model.save(e),n(window.i18nLocaleVcAutomapper.shortcode_updated,"success"),this.close()):c(this.validationError,this.$el.find("#vc_atm-save"))},validate:function(e){var r,n,c;return s(".vc_error,.form-invalid").removeClass("vc_error form-invalid"),r=!1,n={},e.name?e.tag&&e.tag.match(/^\S+$/)?(c=["param_name","heading","type"],_.each(e.params,function(t,a){var i=s("#vc_atm-params-list [name=param_name]:eq("+a+")");"content"!==t.param_name||i.data("system")?(_.isBoolean(n[t.param_name])&&1==n[t.param_name]&&(i.addClass("vc_error"),i.closest(".vc_param-field").addClass("form-invalid"),r=r||window.i18nLocaleVcAutomapper.error_param_already_exists.replace(/\%s/,t.param_name)),n[t.param_name]=!0,_.each(c,function(e){"hidden"!==t.type&&""===t[e]||"hidden"===t.type&&"heading"!==e&&""===t[e]?(s("#vc_atm-params-list [name="+e+"]:eq("+a+")").addClass("vc_error").closest(".vc_param-field").addClass("form-invalid"),r=r||window.i18nLocaleVcAutomapper.error_enter_required_fields):"param_name"!==e||t[e].match(/^[a-z0-9_]+$/g)||(i.addClass("vc_error").closest(".vc_param-field").addClass("form-invalid"),r=r||window.i18nLocaleVcAutomapper.error_wrong_param_name)},this)):(r=window.i18nLocaleVcAutomapper.error_content_param_not_manually,i.addClass("vc_error"),i.closest(".vc_param-field").addClass("form-invalid"))},this),r||null):(s("#vc_atm-tag").addClass("vc_error").parent().addClass("form-invalid"),window.i18nLocaleVcAutomapper.error_enter_valid_shortcode_tag):(s("#vc_atm-name").addClass("vc_error"),s("#vc_atm-header-name").parent().addClass("form-invalid"),window.i18nLocaleVcAutomapper.error_shortcode_name_is_required)},setContentParam:function(e){s(e.currentTarget)[0].checked?(this.addParamField({type:"textarea",heading:"Content",description:"",param_name:"content",value:""}),this.setParamSorting()):this.removeParamField("content"),s(".edit-form-info").initializeTooltips(".vc_wrapper"),this.setPreview()},addAllParams:function(){s("#vc_atm-params-list").empty(),_.each(this.model.get("params"),function(e){this.addParamField(e),"content"===e.param_name&&s("#vc_atm-is-container").prop("checked",!0)},this),this.setParamSorting()},getParams:function(){var t=[];return _.each(s(".vc_param"),function(e){e=s(e);t.push({param_name:e.find("[name=param_name]").val(),type:e.find("[name=type]").val(),description:e.find("[name=description]").val(),heading:e.find("[name=heading]").val(),value:e.find("[name=value]").val()})},this),t},addParam:function(e){e&&e.preventDefault&&e.preventDefault(),this.addParamField({type:"",heading:"",description:"",param_name:"",value:""}),s(".edit-form-info").initializeTooltips(".vc_wrapper"),this.setPreview()},removeParamField:function(e){s('.vc_param-name[value="'+e+'"]').parents(".vc_param").remove()},addParamField:function(e){var t=s('<div class="vc_param wpb_vc_row'+("content"===e.param_name?" vc_content":"")+'"/>').appendTo("#vc_atm-params-list"),a=vc.template(this.param_template_html,vc.templateOptions.custom);t.html(a(e))},setParamSorting:function(){s("#vc_atm-params-list").sortable({items:"> .vc_param",tolerance:"pointer",handle:".vc_move-param",update:this.setPreview,placeholder:"vc_sortable-placeholder"})},deleteParam:function(e){e&&e.preventDefault&&e.preventDefault(),confirm(window.i18nLocaleVcAutomapper.are_you_sure_delete_param)&&(s(e.currentTarget).parents(".vc_param").remove(),this.setPreview())},close:function(e){e&&e.preventDefault&&e.preventDefault(),this.model&&s("[data-item-id="+this.model.get("id")+"]").show(),vc_am.current_form=!1,s(".vc_atm-message").remove(),this.remove()},clear:function(e){e&&e.preventDefault&&e.preventDefault(),confirm(window.i18nLocaleVcAutomapper.are_you_sure_delete)&&(this.model.destroy(),this.close())}})).extend({template_html:s("#vc_automapper-form-tpl").html(),getType:function(){return"edit"},initialize:function(){_.bindAll(this,"setPreview")},render:function(){var e=this.model.view,t=(this.model.get("params"),o.__super__.render.call(this),vc.template(this.template_html,vc.templateOptions.custom));return this.$el.html(t(_.extend({shortcode_preview:this.getPreview(this.model.toJSON())},this.model.toJSON()))),this.$el.appendTo(e.$editForm()),e.$widgetTitle().html('<span class="vc_atm-header"><input type="text" name="name" value="" id="vc_atm-header-name" class="vc_header-name"></span><span class="in-widget-title"></span>'),s("#vc_atm-header-name").val(this.model.get("name")),this.addAllParams(),e.$editForm().slideDown(),s(".edit-form-info").initializeTooltips(".vc_wrapper"),this},save:function(e){e&&e.preventDefault&&e.preventDefault(),this.model.view.beforeSave(),p.__super__.save.call(this)},close:function(e){e&&e.preventDefault&&e.preventDefault(),vc_am.current_form=!1,this.model.view.close()},clear:function(e){e&&e.preventDefault&&e.preventDefault(),confirm(window.i18nLocaleVcAutomapper.are_you_sure_delete)&&(this.model.view.clear(),this.remove())}}),d=Backbone.View.extend({events:{"click #vc_automapper-add-btn":"create",submit:"formSubmit"},className:"vc_atm-form",addFormView:!1,initialize:function(){this.listenTo(vc_am.shortcodes,"add",this.addOne),this.listenTo(vc_am.shortcodes,"reset",this.addAll),this.listenTo(vc_am.shortcodes,"all",this.render),this.$list=s(".vc_automapper-list"),vc_am.shortcodes.fetch()},formSubmit:function(e){e&&e.preventDefault&&e.preventDefault(),_.isObject(e)&&this.addFormView&&!_.isEmpty(e.currentTarget)&&!_.isEmpty(e.currentTarget[0])&&(e=e.currentTarget[0],s(e).is("#vc_atm-shortcode-string"))&&this.addFormView.parseShortcode()},addAll:function(e){e.each(function(e){this.addOne(e)},this)},addOne:function(e){e=new l({model:e});this.$list.append(e.render().el)},create:function(e){e&&e.preventDefault&&e.preventDefault(),vc_am.current_form&&"create"===vc_am.current_form.getType()||(this.addFormView=(new v).render())},render:function(){}});i.length&&new d({el:i})})(window.jQuery);