PageSourceSearch

https://www.gourmet-xchange-capitaland.com/wp-content/cache/min/1/widget.js?ver=1772425318

js gourmet-xchange-capitaland.com collected 2026-10-08 22:59:38 UTC 76,617 bytes, 51 lines download raw bytes

1(function(){"use strict";class n{static widgetID;static userID;static widgetData;static appContainer;static frameContainer;static triggerContainer;static chatwayLauncherIcon;static chatwayCloseIcon;static iconToggler;static agents=null;static included=null;static previewText=null;static status="online";static unReadCount=0;static pageTitle="";static fallbackAvatar="https://prod-chaty-uploads.s3.us-west-2.amazonaws.com/npgRZqDneIU48ejuo2VR9TK13Lu40mnVdoOGA59Jj3P5VgT140758.svg";static agentMessage=null;static hasAlreadyLoaded=!1;static token="";static isChatInitialized="";static visibilityHourTimezone="";static visibilityHours=[];static isWidgetVisible=!1;static widgetTriggers={is_trigger_enabled:!1,has_display_after_time:!1,display_after_time:0,has_display_page_scroll:!1,display_page_scroll:0,widget_id:""};static pageRules;static isHideChatwayIcon=!1;static previewTextBubbleDelay=0;static chatContactId="";static shopifyCustomerId="";static isVerifiedVisitor=!1;static widgets=[];static browserData={ip:"",loc:""};static aiAssistant=null}const oe=(a,e,t)=>{const i=new Date;i.setTime(i.getTime()+t*24*60*60*1e3);let s="expires="+i.toUTCString();document.cookie=a+"="+e+";"+s+";path=/;SameSite=None;Secure"},J=a=>{let e=a+"=",t=document.cookie.split(";");for(let i=0;i<t.length;i++){let s=t[i];for(;s.charAt(0)==" ";)s=s.substring(1);if(s.indexOf(e)==0)return s.substring(e.length,s.length)}return""},W=a=>{document.cookie=a+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;SameSite=None;Secure",document.cookie=a+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;domain=.chatway.app;Secure;SameSite=None"},O=(a,e)=>{try{localStorage.setItem(a,e)}catch(t){console.error("Error setting localStorage for key:",a,t)}},ee=a=>{try{return localStorage.getItem(a)||""}catch(e){return console.error("Error getting localStorage for key:",a,e),""}},j=a=>{try{localStorage.removeItem(a)}catch(e){console.error("Error removing localStorage for key:",a,e)}},K=a=>{const e=ee(a),t=J(a);return e?(t&&W(a),e):t?(O(a,t),W(a),t):""},S=()=>window.matchMedia("(max-width: 600px)").matches,q=(a,e)=>{const t=document.querySelector(`#${a}`);if(t){const i=t.src;return new URL(i).searchParams.get(e)||null}else return re("chatway.app",e)},re=(a,e)=>{const t=document.getElementsByTagName("script");for(let i=0;i<t.length;i++){let s=t[i].src;if(s&&s.includes(a))return new URL(s).searchParams.get(e)||null}return null},ce=(a,e,t)=>{let i,s,o=!1;if(a){const r=a.split(/\s+/);for(s=0;s<r.length;s+=1)new RegExp(`\\b${r[s]}\\b`,"g"),i=new RegExp(` *${r[s]}\\b`,"g"),t.className=t.className.replace(i,"")}return o},E=(a,e)=>{e&&(a.className+=` ${e}`)},b=(a,e)=>{ce(e,"remove",a)},g=a=>document.querySelector(a),G=a=>document.querySelectorAll(a),de=()=>{const a=document.createElement("link");a.rel="stylesheet",a.href="https://cdn.chatway.app/sdk.css",a.id="chatway-widget-css",document.head.appendChild(a)},z=(a,e)=>{switch(a){case"s":return 44;case"m":return 60;case"l":return 70;case"xl":return 84;case"xxl":return 94;case"custom":return e?Number(e):60;default:return 60}},te=a=>[{color:"#0446DE",hex:"#0446DE"},{color:"linear-gradient(100.96deg, #43cea2 0%, #185a9d 100%), #414141",hex:"#185A9D"},{color:"#282D3E",hex:"#282D3E"},{color:"linear-gradient(101.04deg, #56CCF2 0.59%, #2F80ED 100%), #7E8E9C",hex:"#2F80ED"},{color:"linear-gradient(101.04deg, #00317A 0.59%, #001F4F 100%)",hex:"#001F4F"},{color:"linear-gradient(100.96deg, #5E3D86 0%, #2F164D 100%), #537EE1",hex:"#2F164D"},{color:"linear-gradient(180deg, #F69D01 0%, #F65901 100%)",hex:"#F65901"},{color:"linear-gradient(100.96deg, #6A3093 0%, #A044FF 100%), #3B9488",hex:"#A044FF"},{color:"linear-gradient(100.96deg, #E96443 0%, #904E95 100%), #5BB055",hex:"#904E95"}].find(e=>e.color.includes(a))?.hex||a,le=(a=100)=>new Promise(e=>setTimeout(e,a)),he=()=>{const a=document.activeElement;a&&a.blur()},ge=()=>{const a=document.querySelector("body"),e=window.getComputedStyle(a),t=window.scrollY;sessionStorage.setItem("_bdyF",e.getPropertyValue("overflow")),sessionStorage.setItem("_scrollY",t.toString()),document.body.style.position="fixed",document.body.style.top=`-${t}px`,document.body.style.width="100%",document.body.style.overflow="hidden"},ue=()=>{const a=sessionStorage.getItem("_bdyF")||"auto",e=sessionStorage.getItem("_scrollY");document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow=a,e&&window.scrollTo(0,parseInt(e)),sessionStorage.removeItem("_bdyF"),sessionStorage.removeItem("_scrollY")},we=a=>{const e=window.location.search;return new URLSearchParams(e).get(a)},pe=a=>a.trim().split(`
2`).reduce(function(e,t){return t=t.split("="),e[t[0]]=t[1],e},{}),ie=()=>
2window.Shopify?"shopify":window.wpChatwaySettings?"wordpress":document.querySelector("meta[name='generator']")?.getAttribute("content")?.toLowerCase().includes("wix")?"wix":ye()?"duda":"",Z=()=>ie()==="shopify",V=()=>window.location.origin,D=a=>a?a.replace(/^(https?:\/\/)?(www\.)?/,"").replace(/:\d+$/,"").replace(/\/$/,""):"",R=a=>!a||a==="/"?"/":a.replace(/^\/|\/$/g,""),H=()=>{const a=n.widgetData;return!a.is_separate_device_preference&&a.device_appearance==="both"?"desktop":S()?"mobile":"desktop"},me=()=>window.Shopify?fe(window.Shopify.theme.schema_name):"",fe=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"");function ye(){const a=window.dmAPI||window.DM||window.duda,e=Array.from(document.scripts).some(s=>/duda|dmcdn|dudamobile/i.test(s.src)),t=document.querySelector('meta[name="generator"][content*="Duda"]'),i=document.querySelector("[data-dm-page-id], .dmRespRow");return!!(a||e||t||i)}var h=(a=>(a.widgetToggle="widget.toggle",a.widgetLoaded="widget.loaded",a.widgetMetaData="widget.metadata",a.agentStatusChange="agent.status.change",a.unreadMessage="messages.unread",a.locationChange="location.change",a.agentMessaged="agent.messages.received",a.visitorConversationStarted="visitor.conversation.started",a.loadImage="load.image",a.newVisitorNotification="new.visitor.notification",a.removeImage="remove.image",a.nextImage="next.image",a.prevImage="prev.image",a.profileData="profile.data",a.chatHistory="chat.history",a.focusEvent="focus.event",a.widgetReload="widget.reload",a.widgetDestroy="widget.destroy",a.customData="custom.data",a.removeToken="remove.token",a.chatContactLoaded="chat.contact.loaded",a.customerDataLoaded="customer.data.loaded",a.setVisitorEmail="set.visitor.email",a.setChatwaySettings="set.chatway.settings",a.openContactChannel="open.contact.channel",a.copyToClipboard="copy.to.clipboard",a.widgetDisable="widget.disable",a.aiAssistantLoaded="ai.assistant.loaded",a.pageVisitAutomationTrigger="page.visit.trigger",a.liveChatWidgetIsOpenedAutomationTrigger="live.chat.widget.is.opened.trigger",a.hasConversation="conversation.exist",a.showQuickReplies="show.quick.replies",a.hideQuickReplies="hide.quick.replies",a.quickReplyPositionUpdate="quick.reply.position.update",a.themeUpdate="theme.update",a.previewClosed="preview.closed",a.showPreviewText="show.preview.text",a.hidePreviewText="hide.preview.text",a.showUnreadMessage="show.unread.message",a.widgetExpand="widget.expand",a))(h||{});class w{constructor(){}getSessionToken(){return K(`ch_cw_token_${n.widgetID}`)||n.token||""}setSessionToken(e){O(`ch_cw_token_${n.widgetID}`,e)}getChatInitStatus(){return K(`ch_cw_status_${n.widgetID}`)||n.isChatInitialized||"false"}setChatInitStatus(e){O(`ch_cw_status_${n.widgetID}`,e)}setWidgetStatus(e){const t=this.getUserConfig();t.widgetStatus=e?"open":"close",this.setUserConfig(t)}setTextBubbleStatus(e){const t=this.getUserConfig();t.hasOpenedTextBubble=e,this.setUserConfig(t)}setShowAttentionEffect(e){oe(`ch_cw_shw_atn_efct_${n.widgetID}`,e?"true":"false",1)}getShowAttentionEffect(){return J(`ch_cw_shw_atn_efct_${n.widgetID}`)!=="false"}getUserConfig(){return JSON.parse(sessionStorage.getItem(`ch_session_info_${n.widgetID}`)||"{}")}setUserConfig(e){sessionStorage.setItem(`ch_session_info_${n.widgetID}`,JSON.stringify(e))}deleteUserConfig(){const e=n.widgetID;sessionStorage.removeItem(`ch_session_info_${e}`),sessionStorage.removeItem(`ch_cw_status_${e}`),sessionStorage.removeItem(`ch_cw_token_${e}`),sessionStorage.removeItem(`ch_cw_quick_reply_${e}`),j(`ch_cw_status_${e}`),j(`ch_cw_token_${e}`),W(`ch_cw_status_${e}`),W(`ch_cw_token_${e}`)}setBubbleExpiration(){let e={data:"false",expireTime:Date.now()+36e5};localStorage.setItem("showTextBubble",JSON.stringify(e))}get wasWidgetOpen(){return this.getUserConfig().widgetStatus==="open"}get hasShownTextBubble(){return!!this.getUserConfig().hasOpenedTextBubble}get showTextBubble(){const e=localStorage.getItem("showTextBubble");if(e){let t=JSON.parse(e);return t.expireTime<=Date.now()?(localStorage.removeItem("showTextBubble"),null):t.data?t.data:"true"}return null}}class C{widgetData;iframeLoadHandler;constructor(){this.widgetData=n.widgetData}
2getCalculatedWidgetHeight(e){const t=window.innerHeight,i=704,s=400,o=t-e-104,r=Math.max(s,o);return Math.min(r,i)}async makeAppContainer(){let e;if(e=document.getElementsByTagName("body")[0],e||(await new Promise(r=>setTimeout(r,1e3)),e=document.body),!e)return;const t=document.createElement("div");t.classList.add("chatway--container"),t.classList.add("disable--widget");const i=document.createElement("div");i.classList.add("chatway--frame-container"),i.classList.add("chatway--chat--widget--container");const s=document.createElement("div");s.classList.add("chatway--trigger-container");const o=me();if(o){const r=`theme-${o}`;i.classList.add("shopify-theme",r),s.classList.add("shopify-theme",r)}if(t.appendChild(i),t.appendChild(s),this.widgetData.default_state=="opened"&&!localStorage.getItem("showTextBubble")&&!S()&&(t.classList.add("widget--open"),e&&e.classList.add("chatway-is-open")),this.widgetData.position=="left"&&t.classList.add("widget--left"),this.widgetData.position=="custom"){this.widgetData.custom_position_side=="left"&&t.classList.add("widget--left");const r=this.getCalculatedWidgetHeight(this.widgetData.bottom_spacing),c=document.createElement("style");c.innerHTML="@media screen and (min-width: 601px) { .custom-position-widget-height .chatway--frame-container{ height: min("+r+"px,100% - 104px); }}",document.head.appendChild(c),t.classList.add("custom-position-widget-height")}return e.appendChild(t),t}makeTriggerContainer(){const e=g(".chatway--trigger-container"),t=document.createElement("div");t.id="chatway_widget_trigger",t.classList.add("chatway--trigger-icon-container");const i=z(this.widgetData.widget_size,this.widgetData.custom_widget_size);return t.style.width=`${i}px`,t.style.height=`${i}px`,this.setPosition(e),e.appendChild(t),t}makeFrameContainer(){const e=n.widgetID,i=`https://widget.chatway.app/?userId=${n.userID}&widgetId=${e}&bg-color=${this.widgetData.widget_color}`;if(g(".chatway--widget-frame"))return null;const s=g(".chatway--frame-container"),o=document.createElement("iframe");return o.classList.add("chatway--widget-frame"),o.src=i,o.id="chatway_widget_app",o.title="Live chat widget",this.iframeLoadHandler=()=>{o.focus()},this.setPosition(s),s.appendChild(o),s}setPosition(e){const t=z(this.widgetData.widget_size,this.widgetData.custom_widget_size),i=10,s=20,o=10;let r=this.widgetData.bottom_spacing;if(e.classList.contains("chatway--frame-container"))if(this.widgetData.position=="custom"){r=t+i+Number(this.widgetData.bottom_spacing);const d=this.getCalculatedWidgetHeight(r),l=r+d;if(l>window.innerHeight){const u=l-window.innerHeight+o;r=r-u}}else r=t+i+s;if(e.classList.contains("chatway--trigger-container"))if(this.widgetData.position=="custom"){r=Number(this.widgetData.bottom_spacing);const d=this.getCalculatedWidgetHeight(r),l=r+d;if(l>window.innerHeight){const u=l-window.innerHeight;r=r-u-t-s}}else r=s;const c=window.innerWidth;if(this.widgetData.position=="custom"){e.style.left="unset",e.style.right="unset";let d=this.widgetData.side_spacing;if(c>=480){const l=c-420;d>l&&(d=l)}else{const l=c-70;d>l&&(d=l)}d<0&&(d=0),this.widgetData.custom_position_side=="left"?e.style.left=`${d}px`:e.style.right=`${d}px`}e.classList.contains("chatway--frame-container")&&c<=600&&(e.style.left="unset",e.style.right="unset"),e.style.bottom=`${r}px`}destroyAppContainer(){const e=g(".chatway--container"),t=document.getElementById("chatway_widget_app");t&&this.iframeLoadHandler&&(t.removeEventListener("load",this.iframeLoadHandler),this.iframeLoadHandler=void 0),e?.remove()}get isWidgetVisible(){return n.appContainer?.classList.contains("widget--open")}focusIframe(){const e=document.getElementById("chatway_widget_app");if(e)if(e.contentDocument||e.contentWindow)e.focus();else{const t=()=>{e.focus()};e.addEventListener("load",t,{once:!0})}}}class _{static isPreviewShown=!1;getPreviewData(){const e=n.widgetData,t=H(),i=e.device_preferences[t];return{agents:n.agents||[],previewText:n.previewText,status:n.status,widgetData:{avatar_border_color:e.avatar_border_color,header_text_color:e.header_text_color,chat_font_type:e.chat_font_type,is_preview_text_enabled:e.is_preview_text_enabled,widget_color:e.widget_color},preferences:{position:i?.position,custom_position_side:i?.custom_position_side,side_spacing:i?.side_spacing,bottom_spacing:i?.bottom_spacing,hide_automated_message_when_all_agent_offline:i?.hide_automated_message_when_all_agent_offline,show_quick_responses:i?.show_quick_responses,quick_responses:i?.quick_responses||[],is_enabled_reply_textbox:i?.is_enabled_reply_textbox,is_preview_text_enabled:i?.is_preview_text_enabled,preview_text_bubble_delay:i?.preview_text_bubble_delay},hasQuickReplies:this.hasQuickReplies()}}hasQuickReplies(){const e=n.widgetData,t=H(),i=e.device_preferences[t];return!!(i?.show_quick_responses&&i.quick_responses?.length>0||i?.is_enabled_reply_textbox)}showPreviewInIframe(){if(new C().isWidgetVisible||new w().showTextBubble==="false")return;const i=n.widgetData,s=H(),o=i.device_preferences[s];if(!this.shouldShowPreviewText(o))return;const r=this.getPreviewData(),c=new m;
2this.showIframeContainer(),c.dispatchEvent(h.showPreviewText,JSON.stringify(r)),_.isPreviewShown=!0}showUnreadMessageInIframe(){!n.agentMessage||new C().isWidgetVisible||(this.showIframeContainer(),_.isPreviewShown=!0)}showIframeContainer(){const e=g(".chatway--frame-container"),t=n.appContainer;if(!e||!t)return;e.classList.remove("chatway--chat--widget--container"),e.classList.remove("chatway--preview--only--container"),e.classList.remove("chatway--quick--reply--container");const i=n.widgetData.position==="custom",s=z(n.widgetData.widget_size,n.widgetData.custom_widget_size),o=20,r=10;let c;if(i){const d=Number(n.widgetData.bottom_spacing)||0;c=s+r+d}else c=s+r+o;this.hasQuickReplies()?(t.style.setProperty("--quick-reply-bottom",`${c}px`),e.classList.add("chatway--quick--reply--container"),E(t,"quick--reply--open"),b(t,"preview--open")):(t.style.setProperty("--preview-only-bottom",`${c}px`),e.classList.add("chatway--preview--only--container"),E(t,"preview--open"),b(t,"quick--reply--open"))}hideIframeContainer(){const e=g(".chatway--frame-container"),t=n.appContainer;!e||!t||(e.classList.remove("chatway--preview--only--container"),e.classList.remove("chatway--quick--reply--container"),e.classList.add("chatway--chat--widget--container"),b(t,"preview--open"),b(t,"quick--reply--open"))}hidePreview(){this.hideIframeContainer(),_.isPreviewShown=!1}get isPreviewVisible(){return _.isPreviewShown}shouldShowPreviewText(e){const t=!!(n.aiAssistant?.active||n.agents?.length||!e?.hide_automated_message_when_all_agent_offline||n.status==="online"),i=!!(n.widgetData.is_preview_text_enabled&&n.previewText);return t&&i}}class be{removePendingStatus(){const e=g("#chatway_widget_trigger");e&&e.classList.add("has-unread-message");const t=G(".Chatway-channel-link, .csaas-widget-trigger.has-chatway-channel");t&&t.forEach(i=>{i.classList.add("has-unread-message")})}updatePendingStatus(){const e=g("#chatway_widget_trigger");if(!e)return;const t=n.pageTitle,i=n.unReadCount,s=n.isWidgetVisible;!s||i==0?(document.title=t,e.classList.remove("has-unread-message")):(document.title=`(${i}) ${t}`,e.classList.add("has-unread-message")),e.setAttribute("data-unread-message",String(i));const o=G(".Chatway-channel-link, .csaas-widget-trigger.has-chatway-channel");o&&o.forEach(r=>{!s||i==0?(document.title=t,r.classList.remove("has-unread-message")):(document.title=`(${i}) ${t}`,r.classList.add("has-unread-message")),r.setAttribute("data-unread-message",String(i))})}}class M extends Event{constructor(e={}){super("urlchangeevent",{cancelable:!0,...e}),this.newURL=e.newURL,this.oldURL=e.oldURL,this.action=e.action}get[Symbol.toStringTag](){return"UrlChangeEvent"}}const Ce=window.history.pushState.bind(window.history);window.history.pushState=function(a,e,t){const i=new URL(t||"",window.location.href);window.dispatchEvent(new M({newURL:i,oldURL:A,action:"pushState"}))&&(Ce({_index:P+1,...a},e,t),U())};const se=window.history.replaceState.bind(window.history);window.history.replaceState=function(a,e,t){const i=new URL(t||"",window.location.href);window.dispatchEvent(new M({newURL:i,oldURL:A,action:"replaceState"}))&&(se({_index:P,...a},e,t),U())};let A,P;function ae(){const a=window.history.state;(!a||typeof a._index!="number")&&se({_index:window.history.length,...a},null,null)}function U(){A=new URL(window.location.href),P=window.history.state._index}ae();U();window.addEventListener("popstate",function(a){ae();const e=window.history.state._index,t=new URL(window.location);if(e===P){a.stopImmediatePropagation();return}if(!window.dispatchEvent(new M({oldURL:A,newURL:t,action:"popstate"}))){a.stopImmediatePropagation(),window.history.go(P-e);return}U()});window.addEventListener("beforeunload",function(a){if(!window.dispatchEvent(new M({oldURL:A,newURL:null,action:"beforeunload"}))){a.preventDefault();const t="o/";return a.returnValue=t,t}});class v{static currentInstance=null;src="";list=null;index=0;constructor(e){this.src=e}static fromList(e,t=0){const i=Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.trim().length>0):[];if(i.length===0){const r=new v("");return r.list=[],r.index=0,r}const s=Math.min(Math.max(t,0),i.length-1),o=new v(i[s]);return o.list=i,o.index=s,o}
2openImageViewer(){if(!this.src)return;const e=this.makeViewerContainer();document.body.appendChild(e),this.animateContainer(),v.currentInstance=this,this.addKeyboardListeners()}closeImageViewer(){g(".chatway--image-viewer-container")?.remove(),this.removeKeyboardListeners(),v.currentInstance=null}handleKeyDown=e=>{e.key==="Escape"?this.closeImageViewer():e.key==="ArrowLeft"?this.prevImage():e.key==="ArrowRight"&&this.nextImage()};addKeyboardListeners(){document.addEventListener("keydown",this.handleKeyDown)}removeKeyboardListeners(){document.removeEventListener("keydown",this.handleKeyDown)}makeViewerContainer(){const e=document.createElement("div"),t=document.createElement("div");t.classList.add("chatway--image--container");const i=this.makeImage();i.addEventListener("load",()=>{e.classList.add("chatway--image--loaded")});const s=this.makeCloseButton(),o=this.list&&this.list.length>1?this.makeThumbStrip():null,r=this.list&&this.list.length>1?this.makePrevButton():null,c=this.list&&this.list.length>1?this.makeNextButton():null;return t.appendChild(i),t.appendChild(s),r&&t.appendChild(r),c&&t.appendChild(c),o&&t.appendChild(o),e.classList.add("chatway--image-viewer-container"),e.appendChild(t),e.addEventListener("click",d=>{d.target===e&&this.closeImageViewer()}),e}makeImage(){const e=new Image;return e.src=this.src,e.classList.add("chatway--image-viewer-image"),e}makeThumbStrip(){const e=document.createElement("div");return e.classList.add("chatway--image-thumbs"),this.list?.forEach((t,i)=>{const s=document.createElement("button");s.type="button",s.classList.add("chatway--image-thumb"),i===this.index&&s.classList.add("active");const o=new Image;o.src=t,o.alt=`Image ${i+1}`,s.appendChild(o),s.addEventListener("click",()=>this.setIndex(i)),e.appendChild(s)}),e}setIndex(e){if(!this.list||e<0||e>=this.list.length)return;const t=this.list[e];if(!t)throw new Error(`Invalid image source at index ${e}`);this.index=e,this.src=t;const i=g(".chatway--image-viewer-image");i&&(i.src=this.src),document.querySelectorAll(".chatway--image-thumb").forEach((o,r)=>o.classList.toggle("active",r===e)),this.updateArrowButtons()}nextImage(){!this.list||this.index>=this.list.length-1||this.setIndex(this.index+1)}prevImage(){!this.list||this.index<=0||this.setIndex(this.index-1)}updateArrowButtons(){const e=g(".chatway--image-prev-btn"),t=g(".chatway--image-next-btn");e&&(e.style.display=this.list&&this.index>0?"flex":"none"),t&&(t.style.display=this.list&&this.index<this.list.length-1?"flex":"none")}convertStringToElement(e){return new DOMParser().parseFromString(e,"image/svg+xml").documentElement}makeCloseButton(){const e=document.createElement("a");return e.href="#",e.classList.add("dismiss--button"),e.setAttribute("aria-label","Close"),e.appendChild(this.convertStringToElement(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"  class="" style="" focusable="false" role="presentation" tabindex="-1">
3                            <path d="M12 4L4 12" stroke-linecap="round" stroke-linejoin="round"></path>
4                            <path d="M4 4L12 12" stroke-linecap="round" stroke-linejoin="round"></path>
5                        </svg>`)),e.addEventListener("click",i=>{i.preventDefault(),this.closeImageViewer()}),e}makePrevButton(){const e=document.createElement("button");return e.type="button",e.classList.add("chatway--image-nav-btn","chatway--image-prev-btn"),e.style.display=this.index>0?"flex":"none",e.setAttribute("aria-label","Previous image"),e.appendChild(this.convertStringToElement(`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
6                            <path d="M15 18L9 12L15 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
7                        </svg>`)),e.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.prevImage()}),e}makeNextButton(){const e=document.createElement("button");return e.type="button",e.classList.add("chatway--image-nav-btn","chatway--image-next-btn"),e.style.display=this.list&&this.index<this.list.length-1?"flex":"none",e.setAttribute("aria-label","Next image"),e.appendChild(this.convertStringToElement(`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
8                            <path d="M9 18L15 12L9 6" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
9                        </svg>`)),e.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.nextImage()}),e}animateContainer(){setTimeout(()=>{g(".chatway--image-viewer-container")?.classList.add("enter-active")},150)}}var X;(function(a){a.fatal="fatal",a.error="error",a.warning="warning",a.log="log",a.info="info",a.debug="debug",a.critical="critical"})(X||(X={}));const _e=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ve=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i,Se=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,$="?",Ie="X-Sentry-Auth",xe=/^(?:(\w+):)\/\/(?:([\w-]+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;function ke(a){if(!a.stack)return null;const e=[],t=a.stack.split(`
10`);let i,s;for(let o=0;o<t.length;
10++o){if(i=_e.exec(t[o]))s={filename:i[2]&&i[2].indexOf("address at ")===0?i[2].substr(11):i[2],function:i[1]||$,lineno:i[3]?+i[3]:null,colno:i[4]?+i[4]:null};else if(i=Se.exec(t[o]))s={filename:i[2],function:i[1]||$,lineno:+i[3],colno:i[4]?+i[4]:null};else if(i=ve.exec(t[o]))o===0&&!i[5]&&a.columnNumber!==void 0&&(e[0].column=a.columnNumber+1),s={filename:i[3],function:i[1]||$,lineno:i[4]?+i[4]:null,colno:i[5]?+i[5]:null};else continue;!s.function&&s.lineno&&(s.function=$),e.push(s)}return e.length?{value:ne(a),type:a.name,stacktrace:{frames:e.reverse()}}:null}function ne(a){return(a&&a.message||"No error message").split(`
11`).filter(t=>!!t)[0]}function De(a){try{const e=ke(a);if(e)return e}catch{}return{value:ne(a),type:a&&a.name,stacktrace:{frames:[]}}}function Le(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,a=>{const e=Math.random()*16|0;return(a==="x"?e:e&3|8).toString(16)})}class Ee{constructor(e){if(e&&e.dsn){const t=xe.exec(e.dsn),i=t?t.slice(1):[],s=i[5].split("/"),o=s.slice(0,-1).join("/");this.apiUrl=i[0]+"://"+i[3]+(i[4]?":"+i[4]:"")+(o?"/"+o:"")+"/api/"+s.pop()+"/store/",this.authHeader="Sentry sentry_version=7,sentry_key="+i[1]+(i[2]?",sentry_secret="+i[2]:"")}this.environment=e&&e.environment}prepare(e){return{...this.getRequestBlank(),exception:{values:[De(e)]}}}report(e){this.send(this.prepare(e))}send(e){!this.apiUrl||!e||this.createRequest(e)}createRequest(e){const t=new XMLHttpRequest;t.open("POST",this.apiUrl,!0),t.setRequestHeader("Content-type","application/json"),t.setRequestHeader(Ie,this.authHeader||""),t.send(JSON.stringify(e))}getRequestBlank(){return{platform:"javascript",event_id:Le(),sdk:{name:"micro-sentry.javascript.core",version:"0.0.0"},timestamp:Date.now()/1e3,environment:this.environment}}}function Y(a,e){return Object.prototype.toString.call(e)==="[object RegExp]"?e.test(a):typeof e=="string"?a.indexOf(e)!==-1:!1}function Te(){return window}class Q extends Ee{constructor(e,t=Te()){super(e),this.options=e,this.window=t,this.destroyed=!1,this._state={};const{plugins:i=[],beforeSend:s=l=>l,beforeBreadcrumb:o=l=>l,blacklistUrls:r=[],ignoreErrors:c=[],release:d=void 0}=this.options||{};this.plugins=i.map(l=>new l(this)),this.beforeSend=s,this.beforeBreadcrumb=o,this.blackl
11istUrls=r,this.ignoreErrors=c,this.release=d}get state(){return this._state}clearState(){this._state={}}setTags(e){return this.setKeyState("tags",{...e}),this}setTag(e,t){return this.extendState({tags:{[e]:t}}),this}setExtra(e,t){return this.extendState({extra:{[e]:t}}),this}setExtras(e){return this.setKeyState("extra",{...e}),this}setUser(e){return this.setKeyState("user",{...e}),this}clone(){const e=new Q({...this.options,plugins:[]});return e.extendState(this.state),e}withScope(e){const t=this.clone();e(t),t.destroy(),this.setBreadcrumbs(void 0)}addBreadcrumb(e){this.extendState({breadcrumbs:[{timestamp:Date.now()/1e3,...this.beforeBreadcrumb(e)}]})}setBreadcrumbs(e){this.setKeyState("breadcrumbs",e)}captureMessage(e,t){this.send({...this.getRequestBlank(),message:e,level:t})}destroy(){this.destroyed=!0,this.plugins.forEach(e=>{e.destroy&&e.destroy()})}isIgnoredError(e){return this.ignoreErrors.length?this.getPossibleEventMessages(e).some(t=>this.ignoreErrors.some(i=>Y(t,i))):!1}getRequestBlank(){return{request:{url:this.window.location.toString(),headers:{"User-Agent":this.window.navigator.userAgent}},...super.getRequestBlank(),sdk:{name:"micro-sentry.javascript.browser",version:"0.0.0"},...this.state}}send(e){this.destroyed||this.isDeniedUrl(e)||this.isIgnoredError(e)||(super.send(this.beforeSend({release:this.release,...e})),this.setBreadcrumbs(void 0))}getPossibleEventMessages(e){if(e.message)return[e.message];if(e.exception)try{const{type:t="",value:i=""}=e.exception.values&&e.exception.values[0]||{};return[`${i}`,`${t}: ${i}`]}catch{return[]}return[]}isDeniedUrl(e){if(!this.blacklistUrls.length)return!1;const t=this.getEventFilterUrl(e);
11return t?this.blacklistUrls.some(i=>Y(t,i)):!1}getEventFilterUrl(e){try{if(e.exception){const t=e.exception.values&&e.exception.values[0].stacktrace&&e.exception.values[0].stacktrace.frames;return t&&t[t.length-1].filename||null}return null}catch{return null}}extendState(e){this._state=Object.keys(e).reduce((t,i)=>{const s=this._state[i],o=Array.isArray(s)?s:null,r=e[i],c=Array.isArray(r)?r:null;return{...t,[i]:o||c?[...o||[],...c||[]]:{...typeof s!="string"?s:{},...typeof r!="string"?r:{}}}},this._state)}setKeyState(e,t){this._state[e]=t}}class y{init(){new Q({dsn:"https://830cd780e8fd7e83482ca5710da08c54@o4505458601361408.ingest.sentry.io/4506268568518656",ignoreErrors:["Failed to fetch","NetworkError when attempting to fetch resource.","Property description must be an object.","No error message","App container not found","JSON.parse: unexpected","Unexpected token","The string did not match the expected pattern."]})}logError(e){}}const k=()=>{const a="https://prod-api.chatway.app/api/widget/",e={headers:{"Content-Type":"application/json",Accept:"application/json"}};function t(c,d){return fetch(a+c,{...e,...d,method:"get"})}function i(c,d,l){return fetch(a+c,{...e,...l,body:JSON.stringify(d),method:"post"})}function s(c,d,l){return fetch(a+c,{...e,...l,body:JSON.stringify(d),method:"put"})}function o(c,d,l){return fetch(a+c,{...e,...l,body:JSON.stringify(d),method:"PATCH"})}function r(c,d,l){return fetch(a+c,{...e,...l,body:JSON.stringify(d),method:"DELETE"})}return{post:i,get:t,put:s,patch:o,delete:r}};class I{addCustomData({token:e,name:t,value:i}){return k().post("chat-contacts/custom-fields",{name:t,value:i},{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}deleteCustomData({token:e,name:t}){return k().delete("chat-contacts/custom-fields",{name:t},{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}updateEmailName({token:e,name:t,value:i}){return k().patch("chat-contacts/profile",{[t]:i},{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}deleteEmailName({token:e,name:t}){return k().patch("chat-contacts/profile",{remove:t},{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}addTag({token:e,tags:t}){return k().post("chat-contacts/tags",{tags:t},{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}deleteTag({token:e,tags:t}){return k().delete("chat-contacts/tags",{tags:t},{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}assignShopifyCustomer(e){return fetch(`${e.marketplace_origin}/apps/chatway-app-proxy/chat-contacts/${e.chat_contact_id}/assign-customer-id`,{method:"GET",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"}})}getShopifyCustomerData(e){return fetch(`${e.marketplace_origin}/apps/chatway-app-proxy/logged-in-customer-id`,{method:"GET",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"}})}saveShopifyCartData({token:e,chat_contact_id:t,cart_data:i}){return fetch(`https://prod-api.chatway.app/api/pixel/chat-contacts/${t}/cart-info`,{method:"POST",body:JSON.stringify({cart_data:i}),headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}})}sendVisitorData(e){return k().post("../notification/notify-new-visitor-on-website",e,{headers:{"Content-Type":"application/json",Accept:"application/json"}})}}class T{async updateChatwayCustomData(e,t){try{if(!e||!t)return;const i=new w().getSessionToken();if(!i)return new m().dispatchEvent(h.customData,JSON.stringify({name:e,value:t,method:"updateChatwayCustomData"}));const s=new I;if(e.toLowerCase()==="email"||e.toLowerCase()==="name"||e.toLowerCase()==="phone"){const r=await s.updateEmailName({token:i,name:e,value:t}),{data:c}=await r.json();let d;return d={email:c.attributes.email,phone:c.attributes.phone},e==="name"&&(d={...d,name:c.attributes.name}),new m().actionDispatcher(h.profileData,d),{message:"Success"}}return(await s.addCustomData({token:i,name:e,value:t})).json()}catch(i){new y().logError(i)}}getContactId(){return n.chatContactId}getContactToken(){return new w().getSessionToken()}async removeChatwayCustomData(e){try{if(!e)return;const t=new w().getSessionToken();if(!t)return new m().dispatchEvent(h.customData,JSON.stringify({name:e,method:"removeChatwayCustomData"}));const i=new I;if(e.toLowerCase()==="email"||e.toLowerCase()==="name"||e.toLowerCase()==="phone"){const o=await i.deleteEmailName({token:t,name:e}),{data:r}=await o.json();let c;return c={email:r.attributes.email,phone:r.attributes.phone},e==="name"&&(c={...c,name:"remove"}),new m().actionDispatcher(h.profileData,c),r}return(await i.deleteCustomData({token:t,name:e})).json()}catch(t){new y().logError(t)}}hideChatwayIcon(){n.isHideChatwayIcon=!0;const e=document.getElementsByClassName("chatway--trigger-icon-container")[0];if(!e)return;e.classList&&e.classList.add("hide--chatway");const t=g(".chatway--container");if(!t)return;!!n.agentMessage?t.classList.remove("hide--widget"):t.classList.add("hide--widget")}showChatwayIcon(){const e=new m;if(!(e.checkForPageRules("show")&&e.checkForPageRules("hide")))return;n.isHideChatwayIcon=!1;const i=document.getElementsByClassName("chatway--trigger-icon-container")[0];if(!i)return;i.classList&&i.classList.remove("hide--chatway");const s=g(".chatway--container");s&&s.classList.remove("hide--widget")}openChatwayWidget(){const e=document.querySelector(".chatway--container");if(!e)return;const t=e.classList.contains("widget--open"),i=e.classList.contains("disable--widget"),s=e.classList.contains("hide--widget"),o=i||s;if(e.classList.remove("disable--widget"),e.classList.remove("hide--widget"),n.isHideChatwayIcon||document.querySelector(".chatway--trigger-icon-container")?.classList.remove("hide--chatway"),t&&o){e.classList.remove("widget--open"),e.offsetHeight,requestAnimationFrame(()=>{e.classList.add("widget--open")});return}t||(o?(e.offsetHeight,requestAnimationFrame(()=>
11{new m().openWidget()})):new m().openWidget())}closeChatwayWidget(){new m().closeWidget()}isChatwayWidgetOpen(){const e=document.querySelector(".chatway--container");return e?e.classList.contains("widget--open"):!1}isChatwayLoaded(){return n.hasAlreadyLoaded}async addChatwayTags(e){try{if(!e)return;const t=new w().getSessionToken();if(!t)return new m().dispatchEvent(h.customData,JSON.stringify({tag:e,method:"addChatwayTags"}));const i=new I,s=Array.isArray(e)?e.map(r=>({name:r})):[{name:e}];return(await i.addTag({token:t,tags:s})).json()}catch(t){new y().logError(t)}}async removeChatwayTags(e){try{if(!e)return;const t=new w().getSessionToken();if(!t)return new m().dispatchEvent(h.customData,JSON.stringify({tag:e,method:"removeChatwayTags"}));const i=new I,s=Array.isArray(e)?e.map(r=>({name:r})):[{name:e}];return(await i.deleteTag({token:t,tags:s})).json()}catch(t){new y().logError(t)}}setChatwaySettings(e){if(window.chatwaySettings=e,!e?.visitor)return;const{data:t,hmac:i}=e.visitor;!t?.id&&!t?.email||!i||new m().dispatchEvent(h.setChatwaySettings,JSON.stringify(e))}}const L=new class{async assignCustomer(){if(!V()||!n.chatContactId)return;const e={chat_contact_id:n.chatContactId,marketplace_origin:V()};try{const i=await(await new I().assignShopifyCustomer(e)).json();new m().dispatchEvent(h.setVisitorEmail,JSON.stringify(i))}catch(t){console.log(t)}}isShopifyCartURL(e){if(typeof e!="string")return!1;const t=["/cart/add","/cart/change","/cart/clear","/cart/add.js","/cart/change.js","/cart/clear.js"];try{const i=e.split("/").pop();return t.includes(`/cart/${i}`)}catch{return!1}}watchCartChange(){if(!window.fetch||typeof window.fetch!="function")return;const e=window.fetch,t=this;window.fetch=function(){const i=e.apply(this,arguments);return t.isShopifyCartURL(arguments[0])&&i.then(s=>{s.clone().json().then(o=>t.saveCartData(o))}),i}}async getCartData(){if(window?.Shopify?.routes?.root)try{return await(await fetch(window.location.origin+window.Shopify.routes.root+"cart.js")).json()}catch(e){console.log(e)}}async saveCartData(e){const t=new w().getSessionToken(),i=e?.token?e:await this.getCartData();if(!t||!n.chatContactId||!i)return;const s={token:t,cart_data:i,chat_contact_id:n.chatContactId};try{await new I().saveShopifyCartData(s)}catch(o){console.error(o)}}async getCustomerData(){if(!V())return;const e={marketplace_origin:V()};try{const i=await(await new I().getShopifyCustomerData(e)).json();new m().dispatchEvent(h.customerDataLoaded,JSON.stringify(i)),n.chatContactId=i?.contact_id,n.shopifyCustomerId=i?.logged_in_customer_id}catch(t){console.log(t),new m().dispatchEvent(h.customerDataLoaded,JSON.stringify({}))}}};class m{origin="https://widget.chatway.app/";actionType="CHATWAY";appContainer;chatwayLauncherIcon;chatwayCloseIcon;frameContainer;bodyContainer;triggerContainer;iconToggler;widgetStatus=!0;originalViewport=null;currentEvaluationUrl=null;boundMessageCallback;boundUrlChangeCallback;boundIconToggleHandler;constructor(){this.appContainer=n.appContainer,this.bodyContainer=document.getElementsByTagName("body")[0]?document.getElementsByTagName("body")[0]:null,this.frameContainer=n.frameContainer,this.triggerContainer=n.triggerContainer,this.iconToggler=n.iconToggler,this.chatwayLauncherIcon=n.chatwayLauncherIcon,this.chatwayCloseIcon=n.chatwayCloseIcon,this.boundMessageCallback=this.messageCallback.bind(this),this.boundUrlChangeCallback=this.urlChangeCallback.bind(this),this.boundIconToggleHandler=()=>{this.actionDispatcher(h.widgetToggle)}}setupEvents(){window.addEventListener("message",this.boundMessageCallback,!1),window.addEventListener("urlchangeevent",this.boundUrlChangeCallback,!1)}cleanupEvents(){this.iconToggler?.removeEventListener("click",this.boundIconToggleHandler),window.removeEventListener("message",this.boundMessageCallback,!1),window.removeEventListener("urlchangeevent",this.boundUrlChangeCallback,!1)}async actionDispatcher(e,t=null){switch(e){case h.widgetToggle:this.toggleWidget();break;case h.widgetDestroy:new N().destroyApp();break;case h.widgetReload:new w().deleteUserConfig(),new N().destroyApp(),n.isChatInitialized="false",n.token="",await le(300),new N().initialize();break;case h.agentStatusChange:const i=n.previewTextBubbleDelay*1e3;setTimeout(()=>{this.toggleTextBubble({agentDetails:t,isNewMessage:!1,isStatusChange:!0})},i);break;case h.unreadMessage:this.handleUnread(t);break;case h.agentMessaged:this.handleIncomingMessage(t);break;case h.visitorConversationStarted:this.setVisitorID(t);break;case h.loadImage:this.loadImage(t);break;case h.newVisitorNotification:this.sendNewVisitorNotification(t);break;case h.removeImage:this.removeImage();break;case h.nextImage:this.nextImage();break;case h.prevImage:this.prevImage();break;case h.widgetDisable:this.toggleWidgetStatus(t);break;case h.widgetLoaded:this.sendTheme(),await this.updateSessionKeys(),this.sendChatHistoryData(),this.sendWidgetData(),this.runConfigChecks(),this.emitIconState(),Z()&&!new w().getSessionToken()&&L.getCustomerData(),this.triggerPageVisitedAutomation(),this.triggerQuickReplyVisibility(),this.checkPageRules();break;case h.profileData:this.setProfileData(t);break;case h.focusEvent:this.handleFocusEvent();break;case h.customData:this.saveCustomData(t);break;case h.removeToken:new w().deleteUserConfig();break;case h.chatContactLoaded:this.setContactData(t),this.syncWordPressData(),Z()&&(L.assignCustomer(),L.saveCartData(),L.watchCartChange(),n.isVerifiedVisitor||await L.assignCustomer(),L.getCustomerData());break;case h.openContactChannel:this.openContactChannel(t);break;case h.copyToClipboard:this.copyToClipboard(t);break;case h.aiAssistantLoaded:this.setAIAssistant(t);break;case h.hasConversation:case h.hideQuickReplies:this.hideQuickReply();break;case h.quickReplyPositionUpdate:if(g(".chatway--quick--reply--container")||g(".chatway--preview--only--container")){const o=JSON.parse(t);document.documentElement.style.setProperty("--quick-reply-height",o.height+"px"),document.documentElement.style.setProperty("--quick-reply-width",o.width+"px"),document.documentElement.style.setProperty("--quick-reply-right",o.right),document.documentElement.style.setProperty("--quick-reply-left",o.left)}break;case h.previewClosed:this.hidePreview(),this.hideQuickReply(),new w().setBubbleE
11xpiration();break;case h.hidePreviewText:this.hidePreview();break;case h.widgetExpand:this.handleWidgetExpand(t);break}}setAIAssistant(e){if(e)try{const t=JSON.parse(e);n.aiAssistant=t}catch(t){console.error("Failed to parse AI assistant data:",t)}}saveCustomData(e){if(!new w().getSessionToken()||!e)return;const s=JSON.parse(e);switch(s.method){case"updateChatwayCustomData":new T().updateChatwayCustomData(s.name,s.value);break;case"removeChatwayCustomData":new T().removeChatwayCustomData(s.name);break;case"addChatwayTags":new T().addChatwayTags(s.tag);break;case"removeChatwayTags":new T().removeChatwayTags(s.tag);break}}addIconEvent(){this.iconToggler?.addEventListener("click",this.boundIconToggleHandler)}messageCallback(e){e.data.type&&e.data.type==this.actionType&&this.actionDispatcher(e.data.action,e.data.meta)}urlChangeCallback(e){try{const t=e.oldURL?.pathname||"",i=e.newURL?.pathname||"";if(e.action=="popstate"&&S()){const s=new C().isWidgetVisible;if(t===i&&!s||!s)return;if(t===i&&s){this.closeWidget();return}e.preventDefault(),this.closeWidget(),window.history?.pushState(null,"",window.location.href)}if(e.action=="pushState"&&e.oldURL.href!=e.newURL.href){const s=h.locationChange,o={origin:e.newURL.origin,path:e.newURL.pathname};this.dispatchEvent(s,JSON.stringify(o))}if(t!==i){try{this.currentEvaluationUrl=e.newURL?.href?new URL(e.newURL.href):null}catch{this.currentEvaluationUrl=null}this.triggerPageVisitedAutomation(e.newURL?.href),this.checkPageRules(),this.currentEvaluationUrl=null}}catch(t){new y().logError(t)}}toggleWidget(){new C().isWidgetVisible?this.closeWidget():this.openWidget()}closeWidget(){if(new C().isWidgetVisible){b(this.triggerContainer,"hide--chatway-trigger-on-open"),this.restoreViewport(),b(this.appContainer,"widget--open"),b(this.bodyContainer,"chatway-is-open"),this.emitIconState(),new w().setWidgetStatus(!1),(window.innerWidth<601||sessionStorage.getItem("_bdyF"))&&ue();const t={data:"false",expireTime:Date.now()+3600*1e3};localStorage.setItem("showTextBubble",JSON.stringify(t)),window.removeEventListener("popstate",this.boundUrlChangeCallback,!1),this.dispatchWidgetStateEvent(!1)}}findAttentionEffectClass(e){const t=/\S*effect\S*/,i=e?.className.match(t);return i?i[0]:""}openWidget(){sessionStorage.getItem(`ch_quick_reply_open_${n.widgetID}`)==="true"&&this.hideQuickReply();const t=new _;t.isPreviewVisible&&t.hidePreview(),S()&&this.setupViewport();const i=new C().isWidgetVisible,s=document.getElementsByClassName("chatway-launcher")?document.getElementsByClassName("chatway-launcher")[0]:null;if(s&&this.findAttentionEffectClass(s)&&(s.classList&&s.classList.remove(this.findAttentionEffectClass(s)),new w().setShowAttentionEffect(!1)),window.history?.pushState({page:"widget"},"",window.location.href),window.addEventListener("popstate",this.boundUrlChangeCallback,!1),!i){const o=g(".chatway--frame-container");o.classList.remove("chatway--preview--only--container"),o.classList.remove("chatway--quick--reply--container"),o.classList.add("chatway--chat--widget--container"),b(this.appContainer,"preview--open"),b(this.appContainer,"quick--reply--open"),E(this.appContainer,"widget--open"),E(this.bodyContainer,"chatway-is-open"),he(),window.innerWidth<=601&&ge(),this.emitIconState(),new w().setWidgetStatus(!0),new w().setBubbleExpiration(),new C().focusIframe(),S()&&E(this.triggerContainer,"hide--chatway-trigger-on-open"),this.dispatchWidgetStateEvent(!0)}this.triggerLiveChatWidgetIsOpenedAutomation()}emitIconState(){if(this.appContainer){const e=h.widgetToggle,t=new C().isWidgetVisible;let i={isOpen:!1};t&&(i.isOpen=!0),this.dispatchEvent(e,JSON.stringify(i))}}syncWordPressData(){window?.syncChatwayData&&window.syncChatwayData()}sendChatHistoryData(){const e=we("res_chtwy_cht");if(e){const t=h.chatHistory,i={res_chtwy_cht:e};this.dispatchEvent(t,JSON.stringify(i))}}sendWidgetData(){const e=n.widgetData,t=new w,i={"bg-color":e.widget_color,"icon-color":te(e.widget_color),isMobileDevice:S(),userId:n.userID,widgetId:n.widgetID,origin:location.origin,marketplace:ie(),path:location.pathname,agents:this.getIncludedDataByWidget(),previewText:n.previewText,token:t.getSessionToken(),isChatInitialized:t.getChatInitStatus(),chatwaySettings:window.chatwaySettings,visitorStatus:this.checkForVisitorStatus(),wpUserInfo:window?.wpChatwaySettings,...e};this.dispatchEvent(h.widgetLoaded,JSON.stringify(i))}checkForVisitorStatus(){const e=ee(`ch_visitor_id_${n.userID}`);return e?JSON.parse(e)?.expireTime>Date.now()?!1:(j(`ch_visitor_id_${n.userID}`),!0):!0}getIncludedDataByWidget(){return!n.included||!n.widgetID?[]:n.included.filter(e=>e.type=="agents"||e.attributes.widget_id===n.widgetID)}runConfigChecks(){if(S()){this.closeWidget();return}new w().wasWidgetOpen&&this.toggleWidget()}dispatchEvent(e,t=null){try{const i=g("#chatway_widget_app"),s={type:"CHATWAY",action:e,meta:t};if(!i||i.contentWindow===null)return;i.contentWindow?.postMessage(s,"*")}catch(i){new y().logError(i)}}toggleTextBubble(e){const t=new w,i=JSON.parse(e.agentDetails);if(n.agents=i,!n.widgetData.is_preview_text_enabled||t.showTextBubble==="false"&&!e.isNewMessage||n.isHideChatwayIcon&&e.isStatusChange)return;n.status=i?.some(o=>o.attributes.online_status.toLowerCase()==="online")?"online":"offline",new _().showPreviewInIframe(),t.setTextBubbleStatus(!0)}handleUnread(e){const t=JSON.parse(e);n.unReadCount=parseInt(t.count),new be().updatePendingStatus()}handleIncomingMessage(e){n.agentMessage=JSON.parse(e);const t=JSON.stringify(n.agents),i=n.widgetID;if(JSON.parse(sessionStorage.getItem(`ch_session_info_${i}`)||"{}")?.widgetStatus!=="open"&&this.toggleTextBubble({agentDetails:t,isNewMessage:!0,isStatusChange:!1}),!(this.checkForPageRules("show")&&this.checkForPageRules("hide")))return;new _().showUnreadMessageInIframe(),this.toggleWidgetVisibility(!0)}ensurePreviewVisible(){if(new w().showTextBubble==="false")return;n.isHideChatwayIcon&&this.toggleWidgetVisibility(!0);const t=g(".chatway--preview-container");t?.classList.contains("hide--chatway")&&t.classList.remove("hide--chatway")}setVisitorID(e){const t=JSON.parse(e),i=new w;n.token=t.token,n.isChatInitialized=t.isChatInitialized,i.setSessionToken(t.token),i.setChatInitStatus(t.isChatInitialized),this.addConversationStartedEvent(t.isChatInitialized),window?.syncChatwayData&&window.syncChatwayData()}addConversationStartedEvent(e){typeof window.$chatwayConversationStarted=="function"&&window.$chatwayConversationStarted({isChatInitialized:e})}setContactData(e){if(!e)return;const t=JSON.parse(e);n.chatContactId=t.contactId,n.isVerifiedVisitor=t.isVerified}setProfileData(e){const t=h.profileData;this.dispatchEvent(t,JSON.stringify(e))}async updateSessionKeys(){return new Promise((e,t)=>
11{try{const i=n.userID,s=new w,o=`ch_cw_token_${i}`,r=sessionStorage.getItem(o);r&&!s.getSessionToken()&&s.setSessionToken(r),sessionStorage.removeItem(o);const c=`ch_cw_status_${i}`,d=sessionStorage.getItem(c);d&&!s.getChatInitStatus()&&s.setChatInitStatus(d),sessionStorage.removeItem(c),J(`ch_cw_shw_atn_efct_${i}`)&&(s.setShowAttentionEffect(!0),W(`ch_cw_shw_atn_efct_${i}`)),sessionStorage.getItem(`ch_session_info_${i}`)&&(s.setUserConfig(JSON.parse(sessionStorage.getItem(`ch_session_info_${i}`)||"{}")),sessionStorage.removeItem(`ch_session_info_${i}`)),e("Tokens updated")}catch{t("Couldn't update tokens")}})}handleFocusEvent(){this.closeWidget()}loadImage(e){try{const t=JSON.parse(e);if(t&&Array.isArray(t.list)){v.fromList(t.list,Number(t.index)||0).openImageViewer();return}new v(t.src).openImageViewer()}catch(t){new y().logError(t)}}async sendNewVisitorNotification(e){if(this.checkForVisitorStatus()&&e?.visitor_unique_id){const t={data:e.visitor_unique_id,expireTime:Date.now()+36e5};O(`ch_visitor_id_${n.userID}`,JSON.stringify(t)),await new I().sendVisitorData(e)}}removeImage(){new v("").closeImageViewer()}nextImage(){const e=v.currentInstance;e&&e.nextImage()}prevImage(){const e=v.currentInstance;e&&e.prevImage()}toggleWidgetStatus(e){this.widgetStatus=e;const t=g(".chatway--container");t&&(e?t.classList.remove("disable--widget"):t.classList.add("disable--widget"))}checkPageRules(){const e=n.pageRules;if(!e?.is_enable||!e?.rules||!e.rules.length){this.toggleWidgetVisibility(!0);return}const t=this.checkForPageRules("show"),i=this.checkForPageRules("hide"),s=t&&i;s||(n.agentMessage=null,new _().hidePreview()),this.toggleWidgetVisibility(s)}checkForPageRules(e){if(!n.pageRules)return!0;const t=this.currentEvaluationUrl||window.location,i=R(t.pathname+t.search+t.hash),s=D(t.host);let o=e==="show",r=!o,c=!1;for(const d of n.pageRules.rules){const l=D(d.domain),u=R(d.page),f=s===l,p=d.visibility==e,F=d.condition==="any-page"||d.condition==="contains"&&i.includes(u)||d.condition==="equals"&&i===u||d.condition==="start-with"&&i.startsWith(u)||d.condition==="end-with"&&i.endsWith(u)||d.condition==="homepage"&&t.pathname==="/";f&&p&&(c=!0,F&&(r=o))}return c?r:!0}toggleWidgetVisibility(e){const t=g(".chatway--container"),i=g("body");if(!t||!i)return;const s=!!n.agentMessage,o=t.classList.contains("widget--open");if(o&&!e)return;if(n.isHideChatwayIcon){s||o?(t.classList.remove("hide--widget"),i.classList.add("chatway--active")):(t.classList.add("hide--widget"),i.classList.remove("chatway--active"));return}e&&this.widgetStatus?(t.classList.remove("hide--widget"),i.classList.add("chatway--active")):(t.classList.add("hide--widget"),i.classList.remove("chatway--active"))}checkVisibilityRules(){const e=g(".chatway--container");if(!e)return;const t=n.visibilityHours;if(n.visibilityHourTimezone==null||!t.length){n.isWidgetVisible=!0,this.checkForTriggers();return}let i=!1;const s=new Date,o=new Date(s.toLocaleString("en-US",{timeZone:n.visibilityHourTimezone})),r=s.getDay(),d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][r]?.toLowerCase();for(const u of t){const f=u.is_full_day||this.timeWithinRange(o,u.start_time,u.end_time);if(u.is_custom&&u.custom_date===o.toISOString().slice(0,10)&&(i=u.is_published?f:!f,f))break;u.is_published&&u.day?.toLowerCase()===d&&f&&(i=!0)}n.isWidgetVisible=i;const l=e.classList.contains("widget--open");i?(this.checkForTriggers(),this.checkPageRules()):l||(e.style.display="none",this.toggleWidgetVisibility(!1))}displayWidget(){const e=g(".chatway--container");e!==null&&e.classList.add("has-loaded"),localStorage.setItem("isWidgetVisible","true")}checkForTriggers(){const{is_trigger_enabled:e,has_display_after_time:t,has_display_page_scroll:i,display_after_time:s,display_page_scroll:o}=n.widgetTriggers;if(this.toggleWidgetVisibility(!0),localStorage.getItem("isWidgetVisible")==="true"||!e){this.displayWidget();return}if(!t&&!i){this.displayWidget();return}t&&setTimeout(()=>this.displayWidget(),1e3*s),i&&(document.body.scrollHeight>window.innerHeight?window.onscroll=()=>{Math.ceil(window.scrollY/(document.documentElement.scrollHeight-window.innerHeight)*100)>=o&&this.displayWidget()}:this.displayWidget())}timeWithinRange(e,t,i){const s=new Date(`${e.toDateString()} ${t}`),o=new Date(`${e.toDateString()} ${i}`);return e>=s&&e<=o}openContactChannel(e){if(e)try{const{channelUrl:t,target:i}=JSON.parse(e);window.open(t,i)}catch(t){new y().logError(t)}}copyToClipboard(e){if(e)try{const{text:t}=JSON.parse(e);navigator.clipboard.writeText(t)}
11catch(t){new y().logError(t)}}evaluatePageVisitTrigger=(e,t)=>{const{page:i,rule:s,domain:o}=e;if(!t)return console.warn("Missing currentUrl in context for page visit trigger"),!1;try{t=new URL(t);const r=t.pathname,c=t.hostname;let d="";try{d=new URL(o).hostname}catch{d=o.replace(/^https?:\/\//,"").split("/")[0]}if(c!==d)return!1;switch(s){case"homepage":return r==="/"||r==="";case"contains":return t.href.includes(i);case"equals":return r===(i.startsWith("/")?i:`/${i}`);case"start-with":return r.startsWith(i);case"end-with":return r.endsWith(i);case"any-page":return!0;default:return console.warn(`Unknown page visit rule: ${s}`),!1}}catch(r){return console.error("Error evaluating page visit trigger:",r),!1}};triggerPageVisitedAutomation(e=window.location.href){const t=n.widgetData.automation_triggers?.find(s=>s.type==="website_pages_are_visited");if(!n.widgetData.has_paid_access||!t||!t.params)return;this.evaluatePageVisitTrigger(t.params,e)&&this.dispatchEvent(h.pageVisitAutomationTrigger,JSON.stringify(t))}triggerLiveChatWidgetIsOpenedAutomation(){const e=n.widgetData.automation_triggers?.find(t=>t.type==="live_chat_widget_is_opened");!n.widgetData.has_paid_access||!e||this.dispatchEvent(h.liveChatWidgetIsOpenedAutomationTrigger,JSON.stringify(e))}triggerQuickReplyVisibility(){if(g(".chatway--container")?.classList.contains("hide--widget"))return;const t=new C().isWidgetVisible,i=sessionStorage.getItem(`ch_quick_reply_open_${n.widgetID}`);if(t||i==="false")return;const s=n.widgetData;let o=H();const r=s.device_preferences[o],c=r&&r.is_preview_text_enabled&&(r.is_enabled_reply_textbox||r.show_quick_responses&&r.quick_responses?.length),d=n.previewTextBubbleDelay*1e3;if(c){const l=g(".chatway--frame-container");if(!l)return;l.classList.remove("chatway--chat--widget--container"),l.classList.remove("chatway--preview--only--container"),setTimeout(()=>{g(".chatway--container")?.classList.contains("hide--widget")||new C().isWidgetVisible||(l.classList.add("chatway--quick--reply--container"),E(this.appContainer,"quick--reply--open"),b(this.appContainer,"preview--open"),sessionStorage.setItem(`ch_quick_reply_open_${n.widgetID}`,"true"),this.dispatchEvent(h.showQuickReplies,JSON.stringify({showQuickReply:!0})))},d)}else r&&r.is_preview_text_enabled&&setTimeout(()=>{new _().showPreviewInIframe()},d)}hideQuickReply(){if(sessionStorage.getItem(`ch_quick_reply_open_${n.widgetID}`)==="false")return;const t=g(".chatway--frame-container");t&&(t.classList.remove("chatway--quick--reply--container"),t.classList.remove("chatway--preview--only--container"),t.classList.add("chatway--chat--widget--container")),b(this.appContainer,"quick--reply--open"),b(this.appContainer,"preview--open"),sessionStorage.setItem(`ch_quick_reply_open_${n.widgetID}`,"false"),this.dispatchEvent(h.hideQuickReplies,JSON.stringify({showQuickReply:!1}))}hidePreview(){new _().hidePreview()}expandedOriginalStyles=null;expandCleanupTimer=null;handleWidgetExpand(e){try{const t=typeof e=="string"?JSON.parse(e):e,i=g(".chatway--frame-container");if(!i)return;if(t?.isExpanded){this.expandCleanupTimer&&(clearTimeout(this.expandCleanupTimer),this.expandCleanupTimer=null),this.triggerContainer?.parentElement?.classList.add("chatway-trigger--behind");const s=window.innerWidth;if(s>600){this.expandedOriginalStyles||(this.expandedOriginalStyles={right:i.style.right,left:i.style.left});const o=n.widgetData,r=20,c=Math.min(688,s-40);if(o.position==="custom"){const f=o.side_spacing||0;if(o.custom_position_side==="left"){const p=s-c-r;i.style.left=`${Math.max(0,Math.min(f,p))}px`,i.style.right=""}else{const p=s-c-r;i.style.right=`${Math.max(0,Math.min(f,p))}px`,i.style.left=""}}else if(o.position==="left"){const f=parseInt(i.style.left,10)||20,p=s-c-r;f>p&&(i.style.left=`${Math.max(0,p)}px`)}else{const f=parseInt(i.style.right,10)||20,p=s-c-r;f>p&&(i.style.right=`${Math.max(0,p)}px`)}const l=(parseInt(i.style.bottom,10)||84)+20;let u=document.getElementById("chatway-expanded-style");u||(u=document.createElement("style"),u.id="chatway-expanded-style",document.head.appendChild(u)),u.textContent=`.chatway--chat--widget--container.chatway--expanded { height: calc(100vh - ${l}
11px) !important; max-height: calc(100vh - ${l}px) !important; }`}i.classList.add("chatway--expanded")}else this.triggerContainer?.parentElement?.classList.remove("chatway-trigger--behind"),this.expandedOriginalStyles&&(i.style.right=this.expandedOriginalStyles.right,i.style.left=this.expandedOriginalStyles.left,this.expandedOriginalStyles=null),i.classList.remove("chatway--expanded"),this.expandCleanupTimer=setTimeout(()=>{const s=document.getElementById("chatway-expanded-style");s&&s.remove(),this.expandCleanupTimer=null},220)}catch(t){new y().logError(t)}}sendTheme(){this.dispatchEvent(h.themeUpdate,JSON.stringify({theme:"auto"}))}setupViewport(){if(this.originalViewport!=null)return;const e=document.querySelector('meta[name="viewport"]');if(e)this.originalViewport={exists:!0,content:e.getAttribute("content")},e.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no");else{this.originalViewport={exists:!1};const t=document.createElement("meta");t.name="viewport",t.content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no",document.head.appendChild(t)}}restoreViewport(){if(!this.originalViewport)return;const e=document.querySelector('meta[name="viewport"]');if(!e){if(this.originalViewport.exists){const t=document.createElement("meta");t.name="viewport",t.content=this.originalViewport.content||"",document.head.appendChild(t)}return}this.originalViewport.exists?e.setAttribute("content",this.originalViewport.content):e.remove(),this.originalViewport=null,document.body.offsetHeight}dispatchWidgetStateEvent(e){try{const t=e?"chatwayWidgetOpened":"chatwayWidgetClosed",i=new CustomEvent(t,{detail:{isOpen:e},bubbles:!0});document.dispatchEvent(i),typeof window.$chatwayWidgetStateChange=="function"&&window.$chatwayWidgetStateChange({isOpen:e})}catch(t){console.error(t)}}}class Re{constructor(e,t,i){this.widgetIcon=e,this.widgetColor=t,this.widgetImage=i}getChatIcon(){let e=null;switch(!0){case this.widgetIcon=="chat-base":e=this.chatBase;break;case this.widgetIcon=="chat-smile":e=this.chatSmile;break;case this.widgetIcon=="chat-bubble":e=this.chatBubble;break;case this.widgetIcon=="chat-db":e=this.chatDb;break;case this.widgetIcon=="chat-image":e=this.chatImage;break;default:e="";break}return this.widgetIcon=="chat-image"?this.parseImage(e):this.convertStringToElement(e)}hasCustomImage(){return this.widgetIcon=="chat-image"}getCloseIcon(){return this.convertStringToElement(this.closeIcon)}convertStringToElement(e){const i=new DOMParser().parseFromString(e,"image/svg+xml"),s=i.querySelectorAll(".fill--element");return s.length>0&&s.forEach(o=>o.setAttribute("fill",this.widgetColor)),i.documentElement}parseImage(e){return new DOMParser().parseFromString(e,"text/html").querySelector("img")}get chatBase(){return`
12      <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
13        <path
14          fill-rule="evenodd"
15          clip-rule="evenodd"
16          d="M10.7322 5H24.5989C26.2878 5 27.71 6.42222 27.6211 8.11111V24.1111C27.6211 24.4667 27.4433 24.7334 27.1767 24.9111H26.91C26.5544 24.9111 26.4655 24.9111 26.2878 24.7333L24.5989 23.0444V12.7333C24.5989 10.1556 22.5544 8.11111 19.9766 8.11111H7.62109C7.62109 6.42222 9.04332 5 10.7322 5ZM6.11111 9.62305H19.9778C21.6667 9.62305 23.0889 11.0453 23.0889 12.7342V28.9119C23.0889 29.2675 22.9111 29.5341 22.6444 29.7119H22.3778C22.0222 29.7119 21.9333 29.7119 21.7556 29.5341L17.3111 25.0897H6.11111C4.42222 25.0897 3 23.6675 3 21.9786V12.7342C3 11.0453 4.42222 9.62305 6.11111 9.62305Z"
17          fill="currentColor"
18        />
19      </svg>
20    `}get chatBubble(){return`
21      <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
22        <path
23          d="M13.2222 5H17.9333C20.6 5 23.2667 6.06669 25.1333 8.02224C27 9.88891 28.1556 12.5556 28.1556 15.2222C28.1556 20.5556 24.0667 25 18.7333 25.4444V29.3556C18.7333 29.7111 18.5556 29.9778 18.2889 30.1556C18.1111 30.1556 18.1111 30.1556 17.9333 30.1556C17.7556 30.1556 17.4889 29.9778 17.3111 29.8L13.2222 25.3556C10.5556 25.3556 7.88888 24.2889 6.02222 22.3333C4.15555 20.3778 3 17.8 3 15.1334C3 9.53335 7.62222 5 13.2222 5ZM21.8445 16.7333C22.8222 16.7333 23.4444 16.1111 23.4444 15.1334C23.4444 14.1556 22.8222 13.5334 21.8445 13.5334C20.8667 13.5334 20.2444 14.1556 20.2444 15.1334C20.3333 16.1111 20.9556 16.7333 21.8445 16.7333ZM15.6222 16.7333C16.6 16.7333 17.2222 16.1111 17.2222 15.1334C17.2222 14.1556 16.6 13.5334 15.6222 13.5334C14.6445 13.5334 14.0222 14.1556 14.0222 15.1334C14.0222 16.1111 14.6445 16.7333 15.6222 16.7333ZM9.31112 16.7333C10.2889 16.7333 10.9111 16.1111 10.9111 15.1334C10.9111 14.1556 10.2889 13.5334 9.31112 13.5334C8.33334 13.5334 7.71113 14.1556 7.71113 15.1334C7.71113 16.1111 8.33334 16.7333 9.31112 16.7333Z"
24          fill="currentColor"
25        />
26      </svg>
27    `}get chatDb(){return`
28      <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
29        <path
30          d="M25.2891 6C27.0668 6.00009 28.5781 7.51134 28.7559 9.28906V27.4004C28.7557 27.6669 28.5779 28.0225 28.2227 28.2002H27.8662C27.5998 28.2002 27.4218 28.2001 27.2441 28.0225L22.4443 24.2227H5.28906C3.51137 24.2227 2.00015 22.8001 2 20.9336V9.28906C2 7.51128 3.4224 6 5.28906 6H25.2891ZM22.2441 15.3203C21.942 15.0372 21.4678 15.0524 21.1846 15.3545C17.72 19.0496 13.1582 18.5723 10.8984 17.749L10.4775 17.5811L10.4062 17.5537C10.0447 17.4366 9.64571 17.6096 9.48926 17.9648C9.33334 18.3199 9.47465 18.7314 9.80469 18.9189L9.87402 18.9541L10.1064 19.0518C12.6081 20.0554 18.1091 20.8267 22.2783 16.3799C22.5615 16.0778 22.546 15.6036 22.2441 15.3203ZM22.8223 12.5918C22.2936 12.4142 21.6916 12.3998 21.0254 12.5596C20.6227 12.6562 20.3742 13.0612 20.4707 13.4639C20.5676 13.8663 20.9725 14.1141 21.375 14.0176C21.8193 13.911 22.1293 13.9413 22.3447 14.0137C22.5591 14.0858 22.7339 14.2178 22.8809 14.4014C23.1549 14.7442 23.3069 15.2368 23.3662 15.6621L23.3857 15.8398L23.3965 15.916C23.4664 16.2894 23.8095 16.5576 24.1963 16.5254C24.6084 16.4905 24.915 16.1271 24.8809 15.7148C24.8302 15.108 24.6275 14.1836 24.0527 13.4648C23.7555 13.0934 23.3516 12.7697 22.8223 12.5918Z"
31          fill="currentColor"
32        />
33      </svg>
34    `}get chatSmile(){return`
35      <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
36        <path
37          d="M23.9473 4C26.7378 4 29 6.26224 29 9.05273V22.2236C28.9998 25.0139 26.7376 27.2754 23.9473 27.2754H20.8984C20.1689 27.27
3754 19.4749 27.5911 18.9951 28.1406L17.2539 30.1367C16.8554 30.5934 16.1446 30.5934 15.7461 30.1367L14.0049 28.1406C13.5251 27.5911 12.8311 27.2754 12.1016 27.2754H9.05273C6.26238 27.2754 4.00022 25.0139 4 22.2236V9.05273C4 6.26224 6.26224 4 9.05273 4H23.9473ZM12.5 18.5C11.7903 18.5 11 18.4711 11 19.0518C11.0001 21.2325 13.3347 24 16 24H17C19.6653 24 21.9999 21.2325 22 19.0518C22 18.4711 21.2097 18.5 20.5 18.5H12.5Z"
38          fill="currentColor"
39        />
40      </svg>
41    `}get chatImage(){return`<img class=""  src="${this.widgetImage}" alt="">`}get closeIcon(){return`
42      <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
43        <path
44          d="M8 12L16 20L24 12"
45          stroke="currentColor"
46          stroke-width="2.67"
47          stroke-linecap="round"
48          stroke-linejoin="round"
49        />
50      </svg>
51    `}}class We{_svgBuilder;widgetData;constructor(){this.widgetData=n.widgetData,this._svgBuilder=new Re(this.widgetData.widget_icon,te(this.widgetData.widget_color),this.widgetData.widget_icon_url)}makeIconContainer(){const e=document.createElement("div");return e.classList.add("chatway-launcher"),e.style.background=this.widgetData.widget_color,new w().getShowAttentionEffect()&&this.widgetData.default_state==="click"&&e.classList.add(this.widgetData.attention_effect+"-effect"),e}makeLauncherContainer(){const e=document.createElement("button");e.classList.add("launcher-icon"),e.classList.add("launcher-default-open-icon"),e.classList.add("launcher-default-open-animated"),e.style.color=this.getIconColor(),e.style.background=this.widgetData.widget_color;const t=this._svgBuilder.getChatIcon();t.setAttribute("aria-hidden","true");const i=document.createElement("span");return i.classList.add("sr-only"),i.innerText="Show Chatway Messenger",this._svgBuilder.hasCustomImage()&&e.classList.add("has-custom-image"),e.appendChild(t),e.appendChild(i),n.chatwayLauncherIcon=e,e}makeAnimatedContainer(){const e=document.createElement("button");e.classList.add("launcher-icon"),e.classList.add("animatedIcon"),e.style.background=this.widgetData.widget_color,e.style.color=this.getIconColor();const t=document.createElement("dotlottie-player");return t.setAttribute("src","https://lottie.host/6468be3e-a133-4b36-aba2-01a8014e8406/LoRT0NHpMO.json"),t.setAttribute("background","transparent"),t.setAttribute("speed","1"),t.setAttribute("style","width: inherit; height: inherit;"),t.setAttribute("loop","true"),t.setAttribute("autoplay","true"),e.appendChild(t),e}makeCloseContainer(){const e=document.createElement("button");e.classList.add("launcher-icon"),e.classList.add("launcher-minimize-icon"),e.style.background=this.widgetData.widget_color,e.style.color=this.getIconColor();const t=document.createElement("span");t.classList.add("sr-only"),t.innerText="Hide Chatway Messenger";const i=this._svgBuilder.getCloseIcon();return e.appendChild(i),e.appendChild(t),n.chatwayCloseIcon=e,e}makeIcon(){const e=this.makeIconContainer(),t=this.makeLauncherContainer(),i=this.makeCloseContainer();return e.appendChild(t),e.appendChild(i),e}getIconColor(){if(this.widgetData?.widget_icon_color)return this.widgetData?.widget_icon_color;const e=this.widgetData?.header_text_color;return e&&e!=="#FFFFFF"?e:this.getTextColor(this.widgetData.widget_color)}getTextColor=e=>{if(!e)return"#ffffff";let t=0,i=0,s=0;if(e.startsWith("#")){const r=e.slice(1);t=parseInt(r.slice(0,2),16),i=parseInt(r.slice(2,4),16),s=parseInt(r.slice(4,6),16)}else if(e.startsWith("rgb")){const r=e.match(/\d+/g);if(!r||r.length<3)return"#ffffff";t=parseInt(r[0]),i=parseInt(r[1]),s=parseInt(r[2])}else return"#FFFFFF";return.299*t+.587*i+.114*s>150?"#000000":"#FFFFFF"}}const Pe=a=>new Promise(function(e,t){var i=new XMLHttpRequest;i.open("GET",a,!0),typeof i.setRequestHeader=="function"&&(i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("Accept","application/json")),i.onload=function(){i.status==200?e(JSON.parse(i.responseText)):t("Error "+i.status+": "+i.statusText)},i.onerror=function(){t("Network error")},i.send()}),Ae=new class{botPatterns;headlessAgents;constructor(){this.botPatterns=["bot","crawler","spider","scraper","facebookexternalhit","facebookcatalog","twitterbot","linkedinbot","whatsapp","slackbot","discord","telegram","skype","pinterest","tumblr","reddit","quora","lighthouse","gtmetrix","pingdom","uptimerobot","statuscake","newrelic","appinsights","googlebot","bingbot","yandexbot","duckduckbot","baiduspider","sogou","exabot","konqueror","ia_archiver","ahrefsbot","semrushbot","dotbot","mj12bot","blexbot","dataprovider","dataforseo","megaindex","serpstatbot","petalbot","amazonbot","applebot","chrome-lighthouse","headlesschrome","phantomjs","selenium","puppeteer","playwright","webdriver","wget","curl","python-requests","python-urllib","go-http-client","java/","apache-httpclient","okhttp","postman","insomnia","paw/","rest-client","ruby/","perl/","php/","no
51de-fetch","axios/","got/","superagent"],this.headlessAgents=["headlesschrome","phantomjs","slimerjs","selenium","puppeteer"]}isBot(){if(window.Cypress)return!1;const e=navigator.userAgent.toLowerCase();return!!(!e||e==="0"||this.botPatterns.some(t=>e.includes(t))||this.isHeadlessBrowser())}isHeadlessBrowser(){const e=navigator.userAgent.toLowerCase();if(this.headlessAgents.some(i=>e.includes(i))||navigator.webdriver)return!0;const t=["__driver_evaluate","__webdriver_evaluate","__selenium_evaluate","__fxdriver_evaluate","_Selenium_IDE_Recorder","_WEBDRIVER_ELEM_CACHE","callSelenium","callPhantom"];for(const i of t)if(i in window)return!0;return!1}};class N{scriptId;widgetId;constructor(){}start(){this.isChatwayInstalled||Ae.isBot()||(this.setupGlobalFunctions(),this.addWindowLoadEvent())}getEcwidShopID(){let e=0;return typeof window.Ecwid=="object"&&(e=window.Ecwid.getOwnerId()),e}async initialize(){if(!n.hasAlreadyLoaded)try{if(this.setChatLoadedStatus(!0),this.removeWindowLoadEvent(),this.setIdentifiers(),!this.scriptId&&!this.widgetId)return;de(),await this.fetchWidgetData()&&(this.checkForChatyScript(),this.buildApp())}catch(e){new y().logError(e)}}addWindowLoadEvent(){document.readyState=="complete"?this.initialize():window.addEventListener&&window.addEventListener("load",()=>{this.initialize()},!0)}addChatwayLoadedEvent(){typeof window.$chatwayOnLoad=="function"&&window.$chatwayOnLoad({widgetId:n.widgetID,timestamp:Date.now()}),document.dispatchEvent(new CustomEvent("chatwayLoaded",{detail:{widgetId:n.widgetID,timestamp:Date.now()},bubbles:!0}))}removeWindowLoadEvent(){window.removeEventListener("load",this.initialize),window.removeEventListener("chatwayLoaded",this.addChatwayLoadedEvent)}setIdentifiers(){this.scriptId=q("chatway","id"),this.widgetId=q("chatway","widget_id"),!this.scriptId&&window.wpChatwaySettings?.widgetId&&(this.scriptId=window.wpChatwaySettings.widgetId),!this.scriptId&&!window.wpChatwaySettings?.widgetId&&this.getEcwidShopID()&&(this.scriptId=this.getEcwidShopID().toString()),n.userID=this.scriptId}async fetchLocationData(){try{return await(await fetch("https://www.cloudflare.com/cdn-cgi/trace",{method:"GET"})).text()}catch(e){console.log(e)}return""}async fetchWidgetData(){try{const e=await this.fetchLocationData(),t=pe(e),i=t?.ip||"",s=t?.loc||"",o=S()?1:0,r=q("chatway","id");let c="";!r&&this.getEcwidShopID()&&(c="ecwid");const d=D(window.location.hostname),l="https://prod-api.chatway.app/api/v2/pixel/widgets",u=`${!r&&this.getEcwidShopID()?"site_identifier":"user_identifier"}=${this.scriptId}&include[]=agents&include[]=faqs&ip=${i}&is_mobile=${o}&loc=${s}&channel=${c}&domain=${d}`,f=this.widgetId?`${l}/${this.widgetId}?${u}`:`${l}?${u}`,{data:p,included:F}=await Pe(f);if(!p)throw new Error(`No data returned from API for ${this.scriptId}`);if(p.attributes?.is_ch_ob==0)return!1;let x=null;if(Array.isArray(p)?p.length>1?(n.widgets=p,this.setupPushState(),x=this.getWidgetByPageRules()):p.length===1&&(x=p[0]):p&&p.attributes&&(x=p),!x||!x.attributes)return!1;const B=x.attributes;return B.is_blocked?!1:(n.included=F,n.browserData=t,this.setWidgetId(x.id),this.setWidgetData(B),this.setPageTitle(document.title),this.setVisibilityHourTimezone(B.timezone),this.setPageRules(B),this.setWidgetVisibilityHour(),this.setWidgetTriggers(),this.setDevicePreferences(),!0)}catch(e){throw new y().logError(e),e}}setupPushState(){const e=history.pushState;history.pushState=async(...t)=>{e.apply(history,t),this.handleWidgetOnPageChange()}}async handleWidgetOnPageChange(){const e=this.getWidgetByPageRules();if(!e||e.id==n.widgetID){new m().checkVisibilityRules();return}const t=e.attributes;if(t.is_blocked){await this.destroyApp();return}this.setWidgetId(e.id),this.setWidgetData(t),this.setPageTitle(document.title),this.setVisibilityHourTimezone(t.timezone),this.setPageRules(t),this.setWidgetVisibilityHour(),this.setWidgetTriggers(),this.setDevicePreferences(),await this.destroyApp(),this.setChatLoadedStatus(!0),await this.buildApp()}getWidgetByPageRules(){const e=n.widgets.reduce((s,o)=>{const{id:r,attributes:c}=o;return c.page_targeting.is_enable&&c.page_targeting.rules.length>0&&(s[r]=c.page_targeting.rules),s},{});if(!Object.values(e)?.length)return n.widgets[0];const t=this.getWidgetIdByPageRules(e);if(!t)return this.getFallbackWidget(e);const i=n.widgets.find(s=>s.id===t);return i||null}getWidgetIdByPageRules(e){for(const[t,i]of Object.entries(e)){const s=new Set(i.filter(o=>D(o.domain)==D(window.location.host)).map(o=>o.visibility));if(s.size===1){const o=[...s][0],r=i.some(c=>this.matchPageRule(c));if(o==="show"&&r||o==="hide"&&!r)return t}else{const o=i.some(c=>c.visibility==="hide"&&this.matchPageRule(c));if(i.some(c=>c.visibility==="show"&&this.matchPageRule(c))&&!o)return t}}return null}matchPageRule(e){const t=D(window.location.host);if(D(e.domain)!==t)return!1;const i=R(window.location.pathname),s=R(window.location.pathname+window.location.search+window.location.hash),o=R(e.page);switch(e.condition){case"equals":return s===o;case"any-page":return!0;case"contains":return s.includes(o);case"start-with":return s.startsWith(o);case"end-with":return s.endsWith(o);case"homepage":return i==="/";default:return!1}}getFallbackWidget(e){if(Object.entries(e).flatMap(([o,r])=>r.map(c=>({...c,widget_id:o}))).find(o=>!this.matchPageRule(o)))return null;const s=n.widgets.find(o=>!o.attributes.page_targeting.is_enable);return s||null}setWidgetId(e){n.widgetID=e}setWidgetData(e){n.widgetData={...e,browserData:n.browserData}}setPageTitle(e){n.pageTitle=e}setVisibilityHourTimezone(e){n.visibilityHourTimezone=e}setChatLoadedStatus(e){n.hasAlreadyLoaded=e}setDevicePreferences(){if(!n.included||!n.widgetID)return;const e=n.included.filter(l=>l.type==="device_preferences"&&l.attributes.widget_id===n.widgetID),t=n.widgetData,i=e.find(l=>l.attributes.is_mobile),s=e.find(l=>!l.attributes.is_mobile),o=n.included.filter(l=>l.type==="device_preference_quick_response");if(i&&s)t.device_preferences={desktop:{...s.attributes,quick_responses:o.filter(l=>!l.attributes.is_mobile).map(l=>({order_id:l.attributes.order_id,text:l.attributes.text}))},mobile:{...i.attributes,quick_responses:o.filter(l=>l.attributes.is_mobile).map(l=>({order_id:l.attributes.order_id,text:l.attributes.text}))}};else{const l={position:t?.position,custom_position_side:t?.custom_position_side,bottom_spacing:t?.bottom_spacing,side_spacing:t?.side_spacing,custom_widget_size:t?.custom_widget_size,is_preview_text_enabled:!!t?.is_preview_text_enabled,preview_text_bubble_delay:t?.preview_text_bubble_delay,preview_text:t?.preview_text,is_welcome_text_enabled:t?.is_welcome_text_enabled,widget_size:t?.widget_size,is_enabled_reply_textbox:!1,show_quick_responses:!1,hide_automated_message_when_all_agent_offline:!1,quick_responses:[]};t.device_preferences={desktop:l,mobile:l}}if(!n.widgetData)return;let r=!t.is_separate_device_preference&&t.device_appearance==="both"?"desktop":S()?"mobile":"desktop";const c=t.device_preferences[r];
51Object.keys(c).forEach(l=>{n.widgetData[l]=c[l]}),n.previewText=this.getPreviewText(t.device_preferences[r].preview_text,r),n.previewTextBubbleDelay=t.device_preferences[r].preview_text_bubble_delay}setPageRules(e){e?.has_paid_access&&e?.page_targeting?.is_enable&&e?.page_targeting?.rules.length>0?n.pageRules=e?.page_targeting:n.pageRules={is_enable:!1,rules:[]}}setWidgetTriggers(){let e={is_trigger_enabled:!1,has_display_after_time:!1,display_after_time:0,has_display_page_scroll:!1,display_page_scroll:0,widget_id:""};if(!n.included||!n.widgetID){n.widgetTriggers=e;return}n.included.forEach(t=>{t.type==="widget_trigger"&&t.attributes.widget_id===n.widgetID&&(e=t.attributes)}),n.widgetTriggers=e}setWidgetVisibilityHour(){if(!n.included||!n.widgetID){n.visibilityHours=[];return}const e=[];n.included.forEach(t=>{t.type==="widget_visibility_hour"&&t.attributes.widget_id===n.widgetID&&e.push(t.attributes)}),n.visibilityHours=e}checkForChatyScript(){if(document.getElementById("pixel-chaty")){let e=document.getElementsByTagName("body")[0]?document.getElementsByTagName("body")[0]:null;e&&e.classList.add("has--chaty")}}async buildApp(){try{const e=new C,t=await e.makeAppContainer();if(!t)throw new Error("App container not found");const i=e.makeFrameContainer();if(!i)throw new Error("Frame container not found");const s=e.makeTriggerContainer();if(!s)throw new Error("Trigger container not found");const r=new We().makeIcon();s.appendChild(r),n.appContainer=t,n.frameContainer=i,n.triggerContainer=s,n.iconToggler=r;const c=new m;c.setupEvents(),c.addIconEvent(),c.emitIconState(),c.checkVisibilityRules(),setInterval(()=>{c.checkVisibilityRules()},6e4),this.addChatwayLoadedEvent()}catch(e){new y().logError(e)}}setupGlobalFunctions(){window.$chatway=window.$chatway||new T}get isChatwayInstalled(){return window.$chatway!==void 0}async destroyApp(){const e=new m,t=new C;e.cleanupEvents(),e.closeWidget(),t.destroyAppContainer(),this.setChatLoadedStatus(!1)}getPreviewText(e,t){if(!n.included||!n.widgetID)return e;const i=n.included.filter(d=>d.type==="widget_langs"&&d.attributes.widget_id===n.widgetID);let s=navigator.language;s!=="zh-TW"&&(s=s.split("-")[0]);const o=n.included.filter(d=>d.type==="device_preferences"&&d.attributes.widget_id===n.widgetID),r=i.find(d=>d.attributes.locale===s);if(r)return r.attributes[o.length?`widget_text_bubble_${t}`:"widget_text_bubble"];const c=i.find(d=>d.attributes?.is_default);if(c){const d=c.attributes[o.length?`widget_text_bubble_${t}`:"widget_text_bubble"];return d!==e?e:d}return e}}new y().init();new N().start()})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.