UNPKG

amazon-connect-streams

Version:
1 lines 728 kB
(()=>{var e={19(e,t){"use strict";function n(e,t,n){if(!n)return fetch(e,t);const i=o(e,n),a=r(t,n);return fetch(i,a)}function r(e,t){return(null==t?void 0:t.headers)?e?Object.assign(Object.assign({},e),{headers:Object.assign(Object.assign({},e.headers||{}),t.headers)}):{headers:t.headers}:e}function o(e,t){if(!(null==t?void 0:t.escapedQueryString))return e;const n=-1!==e.lastIndexOf("?");return`${e}${n?"&":"?"}${t.escapedQueryString}`}Object.defineProperty(t,"__esModule",{value:!0}),t.isValidRevisionID=t.isValidAssetGroup=t.resolveURL=t.addQueryParams=t.withQueryString=t.withRequestHeaders=t.fetchWithBehavior=void 0,t.fetchWithBehavior=n,t.withRequestHeaders=r,t.withQueryString=o,t.addQueryParams=function(e,t){const n=Object.keys(t);if(!n.length)return e;const r=new URLSearchParams(null==e?void 0:e.escapedQueryString);for(const e of n)r.append(e,t[e]);return Object.assign(Object.assign({},e),{escapedQueryString:r.toString()})};const i={method:"HEAD",mode:"cors",credentials:"omit",redirect:"follow",referrerPolicy:"origin"};t.resolveURL=function(e,t){return n(e,i,t).then(t=>t.redirected?t.url:e)},t.isValidAssetGroup=function(e){return!!e&&/^[-.a-zA-Z0-9]+$/.test(e)},t.isValidRevisionID=function(e){return!!e&&/^[123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]{22}$/.test(e)}},60(){function e(){var n,r,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.toStringTag||"@@toStringTag";function s(e,o,i,a){var s=o&&o.prototype instanceof u?o:u,l=Object.create(s.prototype);return t(l,"_invoke",function(e,t,o){var i,a,s,u=0,l=o||[],d=!1,p={p:0,n:0,v:n,a:h,f:h.bind(n,4),d:function(e,t){return i=e,a=0,s=n,p.n=t,c}};function h(e,t){for(a=e,s=t,r=0;!d&&u&&!o&&r<l.length;r++){var o,i=l[r],h=p.p,f=i[2];e>3?(o=f===t)&&(s=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=n):i[0]<=h&&((o=e<2&&h<i[1])?(a=0,p.v=t,p.n=i[1]):h<f&&(o=e<3||i[0]>t||t>f)&&(i[4]=e,i[5]=t,p.n=f,a=0))}if(o||e>1)return c;throw d=!0,t}return function(o,l,f){if(u>1)throw TypeError("Generator is already running");for(d&&1===l&&h(l,f),a=l,s=f;(r=a<2?n:s)||!d;){i||(a?a<3?(a>1&&(p.n=-1),h(a,s)):p.n=s:p.v=s);try{if(u=2,i){if(a||(o="next"),r=i[o]){if(!(r=r.call(i,s)))throw TypeError("iterator result is not an object");if(!r.done)return r;s=r.value,a<2&&(a=0)}else 1===a&&(r=i.return)&&r.call(i),a<2&&(s=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=n}else if((r=(d=p.n<0)?s:e.call(t,p))!==c)break}catch(e){i=n,a=1,s=e}finally{u=1}}return{value:r,done:d}}}(e,i,a),!0),l}var c={};function u(){}function l(){}function d(){}r=Object.getPrototypeOf;var p=[][i]?r(r([][i]())):(t(r={},i,function(){return this}),r),h=d.prototype=u.prototype=Object.create(p);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,t(e,a,"GeneratorFunction")),e.prototype=Object.create(h),e}return l.prototype=d,t(h,"constructor",d),t(d,"constructor",l),l.displayName="GeneratorFunction",t(d,a,"GeneratorFunction"),t(h),t(h,a,"Generator"),t(h,i,function(){return this}),t(h,"toString",function(){return"[object Generator]"}),(e=function(){return{w:s,m:f}})()}function t(e,n,r,o){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}t=function(e,n,r,o){function a(n,r){t(e,n,function(e){return this._invoke(n,r,e)})}n?i?i(e,n,{value:r,enumerable:!o,configurable:!o,writable:!o}):e[n]=r:(a("next",0),a("throw",1),a("return",2))},t(e,n,r,o)}function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=a(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,o)}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}!function(){var t=this||globalThis,n=t.connect||{};t.connect=n,t.lily=n;var o=navigator.userAgent,s=["bubbles","cancelBubble","cancelable","composed","data","defaultPrevented","eventPhase","isTrusted","lastEventId","origin","returnValue","timeStamp","type"];n.sprintf=t.sprintf,n.vsprintf=t.vsprintf,delete t.sprintf,delete t.vsprintf,n.HTTP_STATUS_CODES={SUCCESS:200,UNAUTHORIZED:401,ACCESS_DENIED:403,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500},n.TRANSPORT_TYPES={CHAT_TOKEN:"chat_token",WEB_SOCKET:"web_socket",AGENT_DISCOVERY:"agent_discovery",WEB_RTC:"web_rtc"},n.hitch=function(){var e=Array.prototype.slice.call(arguments),t=e.shift(),r=e.shift();return n.assertNotNull(t,"scope"),n.assertNotNull(r,"method"),n.assertTrue(n.isFunction(r),"method must be a function"),function(){var n=Array.prototype.slice.call(arguments);return r.apply(t,e.concat(n))}},n.isFunction=function(e){return!!(e&&e.constructor&&e.call&&e.apply)},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},n.keys=function(e){var t=[];for(var r in n.assertNotNull(e,"map"),e)t.push(r);return t},n.values=function(e){var t=[];for(var r in n.assertNotNull(e,"map"),e)t.push(e[r]);return t},n.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},n.merge=function(){var e=Array.prototype.slice.call(arguments,0),t={};return e.forEach(function(e){n.entries(e).forEach(function(e){t[e.key]=e.value})}),t},n.now=function(){return(new Date).getTime()},n.find=function(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n];return null},n.contains=function(e,t){return e instanceof Array?null!=n.find(e,function(e){return e===t}):t in e},n.containsValue=function(e,t){return e instanceof Array?null!=n.find(e,function(e){return e===t}):null!=n.find(n.values(e),function(e){return e===t})},n.randomId=function(){return n.sprintf("%s-%s",n.now(),Math.random().toString(36).slice(2))},n.makeEnum=function(e){var t={};return e.forEach(function(e){var n=e.replace(/\.?([a-z]+)_?/g,function(e,t){return t.toUpperCase()+"_"}).replace(/_$/,"");t[n]=e}),t},n.makeNamespacedEnum=function(e,t){var r=n.makeEnum(t);return n.keys(r).forEach(function(t){r[t]=n.sprintf("%s::%s",e,r[t])}),r},n.makeGenericNamespacedEnum=function(e,t,r){var o=n.makeEnum(t);return n.keys(o).forEach(function(t){o[t]=n.sprintf("%s"+r+"%s",e,o[t])}),o},n.isChromeBrowser=function(){return-1!==o.indexOf("Chrome")},n.isFirefoxBrowser=function(){return-1!==o.indexOf("Firefox")},n.isOperaBrowser=function(){return-1!==o.indexOf("Opera")},n.isEdgeBrowser=function(){return-1!==o.indexOf("Edg")},n.getChromeBrowserVersion=function(){var e=o.substring(o.indexOf("Chrome")+7);return e?parseFloat(e):-1},n.getFirefoxBrowserVersion=function(){var e=o.substring(o.indexOf("Firefox")+8);return e?parseFloat(e):-1},n.isValidLocale=function(e){return[{id:"en_US",label:"English"},{id:"de_DE",label:"Deutsch"},{id:"es_ES",label:"Español"},{id:"fr_FR",label:"Français"},{id:"ja_JP",label:"日本語"},{id:"it_IT",label:"Italiano"},{id:"ko_KR",label:"한국어"},{id:"pt_BR",label:"Português"},{id:"zh_CN",label:"中文(简体)"},{id:"zh_TW",label:"中文(繁體)"}].map(function(e){return e.id}).includes(e)},n.getOperaBrowserVersion=function(){var e=o.indexOf("Opera"),t=-1!==o.indexOf("Version")?o.substring(e+8):o.substring(e+6);return t?parseFloat(t):-1},n.index=function(e,t){var n={};return e.forEach(function(e){n[t(e)]=e}),n},n.set=function(e){var t={};return e.forEach(function(e){t[e]=1}),t},n.relativeComplement=function(e,t){var r={};return n.keys(t).forEach(function(n){n in e||(r[n]=t[n])}),r},n.assertTrue=function(e,t){if(!e)throw new n.ValueError(t)},n.assertNotNull=function(e,t){return n.assertTrue(null!=e&&void 0!==a(e),n.sprintf("%s must be provided",t||"A value")),e},n.deepcopy=function(e){return JSON.parse(JSON.stringify(e))},n.deepcopyCrossOriginEvent=function(e){var t={};return s.forEach(function(r){try{t[r]=e[r]}catch(e){n.getLog().info("deepcopyCrossOriginEvent failed on key: ",r).sendInternalLogToServer()}}),n.deepcopy(t)},n.getBaseUrl=function(){var e=t.location;return n.sprintf("%s//%s:%s",e.protocol,e.hostname,e.port)},n.getUrlWithProtocol=function(e){var r=t.location.protocol;return e.substr(0,r.length)!==r?n.sprintf("%s//%s",r,e):e},n.isFramed=function(){try{return window.self!==window.top}catch(e){return!0}},n.hasOtherConnectedCCPs=function(){return n.numberOfConnectedCCPs>1},n.fetch=function(e,t,r,o){return o=o||5,r=r||1e3,t=t||{},new Promise(function(i,a){!function o(s){fetch(e,t).then(function(e){e.status===n.HTTP_STATUS_CODES.SUCCESS?e.json().then(function(e){return i(e)}).catch(function(){return i({})}):1!==s&&(e.status>=n.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===n.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout(function(){o(--s)},r):a(e)}).catch(function(e){a(e)})}(o)})},n.fetchWithTimeout=function(){var t,o=(t=e().m(function t(o,i,a,s,c){var u,l,d;return e().w(function(e){for(;;)switch(e.n){case 0:if(a=a||{},i){e.n=1;break}return e.a(2,n.fetch(o,a,s,c));case 1:return u=new AbortController,l=setTimeout(function(){return u.abort()},i),e.n=2,n.fetch(o,r(r({},a),{},{signal:u.signal}),s,c);case 2:return d=e.v,clearTimeout(l),e.a(2,d)}},t)}),function(){var e=this,n=arguments;return new Promise(function(r,o){var a=t.apply(e,n);function s(e){i(a,r,o,s,c,"next",e)}function c(e){i(a,r,o,s,c,"throw",e)}s(void 0)})});return function(e,t,n,r,i){return o.apply(this,arguments)}}(),n.backoff=function(e,r,o,i){n.assertTrue(n.isFunction(e),"func must be a Function");var a=this;e({success:function(e){i&&i.success&&i.success(e)},failure:function(n,s){if(o>0){var c=2*r*Math.random();t.setTimeout(function(){a.backoff(e,2*c,--o,i)},c)}else i&&i.failure&&i.failure(n,s)}})},n.publishMetric=function(e){n.core.getUpstream().sendUpstream(n.EventType.BROADCAST,{event:n.EventType.CLIENT_METRIC,data:e})},n.publishSoftphoneStats=function(e){n.core.getUpstream().sendUpstream(n.EventType.BROADCAST,{event:n.EventType.SOFTPHONE_STATS,data:e})},n.publishSoftphoneReport=function(e){n.core.getUpstream().sendUpstream(n.EventType.BROADCAST,{event:n.EventType.SOFTPHONE_REPORT,data:e})},n.publishClickStreamData=function(e){n.core.getUpstream().sendUpstream(n.EventType.BROADCAST,{event:n.EventType.CLICK_STREAM_DATA,data:e})},n.publishClientSideLogs=function(e){n.core.getEventBus().trigger(n.EventType.CLIENT_SIDE_LOGS,e)},n.addNamespaceToLogs=function(e){["log","error","warn","info","debug"].forEach(function(t){var n=window.console[t];window.console[t]=function(){var t=Array.from(arguments);t.unshift("[".concat(e,"]")),n.apply(window.console,t)}})},n.PopupManager=function(){this.windows={},this.windowUrls={}},n.PopupManager.prototype.open=function(e,t,r){var o="";if(r){var i=r.height||578;o="width="+(r.width||433)+", height="+i+", top="+(r.top||0)+", left="+(r.left||0)}var a=this.windows[t],s=this.windowUrls[t];if(a)try{if(a.closed)delete this.windows[t],delete this.windowUrls[t];else if(s===e){try{a.focus()}catch(e){}return n.getLog().info("[PopupManager] Reusing existing popup window").sendInternalLogToServer(),a}}catch(e){delete this.windows[t],delete this.windowUrls[t]}var c=window.open(e,t,o);if(c)try{c.closed||(this.windows[t]=c,this.windowUrls[t]=e,n.getLog().info("[PopupManager] Opened popup window").withObject({url:e,name:t}).sendInternalLogToServer())}catch(e){}return c},n.PopupManager.prototype.clear=function(e){delete this.windows[e],delete this.windowUrls[e];var n=this._getLocalStorageKey(e);t.localStorage.removeItem(n)},n.PopupManager.prototype._getLastOpenedTimestamp=function(e){var n=this._getLocalStorageKey(e),r=t.localStorage.getItem(n);return r?parseInt(r,10):0},n.PopupManager.prototype._setLastOpenedTimestamp=function(e,n){var r=this._getLocalStorageKey(e);t.localStorage.setItem(r,""+n)},n.PopupManager.prototype._getLocalStorageKey=function(e){return"connectPopupManager::"+e};var c=n.makeEnum(["granted","denied","default"]);n.NotificationManager=function(){this.queue=[],this.permission=c.DEFAULT},n.NotificationManager.prototype.requestPermission=function(){var e=this;"Notification"in t?t.Notification.permission===c.DENIED?(n.getLog().warn("The user has requested to not receive notifications.").sendInternalLogToServer(),this.permission=c.DENIED):this.permission!==c.GRANTED&&t.Notification.requestPermission().then(function(t){e.permission=t,t===c.GRANTED?e._showQueued():e.queue=[]}):(n.getLog().warn("This browser doesn't support notifications.").sendInternalLogToServer(),this.permission=c.DENIED)},n.NotificationManager.prototype.show=function(e,t){if(this.permission===c.GRANTED)return this._showImpl({title:e,options:t});if(this.permission===c.DENIED)n.getLog().warn("Unable to show notification.").sendInternalLogToServer().withObject({title:e,options:t});else{var r={title:e,options:t};n.getLog().warn("Deferring notification until user decides to allow or deny.").withObject(r).sendInternalLogToServer(),this.queue.push(r)}},n.NotificationManager.prototype._showQueued=function(){var e=this,t=this.queue.map(function(t){return e._showImpl(t)});return this.queue=[],t},n.NotificationManager.prototype._showImpl=function(e){var n=new t.Notification(e.title,e.options);return e.options.clicked&&(n.onclick=function(){e.options.clicked.call(n)}),n},n.ValueError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift(),r=new Error(n.vsprintf(t,e));return Object.setPrototypeOf(r,n.ValueError.prototype),r},Object.setPrototypeOf(n.ValueError.prototype,Error.prototype),Object.setPrototypeOf(n.ValueError,Error),n.ValueError.prototype.name="ValueError",n.NotImplementedError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift(),r=new Error(n.vsprintf(t,e));return Object.setPrototypeOf(r,n.NotImplementedError.prototype),r},Object.setPrototypeOf(n.NotImplementedError.prototype,Error.prototype),Object.setPrototypeOf(n.NotImplementedError,Error),n.NotImplementedError.prototype.name="NotImplementedError",n.StateError=function(){var e=Array.prototype.slice.call(arguments,0),t=e.shift(),r=new Error(n.vsprintf(t,e));return Object.setPrototypeOf(r,n.StateError.prototype),r},Object.setPrototypeOf(n.StateError.prototype,Error.prototype),Object.setPrototypeOf(n.StateError,Error),n.StateError.prototype.name="StateError",n.VoiceIdError=function(e,t,n){var r={};return r.type=e,r.message=t,r.stack=Error(t).stack,r.err=n,r},n.isCCP=function(){return!!n.core.upstream&&"ConnectSharedWorkerConduit"===n.core.getUpstream().name},n.isSharedWorker=function(){return n.worker&&!!n.worker.clientEngine},n.isCRM=function(){return!!n.core.upstream&&(n.core.getUpstream()instanceof n.IFrameConduit||n.core.getUpstream()instanceof n.GRProxyIframeConduit)},n.isActiveConduit=function(e){var t=n.core.getUpstream();return t instanceof n.GRProxyIframeConduit?e.name===t.activeRegionUrl:(n.getLog().debug("connect.isActiveConduit is called but there is no GR proxy conduit").sendInternalLogToServer(),!0)}}()},95(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}!function(t){var n={};function r(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=n,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,n){if(1&n&&(t=r(t)),8&n)return t;if(4&n&&"object"==e(t)&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)r.d(o,i,function(e){return t[e]}.bind(null,i));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(t,n,r){"use strict";var o=r(1),i="DEBUG",a="AMZ_WEB_SOCKET_MANAGER:",s="Network offline",c="Network online, connecting to WebSocket server",u="Network offline, ignoring this getWebSocketConnConfig request",l="Heartbeat response not received",d="Failed to send heartbeat since WebSocket is not open",p="WebSocket connection established!",h="WebSocket connection is closed",f="WebSocketManager Error, error_event: ",g="Scheduling WebSocket reinitialization, after delay ",m="WebSocket URL cannot be used to establish connection",v="WebSocket Initialization failed - Terminating and cleaning subscriptions",y="Fetching new WebSocket connection configuration",b="Successfully fetched webSocket connection configuration",S="Failed to fetch webSocket connection configuration",C="Retrying fetching new WebSocket connection configuration",E="Initializing Websocket Manager",I="WebSocketManager Message Error",T="Message received for topic ",w="Invalid incoming message",A="aws/subscribe",_="aws/heartbeat",R="disconnected";function O(t){return(O="function"==typeof Symbol&&"symbol"==e(Symbol.iterator)?function(t){return e(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)})(t)}var k={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return k.assertTrue(null!==e&&void 0!==O(e),Object(o.sprintf)("%s must be provided",t||"A value")),e},isNonEmptyString:function(e){return"string"==typeof e&&e.length>0},assertIsList:function(e,t){if(!Array.isArray(e))throw new Error(t+" is not an array")},isFunction:function(e){return!!(e&&e.constructor&&e.call&&e.apply)},isObject:function(e){return!("object"!==O(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},L=new RegExp("^(wss://)\\w*");k.validWSUrl=function(e){return L.test(e)},k.getSubscriptionResponse=function(e,t,n){return{topic:e,content:{status:t?"success":"failure",topics:n}}},k.assertIsObject=function(e,t){if(!k.isObject(e))throw new Error(t+" is not an object!")},k.addJitter=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;t=Math.min(t,1);var n=Math.random()>.5?1:-1;return Math.floor(e+n*e*Math.random()*t)},k.isNetworkOnline=function(){return navigator.onLine},k.isNetworkFailure=function(e){return!(!e._debug||!e._debug.type)&&"NetworkingError"===e._debug.type};var P=k;function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t){return(D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function x(t){return(x="function"==typeof Symbol&&"symbol"==e(Symbol.iterator)?function(t){return e(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":e(t)})(t)}function M(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function U(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function F(e,t,n){return t&&U(e.prototype,t),n&&U(e,n),e}var j=function(){function e(){M(this,e)}return F(e,[{key:"debug",value:function(e){}},{key:"info",value:function(e){}},{key:"warn",value:function(e){}},{key:"error",value:function(e){}},{key:"advancedLog",value:function(e){}}]),e}(),q=a,B={DEBUG:10,INFO:20,WARN:30,ERROR:40,ADVANCED_LOG:50},V=function(){function e(){M(this,e),this.updateLoggerConfig(),this.consoleLoggerWrapper=H()}return F(e,[{key:"writeToClientLogger",value:function(e,t){if(this.hasClientLogger())switch(e){case B.DEBUG:return this._clientLogger.debug(t)||t;case B.INFO:return this._clientLogger.info(t)||t;case B.WARN:return this._clientLogger.warn(t)||t;case B.ERROR:return this._clientLogger.error(t)||t;case B.ADVANCED_LOG:return this._advancedLogWriter?this._clientLogger[this._advancedLogWriter](t)||t:""}}},{key:"isLevelEnabled",value:function(e){return e>=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var t=e.prefix||q;return this._logsDestination===i?this.consoleLoggerWrapper:new W(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||B.INFO,this._advancedLogWriter="warn",t.advancedLogWriter&&(this._advancedLogWriter=t.advancedLogWriter),t.customizedLogger&&"object"===x(t.customizedLogger)&&(this.useClientLogger=!0),this._clientLogger=t.logger||this.selectLogger(t),this._logsDestination="NULL",t.debug&&(this._logsDestination=i),t.logger&&(this._logsDestination="CLIENT_LOGGER")}},{key:"selectLogger",value:function(e){return e.customizedLogger&&"object"===x(e.customizedLogger)?e.customizedLogger:e.useDefaultLogger?(this.consoleLoggerWrapper=H(),this.consoleLoggerWrapper):null}}]),e}(),G=function(){function e(){M(this,e)}return F(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}},{key:"advancedLog",value:function(){}}]),e}(),W=function(){function e(t){var n;return M(this,e),(n=function(e,t){return!t||"object"!==x(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}(this,N(e).call(this))).prefix=t||q,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&D(e,t)}(e,G),F(e,[{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(B.DEBUG,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(B.INFO,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(B.WARN,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(B.ERROR,t)}},{key:"advancedLog",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._log(B.ADVANCED_LOG,t)}},{key:"_shouldLog",value:function(e){return z.hasClientLogger()&&z.isLevelEnabled(e)}},{key:"_writeToClientLogger",value:function(e,t){return z.writeToClientLogger(e,t)}},{key:"_log",value:function(e,t){if(this._shouldLog(e)){var n=z.useClientLogger?t:this._convertToSingleStatement(t,e);return this._writeToClientLogger(e,n)}}},{key:"_convertToSingleStatement",value:function(e,t){var n=new Date(Date.now()).toISOString(),r=this._getLogLevelByValue(t),o="[".concat(n,"][").concat(r,"]");this.prefix&&(o+=this.prefix+" "),this.options&&(this.options.prefix?o+=" "+this.options.prefix+":":o+="",this.options.logMetaData?o+=" Meta data: "+JSON.stringify(this.options.logMetaData):o+="");for(var i=0;i<e.length;i++){var a=e[i];o+=this._convertToString(a)+" "}return o}},{key:"_getLogLevelByValue",value:function(e){switch(e){case 10:return"DEBUG";case 20:return"INFO";case 30:return"WARN";case 40:return"ERROR";case 50:return"ADVANCED_LOG"}}},{key:"_convertToString",value:function(e){try{if(!e)return"";if(P.isString(e))return e;if(P.isObject(e)&&P.isFunction(e.toString)){var t=e.toString();if("[object Object]"!==t)return t}return JSON.stringify(e)}catch(t){return console.error("Error while converting argument to string",e,t),""}}}]),e}(),H=function(){var e=new G;return e.debug=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.debug.apply(window.console,[].concat(t))},e.info=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.info.apply(window.console,[].concat(t))},e.warn=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.warn.apply(window.console,[].concat(t))},e.error=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return console.error.apply(window.console,[].concat(t))},e},z=new V;function K(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var Q=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.numAttempts=0,this.executor=t,this.hasActiveReconnection=!1,this.defaultRetry=n}var t,n;return t=e,(n=[{key:"retry",value:function(){var e=this;this.hasActiveReconnection||(this.hasActiveReconnection=!0,setTimeout(function(){e._execute()},this._getDelay()))}},{key:"_execute",value:function(){this.hasActiveReconnection=!1,this.executor(),this.numAttempts++}},{key:"connected",value:function(){this.numAttempts=0}},{key:"_getDelay",value:function(){var e=Math.pow(2,this.numAttempts)*this.defaultRetry;return e<=3e4?e:3e4}},{key:"getIsConnected",value:function(){return!this.numAttempts}}])&&K(t.prototype,n),e}();r.d(n,"a",function(){return X});var Y=function(){var e=z.getLogger({prefix:a}),t=P.isNetworkOnline(),n={primary:null,secondary:null},r={reconnectWebSocket:!0,websocketInitFailed:!1,exponentialBackOffTime:1e3,exponentialTimeoutHandle:null,lifeTimeTimeoutHandle:null,webSocketInitCheckerTimeoutId:null,connState:null},o={connectWebSocketRetryCount:0,connectionAttemptStartTime:null,noOpenConnectionsTimestamp:null},i={pendingResponse:!1,intervalHandle:null},O={initFailure:new Set,getWebSocketTransport:null,subscriptionUpdate:new Set,subscriptionFailure:new Set,topic:new Map,allMessage:new Set,connectionGain:new Set,connectionLost:new Set,connectionOpen:new Set,connectionClose:new Set},k={connConfig:null,promiseHandle:null,promiseCompleted:!0},L={subscribed:new Set,pending:new Set,subscriptionHistory:new Set},N={responseCheckIntervalId:null,requestCompleted:!0,reSubscribeIntervalId:null,consecutiveFailedSubscribeAttempts:0,consecutiveNoResponseRequest:0},D=new Q(function(){se()}),x=new Set([A,"aws/unsubscribe",_]),M=setInterval(function(){if(t!==P.isNetworkOnline()){if(!(t=P.isNetworkOnline()))return e.advancedLog(s),void le(e.info(s));var n=G();t&&(!n||q(n,WebSocket.CLOSING)||q(n,WebSocket.CLOSED))&&(e.advancedLog(c),le(e.info(c)),se())}},250),U=function(t,n){t.forEach(function(t){try{t(n)}catch(t){le(e.error("Error executing callback",t))}})},F=function(e){if(null===e)return"NULL";switch(e.readyState){case WebSocket.CONNECTING:return"CONNECTING";case WebSocket.OPEN:return"OPEN";case WebSocket.CLOSING:return"CLOSING";case WebSocket.CLOSED:return"CLOSED";default:return"UNDEFINED"}},j=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";le(e.debug("["+t+"] Primary WebSocket: "+F(n.primary)+" | Secondary WebSocket: "+F(n.secondary)))},q=function(e,t){return e&&e.readyState===t},B=function(e){return q(e,WebSocket.OPEN)},V=function(e){return null===e||void 0===e.readyState||q(e,WebSocket.CLOSED)},G=function(){return null!==n.secondary?n.secondary:n.primary},W=function(){return B(G())},H=function(){if(i.pendingResponse)return e.advancedLog(l),le(e.warn(l)),clearInterval(i.intervalHandle),i.pendingResponse=!1,void se();W()?(le(e.debug("Sending heartbeat")),G().send(ie(_)),i.pendingResponse=!0):(e.advancedLog(d),le(e.warn(d)),j("sendHeartBeat"),se())},K=function(){e.advancedLog("Reset Websocket state"),r.exponentialBackOffTime=1e3,i.pendingResponse=!1,r.reconnectWebSocket=!0,clearTimeout(r.lifeTimeTimeoutHandle),clearInterval(i.intervalHandle),clearTimeout(r.exponentialTimeoutHandle),clearTimeout(r.webSocketInitCheckerTimeoutId)},Y=function(){N.consecutiveFailedSubscribeAttempts=0,N.consecutiveNoResponseRequest=0,clearInterval(N.responseCheckIntervalId),clearInterval(N.reSubscribeIntervalId)},X=function(){o.connectWebSocketRetryCount=0,o.connectionAttemptStartTime=null,o.noOpenConnectionsTimestamp=null},J=function(){D.connected();try{e.advancedLog(p),le(e.info(p)),j("webSocketOnOpen"),null!==r.connState&&r.connState!==R||U(O.connectionGain),r.connState="connected";var t=Date.now();U(O.connectionOpen,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,noOpenConnectionsTimestamp:o.noOpenConnectionsTimestamp,connectionEstablishedTime:t,timeToConnect:t-o.connectionAttemptStartTime,timeWithoutConnection:o.noOpenConnectionsTimestamp?t-o.noOpenConnectionsTimestamp:null}),X(),K(),G().openTimestamp=Date.now(),0===L.subscribed.size&&B(n.secondary)&&te(n.primary,"[Primary WebSocket] Closing WebSocket"),(L.subscribed.size>0||L.pending.size>0)&&(B(n.secondary)&&le(e.info("Subscribing secondary websocket to topics of primary websocket")),L.subscribed.forEach(function(e){L.subscriptionHistory.add(e),L.pending.add(e)}),L.subscribed.clear(),ee()),H(),i.intervalHandle=setInterval(H,1e4);var a=1e3*k.connConfig.webSocketTransport.transportLifeTimeInSeconds;le(e.debug("Scheduling WebSocket manager reconnection, after delay "+a+" ms")),r.lifeTimeTimeoutHandle=setTimeout(function(){le(e.debug("Starting scheduled WebSocket manager reconnection")),se()},a)}catch(t){le(e.error("Error after establishing WebSocket connection",t))}},$=function(t){j("webSocketOnError"),e.advancedLog(f,JSON.stringify(t)),le(e.error(f,JSON.stringify(t))),D.getIsConnected()?se():D.retry()},Z=function(t){var r=JSON.parse(t.data);switch(r.topic){case A:if(le(e.debug("Subscription Message received from webSocket server",t.data)),N.requestCompleted=!0,N.consecutiveNoResponseRequest=0,"success"===r.content.status)N.consecutiveFailedSubscribeAttempts=0,r.content.topics.forEach(function(e){L.subscriptionHistory.delete(e),L.pending.delete(e),L.subscribed.add(e)}),0===L.subscriptionHistory.size?B(n.secondary)&&(le(e.info("Successfully subscribed secondary websocket to all topics of primary websocket")),te(n.primary,"[Primary WebSocket] Closing WebSocket")):ee(),U(O.subscriptionUpdate,r);else{if(clearInterval(N.reSubscribeIntervalId),++N.consecutiveFailedSubscribeAttempts,5===N.consecutiveFailedSubscribeAttempts)return U(O.subscriptionFailure,r),void(N.consecutiveFailedSubscribeAttempts=0);N.reSubscribeIntervalId=setInterval(function(){ee()},500)}break;case _:le(e.debug("Heartbeat response received")),i.pendingResponse=!1;break;default:if(r.topic){if(e.advancedLog(T,r.topic),le(e.debug(T+r.topic)),B(n.primary)&&B(n.secondary)&&0===L.subscriptionHistory.size&&this===n.primary)return void le(e.warn("Ignoring Message for Topic "+r.topic+", to avoid duplicates"));if(0===O.allMessage.size&&0===O.topic.size)return void le(e.warn("No registered callback listener for Topic",r.topic));e.advancedLog("WebsocketManager invoke callbacks for topic success ",r.topic),U(O.allMessage,r),O.topic.has(r.topic)&&U(O.topic.get(r.topic),r)}else r.message?(e.advancedLog(I,r),le(e.warn(I,r))):(e.advancedLog(w,r),le(e.warn(w,r)))}},ee=function t(){if(N.consecutiveNoResponseRequest>3)return le(e.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response")),void U(O.subscriptionFailure,P.getSubscriptionResponse(A,!1,Array.from(L.pending)));W()?0!==Array.from(L.pending).length&&(clearInterval(N.responseCheckIntervalId),G().send(ie(A,{topics:Array.from(L.pending)})),N.requestCompleted=!1,N.responseCheckIntervalId=setInterval(function(){N.requestCompleted||(++N.consecutiveNoResponseRequest,t())},1e3)):le(e.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open"))},te=function(t,n){q(t,WebSocket.CONNECTING)||q(t,WebSocket.OPEN)?t.close(1e3,n):le(e.warn("Ignoring WebSocket Close request, WebSocket State: "+F(t)))},ne=function(e){te(n.primary,"[Primary] WebSocket "+e),te(n.secondary,"[Secondary] WebSocket "+e)},re=function(){o.connectWebSocketRetryCount++;var t=P.addJitter(r.exponentialBackOffTime,.3);Date.now()+t<=k.connConfig.urlConnValidTime?(e.advancedLog(g),le(e.debug(g+t+" ms")),r.exponentialTimeoutHandle=setTimeout(function(){return ce()},t),r.exponentialBackOffTime*=2):(e.advancedLog(m),le(e.warn(m)),se())},oe=function(t){K(),Y(),e.advancedLog(v,t),le(e.error(v)),r.websocketInitFailed=!0,ne("Terminating WebSocket Manager"),clearInterval(M),U(O.initFailure,{connectWebSocketRetryCount:o.connectWebSocketRetryCount,connectionAttemptStartTime:o.connectionAttemptStartTime,reason:t}),X()},ie=function(e,t){return JSON.stringify({topic:e,content:t})},ae=function(t){return!!(P.isObject(t)&&P.isObject(t.webSocketTransport)&&P.isNonEmptyString(t.webSocketTransport.url)&&P.validWSUrl(t.webSocketTransport.url)&&1e3*t.webSocketTransport.transportLifeTimeInSeconds>=3e5)||(le(e.error("Invalid WebSocket Connection Configuration",t)),!1)},se=function(){if(!P.isNetworkOnline())return e.advancedLog(u),void le(e.info(u));if(r.websocketInitFailed)le(e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request"));else{if(k.promiseCompleted)return K(),e.advancedLog(y),le(e.info(y)),o.connectionAttemptStartTime=o.connectionAttemptStartTime||Date.now(),k.promiseCompleted=!1,k.promiseHandle=O.getWebSocketTransport(),k.promiseHandle.then(function(t){return k.promiseCompleted=!0,e.advancedLog(b),le(e.debug(b,t)),ae(t)?(k.connConfig=t,k.connConfig.urlConnValidTime=Date.now()+85e3,ce()):(oe("Invalid WebSocket connection configuration: "+t),{webSocketConnectionFailed:!0})},function(t){return k.promiseCompleted=!0,e.advancedLog(S),le(e.error(S,t)),P.isNetworkFailure(t)?(e.advancedLog(C+JSON.stringify(t)),le(e.info(C+JSON.stringify(t))),D.retry()):oe("Failed to fetch webSocket connection configuration: "+JSON.stringify(t)),{webSocketConnectionFailed:!0}});le(e.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored"))}},ce=function(){if(r.websocketInitFailed)return le(e.info("web-socket initializing had failed, aborting re-init")),{webSocketConnectionFailed:!0};if(!P.isNetworkOnline())return le(e.warn("System is offline aborting web-socket init")),{webSocketConnectionFailed:!0};e.advancedLog(E),le(e.info(E)),j("initWebSocket");try{if(ae(k.connConfig)){var t=null;return B(n.primary)?(le(e.debug("Primary Socket connection is already open")),q(n.secondary,WebSocket.CONNECTING)||(le(e.debug("Establishing a secondary web-socket connection")),D.numAttempts=0,n.secondary=ue()),t=n.secondary):(q(n.primary,WebSocket.CONNECTING)||(le(e.debug("Establishing a primary web-socket connection")),n.primary=ue()),t=n.primary),r.webSocketInitCheckerTimeoutId=setTimeout(function(){B(t)||re()},1e3),{webSocketConnectionFailed:!1}}}catch(t){return le(e.error("Error Initializing web-socket-manager",t)),oe("Failed to initialize new WebSocket: "+t.message),{webSocketConnectionFailed:!0}}},ue=function(){var t=new WebSocket(k.connConfig.webSocketTransport.url);return t.addEventListener("open",J),t.addEventListener("message",Z),t.addEventListener("error",$),t.addEventListener("close",function(i){return function(t,i){e.advancedLog(h,JSON.stringify(t)),le(e.info(h,JSON.stringify(t))),j("webSocketOnClose before-cleanup"),U(O.connectionClose,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),V(n.primary)&&(n.primary=null),V(n.secondary)&&(n.secondary=null),r.reconnectWebSocket&&(B(n.primary)||B(n.secondary)?V(n.primary)&&B(n.secondary)&&(le(e.info("[Primary] WebSocket Cleanly Closed")),n.primary=n.secondary,n.secondary=null):(le(e.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection")),r.connState===R?le(e.info("Ignoring connectionLost callback invocation")):(U(O.connectionLost,{openTimestamp:i.openTimestamp,closeTimestamp:Date.now(),connectionDuration:Date.now()-i.openTimestamp,code:t.code,reason:t.reason}),o.noOpenConnectionsTimestamp=Date.now()),r.connState=R,se()),j("webSocketOnClose after-cleanup"))}(i,t)}),t},le=function(e){return e&&"function"==typeof e.sendInternalLogToServer&&e.sendInternalLogToServer(),e};this.init=function(t){if(P.assertTrue(P.isFunction(t),"transportHandle must be a function"),null===O.getWebSocketTransport)return O.getWebSocketTransport=t,se();le(e.warn("Web Socket Manager was already initialized"))},this.onInitFailure=function(t){return e.advancedLog("Initializing Websocket Manager Failed!"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.initFailure.add(t),r.websocketInitFailed&&t(),function(){return O.initFailure.delete(t)}},this.onConnectionOpen=function(t){return e.advancedLog("Websocket connection open"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.connectionOpen.add(t),function(){return O.connectionOpen.delete(t)}},this.onConnectionClose=function(t){return e.advancedLog("Websocket connection close"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.connectionClose.add(t),function(){return O.connectionClose.delete(t)}},this.onConnectionGain=function(t){return e.advancedLog("Websocket connection gain"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.connectionGain.add(t),W()&&t(),function(){return O.connectionGain.delete(t)}},this.onConnectionLost=function(t){return e.advancedLog("Websocket connection lost"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.connectionLost.add(t),r.connState===R&&t(),function(){return O.connectionLost.delete(t)}},this.onSubscriptionUpdate=function(e){return P.assertTrue(P.isFunction(e),"cb must be a function"),O.subscriptionUpdate.add(e),function(){return O.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(t){return e.advancedLog("Websocket subscription failure"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.subscriptionFailure.add(t),function(){return O.subscriptionFailure.delete(t)}},this.onMessage=function(e,t){return P.assertNotNull(e,"topicName"),P.assertTrue(P.isFunction(t),"cb must be a function"),O.topic.has(e)?O.topic.get(e).add(t):O.topic.set(e,new Set([t])),function(){return O.topic.get(e).delete(t)}},this.onAllMessage=function(e){return P.assertTrue(P.isFunction(e),"cb must be a function"),O.allMessage.add(e),function(){return O.allMessage.delete(e)}},this.subscribeTopics=function(e){P.assertNotNull(e,"topics"),P.assertIsList(e),e.forEach(function(e){L.subscribed.has(e)||L.pending.add(e)}),N.consecutiveNoResponseRequest=0,ee()},this.sendMessage=function(t){if(P.assertIsObject(t,"payload"),void 0===t.topic||x.has(t.topic))le(e.warn("Cannot send message, Invalid topic",t));else{try{t=JSON.stringify(t)}catch(n){return void le(e.warn("Error stringify message",t))}W()?G().send(t):le(e.warn("Cannot send message, web socket connection is not open"))}},this.closeWebSocket=function(){K(),Y(),r.reconnectWebSocket=!1,clearInterval(M),ne("User request to close WebSocket")},this.terminateWebSocketManager=oe},X={create:function(){return new Y},setGlobalConfig:function(e){var t=e&&e.loggerConfig;z.updateLoggerConfig(t)},LogLevel:B,Logger:j}},function(t,n,r){var o;!function(){"use strict";var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function a(t){return function(t,n){var r,o,s,c,u,l,d,p,h,f=1,g=t.length,m="";for(o=0;o<g;o++)if("string"==typeof t[o])m+=t[o];else if("object"==e(t[o])){if((c=t[o]).keys)for(r=n[f],s=0;s<c.keys.length;s++){if(null==r)throw new Error(a('[sprintf] Cannot access property "%s" of undefined value "%s"',c.keys[s],c.keys[s-1]));r=r[c.keys[s]]}else r=c.param_no?n[c.param_no]:n[f++];if(i.not_type.test(c.type)&&i.not_primitive.test(c.type)&&r instanceof Function&&(r=r()),i.numeric_arg.test(c.type)&&"number"!=typeof r&&isNaN(r))throw new TypeError(a("[sprintf] expecting number but found %T",r));switch(i.number.test(c.type)&&(p=r>=0),c.type){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,c.width?parseInt(c.width):0);break;case"e":r=c.precision?parseFloat(r).toExponential(c.precision):parseFloat(r).toExponential();break;case"f":r=c.precision?parseFloat(r).toFixed(c.precision):parseFloat(r);break;case"g":r=c.precision?String(Number(r.toPrecision(c.precision))):parseFloat(r);break;case"o":r=(parseInt(r,10)>>>0).toString(8);break;case"s":r=String(r),r=c.precision?r.substring(0,c.precision):r;break;case"t":r=String(!!r),r=c.precision?r.substring(0,c.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=c.precision?r.substring(0,c.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=c.precision?r.substring(0,c.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}i.json.test(c.type)?m+=r:(!i.number.test(c.type)||p&&!c.sign?h="":(h=p?"+":"-",r=r.toString().replace(i.sign,"")),l=c.pad_char?"0"===c.pad_char?"0":c.pad_char.charAt(1):" ",d=c.width-(h+r).length,u=c.width&&d>0?l.repeat(d):"",m+=c.align?h+r+u:"0"===l?h+u+r:u+h+r)}return m}(function(e){if(c[e])return c[e];for(var t,n=e,r=[],o=0;n;){if(null!==(t=i.text.exec(n)))r.push(t[0]);else if(null!==(t=i.modulo.exec(n)))r.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){o|=1;var a=[],s=t[2],u=[];if(null===(u=i.key.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a.push(u[1]);""!==(s=s.substring(u[0].length));)if(null!==(u=i.key_access.exec(s)))a.push(u[1]);else{if(null===(u=i.index_access.exec(s)))throw new SyntaxError("[sprintf] failed to parse named argument key");a.push(u[1])}t[2]=a}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return c[e]=r}(t),arguments)}function s(e,t){return a.apply(null,[e].concat(t||[]))}var c=Object.create(null);n.sprintf=a,n.vsprintf=s,"undefined"!=typeof window&&(window.sprintf=a,window.vsprintf=s,void 0===(o=function(){return{sprintf:a,vsprintf:s}}.call(n,r,n,t))||(t.exports=o))}()},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"WebSocketManager",function(){return o});var r=n(0);e.connect=e.connect||{},connect.WebSocketManager=r.a;var o=r.a}.call(this,n(3))},function(t,n){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==("undefined"==typeof window?"undefined":e(window))&&(r=window)}t.exports=r}])},104(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});const o=n(128),i=n(614),a=0,s=1,c=0,u=1,l=2;class d extends i.VoiceFocusAudioWorkletNode{constructor(e,t){super(e,t.processor,t),this.enabled=!1,this.channelCountMode="explicit",this.channelCount=1;const{modelURL:n,resamplerURL:r,worker:i,fetchBehavior:a,delegate:s}=t;this.delegate=s,this.worker=i,this.worker.onmessage=this.onWorkerMessage.bind(this),this.port.onmessage=this.onProcessorMessage.bind(this);const{enabled:c,supportFarendStream:u}=t.processorOptions;this.worker.postMessage({message:"init",approach:"sab",frames:16e3===e.sampleRate?160:480,enabled:c,model:n,supportFarendStream:u});const l=(0,o.supportsWASMPostMessage)(globalThis)?"get-module":"get-module-buffer";this.worker.postMessage({message:l,key:"resampler",fetchBehavior:a,path:r}),this.enabled=!0}enable(){return r(this,void 0,void 0,function*(){this.state?(Atomics.store(this.state,s,u),Atomics.notify(this.state,a,1)):this.worker.postMessage({message:"enable"}),this.enabled=!0})}disable(){return r(this,void 0,void 0,function*(){this.state?(Atomics.store(this.state,s,c),Atomics.notify(this.state,a,1)):this.worker.postMessage({message:"disable"}),this.enabled=!1})}setMode(e){return r(this,void 0,void 0,function*(){this.port.postMessage({message:"set-mode",mode:e})})}stop(){return r(this,void 0,void 0,function*(){if(this.state)Atomics.store(this.state,s,l),Atomics.notify(this.state,a,1);else try{this.worker.postMessage({message:"stop"})}catch(e){}this.disconnect(),this.enabled=!1})}getModelMetrics(){}reset(){}isEnabled(){return this.enabled}onWorkerMessage(e){var t;const n=e.data;switch(n.message){case"ready":if(!n.shared)throw new Error("No shared state.");this.state=new Int32Array(n.shared.state),this.port.postMessage(n);break;case"stopped":this.worker.terminate();break;case"module-buffer":case"module":case"processing":this.port.postMessage(n);break;case"cpu":null===(t=this.delegate)||void 0===t||t.onCPUWarning();break;default:return}}onProcessorMessage(e){var t;const n=e.data;switch(n.message){case"cpu":null===(t=this.delegate)||void 0===t||t.onCPUWarning();break;case"prepare-for-frames":this.worker.postMessage(n)}}}t.default=d},128(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.isOldChrome=t.supportsWASMStreaming=t.supportsSharedArrayBuffer=t.supportsWASM=t.supportsAudioWorklet=t.supportsWorker=t.supportsVoiceFocusWorker=t.supportsWASMPostMessage=t.isSafari=void 0;const o=n(364);t.isSafari=(e=globalThis)=>{const t=e.navigator.userAgent,n=t.match(/Safari\//),r=t.match(/Chrom(?:e|ium)\//);return!(!n||r)},t.supportsWASMPostMessage=(e=globalThis)=>!(0,t.isSafari)(e)&&(!((e=globalThis)=>!!e.navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)/))(e)||(i(e)||0)<95),t.supportsVoiceFocusWorker=(e=globalThis,n,i)=>r(void 0,void 0,void 0,function*(){if(!(0,t.supportsWorker)(e,i))return!1;const r=`${n.paths.workers}worker-v1.js`;try{const e=yield(0,o.loadWorker)(r,"VoiceFocusTestWorker",n,i);try{e.terminate()}catch(e){null==i||i.debug("Failed to terminate worker.",e)}return!0}catch(e){return null==i||i.info("Failed to fetch and instantiate test worker",e),!1}}),t.supportsWorker=(e=globalThis,t)=>{try{return!!e.Worker}catch(e){return null==t||t.info("Does not support Worker",e),!1}},t.supportsAudioWorklet=(e=globalThis,t)=>{try{return!!e.AudioWorklet&&!!e.AudioWorkletNode}catch(e){return null==t||t.info("Does not support Audio Worklet",e),!1}},t.supportsWASM=(e=globalThis,t)=>{try{return!(!e.WebAssembly||!e.WebAssembly.compile&&!e.WebAssembly.compileStreaming)}catch(e){return null==t||t.info("Does not support WASM",e),!1}},t.supportsSharedArrayBuffer=(e=globalThis,t=globalThis,n)=>{try{return!(!e.SharedArrayBuffer||!t.chrome&&!e.crossOriginIsolated)}catch(e){return null==n||n.info("Does not support SharedArrayBuffer."),!1}},t.supportsWASMStreaming=(e=globalThis,t)=>{var n;try{return!!(null===(n=e.WebAssembly)||void 0===n?void 0:n.compileStreaming)}catch(e){return null==t||t.info("Does not support WASM streaming compilation",e),!1}};const i=(e=globalThis)=>{try{if(!e.chrome)return}catch(e){}const t=e.navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)/);if(t)return parseInt(t[1],10)};t.isOldChrome=(e=globalThis,t)=>{const n=i(e);return!!n&&n<90&&(null==t||t.debug(`Chrome ${n} has incomplete SIMD support.`),!0)}},142(){!function(){var e=this||globalThis,t=e.connect||{};e.connect=t,t.ChatMediaController=function(e,n){var r=t.getLog(),o=t.LogComponent.CHAT,i=function(n,r){t.publishMetric({name:n,contactId:e.contactId,data:r||e})},a=function(e){e.onConnectionBroken(function(e){r.error(o,"Chat Session connection broken").withException(e).sendInternalLogToServer(),i("Chat Session connection broken",e)}),e.onConnectionEstablished(function(e){r.info(o,"Chat Session connection established").withObject(e).sendInternalLogToServer(),i("Chat Session connection established",e)})};return{get:function(){return function(){i("Chat media controller init",e.contactId),r.info(o,"Chat media controller init").withObject(e).sendInternalLogToServer(),t.ChatSession.setGlobalConfig({loggerConfig:{logger:r},region:n.region});var s=t.ChatSession.create({chatDetails:e,type:"AGENT",websocketManager:t.core.getWebSocketManager()});return a(s),s.connect().then(function(t){return r.info(o,"Chat Session Successfully established for contactId %s",e.contactId).sendInternalLogToServer(),i("Chat Session Successfully established",e.contactId),s}).catch(function(t){throw r.error(o,"Chat Session establishement failed for contact %s",e.contactId).withException(t).sendInternalLogToServer(),i("Chat Session establishement failed",e.contactId,t),t})}()}}}}()},144(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==