!function(t){t((function(){var e="",c=window.location.href,n=void 0!==document.title?document.title:"",o=0,_={};function a(){localStorage.getItem("ht_ctc_storage")&&(_=localStorage.getItem("ht_ctc_storage"),_=JSON.parse(_))}function r(t){return!!_[t]&&_[t]}function i(t,e){a(),_[t]=e;var c=JSON.stringify(_);localStorage.setItem("ht_ctc_storage",c)}a();var s="";!function(){if("undefined"!=typeof ht_ctc_chat_var)s=ht_ctc_chat_var;else try{if(document.querySelector(".ht_ctc_chat_data")){var e=t(".ht_ctc_chat_data").attr("data-settings");s=JSON.parse(e)}}catch(t){s={}}}();var l,d,u,g,f={};function h(e){var c="",n=e+"_data";if(void 0!==window[e])c=window[e];else try{if(document.querySelector("."+n)){var o=t("."+n).attr("data-settings");c=JSON.parse(o)}}catch(t){c={}}return t("."+n).remove(),c}function m(t){var e=s.chat_number&&""!==s.chat_number?s.chat_number:s.number;try{var o;(o=(t=(t=(t=t.replace("{number}",e)).replace("{title}",n)).replace("{url}",c)).match(/\[\[(.*?)\]\]/g))&&o.forEach((e=>{var c,n,o=e.replace("[[","").replace("]]","");t=t.replace(e,(c=o,2==(n=("; "+document.cookie).split("; "+c+"=")).length?n.pop().split(";").shift():""))})),(o=t.match(/\[(.*?)\]/g))&&o.forEach((e=>{var c=e.replace("[","").replace("]","");t=t.replace(e,function(t){var e=window.location.href;t=t.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+t+"(=([^&#]*)|&|#|$)").exec(e);return c&&c[2]?decodeURIComponent(c[2].replace(/\+/g," ")):""}(c))}))}catch(t){}return t}function p(){var t=new Date,e=t.getTime()+6e4*t.getTimezoneOffset(),c=parseFloat(s.tz);return new Date(e+36e5*c)}"undefined"!=typeof ht_ctc_variables?f=ht_ctc_variables:(f={},setTimeout((()=>{f="undefined"!=typeof ht_ctc_variables?ht_ctc_variables:{}}),2e3)),document.dispatchEvent(new CustomEvent("ht_ctc_pro_init",{detail:{ht_ctc_storage:_,ctc_setItem:i,ctc_getItem:r}})),l=t(".ht_ctc_multi_agent"),d=h("ht_ctc_multi_agent_main"),u="yes",l.each((function(e,c){var n=h(t(c).attr("data-key")),o=p().getDay();"0"==o&&(o=7);var _=[];for(e=o;e<=7;e++)_.push(e);if(7!==_.length){var a=7-_.length;for(e=1;e<=a;e++)_.push(e)}var r="yes";if(n.timings&&"always"==n.timings)r="yes";else if(n.timings&&"set"==n.timings)if(n.time_sets){r="no";var i=n.time_sets,s=b(),l=1;i.forEach((t=>{t.stm<=s&&s<=t.etm&&1==l&&(r="yes",l++)}))}else r="no",u="no";function g(e){var o=t(c);t(c).css({order:"1"}),o.find(".g_multi_box").css({opacity:"0.5"}),o.find(".ctc_g_agent_tags").css({color:"unset"}),"nochat"==e&&t(c).css({"pointer-events":"none"});var _=function(){var t="";if(n.time_sets){var e=b(),c=n.time_sets,o="",_=1;if(c.forEach((t=>{e<=t.stm&&1==_&&(o=t.stm,_++)})),""==o){var a=10080-e;next_week_start_minute=c[0].stm,r=a+next_week_start_minute}else var r=o-e;(t=r)<60?t=(t=Math.round(t))+" "+(t<2?d.ctc_minute:d.ctc_minutes):24>(t/=60)?t=(t=Math.round(t))+" "+(t<2?d.ctc_hour:d.ctc_hours):(t/=24,t=(t=Math.round(t))+" "+(t<2?d.ctc_day:d.ctc_days))}return t}();"no"!==u&&(o.find(".ctc_g_agent_tags .ctc_agent_next_time").append(_),o.find(".ctc_g_agent_tags .ctc_agent_next_time").css({display:"flex"}))}"no"==r&&d.agent_offline&&("chat"==d.agent_offline?g("chat"):"nochat"==d.agent_offline?g("nochat"):c.remove())})),g_hook_v=s.hook_v?s.hook_v:"",g_hook_url=s.hook_url?s.hook_url:"",document.addEventListener("ht_ctc_event_number",(function(e){try{if((s=e.detail.ctc).r_nums&&s.r_nums[0])if(void 0===s.r_sqx||""===s.r_sqx||isNaN(s.r_sqx)){var c=s.r_nums,n=Math.floor(Math.random()*c.length);s.number=c[n]}else{var o=s.r_nums.length,_=s.r_sqx;_>=o&&(_=0);var a=s.r_nums[_];s.number=a,_>=o&&(_=0),s.r_sqx=_,function(e){try{void 0===s.r_sqx||isNaN(s.r_sqx)||t.ajax({url:s.ajaxurl,method:"POST",data:{action:"ctc_pro_update_r_sqx",r_sqx:e,nonce:s.nonce},success:function(t){try{t.success&&(s.r_sqx=Number(e))}catch(t){}},error:function(t,e,c){}})}catch(t){}}(++_)}}catch(t){}})),function(){try{if(!s.r_sqx)return;if(0!==o)return;o++,t.ajax({url:s.ajaxurl,method:"POST",data:{action:"ctc_pro_get_r_sqx",nonce:s.nonce},success:function(t){try{t.success?s.r_sqx=t.data:s.r_sqx=""}catch(t){s.r_sqx=""}},error:function(t,e,c){s.r_sqx=""}})}catch(t){s.r_sqx=""}}(),t(document).on("click",".ht_ctc_chat_greetings_for_forum_link",(function(e){t(".ht_ctc_chat_greetings_forum_link").trigger("click");var c=document.getElementById("ctc_pro_greetings_form");c&&!1===c.checkValidity()&&t("#ctc_pro_greetings_form [type=checkbox][required]:not(:checked)").closest("div").fadeOut("1").fadeIn("1")})),document.querySelector("#ctc_opt_g_form")&&(t("#ctc_opt_g_form").on("change",(function(e){t("#ctc_opt_g_form").is(":checked")&&(t(".ctc_opt_g_form").hide(500),i("g_optin","y"))})),r("g_optin")?(t("#ctc_opt_g_form").prop("checked",!0),t(".ctc_opt_g_form").hide()):t("#ctc_opt_g_form").prop("required",!0)),document.querySelector(".ht_ctc_g_form_field_hidden")&&t(".ht_ctc_g_form_field_hidden").each((function(e,c){var n=t(c).val();n=m(n),t(c).val(n)})),t(document).on("click",".ht_ctc_chat_greetings_box_link_multi",(function(e){function c(){var e=t(".ctc_g_content").attr("data-agentstyle");if("card-1"==e?t(".ctc_g_content").css({padding:"4px 0px","background-color":"#f8f8f8"}):"7_1"==e&&t(".ctc_g_content").css({padding:"4px 0px 8px 0px"}),t(".ctc_g_sentbutton").hide(),"card-1"==e){var c=t(".ctc_g_message_box");t(c).removeClass("ctc_g_message_box"),t(c).css({"background-color":"","text-align":"inherit",padding:"4px 0px"}),t(".ctc_g_heading_for_main_content").append(c)}else"7_1"==e&&t(".ctc_g_message_box").css({"background-color":"","text-align":"center",padding:"4px 0px"});t(".ctc_g_agents").slideToggle("slow",(function(){}))}e.preventDefault(),document.querySelector("#ctc_opt_multi")?t("#ctc_opt_multi").is(":checked")||r("g_optin")?c():t(".ctc_opt_in").show(400).fadeOut("1").fadeIn("1"):c(),document.querySelector("#ctc_opt_multi")&&t("#ctc_opt_multi").on("change",(function(e){t("#ctc_opt_multi").is(":checked")&&(t(".ctc_opt_in").hide(100),i("g_optin","y"),setTimeout((()=>{c()}),500))}))})),document.querySelector(".add_ctc_chat")&&((t("#ctc_opt_multi").is(":checked")||r("g_optin"))&&t(".add_ctc_chat").addClass("ctc_chat").removeClass("add_ctc_chat"),t(document).on("click",".add_ctc_chat",(function(e){t(".ctc_opt_in").show(400).fadeOut("1").fadeIn("1")})),t("#ctc_opt_multi").on("change",(function(e){t("#ctc_opt_multi").is(":checked")&&(t(".ctc_opt_in").hide(100),i("g_optin","y"),t(".add_ctc_chat").addClass("ctc_chat").removeClass("add_ctc_chat"))}))),g="no",t(document).on("submit",".ctc_pro_greetings_form",(function(e){if(e.preventDefault(),"yes"!=g){g="yes",setTimeout((()=>{g="no"}),2500),function(){try{t(".ctc_g_its_checkbox").each((function(){t(this).is(":checked")&&t(this).siblings(['type="hidden"']).prop("disabled",!0)}))}catch(t){}}();var o=t(".ctc_pro_greetings_form").find(".ht_ctc_g_form_field").serializeArray(),_=s.pre_filled;!function(){if(!document.querySelector(".ctc_g_field_add_to_prefilled"))return"";var e=s.pre_filled,c=t(".ctc_pro_greetings_form").find(".ctc_g_field_add_to_prefilled").serializeArray(),n="\n";for(var o of c.values()){var _=o.name,a=".ctc_pro_greetings_form [name='"+_+"']",r=_;t(a)[0].hasAttribute("data-name")&&(r=t(a).attr("data-name"));var i=o.value;""!==i&&(n+=r+": "+i+"\n")}e+=n,s.pre_filled=e}(),t(".ht_ctc_chat_greetings_forum_link").addClass("ht_ctc_chat_greetings_box_link"),setTimeout((()=>{t(".ht_ctc_chat_greetings_box_link").trigger("click")}),20),setTimeout((()=>{t(".ht_ctc_chat_greetings_forum_link").removeClass("ht_ctc_chat_greetings_box_link"),s.pre_filled=_}),500),function(e){s.ajaxurl&&s.g1_form_email&&function(e){var c=t(".ctc_g_form_keys #ht_ctc_pro_greetings_nonce").val();t.ajax({url:s.ajaxurl,type:"POST",data:{action:"ctc_pro_greetings_form",form_data:e,nonce:c},success:function(t){},error:function(t){}})}(e),s.g1_form_webhook&&function(e){var o=s.g1_form_webhook,_={};for(var a of e.values()){var r=a.name,i=a.value;_[r]=i}decoded_url=x(c),_.ctc_page_url=decoded_url;var l=p();if(_.ctc_wp_date=l.toDateString(),_.ctc_wp_time=l.getHours()+":"+l.getMinutes()+":"+l.getSeconds(),_.ctc_page_title=n,s.webhook_format&&"json"==s.webhook_format)var d=_;else d=JSON.stringify(_);t.ajax({url:o,type:"POST",mode:"no-cors",data:d,success:function(t){},error:function(t){}})}(e)}(o),function(){try{t(".ctc_g_hidden_for_checkbox").each((function(){t(this).prop("disabled",!1)}))}catch(t){}}()}})),document.addEventListener("ht_ctc_event_hook",(function(t){s=t.detail.ctc,number=s.chat_number&&""!==s.chat_number?s.chat_number:t.detail.number;var e=p(),n=e.toDateString()+", "+e.getHours()+":"+e.getMinutes()+":"+e.getSeconds();if(s.hook_url){var o=s.hook_url?s.hook_url:"";if(decoded_url=x(c),o=m(o=(o=o.replace(/\{url}/gi,decoded_url)).replace(/\{time}/gi,n)),s.hook_v){hook_values=g_hook_v;var _={},a=1;hook_values.forEach((t=>{t=m(t=(t=t.replace(/\{url}/gi,decoded_url)).replace(/\{time}/gi,n)),_["value"+a]=t,a++})),s.hook_url=o,s.hook_v=_}}})),document.addEventListener("ht_ctc_event_display",(function(c){if(s=c.detail.ctc,online_content=c.detail.online_content,s.display_user_base&&(e=function(c){e="no";var n=(s=c.detail.ctc).display_user_base?s.display_user_base:"",o="logged_out";return document.querySelector("body").classList.contains("logged-in")&&(o="logged_in"),"logged_in"==n?"logged_in"==o?e="yes":s.ajaxurl&&t.ajax({url:s.ajaxurl,data:{action:"ctc_pro_is_user_logged_in"},success:function(t){"yes"==t.data&&(e="yes")}}):"logged_out"==n&&"logged_out"==o&&(e="yes"),e}(c)),"no"!==e)if(f.display_countries_list&&f.display_countries_list.length>0){document.dispatchEvent(new CustomEvent("ht_ctc_event_display_country_base",{detail:{ctc:s,ctc_setItem:i,ctc_getItem:r}}));var n=0,o=setInterval((()=>{n++,f.country_code&&(f.country_code.length>0&&(e=f.display_countries_list.includes(f.country_code)?"yes":"no"),clearInterval(o),_()),n>40&&(clearInterval(o),_())}),200)}else _();function _(){"no"!==e&&function(e){s=e.detail.ctc,display_chat=e.detail.display_chat,ht_ctc_chat=e.detail.ht_ctc_chat;var c="",n=s.bh,o=(y.getDay(),y.getHours()),_=y.getMinutes();if("always"==n)c="yes";else if("timebase"==n){var a=y.getDay();"0"==a&&(a=7);var r="d"+a;if(s[r]){var i=r+"_et";if(s[l=r+"_st"]&&s[i]){var l=s[l],d=(i=s[i],l.split(":")),u=i.split(":"),g=d[0],f=d[1],h=u[0],m=u[1];g<=o&&o<=h?(c="yes",g==o?f>_&&(c="no"):o==h&&_>m&&(c="no")):c="no"}else c="yes"}else c="no"}function p(){""!==s.timedelay||""!==s.scroll?(""!==s.timedelay&&setTimeout((()=>{display_chat(ht_ctc_chat)}),1e3*s.timedelay),""!==s.scroll&&window.addEventListener("scroll",(function t(){var e=document.documentElement,c=document.body,n="scrollTop",o="scrollHeight";(e[n]||c[n])/((e[o]||c[o])-e.clientHeight)*100>=s.scroll&&(display_chat(ht_ctc_chat),window.removeEventListener("scroll",t))}),!1)):display_chat(ht_ctc_chat)}function v(){if(document.querySelector(".ctc_woo_schedule")){var e=t(".ctc_woo_schedule").attr("data-dt");t(".ctc_woo_schedule").css("display",e)}}"yes"==c?(p(),v(),"undefined"!=typeof online_content&&online_content()):"no"==c&&(s.off_cta&&(t(".ht-ctc-chat .ctc_cta").text(s.off_cta),t(".ctc_chat.ctc_woo_schedule .ctc_cta").text(s.off_cta)),s.off_num&&(s.number=s.off_num,s.r_nums=""),s.off_hide||(p(),v()),t(".for_greetings_header_image_badge").length&&(s.offline_badge_color&&(t(".for_greetings_header_image_badge").addClass("g_header_badge_online"),t(".g_header_badge_online").css("background-color",s.offline_badge_color)),t(".for_greetings_header_image_badge").show()))}(c)}})),document.addEventListener("ht_ctc_event_after_chat_displayed",(function(t){if(s=t.detail.ctc,greetings_open=t.detail.greetings_open,greetings_close=t.detail.greetings_close,s.g_no_reopen&&"user_closed"==r("g_user_action"));else if(s.g_time_action&&setTimeout((()=>{greetings_open("time_action")}),1e3*s.g_time_action),s.g_scroll_action){window.addEventListener("scroll",(function t(){var e=document.documentElement,c=document.body,n="scrollTop",o="scrollHeight";(e[n]||c[n])/((e[o]||c[o])-e.clientHeight)*100>=s.g_scroll_action&&(greetings_open("scroll_action"),window.removeEventListener("scroll",t))}),!1)}if(document.querySelector(".ctc_greetings_now")&&"IntersectionObserver"in window){var e=window.innerHeight/4*-1;e=parseInt(e),rm=e+"px",rm=String(rm);var c=new IntersectionObserver((function(t){t.forEach((t=>{t.isIntersecting&&(greetings_open("now"),c.unobserve(t.target))}))}),{rootMargin:rm});document.querySelectorAll(".ctc_greetings_now").forEach((t=>{c.observe(t,{subtree:!0,childList:!0})}))}})),document.addEventListener("ht_ctc_event_apply_variables",(function(t){v=t.detail.v,v=m(v),window.apply_variables_value=v})),document.addEventListener("ht_ctc_event_analytics",(function(e){var o=s.chat_number&&""!==s.chat_number?s.chat_number:s.number;if(s.gads_conversation){var _=window.dataLayer;if("object"==typeof _){"undefined"==typeof gtag&&(window.gtag=function(){_.push(arguments)});var a=s.gads_conversation,r={};r.send_to=a,f.g_ads_params&&f.g_ads_params.forEach((t=>{if(f[t]){var e=f[t],c=e.key,n=e.value;c=m(c),n=m(n),r[c]=n}})),gtag("event","conversion",r)}}var i=s.nonce?s.nonce:"";s.fb_conversion&&t.ajax({url:s.ajaxurl,data:{action:"ctc_pro_capi",url:c,title:n,number:o,nonce:i},type:"POST",success:function(t){},error:function(t){}})})),document.querySelector(".ht_ctc_chat_greetings_box_layout")&&t(".ht_ctc_chat_greetings_box_layout").css("background-color","unset");var y=p();function b(){var t=p(),e=t.getDay();return"0"==e&&(e=7),60*(24*(e-1)+t.getHours())+t.getMinutes()}function x(t){new_value=t;try{new_value=decodeURI(t)}catch(t){}return new_value}b()}))}(jQuery);