"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ThriveComments=ThriveComments||{};ThriveComments.util=ThriveComments.util||{},_.templateSettings={evaluate:/<#([\s\S]+?)#>/g,interpolate:/<#=([\s\S]+?)#>/g,escape:/<#-([\s\S]+?)#>/g},function(a){ThriveComments.util.tpl=function(b,c){var d=a("script#"+b.replace(/\//g,"-")).html()||"";return c?_.template(d)(c):_.template(d)},ThriveComments.util.nested=function(a,b){var c=this;return a instanceof Backbone.Model?this.nested(a.attributes,b):_.each(b,function(b){b.children&&(a[b.name]=c.nested(a[b.name],b.children)),_.isArray(a)?_.each(a,function(a){a[b.name]=new b.obj(a[b.name])}):a[b.name]=new b.obj(a[b.name])}),a},ThriveComments.util.validateInput=function(a,b,c){var d=a instanceof jQuery?a.val():a,e=!0;return d=d.trim(),""==d?(b||(b=ThriveComments.util.render_label("isRequired")),e=!1,a instanceof jQuery&&(a.removeClass("tcm-valid"),a.addClass("tcm-invalid"),a.prev(".tcm-error-message").show().html(b))):(a.removeClass("tcm-invalid"),a.prev(".tcm-error-message").hide(b)),e},ThriveComments.util.validateInputUrl=function(a,b,c){var d=a instanceof jQuery?a.val():a,e=!0;return void 0!=d&&0==this.isValidUrl(this.addHttp(d))?(b||(b=ThriveComments.util.render_label("isRequired")),e=!1,a instanceof jQuery&&(a.removeClass("tcm-valid"),a.addClass("tcm-invalid"),a.prev(".tcm-error-message").show().html(b))):(a.removeClass("tcm-invalid"),a.prev(".tcm-error-message").hide(b)),e},ThriveComments.util.validateStoringConsent=function(a,b){var c=a instanceof jQuery?a.is(":checked"):a,d=a.siblings(".tcm-consent-text"),e=ThriveComments.util.get_cookie("tcm_cookie_user_name"),f=!0;return""===ThriveComments.settings.storing_consent||0===ThriveComments.settings.storing_consent?f:(c||""!==e?(d.removeClass("tcm-not-selected"),a.prev(".tcm-error-message").hide(b)):(b||(b=ThriveComments.util.render_label("isRequired")),f=!1,a instanceof jQuery&&(d.removeClass("tcm-not-selected"),d.addClass("tcm-not-selected"),a.prev(".tcm-error-message").show().html(b))),f)},ThriveComments.util.validateEmail=function(a,b){var c=a.length?a.val():a;return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(c)?(a instanceof jQuery&&(a.removeClass("tcm-invalid"),a.prev(".tcm-error-message").hide()),!0):(a instanceof jQuery&&(a.removeClass("tcm-valid"),a.addClass("tcm-invalid"),a.prev(".tcm-error-message").show().html(b)),!1)},ThriveComments.util.valuesToArray=function(a){return Object.keys(a).map(function(b){return a[b]})},ThriveComments.util.set_avatar_url=function(a){a.length&&a.attr("data-src")===ThriveComments.default_author_picture_url&&this.checkGravatar(a.attr("data-email-hash")).done(function(b){a.css("background-image",'url("'+b+'")')})},ThriveComments.util.previousUser=function(){return""!==ThriveComments.util.get_cookie("social-login")||!!ThriveComments.current_user.ID||void 0},ThriveComments.util.set_cookie=function(a,b,c,d){d=d||"/",c=c||2592e3;var e,f=new Date;c=parseInt(c),f.setTime(f.getTime()+1e3*c),e=f.toUTCString(),"object"===(void 0===b?"undefined":_typeof(b))&&(b=JSON.stringify(b)),document.cookie=encodeURIComponent(a)+"="+b+";expires="+e+";path="+d},ThriveComments.util.get_cookie=function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;de&&cd[a]?1:0)*b}},ThriveComments.util.insertAtCaret=function(a,b){if(a.length){var c=a[0],d=c.scrollTop,e=0,f=c.selectionStart||"0"==c.selectionStart?"ff":!!document.selection&&"ie";if("ie"==f){c.focus();var g=document.selection.createRange();g.moveStart("character",-c.value.length),e=g.text.length}else"ff"==f&&(e=c.selectionStart);var h=c.value.substring(0,e),i=c.value.substring(e,c.value.length);if(c.value=h+b+i,e+=b.length,"ie"==f){c.focus();var j=document.selection.createRange();j.moveStart("character",-c.value.length),j.moveStart("character",e),j.moveEnd("character",0),j.select()}else"ff"==f&&(c.selectionStart=e,c.selectionEnd=e,c.focus());c.scrollTop=d}},ThriveComments.util.ajaxurl=function(a){var b=-1!==ajaxurl.indexOf("?")?"&":"?";return a&&a.length?(a=a.replace(/^(\?|&)/,""),a+="&_nonce="+ThriveComments.admin_nonce,ajaxurl+b+a):ajaxurl+b+"_nonce="+ThriveComments.admin_nonce},ThriveComments.util.toCamelCase=function(a){return a=a.replace(/_/g," "),a.toLowerCase().replace(/(?:(^.))/g,function(a){return a.charAt(a.length-1).toUpperCase()})},ThriveComments.util.formatSelection=function(a){var b=a,c=document.getElementById(b),d=void 0,e=void 0,f=void 0;if(void 0!==document.selection){c.focus();d=document.selection.createRange().text}else void 0!==c.selectionStart&&(e=c.selectionStart,f=c.selectionEnd,d=c.value.substring(e,f));return{selectedText:d,startPos:e,endPos:f}},ThriveComments.util.set_subscriber_cookies=function(a){var b=ThriveComments.util.get_cookie("subscribed_posts");if(""!==b&&(b=JSON.parse(b)),0===a){var c=b.indexOf(ThriveComments.post.ID);c>-1&&(b.splice(c,1),ThriveComments.util.set_cookie("subscribed_posts",JSON.stringify(b),31104e3))}else""===b?b=[ThriveComments.post.ID]:b.push(ThriveComments.post.ID),ThriveComments.util.set_cookie("subscribed_posts",JSON.stringify(b),31104e3)},ThriveComments.util.checkGravatar=function(b){var c=this,d=a.Deferred();if(this.gravatarCache=this.gravatarCache||{},this.gravatarCache[b])this.gravatarCache[b].success?d.resolve(this.gravatarCache[b].url):d.reject();else{var e="https://www.gravatar.com/avatar/"+b+"?s=512";a.ajax({type:"HEAD",url:e+"&d=404"}).done(function(a){c.gravatarCache[b]={url:e,success:!0},d.resolve(e)}).error(function(){c.gravatarCache[b]={url:"",success:!1},d.reject()})}return d}}(jQuery);var ThriveComments=ThriveComments||{};ThriveComments.models=ThriveComments.models||{},ThriveComments.collections=ThriveComments.collections||{},function(a){ThriveComments.models.Base=Backbone.Model.extend({idAttribute:"comment_ID",sync:function(a,b,c){var d;return c=c||{},c.cache=!1,_.isUndefined(ThriveComments.nonce)||_.isNull(ThriveComments.nonce)||(d=c.beforeSend,c.beforeSend=function(a){if(a.setRequestHeader("X-WP-Nonce",ThriveComments.nonce),d)return d.apply(this,arguments)}),Backbone.sync(a,b,c)}}),ThriveComments.collections.Base=Backbone.Collection.extend({sync:function(a,b,c){var d;return c=c||{},c.cache=!1,c.url=this.url(),_.isUndefined(ThriveComments.nonce)||_.isNull(ThriveComments.nonce)||(d=c.beforeSend,c.beforeSend=function(a){if(a.setRequestHeader("X-WP-Nonce",ThriveComments.nonce),d)return d.apply(this,arguments)}),Backbone.sync(a,b,c)}}),ThriveComments.models.Comment=ThriveComments.models.Base.extend({getCommentStatus:function(){var a="";switch(1===parseInt(this.get("tcm_featured"))&&(a="featured"),this.get("comment_approved").toString()){case"1":case"approved":a="approved";break;case"0":case"hold":a="unapproved";break;case"spam":a="spam";break;case"trash":a="trash";break;default:0===parseInt(this.get("tcm_featured"))&&(a="stop_featuring")}return a},setCommentApproved:function(){if(void 0!==this.get("status")){var a=this.get("status")===ThriveComments.const.moderation.unapprove?0:1;this.set("comment_approved",a)}},url:function(){return ThriveComments.routes.comments+"/"+ThriveComments.post.ID},isPostAuthor:function(){return this.attributes.user_id===ThriveComments.post.post_author},parse:function(a){return delete a.author,void 0===a.replace_keyword||!1===a.replace_keyword?a:(ThriveComments.settings.tcm_keywords&&ThriveComments.settings.tcm_keywords.sort(ThriveComments.util.dynamicSortByProperty("-name")),_.each(ThriveComments.settings.tcm_keywords,function(b){var c=b.name.split(", ");_.each(c,function(c){var d,e='"+c+"";var f=new RegExp("\\b"+c+"\\b(?![^<]*?<\\/a>)","gi"),g=c.length;d=a.comment_content;var h=d.match(f);_.each(h,function(a){var b=d.search(f),h=e,i=e.search(">"+c+"<")+1;h=[h.slice(0,i),a,h.slice(i+g)].join(""),d=[d.slice(0,b),h,d.slice(b+g)].join("")}),a.comment_content=d})}),a)}}),ThriveComments.collections.Comments=ThriveComments.collections.Base.extend({model:ThriveComments.models.Comment,compField:ThriveComments.sorting.sort_field,compOrder:ThriveComments.sorting.order,tcm_secret:"",commentCount:0,awaiting_moderation:0,userCommentCount:0,minCompField:null,url:function(){return ThriveComments.routes.comments+"/"+ThriveComments.post.ID},comparator:function(a){return 1===parseInt(a.get("tcm_featured"))?-1*Number.MAX_SAFE_INTEGER+this.compOrder*a.get(this.compField):this.compOrder*a.get(this.compField)},nested:function(a){var b=this;return a.children&&_.each(a.children,function(c,d){b.nested(c),a.children[d]=new ThriveComments.models.Comment(c,{parse:!0})}),a},parse:function(a){var b=this;return this.commentCount=a.count,this.userCommentCount=a.user_comment_count,a=a.comments,_.each(a,function(c,d){c.children&&c.children.length&&(a[d]=b.nested(c))}),a},insertComment:function(a,b){var c=this;_.each(a,function(d,e){if(d.get("comment_ID")===parseInt(b.get("comment_parent"))){var f=a[e].get("children");f||(f=[]),f.push(b),a[e].set("children",f)}else d.get("children")&&d.get("children").length&&c.insertComment(d.get("children"),b)})},push:function(a){this.commentCount++,0==a.get("comment_parent")?(this.models.push(a),this.length=this.length+1):this.insertComment(this.models,a)}})}(jQuery);var ThriveComments=ThriveComments||{};ThriveComments.views=ThriveComments.views||{},ThriveComments.objects=ThriveComments.objects||{},function(a){ThriveComments.views.CreateComment=Backbone.View.extend({template:ThriveComments.util.tpl("comments/create"),events:{"focus #tcm-post-content":"showMainCreateFields","click .tcm-save-btn":"saveComment","click .tcm-show-login":"showLogin","keydown .form-input":"keyAction","input textarea":"textareaSizing","click #tcm-fb-logo":"facebookLogin","click #tcm-gp-logo":"googleLogin","click .tcm-logout-label":"logout"},keyAction:function(a){13===a.keyCode&&(this.saveComment(a),a.stopPropagation())},initialize:function(a){a&&(this.viewList=a.viewList),this.comments_media_query()},comments_media_query:function(){var a=this.$el.parents("#comments");a.width()<600&&a.addClass("tcm-small")},textareaSizing:function(b){var c=b.currentTarget;a(c).css("height",1).css("height",c.scrollHeight+2)},showMainCreateFields:function(a){if(ThriveComments.util.tcm_hide_textareas(a),this.viewList.showPreviousClickedReplys(),this.$(".tcm-comment-additional-fields").slideDown(),!ThriveComments.current_user.ID){var b=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_name")).slice(1,-1).replace(/\+/g," "),c=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email")).slice(1,-1),d=JSON.parse('{ "link": "'+decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_website")).slice(1,-1)+'" }');b&&""===this.$("#tcm-guest-name").val()&&(this.$("#tcm-guest-name").val(b),this.$("#tcm-guest-email").val(c),this.$("#tcm-author-url").val(d.link),this.$("span.checkmark").click())}},render:function(b){var c=this.$("#tcm-post-content").val(),d=ThriveComments.util.get_cookie("social-login");return""!==d&&(ThriveComments.social_user=JSON.parse(d)),b=a.extend({},b,{gravatarActive:ThriveComments.settings.gravatar_active,share_individual_comments:ThriveComments.settings.share_individual_comments,comment_registration:ThriveComments.settings.comment_registration,current_user_id:void 0!==ThriveComments.current_user.ID?ThriveComments.current_user.ID:0,comment_content:void 0!==c?c:"",close_comments:ThriveComments.close_comments}),this.$el.html(this.template(b)),this.afterRender(),this},afterRender:function(){new Clipboard("#tcm-click-to-copy").on("success",function(b){var c=a(b.trigger).text(),d=a(b.trigger);d.text(ThriveComments.translations.copy_input),setTimeout(function(){d.text(c)},1e3),b.clearSelection()})},saveComment:function(b){var c=this;if(!this.validateComment())return!1;this.$("#tcm-submit-comment").text(ThriveComments.translations.comment_sending);var d=this.prepareCommentForSave();d=new ThriveComments.models.Comment(d),d.save().done(function(d){var e=new ThriveComments.models.Comment(d),f=c.$("textarea");a(".tcm-post-input-container textarea").val(""),c.$("#tcm-submit-comment").text(ThriveComments.util.render_label("submit_comment")),"trash"!==e.get("comment_approved")&&c.addNewCommentToList(b.currentTarget,e,0),c.removeCreateForm(),f.css("height",1),c.replyAndApprove(d,e),a(".tcm-reply-btn").attr("data-clicked",0),c.viewList.showPreviousClickedReplys()}).error(function(a){var b=c.handleError(a);ThriveComments.util.err(b)}).always(function(){c.$("#tcm-submit-comment").text(ThriveComments.util.render_label("submit_comment"))})},prepareCommentForSave:function(){var a,b,c,d=ThriveComments.util.get_cookie("social-login"),e=this.$("#tcm-author-url").val(),f="",g={};return""!==d?(a=JSON.parse(d),b=a.name,c=a.email,f=a.picture):(b=ThriveComments.util.previousUser()?ThriveComments.current_user.display_name:this.$("input[name='name']").val(),c=ThriveComments.util.previousUser()?ThriveComments.current_user.user_email:this.$("input[name='email']").val()),this.$(".tcm-extra-fields input").each(function(){g[this.getAttribute("name")]=this.value}),{children:[],comment_content:this.$("#tcm-post-content").val().trim(),comment_author:b,comment_author_email:c,comment_author_url:void 0!==e&&ThriveComments.util.isValidUrl(ThriveComments.util.addHttp(e))?e:"",comment_author_picture:f,comment_parent:this.$(".tcm-save-btn").attr("data-parent"),level:this.$(".tcm-save-btn").attr("data-parent")>0?Math.min(parseInt(this.$(".tcm-save-btn").attr("data-level"))+1,3):0,secret_spam:ThriveComments.secret_spam,comment_post_ID:ThriveComments.post.ID,tva_term:void 0!==ThriveComments.tva_term&&ThriveComments.tva_term,tcm_receive_notifications:this.$("#tcm_receive_notifications").prop("checked"),tcm_remember_me:this.$("#tcm_remember_me").prop("checked"),tcm_storing_consent:this.$("#tcm_storing_consent").prop("checked"),tcm_extra_fields:g}},handleError:function(a){var b="";switch(a.status){case 409:b=ThriveComments.util.render_label("comment_duplicate");break;case 429:b=ThriveComments.util.render_label("comment_flood");break;default:b=ThriveComments.util.render_label(a.responseJSON.code),""===b&&(b=a.responseJSON.code+". "+a.responseJSON.message)}return b},replyAndApprove:function(a,b){var c=b.get("comment_parent"),d=null;if(c&&b.get("is_moderator")&&(d=ThriveComments.util.search_comment(ThriveComments.objects.Comments,c))){var e={id:d.get("comment_ID")};d.set("comment_approved",1),d.set("status",1),d.save(e,{error:this.handleError})}},removeCreateForm:function(){var a=this.$(".mainInput");a.parents("div.tcm-lazy-comments").length&&this.$(".tcm-create-post-container").hide(),a.length?(a.val(""),this.$(".tcm-comment-additional-fields").hide()):this.$el.remove()},addNewCommentToList:function(b,c,d){var e=jQuery(b).closest(".tcm-comment-item"),f=this.$el.siblings(".tcm-comments-list"),g="";return!!f.first().find("div[data-comment-id="+c.get("comment_ID")+"]").length||(ThriveComments.objects.Comments.push(c),this.updateCommentCountLabel(c),g=this.insertCommentIntoPosition(b,c,e,d),g&&ThriveComments.util.showCommentConversion(g),a(window).trigger("scroll"),this)},insertCommentIntoPosition:function(b,c,d,e){var f,g=new ThriveComments.views.CommentsItem({model:c,commentsList:this.viewList});if(f=g.render().$el,!d.length){var h=a(b).closest(".tcm-create-post-container").attr("data-position");return f.addClass("tcm-main-parent"),"top"===h&&-1===ThriveComments.objects.Comments.compOrder?(this.$el.next().prepend(f),g):"bottom"!==h||1!==ThriveComments.objects.Comments.compOrder||jQuery(".tcm-loader").is(":visible")?e?(jQuery(".tcm-loader").is(":visible")&&-1!==ThriveComments.objects.Comments.compOrder||this.$el.next().prepend(f),g):(this.viewList.close(),this.viewList.pushCommentsCreated({comment_id:c.get("comment_ID"),comment_after_save:c.get("show_after_save")}),this.viewList.initDisplayComments(c.get("comment_ID")),!1):(this.$el.parent().prev().append(f),g)}return c.get("level")>2&&f.addClass("stop-nesting"),d.append(f),g},updateCommentCountLabel:function(b){"1"===b.get("comment_approved")&&a(".tcm-comments-number").text(function(a,b){return b.replace(/(\d+)/,ThriveComments.objects.Comments.commentCount)})},validateComment:function(){var a=!0;ThriveComments.util.get_cookie("social-login");return ThriveComments.util.previousUser()||(ThriveComments.util.validateInput(this.$("input[name='name']"),ThriveComments.util.render_label("author_name_required"),!0)||(a=!1),ThriveComments.util.validateEmail(this.$("input[name='email']"),ThriveComments.util.render_label("isRequired"),!0)||(a=!1),""!==this.$("#tcm-author-url").val()&&(ThriveComments.util.validateInputUrl(this.$("#tcm-author-url"),ThriveComments.translations.invalid_website_url,!0)||(a=!1)),ThriveComments.util.validateStoringConsent(this.$("#tcm_storing_consent"),ThriveComments.translations.accept_privacy_checkbox)||(a=!1)),ThriveComments.util.validateInput(this.$("#tcm-post-content"),ThriveComments.util.render_label("comment_content_missing"),!0)||(a=!1),a},showLogin:function(b){var c,d=a("#wp-auth-check"),e=a("#wp-auth-check-form"),f=a("#wp-auth-check-wrap"),g=f.find(".wp-auth-fallback-expired"),h=this,i=!1,j=jQuery(b.currentTarget).closest(".tcm-create-post-container");ThriveComments.util.position=j.data("position"),ThriveComments.util.content=j.find("textarea#tcm-post-content").val(),ThriveComments.util.afterLogin=1,ThriveComments.util.commentId=j.data("comment-id"),e.length&&(a(window).on("beforeunload.wp-auth-check",function(a){a.originalEvent.returnValue=window.authcheckL10n.beforeunload}),e.attr("data-src",e.attr("data-src").replace("members/login/","wp-login.php")),c=a('