!function(i,o,r,a){"use strict";var n;a=i.extend({settings:null,is_mobile:!!navigator.userAgent.match(/Android|iPhone|BlackBerry|IEMobile|Opera Mini/i),can_qr:o.QrCreator&&"function"==typeof QrCreator.render},a),(o.joinchat_obj=a).send_event=function(e){var t,n,a,s;(e=i.extend({event_category:"JoinChat",event_label:"",event_action:"",chat_channel:"whatsapp",chat_id:"--",is_mobile:this.is_mobile?"yes":"no",page_location:location.href,page_title:r.title||"no title"},e)).event_label=e.event_label||e.link||"",e.event_action=e.event_action||e.chat_channel+": "+e.chat_id,delete e.link,!1!==i(r).triggerHandler("joinchat:event",[e])&&(t=o[this.settings.data_layer]||o[o.gtm4wp_datalayer_name]||o.dataLayer,"function"==typeof gtag&&"object"==typeof t&&(n=this.settings.ga_event||"generate_lead",a=i.extend({transport_type:"beacon"},e),i.each(a,function(e,t){"page_location"==e?a[e]=t.substring(0,1e3):"page_referrer"==e?a[e]=t.substring(0,420):"page_title"==e?a[e]=t.substring(0,300):"string"==typeof t&&(a[e]=t.substring(0,100))}),t.forEach(function(e){"config"==e[0]&&e[1]&&"G-"==e[1].substring(0,2)&&(a.send_to=e[1],gtag("event",n,a))}),this.settings.gads)&>ag("event","conversion",{send_to:this.settings.gads}),s=e.event_category,delete e.event_category,"object"==typeof t&&t.push(i.extend({event:s},e)),"function"==typeof fbq)&&fbq("trackCustom",s,e)},a.whatsapp_link=function(e,t,n){return t=void 0!==t?t:this.settings.message_send||"",((n=void 0!==n?n:this.settings.whatsapp_web&&!this.is_mobile)?"https://web.whatsapp.com/send?phone=":"https://wa.me/")+encodeURIComponent(e||this.settings.telephone)+(t?(n?"&text=":"?text=")+encodeURIComponent(t):"")},a.open_whatsapp=function(e,t){e=e||this.settings.telephone,t=void 0!==t?t:this.settings.message_send||"";e={link:this.whatsapp_link(e,t),chat_channel:"whatsapp",chat_id:e,chat_message:t},t=new RegExp("^https?://(wa.me|(api|web|chat).whatsapp.com|"+location.hostname.replace(".",".")+")/.*","i");!1!==i(r).triggerHandler("joinchat:open",[e])&&(t.test(e.link)?(this.send_event(e),o.open(e.link,"joinchat","noopener")):console.error("Joinchat: the link doesn't seem safe, it must point to the current domain or whatsapp.com"))},a.qr=function(e,t){var n=r.createElement("CANVAS");return QrCreator.render(i.extend({text:e,radius:.4,background:"#FFF",size:200},a.settings.qr||{},t||{}),n),n},i(r).on("click",'.joinchat_open, .joinchat_app, a[href="#joinchat"], a[href="#whatsapp"]',function(e){e.preventDefault(),a.open_whatsapp(i(this).data("phone"),i(this).data("message"))}),a.can_qr&&!a.is_mobile?i(".joinchat-button__qr").each(function(){i(this).append(a.qr(a.whatsapp_link(i(this).data("phone"),i(this).data("message"),!1)))}):i(".wp-block-joinchat-button figure").remove(),a.settings&&void 0!==a.settings.sku&&(n=a.settings.message_send,i("form.variations_form").on("found_variation reset_data",function(e,t){t=t&&t.sku||a.settings.sku;a.settings.message_send=n.replace(/.*<\/sku>/g,t)}))}(jQuery,window,document,window.joinchat_obj||{});