/* Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations. */ (function(l){function d(){var a=!1,b;this.settings={appendHelpButton:!0,displayHelpButton:!0,isExternalPage:!0,devMode:!1,targetElement:document.body,elementForOnlineDisplay:void 0,elementForOfflineDisplay:void 0,defaultMinimizedText:"",disabledMinimizedText:"",defaultAssistiveText:"",loadingText:"Loading",showIcon:void 0,enabledFeatures:[],entryFeature:"FieldService",storageDomain:document.domain,language:void 0,linkAction:{feature:void 0,name:void 0,valid:!1},linkActionParameters:{},useCustomAuthentication:!1, allowGuestUsers:!1,requireSLDS:!1,hasBottomTabBar:!1};this.auth={};this.validLinkActions={};this.alwaysWarnOnBeforeUnload=!1;Object.defineProperty(this.auth,"oauthToken",{get:function(){return b},set:function(c){this.validateHeaderValue(c)?(b=c)?(this.setSessionData("ESW_OAUTH_TOKEN",c),this.checkAuthentication()):this.deleteSessionData("ESW_OAUTH_TOKEN"):this.error('"'+c+'" is not a valid OAuth token.')}.bind(this)});this.featureScripts={};this.storedEventHandlers={};this.messageHandlers={};this.storageKeys= ["ESW_BODY_SCROLL_POSITION","ESW_IS_MINIMIZED","ESW_MINIMIZED_TEXT","ESW_OAUTH_TOKEN"];this.defaultSettings={};this.snippetSettingsFile={};this.eswFrame=void 0;this.availableFeatures=["script","session"];this.outboundMessagesAwaitingIframeLoad=[];this.pendingMessages={};this.iframeScriptsToLoad=[];this.isAuthenticationRequired=this.isIframeReady=this.hasSessionDataLoaded=this.componentInitInProgress=this.domInitInProgress=!1;this.loginPendingSerializedData=void 0;this.componentLoaded=!1;Object.defineProperty(this, "isButtonDisabled",{get:function(){return a},set:function(c){a=c;this.onButtonStatusChange()}.bind(this),configurable:!0});this.setupMessageListener();this.getLinkActionData()}var m=[".salesforce.com",".force.com",".sfdc.net",".site.com",".salesforce-sites.com"],n="liveagent.chatCanceledOnDifferentTab liveagent.fileTransfer.resetFileSelector liveagent.fileTransfer.uploadFile session.deletedSessionData session.onLoad session.sessionData session.updatePrimary".split(" ");d.prototype.getLightningOutParamsObj= function(){var a={};embedded_svc.config&&embedded_svc.config.additionalSettings&&embedded_svc.config.additionalSettings.labelsLanguage?a={"aura.altLang":embedded_svc.config.additionalSettings.labelsLanguage}:embedded_svc.settings.language&&""!==embedded_svc.settings.language.trim()&&(a={"aura.altLang":embedded_svc.settings.language});a.eswConfigDeveloperName=embedded_svc.settings.eswConfigDevName;return a};d.prototype.adjustCommunityStorageDomain=function(){this.isCommunityDomain(this.settings.storageDomain)&& this.settings.storageDomain===document.domain&&(this.settings.storageDomain=this.settings.storageDomain+"/"+window.location.pathname.split("/")[1])};d.prototype.loadLightningOutScripts=function(a){if("function"!==typeof Promise)this.loadScriptFromDirectory("common","promisepolyfill",function(){return this.loadLightningOutScripts(a)}.bind(this),!0);else return new Promise(function(b,c){try{var e=a&&a.baseCoreURL?a.baseCoreURL:embedded_svc.settings.baseCoreURL;if(window.$Lightning)b("Lightning Out is already loaded on this page."); else if(embedded_svc.utils.isCommunityOrSite())b("Communities context does not require Lightning Out to use Embedded Service.");else if(e){var f=document.createElement("script");f.type="text/javascript";f.src=e+"/lightning/lightning.out.js";f.onload=function(){b("Lightning Out scripts loaded.")};document.getElementsByTagName("head")[0].appendChild(f)}}catch(h){c(h)}})};d.prototype.instantiateLightningOutApplication=function(a){if("function"!==typeof Promise)this.loadScriptFromDirectory("common","promisepolyfill", function(){return this.instantiateLightningOutApplication(a)}.bind(this),!0);else return new Promise(function(b,c){try{var e=a&&a.communityEndpointURL?a.communityEndpointURL:embedded_svc.settings.communityEndpointURL;var f=a&&a.oauthToken?a.oauthToken:embedded_svc.settings.oauthToken;var h=a&&a.paramsObj?a.paramsObj:embedded_svc.getLightningOutParamsObj()||void 0;embedded_svc.utils.isCommunityOrSite()?b("Communities context already has an Aura context."):window.$Lightning&&$Lightning.use("embeddedService:sidebarApp", function(){b("Lightning Out application request complete.")},e,f,h)}catch(g){c(g)}})};d.prototype.createEmbeddedServiceComponent=function(a){if("function"!==typeof Promise)this.loadScriptFromDirectory("common","promisepolyfill",function(){return this.createEmbeddedServiceComponent(a)}.bind(this),!0);else return new Promise(function(b,c){var e=a&&a.chatAPISettings?embedded_svc.validateStartChatAttributes(a.chatAPISettings):{};try{var f=a&&a.attributes?a.attributes:{configurationData:embedded_svc.settings, chatAPISettings:e};var h=a&&a.locator?a.locator:embedded_svc.settings.targetElement;embedded_svc.preparePageForSidebar();window.$Lightning&&!document.querySelector(".embeddedServiceSidebar")?$Lightning.ready($Lightning.createComponent.bind(this,"embeddedService:sidebar",f,h,function(g,k,p){"SUCCESS"===k?embedded_svc.utils.addEventHandler("afterInitialization",function(){b("Embedded Service component created.")}):c(p)})):embedded_svc.utils.isCommunityOrSite()?window.dispatchEvent(new CustomEvent("embeddedServiceCreateSidebar", {detail:{componentAttributes:f,resolve:b,reject:c}})):"undefined"===typeof window.$Lightning?b("Lightning Out should be loaded on this page before creating the Embedded Service component."):b("Embedded Service component already exists.")}catch(g){c(g)}})};d.prototype.bootstrapEmbeddedService=function(a){if("function"!==typeof Promise)this.loadScriptFromDirectory("common","promisepolyfill",function(){return embedded_svc.bootstrapEmbeddedService(a)},!0);else return new Promise(function(b,c){try{embedded_svc.loadLightningOutScripts(a).then(function(){embedded_svc.instantiateLightningOutApplication(a).then(function(){embedded_svc.createEmbeddedServiceComponent(a).then(function(){window.requestAnimationFrame(function(){embedded_svc.hideHelpButton(); b("Embedded Service application and component bootstrapped.")})})})})}catch(e){c(e)}})};d.prototype.validateStartChatAttributes=function(a){var b=(a=a?a:{})&&a.prepopulatedPrechatFields?a.prepopulatedPrechatFields:{},c=a&&a.extraPrechatInfo?a.extraPrechatInfo:[],e=a&&a.extraPrechatFormDetails?a.extraPrechatFormDetails:[],f=a&&a.fallbackRouting?a.fallbackRouting:[],h=a&&a.directToButtonRouting?a.directToButtonRouting:void 0,g={buttonId:a&&a.buttonId?a.buttonId:void 0,userId:a&&a.userId?a.userId:void 0, fallback:a&&"boolean"===typeof a.fallback?a.fallback:void 0};if("object"===typeof b)a.prepopulatedPrechatFields=b;else throw Error("Validation failed for prepopulatedPrechatFields, received: "+b);if(Array.isArray(e))a.extraPrechatFormDetails=e;else throw Error("Validation failed for extraPrechatFormDetails, received: "+e);if(Array.isArray(c))a.extraPrechatInfo=c;else throw Error("Validation failed for extraPrechatInfo, received: "+c);if(Array.isArray(f))a.fallbackRouting=f;else throw Error("Validation failed for fallbackRouting, received: "+ f);"function"===typeof h?a.directToButtonRouting=h:embedded_svc.log("Did not receive an actionable parameter for directToButtonRouting, received: "+h);if("object"===typeof g)if(a.directToAgentRouting=g,g.buttonId)if("string"===typeof g.buttonId&&g.buttonId.trim().length)a.directToAgentRouting.buttonId=g.buttonId.trim(),a.directToAgentRouting.fallback=g.fallback,g.userId&&("string"===typeof g.userId&&g.userId.trim().length?a.directToAgentRouting.userId=g.userId.trim():embedded_svc.log("Did not receive an actionable parameter for directToAgentRouting's userId, received: "+ g.userId));else throw Error("Validation failed for directToAgentRouting's buttonId, received: "+g.buttonId);else embedded_svc.log("Did not receive an actionable parameter for directToAgentRouting's buttonId, received: "+g.buttonId);else throw Error("Validation failed for directToAgentRouting, received: "+g);return a};d.prototype.isInternetExplorer=function(){return"ActiveXObject"in window};d.prototype.outputToConsole=function(a,b,c){if((c||this.settings.devMode)&&console&&console[a])console[a]("[Snap-ins] "+ (Array.isArray(b)?b.join(", "):b))};d.prototype.log=function(){this.outputToConsole("log",[].slice.apply(arguments))};d.prototype.error=function(a,b){a?this.outputToConsole("error",a,b):this.outputToConsole("error","esw responed with an unspecified error.",b);embedded_svc.utils.fireEvent("error")};d.prototype.warning=function(a,b){a?this.outputToConsole("warn","Warning: "+a,b):this.outputToConsole("warn","esw sent an anonymous warning.",b)};d.prototype.deprecated=function(a){this.warning(a+" is deprecated in version "+ Number("5.0").toFixed(1)+" and will be removed in version "+(Number("5.0")+1).toFixed(1))};d.prototype.getCookie=function(a){var b=document.cookie;if(b){var c=b.indexOf(a+"=");if(-1!==c)return c+=(a+"=").length,a=b.indexOf(";",c),-1===a&&(a=b.length),b.substring(c,a)}};d.prototype.setCookie=function(a,b,c){a=a+"="+b+";";c&&(c=new Date,c.setFullYear(c.getFullYear()+10),a+="expires="+c.toUTCString()+";");document.cookie=a+"path=/;"};d.prototype.mergeSettings=function(a){Object.keys(a).forEach(function(b){void 0=== this.settings[b]&&(this.settings[b]=a[b])}.bind(this))};d.prototype.loadFeatureScript=function(a,b){var c=decodeURI(a).toLowerCase();-1===a.indexOf("..")?this.loadScriptFromDirectory("client",c+".esw",function(){this.featureScripts[a](this);this.availableFeatures.push(c);embedded_svc.utils.fireEvent("featureLoaded",void 0,a);b&&b();this.processPendingMessages(c)}.bind(this)):this.error('"'+a+'" is not a valid feature name.')};d.prototype.fireEvent=function(a,b){var c=[].slice.apply(arguments).slice(2); if(window.embedded_svc&&embedded_svc.utils)return embedded_svc.utils.fireEvent(a,b,c);this.error("fireEvent should not be called before calling init!");return!0};d.prototype.isValidEntityId=function(a){return"string"===typeof a&&(18===a.length||15===a.length)};d.prototype.getKeyPrefix=function(a){if(this.isValidEntityId(a))return a.substr(0,3)};d.prototype.isOrganizationId=function(a){return"00D"===this.getKeyPrefix(a)};d.prototype.getESWFrame=function(){if(!this.eswFrame){var a=document.getElementById("esw_storage_iframe"); a&&a.contentWindow&&(this.eswFrame=a.contentWindow)}return this.eswFrame};d.prototype.isFrameStorageEnabled=function(){this.deprecated("isFrameStorageEnabled");return!0};d.prototype.processPendingMessages=function(a){this.pendingMessages[a]&&(this.pendingMessages[a].forEach(function(b){this.handleMessage(b.payload)}.bind(this)),this.pendingMessages[a]=void 0)};d.prototype.loadCSS=function(){var a=document.createElement("link");a.href=(this.settings.gslbBaseURL?this.settings.gslbBaseURL:this.settings.baseCoreURL)+ "/embeddedservice/"+this.settings.releaseVersion+"/esw"+(this.settings.devMode?"":".min")+".css";a.type="text/css";a.rel="stylesheet";document.getElementsByTagName("head")[0].appendChild(a)};d.prototype.appendHelpButton=function(a){var b=document.createElement("div"),c="";b.className="embeddedServiceHelpButton";this.isLanguageRtl(this.settings.language)&&this.isDesktop()&&(c='dir="rtl"');b.innerHTML='
';a||(b.style.display="none");this.settings.hasBottomTabBar&&b.classList.add("embeddedServiceBottomTabBar");this.settings.targetElement.appendChild(b);this.setHelpButtonText(this.settings.defaultMinimizedText);"ontouchstart"in document.documentElement&&[].slice.apply(document.querySelectorAll(".embeddedServiceHelpButton .uiButton")).forEach(function(e){e.classList.add("no-hover")});this.onButtonStatusChange()}; d.prototype.appendIFrame=function(){var a=document.createElement("iframe"),b={};a.id="esw_storage_iframe";a.src=this.settings.iframeURL;a.style.display="none";a.title="Live Chat Metadata";a.onload=function(){var c=this.getESWFrame();this.outboundMessagesAwaitingIframeLoad.forEach(function(e){c.postMessage(e,this.settings.iframeURL)}.bind(this));this.outboundMessagesAwaitingIframeLoad=[];this.iframeScriptsToLoad.forEach(function(e){this.loadStorageScript(e)}.bind(this));b.deploymentId=this.settings.deploymentId; b.isSamePageNavigation=this.isSamePageNavigation();b.isRefresh=1===window.performance.navigation.type;this.postMessage("session.updateStorage",b);this.iframeScriptsToLoad=[]}.bind(this);this.settings.targetElement.appendChild(a);window.addEventListener("beforeunload",function(c){this.isInternetExplorer()&&(a.src="about:blank");if(this.warnOnBeforeUnload&&this.componentLoaded)if(embedded_svc.utils.fireEvent("snapinsCloseSessionWarning"),this.settings.closeSessionWarning&&"function"===typeof this.settings.closeSessionWarning)this.settings.closeSessionWarning(); else return(c||window.event).returnValue="You might lose the active chat session if you close this tab. Are you sure?"}.bind(this),!1)};d.prototype.preparePageForSidebar=function(){document.getElementById("snapins_invite")&&embedded_svc.inviteAPI&&embedded_svc.inviteAPI.inviteButton.setOnlineState(!1);embedded_svc.utils.fireEvent("beforeCreate");Object.keys(this.settings).forEach(function(a){}.bind(this));this.mergeSettings(this.defaultSettings)};d.prototype.createLightningComponent=function(a){this.preparePageForSidebar(); this.createEmbeddedServiceComponent({attributes:{configurationData:this.settings,serializedSessionData:a},locator:this.settings.targetElement}).then(function(){this.hideHelpButton();this.componentInitInProgress=!1;this.componentLoaded=!0;embedded_svc&&embedded_svc.liveAgentAPI&&embedded_svc.liveAgentAPI.ping();embedded_svc.utils.fireEvent("ready")}.bind(this))};d.prototype.loadLightningApp=function(a){var b;if(this.settings.isExternalPage&&"string"!==typeof this.settings.communityEndpointURL)throw Error("communityEndpointURL String property not set"); if(b=document.getElementsByClassName("helpButton")[0]){var c=b.getBoundingClientRect().width;0