var widget=function(b){var A;"use strict";const c={iframe:{width:"800",height:"600",title:"Allstate Chat",id:"va_chat_widget",app:"va_chat_container",styleId:"va_chat_style",iframeContainer:"va_chat_iframe"},logLevels:["ERROR","WARN","INFO","DEBUG"],pcfURI:"https://cdn.virtualassistant.allstate.com"},C='/*! modern-normalize v2.0.0 | MIT License | https://github.com/sindresorhus/modern-normalize */*,:after,:before{box-sizing:border-box}html{font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";line-height:1.15;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4}body{margin:0}hr{height:0;color:inherit}abbr[title]{text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}legend{padding:0}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}form {margin-block-end: 0;} ',k=(t,o,i,s)=>` .va_chat_widget { width: 100%; height: 100%; min-height: 0px; min-width: 0px; margin: 0px; padding: 0px; background-image: none; background-position: 0% 0%; background-size: initial; background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: rgba(0, 0, 0, 0); border-width: 0px; float: none; color-scheme: normal; position: absolute; inset: 0px; transition: none 0s ease 0s !important; display: block; } #va_chat_iframe{ opacity: 1; visibility: visible; z-index: 2147483639; position: fixed; bottom: ${s}px; width: ${i}px; height: ${i}px; max-width: 100%; max-height: calc(100% - 0px); min-height: 0px; min-width: 0px; background-color: transparent; border: 0px; overflow: hidden; right: 0px; transition: none 0s ease 0s !important; } .va_chat_resume { width: 99px !important; height: 99px !important; } .va_chat_open { bottom: 0px !important; width: ${o}px !important; height: ${t}px !important; } .va_widget_open { width: 800px !important; height: ${t}px !important; } `,I=`${c==null?void 0:c.pcfURI}/va_connect_sdk.js`;console.debug("[__VA_CHAT__] The chat SDK has been integrated.");const y=()=>{const t=document.getElementById(c.iframe.id);t&&(t.contentWindow.postMessage("hello","*"),t.contentWindow.__CONFIG__=window.vaChat&&window.vaChat.__CONFIG__)},N=()=>{const t=document.createElement("div");t.id="va_minimize",document.body.appendChild(t)},F=t=>{if(!t){const o=document.createElement("div");o.id=c.iframe.iframeContainer,document.body.appendChild(o)}},G=t=>{if(!document.getElementById(t||c.iframe.iframeContainer))return console.error("[__VA_CHAT__] Chat container undefined."),!1;const o=document.createElement("iframe");return o.setAttribute("style","overflow:hidden;"),o.setAttribute("scrolling","no"),o.setAttribute("id",c.iframe.id),o.setAttribute("title",c.iframe.title),o.setAttribute("name",c.iframe.title),o.setAttribute("class",c.iframe.id),o.setAttribute("data-protocol",window.location.protocol),o.setAttribute("data-url",window.location.href),document.getElementById(t||c.iframe.iframeContainer).appendChild(o),!0},T=t=>{const o=document.createElement("style");o.id=c.iframe.styleId,o.type="text/css",o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o)},L=()=>{var n;const t=document.getElementById(c.iframe.id);if(!t)return!1;const i=(t==null?void 0:t.contentDocument)||((n=t==null?void 0:t.contentWindow)==null?void 0:n.document),s=i.createElement("div");s.id=c.iframe.app,i.body.appendChild(s);const r=i.createElement("script");r.async=!1,r.type="text/javascript",r.src=I,i.body.appendChild(r);const d=i.createElement("style");d.type="text/css",d.rel="stylesheet",d.innerHTML=C,i.head.appendChild(d)},W=()=>{const t=document.getElementById(c.iframe.id);if(!t)return!1;window.setTimeout(()=>{var n;const i=(t==null?void 0:t.contentDocument)||((n=t==null?void 0:t.contentWindow)==null?void 0:n.document),s=i.createElement("div");s.id=c.iframe.app,i.body.appendChild(s);const r=i.createElement("script");r.async=!1,r.type="text/javascript",r.src=I,i.body.appendChild(r);const d=i.createElement("style");d.type="text/css",d.rel="stylesheet",d.innerHTML=C,i.head.appendChild(d)},200)},z=()=>{const t=document.getElementById(c.iframe.id);t.contentWindow&&t.contentWindow.toggleChatWindow(!0)},x=(t,o)=>{if(t&&o){const i=document.getElementById(c.iframe.id);i.contentWindow&&i.contentWindow.callOtherApi(t,o)}},P=t=>{var u,p,f,h;const o=(u=t==null?void 0:t.detail)==null?void 0:u.isChatWindowOpen,i=(p=t==null?void 0:t.detail)==null?void 0:p.webformWidgetState,s=(f=t==null?void 0:t.detail)==null?void 0:f.key,r=(h=t==null?void 0:t.detail)==null?void 0:h.isChatActive,d=window.vaChat&&window.vaChat.__CONFIG__,n=d==null?void 0:d.chatContainer,e=document.getElementById(n||c.iframe.iframeContainer);s==="chatToggle"&&(o?(e.classList.contains("va_chat_open")||e.classList.add("va_chat_open"),e.classList.remove("va_chat_resume")):(e.classList.remove("va_chat_open"),r?e.classList.contains("va_chat_resume")||e.classList.add("va_chat_resume"):e.classList.remove("va_chat_resume"))),s==="webformToggle"&&(i?e.classList.contains("va_widget_open")||e.classList.add("va_widget_open"):e.classList.remove("va_widget_open"))};var M=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function B(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var O={exports:{}};(function(t,o){(function(i,s){t.exports=s()})(M,function(){function i(a,l){var _=window.matchMedia(a);l(_.matches);var S=function(){return l(_.matches)};return _.addListener(S),function(){return _.removeListener(S)}}function s(a,l){return e[a]!==l&&(e[a]=l,p(a,l),!0)}var r=typeof navigator<"u"&&typeof window<"u";if(r&&typeof nw<"u")try{nw.Window.get()}catch{r=!1}var d=!r,n=r?navigator.userAgent:void 0,e={gui:r,terminal:d,registerQuery:i};e.node=typeof process<"u"&&!!process.versions&&!!process.versions.node,e.pwa=e.gui&&window.matchMedia("(display-mode: standalone)").matches&&document.head.querySelector('[rel="manifest"]')!==null,e.uwp=typeof Windows<"u"&&typeof MSApp<"u",e.nwjs=!(!e.node||!process.versions.nw),e.electron=!(!e.node||!process.versions.electron),e.cordova=!(!e.gui||!window.cordova),e.packaged=e.uwp||e.nwjs||e.electron||e.cordova,e.web=!e.node&&!e.packaged,e.browser=e.web,e.website=e.web&&!e.pwa,e.worker=!e.gui&&typeof self<"u"&&self.importScripts!==void 0,e.serviceWorker=e.worker&&!!navigator.serviceWorker.controller||!1,e.android=!!e.gui&&n.includes("Android"),e.chromeos=!!e.gui&&n.includes("CrOS"),e.tizen=!!e.gui&&n.includes("Tizen"),e.ios=e.gui&&/iPad|iPhone|iPod/.test(n)&&!window.MSStream||!1,e.linuxBased=e.android||e.tizen,e.windows=e.node?process.platform==="win32":n.includes("Windows"),e.macos=e.node?process.platform==="darwin":n.includes("Macintosh"),e.linux=e.node?process.platform==="linux":n.includes("Linux")&&!e.linuxBased&&!e.macos,e.edgeHtml=e.gui&&n.includes("Edge/"),e.edgeChromium=e.gui&&n.includes("Edg/"),e.edgeAndroid=e.gui&&n.includes("EdgA/"),e.edgeIos=e.gui&&n.includes("EdgiOS/"),e.chromeIos=e.gui&&n.includes("CriOS/"),e.firefoxIos=e.gui&&n.includes("FxiOS/"),e.edge=e.edgeHtml||e.edgeChromium||e.edgeAndroid||e.edgeIos,e.samsungBrowser=e.gui&&n.includes("SamsungBrowser/"),e.opera=e.gui&&(n.includes("Opera")||n.includes("OPR/")),e.firefox=e.gui&&(n.includes("Firefox")||e.firefoxIos),e.chrome=e.gui&&(n.includes("Chrome")||e.chromeIos)&&!e.edge&&!e.opera&&!e.samsungBrowser,e.safari=e.gui&&n.includes("Safari")&&!e.chrome&&!e.edge&&!e.firefox&&!e.opera&&!e.samsungBrowser||e.edgeIos||e.chromeIos||e.firefoxIos,e.ie=e.trident=e.gui&&n.includes("Trident"),e.blink=e.chrome&&!e.chromeIos||e.edgeChromium||e.edgeAndroid||e.samsungBrowser,e.webkit=e.blink||e.safari,e.gecko=e.firefox&&!e.firefoxIos&&!e.webkit&&!e.safari;var u={};e.on=function(a,l){u[a]=u[a]||new Set,u[a].add(l)},e.off=e.removeListener=function(a,l){u[a]&&u[a].delete(l)};var p=e.emit=function(a,l){u[a]&&u[a].forEach(function(_){return _(l)})};if(e.gui){e.pixelRatio=parseFloat(window.devicePixelRatio.toFixed(2)),e.gameconsole=n.includes("Xbox")||n.includes("PlayStation");var f=0;if(window.addEventListener("gamepadconnected",function(a){return f++}),window.addEventListener("gamepaddisconnected",function(a){return f--}),e.gameconsole)e.gamepad=!0,e.mouse=!0,e.touch=!1,e.tv=!0,e.battery=!1,e.phone=e.tablet=e.hybrid=e.laptop=e.desktop=!1,e.formfactor="gameconsole";else{var h=function(){s("tv",e.formfactor==="tv"),s("phone",e.formfactor==="phone"),s("tablet",e.formfactor==="tablet"),s("hybrid",e.formfactor==="hybrid"),s("laptop",e.formfactor==="laptop"),s("desktop",e.formfactor==="desktop")},g=function(){var a=Math.min(window.screen.width,window.screen.height);return e.tv?"tv":e.touch&&a<600?"phone":e.touch&&!e.mouse?"tablet":e.touch&&e.mouse?"hybrid":e.battery?"laptop":"desktop"};e.touch=navigator.maxTouchPoints>0,e.tv=n.includes("TV"),f=navigator.getGamepads?Array.from(navigator.getGamepads()).filter(function(a){return a!=null}).length:0,e.gamepad=f>0,i("(orientation: portrait)",function(a){e.portrait=a,e.landscape=!a,e.orientation=a?"portrait":"landscape",p("portrait",e.portrait),p("landscape",e.landscape),p("orientation",e.orientation)}),i("(any-pointer: coarse)",function(a){s("touch",a),s("formfactor",g())&&h()}),i("(hover: hover)",function(a){s("mouse",a),s("input",a?"mouse":"touch"),s("formfactor",g())&&h()})}}return e.csp=e.uwp||!1,e.nwjs?e.dev=process.versions["nw-flavor"]==="sdk":e.electron?e.dev=process.execPath.replace(/\\/g,"/").includes("node_modules/electron/"):e.uwp?e.dev=Windows.ApplicationModel.Package.current.isDevelopmentMode:e.node?e.dev=!1:e.dev=void 0,e})})(O);var D=O.exports;const v=B(D),m="[__VA_CHAT__]",w=(t,...o)=>o.find(i=>!!t[i]),E={va_browser:w(v,"chrome","safari","edge","ie","firefox","samsungBrowser","edgeIos","edgeAndroid","firefoxIos","chromeIos"),va_os:w(v,"windows","android","chromeos","macos","ios","tizen","linux","linuxBased"),va_device:w(v,"phone","tablet","hybrid","laptop","desktop","tv","gameconsole")},j=t=>{if(F(t),G(t)){const s=window.vaChat.__CONFIG__.fullScreen?window.innerHeight:600,r=window.vaChat.__CONFIG__.fullScreen?window.innerWidth:400,d=window.vaChat.__CONFIG__.hideChatIcon?0:99,n=window.vaChat.__CONFIG__.hideChatIcon?105:0,e=k(s,r,d,n);var i=navigator.userAgent;i.indexOf("Firefox")>-1?W():L(),T(e),y(),N()}};window.document.addEventListener(c.iframe.id,P,!1),window.vaChat={__CONFIG__:((A=window==null?void 0:window.vaChat)==null?void 0:A.__CONFIG__)||{id:"",logLevel:"ERROR",title:"Message Us!",hideChatIcon:!1,attributes:{},displayName:"User",isConnected:!1,hideHeader:!1,va_securedformopen:""},config({id:t,title:o="Message Us!",hideChatIcon:i=!1,va_chatname:s,url:r=window.location.href,chatContainer:d,color:n,company:e,text_theme:u,autoOpen:p,fullScreen:f,minimize:h,hideHeader:g,resumeChat:a="Chat",va_securedformopen:l}){console.debug(`${m} Set widget configuration`,t,o,i,s,r,d,n,e,u,p,f,h,g,a,l),this.__CONFIG__={...this.__CONFIG__,id:t,title:o,hideChatIcon:i,va_chatname:s,url:r,chatContainer:d,color:n,company:e,text_theme:u,autoOpen:p,fullScreen:f,minimize:h,hideHeader:g,resumeChat:a,va_securedformopen:l}},setLogLevel(t){console.debug(`${m} Set logleve`,t),c.logLevels.includes(t)&&(this.__CONFIG__={...this.__CONFIG__,logLevel:t})},set({displayName:t="User",connectId:o,attributes:i={}}){this.__CONFIG__={...this.__CONFIG__,displayName:t,connectId:o,attributes:i}},info(){return this.__CONFIG__},updateConnectParameters(t){var i;const o=window.vaChat.__CONFIG__.va_chatname?localStorage.getItem(`__VirtualAssistant____ACTIVE_SESSION__${window.vaChat.__CONFIG__.va_chatname}`):localStorage.getItem("__VirtualAssistant____ACTIVE_SESSION__");if(o){let s=JSON.parse(o);if(this.__CONFIG__.id&&this.__CONFIG__.isConnected){const r={attributes:t==null?void 0:t.attributes,initialContactId:s.ContactId,instanceId:t==null?void 0:t.connectId},d={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)};x("updateParams",d)}}if(o&&((i=t==null?void 0:t.attributes)!=null&&i.botId)&&this.__CONFIG__.id&&this.__CONFIG__.isConnected){let s=JSON.parse(o);const r={botId:t==null?void 0:t.attributes.botId,botAliasId:t==null?void 0:t.attributes.botAliasId,localeId:t==null?void 0:t.attributes.localeId,sessionId:s.ParticipantId,sessionState:{sessionAttributes:t.attributes}},d={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)};x("updateLexParams",d)}},initializeChat(){if(this.__CONFIG__.isConnected)console.error(`${m} Chatwindow already initialized.`);else{this.__CONFIG__={...this.__CONFIG__,isConnected:!0},this.__CONFIG__.id||(this.__CONFIG__.autoOpen=!0),j(this.__CONFIG__.chatContainer),console.debug(`${m} Initialize ChatWindow`);const t=new CustomEvent("chatAppear",{detail:{description:"Chat is offered to the user",startPage:window.location.href,...E},bubbles:!0,cancelable:!0});console.debug(`${m} dispatching chatAppear event`),window.parent.document.dispatchEvent(t)}},refresh(){console.debug(`${m} Reset attributes.`),y()},open(){this.__CONFIG__.isConnected&&z()}};const R=new CustomEvent("vaWidgetLoaded",{detail:{message:"virtual assistant chat widget has loaded"},bubbles:!0,cancelable:!0});document.dispatchEvent(R);const $=t=>{const o=new CustomEvent("proactiveChatAppear",{detail:{description:"Chat is offered to the user",startPage:window.location.href,...E,...t},bubbles:!0,cancelable:!0});console.debug(`${m} dispatching chatAppear event for proactive`,t),window.parent.document.dispatchEvent(o)};return window.parent.document.addEventListener("proactiveIconAppeared",$),b.pick=w,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),b}({});
