//~~tv:20010.20140827
//~~tc: Tealium Custom Container
/*
Tealium Custom Container Notes:
- Add sending code between "Start Tag Sending Code" and "End Tag Sending Code".
- Add JavaScript tag library code between "Start Tag Library Code" and "End Tag Library Code".
- Add JavaScript code only, do not add HTML code in this file.
- Remove any tags from the code you place in this file.
Loading external JavaScript files (Loader):
- If you need to load an additional external JavaScript file, un-comment the singe-line JavaScript comments ("//") within the following Loader sections near the bottom of this file:
- "Start Loader Function Call"
- "End Loader Function Call"
- "Start Loader Callback Function"
- "End Loader Callback Function"
- After un-commenting, insert the path to the external JavaScript file you want to load.
- Finally, within the Loader callback function, insert the JavaScript code that should run after the external JavaScript file has loaded.
*/
/* Start Tag Library Code */
/* End Tag Library Code */
//tealium universal tag - utag.sender.custom_container ut4.0.202508160004, Copyright 2025 Tealium.com Inc. All Rights Reserved.
try {
(function (id, loader) {
var u = {};
utag.o[loader].sender[id] = u;
// Start Tealium loader 4.32
// Please do not modify
if (utag === undefined) { utag = {}; } if (utag.ut === undefined) { utag.ut = {}; } if (utag.ut.loader === undefined) { u.loader = function (o) { var a, b, c, l; a = document; if (o.type === "iframe") { b = a.createElement("iframe"); b.setAttribute("height", "1"); b.setAttribute("width", "1"); b.setAttribute("style", "display:none"); b.setAttribute("src", o.src); } else if (o.type === "img") { utag.DB("Attach img: " + o.src); b = new Image(); b.src = o.src; return; } else { b = a.createElement("script"); b.language = "javascript"; b.type = "text/javascript"; b.async = 1; b.charset = "utf-8"; b.src = o.src; } if (o.id) { b.id = o.id; } if (typeof o.cb === "function") { if (b.addEventListener) { b.addEventListener("load", function () { o.cb(); }, false); } else { b.onreadystatechange = function () { if (this.readyState === "complete" || this.readyState === "loaded") { this.onreadystatechange = null; o.cb(); } }; } } l = o.loc || "head"; c = a.getElementsByTagName(l)[0]; if (c) { utag.DB("Attach to " + l + ": " + o.src); if (l === "script") { c.parentNode.insertBefore(b, c); } else { c.appendChild(b); } } }; } else { u.loader = utag.ut.loader; }
// End Tealium loader
u.ev = {'view' : 1};
u.initialized = false;
u.map={};
u.extend=[function(a,b){ try{ if(1){
/******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./node_modules/cometd/cometd.js":
/*!***************************************!*\
!*** ./node_modules/cometd/cometd.js ***!
\***************************************/
/***/ (function(module, exports) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
/*
* Copyright (c) 2008-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* CometD Version 4.0.9 */
(function (root, factory) {
if (( false ? 0 : _typeof(exports)) === 'object') {
// CommonJS.
module.exports = factory();
} else if (true) {
// AMD.
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
})(this, function () {
/**
* Browsers may throttle the Window scheduler,
* so we may replace it with a Worker scheduler.
*/
var Scheduler = function Scheduler() {
var _ids = 0;
var _tasks = {};
this.register = function (funktion) {
var id = ++_ids;
_tasks[id] = funktion;
return id;
};
this.unregister = function (id) {
var funktion = _tasks[id];
delete _tasks[id];
return funktion;
};
this.setTimeout = function (funktion, delay) {
return window.setTimeout(funktion, delay);
};
this.clearTimeout = function (id) {
window.clearTimeout(id);
};
};
/**
* The scheduler code that will run in the Worker.
* Workers have a built-in `self` variable similar to `window`.
*/
function WorkerScheduler() {
var _tasks = {};
self.onmessage = function (e) {
var cmd = e.data;
var id = _tasks[cmd.id];
switch (cmd.type) {
case 'setTimeout':
_tasks[cmd.id] = self.setTimeout(function () {
delete _tasks[cmd.id];
self.postMessage({
id: cmd.id
});
}, cmd.delay);
break;
case 'clearTimeout':
delete _tasks[cmd.id];
if (id) {
self.clearTimeout(id);
}
break;
default:
throw 'Unknown command ' + cmd.type;
}
};
}
/**
* Utility functions.
*/
var Utils = {
isString: function isString(value) {
if (value === undefined || value === null) {
return false;
}
return typeof value === 'string' || value instanceof String;
},
isArray: function isArray(value) {
if (value === undefined || value === null) {
return false;
}
return value instanceof Array;
},
/**
* Returns whether the given element is contained into the given array.
* @param element the element to check presence for
* @param array the array to check for the element presence
* @return the index of the element, if present, or a negative index if the element is not present
*/
inArray: function inArray(element, array) {
for (var i = 0; i < array.length; ++i) {
if (element === array[i]) {
return i;
}
}
return -1;
}
};
/**
* A registry for transports used by the CometD object.
*/
var TransportRegistry = function TransportRegistry() {
var _types = [];
var _transports = {};
this.getTransportTypes = function () {
return _types.slice(0);
};
this.findTransportTypes = function (version, crossDomain, url) {
var result = [];
for (var i = 0; i < _types.length; ++i) {
var type = _types[i];
if (_transports[type].accept(version, crossDomain, url) === true) {
result.push(type);
}
}
return result;
};
this.negotiateTransport = function (types, version, crossDomain, url) {
for (var i = 0; i < _types.length; ++i) {
var type = _types[i];
for (var j = 0; j < types.length; ++j) {
if (type === types[j]) {
var transport = _transports[type];
if (transport.accept(version, crossDomain, url) === true) {
return transport;
}
}
}
}
return null;
};
this.add = function (type, transport, index) {
var existing = false;
for (var i = 0; i < _types.length; ++i) {
if (_types[i] === type) {
existing = true;
break;
}
}
if (!existing) {
if (typeof index !== 'number') {
_types.push(type);
} else {
_types.splice(index, 0, type);
}
_transports[type] = transport;
}
return !existing;
};
this.find = function (type) {
for (var i = 0; i < _types.length; ++i) {
if (_types[i] === type) {
return _transports[type];
}
}
return null;
};
this.remove = function (type) {
for (var i = 0; i < _types.length; ++i) {
if (_types[i] === type) {
_types.splice(i, 1);
var transport = _transports[type];
delete _transports[type];
return transport;
}
}
return null;
};
this.clear = function () {
_types = [];
_transports = {};
};
this.reset = function (init) {
for (var i = 0; i < _types.length; ++i) {
_transports[_types[i]].reset(init);
}
};
};
/**
* Base object with the common functionality for transports.
*/
var Transport = function Transport() {
var _type;
var _cometd;
var _url;
/**
* Function invoked just after a transport has been successfully registered.
* @param type the type of transport (for example 'long-polling')
* @param cometd the cometd object this transport has been registered to
* @see #unregistered()
*/
this.registered = function (type, cometd) {
_type = type;
_cometd = cometd;
};
/**
* Function invoked just after a transport has been successfully unregistered.
* @see #registered(type, cometd)
*/
this.unregistered = function () {
_type = null;
_cometd = null;
};
this._debug = function () {
_cometd._debug.apply(_cometd, arguments);
};
this._mixin = function () {
return _cometd._mixin.apply(_cometd, arguments);
};
this.getConfiguration = function () {
return _cometd.getConfiguration();
};
this.getAdvice = function () {
return _cometd.getAdvice();
};
this.setTimeout = function (funktion, delay) {
return _cometd.setTimeout(funktion, delay);
};
this.clearTimeout = function (id) {
_cometd.clearTimeout(id);
};
/**
* Converts the given response into an array of bayeux messages
* @param response the response to convert
* @return an array of bayeux messages obtained by converting the response
*/
this.convertToMessages = function (response) {
if (Utils.isString(response)) {
try {
return JSON.parse(response);
} catch (x) {
this._debug('Could not convert to JSON the following string', '"' + response + '"');
throw x;
}
}
if (Utils.isArray(response)) {
return response;
}
if (response === undefined || response === null) {
return [];
}
if (response instanceof Object) {
return [response];
}
throw 'Conversion Error ' + response + ', typeof ' + _typeof(response);
};
/**
* Returns whether this transport can work for the given version and cross domain communication case.
* @param version a string indicating the transport version
* @param crossDomain a boolean indicating whether the communication is cross domain
* @param url the URL to connect to
* @return true if this transport can work for the given version and cross domain communication case,
* false otherwise
*/
this.accept = function (version, crossDomain, url) {
throw 'Abstract';
};
/**
* Returns the type of this transport.
* @see #registered(type, cometd)
*/
this.getType = function () {
return _type;
};
this.getURL = function () {
return _url;
};
this.setURL = function (url) {
_url = url;
};
this.send = function (envelope, metaConnect) {
throw 'Abstract';
};
this.reset = function (init) {
this._debug('Transport', _type, 'reset', init ? 'initial' : 'retry');
};
this.abort = function () {
this._debug('Transport', _type, 'aborted');
};
this.toString = function () {
return this.getType();
};
};
Transport.derive = function (baseObject) {
function F() {}
F.prototype = baseObject;
return new F();
};
/**
* Base object with the common functionality for transports based on requests.
* The key responsibility is to allow at most 2 outstanding requests to the server,
* to avoid that requests are sent behind a long poll.
* To achieve this, we have one reserved request for the long poll, and all other
* requests are serialized one after the other.
*/
var RequestTransport = function RequestTransport() {
var _super = new Transport();
var _self = Transport.derive(_super);
var _requestIds = 0;
var _metaConnectRequest = null;
var _requests = [];
var _envelopes = [];
function _coalesceEnvelopes(envelope) {
while (_envelopes.length > 0) {
var envelopeAndRequest = _envelopes[0];
var newEnvelope = envelopeAndRequest[0];
var newRequest = envelopeAndRequest[1];
if (newEnvelope.url === envelope.url && newEnvelope.sync === envelope.sync) {
_envelopes.shift();
envelope.messages = envelope.messages.concat(newEnvelope.messages);
this._debug('Coalesced', newEnvelope.messages.length, 'messages from request', newRequest.id);
continue;
}
break;
}
}
function _transportSend(envelope, request) {
this.transportSend(envelope, request);
request.expired = false;
if (!envelope.sync) {
var maxDelay = this.getConfiguration().maxNetworkDelay;
var delay = maxDelay;
if (request.metaConnect === true) {
delay += this.getAdvice().timeout;
}
this._debug('Transport', this.getType(), 'waiting at most', delay, 'ms for the response, maxNetworkDelay', maxDelay);
var self = this;
request.timeout = this.setTimeout(function () {
request.expired = true;
var errorMessage = 'Request ' + request.id + ' of transport ' + self.getType() + ' exceeded ' + delay + ' ms max network delay';
var failure = {
reason: errorMessage
};
var xhr = request.xhr;
failure.httpCode = self.xhrStatus(xhr);
self.abortXHR(xhr);
self._debug(errorMessage);
self.complete(request, false, request.metaConnect);
envelope.onFailure(xhr, envelope.messages, failure);
}, delay);
}
}
function _queueSend(envelope) {
var requestId = ++_requestIds;
var request = {
id: requestId,
metaConnect: false,
envelope: envelope
};
// Consider the /meta/connect requests which should always be present.
if (_requests.length < this.getConfiguration().maxConnections - 1) {
_requests.push(request);
_transportSend.call(this, envelope, request);
} else {
this._debug('Transport', this.getType(), 'queueing request', requestId, 'envelope', envelope);
_envelopes.push([envelope, request]);
}
}
function _metaConnectComplete(request) {
var requestId = request.id;
this._debug('Transport', this.getType(), '/meta/connect complete, request', requestId);
if (_metaConnectRequest !== null && _metaConnectRequest.id !== requestId) {
throw '/meta/connect request mismatch, completing request ' + requestId;
}
_metaConnectRequest = null;
}
function _complete(request, success) {
var index = Utils.inArray(request, _requests);
// The index can be negative if the request has been aborted
if (index >= 0) {
_requests.splice(index, 1);
}
if (_envelopes.length > 0) {
var envelopeAndRequest = _envelopes.shift();
var nextEnvelope = envelopeAndRequest[0];
var nextRequest = envelopeAndRequest[1];
this._debug('Transport dequeued request', nextRequest.id);
if (success) {
if (this.getConfiguration().autoBatch) {
_coalesceEnvelopes.call(this, nextEnvelope);
}
_queueSend.call(this, nextEnvelope);
this._debug('Transport completed request', request.id, nextEnvelope);
} else {
// Keep the semantic of calling response callbacks asynchronously after the request
var self = this;
this.setTimeout(function () {
self.complete(nextRequest, false, nextRequest.metaConnect);
var failure = {
reason: 'Previous request failed'
};
var xhr = nextRequest.xhr;
failure.httpCode = self.xhrStatus(xhr);
nextEnvelope.onFailure(xhr, nextEnvelope.messages, failure);
}, 0);
}
}
}
_self.complete = function (request, success, metaConnect) {
if (metaConnect) {
_metaConnectComplete.call(this, request);
} else {
_complete.call(this, request, success);
}
};
/**
* Performs the actual send depending on the transport type details.
* @param envelope the envelope to send
* @param request the request information
*/
_self.transportSend = function (envelope, request) {
throw 'Abstract';
};
_self.transportSuccess = function (envelope, request, responses) {
if (!request.expired) {
this.clearTimeout(request.timeout);
this.complete(request, true, request.metaConnect);
if (responses && responses.length > 0) {
envelope.onSuccess(responses);
} else {
envelope.onFailure(request.xhr, envelope.messages, {
httpCode: 204
});
}
}
};
_self.transportFailure = function (envelope, request, failure) {
if (!request.expired) {
this.clearTimeout(request.timeout);
this.complete(request, false, request.metaConnect);
envelope.onFailure(request.xhr, envelope.messages, failure);
}
};
function _metaConnectSend(envelope) {
if (_metaConnectRequest !== null) {
throw 'Concurrent /meta/connect requests not allowed, request id=' + _metaConnectRequest.id + ' not yet completed';
}
var requestId = ++_requestIds;
this._debug('Transport', this.getType(), '/meta/connect send, request', requestId, 'envelope', envelope);
var request = {
id: requestId,
metaConnect: true,
envelope: envelope
};
_transportSend.call(this, envelope, request);
_metaConnectRequest = request;
}
_self.send = function (envelope, metaConnect) {
if (metaConnect) {
_metaConnectSend.call(this, envelope);
} else {
_queueSend.call(this, envelope);
}
};
_self.abort = function () {
_super.abort();
for (var i = 0; i < _requests.length; ++i) {
var request = _requests[i];
if (request) {
this._debug('Aborting request', request);
if (!this.abortXHR(request.xhr)) {
this.transportFailure(request.envelope, request, {
reason: 'abort'
});
}
}
}
var metaConnectRequest = _metaConnectRequest;
if (metaConnectRequest) {
this._debug('Aborting /meta/connect request', metaConnectRequest);
if (!this.abortXHR(metaConnectRequest.xhr)) {
this.transportFailure(metaConnectRequest.envelope, metaConnectRequest, {
reason: 'abort'
});
}
}
this.reset(true);
};
_self.reset = function (init) {
_super.reset(init);
_metaConnectRequest = null;
_requests = [];
_envelopes = [];
};
_self.abortXHR = function (xhr) {
if (xhr) {
try {
var state = xhr.readyState;
xhr.abort();
return state !== window.XMLHttpRequest.UNSENT;
} catch (x) {
this._debug(x);
}
}
return false;
};
_self.xhrStatus = function (xhr) {
if (xhr) {
try {
return xhr.status;
} catch (x) {
this._debug(x);
}
}
return -1;
};
return _self;
};
var LongPollingTransport = function LongPollingTransport() {
var _super = new RequestTransport();
var _self = Transport.derive(_super);
// By default, support cross domain
var _supportsCrossDomain = true;
_self.accept = function (version, crossDomain, url) {
return _supportsCrossDomain || !crossDomain;
};
_self.newXMLHttpRequest = function () {
return new window.XMLHttpRequest();
};
function _copyContext(xhr) {
try {
// Copy external context, to be used in other environments.
xhr.context = _self.context;
} catch (e) {
// May happen if XHR is wrapped by Object.seal(),
// Object.freeze(), or Object.preventExtensions().
this._debug('Could not copy transport context into XHR', e);
}
}
_self.xhrSend = function (packet) {
var xhr = _self.newXMLHttpRequest();
_copyContext(xhr);
xhr.withCredentials = true;
xhr.open('POST', packet.url, packet.sync !== true);
var headers = packet.headers;
if (headers) {
for (var headerName in headers) {
if (headers.hasOwnProperty(headerName)) {
xhr.setRequestHeader(headerName, headers[headerName]);
}
}
}
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.onload = function () {
if (xhr.status === 200) {
packet.onSuccess(xhr.responseText);
} else {
packet.onError(xhr.statusText);
}
};
xhr.onabort = xhr.onerror = function () {
packet.onError(xhr.statusText);
};
xhr.send(packet.body);
return xhr;
};
_self.transportSend = function (envelope, request) {
this._debug('Transport', this.getType(), 'sending request', request.id, 'envelope', envelope);
var self = this;
try {
var sameStack = true;
request.xhr = this.xhrSend({
transport: this,
url: envelope.url,
sync: envelope.sync,
headers: this.getConfiguration().requestHeaders,
body: JSON.stringify(envelope.messages),
onSuccess: function onSuccess(response) {
self._debug('Transport', self.getType(), 'received response', response);
var success = false;
try {
var received = self.convertToMessages(response);
if (received.length === 0) {
_supportsCrossDomain = false;
self.transportFailure(envelope, request, {
httpCode: 204
});
} else {
success = true;
self.transportSuccess(envelope, request, received);
}
} catch (x) {
self._debug(x);
if (!success) {
_supportsCrossDomain = false;
var failure = {
exception: x
};
failure.httpCode = self.xhrStatus(request.xhr);
self.transportFailure(envelope, request, failure);
}
}
},
onError: function onError(reason, exception) {
self._debug('Transport', self.getType(), 'received error', reason, exception);
_supportsCrossDomain = false;
var failure = {
reason: reason,
exception: exception
};
failure.httpCode = self.xhrStatus(request.xhr);
if (sameStack) {
// Keep the semantic of calling response callbacks asynchronously after the request
self.setTimeout(function () {
self.transportFailure(envelope, request, failure);
}, 0);
} else {
self.transportFailure(envelope, request, failure);
}
}
});
sameStack = false;
} catch (x) {
_supportsCrossDomain = false;
// Keep the semantic of calling response callbacks asynchronously after the request
this.setTimeout(function () {
self.transportFailure(envelope, request, {
exception: x
});
}, 0);
}
};
_self.reset = function (init) {
_super.reset(init);
_supportsCrossDomain = true;
};
return _self;
};
var CallbackPollingTransport = function CallbackPollingTransport() {
var _super = new RequestTransport();
var _self = Transport.derive(_super);
var jsonp = 0;
_self.accept = function (version, crossDomain, url) {
return true;
};
_self.jsonpSend = function (packet) {
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
var callbackName = '_cometd_jsonp_' + jsonp++;
window[callbackName] = function (responseText) {
head.removeChild(script);
delete window[callbackName];
packet.onSuccess(responseText);
};
var url = packet.url;
url += url.indexOf('?') < 0 ? '?' : '&';
url += 'jsonp=' + callbackName;
url += '&message=' + encodeURIComponent(packet.body);
script.src = url;
script.async = packet.sync !== true;
script.type = 'application/javascript';
script.onerror = function (e) {
packet.onError('jsonp ' + e.type);
};
head.appendChild(script);
};
function _failTransportFn(envelope, request, x) {
var self = this;
return function () {
self.transportFailure(envelope, request, 'error', x);
};
}
_self.transportSend = function (envelope, request) {
var self = this;
// Microsoft Internet Explorer has a 2083 URL max length
// We must ensure that we stay within that length
var start = 0;
var length = envelope.messages.length;
var lengths = [];
while (length > 0) {
// Encode the messages because all brackets, quotes, commas, colons, etc
// present in the JSON will be URL encoded, taking many more characters
var json = JSON.stringify(envelope.messages.slice(start, start + length));
var urlLength = envelope.url.length + encodeURI(json).length;
var maxLength = this.getConfiguration().maxURILength;
if (urlLength > maxLength) {
if (length === 1) {
var x = 'Bayeux message too big (' + urlLength + ' bytes, max is ' + maxLength + ') ' + 'for transport ' + this.getType();
// Keep the semantic of calling response callbacks asynchronously after the request
this.setTimeout(_failTransportFn.call(this, envelope, request, x), 0);
return;
}
--length;
continue;
}
lengths.push(length);
start += length;
length = envelope.messages.length - start;
}
// Here we are sure that the messages can be sent within the URL limit
var envelopeToSend = envelope;
if (lengths.length > 1) {
var begin = 0;
var end = lengths[0];
this._debug('Transport', this.getType(), 'split', envelope.messages.length, 'messages into', lengths.join(' + '));
envelopeToSend = this._mixin(false, {}, envelope);
envelopeToSend.messages = envelope.messages.slice(begin, end);
envelopeToSend.onSuccess = envelope.onSuccess;
envelopeToSend.onFailure = envelope.onFailure;
for (var i = 1; i < lengths.length; ++i) {
var nextEnvelope = this._mixin(false, {}, envelope);
begin = end;
end += lengths[i];
nextEnvelope.messages = envelope.messages.slice(begin, end);
nextEnvelope.onSuccess = envelope.onSuccess;
nextEnvelope.onFailure = envelope.onFailure;
this.send(nextEnvelope, request.metaConnect);
}
}
this._debug('Transport', this.getType(), 'sending request', request.id, 'envelope', envelopeToSend);
try {
var sameStack = true;
this.jsonpSend({
transport: this,
url: envelopeToSend.url,
sync: envelopeToSend.sync,
headers: this.getConfiguration().requestHeaders,
body: JSON.stringify(envelopeToSend.messages),
onSuccess: function onSuccess(responses) {
var success = false;
try {
var received = self.convertToMessages(responses);
if (received.length === 0) {
self.transportFailure(envelopeToSend, request, {
httpCode: 204
});
} else {
success = true;
self.transportSuccess(envelopeToSend, request, received);
}
} catch (x) {
self._debug(x);
if (!success) {
self.transportFailure(envelopeToSend, request, {
exception: x
});
}
}
},
onError: function onError(reason, exception) {
var failure = {
reason: reason,
exception: exception
};
if (sameStack) {
// Keep the semantic of calling response callbacks asynchronously after the request
self.setTimeout(function () {
self.transportFailure(envelopeToSend, request, failure);
}, 0);
} else {
self.transportFailure(envelopeToSend, request, failure);
}
}
});
sameStack = false;
} catch (xx) {
// Keep the semantic of calling response callbacks asynchronously after the request
this.setTimeout(function () {
self.transportFailure(envelopeToSend, request, {
exception: xx
});
}, 0);
}
};
return _self;
};
var WebSocketTransport = function WebSocketTransport() {
var _super = new Transport();
var _self = Transport.derive(_super);
var _cometd;
// By default WebSocket is supported
var _webSocketSupported = true;
// Whether we were able to establish a WebSocket connection
var _webSocketConnected = false;
var _stickyReconnect = true;
// The context contains the envelopes that have been sent
// and the timeouts for the messages that have been sent.
var _context = null;
var _connecting = null;
var _connected = false;
var _successCallback = null;
_self.reset = function (init) {
_super.reset(init);
_webSocketSupported = true;
if (init) {
_webSocketConnected = false;
}
_stickyReconnect = true;
_context = null;
_connecting = null;
_connected = false;
};
function _forceClose(context, event) {
if (context) {
this.webSocketClose(context, event.code, event.reason);
// Force immediate failure of pending messages to trigger reconnect.
// This is needed because the server may not reply to our close()
// and therefore the onclose function is never called.
this.onClose(context, event);
}
}
function _sameContext(context) {
return context === _connecting || context === _context;
}
function _storeEnvelope(context, envelope, metaConnect) {
var messageIds = [];
for (var i = 0; i < envelope.messages.length; ++i) {
var message = envelope.messages[i];
if (message.id) {
messageIds.push(message.id);
}
}
context.envelopes[messageIds.join(',')] = [envelope, metaConnect];
this._debug('Transport', this.getType(), 'stored envelope, envelopes', context.envelopes);
}
function _websocketConnect(context) {
// We may have multiple attempts to open a WebSocket
// connection, for example a /meta/connect request that
// may take time, along with a user-triggered publish.
// Early return if we are already connecting.
if (_connecting) {
return;
}
// Mangle the URL, changing the scheme from 'http' to 'ws'.
var url = _cometd.getURL().replace(/^http/, 'ws');
this._debug('Transport', this.getType(), 'connecting to URL', url);
try {
var protocol = _cometd.getConfiguration().protocol;
context.webSocket = protocol ? new window.WebSocket(url, protocol) : new window.WebSocket(url);
_connecting = context;
} catch (x) {
_webSocketSupported = false;
this._debug('Exception while creating WebSocket object', x);
throw x;
}
// By default use sticky reconnects.
_stickyReconnect = _cometd.getConfiguration().stickyReconnect !== false;
var self = this;
var connectTimeout = _cometd.getConfiguration().connectTimeout;
if (connectTimeout > 0) {
context.connectTimer = this.setTimeout(function () {
_cometd._debug('Transport', self.getType(), 'timed out while connecting to URL', url, ':', connectTimeout, 'ms');
// The connection was not opened, close anyway.
_forceClose.call(self, context, {
code: 1000,
reason: 'Connect Timeout'
});
}, connectTimeout);
}
var onopen = function onopen() {
_cometd._debug('WebSocket onopen', context);
if (context.connectTimer) {
self.clearTimeout(context.connectTimer);
}
if (_sameContext(context)) {
_connecting = null;
_context = context;
_webSocketConnected = true;
self.onOpen(context);
} else {
// We have a valid connection already, close this one.
_cometd._warn('Closing extra WebSocket connection', this, 'active connection', _context);
_forceClose.call(self, context, {
code: 1000,
reason: 'Extra Connection'
});
}
};
// This callback is invoked when the server sends the close frame.
// The close frame for a connection may arrive *after* another
// connection has been opened, so we must make sure that actions
// are performed only if it's the same connection.
var onclose = function onclose(event) {
event = event || {
code: 1000
};
_cometd._debug('WebSocket onclose', context, event, 'connecting', _connecting, 'current', _context);
if (context.connectTimer) {
self.clearTimeout(context.connectTimer);
}
self.onClose(context, event);
};
var onmessage = function onmessage(wsMessage) {
_cometd._debug('WebSocket onmessage', wsMessage, context);
self.onMessage(context, wsMessage);
};
context.webSocket.onopen = onopen;
context.webSocket.onclose = onclose;
context.webSocket.onerror = function () {
// Clients should call onclose(), but if they do not we do it here for safety.
onclose({
code: 1000,
reason: 'Error'
});
};
context.webSocket.onmessage = onmessage;
this._debug('Transport', this.getType(), 'configured callbacks on', context);
}
function _webSocketSend(context, envelope, metaConnect) {
var json = JSON.stringify(envelope.messages);
context.webSocket.send(json);
this._debug('Transport', this.getType(), 'sent', envelope, '/meta/connect =', metaConnect);
// Manage the timeout waiting for the response.
var maxDelay = this.getConfiguration().maxNetworkDelay;
var delay = maxDelay;
if (metaConnect) {
delay += this.getAdvice().timeout;
_connected = true;
}
var self = this;
var messageIds = [];
for (var i = 0; i < envelope.messages.length; ++i) {
(function () {
var message = envelope.messages[i];
if (message.id) {
messageIds.push(message.id);
context.timeouts[message.id] = self.setTimeout(function () {
_cometd._debug('Transport', self.getType(), 'timing out message', message.id, 'after', delay, 'on', context);
_forceClose.call(self, context, {
code: 1000,
reason: 'Message Timeout'
});
}, delay);
}
})();
}
this._debug('Transport', this.getType(), 'waiting at most', delay, 'ms for messages', messageIds, 'maxNetworkDelay', maxDelay, ', timeouts:', context.timeouts);
}
_self._notifySuccess = function (fn, messages) {
fn.call(this, messages);
};
_self._notifyFailure = function (fn, context, messages, failure) {
fn.call(this, context, messages, failure);
};
function _send(context, envelope, metaConnect) {
try {
if (context === null) {
context = _connecting || {
envelopes: {},
timeouts: {}
};
_storeEnvelope.call(this, context, envelope, metaConnect);
_websocketConnect.call(this, context);
} else {
_storeEnvelope.call(this, context, envelope, metaConnect);
_webSocketSend.call(this, context, envelope, metaConnect);
}
} catch (x) {
// Keep the semantic of calling response callbacks asynchronously after the request.
var self = this;
this.setTimeout(function () {
_forceClose.call(self, context, {
code: 1000,
reason: 'Exception',
exception: x
});
}, 0);
}
}
_self.onOpen = function (context) {
var envelopes = context.envelopes;
this._debug('Transport', this.getType(), 'opened', context, 'pending messages', envelopes);
for (var key in envelopes) {
if (envelopes.hasOwnProperty(key)) {
var element = envelopes[key];
var envelope = element[0];
var metaConnect = element[1];
// Store the success callback, which is independent from the envelope,
// so that it can be used to notify arrival of messages.
_successCallback = envelope.onSuccess;
_webSocketSend.call(this, context, envelope, metaConnect);
}
}
};
_self.onMessage = function (context, wsMessage) {
this._debug('Transport', this.getType(), 'received websocket message', wsMessage, context);
var close = false;
var messages = this.convertToMessages(wsMessage.data);
var messageIds = [];
for (var i = 0; i < messages.length; ++i) {
var message = messages[i];
// Detect if the message is a response to a request we made.
// If it's a meta message, for sure it's a response; otherwise it's
// a publish message and publish responses don't have the data field.
if (/^\/meta\//.test(message.channel) || message.data === undefined) {
if (message.id) {
messageIds.push(message.id);
var timeout = context.timeouts[message.id];
if (timeout) {
this.clearTimeout(timeout);
delete context.timeouts[message.id];
this._debug('Transport', this.getType(), 'removed timeout for message', message.id, ', timeouts', context.timeouts);
}
}
}
if ('/meta/connect' === message.channel) {
_connected = false;
}
if ('/meta/disconnect' === message.channel && !_connected) {
close = true;
}
}
// Remove the envelope corresponding to the messages.
var removed = false;
var envelopes = context.envelopes;
for (var j = 0; j < messageIds.length; ++j) {
var id = messageIds[j];
for (var key in envelopes) {
if (envelopes.hasOwnProperty(key)) {
var ids = key.split(',');
var index = Utils.inArray(id, ids);
if (index >= 0) {
removed = true;
ids.splice(index, 1);
var envelope = envelopes[key][0];
var metaConnect = envelopes[key][1];
delete envelopes[key];
if (ids.length > 0) {
envelopes[ids.join(',')] = [envelope, metaConnect];
}
break;
}
}
}
}
if (removed) {
this._debug('Transport', this.getType(), 'removed envelope, envelopes', envelopes);
}
this._notifySuccess(_successCallback, messages);
if (close) {
this.webSocketClose(context, 1000, 'Disconnect');
}
};
_self.onClose = function (context, event) {
this._debug('Transport', this.getType(), 'closed', context, event);
if (_sameContext(context)) {
// Remember if we were able to connect.
// This close event could be due to server shutdown,
// and if it restarts we want to try websocket again.
_webSocketSupported = _stickyReconnect && _webSocketConnected;
_connecting = null;
_context = null;
}
var timeouts = context.timeouts;
context.timeouts = {};
for (var id in timeouts) {
if (timeouts.hasOwnProperty(id)) {
this.clearTimeout(timeouts[id]);
}
}
var envelopes = context.envelopes;
context.envelopes = {};
for (var key in envelopes) {
if (envelopes.hasOwnProperty(key)) {
var envelope = envelopes[key][0];
var metaConnect = envelopes[key][1];
if (metaConnect) {
_connected = false;
}
var failure = {
websocketCode: event.code,
reason: event.reason
};
if (event.exception) {
failure.exception = event.exception;
}
this._notifyFailure(envelope.onFailure, context, envelope.messages, failure);
}
}
};
_self.registered = function (type, cometd) {
_super.registered(type, cometd);
_cometd = cometd;
};
_self.accept = function (version, crossDomain, url) {
this._debug('Transport', this.getType(), 'accept, supported:', _webSocketSupported);
// Using !! to return a boolean (and not the WebSocket object).
return _webSocketSupported && !!window.WebSocket && _cometd.websocketEnabled !== false;
};
_self.send = function (envelope, metaConnect) {
this._debug('Transport', this.getType(), 'sending', envelope, '/meta/connect =', metaConnect);
_send.call(this, _context, envelope, metaConnect);
};
_self.webSocketClose = function (context, code, reason) {
try {
if (context.webSocket) {
context.webSocket.close(code, reason);
}
} catch (x) {
this._debug(x);
}
};
_self.abort = function () {
_super.abort();
_forceClose.call(this, _context, {
code: 1000,
reason: 'Abort'
});
this.reset(true);
};
return _self;
};
/**
* The constructor for a CometD object, identified by an optional name.
* The default name is the string 'default'.
* @param name the optional name of this cometd object
*/
var CometD = function CometD(name) {
var _scheduler = new Scheduler();
var _cometd = this;
var _name = name || 'default';
var _crossDomain = false;
var _transports = new TransportRegistry();
var _transport;
var _status = 'disconnected';
var _messageId = 0;
var _clientId = null;
var _batch = 0;
var _messageQueue = [];
var _internalBatch = false;
var _listenerId = 0;
var _listeners = {};
var _backoff = 0;
var _scheduledSend = null;
var _extensions = [];
var _advice = {};
var _handshakeProps;
var _handshakeCallback;
var _callbacks = {};
var _remoteCalls = {};
var _reestablish = false;
var _connected = false;
var _unconnectTime = 0;
var _handshakeMessages = 0;
var _metaConnect = null;
var _config = {
useWorkerScheduler: true,
protocol: null,
stickyReconnect: true,
connectTimeout: 0,
maxConnections: 2,
backoffIncrement: 1000,
maxBackoff: 60000,
logLevel: 'info',
maxNetworkDelay: 10000,
requestHeaders: {},
appendMessageTypeToURL: true,
autoBatch: false,
urls: {},
maxURILength: 2000,
advice: {
timeout: 60000,
interval: 0,
reconnect: undefined,
maxInterval: 0
}
};
function _fieldValue(object, name) {
try {
return object[name];
} catch (x) {
return undefined;
}
}
/**
* Mixes in the given objects into the target object by copying the properties.
* @param deep if the copy must be deep
* @param target the target object
* @param objects the objects whose properties are copied into the target
*/
this._mixin = function (deep, target, objects) {
var result = target || {};
// Skip first 2 parameters (deep and target), and loop over the others
for (var i = 2; i < arguments.length; ++i) {
var object = arguments[i];
if (object === undefined || object === null) {
continue;
}
for (var propName in object) {
if (object.hasOwnProperty(propName)) {
var prop = _fieldValue(object, propName);
var targ = _fieldValue(result, propName);
// Avoid infinite loops
if (prop === target) {
continue;
}
// Do not mixin undefined values
if (prop === undefined) {
continue;
}
if (deep && _typeof(prop) === 'object' && prop !== null) {
if (prop instanceof Array) {
result[propName] = this._mixin(deep, targ instanceof Array ? targ : [], prop);
} else {
var source = _typeof(targ) === 'object' && !(targ instanceof Array) ? targ : {};
result[propName] = this._mixin(deep, source, prop);
}
} else {
result[propName] = prop;
}
}
}
}
return result;
};
function _isString(value) {
return Utils.isString(value);
}
function _isFunction(value) {
if (value === undefined || value === null) {
return false;
}
return typeof value === 'function';
}
function _zeroPad(value, length) {
var result = '';
while (--length > 0) {
if (value >= Math.pow(10, length)) {
break;
}
result += '0';
}
result += value;
return result;
}
function _log(level, args) {
if (window.console) {
var logger = window.console[level];
if (_isFunction(logger)) {
var now = new Date();
[].splice.call(args, 0, 0, _zeroPad(now.getHours(), 2) + ':' + _zeroPad(now.getMinutes(), 2) + ':' + _zeroPad(now.getSeconds(), 2) + '.' + _zeroPad(now.getMilliseconds(), 3));
logger.apply(window.console, args);
}
}
}
this._warn = function () {
_log('warn', arguments);
};
this._info = function () {
if (_config.logLevel !== 'warn') {
_log('info', arguments);
}
};
this._debug = function () {
if (_config.logLevel === 'debug') {
_log('debug', arguments);
}
};
function _splitURL(url) {
// [1] = protocol://,
// [2] = host:port,
// [3] = host,
// [4] = IPv6_host,
// [5] = IPv4_host,
// [6] = :port,
// [7] = port,
// [8] = uri,
// [9] = rest (query / fragment)
return new RegExp('(^https?://)?(((\\[[^\\]]+])|([^:/?#]+))(:(\\d+))?)?([^?#]*)(.*)?').exec(url);
}
/**
* Returns whether the given hostAndPort is cross domain.
* The default implementation checks against window.location.host
* but this function can be overridden to make it work in non-browser
* environments.
*
* @param hostAndPort the host and port in format host:port
* @return whether the given hostAndPort is cross domain
*/
this._isCrossDomain = function (hostAndPort) {
if (window.location && window.location.host) {
if (hostAndPort) {
return hostAndPort !== window.location.host;
}
}
return false;
};
function _configure(configuration) {
_cometd._debug('Configuring cometd object with', configuration);
// Support old style param, where only the Bayeux server URL was passed.
if (_isString(configuration)) {
configuration = {
url: configuration
};
}
if (!configuration) {
configuration = {};
}
_config = _cometd._mixin(false, _config, configuration);
var url = _cometd.getURL();
if (!url) {
throw 'Missing required configuration parameter \'url\' specifying the Bayeux server URL';
}
// Check if we're cross domain.
var urlParts = _splitURL(url);
var hostAndPort = urlParts[2];
var uri = urlParts[8];
var afterURI = urlParts[9];
_crossDomain = _cometd._isCrossDomain(hostAndPort);
// Check if appending extra path is supported.
if (_config.appendMessageTypeToURL) {
if (afterURI !== undefined && afterURI.length > 0) {
_cometd._info('Appending message type to URI ' + uri + afterURI + ' is not supported, disabling \'appendMessageTypeToURL\' configuration');
_config.appendMessageTypeToURL = false;
} else {
var uriSegments = uri.split('/');
var lastSegmentIndex = uriSegments.length - 1;
if (uri.match(/\/$/)) {
lastSegmentIndex -= 1;
}
if (uriSegments[lastSegmentIndex].indexOf('.') >= 0) {
// Very likely the CometD servlet's URL pattern is mapped to an extension, such as *.cometd
// It will be difficult to add the extra path in this case
_cometd._info('Appending message type to URI ' + uri + ' is not supported, disabling \'appendMessageTypeToURL\' configuration');
_config.appendMessageTypeToURL = false;
}
}
}
if (window.Worker && window.Blob && window.URL && _config.useWorkerScheduler) {
var code = WorkerScheduler.toString();
// Remove the function declaration, the opening brace and the closing brace.
code = code.substring(code.indexOf('{') + 1, code.lastIndexOf('}'));
var blob = new window.Blob([code], {
type: 'application/json'
});
var blobURL = window.URL.createObjectURL(blob);
var worker = new window.Worker(blobURL);
_scheduler.setTimeout = function (funktion, delay) {
var id = _scheduler.register(funktion);
worker.postMessage({
id: id,
type: 'setTimeout',
delay: delay
});
return id;
};
_scheduler.clearTimeout = function (id) {
_scheduler.unregister(id);
worker.postMessage({
id: id,
type: 'clearTimeout'
});
};
worker.onmessage = function (e) {
var id = e.data.id;
var funktion = _scheduler.unregister(id);
if (funktion) {
funktion();
}
};
}
}
function _removeListener(subscription) {
if (subscription) {
var subscriptions = _listeners[subscription.channel];
if (subscriptions && subscriptions[subscription.id]) {
delete subscriptions[subscription.id];
_cometd._debug('Removed', subscription.listener ? 'listener' : 'subscription', subscription);
}
}
}
function _removeSubscription(subscription) {
if (subscription && !subscription.listener) {
_removeListener(subscription);
}
}
function _clearSubscriptions() {
for (var channel in _listeners) {
if (_listeners.hasOwnProperty(channel)) {
var subscriptions = _listeners[channel];
if (subscriptions) {
for (var id in subscriptions) {
if (subscriptions.hasOwnProperty(id)) {
_removeSubscription(subscriptions[id]);
}
}
}
}
}
}
function _setStatus(newStatus) {
if (_status !== newStatus) {
_cometd._debug('Status', _status, '->', newStatus);
_status = newStatus;
}
}
function _isDisconnected() {
return _status === 'disconnecting' || _status === 'disconnected';
}
function _nextMessageId() {
var result = ++_messageId;
return '' + result;
}
function _applyExtension(scope, callback, name, message, outgoing) {
try {
return callback.call(scope, message);
} catch (x) {
var handler = _cometd.onExtensionException;
if (_isFunction(handler)) {
_cometd._debug('Invoking extension exception handler', name, x);
try {
handler.call(_cometd, x, name, outgoing, message);
} catch (xx) {
_cometd._info('Exception during execution of extension exception handler', name, xx);
}
} else {
_cometd._info('Exception during execution of extension', name, x);
}
return message;
}
}
function _applyIncomingExtensions(message) {
for (var i = 0; i < _extensions.length; ++i) {
if (message === undefined || message === null) {
break;
}
var extension = _extensions[i];
var callback = extension.extension.incoming;
if (_isFunction(callback)) {
var result = _applyExtension(extension.extension, callback, extension.name, message, false);
message = result === undefined ? message : result;
}
}
return message;
}
function _applyOutgoingExtensions(message) {
for (var i = _extensions.length - 1; i >= 0; --i) {
if (message === undefined || message === null) {
break;
}
var extension = _extensions[i];
var callback = extension.extension.outgoing;
if (_isFunction(callback)) {
var result = _applyExtension(extension.extension, callback, extension.name, message, true);
message = result === undefined ? message : result;
}
}
return message;
}
function _notify(channel, message) {
var subscriptions = _listeners[channel];
if (subscriptions) {
for (var id in subscriptions) {
if (subscriptions.hasOwnProperty(id)) {
var subscription = subscriptions[id];
// Subscriptions may come and go, so the array may have 'holes'
if (subscription) {
try {
subscription.callback.call(subscription.scope, message);
} catch (x) {
var handler = _cometd.onListenerException;
if (_isFunction(handler)) {
_cometd._debug('Invoking listener exception handler', subscription, x);
try {
handler.call(_cometd, x, subscription, subscription.listener, message);
} catch (xx) {
_cometd._info('Exception during execution of listener exception handler', subscription, xx);
}
} else {
_cometd._info('Exception during execution of listener', subscription, message, x);
}
}
}
}
}
}
}
function _notifyListeners(channel, message) {
// Notify direct listeners
_notify(channel, message);
// Notify the globbing listeners
var channelParts = channel.split('/');
var last = channelParts.length - 1;
for (var i = last; i > 0; --i) {
var channelPart = channelParts.slice(0, i).join('/') + '/*';
// We don't want to notify /foo/* if the channel is /foo/bar/baz,
// so we stop at the first non recursive globbing
if (i === last) {
_notify(channelPart, message);
}
// Add the recursive globber and notify
channelPart += '*';
_notify(channelPart, message);
}
}
function _cancelDelayedSend() {
if (_scheduledSend !== null) {
_cometd.clearTimeout(_scheduledSend);
}
_scheduledSend = null;
}
function _delayedSend(operation, delay) {
_cancelDelayedSend();
var time = _advice.interval + delay;
_cometd._debug('Function scheduled in', time, 'ms, interval =', _advice.interval, 'backoff =', _backoff, operation);
_scheduledSend = _cometd.setTimeout(operation, time);
}
// Needed to break cyclic dependencies between function definitions
var _handleMessages;
var _handleFailure;
/**
* Delivers the messages to the CometD server
* @param messages the array of messages to send
* @param metaConnect true if this send is on /meta/connect
* @param extraPath an extra path to append to the Bayeux server URL
*/
function _send(messages, metaConnect, extraPath) {
// We must be sure that the messages have a clientId.
// This is not guaranteed since the handshake may take time to return
// (and hence the clientId is not known yet) and the application
// may create other messages.
for (var i = 0; i < messages.length; ++i) {
var message = messages[i];
var messageId = message.id;
if (_clientId) {
message.clientId = _clientId;
}
message = _applyOutgoingExtensions(message);
if (message !== undefined && message !== null) {
// Extensions may have modified the message id, but we need to own it.
message.id = messageId;
messages[i] = message;
} else {
delete _callbacks[messageId];
messages.splice(i--, 1);
}
}
if (messages.length === 0) {
return;
}
if (metaConnect) {
_metaConnect = messages[0];
}
var url = _cometd.getURL();
if (_config.appendMessageTypeToURL) {
// If url does not end with '/', then append it
if (!url.match(/\/$/)) {
url = url + '/';
}
if (extraPath) {
url = url + extraPath;
}
}
var envelope = {
url: url,
sync: false,
messages: messages,
onSuccess: function onSuccess(rcvdMessages) {
try {
_handleMessages.call(_cometd, rcvdMessages);
} catch (x) {
_cometd._info('Exception during handling of messages', x);
}
},
onFailure: function onFailure(conduit, messages, failure) {
try {
var transport = _cometd.getTransport();
failure.connectionType = transport ? transport.getType() : "unknown";
_handleFailure.call(_cometd, conduit, messages, failure);
} catch (x) {
_cometd._info('Exception during handling of failure', x);
}
}
};
_cometd._debug('Send', envelope);
_transport.send(envelope, metaConnect);
}
function _queueSend(message) {
if (_batch > 0 || _internalBatch === true) {
_messageQueue.push(message);
} else {
_send([message], false);
}
}
/**
* Sends a complete bayeux message.
* This method is exposed as a public so that extensions may use it
* to send bayeux message directly, for example in case of re-sending
* messages that have already been sent but that for some reason must
* be resent.
*/
this.send = _queueSend;
function _resetBackoff() {
_backoff = 0;
}
function _increaseBackoff() {
if (_backoff < _config.maxBackoff) {
_backoff += _config.backoffIncrement;
}
return _backoff;
}
/**
* Starts a the batch of messages to be sent in a single request.
* @see #_endBatch(sendMessages)
*/
function _startBatch() {
++_batch;
_cometd._debug('Starting batch, depth', _batch);
}
function _flushBatch() {
var messages = _messageQueue;
_messageQueue = [];
if (messages.length > 0) {
_send(messages, false);
}
}
/**
* Ends the batch of messages to be sent in a single request,
* optionally sending messages present in the message queue depending
* on the given argument.
* @see #_startBatch()
*/
function _endBatch() {
--_batch;
_cometd._debug('Ending batch, depth', _batch);
if (_batch < 0) {
throw 'Calls to startBatch() and endBatch() are not paired';
}
if (_batch === 0 && !_isDisconnected() && !_internalBatch) {
_flushBatch();
}
}
/**
* Sends the connect message
*/
function _connect() {
if (!_isDisconnected()) {
var bayeuxMessage = {
id: _nextMessageId(),
channel: '/meta/connect',
connectionType: _transport.getType()
};
// In case of reload or temporary loss of connection
// we want the next successful connect to return immediately
// instead of being held by the server, so that connect listeners
// can be notified that the connection has been re-established
if (!_connected) {
bayeuxMessage.advice = {
timeout: 0
};
}
_setStatus('connecting');
_cometd._debug('Connect sent', bayeuxMessage);
_send([bayeuxMessage], true, 'connect');
_setStatus('connected');
}
}
function _delayedConnect(delay) {
_setStatus('connecting');
_delayedSend(function () {
_connect();
}, delay);
}
function _updateAdvice(newAdvice) {
if (newAdvice) {
_advice = _cometd._mixin(false, {}, _config.advice, newAdvice);
_cometd._debug('New advice', _advice);
}
}
function _disconnect(abort) {
_cancelDelayedSend();
if (abort && _transport) {
_transport.abort();
}
_crossDomain = false;
_transport = null;
_setStatus('disconnected');
_clientId = null;
_batch = 0;
_resetBackoff();
_reestablish = false;
_connected = false;
_unconnectTime = 0;
_metaConnect = null;
// Fail any existing queued message
if (_messageQueue.length > 0) {
var messages = _messageQueue;
_messageQueue = [];
_handleFailure.call(_cometd, undefined, messages, {
reason: 'Disconnected'
});
}
}
function _notifyTransportException(oldTransport, newTransport, failure) {
var handler = _cometd.onTransportException;
if (_isFunction(handler)) {
_cometd._debug('Invoking transport exception handler', oldTransport, newTransport, failure);
try {
handler.call(_cometd, failure, oldTransport, newTransport);
} catch (x) {
_cometd._info('Exception during execution of transport exception handler', x);
}
}
}
/**
* Sends the initial handshake message
*/
function _handshake(handshakeProps, handshakeCallback) {
if (_isFunction(handshakeProps)) {
handshakeCallback = handshakeProps;
handshakeProps = undefined;
}
_clientId = null;
_clearSubscriptions();
// Reset the transports if we're not retrying the handshake
if (_isDisconnected()) {
_transports.reset(true);
}
// Reset the advice.
_updateAdvice({});
_batch = 0;
// Mark the start of an internal batch.
// This is needed because handshake and connect are async.
// It may happen that the application calls init() then subscribe()
// and the subscribe message is sent before the connect message, if
// the subscribe message is not held until the connect message is sent.
// So here we start a batch to hold temporarily any message until
// the connection is fully established.
_internalBatch = true;
// Save the properties provided by the user, so that
// we can reuse them during automatic re-handshake
_handshakeProps = handshakeProps;
_handshakeCallback = handshakeCallback;
var version = '1.0';
// Figure out the transports to send to the server
var url = _cometd.getURL();
var transportTypes = _transports.findTransportTypes(version, _crossDomain, url);
var bayeuxMessage = {
id: _nextMessageId(),
version: version,
minimumVersion: version,
channel: '/meta/handshake',
supportedConnectionTypes: transportTypes,
advice: {
timeout: _advice.timeout,
interval: _advice.interval
}
};
// Do not allow the user to override important fields.
var message = _cometd._mixin(false, {}, _handshakeProps, bayeuxMessage);
// Save the callback.
_cometd._putCallback(message.id, handshakeCallback);
// Pick up the first available transport as initial transport
// since we don't know if the server supports it
if (!_transport) {
_transport = _transports.negotiateTransport(transportTypes, version, _crossDomain, url);
if (!_transport) {
var failure = 'Could not find initial transport among: ' + _transports.getTransportTypes();
_cometd._warn(failure);
throw failure;
}
}
_cometd._debug('Initial transport is', _transport.getType());
// We started a batch to hold the application messages,
// so here we must bypass it and send immediately.
_setStatus('handshaking');
_cometd._debug('Handshake sent', message);
_send([message], false, 'handshake');
}
function _delayedHandshake(delay) {
_setStatus('handshaking');
// We will call _handshake() which will reset _clientId, but we want to avoid
// that between the end of this method and the call to _handshake() someone may
// call publish() (or other methods that call _queueSend()).
_internalBatch = true;
_delayedSend(function () {
_handshake(_handshakeProps, _handshakeCallback);
}, delay);
}
function _notifyCallback(callback, message) {
try {
callback.call(_cometd, message);
} catch (x) {
var handler = _cometd.onCallbackException;
if (_isFunction(handler)) {
_cometd._debug('Invoking callback exception handler', x);
try {
handler.call(_cometd, x, message);
} catch (xx) {
_cometd._info('Exception during execution of callback exception handler', xx);
}
} else {
_cometd._info('Exception during execution of message callback', x);
}
}
}
this._getCallback = function (messageId) {
return _callbacks[messageId];
};
this._putCallback = function (messageId, callback) {
var result = this._getCallback(messageId);
if (_isFunction(callback)) {
_callbacks[messageId] = callback;
}
return result;
};
function _handleCallback(message) {
var callback = _cometd._getCallback([message.id]);
if (_isFunction(callback)) {
delete _callbacks[message.id];
_notifyCallback(callback, message);
}
}
function _handleRemoteCall(message) {
var context = _remoteCalls[message.id];
delete _remoteCalls[message.id];
if (context) {
_cometd._debug('Handling remote call response for', message, 'with context', context);
// Clear the timeout, if present.
var timeout = context.timeout;
if (timeout) {
_cometd.clearTimeout(timeout);
}
var callback = context.callback;
if (_isFunction(callback)) {
_notifyCallback(callback, message);
return true;
}
}
return false;
}
this.onTransportFailure = function (message, failureInfo, failureHandler) {
this._debug('Transport failure', failureInfo, 'for', message);
var transports = this.getTransportRegistry();
var url = this.getURL();
var crossDomain = this._isCrossDomain(_splitURL(url)[2]);
var version = '1.0';
var transportTypes = transports.findTransportTypes(version, crossDomain, url);
if (failureInfo.action === 'none') {
if (message.channel === '/meta/handshake') {
if (!failureInfo.transport) {
var failure = 'Could not negotiate transport, client=[' + transportTypes + '], server=[' + message.supportedConnectionTypes + ']';
this._warn(failure);
_notifyTransportException(_transport.getType(), null, {
reason: failure,
connectionType: _transport.getType(),
transport: _transport
});
}
}
} else {
failureInfo.delay = this.getBackoffPeriod();
// Different logic depending on whether we are handshaking or connecting.
if (message.channel === '/meta/handshake') {
if (!failureInfo.transport) {
// The transport is invalid, try to negotiate again.
var oldTransportType = _transport ? _transport.getType() : null;
var newTransport = transports.negotiateTransport(transportTypes, version, crossDomain, url);
if (!newTransport) {
this._warn('Could not negotiate transport, client=[' + transportTypes + ']');
_notifyTransportException(oldTransportType, null, message.failure);
failureInfo.action = 'none';
} else {
var newTransportType = newTransport.getType();
this._debug('Transport', oldTransportType, '->', newTransportType);
_notifyTransportException(oldTransportType, newTransportType, message.failure);
failureInfo.action = 'handshake';
failureInfo.transport = newTransport;
}
}
if (failureInfo.action !== 'none') {
this.increaseBackoffPeriod();
}
} else {
var now = new Date().getTime();
if (_unconnectTime === 0) {
_unconnectTime = now;
}
if (failureInfo.action === 'retry') {
failureInfo.delay = this.increaseBackoffPeriod();
// Check whether we may switch to handshaking.
var maxInterval = _advice.maxInterval;
if (maxInterval > 0) {
var expiration = _advice.timeout + _advice.interval + maxInterval;
var unconnected = now - _unconnectTime;
if (unconnected + _backoff > expiration) {
failureInfo.action = 'handshake';
}
}
}
if (failureInfo.action === 'handshake') {
failureInfo.delay = 0;
transports.reset(false);
this.resetBackoffPeriod();
}
}
}
failureHandler.call(_cometd, failureInfo);
};
function _handleTransportFailure(failureInfo) {
_cometd._debug('Transport failure handling', failureInfo);
if (failureInfo.transport) {
_transport = failureInfo.transport;
}
if (failureInfo.url) {
_transport.setURL(failureInfo.url);
}
var action = failureInfo.action;
var delay = failureInfo.delay || 0;
switch (action) {
case 'handshake':
_delayedHandshake(delay);
break;
case 'retry':
_delayedConnect(delay);
break;
case 'none':
_disconnect(true);
break;
default:
throw 'Unknown action ' + action;
}
}
function _failHandshake(message, failureInfo) {
_handleCallback(message);
_notifyListeners('/meta/handshake', message);
_notifyListeners('/meta/unsuccessful', message);
// The listeners may have disconnected.
if (_isDisconnected()) {
failureInfo.action = 'none';
}
_cometd.onTransportFailure.call(_cometd, message, failureInfo, _handleTransportFailure);
}
function _handshakeResponse(message) {
var url = _cometd.getURL();
if (message.successful) {
var crossDomain = _cometd._isCrossDomain(_splitURL(url)[2]);
var newTransport = _transports.negotiateTransport(message.supportedConnectionTypes, message.version, crossDomain, url);
if (newTransport === null) {
message.successful = false;
_failHandshake(message, {
cause: 'negotiation',
action: 'none',
transport: null
});
return;
} else if (_transport !== newTransport) {
_cometd._debug('Transport', _transport.getType(), '->', newTransport.getType());
_transport = newTransport;
}
_clientId = message.clientId;
// End the internal batch and allow held messages from the application
// to go to the server (see _handshake() where we start the internal batch).
_internalBatch = false;
_flushBatch();
// Here the new transport is in place, as well as the clientId, so
// the listeners can perform a publish() if they want.
// Notify the listeners before the connect below.
message.reestablish = _reestablish;
_reestablish = true;
_handleCallback(message);
_notifyListeners('/meta/handshake', message);
_handshakeMessages = message['x-messages'] || 0;
var action = _isDisconnected() ? 'none' : _advice.reconnect || 'retry';
switch (action) {
case 'retry':
_resetBackoff();
if (_handshakeMessages === 0) {
_delayedConnect(0);
} else {
_cometd._debug('Processing', _handshakeMessages, 'handshake-delivered messages');
}
break;
case 'none':
_disconnect(true);
break;
default:
throw 'Unrecognized advice action ' + action;
}
} else {
_failHandshake(message, {
cause: 'unsuccessful',
action: _advice.reconnect || 'handshake',
transport: _transport
});
}
}
function _handshakeFailure(message) {
_failHandshake(message, {
cause: 'failure',
action: 'handshake',
transport: null
});
}
function _matchMetaConnect(connect) {
if (_status === 'disconnected') {
return true;
}
if (_metaConnect && _metaConnect.id === connect.id) {
_metaConnect = null;
return true;
}
return false;
}
function _failConnect(message, failureInfo) {
// Notify the listeners after the status change but before the next action.
_notifyListeners('/meta/connect', message);
_notifyListeners('/meta/unsuccessful', message);
// The listeners may have disconnected.
if (_isDisconnected()) {
failureInfo.action = 'none';
}
_cometd.onTransportFailure.call(_cometd, message, failureInfo, _handleTransportFailure);
}
function _connectResponse(message) {
if (_matchMetaConnect(message)) {
_connected = message.successful;
if (_connected) {
_notifyListeners('/meta/connect', message);
// Normally, the advice will say "reconnect: 'retry', interval: 0"
// and the server will hold the request, so when a response returns
// we immediately call the server again (long polling).
// Listeners can call disconnect(), so check the state after they run.
var action = _isDisconnected() ? 'none' : _advice.reconnect || 'retry';
switch (action) {
case 'retry':
_resetBackoff();
_delayedConnect(_backoff);
break;
case 'none':
_disconnect(false);
break;
default:
throw 'Unrecognized advice action ' + action;
}
} else {
_failConnect(message, {
cause: 'unsuccessful',
action: _advice.reconnect || 'retry',
transport: _transport
});
}
} else {
_cometd._debug('Mismatched /meta/connect reply', message);
}
}
function _connectFailure(message) {
if (_matchMetaConnect(message)) {
_connected = false;
_failConnect(message, {
cause: 'failure',
action: 'retry',
transport: null
});
} else {
_cometd._debug('Mismatched /meta/connect failure', message);
}
}
function _failDisconnect(message) {
_disconnect(true);
_handleCallback(message);
_notifyListeners('/meta/disconnect', message);
_notifyListeners('/meta/unsuccessful', message);
}
function _disconnectResponse(message) {
if (message.successful) {
// Wait for the /meta/connect to arrive.
_disconnect(false);
_handleCallback(message);
_notifyListeners('/meta/disconnect', message);
} else {
_failDisconnect(message);
}
}
function _disconnectFailure(message) {
_failDisconnect(message);
}
function _failSubscribe(message) {
var subscriptions = _listeners[message.subscription];
if (subscriptions) {
for (var id in subscriptions) {
if (subscriptions.hasOwnProperty(id)) {
var subscription = subscriptions[id];
if (subscription && !subscription.listener) {
delete subscriptions[id];
_cometd._debug('Removed failed subscription', subscription);
}
}
}
}
_handleCallback(message);
_notifyListeners('/meta/subscribe', message);
_notifyListeners('/meta/unsuccessful', message);
}
function _subscribeResponse(message) {
if (message.successful) {
_handleCallback(message);
_notifyListeners('/meta/subscribe', message);
} else {
_failSubscribe(message);
}
}
function _subscribeFailure(message) {
_failSubscribe(message);
}
function _failUnsubscribe(message) {
_handleCallback(message);
_notifyListeners('/meta/unsubscribe', message);
_notifyListeners('/meta/unsuccessful', message);
}
function _unsubscribeResponse(message) {
if (message.successful) {
_handleCallback(message);
_notifyListeners('/meta/unsubscribe', message);
} else {
_failUnsubscribe(message);
}
}
function _unsubscribeFailure(message) {
_failUnsubscribe(message);
}
function _failMessage(message) {
if (!_handleRemoteCall(message)) {
_handleCallback(message);
_notifyListeners('/meta/publish', message);
_notifyListeners('/meta/unsuccessful', message);
}
}
function _messageResponse(message) {
if (message.data !== undefined) {
if (!_handleRemoteCall(message)) {
_notifyListeners(message.channel, message);
if (_handshakeMessages > 0) {
--_handshakeMessages;
if (_handshakeMessages === 0) {
_cometd._debug('Processed last handshake-delivered message');
_delayedConnect(0);
}
}
}
} else {
if (message.successful === undefined) {
_cometd._warn('Unknown Bayeux Message', message);
} else {
if (message.successful) {
_handleCallback(message);
_notifyListeners('/meta/publish', message);
} else {
_failMessage(message);
}
}
}
}
function _messageFailure(failure) {
_failMessage(failure);
}
function _receive(message) {
_unconnectTime = 0;
message = _applyIncomingExtensions(message);
if (message === undefined || message === null) {
return;
}
_updateAdvice(message.advice);
var channel = message.channel;
switch (channel) {
case '/meta/handshake':
_handshakeResponse(message);
break;
case '/meta/connect':
_connectResponse(message);
break;
case '/meta/disconnect':
_disconnectResponse(message);
break;
case '/meta/subscribe':
_subscribeResponse(message);
break;
case '/meta/unsubscribe':
_unsubscribeResponse(message);
break;
default:
_messageResponse(message);
break;
}
}
/**
* Receives a message.
* This method is exposed as a public so that extensions may inject
* messages simulating that they had been received.
*/
this.receive = _receive;
_handleMessages = function _handleMessages(rcvdMessages) {
_cometd._debug('Received', rcvdMessages);
for (var i = 0; i < rcvdMessages.length; ++i) {
var message = rcvdMessages[i];
_receive(message);
}
};
_handleFailure = function _handleFailure(conduit, messages, failure) {
_cometd._debug('handleFailure', conduit, messages, failure);
failure.transport = conduit;
for (var i = 0; i < messages.length; ++i) {
var message = messages[i];
var failureMessage = {
id: message.id,
successful: false,
channel: message.channel,
failure: failure
};
failure.message = message;
switch (message.channel) {
case '/meta/handshake':
_handshakeFailure(failureMessage);
break;
case '/meta/connect':
_connectFailure(failureMessage);
break;
case '/meta/disconnect':
_disconnectFailure(failureMessage);
break;
case '/meta/subscribe':
failureMessage.subscription = message.subscription;
_subscribeFailure(failureMessage);
break;
case '/meta/unsubscribe':
failureMessage.subscription = message.subscription;
_unsubscribeFailure(failureMessage);
break;
default:
_messageFailure(failureMessage);
break;
}
}
};
function _hasSubscriptions(channel) {
var subscriptions = _listeners[channel];
if (subscriptions) {
for (var id in subscriptions) {
if (subscriptions.hasOwnProperty(id)) {
if (subscriptions[id]) {
return true;
}
}
}
}
return false;
}
function _resolveScopedCallback(scope, callback) {
var delegate = {
scope: scope,
method: callback
};
if (_isFunction(scope)) {
delegate.scope = undefined;
delegate.method = scope;
} else {
if (_isString(callback)) {
if (!scope) {
throw 'Invalid scope ' + scope;
}
delegate.method = scope[callback];
if (!_isFunction(delegate.method)) {
throw 'Invalid callback ' + callback + ' for scope ' + scope;
}
} else if (!_isFunction(callback)) {
throw 'Invalid callback ' + callback;
}
}
return delegate;
}
function _addListener(channel, scope, callback, isListener) {
// The data structure is a map, where each subscription
// holds the callback to be called and its scope.
var delegate = _resolveScopedCallback(scope, callback);
_cometd._debug('Adding', isListener ? 'listener' : 'subscription', 'on', channel, 'with scope', delegate.scope, 'and callback', delegate.method);
var id = ++_listenerId;
var subscription = {
id: id,
channel: channel,
scope: delegate.scope,
callback: delegate.method,
listener: isListener
};
var subscriptions = _listeners[channel];
if (!subscriptions) {
subscriptions = {};
_listeners[channel] = subscriptions;
}
subscriptions[id] = subscription;
_cometd._debug('Added', isListener ? 'listener' : 'subscription', subscription);
return subscription;
}
//
// PUBLIC API
//
/**
* Registers the given transport under the given transport type.
* The optional index parameter specifies the "priority" at which the
* transport is registered (where 0 is the max priority).
* If a transport with the same type is already registered, this function
* does nothing and returns false.
* @param type the transport type
* @param transport the transport object
* @param index the index at which this transport is to be registered
* @return true if the transport has been registered, false otherwise
* @see #unregisterTransport(type)
*/
this.registerTransport = function (type, transport, index) {
var result = _transports.add(type, transport, index);
if (result) {
this._debug('Registered transport', type);
if (_isFunction(transport.registered)) {
transport.registered(type, this);
}
}
return result;
};
/**
* Unregisters the transport with the given transport type.
* @param type the transport type to unregister
* @return the transport that has been unregistered,
* or null if no transport was previously registered under the given transport type
*/
this.unregisterTransport = function (type) {
var transport = _transports.remove(type);
if (transport !== null) {
this._debug('Unregistered transport', type);
if (_isFunction(transport.unregistered)) {
transport.unregistered();
}
}
return transport;
};
this.unregisterTransports = function () {
_transports.clear();
};
/**
* @return an array of all registered transport types
*/
this.getTransportTypes = function () {
return _transports.getTransportTypes();
};
this.findTransport = function (name) {
return _transports.find(name);
};
/**
* @returns the TransportRegistry object
*/
this.getTransportRegistry = function () {
return _transports;
};
/**
* Configures the initial Bayeux communication with the Bayeux server.
* Configuration is passed via an object that must contain a mandatory field url
* of type string containing the URL of the Bayeux server.
* @param configuration the configuration object
*/
this.configure = function (configuration) {
_configure.call(this, configuration);
};
/**
* Configures and establishes the Bayeux communication with the Bayeux server
* via a handshake and a subsequent connect.
* @param configuration the configuration object
* @param handshakeProps an object to be merged with the handshake message
* @see #configure(configuration)
* @see #handshake(handshakeProps)
*/
this.init = function (configuration, handshakeProps) {
this.configure(configuration);
this.handshake(handshakeProps);
};
/**
* Establishes the Bayeux communication with the Bayeux server
* via a handshake and a subsequent connect.
* @param handshakeProps an object to be merged with the handshake message
* @param handshakeCallback a function to be invoked when the handshake is acknowledged
*/
this.handshake = function (handshakeProps, handshakeCallback) {
if (_status !== 'disconnected') {
throw 'Illegal state: handshaken';
}
_handshake(handshakeProps, handshakeCallback);
};
/**
* Disconnects from the Bayeux server.
* @param disconnectProps an object to be merged with the disconnect message
* @param disconnectCallback a function to be invoked when the disconnect is acknowledged
*/
this.disconnect = function (disconnectProps, disconnectCallback) {
if (_isDisconnected()) {
return;
}
if (_isFunction(disconnectProps)) {
disconnectCallback = disconnectProps;
disconnectProps = undefined;
}
var bayeuxMessage = {
id: _nextMessageId(),
channel: '/meta/disconnect'
};
// Do not allow the user to override important fields.
var message = this._mixin(false, {}, disconnectProps, bayeuxMessage);
// Save the callback.
_cometd._putCallback(message.id, disconnectCallback);
_setStatus('disconnecting');
_send([message], false, 'disconnect');
};
/**
* Marks the start of a batch of application messages to be sent to the server
* in a single request, obtaining a single response containing (possibly) many
* application reply messages.
* Messages are held in a queue and not sent until {@link #endBatch()} is called.
* If startBatch() is called multiple times, then an equal number of endBatch()
* calls must be made to close and send the batch of messages.
* @see #endBatch()
*/
this.startBatch = function () {
_startBatch();
};
/**
* Marks the end of a batch of application messages to be sent to the server
* in a single request.
* @see #startBatch()
*/
this.endBatch = function () {
_endBatch();
};
/**
* Executes the given callback in the given scope, surrounded by a {@link #startBatch()}
* and {@link #endBatch()} calls.
* @param scope the scope of the callback, may be omitted
* @param callback the callback to be executed within {@link #startBatch()} and {@link #endBatch()} calls
*/
this.batch = function (scope, callback) {
var delegate = _resolveScopedCallback(scope, callback);
this.startBatch();
try {
delegate.method.call(delegate.scope);
this.endBatch();
} catch (x) {
this._info('Exception during execution of batch', x);
this.endBatch();
throw x;
}
};
/**
* Adds a listener for bayeux messages, performing the given callback in the given scope
* when a message for the given channel arrives.
* @param channel the channel the listener is interested to
* @param scope the scope of the callback, may be omitted
* @param callback the callback to call when a message is sent to the channel
* @returns the subscription handle to be passed to {@link #removeListener(object)}
* @see #removeListener(subscription)
*/
this.addListener = function (channel, scope, callback) {
if (arguments.length < 2) {
throw 'Illegal arguments number: required 2, got ' + arguments.length;
}
if (!_isString(channel)) {
throw 'Illegal argument type: channel must be a string';
}
return _addListener(channel, scope, callback, true);
};
/**
* Removes the subscription obtained with a call to {@link #addListener(string, object, function)}.
* @param subscription the subscription to unsubscribe.
* @see #addListener(channel, scope, callback)
*/
this.removeListener = function (subscription) {
// Beware of subscription.id == 0, which is falsy => cannot use !subscription.id
if (!subscription || !subscription.channel || !("id" in subscription)) {
throw 'Invalid argument: expected subscription, not ' + subscription;
}
_removeListener(subscription);
};
/**
* Removes all listeners registered with {@link #addListener(channel, scope, callback)} or
* {@link #subscribe(channel, scope, callback)}.
*/
this.clearListeners = function () {
_listeners = {};
};
/**
* Subscribes to the given channel, performing the given callback in the given scope
* when a message for the channel arrives.
* @param channel the channel to subscribe to
* @param scope the scope of the callback, may be omitted
* @param callback the callback to call when a message is sent to the channel
* @param subscribeProps an object to be merged with the subscribe message
* @param subscribeCallback a function to be invoked when the subscription is acknowledged
* @return the subscription handle to be passed to {@link #unsubscribe(object)}
*/
this.subscribe = function (channel, scope, callback, subscribeProps, subscribeCallback) {
if (arguments.length < 2) {
throw 'Illegal arguments number: required 2, got ' + arguments.length;
}
if (!_isString(channel)) {
throw 'Illegal argument type: channel must be a string';
}
if (_isDisconnected()) {
throw 'Illegal state: disconnected';
}
// Normalize arguments
if (_isFunction(scope)) {
subscribeCallback = subscribeProps;
subscribeProps = callback;
callback = scope;
scope = undefined;
}
if (_isFunction(subscribeProps)) {
subscribeCallback = subscribeProps;
subscribeProps = undefined;
}
// Only send the message to the server if this client has not yet subscribed to the channel
var send = !_hasSubscriptions(channel);
var subscription = _addListener(channel, scope, callback, false);
if (send) {
// Send the subscription message after the subscription registration to avoid
// races where the server would send a message to the subscribers, but here
// on the client the subscription has not been added yet to the data structures
var bayeuxMessage = {
id: _nextMessageId(),
channel: '/meta/subscribe',
subscription: channel
};
// Do not allow the user to override important fields.
var message = this._mixin(false, {}, subscribeProps, bayeuxMessage);
// Save the callback.
_cometd._putCallback(message.id, subscribeCallback);
_queueSend(message);
}
return subscription;
};
/**
* Unsubscribes the subscription obtained with a call to {@link #subscribe(string, object, function)}.
* @param subscription the subscription to unsubscribe.
* @param unsubscribeProps an object to be merged with the unsubscribe message
* @param unsubscribeCallback a function to be invoked when the unsubscription is acknowledged
*/
this.unsubscribe = function (subscription, unsubscribeProps, unsubscribeCallback) {
if (arguments.length < 1) {
throw 'Illegal arguments number: required 1, got ' + arguments.length;
}
if (_isDisconnected()) {
throw 'Illegal state: disconnected';
}
if (_isFunction(unsubscribeProps)) {
unsubscribeCallback = unsubscribeProps;
unsubscribeProps = undefined;
}
// Remove the local listener before sending the message
// This ensures that if the server fails, this client does not get notifications
this.removeListener(subscription);
var channel = subscription.channel;
// Only send the message to the server if this client unsubscribes the last subscription
if (!_hasSubscriptions(channel)) {
var bayeuxMessage = {
id: _nextMessageId(),
channel: '/meta/unsubscribe',
subscription: channel
};
// Do not allow the user to override important fields.
var message = this._mixin(false, {}, unsubscribeProps, bayeuxMessage);
// Save the callback.
_cometd._putCallback(message.id, unsubscribeCallback);
_queueSend(message);
}
};
this.resubscribe = function (subscription, subscribeProps) {
_removeSubscription(subscription);
if (subscription) {
return this.subscribe(subscription.channel, subscription.scope, subscription.callback, subscribeProps);
}
return undefined;
};
/**
* Removes all subscriptions added via {@link #subscribe(channel, scope, callback, subscribeProps)},
* but does not remove the listeners added via {@link addListener(channel, scope, callback)}.
*/
this.clearSubscriptions = function () {
_clearSubscriptions();
};
/**
* Publishes a message on the given channel, containing the given content.
* @param channel the channel to publish the message to
* @param content the content of the message
* @param publishProps an object to be merged with the publish message
* @param publishCallback a function to be invoked when the publish is acknowledged by the server
*/
this.publish = function (channel, content, publishProps, publishCallback) {
if (arguments.length < 1) {
throw 'Illegal arguments number: required 1, got ' + arguments.length;
}
if (!_isString(channel)) {
throw 'Illegal argument type: channel must be a string';
}
if (/^\/meta\//.test(channel)) {
throw 'Illegal argument: cannot publish to meta channels';
}
if (_isDisconnected()) {
throw 'Illegal state: disconnected';
}
if (_isFunction(content)) {
publishCallback = content;
content = {};
publishProps = undefined;
} else if (_isFunction(publishProps)) {
publishCallback = publishProps;
publishProps = undefined;
}
var bayeuxMessage = {
id: _nextMessageId(),
channel: channel,
data: content
};
// Do not allow the user to override important fields.
var message = this._mixin(false, {}, publishProps, bayeuxMessage);
// Save the callback.
_cometd._putCallback(message.id, publishCallback);
_queueSend(message);
};
/**
* Publishes a message with binary data on the given channel.
* The binary data chunk may be an ArrayBuffer, a DataView, a TypedArray
* (such as Uint8Array) or a plain integer array.
* The meta data object may contain additional application data such as
* a file name, a mime type, etc.
* @param channel the channel to publish the message to
* @param data the binary data to publish
* @param last whether the binary data chunk is the last
* @param meta an object containing meta data associated to the binary chunk
* @param callback a function to be invoked when the publish is acknowledged by the server
*/
this.publishBinary = function (channel, data, last, meta, callback) {
if (_isFunction(data)) {
callback = data;
data = new ArrayBuffer(0);
last = true;
meta = undefined;
} else if (_isFunction(last)) {
callback = last;
last = true;
meta = undefined;
} else if (_isFunction(meta)) {
callback = meta;
meta = undefined;
}
var content = {
meta: meta,
data: data,
last: last
};
var ext = {
ext: {
binary: {}
}
};
this.publish(channel, content, ext, callback);
};
this.remoteCall = function (target, content, timeout, callProps, callback) {
if (arguments.length < 1) {
throw 'Illegal arguments number: required 1, got ' + arguments.length;
}
if (!_isString(target)) {
throw 'Illegal argument type: target must be a string';
}
if (_isDisconnected()) {
throw 'Illegal state: disconnected';
}
if (_isFunction(content)) {
callback = content;
content = {};
timeout = _config.maxNetworkDelay;
callProps = undefined;
} else if (_isFunction(timeout)) {
callback = timeout;
timeout = _config.maxNetworkDelay;
callProps = undefined;
} else if (_isFunction(callProps)) {
callback = callProps;
callProps = undefined;
}
if (typeof timeout !== 'number') {
throw 'Illegal argument type: timeout must be a number';
}
if (!target.match(/^\//)) {
target = '/' + target;
}
var channel = '/service' + target;
var bayeuxMessage = {
id: _nextMessageId(),
channel: channel,
data: content
};
var message = this._mixin(false, {}, callProps, bayeuxMessage);
var context = {
callback: callback
};
if (timeout > 0) {
context.timeout = _cometd.setTimeout(function () {
_cometd._debug('Timing out remote call', message, 'after', timeout, 'ms');
_failMessage({
id: message.id,
error: '406::timeout',
successful: false,
failure: {
message: message,
reason: 'Remote Call Timeout'
}
});
}, timeout);
_cometd._debug('Scheduled remote call timeout', message, 'in', timeout, 'ms');
}
_remoteCalls[message.id] = context;
_queueSend(message);
};
this.remoteCallBinary = function (target, data, last, meta, timeout, callback) {
if (_isFunction(data)) {
callback = data;
data = new ArrayBuffer(0);
last = true;
meta = undefined;
timeout = _config.maxNetworkDelay;
} else if (_isFunction(last)) {
callback = last;
last = true;
meta = undefined;
timeout = _config.maxNetworkDelay;
} else if (_isFunction(meta)) {
callback = meta;
meta = undefined;
timeout = _config.maxNetworkDelay;
} else if (_isFunction(timeout)) {
callback = timeout;
timeout = _config.maxNetworkDelay;
}
var content = {
meta: meta,
data: data,
last: last
};
var ext = {
ext: {
binary: {}
}
};
this.remoteCall(target, content, timeout, ext, callback);
};
/**
* Returns a string representing the status of the bayeux communication with the Bayeux server.
*/
this.getStatus = function () {
return _status;
};
/**
* Returns whether this instance has been disconnected.
*/
this.isDisconnected = _isDisconnected;
/**
* Sets the backoff period used to increase the backoff time when retrying an unsuccessful or failed message.
* Default value is 1 second, which means if there is a persistent failure the retries will happen
* after 1 second, then after 2 seconds, then after 3 seconds, etc. So for example with 15 seconds of
* elapsed time, there will be 5 retries (at 1, 3, 6, 10 and 15 seconds elapsed).
* @param period the backoff period to set
* @see #getBackoffIncrement()
*/
this.setBackoffIncrement = function (period) {
_config.backoffIncrement = period;
};
/**
* Returns the backoff period used to increase the backoff time when retrying an unsuccessful or failed message.
* @see #setBackoffIncrement(period)
*/
this.getBackoffIncrement = function () {
return _config.backoffIncrement;
};
/**
* Returns the backoff period to wait before retrying an unsuccessful or failed message.
*/
this.getBackoffPeriod = function () {
return _backoff;
};
/**
* Increases the backoff period up to the maximum value configured.
* @returns the backoff period after increment
* @see getBackoffIncrement
*/
this.increaseBackoffPeriod = function () {
return _increaseBackoff();
};
/**
* Resets the backoff period to zero.
*/
this.resetBackoffPeriod = function () {
_resetBackoff();
};
/**
* Sets the log level for console logging.
* Valid values are the strings 'error', 'warn', 'info' and 'debug', from
* less verbose to more verbose.
* @param level the log level string
*/
this.setLogLevel = function (level) {
_config.logLevel = level;
};
/**
* Registers an extension whose callbacks are called for every incoming message
* (that comes from the server to this client implementation) and for every
* outgoing message (that originates from this client implementation for the
* server).
* The format of the extension object is the following:
*
* {
* incoming: function(message) { ... },
* outgoing: function(message) { ... }
* }
*
* Both properties are optional, but if they are present they will be called
* respectively for each incoming message and for each outgoing message.
* @param name the name of the extension
* @param extension the extension to register
* @return true if the extension was registered, false otherwise
* @see #unregisterExtension(name)
*/
this.registerExtension = function (name, extension) {
if (arguments.length < 2) {
throw 'Illegal arguments number: required 2, got ' + arguments.length;
}
if (!_isString(name)) {
throw 'Illegal argument type: extension name must be a string';
}
var existing = false;
for (var i = 0; i < _extensions.length; ++i) {
var existingExtension = _extensions[i];
if (existingExtension.name === name) {
existing = true;
break;
}
}
if (!existing) {
_extensions.push({
name: name,
extension: extension
});
this._debug('Registered extension', name);
// Callback for extensions
if (_isFunction(extension.registered)) {
extension.registered(name, this);
}
return true;
} else {
this._info('Could not register extension with name', name, 'since another extension with the same name already exists');
return false;
}
};
/**
* Unregister an extension previously registered with
* {@link #registerExtension(name, extension)}.
* @param name the name of the extension to unregister.
* @return true if the extension was unregistered, false otherwise
*/
this.unregisterExtension = function (name) {
if (!_isString(name)) {
throw 'Illegal argument type: extension name must be a string';
}
var unregistered = false;
for (var i = 0; i < _extensions.length; ++i) {
var extension = _extensions[i];
if (extension.name === name) {
_extensions.splice(i, 1);
unregistered = true;
this._debug('Unregistered extension', name);
// Callback for extensions
var ext = extension.extension;
if (_isFunction(ext.unregistered)) {
ext.unregistered();
}
break;
}
}
return unregistered;
};
/**
* Find the extension registered with the given name.
* @param name the name of the extension to find
* @return the extension found or null if no extension with the given name has been registered
*/
this.getExtension = function (name) {
for (var i = 0; i < _extensions.length; ++i) {
var extension = _extensions[i];
if (extension.name === name) {
return extension.extension;
}
}
return null;
};
/**
* Returns the name assigned to this CometD object, or the string 'default'
* if no name has been explicitly passed as parameter to the constructor.
*/
this.getName = function () {
return _name;
};
/**
* Returns the clientId assigned by the Bayeux server during handshake.
*/
this.getClientId = function () {
return _clientId;
};
/**
* Returns the URL of the Bayeux server.
*/
this.getURL = function () {
if (_transport) {
var url = _transport.getURL();
if (url) {
return url;
}
url = _config.urls[_transport.getType()];
if (url) {
return url;
}
}
return _config.url;
};
this.getTransport = function () {
return _transport;
};
this.getConfiguration = function () {
return this._mixin(true, {}, _config);
};
this.getAdvice = function () {
return this._mixin(true, {}, _advice);
};
this.setTimeout = function (funktion, delay) {
return _scheduler.setTimeout(function () {
try {
_cometd._debug('Invoking timed function', funktion);
funktion();
} catch (x) {
_cometd._debug('Exception invoking timed function', funktion, x);
}
}, delay);
};
this.clearTimeout = function (id) {
_scheduler.clearTimeout(id);
};
// Initialize transports.
if (window.WebSocket) {
this.registerTransport('websocket', new WebSocketTransport());
}
this.registerTransport('long-polling', new LongPollingTransport());
this.registerTransport('callback-polling', new CallbackPollingTransport());
};
var _z85EncodeTable = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '.', '-', ':', '+', '=', '^', '!', '/', '*', '?', '&', '<', '>', '(', ')', '[', ']', '{', '}', '@', '%', '$', '#'];
var _z85DecodeTable = [0x00, 0x44, 0x00, 0x54, 0x53, 0x52, 0x48, 0x00, 0x4B, 0x4C, 0x46, 0x41, 0x00, 0x3F, 0x3E, 0x45, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x40, 0x00, 0x49, 0x42, 0x4A, 0x47, 0x51, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x4D, 0x00, 0x4E, 0x43, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x4F, 0x00, 0x50, 0x00, 0x00];
var Z85 = {
encode: function encode(bytes) {
var buffer = null;
if (bytes instanceof ArrayBuffer) {
buffer = bytes;
} else if (bytes.buffer instanceof ArrayBuffer) {
buffer = bytes.buffer;
} else if (Array.isArray(bytes)) {
buffer = new Uint8Array(bytes).buffer;
}
if (buffer == null) {
throw 'Cannot Z85 encode ' + bytes;
}
var length = buffer.byteLength;
var remainder = length % 4;
var padding = 4 - (remainder === 0 ? 4 : remainder);
var view = new DataView(buffer);
var result = '';
var value = 0;
for (var i = 0; i < length + padding; ++i) {
var isPadding = i >= length;
value = value * 256 + (isPadding ? 0 : view.getUint8(i));
if ((i + 1) % 4 === 0) {
var divisor = 85 * 85 * 85 * 85;
for (var j = 5; j > 0; --j) {
if (!isPadding || j > padding) {
var code = Math.floor(value / divisor) % 85;
result += _z85EncodeTable[code];
}
divisor /= 85;
}
value = 0;
}
}
return result;
},
decode: function decode(string) {
var remainder = string.length % 5;
var padding = 5 - (remainder === 0 ? 5 : remainder);
for (var p = 0; p < padding; ++p) {
string += _z85EncodeTable[_z85EncodeTable.length - 1];
}
var length = string.length;
var buffer = new ArrayBuffer(length * 4 / 5 - padding);
var view = new DataView(buffer);
var value = 0;
var charIdx = 0;
var byteIdx = 0;
for (var i = 0; i < length; ++i) {
var code = string.charCodeAt(charIdx++) - 32;
value = value * 85 + _z85DecodeTable[code];
if (charIdx % 5 === 0) {
var divisor = 256 * 256 * 256;
while (divisor >= 1) {
if (byteIdx < view.byteLength) {
view.setUint8(byteIdx++, Math.floor(value / divisor) % 256);
}
divisor /= 256;
}
value = 0;
}
}
return buffer;
}
};
return {
CometD: CometD,
Transport: Transport,
RequestTransport: RequestTransport,
LongPollingTransport: LongPollingTransport,
CallbackPollingTransport: CallbackPollingTransport,
WebSocketTransport: WebSocketTransport,
Utils: Utils,
Z85: Z85
};
});
/***/ }),
/***/ "./src/site/site-utilities/isMobileChat.js":
/*!*************************************************!*\
!*** ./src/site/site-utilities/isMobileChat.js ***!
\*************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ cookieCheck: function() { return /* binding */ cookieCheck; },
/* harmony export */ isMobileChat: function() { return /* binding */ isMobileChat; },
/* harmony export */ nativeAndRefIDDefined: function() { return /* binding */ nativeAndRefIDDefined; }
/* harmony export */ });
/* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utilities/getParentInfo */ "./src/site/site-utilities/utilities/getParentInfo.ts");
/* harmony import */ var _site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/cookie-storage/get */ "./src/site/site-utilities/cookie-storage/get.ts");
/**
* cookieCheck
* @param {string} name
* @returns boolean
*/
function cookieCheck(name, key, getValue) {
var bactmCookies = new bactm.Cookies();
var cookieExists = bactmCookies.get(name);
var cookie = cookieExists ? JSON.parse(cookieExists) : '';
if (getValue) return cookie[key];
return cookie[key] ? true : false; // if key exists, return true.
}
/**
* isMobileChat
* @returns boolean
*/
function isMobileChat() {
var _parentDDO$page;
var _getParentInfo = (0,_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__.getParentInfo)(),
parentDDO = _getParentInfo.parentDDO,
parentHref = _getParentInfo.parentHref;
// read qs for parameters
var qsParameters = ['nativeChat=available', 'nativeChat=active', 'wrap=MDA']; // wrap=MDA is not a solid indicator of ACS flow
var qsCheck = parentHref.includes(qsParameters); // this won't work.
// read ddo for parameters
var ddoCheck = (parentDDO === null || parentDDO === void 0 || (_parentDDO$page = parentDDO.page) === null || _parentDDO$page === void 0 || (_parentDDO$page = _parentDDO$page.attributes) === null || _parentDDO$page === void 0 || (_parentDDO$page = _parentDDO$page.chat) === null || _parentDDO$page === void 0 ? void 0 : _parentDDO$page.mobileIndicator) == 'Y' ? true : false;
// check occtChat cookie
var occtChatCookieCheck = cookieCheck('occtChat', 'nativeChat');
// check occtChat_LTS cookie
var occtChat_LTSCookieCheck = cookieCheck('occtChat_LTS', 'nativeChat');
if (qsCheck || ddoCheck || occtChatCookieCheck || occtChat_LTSCookieCheck) {
(0,_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(1, 'Mobile ACS FLOW ', true);
return true;
} else {
return false;
}
}
function nativeAndRefIDDefined() {
var nativeChatCorrect = false;
var refIDCorrect = false;
var _getParentInfo2 = (0,_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__.getParentInfo)(),
parentHref = _getParentInfo2.parentHref;
// read qs for parameters
var qsCheck = function qsCheck(key) {
if (!parentHref) return;
var parentURLParts = new URL(parentHref);
// parentHref.includes(qsParameters) // loop through indicators.
var chatQS = parentURLParts.searchParams.get(key);
if (!chatQS) return;
if (key === 'nativeChat' && (chatQS.includes('available') || chatQS.includes('active'))) return nativeChatCorrect = true;
if (key === 'chatRefID' && chatQS.length > 1 && typeof chatQS === "string") return refIDCorrect = true; // working
return false;
};
var ensureCookieVal = function ensureCookieVal(cookieName, values) {
var cookie = (0,_site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_2__["default"])(cookieName);
if (!cookie) return false;
if (Array.isArray(values)) {
values.forEach(function (val) {
// ensure cookie contains expected values, if so, set 'correct' flags to true.
if (!cookie || !cookie[val]) return;
if (val === "nativeChat" && typeof cookie[val] === "string" && cookie[val].length > 0) return nativeChatCorrect = true;
if (val === "chatRefID" && typeof cookie[val] === "string" && cookie[val].length > 0) return refIDCorrect = true;
return false;
});
}
};
// check if query strings are populated and correct.
qsCheck('nativeChat');
qsCheck('chatRefID');
// check if cookies are populated and correct
// ensureCookieVal('occtChat_LTS', ['chatRefID', 'nativeChat']);
ensureCookieVal('occtChat', ['chatRefID', 'nativeChat']);
// if both are defined correctly, return true
if (nativeChatCorrect && refIDCorrect) return true;
return false;
}
/***/ }),
/***/ "./src/site/site-utilities/utilities/logger.js":
/*!*****************************************************!*\
!*** ./src/site/site-utilities/utilities/logger.js ***!
\*****************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ mobileACSLoggerService; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _getParentInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getParentInfo */ "./src/site/site-utilities/utilities/getParentInfo.ts");
function mobileACSLoggerService(label, error) {
var _getParentInfo = (0,_getParentInfo__WEBPACK_IMPORTED_MODULE_2__.getParentInfo)(),
parentHref = _getParentInfo.parentHref;
console.info(parentHref);
if (parentHref.includes('secure')) {
var parentUrl = new URL(parentHref);
if (!window.bactm_envSelector) return;
(0,_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Client Logger fired', error);
var errorPayload = {
"payload": [{
"logLevel": "debug",
"entry": "label: ".concat(label, " | error: ").concat(error.message)
}]
};
var domain = parentUrl.origin.replace('secure', 'mservice');
var errorURL = "".concat(domain).concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.ACS_LOGGER_URL);
fetch(errorURL, {
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
method: "POST",
body: JSON.stringify(errorPayload),
credentials: 'include'
}).then(function (res) {
console.info(res);
})["catch"](function (e) {
console.info(e);
});
}
}
/***/ }),
/***/ "./src/site/messaging/channel.ts":
/*!***************************************!*\
!*** ./src/site/messaging/channel.ts ***!
\***************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ cometdRequestChannel: function() { return /* binding */ cometdRequestChannel; },
/* harmony export */ cometdSendMessage: function() { return /* binding */ cometdSendMessage; },
/* harmony export */ cometdSubscribeChannel: function() { return /* binding */ cometdSubscribeChannel; },
/* harmony export */ isValidHTMLtag: function() { return /* binding */ isValidHTMLtag; },
/* harmony export */ publishCometdChannelMessages: function() { return /* binding */ publishCometdChannelMessages; },
/* harmony export */ publishCometdChannelSubscription: function() { return /* binding */ publishCometdChannelSubscription; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../site-utilities/cookie-storage/get */ "./src/site/site-utilities/cookie-storage/get.ts");
/* harmony import */ var _post_messages__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./post-messages */ "./src/site/messaging/post-messages.ts");
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/** @module cometd/channel */
/**
* Publish cometd channel messages
* @param {object} payload - cometd channel messages payload
*/
function publishCometdChannelMessages(payload) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_CHANNEL_MESSAGES, payload);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Channel Message', payload);
}
/**
* Publish cometd channel subscription
* @param {object} payload - cometd channel subscription payload
*/
function publishCometdChannelSubscription(payload) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_CHANNEL_SUBSCRIPTION, payload);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Channel Subscription', payload);
}
/**
* Comet D request channel*
* @param {string} eventName - name of event
* @param {string} requestChannel - Channel being requested
* @param {string} requestChatData - cometd request channel
* @example
TealiumPubSub.publish(COMETD_REQUEST_CHANNEL, {
requestChannel: '/service/chatV2/digital-poc',
requestChatData: {
operation: "requestChat",
firstName: "Joan",
lastName: "Smith",
subject: "Savings Account",
userData: {
key1: "value1",
key2: "value2"
},
auth: {
username: "user1",
password: "pass1"
}
}
});
*/
function cometdRequestChannel(eventName, _a) {
var requestChannel = _a.requestChannel, requestChatData = _a.requestChatData;
try {
var refIDCookie = (0,_site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_3__["default"])('mockRefID');
var chatRefID = refIDCookie === null || refIDCookie === void 0 ? void 0 : refIDCookie.mockRefID;
if (chatRefID && window.bactm_envSelector === 'notprod')
requestChatData.userData.CHAT_REF_ID = chatRefID;
var dataToSend_1 = requestChatData.userData;
if (dataToSend_1.MLD_OAO_ACCOUNTNUMBER)
delete dataToSend_1.MLD_OAO_ACCOUNTNUMBER;
Object.keys(dataToSend_1).forEach(function (key) {
var value = dataToSend_1[key];
if (typeof value === 'undefined' || value === null) {
delete dataToSend_1[key];
}
else if (Array.isArray(value) && value.length === 0) {
delete dataToSend_1[key];
}
else if (Array.isArray(value) && value.length) {
var altValue = value.toString();
dataToSend_1[key] = altValue;
}
else if (typeof value === 'object') {
var altValue = JSON.stringify(value);
dataToSend_1[key] = altValue;
}
else if (typeof value !== 'string' && value.toString()) {
var altValue = value.toString();
dataToSend_1[key] = altValue;
}
else {
dataToSend_1[key] = value;
}
});
// eslint-disable-next-line no-param-reassign
requestChatData.userData = __assign({}, dataToSend_1);
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].publish(requestChannel, requestChatData);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Request Channel', { requestChannel: requestChannel, requestChatData: requestChatData });
var isMonitoring = window.bactm.ddo.get('page.attributes.chat.monitoring');
if (isMonitoring)
(0,_post_messages__WEBPACK_IMPORTED_MODULE_4__.sendPostMessage)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.CANCEL_HEARTBEAT);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Request Channel Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdRequestChannel', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/**
* Comet D subscribe to channel
* @param {string} eventName - name of event
* @param {string} requestChannel - requested channel relative url
*/
function cometdSubscribeChannel(eventName, _a) {
var requestChannel = _a.requestChannel;
try {
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].subscribe(requestChannel, publishCometdChannelMessages, publishCometdChannelSubscription);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Subscribe Channel', { requestChannel: requestChannel });
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Subscribe Channel Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdSubscribeChannel', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/**
* Handles incoming message event from utag.
*
* @param {String} value - the messages string from user input
* @returns {Boolean} true if allow whitelisted tags, false otherwise
*/
function isValidHTMLtag(value) {
var checkHTMLallowedTags = false;
var allowedTags = [
'',
'',
'',
'',
'
',
'',
'',
'',
'',
'
',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'
',
'
',
'',
'',
'
',
'',
'
',
'',
'
',
'',
'
'
];
var domEle = new DOMParser().parseFromString(value, "text/html");
var link = domEle.querySelectorAll('a'); // locate your tag
if (link.length > 0) {
link.forEach(function (tag) {
return tag.href != "javascript:foo()" ? checkHTMLallowedTags = false : checkHTMLallowedTags = true;
});
}
else {
var tagsInArray = domEle.body.outerHTML.match(/\<.*?\>/g);
var jsonArray = [];
jsonArray = tagsInArray === null || tagsInArray === void 0 ? void 0 : tagsInArray.map(function (i) {
return allowedTags.includes(i);
});
for (var i = 0; i <= (jsonArray === null || jsonArray === void 0 ? void 0 : jsonArray.length); i++) {
if (jsonArray[i] == false) {
checkHTMLallowedTags = true;
return checkHTMLallowedTags;
}
else {
checkHTMLallowedTags = false;
}
}
}
return checkHTMLallowedTags;
}
/**
* Comet D send message
* @param {string} eventName - name of event
* @param {string} requestChannel - requested channel relative url
* @param {string} data - user's send message information
* @example
TealiumPubSub.publish(COMETD_REQUEST_SEND_MESSAGE, {
requestChannel: '/service/chatV2/digital-poc',
data: {
secureKey: "***********",
operation: 'sendMessage',
message: 'Hello, ...'
}
});
*/
function cometdSendMessage(eventName, _a) {
var requestChannel = _a.requestChannel, data = _a.data;
try {
// filter for malicious inputs
var value = data === null || data === void 0 ? void 0 : data.message;
var scriptExp = /(<[A-Za-z0-9_\s]+)[A-Za-z0-9_\/]*(on\S+)(\s+)?=(\s+)?["']?/ig;
var scriptTag = /<[^>]*script|(?:<[^>]+\s)(on\S+)(\s+)?=(\s+)?["']?/ig;
var scriptOther = /(<[A-Za-z0-9_\s\S]+)[A-Za-z0-9_\/]*(on\S+)(\s+)?=(\s+)?["']?/ig;
var iFrameTag = /<[^>]*iframe/ig;
// Adding condition for cross site scripting issue
var allHtmlTags = /<\/?[a-z][\s\S]*>/i.test(value);
if (allHtmlTags && isValidHTMLtag(value))
return;
if (value.match(scriptExp) || value.match(scriptTag) || value.match(iFrameTag || value.match(scriptOther)))
throw new Error('Invalid Input Received');
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].publish(requestChannel, data);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Send Message', { requestChannel: requestChannel, data: data });
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Send Message Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdSendMessage', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/disconnect.ts":
/*!******************************************!*\
!*** ./src/site/messaging/disconnect.ts ***!
\******************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/** @module web-socket/disconnect */
/**
* disconnect from chat
* @example
cometd.disconnect();
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName) {
try {
// TODO follow cometd's types
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].disconnect(function () { });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Disconnect', eventName);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Disconnect Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdDisconnet', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/handlers/channel-message.ts":
/*!********************************************************!*\
!*** ./src/site/messaging/handlers/channel-message.ts ***!
\********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ handleChannelMessage; },
/* harmony export */ isValidHTMLtag: function() { return /* binding */ isValidHTMLtag; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../site-utilities/cookie-storage/set */ "./src/site/site-utilities/cookie-storage/set.ts");
/* eslint-disable max-len */
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/* eslint-disable consistent-return */
/** @module messaging/handlers/channelMessage */
/**
* Handles incoming message event from utag.
*
* @param {String} value - the messages string from user input
* @returns {Boolean} true if allow whitelisted tags, false otherwise
*/
function isValidHTMLtag(value) {
var checkHTMLallowedTags = false;
var allowedTags = [
'',
'',
'',
'',
'
',
'',
'',
'',
'',
'
',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'
',
'
',
'',
'',
'
',
'',
'
',
'',
'
',
'',
'
'
];
var domEle = new DOMParser().parseFromString(value, "text/html");
var link = domEle.querySelectorAll('a'); // locate your tag
if (link.length > 0) {
link.forEach(function (tag) {
return tag.href != "javascript:foo()" ? checkHTMLallowedTags = false : checkHTMLallowedTags = true;
});
}
else {
var tagsInArray = domEle.body.outerHTML.match(/\<.*?\>/g);
var jsonArray = [];
jsonArray = tagsInArray === null || tagsInArray === void 0 ? void 0 : tagsInArray.map(function (i) {
return allowedTags.includes(i);
});
for (var i = 0; i <= jsonArray.length; i++) {
if (jsonArray[i] == false) {
checkHTMLallowedTags = true;
return checkHTMLallowedTags;
}
else {
checkHTMLallowedTags = false;
}
}
}
return checkHTMLallowedTags;
}
/**
* Subscribe Tealium and Sparta widget loader events
* @param {string} eventName - name of event
* @param {object} payload - Cometd channel message payload
* @returns {boolean}
*/
function handleChannelMessage(eventName, payload) {
try {
var _a = payload.data, secureKey = _a.secureKey, messages = _a.messages;
var scriptExp_1 = /(<[A-Za-z0-9_\s]+)[A-Za-z0-9_\/]*(on\S+)(\s+)?=(\s+)?["']?/ig;
var scriptTag_1 = /<[^>]*script|(?:<[^>]+\s)(on\S+)(\s+)?=(\s+)?["']?/ig;
var scriptOther_1 = /(<[A-Za-z0-9_\s\S]+)[A-Za-z0-9_\/]*(on\S+)(\s+)?=(\s+)?["']?/ig;
var iFrameTag_1 = /<[^>]*iframe/ig;
if (secureKey && messages[0]) {
var index = messages[0].index;
(0,_site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_2__["default"])({ secureKey: secureKey, index: index });
}
else {
(0,_site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_2__["default"])({ secureKey: secureKey });
}
payload.data.messages.forEach(function (message, index) {
if (!message.text)
return;
var value = message.text;
// Adding condition for cross site scripting issue
var allHtmlTags = /<\/?[a-z][\s\S]*>/i.test(value);
if (allHtmlTags && isValidHTMLtag(value)) {
payload.data.messages[index].text = '';
}
// returning for failed messages since it will be blocked by chat-site code. Cannot delete the whole object as it causes problems.
if (value.match(scriptExp_1) || value.match(scriptTag_1) || value.match(iFrameTag_1 || value.match(scriptOther_1))) {
payload.data.messages[index].text = '';
}
});
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_CHANNEL_MESSAGES, payload);
return false;
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Cometd Handle Channel Message Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag) {
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(e));
}
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_FAILURE, {
event: 'handleChannelMessage',
error: e,
});
}
}
/***/ }),
/***/ "./src/site/messaging/handlers/request-channel.ts":
/*!********************************************************!*\
!*** ./src/site/messaging/handlers/request-channel.ts ***!
\********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ handleRequestChannel; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/** @module messaging/handlers/request-channel */
/**
* Request chat channel
* @param {object} payload - Cometd channel request payload
* @returns {boolean}
*/
function handleRequestChannel(payload) {
var requestChannelPayload = { requestChannel: payload.detail.requestChannel,
requestChatData: payload.detail.requestChatData };
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_CHANNEL, requestChannelPayload);
return false;
}
/***/ }),
/***/ "./src/site/messaging/handlers/request-handshake.ts":
/*!**********************************************************!*\
!*** ./src/site/messaging/handlers/request-handshake.ts ***!
\**********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ handleRequestHandshake; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/** @module messaging/handlers/request-handshake */
/**
* Request chat handshake
* @returns {boolean}
*/
function handleRequestHandshake() {
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getCurrentDomain)();
var payload = {
widget: spaParams.siteParams.domains[currentTLD].widgetAPIEndpoint,
genesys: spaParams.siteParams.domains[currentTLD].genesys,
};
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_HANDSHAKE, payload);
return false;
}
/***/ }),
/***/ "./src/site/messaging/handshake.ts":
/*!*****************************************!*\
!*** ./src/site/messaging/handshake.ts ***!
\*****************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/** @module web-socket/handshake */
/**
* Make handshake w/ cometd websocket
* @param {string} eventName - name of event
* @param {string} genesys - Environment variable from Sparta. needs to be LLE specific
* @example
cometd.configure({ url: `${genesys}cometd` });
cometd.handshake();
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, _a) {
var genesys = _a.genesys;
var configuration = {
url: "".concat(genesys, "cometd"),
};
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Handshake', configuration);
try {
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].configure(configuration);
// TODO follow cometd's types
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].handshake(function () { });
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Handshake Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdHandshake', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/meta.ts":
/*!************************************!*\
!*** ./src/site/messaging/meta.ts ***!
\************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ publishEvent: function() { return /* binding */ publishEvent; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/** @module messaging/meta */
/**
* Publish cometD meta channel event
* @param {object} payload - cometd request response data
* @example
cometd.addListener('/meta/handshake', () => {}));
cometd.addListener('/meta/connect', () => {}));
cometd.addListener('/meta/disconnect', () => {}));
cometd.addListener('/meta/subscribe', () => {}));
cometd.addListener('/meta/unsubscribe', () => {}));
cometd.addListener('/meta/publish', () => {}));
cometd.addListener('/meta/unsuccessful', () => {}));
*/
// eslint-disable-next-line consistent-return
function publishEvent(payload) {
if (payload.successful) {
switch (payload.channel) {
case '/meta/handshake':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_HANDSHAKE, payload);
break;
case '/meta/connect':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_CONNECT, payload);
break;
case '/meta/disconnect':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_DISCONNECT, payload);
break;
case '/meta/subscribe':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_SUBSCRIBE, payload);
break;
case '/meta/unsubscribe':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_UNSUBSCRIBE, payload);
break;
case '/meta/publish':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_PUBLISH, payload);
break;
case '/meta/unsuccessful':
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_UNSUCCESSFUL, payload);
break;
default:
return false;
}
}
}
/**
* Add cometd listeners
* come back in meta listeners
* @example
cometd.addListener('/meta/*', () => {}));
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
_vendor__WEBPACK_IMPORTED_MODULE_1__["default"].addListener('/meta/*', publishEvent);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Meta Listeners', 'Adding listeners for handshake, connect, disconnect, subscribe, unsubscribe, publish, and unsuccessful');
return false;
}
/***/ }),
/***/ "./src/site/messaging/nickname-update.ts":
/*!***********************************************!*\
!*** ./src/site/messaging/nickname-update.ts ***!
\***********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/* eslint-disable no-param-reassign */
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/** @module messaging/notification */
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, cometdUpdateNicknamePayload) {
try {
var requestChannel = cometdUpdateNicknamePayload.requestChannel, nickname = cometdUpdateNicknamePayload.nickname, secureKey = cometdUpdateNicknamePayload.secureKey, operation = cometdUpdateNicknamePayload.operation;
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Update Nickname Data', cometdUpdateNicknamePayload);
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].publish(requestChannel, {
nickname: nickname,
secureKey: secureKey,
operation: operation,
});
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_UPDATE_SUCCESS, {});
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_UPDATE_SUCCESS);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Update Nickname Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_UPDATE_FAILURE, e);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/notification.ts":
/*!********************************************!*\
!*** ./src/site/messaging/notification.ts ***!
\********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/** @module messaging/notification */
/**
* Comet D request notification
* @param {string} eventName - name of event
* @param {string} cometdNotificationPayload - Channel being requested
* @example
window.sparta.chat.widgetLoader.pub('COMETD_REQUEST_NOTIFICATION', {
requestChannel: '/service/chatV2/testing',
transcriptPosition: 0,
secureKey:'...',
operation: 'requestNotifications'
});
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, cometdNotificationPayload) {
try {
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].publish(cometdNotificationPayload.requestChannel, cometdNotificationPayload);
var agentLTS = bactm.Store('chat', { type: 'cookie' });
var agentID = agentLTS.get('secureAgentID');
digitalData.page.attributes.chat.agent_id = agentID;
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Request Notifications', cometdNotificationPayload);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Request Notifications Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdRequestNotifications', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/post-messages.ts":
/*!*********************************************!*\
!*** ./src/site/messaging/post-messages.ts ***!
\*********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ postToCancelSubsOnWidget: function() { return /* binding */ postToCancelSubsOnWidget; },
/* harmony export */ sendPostMessage: function() { return /* binding */ sendPostMessage; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _sales_sale_event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../sales/sale-event */ "./src/site/sales/sale-event.ts");
/* harmony import */ var _site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../site-utilities/cookie-storage/get */ "./src/site/site-utilities/cookie-storage/get.ts");
/* harmony import */ var _site_api_handlers_request_preconnect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../site-api/handlers/request-preconnect */ "./src/site/site-api/handlers/request-preconnect.ts");
/* harmony import */ var _site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../site-utilities/utilities/getParentInfo */ "./src/site/site-utilities/utilities/getParentInfo.ts");
/**
* PostMessages
* The following script provides the post message scripts that provide communication back
* and forth with the widget. All of the messages will be kept in this file and not set
* as a function so the counters will be remembered and stored.
*
*/
var win = window.opener;
var chatOrigin = '';
if (window !== window.top) {
win = window.parent;
}
function terminateGenesysChat() {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Canceling All Site Subscriptions', 'Disconnecting Cometd and all subscriptions');
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_DISCONNECT);
TealiumPubSub.clearAllSubscriptions();
}
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
// window.spaParams is needed to pass chat configs back to the widget, ensuring that is defined before publishing utagInit;
if (win && window.spaParams) {
win.postMessage({ utagInit: true, spaParams: window.spaParams }, '*');
}
else {
var checkForSpaParams_1 = setInterval(function () {
if (!window.spaParams)
return;
clearInterval(checkForSpaParams_1);
return window.postMessage({ utagInit: true }, '*');
}, 100);
setTimeout(function () {
clearInterval(checkForSpaParams_1);
console.log("spaParams not defined in chat site iframe after 5 seconds");
}, 5000);
}
function handlePostMessage(event) {
if (event.data.ddo && event.data.href)
(0,_site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_5__.setParentInfo)(event.data);
if (event.data.utagInit) {
chatOrigin = event.data.utagInit.postMessageOrigin;
if (event.data.utagInit.showDebugConsole)
window.showChatDebugConsole = true;
if (event.data.utagInit.postMessageOrigin)
(0,_site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_5__.setOrigin)(event.data.utagInit.postMessageOrigin);
sendPostMessage(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CHECK_FOR_SALE);
}
if (event.data.vtimData) {
var data = event.data.vtimData;
switch (data.message) {
case _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SEND_PROXY_DATA:
processProxyMessage(data);
break;
case _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SET_MONITORING_STATUS:
bactm.ddo.set('page.attributes.chat.monitoring', data.monitoringStatus);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Monitoring Status Post Message', { status: data.monitoringStatus });
break;
case _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT:
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT, event.data.vtimData.dataToSend);
break;
case _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SET_AGENT_ID:
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SET_AGENT_ID, event.data.vtimData.dataToSend);
break;
default:
break;
}
;
}
if (typeof event.data === 'string') {
if (event.origin !== chatOrigin) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(2, 'Post Message Bad Origin', { origin: event.origin });
return;
}
switch (event.data) {
case _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CANCEL_SITE_SUBS:
terminateGenesysChat();
break;
case _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CHECK_AH_TOKEN:
var findAhToken = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getAhToken)();
if (!(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.isEmptyObj)(findAhToken)) {
sendPostMessage(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GRAB_HEARTBEAT_DATA);
}
else {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_VALIDATE_IP_ADDRESS, {
ogwUrl: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.OGW_URL,
});
}
break;
default:
break;
}
}
}
function processProxyMessage(data) {
if (!data.genesysData[data.key])
data.genesysData[data.key] = data.newValue;
if (data.key === 'site_id') {
var preConnectParams = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getParams)();
var occtChat = (0,_site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_3__["default"])();
if (!occtChat.secureKey) {
preConnectParams._page_id = data.newValue;
bactm.ddo.set('page.attributes.chat.site_id', data.newValue);
bactm.ddo.set('page.attributes.chat.altered_site_id', true);
(0,_site_api_handlers_request_preconnect__WEBPACK_IMPORTED_MODULE_4__["default"])({ detail: preConnectParams });
}
;
}
else if (_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SALE_INDICATORS.indexOf(data.key) > -1) {
(0,_sales_sale_event__WEBPACK_IMPORTED_MODULE_2__["default"])(data.genesysData, data.key);
}
;
}
window.removeEventListener("message", handlePostMessage.bind(window), false);
window.addEventListener('message', handlePostMessage.bind(window), false);
}
function sendPostMessage(data) {
try {
win.postMessage(data, chatOrigin);
}
catch (err) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Post Message Error', err);
}
}
function postToCancelSubsOnWidget() {
terminateGenesysChat();
sendPostMessage(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CANCEL_WIDGET_SUBS);
}
/***/ }),
/***/ "./src/site/messaging/typing.ts":
/*!**************************************!*\
!*** ./src/site/messaging/typing.ts ***!
\**************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/** @module messaging/typing */
/**
* Comet D typing
* @param {string} eventName - name of event publishing
* @param {string} requestChannel - chat request channel
* @param {string} payload - cometd request payload
* @example
TealiumPubSub.publish('COMETD_NOTIFY_START_TYPING', {
requestChannel: '/service/chatV2/digital-poc',
data: {
secureKey: "***********",
operation: 'startTyping',
message: 'User is Typing'
}
});
TealiumPubSub.publish('COMETD_NOTIFY_READ_RECEIPT', {
requestChannel: '/service/chatV2/digital-poc',
data: {
secureKey: "***********",
operation: 'readReceipt',
transcriptPosition: 1
}
});
TealiumPubSub.publish(COMETD_REQUEST_SEND_MESSAGE, {
requestChannel: '/service/chatV2/digital-poc',
data: {
secureKey: "***********",
operation: 'sendMessage',
message: 'Hello, ...'
}
});
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, _a) {
var requestChannel = _a.requestChannel, payload = _a.payload;
try {
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].publish(requestChannel, payload);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Typing Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENERIC_FAILURE, { event: 'cometdTypingNotification', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/update.ts":
/*!**************************************!*\
!*** ./src/site/messaging/update.ts ***!
\**************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */ "./src/site/messaging/vendor.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/* eslint-disable no-param-reassign */
/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/** @module messaging/notification */
/**
* Comet D request notification
* @param {string} eventName - name of event
* @param {string} cometdUpdatePayload - Channel info, Customer Info, Data being sent
* @example
window.sparta.chat.widgetLoader.pub('COMETD_REQUEST_NOTIFICATION', {
requestChannel: '/service/chatV2/customer-support',
userData: { key1: value1, key2: value2, etc...}
secureKey:'...',
operation: 'updateData'
});
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, cometdUpdatePayload) {
try {
var dataToSend_1 = cometdUpdatePayload.userData;
if (dataToSend_1.MLD_OAO_ACCOUNTNUMBER)
delete dataToSend_1.MLD_OAO_ACCOUNTNUMBER;
Object.keys(dataToSend_1).forEach(function (key) {
var value = dataToSend_1[key];
if (typeof value === 'undefined' || value === null) {
delete dataToSend_1[key];
}
else if (Array.isArray(value) && value.length === 0) {
delete dataToSend_1[key];
}
else if (Array.isArray(value) && value.length) {
var altValue = value.toString();
dataToSend_1[key] = altValue;
}
else if (typeof value === 'object') {
var altValue = JSON.stringify(value);
dataToSend_1[key] = altValue;
}
else if (typeof value !== 'string' && value.toString()) {
var altValue = value.toString();
dataToSend_1[key] = altValue;
}
else {
dataToSend_1[key] = value;
}
});
// eslint-disable-next-line no-param-reassign
cometdUpdatePayload.userData = __assign({}, dataToSend_1);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(1, 'Cometd Update Data', cometdUpdatePayload);
_vendor__WEBPACK_IMPORTED_MODULE_0__["default"].publish(cometdUpdatePayload.requestChannel, cometdUpdatePayload);
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_UPDATE_SUCCESS, {});
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.logGenesysEvent)(3, 'Cometd Update Data Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COMETD_UPDATE_FAILURE, e);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_2__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/messaging/vendor.ts":
/*!**************************************!*\
!*** ./src/site/messaging/vendor.ts ***!
\**************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var cometd__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cometd */ "./node_modules/cometd/cometd.js");
/* harmony import */ var cometd__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cometd__WEBPACK_IMPORTED_MODULE_0__);
/** @module messaging/cometd */
/**
* Integrate cometd
*/
/* harmony default export */ __webpack_exports__["default"] = (new (cometd__WEBPACK_IMPORTED_MODULE_0___default().CometD)());
/***/ }),
/***/ "./src/site/sales/sale-event.ts":
/*!**************************************!*\
!*** ./src/site/sales/sale-event.ts ***!
\**************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ errorSaleEvent: function() { return /* binding */ errorSaleEvent; },
/* harmony export */ successSaleEvent: function() { return /* binding */ successSaleEvent; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/cookie-storage/get */ "./src/site/site-utilities/cookie-storage/get.ts");
/* harmony import */ var _site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../site-utilities/cookie-storage/set */ "./src/site/site-utilities/cookie-storage/set.ts");
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/* eslint-disable guard-for-in */
/* eslint-disable no-param-reassign */
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/* eslint-disable no-restricted-syntax */
/** @module sales/notification */
/**
* Error Sale Event
* @param {object} response - Error response
* @returns {boolean}
*/
function errorSaleEvent(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_SALES_OCCURRED_FAILURE, response);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(response));
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Cometd Sales Occurred Failure', response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
return false;
}
/**
* Success Sale Event
* @param {object} response - Success Response
* @example
// success response
* @returns {boolean}
*/
function successSaleEvent(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_SALES_OCCURRED_SUCCESS, response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Cometd Sales Occurred Success', response);
return false;
}
/**
* Sale Occurred Event
* @param {string} eventName - name of event
* @param {string} cometdSalesOccurredPayload - Channel info, Interaction ID, Data being sent
* @example
TealiumPubSub.publish('COMETD_REQUEST_SALE_OCCURRED', {
requestChannel: '/service/chatV2/customer-support',
userData: { key1: value1, key2: value2, etc...},
interaction_id: ID,
});
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(data, key) {
try {
if (typeof bactm === 'undefined')
throw new Error('Bactm Not Defined, Sale Cannot Process');
var genesysData_1 = __assign({}, data);
var inqClientOrderNum = genesysData_1.inqClientOrderNum || data[key];
if (!inqClientOrderNum)
return;
var cookieInfo = (0,_site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_2__["default"])(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS.NAME);
var agent_id = cookieInfo.secureAgentID;
var interaction_id = cookieInfo.ix_id;
var previousOrderNums = cookieInfo.inqClientOrderNum || null;
if (previousOrderNums)
previousOrderNums = previousOrderNums.toString();
var orderNumArray = previousOrderNums && previousOrderNums.split(',') || null;
if (inqClientOrderNum && agent_id) {
if (orderNumArray && orderNumArray.indexOf(inqClientOrderNum.toString()) > -1) {
return;
}
}
if (previousOrderNums) {
var newOrderNum = "".concat(previousOrderNums, ",").concat(inqClientOrderNum);
genesysData_1.inqClientOrderNum = newOrderNum;
cookieInfo.inqClientOrderNum = newOrderNum;
(0,_site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_3__["default"])(cookieInfo, _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS);
}
else {
genesysData_1.inqClientOrderNum = inqClientOrderNum;
cookieInfo.inqClientOrderNum = inqClientOrderNum;
(0,_site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_3__["default"])(cookieInfo, _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS);
}
if (agent_id && interaction_id) {
var dataToSend_1 = __assign(__assign({}, genesysData_1), { agent_id: agent_id });
if (dataToSend_1.MLD_OAO_ACCOUNTNUMBER)
delete dataToSend_1.MLD_OAO_ACCOUNTNUMBER;
Object.keys(dataToSend_1).forEach(function (key) {
var value = dataToSend_1[key];
if (typeof value === 'undefined' || value === null) {
delete dataToSend_1[key];
}
else if (Array.isArray(value) && value.length === 0) {
delete dataToSend_1[key];
}
else if (Array.isArray(value) && value.length) {
var altValue = value.toString();
dataToSend_1[key] = altValue;
}
else if (typeof value === 'object') {
var altValue = JSON.stringify(value);
dataToSend_1[key] = altValue;
}
else if (typeof value !== 'string' && value.toString()) {
var altValue = value.toString();
dataToSend_1[key] = altValue;
}
else {
dataToSend_1[key] = value;
}
});
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Cometd Sales Occurred Data', dataToSend_1);
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getCurrentDomain)();
var domain = spaParams.siteParams.domains[currentTLD].genesys;
var jsonUserData = JSON.stringify(dataToSend_1);
var genesysSaleEventURL = "".concat(domain).concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_UPDATE_CHAT_DATA_ENDPOINT);
var genesysSaleEventParams = "_userdata=".concat(jsonUserData, "&_interaction_id=").concat(interaction_id);
fetch(genesysSaleEventURL, {
method: 'POST',
body: genesysSaleEventParams,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
credentials: 'include',
})
.then(function (resp) { return resp.json(); })
.then(successSaleEvent)
.catch(errorSaleEvent);
if (window.dataCollector) {
window.dataCollector.push({
event: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_SALES_OCCURRED_SUCCESS,
data: {
inqClientOrderNum: dataToSend_1.inqClientOrderNum,
},
});
}
}
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Cometd Sales Occurred Error', e);
errorSaleEvent(e);
}
}
/***/ }),
/***/ "./src/site/site-api/co-browse.ts":
/*!****************************************!*\
!*** ./src/site/site-api/co-browse.ts ***!
\****************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable func-names */
/* eslint-disable no-underscore-dangle */
/* eslint-disable prefer-const */
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/** @module site-api/coBrowse */
/**
* Co browse
* @param {string} eventName - name of event
* @param {object} configuration
* TODO http://localhost:4000/sparta-demo/chat-widget-demo/undefinedjs/gcb.min.js undefined is envCobrowseURL
* TODO Cobrowse configuration incorrect
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, configuration) {
try {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Cobrowse Configuration', configuration);
(function (d, s, id, o) {
var _a;
var fs = d.getElementsByTagName(s)[0];
var e;
if (d.getElementById(id))
return;
e = d.createElement(s);
e.id = id;
e.src = o.src;
e.setAttribute('data-gcb-url', o.cbUrl);
(_a = fs.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(e, fs);
}(document, 'script', 'genesys-js', {
src: "".concat(configuration.envCobrowseURL, "js/gcb.min.js"),
cbUrl: configuration.envCobrowseURL,
}));
window._genesys = configuration;
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_COBROWSE_CONFIGURED, configuration);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Cobrowse Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENERIC_FAILURE, { event: 'requestCoBrowse', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
}
}
/***/ }),
/***/ "./src/site/site-api/handlers/configure-cobrowse.ts":
/*!**********************************************************!*\
!*** ./src/site/site-api/handlers/configure-cobrowse.ts ***!
\**********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ handleConfigureCobrowse; }
/* harmony export */ });
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/* eslint-disable prefer-object-spread */
/* eslint-disable no-undef */
/** @module site-api/handlers/configure-cobrowse */
/**
* Handle cobrowse
* @param {object} payload
* @returns {boolean}
*/
function handleConfigureCobrowse(payload) {
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.getCurrentDomain)();
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.publishTealium)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENESYS_COBROWSE_CONFIGURATION, __assign(__assign({}, payload.detail), { envCobrowseURL: spaParams.siteParams.domains[currentTLD].cobrowse }));
return false;
}
/***/ }),
/***/ "./src/site/site-api/handlers/request-polling.ts":
/*!*******************************************************!*\
!*** ./src/site/site-api/handlers/request-polling.ts ***!
\*******************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ handleRequestPolling; }
/* harmony export */ });
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-utilities/utilities/getParentInfo */ "./src/site/site-utilities/utilities/getParentInfo.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_isMobileChat__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../site-utilities/isMobileChat */ "./src/site/site-utilities/isMobileChat.js");
/* eslint-disable camelcase */
/** @module genesys/handlers/requestPreConnect */
/**
* Request genesys pre connect
* @returns {boolean}
*/
function handleRequestPolling(_a) {
var _b = _a.detail, _language_code = _b._language_code, _customer_lob = _b._customer_lob, _site_id = _b._site_id, _unit = _b._unit, _programtrait = _b._programtrait, _run_id = _b._run_id, _route_param = _b._route_param, _account_type = _b._account_type, _channel = _b._channel, _page_id = _b._page_id, nativeChat = _b.nativeChat, UAID = _b.UAID;
try {
var parentHref = (0,_site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__.getParentInfo)().parentHref;
}
catch (error) {
bactm.reportError(error);
}
var handleLOB = function (lob) {
if (parentHref) {
if (parentHref.includes('/secure-offers/customizedSbOffers'))
return "sbob";
}
return lob;
};
var pageId = null;
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.getCurrentDomain)();
// <--------------------------------------------------------------------------->
var configuration = {
languageCode: _language_code,
pollingUrl: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__.GENESYS_CHAT_SERVICE_ENDPOINT,
domain: spaParams.siteParams.domains[currentTLD].genesys,
customerLob: handleLOB(_customer_lob) || '',
siteID: _site_id || '',
unit: _unit || '',
programTrait: _programtrait || '',
runID: _run_id || '',
routeParam: _route_param || '',
accountType: _account_type || '',
channel: _channel || null,
mobileIndicator: (0,_site_utilities_isMobileChat__WEBPACK_IMPORTED_MODULE_3__.nativeAndRefIDDefined)() ? 'Y' : 'N',
UAID: UAID // new parameter per Collaborators
};
// <--------------------------------------------------------------------------->
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(1, 'Genesys Request Polling Config', configuration);
try {
var alteredSiteID = bactm.ddo.get('page.attributes.chat.altered_site_id');
pageId = alteredSiteID ? bactm.ddo.get('page.attributes.chat.site_id') : _page_id;
Object.assign(configuration, {
pageId: pageId,
});
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(3, 'Genesys Request Polling Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__.GENERIC_FAILURE, { event: 'handleRequestPolling', error: e });
}
var pollingTimer = setInterval(function () {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.waitForAHToken)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__.GENESYS_REQUEST_POLLING, configuration);
}, 30000);
function clearPollingInterval() {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(1, 'Genesys Suspend Polling', 'Clearing polling timer');
clearInterval(pollingTimer);
TealiumPubSub.unsubscribe(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__.GENESYS_SUSPEND_POLLING);
}
TealiumPubSub.subscribe(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_2__.GENESYS_SUSPEND_POLLING, clearPollingInterval);
}
/***/ }),
/***/ "./src/site/site-api/handlers/request-preconnect.ts":
/*!**********************************************************!*\
!*** ./src/site/site-api/handlers/request-preconnect.ts ***!
\**********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ handleRequestPreConnect; }
/* harmony export */ });
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-utilities/utilities/getParentInfo */ "./src/site/site-utilities/utilities/getParentInfo.ts");
/* harmony import */ var _site_utilities_isMobileChat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../site-utilities/isMobileChat */ "./src/site/site-utilities/isMobileChat.js");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* eslint-disable camelcase */
/** @module genesys/handlers/requestPreConnect */
/**
* Request genesys pre connect
* @returns {boolean}
*/
function handleRequestPreConnect(_a) {
var _b, _c, _d;
var _e = _a.detail, _language_code = _e._language_code, _customer_lob = _e._customer_lob, _site_id = _e._site_id, _unit = _e._unit, _programtrait = _e._programtrait, _run_id = _e._run_id, _route_param = _e._route_param, _account_type = _e._account_type, _channel = _e._channel, _page_id = _e._page_id, chatID = _e.chatID, nativeChat = _e.nativeChat, UAID = _e.UAID;
try {
var _f = (0,_site_utilities_utilities_getParentInfo__WEBPACK_IMPORTED_MODULE_1__.getParentInfo)(), parentDDO = _f.parentDDO, parentTitle = _f.parentTitle, parentHref = _f.parentHref;
var currentWebPage = parentTitle || '';
var bactmCookies = new bactm.Cookies();
// may not be needed anymore
var ddoMobileIndicator = (_d = (_c = (_b = parentDDO === null || parentDDO === void 0 ? void 0 : parentDDO.page) === null || _b === void 0 ? void 0 : _b.attributes) === null || _c === void 0 ? void 0 : _c.chat) === null || _d === void 0 ? void 0 : _d.mobileIndicator;
// change to LTS cookie
var cookieExists = bactmCookies.get('occtChat');
var occtChatCookie = cookieExists ? JSON.parse(cookieExists) : '';
var chatIDChecker = occtChatCookie.chatRefID ? occtChatCookie.chatRefID : '';
var nativeChatChecker = occtChatCookie.nativeChat ? occtChatCookie.nativeChat : '';
}
catch (error) {
bactm.reportError(error);
}
var ensureNativeChat = nativeChat || nativeChatChecker;
var pageId = null;
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.getCurrentDomain)();
// Add object destructing
var nativeChatConfig = {
currentWebPage: currentWebPage,
chatID: chatID || chatIDChecker,
};
if (ensureNativeChat) {
// only log this when necessary
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(1, 'Genesys Request Native Chat Config', nativeChatConfig);
}
var handleLOB = function (lob) {
if (parentHref) {
if (parentHref.includes('/secure-offers/customizedSbOffers'))
return "sbob";
}
return lob;
};
// <--------------------------------------------------------------------------->
var configuration = {
languageCode: _language_code,
pageId: pageId,
customerLob: handleLOB(_customer_lob) || '',
accountType: _account_type || '',
channel: _channel || null,
preConnectUrl: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_3__.GENESYS_CHAT_SERVICE_ENDPOINT,
domain: spaParams.siteParams.domains[currentTLD].genesys,
siteID: _site_id || '',
unit: _unit || '',
programTrait: _programtrait || '',
runID: _run_id || '',
routeParam: _route_param || '',
mobileIndicator: (0,_site_utilities_isMobileChat__WEBPACK_IMPORTED_MODULE_2__.nativeAndRefIDDefined)() ? 'Y' : 'N',
UAID: UAID,
};
// <--------------------------------------------------------------------------->
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(1, 'Genesys Request Preconnect Config', configuration);
try {
pageId = _page_id;
Object.assign(configuration, { pageId: pageId });
nativeChatConfig.pageId = pageId;
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.logGenesysEvent)(3, 'Genesys Request Preconnect Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag) {
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_3__.PIXEL_TAG_URL, "?error=").concat(e));
}
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_3__.GENERIC_FAILURE, {
event: 'handleRequestPreConnect',
error: e,
});
}
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.publishTealium)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_3__.GENESYS_REQUEST_PRE_CONNECT, configuration);
return false;
}
/***/ }),
/***/ "./src/site/site-api/handlers/survey-get-response.ts":
/*!***********************************************************!*\
!*** ./src/site/site-api/handlers/survey-get-response.ts ***!
\***********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ surveyGetResponse; }
/* harmony export */ });
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/** @module site-api/handlers/surveyGetResponse */
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**
* Handle survey get response
* @param {object} payload
* @returns {boolean}
*/
function surveyGetResponse(payload, isPrechat) {
if (isPrechat === void 0) { isPrechat = false; }
var tempObj = {
payload: payload.detail,
};
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.getCurrentDomain)();
var surveyDetails = __assign(__assign({}, tempObj), { envSurveyURL: spaParams.siteParams.domains[currentTLD].survey, chatSurveyEndpoint: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENESYS_CHAT_SURVEY_ENDPOINT });
if (isPrechat)
Object.assign(surveyDetails, { isPrechat: isPrechat });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.waitForAHToken)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.SURVEY_GET_RESPONSE, surveyDetails);
return false;
}
/***/ }),
/***/ "./src/site/site-api/native-chat-update.ts":
/*!*************************************************!*\
!*** ./src/site/site-api/native-chat-update.ts ***!
\*************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ errorUpdateEvent: function() { return /* binding */ errorUpdateEvent; },
/* harmony export */ successUpdateEvent: function() { return /* binding */ successUpdateEvent; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_utilities_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/utilities/logger */ "./src/site/site-utilities/utilities/logger.js");
/** @module site-api/nativeChatUpdate */
/**
* Error nativeChatUpdate Event
* @param {object} response - Error response
* @returns {boolean}
*/
function errorUpdateEvent(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT_FAILURE, response);
if (bactm && bactm.plugins && bactm.plugins.pixelTag) {
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(response));
}
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, ' Native Chat Request Failure', response);
(0,_site_utilities_utilities_logger__WEBPACK_IMPORTED_MODULE_2__["default"])('updateChatData', response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
return false;
}
/**
* Success nativeChatUpdate Event
* @param {object} response - Success response
* @returns {boolean}
*
* success response
* {
* Id: "6H98FMGB7T7EP9E3VF6QVEDG3S0000DF",
* Reason: "SUCCESSFULLY UPDATED"
* }
*/
function successUpdateEvent(response) {
// TODO: add in a thing to the response to keep the session going no matter what.
// Just for testing 12 / 13 / 2022 Kevin Conway
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT_SUCCESS, /* response */ response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Request Native Chat Success', /* response */ response);
return false;
}
/**
* Makes nativeChat=active request to genesys
* @param {string} eventName - name of event
* @param {object} configuration - payload
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(event, _a) {
var CHAT_ID = _a.CHAT_ID, currentWebPage = _a.currentWebPage;
try {
if (typeof bactm === 'undefined') {
throw new Error('Native Chat Request unable to process');
}
var genesysData_1 = {
CURRENT_PAGE: currentWebPage,
};
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Native Chat Pageview Params', genesysData_1);
// TODO: remove requirement to check for chat_id kpc.
if (CHAT_ID) {
// While confusing, currently, this is how its setup. Chat ID and Interaction ID are not the same.
var interactionID = CHAT_ID;
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getCurrentDomain)();
var GSID = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getGSID)();
var domain = spaParams.siteParams.domains[currentTLD].genesys;
var jsonUserData = JSON.stringify(genesysData_1);
var genesysPreConnectParams = {
_interaction_id: interactionID,
_userdata: jsonUserData,
_GSID: GSID,
_updateForActiveChatOnly: 'Y',
};
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Native Chat Request Params', genesysPreConnectParams);
var genesysNativeChatEndPoint = "".concat(domain).concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_UPDATE_CHAT_DATA_ENDPOINT);
fetch(genesysNativeChatEndPoint, {
method: 'POST',
body: JSON.stringify(genesysPreConnectParams),
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
}).then(function (resp) { return resp.json(); }).then(successUpdateEvent).catch(errorUpdateEvent);
}
else {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Chat Id undefined', CHAT_ID);
}
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Native Chat Error occurred', e);
errorUpdateEvent(e);
}
}
/***/ }),
/***/ "./src/site/site-api/polling.ts":
/*!**************************************!*\
!*** ./src/site/site-api/polling.ts ***!
\**************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ errorPolling: function() { return /* binding */ errorPolling; },
/* harmony export */ successPolling: function() { return /* binding */ successPolling; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _messaging_post_messages__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../messaging/post-messages */ "./src/site/messaging/post-messages.ts");
/* eslint-disable camelcase */
/** @module genesys/polling */
/**
* Error polling
* @param {object} response - Error response
* @returns {boolean}
*/
function errorPolling(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_POLLING_FAILURE, response);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(response));
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Request Polling Failure', response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
return false;
}
/**
* Success polling
* @param {object} response - polling response
* @example
// success response
{
"Availability": "false",
"Reason": "Out of Office Hours",
"EWT": 0,
"AgentAvailable": 3,
"Id": "GL7R2K4DJP6JN7FFTRK5A1B5CC0000TJ",
"SplashMessage": "Chat Splash Message"
}
* @returns {boolean}
*/
function successPolling(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_POLLING_SUCCESS, response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Polling Response', response);
var Availability = response.Availability;
var isMonitoring = window.digitalData.page.attributes.chat.monitoring;
// eslint-disable-next-line no-unused-vars
var isInPage = (window.top === window.self);
if (!Availability && isMonitoring) {
(0,_messaging_post_messages__WEBPACK_IMPORTED_MODULE_2__.sendPostMessage)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CANCEL_HEARTBEAT);
}
return false;
}
/**
* Making polling request to genesys
* @param {string} eventName - name of event
* @param {object} configuration
*/
// <--------------------------------------------------------------------------->
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, configuration) {
try {
var customerLob = configuration.customerLob, domain = configuration.domain, languageCode = configuration.languageCode, pageId = configuration.pageId, pollingUrl = configuration.pollingUrl, siteID = configuration.siteID, unit = configuration.unit, programTrait = configuration.programTrait, runID = configuration.runID, routeParam = configuration.routeParam, accountType = configuration.accountType, channel = configuration.channel, // only used in OLB
mobileIndicator = configuration.mobileIndicator, _a = configuration.UAID, UAID = _a === void 0 ? '' : _a;
// eslint-disable-next-line prefer-const
var genesysPollingEndpoint = "".concat(domain).concat(pollingUrl);
var GSID = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getGSID)();
// add new parameter to all 3 of these use cases below.
var uaIDDefined = UAID.length > 0 ? "&_UAID=".concat(UAID) : "";
var genesysPollingParams = "_language_code=".concat(languageCode, "&_page_id=").concat(pageId, "&_customer_lob=").concat(customerLob, "&_account_type=").concat(accountType, "&_channel=").concat(channel, "&_mobile_indicator=").concat(mobileIndicator, "&_GSID=").concat(GSID).concat(uaIDDefined);
if (siteID !== '') {
genesysPollingParams = "_site_id=".concat(siteID, "&_unit=").concat(unit, "&_programtrait=").concat(programTrait, "&_pagemarker=").concat(runID).concat(uaIDDefined);
}
else if (routeParam !== '') {
genesysPollingParams = "_route_param=".concat(routeParam, "&_language_code=").concat(languageCode, "&_customer_lob=").concat(customerLob).concat(uaIDDefined);
}
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Polling Availability', genesysPollingParams);
fetch(genesysPollingEndpoint, {
method: 'POST',
body: genesysPollingParams,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
credentials: 'include',
})
.then(function (resp) { return resp.json(); })
.then(successPolling)
.catch(errorPolling);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Polling Error', e);
errorPolling(e);
}
}
/***/ }),
/***/ "./src/site/site-api/pre-connect.ts":
/*!******************************************!*\
!*** ./src/site/site-api/pre-connect.ts ***!
\******************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ errorCheckPreConnect: function() { return /* binding */ errorCheckPreConnect; },
/* harmony export */ successCheckPreConnect: function() { return /* binding */ successCheckPreConnect; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _messaging_post_messages__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../messaging/post-messages */ "./src/site/messaging/post-messages.ts");
/** @module genesys/preConnect */
/**
* Error check pre connect errorCheckPreConnect
* @param {object} response - Error response
* @returns {boolean}
*/
function errorCheckPreConnect(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_PRE_CONNECT_FAILURE, response);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(response));
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Preconnect Failure', response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
return false;
}
/**
* Success check pre connect
* @param {object} response - pre connect response
* @example
// success response
{
"Availability": "false",
"Reason": "Out of Office Hours",
"EWT": 0,
"AgentAvailable": 3,
"Id": "GL7R2K4DJP6JN7FFTRK5A1B5CC0000TJ",
"SplashMessage": "Chat Splash Message"
}
* @returns {boolean}
*/
function successCheckPreConnect(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_PRE_CONNECT_SUCCESS, response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Preconnect Success', response);
// this sets bactm_lts cookie with a chatService object and RLD property
var chatService = bactm.Store('chatService', { type: 'cookie' });
chatService.set('RLD', response === null || response === void 0 ? void 0 : response.RLD);
chatService.save();
if (response && response.IP && bactm && bactm.ddo) {
bactm.ddo.set('page.attributes.chat.IP_ADDRESS', response.IP);
}
var Availability = response.Availability;
var isMonitoring = window.digitalData.page.attributes.chat.monitoring;
if (!Availability && isMonitoring) {
(0,_messaging_post_messages__WEBPACK_IMPORTED_MODULE_2__.sendPostMessage)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CANCEL_HEARTBEAT);
}
return false;
}
/**
* Making pre connects request to genesys
* @param {string} eventName - name of event
* @param {object} configuration
*/
// <--------------------------------------------------------------------------->
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, configuration) {
try {
var domain = configuration.domain, languageCode = configuration.languageCode, pageId = configuration.pageId, preConnectUrl = configuration.preConnectUrl, customerLob = configuration.customerLob, siteID = configuration.siteID, unit = configuration.unit, programTrait = configuration.programTrait, runID = configuration.runID, routeParam = configuration.routeParam, accountType = configuration.accountType, channel = configuration.channel, // only used in OLB
mobileIndicator = configuration.mobileIndicator, _a = configuration.UAID, UAID = _a === void 0 ? '' : _a;
// eslint-disable-next-line prefer-const
var genesysPreConnectEndpoint = "".concat(domain).concat(preConnectUrl);
var GSID = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getGSID)();
// add new parameter to all 3 of these use cases below.
var uaIDDefined = UAID.length > 0 ? "&_UAID=".concat(UAID) : "";
var genesysPreConnectParams = "_language_code=".concat(languageCode, "&_page_id=").concat(pageId, "&_customer_lob=").concat(customerLob, "&_account_type=").concat(accountType, "&_channel=").concat(channel, "&_mobile_indicator=").concat(mobileIndicator, "&_GSID=").concat(GSID).concat(uaIDDefined);
if (siteID !== '') {
genesysPreConnectParams = "_site_id=".concat(siteID, "&_unit=").concat(unit, "&_programtrait=").concat(programTrait, "&_pagemarker=").concat(runID).concat(uaIDDefined);
}
else if (routeParam !== '') {
genesysPreConnectParams = "_route_param=".concat(routeParam, "&_language_code=").concat(languageCode, "&_customer_lob=").concat(customerLob).concat(uaIDDefined);
}
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Preconnect Params', genesysPreConnectParams);
fetch(genesysPreConnectEndpoint, {
method: 'POST',
body: genesysPreConnectParams,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
credentials: 'include',
})
.then(function (resp) { return resp.json(); })
.then(successCheckPreConnect)
.catch(errorCheckPreConnect);
}
catch (error) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Preconnect Error', error);
errorCheckPreConnect(error);
}
}
/***/ }),
/***/ "./src/site/site-api/send-survey.ts":
/*!******************************************!*\
!*** ./src/site/site-api/send-survey.ts ***!
\******************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ errorSendSurvey: function() { return /* binding */ errorSendSurvey; },
/* harmony export */ successSendSurvey: function() { return /* binding */ successSendSurvey; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/cookie-storage/get */ "./src/site/site-utilities/cookie-storage/get.ts");
/* eslint-disable camelcase */
/**
* Error Send Survey
* @param {object} response - Error response
* @returns {boolean}
*/
function errorSendSurvey(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY_FAILURE, response);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(response));
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Genesys Send Survey Failure', response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
return false;
}
/**
* Success Send Survey
* @param {object} response - Success response
* @example
// success response
* @returns {boolean}
*/
function successSendSurvey(response) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY_SUCCESS, response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Send Survey Success', response);
return false;
}
/**
* Genesys Send Survey Request
* @param {string} eventName - name of event
* @param {string} genesysSendSurveyPayload - User information
* @example
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, genesysSendSurveyPayload) {
try {
var dataToSend = {};
dataToSend._userdata = JSON.stringify(genesysSendSurveyPayload);
// const agentLTS = bactm.Store('chat', { type: 'cookie' });
var agentLTS = (0,_site_utilities_cookie_storage_get__WEBPACK_IMPORTED_MODULE_2__["default"])(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS.NAME);
var interaction_id = agentLTS.ix_id;
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Cometd Send Survey Data', dataToSend);
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.getCurrentDomain)();
var domain = spaParams.siteParams.domains[currentTLD].genesys;
var sendSurveyEndpoint = _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_UPDATE_CHAT_DATA_ENDPOINT;
var genesysSendSurveyURL = "".concat(domain).concat(sendSurveyEndpoint);
var genesysSurveyParams = "_userdata=".concat(dataToSend._userdata, "&_interaction_id=").concat(interaction_id);
fetch(genesysSendSurveyURL, {
method: 'POST',
body: genesysSurveyParams,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
credentials: 'include',
})
.then(function (resp) { return resp.json(); })
.then(successSendSurvey)
.catch(errorSendSurvey);
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY_SUCCESS, {});
}
catch (e) {
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(e));
errorSendSurvey(e);
}
}
/***/ }),
/***/ "./src/site/site-api/set-agent-id.ts":
/*!*******************************************!*\
!*** ./src/site/site-api/set-agent-id.ts ***!
\*******************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ genesysSetAgentID; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/cookie-storage/set */ "./src/site/site-utilities/cookie-storage/set.ts");
/* harmony import */ var _site_utilities_cookie_storage_remove__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../site-utilities/cookie-storage/remove */ "./src/site/site-utilities/cookie-storage/remove.ts");
/* eslint-disable no-undef */
/* eslint-disable camelcase */
/** @module genesys/agentIncentive */
var setQualifiedLead = function (agentID, interactionID) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Qualified Lead: Set Agent ID', { agentID: agentID });
try {
(0,_site_utilities_cookie_storage_remove__WEBPACK_IMPORTED_MODULE_3__["default"])(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS.NAME); // removing cookie just in case
(0,_site_utilities_cookie_storage_set__WEBPACK_IMPORTED_MODULE_2__["default"])({
secureAgentID: agentID,
ix_id: interactionID,
inqClientOrderNum: '',
expiration: new Date(Date.now() + (_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS.EXPIRATION * 60 * 1000)),
}, _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_LTS);
}
catch (e) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Set Agent ID Error', e);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(e));
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENERIC_FAILURE, { event: 'genesysSetAgentID', error: e });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
}
};
/**
* Genesys Qualified Lead
* @param {string} agentID - encrypted NBKID for the agent
* @description - Genesys sends an encrypted NBKID once the chat has made a qualified lead.
* This function stores the encrypted ID as a cookie so it can be collected by ABPA once a sale
* has occurred
*
*/
function genesysSetAgentID(eventName, agentDetails) {
var agentID = agentDetails.agentID;
// in acs workflow it will come as uid not agentID (thats bau)
if (!agentID) {
setQualifiedLead(agentDetails.UID, agentDetails.IXNID);
}
else {
setQualifiedLead(agentID.UID, agentID.IXNID);
}
}
/***/ }),
/***/ "./src/site/site-api/survey.ts":
/*!*************************************!*\
!*** ./src/site/site-api/survey.ts ***!
\*************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ failureSurveyGetResponse: function() { return /* binding */ failureSurveyGetResponse; },
/* harmony export */ successSurveyGetResponse: function() { return /* binding */ successSurveyGetResponse; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/** @module site-api/survey */
/**
* Survey Get Response - Success
* @desc Upon success, function delivers a Pub/Sub event to send survey information back to UI
* @returns {undefined}
*/
function successSurveyGetResponse(surveyResponse, isPrechat) {
var eventName = isPrechat ? _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PRECHAT_SURVEY_GET_RESPONSE_SUCCESS : _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SURVEY_GET_RESPONSE_SUCCESS;
TealiumPubSub.publish(eventName, surveyResponse);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Survey Response Success', surveyResponse);
return false;
}
/**
* Survey Get Response - Failure
* @desc Upon failure, function delivers a Pub/Sub event to send error information back to UI
* @returns {undefined}
*/
function failureSurveyGetResponse(surveyResponse, isPrechat) {
var eventName = isPrechat ? _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PRECHAT_SURVEY_GET_RESPONSE_FAILURE : _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SURVEY_GET_RESPONSE_FAILURE;
TealiumPubSub.publish(eventName, surveyResponse);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.PIXEL_TAG_URL, "?error=").concat(surveyResponse));
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(3, 'Survey Response Failure', { eventName: eventName, surveyResponse: surveyResponse });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.increaseErrorCount)();
return false;
}
/**
* Survey Get Response
* @param {string} eventName
* @param {object} configuration
* @desc The following method will grab the survey information sent from
* UI and deliver the response form back to the UI
* @returns {undefined}
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, configuration) {
try {
var payload = configuration.payload, envSurveyURL = configuration.envSurveyURL, chatSurveyEndpoint = configuration.chatSurveyEndpoint, isPrechat_1 = configuration.isPrechat;
var genesysSurveyDetails = JSON.stringify(payload);
var genesysSurveyEndpoint = "".concat(envSurveyURL).concat(chatSurveyEndpoint);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'Genesys Survey Configuration', configuration);
fetch(genesysSurveyEndpoint, {
method: 'POST',
body: genesysSurveyDetails,
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
})
.then(function (resp) { return resp.json(); })
.then(function (resp) { return successSurveyGetResponse(resp, isPrechat_1); })
.catch(function (resp) { return failureSurveyGetResponse(resp, isPrechat_1); });
}
catch (error) {
failureSurveyGetResponse(error);
}
}
/***/ }),
/***/ "./src/site/site-api/validate-ip-address.ts":
/*!**************************************************!*\
!*** ./src/site/site-api/validate-ip-address.ts ***!
\**************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; },
/* harmony export */ errorValidateIPAddress: function() { return /* binding */ errorValidateIPAddress; },
/* harmony export */ successValidateIPAddress: function() { return /* binding */ successValidateIPAddress; }
/* harmony export */ });
/* harmony import */ var _messaging_post_messages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../messaging/post-messages */ "./src/site/messaging/post-messages.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_isMobileChat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-utilities/isMobileChat */ "./src/site/site-utilities/isMobileChat.js");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _site_utilities_utilities_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../site-utilities/utilities/logger */ "./src/site/site-utilities/utilities/logger.js");
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/* eslint-disable camelcase */
/* eslint-disable no-undef */
/** @module api-requests/validateIpAddress */
function setAhCookie(value) {
var isLocal = window.sparta.env === 'local';
var expiry = "; expires=".concat((new Date(Date.now() + (30 * 60 * 1000))).toUTCString());
var domain = isLocal ? '' : "; domain=".concat((0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.getCurrentDomain)());
var secure = (_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COOKIE.SECURE && !isLocal) ? '; secure' : '';
var sameSite = (_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COOKIE.SECURE && !isLocal) ? '; sameSite=none' : '';
var cookie = "ah_token=".concat(value).concat(expiry, "; path=").concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.COOKIE.PATH).concat(domain).concat(secure).concat(sameSite);
window.document.cookie = cookie;
(0,_messaging_post_messages__WEBPACK_IMPORTED_MODULE_0__.sendPostMessage)(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.AH_COOKIE_SET);
}
/**
* Error errorValidateIPAddress
* @param {object} response - Error response
* @returns {boolean}
*/
function errorValidateIPAddress(response) {
var acsFlow = (0,_site_utilities_isMobileChat__WEBPACK_IMPORTED_MODULE_2__.isMobileChat)();
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENESYS_VALIDATE_IP_ADDRESS_FAILURE, response);
if (bactm && bactm.plugins && bactm.plugins.pixelTag)
bactm.plugins.pixelTag.firePixelTag("".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.PIXEL_TAG_URL, "?error=").concat(response));
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.logGenesysEvent)(3, 'Genesys Validate IP Address Failure', response);
if (acsFlow) {
(0,_site_utilities_utilities_logger__WEBPACK_IMPORTED_MODULE_4__["default"])('validateIpAddress', response);
}
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.increaseErrorCount)();
return false;
}
/**
* Success calling validateIpAddress endpoint
* Will maybe have to do some manipulation if jwt token comes via payload
* @param {object} response - pre connect response
* @example
// success response
{
status: "SUCCESS",
ah_token: "someJWTTokenValue"
}
* @returns {boolean}
*/
function successValidateIPAddress(_a) {
var response = _a.response, nextFunc = _a.nextFunc;
var segments = response.c_loc ? response.c_loc.split(':') : true;
var chat_loc = segments && segments[1] ? segments[1].toLowerCase() === 'us' : true;
if (bactm && bactm.ddo && _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.ML_SITE_IDS.includes(bactm.ddo.get('page.attributes.chat.SITE_ID')) && chat_loc === false) {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.CANCEL_WIDGET_SUBS);
}
else {
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.GENESYS_VALIDATE_IP_ADDRESS_SUCCESS, response);
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.logGenesysEvent)(1, 'Genesys Validate IP Address Success', response);
// Set the ah_token cookie
setAhCookie(response.ah_token);
if (nextFunc)
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.publishTealium)(nextFunc.eventName, nextFunc.payload);
}
return false;
}
/**
* Making pre connects request to genesys
* @param {string} eventName - name of event
* @param {object} configuration
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(eventName, configuration, nextFunc) {
try {
var ogwUrl = configuration.ogwUrl;
var currentTLD = (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.getCurrentDomain)();
var domain = spaParams.siteParams.domains[currentTLD].ogwEndpoint;
if (window.bactm_envSelector !== "prod") {
console.log("Received validateIPAddress Endpoint from chat site config: ", domain);
}
var genesysOGWUrl = "".concat(domain).concat(ogwUrl);
var ogwPayload = {
useCase: 'default',
processRules: [{
name: 'AuthenticationContext',
value: 'LocationLookUp',
}],
};
var fetch_with_retry_1 = function (url, options, n) { return fetch(url, options).catch(function (error) {
if (n > 1) {
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.logGenesysEvent)(3, 'Genesys Validate IP Address Fetch Failed', 'Clearing Cookie & Trying Again');
setAhCookie('');
}
if (n === 1)
throw error;
return fetch_with_retry_1(url, options, n - 1);
}); };
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.logGenesysEvent)(1, 'Genesys Validate IP Address Configuration', __assign(__assign({}, configuration), { domain: domain }));
fetch_with_retry_1(genesysOGWUrl, {
method: 'POST',
body: JSON.stringify(ogwPayload),
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
}, _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_1__.MAX_ATTEMPTS)
.then(function (resp) { return resp.json(); })
.then(function (resp) { return successValidateIPAddress({ response: resp, nextFunc: nextFunc }); })
.catch(function (error) {
errorValidateIPAddress(error);
});
}
catch (error) {
errorValidateIPAddress(error);
}
}
/***/ }),
/***/ "./src/site/site-pub-sub/add-pub-sub.ts":
/*!**********************************************!*\
!*** ./src/site/site-pub-sub/add-pub-sub.ts ***!
\**********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _pub_sub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pub-sub */ "./src/site/site-pub-sub/pub-sub.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/** @module document/addPubSub */
/**
* In Borneo we need to add the pub script first
* Will append newly created div to document
* @returns {boolean}
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
(0,_pub_sub__WEBPACK_IMPORTED_MODULE_0__["default"])();
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.logGenesysEvent)(1, 'PubSub', 'adding TealiumPubSub');
return false;
}
/***/ }),
/***/ "./src/site/site-pub-sub/events.ts":
/*!*****************************************!*\
!*** ./src/site/site-pub-sub/events.ts ***!
\*****************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _messaging_update__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../messaging/update */ "./src/site/messaging/update.ts");
/* harmony import */ var _messaging_typing__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../messaging/typing */ "./src/site/messaging/typing.ts");
/* harmony import */ var _messaging_handshake__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../messaging/handshake */ "./src/site/messaging/handshake.ts");
/* harmony import */ var _messaging_disconnect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../messaging/disconnect */ "./src/site/messaging/disconnect.ts");
/* harmony import */ var _messaging_nickname_update__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../messaging/nickname-update */ "./src/site/messaging/nickname-update.ts");
/* harmony import */ var _messaging_notification__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../messaging/notification */ "./src/site/messaging/notification.ts");
/* harmony import */ var _sales_sale_event__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sales/sale-event */ "./src/site/sales/sale-event.ts");
/* harmony import */ var _messaging_channel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../messaging/channel */ "./src/site/messaging/channel.ts");
/* harmony import */ var _site_api_set_agent_id__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../site-api/set-agent-id */ "./src/site/site-api/set-agent-id.ts");
/* harmony import */ var _site_api_send_survey__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../site-api/send-survey */ "./src/site/site-api/send-survey.ts");
/* harmony import */ var _site_api_survey__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../site-api/survey */ "./src/site/site-api/survey.ts");
/* harmony import */ var _site_api_co_browse__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../site-api/co-browse */ "./src/site/site-api/co-browse.ts");
/* harmony import */ var _site_api_pre_connect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../site-api/pre-connect */ "./src/site/site-api/pre-connect.ts");
/* harmony import */ var _site_api_polling__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../site-api/polling */ "./src/site/site-api/polling.ts");
/* harmony import */ var _site_api_validate_ip_address__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../site-api/validate-ip-address */ "./src/site/site-api/validate-ip-address.ts");
/* harmony import */ var _site_api_native_chat_update__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../site-api/native-chat-update */ "./src/site/site-api/native-chat-update.ts");
/* harmony import */ var _messaging_post_messages__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../messaging/post-messages */ "./src/site/messaging/post-messages.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* eslint-disable no-undef */
/** @module pub-sub/events */
/**
* Initializing subscriptions
* @desc Initialize subscriptions. These subscriptions will wait on publishes from the widget
* @example
TealiumPubSub.subscribe(COMETD_REQUEST_HANDSHAKE, cometdHandshake);
TealiumPubSub.subscribe(COMETD_REQUEST_DISCONNECT, cometdDisconnect);
TealiumPubSub.subscribe(COMETD_NOTIFY_STOP_TYPING, cometdTyping);
TealiumPubSub.subscribe(COMETD_NOTIFY_START_TYPING, cometdTyping);
TealiumPubSub.subscribe(COMETD_NOTIFY_READ_RECEIPT, cometdTyping);
TealiumPubSub.subscribe(COMETD_REQUEST_CHANNEL, cometdRequestChannel);
TealiumPubSub.subscribe(COMETD_REQUEST_SEND_MESSAGE, cometdSendMessage);
TealiumPubSub.subscribe(COMETD_REQUEST_CHANNEL_SUBSCRIPTION, cometdSubscribeChannel);
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT, function (title, data) {
(0,_site_api_native_chat_update__WEBPACK_IMPORTED_MODULE_16__["default"])(title, data);
});
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_UPDATE, _messaging_update__WEBPACK_IMPORTED_MODULE_1__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NICKNAME_UPDATE, _messaging_nickname_update__WEBPACK_IMPORTED_MODULE_5__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_STOP_TYPING, _messaging_typing__WEBPACK_IMPORTED_MODULE_2__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_START_TYPING, _messaging_typing__WEBPACK_IMPORTED_MODULE_2__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_READ_RECEIPT, _messaging_typing__WEBPACK_IMPORTED_MODULE_2__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_HANDSHAKE, _messaging_handshake__WEBPACK_IMPORTED_MODULE_3__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_DISCONNECT, _messaging_disconnect__WEBPACK_IMPORTED_MODULE_4__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_CHANNEL, _messaging_channel__WEBPACK_IMPORTED_MODULE_8__.cometdRequestChannel);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_SEND_MESSAGE, _messaging_channel__WEBPACK_IMPORTED_MODULE_8__.cometdSendMessage);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_NOTIFICATION, _messaging_notification__WEBPACK_IMPORTED_MODULE_6__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_CHANNEL_SUBSCRIPTION, _messaging_channel__WEBPACK_IMPORTED_MODULE_8__.cometdSubscribeChannel);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_SALE_OCCURRED, _sales_sale_event__WEBPACK_IMPORTED_MODULE_7__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_POLLING, _site_api_polling__WEBPACK_IMPORTED_MODULE_14__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SET_AGENT_ID, _site_api_set_agent_id__WEBPACK_IMPORTED_MODULE_9__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.SURVEY_GET_RESPONSE, _site_api_survey__WEBPACK_IMPORTED_MODULE_11__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_COBROWSE_CONFIGURATION, _site_api_co_browse__WEBPACK_IMPORTED_MODULE_12__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_PRE_CONNECT, _site_api_pre_connect__WEBPACK_IMPORTED_MODULE_13__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY, _site_api_send_survey__WEBPACK_IMPORTED_MODULE_10__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_VALIDATE_IP_ADDRESS, _site_api_validate_ip_address__WEBPACK_IMPORTED_MODULE_15__["default"]);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.CANCEL_WIDGET_SUBS, _messaging_post_messages__WEBPACK_IMPORTED_MODULE_17__.postToCancelSubsOnWidget);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.PRE_CHAT_SURVEY, function (title, data) { return (0,_messaging_post_messages__WEBPACK_IMPORTED_MODULE_17__.sendPostMessage)(data); });
(0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_18__.logGenesysEvent)(1, 'TealiumPubSub Subscribing', 'Subscribing All Tealium Events');
return false;
}
/***/ }),
/***/ "./src/site/site-pub-sub/pub-sub.ts":
/*!******************************************!*\
!*** ./src/site/site-pub-sub/pub-sub.ts ***!
\******************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* eslint-disable */
/**
* Copyright (c) 2010,2011,2012,2013,2014 Morgan Roderick http://roderick.dk
* License: MIT - http://mrgnrdrck.mit-license.org
*
* https://github.com/mroderick/PubSubJS
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
var PubSub = {};
var messages = {}, lastUid = -1;
function hasKeys(obj) {
var key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
return true;
}
}
return false;
}
/**
* Returns a function that throws the passed exception, for use as argument for setTimeout
* @alias throwException
* @function
* @param { Object } ex An Error object
*/
function throwException(ex) {
return function reThrowException() {
throw ex;
};
}
function callSubscriberWithDelayedExceptions(subscriber, message, data) {
try {
subscriber(message, data);
}
catch (ex) {
setTimeout(throwException(ex), 0);
}
}
function callSubscriberWithImmediateExceptions(subscriber, message, data) {
subscriber(message, data);
}
function deliverMessage(originalMessage, matchedMessage, data, immediateExceptions) {
var subscribers = messages[matchedMessage], callSubscriber = immediateExceptions ? callSubscriberWithImmediateExceptions : callSubscriberWithDelayedExceptions, s;
if (!messages.hasOwnProperty(matchedMessage)) {
return;
}
for (s in subscribers) {
if (subscribers.hasOwnProperty(s)) {
callSubscriber(subscribers[s], originalMessage, data);
}
}
}
function createDeliveryFunction(message, data, immediateExceptions) {
return function deliverNamespaced() {
var topic = String(message), position = topic.lastIndexOf('.');
// deliver the message as it is now
deliverMessage(message, message, data, immediateExceptions);
// trim the hierarchy and deliver message to each level
while (position !== -1) {
topic = topic.substr(0, position);
position = topic.lastIndexOf('.');
deliverMessage(message, topic, data, immediateExceptions);
}
};
}
function messageHasSubscribers(message) {
var topic = String(message), found = messages.hasOwnProperty(topic) && hasKeys(messages[topic]), position = topic.lastIndexOf('.');
while (!found && position !== -1) {
topic = topic.substr(0, position);
position = topic.lastIndexOf('.');
found = messages.hasOwnProperty(topic) && hasKeys(messages[topic]);
}
return found;
}
function publish(message, data, sync, immediateExceptions) {
message = (typeof message === 'symbol') ? message.toString() : message;
var deliver = createDeliveryFunction(message, data, immediateExceptions), hasSubscribers = messageHasSubscribers(message);
if (!hasSubscribers) {
return false;
}
if (sync === true) {
deliver();
}
else {
setTimeout(deliver, 0);
}
return true;
}
/**
* Publishes the message, passing the data to it's subscribers
* @function
* @alias publish
* @param { String } message The message to publish
* @param {} data The data to pass to subscribers
* @return { Boolean }
*/
PubSub.publish = function (message, data) {
return publish(message, data, false, PubSub.immediateExceptions);
};
/**
* Publishes the the message synchronously, passing the data to it's subscribers
* @function
* @alias publishSync
* @param { String } message The message to publish
* @param {} data The data to pass to subscribers
* @return { Boolean }
*/
PubSub.publishSync = function (message, data) {
return publish(message, data, true, PubSub.immediateExceptions);
};
/**
* Subscribes the passed function to the passed message. Every returned token is unique and should be stored if you need to unsubscribe
* @function
* @alias subscribe
* @param { String } message The message to subscribe to
* @param { Function } func The function to call when a new message is published
* @return { String }
*/
PubSub.subscribe = function (message, func) {
if (typeof func !== 'function') {
return false;
}
message = (typeof message === 'symbol') ? message.toString() : message;
// message is not registered yet
if (!messages.hasOwnProperty(message)) {
messages[message] = {};
}
// forcing token as String, to allow for future expansions without breaking usage
// and allow for easy use as key names for the 'messages' object
var token = 'uid_' + String(++lastUid);
messages[message][token] = func;
// return token for unsubscribing
return token;
};
/**
* Subscribes the passed function to the passed message once
* @function
* @alias subscribeOnce
* @param { String } message The message to subscribe to
* @param { Function } func The function to call when a new message is published
* @return { PubSub }
*/
PubSub.subscribeOnce = function (message, func) {
var token = PubSub.subscribe(message, function () {
// before func apply, unsubscribe message
PubSub.unsubscribe(token);
func.apply(this, arguments);
});
return PubSub;
};
/**
* Clears all subscriptions
* @function
* @public
* @alias clearAllSubscriptions
*/
PubSub.clearAllSubscriptions = function clearAllSubscriptions() {
messages = {};
};
/**
* Clear subscriptions by the topic
* @function
* @public
* @alias clearAllSubscriptions
*/
PubSub.clearSubscriptions = function clearSubscriptions(topic) {
var m;
for (m in messages) {
if (messages.hasOwnProperty(m) && m.indexOf(topic) === 0) {
delete messages[m];
}
}
};
/**
* Removes subscriptions
*
* - When passed a token, removes a specific subscription.
*
* - When passed a function, removes all subscriptions for that function
*
* - When passed a topic, removes all subscriptions for that topic (hierarchy)
* @function
* @public
* @alias subscribeOnce
* @param { String | Function } value A token, function or topic to unsubscribe from
* @example // Unsubscribing with a token
* var token = PubSub.subscribe('mytopic', myFunc);
* PubSub.unsubscribe(token);
* @example // Unsubscribing with a function
* PubSub.unsubscribe(myFunc);
* @example // Unsubscribing from a topic
* PubSub.unsubscribe('mytopic');
*/
PubSub.unsubscribe = function (value) {
var descendantTopicExists = function (topic) {
var m;
for (m in messages) {
if (messages.hasOwnProperty(m) && m.indexOf(topic) === 0) {
// a descendant of the topic exists:
return true;
}
}
return false;
}, isTopic = typeof value === 'string' && (messages.hasOwnProperty(value) || descendantTopicExists(value)), isToken = !isTopic && typeof value === 'string', isFunction = typeof value === 'function', result = false, m, message, t;
if (isTopic) {
PubSub.clearSubscriptions(value);
return;
}
for (m in messages) {
if (messages.hasOwnProperty(m)) {
message = messages[m];
if (isToken && message[value]) {
delete message[value];
result = value;
// tokens are unique, so we can just stop here
break;
}
if (isFunction) {
for (t in message) {
if (message.hasOwnProperty(t) && message[t] === value) {
delete message[t];
result = true;
}
}
}
}
}
return result;
};
window.TealiumPubSub = PubSub;
}
/***/ }),
/***/ "./src/site/site-pub-sub/site-globals.ts":
/*!***********************************************!*\
!*** ./src/site/site-pub-sub/site-globals.ts ***!
\***********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ ACS_LOGGER_PUBLIC_URL: function() { return /* binding */ ACS_LOGGER_PUBLIC_URL; },
/* harmony export */ ACS_LOGGER_URL: function() { return /* binding */ ACS_LOGGER_URL; },
/* harmony export */ AH_COOKIE_SET: function() { return /* binding */ AH_COOKIE_SET; },
/* harmony export */ CANCEL_HEARTBEAT: function() { return /* binding */ CANCEL_HEARTBEAT; },
/* harmony export */ CANCEL_SITE_SUBS: function() { return /* binding */ CANCEL_SITE_SUBS; },
/* harmony export */ CANCEL_WIDGET_SUBS: function() { return /* binding */ CANCEL_WIDGET_SUBS; },
/* harmony export */ CHAT_INITIALIZATION: function() { return /* binding */ CHAT_INITIALIZATION; },
/* harmony export */ CHECK_AH_TOKEN: function() { return /* binding */ CHECK_AH_TOKEN; },
/* harmony export */ CHECK_FOR_SALE: function() { return /* binding */ CHECK_FOR_SALE; },
/* harmony export */ COMETD_CHANNEL_MESSAGES: function() { return /* binding */ COMETD_CHANNEL_MESSAGES; },
/* harmony export */ COMETD_CHANNEL_SUBSCRIPTION: function() { return /* binding */ COMETD_CHANNEL_SUBSCRIPTION; },
/* harmony export */ COMETD_FAILURE: function() { return /* binding */ COMETD_FAILURE; },
/* harmony export */ COMETD_META_CONNECT: function() { return /* binding */ COMETD_META_CONNECT; },
/* harmony export */ COMETD_META_DISCONNECT: function() { return /* binding */ COMETD_META_DISCONNECT; },
/* harmony export */ COMETD_META_HANDSHAKE: function() { return /* binding */ COMETD_META_HANDSHAKE; },
/* harmony export */ COMETD_META_PUBLISH: function() { return /* binding */ COMETD_META_PUBLISH; },
/* harmony export */ COMETD_META_SUBSCRIBE: function() { return /* binding */ COMETD_META_SUBSCRIBE; },
/* harmony export */ COMETD_META_UNSUBSCRIBE: function() { return /* binding */ COMETD_META_UNSUBSCRIBE; },
/* harmony export */ COMETD_META_UNSUCCESSFUL: function() { return /* binding */ COMETD_META_UNSUCCESSFUL; },
/* harmony export */ COMETD_NOTIFICATION_FAILURE: function() { return /* binding */ COMETD_NOTIFICATION_FAILURE; },
/* harmony export */ COMETD_NOTIFICATION_SUCCESS: function() { return /* binding */ COMETD_NOTIFICATION_SUCCESS; },
/* harmony export */ COMETD_NOTIFY_READ_RECEIPT: function() { return /* binding */ COMETD_NOTIFY_READ_RECEIPT; },
/* harmony export */ COMETD_NOTIFY_START_TYPING: function() { return /* binding */ COMETD_NOTIFY_START_TYPING; },
/* harmony export */ COMETD_NOTIFY_STOP_TYPING: function() { return /* binding */ COMETD_NOTIFY_STOP_TYPING; },
/* harmony export */ COMETD_REQUEST_CHANNEL: function() { return /* binding */ COMETD_REQUEST_CHANNEL; },
/* harmony export */ COMETD_REQUEST_CHANNEL_SUBSCRIPTION: function() { return /* binding */ COMETD_REQUEST_CHANNEL_SUBSCRIPTION; },
/* harmony export */ COMETD_REQUEST_CHAT: function() { return /* binding */ COMETD_REQUEST_CHAT; },
/* harmony export */ COMETD_REQUEST_DISCONNECT: function() { return /* binding */ COMETD_REQUEST_DISCONNECT; },
/* harmony export */ COMETD_REQUEST_HANDSHAKE: function() { return /* binding */ COMETD_REQUEST_HANDSHAKE; },
/* harmony export */ COMETD_REQUEST_NOTIFICATION: function() { return /* binding */ COMETD_REQUEST_NOTIFICATION; },
/* harmony export */ COMETD_REQUEST_SALE_OCCURRED: function() { return /* binding */ COMETD_REQUEST_SALE_OCCURRED; },
/* harmony export */ COMETD_REQUEST_SEND_MESSAGE: function() { return /* binding */ COMETD_REQUEST_SEND_MESSAGE; },
/* harmony export */ COMETD_REQUEST_UPDATE: function() { return /* binding */ COMETD_REQUEST_UPDATE; },
/* harmony export */ COMETD_SALES_OCCURRED_FAILURE: function() { return /* binding */ COMETD_SALES_OCCURRED_FAILURE; },
/* harmony export */ COMETD_SALES_OCCURRED_SUCCESS: function() { return /* binding */ COMETD_SALES_OCCURRED_SUCCESS; },
/* harmony export */ COMETD_UPDATE_FAILURE: function() { return /* binding */ COMETD_UPDATE_FAILURE; },
/* harmony export */ COMETD_UPDATE_SUCCESS: function() { return /* binding */ COMETD_UPDATE_SUCCESS; },
/* harmony export */ COOKIE: function() { return /* binding */ COOKIE; },
/* harmony export */ COOKIE_GSID: function() { return /* binding */ COOKIE_GSID; },
/* harmony export */ COOKIE_LTS: function() { return /* binding */ COOKIE_LTS; },
/* harmony export */ GENERIC_FAILURE: function() { return /* binding */ GENERIC_FAILURE; },
/* harmony export */ GENESYS_CHAT_SERVICE_ENDPOINT: function() { return /* binding */ GENESYS_CHAT_SERVICE_ENDPOINT; },
/* harmony export */ GENESYS_CHAT_SURVEY_ENDPOINT: function() { return /* binding */ GENESYS_CHAT_SURVEY_ENDPOINT; },
/* harmony export */ GENESYS_COBROWSE_CONFIGURATION: function() { return /* binding */ GENESYS_COBROWSE_CONFIGURATION; },
/* harmony export */ GENESYS_COBROWSE_CONFIGURED: function() { return /* binding */ GENESYS_COBROWSE_CONFIGURED; },
/* harmony export */ GENESYS_FETCH_SESSION_ENDPOINT: function() { return /* binding */ GENESYS_FETCH_SESSION_ENDPOINT; },
/* harmony export */ GENESYS_REQUEST_NATIVE_CHAT: function() { return /* binding */ GENESYS_REQUEST_NATIVE_CHAT; },
/* harmony export */ GENESYS_REQUEST_NATIVE_CHAT_FAILURE: function() { return /* binding */ GENESYS_REQUEST_NATIVE_CHAT_FAILURE; },
/* harmony export */ GENESYS_REQUEST_NATIVE_CHAT_SUCCESS: function() { return /* binding */ GENESYS_REQUEST_NATIVE_CHAT_SUCCESS; },
/* harmony export */ GENESYS_REQUEST_NICKNAME_UPDATE: function() { return /* binding */ GENESYS_REQUEST_NICKNAME_UPDATE; },
/* harmony export */ GENESYS_REQUEST_POLLING: function() { return /* binding */ GENESYS_REQUEST_POLLING; },
/* harmony export */ GENESYS_REQUEST_POLLING_FAILURE: function() { return /* binding */ GENESYS_REQUEST_POLLING_FAILURE; },
/* harmony export */ GENESYS_REQUEST_POLLING_SUCCESS: function() { return /* binding */ GENESYS_REQUEST_POLLING_SUCCESS; },
/* harmony export */ GENESYS_REQUEST_PRE_CONNECT: function() { return /* binding */ GENESYS_REQUEST_PRE_CONNECT; },
/* harmony export */ GENESYS_REQUEST_PRE_CONNECT_FAILURE: function() { return /* binding */ GENESYS_REQUEST_PRE_CONNECT_FAILURE; },
/* harmony export */ GENESYS_REQUEST_PRE_CONNECT_SUCCESS: function() { return /* binding */ GENESYS_REQUEST_PRE_CONNECT_SUCCESS; },
/* harmony export */ GENESYS_REQUEST_TC_UPDATE: function() { return /* binding */ GENESYS_REQUEST_TC_UPDATE; },
/* harmony export */ GENESYS_REQUEST_TC_UPDATE_FAILURE: function() { return /* binding */ GENESYS_REQUEST_TC_UPDATE_FAILURE; },
/* harmony export */ GENESYS_REQUEST_TC_UPDATE_SUCCESS: function() { return /* binding */ GENESYS_REQUEST_TC_UPDATE_SUCCESS; },
/* harmony export */ GENESYS_SEND_SURVEY: function() { return /* binding */ GENESYS_SEND_SURVEY; },
/* harmony export */ GENESYS_SEND_SURVEY_FAILURE: function() { return /* binding */ GENESYS_SEND_SURVEY_FAILURE; },
/* harmony export */ GENESYS_SEND_SURVEY_SUCCESS: function() { return /* binding */ GENESYS_SEND_SURVEY_SUCCESS; },
/* harmony export */ GENESYS_SET_AGENT_ID: function() { return /* binding */ GENESYS_SET_AGENT_ID; },
/* harmony export */ GENESYS_SUSPEND_POLLING: function() { return /* binding */ GENESYS_SUSPEND_POLLING; },
/* harmony export */ GENESYS_UPDATE_CHAT_DATA_ENDPOINT: function() { return /* binding */ GENESYS_UPDATE_CHAT_DATA_ENDPOINT; },
/* harmony export */ GENESYS_VALIDATE_IP_ADDRESS: function() { return /* binding */ GENESYS_VALIDATE_IP_ADDRESS; },
/* harmony export */ GENESYS_VALIDATE_IP_ADDRESS_FAILURE: function() { return /* binding */ GENESYS_VALIDATE_IP_ADDRESS_FAILURE; },
/* harmony export */ GENESYS_VALIDATE_IP_ADDRESS_SUCCESS: function() { return /* binding */ GENESYS_VALIDATE_IP_ADDRESS_SUCCESS; },
/* harmony export */ GRAB_HEARTBEAT_DATA: function() { return /* binding */ GRAB_HEARTBEAT_DATA; },
/* harmony export */ GWE_SEND_DISPOSITION_CODE: function() { return /* binding */ GWE_SEND_DISPOSITION_CODE; },
/* harmony export */ GWE_SEND_DISPOSITION_CODE_FAILURE: function() { return /* binding */ GWE_SEND_DISPOSITION_CODE_FAILURE; },
/* harmony export */ GWE_SEND_DISPOSITION_CODE_SUCCESS: function() { return /* binding */ GWE_SEND_DISPOSITION_CODE_SUCCESS; },
/* harmony export */ MAX_ATTEMPTS: function() { return /* binding */ MAX_ATTEMPTS; },
/* harmony export */ MAX_ERR_RETRIES: function() { return /* binding */ MAX_ERR_RETRIES; },
/* harmony export */ ML_SITE_IDS: function() { return /* binding */ ML_SITE_IDS; },
/* harmony export */ MONITORINGJS_HEARTBEAT: function() { return /* binding */ MONITORINGJS_HEARTBEAT; },
/* harmony export */ MONITORINGJS_HEARTBEAT_FAILURE: function() { return /* binding */ MONITORINGJS_HEARTBEAT_FAILURE; },
/* harmony export */ MONITORINGJS_REQUEST: function() { return /* binding */ MONITORINGJS_REQUEST; },
/* harmony export */ MONITORINGJS_RESPONSE: function() { return /* binding */ MONITORINGJS_RESPONSE; },
/* harmony export */ MONITORINGJS_RESPONSE_FAILURE: function() { return /* binding */ MONITORINGJS_RESPONSE_FAILURE; },
/* harmony export */ MONITORING_ID_RESPONSE: function() { return /* binding */ MONITORING_ID_RESPONSE; },
/* harmony export */ OGW_URL: function() { return /* binding */ OGW_URL; },
/* harmony export */ PIXEL_TAG_URL: function() { return /* binding */ PIXEL_TAG_URL; },
/* harmony export */ PRECHAT_SURVEY_GET_RESPONSE: function() { return /* binding */ PRECHAT_SURVEY_GET_RESPONSE; },
/* harmony export */ PRECHAT_SURVEY_GET_RESPONSE_FAILURE: function() { return /* binding */ PRECHAT_SURVEY_GET_RESPONSE_FAILURE; },
/* harmony export */ PRECHAT_SURVEY_GET_RESPONSE_SUCCESS: function() { return /* binding */ PRECHAT_SURVEY_GET_RESPONSE_SUCCESS; },
/* harmony export */ PRE_CHAT_SURVEY: function() { return /* binding */ PRE_CHAT_SURVEY; },
/* harmony export */ SALE_INDICATORS: function() { return /* binding */ SALE_INDICATORS; },
/* harmony export */ SEND_PROXY_DATA: function() { return /* binding */ SEND_PROXY_DATA; },
/* harmony export */ SET_MONITORING_STATUS: function() { return /* binding */ SET_MONITORING_STATUS; },
/* harmony export */ SPARTA_WIDGET_READY: function() { return /* binding */ SPARTA_WIDGET_READY; },
/* harmony export */ SURVEY_GET_RESPONSE: function() { return /* binding */ SURVEY_GET_RESPONSE; },
/* harmony export */ SURVEY_GET_RESPONSE_FAILURE: function() { return /* binding */ SURVEY_GET_RESPONSE_FAILURE; },
/* harmony export */ SURVEY_GET_RESPONSE_SUCCESS: function() { return /* binding */ SURVEY_GET_RESPONSE_SUCCESS; },
/* harmony export */ WIDGET_REQUEST_CONFIGURATION: function() { return /* binding */ WIDGET_REQUEST_CONFIGURATION; },
/* harmony export */ WIDGET_REQUEST_CONFIGURATION_ERROR: function() { return /* binding */ WIDGET_REQUEST_CONFIGURATION_ERROR; },
/* harmony export */ WIDGET_REQUEST_CONFIGURATION_SUCCESSFUL: function() { return /* binding */ WIDGET_REQUEST_CONFIGURATION_SUCCESSFUL; },
/* harmony export */ errorLoadingWidget: function() { return /* binding */ errorLoadingWidget; },
/* harmony export */ spartaLoaderLoaded: function() { return /* binding */ spartaLoaderLoaded; }
/* harmony export */ });
/** @module base/constants */
/**
* cometd meta constants
* @type {string}
*/
var COMETD_META_CONNECT = 'COMETD_META_CONNECT';
var COMETD_META_PUBLISH = 'COMETD_META_PUBLISH';
var COMETD_META_SUBSCRIBE = 'COMETD_META_SUBSCRIBE';
var COMETD_META_HANDSHAKE = 'COMETD_META_HANDSHAKE';
var COMETD_META_DISCONNECT = 'COMETD_META_DISCONNECT';
var COMETD_META_UNSUBSCRIBE = 'COMETD_META_UNSUBSCRIBE';
var COMETD_META_UNSUCCESSFUL = 'COMETD_META_UNSUCCESSFUL';
/**
* genesys native chat event
* @type {string}
*/
var GENESYS_REQUEST_NATIVE_CHAT = 'GENESYS_REQUEST_NATIVE_CHAT';
var GENESYS_REQUEST_NATIVE_CHAT_SUCCESS = 'GENESYS_REQUEST_NATIVE_CHAT_SUCCESS';
var GENESYS_REQUEST_NATIVE_CHAT_FAILURE = 'GENESYS_REQUEST_NATIVE_CHAT_FAILURE';
/**
* genesys request terms and conditions update event
* @type {string}
*/
var GENESYS_REQUEST_TC_UPDATE = 'GENESYS_REQUEST_TC_UPDATE';
var GENESYS_REQUEST_TC_UPDATE_SUCCESS = 'GENESYS_REQUEST_TC_UPDATE_SUCCESS';
var GENESYS_REQUEST_TC_UPDATE_FAILURE = 'GENESYS_REQUEST_TC_UPDATE_FAILURE';
/**
* cometd request constants
* @type {string}
*/
var COMETD_REQUEST_UPDATE = 'COMETD_REQUEST_UPDATE';
var COMETD_REQUEST_CHANNEL = 'COMETD_REQUEST_CHANNEL';
var COMETD_REQUEST_HANDSHAKE = 'COMETD_REQUEST_HANDSHAKE';
var COMETD_REQUEST_DISCONNECT = 'COMETD_REQUEST_DISCONNECT';
var COMETD_REQUEST_SEND_MESSAGE = 'COMETD_REQUEST_SEND_MESSAGE';
var COMETD_REQUEST_NOTIFICATION = 'COMETD_REQUEST_NOTIFICATION';
var COMETD_REQUEST_SALE_OCCURRED = 'COMETD_REQUEST_SALE_OCCURRED';
var COMETD_FAILURE = 'COMETD_FAILURE';
/**
* genesys request constants
* @type {string}
*/
var GENESYS_REQUEST_PRE_CONNECT = 'GENESYS_REQUEST_PRE_CONNECT';
var GENESYS_REQUEST_POLLING = 'GENESYS_REQUEST_POLLING';
var GENESYS_SUSPEND_POLLING = 'GENESYS_SUSPEND_POLLING';
var GENESYS_REQUEST_NICKNAME_UPDATE = 'GENESYS_REQUEST_NICKNAME_UPDATE';
/**
* genesys send survey constants
* @type {string}
*/
var GENESYS_SEND_SURVEY = 'GENESYS_SEND_SURVEY';
var GENESYS_SEND_SURVEY_SUCCESS = 'GENESYS_SEND_SURVEY_SUCCESS';
var GENESYS_SEND_SURVEY_FAILURE = 'GENESYS_SEND_SURVEY_FAILURE';
/**
* Genesys Set Agent ID
* @type {string}
*/
var GENESYS_SET_AGENT_ID = 'GENESYS_SET_AGENT_ID';
/**
* genesys validate IP address
* @type {string}
*/
var GENESYS_VALIDATE_IP_ADDRESS = 'GENESYS_VALIDATE_IP_ADDRESS';
/**
* Cometd notifications constants
* @type {string}
*/
var COMETD_NOTIFY_STOP_TYPING = 'COMETD_NOTIFY_STOP_TYPING';
var COMETD_NOTIFY_READ_RECEIPT = 'COMETD_NOTIFY_READ_RECEIPT';
var COMETD_NOTIFY_START_TYPING = 'COMETD_NOTIFY_START_TYPING';
var COMETD_REQUEST_CHAT = 'COMETD_REQUEST_CHAT';
/**
* Cometd subscriptions constants
* @type {string}
*/
var COMETD_CHANNEL_MESSAGES = 'COMETD_CHANNEL_MESSAGES';
var COMETD_CHANNEL_SUBSCRIPTION = 'COMETD_CHANNEL_SUBSCRIPTION';
var COMETD_REQUEST_CHANNEL_SUBSCRIPTION = 'COMETD_REQUEST_CHANNEL_SUBSCRIPTION';
/**
* MonitoringJS constants
* @type {string}
*/
var MONITORINGJS_REQUEST = 'MONITORINGJS_REQUEST';
var MONITORINGJS_HEARTBEAT = 'MONITORINGJS_HEARTBEAT';
/**
* Genesys configurations & request constants
* @type {string}
*/
var GENESYS_COBROWSE_CONFIGURED = 'GENESYS_COBROWSE_CONFIGURED';
var GENESYS_COBROWSE_CONFIGURATION = 'GENESYS_COBROWSE_CONFIGURATION';
/**
* GWE send disposition request, success, & failure constants
* @type {string}
*/
var GWE_SEND_DISPOSITION_CODE = 'GWE_SEND_DISPOSITION_CODE';
var GWE_SEND_DISPOSITION_CODE_SUCCESS = 'GWE_SEND_DISPOSITION_CODE_SUCCESS';
var GWE_SEND_DISPOSITION_CODE_FAILURE = 'GWE_SEND_DISPOSITION_CODE_FAILURE';
/**
* Post Message Constants
* @type {string}
*/
var CANCEL_HEARTBEAT = 'CANCEL_HEARTBEAT';
var CANCEL_WIDGET_SUBS = 'CANCEL_WIDGET_SUBS';
var CANCEL_SITE_SUBS = 'CANCEL_SITE_SUBS';
var CHECK_AH_TOKEN = 'CHECK_AH_TOKEN';
var CHECK_FOR_SALE = 'CHECK_FOR_SALE';
var GRAB_HEARTBEAT_DATA = 'GRAB_HEARTBEAT_DATA';
var SET_MONITORING_STATUS = 'SET_MONITORING_STATUS';
var SEND_PROXY_DATA = 'SEND_PROXY_DATA';
var MAX_ERR_RETRIES = 3;
/**
* response failures constants
* @type {string}
*/
var GENERIC_FAILURE = 'GENERIC_FAILURE';
var COMETD_NOTIFICATION_FAILURE = 'COMETD_NOTIFICATION_FAILURE';
var COMETD_SALES_OCCURRED_FAILURE = 'COMETD_SALES_OCCURRED_FAILURE';
var COMETD_UPDATE_FAILURE = 'COMETD_UPDATE_FAILURE';
var GENESYS_REQUEST_POLLING_FAILURE = 'GENESYS_REQUEST_POLLING_FAILURE';
var GENESYS_REQUEST_PRE_CONNECT_FAILURE = 'GENESYS_REQUEST_PRE_CONNECT_FAILURE';
var GENESYS_VALIDATE_IP_ADDRESS_FAILURE = 'GENESYS_VALIDATE_IP_ADDRESS_FAILURE';
var MONITORINGJS_HEARTBEAT_FAILURE = 'MONITORINGJS_HEARTBEAT_FAILURE';
var MONITORINGJS_RESPONSE_FAILURE = 'MONITORINGJS_RESPONSE_FAILURE';
var PRECHAT_SURVEY_GET_RESPONSE_FAILURE = 'PRECHAT_SURVEY_GET_RESPONSE_FAILURE';
var SURVEY_GET_RESPONSE_FAILURE = 'SURVEY_GET_RESPONSE_FAILURE';
/**
* response success constants
* @type {string}
*/
var COMETD_NOTIFICATION_SUCCESS = 'COMETD_NOTIFICATION_SUCCESS';
var COMETD_SALES_OCCURRED_SUCCESS = 'COMETD_SALES_OCCURRED_SUCCESS';
var COMETD_UPDATE_SUCCESS = 'COMETD_UPDATE_SUCCESS';
var GENESYS_REQUEST_POLLING_SUCCESS = 'GENESYS_REQUEST_POLLING_SUCCESS';
var GENESYS_REQUEST_PRE_CONNECT_SUCCESS = 'GENESYS_REQUEST_PRE_CONNECT_SUCCESS';
var GENESYS_VALIDATE_IP_ADDRESS_SUCCESS = 'GENESYS_VALIDATE_IP_ADDRESS_SUCCESS';
var MONITORINGJS_RESPONSE = 'MONITORINGJS_RESPONSE';
var MONITORING_ID_RESPONSE = 'MONITORING_ID_RESPONSE';
var PRECHAT_SURVEY_GET_RESPONSE = 'PRECHAT_SURVEY_GET_RESPONSE';
var PRECHAT_SURVEY_GET_RESPONSE_SUCCESS = 'PRECHAT_SURVEY_GET_RESPONSE_SUCCESS';
var SURVEY_GET_RESPONSE = 'SURVEY_GET_RESPONSE';
var SURVEY_GET_RESPONSE_SUCCESS = 'SURVEY_GET_RESPONSE_SUCCESS';
/**
* chat & widget constants
* @type {string}
*/
var AH_COOKIE_SET = 'AH_COOKIE_SET';
var spartaLoaderLoaded = 'spartaLoaderLoaded';
var errorLoadingWidget = 'errorLoadingWidget';
var CHAT_INITIALIZATION = 'CHAT_INITIALIZATION';
var WIDGET_REQUEST_CONFIGURATION = 'WIDGET_REQUEST_CONFIGURATION';
var SPARTA_WIDGET_READY = 'SPARTA_WIDGET_READY.spartaWidgetUtility';
var WIDGET_REQUEST_CONFIGURATION_ERROR = 'WIDGET_REQUEST_CONFIGURATION_ERROR';
var WIDGET_REQUEST_CONFIGURATION_SUCCESSFUL = 'WIDGET_REQUEST_CONFIGURATION_SUCCESSFUL';
var PRE_CHAT_SURVEY = 'PRE_CHAT_SURVEY';
/**
* ML Site IDs
* @type {array}
*/
var ML_SITE_IDS = ['OSE', 'MLD', 'MLDOA'];
/**
* chat cookie constants
* @type {string}
*/
var COOKIE = {
NAME: 'occtChat',
EXPIRATION: 10,
DOMAIN: '.bankofamerica.com',
SECURE: true,
PATH: '/',
};
/**
* chat lts cookie constants
* @type {string}
*/
var COOKIE_LTS = {
NAME: 'occtChat_lts',
EXPIRATION: 60 * 24 * 30,
DOMAIN: '.bankofamerica.com',
SECURE: true,
PATH: '/',
};
/**
* GSID Cookie
*/
var COOKIE_GSID = {
NAME: 'GSID',
DOMAIN: '.bankofamerica.com',
SECURE: true,
PATH: '/',
};
/**
* Maximum number of attempts for validateIpAddress call.
*/
var MAX_ATTEMPTS = 2;
/**
* URLS
* @type {string}
*/
var PIXEL_TAG_URL = 'https://www.bankofamerica.com/pa/global-assets/1.0/graphic/clr.gif';
var OGW_URL = '/ogateway/public/login/rest/sas/v1/validateIpAddress';
/**
* Genesys Endpoints and temporary Dev Chat domain.
* @type {string}
*/
var GENESYS_UPDATE_CHAT_DATA_ENDPOINT = '1/service/UpdateChatData';
var GENESYS_FETCH_SESSION_ENDPOINT = '1/service/GetRefIDInfo/';
var GENESYS_CHAT_SERVICE_ENDPOINT = '1/service/ChatService/'; // add new endpoint here
var GENESYS_CHAT_SURVEY_ENDPOINT = '1/service/ChatSurvey/';
/**
* Sale Indicators Constants Array
* @type {array}
*/
var SALE_INDICATORS = [
'inqClientOrderNum',
'MLD_OAO_CONFIRMATIONNUMBER',
'MLD_OAO_ACCOUNTNUMBER',
];
/**
* Mobile ACS Logger Service
* @type {string}
*/
var ACS_LOGGER_URL = '/mgateway/v1/clientLogger/log';
var ACS_LOGGER_PUBLIC_URL = '/mgateway/public/v1/clientLogger/log';
/***/ }),
/***/ "./src/site/site-pub-sub/subscriptions.ts":
/*!************************************************!*\
!*** ./src/site/site-pub-sub/subscriptions.ts ***!
\************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
/* harmony export */ });
/* harmony import */ var _site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/* harmony import */ var _messaging_handlers_request_channel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../messaging/handlers/request-channel */ "./src/site/messaging/handlers/request-channel.ts");
/* harmony import */ var _messaging_handlers_channel_message__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../messaging/handlers/channel-message */ "./src/site/messaging/handlers/channel-message.ts");
/* harmony import */ var _messaging_handlers_request_handshake__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../messaging/handlers/request-handshake */ "./src/site/messaging/handlers/request-handshake.ts");
/* harmony import */ var _site_api_handlers_configure_cobrowse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../site-api/handlers/configure-cobrowse */ "./src/site/site-api/handlers/configure-cobrowse.ts");
/* harmony import */ var _site_api_handlers_survey_get_response__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../site-api/handlers/survey-get-response */ "./src/site/site-api/handlers/survey-get-response.ts");
/* harmony import */ var _site_api_handlers_request_polling__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../site-api/handlers/request-polling */ "./src/site/site-api/handlers/request-polling.ts");
/* harmony import */ var _site_api_handlers_request_preconnect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../site-api/handlers/request-preconnect */ "./src/site/site-api/handlers/request-preconnect.ts");
/* harmony import */ var _site_api_native_chat_update__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../site-api/native-chat-update */ "./src/site/site-api/native-chat-update.ts");
/* eslint-disable max-len */
/* eslint-disable no-undef */
/** @module site-pub-sub/subscriptions */
/**
* Subscribe Tealium and Sparta widget loader events
* @returns {boolean}
*/
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENERIC_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_CONNECT, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_PUBLISH, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_SUBSCRIBE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_HANDSHAKE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_DISCONNECT, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_UNSUBSCRIBE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_META_UNSUCCESSFUL, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_CHANNEL_SUBSCRIPTION, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
// TealiumPubSub.subscribe(GENESYS_REQUEST_TC_UPDATE_FAILURE, publishWindow);
// TealiumPubSub.subscribe(GENESYS_REQUEST_TC_UPDATE_SUCCESS, publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_PRE_CONNECT_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_PRE_CONNECT_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.SURVEY_GET_RESPONSE_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.SURVEY_GET_RESPONSE_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.PRECHAT_SURVEY_GET_RESPONSE_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.PRECHAT_SURVEY_GET_RESPONSE_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_UPDATE_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_UPDATE_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_POLLING_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_POLLING_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_VALIDATE_IP_ADDRESS_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY_SUCCESS, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT_FAILURE, _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishWindow);
TealiumPubSub.subscribe(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_CHANNEL_MESSAGES, _messaging_handlers_channel_message__WEBPACK_IMPORTED_MODULE_3__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_CHANNEL, _messaging_handlers_request_channel__WEBPACK_IMPORTED_MODULE_2__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.PRECHAT_SURVEY_GET_RESPONSE, function (payload) { return (0,_site_api_handlers_survey_get_response__WEBPACK_IMPORTED_MODULE_6__["default"])(payload, true); });
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.SURVEY_GET_RESPONSE, _site_api_handlers_survey_get_response__WEBPACK_IMPORTED_MODULE_6__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_HANDSHAKE, _messaging_handlers_request_handshake__WEBPACK_IMPORTED_MODULE_4__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_COBROWSE_CONFIGURATION, _site_api_handlers_configure_cobrowse__WEBPACK_IMPORTED_MODULE_5__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NATIVE_CHAT, _site_api_native_chat_update__WEBPACK_IMPORTED_MODULE_9__["default"]);
// window.sparta.chat.widgetLoader.sub(GENESYS_REQUEST_TC_UPDATE, requestTCUpdate)
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_PRE_CONNECT, _site_api_handlers_request_preconnect__WEBPACK_IMPORTED_MODULE_8__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_POLLING, _site_api_handlers_request_polling__WEBPACK_IMPORTED_MODULE_7__["default"]);
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NICKNAME_UPDATE, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_REQUEST_NICKNAME_UPDATE, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SET_AGENT_ID, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SET_AGENT_ID, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SEND_SURVEY, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SUSPEND_POLLING, function () { return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_SUSPEND_POLLING, {}); });
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_DISCONNECT, function () { return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_DISCONNECT, {}); });
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_STOP_TYPING, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_STOP_TYPING, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_START_TYPING, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_START_TYPING, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_READ_RECEIPT, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_NOTIFY_READ_RECEIPT, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_CHANNEL_SUBSCRIPTION, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_CHANNEL_SUBSCRIPTION, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_SEND_MESSAGE, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_SEND_MESSAGE, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_NOTIFICATION, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_NOTIFICATION, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_SALE_OCCURRED, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_SALE_OCCURRED, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GWE_SEND_DISPOSITION_CODE, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.GWE_SEND_DISPOSITION_CODE, detail);
});
window.sparta.chat.widgetLoader.sub(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_UPDATE, function (_a) {
var detail = _a.detail;
return (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.publishTealium)(_site_globals__WEBPACK_IMPORTED_MODULE_0__.COMETD_REQUEST_UPDATE, detail);
});
return false;
}
/***/ }),
/***/ "./src/site/site-utilities/cookie-storage/get.ts":
/*!*******************************************************!*\
!*** ./src/site/site-utilities/cookie-storage/get.ts ***!
\*******************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ getCookieStorage; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/** @module cookie-storage/get */
function getCookieStorage(name) {
if (name === void 0) { name = _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE.NAME; }
var lookup = "".concat(name, "=");
var decodedCookie = decodeURIComponent(document.cookie);
var cookieArr = decodedCookie.split(';');
for (var i = 0; i < cookieArr.length; i += 1) {
var cookie = cookieArr[i];
while (cookie.charAt(0) === ' ') {
cookie = cookie.substring(1);
}
if (cookie.indexOf(lookup) === 0) {
return JSON.parse(cookie.substring(lookup.length, cookie.length));
}
}
return {};
}
/***/ }),
/***/ "./src/site/site-utilities/cookie-storage/remove.ts":
/*!**********************************************************!*\
!*** ./src/site/site-utilities/cookie-storage/remove.ts ***!
\**********************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ removeCookie; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _get__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./get */ "./src/site/site-utilities/cookie-storage/get.ts");
/** @module cookie-storage/remove */
function removeCookie(name) {
if (name === void 0) { name = _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE.NAME; }
if ((0,_get__WEBPACK_IMPORTED_MODULE_1__["default"])(name)) {
var isLocal = window.sparta.env === 'local';
var expiry = '; expires=Thu, 01 Jan 1970 00:00:01 GMT';
var domain = isLocal ? '' : "; domain=".concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE.DOMAIN);
var secure = (_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE.SECURE && !isLocal) ? '; secure' : '';
var cookie = "".concat(name, "=").concat(expiry, "; path=").concat(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE.PATH).concat(domain).concat(secure);
window.document.cookie = cookie;
}
}
/***/ }),
/***/ "./src/site/site-utilities/cookie-storage/set.ts":
/*!*******************************************************!*\
!*** ./src/site/site-utilities/cookie-storage/set.ts ***!
\*******************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": function() { return /* binding */ setCookieStorage; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _get__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./get */ "./src/site/site-utilities/cookie-storage/get.ts");
/* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utilities */ "./src/site/site-utilities/utilities.ts");
/** @module cookie-storage/set */
function setCookieStorage(payload, cookie) {
if (cookie === void 0) { cookie = _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE; }
var stringifiedValue = JSON.stringify(Object.assign((0,_get__WEBPACK_IMPORTED_MODULE_1__["default"])(cookie.NAME), payload));
var isLocal = window.sparta.env === 'local';
var expiry = "; expires=".concat((new Date(Date.now() + (cookie.EXPIRATION * 60 * 1000))).toUTCString());
var domain = isLocal ? '' : "; domain=".concat((0,_utilities__WEBPACK_IMPORTED_MODULE_2__.getCurrentDomain)());
var secure = (cookie.SECURE && !isLocal) ? '; secure' : '';
var sameSite = (cookie.SECURE && !isLocal) ? '; sameSite=none' : '';
var cookieInfo = "".concat(cookie.NAME, "=").concat(stringifiedValue).concat(expiry, "; path=").concat(cookie.PATH).concat(domain).concat(secure).concat(sameSite);
window.document.cookie = cookieInfo;
}
/***/ }),
/***/ "./src/site/site-utilities/utilities.ts":
/*!**********************************************!*\
!*** ./src/site/site-utilities/utilities.ts ***!
\**********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ getAhToken: function() { return /* binding */ getAhToken; },
/* harmony export */ getCurrentDomain: function() { return /* binding */ getCurrentDomain; },
/* harmony export */ getDomain: function() { return /* binding */ getDomain; },
/* harmony export */ getGSID: function() { return /* binding */ getGSID; },
/* harmony export */ getHostName: function() { return /* binding */ getHostName; },
/* harmony export */ getParams: function() { return /* binding */ getParams; },
/* harmony export */ increaseErrorCount: function() { return /* binding */ increaseErrorCount; },
/* harmony export */ isEmptyArr: function() { return /* binding */ isEmptyArr; },
/* harmony export */ isEmptyObj: function() { return /* binding */ isEmptyObj; },
/* harmony export */ isLocal: function() { return /* binding */ isLocal; },
/* harmony export */ isSalePresent: function() { return /* binding */ isSalePresent; },
/* harmony export */ isSpanish: function() { return /* binding */ isSpanish; },
/* harmony export */ logGenesysEvent: function() { return /* binding */ logGenesysEvent; },
/* harmony export */ publishTealium: function() { return /* binding */ publishTealium; },
/* harmony export */ publishWindow: function() { return /* binding */ publishWindow; },
/* harmony export */ queryStringParse: function() { return /* binding */ queryStringParse; },
/* harmony export */ waitForAHToken: function() { return /* binding */ waitForAHToken; }
/* harmony export */ });
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _cookie_storage_get__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cookie-storage/get */ "./src/site/site-utilities/cookie-storage/get.ts");
/* harmony import */ var _site_api_validate_ip_address__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../site-api/validate-ip-address */ "./src/site/site-api/validate-ip-address.ts");
/* eslint-disable no-undef */
/* eslint-disable max-len */
/** @module utilities/utilities */
/**
* We have two different language versions of chat. A Spanish version and an English version. We will load the corresponding
* version that relates to language value of the page.
* @returns {string}
*/
function isSpanish() {
return genesysData.LANGUAGE === 'es-us' ? 'es' : 'en';
}
/**
* getParams
* Returns all query string params in an object
* @returns {object}
*/
function getParams() {
var obj = {};
window.location.search.substr(1).split('&').forEach(function (param) {
var _a = param.split('='), name = _a[0], value = _a[1];
obj[name] = value;
});
return obj;
}
/**
* When localhost set to localhost, if not we'll use hostname. Will fail if it's relative, widget
* accepts hostname
* @returns {string}
*/
function isLocal() {
if (window.location.href.indexOf('localhost') > -1) {
return 'http://localhost:3005';
}
return 'https://' + window.location.hostname;
}
/**
* isEmptyObj
* Function designed to check if an object is empty (returns true) or contains key/value pairs (returns false)
* @returns {boolean}
*/
function isEmptyObj(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key))
return false;
}
return true;
}
/**
* isEmptyArr
* Function designed to check if an array is empty (returns true) or contains items (returns false)
* @param {array} arr
* @returns {boolean}
*/
function isEmptyArr(arr) {
return (Array.isArray(arr) && arr.length === 0);
}
/**
* isSalePresent
* Function designed to check through the digitalData object for the presence of all the possible sale indicators
* @param {object} ddo - the digitalData object on the window
* @returns {string} - if defined
* @returns {null} - if undefined
*/
function isSalePresent(ddo) {
for (var i = 0; i < _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SALE_INDICATORS.length; i++) {
if (ddo[_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SALE_INDICATORS[i]] && ddo[_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SALE_INDICATORS[i]] !== null && ddo[_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SALE_INDICATORS[i]] !== '') {
return ddo[_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.SALE_INDICATORS[i]];
}
}
return null;
}
/**
* increaseErrorCount
* Function designed to count every time that an error occurs. Once 3 errors occur,
* publish will occur to shutdown chat on widget and site
*/
function increaseErrorCount() {
if (bactm && bactm.ddo) {
var errorCount = bactm.ddo.get('page.attributes.chat.genesys_error_count') || 0;
errorCount++;
bactm.ddo.set('page.attributes.chat.genesys_error_count', errorCount);
if (errorCount === _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.MAX_ERR_RETRIES)
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.CANCEL_WIDGET_SUBS);
}
}
/**
* getAhToken
* Checks to see if the AhToken Cookie is still present
* @param {string} name - Optional as it should always be 'ah_token'
* @returns {object}
*/
function getAhToken(name) {
if (name === void 0) { name = 'ah_token'; }
var lookup = "".concat(name, "=");
var decodedCookie = decodeURIComponent(document.cookie);
var cookieArr = decodedCookie.split(';');
for (var i = 0; i < cookieArr.length; i += 1) {
var cookie = cookieArr[i];
while (cookie.charAt(0) === ' ') {
cookie = cookie.substring(1);
}
if (cookie.indexOf(lookup) === 0) {
return { ah_token: cookie.substring(lookup.length, cookie.length) };
}
}
return {};
}
/**
* waitForAHToken
* async function that will confirm the AH token and if it is present then proceed; if not,
* await the validateIPAddress function
* @param {string} eventName
* @param {object} payload
* @returns {boolean}
*/
function waitForAHToken(eventName, payload) {
var isAhToken = getAhToken();
if (isEmptyObj(isAhToken)) {
(0,_site_api_validate_ip_address__WEBPACK_IMPORTED_MODULE_2__["default"])(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.GENESYS_VALIDATE_IP_ADDRESS, { ogwUrl: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.OGW_URL }, { eventName: eventName, payload: payload });
}
else {
publishTealium(eventName, payload);
}
}
/**
* getHostName
* Extracts hostname from URL String
* @param {string} url to extract hostname
* @returns {string} hostname
*/
function getHostName(url) {
var match = url.match(/:\/\/(www[0-9]?\.)?(.[^/:]+)/i);
if (match != null && match.length > 2 && typeof match[2] === 'string' && match[2].length > 0) {
return match[2];
}
return null;
}
/**
* getDomain
* Extract TLD from URL string
* @param {string} url to extract tld
* @returns {string} top level domain
*/
function getDomain(url) {
var hostName = getHostName(url);
var domain = hostName;
if (hostName != null) {
var parts = hostName.split('.').reverse();
if (parts != null && parts.length > 1) {
domain = "".concat(parts[1], ".").concat(parts[0]);
}
}
if (document.referrer.includes('fssit1.ml.com'))
return 'fssit1.ml.com';
if (document.referrer.includes('fssit2.ml.com'))
return 'fssit2.ml.com';
if (document.referrer.includes('benefitssit1'))
return 'benefitssit1.ml.com';
if (document.referrer.includes('benefitssit2'))
return 'benefitssit2.ml.com';
return domain;
}
/**
* getCurrentDomain
* Obtains the current TLD domain from current window.location.href
* @returns {string} Current TLD
*/
function getCurrentDomain() {
return getDomain(window.location.origin);
}
/**
* Publish to window
* @param {string} eventName - name on event
* @param {object} payload - Events payload
* @returns {boolean}
*/
function publishWindow(eventName, payload) {
window.sparta.chat.widgetLoader.pub(eventName, payload);
return false;
}
/**
* Publish to Tealium
* @param {string} eventName - name on event
* @param {object} payload - Events payload
* @returns {boolean}
*/
function publishTealium(eventName, payload) {
TealiumPubSub.publish(eventName, payload);
return false;
}
/**
* queryStringParse
* Used to parse out query string values to provide a modified chat experience in LLEs
* @param {string} name - name for query string to parse
* @returns {string}
*/
function queryStringParse(name) {
var url = window.location.href;
var regex = new RegExp("[?&]".concat(name, "(=([^]*)|&|#|$)"));
var results = regex.exec(url);
if (results && results[2])
return decodeURIComponent(results[2]);
return '';
}
/**
* Log Genesys Event
* @param {eventName} - Name of the genesys event
* @param {info} - Other information that needs to be collected
* @returns {void}
*/
function logGenesysEvent(levelNum, eventName, data) {
var ddoEnvProd = window.digitalData && digitalData.environmentVariables && digitalData.environmentVariables.env.indexOf('notprod') > -1 ? false : true;
if (window.bactm_envSelector === 'prod' || ddoEnvProd)
return;
if (!window.bactm) {
window.bactm = {};
window.bactm.chat_dataCollector = [];
}
var levelNumEvents = {
1: 'info',
2: 'warn',
3: 'error',
};
var level = levelNumEvents[levelNum];
var newEvent = {
eventName: eventName,
data: data,
};
if (window.showChatDebugConsole) {
console.groupCollapsed("Bactm Genesys Chat - ".concat(eventName));
console.log({ data: data, level: level });
console.groupEnd();
}
window.bactm.chat_dataCollector.push({ level: level, newEvent: newEvent });
}
/**
* getGSID
* @returns null || string
*/
function getGSID() {
var gsid = (0,_cookie_storage_get__WEBPACK_IMPORTED_MODULE_1__["default"])(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_0__.COOKIE_GSID);
if (isEmptyObj(gsid)) {
return '';
}
return gsid;
}
/***/ }),
/***/ "./src/site/site-utilities/utilities/getParentInfo.ts":
/*!************************************************************!*\
!*** ./src/site/site-utilities/utilities/getParentInfo.ts ***!
\************************************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ getParentInfo: function() { return /* binding */ getParentInfo; },
/* harmony export */ setOrigin: function() { return /* binding */ setOrigin; },
/* harmony export */ setParentInfo: function() { return /* binding */ setParentInfo; }
/* harmony export */ });
var parentDDO = {};
var parentOrigin = "";
var parentHref = "";
var parentTitle = "";
function setOrigin(url) {
parentOrigin = url;
console.log('inside setOrigin, parent url is: ', parentOrigin);
getQueryStringsAndDDO();
}
;
function getQueryStringsAndDDO() {
window.parent.postMessage("GET_QS_DDO", parentOrigin);
}
;
function setParentInfo(data) {
var href = data.href, ddo = data.ddo, title = data.title;
parentHref = href;
parentDDO = ddo;
parentTitle = title;
// These need to be removed before Sept release
console.log('inside setParentDDO, ddo is: ', parentDDO);
console.log('inside setParentDDO, href is: ', parentHref);
}
function getParentInfo() {
return {
parentDDO: parentDDO,
parentHref: parentHref,
parentTitle: parentTitle,
};
}
/***/ }),
/***/ "./node_modules/whatwg-fetch/fetch.js":
/*!********************************************!*\
!*** ./node_modules/whatwg-fetch/fetch.js ***!
\********************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ DOMException: function() { return /* binding */ DOMException; },
/* harmony export */ Headers: function() { return /* binding */ Headers; },
/* harmony export */ Request: function() { return /* binding */ Request; },
/* harmony export */ Response: function() { return /* binding */ Response; },
/* harmony export */ fetch: function() { return /* binding */ fetch; }
/* harmony export */ });
/* eslint-disable no-prototype-builtins */
var g =
(typeof globalThis !== 'undefined' && globalThis) ||
(typeof self !== 'undefined' && self) ||
// eslint-disable-next-line no-undef
(typeof __webpack_require__.g !== 'undefined' && __webpack_require__.g) ||
{}
var support = {
searchParams: 'URLSearchParams' in g,
iterable: 'Symbol' in g && 'iterator' in Symbol,
blob:
'FileReader' in g &&
'Blob' in g &&
(function() {
try {
new Blob()
return true
} catch (e) {
return false
}
})(),
formData: 'FormData' in g,
arrayBuffer: 'ArrayBuffer' in g
}
function isDataView(obj) {
return obj && DataView.prototype.isPrototypeOf(obj)
}
if (support.arrayBuffer) {
var viewClasses = [
'[object Int8Array]',
'[object Uint8Array]',
'[object Uint8ClampedArray]',
'[object Int16Array]',
'[object Uint16Array]',
'[object Int32Array]',
'[object Uint32Array]',
'[object Float32Array]',
'[object Float64Array]'
]
var isArrayBufferView =
ArrayBuffer.isView ||
function(obj) {
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
}
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = String(name)
}
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
throw new TypeError('Invalid character in header field name: "' + name + '"')
}
return name.toLowerCase()
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = String(value)
}
return value
}
// Build a destructive iterator for the value list
function iteratorFor(items) {
var iterator = {
next: function() {
var value = items.shift()
return {done: value === undefined, value: value}
}
}
if (support.iterable) {
iterator[Symbol.iterator] = function() {
return iterator
}
}
return iterator
}
function Headers(headers) {
this.map = {}
if (headers instanceof Headers) {
headers.forEach(function(value, name) {
this.append(name, value)
}, this)
} else if (Array.isArray(headers)) {
headers.forEach(function(header) {
if (header.length != 2) {
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
}
this.append(header[0], header[1])
}, this)
} else if (headers) {
Object.getOwnPropertyNames(headers).forEach(function(name) {
this.append(name, headers[name])
}, this)
}
}
Headers.prototype.append = function(name, value) {
name = normalizeName(name)
value = normalizeValue(value)
var oldValue = this.map[name]
this.map[name] = oldValue ? oldValue + ', ' + value : value
}
Headers.prototype['delete'] = function(name) {
delete this.map[normalizeName(name)]
}
Headers.prototype.get = function(name) {
name = normalizeName(name)
return this.has(name) ? this.map[name] : null
}
Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(normalizeName(name))
}
Headers.prototype.set = function(name, value) {
this.map[normalizeName(name)] = normalizeValue(value)
}
Headers.prototype.forEach = function(callback, thisArg) {
for (var name in this.map) {
if (this.map.hasOwnProperty(name)) {
callback.call(thisArg, this.map[name], name, this)
}
}
}
Headers.prototype.keys = function() {
var items = []
this.forEach(function(value, name) {
items.push(name)
})
return iteratorFor(items)
}
Headers.prototype.values = function() {
var items = []
this.forEach(function(value) {
items.push(value)
})
return iteratorFor(items)
}
Headers.prototype.entries = function() {
var items = []
this.forEach(function(value, name) {
items.push([name, value])
})
return iteratorFor(items)
}
if (support.iterable) {
Headers.prototype[Symbol.iterator] = Headers.prototype.entries
}
function consumed(body) {
if (body._noBody) return
if (body.bodyUsed) {
return Promise.reject(new TypeError('Already read'))
}
body.bodyUsed = true
}
function fileReaderReady(reader) {
return new Promise(function(resolve, reject) {
reader.onload = function() {
resolve(reader.result)
}
reader.onerror = function() {
reject(reader.error)
}
})
}
function readBlobAsArrayBuffer(blob) {
var reader = new FileReader()
var promise = fileReaderReady(reader)
reader.readAsArrayBuffer(blob)
return promise
}
function readBlobAsText(blob) {
var reader = new FileReader()
var promise = fileReaderReady(reader)
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type)
var encoding = match ? match[1] : 'utf-8'
reader.readAsText(blob, encoding)
return promise
}
function readArrayBufferAsText(buf) {
var view = new Uint8Array(buf)
var chars = new Array(view.length)
for (var i = 0; i < view.length; i++) {
chars[i] = String.fromCharCode(view[i])
}
return chars.join('')
}
function bufferClone(buf) {
if (buf.slice) {
return buf.slice(0)
} else {
var view = new Uint8Array(buf.byteLength)
view.set(new Uint8Array(buf))
return view.buffer
}
}
function Body() {
this.bodyUsed = false
this._initBody = function(body) {
/*
fetch-mock wraps the Response object in an ES6 Proxy to
provide useful test harness features such as flush. However, on
ES5 browsers without fetch or Proxy support pollyfills must be used;
the proxy-pollyfill is unable to proxy an attribute unless it exists
on the object before the Proxy is created. This change ensures
Response.bodyUsed exists on the instance, while maintaining the
semantic of setting Request.bodyUsed in the constructor before
_initBody is called.
*/
// eslint-disable-next-line no-self-assign
this.bodyUsed = this.bodyUsed
this._bodyInit = body
if (!body) {
this._noBody = true;
this._bodyText = ''
} else if (typeof body === 'string') {
this._bodyText = body
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this._bodyText = body.toString()
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
this._bodyArrayBuffer = bufferClone(body.buffer)
// IE 10-11 can't handle a DataView body.
this._bodyInit = new Blob([this._bodyArrayBuffer])
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
this._bodyArrayBuffer = bufferClone(body)
} else {
this._bodyText = body = Object.prototype.toString.call(body)
}
if (!this.headers.get('content-type')) {
if (typeof body === 'string') {
this.headers.set('content-type', 'text/plain;charset=UTF-8')
} else if (this._bodyBlob && this._bodyBlob.type) {
this.headers.set('content-type', this._bodyBlob.type)
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8')
}
}
}
if (support.blob) {
this.blob = function() {
var rejected = consumed(this)
if (rejected) {
return rejected
}
if (this._bodyBlob) {
return Promise.resolve(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as blob')
} else {
return Promise.resolve(new Blob([this._bodyText]))
}
}
}
this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
var isConsumed = consumed(this)
if (isConsumed) {
return isConsumed
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
return Promise.resolve(
this._bodyArrayBuffer.buffer.slice(
this._bodyArrayBuffer.byteOffset,
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
)
)
} else {
return Promise.resolve(this._bodyArrayBuffer)
}
} else if (support.blob) {
return this.blob().then(readBlobAsArrayBuffer)
} else {
throw new Error('could not read as ArrayBuffer')
}
}
this.text = function() {
var rejected = consumed(this)
if (rejected) {
return rejected
}
if (this._bodyBlob) {
return readBlobAsText(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as text')
} else {
return Promise.resolve(this._bodyText)
}
}
if (support.formData) {
this.formData = function() {
return this.text().then(decode)
}
}
this.json = function() {
return this.text().then(JSON.parse)
}
return this
}
// HTTP methods whose capitalization should be normalized
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE']
function normalizeMethod(method) {
var upcased = method.toUpperCase()
return methods.indexOf(upcased) > -1 ? upcased : method
}
function Request(input, options) {
if (!(this instanceof Request)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
}
options = options || {}
var body = options.body
if (input instanceof Request) {
if (input.bodyUsed) {
throw new TypeError('Already read')
}
this.url = input.url
this.credentials = input.credentials
if (!options.headers) {
this.headers = new Headers(input.headers)
}
this.method = input.method
this.mode = input.mode
this.signal = input.signal
if (!body && input._bodyInit != null) {
body = input._bodyInit
input.bodyUsed = true
}
} else {
this.url = String(input)
}
this.credentials = options.credentials || this.credentials || 'same-origin'
if (options.headers || !this.headers) {
this.headers = new Headers(options.headers)
}
this.method = normalizeMethod(options.method || this.method || 'GET')
this.mode = options.mode || this.mode || null
this.signal = options.signal || this.signal || (function () {
if ('AbortController' in g) {
var ctrl = new AbortController();
return ctrl.signal;
}
}());
this.referrer = null
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('Body not allowed for GET or HEAD requests')
}
this._initBody(body)
if (this.method === 'GET' || this.method === 'HEAD') {
if (options.cache === 'no-store' || options.cache === 'no-cache') {
// Search for a '_' parameter in the query string
var reParamSearch = /([?&])_=[^&]*/
if (reParamSearch.test(this.url)) {
// If it already exists then set the value with the current time
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime())
} else {
// Otherwise add a new '_' parameter to the end with the current time
var reQueryString = /\?/
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime()
}
}
}
}
Request.prototype.clone = function() {
return new Request(this, {body: this._bodyInit})
}
function decode(body) {
var form = new FormData()
body
.trim()
.split('&')
.forEach(function(bytes) {
if (bytes) {
var split = bytes.split('=')
var name = split.shift().replace(/\+/g, ' ')
var value = split.join('=').replace(/\+/g, ' ')
form.append(decodeURIComponent(name), decodeURIComponent(value))
}
})
return form
}
function parseHeaders(rawHeaders) {
var headers = new Headers()
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
// https://tools.ietf.org/html/rfc7230#section-3.2
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ')
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
// https://github.com/github/fetch/issues/748
// https://github.com/zloirock/core-js/issues/751
preProcessedHeaders
.split('\r')
.map(function(header) {
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
})
.forEach(function(line) {
var parts = line.split(':')
var key = parts.shift().trim()
if (key) {
var value = parts.join(':').trim()
try {
headers.append(key, value)
} catch (error) {
console.warn('Response ' + error.message)
}
}
})
return headers
}
Body.call(Request.prototype)
function Response(bodyInit, options) {
if (!(this instanceof Response)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
}
if (!options) {
options = {}
}
this.type = 'default'
this.status = options.status === undefined ? 200 : options.status
if (this.status < 200 || this.status > 599) {
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
}
this.ok = this.status >= 200 && this.status < 300
this.statusText = options.statusText === undefined ? '' : '' + options.statusText
this.headers = new Headers(options.headers)
this.url = options.url || ''
this._initBody(bodyInit)
}
Body.call(Response.prototype)
Response.prototype.clone = function() {
return new Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
headers: new Headers(this.headers),
url: this.url
})
}
Response.error = function() {
var response = new Response(null, {status: 200, statusText: ''})
response.ok = false
response.status = 0
response.type = 'error'
return response
}
var redirectStatuses = [301, 302, 303, 307, 308]
Response.redirect = function(url, status) {
if (redirectStatuses.indexOf(status) === -1) {
throw new RangeError('Invalid status code')
}
return new Response(null, {status: status, headers: {location: url}})
}
var DOMException = g.DOMException
try {
new DOMException()
} catch (err) {
DOMException = function(message, name) {
this.message = message
this.name = name
var error = Error(message)
this.stack = error.stack
}
DOMException.prototype = Object.create(Error.prototype)
DOMException.prototype.constructor = DOMException
}
function fetch(input, init) {
return new Promise(function(resolve, reject) {
var request = new Request(input, init)
if (request.signal && request.signal.aborted) {
return reject(new DOMException('Aborted', 'AbortError'))
}
var xhr = new XMLHttpRequest()
function abortXhr() {
xhr.abort()
}
xhr.onload = function() {
var options = {
statusText: xhr.statusText,
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
}
// This check if specifically for when a user fetches a file locally from the file system
// Only if the status is out of a normal range
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
options.status = 200;
} else {
options.status = xhr.status;
}
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL')
var body = 'response' in xhr ? xhr.response : xhr.responseText
setTimeout(function() {
resolve(new Response(body, options))
}, 0)
}
xhr.onerror = function() {
setTimeout(function() {
reject(new TypeError('Network request failed'))
}, 0)
}
xhr.ontimeout = function() {
setTimeout(function() {
reject(new TypeError('Network request timed out'))
}, 0)
}
xhr.onabort = function() {
setTimeout(function() {
reject(new DOMException('Aborted', 'AbortError'))
}, 0)
}
function fixUrl(url) {
try {
return url === '' && g.location.href ? g.location.href : url
} catch (e) {
return url
}
}
xhr.open(request.method, fixUrl(request.url), true)
if (request.credentials === 'include') {
xhr.withCredentials = true
} else if (request.credentials === 'omit') {
xhr.withCredentials = false
}
if ('responseType' in xhr) {
if (support.blob) {
xhr.responseType = 'blob'
} else if (
support.arrayBuffer
) {
xhr.responseType = 'arraybuffer'
}
}
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
var names = [];
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
names.push(normalizeName(name))
xhr.setRequestHeader(name, normalizeValue(init.headers[name]))
})
request.headers.forEach(function(value, name) {
if (names.indexOf(name) === -1) {
xhr.setRequestHeader(name, value)
}
})
} else {
request.headers.forEach(function(value, name) {
xhr.setRequestHeader(name, value)
})
}
if (request.signal) {
request.signal.addEventListener('abort', abortXhr)
xhr.onreadystatechange = function() {
// DONE (success or failure)
if (xhr.readyState === 4) {
request.signal.removeEventListener('abort', abortXhr)
}
}
}
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit)
})
}
fetch.polyfill = true
if (!g.fetch) {
g.fetch = fetch
g.Headers = Headers
g.Request = Request
g.Response = Response
}
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ !function() {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function() { return module['default']; } :
/******/ function() { return module; };
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ !function() {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = function(exports, definition) {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/global */
/******/ !function() {
/******/ __webpack_require__.g = (function() {
/******/ if (typeof globalThis === 'object') return globalThis;
/******/ try {
/******/ return this || new Function('return this')();
/******/ } catch (e) {
/******/ if (typeof window === 'object') return window;
/******/ }
/******/ })();
/******/ }();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ !function() {
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ }();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
!function() {
"use strict";
/*!***************************!*\
!*** ./src/site/index.ts ***!
\***************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var whatwg_fetch__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! whatwg-fetch */ "./node_modules/whatwg-fetch/fetch.js");
/* harmony import */ var _messaging_post_messages__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./messaging/post-messages */ "./src/site/messaging/post-messages.ts");
/* harmony import */ var _site_pub_sub_add_pub_sub__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./site-pub-sub/add-pub-sub */ "./src/site/site-pub-sub/add-pub-sub.ts");
/* harmony import */ var _site_pub_sub_subscriptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./site-pub-sub/subscriptions */ "./src/site/site-pub-sub/subscriptions.ts");
/* harmony import */ var _site_pub_sub_events__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./site-pub-sub/events */ "./src/site/site-pub-sub/events.ts");
/* harmony import */ var _messaging_meta__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./messaging/meta */ "./src/site/messaging/meta.ts");
/* harmony import */ var _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./site-pub-sub/site-globals */ "./src/site/site-pub-sub/site-globals.ts");
/* harmony import */ var _site_utilities_utilities__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./site-utilities/utilities */ "./src/site/site-utilities/utilities.ts");
/**
* @file Bactm.genesys
*/
var initChat = function () {
(0,_site_pub_sub_add_pub_sub__WEBPACK_IMPORTED_MODULE_2__["default"])();
(0,_messaging_post_messages__WEBPACK_IMPORTED_MODULE_1__["default"])();
(0,_site_pub_sub_events__WEBPACK_IMPORTED_MODULE_4__["default"])();
(0,_site_pub_sub_subscriptions__WEBPACK_IMPORTED_MODULE_3__["default"])();
(0,_messaging_meta__WEBPACK_IMPORTED_MODULE_5__["default"])();
bactm.on("afterPageview", function (data) {
window.sparta.chat.widgetLoader.pub(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_6__.COMETD_REQUEST_CHAT, data);
});
TealiumPubSub.publish(_site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_6__.GENESYS_VALIDATE_IP_ADDRESS, { ogwUrl: _site_pub_sub_site_globals__WEBPACK_IMPORTED_MODULE_6__.OGW_URL });
window.sparta.chat.widgetLoader.pub("chat.utagLoaded", {});
window.sparta.chat.utagLoaded = true;
};
var setHBSParams = function () {
var hbsToken = decodeURIComponent((0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_7__.queryStringParse)("token"));
bactm.ddo.set("page.attributes.chat.DATA", hbsToken);
bactm.ddo.set("page.attributes.chat.customer_lob", "HBS");
bactm.ddo.set("user.authenticated", true);
};
if (window.location.href.indexOf("/chat/") > -1) {
if (window.sparta && window.sparta.chat && window.sparta.chat.widgetLoader) {
if (bactm && bactm.ddo && (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_7__.queryStringParse)("token")) {
setHBSParams();
}
initChat();
}
else {
if (bactm && bactm.ddo && (0,_site_utilities_utilities__WEBPACK_IMPORTED_MODULE_7__.queryStringParse)("token")) {
setHBSParams();
}
document.addEventListener("chat.spartaLoaderLoaded", initChat);
}
}
}();
/******/ })()
;
} } catch(e){ utag.DB(e) } }];
u.send = function(a, b) {
if (u.ev[a] || u.ev.all !== undefined) {
//##UTENABLEDEBUG##utag.DB("send:##UTID##");
var c, d, e, f, i;
u.data = {
/* Initialize default tag parameter values here */
/* Examples: */
/* "account_id" : "1234567" */
/* "base_url" : "//insert.your.javascript.library.url.here.js" */
/* A value mapped to "account_id" or "base_url" in TiQ will replace these default values. */
};
/* Start Tag-Scoped Extensions Code */
/* Please Do Not Edit This Section */
for(c=0;c