(()=>{function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,s)}return n}function t(t){for(var s=1;s/g,interpolate:/<#=([\s\S]+?)#>/g,escape:/<#-([\s\S]+?)#>/g},Backbone.emulateHTTP=!0;var n=Backbone.Router.extend({routes:{"done/:api":"done","failed/:api":"failed","edit/:api(/:action)":"edit"},done:function(e){TVE_Dash.API.ConnectedAPIs.findWhere({key:e}).set("state","done")},failed:function(e){TVE_Dash.API.ToBeConnected.set({key:e,state:"error",response:{message:window.tve_dash_api_error&&"constantcontact_v3"!==e?tve_dash_api_error.message:"Failed to connect",success:!1}})},edit:function(e,t){TVE_Dash.API.ConnectedAPIs.findWhere({key:e}).set({state:"edit",customAction:t})}});TVE_Dash.API.models.Connection=Backbone.Model.extend({defaults:{state:""}}),TVE_Dash.API.models.ToBeConnected=Backbone.Model.extend({defaults:{state:"new"}}),TVE_Dash.API.models.APIType=Backbone.Model.extend({}),TVE_Dash.API.collections.APITypes=Backbone.Collection.extend({model:TVE_Dash.API.models.APIType}),TVE_Dash.API.collections.Connections=Backbone.Collection.extend({model:TVE_Dash.API.models.Connection,getAPIs:function(e){return!0!==e&&(e=!1),e=this.filter(function(t){return t.get("connected")===e}),new TVE_Dash.API.collections.Connections(e)},getByType:function(e){if(void 0===e)return this;var t=this.filter(function(t){return t.get("type")===e});return new TVE_Dash.API.collections.Connections(t)}}),TVE_Dash.API.views.Connection=Backbone.View.extend({initialize:function(){this.listenTo(this.model,"change:state",_.bind(this.renderState,this))},render:function(){return this.renderState(),this},renderState:function(){var t,n,s;return"Edit"===(t=this.model.get("state").length?this.model.get("state")[0].toUpperCase()+this.model.get("state").slice(1):"connected")&&(s=!0),(n=TVE_Dash.API.views["Connection"+t]?new TVE_Dash.API.views["Connection"+t]({model:this.model,collection:this.collection}):new TVE_Dash.API.views.ConnectionConnected({model:this.model,collection:this.collection})).render(s),this.$el.replaceWith(n.$el),this.setElement(n.$el),"zapier"===this.model.get("key")&&(TVE_Dash.bindZClip(e(".tvd-zapier-copy-key")),TVE_Dash.bindZClip(e(".tvd-zapier-copy-url"))),void 0!==this.model.attributes.credentials.api&&this.$el.addClass("api-cls-"+this.model.attributes.credentials.api),this.$el.find("select").select2(),this}}),TVE_Dash.API.views.ConnectionConnected=Backbone.View.extend({className:"tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3",events:{"click .tvd-api-edit":function(){if(this.collection.each(_.bind(function(e){e.set("state","connected")},this)),this.model.set("state","edit"),void 0!==this.model.attributes.credentials.connection){for(var t=["client_id","api_key","key","api_url","api_token","token","url","apiUsername","apiPassword","appId","kt_user","kt_password","username","password","email","app_id","account_url","client_id","client_secret","access_code","hash_key","secretkey","secret","app_secret","access_token","blog_url","domain","pixel_id","memberid"],n=0;n'+this.model.get("notification").info+""),this}}),TVE_Dash.API.views.ConnectionTest=Backbone.View.extend({className:"tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3",events:{"click .tvd-close-card":function(){this.model.set("state","connected")},"click .tvd-close-anywhere":function(){this.model.set("state","connected")}},render:function(){return this.$el.html(TVE_Dash.tpl("tvd-api-connection-hover",{text:TVE_Dash_Const.translations.Testing,color:"",icon:"tvd-no-icon"})),TVE_Dash.cardLoader(this.$el.find(".tvd-card")),this.test(),this},test:function(){var t=this,n=e.ajax({type:"post",url:ajaxurl,dataType:"json",data:{api:this.model.get("key"),action:TVE_Dash_Const.actions.api_handle_save,test:!0}});n.fail(function(){t.model.set("title","Connection Error"),t.model.set("state","connected")}),n.done(function(e){var n={};e.success?(n.text=TVE_Dash_Const.translations.ConnectionWorks,n.color="tvd-green tvd-close-anywhere",n.icon="tvd-icon-check",t.$el.html(TVE_Dash.tpl("tvd-api-connection-hover",n))):(t.model.set("response",e),t.model.set("state","error"))})}}),TVE_Dash.API.views.ConnectionError=Backbone.View.extend({className:"tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3",events:{"click .tvd-api-edit":function(){this.model.set("state","edit")},"click .tvd-close-card":function(){this.model.set("state","connected")}},render:function(){return this.$el.html(TVE_Dash.tpl("tvd-api-connection-error",{item:this.model})),this}}),TVE_Dash.API.views.ConnectionDelete=Backbone.View.extend({className:"tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3",events:{"click .tvd-api-delete-yes":"yes","click .tvd-api-delete-no":function(){this.model.set("state","connected")}},render:function(){return this.$el.html(TVE_Dash.tpl("tvd-api-confirm-delete",{item:this.model})),this},yes:function(){var t=this,n=e.ajax({type:"post",url:ajaxurl,data:{api:this.model.get("key"),action:TVE_Dash_Const.actions.api_handle_save,disconnect:!0},dataType:"json"});this.$el.find(".tvd-card").replaceWith(TVE_Dash.tpl("tvd-api-connection-hover",{text:TVE_Dash_Const.translations.Deleting,color:"tvd-red",icon:"tvd-icon-spinner mdi-pulse"})),n.fail(function(e){t.model.set("state","connected")}),n.done(function(e){e.success?(new TVE_Dash.API.models.Connection({connected:!1,key:t.model.get("key"),credentials:t.model.get("credentials"),title:t.model.get("title"),type:t.model.get("type"),logoUrl:t.model.get("logoUrl")}),window.location.reload()):t.model.set("state","connected")})}}),TVE_Dash.API.views.ConnectionDone=Backbone.View.extend({className:"tvd-col tvd-s6 tvd-ms6 tvd-m4 tvd-l3",events:{"click .tvd-api-done":function(){this.model.set("state","connected"),TVE_Dash.API.router.navigate("",{trigger:!0})}},render:function(){return this.$el.html(TVE_Dash.tpl("tvd-api-state-success",{item:this.model})),this}}),TVE_Dash.API.views.ConnectionSuccess=TVE_Dash.API.views.ConnectionDone.extend({}),TVE_Dash.API.views.NewState=Backbone.View.extend({className:"tvd-col tvd-s12 tvd-m4 tvd-l3",events:{"click .tvd-card-content":function(){this.model.set("state","select")},"click .tvd-request-api":function(e){e.stopPropagation()}},render:function(){return this.$el.html(TVE_Dash.tpl("tvd-api-state-new",{item:this.model})),this}}),TVE_Dash.API.views.HiddenState=Backbone.View.extend({render:function(){return this}}),TVE_Dash.API.views.SelectState=Backbone.View.extend({className:"tvd-col tvd-s12 tvd-m4 tvd-l3",events:{"change #selected-api":"onAPISelect"},render:function(){return this.$el.html(TVE_Dash.tpl("tvd-api-state-select",{item:this.model})),this.renderAPIsList(),this},onAPISelect:function(n){const s=e(n.target).val();if("none"===s)return;const i=TVE_Dash.API.AvailableAPIs.findWhere({key:s});this.model.set(t(t({},i.toJSON()),{},{state:"form"}))},renderAPIsList:function(){var t=this.$el.find("#selected-api");TVE_Dash.API.APITypes.each(function(n){var s=e("").attr("label",n.get("label")),i=this.collection.getAPIs(!1).getByType(n.get("type"));i.each(function(t){let n=t.get("title");"Brevo"===n&&(n="Brevo formerly SendinBlue");const i=e("