document.addEventListener("DOMContentLoaded",(()=>{const n=document.bubbleSettings,e="https://dashboard.my-coco.ai/images/bubble",t=`${e}/whatsapp-icon.png`,o=`${e}/coco-profile.png`,i="data:image/svg+xml;utf8,"+encodeURIComponent(''),a=!n.shop_pic||/my-coco\.ai\/wp-content\//.test(n.shop_pic)?o:n.shop_pic;n.phone_number="33744900716";let s="";n.show_mobile_only&&(s+="\n @media (min-width: 768px) {\n #OJIAJ978617_coco-body {\n display: none !important;\n }\n }\n ");const d="full-coco-left"===n.tooltip_position?"left: 15px; right: auto;":"right: 15px; left: auto;",c=n.custom_css||"",r=n.disable_breathe?"":"animation: breathe 2s infinite ease-in-out;";let l=document.getElementById("OJIAJ978617_coco-body");l||(l=document.createElement("div"),l.id="OJIAJ978617_coco-body",document.body.appendChild(l));const p=`\n \n\n
\n ${n.whatsapp_message}\n ×\n
\n \n

\n
1
\n
\n\n \n `;if(l.innerHTML=p,s){const n=document.createElement("style");n.type="text/css",n.innerText=s,document.head.appendChild(n)}if(!n.show_ai_mention){const n=document.getElementById("OJIAJ978617_ai-mention");n&&(n.style.display="none")}const g={cocoBody:l,chatWidget:document.getElementById("OJIAJ978617_chat-widget-container"),whatsappIcon:document.getElementById("OJIAJ978617_whatsapp-icon"),notificationBubble:document.getElementById("OJIAJ978617_notification-bubble"),closeChat:document.getElementById("OJIAJ978617_chat-widget-close"),sendMessageButton:document.getElementById("OJIAJ978617_chat-widget-send"),messageInput:document.querySelector("#OJIAJ978617_chat-widget-footer input"),chatMessages:document.getElementById("OJIAJ978617_chat-messages"),closeAllMessages:document.getElementById("OJIAJ978617_notification-bubble-close"),notificationText:document.getElementById("OJIAJ978617_notification-bubble-text"),headerChatBox:document.getElementById("OJIAJ978617_chat-widget-header"),cartDrawer:document.querySelector(".drawer.is-empty"),poweredBy:document.getElementById("OJIAJ978617_powered-by"),messageNotification:document.getElementById("OJIAJ978617_message-notification"),chatWidgetContent:document.getElementById("OJIAJ978617_chat-widget-content")};if(setTimeout((()=>{g.cocoBody.style.display="block"}),n.delay),g.cartDrawer){new MutationObserver((n=>{n.forEach((n=>{if("class"===n.attributeName){const n=g.cartDrawer.classList.contains("active");g.cocoBody.style.display=n?"none":"block"}}))})).observe(g.cartDrawer,{attributes:!0})}function u(e){let t=n.phone_number;n.is_relayed&&(e=`@[${n.relaying_slug_name}]\n${e}`,t=n.relaying_phone_number);const o=`https://api.whatsapp.com/send/?phone=${t}&text=${encodeURIComponent(e)}`;window.open(o,"_blank")}function b(){const e=document.createElement("div");e.textContent="...",e.className="typing-indicator",g.chatMessages.appendChild(e),setTimeout((()=>{g.chatMessages.removeChild(e),function(){const e=document.createElement("div");e.textContent=n.whatsapp_message_inside,e.className="welcome-message",g.chatMessages.appendChild(e)}()}),2e3)}function m(e=!1){"block"===g.chatWidget.style.display?function(e=!1){g.chatWidget.style.display="none",g.notificationBubble.style.display="flex",localStorage.removeItem("notificationBubbleHidden"),g.chatMessages.innerHTML="",_(),n.show_notification_bubble||(g.notificationBubble.style.display="none");e&&localStorage.setItem("keepClosed","true")}(e):(g.chatWidget.style.display="block",function(n=!1){g.notificationBubble.style.display="none",n&&localStorage.setItem("notificationBubbleHidden","true")}(),b(),J&&(clearInterval(J),g.notificationText.textContent=n.whatsapp_message,J=null))}const h=window.location.href,f=n.path_filter,x=!f||function(n,e){try{return new RegExp(e).test(n)}catch(n){return console.error("Invalid regex pattern:",e),!1}}(h,f);g.notificationText.addEventListener("click",(()=>m())),g.headerChatBox.addEventListener("click",(()=>m())),g.closeAllMessages.addEventListener("click",(()=>{n.show_notification_bubble=!1,localStorage.setItem("notificationBubbleHidden","true"),g.notificationBubble.style.display="none"})),g.sendMessageButton.addEventListener("click",(()=>{const n=g.messageInput.value.trim();n&&(u(n),g.messageInput.value="")})),g.messageInput.addEventListener("keypress",(n=>{"Enter"===n.key&&(n.preventDefault(),g.sendMessageButton.click())})),n.show_notification_bubble||(g.notificationBubble.style.display="none"),g.chatWidgetContent.addEventListener("click",(n=>{if("BUTTON"===n.target.tagName){u(n.target.getAttribute("data-message"))}})),g.whatsappIcon.addEventListener("click",(()=>m()));let J=null;function _(){if(J)return;let e=1;const t=[n.whatsapp_message,n.button_one,n.button_two,n.button_three];J=setInterval((()=>{g.notificationText.textContent=t[e],e=(e+1)%t.length}),3500)}_(),x||(g.cocoBody.style.display="none",g.whatsappIcon.style.display="none",g.messageNotification&&(g.messageNotification.style.display="none"),g.notificationBubble.style.display="none")}));